Per world disable of BlockState module
This commit is contained in:
parent
a704d9bc57
commit
ea1921935e
8 changed files with 63 additions and 8 deletions
|
@ -30,6 +30,8 @@ public class BlockListener implements Listener {
|
|||
|
||||
@EventHandler(priority = EventPriority.HIGHEST, ignoreCancelled = true)
|
||||
public void onBlockBreak(BlockBreakEvent event) {
|
||||
if (mod.getConfig().getIgnoredWorlds().contains(event.getBlock().getWorld().getName()))
|
||||
return;
|
||||
if (mod.getModel().isRestricted(event.getBlock())) {
|
||||
if (mod.isDebug())
|
||||
mod.getLog().debug("Breaking bad, err.. block: " + event.getBlock().getLocation().toString());
|
||||
|
@ -46,6 +48,8 @@ public class BlockListener implements Listener {
|
|||
|
||||
@EventHandler
|
||||
public void onOtherBlockDestroy(BlockDestroyedEvent event) {
|
||||
if (mod.getConfig().getIgnoredWorlds().contains(event.getBlock().getWorld().getName()))
|
||||
return;
|
||||
if (mod.getModel().isRestricted(event.getBlock())) {
|
||||
if (mod.isDebug())
|
||||
mod.getLog().debug("Breaking attached block: " + event.getBlock().getLocation().toString());
|
||||
|
@ -59,6 +63,8 @@ public class BlockListener implements Listener {
|
|||
|
||||
@EventHandler(priority = EventPriority.HIGHEST, ignoreCancelled = true)
|
||||
public void onBlocksBreakByExplosion(EntityExplodeEvent event) {
|
||||
if (mod.getConfig().getIgnoredWorlds().contains(event.getLocation().getWorld().getName()))
|
||||
return;
|
||||
Map<Block, Boolean> states = mod.getModel().getRestrictedStates(event.blockList());
|
||||
DBTransaction update = mod.getModel().groupUpdate();
|
||||
for (Block block : event.blockList()) {
|
||||
|
@ -78,6 +84,8 @@ public class BlockListener implements Listener {
|
|||
|
||||
@EventHandler(priority = EventPriority.MONITOR, ignoreCancelled = true)
|
||||
public void onBlockPlace(BlockPlaceEvent event) {
|
||||
if (mod.getConfig().getIgnoredWorlds().contains(event.getBlock().getWorld().getName()))
|
||||
return;
|
||||
BlockState s = new BlockState();
|
||||
s.setLocation(event.getBlock().getLocation());
|
||||
s.setPlayer(event.getPlayer());
|
||||
|
@ -90,6 +98,8 @@ public class BlockListener implements Listener {
|
|||
|
||||
@EventHandler(priority = EventPriority.MONITOR, ignoreCancelled = true)
|
||||
public void onPistionExtend(BlockPistonExtendEvent event) {
|
||||
if (mod.getConfig().getIgnoredWorlds().contains(event.getBlock().getWorld().getName()))
|
||||
return;
|
||||
if (event.getBlock().getMetadata("LCBS_pistonIsAlreadyExtended").size() > 0) // Fixes long known Bukkit issue
|
||||
return;
|
||||
event.getBlock().setMetadata("LCBS_pistonIsAlreadyExtended", new FixedMetadataValue(mod.getPlugin(), new Boolean(true)));
|
||||
|
@ -119,6 +129,8 @@ public class BlockListener implements Listener {
|
|||
|
||||
@EventHandler(priority = EventPriority.MONITOR, ignoreCancelled = true)
|
||||
public void onPistionRetract(BlockPistonRetractEvent event) {
|
||||
if (mod.getConfig().getIgnoredWorlds().contains(event.getBlock().getWorld().getName()))
|
||||
return;
|
||||
event.getBlock().removeMetadata("LCBS_pistonIsAlreadyExtended", mod.getPlugin());
|
||||
|
||||
Block dest = event.getBlock().getRelative(event.getDirection());
|
||||
|
|
|
@ -102,6 +102,10 @@ public class BlockStateCommand extends BukkitCommand implements IHelpDescribed {
|
|||
if (args.length < 1) {// doesn't count parameters
|
||||
return false;
|
||||
}
|
||||
if (mod.getConfig().getIgnoredWorlds().contains(context.getPlayer().getWorld().getName())) {
|
||||
context.response(L("command.blockstate.world_ignored", context.getPlayer().getWorld().getName()));
|
||||
return true;
|
||||
}
|
||||
String gm = args[0].toLowerCase();
|
||||
final GameMode tgm;
|
||||
if (gm.equals("0") || gm.equals("s") || gm.equals("survival"))
|
||||
|
|
|
@ -4,6 +4,7 @@ import org.bukkit.Material;
|
|||
import org.bukkit.configuration.ConfigurationSection;
|
||||
|
||||
import de.jaschastarke.bukkit.lib.configuration.Configuration;
|
||||
import de.jaschastarke.bukkit.lib.configuration.StringList;
|
||||
import de.jaschastarke.configuration.IConfigurationNode;
|
||||
import de.jaschastarke.configuration.IConfigurationSubGroup;
|
||||
import de.jaschastarke.configuration.InvalidValueException;
|
||||
|
@ -131,11 +132,29 @@ public class BlockStateConfig extends Configuration implements IConfigurationSub
|
|||
*
|
||||
* default: true
|
||||
*/
|
||||
@IsConfigurationNode(order = 100)
|
||||
@IsConfigurationNode(order = 400)
|
||||
public boolean getLogSurvival() {
|
||||
return config.getBoolean("logSurvival", true);
|
||||
}
|
||||
|
||||
private StringList ignoredWorlds = null;
|
||||
|
||||
/**
|
||||
* BlockStateIgnoredWorlds
|
||||
*
|
||||
* While you may use per world permissions to configure limitations fine graded, you may want to disable the
|
||||
* BlockState-Feature for certain worlds (like complete creative worlds) to save cpu and memory.
|
||||
*
|
||||
* default: []
|
||||
*/
|
||||
@IsConfigurationNode(order = 500)
|
||||
public StringList getIgnoredWorlds() {
|
||||
if (ignoredWorlds == null) {
|
||||
ignoredWorlds = new StringList(config.getStringList("ignoredWorlds"));
|
||||
}
|
||||
return ignoredWorlds;
|
||||
}
|
||||
|
||||
protected void setTool(Object val) throws InvalidValueException {
|
||||
String v = (String) val;
|
||||
Material m = null;
|
||||
|
|
|
@ -22,6 +22,8 @@ public class HangingListener implements Listener {
|
|||
|
||||
@EventHandler(priority = EventPriority.HIGHEST, ignoreCancelled = true)
|
||||
public void onPlayerInteractEntity(PlayerInteractEntityEvent event) {
|
||||
if (mod.getConfig().getIgnoredWorlds().contains(event.getRightClicked().getWorld().getName()))
|
||||
return;
|
||||
if (event.getRightClicked() instanceof ItemFrame) {
|
||||
if (mod.getModel().isRestricted(event.getRightClicked().getLocation().getBlock())) {
|
||||
if (mod.isDebug())
|
||||
|
@ -49,6 +51,8 @@ public class HangingListener implements Listener {
|
|||
|
||||
@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());
|
||||
|
@ -67,6 +71,8 @@ public class HangingListener implements Listener {
|
|||
|
||||
@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());
|
||||
|
|
|
@ -30,15 +30,23 @@ public class PlayerListener implements Listener {
|
|||
if (event.getAction() == Action.RIGHT_CLICK_BLOCK) {
|
||||
Block b = event.getClickedBlock();
|
||||
if (b != null && event.getPlayer().getItemInHand().getType().equals(mod.getConfig().getTool()) && mod.getPlugin().getPermManager().hasPermission(event.getPlayer(), BlockStatePermissions.TOOL)) {
|
||||
if (mod.getConfig().getIgnoredWorlds().contains(event.getClickedBlock().getWorld().getName())) {
|
||||
event.getPlayer().sendMessage(mod.getPlugin().getLocale().trans("command.blockstate.world_ignored", event.getClickedBlock().getWorld().getName()));
|
||||
} else {
|
||||
showInfo(event.getPlayer(), b.getLocation(), b.getType());
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@EventHandler(priority = EventPriority.HIGH)
|
||||
public void onInteractEntity(PlayerInteractEntityEvent event) {
|
||||
Entity e = event.getRightClicked();
|
||||
if (e != null && e instanceof ItemFrame && event.getPlayer().getItemInHand().getType().equals(mod.getConfig().getTool()) && mod.getPlugin().getPermManager().hasPermission(event.getPlayer(), BlockStatePermissions.TOOL)) {
|
||||
if (mod.getConfig().getIgnoredWorlds().contains(e.getWorld().getName())) {
|
||||
event.getPlayer().sendMessage(mod.getPlugin().getLocale().trans("command.blockstate.world_ignored", e.getWorld().getName()));
|
||||
} else {
|
||||
showInfo(event.getPlayer(), e.getLocation(), Material.ITEM_FRAME);
|
||||
}
|
||||
event.setCancelled(true);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -42,10 +42,12 @@ public class ThreadedModel extends AbstractModel implements DBModel, Listener {
|
|||
// We don't keep any reference to queries, because it contains the DB-Connection, which should be only used
|
||||
// from the thread from now on (as SQLite may not threadsafe)
|
||||
for (World w : mod.getPlugin().getServer().getWorlds()) {
|
||||
if (!mod.getConfig().getIgnoredWorlds().containsIgnoreCase(w.getName())) {
|
||||
for (Chunk chunk : w.getLoadedChunks()) {
|
||||
threads.queueChunkLoad(chunk);
|
||||
}
|
||||
}
|
||||
}
|
||||
threads.start();
|
||||
}
|
||||
|
||||
|
@ -61,8 +63,10 @@ public class ThreadedModel extends AbstractModel implements DBModel, Listener {
|
|||
|
||||
@EventHandler(priority = EventPriority.HIGH, ignoreCancelled = true)
|
||||
public void onChunkLoad(ChunkLoadEvent event) {
|
||||
if (!mod.getConfig().getIgnoredWorlds().containsIgnoreCase(event.getWorld().getName())) {
|
||||
threads.queueChunkLoad(event.getChunk());
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void moveState(Block from, Block to) {
|
||||
|
|
|
@ -25,6 +25,7 @@ command.worldguard.flag_set: "The flag {0} was set"
|
|||
command.worldguard.additional_flags: Additional flags:
|
||||
|
||||
command.blockstate: LimitedCreative-BlockState-Command: modify blockstate database to prevent drops of selected blocks (requires WorldEdit)
|
||||
command.blockstate.world_ignored: The BlockState-Feature is disabled for this World ({0})
|
||||
command.blockstate.requires_worldedit: This command requires WorldEdit-Plugin
|
||||
command.blockstate.worledit_selection_empty: Select a region with WorldEdit first
|
||||
command.blockstate.command_updated: Successfully updated {0} blocks.
|
||||
|
|
|
@ -25,6 +25,7 @@ command.worldguard.flag_set: Das Attribut {0} wurde gesetzt
|
|||
command.worldguard.additional_flags: Zusätzliche Attribute:
|
||||
|
||||
command.blockstate: LimitedCreative-BlockStatus-Kommando: Ändern der BlockStatus Datenbank um Beute aus den ausgewählten Blöcken zu verhindern (benötigt WorldEdit)
|
||||
command.blockstate.world_ignored: Das BlockStatus-Modul ist für diese Welt deaktiviert ({0})
|
||||
command.blockstate.requires_worldedit: Dieser Befehl benötigt WorldEdit
|
||||
command.blockstate.worledit_selection_empty: Zuerst eine Region mit WorldEdit auswählen
|
||||
command.blockstate.command_updated: Erfolgreich {0} Blöcke aktuallisiert
|
||||
|
|
Loading…
Reference in a new issue