ItemFrame (Hanging) Handling
This commit is contained in:
parent
2477ec8f81
commit
f545debb97
5 changed files with 36 additions and 0 deletions
|
@ -5,6 +5,7 @@ import de.jaschastarke.bukkit.lib.Core;
|
||||||
import de.jaschastarke.bukkit.lib.PluginLang;
|
import de.jaschastarke.bukkit.lib.PluginLang;
|
||||||
import de.jaschastarke.bukkit.lib.configuration.command.ConfigCommand;
|
import de.jaschastarke.bukkit.lib.configuration.command.ConfigCommand;
|
||||||
import de.jaschastarke.bukkit.lib.modules.AdditionalBlockBreaks;
|
import de.jaschastarke.bukkit.lib.modules.AdditionalBlockBreaks;
|
||||||
|
import de.jaschastarke.bukkit.lib.modules.InstantHangingBreak;
|
||||||
import de.jaschastarke.utils.ClassDescriptorStorage;
|
import de.jaschastarke.utils.ClassDescriptorStorage;
|
||||||
|
|
||||||
public class LimitedCreative extends Core {
|
public class LimitedCreative extends Core {
|
||||||
|
@ -27,6 +28,7 @@ public class LimitedCreative extends Core {
|
||||||
Hooks.inizializeHooks(this);
|
Hooks.inizializeHooks(this);
|
||||||
|
|
||||||
modules.addSharedModule(new AdditionalBlockBreaks(this));
|
modules.addSharedModule(new AdditionalBlockBreaks(this));
|
||||||
|
modules.addSharedModule(new InstantHangingBreak(this));
|
||||||
modules.addSharedModule(new FeatureBlockItemSpawn(this));
|
modules.addSharedModule(new FeatureBlockItemSpawn(this));
|
||||||
addModule(new FeatureSwitchGameMode(this));
|
addModule(new FeatureSwitchGameMode(this));
|
||||||
addModule(new ModInventories(this));
|
addModule(new ModInventories(this));
|
||||||
|
|
|
@ -6,6 +6,7 @@ import de.jaschastarke.bukkit.lib.CoreModule;
|
||||||
import de.jaschastarke.bukkit.lib.commands.AliasHelpedCommand;
|
import de.jaschastarke.bukkit.lib.commands.AliasHelpedCommand;
|
||||||
import de.jaschastarke.bukkit.lib.modules.AdditionalBlockBreaks;
|
import de.jaschastarke.bukkit.lib.modules.AdditionalBlockBreaks;
|
||||||
import de.jaschastarke.bukkit.lib.modules.BlockFall;
|
import de.jaschastarke.bukkit.lib.modules.BlockFall;
|
||||||
|
import de.jaschastarke.bukkit.lib.modules.InstantHangingBreak;
|
||||||
import de.jaschastarke.minecraft.limitedcreative.blockstate.BlockListener;
|
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;
|
||||||
|
@ -42,6 +43,7 @@ public class ModBlockStates extends CoreModule<LimitedCreative> {
|
||||||
|
|
||||||
blockDrops = modules.linkSharedModule(FeatureBlockItemSpawn.class, plugin.getModules());
|
blockDrops = modules.linkSharedModule(FeatureBlockItemSpawn.class, plugin.getModules());
|
||||||
modules.linkSharedModule(AdditionalBlockBreaks.class, plugin.getModules());
|
modules.linkSharedModule(AdditionalBlockBreaks.class, plugin.getModules());
|
||||||
|
modules.linkSharedModule(InstantHangingBreak.class, plugin.getModules());
|
||||||
this.addModule(new BlockFall(plugin));
|
this.addModule(new BlockFall(plugin));
|
||||||
|
|
||||||
listeners.addListener(new BlockListener(this));
|
listeners.addListener(new BlockListener(this));
|
||||||
|
|
|
@ -2,6 +2,7 @@ package de.jaschastarke.minecraft.limitedcreative;
|
||||||
|
|
||||||
import de.jaschastarke.bukkit.lib.CoreModule;
|
import de.jaschastarke.bukkit.lib.CoreModule;
|
||||||
import de.jaschastarke.bukkit.lib.modules.AdditionalBlockBreaks;
|
import de.jaschastarke.bukkit.lib.modules.AdditionalBlockBreaks;
|
||||||
|
import de.jaschastarke.bukkit.lib.modules.InstantHangingBreak;
|
||||||
import de.jaschastarke.minecraft.limitedcreative.limits.BlockListener;
|
import de.jaschastarke.minecraft.limitedcreative.limits.BlockListener;
|
||||||
import de.jaschastarke.minecraft.limitedcreative.limits.EntityListener;
|
import de.jaschastarke.minecraft.limitedcreative.limits.EntityListener;
|
||||||
import de.jaschastarke.minecraft.limitedcreative.limits.EntityNoDrop;
|
import de.jaschastarke.minecraft.limitedcreative.limits.EntityNoDrop;
|
||||||
|
@ -37,6 +38,7 @@ public class ModCreativeLimits extends CoreModule<LimitedCreative> {
|
||||||
|
|
||||||
blockDrops = modules.linkSharedModule(FeatureBlockItemSpawn.class, plugin.getModules());
|
blockDrops = modules.linkSharedModule(FeatureBlockItemSpawn.class, plugin.getModules());
|
||||||
modules.linkSharedModule(AdditionalBlockBreaks.class, plugin.getModules());
|
modules.linkSharedModule(AdditionalBlockBreaks.class, plugin.getModules());
|
||||||
|
modules.linkSharedModule(InstantHangingBreak.class, plugin.getModules());
|
||||||
}
|
}
|
||||||
|
|
||||||
public FeatureBlockItemSpawn getBlockSpawn() {
|
public FeatureBlockItemSpawn getBlockSpawn() {
|
||||||
|
|
|
@ -25,6 +25,7 @@ import org.bukkit.event.block.BlockBreakEvent;
|
||||||
import org.bukkit.event.block.BlockPlaceEvent;
|
import org.bukkit.event.block.BlockPlaceEvent;
|
||||||
|
|
||||||
import de.jaschastarke.bukkit.lib.events.AttachedBlockDestroyedByPlayerEvent;
|
import de.jaschastarke.bukkit.lib.events.AttachedBlockDestroyedByPlayerEvent;
|
||||||
|
import de.jaschastarke.bukkit.lib.events.HangingBreakByPlayerBlockEvent;
|
||||||
import de.jaschastarke.minecraft.lib.permissions.IAbstractPermission;
|
import de.jaschastarke.minecraft.lib.permissions.IAbstractPermission;
|
||||||
import de.jaschastarke.minecraft.lib.permissions.IDynamicPermission;
|
import de.jaschastarke.minecraft.lib.permissions.IDynamicPermission;
|
||||||
import de.jaschastarke.minecraft.limitedcreative.ModCreativeLimits;
|
import de.jaschastarke.minecraft.limitedcreative.ModCreativeLimits;
|
||||||
|
@ -67,6 +68,14 @@ public class BlockListener implements Listener {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@EventHandler(ignoreCancelled = true)
|
||||||
|
public void onHangingBreakByPlayer(HangingBreakByPlayerBlockEvent event) {
|
||||||
|
if (mod.isDebug())
|
||||||
|
mod.getLog().debug("Attached Hanging " + event.getEntity().getType() + " destroyed by player block place/break: " + event.getPlayer().getName() + " in GM " + event.getPlayer().getGameMode().toString());
|
||||||
|
if (event.getPlayer().getGameMode() == GameMode.CREATIVE) {
|
||||||
|
event.getDrops().clear();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
private boolean checkPermission(Player player, IDynamicPermission perm) {
|
private boolean checkPermission(Player player, IDynamicPermission perm) {
|
||||||
return mod.getPlugin().getPermManager().hasPermission(player, perm);
|
return mod.getPlugin().getPermManager().hasPermission(player, perm);
|
||||||
|
|
|
@ -13,6 +13,7 @@ import org.bukkit.event.block.BlockPistonRetractEvent;
|
||||||
import org.bukkit.event.block.BlockPlaceEvent;
|
import org.bukkit.event.block.BlockPlaceEvent;
|
||||||
import org.bukkit.event.entity.ItemSpawnEvent;
|
import org.bukkit.event.entity.ItemSpawnEvent;
|
||||||
import org.bukkit.event.hanging.HangingBreakByEntityEvent;
|
import org.bukkit.event.hanging.HangingBreakByEntityEvent;
|
||||||
|
import org.bukkit.event.hanging.HangingPlaceEvent;
|
||||||
|
|
||||||
import de.jaschastarke.bukkit.lib.Utils;
|
import de.jaschastarke.bukkit.lib.Utils;
|
||||||
import de.jaschastarke.minecraft.limitedcreative.ModRegions;
|
import de.jaschastarke.minecraft.limitedcreative.ModRegions;
|
||||||
|
@ -88,6 +89,26 @@ public class BlockListener extends Listener {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@EventHandler(ignoreCancelled = true)
|
||||||
|
public void onHangingPlace(HangingPlaceEvent event) {
|
||||||
|
PlayerMeta pdata = new PlayerMeta(event.getPlayer());
|
||||||
|
boolean diffrent_region = getRM().isDiffrentRegion(event.getPlayer(), event.getEntity().getLocation());
|
||||||
|
|
||||||
|
if (pdata.isActiveRegionGameMode() && diffrent_region) {
|
||||||
|
// do not build outside of "gamemod-change-region" when in the region
|
||||||
|
if (getRM().getRegionSet(event.getBlock()).getFlag(Flags.GAMEMODE, event.getPlayer()) != pdata.getActiveRegionGameMode()) {
|
||||||
|
event.getPlayer().sendMessage(L("blocked.outside_place"));
|
||||||
|
event.setCancelled(true);
|
||||||
|
}
|
||||||
|
} else if (diffrent_region) {
|
||||||
|
// do not build inside of "survial-region in creative world" when outside
|
||||||
|
if (getRM().getRegionSet(event.getBlock()).getFlag(Flags.GAMEMODE) != null && getRM().getRegionSet(event.getBlock()).getFlag(Flags.GAMEMODE, event.getPlayer()) != event.getPlayer().getGameMode()) {
|
||||||
|
event.getPlayer().sendMessage(L("blocked.inside_place"));
|
||||||
|
event.setCancelled(true);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
@EventHandler
|
@EventHandler
|
||||||
public void onPistonExtend(BlockPistonExtendEvent event) {
|
public void onPistonExtend(BlockPistonExtendEvent event) {
|
||||||
if (event.isCancelled())
|
if (event.isCancelled())
|
||||||
|
|
Loading…
Reference in a new issue