Spigot 1.8: Armor Stand Support (Somehow. Spigot Implementation is Buggy)
This commit is contained in:
parent
7b72e1d5cf
commit
d010249107
8 changed files with 234 additions and 144 deletions
4
.gitignore
vendored
4
.gitignore
vendored
|
@ -1,11 +1,13 @@
|
||||||
/bin
|
/bin
|
||||||
|
|
||||||
# Eclipse stuff
|
# IDE stuff
|
||||||
/.project
|
/.project
|
||||||
/.classpath
|
/.classpath
|
||||||
/.settings
|
/.settings
|
||||||
/.buildpath
|
/.buildpath
|
||||||
/.checkstyle
|
/.checkstyle
|
||||||
|
/.idea
|
||||||
|
/LimitedCreative.iml
|
||||||
|
|
||||||
# maven
|
# maven
|
||||||
/target
|
/target
|
||||||
|
|
|
@ -4,17 +4,16 @@ import java.util.ArrayList;
|
||||||
import java.util.Iterator;
|
import java.util.Iterator;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
|
import org.bukkit.Bukkit;
|
||||||
import org.bukkit.Location;
|
import org.bukkit.Location;
|
||||||
import org.bukkit.Material;
|
import org.bukkit.Material;
|
||||||
import org.bukkit.block.Block;
|
import org.bukkit.block.Block;
|
||||||
import org.bukkit.enchantments.Enchantment;
|
import org.bukkit.enchantments.Enchantment;
|
||||||
import org.bukkit.entity.Item;
|
|
||||||
import org.bukkit.entity.Player;
|
import org.bukkit.entity.Player;
|
||||||
import org.bukkit.event.EventHandler;
|
import org.bukkit.event.EventHandler;
|
||||||
import org.bukkit.event.Listener;
|
import org.bukkit.event.Listener;
|
||||||
import org.bukkit.event.entity.ItemSpawnEvent;
|
import org.bukkit.event.entity.ItemSpawnEvent;
|
||||||
import org.bukkit.inventory.ItemStack;
|
import org.bukkit.inventory.ItemStack;
|
||||||
import org.bukkit.scheduler.BukkitRunnable;
|
|
||||||
|
|
||||||
import de.jaschastarke.bukkit.lib.CoreModule;
|
import de.jaschastarke.bukkit.lib.CoreModule;
|
||||||
|
|
||||||
|
@ -47,10 +46,10 @@ public class FeatureBlockItemSpawn extends CoreModule<LimitedCreative> implement
|
||||||
private void scheduleCleanUp() {
|
private void scheduleCleanUp() {
|
||||||
if (cleanup.maxTime == 0) { // if not scheduled yet
|
if (cleanup.maxTime == 0) { // if not scheduled yet
|
||||||
cleanup.maxTime = System.currentTimeMillis();
|
cleanup.maxTime = System.currentTimeMillis();
|
||||||
cleanup.runTaskLater(plugin, TICK_OFFSET);
|
Bukkit.getScheduler().runTaskLater(plugin, cleanup, TICK_OFFSET);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private class BlockItemDrop {
|
private class BlockItemDrop {
|
||||||
public BlockItemDrop(Location l, Material type) {
|
public BlockItemDrop(Location l, Material type) {
|
||||||
this.l = l;
|
this.l = l;
|
||||||
|
@ -96,11 +95,15 @@ public class FeatureBlockItemSpawn extends CoreModule<LimitedCreative> implement
|
||||||
list.add(new BlockItemDrop(l, type));
|
list.add(new BlockItemDrop(l, type));
|
||||||
scheduleCleanUp();
|
scheduleCleanUp();
|
||||||
}
|
}
|
||||||
|
public void block(Location l, ItemStack item) {
|
||||||
|
if (item != null)
|
||||||
|
block(l, item.getType());
|
||||||
|
}
|
||||||
|
|
||||||
@EventHandler(ignoreCancelled = true)
|
@EventHandler(ignoreCancelled = true)
|
||||||
public void onItemSpawn(ItemSpawnEvent event) {
|
public void onItemSpawn(ItemSpawnEvent event) {
|
||||||
if (event.getEntity() instanceof Item) {
|
if (event.getEntity() != null) {
|
||||||
if (this.isBlocked(event.getLocation().getBlock().getLocation(), ((Item) event.getEntity()).getItemStack().getType())) {
|
if (this.isBlocked(event.getLocation().getBlock().getLocation(), event.getEntity().getItemStack().getType())) {
|
||||||
event.setCancelled(true);
|
event.setCancelled(true);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -113,8 +116,9 @@ public class FeatureBlockItemSpawn extends CoreModule<LimitedCreative> implement
|
||||||
return debug;
|
return debug;
|
||||||
}
|
}
|
||||||
|
|
||||||
private class CleanUp extends BukkitRunnable {
|
private class CleanUp implements Runnable {
|
||||||
public long maxTime = 0;
|
public long maxTime = 0;
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void run() {
|
public void run() {
|
||||||
if (plugin.isDebug())
|
if (plugin.isDebug())
|
||||||
|
|
|
@ -15,10 +15,10 @@ import de.jaschastarke.minecraft.limitedcreative.blockstate.BlockListener;
|
||||||
import de.jaschastarke.minecraft.limitedcreative.blockstate.BlockStateCommand;
|
import de.jaschastarke.minecraft.limitedcreative.blockstate.BlockStateCommand;
|
||||||
import de.jaschastarke.minecraft.limitedcreative.blockstate.BlockStateConfig;
|
import de.jaschastarke.minecraft.limitedcreative.blockstate.BlockStateConfig;
|
||||||
import de.jaschastarke.minecraft.limitedcreative.blockstate.DBModel;
|
import de.jaschastarke.minecraft.limitedcreative.blockstate.DBModel;
|
||||||
import de.jaschastarke.minecraft.limitedcreative.blockstate.HangingListener;
|
import de.jaschastarke.minecraft.limitedcreative.blockstate.HangingStandingListener;
|
||||||
import de.jaschastarke.minecraft.limitedcreative.blockstate.PlayerListener;
|
import de.jaschastarke.minecraft.limitedcreative.blockstate.PlayerListener;
|
||||||
import de.jaschastarke.minecraft.limitedcreative.blockstate.SyncronizedModel;
|
import de.jaschastarke.minecraft.limitedcreative.blockstate.SyncronizedModel;
|
||||||
import de.jaschastarke.minecraft.limitedcreative.blockstate.ThreadedModel;
|
import de.jaschastarke.minecraft.limitedcreative.blockstate.ThreadedModel;
|
||||||
import de.jaschastarke.minecraft.limitedcreative.blockstate.worldedit.EditSessionListener;
|
import de.jaschastarke.minecraft.limitedcreative.blockstate.worldedit.EditSessionListener;
|
||||||
import de.jaschastarke.modularize.IModule;
|
import de.jaschastarke.modularize.IModule;
|
||||||
import de.jaschastarke.modularize.ModuleEntry;
|
import de.jaschastarke.modularize.ModuleEntry;
|
||||||
|
@ -50,7 +50,7 @@ public class ModBlockStates extends CoreModule<LimitedCreative> {
|
||||||
this.addModule(new BlockFall(plugin));
|
this.addModule(new BlockFall(plugin));
|
||||||
|
|
||||||
listeners.addListener(new BlockListener(this));
|
listeners.addListener(new BlockListener(this));
|
||||||
listeners.addListener(new HangingListener(this));
|
listeners.addListener(new HangingStandingListener(this));
|
||||||
listeners.addListener(new PlayerListener(this));
|
listeners.addListener(new PlayerListener(this));
|
||||||
|
|
||||||
command = new BlockStateCommand(this);
|
command = new BlockStateCommand(this);
|
||||||
|
|
|
@ -93,11 +93,11 @@ public class BlockStateConfig extends Configuration implements IConfigurationSub
|
||||||
*
|
*
|
||||||
* Without threading, huge WorldEdits becomes much noticeable slower.
|
* Without threading, huge WorldEdits becomes much noticeable slower.
|
||||||
*
|
*
|
||||||
* default: false
|
* default: true
|
||||||
*/
|
*/
|
||||||
@IsConfigurationNode(order = 150)
|
@IsConfigurationNode(order = 150)
|
||||||
public boolean getUseThreading() {
|
public boolean getUseThreading() {
|
||||||
return config.getBoolean("useThreading", false);
|
return config.getBoolean("useThreading", true);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
@ -1,117 +1,206 @@
|
||||||
package de.jaschastarke.minecraft.limitedcreative.blockstate;
|
package de.jaschastarke.minecraft.limitedcreative.blockstate;
|
||||||
|
|
||||||
import java.util.Date;
|
import java.util.Date;
|
||||||
|
|
||||||
import org.bukkit.GameMode;
|
import org.bukkit.GameMode;
|
||||||
import org.bukkit.Material;
|
import org.bukkit.Material;
|
||||||
import org.bukkit.entity.ItemFrame;
|
import org.bukkit.block.BlockFace;
|
||||||
import org.bukkit.entity.Player;
|
import org.bukkit.entity.ArmorStand;
|
||||||
import org.bukkit.event.EventHandler;
|
import org.bukkit.entity.ItemFrame;
|
||||||
import org.bukkit.event.EventPriority;
|
import org.bukkit.entity.Player;
|
||||||
import org.bukkit.event.Listener;
|
import org.bukkit.event.EventHandler;
|
||||||
import org.bukkit.event.entity.EntityDamageByEntityEvent;
|
import org.bukkit.event.EventPriority;
|
||||||
import org.bukkit.event.hanging.HangingBreakEvent;
|
import org.bukkit.event.Listener;
|
||||||
import org.bukkit.event.hanging.HangingPlaceEvent;
|
import org.bukkit.event.entity.CreatureSpawnEvent;
|
||||||
import org.bukkit.event.player.PlayerInteractEntityEvent;
|
import org.bukkit.event.entity.EntityDamageByEntityEvent;
|
||||||
|
import org.bukkit.event.entity.EntityDeathEvent;
|
||||||
import de.jaschastarke.minecraft.limitedcreative.ModBlockStates;
|
import org.bukkit.event.hanging.HangingBreakEvent;
|
||||||
|
import org.bukkit.event.hanging.HangingPlaceEvent;
|
||||||
public class HangingListener implements Listener {
|
import org.bukkit.event.player.PlayerArmorStandManipulateEvent;
|
||||||
private ModBlockStates mod;
|
import org.bukkit.event.player.PlayerInteractAtEntityEvent;
|
||||||
public HangingListener(ModBlockStates mod) {
|
import org.bukkit.event.player.PlayerInteractEntityEvent;
|
||||||
this.mod = mod;
|
|
||||||
}
|
import de.jaschastarke.minecraft.limitedcreative.ModBlockStates;
|
||||||
|
|
||||||
@EventHandler(priority = EventPriority.HIGHEST, ignoreCancelled = true)
|
public class HangingStandingListener implements Listener {
|
||||||
public void onPlayerInteractEntity(PlayerInteractEntityEvent event) {
|
private ModBlockStates mod;
|
||||||
if (mod.getConfig().getIgnoredWorlds().contains(event.getRightClicked().getWorld().getName()))
|
public HangingStandingListener(ModBlockStates mod) {
|
||||||
return;
|
this.mod = mod;
|
||||||
if (event.getRightClicked() instanceof ItemFrame) {
|
}
|
||||||
if (mod.getModel().isRestricted(event.getRightClicked().getLocation().getBlock())) {
|
|
||||||
if (mod.isDebug())
|
@EventHandler(priority = EventPriority.HIGHEST, ignoreCancelled = true)
|
||||||
mod.getLog().debug("Modifying hanging: " + event.getRightClicked().getLocation().toString());
|
public void onPlayerInteractEntity(PlayerInteractEntityEvent event) {
|
||||||
|
if (mod.getConfig().getIgnoredWorlds().contains(event.getRightClicked().getWorld().getName()))
|
||||||
if (event.getPlayer().getGameMode() != GameMode.CREATIVE) {
|
return;
|
||||||
if (mod.isDebug())
|
if (event.getRightClicked() instanceof ItemFrame) {
|
||||||
mod.getLog().debug("... was placed by creative. Modify prevented");
|
if (mod.getModel().isRestricted(event.getRightClicked().getLocation().getBlock())) {
|
||||||
event.setCancelled(true);
|
if (mod.isDebug())
|
||||||
return;
|
mod.getLog().debug("Modifying hanging: " + event.getRightClicked().getLocation().toString());
|
||||||
}
|
|
||||||
} else {
|
if (event.getPlayer().getGameMode() != GameMode.CREATIVE) {
|
||||||
BlockState s = new BlockState();
|
if (mod.isDebug())
|
||||||
s.setLocation(event.getRightClicked().getLocation().getBlock().getLocation());
|
mod.getLog().debug("... was placed by creative. Modify prevented");
|
||||||
s.setPlayer(event.getPlayer());
|
event.setCancelled(true);
|
||||||
s.setDate(new Date());
|
}
|
||||||
|
} else {
|
||||||
if (mod.isDebug())
|
BlockState s = new BlockState();
|
||||||
mod.getLog().debug("Saving BlockState: " + s.toString());
|
s.setLocation(event.getRightClicked().getLocation().getBlock().getLocation());
|
||||||
|
s.setPlayer(event.getPlayer());
|
||||||
mod.getModel().setState(s);
|
s.setDate(new Date());
|
||||||
}
|
|
||||||
}
|
if (mod.isDebug())
|
||||||
}
|
mod.getLog().debug("Saving BlockState: " + s.toString());
|
||||||
@EventHandler(priority = EventPriority.HIGHEST, ignoreCancelled = true)
|
|
||||||
public void onPlayerLeftInteractEntity(EntityDamageByEntityEvent event) {
|
mod.getModel().setState(s);
|
||||||
if (mod.getConfig().getIgnoredWorlds().contains(event.getEntity().getWorld().getName()))
|
}
|
||||||
return;
|
} else if (event.getRightClicked() instanceof ArmorStand) {
|
||||||
if (event.getDamager() instanceof Player && event.getEntity() instanceof ItemFrame) {
|
if (mod.getModel().isRestricted(event.getRightClicked().getLocation().getBlock())) {
|
||||||
if (mod.getModel().isRestricted(event.getEntity().getLocation().getBlock())) {
|
if (mod.isDebug())
|
||||||
if (mod.isDebug())
|
mod.getLog().debug("Modifying standing: " + event.getRightClicked().getLocation().toString());
|
||||||
mod.getLog().debug("Modifying hanging: " + event.getEntity().getLocation().toString());
|
|
||||||
|
if (event.getPlayer().getGameMode() != GameMode.CREATIVE) {
|
||||||
if (((Player) event.getDamager()).getGameMode() != GameMode.CREATIVE) {
|
if (mod.isDebug())
|
||||||
if (mod.isDebug())
|
mod.getLog().debug("... was placed by creative. Modify prevented");
|
||||||
mod.getLog().debug("... was placed by creative. Modify prevented");
|
event.setCancelled(true);
|
||||||
event.setCancelled(true);
|
}
|
||||||
return;
|
} else {
|
||||||
}
|
BlockState s = new BlockState();
|
||||||
} else {
|
s.setLocation(event.getRightClicked().getLocation().getBlock().getLocation());
|
||||||
BlockState s = new BlockState();
|
s.setPlayer(event.getPlayer());
|
||||||
s.setLocation(event.getEntity().getLocation().getBlock().getLocation());
|
s.setDate(new Date());
|
||||||
s.setPlayer((Player) event.getDamager());
|
|
||||||
s.setDate(new Date());
|
if (mod.isDebug())
|
||||||
|
mod.getLog().debug("Saving BlockState: " + s.toString());
|
||||||
if (mod.isDebug())
|
|
||||||
mod.getLog().debug("Saving BlockState: " + s.toString());
|
mod.getModel().setState(s);
|
||||||
|
}
|
||||||
mod.getModel().setState(s);
|
}
|
||||||
}
|
}
|
||||||
}
|
@EventHandler(priority = EventPriority.HIGHEST, ignoreCancelled = true)
|
||||||
}
|
public void onPlayerInteractAtEntity(PlayerInteractAtEntityEvent event) {
|
||||||
|
onPlayerInteractEntity(event);
|
||||||
@EventHandler(priority = EventPriority.HIGHEST, ignoreCancelled = true)
|
}
|
||||||
public void onHangingBreak(HangingBreakEvent event) {
|
@EventHandler(priority = EventPriority.HIGHEST, ignoreCancelled = true)
|
||||||
if (mod.getConfig().getIgnoredWorlds().contains(event.getEntity().getWorld().getName()))
|
public void onArmorStandManipulateEvent(PlayerArmorStandManipulateEvent event) {
|
||||||
return;
|
onPlayerInteractEntity(event);
|
||||||
if (event.getEntity() instanceof ItemFrame) {
|
}
|
||||||
if (mod.isDebug())
|
|
||||||
mod.getLog().debug("Breaking hanging: " + event.getEntity().getLocation().toString());
|
@EventHandler(priority = EventPriority.HIGHEST, ignoreCancelled = true)
|
||||||
|
public void onPlayerLeftInteractEntity(EntityDamageByEntityEvent event) {
|
||||||
if (mod.getModel().isRestricted(event.getEntity().getLocation().getBlock())) {
|
if (mod.getConfig().getIgnoredWorlds().contains(event.getEntity().getWorld().getName()))
|
||||||
if (mod.isDebug())
|
return;
|
||||||
mod.getLog().debug("... was placed by creative. Drop prevented");
|
if (event.getDamager() instanceof Player && event.getEntity() instanceof ItemFrame) {
|
||||||
|
if (mod.getModel().isRestricted(event.getEntity().getLocation().getBlock())) {
|
||||||
mod.getBlockSpawn().block(event.getEntity().getLocation().getBlock().getLocation(), Material.ITEM_FRAME);
|
if (mod.isDebug())
|
||||||
mod.getBlockSpawn().block(event.getEntity().getLocation().getBlock().getLocation(), ((ItemFrame) event.getEntity()).getItem().getType());
|
mod.getLog().debug("Modifying hanging: " + event.getEntity().getLocation().toString());
|
||||||
}
|
|
||||||
|
if (((Player) event.getDamager()).getGameMode() != GameMode.CREATIVE) {
|
||||||
mod.getModel().removeState(event.getEntity().getLocation().getBlock());
|
if (mod.isDebug())
|
||||||
}
|
mod.getLog().debug("... was placed by creative. Modify prevented");
|
||||||
}
|
event.setCancelled(true);
|
||||||
|
}
|
||||||
@EventHandler(priority = EventPriority.HIGHEST, ignoreCancelled = true)
|
} else {
|
||||||
public void onHangingPlace(HangingPlaceEvent event) {
|
BlockState s = new BlockState();
|
||||||
if (mod.getConfig().getIgnoredWorlds().contains(event.getEntity().getWorld().getName()))
|
s.setLocation(event.getEntity().getLocation().getBlock().getLocation());
|
||||||
return;
|
s.setPlayer((Player) event.getDamager());
|
||||||
if (event.getEntity() instanceof ItemFrame) {
|
s.setDate(new Date());
|
||||||
BlockState s = new BlockState();
|
|
||||||
s.setLocation(event.getEntity().getLocation().getBlock().getLocation());
|
if (mod.isDebug())
|
||||||
s.setPlayer(event.getPlayer());
|
mod.getLog().debug("Saving BlockState: " + s.toString());
|
||||||
s.setDate(new Date());
|
|
||||||
if (mod.isDebug())
|
mod.getModel().setState(s);
|
||||||
mod.getLog().debug("Saving BlockState: " + s.toString());
|
}
|
||||||
|
}
|
||||||
mod.getModel().setState(s);
|
}
|
||||||
}
|
|
||||||
}
|
@EventHandler(priority = EventPriority.HIGHEST, ignoreCancelled = true)
|
||||||
}
|
public void onHangingBreak(HangingBreakEvent event) {
|
||||||
|
if (mod.getConfig().getIgnoredWorlds().contains(event.getEntity().getWorld().getName()))
|
||||||
|
return;
|
||||||
|
if (event.getEntity() instanceof ItemFrame) {
|
||||||
|
if (mod.isDebug())
|
||||||
|
mod.getLog().debug("Breaking hanging: " + event.getEntity().getLocation().toString());
|
||||||
|
|
||||||
|
if (mod.getModel().isRestricted(event.getEntity().getLocation().getBlock())) {
|
||||||
|
if (mod.isDebug())
|
||||||
|
mod.getLog().debug("... was placed by creative. Drop prevented");
|
||||||
|
|
||||||
|
mod.getBlockSpawn().block(event.getEntity().getLocation().getBlock().getLocation(), Material.ITEM_FRAME);
|
||||||
|
mod.getBlockSpawn().block(event.getEntity().getLocation().getBlock().getLocation(), ((ItemFrame) event.getEntity()).getItem().getType());
|
||||||
|
}
|
||||||
|
|
||||||
|
mod.getModel().removeState(event.getEntity().getLocation().getBlock());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
protected void checkArmoryDestroy(ArmorStand entity, boolean deRemove) {
|
||||||
|
if (mod.isDebug())
|
||||||
|
mod.getLog().debug("Breaking standing: " + entity.getLocation().toString());
|
||||||
|
|
||||||
|
if (mod.getModel().isRestricted(entity.getLocation().getBlock())) {
|
||||||
|
if (mod.isDebug())
|
||||||
|
mod.getLog().debug("... was placed by creative. Drop prevented");
|
||||||
|
|
||||||
|
|
||||||
|
mod.getBlockSpawn().block(entity.getLocation().getBlock().getLocation(), Material.ARMOR_STAND);
|
||||||
|
mod.getBlockSpawn().block(entity.getLocation().getBlock().getRelative(BlockFace.UP).getLocation(), Material.ARMOR_STAND);
|
||||||
|
|
||||||
|
mod.getBlockSpawn().block(entity.getLocation().getBlock().getLocation(), entity.getHelmet());
|
||||||
|
mod.getBlockSpawn().block(entity.getLocation().getBlock().getLocation(), entity.getChestplate());
|
||||||
|
mod.getBlockSpawn().block(entity.getLocation().getBlock().getLocation(), entity.getBoots());
|
||||||
|
mod.getBlockSpawn().block(entity.getLocation().getBlock().getLocation(), entity.getItemInHand());
|
||||||
|
mod.getBlockSpawn().block(entity.getLocation().getBlock().getLocation(), entity.getLeggings());
|
||||||
|
|
||||||
|
mod.getBlockSpawn().block(entity.getLocation().getBlock().getRelative(BlockFace.UP).getLocation(), entity.getHelmet());
|
||||||
|
mod.getBlockSpawn().block(entity.getLocation().getBlock().getRelative(BlockFace.UP).getLocation(), entity.getChestplate());
|
||||||
|
mod.getBlockSpawn().block(entity.getLocation().getBlock().getRelative(BlockFace.UP).getLocation(), entity.getBoots());
|
||||||
|
mod.getBlockSpawn().block(entity.getLocation().getBlock().getRelative(BlockFace.UP).getLocation(), entity.getItemInHand());
|
||||||
|
mod.getBlockSpawn().block(entity.getLocation().getBlock().getRelative(BlockFace.UP).getLocation(), entity.getLeggings());
|
||||||
|
/*entity.setBoots(null);
|
||||||
|
entity.setChestplate(null);
|
||||||
|
entity.setHelmet(null);
|
||||||
|
entity.setItemInHand(null);
|
||||||
|
entity.setLeggings(null);*/
|
||||||
|
}
|
||||||
|
|
||||||
|
if (deRemove)
|
||||||
|
mod.getModel().removeState(entity.getLocation().getBlock());
|
||||||
|
}
|
||||||
|
|
||||||
|
@EventHandler(priority = EventPriority.HIGHEST, ignoreCancelled = true)
|
||||||
|
public void onStandingBreak(EntityDeathEvent event) {
|
||||||
|
if (mod.getConfig().getIgnoredWorlds().contains(event.getEntity().getWorld().getName()))
|
||||||
|
return;
|
||||||
|
if (event.getEntity() instanceof ArmorStand) {
|
||||||
|
checkArmoryDestroy((ArmorStand) event.getEntity(), true);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@EventHandler(priority = EventPriority.HIGHEST, ignoreCancelled = true)
|
||||||
|
public void onStandingBreaking(EntityDamageByEntityEvent event) {
|
||||||
|
if (mod.getConfig().getIgnoredWorlds().contains(event.getEntity().getWorld().getName()))
|
||||||
|
return;
|
||||||
|
if (event.getEntity() instanceof ArmorStand) {
|
||||||
|
// TODO: Bug in Spigot, we can not check for destroying yet. so the block state stays in DB :(
|
||||||
|
//if (event.getEntity().isDead() || ((ArmorStand) event.getEntity()).getHealth() <= event.getFinalDamage()) {
|
||||||
|
checkArmoryDestroy((ArmorStand) event.getEntity(), false);
|
||||||
|
//}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@EventHandler(priority = EventPriority.HIGHEST, ignoreCancelled = true)
|
||||||
|
public void onHangingPlace(HangingPlaceEvent event) {
|
||||||
|
if (mod.getConfig().getIgnoredWorlds().contains(event.getEntity().getWorld().getName()))
|
||||||
|
return;
|
||||||
|
if (event.getEntity() instanceof ItemFrame) {
|
||||||
|
BlockState s = new BlockState();
|
||||||
|
s.setLocation(event.getEntity().getLocation().getBlock().getLocation());
|
||||||
|
s.setPlayer(event.getPlayer());
|
||||||
|
s.setDate(new Date());
|
||||||
|
if (mod.isDebug())
|
||||||
|
mod.getLog().debug("Saving BlockState: " + s.toString());
|
||||||
|
|
||||||
|
mod.getModel().setState(s);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
|
@ -19,7 +19,6 @@ package de.jaschastarke.minecraft.limitedcreative.limits;
|
||||||
|
|
||||||
import org.bukkit.GameMode;
|
import org.bukkit.GameMode;
|
||||||
import org.bukkit.entity.Creature;
|
import org.bukkit.entity.Creature;
|
||||||
import org.bukkit.entity.LivingEntity;
|
|
||||||
import org.bukkit.entity.Player;
|
import org.bukkit.entity.Player;
|
||||||
import org.bukkit.event.EventHandler;
|
import org.bukkit.event.EventHandler;
|
||||||
import org.bukkit.event.Listener;
|
import org.bukkit.event.Listener;
|
||||||
|
@ -53,7 +52,7 @@ public class EntityListener implements Listener {
|
||||||
|
|
||||||
@EventHandler
|
@EventHandler
|
||||||
public void onEntityDeath(EntityDeathEvent event) {
|
public void onEntityDeath(EntityDeathEvent event) {
|
||||||
if (event.getEntity() instanceof LivingEntity && event.getDroppedExp() > 0) {
|
if (event.getEntity() != null && event.getDroppedExp() > 0) {
|
||||||
if (mod.getNoDropMobs().isXPPrevented(event.getEntity())) {
|
if (mod.getNoDropMobs().isXPPrevented(event.getEntity())) {
|
||||||
event.setDroppedExp(0);
|
event.setDroppedExp(0);
|
||||||
event.getDrops().clear();
|
event.getDrops().clear();
|
||||||
|
|
|
@ -125,7 +125,7 @@ public class LimitConfig extends Configuration implements IConfigurationSubGroup
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
public static enum BlockPickup implements IToGeneric {
|
public enum BlockPickup implements IToGeneric {
|
||||||
PREVENT,
|
PREVENT,
|
||||||
REMOVE;
|
REMOVE;
|
||||||
|
|
||||||
|
@ -289,7 +289,7 @@ public class LimitConfig extends Configuration implements IConfigurationSubGroup
|
||||||
public Object getValue(final IConfigurationNode node) {
|
public Object getValue(final IConfigurationNode node) {
|
||||||
Object val = super.getValue(node);
|
Object val = super.getValue(node);
|
||||||
if (node.getName().equals("pickup") && val == null) {
|
if (node.getName().equals("pickup") && val == null) {
|
||||||
return new Boolean(false);
|
return false;
|
||||||
} else {
|
} else {
|
||||||
return val;
|
return val;
|
||||||
}
|
}
|
||||||
|
|
|
@ -35,13 +35,7 @@ import org.bukkit.event.entity.EntityDeathEvent;
|
||||||
import org.bukkit.event.entity.EntityRegainHealthEvent;
|
import org.bukkit.event.entity.EntityRegainHealthEvent;
|
||||||
import org.bukkit.event.entity.FoodLevelChangeEvent;
|
import org.bukkit.event.entity.FoodLevelChangeEvent;
|
||||||
import org.bukkit.event.inventory.InventoryOpenEvent;
|
import org.bukkit.event.inventory.InventoryOpenEvent;
|
||||||
import org.bukkit.event.player.PlayerDropItemEvent;
|
import org.bukkit.event.player.*;
|
||||||
import org.bukkit.event.player.PlayerEvent;
|
|
||||||
import org.bukkit.event.player.PlayerExpChangeEvent;
|
|
||||||
import org.bukkit.event.player.PlayerGameModeChangeEvent;
|
|
||||||
import org.bukkit.event.player.PlayerInteractEntityEvent;
|
|
||||||
import org.bukkit.event.player.PlayerInteractEvent;
|
|
||||||
import org.bukkit.event.player.PlayerPickupItemEvent;
|
|
||||||
import org.bukkit.inventory.InventoryHolder;
|
import org.bukkit.inventory.InventoryHolder;
|
||||||
import org.bukkit.material.DirectionalContainer;
|
import org.bukkit.material.DirectionalContainer;
|
||||||
import org.bukkit.potion.PotionEffect;
|
import org.bukkit.potion.PotionEffect;
|
||||||
|
@ -185,13 +179,11 @@ public class PlayerListener implements Listener {
|
||||||
if (!checkPermission(event, NoLimitPermissions.CHEST)) {
|
if (!checkPermission(event, NoLimitPermissions.CHEST)) {
|
||||||
event.setCancelled(true);
|
event.setCancelled(true);
|
||||||
event.getPlayer().sendMessage(mod.getPlugin().getLocale().trans("blocked.chest"));
|
event.getPlayer().sendMessage(mod.getPlugin().getLocale().trans("blocked.chest"));
|
||||||
return;
|
|
||||||
}
|
}
|
||||||
} else if (mod.getConfig().getBlockInteraction().isListed(block)) {
|
} else if (mod.getConfig().getBlockInteraction().isListed(block)) {
|
||||||
if (!checkPermission(event, NoLimitPermissions.INTERACT(block))) {
|
if (!checkPermission(event, NoLimitPermissions.INTERACT(block))) {
|
||||||
event.setCancelled(true);
|
event.setCancelled(true);
|
||||||
event.getPlayer().sendMessage(mod.getPlugin().getLocale().trans("blocked.interact"));
|
event.getPlayer().sendMessage(mod.getPlugin().getLocale().trans("blocked.interact"));
|
||||||
return;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -213,11 +205,15 @@ public class PlayerListener implements Listener {
|
||||||
if (!checkPermission(event, NoLimitPermissions.BASE_INTERACT)) {
|
if (!checkPermission(event, NoLimitPermissions.BASE_INTERACT)) {
|
||||||
event.setCancelled(true);
|
event.setCancelled(true);
|
||||||
event.getPlayer().sendMessage(mod.getPlugin().getLocale().trans("blocked.entity"));
|
event.getPlayer().sendMessage(mod.getPlugin().getLocale().trans("blocked.entity"));
|
||||||
return;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@EventHandler
|
||||||
|
public void onPlayerInteractAtEntity(PlayerInteractAtEntityEvent event) {
|
||||||
|
onPlayerInteractEntity(event);
|
||||||
|
}
|
||||||
|
|
||||||
@EventHandler(ignoreCancelled = true)
|
@EventHandler(ignoreCancelled = true)
|
||||||
public void onEntityDamageByEntity(EntityDamageEvent rawevent) {
|
public void onEntityDamageByEntity(EntityDamageEvent rawevent) {
|
||||||
|
|
Loading…
Reference in a new issue