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)
|
@EventHandler(priority = EventPriority.HIGHEST, ignoreCancelled = true)
|
||||||
public void onBlockBreak(BlockBreakEvent event) {
|
public void onBlockBreak(BlockBreakEvent event) {
|
||||||
|
if (mod.getConfig().getIgnoredWorlds().contains(event.getBlock().getWorld().getName()))
|
||||||
|
return;
|
||||||
if (mod.getModel().isRestricted(event.getBlock())) {
|
if (mod.getModel().isRestricted(event.getBlock())) {
|
||||||
if (mod.isDebug())
|
if (mod.isDebug())
|
||||||
mod.getLog().debug("Breaking bad, err.. block: " + event.getBlock().getLocation().toString());
|
mod.getLog().debug("Breaking bad, err.. block: " + event.getBlock().getLocation().toString());
|
||||||
|
@ -46,6 +48,8 @@ public class BlockListener implements Listener {
|
||||||
|
|
||||||
@EventHandler
|
@EventHandler
|
||||||
public void onOtherBlockDestroy(BlockDestroyedEvent event) {
|
public void onOtherBlockDestroy(BlockDestroyedEvent event) {
|
||||||
|
if (mod.getConfig().getIgnoredWorlds().contains(event.getBlock().getWorld().getName()))
|
||||||
|
return;
|
||||||
if (mod.getModel().isRestricted(event.getBlock())) {
|
if (mod.getModel().isRestricted(event.getBlock())) {
|
||||||
if (mod.isDebug())
|
if (mod.isDebug())
|
||||||
mod.getLog().debug("Breaking attached block: " + event.getBlock().getLocation().toString());
|
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)
|
@EventHandler(priority = EventPriority.HIGHEST, ignoreCancelled = true)
|
||||||
public void onBlocksBreakByExplosion(EntityExplodeEvent event) {
|
public void onBlocksBreakByExplosion(EntityExplodeEvent event) {
|
||||||
|
if (mod.getConfig().getIgnoredWorlds().contains(event.getLocation().getWorld().getName()))
|
||||||
|
return;
|
||||||
Map<Block, Boolean> states = mod.getModel().getRestrictedStates(event.blockList());
|
Map<Block, Boolean> states = mod.getModel().getRestrictedStates(event.blockList());
|
||||||
DBTransaction update = mod.getModel().groupUpdate();
|
DBTransaction update = mod.getModel().groupUpdate();
|
||||||
for (Block block : event.blockList()) {
|
for (Block block : event.blockList()) {
|
||||||
|
@ -78,6 +84,8 @@ public class BlockListener implements Listener {
|
||||||
|
|
||||||
@EventHandler(priority = EventPriority.MONITOR, ignoreCancelled = true)
|
@EventHandler(priority = EventPriority.MONITOR, ignoreCancelled = true)
|
||||||
public void onBlockPlace(BlockPlaceEvent event) {
|
public void onBlockPlace(BlockPlaceEvent event) {
|
||||||
|
if (mod.getConfig().getIgnoredWorlds().contains(event.getBlock().getWorld().getName()))
|
||||||
|
return;
|
||||||
BlockState s = new BlockState();
|
BlockState s = new BlockState();
|
||||||
s.setLocation(event.getBlock().getLocation());
|
s.setLocation(event.getBlock().getLocation());
|
||||||
s.setPlayer(event.getPlayer());
|
s.setPlayer(event.getPlayer());
|
||||||
|
@ -90,6 +98,8 @@ public class BlockListener implements Listener {
|
||||||
|
|
||||||
@EventHandler(priority = EventPriority.MONITOR, ignoreCancelled = true)
|
@EventHandler(priority = EventPriority.MONITOR, ignoreCancelled = true)
|
||||||
public void onPistionExtend(BlockPistonExtendEvent event) {
|
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
|
if (event.getBlock().getMetadata("LCBS_pistonIsAlreadyExtended").size() > 0) // Fixes long known Bukkit issue
|
||||||
return;
|
return;
|
||||||
event.getBlock().setMetadata("LCBS_pistonIsAlreadyExtended", new FixedMetadataValue(mod.getPlugin(), new Boolean(true)));
|
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)
|
@EventHandler(priority = EventPriority.MONITOR, ignoreCancelled = true)
|
||||||
public void onPistionRetract(BlockPistonRetractEvent event) {
|
public void onPistionRetract(BlockPistonRetractEvent event) {
|
||||||
|
if (mod.getConfig().getIgnoredWorlds().contains(event.getBlock().getWorld().getName()))
|
||||||
|
return;
|
||||||
event.getBlock().removeMetadata("LCBS_pistonIsAlreadyExtended", mod.getPlugin());
|
event.getBlock().removeMetadata("LCBS_pistonIsAlreadyExtended", mod.getPlugin());
|
||||||
|
|
||||||
Block dest = event.getBlock().getRelative(event.getDirection());
|
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
|
if (args.length < 1) {// doesn't count parameters
|
||||||
return false;
|
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();
|
String gm = args[0].toLowerCase();
|
||||||
final GameMode tgm;
|
final GameMode tgm;
|
||||||
if (gm.equals("0") || gm.equals("s") || gm.equals("survival"))
|
if (gm.equals("0") || gm.equals("s") || gm.equals("survival"))
|
||||||
|
|
|
@ -4,6 +4,7 @@ import org.bukkit.Material;
|
||||||
import org.bukkit.configuration.ConfigurationSection;
|
import org.bukkit.configuration.ConfigurationSection;
|
||||||
|
|
||||||
import de.jaschastarke.bukkit.lib.configuration.Configuration;
|
import de.jaschastarke.bukkit.lib.configuration.Configuration;
|
||||||
|
import de.jaschastarke.bukkit.lib.configuration.StringList;
|
||||||
import de.jaschastarke.configuration.IConfigurationNode;
|
import de.jaschastarke.configuration.IConfigurationNode;
|
||||||
import de.jaschastarke.configuration.IConfigurationSubGroup;
|
import de.jaschastarke.configuration.IConfigurationSubGroup;
|
||||||
import de.jaschastarke.configuration.InvalidValueException;
|
import de.jaschastarke.configuration.InvalidValueException;
|
||||||
|
@ -86,7 +87,7 @@ public class BlockStateConfig extends Configuration implements IConfigurationSub
|
||||||
* BlockStateThreading
|
* BlockStateThreading
|
||||||
*
|
*
|
||||||
* This experimental variant of the experimental Feature uses Threading to minimize lag. This fully relies on
|
* This experimental variant of the experimental Feature uses Threading to minimize lag. This fully relies on
|
||||||
* Bukkit metadata implementation. You only should need this, if there are often plays more then 10 players at once
|
* Bukkit metadata implementation. You only should need this, if there are often plays more then 10 players at once
|
||||||
* on your server. Be aware that this requires more memory.
|
* on your server. Be aware that this requires more memory.
|
||||||
*
|
*
|
||||||
* default: false
|
* default: false
|
||||||
|
@ -126,16 +127,34 @@ public class BlockStateConfig extends Configuration implements IConfigurationSub
|
||||||
/**
|
/**
|
||||||
* BlockStateLogSurvival
|
* BlockStateLogSurvival
|
||||||
*
|
*
|
||||||
* Log all Block-Places to the database. Disable to make the database more slim by not adding blocks placed in
|
* Log all Block-Places to the database. Disable to make the database more slim by not adding blocks placed in
|
||||||
* survival-mode.
|
* survival-mode.
|
||||||
*
|
*
|
||||||
* default: true
|
* default: true
|
||||||
*/
|
*/
|
||||||
@IsConfigurationNode(order = 100)
|
@IsConfigurationNode(order = 400)
|
||||||
public boolean getLogSurvival() {
|
public boolean getLogSurvival() {
|
||||||
return config.getBoolean("logSurvival", true);
|
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 {
|
protected void setTool(Object val) throws InvalidValueException {
|
||||||
String v = (String) val;
|
String v = (String) val;
|
||||||
Material m = null;
|
Material m = null;
|
||||||
|
|
|
@ -22,6 +22,8 @@ public class HangingListener implements Listener {
|
||||||
|
|
||||||
@EventHandler(priority = EventPriority.HIGHEST, ignoreCancelled = true)
|
@EventHandler(priority = EventPriority.HIGHEST, ignoreCancelled = true)
|
||||||
public void onPlayerInteractEntity(PlayerInteractEntityEvent event) {
|
public void onPlayerInteractEntity(PlayerInteractEntityEvent event) {
|
||||||
|
if (mod.getConfig().getIgnoredWorlds().contains(event.getRightClicked().getWorld().getName()))
|
||||||
|
return;
|
||||||
if (event.getRightClicked() instanceof ItemFrame) {
|
if (event.getRightClicked() instanceof ItemFrame) {
|
||||||
if (mod.getModel().isRestricted(event.getRightClicked().getLocation().getBlock())) {
|
if (mod.getModel().isRestricted(event.getRightClicked().getLocation().getBlock())) {
|
||||||
if (mod.isDebug())
|
if (mod.isDebug())
|
||||||
|
@ -49,6 +51,8 @@ public class HangingListener implements Listener {
|
||||||
|
|
||||||
@EventHandler(priority = EventPriority.HIGHEST, ignoreCancelled = true)
|
@EventHandler(priority = EventPriority.HIGHEST, ignoreCancelled = true)
|
||||||
public void onHangingBreak(HangingBreakEvent event) {
|
public void onHangingBreak(HangingBreakEvent event) {
|
||||||
|
if (mod.getConfig().getIgnoredWorlds().contains(event.getEntity().getWorld().getName()))
|
||||||
|
return;
|
||||||
if (event.getEntity() instanceof ItemFrame) {
|
if (event.getEntity() instanceof ItemFrame) {
|
||||||
if (mod.isDebug())
|
if (mod.isDebug())
|
||||||
mod.getLog().debug("Breaking hanging: " + event.getEntity().getLocation().toString());
|
mod.getLog().debug("Breaking hanging: " + event.getEntity().getLocation().toString());
|
||||||
|
@ -67,6 +71,8 @@ public class HangingListener implements Listener {
|
||||||
|
|
||||||
@EventHandler(priority = EventPriority.HIGHEST, ignoreCancelled = true)
|
@EventHandler(priority = EventPriority.HIGHEST, ignoreCancelled = true)
|
||||||
public void onHangingPlace(HangingPlaceEvent event) {
|
public void onHangingPlace(HangingPlaceEvent event) {
|
||||||
|
if (mod.getConfig().getIgnoredWorlds().contains(event.getEntity().getWorld().getName()))
|
||||||
|
return;
|
||||||
if (event.getEntity() instanceof ItemFrame) {
|
if (event.getEntity() instanceof ItemFrame) {
|
||||||
BlockState s = new BlockState();
|
BlockState s = new BlockState();
|
||||||
s.setLocation(event.getEntity().getLocation().getBlock().getLocation());
|
s.setLocation(event.getEntity().getLocation().getBlock().getLocation());
|
||||||
|
|
|
@ -30,7 +30,11 @@ public class PlayerListener implements Listener {
|
||||||
if (event.getAction() == Action.RIGHT_CLICK_BLOCK) {
|
if (event.getAction() == Action.RIGHT_CLICK_BLOCK) {
|
||||||
Block b = event.getClickedBlock();
|
Block b = event.getClickedBlock();
|
||||||
if (b != null && event.getPlayer().getItemInHand().getType().equals(mod.getConfig().getTool()) && mod.getPlugin().getPermManager().hasPermission(event.getPlayer(), BlockStatePermissions.TOOL)) {
|
if (b != null && event.getPlayer().getItemInHand().getType().equals(mod.getConfig().getTool()) && mod.getPlugin().getPermManager().hasPermission(event.getPlayer(), BlockStatePermissions.TOOL)) {
|
||||||
showInfo(event.getPlayer(), b.getLocation(), b.getType());
|
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());
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -38,7 +42,11 @@ public class PlayerListener implements Listener {
|
||||||
public void onInteractEntity(PlayerInteractEntityEvent event) {
|
public void onInteractEntity(PlayerInteractEntityEvent event) {
|
||||||
Entity e = event.getRightClicked();
|
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 (e != null && e instanceof ItemFrame && event.getPlayer().getItemInHand().getType().equals(mod.getConfig().getTool()) && mod.getPlugin().getPermManager().hasPermission(event.getPlayer(), BlockStatePermissions.TOOL)) {
|
||||||
showInfo(event.getPlayer(), e.getLocation(), Material.ITEM_FRAME);
|
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);
|
event.setCancelled(true);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -42,8 +42,10 @@ 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
|
// 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)
|
// from the thread from now on (as SQLite may not threadsafe)
|
||||||
for (World w : mod.getPlugin().getServer().getWorlds()) {
|
for (World w : mod.getPlugin().getServer().getWorlds()) {
|
||||||
for (Chunk chunk : w.getLoadedChunks()) {
|
if (!mod.getConfig().getIgnoredWorlds().containsIgnoreCase(w.getName())) {
|
||||||
threads.queueChunkLoad(chunk);
|
for (Chunk chunk : w.getLoadedChunks()) {
|
||||||
|
threads.queueChunkLoad(chunk);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
threads.start();
|
threads.start();
|
||||||
|
@ -61,7 +63,9 @@ public class ThreadedModel extends AbstractModel implements DBModel, Listener {
|
||||||
|
|
||||||
@EventHandler(priority = EventPriority.HIGH, ignoreCancelled = true)
|
@EventHandler(priority = EventPriority.HIGH, ignoreCancelled = true)
|
||||||
public void onChunkLoad(ChunkLoadEvent event) {
|
public void onChunkLoad(ChunkLoadEvent event) {
|
||||||
threads.queueChunkLoad(event.getChunk());
|
if (!mod.getConfig().getIgnoredWorlds().containsIgnoreCase(event.getWorld().getName())) {
|
||||||
|
threads.queueChunkLoad(event.getChunk());
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|
|
@ -25,6 +25,7 @@ command.worldguard.flag_set: "The flag {0} was set"
|
||||||
command.worldguard.additional_flags: Additional flags:
|
command.worldguard.additional_flags: Additional flags:
|
||||||
|
|
||||||
command.blockstate: LimitedCreative-BlockState-Command: modify blockstate database to prevent drops of selected blocks (requires WorldEdit)
|
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.requires_worldedit: This command requires WorldEdit-Plugin
|
||||||
command.blockstate.worledit_selection_empty: Select a region with WorldEdit first
|
command.blockstate.worledit_selection_empty: Select a region with WorldEdit first
|
||||||
command.blockstate.command_updated: Successfully updated {0} blocks.
|
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.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: 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.requires_worldedit: Dieser Befehl benötigt WorldEdit
|
||||||
command.blockstate.worledit_selection_empty: Zuerst eine Region mit WorldEdit auswählen
|
command.blockstate.worledit_selection_empty: Zuerst eine Region mit WorldEdit auswählen
|
||||||
command.blockstate.command_updated: Erfolgreich {0} Blöcke aktuallisiert
|
command.blockstate.command_updated: Erfolgreich {0} Blöcke aktuallisiert
|
||||||
|
|
Loading…
Reference in a new issue