Compare commits
19 commits
spigot-1.8
...
master
Author | SHA1 | Date | |
---|---|---|---|
d46adfd957 | |||
12a8ccf3ce | |||
dcd3ff31db | |||
e4548069dc | |||
3f9c2b99f9 | |||
6d5f42b2a5 | |||
14bdf0ebe0 | |||
24ed3393d3 | |||
cd7b7a550d | |||
b84ecf8545 | |||
ecaecd4136 | |||
362d1d823c | |||
b8d21657ce | |||
d7e4eafc4d | |||
f2af77b9b7 | |||
|
8c1240cc24 | ||
|
05d37326e0 | ||
|
b2e154be45 | ||
|
8cfc3b7f01 |
31 changed files with 1691 additions and 1420 deletions
|
@ -18,3 +18,11 @@ Dependencies for optional integrations
|
|||
* [Vault](http://dev.bukkit.org/bukkit-plugins/vault/)
|
||||
* [Multiworld](http://dev.bukkit.org/bukkit-plugins/multiworld-v-2-0/)
|
||||
* [LogBlock](http://dev.bukkit.org/bukkit-plugins/logblock/)
|
||||
|
||||
Building
|
||||
--------
|
||||
Download and install xAuth and Multiworld into the local `repo` repository with a command like so:
|
||||
|
||||
```bash
|
||||
mvn install:install-file -Dfile=xAuth-2.0.26.jar -Dpackaging=jar -DlocalRepositoryPath=repo -DgroupId=de.luricos.bukkit -DartifactId=xAuth -Dversion=2.0.26
|
||||
```
|
552
pom.xml
552
pom.xml
|
@ -1,267 +1,303 @@
|
|||
<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>
|
||||
<groupId>de.jaschastarke</groupId>
|
||||
<artifactId>LimitedCreative</artifactId>
|
||||
<name>LimitedCreative</name>
|
||||
<version>2.3-SNAPSHOT</version>
|
||||
<url>https://github.com/possi/LimitedCreative</url>
|
||||
<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>
|
||||
<groupId>de.jaschastarke</groupId>
|
||||
<artifactId>LimitedCreative</artifactId>
|
||||
<name>LimitedCreative</name>
|
||||
<version>2.5</version>
|
||||
<url>https://github.com/possi/LimitedCreative</url>
|
||||
|
||||
<properties>
|
||||
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
|
||||
<plib.version>1.4-SNAPSHOT</plib.version>
|
||||
<bukkit.version>1.8.3-R0.1-SNAPSHOT</bukkit.version>
|
||||
</properties>
|
||||
<properties>
|
||||
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
|
||||
<plib.version>1.4-SNAPSHOT</plib.version>
|
||||
<bukkit.version>1.12.2-R0.1-SNAPSHOT</bukkit.version>
|
||||
</properties>
|
||||
|
||||
<scm>
|
||||
<connection>scm:git:git://github.com/possi/LimitedCreative.git</connection>
|
||||
<developerConnection>scm:git:git@github.com:possi/LimitedCreative.git</developerConnection>
|
||||
<url>https://github.com/possi/LimitedCreative/tree/plib</url>
|
||||
</scm>
|
||||
<distributionManagement>
|
||||
<repository>
|
||||
<id>de-jas-repo</id>
|
||||
<url>scp://repo@ja-s.de/var/customers/webs/repo/mvn</url>
|
||||
</repository>
|
||||
</distributionManagement>
|
||||
<ciManagement>
|
||||
<system>jenkins</system>
|
||||
<url>http://ci.ja-s.de:8080/</url>
|
||||
</ciManagement>
|
||||
<issueManagement>
|
||||
<system>BukkitDev</system>
|
||||
<url>http://dev.bukkit.org/server-mods/limited-creative/tickets/</url>
|
||||
</issueManagement>
|
||||
<scm>
|
||||
<connection>scm:git:git://github.com/possi/LimitedCreative.git</connection>
|
||||
<developerConnection>scm:git:git@github.com:possi/LimitedCreative.git</developerConnection>
|
||||
<url>https://github.com/possi/LimitedCreative/tree/plib</url>
|
||||
</scm>
|
||||
<distributionManagement>
|
||||
<repository>
|
||||
<id>de-jas-repo</id>
|
||||
<url>scp://repo@ja-s.de/var/customers/webs/repo/mvn</url>
|
||||
</repository>
|
||||
</distributionManagement>
|
||||
<ciManagement>
|
||||
<system>jenkins</system>
|
||||
<url>http://ci.ja-s.de:8080/</url>
|
||||
</ciManagement>
|
||||
<issueManagement>
|
||||
<system>BukkitDev</system>
|
||||
<url>http://dev.bukkit.org/server-mods/limited-creative/tickets/</url>
|
||||
</issueManagement>
|
||||
|
||||
<repositories>
|
||||
<!-- Possible public Maven Repository, containing LimitedCreative builds and other dependencies without own rep.
|
||||
like AuthMe, etc.
|
||||
Supports http only -->
|
||||
<repository>
|
||||
<id>de-jas-rep</id>
|
||||
<url>http://repo.ja-s.de/mvn</url>
|
||||
</repository>
|
||||
<repositories>
|
||||
<!-- Possible public Maven Repository, containing LimitedCreative builds and other dependencies without own rep.
|
||||
like AuthMe, etc.
|
||||
Supports http only -->
|
||||
<!-- <repository> - offline
|
||||
<id>de-jas-rep</id>
|
||||
<url>http://repo.ja-s.de/mvn</url>
|
||||
</repository> -->
|
||||
<!-- Local repository for plugins without a repo -->
|
||||
<repository>
|
||||
<id>localRepo</id>
|
||||
<url>file://${project.basedir}/repo</url>
|
||||
</repository>
|
||||
|
||||
<!-- (Craft-)Bukkit repository -->
|
||||
<repository>
|
||||
<id>spigot-repo</id>
|
||||
<url>http://repo.bukkit.org/content/groups/public</url>
|
||||
</repository>
|
||||
<!-- Official WorldGuard and WorldEdit repository -->
|
||||
<repository>
|
||||
<id>sk89q-mvn2</id>
|
||||
<url>http://mvn2.sk89q.com/repo</url>
|
||||
</repository>
|
||||
<!-- Official Multiverse repository -->
|
||||
<repository>
|
||||
<id>onarandombox</id>
|
||||
<url>http://repo.onarandombox.com/content/groups/public</url>
|
||||
</repository>
|
||||
<!-- Official xAuth repository; it is no good! we keep our own dep-files of it - ->
|
||||
<repository>
|
||||
<id>luricos.de-repo</id>
|
||||
<url>http://repo.luricos.de/bukkit-plugins/</url>
|
||||
</repository><!- - -->
|
||||
<!-- Official LogBlock repository -->
|
||||
<repository>
|
||||
<id>md5</id>
|
||||
<url>http://repo.md-5.net/content/groups/public/</url>
|
||||
</repository>
|
||||
<!-- https://github.com/Hidendra/Plugin-Metrics/wiki/Usage -->
|
||||
<repository>
|
||||
<id>Plugin Metrics</id>
|
||||
<url>http://repo.mcstats.org/content/repositories/public</url>
|
||||
</repository>
|
||||
</repositories>
|
||||
<!-- Official (Craft-)Bukkit repository -->
|
||||
<repository>
|
||||
<id>spigot-repo</id>
|
||||
<url>https://hub.spigotmc.org/nexus/content/repositories/snapshots/</url>
|
||||
</repository>
|
||||
<!-- Official WorldGuard and WorldEdit repository -->
|
||||
<repository>
|
||||
<id>sk89q-mvn2</id>
|
||||
<url>https://maven.enginehub.org/repo/</url>
|
||||
</repository>
|
||||
<!-- Official Multiverse repository -->
|
||||
<repository>
|
||||
<id>onarandombox</id>
|
||||
<url>http://repo.onarandombox.com/content/groups/public</url>
|
||||
</repository>
|
||||
<!-- Official xAuth repository; it is no good! we keep our own dep-files of it - ->
|
||||
<repository>
|
||||
<id>luricos.de-repo</id>
|
||||
<url>http://repo.luricos.de/repository/bukkit-plugins/</url>
|
||||
</repository><!- - It points to dependencies that don't exist anymore -->
|
||||
<!-- Official LogBlock repository -->
|
||||
<repository>
|
||||
<id>md5</id>
|
||||
<url>http://repo.md-5.net/content/groups/public/</url>
|
||||
</repository>
|
||||
<!-- Official AuthMe Reloaded repository -->
|
||||
<repository>
|
||||
<id>codemc-repo</id>
|
||||
<url>https://repo.codemc.org/repository/maven-public/</url>
|
||||
</repository>
|
||||
<!-- Official CoreProtect repository -->
|
||||
<repository>
|
||||
<id>coreprotect-repo</id>
|
||||
<url>http://maven.playpro.com/</url>
|
||||
</repository>
|
||||
<!-- Official PermissionsEx repository -->
|
||||
<repository>
|
||||
<id>pex-repo</id>
|
||||
<url>https://repo.glaremasters.me/repository/permissionsex/</url>
|
||||
</repository>
|
||||
</repositories>
|
||||
|
||||
<dependencies>
|
||||
<dependency>
|
||||
<groupId>de.jaschastarke</groupId>
|
||||
<artifactId>plib</artifactId>
|
||||
<version>${plib.version}</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<!-- http://dl.bukkit.org/ -->
|
||||
<groupId>org.bukkit</groupId>
|
||||
<artifactId>bukkit</artifactId>
|
||||
<version>${bukkit.version}</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<!-- http://dev.bukkit.org/server-mods/worldguard/ -->
|
||||
<groupId>com.sk89q</groupId>
|
||||
<artifactId>worldguard</artifactId>
|
||||
<version>6.0.0-SNAPSHOT</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<!-- http://dev.bukkit.org/server-mods/worldedit/ -->
|
||||
<groupId>com.sk89q</groupId>
|
||||
<artifactId>worldedit</artifactId>
|
||||
<version>6.0.0-SNAPSHOT</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<!-- http://dev.bukkit.org/server-mods/authme-reloaded/ -->
|
||||
<groupId>uk.org.whoami</groupId>
|
||||
<artifactId>authme</artifactId>
|
||||
<version>2.9.5</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<!-- http://dev.bukkit.org/server-mods/authme-reloaded/ -->
|
||||
<groupId>fr.xephi</groupId>
|
||||
<artifactId>authme</artifactId>
|
||||
<version>3.0</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<!-- http://dev.bukkit.org/server-mods/multiverse-core/ -->
|
||||
<groupId>com.onarandombox.multiversecore</groupId>
|
||||
<artifactId>Multiverse-Core</artifactId>
|
||||
<version>2.4</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<!-- http://dev.bukkit.org/bukkit-plugins/multiworld-v-2-0/ -->
|
||||
<groupId>multiworld</groupId>
|
||||
<artifactId>multiworld</artifactId>
|
||||
<version>4.7.2</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<!-- http://dev.bukkit.org/server-mods/xauth/ -->
|
||||
<groupId>com.cypherx</groupId>
|
||||
<artifactId>xauth</artifactId>
|
||||
<version>2.0.26</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<!-- https://github.com/Hidendra/Plugin-Metrics/wiki/Usage -->
|
||||
<groupId>org.mcstats.bukkit</groupId>
|
||||
<artifactId>metrics</artifactId>
|
||||
<version>R7</version>
|
||||
<scope>compile</scope>
|
||||
</dependency>
|
||||
</dependencies>
|
||||
<pluginRepositories>
|
||||
<pluginRepository>
|
||||
<id>de-jas-rep</id>
|
||||
<url>http://repo.ja-s.de/mvn</url>
|
||||
</pluginRepository>
|
||||
</pluginRepositories>
|
||||
|
||||
<build>
|
||||
<sourceDirectory>${basedir}/src/main/java</sourceDirectory>
|
||||
<finalName>${project.artifactId}</finalName>
|
||||
<dependencies>
|
||||
<dependency>
|
||||
<groupId>de.jaschastarke</groupId>
|
||||
<artifactId>plib</artifactId>
|
||||
<version>${plib.version}</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<!-- http://dl.bukkit.org/ -->
|
||||
<groupId>org.bukkit</groupId>
|
||||
<artifactId>bukkit</artifactId>
|
||||
<version>${bukkit.version}</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<!-- http://dl.bukkit.org/ -->
|
||||
<groupId>org.bukkit.</groupId> <!-- Needed for WE integration -->
|
||||
<artifactId>bukkit</artifactId>
|
||||
<version>1.14.4-R0.1-SNAPSHOT</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<!-- http://dev.bukkit.org/server-mods/worldguard/ -->
|
||||
<groupId>com.sk89q.worldguard</groupId>
|
||||
<artifactId>worldguard-bukkit</artifactId>
|
||||
<version>7.0.0</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<!-- http://dev.bukkit.org/server-mods/worldguard/ -->
|
||||
<groupId>com.sk89q.worldedit</groupId>
|
||||
<artifactId>worldedit-bukkit</artifactId>
|
||||
<version>7.0.0</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<!-- http://dev.bukkit.org/server-mods/authme-reloaded/ -->
|
||||
<groupId>fr.xephi</groupId>
|
||||
<artifactId>authme</artifactId>
|
||||
<version>5.6.0-SNAPSHOT</version>
|
||||
<scope>provided</scope>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<!-- http://dev.bukkit.org/server-mods/multiverse-core/ -->
|
||||
<groupId>com.onarandombox.multiversecore</groupId>
|
||||
<artifactId>Multiverse-Core</artifactId>
|
||||
<version>2.4</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<!-- http://dev.bukkit.org/bukkit-plugins/multiworld-v-2-0/ -->
|
||||
<groupId>multiworld</groupId>
|
||||
<artifactId>multiworld</artifactId>
|
||||
<version>5.2.8</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<!-- http://dev.bukkit.org/server-mods/xauth/ -->
|
||||
<groupId>de.luricos.bukkit</groupId>
|
||||
<artifactId>xAuth</artifactId>
|
||||
<version>2.0.26</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<!-- http://dev.bukkit.org/bukkit-plugins/coreprotect/ -->
|
||||
<groupId>net.coreprotect</groupId>
|
||||
<artifactId>coreprotect</artifactId>
|
||||
<version>19.1</version>
|
||||
</dependency>
|
||||
<!-- https://mvnrepository.com/artifact/org.avaje/ebean -->
|
||||
<dependency>
|
||||
<groupId>org.avaje</groupId>
|
||||
<artifactId>ebean</artifactId>
|
||||
<version>2.7.3</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.bstats</groupId>
|
||||
<artifactId>bstats-bukkit</artifactId>
|
||||
<version>2.2.1</version>
|
||||
<scope>compile</scope>
|
||||
</dependency>
|
||||
</dependencies>
|
||||
|
||||
<plugins>
|
||||
<plugin>
|
||||
<groupId>org.apache.maven.plugins</groupId>
|
||||
<artifactId>maven-compiler-plugin</artifactId>
|
||||
<version>2.3.2</version>
|
||||
<configuration>
|
||||
<source>1.6</source>
|
||||
<target>1.6</target>
|
||||
<annotationProcessors>
|
||||
<!-- Needed to fetch DocComments from Source -->
|
||||
<annotationProcessor>de.jaschastarke.maven.AnnotationProcessor</annotationProcessor>
|
||||
</annotationProcessors>
|
||||
</configuration>
|
||||
</plugin>
|
||||
<plugin>
|
||||
<groupId>de.jaschastarke</groupId>
|
||||
<artifactId>plib</artifactId>
|
||||
<version>${plib.version}</version>
|
||||
<executions>
|
||||
<execution>
|
||||
<phase>compile</phase>
|
||||
<goals>
|
||||
<goal>pluginyaml</goal>
|
||||
</goals>
|
||||
<configuration>
|
||||
<!-- plugin.yml -->
|
||||
<mainClass>de.jaschastarke.minecraft.limitedcreative.LimitedCreative</mainClass>
|
||||
<softdepend>
|
||||
<param>WorldGuard</param>
|
||||
<param>WorldEdit</param>
|
||||
<param>Multiverse-Core</param>
|
||||
<param>Multiworld</param>
|
||||
<param>xAuth</param>
|
||||
<param>AuthMe</param>
|
||||
<param>MultiInv</param>
|
||||
<param>Multiverse-Inventories</param>
|
||||
<param>Vault</param>
|
||||
</softdepend>
|
||||
<custom>
|
||||
<dev-url>http://dev.bukkit.org/server-mods/limited-creative/</dev-url>
|
||||
</custom>
|
||||
</configuration>
|
||||
</execution>
|
||||
</executions>
|
||||
</plugin>
|
||||
<plugin>
|
||||
<groupId>org.apache.maven.plugins</groupId>
|
||||
<artifactId>maven-shade-plugin</artifactId>
|
||||
<version>2.0</version>
|
||||
<executions>
|
||||
<execution>
|
||||
<phase>package</phase>
|
||||
<goals>
|
||||
<goal>shade</goal>
|
||||
</goals>
|
||||
<configuration>
|
||||
<createDependencyReducedPom>false</createDependencyReducedPom>
|
||||
<artifactSet>
|
||||
<includes>
|
||||
<include>de.jaschastarke:plib</include>
|
||||
<include>org.mcstats.*:*</include>
|
||||
</includes>
|
||||
</artifactSet>
|
||||
<filters>
|
||||
<filter>
|
||||
<artifact>de.jaschastarke:plib</artifact>
|
||||
<excludes>
|
||||
<exclude>de/jaschastarke/maven/**</exclude>
|
||||
<exclude>de/jaschastarke/bukkit/maven/**</exclude>
|
||||
</excludes>
|
||||
</filter>
|
||||
</filters>
|
||||
<relocations>
|
||||
<relocation>
|
||||
<pattern>org.mcstats</pattern>
|
||||
<shadedPattern>de.jaschastarke.minecraft.limitedcreative.metrics</shadedPattern>
|
||||
</relocation>
|
||||
</relocations>
|
||||
</configuration>
|
||||
</execution>
|
||||
</executions>
|
||||
</plugin>
|
||||
</plugins>
|
||||
<build>
|
||||
<sourceDirectory>${basedir}/src/main/java</sourceDirectory>
|
||||
<finalName>${project.artifactId}</finalName>
|
||||
|
||||
<pluginManagement>
|
||||
<plugins>
|
||||
<!--This plugin's configuration is used to store Eclipse m2e settings only. It has no influence on the Maven build itself.-->
|
||||
<plugin>
|
||||
<groupId>org.eclipse.m2e</groupId>
|
||||
<artifactId>lifecycle-mapping</artifactId>
|
||||
<version>1.0.0</version>
|
||||
<configuration>
|
||||
<lifecycleMappingMetadata>
|
||||
<pluginExecutions>
|
||||
<pluginExecution>
|
||||
<pluginExecutionFilter>
|
||||
<groupId>de.jaschastarke</groupId>
|
||||
<artifactId>plib</artifactId>
|
||||
<versionRange>
|
||||
[0.1-SNAPSHOT,)
|
||||
</versionRange>
|
||||
<goals>
|
||||
<goal>pluginyaml</goal>
|
||||
</goals>
|
||||
</pluginExecutionFilter>
|
||||
<action>
|
||||
<ignore></ignore>
|
||||
</action>
|
||||
</pluginExecution>
|
||||
</pluginExecutions>
|
||||
</lifecycleMappingMetadata>
|
||||
</configuration>
|
||||
</plugin>
|
||||
</plugins>
|
||||
</pluginManagement>
|
||||
<extensions>
|
||||
<!-- Enabling the use of SCP -->
|
||||
<extension>
|
||||
<groupId>org.apache.maven.wagon</groupId>
|
||||
<artifactId>wagon-ssh</artifactId>
|
||||
<version>1.0</version>
|
||||
</extension>
|
||||
</extensions>
|
||||
</build>
|
||||
<plugins>
|
||||
<plugin>
|
||||
<groupId>org.apache.maven.plugins</groupId>
|
||||
<artifactId>maven-compiler-plugin</artifactId>
|
||||
<version>3.8.1</version>
|
||||
<configuration>
|
||||
<source>1.8</source>
|
||||
<target>1.8</target>
|
||||
<annotationProcessors>
|
||||
<!-- Needed to fetch DocComments from Source -->
|
||||
<annotationProcessor>de.jaschastarke.maven.AnnotationProcessor</annotationProcessor>
|
||||
</annotationProcessors>
|
||||
</configuration>
|
||||
</plugin>
|
||||
<plugin>
|
||||
<groupId>de.jaschastarke</groupId>
|
||||
<artifactId>plib</artifactId>
|
||||
<version>${plib.version}</version>
|
||||
<executions>
|
||||
<execution>
|
||||
<phase>compile</phase>
|
||||
<goals>
|
||||
<goal>pluginyaml</goal>
|
||||
</goals>
|
||||
<configuration>
|
||||
<!-- plugin.yml -->
|
||||
<mainClass>de.jaschastarke.minecraft.limitedcreative.LimitedCreative</mainClass>
|
||||
<softdepend>
|
||||
<param>WorldGuard</param>
|
||||
<param>WorldEdit</param>
|
||||
<param>Multiverse-Core</param>
|
||||
<param>Multiworld</param>
|
||||
<param>xAuth</param>
|
||||
<param>AuthMe</param>
|
||||
<param>MultiInv</param>
|
||||
<param>Multiverse-Inventories</param>
|
||||
<param>Vault</param>
|
||||
<param>CoreProtect</param>
|
||||
</softdepend>
|
||||
<custom>
|
||||
<dev-url>http://dev.bukkit.org/server-mods/limited-creative/</dev-url>
|
||||
</custom>
|
||||
</configuration>
|
||||
</execution>
|
||||
</executions>
|
||||
</plugin>
|
||||
<plugin>
|
||||
<groupId>org.apache.maven.plugins</groupId>
|
||||
<artifactId>maven-shade-plugin</artifactId>
|
||||
<version>3.2.4</version>
|
||||
<executions>
|
||||
<execution>
|
||||
<phase>package</phase>
|
||||
<goals>
|
||||
<goal>shade</goal>
|
||||
</goals>
|
||||
<configuration>
|
||||
<createDependencyReducedPom>false</createDependencyReducedPom>
|
||||
<artifactSet>
|
||||
<includes>
|
||||
<include>de.jaschastarke:plib</include>
|
||||
<include>org.bstats</include>
|
||||
</includes>
|
||||
</artifactSet>
|
||||
<filters>
|
||||
<filter>
|
||||
<artifact>de.jaschastarke:plib</artifact>
|
||||
<excludes>
|
||||
<exclude>de/jaschastarke/maven/**</exclude>
|
||||
<exclude>de/jaschastarke/bukkit/maven/**</exclude>
|
||||
</excludes>
|
||||
</filter>
|
||||
</filters>
|
||||
<relocations>
|
||||
<relocation>
|
||||
<pattern>org.bstats</pattern>
|
||||
<shadedPattern>de.jaschastarke.minecraft.limitedcreative.bstats</shadedPattern>
|
||||
</relocation>
|
||||
</relocations>
|
||||
</configuration>
|
||||
</execution>
|
||||
</executions>
|
||||
</plugin>
|
||||
</plugins>
|
||||
|
||||
<pluginManagement>
|
||||
<plugins>
|
||||
<!--This plugin's configuration is used to store Eclipse m2e settings only. It has no influence on the Maven build itself.-->
|
||||
<plugin>
|
||||
<groupId>org.eclipse.m2e</groupId>
|
||||
<artifactId>lifecycle-mapping</artifactId>
|
||||
<version>1.0.0</version>
|
||||
<configuration>
|
||||
<lifecycleMappingMetadata>
|
||||
<pluginExecutions>
|
||||
<pluginExecution>
|
||||
<pluginExecutionFilter>
|
||||
<groupId>de.jaschastarke</groupId>
|
||||
<artifactId>plib</artifactId>
|
||||
<versionRange>
|
||||
[0.1-SNAPSHOT,)
|
||||
</versionRange>
|
||||
<goals>
|
||||
<goal>pluginyaml</goal>
|
||||
</goals>
|
||||
</pluginExecutionFilter>
|
||||
<action>
|
||||
<ignore/>
|
||||
</action>
|
||||
</pluginExecution>
|
||||
</pluginExecutions>
|
||||
</lifecycleMappingMetadata>
|
||||
</configuration>
|
||||
</plugin>
|
||||
</plugins>
|
||||
</pluginManagement>
|
||||
<extensions>
|
||||
<!-- Enabling the use of SCP -->
|
||||
<extension>
|
||||
<groupId>org.apache.maven.wagon</groupId>
|
||||
<artifactId>wagon-ssh</artifactId>
|
||||
<version>2.1</version>
|
||||
</extension>
|
||||
</extensions>
|
||||
</build>
|
||||
</project>
|
||||
|
|
|
@ -74,11 +74,11 @@ public class FeatureBlockItemSpawn extends CoreModule<LimitedCreative> implement
|
|||
}
|
||||
|
||||
public void block(Block block, Player player) {
|
||||
if (player.getItemInHand().containsEnchantment(Enchantment.SILK_TOUCH)) {
|
||||
if (player.getInventory().getItemInMainHand().containsEnchantment(Enchantment.SILK_TOUCH)) {
|
||||
block(block.getLocation(), block.getType());
|
||||
} else {
|
||||
// doesn't include silktouch
|
||||
for (ItemStack i : block.getDrops(player.getItemInHand())) {
|
||||
for (ItemStack i : block.getDrops(player.getInventory().getItemInMainHand())) {
|
||||
block(block.getLocation(), i.getType());
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,70 +1,46 @@
|
|||
package de.jaschastarke.minecraft.limitedcreative;
|
||||
|
||||
import java.io.IOException;
|
||||
|
||||
import org.bukkit.event.Listener;
|
||||
import org.mcstats.Metrics;
|
||||
|
||||
import de.jaschastarke.bukkit.lib.CoreModule;
|
||||
import de.jaschastarke.bukkit.tools.stats.IStatistics;
|
||||
import de.jaschastarke.bukkit.tools.stats.PiwikStatistics;
|
||||
import de.jaschastarke.modularize.IModule;
|
||||
import de.jaschastarke.modularize.ModuleEntry;
|
||||
import de.jaschastarke.modularize.ModuleEntry.ModuleState;
|
||||
import org.bstats.bukkit.Metrics;
|
||||
import org.bstats.charts.AdvancedPie;
|
||||
import org.bukkit.event.Listener;
|
||||
|
||||
import java.util.HashMap;
|
||||
|
||||
public class FeatureMetrics extends CoreModule<LimitedCreative> implements Listener {
|
||||
public FeatureMetrics(LimitedCreative plugin) {
|
||||
super(plugin);
|
||||
}
|
||||
private IStatistics metric;
|
||||
private Metrics mcstats = null;
|
||||
|
||||
private Metrics bstats = null;
|
||||
|
||||
@Override
|
||||
public void onEnable() {
|
||||
super.onEnable();
|
||||
metric = new PiwikStatistics(plugin);
|
||||
if (mcstats == null) {
|
||||
try {
|
||||
mcstats = new Metrics(plugin);
|
||||
if (bstats == null) {
|
||||
bstats = new Metrics(plugin, 10413);
|
||||
|
||||
Metrics.Graph moduleGraph = mcstats.createGraph("Module Usage");
|
||||
for (final ModuleEntry<IModule> mod : plugin.getModules()) {
|
||||
if (mod.getModule() instanceof CoreModule<?>) {
|
||||
moduleGraph.addPlotter(new Metrics.Plotter(((CoreModule<?>) mod.getModule()).getName()) {
|
||||
@Override
|
||||
public int getValue() {
|
||||
return mod.getState() == ModuleState.ENABLED ? 1 : 0;
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
Metrics.Graph depGraph = mcstats.createGraph("Dependencies");
|
||||
for (final String dep : plugin.getDescription().getSoftDepend()) {
|
||||
depGraph.addPlotter(new Metrics.Plotter(dep) {
|
||||
@Override
|
||||
public int getValue() {
|
||||
return plugin.getServer().getPluginManager().isPluginEnabled(dep) ? 1 : 0;
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
mcstats.start();
|
||||
} catch (IOException e) {
|
||||
// Failed to submit the stats :-(
|
||||
getLog().warn("MCStats-Error: " + e.getMessage());
|
||||
}
|
||||
bstats.addCustomChart(new AdvancedPie("module_usage", () -> {
|
||||
HashMap<String, Integer> ret = new HashMap<>();
|
||||
for (final ModuleEntry<IModule> mod : plugin.getModules())
|
||||
if (mod.getModule() instanceof CoreModule<?>)
|
||||
ret.put(((CoreModule<?>) mod.getModule()).getName(), mod.getState() == ModuleState.ENABLED ? 1 : 0);
|
||||
return ret;
|
||||
}));
|
||||
bstats.addCustomChart(new AdvancedPie("dependencies", () -> {
|
||||
HashMap<String, Integer> ret = new HashMap<>();
|
||||
for (final String dep : plugin.getDescription().getSoftDepend())
|
||||
ret.put(dep, plugin.getServer().getPluginManager().isPluginEnabled(dep) ? 1 : 0);
|
||||
return ret;
|
||||
}));
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onDisable() {
|
||||
super.onDisable();
|
||||
metric.unregister();
|
||||
}
|
||||
|
||||
public void track(String event) throws IOException {
|
||||
if (metric == null)
|
||||
throw new IllegalAccessError("The feature hasn't been enabled");
|
||||
metric.trackEvent(event);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,13 +1,12 @@
|
|||
package de.jaschastarke.minecraft.limitedcreative;
|
||||
|
||||
import org.bukkit.Bukkit;
|
||||
|
||||
import de.jaschastarke.hooking.BooleanHooker;
|
||||
import de.jaschastarke.hooking.GetHooker;
|
||||
import de.jaschastarke.minecraft.limitedcreative.hooks.MultiVerseHooks;
|
||||
import de.jaschastarke.minecraft.limitedcreative.hooks.PlayerCheckHooker;
|
||||
import de.jaschastarke.minecraft.limitedcreative.hooks.WorldTypeHooker;
|
||||
import de.jaschastarke.minecraft.limitedcreative.hooks.xAuthHooks;
|
||||
import org.bukkit.Bukkit;
|
||||
|
||||
public final class Hooks {
|
||||
public static PlayerCheckHooker IsLoggedIn = new PlayerCheckHooker(true);
|
||||
|
@ -53,7 +52,8 @@ public final class Hooks {
|
|||
public static boolean isAuthMePresent() {
|
||||
if (isPluginEnabled("AuthMe")) {
|
||||
try {
|
||||
return Class.forName("uk.org.whoami.authme.api.API") != null;
|
||||
Class.forName("uk.org.whoami.authme.api.API");
|
||||
return true;
|
||||
} catch (ClassNotFoundException e) {
|
||||
return false;
|
||||
}
|
||||
|
@ -64,7 +64,8 @@ public final class Hooks {
|
|||
public static boolean isXAuth20Present() {
|
||||
if (isPluginEnabled("xAuth")) {
|
||||
try {
|
||||
return Class.forName("com.cypherx.xauth.xAuth") != null;
|
||||
Class.forName("com.cypherx.xauth.xAuth");
|
||||
return true;
|
||||
} catch (ClassNotFoundException e) {
|
||||
return false;
|
||||
}
|
||||
|
|
|
@ -1,23 +1,18 @@
|
|||
package de.jaschastarke.minecraft.limitedcreative;
|
||||
|
||||
import java.io.File;
|
||||
import java.util.Map;
|
||||
import java.util.WeakHashMap;
|
||||
|
||||
import de.jaschastarke.bukkit.lib.CoreModule;
|
||||
import de.jaschastarke.minecraft.limitedcreative.inventories.*;
|
||||
import de.jaschastarke.minecraft.limitedcreative.inventories.store.PlayerInventoryStorage;
|
||||
import de.jaschastarke.minecraft.limitedcreative.inventories.store.ReflectionStorage;
|
||||
import de.jaschastarke.modularize.IModule;
|
||||
import de.jaschastarke.modularize.ModuleEntry;
|
||||
import org.bukkit.GameMode;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.inventory.ItemStack;
|
||||
|
||||
import de.jaschastarke.bukkit.lib.CoreModule;
|
||||
import de.jaschastarke.minecraft.limitedcreative.inventories.ArmoryConfig;
|
||||
import de.jaschastarke.minecraft.limitedcreative.inventories.Inventory;
|
||||
import de.jaschastarke.minecraft.limitedcreative.inventories.InventoryConfig;
|
||||
import de.jaschastarke.minecraft.limitedcreative.inventories.InventoryPermissions;
|
||||
import de.jaschastarke.minecraft.limitedcreative.inventories.PlayerListener;
|
||||
import de.jaschastarke.minecraft.limitedcreative.inventories.store.InvYamlStorage;
|
||||
import de.jaschastarke.minecraft.limitedcreative.inventories.store.PlayerInventoryStorage;
|
||||
import de.jaschastarke.modularize.IModule;
|
||||
import de.jaschastarke.modularize.ModuleEntry;
|
||||
import java.io.File;
|
||||
import java.util.Map;
|
||||
import java.util.WeakHashMap;
|
||||
|
||||
public class ModInventories extends CoreModule<LimitedCreative> {
|
||||
protected PlayerInventoryStorage storage;
|
||||
|
@ -33,7 +28,6 @@ public class ModInventories extends CoreModule<LimitedCreative> {
|
|||
return "Inventory";
|
||||
}
|
||||
|
||||
@SuppressWarnings("deprecation")
|
||||
@Override
|
||||
public void initialize(ModuleEntry<IModule> entry) {
|
||||
super.initialize(entry);
|
||||
|
@ -57,7 +51,8 @@ public class ModInventories extends CoreModule<LimitedCreative> {
|
|||
throw new IllegalAccessError(plugin.getLocale().trans("inventory.warning.conflict", incomp, this.getName()));
|
||||
}
|
||||
super.onEnable();
|
||||
storage = new InvYamlStorage(this, new File(plugin.getDataFolder(), config.getFolder()));
|
||||
//storage = new InvYamlStorage(this, new File(plugin.getDataFolder(), config.getFolder()));
|
||||
storage = new ReflectionStorage(this, new File(plugin.getDataFolder(), config.getFolder()));
|
||||
inventories = new WeakHashMap<Player, Inventory>();
|
||||
getLog().info(plugin.getLocale().trans("basic.loaded.module"));
|
||||
}
|
||||
|
|
|
@ -1,6 +1,5 @@
|
|||
package de.jaschastarke.minecraft.limitedcreative.blockstate;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Date;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
@ -144,19 +143,15 @@ public class BlockListener implements Listener {
|
|||
return;
|
||||
event.getBlock().setMetadata("LCBS_pistonIsAlreadyExtended", blockAlreadExtended);
|
||||
|
||||
Block source = event.getBlock().getRelative(event.getDirection());
|
||||
/*if (mod.isDebug())
|
||||
mod.getLog().debug("PistonExtend "+source.getType()+" "+source.getLocation()+" "+event.getDirection());*/
|
||||
|
||||
List<Block> movedBlocks = new ArrayList<Block>();
|
||||
while (source != null && source.getType() != Material.AIR) {
|
||||
movedBlocks.add(0, source); // put on top, so iterating the
|
||||
source = source.getRelative(event.getDirection());
|
||||
}
|
||||
List<Block> movedBlocks = event.getBlocks();
|
||||
|
||||
if (movedBlocks.size() > 0) {
|
||||
DBTransaction update = mod.getModel().groupUpdate();
|
||||
for (Block sblock : movedBlocks) {
|
||||
for(int count = movedBlocks.size()-1; count >= 0; count--){
|
||||
Block sblock = movedBlocks.get(count);
|
||||
Block dest = sblock.getRelative(event.getDirection());
|
||||
if (mod.isDebug())
|
||||
mod.getLog().debug("PistionExtend moves "+sblock.getType()+"-Block from "+sblock.getLocation()+" to "+dest.getLocation());
|
||||
|
@ -173,12 +168,19 @@ public class BlockListener implements Listener {
|
|||
return;
|
||||
event.getBlock().removeMetadata("LCBS_pistonIsAlreadyExtended", mod.getPlugin());
|
||||
|
||||
Block dest = event.getBlock().getRelative(event.getDirection());
|
||||
Block source = dest.getRelative(event.getDirection());
|
||||
if (event.isSticky() && source.getType() != Material.AIR) {
|
||||
if (mod.isDebug())
|
||||
mod.getLog().debug("PistionRetract moves "+source.getType()+"-Block from "+source.getLocation()+" to "+dest.getLocation());
|
||||
mod.getModel().moveState(source, source.getRelative(event.getDirection().getOppositeFace()));
|
||||
List<Block> movedBlocks = event.getBlocks();
|
||||
if(movedBlocks.size() > 0)
|
||||
{
|
||||
DBTransaction update = mod.getModel().groupUpdate();
|
||||
for(int count = movedBlocks.size()-1; count >= 0; count--){
|
||||
Block sblock = movedBlocks.get(count);
|
||||
Block dest = sblock.getRelative(event.getDirection());
|
||||
if (mod.isDebug())
|
||||
mod.getLog().debug("PistionRetract moves "+sblock.getType()+"-Block from "+sblock.getLocation()+" to "+dest.getLocation());
|
||||
|
||||
update.moveState(sblock, dest);
|
||||
}
|
||||
update.finish();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,6 +1,7 @@
|
|||
package de.jaschastarke.minecraft.limitedcreative.blockstate;
|
||||
|
||||
import java.util.Date;
|
||||
import java.util.UUID;
|
||||
|
||||
import javax.persistence.Column;
|
||||
//import javax.persistence.EmbeddedId;
|
||||
|
@ -37,7 +38,7 @@ public class BlockState {
|
|||
private GameMode gameMode;
|
||||
|
||||
@Column(name = "player")
|
||||
private String playerName;
|
||||
private UUID uuid;
|
||||
|
||||
@NotNull
|
||||
@Column(name = "cdate")
|
||||
|
@ -51,7 +52,7 @@ public class BlockState {
|
|||
public BlockState(BlockState copy) {
|
||||
this.location = copy.location;
|
||||
this.gameMode = copy.gameMode;
|
||||
this.playerName = copy.playerName;
|
||||
this.uuid = copy.uuid;
|
||||
this.date = copy.date;
|
||||
this.source = copy.source;
|
||||
}
|
||||
|
@ -72,24 +73,35 @@ public class BlockState {
|
|||
this.gameMode = gm;
|
||||
}
|
||||
|
||||
public String getPlayerName() {
|
||||
return playerName;
|
||||
public UUID getPlayerUUID() {
|
||||
return uuid;
|
||||
}
|
||||
|
||||
public void setPlayerName(String s) {
|
||||
playerName = s;
|
||||
public String getPlayerName() {
|
||||
return Bukkit.getOfflinePlayer(uuid).getName();
|
||||
}
|
||||
|
||||
//TODO Rename
|
||||
@SuppressWarnings("deprecation")
|
||||
public void setPlayerNameOrUUID(String s) {
|
||||
if(s==null)
|
||||
uuid=null;
|
||||
else if(!s.matches("^[0-9a-fA-F]{8}-[0-9a-fA-F]{4}-[0-9a-fA-F]{4}-[0-9a-fA-F]{4}-[0-9a-fA-F]{12}$"))
|
||||
uuid = Bukkit.getOfflinePlayer(s).getUniqueId(); //If it's a name, get UUID
|
||||
else
|
||||
uuid = UUID.fromString(s);
|
||||
}
|
||||
|
||||
public OfflinePlayer getPlayer() {
|
||||
OfflinePlayer p = Bukkit.getPlayerExact(playerName);
|
||||
OfflinePlayer p = Bukkit.getPlayer(uuid);
|
||||
if (p == null)
|
||||
p = Bukkit.getOfflinePlayer(playerName);
|
||||
p = Bukkit.getOfflinePlayer(uuid);
|
||||
return p;
|
||||
}
|
||||
|
||||
public void setPlayer(OfflinePlayer player) {
|
||||
setSource(Source.PLAYER);
|
||||
this.playerName = player.getName();
|
||||
this.uuid = player.getUniqueId();
|
||||
if (player instanceof Player) {
|
||||
setGameMode(((Player) player).getGameMode());
|
||||
}
|
||||
|
@ -109,7 +121,7 @@ public class BlockState {
|
|||
|
||||
public void setSource(Source source) {
|
||||
if (source != Source.PLAYER && source != Source.EDIT && source != Source.COMMAND)
|
||||
setPlayerName(null);
|
||||
setPlayerNameOrUUID(null);
|
||||
this.source = source;
|
||||
}
|
||||
|
||||
|
@ -119,6 +131,7 @@ public class BlockState {
|
|||
|
||||
@Override
|
||||
public String toString() {
|
||||
String playerName = Bukkit.getOfflinePlayer(uuid).getName();
|
||||
//return blockLocation.toString() + " by " +
|
||||
return location.toString() + " by " +
|
||||
(source == Source.PLAYER ? playerName : (source.toString() + (playerName != null ? "(" + playerName + ")" : ""))) +
|
||||
|
|
|
@ -1,25 +1,14 @@
|
|||
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 org.bukkit.scheduler.BukkitRunnable;
|
||||
|
||||
import com.sk89q.worldedit.bukkit.WorldEditPlugin;
|
||||
import com.sk89q.worldedit.bukkit.selections.Selection;
|
||||
|
||||
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.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.*;
|
||||
import de.jaschastarke.bukkit.lib.commands.annotations.IsCommand;
|
||||
import de.jaschastarke.bukkit.lib.commands.annotations.Usages;
|
||||
import de.jaschastarke.bukkit.lib.commands.parser.DefinedParameterParser;
|
||||
|
@ -34,6 +23,11 @@ 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)
|
||||
|
@ -105,7 +99,7 @@ public class BlockStateCommand extends BukkitCommand implements IHelpDescribed {
|
|||
if (mod.getConfig().getLogSurvival()) {
|
||||
context.responseFormatted(ChatFormattings.INFO, L("command.blockstate.nothing_to_cleanup"));
|
||||
} else {
|
||||
mod.getPlugin().getServer().getScheduler().runTaskAsynchronously(mod.getPlugin(), new BukkitRunnable() {
|
||||
mod.getPlugin().getServer().getScheduler().runTaskAsynchronously(mod.getPlugin(), new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
int countDeleted = mod.getModel().cleanUp(DBModel.Cleanup.SURVIVAL);
|
||||
|
@ -157,52 +151,56 @@ public class BlockStateCommand extends BukkitCommand implements IHelpDescribed {
|
|||
return false;
|
||||
}
|
||||
|
||||
WorldEditPlugin we = (WorldEditPlugin) mod.getPlugin().getServer().getPluginManager().getPlugin("WorldEdit");
|
||||
final Selection selection = we.getSelection(context.getPlayer());
|
||||
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 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 BukkitRunnable() {
|
||||
@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();
|
||||
mod.getPlugin().getServer().getScheduler().runTaskAsynchronously(mod.getPlugin(), () -> {
|
||||
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(min);
|
||||
c.add(max);
|
||||
mod.getModel().cacheStates(c);
|
||||
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++) {
|
||||
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++;
|
||||
}
|
||||
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));
|
||||
}
|
||||
update.finish();
|
||||
|
||||
context.response(L("command.blockstate.command_updated", count));
|
||||
});
|
||||
return true;
|
||||
}
|
||||
|
|
|
@ -131,7 +131,7 @@ public class CreativeControlImportThread extends DatabaseMigrationThread {
|
|||
bs.setLocation(new Location(c.getWorld(), rs.getInt("x"), rs.getInt("y"), rs.getInt("z")));
|
||||
bs.setDate(new Date(rs.getLong("time")));
|
||||
bs.setGameMode(GameMode.CREATIVE);
|
||||
bs.setPlayerName(rs.getString("player"));
|
||||
bs.setPlayerNameOrUUID(rs.getString("player"));
|
||||
bs.setSource(Source.PLAYER);
|
||||
return bs;
|
||||
}
|
||||
|
|
|
@ -42,7 +42,7 @@ public class DBQueries {
|
|||
bs.setLocation(loc);
|
||||
bs.setDate(rs.getTimestamp("cdate"));
|
||||
bs.setGameMode(getGameMode(rs));
|
||||
bs.setPlayerName(rs.getString("player"));
|
||||
bs.setPlayerNameOrUUID(rs.getString("player"));
|
||||
bs.setSource(getSource(rs));
|
||||
rs.close();
|
||||
return bs;
|
||||
|
@ -72,7 +72,7 @@ public class DBQueries {
|
|||
bs.setLocation(new Location(c.getWorld(), rs.getInt("x"), rs.getInt("y"), rs.getInt("z")));
|
||||
bs.setDate(rs.getTimestamp("cdate"));
|
||||
bs.setGameMode(getGameMode(rs));
|
||||
bs.setPlayerName(rs.getString("player"));
|
||||
bs.setPlayerNameOrUUID(rs.getString("player"));
|
||||
bs.setSource(getSource(rs));
|
||||
blocks.add(bs);
|
||||
}
|
||||
|
@ -100,7 +100,7 @@ public class DBQueries {
|
|||
bs.setLocation(new Location(c.getWorld(), rs.getInt("x"), rs.getInt("y"), rs.getInt("z")));
|
||||
bs.setDate(rs.getTimestamp("cdate"));
|
||||
bs.setGameMode(getGameMode(rs));
|
||||
bs.setPlayerName(rs.getString("player"));
|
||||
bs.setPlayerNameOrUUID(rs.getString("player"));
|
||||
bs.setSource(getSource(rs));
|
||||
return bs;
|
||||
}
|
||||
|
@ -138,7 +138,7 @@ public class DBQueries {
|
|||
update.setString(1, s.getGameMode().name());
|
||||
else
|
||||
update.setInt(1, s.getGameMode().getValue());
|
||||
update.setString(2, s.getPlayerName());
|
||||
update.setString(2, s.getPlayerUUID().toString());
|
||||
update.setTimestamp(3, new java.sql.Timestamp(s.getDate().getTime()));
|
||||
if (db.getType() == Type.MySQL)
|
||||
update.setString(4, s.getSource().name());
|
||||
|
@ -207,7 +207,7 @@ public class DBQueries {
|
|||
insert.setString(5, s.getGameMode().name());
|
||||
else
|
||||
insert.setInt(5, s.getGameMode().getValue());
|
||||
insert.setString(6, s.getPlayerName());
|
||||
insert.setString(6, s.getPlayerUUID().toString());
|
||||
insert.setTimestamp(7, new java.sql.Timestamp(s.getDate().getTime()));
|
||||
if (db.getType() == Type.MySQL)
|
||||
insert.setString(8, s.getSource().name());
|
||||
|
|
|
@ -11,7 +11,6 @@ import org.bukkit.entity.Player;
|
|||
import org.bukkit.event.EventHandler;
|
||||
import org.bukkit.event.EventPriority;
|
||||
import org.bukkit.event.Listener;
|
||||
import org.bukkit.event.entity.CreatureSpawnEvent;
|
||||
import org.bukkit.event.entity.EntityDamageByEntityEvent;
|
||||
import org.bukkit.event.entity.EntityDeathEvent;
|
||||
import org.bukkit.event.hanging.HangingBreakEvent;
|
||||
|
|
|
@ -29,7 +29,7 @@ public class PlayerListener implements Listener {
|
|||
public void onInteract(PlayerInteractEvent event) {
|
||||
if (event.getAction() == Action.RIGHT_CLICK_BLOCK) {
|
||||
Block b = event.getClickedBlock();
|
||||
if (b != null && event.getPlayer().getItemInHand().getType().equals(mod.getConfig().getTool()) && mod.getPlugin().getPermManager().hasPermission(event.getPlayer(), BlockStatePermissions.TOOL)) {
|
||||
if (b != null && event.getPlayer().getInventory().getItemInMainHand().getType().equals(mod.getConfig().getTool()) && mod.getPlugin().getPermManager().hasPermission(event.getPlayer(), BlockStatePermissions.TOOL)) {
|
||||
if (mod.getConfig().getIgnoredWorlds().contains(event.getClickedBlock().getWorld().getName())) {
|
||||
event.getPlayer().sendMessage(mod.getPlugin().getLocale().trans("command.blockstate.world_ignored", event.getClickedBlock().getWorld().getName()));
|
||||
} else {
|
||||
|
@ -41,7 +41,7 @@ public class PlayerListener implements Listener {
|
|||
@EventHandler(priority = EventPriority.HIGH)
|
||||
public void onInteractEntity(PlayerInteractEntityEvent event) {
|
||||
Entity e = event.getRightClicked();
|
||||
if (e != null && e instanceof ItemFrame && event.getPlayer().getItemInHand().getType().equals(mod.getConfig().getTool()) && mod.getPlugin().getPermManager().hasPermission(event.getPlayer(), BlockStatePermissions.TOOL)) {
|
||||
if (e != null && e instanceof ItemFrame && event.getPlayer().getInventory().getItemInMainHand().getType().equals(mod.getConfig().getTool()) && mod.getPlugin().getPermManager().hasPermission(event.getPlayer(), BlockStatePermissions.TOOL)) {
|
||||
if (mod.getConfig().getIgnoredWorlds().contains(e.getWorld().getName())) {
|
||||
event.getPlayer().sendMessage(mod.getPlugin().getLocale().trans("command.blockstate.world_ignored", e.getWorld().getName()));
|
||||
} else {
|
||||
|
|
|
@ -1,22 +1,21 @@
|
|||
package de.jaschastarke.minecraft.limitedcreative.blockstate.thread;
|
||||
|
||||
import de.jaschastarke.bukkit.lib.ModuleLogger;
|
||||
import de.jaschastarke.minecraft.limitedcreative.ModBlockStates;
|
||||
import de.jaschastarke.minecraft.limitedcreative.blockstate.AbstractModel.HasBlockState;
|
||||
import de.jaschastarke.minecraft.limitedcreative.blockstate.BlockState;
|
||||
import de.jaschastarke.minecraft.limitedcreative.blockstate.DBModel.Cuboid;
|
||||
import de.jaschastarke.minecraft.limitedcreative.blockstate.DBQueries;
|
||||
import de.jaschastarke.minecraft.limitedcreative.blockstate.ThreadedModel;
|
||||
import org.bukkit.Chunk;
|
||||
import org.bukkit.Location;
|
||||
import org.bukkit.block.Block;
|
||||
|
||||
import java.lang.Thread.UncaughtExceptionHandler;
|
||||
import java.util.LinkedList;
|
||||
import java.util.List;
|
||||
import java.util.Stack;
|
||||
|
||||
import org.bukkit.Chunk;
|
||||
import org.bukkit.Location;
|
||||
import org.bukkit.block.Block;
|
||||
|
||||
import de.jaschastarke.bukkit.lib.ModuleLogger;
|
||||
import de.jaschastarke.minecraft.limitedcreative.ModBlockStates;
|
||||
import de.jaschastarke.minecraft.limitedcreative.blockstate.BlockState;
|
||||
import de.jaschastarke.minecraft.limitedcreative.blockstate.AbstractModel.HasBlockState;
|
||||
import de.jaschastarke.minecraft.limitedcreative.blockstate.DBModel.Cuboid;
|
||||
import de.jaschastarke.minecraft.limitedcreative.blockstate.DBQueries;
|
||||
import de.jaschastarke.minecraft.limitedcreative.blockstate.ThreadedModel;
|
||||
|
||||
public class ThreadLink {
|
||||
private static final int BATCH_ACTION_LENGTH = 25;
|
||||
private static final int QUEUE_ACCESS_WARNING_DURATION = 5; // ms
|
||||
|
@ -24,10 +23,11 @@ public class ThreadLink {
|
|||
private static final int COUNT_ERROR_QUEUE = 20;
|
||||
private static final int QUEUE_TIMING_DURATION = 500; // ms
|
||||
private static final int STARTUP_TIMING = 30000; // ms
|
||||
private static final int THREAD_SHUTDOWN_WAIT_MS = 30000;
|
||||
private long lastTimeout;
|
||||
private Stack<Action> updateQueue = new Stack<Action>();
|
||||
private final Stack<Action> updateQueue = new Stack<Action>();
|
||||
|
||||
private boolean shutdown = false;
|
||||
private boolean shutdown;
|
||||
private ModuleLogger log;
|
||||
private ThreadedModel model;
|
||||
private Thread thread;
|
||||
|
@ -39,15 +39,8 @@ public class ThreadLink {
|
|||
/*
|
||||
* In theory we could add multiple threads, e.g. 1 write and 2 read threads.
|
||||
*/
|
||||
thread = new DBThread(queries);
|
||||
thread.setName("LC BlockState DB-Thread");
|
||||
thread.setUncaughtExceptionHandler(new UncaughtExceptionHandler() {
|
||||
@Override
|
||||
public void uncaughtException(Thread thread, Throwable e) {
|
||||
e.printStackTrace();
|
||||
log.severe("Thread " + thread.getName() + " encoutered an uncaught Exception: " + e.getMessage());
|
||||
}
|
||||
});
|
||||
createThread(queries);
|
||||
shutdown = true; //Don't allow the thread to run until it's started
|
||||
}
|
||||
|
||||
private class DBThread extends Thread {
|
||||
|
@ -62,6 +55,8 @@ public class ThreadLink {
|
|||
lastTimeout = System.currentTimeMillis() + STARTUP_TIMING;
|
||||
while (!shutdown || !updateQueue.isEmpty()) {
|
||||
try {
|
||||
//Thread.sleep(1000);
|
||||
//throw new RuntimeException("Test exception pls ignore");
|
||||
List<Action> acts = new LinkedList<Action>();
|
||||
synchronized (updateQueue) {
|
||||
while (updateQueue.isEmpty() && !shutdown)
|
||||
|
@ -91,6 +86,7 @@ public class ThreadLink {
|
|||
for (Action act : acts) {
|
||||
if (!shutdown || !(act instanceof CacheChunkAction)) {
|
||||
if (act instanceof CallableAction) {
|
||||
//noinspection SynchronizationOnLocalVariableOrMethodParameter
|
||||
synchronized (act) {
|
||||
act.process(ThreadLink.this, this.q);
|
||||
act.notify();
|
||||
|
@ -104,7 +100,7 @@ public class ThreadLink {
|
|||
log.debug("DB-Thread '" + Thread.currentThread().getName() + "' execution time: " + (System.currentTimeMillis() - t) + "ms");
|
||||
} catch (InterruptedException e) {
|
||||
e.printStackTrace();
|
||||
log.severe("DB-Thread '" + Thread.currentThread().getName() + "' was harmfull interupted");
|
||||
log.severe("DB-Thread '" + Thread.currentThread().getName() + "' was harmfully interupted");
|
||||
}
|
||||
Thread.yield();
|
||||
}
|
||||
|
@ -114,42 +110,47 @@ public class ThreadLink {
|
|||
}
|
||||
|
||||
public void start() {
|
||||
shutdown = false;
|
||||
if (!thread.isAlive())
|
||||
thread.start();
|
||||
}
|
||||
|
||||
|
||||
public void queueUpdate(Block block) {
|
||||
restartThreadIfNeeded();
|
||||
long l = System.currentTimeMillis();
|
||||
synchronized (updateQueue) {
|
||||
updateQueue.add(new UpdateBlockStateAction(block));
|
||||
updateQueue.notify();
|
||||
updateQueue.notifyAll();
|
||||
}
|
||||
long l2 = System.currentTimeMillis();
|
||||
if (l2 - l > QUEUE_ACCESS_WARNING_DURATION) {
|
||||
getLog().warn("queueUpdate-action took to long: " + (l - 2) + "ms");
|
||||
getLog().warn("queueUpdate-action took too long: " + (l2 - l) + "ms");
|
||||
}
|
||||
}
|
||||
|
||||
public BlockState callUpdate(Block block) {
|
||||
restartThreadIfNeeded();
|
||||
FetchBlockStateAction action = new FetchBlockStateAction(block);
|
||||
synchronized (updateQueue) {
|
||||
updateQueue.push(action);
|
||||
updateQueue.notify();
|
||||
updateQueue.notifyAll();
|
||||
}
|
||||
return action.getValue();
|
||||
}
|
||||
|
||||
public void queue(Action act) {
|
||||
restartThreadIfNeeded();
|
||||
synchronized (updateQueue) {
|
||||
updateQueue.add(act);
|
||||
updateQueue.notify();
|
||||
updateQueue.notifyAll();
|
||||
}
|
||||
}
|
||||
public <T> T call(CallableAction<T> act) {
|
||||
restartThreadIfNeeded();
|
||||
synchronized (updateQueue) {
|
||||
updateQueue.push(act);
|
||||
updateQueue.notify();
|
||||
updateQueue.notifyAll();
|
||||
}
|
||||
return act.getValue();
|
||||
}
|
||||
|
@ -158,38 +159,43 @@ public class ThreadLink {
|
|||
FetchCuboidAction action = new FetchCuboidAction(c);
|
||||
synchronized (updateQueue) {
|
||||
updateQueue.push(action);
|
||||
updateQueue.notify();
|
||||
updateQueue.notifyAll();
|
||||
}
|
||||
return action.getValue();
|
||||
}
|
||||
|
||||
public void queueMetaMove(Location from, Location to) {
|
||||
restartThreadIfNeeded();
|
||||
synchronized (updateQueue) {
|
||||
updateQueue.add(new MoveBlockStateAction(from, to));
|
||||
updateQueue.notify();
|
||||
updateQueue.notifyAll();
|
||||
}
|
||||
}
|
||||
|
||||
public void queueChunkLoad(Chunk chunk) {
|
||||
restartThreadIfNeeded();
|
||||
synchronized (updateQueue) {
|
||||
updateQueue.add(new CacheChunkAction(chunk));
|
||||
updateQueue.notify();
|
||||
updateQueue.notifyAll();
|
||||
}
|
||||
}
|
||||
|
||||
public void queueTransaction(Transaction transaction) {
|
||||
restartThreadIfNeeded();
|
||||
synchronized (updateQueue) {
|
||||
updateQueue.add(transaction);
|
||||
updateQueue.notify();
|
||||
updateQueue.notifyAll();
|
||||
}
|
||||
}
|
||||
|
||||
public void shutdown() throws InterruptedException {
|
||||
synchronized (updateQueue) {
|
||||
shutdown = true;
|
||||
updateQueue.notify();
|
||||
updateQueue.notifyAll();
|
||||
}
|
||||
thread.join();
|
||||
thread.join(THREAD_SHUTDOWN_WAIT_MS);
|
||||
if (thread.isAlive())
|
||||
thread.interrupt(); //Wake it up
|
||||
}
|
||||
|
||||
public HasBlockState getMetaState(Block block) {
|
||||
|
@ -209,4 +215,27 @@ public class ThreadLink {
|
|||
public ModuleLogger getLog() {
|
||||
return log;
|
||||
}
|
||||
|
||||
private void restartThreadIfNeeded() {
|
||||
if ((thread != null && thread.isAlive()) || shutdown)
|
||||
return;
|
||||
log.warn("Thread is dead, restarting!");
|
||||
new Exception("Thread-restarting update called").printStackTrace();
|
||||
createThread(((DBThread) thread).q);
|
||||
start();
|
||||
}
|
||||
|
||||
private void createThread(DBQueries queries) {
|
||||
if (shutdown)
|
||||
return;
|
||||
thread = new DBThread(queries);
|
||||
thread.setName("LC BlockState DB-Thread");
|
||||
thread.setUncaughtExceptionHandler(new UncaughtExceptionHandler() {
|
||||
@Override
|
||||
public void uncaughtException(Thread thread, Throwable e) {
|
||||
e.printStackTrace();
|
||||
log.severe("Thread " + thread.getName() + " encoutered an uncaught Exception: " + e.getMessage());
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
|
|
|
@ -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 <T extends BlockStateHolder<T>> boolean setBlock(BlockVector3 pt, T newBlock) throws WorldEditException {
|
||||
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());
|
||||
if (newBlock.getType() == 0) {
|
||||
if (newBlock.getBlockType().getMaterial().isAir()) {
|
||||
mod.getModel().removeState(loc.getBlock());
|
||||
} else {
|
||||
BlockState s = mod.getModel().getState(loc.getBlock());
|
||||
|
@ -46,7 +46,7 @@ public class EditSessionExtent extends AbstractLoggingExtent {
|
|||
s.setLocation(loc);
|
||||
}
|
||||
s.setGameMode(null);
|
||||
s.setPlayerName(player.getName());
|
||||
s.setPlayerNameOrUUID(player.getUniqueId().toString());
|
||||
s.setDate(new Date());
|
||||
s.setSource(Source.EDIT);
|
||||
if (mod.isDebug())
|
||||
|
@ -54,5 +54,7 @@ public class EditSessionExtent extends AbstractLoggingExtent {
|
|||
|
||||
mod.getModel().setState(s);
|
||||
}
|
||||
super.setBlock(pt, newBlock);
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,18 +1,17 @@
|
|||
package de.jaschastarke.minecraft.limitedcreative.hooks;
|
||||
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
import uk.org.whoami.authme.api.API;
|
||||
import de.jaschastarke.minecraft.limitedcreative.Hooks;
|
||||
import de.jaschastarke.minecraft.limitedcreative.LimitedCreative;
|
||||
import fr.xephi.authme.api.v3.AuthMeApi;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
@Deprecated // AuthMe 3.0 released. Compatibility for older versions will be removed sometime
|
||||
//@Deprecated // AuthMe 3.0 released. Compatibility for older versions will be removed sometime
|
||||
public class AuthMeHooks {
|
||||
public AuthMeHooks(final LimitedCreative plugin) {
|
||||
Hooks.IsLoggedIn.register(new PlayerCheckHooker.Check() {
|
||||
@Override
|
||||
public boolean test(Player player) {
|
||||
boolean li = API.isAuthenticated(player);
|
||||
boolean li = AuthMeApi.getInstance().isAuthenticated(player);
|
||||
if (plugin.isDebug()) // not nessesary, but so no string concation without debug needed
|
||||
plugin.getLog().debug("AuthMe: "+player.getName()+": logged in: "+li);
|
||||
return li;
|
||||
|
|
|
@ -1,16 +1,15 @@
|
|||
package de.jaschastarke.minecraft.limitedcreative.inventories;
|
||||
|
||||
import de.jaschastarke.bukkit.lib.SimpleModule;
|
||||
import de.jaschastarke.minecraft.limitedcreative.LimitedCreative;
|
||||
import de.jaschastarke.minecraft.limitedcreative.ModInventories;
|
||||
import fr.xephi.authme.events.ProtectInventoryEvent;
|
||||
import fr.xephi.authme.events.RestoreInventoryEvent;
|
||||
import org.bukkit.GameMode;
|
||||
import org.bukkit.event.EventHandler;
|
||||
import org.bukkit.event.Listener;
|
||||
|
||||
import uk.org.whoami.authme.events.RestoreInventoryEvent;
|
||||
import uk.org.whoami.authme.events.StoreInventoryEvent;
|
||||
import de.jaschastarke.bukkit.lib.SimpleModule;
|
||||
import de.jaschastarke.minecraft.limitedcreative.LimitedCreative;
|
||||
import de.jaschastarke.minecraft.limitedcreative.ModInventories;
|
||||
|
||||
@Deprecated // AuthMe 3.0 released. Compatibility for older versions will be removed sometime
|
||||
//@Deprecated // AuthMe 3.0 released. Compatibility for older versions will be removed sometime
|
||||
public class AuthMeInventories extends SimpleModule<LimitedCreative> implements Listener {
|
||||
ModInventories invmod;
|
||||
public AuthMeInventories(LimitedCreative plugin, ModInventories modInventories) {
|
||||
|
@ -19,9 +18,9 @@ public class AuthMeInventories extends SimpleModule<LimitedCreative> implements
|
|||
}
|
||||
|
||||
@EventHandler
|
||||
public void onStoreInventory(StoreInventoryEvent event) {
|
||||
public void onStoreInventory(ProtectInventoryEvent event) {
|
||||
if (isDebug())
|
||||
getLog().debug("AuthMe Store Event: "+event.getPlayer().getName());
|
||||
getLog().debug("AuthMe Store Event: " + event.getPlayer().getName());
|
||||
|
||||
event.getPlayer().closeInventory();
|
||||
GameMode cgm = event.getPlayer().getGameMode();
|
||||
|
|
|
@ -47,7 +47,7 @@ public class Fallback {
|
|||
@Override
|
||||
public void store(ConfigurationSection section) {
|
||||
for (int i = 0; i < inv.getSize(); i++) {
|
||||
if (inv.getItem(i) != null && inv.getItem(i).getTypeId() != 0)
|
||||
if (inv.getItem(i) != null && !inv.getItem(i).getType().equals(Material.AIR))
|
||||
sectionSetItem(section, String.valueOf(i), inv.getItem(i));
|
||||
}
|
||||
}
|
||||
|
@ -97,7 +97,7 @@ public class Fallback {
|
|||
public static Map<Integer, ItemStack> storeInventory(PlayerInventory inv) {
|
||||
Map<Integer, ItemStack> map = new HashMap<Integer, ItemStack>();
|
||||
for (int i = 0; i < inv.getSize(); i++) {
|
||||
if (inv.getItem(i) != null && inv.getItem(i).getTypeId() != 0) {
|
||||
if (inv.getItem(i) != null && !inv.getItem(i).getType().equals(Material.AIR)) {
|
||||
map.put(i, inv.getItem(i));
|
||||
}
|
||||
}
|
||||
|
@ -133,13 +133,13 @@ public class Fallback {
|
|||
|
||||
@Override
|
||||
public void store(ConfigurationSection section) {
|
||||
if (inv.getHelmet() != null && inv.getHelmet().getTypeId() != 0)
|
||||
if (inv.getHelmet() != null && !inv.getHelmet().getType().equals(Material.AIR))
|
||||
Items.sectionSetItem(section, "helmet", inv.getHelmet());
|
||||
if (inv.getChestplate() != null && inv.getChestplate().getTypeId() != 0)
|
||||
if (inv.getChestplate() != null && !inv.getChestplate().getType().equals(Material.AIR))
|
||||
Items.sectionSetItem(section, "chestplate", inv.getChestplate());
|
||||
if (inv.getLeggings() != null && inv.getLeggings().getTypeId() != 0)
|
||||
if (inv.getLeggings() != null && !inv.getLeggings().getType().equals(Material.AIR))
|
||||
Items.sectionSetItem(section, "leggins", inv.getLeggings());
|
||||
if (inv.getBoots() != null && inv.getBoots().getTypeId() != 0)
|
||||
if (inv.getBoots() != null && !inv.getBoots().getType().equals(Material.AIR))
|
||||
Items.sectionSetItem(section, "boots", inv.getBoots());
|
||||
}
|
||||
|
||||
|
|
|
@ -43,7 +43,7 @@ public class InvYamlStorage extends InvConfStorage {
|
|||
|
||||
@Override
|
||||
public void load(Inventory pinv, Target target) {
|
||||
load(pinv, YamlConfiguration.loadConfiguration(getFile(pinv, target)));
|
||||
load(pinv, YamlConfiguration.loadConfiguration(getFile(pinv, target, false)));
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -52,7 +52,11 @@ public class InvYamlStorage extends InvConfStorage {
|
|||
yml.options().header("DO NOT MODIFY THIS FILE");
|
||||
store(pinv, yml);
|
||||
try {
|
||||
yml.save(getFile(pinv, target));
|
||||
File nameFile=getFile(pinv, target, false);
|
||||
File uuidFile=getFile(pinv, target, true);
|
||||
if(!nameFile.equals(uuidFile)) //It'd be recreated right after, still, don't remove if the same
|
||||
nameFile.delete(); //Delete file with name so it doesn't get loaded again
|
||||
yml.save(uuidFile);
|
||||
} catch (IOException e) {
|
||||
mod.getLog().warn("Failed to save Inventory for Player " + pinv.getPlayer().getName());
|
||||
e.printStackTrace();
|
||||
|
@ -61,19 +65,28 @@ public class InvYamlStorage extends InvConfStorage {
|
|||
|
||||
@Override
|
||||
public void remove(Inventory pinv, Target target) {
|
||||
getFile(pinv, target).delete();
|
||||
getFile(pinv, target, true).delete();
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean contains(Inventory pinv, Target target) {
|
||||
return getFile(pinv, target).exists();
|
||||
return getFile(pinv, target, false).exists();
|
||||
}
|
||||
|
||||
protected File getFile(Inventory pinv, Target target) {
|
||||
if (target != default_target) {
|
||||
return new File(dir, pinv.getPlayer().getName() + "_" + target.toString().toLowerCase() + SUFFIX);
|
||||
} else {
|
||||
return new File(dir, pinv.getPlayer().getName() + SUFFIX);
|
||||
}
|
||||
protected File getFile(Inventory pinv, Target target, boolean uuidonly) {
|
||||
File file;
|
||||
String player;
|
||||
do {
|
||||
player = uuidonly ? pinv.getPlayer().getUniqueId().toString() : pinv.getPlayer().getName();
|
||||
if (target != default_target) {
|
||||
file = new File(dir, player + "_" + target.toString().toLowerCase() + SUFFIX);
|
||||
} else {
|
||||
file = new File(dir, player + SUFFIX);
|
||||
}
|
||||
if(uuidonly)
|
||||
return file; //Use file with UUID, even if doesn't exist
|
||||
uuidonly = true; //Run again with UUID, then return...
|
||||
} while(!file.exists()); //...if the file with name is not found
|
||||
return file; //Found file with player name
|
||||
}
|
||||
}
|
||||
|
|
|
@ -0,0 +1,217 @@
|
|||
package de.jaschastarke.minecraft.limitedcreative.inventories.store;
|
||||
|
||||
import de.jaschastarke.bukkit.lib.CoreModule;
|
||||
import de.jaschastarke.bukkit.lib.ModuleLogger;
|
||||
import de.jaschastarke.minecraft.limitedcreative.inventories.Inventory;
|
||||
import org.bukkit.configuration.Configuration;
|
||||
import org.bukkit.configuration.file.YamlConfiguration;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
import java.io.*;
|
||||
import java.lang.reflect.Constructor;
|
||||
import java.lang.reflect.Method;
|
||||
import java.util.Arrays;
|
||||
import java.util.Base64;
|
||||
import java.util.Objects;
|
||||
import java.util.UUID;
|
||||
import java.util.function.Function;
|
||||
import java.util.stream.Collectors;
|
||||
import java.util.stream.IntStream;
|
||||
|
||||
public class ReflectionStorage extends PlayerInventoryStorage {
|
||||
private CoreModule<?> mod;
|
||||
private File dir;
|
||||
private String nms;
|
||||
private InvYamlStorage yamlStorage;
|
||||
|
||||
public ReflectionStorage(CoreModule<?> mod, File file) {
|
||||
this.mod = mod;
|
||||
dir = file;
|
||||
yamlStorage = new InvYamlStorage(mod, file);
|
||||
}
|
||||
|
||||
@Override
|
||||
public ModuleLogger getLog() {
|
||||
return mod.getLog();
|
||||
}
|
||||
|
||||
private File getFile(UUID uuid) {
|
||||
return new File(dir, uuid.toString() + "_ref.yml");
|
||||
}
|
||||
|
||||
private Object getInventory(Player player) throws Exception {
|
||||
org.bukkit.inventory.Inventory inv = player.getInventory();
|
||||
if (getInventory == null)
|
||||
getInventory = inv.getClass().getMethod("getInventory");
|
||||
Object handle = getInventory.invoke(inv);
|
||||
if (nms == null)
|
||||
nms = handle.getClass().getPackage().getName();
|
||||
return handle;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void store(Inventory pinv, Inventory.Target target) {
|
||||
try {
|
||||
File f = getFile(pinv.getPlayer().getUniqueId());
|
||||
YamlConfiguration config = YamlConfiguration.loadConfiguration(f);
|
||||
config.set(target.name(), serialize(getInventory(pinv.getPlayer())));
|
||||
config.save(f);
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
|
||||
private Method getInventory;
|
||||
|
||||
@Override
|
||||
public void load(Inventory pinv, Inventory.Target target) {
|
||||
Player player = pinv.getPlayer();
|
||||
try {
|
||||
File f = getFile(player.getUniqueId());
|
||||
if (!f.exists()) { //If not found use the older file(s)
|
||||
yamlStorage.load(pinv, target);
|
||||
return;
|
||||
}
|
||||
//String content = new String(Files.readAllBytes(f.toPath()));
|
||||
Configuration config = YamlConfiguration.loadConfiguration(f);
|
||||
String content = config.getString(target.name());
|
||||
if (content == null) {
|
||||
yamlStorage.load(pinv, target);
|
||||
return;
|
||||
}
|
||||
setFromSerialized(getInventory(player), content);
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void remove(Inventory pinv, Inventory.Target target) {
|
||||
File f = getFile(pinv.getPlayer().getUniqueId());
|
||||
if (!f.exists()) return;
|
||||
Configuration config = YamlConfiguration.loadConfiguration(f);
|
||||
config.set(target.name(), null);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean contains(Inventory pinv, Inventory.Target target) {
|
||||
File f = getFile(pinv.getPlayer().getUniqueId());
|
||||
if (!f.exists()) return yamlStorage.contains(pinv, target);
|
||||
Configuration config = YamlConfiguration.loadConfiguration(f);
|
||||
return config.contains(target.name()) || yamlStorage.contains(pinv, target);
|
||||
}
|
||||
|
||||
//Based on iie's per-world inventory
|
||||
//https://github.com/TBMCPlugins/iiePerWorldInventory/blob/master/src/buttondevteam/perworld/serializers/inventory.java
|
||||
|
||||
private Method save;
|
||||
private Class<?> nbtcl;
|
||||
private Method nbtcsta;
|
||||
private Class<?> nbtcstcl;
|
||||
|
||||
//SERIALIZE ITEMSTACK
|
||||
private String serializeItemStack(Object itemStack) throws Exception {
|
||||
if (nbtcl == null)
|
||||
nbtcl = Class.forName(nms + ".NBTTagCompound");
|
||||
if (save == null)
|
||||
save = itemStack.getClass().getMethod("save", nbtcl);
|
||||
if (nbtcstcl == null)
|
||||
nbtcstcl = Class.forName(nms + ".NBTCompressedStreamTools");
|
||||
if (nbtcsta == null)
|
||||
nbtcsta = nbtcstcl.getMethod("a", nbtcl, OutputStream.class);
|
||||
Object tag = save.invoke(itemStack, nbtcl.newInstance());
|
||||
ByteArrayOutputStream outputStream = new ByteArrayOutputStream();
|
||||
|
||||
nbtcsta.invoke(null, tag, outputStream);
|
||||
|
||||
return Base64.getEncoder().encodeToString(outputStream.toByteArray());
|
||||
}
|
||||
|
||||
|
||||
private Method nbtcstaa;
|
||||
private Function<Object, Object> createStack;
|
||||
|
||||
//DESERIALIZE ITEMSTACK
|
||||
private Object deserializeItemStack(String itemStackString) throws Exception {
|
||||
if (nbtcstcl == null)
|
||||
nbtcstcl = Class.forName(nms + ".NBTCompressedStreamTools");
|
||||
if (nbtcstaa == null)
|
||||
nbtcstaa = nbtcstcl.getMethod("a", InputStream.class);
|
||||
if (nbtcl == null)
|
||||
nbtcl = Class.forName(nms + ".NBTTagCompound");
|
||||
try {
|
||||
if (createStack == null) {
|
||||
final Method a = iscl.getMethod("a", nbtcl);
|
||||
createStack = nbt -> {
|
||||
try {
|
||||
return a.invoke(null, nbt);
|
||||
} catch (Exception e) {
|
||||
throw new RuntimeException(e);
|
||||
}
|
||||
};
|
||||
}
|
||||
} catch (NoSuchMethodException ex) { //It can only get here inside the if
|
||||
final Constructor<?> constructor = iscl.getConstructor(nbtcl);
|
||||
createStack = nbt -> {
|
||||
try {
|
||||
return constructor.newInstance(nbt);
|
||||
} catch (Exception e) {
|
||||
throw new RuntimeException(e);
|
||||
}
|
||||
};
|
||||
}
|
||||
ByteArrayInputStream inputStream = new ByteArrayInputStream(Base64.getDecoder().decode(itemStackString));
|
||||
|
||||
Object nbtTagCompound = nbtcstaa.invoke(null, inputStream);
|
||||
return createStack.apply(nbtTagCompound);
|
||||
}
|
||||
|
||||
private Method getSize;
|
||||
private Method getItem;
|
||||
|
||||
//SERIALIZE INVENTORY
|
||||
private String serialize(Object invInventory) throws Exception {
|
||||
if (getSize == null)
|
||||
getSize = invInventory.getClass().getMethod("getSize");
|
||||
if (getItem == null)
|
||||
getItem = invInventory.getClass().getMethod("getItem", int.class);
|
||||
return IntStream.range(0, (int) getSize.invoke(invInventory))
|
||||
.mapToObj(s -> {
|
||||
try {
|
||||
//nms ItemStack
|
||||
Object i = getItem.invoke(invInventory, s);
|
||||
return Objects.isNull(i) ? null : s + "#" + serializeItemStack(i);
|
||||
} catch (Exception e) {
|
||||
throw new RuntimeException(e);
|
||||
}
|
||||
})
|
||||
.filter(Objects::nonNull)
|
||||
.collect(Collectors.joining(";"));
|
||||
}
|
||||
|
||||
private Method clear;
|
||||
private Method setItem;
|
||||
private Class<?> iscl;
|
||||
|
||||
//SET INVENTORY FROM SERIALIZED
|
||||
private void setFromSerialized(Object invInventory, String invString) throws Exception {
|
||||
if (clear == null)
|
||||
clear = invInventory.getClass().getMethod("clear");
|
||||
if (iscl == null)
|
||||
iscl = Class.forName(nms + ".ItemStack");
|
||||
if (setItem == null)
|
||||
setItem = invInventory.getClass().getMethod("setItem", int.class, iscl);
|
||||
clear.invoke(invInventory); //clear inventory
|
||||
if (invString != null && !invString.isEmpty())
|
||||
Arrays.asList(invString.split(";"))
|
||||
.parallelStream()
|
||||
.forEach(s -> {
|
||||
String[] e = s.split("#");
|
||||
try {
|
||||
setItem.invoke(invInventory, Integer.parseInt(e[0]), deserializeItemStack(e[1]));
|
||||
} catch (Exception ex) {
|
||||
throw new RuntimeException(ex);
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
|
@ -55,7 +55,7 @@ public class BlackList extends ArrayList<BlackList.Blacklisted> implements Confi
|
|||
}
|
||||
public boolean matches(Block block) {
|
||||
if (hasData) {
|
||||
return md.equals(new MaterialData(block.getType(), block.getData()));
|
||||
return md.equals(block.getState().getData());
|
||||
} else {
|
||||
return block.getType().equals(md.getItemType());
|
||||
}
|
||||
|
|
|
@ -52,7 +52,7 @@ public class BlackListEntity extends ArrayList<BlackListEntity.Blacklisted> impl
|
|||
type = null;
|
||||
}
|
||||
if (type == null)
|
||||
type = EntityType.fromName(rep);
|
||||
type = EntityType.valueOf(rep);
|
||||
try {
|
||||
if (type == null)
|
||||
type = EntityType.valueOf(rep);
|
||||
|
|
|
@ -118,16 +118,16 @@ public class NoLimitPermissions extends SimplePermissionContainerNode {
|
|||
return new InventoryPermission(CHEST, invtype);
|
||||
}
|
||||
public static IDynamicPermission INTERACT(Block block) {
|
||||
return new MaterialPermission(BASE_INTERACT, new MaterialData(block.getType(), block.getData()));
|
||||
return new MaterialPermission(BASE_INTERACT, block.getState().getData());
|
||||
}
|
||||
public static IDynamicPermission USE(Block block) {
|
||||
return new MaterialPermission(BASE_USE, new MaterialData(block.getType(), block.getData()));
|
||||
return new MaterialPermission(BASE_USE, block.getState().getData());
|
||||
}
|
||||
public static IDynamicPermission USE(MaterialData m) {
|
||||
return new MaterialPermission(BASE_USE, m);
|
||||
}
|
||||
public static IDynamicPermission BREAK(Block block) {
|
||||
return new MaterialPermission(BASE_BREAK, new MaterialData(block.getType(), block.getData()));
|
||||
return new MaterialPermission(BASE_BREAK, block.getState().getData());
|
||||
}
|
||||
|
||||
|
||||
|
|
|
@ -39,7 +39,6 @@ import org.bukkit.event.player.*;
|
|||
import org.bukkit.inventory.InventoryHolder;
|
||||
import org.bukkit.material.DirectionalContainer;
|
||||
import org.bukkit.potion.PotionEffect;
|
||||
import org.bukkit.projectiles.ProjectileSource;
|
||||
|
||||
import de.jaschastarke.minecraft.lib.permissions.IAbstractPermission;
|
||||
import de.jaschastarke.minecraft.lib.permissions.IDynamicPermission;
|
||||
|
@ -195,8 +194,8 @@ public class PlayerListener implements Listener {
|
|||
@EventHandler
|
||||
public void onPlayerInteractEntity(PlayerInteractEntityEvent event) {
|
||||
if (!event.isCancelled() && event.getPlayer().getGameMode() == GameMode.CREATIVE) {
|
||||
if (mod.getConfig().getBlockUse().isListed(event.getPlayer().getItemInHand())) {
|
||||
if (!checkPermission(event, NoLimitPermissions.USE(event.getPlayer().getItemInHand().getData()))) {
|
||||
if (mod.getConfig().getBlockUse().isListed(event.getPlayer().getInventory().getItemInMainHand())) {
|
||||
if (!checkPermission(event, NoLimitPermissions.USE(event.getPlayer().getInventory().getItemInMainHand().getData()))) {
|
||||
event.setCancelled(true);
|
||||
event.getPlayer().sendMessage(mod.getPlugin().getLocale().trans("blocked.use"));
|
||||
return;
|
||||
|
@ -223,11 +222,8 @@ public class PlayerListener implements Listener {
|
|||
EntityDamageByEntityEvent event = (EntityDamageByEntityEvent) rawevent;
|
||||
|
||||
Entity source = event.getDamager();
|
||||
if (source instanceof Projectile) {
|
||||
ProjectileSource shooter = ((Projectile) source).getShooter();
|
||||
if (shooter instanceof Entity)
|
||||
source = (Entity) shooter;
|
||||
}
|
||||
if (source instanceof Projectile && ((Projectile) source).getShooter() instanceof Entity)
|
||||
source = (Entity) ((Projectile) source).getShooter();
|
||||
|
||||
if (source instanceof Player) {
|
||||
Player player = (Player) source;
|
||||
|
|
|
@ -1,12 +1,10 @@
|
|||
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.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.
|
||||
|
@ -17,7 +15,8 @@ public class GameModeFlag extends Flag<GameMode> {
|
|||
}
|
||||
|
||||
@Override
|
||||
public GameMode parseInput(WorldGuardPlugin plugin, CommandSender sender, String input) throws InvalidFlagFormat {
|
||||
public GameMode parseInput(FlagContext context) throws InvalidFlagFormat {
|
||||
String input = context.getUserInput();
|
||||
input = input.trim();
|
||||
if (input.equalsIgnoreCase("creative")) {
|
||||
return GameMode.CREATIVE;
|
||||
|
|
|
@ -1,31 +1,19 @@
|
|||
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.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.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.*;
|
||||
import de.jaschastarke.bukkit.lib.commands.annotations.IsCommand;
|
||||
import de.jaschastarke.bukkit.lib.commands.annotations.Usages;
|
||||
import de.jaschastarke.bukkit.lib.commands.parser.DefinedParameterParser;
|
||||
|
@ -40,6 +28,13 @@ 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
|
||||
|
@ -138,7 +133,8 @@ public class RegionsCommand extends BukkitCommand implements IHelpDescribed {
|
|||
if (idx > -1 && context.getArgument(idx) != null)
|
||||
w = Bukkit.getWorld(context.getArgument(idx));
|
||||
if (w != null) {
|
||||
RegionManager mgr = getWorldGuard().getGlobalRegionManager().get(w);
|
||||
RegionContainer container = WorldGuard.getInstance().getPlatform().getRegionContainer();
|
||||
RegionManager mgr = container.get(BukkitAdapter.adapt(w));
|
||||
if (mgr != null) {
|
||||
List<String> hints = new ArrayList<String>();
|
||||
for (String rId : mgr.getRegions().keySet()) {
|
||||
|
@ -174,7 +170,8 @@ public class RegionsCommand extends BukkitCommand implements IHelpDescribed {
|
|||
if (w == null)
|
||||
throw new CommandException(L("command.worldguard.world_not_found"));
|
||||
|
||||
RegionManager mgr = getWorldGuard().getGlobalRegionManager().get(w);
|
||||
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));
|
||||
|
@ -202,7 +199,7 @@ public class RegionsCommand extends BukkitCommand implements IHelpDescribed {
|
|||
String value = params.getValue();
|
||||
try {
|
||||
if (value != null && value.trim().length() > 0) {
|
||||
reg.setFlag(flag, flag.parseInput(getWorldGuard(), context.getSender(), value));
|
||||
reg.setFlag(flag, flag.parseInput(FlagContext.create().setInput(value).build()));
|
||||
} else {
|
||||
reg.setFlag(flag, null);
|
||||
}
|
||||
|
@ -237,17 +234,18 @@ public class RegionsCommand extends BukkitCommand implements IHelpDescribed {
|
|||
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 = getWorldGuard().getGlobalRegionManager().get(context.getPlayer().getWorld());
|
||||
ApplicableRegionSet set = mgr.getApplicableRegions(context.getPlayer().getLocation());
|
||||
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 = getWorldGuard().getGlobalRegionManager().get(w).getRegion(GLOBAL_REGION);
|
||||
region = container.get(BukkitAdapter.adapt(w)).getRegion(GLOBAL_REGION);
|
||||
}
|
||||
} else {
|
||||
int rpc = params.getArgumentCount() > 1 ? 1 : 0;
|
||||
RegionManager mgr = getWorldGuard().getGlobalRegionManager().get(w);
|
||||
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));
|
||||
|
|
|
@ -22,6 +22,7 @@ import org.bukkit.entity.Player;
|
|||
import com.sk89q.worldguard.protection.ApplicableRegionSet;
|
||||
import com.sk89q.worldguard.protection.flags.Flag;
|
||||
import com.sk89q.worldguard.protection.flags.StateFlag;
|
||||
import com.sk89q.worldguard.protection.flags.StateFlag.State;
|
||||
import com.sk89q.worldguard.protection.regions.ProtectedRegion;
|
||||
|
||||
public class ApplicableRegions {
|
||||
|
@ -36,28 +37,28 @@ public class ApplicableRegions {
|
|||
|
||||
public boolean allows(StateFlag flag) {
|
||||
extendRegionFlags();
|
||||
boolean r = regions.allows(flag);
|
||||
boolean r = regions.queryState(null, flag).equals(State.ALLOW);
|
||||
contractRegionFlags();
|
||||
return r;
|
||||
}
|
||||
|
||||
public boolean allows(StateFlag flag, Player player) {
|
||||
extendRegionFlags();
|
||||
boolean r = regions.allows(flag, mgr.getWorldGuard().wrapPlayer(player));
|
||||
boolean r = regions.queryState(mgr.getWorldGuard().wrapPlayer(player), flag).equals(State.ALLOW);
|
||||
contractRegionFlags();
|
||||
return r;
|
||||
}
|
||||
|
||||
public <T extends Flag<V>, V> V getFlag(T flag) {
|
||||
extendRegionFlags();
|
||||
V r = regions.getFlag(flag);
|
||||
V r = regions.queryValue(null, flag);
|
||||
contractRegionFlags();
|
||||
return r;
|
||||
}
|
||||
|
||||
public <T extends Flag<V>, V> V getFlag(T flag, Player player) {
|
||||
extendRegionFlags();
|
||||
V r = regions.getFlag(flag, mgr.getWorldGuard().wrapPlayer(player));
|
||||
V r = regions.queryValue(mgr.getWorldGuard().wrapPlayer(player), flag);
|
||||
contractRegionFlags();
|
||||
return r;
|
||||
}
|
||||
|
|
|
@ -17,14 +17,16 @@
|
|||
*/
|
||||
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 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;
|
||||
|
@ -32,16 +34,9 @@ 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.GlobalRegionManager;
|
||||
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;
|
||||
import java.io.File;
|
||||
import java.io.IOException;
|
||||
import java.util.*;
|
||||
|
||||
public class CustomRegionManager {
|
||||
protected YamlConfiguration c;
|
||||
|
@ -161,16 +156,14 @@ public class CustomRegionManager {
|
|||
return ((WorldGuardPlugin) mod.getPlugin().getServer().getPluginManager().getPlugin(WorldGuardIntegration.PLUGIN_NAME));
|
||||
}
|
||||
|
||||
public GlobalRegionManager getWGGlobalManager() {
|
||||
return getWorldGuard().getGlobalRegionManager();
|
||||
}
|
||||
public RegionManager getWGManager(World world) {
|
||||
return getWorldGuard().getRegionManager(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<String> idlist = getWGManager(loc.getWorld()).getApplicableRegionsIDs(BukkitUtil.toVector(loc));
|
||||
List<String> idlist = getWGManager(loc.getWorld()).getApplicableRegionsIDs(BukkitAdapter.asBlockVector(loc));
|
||||
if (idlist.size() > 0) {
|
||||
hash.append("#");
|
||||
String[] ids = idlist.toArray(new String[idlist.size()]);
|
||||
|
@ -183,7 +176,7 @@ public class CustomRegionManager {
|
|||
}
|
||||
|
||||
public ApplicableRegions getRegionSet(Location loc) {
|
||||
return new ApplicableRegions(getWGManager(loc.getWorld()).getApplicableRegions(loc), this.world(loc.getWorld()));
|
||||
return new ApplicableRegions(getWGManager(loc.getWorld()).getApplicableRegions(BukkitAdapter.asBlockVector(loc)), this.world(loc.getWorld()));
|
||||
}
|
||||
|
||||
public ApplicableRegions getRegionSet(Block block) {
|
||||
|
|
|
@ -17,7 +17,6 @@
|
|||
*/
|
||||
package de.jaschastarke.minecraft.limitedcreative.regions.worldguard.events;
|
||||
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.event.HandlerList;
|
||||
|
||||
|
@ -25,11 +24,11 @@ import de.jaschastarke.minecraft.limitedcreative.regions.worldguard.ApplicableRe
|
|||
import de.jaschastarke.minecraft.limitedcreative.regions.worldguard.CustomRegionManager;
|
||||
|
||||
public class PlayerUpdateAreaEvent extends PlayerAreaEvent {
|
||||
private String player;
|
||||
private Player player;
|
||||
private String hash;
|
||||
protected CustomRegionManager mgr;
|
||||
|
||||
public PlayerUpdateAreaEvent(CustomRegionManager mgr, String player, String hash) {
|
||||
public PlayerUpdateAreaEvent(CustomRegionManager mgr, Player player, String hash) {
|
||||
this.mgr = mgr;
|
||||
this.player = player;
|
||||
this.hash = hash;
|
||||
|
@ -46,7 +45,7 @@ public class PlayerUpdateAreaEvent extends PlayerAreaEvent {
|
|||
|
||||
@Override
|
||||
public Player getPlayer() {
|
||||
return Bukkit.getServer().getPlayerExact(player);
|
||||
return player;
|
||||
}
|
||||
|
||||
private static final HandlerList handlers = new HandlerList();
|
||||
|
|
|
@ -1,2 +0,0 @@
|
|||
piwik_url = http://stats.ja-s.de/piwikProxy.php
|
||||
piwik_site_id = 2
|
Loading…
Reference in a new issue