Updated WorldEdit and WorldGuard to 7.0.0

It doesn't work without them atm because it tries to load a class from them
This commit is contained in:
Norbi Peti 2019-08-28 23:29:40 +02:00
parent 24ed3393d3
commit 14bdf0ebe0
No known key found for this signature in database
GPG key ID: DBA4C4549A927E56
6 changed files with 1093 additions and 1089 deletions

542
pom.xml
View file

@ -1,268 +1,274 @@
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"> <project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion> <modelVersion>4.0.0</modelVersion>
<groupId>de.jaschastarke</groupId> <groupId>de.jaschastarke</groupId>
<artifactId>LimitedCreative</artifactId> <artifactId>LimitedCreative</artifactId>
<name>LimitedCreative</name> <name>LimitedCreative</name>
<version>2.3-SNAPSHOT</version> <version>2.3-SNAPSHOT</version>
<url>https://github.com/possi/LimitedCreative</url> <url>https://github.com/possi/LimitedCreative</url>
<properties> <properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding> <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<plib.version>1.4-SNAPSHOT</plib.version> <plib.version>1.4-SNAPSHOT</plib.version>
<bukkit.version>1.12.2-R0.1-SNAPSHOT</bukkit.version> <bukkit.version>1.12.2-R0.1-SNAPSHOT</bukkit.version>
</properties> </properties>
<scm> <scm>
<connection>scm:git:git://github.com/possi/LimitedCreative.git</connection> <connection>scm:git:git://github.com/possi/LimitedCreative.git</connection>
<developerConnection>scm:git:git@github.com:possi/LimitedCreative.git</developerConnection> <developerConnection>scm:git:git@github.com:possi/LimitedCreative.git</developerConnection>
<url>https://github.com/possi/LimitedCreative/tree/plib</url> <url>https://github.com/possi/LimitedCreative/tree/plib</url>
</scm> </scm>
<distributionManagement> <distributionManagement>
<repository> <repository>
<id>de-jas-repo</id> <id>de-jas-repo</id>
<url>scp://repo@ja-s.de/var/customers/webs/repo/mvn</url> <url>scp://repo@ja-s.de/var/customers/webs/repo/mvn</url>
</repository> </repository>
</distributionManagement> </distributionManagement>
<ciManagement> <ciManagement>
<system>jenkins</system> <system>jenkins</system>
<url>http://ci.ja-s.de:8080/</url> <url>http://ci.ja-s.de:8080/</url>
</ciManagement> </ciManagement>
<issueManagement> <issueManagement>
<system>BukkitDev</system> <system>BukkitDev</system>
<url>http://dev.bukkit.org/server-mods/limited-creative/tickets/</url> <url>http://dev.bukkit.org/server-mods/limited-creative/tickets/</url>
</issueManagement> </issueManagement>
<repositories> <repositories>
<!-- Possible public Maven Repository, containing LimitedCreative builds and other dependencies without own rep. <!-- Possible public Maven Repository, containing LimitedCreative builds and other dependencies without own rep.
like AuthMe, etc. like AuthMe, etc.
Supports http only --> Supports http only -->
<repository> <repository>
<id>de-jas-rep</id> <id>de-jas-rep</id>
<url>http://repo.ja-s.de/mvn</url> <url>http://repo.ja-s.de/mvn</url>
</repository> </repository>
<!-- Official (Craft-)Bukkit repository --> <!-- Official (Craft-)Bukkit repository -->
<repository> <repository>
<id>spigot-repo</id> <id>spigot-repo</id>
<url>https://hub.spigotmc.org/nexus/content/repositories/snapshots/</url> <url>https://hub.spigotmc.org/nexus/content/repositories/snapshots/</url>
</repository> </repository>
<!-- Official WorldGuard and WorldEdit repository --> <!-- Official WorldGuard and WorldEdit repository -->
<repository> <repository>
<id>sk89q-mvn2</id> <id>sk89q-mvn2</id>
<url>http://maven.sk89q.com/repo</url> <url>https://maven.enginehub.org/repo/</url>
</repository> </repository>
<!-- Official Multiverse repository --> <!-- Official Multiverse repository -->
<repository> <repository>
<id>onarandombox</id> <id>onarandombox</id>
<url>http://repo.onarandombox.com/content/groups/public</url> <url>http://repo.onarandombox.com/content/groups/public</url>
</repository> </repository>
<!-- Official xAuth repository; it is no good! we keep our own dep-files of it - -> <!-- Official xAuth repository; it is no good! we keep our own dep-files of it - ->
<repository> <repository>
<id>luricos.de-repo</id> <id>luricos.de-repo</id>
<url>http://repo.luricos.de/bukkit-plugins/</url> <url>http://repo.luricos.de/bukkit-plugins/</url>
</repository><!- - --> </repository><!- - -->
<!-- Official LogBlock repository --> <!-- Official LogBlock repository -->
<repository> <repository>
<id>md5</id> <id>md5</id>
<url>http://repo.md-5.net/content/groups/public/</url> <url>http://repo.md-5.net/content/groups/public/</url>
</repository> </repository>
</repositories> </repositories>
<pluginRepositories> <pluginRepositories>
<pluginRepository> <pluginRepository>
<id>de-jas-rep</id> <id>de-jas-rep</id>
<url>http://repo.ja-s.de/mvn</url> <url>http://repo.ja-s.de/mvn</url>
</pluginRepository> </pluginRepository>
</pluginRepositories> </pluginRepositories>
<dependencies> <dependencies>
<dependency> <dependency>
<groupId>de.jaschastarke</groupId> <groupId>de.jaschastarke</groupId>
<artifactId>plib</artifactId> <artifactId>plib</artifactId>
<version>${plib.version}</version> <version>${plib.version}</version>
</dependency> </dependency>
<dependency> <dependency>
<!-- http://dl.bukkit.org/ --> <!-- http://dl.bukkit.org/ -->
<groupId>org.bukkit</groupId> <groupId>org.bukkit</groupId>
<artifactId>bukkit</artifactId> <artifactId>bukkit</artifactId>
<version>${bukkit.version}</version> <version>${bukkit.version}</version>
</dependency> </dependency>
<dependency> <dependency>
<!-- http://dev.bukkit.org/server-mods/worldguard/ --> <!-- http://dl.bukkit.org/ -->
<groupId>com.sk89q</groupId> <groupId>org.bukkit.</groupId> <!-- Needed for WE integration -->
<artifactId>worldguard</artifactId> <artifactId>bukkit</artifactId>
<version>6.1</version> <version>1.14.4-R0.1-SNAPSHOT</version>
</dependency> </dependency>
<dependency> <dependency>
<!-- http://dev.bukkit.org/server-mods/worldguard/ --> <!-- http://dev.bukkit.org/server-mods/worldguard/ -->
<groupId>com.sk89q</groupId> <groupId>com.sk89q.worldguard</groupId>
<artifactId>worldedit</artifactId> <artifactId>worldguard-bukkit</artifactId>
<version>6.0.0-SNAPSHOT</version> <version>7.0.0</version>
</dependency> </dependency>
<dependency> <dependency>
<!-- http://dev.bukkit.org/server-mods/authme-reloaded/ --> <!-- http://dev.bukkit.org/server-mods/worldguard/ -->
<groupId>uk.org.whoami</groupId> <groupId>com.sk89q.worldedit</groupId>
<artifactId>authme</artifactId> <artifactId>worldedit-bukkit</artifactId>
<version>2.9.5</version> <version>7.0.0</version>
</dependency> </dependency>
<dependency> <dependency>
<!-- http://dev.bukkit.org/server-mods/authme-reloaded/ --> <!-- http://dev.bukkit.org/server-mods/authme-reloaded/ -->
<groupId>fr.xephi</groupId> <groupId>uk.org.whoami</groupId>
<artifactId>authme</artifactId> <artifactId>authme</artifactId>
<version>3.0</version> <version>2.9.5</version>
</dependency> </dependency>
<dependency> <dependency>
<!-- http://dev.bukkit.org/server-mods/multiverse-core/ --> <!-- http://dev.bukkit.org/server-mods/authme-reloaded/ -->
<groupId>com.onarandombox.multiversecore</groupId> <groupId>fr.xephi</groupId>
<artifactId>Multiverse-Core</artifactId> <artifactId>authme</artifactId>
<version>2.4</version> <version>3.0</version>
</dependency> </dependency>
<dependency> <dependency>
<!-- http://dev.bukkit.org/bukkit-plugins/multiworld-v-2-0/ --> <!-- http://dev.bukkit.org/server-mods/multiverse-core/ -->
<groupId>multiworld</groupId> <groupId>com.onarandombox.multiversecore</groupId>
<artifactId>multiworld</artifactId> <artifactId>Multiverse-Core</artifactId>
<version>4.7.2</version> <version>2.4</version>
</dependency> </dependency>
<dependency> <dependency>
<!-- http://dev.bukkit.org/server-mods/xauth/ --> <!-- http://dev.bukkit.org/bukkit-plugins/multiworld-v-2-0/ -->
<groupId>com.cypherx</groupId> <groupId>multiworld</groupId>
<artifactId>xauth</artifactId> <artifactId>multiworld</artifactId>
<version>2.0.26</version> <version>4.7.2</version>
</dependency> </dependency>
<dependency> <dependency>
<!-- http://dev.bukkit.org/bukkit-plugins/coreprotect/ --> <!-- http://dev.bukkit.org/server-mods/xauth/ -->
<groupId>net.coreprotect</groupId> <groupId>com.cypherx</groupId>
<artifactId>coreprotect</artifactId> <artifactId>xauth</artifactId>
<version>2.0.8</version> <version>2.0.26</version>
</dependency> </dependency>
<!-- https://mvnrepository.com/artifact/org.avaje/ebean --> <dependency>
<dependency> <!-- http://dev.bukkit.org/bukkit-plugins/coreprotect/ -->
<groupId>org.avaje</groupId> <groupId>net.coreprotect</groupId>
<artifactId>ebean</artifactId> <artifactId>coreprotect</artifactId>
<version>2.7.3</version> <version>2.0.8</version>
</dependency> </dependency>
</dependencies> <!-- https://mvnrepository.com/artifact/org.avaje/ebean -->
<dependency>
<build> <groupId>org.avaje</groupId>
<sourceDirectory>${basedir}/src/main/java</sourceDirectory> <artifactId>ebean</artifactId>
<finalName>${project.artifactId}</finalName> <version>2.7.3</version>
</dependency>
<plugins> </dependencies>
<plugin>
<groupId>org.apache.maven.plugins</groupId> <build>
<artifactId>maven-compiler-plugin</artifactId> <sourceDirectory>${basedir}/src/main/java</sourceDirectory>
<version>2.3.2</version> <finalName>${project.artifactId}</finalName>
<configuration>
<source>1.6</source> <plugins>
<target>1.6</target> <plugin>
<annotationProcessors> <groupId>org.apache.maven.plugins</groupId>
<!-- Needed to fetch DocComments from Source --> <artifactId>maven-compiler-plugin</artifactId>
<annotationProcessor>de.jaschastarke.maven.AnnotationProcessor</annotationProcessor> <version>2.3.2</version>
</annotationProcessors> <configuration>
</configuration> <source>1.6</source>
</plugin> <target>1.6</target>
<plugin> <annotationProcessors>
<groupId>de.jaschastarke</groupId> <!-- Needed to fetch DocComments from Source -->
<artifactId>plib</artifactId> <annotationProcessor>de.jaschastarke.maven.AnnotationProcessor</annotationProcessor>
<version>${plib.version}</version> </annotationProcessors>
<executions> </configuration>
<execution> </plugin>
<phase>compile</phase> <plugin>
<goals> <groupId>de.jaschastarke</groupId>
<goal>pluginyaml</goal> <artifactId>plib</artifactId>
</goals> <version>${plib.version}</version>
<configuration> <executions>
<!-- plugin.yml --> <execution>
<mainClass>de.jaschastarke.minecraft.limitedcreative.LimitedCreative</mainClass> <phase>compile</phase>
<softdepend> <goals>
<param>WorldGuard</param> <goal>pluginyaml</goal>
<param>WorldEdit</param> </goals>
<param>Multiverse-Core</param> <configuration>
<param>Multiworld</param> <!-- plugin.yml -->
<param>xAuth</param> <mainClass>de.jaschastarke.minecraft.limitedcreative.LimitedCreative</mainClass>
<param>AuthMe</param> <softdepend>
<param>MultiInv</param> <param>WorldGuard</param>
<param>Multiverse-Inventories</param> <param>WorldEdit</param>
<param>Vault</param> <param>Multiverse-Core</param>
<param>CoreProtect</param> <param>Multiworld</param>
</softdepend> <param>xAuth</param>
<custom> <param>AuthMe</param>
<dev-url>http://dev.bukkit.org/server-mods/limited-creative/</dev-url> <param>MultiInv</param>
</custom> <param>Multiverse-Inventories</param>
</configuration> <param>Vault</param>
</execution> <param>CoreProtect</param>
</executions> </softdepend>
</plugin> <custom>
<plugin> <dev-url>http://dev.bukkit.org/server-mods/limited-creative/</dev-url>
<groupId>org.apache.maven.plugins</groupId> </custom>
<artifactId>maven-shade-plugin</artifactId> </configuration>
<version>2.0</version> </execution>
<executions> </executions>
<execution> </plugin>
<phase>package</phase> <plugin>
<goals> <groupId>org.apache.maven.plugins</groupId>
<goal>shade</goal> <artifactId>maven-shade-plugin</artifactId>
</goals> <version>2.0</version>
<configuration> <executions>
<createDependencyReducedPom>false</createDependencyReducedPom> <execution>
<artifactSet> <phase>package</phase>
<includes> <goals>
<include>de.jaschastarke:plib</include> <goal>shade</goal>
</includes> </goals>
</artifactSet> <configuration>
<filters> <createDependencyReducedPom>false</createDependencyReducedPom>
<filter> <artifactSet>
<artifact>de.jaschastarke:plib</artifact> <includes>
<excludes> <include>de.jaschastarke:plib</include>
<exclude>de/jaschastarke/maven/**</exclude> </includes>
<exclude>de/jaschastarke/bukkit/maven/**</exclude> </artifactSet>
</excludes> <filters>
</filter> <filter>
</filters> <artifact>de.jaschastarke:plib</artifact>
</configuration> <excludes>
</execution> <exclude>de/jaschastarke/maven/**</exclude>
</executions> <exclude>de/jaschastarke/bukkit/maven/**</exclude>
</plugin> </excludes>
</plugins> </filter>
</filters>
<pluginManagement> </configuration>
<plugins> </execution>
<!--This plugin's configuration is used to store Eclipse m2e settings only. It has no influence on the Maven build itself.--> </executions>
<plugin> </plugin>
<groupId>org.eclipse.m2e</groupId> </plugins>
<artifactId>lifecycle-mapping</artifactId>
<version>1.0.0</version> <pluginManagement>
<configuration> <plugins>
<lifecycleMappingMetadata> <!--This plugin's configuration is used to store Eclipse m2e settings only. It has no influence on the Maven build itself.-->
<pluginExecutions> <plugin>
<pluginExecution> <groupId>org.eclipse.m2e</groupId>
<pluginExecutionFilter> <artifactId>lifecycle-mapping</artifactId>
<groupId>de.jaschastarke</groupId> <version>1.0.0</version>
<artifactId>plib</artifactId> <configuration>
<versionRange> <lifecycleMappingMetadata>
[0.1-SNAPSHOT,) <pluginExecutions>
</versionRange> <pluginExecution>
<goals> <pluginExecutionFilter>
<goal>pluginyaml</goal> <groupId>de.jaschastarke</groupId>
</goals> <artifactId>plib</artifactId>
</pluginExecutionFilter> <versionRange>
<action> [0.1-SNAPSHOT,)
<ignore></ignore> </versionRange>
</action> <goals>
</pluginExecution> <goal>pluginyaml</goal>
</pluginExecutions> </goals>
</lifecycleMappingMetadata> </pluginExecutionFilter>
</configuration> <action>
</plugin> <ignore></ignore>
</plugins> </action>
</pluginManagement> </pluginExecution>
<extensions> </pluginExecutions>
<!-- Enabling the use of SCP --> </lifecycleMappingMetadata>
<extension> </configuration>
<groupId>org.apache.maven.wagon</groupId> </plugin>
<artifactId>wagon-ssh</artifactId> </plugins>
<version>2.1</version> </pluginManagement>
</extension> <extensions>
</extensions> <!-- Enabling the use of SCP -->
</build> <extension>
</project> <groupId>org.apache.maven.wagon</groupId>
<artifactId>wagon-ssh</artifactId>
<version>2.1</version>
</extension>
</extensions>
</build>
</project>

View file

@ -1,285 +1,288 @@
package de.jaschastarke.minecraft.limitedcreative.blockstate; package de.jaschastarke.minecraft.limitedcreative.blockstate;
import java.util.Date; import com.sk89q.worldedit.WorldEdit;
import com.sk89q.worldedit.bukkit.BukkitAdapter;
import org.bukkit.Bukkit; import com.sk89q.worldedit.bukkit.BukkitPlayer;
import org.bukkit.GameMode; import com.sk89q.worldedit.math.BlockVector3;
import org.bukkit.Location; import com.sk89q.worldedit.regions.Region;
import org.bukkit.Material; import com.sk89q.worldedit.world.World;
import org.bukkit.World; import de.jaschastarke.LocaleString;
import com.sk89q.worldedit.bukkit.WorldEditPlugin; import de.jaschastarke.bukkit.lib.chat.ChatFormattings;
import com.sk89q.worldedit.bukkit.selections.Selection; import de.jaschastarke.bukkit.lib.commands.*;
import de.jaschastarke.bukkit.lib.commands.annotations.IsCommand;
import de.jaschastarke.LocaleString; import de.jaschastarke.bukkit.lib.commands.annotations.Usages;
import de.jaschastarke.bukkit.lib.chat.ChatFormattings; import de.jaschastarke.bukkit.lib.commands.parser.DefinedParameterParser;
import de.jaschastarke.bukkit.lib.commands.BukkitCommand; import de.jaschastarke.bukkit.lib.database.DBHelper;
import de.jaschastarke.bukkit.lib.commands.CommandContext; import de.jaschastarke.database.DatabaseConfigurationException;
import de.jaschastarke.bukkit.lib.commands.CommandException; import de.jaschastarke.database.db.Database;
import de.jaschastarke.bukkit.lib.commands.HelpCommand; import de.jaschastarke.maven.ArchiveDocComments;
import de.jaschastarke.bukkit.lib.commands.IHelpDescribed; import de.jaschastarke.maven.PluginCommand;
import de.jaschastarke.bukkit.lib.commands.MissingPermissionCommandException; import de.jaschastarke.minecraft.lib.permissions.IAbstractPermission;
import de.jaschastarke.bukkit.lib.commands.annotations.IsCommand; import de.jaschastarke.minecraft.limitedcreative.ModBlockStates;
import de.jaschastarke.bukkit.lib.commands.annotations.Usages; import de.jaschastarke.minecraft.limitedcreative.blockstate.BlockState.Source;
import de.jaschastarke.bukkit.lib.commands.parser.DefinedParameterParser; import de.jaschastarke.minecraft.limitedcreative.blockstate.DBModel.Cuboid;
import de.jaschastarke.bukkit.lib.database.DBHelper; import de.jaschastarke.minecraft.limitedcreative.blockstate.DBModel.DBTransaction;
import de.jaschastarke.database.DatabaseConfigurationException; import de.jaschastarke.modularize.ModuleEntry.ModuleState;
import de.jaschastarke.database.db.Database; import org.bukkit.Bukkit;
import de.jaschastarke.maven.ArchiveDocComments; import org.bukkit.GameMode;
import de.jaschastarke.maven.PluginCommand; import org.bukkit.Location;
import de.jaschastarke.minecraft.lib.permissions.IAbstractPermission;
import de.jaschastarke.minecraft.limitedcreative.ModBlockStates; import java.util.Date;
import de.jaschastarke.minecraft.limitedcreative.blockstate.BlockState.Source;
import de.jaschastarke.minecraft.limitedcreative.blockstate.DBModel.Cuboid; /**
import de.jaschastarke.minecraft.limitedcreative.blockstate.DBModel.DBTransaction; * LimitedCreative-BlockState-Command: modify blockstate database to prevent drops of selected blocks (requires WorldEdit)
import de.jaschastarke.modularize.ModuleEntry.ModuleState; * @usage /<command> - displays Regions-Command-Help
* @permission limitedcreative.blockstate.command
/** */
* LimitedCreative-BlockState-Command: modify blockstate database to prevent drops of selected blocks (requires WorldEdit) @ArchiveDocComments
* @usage /<command> - displays Regions-Command-Help @PluginCommand
* @permission limitedcreative.blockstate.command public class BlockStateCommand extends BukkitCommand implements IHelpDescribed {
*/ private ModBlockStates mod;
@ArchiveDocComments private HelpCommand help;
@PluginCommand
public class BlockStateCommand extends BukkitCommand implements IHelpDescribed { public BlockStateCommand() {
private ModBlockStates mod; this.help = this.getDefaultHelpCommand();
private HelpCommand help; }
public BlockStateCommand(ModBlockStates mod) {
public BlockStateCommand() { super(mod.getPlugin());
this.help = this.getDefaultHelpCommand(); this.help = this.getDefaultHelpCommand();
} this.mod = mod;
public BlockStateCommand(ModBlockStates mod) { }
super(mod.getPlugin());
this.help = this.getDefaultHelpCommand(); @Override
this.mod = mod; public String getName() {
} return "lcbs";
}
@Override
public String getName() { @Override
return "lcbs"; public String[] getAliases() {
} return new String[]{};
}
@Override
public String[] getAliases() { /**
return new String[]{}; * @internal has no effect, as not tested by any command handler
} * @see IHelpDescribed
*/
/** @Override
* @internal has no effect, as not tested by any command handler public IAbstractPermission[] getRequiredPermissions() {
* @see IHelpDescribed return new IAbstractPermission[]{BlockStatePermissions.COMMAND};
*/ }
@Override
public IAbstractPermission[] getRequiredPermissions() { @Override
return new IAbstractPermission[]{BlockStatePermissions.COMMAND}; public CharSequence[] getUsages() {
} return new String[]{"..."};
}
@Override
public CharSequence[] getUsages() { @Override
return new String[]{"..."}; public CharSequence getDescription() {
} return new LocaleString("command.blockstate");
}
@Override
public CharSequence getDescription() { @Override
return new LocaleString("command.blockstate"); public CharSequence getPackageName() {
} return mod.getPlugin().getName() + " - " + mod.getName();
}
@Override
public CharSequence getPackageName() { public boolean execute(final CommandContext context, final String[] args) throws MissingPermissionCommandException, CommandException {
return mod.getPlugin().getName() + " - " + mod.getName(); if (mod.getModuleEntry().getState() != ModuleState.ENABLED)
} throw new CommandException("Module " + mod.getName() + " is disabled");
return super.execute(context, args);
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")
* Deletes no longer used data from the BlockState-Database. Currently it only removes non-creative entries @Usages("")
* from the database, if you changed to "logSurvival"-config from true to false. public boolean cleanupDatabase(final CommandContext context, String... args) throws CommandException {
*/ if (mod.getConfig().getLogSurvival()) {
@IsCommand("cleanup") context.responseFormatted(ChatFormattings.INFO, L("command.blockstate.nothing_to_cleanup"));
@Usages("") } else {
public boolean cleanupDatabase(final CommandContext context, String... args) throws CommandException { mod.getPlugin().getServer().getScheduler().runTaskAsynchronously(mod.getPlugin(), new Runnable() {
if (mod.getConfig().getLogSurvival()) { @Override
context.responseFormatted(ChatFormattings.INFO, L("command.blockstate.nothing_to_cleanup")); public void run() {
} else { int countDeleted = mod.getModel().cleanUp(DBModel.Cleanup.SURVIVAL);
mod.getPlugin().getServer().getScheduler().runTaskAsynchronously(mod.getPlugin(), new Runnable() { if (countDeleted < 0)
@Override context.responseFormatted(ChatFormattings.ERROR, L("command.blockstate.cleanup_error"));
public void run() { else
int countDeleted = mod.getModel().cleanUp(DBModel.Cleanup.SURVIVAL); context.responseFormatted(ChatFormattings.SUCCESS, L("command.blockstate.cleanup_success", countDeleted));
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;
} }
});
} /**
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
* Modifies the BlockState-Database and sets all blocks in the selection to the provided gamemode. Set it * @throws MissingPermissionCommandException
* 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. @IsCommand("set")
* gamemode can be: survival / creative / adventure / s / c / a / 0 / 1 / 2 @Usages("<gamemode>")
* @throws MissingPermissionCommandException public boolean setGameMode(final CommandContext context, String... args) throws CommandException, MissingPermissionCommandException {
*/ if (!mod.getPlugin().getServer().getPluginManager().isPluginEnabled("WorldEdit")) {
@IsCommand("set") help.execute(context, new String[]{"set"});
@Usages("<gamemode>") context.response(L("command.blockstate.requires_worldedit"));
public boolean setGameMode(final CommandContext context, String... args) throws CommandException, MissingPermissionCommandException { return true;
if (!mod.getPlugin().getServer().getPluginManager().isPluginEnabled("WorldEdit")) { }
help.execute(context, new String[]{"set"}); if (!context.isPlayer()) {
context.response(L("command.blockstate.requires_worldedit")); context.response(L("cmdblock.blocked.not_console"));
return true; return true;
} }
if (!context.isPlayer()) { if (args.length < 1) {// doesn't count parameters
context.response(L("cmdblock.blocked.not_console")); return false;
return true; }
} if (mod.getConfig().getIgnoredWorlds().contains(context.getPlayer().getWorld().getName())) {
if (args.length < 1) {// doesn't count parameters context.response(L("command.blockstate.world_ignored", context.getPlayer().getWorld().getName()));
return false; return true;
} }
if (mod.getConfig().getIgnoredWorlds().contains(context.getPlayer().getWorld().getName())) { String gm = args[0].toLowerCase();
context.response(L("command.blockstate.world_ignored", context.getPlayer().getWorld().getName())); final GameMode tgm;
return true; if (gm.equals("0") || gm.equals("s") || gm.equals("survival"))
} tgm = GameMode.SURVIVAL;
String gm = args[0].toLowerCase(); else if (gm.equals("1") || gm.equals("c") || gm.equals("creative"))
final GameMode tgm; tgm = GameMode.CREATIVE;
if (gm.equals("0") || gm.equals("s") || gm.equals("survival")) else if (gm.equals("2") || gm.equals("a") || gm.equals("adventure"))
tgm = GameMode.SURVIVAL; tgm = GameMode.ADVENTURE;
else if (gm.equals("1") || gm.equals("c") || gm.equals("creative")) else {
tgm = GameMode.CREATIVE; return false;
else if (gm.equals("2") || gm.equals("a") || gm.equals("adventure")) }
tgm = GameMode.ADVENTURE;
else { BukkitPlayer bp = BukkitAdapter.adapt(context.getPlayer());
return false; Region region = null;
} try {
region = WorldEdit.getInstance().getSessionManager().get(bp).getSelection(bp.getWorld());
WorldEditPlugin we = (WorldEditPlugin) mod.getPlugin().getServer().getPluginManager().getPlugin("WorldEdit"); } catch (Exception ignored) { //IncompleteRegionException
final Selection selection = we.getSelection(context.getPlayer()); }
if (selection == null) { final Region selection = region;
context.response(L("command.blockstate.worledit_selection_empty")); if (selection == null) {
return true; context.response(L("command.blockstate.worledit_selection_empty"));
} return true;
}
final Location min = selection.getMinimumPoint();
final Location max = selection.getMaximumPoint(); final BlockVector3 min = selection.getMinimumPoint();
final BlockVector3 max = selection.getMaximumPoint();
mod.getPlugin().getServer().getScheduler().runTaskAsynchronously(mod.getPlugin(), new Runnable() {
@Override mod.getPlugin().getServer().getScheduler().runTaskAsynchronously(mod.getPlugin(), new Runnable() {
public void run() { @Override
if (mod.isDebug()) public void run() {
mod.getLog().debug("Scheduler: Asynchronous Task run"); if (mod.isDebug())
DBTransaction update = mod.getModel().groupUpdate(); mod.getLog().debug("Scheduler: Asynchronous Task run");
int count = 0; DBTransaction update = mod.getModel().groupUpdate();
World w = selection.getWorld(); int count = 0;
World w = selection.getWorld();
Cuboid c = new Cuboid(); assert w != null;
c.add(min); org.bukkit.World bw = BukkitAdapter.adapt(w);
c.add(max);
mod.getModel().cacheStates(c); Cuboid c = new Cuboid();
c.add(new Location(bw, min.getBlockX(), min.getBlockY(), min.getBlockZ()));
BlockState seed = new BlockState(); c.add(new Location(bw, max.getBlockX(), max.getBlockY(), max.getBlockZ()));
seed.setPlayer(context.getPlayer()); mod.getModel().cacheStates(c);
seed.setGameMode(tgm);
seed.setSource(Source.COMMAND); BlockState seed = new BlockState();
seed.setDate(new Date()); seed.setPlayer(context.getPlayer());
for (int x = min.getBlockX(); x <= max.getBlockX(); x++) { seed.setGameMode(tgm);
for (int y = min.getBlockY(); y <= max.getBlockY(); y++) { seed.setSource(Source.COMMAND);
for (int z = min.getBlockZ(); z <= max.getBlockZ(); z++) { seed.setDate(new Date());
Location loc = new Location(w, x, y, z); for (int x = min.getBlockX(); x <= max.getBlockX(); x++) {
if (w.getBlockAt(loc).getType() != Material.AIR && selection.contains(loc)) { for (int y = min.getBlockY(); y <= max.getBlockY(); y++) {
seed.setLocation(loc); for (int z = min.getBlockZ(); z <= max.getBlockZ(); z++) {
update.setState(new BlockState(seed)); BlockVector3 loc = BlockVector3.at(x, y, z);
count++; 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)); }
} update.finish();
});
return true; 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 * Imports BlockState Data from a given Database to the current active Database.
* --import=<type> Import from other Plugins. Supported Types: * A Server-Restart is needed after migration!
* cc CreativeControl * Parameters:
*/ * -u --update Don't delete existing records / only overwrite if newer
@IsCommand("migrate") * --import=<type> Import from other Plugins. Supported Types:
@Usages("-u --import=cc <dsn> [username] [password]") * cc CreativeControl
public boolean migrateDatabase(final CommandContext context, String... args) throws CommandException, MissingPermissionCommandException { */
DefinedParameterParser params = new DefinedParameterParser(args, new String[]{"debug", "d", "update", "u", "confirm"}); @IsCommand("migrate")
if (params.getArgumentCount() < 1) {// doesn't count parameters @Usages("-u --import=cc <dsn> [username] [password]")
return false; 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
if (Bukkit.getServer().getOnlinePlayers().size() > (context.isPlayer() ? 1 : 0)) { return false;
context.responseFormatted(ChatFormattings.ERROR, L("command.blockstate.migrate_useronline_error")); }
return true;
} if (Bukkit.getServer().getOnlinePlayers().size() > (context.isPlayer() ? 1 : 0)) {
context.responseFormatted(ChatFormattings.ERROR, L("command.blockstate.migrate_useronline_error"));
Database source; return true;
Database target; }
try {
Database source;
if (params.getArgumentCount() < 2) Database target;
source = DBHelper.createConnection(params.getArgument(0)); try {
else if (params.getArgumentCount() < 3)
source = DBHelper.createConnection(params.getArgument(0), params.getArgument(1), null); if (params.getArgumentCount() < 2)
else source = DBHelper.createConnection(params.getArgument(0));
source = DBHelper.createConnection(params.getArgument(0), params.getArgument(1), params.getArgument(2)); else if (params.getArgumentCount() < 3)
source = DBHelper.createConnection(params.getArgument(0), params.getArgument(1), null);
target = mod.getPlugin().getDatabaseConnection(); else
} catch (DatabaseConfigurationException e) { source = DBHelper.createConnection(params.getArgument(0), params.getArgument(1), params.getArgument(2));
context.responseFormatted(ChatFormattings.ERROR, L("command.blockstate.migrate_connect_error", e.getMessage()));
return true; target = mod.getPlugin().getDatabaseConnection();
} } catch (DatabaseConfigurationException e) {
context.responseFormatted(ChatFormattings.ERROR, L("command.blockstate.migrate_connect_error", e.getMessage()));
DatabaseMigrationThread thread; return true;
if (params.getParameter("import") != null) { }
if (params.getParameter("import").equals("cc")) {
thread = new CreativeControlImportThread(mod, context, source, target); DatabaseMigrationThread thread;
} else { if (params.getParameter("import") != null) {
context.responseFormatted(ChatFormattings.ERROR, L("command.blockstate.migrate_importtype_error", params.getParameter("import"))); if (params.getParameter("import").equals("cc")) {
return false; thread = new CreativeControlImportThread(mod, context, source, target);
} } else {
} else { context.responseFormatted(ChatFormattings.ERROR, L("command.blockstate.migrate_importtype_error", params.getParameter("import")));
thread = new DatabaseMigrationThread(mod, context, source, target); return false;
} }
if (params.getFlags().contains("update") || params.getFlags().contains("u")) { } else {
thread.setMode(DatabaseMigrationThread.Mode.UPDATE); thread = new DatabaseMigrationThread(mod, context, source, target);
} }
if (params.getFlags().contains("debug") || params.getFlags().contains("d")) { if (params.getFlags().contains("update") || params.getFlags().contains("u")) {
thread.setDebug(true); thread.setMode(DatabaseMigrationThread.Mode.UPDATE);
} }
if (params.getFlags().contains("debug") || params.getFlags().contains("d")) {
if (!params.getFlags().contains("confirm")) { thread.setDebug(true);
context.responseFormatted(ChatFormattings.INFO, L("command.blockstate.migrate_confirm", "--confirm")); }
return true;
} if (!params.getFlags().contains("confirm")) {
context.responseFormatted(ChatFormattings.INFO, L("command.blockstate.migrate_confirm", "--confirm"));
mod.getModuleEntry().disable(); return true;
}
thread.start();
String sourceType = source.getType().toString(); mod.getModuleEntry().disable();
if (params.getParameter("import") != null) {
if (params.getParameter("import").equals("cc")) { thread.start();
sourceType = "CreativeControl-" + sourceType; String sourceType = source.getType().toString();
} if (params.getParameter("import") != null) {
} if (params.getParameter("import").equals("cc")) {
context.response(L("command.blockstate.migrate_started", sourceType, target.getType())); sourceType = "CreativeControl-" + sourceType;
return true; }
} }
context.response(L("command.blockstate.migrate_started", sourceType, target.getType()));
private String L(String msg, Object... args) { return true;
return mod.getPlugin().getLocale().trans(msg, args); }
}
} private String L(String msg, Object... args) {
return mod.getPlugin().getLocale().trans(msg, args);
}
}

View file

@ -1,21 +1,20 @@
package de.jaschastarke.minecraft.limitedcreative.blockstate.worldedit; 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.Location;
import org.bukkit.World; import org.bukkit.World;
import org.bukkit.entity.Player; import org.bukkit.entity.Player;
import com.sk89q.worldedit.Vector; import java.util.Date;
import com.sk89q.worldedit.blocks.BaseBlock;
import com.sk89q.worldedit.extent.Extent;
import com.sk89q.worldedit.extent.logging.AbstractLoggingExtent;
import de.jaschastarke.minecraft.limitedcreative.ModBlockStates; public class EditSessionExtent extends AbstractDelegateExtent {
import de.jaschastarke.minecraft.limitedcreative.blockstate.BlockState;
import de.jaschastarke.minecraft.limitedcreative.blockstate.BlockState.Source;
public class EditSessionExtent extends AbstractLoggingExtent {
private ModBlockStates mod; private ModBlockStates mod;
private Player player = null; private Player player = null;
private World world; private World world;
@ -30,14 +29,15 @@ public class EditSessionExtent extends AbstractLoggingExtent {
/** /**
* Called when a block is being changed. * 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 * @param newBlock the new block to replace the old one
*/ */
protected void onBlockChange(Vector pt, BaseBlock newBlock) { @Override
public <T extends BlockStateHolder<T>> boolean setBlock(BlockVector3 pt, T newBlock) throws WorldEditException {
if (mod.isDebug()) if (mod.isDebug())
mod.getLog().debug("WorldEdit-Integration: BlockChange: "+pt.toString()+" BB: " + newBlock.toString()); mod.getLog().debug("WorldEdit-Integration: BlockChange: "+pt.toString()+" BB: " + newBlock.toString());
Location loc = new Location(world, pt.getBlockX(), pt.getBlockY(), pt.getBlockZ()); 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()); mod.getModel().removeState(loc.getBlock());
} else { } else {
BlockState s = mod.getModel().getState(loc.getBlock()); BlockState s = mod.getModel().getState(loc.getBlock());
@ -54,5 +54,6 @@ public class EditSessionExtent extends AbstractLoggingExtent {
mod.getModel().setState(s); mod.getModel().setState(s);
} }
return true;
} }
} }

View file

@ -1,48 +1,47 @@
package de.jaschastarke.minecraft.limitedcreative.regions; package de.jaschastarke.minecraft.limitedcreative.regions;
import org.bukkit.GameMode; import com.sk89q.worldguard.protection.flags.Flag;
import org.bukkit.command.CommandSender; import com.sk89q.worldguard.protection.flags.FlagContext;
import com.sk89q.worldguard.protection.flags.InvalidFlagFormat;
import com.sk89q.worldguard.bukkit.WorldGuardPlugin; import com.sk89q.worldguard.protection.flags.RegionGroup;
import com.sk89q.worldguard.protection.flags.Flag; import org.bukkit.GameMode;
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.
/** */
* Well, that was an interesting idea, but it doesn't work. public class GameModeFlag extends Flag<GameMode> {
*/ public GameModeFlag(String name, RegionGroup defaultGroup) {
public class GameModeFlag extends Flag<GameMode> { super(name, defaultGroup);
public GameModeFlag(String name, RegionGroup defaultGroup) { }
super(name, defaultGroup);
} @Override
public GameMode parseInput(FlagContext context) throws InvalidFlagFormat {
@Override String input = context.getUserInput();
public GameMode parseInput(WorldGuardPlugin plugin, CommandSender sender, String input) throws InvalidFlagFormat { input = input.trim();
input = input.trim(); if (input.equalsIgnoreCase("creative")) {
if (input.equalsIgnoreCase("creative")) { return GameMode.CREATIVE;
return GameMode.CREATIVE; } else if (input.equalsIgnoreCase("survival")) {
} else if (input.equalsIgnoreCase("survival")) { return GameMode.SURVIVAL;
return GameMode.SURVIVAL; } else if (input.equalsIgnoreCase("adventure")) {
} else if (input.equalsIgnoreCase("adventure")) { return GameMode.ADVENTURE;
return GameMode.ADVENTURE; } else if (input.equalsIgnoreCase("none")) {
} else if (input.equalsIgnoreCase("none")) { return null;
return null; } else {
} else { throw new InvalidFlagFormat("Expected survival/creative/none but got '" + input + "'");
throw new InvalidFlagFormat("Expected survival/creative/none but got '" + input + "'"); }
} }
}
@Override
@Override public GameMode unmarshal(Object o) {
public GameMode unmarshal(Object o) { GameMode gm = null;
GameMode gm = null; if (o != null) {
if (o != null) { gm = GameMode.valueOf((String) o);
gm = GameMode.valueOf((String) o); }
} return gm;
return gm; }
}
@Override
@Override public Object marshal(GameMode o) {
public Object marshal(GameMode o) { return o == null ? null : o.name();
return o == null ? null : o.name(); }
} }
}

View file

@ -1,282 +1,280 @@
package de.jaschastarke.minecraft.limitedcreative.regions; package de.jaschastarke.minecraft.limitedcreative.regions;
import java.util.ArrayList; import com.sk89q.worldedit.bukkit.BukkitAdapter;
import java.util.List; import com.sk89q.worldguard.WorldGuard;
import com.sk89q.worldguard.bukkit.WorldGuardPlugin;
import org.apache.commons.lang.StringUtils; import com.sk89q.worldguard.protection.ApplicableRegionSet;
import org.bukkit.Bukkit; import com.sk89q.worldguard.protection.flags.Flag;
import org.bukkit.ChatColor; import com.sk89q.worldguard.protection.flags.FlagContext;
import org.bukkit.World; import com.sk89q.worldguard.protection.flags.InvalidFlagFormat;
import com.sk89q.worldguard.protection.managers.RegionManager;
import com.sk89q.worldguard.bukkit.WorldGuardPlugin; import com.sk89q.worldguard.protection.regions.GlobalProtectedRegion;
import com.sk89q.worldguard.protection.ApplicableRegionSet; import com.sk89q.worldguard.protection.regions.ProtectedRegion;
import com.sk89q.worldguard.protection.flags.Flag; import com.sk89q.worldguard.protection.regions.RegionContainer;
import com.sk89q.worldguard.protection.flags.InvalidFlagFormat; import de.jaschastarke.LocaleString;
import com.sk89q.worldguard.protection.managers.RegionManager; import de.jaschastarke.bukkit.lib.chat.ChatFormattings;
import com.sk89q.worldguard.protection.regions.GlobalProtectedRegion; import de.jaschastarke.bukkit.lib.commands.*;
import com.sk89q.worldguard.protection.regions.ProtectedRegion; import de.jaschastarke.bukkit.lib.commands.annotations.IsCommand;
import de.jaschastarke.bukkit.lib.commands.annotations.Usages;
import de.jaschastarke.LocaleString; import de.jaschastarke.bukkit.lib.commands.parser.DefinedParameterParser;
import de.jaschastarke.bukkit.lib.chat.ChatFormattings; import de.jaschastarke.bukkit.lib.commands.parser.TabCompletion;
import de.jaschastarke.bukkit.lib.commands.BukkitCommand; import de.jaschastarke.bukkit.lib.commands.parser.TabCompletion.Completer;
import de.jaschastarke.bukkit.lib.commands.CommandContext; import de.jaschastarke.bukkit.lib.commands.parser.TabCompletion.Context;
import de.jaschastarke.bukkit.lib.commands.CommandException; import de.jaschastarke.maven.ArchiveDocComments;
import de.jaschastarke.bukkit.lib.commands.HelpCommand; import de.jaschastarke.maven.PluginCommand;
import de.jaschastarke.bukkit.lib.commands.ICommand; import de.jaschastarke.minecraft.lib.permissions.IAbstractPermission;
import de.jaschastarke.bukkit.lib.commands.IHelpDescribed; import de.jaschastarke.minecraft.limitedcreative.ModRegions;
import de.jaschastarke.bukkit.lib.commands.MethodCommand; import de.jaschastarke.minecraft.limitedcreative.regions.worldguard.FlagList;
import de.jaschastarke.bukkit.lib.commands.MissingPermissionCommandException; import de.jaschastarke.minecraft.limitedcreative.regions.worldguard.FlagValue;
import de.jaschastarke.bukkit.lib.commands.annotations.IsCommand; import de.jaschastarke.minecraft.limitedcreative.regions.worldguard.Region;
import de.jaschastarke.bukkit.lib.commands.annotations.Usages; import de.jaschastarke.modularize.ModuleEntry.ModuleState;
import de.jaschastarke.bukkit.lib.commands.parser.DefinedParameterParser; import org.apache.commons.lang.StringUtils;
import de.jaschastarke.bukkit.lib.commands.parser.TabCompletion; import org.bukkit.Bukkit;
import de.jaschastarke.bukkit.lib.commands.parser.TabCompletion.Completer; import org.bukkit.ChatColor;
import de.jaschastarke.bukkit.lib.commands.parser.TabCompletion.Context; import org.bukkit.World;
import de.jaschastarke.maven.ArchiveDocComments;
import de.jaschastarke.maven.PluginCommand; import java.util.ArrayList;
import de.jaschastarke.minecraft.lib.permissions.IAbstractPermission; import java.util.List;
import de.jaschastarke.minecraft.limitedcreative.ModRegions;
import de.jaschastarke.minecraft.limitedcreative.regions.worldguard.FlagList; /**
import de.jaschastarke.minecraft.limitedcreative.regions.worldguard.FlagValue; * LimitedCreative-Region-Command: configure creative regions
import de.jaschastarke.minecraft.limitedcreative.regions.worldguard.Region; * @usage /<command> - displays Regions-Command-Help
import de.jaschastarke.modularize.ModuleEntry.ModuleState; * @permission limitedcreative.region
*/
/** @ArchiveDocComments
* LimitedCreative-Region-Command: configure creative regions @PluginCommand
* @usage /<command> - displays Regions-Command-Help public class RegionsCommand extends BukkitCommand implements IHelpDescribed {
* @permission limitedcreative.region private final static String GLOBAL_REGION = "__global__";
*/ private ModRegions mod;
@ArchiveDocComments private HelpCommand help;
@PluginCommand private WorldGuardPlugin wg;
public class RegionsCommand extends BukkitCommand implements IHelpDescribed {
private final static String GLOBAL_REGION = "__global__"; public RegionsCommand() {
private ModRegions mod; this.help = this.getDefaultHelpCommand();
private HelpCommand help; }
private WorldGuardPlugin wg; public RegionsCommand(ModRegions mod) {
super(mod.getPlugin());
public RegionsCommand() { this.help = this.getDefaultHelpCommand();
this.help = this.getDefaultHelpCommand(); this.mod = mod;
} this.wg = (WorldGuardPlugin) mod.getPlugin().getServer().getPluginManager().getPlugin(WorldGuardIntegration.PLUGIN_NAME);
public RegionsCommand(ModRegions mod) { fullfillTabCompletion();
super(mod.getPlugin()); }
this.help = this.getDefaultHelpCommand();
this.mod = mod; @Override
this.wg = (WorldGuardPlugin) mod.getPlugin().getServer().getPluginManager().getPlugin(WorldGuardIntegration.PLUGIN_NAME); public String getName() {
fullfillTabCompletion(); return "lcr";
} }
@Override @Override
public String getName() { public String[] getAliases() {
return "lcr"; return new String[]{"/region"};
} }
@Override public boolean execute(final CommandContext context, final String[] args) throws MissingPermissionCommandException, CommandException {
public String[] getAliases() { if (mod.getModuleEntry().getState() != ModuleState.ENABLED)
return new String[]{"/region"}; throw new CommandException("Module " + mod.getName() + " is disabled");
} return super.execute(context, args);
}
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"); * @internal has no effect, as not tested by any command handler
return super.execute(context, args); * @see IHelpDescribed
} */
@Override
/** public IAbstractPermission[] getRequiredPermissions() {
* @internal has no effect, as not tested by any command handler return new IAbstractPermission[]{RegionPermissions.REGION};
* @see IHelpDescribed }
*/ @Override
@Override public String[] getUsages() {
public IAbstractPermission[] getRequiredPermissions() { return null;
return new IAbstractPermission[]{RegionPermissions.REGION}; }
} @Override
@Override public CharSequence getDescription() {
public String[] getUsages() { return new LocaleString("command.regions");
return null; }
} @Override
@Override public String getPackageName() {
public CharSequence getDescription() { return mod.getPlugin().getName() + " - " + mod.getName();
return new LocaleString("command.regions"); }
}
@Override /*@Override
public String getPackageName() { public IPermission getPermission(String subPerm) {
return mod.getPlugin().getName() + " - " + mod.getName(); if (subPerm.equals("region"))
} return RegionPermissions.REGION;
else
/*@Override return RegionPermissions.REGION.getPermission(subPerm);
public IPermission getPermission(String subPerm) { }*/
if (subPerm.equals("region"))
return RegionPermissions.REGION; protected void fullfillTabCompletion() {
else for (ICommand cmd : handler.getCommands()) {
return RegionPermissions.REGION.getPermission(subPerm); if (cmd instanceof MethodCommand) {
}*/ if (cmd.getName().equals("info")) {
((MethodCommand) cmd).getCompleter().add(TabCompletion.forUsageLine("[region]"));
protected void fullfillTabCompletion() { }
for (ICommand cmd : handler.getCommands()) { for (TabCompletion c : ((MethodCommand) cmd).getCompleter()) {
if (cmd instanceof MethodCommand) { c.setCompleter("region", new RegionCompleter());
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<String> get(Context context, String arg) {
} int idx = -1;
String[] args = context.getHelper().getArguments();
private class RegionCompleter implements Completer { for (int i = 0; i < args.length; i++) {
@Override if (args[i].equals("world")) {
public List<String> get(Context context, String arg) { idx = i;
int idx = -1; break;
String[] args = context.getHelper().getArguments(); }
for (int i = 0; i < args.length; i++) { }
if (args[i].equals("world")) { World w = context.getCommandContext().isPlayer() ? context.getCommandContext().getPlayer().getWorld() : null;
idx = i; if (idx > -1 && context.getArgument(idx) != null)
break; w = Bukkit.getWorld(context.getArgument(idx));
} if (w != null) {
} RegionContainer container = WorldGuard.getInstance().getPlatform().getRegionContainer();
World w = context.getCommandContext().isPlayer() ? context.getCommandContext().getPlayer().getWorld() : null; RegionManager mgr = container.get(BukkitAdapter.adapt(w));
if (idx > -1 && context.getArgument(idx) != null) if (mgr != null) {
w = Bukkit.getWorld(context.getArgument(idx)); List<String> hints = new ArrayList<String>();
if (w != null) { for (String rId : mgr.getRegions().keySet()) {
RegionManager mgr = getWorldGuard().getRegionManager(w); if (rId.toLowerCase().startsWith(arg.toLowerCase()))
if (mgr != null) { hints.add(rId);
List<String> hints = new ArrayList<String>(); }
for (String rId : mgr.getRegions().keySet()) { return hints;
if (rId.toLowerCase().startsWith(arg.toLowerCase())) }
hints.add(rId); }
} return null;
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)
/** */
* Sets the Flag of a region to a new value. If no value given, the flag is removed. @IsCommand("flag")
* -g sets the affected group of the flag, instead the flag (equivalent to using flag-group as flag-name) //@NeedsPermission("region") // not needed as the whole command requires permissions
* -w world uses a world by name instead the world your in (required from console) @Usages("<region> -g <flag> -w world [value]")
*/ public boolean setFlag(CommandContext context, String... args) throws CommandException, MissingPermissionCommandException {
@IsCommand("flag") DefinedParameterParser params = new DefinedParameterParser(args, new String[]{"g"}, 2);
//@NeedsPermission("region") // not needed as the whole command requires permissions if (params.getArgumentCount() < 2) {// doesn't count parameters
@Usages("<region> -g <flag> -w world [value]") help.execute(context, new String[]{"flag"});
public boolean setFlag(CommandContext context, String... args) throws CommandException, MissingPermissionCommandException { context.response(L("command.worldguard.available_flags") + FlagList.getStringListAvailableFlags(context.getSender()));
DefinedParameterParser params = new DefinedParameterParser(args, new String[]{"g"}, 2); return true;
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())); World w = context.isPlayer() ? context.getPlayer().getWorld() : null;
return true; if (params.getParameter("-w") != null)
} w = mod.getPlugin().getServer().getWorld(params.getParameter("-w"));
if (w == null)
World w = context.isPlayer() ? context.getPlayer().getWorld() : null; throw new CommandException(L("command.worldguard.world_not_found"));
if (params.getParameter("-w") != null)
w = mod.getPlugin().getServer().getWorld(params.getParameter("-w")); RegionContainer container = WorldGuard.getInstance().getPlatform().getRegionContainer();
if (w == null) RegionManager mgr = container.get(BukkitAdapter.adapt(w));
throw new CommandException(L("command.worldguard.world_not_found")); ProtectedRegion region = mgr.getRegion(params.getArgument(0));
if (region == null && params.getArgument(0).equalsIgnoreCase("__global__")) {
RegionManager mgr = getWorldGuard().getRegionManager(w); region = new GlobalProtectedRegion(params.getArgument(0));
ProtectedRegion region = mgr.getRegion(params.getArgument(0)); mgr.addRegion(region);
if (region == null && params.getArgument(0).equalsIgnoreCase("__global__")) { }
region = new GlobalProtectedRegion(params.getArgument(0)); if (region == null)
mgr.addRegion(region); throw new CommandException(L("command.worldguard.region_not_found"));
}
if (region == null) Region reg = mod.getRegionManager().world(w).region(region);
throw new CommandException(L("command.worldguard.region_not_found"));
Flag<?> flag = FlagList.getFlag(params.getArgument(1));
Region reg = mod.getRegionManager().world(w).region(region); if (flag == null) {
String msg = L("command.worldguard.unknown_flag") + params.getArgument(1) + "\n"
Flag<?> flag = FlagList.getFlag(params.getArgument(1)); + L("command.worldguard.available_flags") + FlagList.getStringListAvailableFlags(context.getSender());
if (flag == null) { throw new CommandException(msg);
String msg = L("command.worldguard.unknown_flag") + params.getArgument(1) + "\n" } else if (params.getFlags().contains("g")) {
+ L("command.worldguard.available_flags") + FlagList.getStringListAvailableFlags(context.getSender()); flag = flag.getRegionGroupFlag();
throw new CommandException(msg); if (flag == null) {
} else if (params.getFlags().contains("g")) { String msg = L("command.worldguard.unknown_flag") + params.getArgument(1) + "-group\n"
flag = flag.getRegionGroupFlag(); + L("command.worldguard.available_flags") + FlagList.getStringListAvailableFlags(context.getSender());
if (flag == null) { throw new CommandException(msg);
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) {
String value = params.getValue(); reg.setFlag(flag, flag.parseInput(FlagContext.create().setInput(value).build()));
try { } else {
if (value != null && value.trim().length() > 0) { reg.setFlag(flag, null);
reg.setFlag(flag, flag.parseInput(getWorldGuard(), context.getSender(), value)); }
} else { } catch (InvalidFlagFormat e) {
reg.setFlag(flag, null); context.response(context.getFormatter().formatString(ChatFormattings.ERROR, e.getLocalizedMessage()));
} return true;
} 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;
}
context.response(L("command.worldguard.flag_set", flag.getName()));
return true; @IsCommand("info")
} //@NeedsPermission("region")
@Usages("[world] [region]")
@IsCommand("info") public boolean getInfo(CommandContext context, String... args) throws CommandException {
//@NeedsPermission("region") DefinedParameterParser params = new DefinedParameterParser(args, new String[]{"s"}, 1);
@Usages("[world] [region]")
public boolean getInfo(CommandContext context, String... args) throws CommandException { if (context.isPlayer()) {
DefinedParameterParser params = new DefinedParameterParser(args, new String[]{"s"}, 1); /*
* WorldEdits intercepting Servers privates commandMap via Reflections realy sucks!
if (context.isPlayer()) { * Just because they are to lazy to add all the lines commands to plugin.yml
/* */
* WorldEdits intercepting Servers privates commandMap via Reflections realy sucks! String orgCmd = ("region info " + StringUtils.join(args)).trim();
* Just because they are to lazy to add all the lines commands to plugin.yml mod.getPlugin().getServer().dispatchCommand(context.getSender(), orgCmd);
*/ }
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));
World w = context.isPlayer() ? context.getPlayer().getWorld() : null; if (w == null)
if (params.getArgumentCount() > 1) throw new CommandException(L("command.worldguard.world_not_found"));
w = mod.getPlugin().getServer().getWorld(params.getArgument(0));
if (w == null) ProtectedRegion region = null;
throw new CommandException(L("command.worldguard.world_not_found")); RegionContainer container = WorldGuard.getInstance().getPlatform().getRegionContainer();
if (params.getArgumentCount() == 0 && context.isPlayer()) {
ProtectedRegion region = null; RegionManager mgr = container.get(BukkitAdapter.adapt(context.getPlayer().getWorld()));
if (params.getArgumentCount() == 0 && context.isPlayer()) { ApplicableRegionSet set = mgr.getApplicableRegions(BukkitAdapter.asBlockVector(context.getPlayer().getLocation()));
RegionManager mgr = getWorldGuard().getRegionManager(context.getPlayer().getWorld()); if (set.size() > 0) {
ApplicableRegionSet set = mgr.getApplicableRegions(context.getPlayer().getLocation()); region = set.iterator().next();
if (set.size() > 0) { } else {
region = set.iterator().next(); region = container.get(BukkitAdapter.adapt(w)).getRegion(GLOBAL_REGION);
} else { }
region = getWorldGuard().getRegionManager(w).getRegion(GLOBAL_REGION); } else {
} int rpc = params.getArgumentCount() > 1 ? 1 : 0;
} else { RegionManager mgr = container.get(BukkitAdapter.adapt(w));
int rpc = params.getArgumentCount() > 1 ? 1 : 0; region = mgr.getRegion(params.getArgument(rpc));
RegionManager mgr = getWorldGuard().getRegionManager(w); if (region == null && params.getArgument(rpc).equalsIgnoreCase(GLOBAL_REGION)) {
region = mgr.getRegion(params.getArgument(rpc)); region = new GlobalProtectedRegion(params.getArgument(rpc));
if (region == null && params.getArgument(rpc).equalsIgnoreCase(GLOBAL_REGION)) { mgr.addRegion(region);
region = new GlobalProtectedRegion(params.getArgument(rpc)); }
mgr.addRegion(region); }
} if (region == null)
} throw new CommandException(L("command.worldguard.region_not_found"));
if (region == null)
throw new CommandException(L("command.worldguard.region_not_found")); Region reg = mod.getRegionManager().world(w).region(region);
Region reg = mod.getRegionManager().world(w).region(region); StringBuilder list = new StringBuilder();
for (FlagValue data : reg.getFlags()) {
StringBuilder list = new StringBuilder(); if (list.length() > 0)
for (FlagValue data : reg.getFlags()) { list.append(", ");
if (list.length() > 0) list.append(data.getFlag().getName());
list.append(", "); list.append(": ");
list.append(data.getFlag().getName()); list.append(data.getValue().toString());
list.append(": "); }
list.append(data.getValue().toString());
} context.response(ChatColor.GREEN + L("command.worldguard.additional_flags") + list.toString());
return true;
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 String L(String msg, Object... args) { }
return mod.getPlugin().getLocale().trans(msg, args);
} private WorldGuardPlugin getWorldGuard() {
return wg;
private WorldGuardPlugin getWorldGuard() { }
return wg; }
}
}

View file

@ -1,192 +1,189 @@
/* /*
* Limited Creative - (Bukkit Plugin) * Limited Creative - (Bukkit Plugin)
* Copyright (C) 2012 jascha@ja-s.de * Copyright (C) 2012 jascha@ja-s.de
* *
* This program is free software: you can redistribute it and/or modify * 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 * it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or * the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version. * (at your option) any later version.
* *
* This program is distributed in the hope that it will be useful, * This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of * but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details. * GNU General Public License for more details.
* *
* You should have received a copy of the GNU General Public License * You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>. * along with this program. If not, see <http://www.gnu.org/licenses/>.
*/ */
package de.jaschastarke.minecraft.limitedcreative.regions.worldguard; package de.jaschastarke.minecraft.limitedcreative.regions.worldguard;
import java.io.File; import com.sk89q.worldedit.bukkit.BukkitAdapter;
import java.io.IOException; import com.sk89q.worldguard.WorldGuard;
import java.util.ArrayList; import com.sk89q.worldguard.bukkit.WorldGuardPlugin;
import java.util.Arrays; import com.sk89q.worldguard.protection.flags.Flag;
import java.util.HashMap; import com.sk89q.worldguard.protection.managers.RegionManager;
import java.util.List; import com.sk89q.worldguard.protection.regions.ProtectedRegion;
import java.util.Map; import com.sk89q.worldguard.protection.regions.RegionContainer;
import de.jaschastarke.minecraft.limitedcreative.ModRegions;
import org.bukkit.Location; import de.jaschastarke.minecraft.limitedcreative.regions.WorldGuardIntegration;
import org.bukkit.World; import de.jaschastarke.utils.StringUtil;
import org.bukkit.block.Block; import org.bukkit.Location;
import org.bukkit.configuration.ConfigurationSection; import org.bukkit.World;
import org.bukkit.configuration.file.YamlConfiguration; import org.bukkit.block.Block;
import org.bukkit.entity.Player; import org.bukkit.configuration.ConfigurationSection;
import org.bukkit.configuration.file.YamlConfiguration;
import com.sk89q.worldguard.bukkit.BukkitUtil; import org.bukkit.entity.Player;
import com.sk89q.worldguard.bukkit.WorldGuardPlugin;
import com.sk89q.worldguard.protection.flags.Flag; import java.io.File;
import com.sk89q.worldguard.protection.managers.RegionManager; import java.io.IOException;
import com.sk89q.worldguard.protection.regions.ProtectedRegion; import java.util.*;
import de.jaschastarke.minecraft.limitedcreative.ModRegions; public class CustomRegionManager {
import de.jaschastarke.minecraft.limitedcreative.regions.WorldGuardIntegration; protected YamlConfiguration c;
import de.jaschastarke.utils.StringUtil; protected File file;
private Map<World, CWorld> worlds = new HashMap<World, CWorld>();
public class CustomRegionManager { private ModRegions mod;
protected YamlConfiguration c; public CustomRegionManager(File file, ModRegions mod) {
protected File file; this.file = file;
private Map<World, CWorld> worlds = new HashMap<World, CWorld>(); this.mod = mod;
private ModRegions mod; c = YamlConfiguration.loadConfiguration(file);
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 {
public CWorld world(World w) { CWorld r = new CWorld(w);
if (worlds.containsKey(w)) { worlds.put(w, r);
return worlds.get(w); return r;
} 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) {
public class CWorld { world = w;
private World world; }
private ConfigurationSection wc = null; public CustomRegionManager getManager() {
public CWorld(World w) { return CustomRegionManager.this;
world = w; }
} private Map<ProtectedRegion, Region> regions = new HashMap<ProtectedRegion, Region>();
public CustomRegionManager getManager() { public Region region(ProtectedRegion pr) {
return CustomRegionManager.this; if (regions.containsKey(pr)) {
} return regions.get(pr);
private Map<ProtectedRegion, Region> regions = new HashMap<ProtectedRegion, Region>(); } else {
public Region region(ProtectedRegion pr) { Region r = new Region(this, pr);
if (regions.containsKey(pr)) { regions.put(pr, r);
return regions.get(pr); return r;
} else { }
Region r = new Region(this, pr); }
regions.put(pr, r); public World getWorld() {
return r; return world;
} }
} public ProtectedRegion getGlobalRegion() {
public World getWorld() { return getWGManager(world).getRegion("__global__");
return world; }
}
public ProtectedRegion getGlobalRegion() { @SuppressWarnings("unchecked")
return getWGManager(world).getRegion("__global__"); public <V> void storeFlag(Region region, Flag<V> flag, Object value) {
} if (wc == null) {
if (c.contains(world.getName().toLowerCase()))
@SuppressWarnings("unchecked") wc = c.getConfigurationSection(world.getName().toLowerCase());
public <V> void storeFlag(Region region, Flag<V> flag, Object value) { else
if (wc == null) { wc = c.createSection(world.getName().toLowerCase());
if (c.contains(world.getName().toLowerCase())) }
wc = c.getConfigurationSection(world.getName().toLowerCase());
else ConfigurationSection rs;
wc = c.createSection(world.getName().toLowerCase()); if (wc.contains(region.getProtectedRegion().getId()))
} rs = wc.getConfigurationSection(region.getProtectedRegion().getId());
else
ConfigurationSection rs; rs = wc.createSection(region.getProtectedRegion().getId());
if (wc.contains(region.getProtectedRegion().getId()))
rs = wc.getConfigurationSection(region.getProtectedRegion().getId()); ConfigurationSection fs = rs.contains("flags") ? rs.getConfigurationSection("flags") : rs.createSection("flags");
else
rs = wc.createSection(region.getProtectedRegion().getId()); if (value == null) {
fs.set(flag.getName(), null);
ConfigurationSection fs = rs.contains("flags") ? rs.getConfigurationSection("flags") : rs.createSection("flags"); } else {
fs.set(flag.getName(), flag.marshal((V) value));
if (value == null) { }
fs.set(flag.getName(), null);
} else { try {
fs.set(flag.getName(), flag.marshal((V) value)); c.save(file);
} } catch (IOException e) {
e.printStackTrace();
try { }
c.save(file); }
} catch (IOException e) { public List<FlagValue> getFlags(Region region) {
e.printStackTrace(); List<FlagValue> list = new ArrayList<FlagValue>();
}
} if (c.contains(world.getName().toLowerCase())) {
public List<FlagValue> getFlags(Region region) { ConfigurationSection wc = c.getConfigurationSection(world.getName().toLowerCase());
List<FlagValue> list = new ArrayList<FlagValue>(); if (wc.contains(region.getProtectedRegion().getId())) {
ConfigurationSection rs = wc.getConfigurationSection(region.getProtectedRegion().getId());
if (c.contains(world.getName().toLowerCase())) { if (rs.contains("flags")) {
ConfigurationSection wc = c.getConfigurationSection(world.getName().toLowerCase()); ConfigurationSection fs = rs.getConfigurationSection("flags");
if (wc.contains(region.getProtectedRegion().getId())) { for (Map.Entry<String, Object> data : fs.getValues(false).entrySet()) {
ConfigurationSection rs = wc.getConfigurationSection(region.getProtectedRegion().getId()); Flag<?> flag = null;
if (rs.contains("flags")) { if (data.getKey().endsWith("-group")) {
ConfigurationSection fs = rs.getConfigurationSection("flags"); flag = FlagList.getFlag(data.getKey().substring(0, data.getKey().length() - 6));
for (Map.Entry<String, Object> data : fs.getValues(false).entrySet()) { if (flag != null)
Flag<?> flag = null; flag = flag.getRegionGroupFlag();
if (data.getKey().endsWith("-group")) { } else {
flag = FlagList.getFlag(data.getKey().substring(0, data.getKey().length() - 6)); flag = FlagList.getFlag(data.getKey());
if (flag != null) }
flag = flag.getRegionGroupFlag(); if (flag != null) { // the flag doesn't exists anymore. just ignore it without error
} else { Object value = flag.unmarshal(data.getValue());
flag = FlagList.getFlag(data.getKey()); list.add(new FlagValue(flag, value));
} } else {
if (flag != null) { // the flag doesn't exists anymore. just ignore it without error if (mod.isDebug())
Object value = flag.unmarshal(data.getValue()); mod.getLog().debug("Couldn't load unknown Flag: "+data.getKey());
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 list; return CustomRegionManager.this.getWorldGuard();
} }
}
public WorldGuardPlugin getWorldGuard() {
return CustomRegionManager.this.getWorldGuard(); private WorldGuardPlugin getWorldGuard() {
} return ((WorldGuardPlugin) mod.getPlugin().getServer().getPluginManager().getPlugin(WorldGuardIntegration.PLUGIN_NAME));
} }
private WorldGuardPlugin getWorldGuard() { public RegionManager getWGManager(World world) {
return ((WorldGuardPlugin) mod.getPlugin().getServer().getPluginManager().getPlugin(WorldGuardIntegration.PLUGIN_NAME)); RegionContainer container = WorldGuard.getInstance().getPlatform().getRegionContainer();
} return container.get(BukkitAdapter.adapt(world));
}
public RegionManager getWGManager(World world) {
return getWorldGuard().getRegionManager(world); public String getRegionsHash(Location loc) {
} StringBuilder hash = new StringBuilder(loc.getWorld().getName());
List<String> idlist = getWGManager(loc.getWorld()).getApplicableRegionsIDs(BukkitAdapter.asBlockVector(loc));
public String getRegionsHash(Location loc) { if (idlist.size() > 0) {
StringBuilder hash = new StringBuilder(loc.getWorld().getName()); hash.append("#");
List<String> idlist = getWGManager(loc.getWorld()).getApplicableRegionsIDs(BukkitUtil.toVector(loc)); String[] ids = idlist.toArray(new String[idlist.size()]);
if (idlist.size() > 0) { if (ids.length > 1) {
hash.append("#"); Arrays.sort(ids);
String[] ids = idlist.toArray(new String[idlist.size()]); }
if (ids.length > 1) { hash.append(StringUtil.join(ids, ","));
Arrays.sort(ids); }
} return hash.toString();
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(Location loc) {
return new ApplicableRegions(getWGManager(loc.getWorld()).getApplicableRegions(loc), this.world(loc.getWorld())); public ApplicableRegions getRegionSet(Block block) {
} return getRegionSet(block.getLocation());
}
public ApplicableRegions getRegionSet(Block block) {
return getRegionSet(block.getLocation()); public boolean isDiffrentRegion(Player player, Location loc) {
} return !getRegionsHash(loc).equals(mod.getPlayerData(player).getHash());
}
public boolean isDiffrentRegion(Player player, Location loc) { }
return !getRegionsHash(loc).equals(mod.getPlayerData(player).getHash());
}
}