Reenable Items #373
@ -81,23 +81,6 @@ public class FlatteningWrapper14 implements FlatteningWrapper {
|
|||||||
return stack.hasItemMeta() && Objects.requireNonNull(stack.getItemMeta()).hasAttributeModifiers();
|
return stack.hasItemMeta() && Objects.requireNonNull(stack.getItemMeta()).hasAttributeModifiers();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
|
||||||
public ItemStack onBreak(Block block) {
|
|
||||||
Material type = block.getType();
|
|
||||||
switch(type){
|
|
||||||
case REDSTONE_WIRE:
|
|
||||||
type = Material.REDSTONE;
|
|
||||||
break;
|
|
||||||
case PISTON_HEAD:
|
|
||||||
type = Material.PISTON;
|
|
||||||
break;
|
|
||||||
case ICE:
|
|
||||||
type = Material.AIR;
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
return new ItemStack(type);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean doRecord(BlockPhysicsEvent e) {
|
public boolean doRecord(BlockPhysicsEvent e) {
|
||||||
return e.getBlock() == e.getSourceBlock() || e.getChangedType() == Material.AIR;
|
return e.getBlock() == e.getSourceBlock() || e.getChangedType() == Material.AIR;
|
||||||
|
@ -58,11 +58,6 @@ public class FlatteningWrapper8 implements FlatteningWrapper {
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
|
||||||
public ItemStack onBreak(Block block) {
|
|
||||||
return block.getDrops().stream().findAny().orElse(new ItemStack(Material.AIR));
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean doRecord(BlockPhysicsEvent e) {
|
public boolean doRecord(BlockPhysicsEvent e) {
|
||||||
return e.getChangedType() != e.getBlock().getType();
|
return e.getChangedType() != e.getBlock().getType();
|
||||||
|
@ -27,6 +27,7 @@ import org.bukkit.event.EventPriority;
|
|||||||
import org.bukkit.event.HandlerList;
|
import org.bukkit.event.HandlerList;
|
||||||
import org.bukkit.event.Listener;
|
import org.bukkit.event.Listener;
|
||||||
import org.bukkit.event.block.*;
|
import org.bukkit.event.block.*;
|
||||||
|
import org.bukkit.event.entity.ItemSpawnEvent;
|
||||||
import org.bukkit.event.inventory.InventoryMoveItemEvent;
|
import org.bukkit.event.inventory.InventoryMoveItemEvent;
|
||||||
import org.bukkit.event.player.PlayerInteractEvent;
|
import org.bukkit.event.player.PlayerInteractEvent;
|
||||||
|
|
||||||
@ -83,6 +84,10 @@ public class FreezeWorld implements Listener {
|
|||||||
public void onBlockExplosion(BlockExplodeEvent e){
|
public void onBlockExplosion(BlockExplodeEvent e){
|
||||||
e.setCancelled(true);
|
e.setCancelled(true);
|
||||||
}
|
}
|
||||||
|
@EventHandler
|
||||||
|
public void onBlockExplosion(ItemSpawnEvent e){
|
||||||
|
e.setCancelled(true);
|
||||||
|
}
|
||||||
|
|
||||||
@EventHandler(priority = EventPriority.LOW)
|
@EventHandler(priority = EventPriority.LOW)
|
||||||
public void handlePlayerInteract(PlayerInteractEvent event) {
|
public void handlePlayerInteract(PlayerInteractEvent event) {
|
||||||
|
@ -160,6 +160,18 @@ public class Kit {
|
|||||||
return inventory;
|
return inventory;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public boolean contains(ItemStack stack) {
|
||||||
|
for(ItemStack i : inventory) {
|
||||||
|
if(similar(i, stack))
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
for(ItemStack i : armor) {
|
||||||
|
if(similar(i, stack))
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
public ItemStack[] getArmor() {
|
public ItemStack[] getArmor() {
|
||||||
return armor;
|
return armor;
|
||||||
}
|
}
|
||||||
|
@ -35,6 +35,7 @@ import org.bukkit.event.block.BlockPlaceEvent;
|
|||||||
import org.bukkit.event.entity.EntityExplodeEvent;
|
import org.bukkit.event.entity.EntityExplodeEvent;
|
||||||
import org.bukkit.event.entity.ProjectileLaunchEvent;
|
import org.bukkit.event.entity.ProjectileLaunchEvent;
|
||||||
import org.bukkit.event.hanging.HangingBreakEvent;
|
import org.bukkit.event.hanging.HangingBreakEvent;
|
||||||
|
import org.bukkit.event.player.PlayerDropItemEvent;
|
||||||
import org.bukkit.event.player.PlayerKickEvent;
|
import org.bukkit.event.player.PlayerKickEvent;
|
||||||
|
|
||||||
public class DenyWorldInteraction implements Listener {
|
public class DenyWorldInteraction implements Listener {
|
||||||
@ -53,6 +54,14 @@ public class DenyWorldInteraction implements Listener {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@EventHandler
|
||||||
|
public void handleItemDrop(PlayerDropItemEvent event) {
|
||||||
|
Player player = event.getPlayer();
|
||||||
|
if(Fight.fighting(player)) {
|
||||||
|
event.setCancelled(true);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
@EventHandler
|
@EventHandler
|
||||||
public void handleHangingBreak(HangingBreakEvent event) {
|
public void handleHangingBreak(HangingBreakEvent event) {
|
||||||
if(Config.ArenaRegion.inRegion(event.getEntity().getLocation())) {
|
if(Config.ArenaRegion.inRegion(event.getEntity().getLocation())) {
|
||||||
|
@ -23,6 +23,7 @@ import de.steamwar.fightsystem.ArenaMode;
|
|||||||
import de.steamwar.fightsystem.Config;
|
import de.steamwar.fightsystem.Config;
|
||||||
import de.steamwar.fightsystem.FightSystem;
|
import de.steamwar.fightsystem.FightSystem;
|
||||||
import de.steamwar.fightsystem.fight.Fight;
|
import de.steamwar.fightsystem.fight.Fight;
|
||||||
|
import de.steamwar.fightsystem.fight.FightPlayer;
|
||||||
import de.steamwar.fightsystem.fight.FightTeam;
|
import de.steamwar.fightsystem.fight.FightTeam;
|
||||||
import de.steamwar.fightsystem.states.FightState;
|
import de.steamwar.fightsystem.states.FightState;
|
||||||
import de.steamwar.fightsystem.states.StateDependentListener;
|
import de.steamwar.fightsystem.states.StateDependentListener;
|
||||||
@ -36,6 +37,8 @@ import org.bukkit.entity.Player;
|
|||||||
import org.bukkit.event.EventHandler;
|
import org.bukkit.event.EventHandler;
|
||||||
import org.bukkit.event.EventPriority;
|
import org.bukkit.event.EventPriority;
|
||||||
import org.bukkit.event.Listener;
|
import org.bukkit.event.Listener;
|
||||||
|
import org.bukkit.event.entity.EntityExplodeEvent;
|
||||||
|
import org.bukkit.event.entity.EntityPickupItemEvent;
|
||||||
import org.bukkit.event.block.BlockDispenseEvent;
|
import org.bukkit.event.block.BlockDispenseEvent;
|
||||||
import org.bukkit.event.block.BlockFromToEvent;
|
import org.bukkit.event.block.BlockFromToEvent;
|
||||||
import org.bukkit.event.entity.FoodLevelChangeEvent;
|
import org.bukkit.event.entity.FoodLevelChangeEvent;
|
||||||
@ -43,12 +46,12 @@ import org.bukkit.event.entity.PlayerDeathEvent;
|
|||||||
import org.bukkit.event.entity.SpawnerSpawnEvent;
|
import org.bukkit.event.entity.SpawnerSpawnEvent;
|
||||||
import org.bukkit.event.inventory.CraftItemEvent;
|
import org.bukkit.event.inventory.CraftItemEvent;
|
||||||
import org.bukkit.event.inventory.FurnaceSmeltEvent;
|
import org.bukkit.event.inventory.FurnaceSmeltEvent;
|
||||||
import org.bukkit.event.inventory.InventoryPickupItemEvent;
|
|
||||||
import org.bukkit.event.player.*;
|
import org.bukkit.event.player.*;
|
||||||
import org.bukkit.event.weather.WeatherChangeEvent;
|
import org.bukkit.event.weather.WeatherChangeEvent;
|
||||||
import org.bukkit.event.world.WorldLoadEvent;
|
import org.bukkit.event.world.WorldLoadEvent;
|
||||||
import org.bukkit.scoreboard.NameTagVisibility;
|
import org.bukkit.scoreboard.NameTagVisibility;
|
||||||
import org.bukkit.scoreboard.Team;
|
import org.bukkit.scoreboard.Team;
|
||||||
|
import org.bukkit.inventory.ItemStack;
|
||||||
|
|
||||||
public class Permanent implements Listener {
|
public class Permanent implements Listener {
|
||||||
|
|
||||||
@ -147,16 +150,38 @@ public class Permanent implements Listener {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@EventHandler
|
@EventHandler
|
||||||
public void onDropPickup(InventoryPickupItemEvent e){
|
public void onDropPickup(EntityPickupItemEvent e) {
|
||||||
if(Config.ArenaRegion.inRegion(e.getItem().getLocation()))
|
if(!(e.getEntity() instanceof Player) || !(Config.ArenaRegion.inRegion(e.getItem().getLocation())))
|
||||||
|
return;
|
||||||
|
Player player = (Player) e.getEntity();
|
||||||
|
|
||||||
|
ItemStack stack = e.getItem().getItemStack();
|
||||||
|
if(Config.PersonalKits) {
|
||||||
|
if(Config.ForbiddenItems.contains(stack.getType())) {
|
||||||
e.setCancelled(true);
|
e.setCancelled(true);
|
||||||
}
|
}
|
||||||
|
} else {
|
||||||
|
FightPlayer fp = Fight.getFightPlayer(player);
|
||||||
|
if(fp == null)
|
||||||
|
return;
|
||||||
|
|
||||||
@EventHandler
|
if(!fp.getKit().contains(stack)) {
|
||||||
public void onDropping(PlayerDropItemEvent e){
|
|
||||||
if(Fight.fighting(e.getPlayer()))
|
|
||||||
e.setCancelled(true);
|
e.setCancelled(true);
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@EventHandler(priority = EventPriority.MONITOR)
|
||||||
|
public void onExplosion(EntityExplodeEvent e) {
|
||||||
|
e.blockList().removeIf(block -> {
|
||||||
|
if(block.getType() == Material.TNT) {
|
||||||
|
return false;
|
||||||
|
} else {
|
||||||
|
block.setType(Material.AIR);
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
@EventHandler
|
@EventHandler
|
||||||
public void onWorldLoad(WorldLoadEvent e) {
|
public void onWorldLoad(WorldLoadEvent e) {
|
||||||
|
@ -25,15 +25,11 @@ import de.steamwar.fightsystem.fight.Fight;
|
|||||||
import de.steamwar.fightsystem.fight.FightPlayer;
|
import de.steamwar.fightsystem.fight.FightPlayer;
|
||||||
import de.steamwar.fightsystem.states.FightState;
|
import de.steamwar.fightsystem.states.FightState;
|
||||||
import de.steamwar.fightsystem.states.StateDependentListener;
|
import de.steamwar.fightsystem.states.StateDependentListener;
|
||||||
import de.steamwar.fightsystem.utils.FlatteningWrapper;
|
|
||||||
import net.md_5.bungee.api.ChatMessageType;
|
import net.md_5.bungee.api.ChatMessageType;
|
||||||
import org.bukkit.Material;
|
import org.bukkit.Material;
|
||||||
import org.bukkit.event.EventHandler;
|
import org.bukkit.event.EventHandler;
|
||||||
import org.bukkit.event.Listener;
|
import org.bukkit.event.Listener;
|
||||||
import org.bukkit.event.block.BlockBreakEvent;
|
|
||||||
import org.bukkit.event.block.BlockPlaceEvent;
|
import org.bukkit.event.block.BlockPlaceEvent;
|
||||||
import org.bukkit.inventory.Inventory;
|
|
||||||
import org.bukkit.inventory.ItemStack;
|
|
||||||
|
|
||||||
public class RunningWorldInteraction implements Listener {
|
public class RunningWorldInteraction implements Listener {
|
||||||
|
|
||||||
@ -41,35 +37,6 @@ public class RunningWorldInteraction implements Listener {
|
|||||||
new StateDependentListener(ArenaMode.AntiReplay, FightState.Running, this);
|
new StateDependentListener(ArenaMode.AntiReplay, FightState.Running, this);
|
||||||
}
|
}
|
||||||
|
|
||||||
@EventHandler
|
|
||||||
public void onBlockBreak(BlockBreakEvent event) {
|
|
||||||
if(!Fight.fighting(event.getPlayer()))
|
|
||||||
return;
|
|
||||||
|
|
||||||
Inventory inventory = event.getPlayer().getInventory();
|
|
||||||
|
|
||||||
ItemStack stack = FlatteningWrapper.impl.onBreak(event.getBlock());
|
|
||||||
|
|
||||||
for (int i = 0; i <= 35; i++) { //35 is the last normal inventory slot
|
|
||||||
ItemStack itemStack = inventory.getItem(i);
|
|
||||||
if (itemStack != null && itemStack.isSimilar(stack) && itemStack.getAmount() != itemStack.getMaxStackSize()) {
|
|
||||||
itemStack.setAmount(itemStack.getAmount() + 1);
|
|
||||||
inventory.setItem(i, itemStack);
|
|
||||||
event.getPlayer().updateInventory();
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
for (int i = 0; i <= 35; i++) { //35 is the last normal inventory slot
|
|
||||||
ItemStack itemStack = inventory.getItem(i);
|
|
||||||
if (itemStack == null || itemStack.getType().equals(Material.AIR)) {
|
|
||||||
inventory.setItem(i, stack);
|
|
||||||
event.getPlayer().updateInventory();
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
@EventHandler
|
@EventHandler
|
||||||
public void onBlockPlace(BlockPlaceEvent e) {
|
public void onBlockPlace(BlockPlaceEvent e) {
|
||||||
FightPlayer fp = Fight.getFightPlayer(e.getPlayer());
|
FightPlayer fp = Fight.getFightPlayer(e.getPlayer());
|
||||||
|
@ -39,8 +39,6 @@ public interface FlatteningWrapper {
|
|||||||
boolean containsBlockMeta(ItemMeta meta);
|
boolean containsBlockMeta(ItemMeta meta);
|
||||||
boolean hasAttributeModifier(ItemStack stack);
|
boolean hasAttributeModifier(ItemStack stack);
|
||||||
|
|
||||||
ItemStack onBreak(Block type);
|
|
||||||
|
|
||||||
boolean doRecord(BlockPhysicsEvent e);
|
boolean doRecord(BlockPhysicsEvent e);
|
||||||
|
|
||||||
void forceLoadChunk(World world, int cX, int cZ);
|
void forceLoadChunk(World world, int cX, int cZ);
|
||||||
|
In neuem Issue referenzieren
Einen Benutzer sperren