Signed-off-by: Lixfel <agga-games@gmx.de>
Dieser Commit ist enthalten in:
Ursprung
d590f52c14
Commit
96034d3b0e
@ -83,23 +83,6 @@ public class FlatteningWrapper14 implements FlatteningWrapper.IFlatteningWrapper
|
||||
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
|
||||
public boolean doRecord(BlockPhysicsEvent e) {
|
||||
return e.getBlock() == e.getSourceBlock() || e.getChangedType() == Material.AIR;
|
||||
|
@ -62,11 +62,6 @@ public class FlatteningWrapper8 implements FlatteningWrapper.IFlatteningWrapper
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public ItemStack onBreak(Block block) {
|
||||
return block.getDrops().stream().findAny().orElse(new ItemStack(Material.AIR));
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean doRecord(BlockPhysicsEvent e) {
|
||||
return e.getChangedType() != e.getBlock().getType();
|
||||
|
@ -149,6 +149,18 @@ public class Kit {
|
||||
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() {
|
||||
return armor;
|
||||
}
|
||||
|
@ -23,24 +23,29 @@ import de.steamwar.fightsystem.ArenaMode;
|
||||
import de.steamwar.fightsystem.Config;
|
||||
import de.steamwar.fightsystem.FightSystem;
|
||||
import de.steamwar.fightsystem.fight.Fight;
|
||||
import de.steamwar.fightsystem.fight.FightPlayer;
|
||||
import de.steamwar.fightsystem.fight.FightTeam;
|
||||
import de.steamwar.fightsystem.record.REntity;
|
||||
import de.steamwar.fightsystem.states.FightState;
|
||||
import de.steamwar.fightsystem.states.StateDependentListener;
|
||||
import net.md_5.bungee.api.ChatMessageType;
|
||||
import org.bukkit.GameMode;
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.block.Block;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.event.EventHandler;
|
||||
import org.bukkit.event.EventPriority;
|
||||
import org.bukkit.event.Listener;
|
||||
import org.bukkit.event.entity.EntityExplodeEvent;
|
||||
import org.bukkit.event.entity.EntityPickupItemEvent;
|
||||
import org.bukkit.event.entity.FoodLevelChangeEvent;
|
||||
import org.bukkit.event.entity.SpawnerSpawnEvent;
|
||||
import org.bukkit.event.inventory.CraftItemEvent;
|
||||
import org.bukkit.event.inventory.FurnaceSmeltEvent;
|
||||
import org.bukkit.event.inventory.InventoryPickupItemEvent;
|
||||
import org.bukkit.event.player.*;
|
||||
import org.bukkit.event.weather.WeatherChangeEvent;
|
||||
import org.bukkit.event.world.WorldLoadEvent;
|
||||
import org.bukkit.inventory.ItemStack;
|
||||
|
||||
public class Permanent implements Listener {
|
||||
|
||||
@ -107,7 +112,7 @@ public class Permanent implements Listener {
|
||||
}
|
||||
|
||||
@EventHandler
|
||||
public void onCrafting(CraftItemEvent e){
|
||||
public void onCrafting(CraftItemEvent e) {
|
||||
e.setCancelled(true);
|
||||
}
|
||||
|
||||
@ -117,13 +122,32 @@ public class Permanent implements Listener {
|
||||
}
|
||||
|
||||
@EventHandler
|
||||
public void onDropPickup(InventoryPickupItemEvent e){
|
||||
e.setCancelled(true);
|
||||
public void onDropPickup(EntityPickupItemEvent e) {
|
||||
if(!(e.getEntity() instanceof Player))
|
||||
return;
|
||||
Player player = (Player) e.getEntity();
|
||||
|
||||
ItemStack stack = e.getItem().getItemStack();
|
||||
if(Config.PersonalKits) {
|
||||
if(Config.ForbiddenItems.contains(stack.getType())) {
|
||||
e.setCancelled(true);
|
||||
}
|
||||
} else {
|
||||
FightPlayer fp = Fight.getFightPlayer(player);
|
||||
if(fp == null)
|
||||
return;
|
||||
|
||||
if(!fp.getKit().contains(stack)) {
|
||||
e.setCancelled(true);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@EventHandler
|
||||
public void onDropping(PlayerDropItemEvent e){
|
||||
e.setCancelled(true);
|
||||
public void onExplosion(EntityExplodeEvent e) {
|
||||
for(Block block : e.blockList()) {
|
||||
block.setType(Material.AIR);
|
||||
}
|
||||
}
|
||||
|
||||
@EventHandler
|
||||
|
@ -25,15 +25,11 @@ import de.steamwar.fightsystem.fight.Fight;
|
||||
import de.steamwar.fightsystem.fight.FightPlayer;
|
||||
import de.steamwar.fightsystem.states.FightState;
|
||||
import de.steamwar.fightsystem.states.StateDependentListener;
|
||||
import de.steamwar.fightsystem.utils.FlatteningWrapper;
|
||||
import net.md_5.bungee.api.ChatMessageType;
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.event.EventHandler;
|
||||
import org.bukkit.event.Listener;
|
||||
import org.bukkit.event.block.BlockBreakEvent;
|
||||
import org.bukkit.event.block.BlockPlaceEvent;
|
||||
import org.bukkit.inventory.Inventory;
|
||||
import org.bukkit.inventory.ItemStack;
|
||||
|
||||
public class RunningWorldInteraction implements Listener {
|
||||
|
||||
@ -41,32 +37,6 @@ public class RunningWorldInteraction implements Listener {
|
||||
new StateDependentListener(ArenaMode.AntiReplay, FightState.Running, this);
|
||||
}
|
||||
|
||||
@EventHandler
|
||||
public void onBlockBreak(BlockBreakEvent event) {
|
||||
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
|
||||
public void onBlockPlace(BlockPlaceEvent e) {
|
||||
FightPlayer fp = Fight.getFightPlayer(e.getPlayer());
|
||||
|
@ -43,8 +43,6 @@ public class FlatteningWrapper {
|
||||
boolean containsBlockMeta(ItemMeta meta);
|
||||
boolean hasAttributeModifier(ItemStack stack);
|
||||
|
||||
ItemStack onBreak(Block type);
|
||||
|
||||
boolean doRecord(BlockPhysicsEvent e);
|
||||
|
||||
void forceLoadChunk(World world, int cX, int cZ);
|
||||
|
In neuem Issue referenzieren
Einen Benutzer sperren