mirror of
https://github.com/StarWishsama/Slimefun4.git
synced 2024-09-20 11:45:51 +00:00
Merge branch 'master' into chore/has-unlocked
This commit is contained in:
commit
32b9788e74
14
.github/ISSUE_TEMPLATE/bug-report.md
vendored
14
.github/ISSUE_TEMPLATE/bug-report.md
vendored
@ -19,7 +19,9 @@ assignees: ''
|
|||||||
<!-- Tell us the exact steps to reproduce this issue, the more detailed the easier we can reproduce it. -->
|
<!-- Tell us the exact steps to reproduce this issue, the more detailed the easier we can reproduce it. -->
|
||||||
<!-- Youtube Videos and Screenshots are recommended!!! -->
|
<!-- Youtube Videos and Screenshots are recommended!!! -->
|
||||||
<!-- Start writing below this line -->
|
<!-- Start writing below this line -->
|
||||||
|
1.
|
||||||
|
2.
|
||||||
|
3.
|
||||||
|
|
||||||
## :bulb: Expected behavior (REQUIRED)
|
## :bulb: Expected behavior (REQUIRED)
|
||||||
<!-- What were you expecting to happen? -->
|
<!-- What were you expecting to happen? -->
|
||||||
@ -34,7 +36,7 @@ assignees: ''
|
|||||||
|
|
||||||
|
|
||||||
## :open_file_folder: /error-reports/ Folder
|
## :open_file_folder: /error-reports/ Folder
|
||||||
<!-- Check the folder /plugins/Slimefun/error-reports/ and upload all files inside that folder. -->
|
<!-- Check the folder /plugins/Slimefun/error-reports/ and upload any files inside that folder. -->
|
||||||
<!-- You can also post these files via https://pastebin.com/ -->
|
<!-- You can also post these files via https://pastebin.com/ -->
|
||||||
<!-- Paste your link(s) below this line -->
|
<!-- Paste your link(s) below this line -->
|
||||||
|
|
||||||
@ -46,7 +48,7 @@ assignees: ''
|
|||||||
<!-- Make sure that the screenshot covers the entire output of that command. -->
|
<!-- Make sure that the screenshot covers the entire output of that command. -->
|
||||||
<!-- If your issue is related to other plugins, make sure to include the versions of these plugins too! -->
|
<!-- If your issue is related to other plugins, make sure to include the versions of these plugins too! -->
|
||||||
|
|
||||||
- Server Software (Spigot/Paper):
|
- Server Software:
|
||||||
- Minecraft Version:
|
- Minecraft Version:
|
||||||
- Slimefun Version:
|
- Slimefun Version:
|
||||||
- CS-CoreLib Version:
|
- CS-CoreLib Version:
|
||||||
|
@ -39,6 +39,7 @@
|
|||||||
* Fixed ghost blocks to some extent (ghost blocks will now drop and be replaced)
|
* Fixed ghost blocks to some extent (ghost blocks will now drop and be replaced)
|
||||||
* Fixed #2636
|
* Fixed #2636
|
||||||
* Fixed some backpack opening issues
|
* Fixed some backpack opening issues
|
||||||
|
* Fixed #2647
|
||||||
|
|
||||||
## Release Candidate 18 (03 Dec 2020)
|
## Release Candidate 18 (03 Dec 2020)
|
||||||
|
|
||||||
|
2
pom.xml
2
pom.xml
@ -348,7 +348,7 @@
|
|||||||
<dependency>
|
<dependency>
|
||||||
<groupId>com.konghq</groupId>
|
<groupId>com.konghq</groupId>
|
||||||
<artifactId>unirest-java</artifactId>
|
<artifactId>unirest-java</artifactId>
|
||||||
<version>3.11.06</version>
|
<version>3.11.09</version>
|
||||||
<scope>compile</scope>
|
<scope>compile</scope>
|
||||||
<exclusions>
|
<exclusions>
|
||||||
<exclusion>
|
<exclusion>
|
||||||
|
@ -1,5 +1,7 @@
|
|||||||
package io.github.thebusybiscuit.slimefun4.implementation.items.armor;
|
package io.github.thebusybiscuit.slimefun4.implementation.items.armor;
|
||||||
|
|
||||||
|
import javax.annotation.Nonnull;
|
||||||
|
|
||||||
import org.bukkit.Bukkit;
|
import org.bukkit.Bukkit;
|
||||||
import org.bukkit.Effect;
|
import org.bukkit.Effect;
|
||||||
import org.bukkit.Location;
|
import org.bukkit.Location;
|
||||||
@ -25,7 +27,7 @@ import me.mrCookieSlime.Slimefun.api.SlimefunItemStack;
|
|||||||
/**
|
/**
|
||||||
* The Boots of the Stomper are boots which damage nearby enemies whenever the {@link Player}
|
* The Boots of the Stomper are boots which damage nearby enemies whenever the {@link Player}
|
||||||
* takes fall damage.
|
* takes fall damage.
|
||||||
*
|
*
|
||||||
* @author TheBusyBiscuit
|
* @author TheBusyBiscuit
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
@ -37,49 +39,49 @@ public class StomperBoots extends SlimefunItem {
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* This will apply the "stomp" effect to the given {@link EntityDamageEvent}.
|
* This will apply the "stomp" effect to the given {@link EntityDamageEvent}.
|
||||||
*
|
*
|
||||||
* @param fallDamageEvent
|
* @param fallDamageEvent
|
||||||
* The {@link EntityDamageEvent} in which the {@link Player} has taken fall damage
|
* The {@link EntityDamageEvent} in which the {@link Player} has taken fall damage
|
||||||
*/
|
*/
|
||||||
public void stomp(EntityDamageEvent fallDamageEvent) {
|
public void stomp(EntityDamageEvent fallDamageEvent) {
|
||||||
Player p = (Player) fallDamageEvent.getEntity();
|
Player player = (Player) fallDamageEvent.getEntity();
|
||||||
p.getWorld().playSound(p.getLocation(), Sound.ENTITY_ZOMBIE_BREAK_WOODEN_DOOR, 1F, 2F);
|
player.getWorld().playSound(player.getLocation(), Sound.ENTITY_ZOMBIE_BREAK_WOODEN_DOOR, 1F, 2F);
|
||||||
p.setVelocity(new Vector(0, 0.7, 0));
|
player.setVelocity(new Vector(0, 0.7, 0));
|
||||||
|
|
||||||
for (Entity n : p.getNearbyEntities(4, 4, 4)) {
|
for (Entity entity : player.getNearbyEntities(4, 4, 4)) {
|
||||||
if (n instanceof LivingEntity && n.isValid() && !n.getUniqueId().equals(p.getUniqueId())) {
|
if (entity instanceof LivingEntity && canPush(player, (LivingEntity) entity)) {
|
||||||
Vector velocity = getShockwave(p.getLocation(), n.getLocation());
|
Vector velocity = getShockwave(player.getLocation(), entity.getLocation());
|
||||||
n.setVelocity(velocity);
|
entity.setVelocity(velocity);
|
||||||
|
|
||||||
// Check if it's not a Player or if PvP is enabled
|
// Check if it's not a Player or if PvP is enabled
|
||||||
if (!(n instanceof Player) || (p.getWorld().getPVP() && SlimefunPlugin.getProtectionManager().hasPermission(p, n.getLocation(), ProtectableAction.ATTACK_PLAYER))) {
|
if (!(entity instanceof Player) || (player.getWorld().getPVP() && SlimefunPlugin.getProtectionManager().hasPermission(player, entity.getLocation(), ProtectableAction.ATTACK_PLAYER))) {
|
||||||
EntityDamageByEntityEvent event = new EntityDamageByEntityEvent(p, n, DamageCause.ENTITY_ATTACK, fallDamageEvent.getDamage() / 2);
|
EntityDamageByEntityEvent event = new EntityDamageByEntityEvent(player, entity, DamageCause.ENTITY_ATTACK, fallDamageEvent.getDamage() / 2);
|
||||||
Bukkit.getPluginManager().callEvent(event);
|
Bukkit.getPluginManager().callEvent(event);
|
||||||
|
|
||||||
if (!event.isCancelled()) {
|
if (!event.isCancelled()) {
|
||||||
((LivingEntity) n).damage(event.getDamage());
|
((LivingEntity) entity).damage(event.getDamage());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
for (BlockFace face : BlockFace.values()) {
|
for (BlockFace face : BlockFace.values()) {
|
||||||
Block b = p.getLocation().getBlock().getRelative(BlockFace.DOWN).getRelative(face);
|
Block block = player.getLocation().getBlock().getRelative(BlockFace.DOWN).getRelative(face);
|
||||||
p.getWorld().playEffect(b.getLocation(), Effect.STEP_SOUND, b.getType());
|
player.getWorld().playEffect(block.getLocation(), Effect.STEP_SOUND, block.getType());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* This gives us the "shockwave" {@link Vector} for a given target.
|
* This gives us the "shockwave" {@link Vector} for a given target.
|
||||||
*
|
*
|
||||||
* @param origin
|
* @param origin
|
||||||
* The {@link Location} of our {@link Player}
|
* The {@link Location} of our {@link Player}
|
||||||
* @param target
|
* @param target
|
||||||
* The {@link Location} of the {@link Entity} we are pushing away
|
* The {@link Location} of the {@link Entity} we are pushing away
|
||||||
*
|
*
|
||||||
* @return A {@link Vector} to determine the velocity for our {@link Entity}
|
* @return A {@link Vector} to determine the velocity for our {@link Entity}
|
||||||
*/
|
*/
|
||||||
private Vector getShockwave(Location origin, Location target) {
|
private Vector getShockwave(@Nonnull Location origin, @Nonnull Location target) {
|
||||||
// As the distance approaches zero we might slip into a "division by zero" when normalizing
|
// As the distance approaches zero we might slip into a "division by zero" when normalizing
|
||||||
if (origin.distanceSquared(target) < 0.05) {
|
if (origin.distanceSquared(target) < 0.05) {
|
||||||
return new Vector(0, 1, 0);
|
return new Vector(0, 1, 0);
|
||||||
@ -89,4 +91,21 @@ public class StomperBoots extends SlimefunItem {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Checks if the stomper boots can move an entity and is not the player who is using the boots.
|
||||||
|
* <p>
|
||||||
|
* <b>For developers:</b> If you're spawning an immovable NPC, you should be denying
|
||||||
|
* collision with {@link LivingEntity#setCollidable(boolean)} or
|
||||||
|
* gravity with {@link LivingEntity#setGravity(boolean)}.
|
||||||
|
*
|
||||||
|
* @param entity
|
||||||
|
* The {@link LivingEntity} to check.
|
||||||
|
* @param player
|
||||||
|
* The {@link Player} using the {@link StomperBoots}.
|
||||||
|
* @return If the entity can move.
|
||||||
|
*/
|
||||||
|
protected boolean canPush(@Nonnull Player player, @Nonnull LivingEntity entity) {
|
||||||
|
return entity.isValid() && !entity.getUniqueId().equals(player.getUniqueId())
|
||||||
|
&& entity.isCollidable() && entity.hasGravity();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user