diff --git a/pom.xml b/pom.xml
index 0f1e00f..0384d7a 100644
--- a/pom.xml
+++ b/pom.xml
@@ -1,268 +1,274 @@
-
- 4.0.0
- de.jaschastarke
- LimitedCreative
- LimitedCreative
- 2.3-SNAPSHOT
- https://github.com/possi/LimitedCreative
-
-
- UTF-8
- 1.4-SNAPSHOT
- 1.12.2-R0.1-SNAPSHOT
-
-
-
- scm:git:git://github.com/possi/LimitedCreative.git
- scm:git:git@github.com:possi/LimitedCreative.git
- https://github.com/possi/LimitedCreative/tree/plib
-
-
-
- de-jas-repo
- scp://repo@ja-s.de/var/customers/webs/repo/mvn
-
-
-
- jenkins
- http://ci.ja-s.de:8080/
-
-
- BukkitDev
- http://dev.bukkit.org/server-mods/limited-creative/tickets/
-
-
-
-
-
- de-jas-rep
- http://repo.ja-s.de/mvn
-
-
-
-
- spigot-repo
- https://hub.spigotmc.org/nexus/content/repositories/snapshots/
-
-
-
- sk89q-mvn2
- http://maven.sk89q.com/repo
-
-
-
- onarandombox
- http://repo.onarandombox.com/content/groups/public
-
-
-
-
- md5
- http://repo.md-5.net/content/groups/public/
-
-
-
-
-
- de-jas-rep
- http://repo.ja-s.de/mvn
-
-
-
-
-
- de.jaschastarke
- plib
- ${plib.version}
-
-
-
- org.bukkit
- bukkit
- ${bukkit.version}
-
-
-
- com.sk89q
- worldguard
- 6.1
-
-
-
- com.sk89q
- worldedit
- 6.0.0-SNAPSHOT
-
-
-
- uk.org.whoami
- authme
- 2.9.5
-
-
-
- fr.xephi
- authme
- 3.0
-
-
-
- com.onarandombox.multiversecore
- Multiverse-Core
- 2.4
-
-
-
- multiworld
- multiworld
- 4.7.2
-
-
-
- com.cypherx
- xauth
- 2.0.26
-
-
-
- net.coreprotect
- coreprotect
- 2.0.8
-
-
-
- org.avaje
- ebean
- 2.7.3
-
-
-
-
- ${basedir}/src/main/java
- ${project.artifactId}
-
-
-
- org.apache.maven.plugins
- maven-compiler-plugin
- 2.3.2
-
-
- 1.6
-
-
- de.jaschastarke.maven.AnnotationProcessor
-
-
-
-
- de.jaschastarke
- plib
- ${plib.version}
-
-
- compile
-
- pluginyaml
-
-
-
- de.jaschastarke.minecraft.limitedcreative.LimitedCreative
-
- WorldGuard
- WorldEdit
- Multiverse-Core
- Multiworld
- xAuth
- AuthMe
- MultiInv
- Multiverse-Inventories
- Vault
- CoreProtect
-
-
- http://dev.bukkit.org/server-mods/limited-creative/
-
-
-
-
-
-
- org.apache.maven.plugins
- maven-shade-plugin
- 2.0
-
-
- package
-
- shade
-
-
- false
-
-
- de.jaschastarke:plib
-
-
-
-
- de.jaschastarke:plib
-
- de/jaschastarke/maven/**
- de/jaschastarke/bukkit/maven/**
-
-
-
-
-
-
-
-
-
-
-
-
-
- org.eclipse.m2e
- lifecycle-mapping
- 1.0.0
-
-
-
-
-
- de.jaschastarke
- plib
-
- [0.1-SNAPSHOT,)
-
-
- pluginyaml
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
- org.apache.maven.wagon
- wagon-ssh
- 2.1
-
-
-
-
+
+ 4.0.0
+ de.jaschastarke
+ LimitedCreative
+ LimitedCreative
+ 2.3-SNAPSHOT
+ https://github.com/possi/LimitedCreative
+
+
+ UTF-8
+ 1.4-SNAPSHOT
+ 1.12.2-R0.1-SNAPSHOT
+
+
+
+ scm:git:git://github.com/possi/LimitedCreative.git
+ scm:git:git@github.com:possi/LimitedCreative.git
+ https://github.com/possi/LimitedCreative/tree/plib
+
+
+
+ de-jas-repo
+ scp://repo@ja-s.de/var/customers/webs/repo/mvn
+
+
+
+ jenkins
+ http://ci.ja-s.de:8080/
+
+
+ BukkitDev
+ http://dev.bukkit.org/server-mods/limited-creative/tickets/
+
+
+
+
+
+ de-jas-rep
+ http://repo.ja-s.de/mvn
+
+
+
+
+ spigot-repo
+ https://hub.spigotmc.org/nexus/content/repositories/snapshots/
+
+
+
+ sk89q-mvn2
+ https://maven.enginehub.org/repo/
+
+
+
+ onarandombox
+ http://repo.onarandombox.com/content/groups/public
+
+
+
+
+ md5
+ http://repo.md-5.net/content/groups/public/
+
+
+
+
+
+ de-jas-rep
+ http://repo.ja-s.de/mvn
+
+
+
+
+
+ de.jaschastarke
+ plib
+ ${plib.version}
+
+
+
+ org.bukkit
+ bukkit
+ ${bukkit.version}
+
+
+
+ org.bukkit.
+ bukkit
+ 1.14.4-R0.1-SNAPSHOT
+
+
+
+ com.sk89q.worldguard
+ worldguard-bukkit
+ 7.0.0
+
+
+
+ com.sk89q.worldedit
+ worldedit-bukkit
+ 7.0.0
+
+
+
+ uk.org.whoami
+ authme
+ 2.9.5
+
+
+
+ fr.xephi
+ authme
+ 3.0
+
+
+
+ com.onarandombox.multiversecore
+ Multiverse-Core
+ 2.4
+
+
+
+ multiworld
+ multiworld
+ 4.7.2
+
+
+
+ com.cypherx
+ xauth
+ 2.0.26
+
+
+
+ net.coreprotect
+ coreprotect
+ 2.0.8
+
+
+
+ org.avaje
+ ebean
+ 2.7.3
+
+
+
+
+ ${basedir}/src/main/java
+ ${project.artifactId}
+
+
+
+ org.apache.maven.plugins
+ maven-compiler-plugin
+ 2.3.2
+
+
+ 1.6
+
+
+ de.jaschastarke.maven.AnnotationProcessor
+
+
+
+
+ de.jaschastarke
+ plib
+ ${plib.version}
+
+
+ compile
+
+ pluginyaml
+
+
+
+ de.jaschastarke.minecraft.limitedcreative.LimitedCreative
+
+ WorldGuard
+ WorldEdit
+ Multiverse-Core
+ Multiworld
+ xAuth
+ AuthMe
+ MultiInv
+ Multiverse-Inventories
+ Vault
+ CoreProtect
+
+
+ http://dev.bukkit.org/server-mods/limited-creative/
+
+
+
+
+
+
+ org.apache.maven.plugins
+ maven-shade-plugin
+ 2.0
+
+
+ package
+
+ shade
+
+
+ false
+
+
+ de.jaschastarke:plib
+
+
+
+
+ de.jaschastarke:plib
+
+ de/jaschastarke/maven/**
+ de/jaschastarke/bukkit/maven/**
+
+
+
+
+
+
+
+
+
+
+
+
+
+ org.eclipse.m2e
+ lifecycle-mapping
+ 1.0.0
+
+
+
+
+
+ de.jaschastarke
+ plib
+
+ [0.1-SNAPSHOT,)
+
+
+ pluginyaml
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ org.apache.maven.wagon
+ wagon-ssh
+ 2.1
+
+
+
+
diff --git a/src/main/java/de/jaschastarke/minecraft/limitedcreative/blockstate/BlockStateCommand.java b/src/main/java/de/jaschastarke/minecraft/limitedcreative/blockstate/BlockStateCommand.java
index 5aac8df..f32358f 100644
--- a/src/main/java/de/jaschastarke/minecraft/limitedcreative/blockstate/BlockStateCommand.java
+++ b/src/main/java/de/jaschastarke/minecraft/limitedcreative/blockstate/BlockStateCommand.java
@@ -1,285 +1,288 @@
-package de.jaschastarke.minecraft.limitedcreative.blockstate;
-
-import java.util.Date;
-
-import org.bukkit.Bukkit;
-import org.bukkit.GameMode;
-import org.bukkit.Location;
-import org.bukkit.Material;
-import org.bukkit.World;
-import com.sk89q.worldedit.bukkit.WorldEditPlugin;
-import com.sk89q.worldedit.bukkit.selections.Selection;
-
-import de.jaschastarke.LocaleString;
-import de.jaschastarke.bukkit.lib.chat.ChatFormattings;
-import de.jaschastarke.bukkit.lib.commands.BukkitCommand;
-import de.jaschastarke.bukkit.lib.commands.CommandContext;
-import de.jaschastarke.bukkit.lib.commands.CommandException;
-import de.jaschastarke.bukkit.lib.commands.HelpCommand;
-import de.jaschastarke.bukkit.lib.commands.IHelpDescribed;
-import de.jaschastarke.bukkit.lib.commands.MissingPermissionCommandException;
-import de.jaschastarke.bukkit.lib.commands.annotations.IsCommand;
-import de.jaschastarke.bukkit.lib.commands.annotations.Usages;
-import de.jaschastarke.bukkit.lib.commands.parser.DefinedParameterParser;
-import de.jaschastarke.bukkit.lib.database.DBHelper;
-import de.jaschastarke.database.DatabaseConfigurationException;
-import de.jaschastarke.database.db.Database;
-import de.jaschastarke.maven.ArchiveDocComments;
-import de.jaschastarke.maven.PluginCommand;
-import de.jaschastarke.minecraft.lib.permissions.IAbstractPermission;
-import de.jaschastarke.minecraft.limitedcreative.ModBlockStates;
-import de.jaschastarke.minecraft.limitedcreative.blockstate.BlockState.Source;
-import de.jaschastarke.minecraft.limitedcreative.blockstate.DBModel.Cuboid;
-import de.jaschastarke.minecraft.limitedcreative.blockstate.DBModel.DBTransaction;
-import de.jaschastarke.modularize.ModuleEntry.ModuleState;
-
-/**
- * LimitedCreative-BlockState-Command: modify blockstate database to prevent drops of selected blocks (requires WorldEdit)
- * @usage / - displays Regions-Command-Help
- * @permission limitedcreative.blockstate.command
- */
-@ArchiveDocComments
-@PluginCommand
-public class BlockStateCommand extends BukkitCommand implements IHelpDescribed {
- private ModBlockStates mod;
- private HelpCommand help;
-
- public BlockStateCommand() {
- this.help = this.getDefaultHelpCommand();
- }
- public BlockStateCommand(ModBlockStates mod) {
- super(mod.getPlugin());
- this.help = this.getDefaultHelpCommand();
- this.mod = mod;
- }
-
- @Override
- public String getName() {
- return "lcbs";
- }
-
- @Override
- public String[] getAliases() {
- return new String[]{};
- }
-
- /**
- * @internal has no effect, as not tested by any command handler
- * @see IHelpDescribed
- */
- @Override
- public IAbstractPermission[] getRequiredPermissions() {
- return new IAbstractPermission[]{BlockStatePermissions.COMMAND};
- }
-
- @Override
- public CharSequence[] getUsages() {
- return new String[]{"..."};
- }
-
- @Override
- public CharSequence getDescription() {
- return new LocaleString("command.blockstate");
- }
-
- @Override
- public CharSequence getPackageName() {
- return mod.getPlugin().getName() + " - " + mod.getName();
- }
-
- public boolean execute(final CommandContext context, final String[] args) throws MissingPermissionCommandException, CommandException {
- if (mod.getModuleEntry().getState() != ModuleState.ENABLED)
- throw new CommandException("Module " + mod.getName() + " is disabled");
- return super.execute(context, args);
- }
-
- /**
- * Deletes no longer used data from the BlockState-Database. Currently it only removes non-creative entries
- * from the database, if you changed to "logSurvival"-config from true to false.
- */
- @IsCommand("cleanup")
- @Usages("")
- public boolean cleanupDatabase(final CommandContext context, String... args) throws CommandException {
- if (mod.getConfig().getLogSurvival()) {
- context.responseFormatted(ChatFormattings.INFO, L("command.blockstate.nothing_to_cleanup"));
- } else {
- mod.getPlugin().getServer().getScheduler().runTaskAsynchronously(mod.getPlugin(), new Runnable() {
- @Override
- public void run() {
- int countDeleted = mod.getModel().cleanUp(DBModel.Cleanup.SURVIVAL);
- if (countDeleted < 0)
- context.responseFormatted(ChatFormattings.ERROR, L("command.blockstate.cleanup_error"));
- else
- context.responseFormatted(ChatFormattings.SUCCESS, L("command.blockstate.cleanup_success", countDeleted));
- }
- });
- }
- return true;
- }
-
- /**
- * Modifies the BlockState-Database and sets all blocks in the selection to the provided gamemode. Set it
- * to "creative" to disable drop of this block on destroying. Set it to "survival" to allow it.
- * WorldEdit is required, because the selection Region is used.
- * gamemode can be: survival / creative / adventure / s / c / a / 0 / 1 / 2
- * @throws MissingPermissionCommandException
- */
- @IsCommand("set")
- @Usages("")
- public boolean setGameMode(final CommandContext context, String... args) throws CommandException, MissingPermissionCommandException {
- if (!mod.getPlugin().getServer().getPluginManager().isPluginEnabled("WorldEdit")) {
- help.execute(context, new String[]{"set"});
- context.response(L("command.blockstate.requires_worldedit"));
- return true;
- }
- if (!context.isPlayer()) {
- context.response(L("cmdblock.blocked.not_console"));
- return true;
- }
- 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"))
- tgm = GameMode.SURVIVAL;
- else if (gm.equals("1") || gm.equals("c") || gm.equals("creative"))
- tgm = GameMode.CREATIVE;
- else if (gm.equals("2") || gm.equals("a") || gm.equals("adventure"))
- tgm = GameMode.ADVENTURE;
- else {
- return false;
- }
-
- WorldEditPlugin we = (WorldEditPlugin) mod.getPlugin().getServer().getPluginManager().getPlugin("WorldEdit");
- final Selection selection = we.getSelection(context.getPlayer());
-
- if (selection == null) {
- context.response(L("command.blockstate.worledit_selection_empty"));
- return true;
- }
-
- final Location min = selection.getMinimumPoint();
- final Location max = selection.getMaximumPoint();
-
- mod.getPlugin().getServer().getScheduler().runTaskAsynchronously(mod.getPlugin(), new Runnable() {
- @Override
- public void run() {
- if (mod.isDebug())
- mod.getLog().debug("Scheduler: Asynchronous Task run");
- DBTransaction update = mod.getModel().groupUpdate();
- int count = 0;
- World w = selection.getWorld();
-
- Cuboid c = new Cuboid();
- c.add(min);
- c.add(max);
- mod.getModel().cacheStates(c);
-
- BlockState seed = new BlockState();
- seed.setPlayer(context.getPlayer());
- seed.setGameMode(tgm);
- seed.setSource(Source.COMMAND);
- seed.setDate(new Date());
- for (int x = min.getBlockX(); x <= max.getBlockX(); x++) {
- for (int y = min.getBlockY(); y <= max.getBlockY(); y++) {
- for (int z = min.getBlockZ(); z <= max.getBlockZ(); z++) {
- Location loc = new Location(w, x, y, z);
- if (w.getBlockAt(loc).getType() != Material.AIR && selection.contains(loc)) {
- seed.setLocation(loc);
- update.setState(new BlockState(seed));
- count++;
- }
- }
- }
- }
- update.finish();
-
- context.response(L("command.blockstate.command_updated", count));
- }
- });
- return true;
- }
-
- /**
- * Imports BlockState Data from a given Database to the current active Database.
- * A Server-Restart is needed after migration!
- * Parameters:
- * -u --update Don't delete existing records / only overwrite if newer
- * --import= Import from other Plugins. Supported Types:
- * cc CreativeControl
- */
- @IsCommand("migrate")
- @Usages("-u --import=cc [username] [password]")
- public boolean migrateDatabase(final CommandContext context, String... args) throws CommandException, MissingPermissionCommandException {
- DefinedParameterParser params = new DefinedParameterParser(args, new String[]{"debug", "d", "update", "u", "confirm"});
- if (params.getArgumentCount() < 1) {// doesn't count parameters
- return false;
- }
-
- if (Bukkit.getServer().getOnlinePlayers().size() > (context.isPlayer() ? 1 : 0)) {
- context.responseFormatted(ChatFormattings.ERROR, L("command.blockstate.migrate_useronline_error"));
- return true;
- }
-
- Database source;
- Database target;
- try {
-
- if (params.getArgumentCount() < 2)
- source = DBHelper.createConnection(params.getArgument(0));
- else if (params.getArgumentCount() < 3)
- source = DBHelper.createConnection(params.getArgument(0), params.getArgument(1), null);
- else
- source = DBHelper.createConnection(params.getArgument(0), params.getArgument(1), params.getArgument(2));
-
- target = mod.getPlugin().getDatabaseConnection();
- } catch (DatabaseConfigurationException e) {
- context.responseFormatted(ChatFormattings.ERROR, L("command.blockstate.migrate_connect_error", e.getMessage()));
- return true;
- }
-
- DatabaseMigrationThread thread;
- if (params.getParameter("import") != null) {
- if (params.getParameter("import").equals("cc")) {
- thread = new CreativeControlImportThread(mod, context, source, target);
- } else {
- context.responseFormatted(ChatFormattings.ERROR, L("command.blockstate.migrate_importtype_error", params.getParameter("import")));
- return false;
- }
- } else {
- thread = new DatabaseMigrationThread(mod, context, source, target);
- }
- if (params.getFlags().contains("update") || params.getFlags().contains("u")) {
- thread.setMode(DatabaseMigrationThread.Mode.UPDATE);
- }
- if (params.getFlags().contains("debug") || params.getFlags().contains("d")) {
- thread.setDebug(true);
- }
-
- if (!params.getFlags().contains("confirm")) {
- context.responseFormatted(ChatFormattings.INFO, L("command.blockstate.migrate_confirm", "--confirm"));
- return true;
- }
-
- mod.getModuleEntry().disable();
-
- thread.start();
- String sourceType = source.getType().toString();
- if (params.getParameter("import") != null) {
- if (params.getParameter("import").equals("cc")) {
- sourceType = "CreativeControl-" + sourceType;
- }
- }
- context.response(L("command.blockstate.migrate_started", sourceType, target.getType()));
- return true;
- }
-
- private String L(String msg, Object... args) {
- return mod.getPlugin().getLocale().trans(msg, args);
- }
-}
+package de.jaschastarke.minecraft.limitedcreative.blockstate;
+
+import com.sk89q.worldedit.WorldEdit;
+import com.sk89q.worldedit.bukkit.BukkitAdapter;
+import com.sk89q.worldedit.bukkit.BukkitPlayer;
+import com.sk89q.worldedit.math.BlockVector3;
+import com.sk89q.worldedit.regions.Region;
+import com.sk89q.worldedit.world.World;
+import de.jaschastarke.LocaleString;
+import de.jaschastarke.bukkit.lib.chat.ChatFormattings;
+import de.jaschastarke.bukkit.lib.commands.*;
+import de.jaschastarke.bukkit.lib.commands.annotations.IsCommand;
+import de.jaschastarke.bukkit.lib.commands.annotations.Usages;
+import de.jaschastarke.bukkit.lib.commands.parser.DefinedParameterParser;
+import de.jaschastarke.bukkit.lib.database.DBHelper;
+import de.jaschastarke.database.DatabaseConfigurationException;
+import de.jaschastarke.database.db.Database;
+import de.jaschastarke.maven.ArchiveDocComments;
+import de.jaschastarke.maven.PluginCommand;
+import de.jaschastarke.minecraft.lib.permissions.IAbstractPermission;
+import de.jaschastarke.minecraft.limitedcreative.ModBlockStates;
+import de.jaschastarke.minecraft.limitedcreative.blockstate.BlockState.Source;
+import de.jaschastarke.minecraft.limitedcreative.blockstate.DBModel.Cuboid;
+import de.jaschastarke.minecraft.limitedcreative.blockstate.DBModel.DBTransaction;
+import de.jaschastarke.modularize.ModuleEntry.ModuleState;
+import org.bukkit.Bukkit;
+import org.bukkit.GameMode;
+import org.bukkit.Location;
+
+import java.util.Date;
+
+/**
+ * LimitedCreative-BlockState-Command: modify blockstate database to prevent drops of selected blocks (requires WorldEdit)
+ * @usage / - displays Regions-Command-Help
+ * @permission limitedcreative.blockstate.command
+ */
+@ArchiveDocComments
+@PluginCommand
+public class BlockStateCommand extends BukkitCommand implements IHelpDescribed {
+ private ModBlockStates mod;
+ private HelpCommand help;
+
+ public BlockStateCommand() {
+ this.help = this.getDefaultHelpCommand();
+ }
+ public BlockStateCommand(ModBlockStates mod) {
+ super(mod.getPlugin());
+ this.help = this.getDefaultHelpCommand();
+ this.mod = mod;
+ }
+
+ @Override
+ public String getName() {
+ return "lcbs";
+ }
+
+ @Override
+ public String[] getAliases() {
+ return new String[]{};
+ }
+
+ /**
+ * @internal has no effect, as not tested by any command handler
+ * @see IHelpDescribed
+ */
+ @Override
+ public IAbstractPermission[] getRequiredPermissions() {
+ return new IAbstractPermission[]{BlockStatePermissions.COMMAND};
+ }
+
+ @Override
+ public CharSequence[] getUsages() {
+ return new String[]{"..."};
+ }
+
+ @Override
+ public CharSequence getDescription() {
+ return new LocaleString("command.blockstate");
+ }
+
+ @Override
+ public CharSequence getPackageName() {
+ return mod.getPlugin().getName() + " - " + mod.getName();
+ }
+
+ public boolean execute(final CommandContext context, final String[] args) throws MissingPermissionCommandException, CommandException {
+ if (mod.getModuleEntry().getState() != ModuleState.ENABLED)
+ throw new CommandException("Module " + mod.getName() + " is disabled");
+ return super.execute(context, args);
+ }
+
+ /**
+ * Deletes no longer used data from the BlockState-Database. Currently it only removes non-creative entries
+ * from the database, if you changed to "logSurvival"-config from true to false.
+ */
+ @IsCommand("cleanup")
+ @Usages("")
+ public boolean cleanupDatabase(final CommandContext context, String... args) throws CommandException {
+ if (mod.getConfig().getLogSurvival()) {
+ context.responseFormatted(ChatFormattings.INFO, L("command.blockstate.nothing_to_cleanup"));
+ } else {
+ mod.getPlugin().getServer().getScheduler().runTaskAsynchronously(mod.getPlugin(), new Runnable() {
+ @Override
+ public void run() {
+ int countDeleted = mod.getModel().cleanUp(DBModel.Cleanup.SURVIVAL);
+ if (countDeleted < 0)
+ context.responseFormatted(ChatFormattings.ERROR, L("command.blockstate.cleanup_error"));
+ else
+ context.responseFormatted(ChatFormattings.SUCCESS, L("command.blockstate.cleanup_success", countDeleted));
+ }
+ });
+ }
+ return true;
+ }
+
+ /**
+ * Modifies the BlockState-Database and sets all blocks in the selection to the provided gamemode. Set it
+ * to "creative" to disable drop of this block on destroying. Set it to "survival" to allow it.
+ * WorldEdit is required, because the selection Region is used.
+ * gamemode can be: survival / creative / adventure / s / c / a / 0 / 1 / 2
+ * @throws MissingPermissionCommandException
+ */
+ @IsCommand("set")
+ @Usages("")
+ public boolean setGameMode(final CommandContext context, String... args) throws CommandException, MissingPermissionCommandException {
+ if (!mod.getPlugin().getServer().getPluginManager().isPluginEnabled("WorldEdit")) {
+ help.execute(context, new String[]{"set"});
+ context.response(L("command.blockstate.requires_worldedit"));
+ return true;
+ }
+ if (!context.isPlayer()) {
+ context.response(L("cmdblock.blocked.not_console"));
+ return true;
+ }
+ 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"))
+ tgm = GameMode.SURVIVAL;
+ else if (gm.equals("1") || gm.equals("c") || gm.equals("creative"))
+ tgm = GameMode.CREATIVE;
+ else if (gm.equals("2") || gm.equals("a") || gm.equals("adventure"))
+ tgm = GameMode.ADVENTURE;
+ else {
+ return false;
+ }
+
+ BukkitPlayer bp = BukkitAdapter.adapt(context.getPlayer());
+ Region region = null;
+ try {
+ region = WorldEdit.getInstance().getSessionManager().get(bp).getSelection(bp.getWorld());
+ } catch (Exception ignored) { //IncompleteRegionException
+ }
+
+ final Region selection = region;
+ if (selection == null) {
+ context.response(L("command.blockstate.worledit_selection_empty"));
+ return true;
+ }
+
+ final BlockVector3 min = selection.getMinimumPoint();
+ final BlockVector3 max = selection.getMaximumPoint();
+
+ mod.getPlugin().getServer().getScheduler().runTaskAsynchronously(mod.getPlugin(), new Runnable() {
+ @Override
+ public void run() {
+ if (mod.isDebug())
+ mod.getLog().debug("Scheduler: Asynchronous Task run");
+ DBTransaction update = mod.getModel().groupUpdate();
+ int count = 0;
+ World w = selection.getWorld();
+ assert w != null;
+ org.bukkit.World bw = BukkitAdapter.adapt(w);
+
+ Cuboid c = new Cuboid();
+ c.add(new Location(bw, min.getBlockX(), min.getBlockY(), min.getBlockZ()));
+ c.add(new Location(bw, max.getBlockX(), max.getBlockY(), max.getBlockZ()));
+ mod.getModel().cacheStates(c);
+
+ BlockState seed = new BlockState();
+ seed.setPlayer(context.getPlayer());
+ seed.setGameMode(tgm);
+ seed.setSource(Source.COMMAND);
+ seed.setDate(new Date());
+ for (int x = min.getBlockX(); x <= max.getBlockX(); x++) {
+ for (int y = min.getBlockY(); y <= max.getBlockY(); y++) {
+ for (int z = min.getBlockZ(); z <= max.getBlockZ(); z++) {
+ BlockVector3 loc = BlockVector3.at(x, y, z);
+ if (!w.getBlock(loc).getBlockType().getMaterial().isAir() && selection.contains(loc)) {
+ seed.setLocation(new Location(bw, x, y, z));
+ update.setState(new BlockState(seed));
+ count++;
+ }
+ }
+ }
+ }
+ update.finish();
+
+ context.response(L("command.blockstate.command_updated", count));
+ }
+ });
+ return true;
+ }
+
+ /**
+ * Imports BlockState Data from a given Database to the current active Database.
+ * A Server-Restart is needed after migration!
+ * Parameters:
+ * -u --update Don't delete existing records / only overwrite if newer
+ * --import= Import from other Plugins. Supported Types:
+ * cc CreativeControl
+ */
+ @IsCommand("migrate")
+ @Usages("-u --import=cc [username] [password]")
+ public boolean migrateDatabase(final CommandContext context, String... args) throws CommandException, MissingPermissionCommandException {
+ DefinedParameterParser params = new DefinedParameterParser(args, new String[]{"debug", "d", "update", "u", "confirm"});
+ if (params.getArgumentCount() < 1) {// doesn't count parameters
+ return false;
+ }
+
+ if (Bukkit.getServer().getOnlinePlayers().size() > (context.isPlayer() ? 1 : 0)) {
+ context.responseFormatted(ChatFormattings.ERROR, L("command.blockstate.migrate_useronline_error"));
+ return true;
+ }
+
+ Database source;
+ Database target;
+ try {
+
+ if (params.getArgumentCount() < 2)
+ source = DBHelper.createConnection(params.getArgument(0));
+ else if (params.getArgumentCount() < 3)
+ source = DBHelper.createConnection(params.getArgument(0), params.getArgument(1), null);
+ else
+ source = DBHelper.createConnection(params.getArgument(0), params.getArgument(1), params.getArgument(2));
+
+ target = mod.getPlugin().getDatabaseConnection();
+ } catch (DatabaseConfigurationException e) {
+ context.responseFormatted(ChatFormattings.ERROR, L("command.blockstate.migrate_connect_error", e.getMessage()));
+ return true;
+ }
+
+ DatabaseMigrationThread thread;
+ if (params.getParameter("import") != null) {
+ if (params.getParameter("import").equals("cc")) {
+ thread = new CreativeControlImportThread(mod, context, source, target);
+ } else {
+ context.responseFormatted(ChatFormattings.ERROR, L("command.blockstate.migrate_importtype_error", params.getParameter("import")));
+ return false;
+ }
+ } else {
+ thread = new DatabaseMigrationThread(mod, context, source, target);
+ }
+ if (params.getFlags().contains("update") || params.getFlags().contains("u")) {
+ thread.setMode(DatabaseMigrationThread.Mode.UPDATE);
+ }
+ if (params.getFlags().contains("debug") || params.getFlags().contains("d")) {
+ thread.setDebug(true);
+ }
+
+ if (!params.getFlags().contains("confirm")) {
+ context.responseFormatted(ChatFormattings.INFO, L("command.blockstate.migrate_confirm", "--confirm"));
+ return true;
+ }
+
+ mod.getModuleEntry().disable();
+
+ thread.start();
+ String sourceType = source.getType().toString();
+ if (params.getParameter("import") != null) {
+ if (params.getParameter("import").equals("cc")) {
+ sourceType = "CreativeControl-" + sourceType;
+ }
+ }
+ context.response(L("command.blockstate.migrate_started", sourceType, target.getType()));
+ return true;
+ }
+
+ private String L(String msg, Object... args) {
+ return mod.getPlugin().getLocale().trans(msg, args);
+ }
+}
diff --git a/src/main/java/de/jaschastarke/minecraft/limitedcreative/blockstate/worldedit/EditSessionExtent.java b/src/main/java/de/jaschastarke/minecraft/limitedcreative/blockstate/worldedit/EditSessionExtent.java
index 57ac3d2..e93aea7 100644
--- a/src/main/java/de/jaschastarke/minecraft/limitedcreative/blockstate/worldedit/EditSessionExtent.java
+++ b/src/main/java/de/jaschastarke/minecraft/limitedcreative/blockstate/worldedit/EditSessionExtent.java
@@ -1,21 +1,20 @@
package de.jaschastarke.minecraft.limitedcreative.blockstate.worldedit;
-import java.util.Date;
-
+import com.sk89q.worldedit.WorldEditException;
+import com.sk89q.worldedit.extent.AbstractDelegateExtent;
+import com.sk89q.worldedit.extent.Extent;
+import com.sk89q.worldedit.math.BlockVector3;
+import com.sk89q.worldedit.world.block.BlockStateHolder;
+import de.jaschastarke.minecraft.limitedcreative.ModBlockStates;
+import de.jaschastarke.minecraft.limitedcreative.blockstate.BlockState;
+import de.jaschastarke.minecraft.limitedcreative.blockstate.BlockState.Source;
import org.bukkit.Location;
import org.bukkit.World;
import org.bukkit.entity.Player;
-import com.sk89q.worldedit.Vector;
-import com.sk89q.worldedit.blocks.BaseBlock;
-import com.sk89q.worldedit.extent.Extent;
-import com.sk89q.worldedit.extent.logging.AbstractLoggingExtent;
+import java.util.Date;
-import de.jaschastarke.minecraft.limitedcreative.ModBlockStates;
-import de.jaschastarke.minecraft.limitedcreative.blockstate.BlockState;
-import de.jaschastarke.minecraft.limitedcreative.blockstate.BlockState.Source;
-
-public class EditSessionExtent extends AbstractLoggingExtent {
+public class EditSessionExtent extends AbstractDelegateExtent {
private ModBlockStates mod;
private Player player = null;
private World world;
@@ -30,14 +29,15 @@ public class EditSessionExtent extends AbstractLoggingExtent {
/**
* Called when a block is being changed.
*
- * @param position the position
+ * @param pt the position
* @param newBlock the new block to replace the old one
*/
- protected void onBlockChange(Vector pt, BaseBlock newBlock) {
+ @Override
+ public > boolean setBlock(BlockVector3 pt, T newBlock) throws WorldEditException {
if (mod.isDebug())
mod.getLog().debug("WorldEdit-Integration: BlockChange: "+pt.toString()+" BB: " + newBlock.toString());
Location loc = new Location(world, pt.getBlockX(), pt.getBlockY(), pt.getBlockZ());
- if (newBlock.getType() == 0) {
+ if (newBlock.getBlockType().getMaterial().isAir()) {
mod.getModel().removeState(loc.getBlock());
} else {
BlockState s = mod.getModel().getState(loc.getBlock());
@@ -54,5 +54,6 @@ public class EditSessionExtent extends AbstractLoggingExtent {
mod.getModel().setState(s);
}
+ return true;
}
}
diff --git a/src/main/java/de/jaschastarke/minecraft/limitedcreative/regions/GameModeFlag.java b/src/main/java/de/jaschastarke/minecraft/limitedcreative/regions/GameModeFlag.java
index e43686f..0332bfa 100644
--- a/src/main/java/de/jaschastarke/minecraft/limitedcreative/regions/GameModeFlag.java
+++ b/src/main/java/de/jaschastarke/minecraft/limitedcreative/regions/GameModeFlag.java
@@ -1,48 +1,47 @@
-package de.jaschastarke.minecraft.limitedcreative.regions;
-
-import org.bukkit.GameMode;
-import org.bukkit.command.CommandSender;
-
-import com.sk89q.worldguard.bukkit.WorldGuardPlugin;
-import com.sk89q.worldguard.protection.flags.Flag;
-import com.sk89q.worldguard.protection.flags.InvalidFlagFormat;
-import com.sk89q.worldguard.protection.flags.RegionGroup;
-
-/**
- * Well, that was an interesting idea, but it doesn't work.
- */
-public class GameModeFlag extends Flag {
- public GameModeFlag(String name, RegionGroup defaultGroup) {
- super(name, defaultGroup);
- }
-
- @Override
- public GameMode parseInput(WorldGuardPlugin plugin, CommandSender sender, String input) throws InvalidFlagFormat {
- input = input.trim();
- if (input.equalsIgnoreCase("creative")) {
- return GameMode.CREATIVE;
- } else if (input.equalsIgnoreCase("survival")) {
- return GameMode.SURVIVAL;
- } else if (input.equalsIgnoreCase("adventure")) {
- return GameMode.ADVENTURE;
- } else if (input.equalsIgnoreCase("none")) {
- return null;
- } else {
- throw new InvalidFlagFormat("Expected survival/creative/none but got '" + input + "'");
- }
- }
-
- @Override
- public GameMode unmarshal(Object o) {
- GameMode gm = null;
- if (o != null) {
- gm = GameMode.valueOf((String) o);
- }
- return gm;
- }
-
- @Override
- public Object marshal(GameMode o) {
- return o == null ? null : o.name();
- }
-}
+package de.jaschastarke.minecraft.limitedcreative.regions;
+
+import com.sk89q.worldguard.protection.flags.Flag;
+import com.sk89q.worldguard.protection.flags.FlagContext;
+import com.sk89q.worldguard.protection.flags.InvalidFlagFormat;
+import com.sk89q.worldguard.protection.flags.RegionGroup;
+import org.bukkit.GameMode;
+
+/**
+ * Well, that was an interesting idea, but it doesn't work.
+ */
+public class GameModeFlag extends Flag {
+ public GameModeFlag(String name, RegionGroup defaultGroup) {
+ super(name, defaultGroup);
+ }
+
+ @Override
+ public GameMode parseInput(FlagContext context) throws InvalidFlagFormat {
+ String input = context.getUserInput();
+ input = input.trim();
+ if (input.equalsIgnoreCase("creative")) {
+ return GameMode.CREATIVE;
+ } else if (input.equalsIgnoreCase("survival")) {
+ return GameMode.SURVIVAL;
+ } else if (input.equalsIgnoreCase("adventure")) {
+ return GameMode.ADVENTURE;
+ } else if (input.equalsIgnoreCase("none")) {
+ return null;
+ } else {
+ throw new InvalidFlagFormat("Expected survival/creative/none but got '" + input + "'");
+ }
+ }
+
+ @Override
+ public GameMode unmarshal(Object o) {
+ GameMode gm = null;
+ if (o != null) {
+ gm = GameMode.valueOf((String) o);
+ }
+ return gm;
+ }
+
+ @Override
+ public Object marshal(GameMode o) {
+ return o == null ? null : o.name();
+ }
+}
diff --git a/src/main/java/de/jaschastarke/minecraft/limitedcreative/regions/RegionsCommand.java b/src/main/java/de/jaschastarke/minecraft/limitedcreative/regions/RegionsCommand.java
index 7d385e9..733c51b 100644
--- a/src/main/java/de/jaschastarke/minecraft/limitedcreative/regions/RegionsCommand.java
+++ b/src/main/java/de/jaschastarke/minecraft/limitedcreative/regions/RegionsCommand.java
@@ -1,282 +1,280 @@
-package de.jaschastarke.minecraft.limitedcreative.regions;
-
-import java.util.ArrayList;
-import java.util.List;
-
-import org.apache.commons.lang.StringUtils;
-import org.bukkit.Bukkit;
-import org.bukkit.ChatColor;
-import org.bukkit.World;
-
-import com.sk89q.worldguard.bukkit.WorldGuardPlugin;
-import com.sk89q.worldguard.protection.ApplicableRegionSet;
-import com.sk89q.worldguard.protection.flags.Flag;
-import com.sk89q.worldguard.protection.flags.InvalidFlagFormat;
-import com.sk89q.worldguard.protection.managers.RegionManager;
-import com.sk89q.worldguard.protection.regions.GlobalProtectedRegion;
-import com.sk89q.worldguard.protection.regions.ProtectedRegion;
-
-import de.jaschastarke.LocaleString;
-import de.jaschastarke.bukkit.lib.chat.ChatFormattings;
-import de.jaschastarke.bukkit.lib.commands.BukkitCommand;
-import de.jaschastarke.bukkit.lib.commands.CommandContext;
-import de.jaschastarke.bukkit.lib.commands.CommandException;
-import de.jaschastarke.bukkit.lib.commands.HelpCommand;
-import de.jaschastarke.bukkit.lib.commands.ICommand;
-import de.jaschastarke.bukkit.lib.commands.IHelpDescribed;
-import de.jaschastarke.bukkit.lib.commands.MethodCommand;
-import de.jaschastarke.bukkit.lib.commands.MissingPermissionCommandException;
-import de.jaschastarke.bukkit.lib.commands.annotations.IsCommand;
-import de.jaschastarke.bukkit.lib.commands.annotations.Usages;
-import de.jaschastarke.bukkit.lib.commands.parser.DefinedParameterParser;
-import de.jaschastarke.bukkit.lib.commands.parser.TabCompletion;
-import de.jaschastarke.bukkit.lib.commands.parser.TabCompletion.Completer;
-import de.jaschastarke.bukkit.lib.commands.parser.TabCompletion.Context;
-import de.jaschastarke.maven.ArchiveDocComments;
-import de.jaschastarke.maven.PluginCommand;
-import de.jaschastarke.minecraft.lib.permissions.IAbstractPermission;
-import de.jaschastarke.minecraft.limitedcreative.ModRegions;
-import de.jaschastarke.minecraft.limitedcreative.regions.worldguard.FlagList;
-import de.jaschastarke.minecraft.limitedcreative.regions.worldguard.FlagValue;
-import de.jaschastarke.minecraft.limitedcreative.regions.worldguard.Region;
-import de.jaschastarke.modularize.ModuleEntry.ModuleState;
-
-/**
- * LimitedCreative-Region-Command: configure creative regions
- * @usage / - displays Regions-Command-Help
- * @permission limitedcreative.region
- */
-@ArchiveDocComments
-@PluginCommand
-public class RegionsCommand extends BukkitCommand implements IHelpDescribed {
- private final static String GLOBAL_REGION = "__global__";
- private ModRegions mod;
- private HelpCommand help;
- private WorldGuardPlugin wg;
-
- public RegionsCommand() {
- this.help = this.getDefaultHelpCommand();
- }
- public RegionsCommand(ModRegions mod) {
- super(mod.getPlugin());
- this.help = this.getDefaultHelpCommand();
- this.mod = mod;
- this.wg = (WorldGuardPlugin) mod.getPlugin().getServer().getPluginManager().getPlugin(WorldGuardIntegration.PLUGIN_NAME);
- fullfillTabCompletion();
- }
-
- @Override
- public String getName() {
- return "lcr";
- }
-
- @Override
- public String[] getAliases() {
- return new String[]{"/region"};
- }
-
- public boolean execute(final CommandContext context, final String[] args) throws MissingPermissionCommandException, CommandException {
- if (mod.getModuleEntry().getState() != ModuleState.ENABLED)
- throw new CommandException("Module " + mod.getName() + " is disabled");
- return super.execute(context, args);
- }
-
- /**
- * @internal has no effect, as not tested by any command handler
- * @see IHelpDescribed
- */
- @Override
- public IAbstractPermission[] getRequiredPermissions() {
- return new IAbstractPermission[]{RegionPermissions.REGION};
- }
- @Override
- public String[] getUsages() {
- return null;
- }
- @Override
- public CharSequence getDescription() {
- return new LocaleString("command.regions");
- }
- @Override
- public String getPackageName() {
- return mod.getPlugin().getName() + " - " + mod.getName();
- }
-
- /*@Override
- public IPermission getPermission(String subPerm) {
- if (subPerm.equals("region"))
- return RegionPermissions.REGION;
- else
- return RegionPermissions.REGION.getPermission(subPerm);
- }*/
-
- protected void fullfillTabCompletion() {
- for (ICommand cmd : handler.getCommands()) {
- if (cmd instanceof MethodCommand) {
- if (cmd.getName().equals("info")) {
- ((MethodCommand) cmd).getCompleter().add(TabCompletion.forUsageLine("[region]"));
- }
- for (TabCompletion c : ((MethodCommand) cmd).getCompleter()) {
- c.setCompleter("region", new RegionCompleter());
- }
- }
- }
- }
-
- private class RegionCompleter implements Completer {
- @Override
- public List get(Context context, String arg) {
- int idx = -1;
- String[] args = context.getHelper().getArguments();
- for (int i = 0; i < args.length; i++) {
- if (args[i].equals("world")) {
- idx = i;
- break;
- }
- }
- World w = context.getCommandContext().isPlayer() ? context.getCommandContext().getPlayer().getWorld() : null;
- if (idx > -1 && context.getArgument(idx) != null)
- w = Bukkit.getWorld(context.getArgument(idx));
- if (w != null) {
- RegionManager mgr = getWorldGuard().getRegionManager(w);
- if (mgr != null) {
- List hints = new ArrayList();
- for (String rId : mgr.getRegions().keySet()) {
- if (rId.toLowerCase().startsWith(arg.toLowerCase()))
- hints.add(rId);
- }
- return hints;
- }
- }
- return null;
- }
- }
-
- /**
- * Sets the Flag of a region to a new value. If no value given, the flag is removed.
- * -g sets the affected group of the flag, instead the flag (equivalent to using flag-group as flag-name)
- * -w world uses a world by name instead the world your in (required from console)
- */
- @IsCommand("flag")
- //@NeedsPermission("region") // not needed as the whole command requires permissions
- @Usages(" -g -w world [value]")
- public boolean setFlag(CommandContext context, String... args) throws CommandException, MissingPermissionCommandException {
- DefinedParameterParser params = new DefinedParameterParser(args, new String[]{"g"}, 2);
- if (params.getArgumentCount() < 2) {// doesn't count parameters
- help.execute(context, new String[]{"flag"});
- context.response(L("command.worldguard.available_flags") + FlagList.getStringListAvailableFlags(context.getSender()));
- return true;
- }
-
- World w = context.isPlayer() ? context.getPlayer().getWorld() : null;
- if (params.getParameter("-w") != null)
- w = mod.getPlugin().getServer().getWorld(params.getParameter("-w"));
- if (w == null)
- throw new CommandException(L("command.worldguard.world_not_found"));
-
- RegionManager mgr = getWorldGuard().getRegionManager(w);
- ProtectedRegion region = mgr.getRegion(params.getArgument(0));
- if (region == null && params.getArgument(0).equalsIgnoreCase("__global__")) {
- region = new GlobalProtectedRegion(params.getArgument(0));
- mgr.addRegion(region);
- }
- if (region == null)
- throw new CommandException(L("command.worldguard.region_not_found"));
-
- Region reg = mod.getRegionManager().world(w).region(region);
-
- Flag> flag = FlagList.getFlag(params.getArgument(1));
- if (flag == null) {
- String msg = L("command.worldguard.unknown_flag") + params.getArgument(1) + "\n"
- + L("command.worldguard.available_flags") + FlagList.getStringListAvailableFlags(context.getSender());
- throw new CommandException(msg);
- } else if (params.getFlags().contains("g")) {
- flag = flag.getRegionGroupFlag();
- if (flag == null) {
- String msg = L("command.worldguard.unknown_flag") + params.getArgument(1) + "-group\n"
- + L("command.worldguard.available_flags") + FlagList.getStringListAvailableFlags(context.getSender());
- throw new CommandException(msg);
- }
- }
-
- String value = params.getValue();
- try {
- if (value != null && value.trim().length() > 0) {
- reg.setFlag(flag, flag.parseInput(getWorldGuard(), context.getSender(), value));
- } else {
- reg.setFlag(flag, null);
- }
- } catch (InvalidFlagFormat e) {
- context.response(context.getFormatter().formatString(ChatFormattings.ERROR, e.getLocalizedMessage()));
- return true;
- }
-
- context.response(L("command.worldguard.flag_set", flag.getName()));
- return true;
- }
-
- @IsCommand("info")
- //@NeedsPermission("region")
- @Usages("[world] [region]")
- public boolean getInfo(CommandContext context, String... args) throws CommandException {
- DefinedParameterParser params = new DefinedParameterParser(args, new String[]{"s"}, 1);
-
- if (context.isPlayer()) {
- /*
- * WorldEdits intercepting Servers privates commandMap via Reflections realy sucks!
- * Just because they are to lazy to add all the lines commands to plugin.yml
- */
- String orgCmd = ("region info " + StringUtils.join(args)).trim();
- mod.getPlugin().getServer().dispatchCommand(context.getSender(), orgCmd);
- }
-
- World w = context.isPlayer() ? context.getPlayer().getWorld() : null;
- if (params.getArgumentCount() > 1)
- w = mod.getPlugin().getServer().getWorld(params.getArgument(0));
- if (w == null)
- throw new CommandException(L("command.worldguard.world_not_found"));
-
- ProtectedRegion region = null;
- if (params.getArgumentCount() == 0 && context.isPlayer()) {
- RegionManager mgr = getWorldGuard().getRegionManager(context.getPlayer().getWorld());
- ApplicableRegionSet set = mgr.getApplicableRegions(context.getPlayer().getLocation());
- if (set.size() > 0) {
- region = set.iterator().next();
- } else {
- region = getWorldGuard().getRegionManager(w).getRegion(GLOBAL_REGION);
- }
- } else {
- int rpc = params.getArgumentCount() > 1 ? 1 : 0;
- RegionManager mgr = getWorldGuard().getRegionManager(w);
- region = mgr.getRegion(params.getArgument(rpc));
- if (region == null && params.getArgument(rpc).equalsIgnoreCase(GLOBAL_REGION)) {
- region = new GlobalProtectedRegion(params.getArgument(rpc));
- mgr.addRegion(region);
- }
- }
- if (region == null)
- throw new CommandException(L("command.worldguard.region_not_found"));
-
- Region reg = mod.getRegionManager().world(w).region(region);
-
- StringBuilder list = new StringBuilder();
- for (FlagValue data : reg.getFlags()) {
- if (list.length() > 0)
- list.append(", ");
- list.append(data.getFlag().getName());
- list.append(": ");
- list.append(data.getValue().toString());
- }
-
- context.response(ChatColor.GREEN + L("command.worldguard.additional_flags") + list.toString());
- return true;
- }
-
- private String L(String msg, Object... args) {
- return mod.getPlugin().getLocale().trans(msg, args);
- }
-
- private WorldGuardPlugin getWorldGuard() {
- return wg;
- }
-}
+package de.jaschastarke.minecraft.limitedcreative.regions;
+
+import com.sk89q.worldedit.bukkit.BukkitAdapter;
+import com.sk89q.worldguard.WorldGuard;
+import com.sk89q.worldguard.bukkit.WorldGuardPlugin;
+import com.sk89q.worldguard.protection.ApplicableRegionSet;
+import com.sk89q.worldguard.protection.flags.Flag;
+import com.sk89q.worldguard.protection.flags.FlagContext;
+import com.sk89q.worldguard.protection.flags.InvalidFlagFormat;
+import com.sk89q.worldguard.protection.managers.RegionManager;
+import com.sk89q.worldguard.protection.regions.GlobalProtectedRegion;
+import com.sk89q.worldguard.protection.regions.ProtectedRegion;
+import com.sk89q.worldguard.protection.regions.RegionContainer;
+import de.jaschastarke.LocaleString;
+import de.jaschastarke.bukkit.lib.chat.ChatFormattings;
+import de.jaschastarke.bukkit.lib.commands.*;
+import de.jaschastarke.bukkit.lib.commands.annotations.IsCommand;
+import de.jaschastarke.bukkit.lib.commands.annotations.Usages;
+import de.jaschastarke.bukkit.lib.commands.parser.DefinedParameterParser;
+import de.jaschastarke.bukkit.lib.commands.parser.TabCompletion;
+import de.jaschastarke.bukkit.lib.commands.parser.TabCompletion.Completer;
+import de.jaschastarke.bukkit.lib.commands.parser.TabCompletion.Context;
+import de.jaschastarke.maven.ArchiveDocComments;
+import de.jaschastarke.maven.PluginCommand;
+import de.jaschastarke.minecraft.lib.permissions.IAbstractPermission;
+import de.jaschastarke.minecraft.limitedcreative.ModRegions;
+import de.jaschastarke.minecraft.limitedcreative.regions.worldguard.FlagList;
+import de.jaschastarke.minecraft.limitedcreative.regions.worldguard.FlagValue;
+import de.jaschastarke.minecraft.limitedcreative.regions.worldguard.Region;
+import de.jaschastarke.modularize.ModuleEntry.ModuleState;
+import org.apache.commons.lang.StringUtils;
+import org.bukkit.Bukkit;
+import org.bukkit.ChatColor;
+import org.bukkit.World;
+
+import java.util.ArrayList;
+import java.util.List;
+
+/**
+ * LimitedCreative-Region-Command: configure creative regions
+ * @usage / - displays Regions-Command-Help
+ * @permission limitedcreative.region
+ */
+@ArchiveDocComments
+@PluginCommand
+public class RegionsCommand extends BukkitCommand implements IHelpDescribed {
+ private final static String GLOBAL_REGION = "__global__";
+ private ModRegions mod;
+ private HelpCommand help;
+ private WorldGuardPlugin wg;
+
+ public RegionsCommand() {
+ this.help = this.getDefaultHelpCommand();
+ }
+ public RegionsCommand(ModRegions mod) {
+ super(mod.getPlugin());
+ this.help = this.getDefaultHelpCommand();
+ this.mod = mod;
+ this.wg = (WorldGuardPlugin) mod.getPlugin().getServer().getPluginManager().getPlugin(WorldGuardIntegration.PLUGIN_NAME);
+ fullfillTabCompletion();
+ }
+
+ @Override
+ public String getName() {
+ return "lcr";
+ }
+
+ @Override
+ public String[] getAliases() {
+ return new String[]{"/region"};
+ }
+
+ public boolean execute(final CommandContext context, final String[] args) throws MissingPermissionCommandException, CommandException {
+ if (mod.getModuleEntry().getState() != ModuleState.ENABLED)
+ throw new CommandException("Module " + mod.getName() + " is disabled");
+ return super.execute(context, args);
+ }
+
+ /**
+ * @internal has no effect, as not tested by any command handler
+ * @see IHelpDescribed
+ */
+ @Override
+ public IAbstractPermission[] getRequiredPermissions() {
+ return new IAbstractPermission[]{RegionPermissions.REGION};
+ }
+ @Override
+ public String[] getUsages() {
+ return null;
+ }
+ @Override
+ public CharSequence getDescription() {
+ return new LocaleString("command.regions");
+ }
+ @Override
+ public String getPackageName() {
+ return mod.getPlugin().getName() + " - " + mod.getName();
+ }
+
+ /*@Override
+ public IPermission getPermission(String subPerm) {
+ if (subPerm.equals("region"))
+ return RegionPermissions.REGION;
+ else
+ return RegionPermissions.REGION.getPermission(subPerm);
+ }*/
+
+ protected void fullfillTabCompletion() {
+ for (ICommand cmd : handler.getCommands()) {
+ if (cmd instanceof MethodCommand) {
+ if (cmd.getName().equals("info")) {
+ ((MethodCommand) cmd).getCompleter().add(TabCompletion.forUsageLine("[region]"));
+ }
+ for (TabCompletion c : ((MethodCommand) cmd).getCompleter()) {
+ c.setCompleter("region", new RegionCompleter());
+ }
+ }
+ }
+ }
+
+ private class RegionCompleter implements Completer {
+ @Override
+ public List get(Context context, String arg) {
+ int idx = -1;
+ String[] args = context.getHelper().getArguments();
+ for (int i = 0; i < args.length; i++) {
+ if (args[i].equals("world")) {
+ idx = i;
+ break;
+ }
+ }
+ World w = context.getCommandContext().isPlayer() ? context.getCommandContext().getPlayer().getWorld() : null;
+ if (idx > -1 && context.getArgument(idx) != null)
+ w = Bukkit.getWorld(context.getArgument(idx));
+ if (w != null) {
+ RegionContainer container = WorldGuard.getInstance().getPlatform().getRegionContainer();
+ RegionManager mgr = container.get(BukkitAdapter.adapt(w));
+ if (mgr != null) {
+ List hints = new ArrayList();
+ for (String rId : mgr.getRegions().keySet()) {
+ if (rId.toLowerCase().startsWith(arg.toLowerCase()))
+ hints.add(rId);
+ }
+ return hints;
+ }
+ }
+ return null;
+ }
+ }
+
+ /**
+ * Sets the Flag of a region to a new value. If no value given, the flag is removed.
+ * -g sets the affected group of the flag, instead the flag (equivalent to using flag-group as flag-name)
+ * -w world uses a world by name instead the world your in (required from console)
+ */
+ @IsCommand("flag")
+ //@NeedsPermission("region") // not needed as the whole command requires permissions
+ @Usages(" -g -w world [value]")
+ public boolean setFlag(CommandContext context, String... args) throws CommandException, MissingPermissionCommandException {
+ DefinedParameterParser params = new DefinedParameterParser(args, new String[]{"g"}, 2);
+ if (params.getArgumentCount() < 2) {// doesn't count parameters
+ help.execute(context, new String[]{"flag"});
+ context.response(L("command.worldguard.available_flags") + FlagList.getStringListAvailableFlags(context.getSender()));
+ return true;
+ }
+
+ World w = context.isPlayer() ? context.getPlayer().getWorld() : null;
+ if (params.getParameter("-w") != null)
+ w = mod.getPlugin().getServer().getWorld(params.getParameter("-w"));
+ if (w == null)
+ throw new CommandException(L("command.worldguard.world_not_found"));
+
+ RegionContainer container = WorldGuard.getInstance().getPlatform().getRegionContainer();
+ RegionManager mgr = container.get(BukkitAdapter.adapt(w));
+ ProtectedRegion region = mgr.getRegion(params.getArgument(0));
+ if (region == null && params.getArgument(0).equalsIgnoreCase("__global__")) {
+ region = new GlobalProtectedRegion(params.getArgument(0));
+ mgr.addRegion(region);
+ }
+ if (region == null)
+ throw new CommandException(L("command.worldguard.region_not_found"));
+
+ Region reg = mod.getRegionManager().world(w).region(region);
+
+ Flag> flag = FlagList.getFlag(params.getArgument(1));
+ if (flag == null) {
+ String msg = L("command.worldguard.unknown_flag") + params.getArgument(1) + "\n"
+ + L("command.worldguard.available_flags") + FlagList.getStringListAvailableFlags(context.getSender());
+ throw new CommandException(msg);
+ } else if (params.getFlags().contains("g")) {
+ flag = flag.getRegionGroupFlag();
+ if (flag == null) {
+ String msg = L("command.worldguard.unknown_flag") + params.getArgument(1) + "-group\n"
+ + L("command.worldguard.available_flags") + FlagList.getStringListAvailableFlags(context.getSender());
+ throw new CommandException(msg);
+ }
+ }
+
+ String value = params.getValue();
+ try {
+ if (value != null && value.trim().length() > 0) {
+ reg.setFlag(flag, flag.parseInput(FlagContext.create().setInput(value).build()));
+ } else {
+ reg.setFlag(flag, null);
+ }
+ } catch (InvalidFlagFormat e) {
+ context.response(context.getFormatter().formatString(ChatFormattings.ERROR, e.getLocalizedMessage()));
+ return true;
+ }
+
+ context.response(L("command.worldguard.flag_set", flag.getName()));
+ return true;
+ }
+
+ @IsCommand("info")
+ //@NeedsPermission("region")
+ @Usages("[world] [region]")
+ public boolean getInfo(CommandContext context, String... args) throws CommandException {
+ DefinedParameterParser params = new DefinedParameterParser(args, new String[]{"s"}, 1);
+
+ if (context.isPlayer()) {
+ /*
+ * WorldEdits intercepting Servers privates commandMap via Reflections realy sucks!
+ * Just because they are to lazy to add all the lines commands to plugin.yml
+ */
+ String orgCmd = ("region info " + StringUtils.join(args)).trim();
+ mod.getPlugin().getServer().dispatchCommand(context.getSender(), orgCmd);
+ }
+
+ World w = context.isPlayer() ? context.getPlayer().getWorld() : null;
+ if (params.getArgumentCount() > 1)
+ w = mod.getPlugin().getServer().getWorld(params.getArgument(0));
+ if (w == null)
+ throw new CommandException(L("command.worldguard.world_not_found"));
+
+ ProtectedRegion region = null;
+ RegionContainer container = WorldGuard.getInstance().getPlatform().getRegionContainer();
+ if (params.getArgumentCount() == 0 && context.isPlayer()) {
+ RegionManager mgr = container.get(BukkitAdapter.adapt(context.getPlayer().getWorld()));
+ ApplicableRegionSet set = mgr.getApplicableRegions(BukkitAdapter.asBlockVector(context.getPlayer().getLocation()));
+ if (set.size() > 0) {
+ region = set.iterator().next();
+ } else {
+ region = container.get(BukkitAdapter.adapt(w)).getRegion(GLOBAL_REGION);
+ }
+ } else {
+ int rpc = params.getArgumentCount() > 1 ? 1 : 0;
+ RegionManager mgr = container.get(BukkitAdapter.adapt(w));
+ region = mgr.getRegion(params.getArgument(rpc));
+ if (region == null && params.getArgument(rpc).equalsIgnoreCase(GLOBAL_REGION)) {
+ region = new GlobalProtectedRegion(params.getArgument(rpc));
+ mgr.addRegion(region);
+ }
+ }
+ if (region == null)
+ throw new CommandException(L("command.worldguard.region_not_found"));
+
+ Region reg = mod.getRegionManager().world(w).region(region);
+
+ StringBuilder list = new StringBuilder();
+ for (FlagValue data : reg.getFlags()) {
+ if (list.length() > 0)
+ list.append(", ");
+ list.append(data.getFlag().getName());
+ list.append(": ");
+ list.append(data.getValue().toString());
+ }
+
+ context.response(ChatColor.GREEN + L("command.worldguard.additional_flags") + list.toString());
+ return true;
+ }
+
+ private String L(String msg, Object... args) {
+ return mod.getPlugin().getLocale().trans(msg, args);
+ }
+
+ private WorldGuardPlugin getWorldGuard() {
+ return wg;
+ }
+}
diff --git a/src/main/java/de/jaschastarke/minecraft/limitedcreative/regions/worldguard/CustomRegionManager.java b/src/main/java/de/jaschastarke/minecraft/limitedcreative/regions/worldguard/CustomRegionManager.java
index ba15f6f..92cfe25 100644
--- a/src/main/java/de/jaschastarke/minecraft/limitedcreative/regions/worldguard/CustomRegionManager.java
+++ b/src/main/java/de/jaschastarke/minecraft/limitedcreative/regions/worldguard/CustomRegionManager.java
@@ -1,192 +1,189 @@
-/*
- * Limited Creative - (Bukkit Plugin)
- * Copyright (C) 2012 jascha@ja-s.de
- *
- * This program is free software: you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation, either version 3 of the License, or
- * (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program. If not, see .
- */
-package de.jaschastarke.minecraft.limitedcreative.regions.worldguard;
-
-import java.io.File;
-import java.io.IOException;
-import java.util.ArrayList;
-import java.util.Arrays;
-import java.util.HashMap;
-import java.util.List;
-import java.util.Map;
-
-import org.bukkit.Location;
-import org.bukkit.World;
-import org.bukkit.block.Block;
-import org.bukkit.configuration.ConfigurationSection;
-import org.bukkit.configuration.file.YamlConfiguration;
-import org.bukkit.entity.Player;
-
-import com.sk89q.worldguard.bukkit.BukkitUtil;
-import com.sk89q.worldguard.bukkit.WorldGuardPlugin;
-import com.sk89q.worldguard.protection.flags.Flag;
-import com.sk89q.worldguard.protection.managers.RegionManager;
-import com.sk89q.worldguard.protection.regions.ProtectedRegion;
-
-import de.jaschastarke.minecraft.limitedcreative.ModRegions;
-import de.jaschastarke.minecraft.limitedcreative.regions.WorldGuardIntegration;
-import de.jaschastarke.utils.StringUtil;
-
-public class CustomRegionManager {
- protected YamlConfiguration c;
- protected File file;
- private Map worlds = new HashMap();
- private ModRegions mod;
- public CustomRegionManager(File file, ModRegions mod) {
- this.file = file;
- this.mod = mod;
- c = YamlConfiguration.loadConfiguration(file);
- }
-
-
- public CWorld world(World w) {
- if (worlds.containsKey(w)) {
- return worlds.get(w);
- } else {
- CWorld r = new CWorld(w);
- worlds.put(w, r);
- return r;
- }
- }
-
- public class CWorld {
- private World world;
- private ConfigurationSection wc = null;
- public CWorld(World w) {
- world = w;
- }
- public CustomRegionManager getManager() {
- return CustomRegionManager.this;
- }
- private Map regions = new HashMap();
- public Region region(ProtectedRegion pr) {
- if (regions.containsKey(pr)) {
- return regions.get(pr);
- } else {
- Region r = new Region(this, pr);
- regions.put(pr, r);
- return r;
- }
- }
- public World getWorld() {
- return world;
- }
- public ProtectedRegion getGlobalRegion() {
- return getWGManager(world).getRegion("__global__");
- }
-
- @SuppressWarnings("unchecked")
- public void storeFlag(Region region, Flag flag, Object value) {
- if (wc == null) {
- if (c.contains(world.getName().toLowerCase()))
- wc = c.getConfigurationSection(world.getName().toLowerCase());
- else
- wc = c.createSection(world.getName().toLowerCase());
- }
-
- ConfigurationSection rs;
- if (wc.contains(region.getProtectedRegion().getId()))
- rs = wc.getConfigurationSection(region.getProtectedRegion().getId());
- else
- rs = wc.createSection(region.getProtectedRegion().getId());
-
- ConfigurationSection fs = rs.contains("flags") ? rs.getConfigurationSection("flags") : rs.createSection("flags");
-
- if (value == null) {
- fs.set(flag.getName(), null);
- } else {
- fs.set(flag.getName(), flag.marshal((V) value));
- }
-
- try {
- c.save(file);
- } catch (IOException e) {
- e.printStackTrace();
- }
- }
- public List getFlags(Region region) {
- List list = new ArrayList();
-
- if (c.contains(world.getName().toLowerCase())) {
- ConfigurationSection wc = c.getConfigurationSection(world.getName().toLowerCase());
- if (wc.contains(region.getProtectedRegion().getId())) {
- ConfigurationSection rs = wc.getConfigurationSection(region.getProtectedRegion().getId());
- if (rs.contains("flags")) {
- ConfigurationSection fs = rs.getConfigurationSection("flags");
- for (Map.Entry data : fs.getValues(false).entrySet()) {
- Flag> flag = null;
- if (data.getKey().endsWith("-group")) {
- flag = FlagList.getFlag(data.getKey().substring(0, data.getKey().length() - 6));
- if (flag != null)
- flag = flag.getRegionGroupFlag();
- } else {
- flag = FlagList.getFlag(data.getKey());
- }
- if (flag != null) { // the flag doesn't exists anymore. just ignore it without error
- Object value = flag.unmarshal(data.getValue());
- list.add(new FlagValue(flag, value));
- } else {
- if (mod.isDebug())
- mod.getLog().debug("Couldn't load unknown Flag: "+data.getKey());
- }
- }
- }
- }
- }
- return list;
- }
-
- public WorldGuardPlugin getWorldGuard() {
- return CustomRegionManager.this.getWorldGuard();
- }
- }
-
- private WorldGuardPlugin getWorldGuard() {
- return ((WorldGuardPlugin) mod.getPlugin().getServer().getPluginManager().getPlugin(WorldGuardIntegration.PLUGIN_NAME));
- }
-
- public RegionManager getWGManager(World world) {
- return getWorldGuard().getRegionManager(world);
- }
-
- public String getRegionsHash(Location loc) {
- StringBuilder hash = new StringBuilder(loc.getWorld().getName());
- List idlist = getWGManager(loc.getWorld()).getApplicableRegionsIDs(BukkitUtil.toVector(loc));
- if (idlist.size() > 0) {
- hash.append("#");
- String[] ids = idlist.toArray(new String[idlist.size()]);
- if (ids.length > 1) {
- Arrays.sort(ids);
- }
- hash.append(StringUtil.join(ids, ","));
- }
- return hash.toString();
- }
-
- public ApplicableRegions getRegionSet(Location loc) {
- return new ApplicableRegions(getWGManager(loc.getWorld()).getApplicableRegions(loc), this.world(loc.getWorld()));
- }
-
- public ApplicableRegions getRegionSet(Block block) {
- return getRegionSet(block.getLocation());
- }
-
- public boolean isDiffrentRegion(Player player, Location loc) {
- return !getRegionsHash(loc).equals(mod.getPlayerData(player).getHash());
- }
-}
+/*
+ * Limited Creative - (Bukkit Plugin)
+ * Copyright (C) 2012 jascha@ja-s.de
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program. If not, see .
+ */
+package de.jaschastarke.minecraft.limitedcreative.regions.worldguard;
+
+import com.sk89q.worldedit.bukkit.BukkitAdapter;
+import com.sk89q.worldguard.WorldGuard;
+import com.sk89q.worldguard.bukkit.WorldGuardPlugin;
+import com.sk89q.worldguard.protection.flags.Flag;
+import com.sk89q.worldguard.protection.managers.RegionManager;
+import com.sk89q.worldguard.protection.regions.ProtectedRegion;
+import com.sk89q.worldguard.protection.regions.RegionContainer;
+import de.jaschastarke.minecraft.limitedcreative.ModRegions;
+import de.jaschastarke.minecraft.limitedcreative.regions.WorldGuardIntegration;
+import de.jaschastarke.utils.StringUtil;
+import org.bukkit.Location;
+import org.bukkit.World;
+import org.bukkit.block.Block;
+import org.bukkit.configuration.ConfigurationSection;
+import org.bukkit.configuration.file.YamlConfiguration;
+import org.bukkit.entity.Player;
+
+import java.io.File;
+import java.io.IOException;
+import java.util.*;
+
+public class CustomRegionManager {
+ protected YamlConfiguration c;
+ protected File file;
+ private Map worlds = new HashMap();
+ private ModRegions mod;
+ public CustomRegionManager(File file, ModRegions mod) {
+ this.file = file;
+ this.mod = mod;
+ c = YamlConfiguration.loadConfiguration(file);
+ }
+
+
+ public CWorld world(World w) {
+ if (worlds.containsKey(w)) {
+ return worlds.get(w);
+ } else {
+ CWorld r = new CWorld(w);
+ worlds.put(w, r);
+ return r;
+ }
+ }
+
+ public class CWorld {
+ private World world;
+ private ConfigurationSection wc = null;
+ public CWorld(World w) {
+ world = w;
+ }
+ public CustomRegionManager getManager() {
+ return CustomRegionManager.this;
+ }
+ private Map regions = new HashMap();
+ public Region region(ProtectedRegion pr) {
+ if (regions.containsKey(pr)) {
+ return regions.get(pr);
+ } else {
+ Region r = new Region(this, pr);
+ regions.put(pr, r);
+ return r;
+ }
+ }
+ public World getWorld() {
+ return world;
+ }
+ public ProtectedRegion getGlobalRegion() {
+ return getWGManager(world).getRegion("__global__");
+ }
+
+ @SuppressWarnings("unchecked")
+ public void storeFlag(Region region, Flag flag, Object value) {
+ if (wc == null) {
+ if (c.contains(world.getName().toLowerCase()))
+ wc = c.getConfigurationSection(world.getName().toLowerCase());
+ else
+ wc = c.createSection(world.getName().toLowerCase());
+ }
+
+ ConfigurationSection rs;
+ if (wc.contains(region.getProtectedRegion().getId()))
+ rs = wc.getConfigurationSection(region.getProtectedRegion().getId());
+ else
+ rs = wc.createSection(region.getProtectedRegion().getId());
+
+ ConfigurationSection fs = rs.contains("flags") ? rs.getConfigurationSection("flags") : rs.createSection("flags");
+
+ if (value == null) {
+ fs.set(flag.getName(), null);
+ } else {
+ fs.set(flag.getName(), flag.marshal((V) value));
+ }
+
+ try {
+ c.save(file);
+ } catch (IOException e) {
+ e.printStackTrace();
+ }
+ }
+ public List getFlags(Region region) {
+ List list = new ArrayList();
+
+ if (c.contains(world.getName().toLowerCase())) {
+ ConfigurationSection wc = c.getConfigurationSection(world.getName().toLowerCase());
+ if (wc.contains(region.getProtectedRegion().getId())) {
+ ConfigurationSection rs = wc.getConfigurationSection(region.getProtectedRegion().getId());
+ if (rs.contains("flags")) {
+ ConfigurationSection fs = rs.getConfigurationSection("flags");
+ for (Map.Entry data : fs.getValues(false).entrySet()) {
+ Flag> flag = null;
+ if (data.getKey().endsWith("-group")) {
+ flag = FlagList.getFlag(data.getKey().substring(0, data.getKey().length() - 6));
+ if (flag != null)
+ flag = flag.getRegionGroupFlag();
+ } else {
+ flag = FlagList.getFlag(data.getKey());
+ }
+ if (flag != null) { // the flag doesn't exists anymore. just ignore it without error
+ Object value = flag.unmarshal(data.getValue());
+ list.add(new FlagValue(flag, value));
+ } else {
+ if (mod.isDebug())
+ mod.getLog().debug("Couldn't load unknown Flag: "+data.getKey());
+ }
+ }
+ }
+ }
+ }
+ return list;
+ }
+
+ public WorldGuardPlugin getWorldGuard() {
+ return CustomRegionManager.this.getWorldGuard();
+ }
+ }
+
+ private WorldGuardPlugin getWorldGuard() {
+ return ((WorldGuardPlugin) mod.getPlugin().getServer().getPluginManager().getPlugin(WorldGuardIntegration.PLUGIN_NAME));
+ }
+
+ public RegionManager getWGManager(World world) {
+ RegionContainer container = WorldGuard.getInstance().getPlatform().getRegionContainer();
+ return container.get(BukkitAdapter.adapt(world));
+ }
+
+ public String getRegionsHash(Location loc) {
+ StringBuilder hash = new StringBuilder(loc.getWorld().getName());
+ List idlist = getWGManager(loc.getWorld()).getApplicableRegionsIDs(BukkitAdapter.asBlockVector(loc));
+ if (idlist.size() > 0) {
+ hash.append("#");
+ String[] ids = idlist.toArray(new String[idlist.size()]);
+ if (ids.length > 1) {
+ Arrays.sort(ids);
+ }
+ hash.append(StringUtil.join(ids, ","));
+ }
+ return hash.toString();
+ }
+
+ public ApplicableRegions getRegionSet(Location loc) {
+ return new ApplicableRegions(getWGManager(loc.getWorld()).getApplicableRegions(BukkitAdapter.asBlockVector(loc)), this.world(loc.getWorld()));
+ }
+
+ public ApplicableRegions getRegionSet(Block block) {
+ return getRegionSet(block.getLocation());
+ }
+
+ public boolean isDiffrentRegion(Player player, Location loc) {
+ return !getRegionsHash(loc).equals(mod.getPlayerData(player).getHash());
+ }
+}