mirror of
https://github.com/StarWishsama/Slimefun4.git
synced 2024-09-20 11:45:51 +00:00
Fixes #1162 (also more performance improvements)
This commit is contained in:
parent
64bd72a695
commit
58889c46d0
@ -156,6 +156,7 @@ public final class SlimefunManager {
|
||||
EmeraldEnchants.getInstance().getRegistry().applyEnchantment(strippedItem, enchantment.getEnchantment(), 0);
|
||||
}
|
||||
}
|
||||
|
||||
if (SlimefunItem.getByItem(strippedItem) instanceof Soulbound) {
|
||||
return true;
|
||||
}
|
||||
|
@ -191,24 +191,9 @@ public final class Slimefun {
|
||||
* <code>false</code> otherwise.
|
||||
*/
|
||||
public static boolean isEnabled(Player p, ItemStack item, boolean message) {
|
||||
String world = p.getWorld().getName();
|
||||
SlimefunItem sfItem = SlimefunItem.getByItem(item);
|
||||
if (sfItem == null) return !SlimefunItem.isDisabled(item);
|
||||
if (SlimefunPlugin.getWhitelist().contains(world + ".enabled")) {
|
||||
if (SlimefunPlugin.getWhitelist().getBoolean(world + ".enabled")) {
|
||||
if (!SlimefunPlugin.getWhitelist().contains(world + ".enabled-items." + sfItem.getID())) SlimefunPlugin.getWhitelist().setDefaultValue(world + ".enabled-items." + sfItem.getID(), true);
|
||||
if (SlimefunPlugin.getWhitelist().getBoolean(world + ".enabled-items." + sfItem.getID())) return true;
|
||||
else {
|
||||
if (message) SlimefunPlugin.getLocal().sendMessage(p, "messages.disabled-in-world", true);
|
||||
return false;
|
||||
}
|
||||
}
|
||||
else {
|
||||
if (message) SlimefunPlugin.getLocal().sendMessage(p, "messages.disabled-in-world", true);
|
||||
return false;
|
||||
}
|
||||
}
|
||||
else return true;
|
||||
else return isEnabled(p, sfItem, message);
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -5,6 +5,7 @@ import java.util.Collections;
|
||||
import java.util.HashMap;
|
||||
import java.util.HashSet;
|
||||
import java.util.Iterator;
|
||||
import java.util.LinkedList;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Set;
|
||||
@ -152,20 +153,17 @@ public class CargoNet extends Network {
|
||||
}
|
||||
else {
|
||||
SimpleHologram.update(b, "&7Status: &a&lONLINE");
|
||||
|
||||
|
||||
final Map<Integer, List<Location>> output = new HashMap<>();
|
||||
|
||||
Set<Location> combinedOutputNodes = new HashSet<>();
|
||||
combinedOutputNodes.addAll(outputNodes);
|
||||
combinedOutputNodes.addAll(advancedOutputNodes);
|
||||
|
||||
List<Location> list = new ArrayList<>();
|
||||
List<Location> list = new LinkedList<>();
|
||||
int lastFrequency = -1;
|
||||
|
||||
for (Location outputNode: combinedOutputNodes) {
|
||||
Integer frequency = getFrequency(outputNode);
|
||||
list.add(outputNode);
|
||||
int frequency = getFrequency(outputNode);
|
||||
|
||||
if (frequency != lastFrequency && lastFrequency != -1) {
|
||||
output.merge(lastFrequency, list, (prev, next) -> {
|
||||
@ -173,9 +171,10 @@ public class CargoNet extends Network {
|
||||
return prev;
|
||||
});
|
||||
|
||||
list.clear();
|
||||
list = new LinkedList<>();
|
||||
}
|
||||
|
||||
list.add(outputNode);
|
||||
lastFrequency = frequency;
|
||||
}
|
||||
|
||||
@ -202,6 +201,7 @@ public class CargoNet extends Network {
|
||||
|
||||
CargoNet self = this;
|
||||
final BlockStorage storage = BlockStorage.getStorage(b.getWorld());
|
||||
|
||||
Bukkit.getScheduler().scheduleSyncDelayedTask(SlimefunPlugin.instance, () -> {
|
||||
|
||||
if (BlockStorage.getLocationInfo(b.getLocation(), "visualizer") == null) {
|
||||
|
@ -18,7 +18,6 @@ import org.bukkit.event.entity.EntityDamageByEntityEvent;
|
||||
import org.bukkit.event.entity.EntityDamageEvent;
|
||||
import org.bukkit.event.entity.EntityDamageEvent.DamageCause;
|
||||
import org.bukkit.event.player.PlayerInteractEvent;
|
||||
import org.bukkit.inventory.ItemStack;
|
||||
import org.bukkit.util.Vector;
|
||||
|
||||
import io.github.thebusybiscuit.cscorelib2.protection.ProtectableAction;
|
||||
@ -38,56 +37,54 @@ public class ArmorListener implements Listener {
|
||||
public void onDamage(EntityDamageEvent e) {
|
||||
if (e.getEntity() instanceof Player && !e.isCancelled()) {
|
||||
Player p = (Player) e.getEntity();
|
||||
for (ItemStack armor: p.getInventory().getArmorContents()) {
|
||||
SlimefunItem item = SlimefunItem.getByItem(armor);
|
||||
if (item != null) {
|
||||
if (item.getID().equals("ENDER_BOOTS")
|
||||
&& Slimefun.hasUnlocked(p, item, true)
|
||||
&& e instanceof EntityDamageByEntityEvent
|
||||
&& ((EntityDamageByEntityEvent) e).getDamager() instanceof EnderPearl
|
||||
) {
|
||||
e.setCancelled(true);
|
||||
}
|
||||
else if (item.getID().equals("SLIME_BOOTS")
|
||||
&& Slimefun.hasUnlocked(p, item, true)
|
||||
&& e.getCause() == DamageCause.FALL
|
||||
) {
|
||||
e.setCancelled(true);
|
||||
}
|
||||
else if (item.getID().equals("BOOTS_OF_THE_STOMPER")
|
||||
&& Slimefun.hasUnlocked(p, item, true)
|
||||
&& e.getCause() == DamageCause.FALL
|
||||
) {
|
||||
e.setCancelled(true);
|
||||
p.getWorld().playSound(p.getLocation(), Sound.ENTITY_ZOMBIE_BREAK_WOODEN_DOOR, 1F, 2F);
|
||||
p.setVelocity(new Vector(0.0, 0.7, 0.0));
|
||||
for (Entity n: p.getNearbyEntities(4, 4, 4)) {
|
||||
if (n instanceof LivingEntity && !n.getUniqueId().equals(p.getUniqueId())) {
|
||||
n.setVelocity(n.getLocation().toVector().subtract(p.getLocation().toVector())
|
||||
.normalize().multiply(1.4));
|
||||
if (p.getWorld().getPVP()
|
||||
&& SlimefunPlugin.getProtectionManager()
|
||||
.hasPermission(p, n.getLocation(), ProtectableAction.PVP)
|
||||
) {
|
||||
EntityDamageByEntityEvent event = new EntityDamageByEntityEvent(p, n,
|
||||
DamageCause.ENTITY_ATTACK, e.getDamage() / 2);
|
||||
Bukkit.getPluginManager().callEvent(event);
|
||||
if (!event.isCancelled()) ((LivingEntity) n).damage(e.getDamage() / 2);
|
||||
}
|
||||
SlimefunItem item = SlimefunItem.getByItem(p.getInventory().getBoots());
|
||||
if (item != null) {
|
||||
if (item.getID().equals("ENDER_BOOTS")
|
||||
&& Slimefun.hasUnlocked(p, item, true)
|
||||
&& e instanceof EntityDamageByEntityEvent
|
||||
&& ((EntityDamageByEntityEvent) e).getDamager() instanceof EnderPearl
|
||||
) {
|
||||
e.setCancelled(true);
|
||||
}
|
||||
else if (item.getID().equals("SLIME_BOOTS")
|
||||
&& Slimefun.hasUnlocked(p, item, true)
|
||||
&& e.getCause() == DamageCause.FALL
|
||||
) {
|
||||
e.setCancelled(true);
|
||||
}
|
||||
else if (item.getID().equals("BOOTS_OF_THE_STOMPER")
|
||||
&& Slimefun.hasUnlocked(p, item, true)
|
||||
&& e.getCause() == DamageCause.FALL
|
||||
) {
|
||||
e.setCancelled(true);
|
||||
p.getWorld().playSound(p.getLocation(), Sound.ENTITY_ZOMBIE_BREAK_WOODEN_DOOR, 1F, 2F);
|
||||
p.setVelocity(new Vector(0.0, 0.7, 0.0));
|
||||
for (Entity n: p.getNearbyEntities(4, 4, 4)) {
|
||||
if (n instanceof LivingEntity && !n.getUniqueId().equals(p.getUniqueId())) {
|
||||
n.setVelocity(n.getLocation().toVector().subtract(p.getLocation().toVector())
|
||||
.normalize().multiply(1.4));
|
||||
if (p.getWorld().getPVP()
|
||||
&& SlimefunPlugin.getProtectionManager()
|
||||
.hasPermission(p, n.getLocation(), ProtectableAction.PVP)
|
||||
) {
|
||||
EntityDamageByEntityEvent event = new EntityDamageByEntityEvent(p, n,
|
||||
DamageCause.ENTITY_ATTACK, e.getDamage() / 2);
|
||||
Bukkit.getPluginManager().callEvent(event);
|
||||
if (!event.isCancelled()) ((LivingEntity) n).damage(e.getDamage() / 2);
|
||||
}
|
||||
}
|
||||
|
||||
for (BlockFace face: BlockFace.values()) {
|
||||
Block b = p.getLocation().getBlock().getRelative(BlockFace.DOWN).getRelative(face);
|
||||
p.getWorld().playEffect(b.getLocation(), Effect.STEP_SOUND, b.getType());
|
||||
}
|
||||
}
|
||||
else if (item.getID().equals("SLIME_STEEL_BOOTS")
|
||||
&& Slimefun.hasUnlocked(p, item, true)
|
||||
&& e.getCause() == DamageCause.FALL
|
||||
)
|
||||
e.setCancelled(true);
|
||||
|
||||
for (BlockFace face: BlockFace.values()) {
|
||||
Block b = p.getLocation().getBlock().getRelative(BlockFace.DOWN).getRelative(face);
|
||||
p.getWorld().playEffect(b.getLocation(), Effect.STEP_SOUND, b.getType());
|
||||
}
|
||||
}
|
||||
else if (item.getID().equals("SLIME_STEEL_BOOTS")
|
||||
&& Slimefun.hasUnlocked(p, item, true)
|
||||
&& e.getCause() == DamageCause.FALL
|
||||
)
|
||||
e.setCancelled(true);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -69,7 +69,7 @@ public class BackpackListener implements Listener {
|
||||
}
|
||||
else if (e.getCurrentItem() != null && e.getCurrentItem().getType() != Material.AIR) {
|
||||
SlimefunItem sfItem = SlimefunItem.getByItem(e.getCurrentItem());
|
||||
if ((SlimefunManager.isItemSimiliar(item, SlimefunItem.getItem("COOLER"), false) && !(sfItem instanceof Juice)) ||
|
||||
if ((SlimefunManager.isItemSimiliar(item, SlimefunItems.COOLER, false) && !(sfItem instanceof Juice)) ||
|
||||
e.getCurrentItem().getType().toString().contains("SHULKER_BOX") ||
|
||||
sfItem instanceof SlimefunBackpack)
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user