mirror of
https://github.com/IntellectualSites/PlotSquared.git
synced 2024-11-22 21:26:45 +01:00
Merge pull request #2 from IntellectualCrafters/master
Getting current state
This commit is contained in:
commit
e67393408f
1
.gitignore
vendored
1
.gitignore
vendored
@ -63,6 +63,7 @@ tmp/
|
|||||||
local.properties
|
local.properties
|
||||||
.settings/
|
.settings/
|
||||||
.loadpath
|
.loadpath
|
||||||
|
\doc
|
||||||
|
|
||||||
# External tool builders
|
# External tool builders
|
||||||
.externalToolBuilders/
|
.externalToolBuilders/
|
||||||
|
@ -8,7 +8,7 @@
|
|||||||
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
|
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
|
||||||
</properties>
|
</properties>
|
||||||
<artifactId>PlotSquared</artifactId>
|
<artifactId>PlotSquared</artifactId>
|
||||||
<version>2.8.1</version>
|
<version>2.10.2</version>
|
||||||
<name>PlotSquared</name>
|
<name>PlotSquared</name>
|
||||||
<packaging>jar</packaging>
|
<packaging>jar</packaging>
|
||||||
<build>
|
<build>
|
||||||
@ -16,23 +16,23 @@
|
|||||||
<sourceDirectory>src/main/java</sourceDirectory>
|
<sourceDirectory>src/main/java</sourceDirectory>
|
||||||
<resources>
|
<resources>
|
||||||
<resource>
|
<resource>
|
||||||
<targetPath>.</targetPath>
|
|
||||||
<filtering>true</filtering>
|
<filtering>true</filtering>
|
||||||
|
<excludes>
|
||||||
|
<exclude>skyblock.template</exclude>
|
||||||
|
<exclude>town.template</exclude>
|
||||||
|
</excludes>
|
||||||
<directory>${basedir}/src/main/resources/</directory>
|
<directory>${basedir}/src/main/resources/</directory>
|
||||||
|
</resource>
|
||||||
|
<resource>
|
||||||
|
<filtering>false</filtering>
|
||||||
<includes>
|
<includes>
|
||||||
<include>
|
<include>skyblock.template</include>
|
||||||
plugin.yml
|
<include>town.template</include>
|
||||||
</include>
|
<include>s_chinese.yml</include>
|
||||||
<include>
|
<include>s_chinese_unescaped.yml</include>
|
||||||
LICENSE
|
<include>german.yml</include>
|
||||||
</include>
|
</includes>
|
||||||
<include>
|
<directory>${basedir}/src/main/resources/</directory>
|
||||||
town.template
|
|
||||||
</include>
|
|
||||||
<include>
|
|
||||||
skyblock.template
|
|
||||||
</include>
|
|
||||||
</includes>
|
|
||||||
</resource>
|
</resource>
|
||||||
</resources>
|
</resources>
|
||||||
<plugins>
|
<plugins>
|
||||||
@ -67,6 +67,10 @@
|
|||||||
<id>sk80q</id>
|
<id>sk80q</id>
|
||||||
<url>http://maven.sk89q.com/artifactory/repo/</url>
|
<url>http://maven.sk89q.com/artifactory/repo/</url>
|
||||||
</repository>
|
</repository>
|
||||||
|
<repository>
|
||||||
|
<id>vault-repo</id>
|
||||||
|
<url>http://nexus.theyeticave.net/content/repositories/pub_releases</url>
|
||||||
|
</repository>
|
||||||
</repositories>
|
</repositories>
|
||||||
<dependencies>
|
<dependencies>
|
||||||
<dependency>
|
<dependency>
|
||||||
@ -77,13 +81,8 @@
|
|||||||
<dependency>
|
<dependency>
|
||||||
<groupId>org.bukkit</groupId>
|
<groupId>org.bukkit</groupId>
|
||||||
<artifactId>bukkit</artifactId>
|
<artifactId>bukkit</artifactId>
|
||||||
<version>1.8-R0.1-SNAPSHOT</version>
|
<version>1.8.3-R0.1-SNAPSHOT</version>
|
||||||
</dependency>
|
</dependency>
|
||||||
<dependency>
|
|
||||||
<groupId>net.milkbowl.vault</groupId>
|
|
||||||
<artifactId>Vault</artifactId>
|
|
||||||
<version>1.3.2</version>
|
|
||||||
</dependency>
|
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>com.sk89q</groupId>
|
<groupId>com.sk89q</groupId>
|
||||||
<artifactId>worldedit</artifactId>
|
<artifactId>worldedit</artifactId>
|
||||||
@ -96,17 +95,16 @@
|
|||||||
<artifactId>BarAPI</artifactId>
|
<artifactId>BarAPI</artifactId>
|
||||||
<version>2.0</version>
|
<version>2.0</version>
|
||||||
</dependency>
|
</dependency>
|
||||||
<dependency>
|
|
||||||
<groupId>com.sk89q</groupId>
|
|
||||||
<artifactId>worldguard</artifactId>
|
|
||||||
<version>5.9</version>
|
|
||||||
<type>jar</type>
|
|
||||||
<scope>compile</scope>
|
|
||||||
</dependency>
|
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>junit</groupId>
|
<groupId>junit</groupId>
|
||||||
<artifactId>junit</artifactId>
|
<artifactId>junit</artifactId>
|
||||||
<version>4.11</version>
|
<version>4.11</version>
|
||||||
</dependency>
|
</dependency>
|
||||||
|
<dependency>
|
||||||
|
<groupId>net.milkbowl.vault</groupId>
|
||||||
|
<artifactId>VaultAPI</artifactId>
|
||||||
|
<version>1.5</version>
|
||||||
|
<scope>provided</scope>
|
||||||
|
</dependency>
|
||||||
</dependencies>
|
</dependencies>
|
||||||
</project>
|
</project>
|
@ -69,7 +69,7 @@ public final class CompoundTag extends Tag {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Get a byte array named with the given key. <p/> <p> If the key does not exist or its value is not a byte array
|
* Get a byte array named with the given key. <p> If the key does not exist or its value is not a byte array
|
||||||
* tag, then an empty byte array will be returned. </p>
|
* tag, then an empty byte array will be returned. </p>
|
||||||
*
|
*
|
||||||
* @param key the key
|
* @param key the key
|
||||||
@ -86,7 +86,7 @@ public final class CompoundTag extends Tag {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Get a byte named with the given key. <p/> <p> If the key does not exist or its value is not a byte tag, then
|
* Get a byte named with the given key. <p> If the key does not exist or its value is not a byte tag, then
|
||||||
* {@code 0} will be returned. </p>
|
* {@code 0} will be returned. </p>
|
||||||
*
|
*
|
||||||
* @param key the key
|
* @param key the key
|
||||||
@ -103,7 +103,7 @@ public final class CompoundTag extends Tag {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Get a double named with the given key. <p/> <p> If the key does not exist or its value is not a double tag, then
|
* Get a double named with the given key. <p> If the key does not exist or its value is not a double tag, then
|
||||||
* {@code 0} will be returned. </p>
|
* {@code 0} will be returned. </p>
|
||||||
*
|
*
|
||||||
* @param key the key
|
* @param key the key
|
||||||
@ -120,7 +120,7 @@ public final class CompoundTag extends Tag {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Get a double named with the given key, even if it's another type of number. <p/> <p> If the key does not exist or
|
* Get a double named with the given key, even if it's another type of number. <p> If the key does not exist or
|
||||||
* its value is not a number, then {@code 0} will be returned. </p>
|
* its value is not a number, then {@code 0} will be returned. </p>
|
||||||
*
|
*
|
||||||
* @param key the key
|
* @param key the key
|
||||||
@ -147,7 +147,7 @@ public final class CompoundTag extends Tag {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Get a float named with the given key. <p/> <p> If the key does not exist or its value is not a float tag, then
|
* Get a float named with the given key. <p> If the key does not exist or its value is not a float tag, then
|
||||||
* {@code 0} will be returned. </p>
|
* {@code 0} will be returned. </p>
|
||||||
*
|
*
|
||||||
* @param key the key
|
* @param key the key
|
||||||
@ -164,7 +164,7 @@ public final class CompoundTag extends Tag {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Get a {@code int[]} named with the given key. <p/> <p> If the key does not exist or its value is not an int array
|
* Get a {@code int[]} named with the given key. <p> If the key does not exist or its value is not an int array
|
||||||
* tag, then an empty array will be returned. </p>
|
* tag, then an empty array will be returned. </p>
|
||||||
*
|
*
|
||||||
* @param key the key
|
* @param key the key
|
||||||
@ -181,7 +181,7 @@ public final class CompoundTag extends Tag {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Get an int named with the given key. <p/> <p> If the key does not exist or its value is not an int tag, then
|
* Get an int named with the given key. <p> If the key does not exist or its value is not an int tag, then
|
||||||
* {@code 0} will be returned. </p>
|
* {@code 0} will be returned. </p>
|
||||||
*
|
*
|
||||||
* @param key the key
|
* @param key the key
|
||||||
@ -198,7 +198,7 @@ public final class CompoundTag extends Tag {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Get an int named with the given key, even if it's another type of number. <p/> <p> If the key does not exist or
|
* Get an int named with the given key, even if it's another type of number. <p> If the key does not exist or
|
||||||
* its value is not a number, then {@code 0} will be returned. </p>
|
* its value is not a number, then {@code 0} will be returned. </p>
|
||||||
*
|
*
|
||||||
* @param key the key
|
* @param key the key
|
||||||
@ -225,7 +225,7 @@ public final class CompoundTag extends Tag {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Get a list of tags named with the given key. <p/> <p> If the key does not exist or its value is not a list tag,
|
* Get a list of tags named with the given key. <p> If the key does not exist or its value is not a list tag,
|
||||||
* then an empty list will be returned. </p>
|
* then an empty list will be returned. </p>
|
||||||
*
|
*
|
||||||
* @param key the key
|
* @param key the key
|
||||||
@ -242,7 +242,7 @@ public final class CompoundTag extends Tag {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Get a {@code TagList} named with the given key. <p/> <p> If the key does not exist or its value is not a list
|
* Get a {@code TagList} named with the given key. <p> If the key does not exist or its value is not a list
|
||||||
* tag, then an empty tag list will be returned. </p>
|
* tag, then an empty tag list will be returned. </p>
|
||||||
*
|
*
|
||||||
* @param key the key
|
* @param key the key
|
||||||
@ -259,7 +259,7 @@ public final class CompoundTag extends Tag {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Get a list of tags named with the given key. <p/> <p> If the key does not exist or its value is not a list tag,
|
* Get a list of tags named with the given key. <p> If the key does not exist or its value is not a list tag,
|
||||||
* then an empty list will be returned. If the given key references a list but the list of of a different type, then
|
* then an empty list will be returned. If the given key references a list but the list of of a different type, then
|
||||||
* an empty list will also be returned. </p>
|
* an empty list will also be returned. </p>
|
||||||
*
|
*
|
||||||
@ -285,7 +285,7 @@ public final class CompoundTag extends Tag {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Get a long named with the given key. <p/> <p> If the key does not exist or its value is not a long tag, then
|
* Get a long named with the given key. <p> If the key does not exist or its value is not a long tag, then
|
||||||
* {@code 0} will be returned. </p>
|
* {@code 0} will be returned. </p>
|
||||||
*
|
*
|
||||||
* @param key the key
|
* @param key the key
|
||||||
@ -302,7 +302,7 @@ public final class CompoundTag extends Tag {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Get a long named with the given key, even if it's another type of number. <p/> <p> If the key does not exist or
|
* Get a long named with the given key, even if it's another type of number. <p> If the key does not exist or
|
||||||
* its value is not a number, then {@code 0} will be returned. </p>
|
* its value is not a number, then {@code 0} will be returned. </p>
|
||||||
*
|
*
|
||||||
* @param key the key
|
* @param key the key
|
||||||
@ -329,7 +329,7 @@ public final class CompoundTag extends Tag {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Get a short named with the given key. <p/> <p> If the key does not exist or its value is not a short tag, then
|
* Get a short named with the given key. <p> If the key does not exist or its value is not a short tag, then
|
||||||
* {@code 0} will be returned. </p>
|
* {@code 0} will be returned. </p>
|
||||||
*
|
*
|
||||||
* @param key the key
|
* @param key the key
|
||||||
@ -346,7 +346,7 @@ public final class CompoundTag extends Tag {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Get a string named with the given key. <p/> <p> If the key does not exist or its value is not a string tag, then
|
* Get a string named with the given key. <p> If the key does not exist or its value is not a string tag, then
|
||||||
* {@code ""} will be returned. </p>
|
* {@code ""} will be returned. </p>
|
||||||
*
|
*
|
||||||
* @param key the key
|
* @param key the key
|
||||||
|
@ -6,7 +6,6 @@ import java.util.Collections;
|
|||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.NoSuchElementException;
|
import java.util.NoSuchElementException;
|
||||||
|
|
||||||
import javax.annotation.Nullable;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The {@code TAG_List} tag.
|
* The {@code TAG_List} tag.
|
||||||
@ -74,7 +73,6 @@ public final class ListTag extends Tag {
|
|||||||
*
|
*
|
||||||
* @return the tag or null
|
* @return the tag or null
|
||||||
*/
|
*/
|
||||||
@Nullable
|
|
||||||
public Tag getIfExists(final int index) {
|
public Tag getIfExists(final int index) {
|
||||||
try {
|
try {
|
||||||
return this.value.get(index);
|
return this.value.get(index);
|
||||||
@ -84,7 +82,7 @@ public final class ListTag extends Tag {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Get a byte array named with the given index. <p/> <p> If the index does not exist or its value is not a byte
|
* Get a byte array named with the given index. <p> If the index does not exist or its value is not a byte
|
||||||
* array tag, then an empty byte array will be returned. </p>
|
* array tag, then an empty byte array will be returned. </p>
|
||||||
*
|
*
|
||||||
* @param index the index
|
* @param index the index
|
||||||
@ -101,7 +99,7 @@ public final class ListTag extends Tag {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Get a byte named with the given index. <p/> <p> If the index does not exist or its value is not a byte tag, then
|
* Get a byte named with the given index. <p> If the index does not exist or its value is not a byte tag, then
|
||||||
* {@code 0} will be returned. </p>
|
* {@code 0} will be returned. </p>
|
||||||
*
|
*
|
||||||
* @param index the index
|
* @param index the index
|
||||||
@ -118,7 +116,7 @@ public final class ListTag extends Tag {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Get a double named with the given index. <p/> <p> If the index does not exist or its value is not a double tag,
|
* Get a double named with the given index. <p> If the index does not exist or its value is not a double tag,
|
||||||
* then {@code 0} will be returned. </p>
|
* then {@code 0} will be returned. </p>
|
||||||
*
|
*
|
||||||
* @param index the index
|
* @param index the index
|
||||||
@ -135,7 +133,7 @@ public final class ListTag extends Tag {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Get a double named with the given index, even if it's another type of number. <p/> <p> If the index does not
|
* Get a double named with the given index, even if it's another type of number. <p> If the index does not
|
||||||
* exist or its value is not a number, then {@code 0} will be returned. </p>
|
* exist or its value is not a number, then {@code 0} will be returned. </p>
|
||||||
*
|
*
|
||||||
* @param index the index
|
* @param index the index
|
||||||
@ -162,7 +160,7 @@ public final class ListTag extends Tag {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Get a float named with the given index. <p/> <p> If the index does not exist or its value is not a float tag,
|
* Get a float named with the given index. <p> If the index does not exist or its value is not a float tag,
|
||||||
* then {@code 0} will be returned. </p>
|
* then {@code 0} will be returned. </p>
|
||||||
*
|
*
|
||||||
* @param index the index
|
* @param index the index
|
||||||
@ -179,7 +177,7 @@ public final class ListTag extends Tag {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Get a {@code int[]} named with the given index. <p/> <p> If the index does not exist or its value is not an int
|
* Get a {@code int[]} named with the given index. <p> If the index does not exist or its value is not an int
|
||||||
* array tag, then an empty array will be returned. </p>
|
* array tag, then an empty array will be returned. </p>
|
||||||
*
|
*
|
||||||
* @param index the index
|
* @param index the index
|
||||||
@ -196,7 +194,7 @@ public final class ListTag extends Tag {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Get an int named with the given index. <p/> <p> If the index does not exist or its value is not an int tag, then
|
* Get an int named with the given index. <p> If the index does not exist or its value is not an int tag, then
|
||||||
* {@code 0} will be returned. </p>
|
* {@code 0} will be returned. </p>
|
||||||
*
|
*
|
||||||
* @param index the index
|
* @param index the index
|
||||||
@ -213,7 +211,7 @@ public final class ListTag extends Tag {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Get an int named with the given index, even if it's another type of number. <p/> <p> If the index does not exist
|
* Get an int named with the given index, even if it's another type of number. <p> If the index does not exist
|
||||||
* or its value is not a number, then {@code 0} will be returned. </p>
|
* or its value is not a number, then {@code 0} will be returned. </p>
|
||||||
*
|
*
|
||||||
* @param index the index
|
* @param index the index
|
||||||
@ -240,7 +238,7 @@ public final class ListTag extends Tag {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Get a list of tags named with the given index. <p/> <p> If the index does not exist or its value is not a list
|
* Get a list of tags named with the given index. <p> If the index does not exist or its value is not a list
|
||||||
* tag, then an empty list will be returned. </p>
|
* tag, then an empty list will be returned. </p>
|
||||||
*
|
*
|
||||||
* @param index the index
|
* @param index the index
|
||||||
@ -257,7 +255,7 @@ public final class ListTag extends Tag {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Get a {@code TagList} named with the given index. <p/> <p> If the index does not exist or its value is not a list
|
* Get a {@code TagList} named with the given index. <p> If the index does not exist or its value is not a list
|
||||||
* tag, then an empty tag list will be returned. </p>
|
* tag, then an empty tag list will be returned. </p>
|
||||||
*
|
*
|
||||||
* @param index the index
|
* @param index the index
|
||||||
@ -274,7 +272,7 @@ public final class ListTag extends Tag {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Get a list of tags named with the given index. <p/> <p> If the index does not exist or its value is not a list
|
* Get a list of tags named with the given index. <p> If the index does not exist or its value is not a list
|
||||||
* tag, then an empty list will be returned. If the given index references a list but the list of of a different
|
* tag, then an empty list will be returned. If the given index references a list but the list of of a different
|
||||||
* type, then an empty list will also be returned. </p>
|
* type, then an empty list will also be returned. </p>
|
||||||
*
|
*
|
||||||
@ -300,7 +298,7 @@ public final class ListTag extends Tag {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Get a long named with the given index. <p/> <p> If the index does not exist or its value is not a long tag, then
|
* Get a long named with the given index. <p> If the index does not exist or its value is not a long tag, then
|
||||||
* {@code 0} will be returned. </p>
|
* {@code 0} will be returned. </p>
|
||||||
*
|
*
|
||||||
* @param index the index
|
* @param index the index
|
||||||
@ -317,7 +315,7 @@ public final class ListTag extends Tag {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Get a long named with the given index, even if it's another type of number. <p/> <p> If the index does not exist
|
* Get a long named with the given index, even if it's another type of number. <p> If the index does not exist
|
||||||
* or its value is not a number, then {@code 0} will be returned. </p>
|
* or its value is not a number, then {@code 0} will be returned. </p>
|
||||||
*
|
*
|
||||||
* @param index the index
|
* @param index the index
|
||||||
@ -344,7 +342,7 @@ public final class ListTag extends Tag {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Get a short named with the given index. <p/> <p> If the index does not exist or its value is not a short tag,
|
* Get a short named with the given index. <p> If the index does not exist or its value is not a short tag,
|
||||||
* then {@code 0} will be returned. </p>
|
* then {@code 0} will be returned. </p>
|
||||||
*
|
*
|
||||||
* @param index the index
|
* @param index the index
|
||||||
@ -361,7 +359,7 @@ public final class ListTag extends Tag {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Get a string named with the given index. <p/> <p> If the index does not exist or its value is not a string tag,
|
* Get a string named with the given index. <p> If the index does not exist or its value is not a string tag,
|
||||||
* then {@code ""} will be returned. </p>
|
* then {@code ""} will be returned. </p>
|
||||||
*
|
*
|
||||||
* @param index the index
|
* @param index the index
|
||||||
|
@ -28,6 +28,8 @@ public class ListTagBuilder {
|
|||||||
/**
|
/**
|
||||||
* Create a new builder instance.
|
* Create a new builder instance.
|
||||||
*
|
*
|
||||||
|
* @param type
|
||||||
|
*
|
||||||
* @return a new builder
|
* @return a new builder
|
||||||
*/
|
*/
|
||||||
public static ListTagBuilder create(final Class<? extends Tag> type) {
|
public static ListTagBuilder create(final Class<? extends Tag> type) {
|
||||||
@ -37,6 +39,9 @@ public class ListTagBuilder {
|
|||||||
/**
|
/**
|
||||||
* Create a new builder instance.
|
* Create a new builder instance.
|
||||||
*
|
*
|
||||||
|
* @param entries
|
||||||
|
* @param <T>
|
||||||
|
*
|
||||||
* @return a new builder
|
* @return a new builder
|
||||||
*/
|
*/
|
||||||
@SafeVarargs
|
@SafeVarargs
|
||||||
|
@ -11,8 +11,8 @@ import java.util.Map;
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* This class reads <strong>NBT</strong>, or <strong>Named Binary Tag</strong> streams, and produces an object graph of
|
* This class reads <strong>NBT</strong>, or <strong>Named Binary Tag</strong> streams, and produces an object graph of
|
||||||
* subclasses of the {@code Tag} object. <p/> <p> The NBT format was created by Markus Persson, and the specification
|
* subclasses of the {@code Tag} object. The NBT format was created by Markus Persson, and the specification
|
||||||
* may be found at <a href="http://www.minecraft.net/docs/NBT.txt"> http://www.minecraft.net/docs/NBT.txt</a>. </p>
|
* may be found at @linktourl http://www.minecraft.net/docs/NBT.txt"> http://www.minecraft.net/docs/NBT.txt.
|
||||||
*/
|
*/
|
||||||
public final class NBTInputStream implements Closeable {
|
public final class NBTInputStream implements Closeable {
|
||||||
private final DataInputStream is;
|
private final DataInputStream is;
|
||||||
|
@ -28,8 +28,9 @@ import java.util.List;
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* <p> This class writes <strong>NBT</strong>, or <strong>Named Binary Tag</strong> <code>Tag</code> objects to an
|
* <p> This class writes <strong>NBT</strong>, or <strong>Named Binary Tag</strong> <code>Tag</code> objects to an
|
||||||
* underlying <code>OutputStream</code>. </p> <p/> <p> The NBT format was created by Markus Persson, and the
|
* underlying <code>OutputStream</code>. </p> <p> The NBT format was created by Markus Persson, and the
|
||||||
* specification may be found at <a href="http://www.minecraft.net/docs/NBT.txt"> http://www.minecraft.net/docs/NBT.txt</a>.
|
* specification may be found at
|
||||||
|
* @linktourl http://www.minecraft.net/docs/NBT.txt
|
||||||
* </p>
|
* </p>
|
||||||
*
|
*
|
||||||
* @author Graham Edgecombe
|
* @author Graham Edgecombe
|
||||||
|
@ -134,6 +134,7 @@ public final class NBTUtils {
|
|||||||
* @param items the map to read from
|
* @param items the map to read from
|
||||||
* @param key the key to look for
|
* @param key the key to look for
|
||||||
* @param expected the expected NBT class type
|
* @param expected the expected NBT class type
|
||||||
|
* @param <T>
|
||||||
*
|
*
|
||||||
* @return child tag
|
* @return child tag
|
||||||
*/
|
*/
|
||||||
|
@ -4,13 +4,13 @@ package com.intellectualcrafters.json;
|
|||||||
* This provides static methods to convert comma delimited text into a JSONArray, and to covert a JSONArray into comma
|
* This provides static methods to convert comma delimited text into a JSONArray, and to covert a JSONArray into comma
|
||||||
* delimited text. Comma delimited text is a very popular format for data interchange. It is understood by most
|
* delimited text. Comma delimited text is a very popular format for data interchange. It is understood by most
|
||||||
* database, spreadsheet, and organizer programs.
|
* database, spreadsheet, and organizer programs.
|
||||||
* <p/>
|
*
|
||||||
* Each row of text represents a row in a table or a data record. Each row ends with a NEWLINE character. Each row
|
* Each row of text represents a row in a table or a data record. Each row ends with a NEWLINE character. Each row
|
||||||
* contains one or more values. Values are separated by commas. A value can contain any character except for comma,
|
* contains one or more values. Values are separated by commas. A value can contain any character except for comma,
|
||||||
* unless is is wrapped in single quotes or double quotes.
|
* unless is is wrapped in single quotes or double quotes.
|
||||||
* <p/>
|
*
|
||||||
* The first row usually contains the names of the columns.
|
* The first row usually contains the names of the columns.
|
||||||
* <p/>
|
*
|
||||||
* A comma delimited list can be converted into a JSONArray of JSONObjects. The names for the elements in the
|
* A comma delimited list can be converted into a JSONArray of JSONObjects. The names for the elements in the
|
||||||
* JSONObjects can be taken from the names in the first row.
|
* JSONObjects can be taken from the names in the first row.
|
||||||
*
|
*
|
||||||
|
@ -13,7 +13,7 @@ public class CookieList {
|
|||||||
* Convert a cookie list into a JSONObject. A cookie list is a sequence of name/value pairs. The names are separated
|
* Convert a cookie list into a JSONObject. A cookie list is a sequence of name/value pairs. The names are separated
|
||||||
* from the values by '='. The pairs are separated by ';'. The names and the values will be unescaped, possibly
|
* from the values by '='. The pairs are separated by ';'. The names and the values will be unescaped, possibly
|
||||||
* converting '+' and '%' sequences.
|
* converting '+' and '%' sequences.
|
||||||
* <p/>
|
*
|
||||||
* To add a cookie to a cooklist, cookielistJSONObject.put(cookieJSONObject.getString("name"),
|
* To add a cookie to a cooklist, cookielistJSONObject.put(cookieJSONObject.getString("name"),
|
||||||
* cookieJSONObject.getString("value"));
|
* cookieJSONObject.getString("value"));
|
||||||
*
|
*
|
||||||
|
@ -34,59 +34,6 @@ public class HTTP {
|
|||||||
*/
|
*/
|
||||||
public static final String CRLF = "\r\n";
|
public static final String CRLF = "\r\n";
|
||||||
|
|
||||||
/**
|
|
||||||
* Convert an HTTP header string into a JSONObject. It can be a request header or a response header. A request
|
|
||||||
* header will contain
|
|
||||||
* <p/>
|
|
||||||
* <p/>
|
|
||||||
* <pre>
|
|
||||||
* {
|
|
||||||
* Method: "POST" (for example),
|
|
||||||
* "Request-URI": "/" (for example),
|
|
||||||
* "HTTP-Version": "HTTP/1.1" (for example)
|
|
||||||
* }
|
|
||||||
* </pre>
|
|
||||||
* <p/>
|
|
||||||
* A response header will contain
|
|
||||||
* <p/>
|
|
||||||
* <p/>
|
|
||||||
* <pre>
|
|
||||||
* {
|
|
||||||
* "HTTP-Version": "HTTP/1.1" (for example),
|
|
||||||
* "Status-Code": "200" (for example),
|
|
||||||
* "Reason-Phrase": "OK" (for example)
|
|
||||||
* }
|
|
||||||
* </pre>
|
|
||||||
* <p/>
|
|
||||||
* In addition, the other parameters in the header will be captured, using the HTTP field names as JSON names, so
|
|
||||||
* that
|
|
||||||
* <p/>
|
|
||||||
* <p/>
|
|
||||||
* <pre>
|
|
||||||
* Date: Sun, 26 May 2002 18:06:04 GMT
|
|
||||||
* Cookie: Q=q2=PPEAsg--; B=677gi6ouf29bn&b=2&f=s
|
|
||||||
* Cache-Control: no-cache
|
|
||||||
* </pre>
|
|
||||||
* <p/>
|
|
||||||
* become
|
|
||||||
* <p/>
|
|
||||||
* <p/>
|
|
||||||
* <pre>
|
|
||||||
* {...
|
|
||||||
* Date: "Sun, 26 May 2002 18:06:04 GMT",
|
|
||||||
* Cookie: "Q=q2=PPEAsg--; B=677gi6ouf29bn&b=2&f=s",
|
|
||||||
* "Cache-Control": "no-cache",
|
|
||||||
* ...}
|
|
||||||
* </pre>
|
|
||||||
* <p/>
|
|
||||||
* It does no further checking or conversion. It does not parse dates. It does not do '%' transforms on URLs.
|
|
||||||
*
|
|
||||||
* @param string An HTTP header string.
|
|
||||||
*
|
|
||||||
* @return A JSONObject containing the elements and attributes of the XML string.
|
|
||||||
*
|
|
||||||
* @throws JSONException
|
|
||||||
*/
|
|
||||||
public static JSONObject toJSONObject(final String string) throws JSONException {
|
public static JSONObject toJSONObject(final String string) throws JSONException {
|
||||||
final JSONObject jo = new JSONObject();
|
final JSONObject jo = new JSONObject();
|
||||||
final HTTPTokener x = new HTTPTokener(string);
|
final HTTPTokener x = new HTTPTokener(string);
|
||||||
@ -116,8 +63,8 @@ public class HTTP {
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* Convert a JSONObject into an HTTP header. A request header must contain
|
* Convert a JSONObject into an HTTP header. A request header must contain
|
||||||
* <p/>
|
*
|
||||||
* <p/>
|
*
|
||||||
* <pre>
|
* <pre>
|
||||||
* {
|
* {
|
||||||
* Method: "POST" (for example),
|
* Method: "POST" (for example),
|
||||||
@ -125,10 +72,10 @@ public class HTTP {
|
|||||||
* "HTTP-Version": "HTTP/1.1" (for example)
|
* "HTTP-Version": "HTTP/1.1" (for example)
|
||||||
* }
|
* }
|
||||||
* </pre>
|
* </pre>
|
||||||
* <p/>
|
*
|
||||||
* A response header must contain
|
* A response header must contain
|
||||||
* <p/>
|
*
|
||||||
* <p/>
|
*
|
||||||
* <pre>
|
* <pre>
|
||||||
* {
|
* {
|
||||||
* "HTTP-Version": "HTTP/1.1" (for example),
|
* "HTTP-Version": "HTTP/1.1" (for example),
|
||||||
@ -136,7 +83,7 @@ public class HTTP {
|
|||||||
* "Reason-Phrase": "OK" (for example)
|
* "Reason-Phrase": "OK" (for example)
|
||||||
* }
|
* }
|
||||||
* </pre>
|
* </pre>
|
||||||
* <p/>
|
*
|
||||||
* Any other members of the JSONObject will be output as HTTP fields. The result will end with two CRLF pairs.
|
* Any other members of the JSONObject will be output as HTTP fields. The result will end with two CRLF pairs.
|
||||||
*
|
*
|
||||||
* @param jo A JSONObject
|
* @param jo A JSONObject
|
||||||
|
@ -34,16 +34,16 @@ import java.util.Map;
|
|||||||
* accessing the values by index, and <code>put</code> methods for adding or replacing values. The values can be any of
|
* accessing the values by index, and <code>put</code> methods for adding or replacing values. The values can be any of
|
||||||
* these types: <code>Boolean</code>, <code>JSONArray</code>, <code>JSONObject</code>, <code>Number</code>,
|
* these types: <code>Boolean</code>, <code>JSONArray</code>, <code>JSONObject</code>, <code>Number</code>,
|
||||||
* <code>String</code>, or the <code>JSONObject.NULL object</code>.
|
* <code>String</code>, or the <code>JSONObject.NULL object</code>.
|
||||||
* <p/>
|
*
|
||||||
* The constructor can convert a JSON text into a Java object. The <code>toString</code> method converts to JSON text.
|
* The constructor can convert a JSON text into a Java object. The <code>toString</code> method converts to JSON text.
|
||||||
* <p/>
|
*
|
||||||
* A <code>get</code> method returns a value if one can be found, and throws an exception if one cannot be found. An
|
* A <code>get</code> method returns a value if one can be found, and throws an exception if one cannot be found. An
|
||||||
* <code>opt</code> method returns a default value instead of throwing an exception, and so is useful for obtaining
|
* <code>opt</code> method returns a default value instead of throwing an exception, and so is useful for obtaining
|
||||||
* optional values.
|
* optional values.
|
||||||
* <p/>
|
*
|
||||||
* The generic <code>get()</code> and <code>opt()</code> methods return an object which you can cast or query for type.
|
* The generic <code>get()</code> and <code>opt()</code> methods return an object which you can cast or query for type.
|
||||||
* There are also typed <code>get</code> and <code>opt</code> methods that do type checking and type coercion for you.
|
* There are also typed <code>get</code> and <code>opt</code> methods that do type checking and type coercion for you.
|
||||||
* <p/>
|
*
|
||||||
* The texts produced by the <code>toString</code> methods strictly conform to JSON syntax rules. The constructors are
|
* The texts produced by the <code>toString</code> methods strictly conform to JSON syntax rules. The constructors are
|
||||||
* more forgiving in the texts they will accept: <ul> <li>An extra <code>,</code> <small>(comma)</small> may appear
|
* more forgiving in the texts they will accept: <ul> <li>An extra <code>,</code> <small>(comma)</small> may appear
|
||||||
* just before the closing bracket.</li> <li>The <code>null</code> value will be inserted when there is <code>,</code>
|
* just before the closing bracket.</li> <li>The <code>null</code> value will be inserted when there is <code>,</code>
|
||||||
@ -789,7 +789,7 @@ public class JSONArray {
|
|||||||
* Make a JSON text of this JSONArray. For compactness, no unnecessary whitespace is added. If it is not possible to
|
* Make a JSON text of this JSONArray. For compactness, no unnecessary whitespace is added. If it is not possible to
|
||||||
* produce a syntactically correct JSON text then null will be returned instead. This could occur if the array
|
* produce a syntactically correct JSON text then null will be returned instead. This could occur if the array
|
||||||
* contains an invalid number.
|
* contains an invalid number.
|
||||||
* <p/>
|
*
|
||||||
* Warning: This method assumes that the data structure is acyclical.
|
* Warning: This method assumes that the data structure is acyclical.
|
||||||
*
|
*
|
||||||
* @return a printable, displayable, transmittable representation of the array.
|
* @return a printable, displayable, transmittable representation of the array.
|
||||||
@ -824,7 +824,7 @@ public class JSONArray {
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* Write the contents of the JSONArray as JSON text to a writer. For compactness, no whitespace is added.
|
* Write the contents of the JSONArray as JSON text to a writer. For compactness, no whitespace is added.
|
||||||
* <p/>
|
*
|
||||||
* Warning: This method assumes that the data structure is acyclical.
|
* Warning: This method assumes that the data structure is acyclical.
|
||||||
*
|
*
|
||||||
* @return The writer.
|
* @return The writer.
|
||||||
@ -837,7 +837,7 @@ public class JSONArray {
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* Write the contents of the JSONArray as JSON text to a writer. For compactness, no whitespace is added.
|
* Write the contents of the JSONArray as JSON text to a writer. For compactness, no whitespace is added.
|
||||||
* <p/>
|
*
|
||||||
* Warning: This method assumes that the data structure is acyclical.
|
* Warning: This method assumes that the data structure is acyclical.
|
||||||
*
|
*
|
||||||
* @param indentFactor The number of spaces to add to each level of indentation.
|
* @param indentFactor The number of spaces to add to each level of indentation.
|
||||||
|
@ -188,7 +188,6 @@ public class JSONML {
|
|||||||
* Convert a well-formed (but not necessarily valid) XML string into a JSONArray using the JsonML transform. Each
|
* Convert a well-formed (but not necessarily valid) XML string into a JSONArray using the JsonML transform. Each
|
||||||
* XML tag is represented as a JSONArray in which the first element is the tag name. If the tag has attributes, then
|
* XML tag is represented as a JSONArray in which the first element is the tag name. If the tag has attributes, then
|
||||||
* the second element will be JSONObject containing the name/value pairs. If the tag contains children, then strings
|
* the second element will be JSONObject containing the name/value pairs. If the tag contains children, then strings
|
||||||
* and JSONArrays will represent the child tags. Comments, prologs, DTDs, and <code><[ [ ]]></code> are ignored.
|
|
||||||
*
|
*
|
||||||
* @param string The source string.
|
* @param string The source string.
|
||||||
*
|
*
|
||||||
@ -222,7 +221,7 @@ public class JSONML {
|
|||||||
* XML tag is represented as a JSONObject with a "tagName" property. If the tag has attributes, then the attributes
|
* XML tag is represented as a JSONObject with a "tagName" property. If the tag has attributes, then the attributes
|
||||||
* will be in the JSONObject as properties. If the tag contains children, the object will have a "childNodes"
|
* will be in the JSONObject as properties. If the tag contains children, the object will have a "childNodes"
|
||||||
* property which will be an array of strings and JsonML JSONObjects.
|
* property which will be an array of strings and JsonML JSONObjects.
|
||||||
* <p/>
|
*
|
||||||
* Comments, prologs, DTDs, and <code><[ [ ]]></code> are ignored.
|
* Comments, prologs, DTDs, and <code><[ [ ]]></code> are ignored.
|
||||||
*
|
*
|
||||||
* @param x An XMLTokener of the XML source text.
|
* @param x An XMLTokener of the XML source text.
|
||||||
@ -240,7 +239,7 @@ public class JSONML {
|
|||||||
* XML tag is represented as a JSONObject with a "tagName" property. If the tag has attributes, then the attributes
|
* XML tag is represented as a JSONObject with a "tagName" property. If the tag has attributes, then the attributes
|
||||||
* will be in the JSONObject as properties. If the tag contains children, the object will have a "childNodes"
|
* will be in the JSONObject as properties. If the tag contains children, the object will have a "childNodes"
|
||||||
* property which will be an array of strings and JsonML JSONObjects.
|
* property which will be an array of strings and JsonML JSONObjects.
|
||||||
* <p/>
|
*
|
||||||
* Comments, prologs, DTDs, and <code><[ [ ]]></code> are ignored.
|
* Comments, prologs, DTDs, and <code><[ [ ]]></code> are ignored.
|
||||||
*
|
*
|
||||||
* @param string The XML source text.
|
* @param string The XML source text.
|
||||||
|
@ -27,21 +27,21 @@ import java.util.Set;
|
|||||||
* values into a JSON text using the <code>put</code> and <code>toString</code> methods. A <code>get</code> method
|
* values into a JSON text using the <code>put</code> and <code>toString</code> methods. A <code>get</code> method
|
||||||
* returns a value if one can be found, and throws an exception if one cannot be found. An <code>opt</code> method
|
* returns a value if one can be found, and throws an exception if one cannot be found. An <code>opt</code> method
|
||||||
* returns a default value instead of throwing an exception, and so is useful for obtaining optional values.
|
* returns a default value instead of throwing an exception, and so is useful for obtaining optional values.
|
||||||
* <p/>
|
*
|
||||||
* The generic <code>get()</code> and <code>opt()</code> methods return an object, which you can cast or query for type.
|
* The generic <code>get()</code> and <code>opt()</code> methods return an object, which you can cast or query for type.
|
||||||
* There are also typed <code>get</code> and <code>opt</code> methods that do type checking and type coercion for you.
|
* There are also typed <code>get</code> and <code>opt</code> methods that do type checking and type coercion for you.
|
||||||
* The opt methods differ from the get methods in that they do not throw. Instead, they return a specified value, such
|
* The opt methods differ from the get methods in that they do not throw. Instead, they return a specified value, such
|
||||||
* as null.
|
* as null.
|
||||||
* <p/>
|
*
|
||||||
* The <code>put</code> methods add or replace values in an object. For example,
|
* The <code>put</code> methods add or replace values in an object. For example,
|
||||||
* <p/>
|
*
|
||||||
* <p/>
|
*
|
||||||
* <pre>
|
* <pre>
|
||||||
* myString = new JSONObject().put("JSON", "Hello, World!").toString();
|
* myString = new JSONObject().put("JSON", "Hello, World!").toString();
|
||||||
* </pre>
|
* </pre>
|
||||||
* <p/>
|
*
|
||||||
* produces the string <code>{"JSON": "Hello, World"}</code>.
|
* produces the string <code>{"JSON": "Hello, World"}</code>.
|
||||||
* <p/>
|
*
|
||||||
* The texts produced by the <code>toString</code> methods strictly conform to the JSON syntax rules. The constructors
|
* The texts produced by the <code>toString</code> methods strictly conform to the JSON syntax rules. The constructors
|
||||||
* are more forgiving in the texts they will accept: <ul> <li>An extra <code>,</code> <small>(comma)</small> may
|
* are more forgiving in the texts they will accept: <ul> <li>An extra <code>,</code> <small>(comma)</small> may
|
||||||
* appear just before the closing brace.</li> <li>Strings may be quoted with <code>'</code> <small>(single
|
* appear just before the closing brace.</li> <li>Strings may be quoted with <code>'</code> <small>(single
|
||||||
@ -164,10 +164,10 @@ public class JSONObject {
|
|||||||
* For each of the methods with no parameters and a name starting with <code>"get"</code> or <code>"is"</code>
|
* For each of the methods with no parameters and a name starting with <code>"get"</code> or <code>"is"</code>
|
||||||
* followed by an uppercase letter, the method is invoked, and a key and the value returned from the getter method
|
* followed by an uppercase letter, the method is invoked, and a key and the value returned from the getter method
|
||||||
* are put into the new JSONObject.
|
* are put into the new JSONObject.
|
||||||
* <p/>
|
*
|
||||||
* The key is formed by removing the <code>"get"</code> or <code>"is"</code> prefix. If the second remaining
|
* The key is formed by removing the <code>"get"</code> or <code>"is"</code> prefix. If the second remaining
|
||||||
* character is not upper case, then the first character is converted to lower case.
|
* character is not upper case, then the first character is converted to lower case.
|
||||||
* <p/>
|
*
|
||||||
* For example, if an object has a method named <code>"getName"</code>, and if the result of calling
|
* For example, if an object has a method named <code>"getName"</code>, and if the result of calling
|
||||||
* <code>object.getName()</code> is <code>"Larry Fine"</code>, then the JSONObject will contain <code>"name": "Larry
|
* <code>object.getName()</code> is <code>"Larry Fine"</code>, then the JSONObject will contain <code>"name": "Larry
|
||||||
* Fine"</code>.
|
* Fine"</code>.
|
||||||
@ -343,7 +343,6 @@ public class JSONObject {
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* Produce a string in double quotes with backslash sequences in all the right places. A backslash will be inserted
|
* Produce a string in double quotes with backslash sequences in all the right places. A backslash will be inserted
|
||||||
* within </, producing <\/, allowing JSON text to be delivered in HTML. In JSON text, a string cannot contain a
|
|
||||||
* control character or an unescaped quote or backslash.
|
* control character or an unescaped quote or backslash.
|
||||||
*
|
*
|
||||||
* @param string A String
|
* @param string A String
|
||||||
@ -495,8 +494,8 @@ public class JSONObject {
|
|||||||
* If the value is an array or Collection, then a JSONArray will be made from it and its toJSONString method will be
|
* If the value is an array or Collection, then a JSONArray will be made from it and its toJSONString method will be
|
||||||
* called. If the value is a MAP, then a JSONObject will be made from it and its toJSONString method will be called.
|
* called. If the value is a MAP, then a JSONObject will be made from it and its toJSONString method will be called.
|
||||||
* Otherwise, the value's toString method will be called, and the result will be quoted.
|
* Otherwise, the value's toString method will be called, and the result will be quoted.
|
||||||
* <p/>
|
*
|
||||||
* <p/>
|
*
|
||||||
* Warning: This method assumes that the data structure is acyclical.
|
* Warning: This method assumes that the data structure is acyclical.
|
||||||
*
|
*
|
||||||
* @param value The value to be serialized.
|
* @param value The value to be serialized.
|
||||||
@ -620,7 +619,7 @@ public class JSONObject {
|
|||||||
* Accumulate values under a key. It is similar to the put method except that if there is already an object stored
|
* Accumulate values under a key. It is similar to the put method except that if there is already an object stored
|
||||||
* under the key then a JSONArray is stored under the key to hold all of the accumulated values. If there is already
|
* under the key then a JSONArray is stored under the key to hold all of the accumulated values. If there is already
|
||||||
* a JSONArray, then the new value is appended to it. In contrast, the put method replaces the previous value.
|
* a JSONArray, then the new value is appended to it. In contrast, the put method replaces the previous value.
|
||||||
* <p/>
|
*
|
||||||
* If only one value is accumulated that is not a JSONArray, then the result will be the same as using put. But if
|
* If only one value is accumulated that is not a JSONArray, then the result will be the same as using put. But if
|
||||||
* multiple values are accumulated, then the result will be like append.
|
* multiple values are accumulated, then the result will be like append.
|
||||||
*
|
*
|
||||||
@ -1347,7 +1346,7 @@ public class JSONObject {
|
|||||||
/**
|
/**
|
||||||
* Make a JSON text of this JSONObject. For compactness, no whitespace is added. If this would not result in a
|
* Make a JSON text of this JSONObject. For compactness, no whitespace is added. If this would not result in a
|
||||||
* syntactically correct JSON text, then null will be returned instead.
|
* syntactically correct JSON text, then null will be returned instead.
|
||||||
* <p/>
|
*
|
||||||
* Warning: This method assumes that the data structure is acyclical.
|
* Warning: This method assumes that the data structure is acyclical.
|
||||||
*
|
*
|
||||||
* @return a printable, displayable, portable, transmittable representation of the object, beginning with
|
* @return a printable, displayable, portable, transmittable representation of the object, beginning with
|
||||||
@ -1365,7 +1364,7 @@ public class JSONObject {
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* Make a prettyprinted JSON text of this JSONObject.
|
* Make a prettyprinted JSON text of this JSONObject.
|
||||||
* <p/>
|
*
|
||||||
* Warning: This method assumes that the data structure is acyclical.
|
* Warning: This method assumes that the data structure is acyclical.
|
||||||
*
|
*
|
||||||
* @param indentFactor The number of spaces to add to each level of indentation.
|
* @param indentFactor The number of spaces to add to each level of indentation.
|
||||||
@ -1385,7 +1384,7 @@ public class JSONObject {
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* Write the contents of the JSONObject as JSON text to a writer. For compactness, no whitespace is added.
|
* Write the contents of the JSONObject as JSON text to a writer. For compactness, no whitespace is added.
|
||||||
* <p/>
|
*
|
||||||
* Warning: This method assumes that the data structure is acyclical.
|
* Warning: This method assumes that the data structure is acyclical.
|
||||||
*
|
*
|
||||||
* @return The writer.
|
* @return The writer.
|
||||||
@ -1398,7 +1397,7 @@ public class JSONObject {
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* Write the contents of the JSONObject as JSON text to a writer. For compactness, no whitespace is added.
|
* Write the contents of the JSONObject as JSON text to a writer. For compactness, no whitespace is added.
|
||||||
* <p/>
|
*
|
||||||
* Warning: This method assumes that the data structure is acyclical.
|
* Warning: This method assumes that the data structure is acyclical.
|
||||||
*
|
*
|
||||||
* @return The writer.
|
* @return The writer.
|
||||||
|
@ -6,28 +6,28 @@ import java.io.StringWriter;
|
|||||||
* JSONStringer provides a quick and convenient way of producing JSON text. The texts produced strictly conform to JSON
|
* JSONStringer provides a quick and convenient way of producing JSON text. The texts produced strictly conform to JSON
|
||||||
* syntax rules. No whitespace is added, so the results are ready for transmission or storage. Each instance of
|
* syntax rules. No whitespace is added, so the results are ready for transmission or storage. Each instance of
|
||||||
* JSONStringer can produce one JSON text.
|
* JSONStringer can produce one JSON text.
|
||||||
* <p/>
|
*
|
||||||
* A JSONStringer instance provides a <code>value</code> method for appending values to the text, and a <code>key</code>
|
* A JSONStringer instance provides a <code>value</code> method for appending values to the text, and a <code>key</code>
|
||||||
* method for adding keys before values in objects. There are <code>array</code> and <code>endArray</code> methods that
|
* method for adding keys before values in objects. There are <code>array</code> and <code>endArray</code> methods that
|
||||||
* make and bound array values, and <code>object</code> and <code>endObject</code> methods which make and bound object
|
* make and bound array values, and <code>object</code> and <code>endObject</code> methods which make and bound object
|
||||||
* values. All of these methods return the JSONWriter instance, permitting cascade style. For example,
|
* values. All of these methods return the JSONWriter instance, permitting cascade style. For example,
|
||||||
* <p/>
|
*
|
||||||
* <p/>
|
*
|
||||||
* <pre>
|
* <pre>
|
||||||
* myString = new JSONStringer().object().key("JSON").value("Hello,
|
* myString = new JSONStringer().object().key("JSON").value("Hello,
|
||||||
* World!").endObject().toString();
|
* World!").endObject().toString();
|
||||||
* </pre>
|
* </pre>
|
||||||
* <p/>
|
*
|
||||||
* which produces the string
|
* which produces the string
|
||||||
* <p/>
|
*
|
||||||
* <p/>
|
*
|
||||||
* <pre>
|
* <pre>
|
||||||
* {"JSON":"Hello, World!"}
|
* {"JSON":"Hello, World!"}
|
||||||
* </pre>
|
* </pre>
|
||||||
* <p/>
|
*
|
||||||
* The first method called must be <code>array</code> or <code>object</code>. There are no methods for adding commas or
|
* The first method called must be <code>array</code> or <code>object</code>. There are no methods for adding commas or
|
||||||
* colons. JSONStringer adds them for you. Objects and arrays can be nested up to 20 levels deep.
|
* colons. JSONStringer adds them for you. Objects and arrays can be nested up to 20 levels deep.
|
||||||
* <p/>
|
*
|
||||||
* This can sometimes be easier than using a JSONObject to build a string.
|
* This can sometimes be easier than using a JSONObject to build a string.
|
||||||
*
|
*
|
||||||
* @author JSON.org
|
* @author JSON.org
|
||||||
|
@ -7,27 +7,27 @@ import java.io.Writer;
|
|||||||
* JSONWriter provides a quick and convenient way of producing JSON text. The texts produced strictly conform to JSON
|
* JSONWriter provides a quick and convenient way of producing JSON text. The texts produced strictly conform to JSON
|
||||||
* syntax rules. No whitespace is added, so the results are ready for transmission or storage. Each instance of
|
* syntax rules. No whitespace is added, so the results are ready for transmission or storage. Each instance of
|
||||||
* JSONWriter can produce one JSON text.
|
* JSONWriter can produce one JSON text.
|
||||||
* <p/>
|
*
|
||||||
* A JSONWriter instance provides a <code>value</code> method for appending values to the text, and a <code>key</code>
|
* A JSONWriter instance provides a <code>value</code> method for appending values to the text, and a <code>key</code>
|
||||||
* method for adding keys before values in objects. There are <code>array</code> and <code>endArray</code> methods that
|
* method for adding keys before values in objects. There are <code>array</code> and <code>endArray</code> methods that
|
||||||
* make and bound array values, and <code>object</code> and <code>endObject</code> methods which make and bound object
|
* make and bound array values, and <code>object</code> and <code>endObject</code> methods which make and bound object
|
||||||
* values. All of these methods return the JSONWriter instance, permitting a cascade style. For example,
|
* values. All of these methods return the JSONWriter instance, permitting a cascade style. For example,
|
||||||
* <p/>
|
*
|
||||||
* <p/>
|
*
|
||||||
* <pre>
|
* <pre>
|
||||||
* new JSONWriter(myWriter).object().key("JSON").value("Hello, World!").endObject();
|
* new JSONWriter(myWriter).object().key("JSON").value("Hello, World!").endObject();
|
||||||
* </pre>
|
* </pre>
|
||||||
* <p/>
|
*
|
||||||
* which writes
|
* which writes
|
||||||
* <p/>
|
*
|
||||||
* <p/>
|
*
|
||||||
* <pre>
|
* <pre>
|
||||||
* {"JSON":"Hello, World!"}
|
* {"JSON":"Hello, World!"}
|
||||||
* </pre>
|
* </pre>
|
||||||
* <p/>
|
*
|
||||||
* The first method called must be <code>array</code> or <code>object</code>. There are no methods for adding commas or
|
* The first method called must be <code>array</code> or <code>object</code>. There are no methods for adding commas or
|
||||||
* colons. JSONWriter adds them for you. Objects and arrays can be nested up to 20 levels deep.
|
* colons. JSONWriter adds them for you. Objects and arrays can be nested up to 20 levels deep.
|
||||||
* <p/>
|
*
|
||||||
* This can sometimes be easier than using a JSONObject to build a string.
|
* This can sometimes be easier than using a JSONObject to build a string.
|
||||||
*
|
*
|
||||||
* @author JSON.org
|
* @author JSON.org
|
||||||
|
@ -5,22 +5,22 @@ package com.intellectualcrafters.json;
|
|||||||
* byte. The last byte of a character never has the MSB reset. Every byte that is not the last byte has the MSB set. Kim
|
* byte. The last byte of a character never has the MSB reset. Every byte that is not the last byte has the MSB set. Kim
|
||||||
* stands for "Keep it minimal". A Unicode character is never longer than 3 bytes. Every byte contributes 7 bits to the
|
* stands for "Keep it minimal". A Unicode character is never longer than 3 bytes. Every byte contributes 7 bits to the
|
||||||
* character. ASCII is unmodified.
|
* character. ASCII is unmodified.
|
||||||
* <p/>
|
*
|
||||||
* Kim UTF-8 one byte U+007F U+007F two bytes U+3FFF U+07FF three bytes U+10FFF U+FFFF four bytes U+10FFFF
|
* Kim UTF-8 one byte U+007F U+007F two bytes U+3FFF U+07FF three bytes U+10FFF U+FFFF four bytes U+10FFFF
|
||||||
* <p/>
|
*
|
||||||
* Characters in the ranges U+0800..U+3FFF and U+10000..U+10FFFF will be one byte smaller when encoded in Kim compared
|
* Characters in the ranges U+0800..U+3FFF and U+10000..U+10FFFF will be one byte smaller when encoded in Kim compared
|
||||||
* to UTF-8.
|
* to UTF-8.
|
||||||
* <p/>
|
*
|
||||||
* Kim is beneficial when using scripts such as Old South Arabian, Aramaic, Avestan, Balinese, Batak, Bopomofo,
|
* Kim is beneficial when using scripts such as Old South Arabian, Aramaic, Avestan, Balinese, Batak, Bopomofo,
|
||||||
* Buginese, Buhid, Carian, Cherokee, Coptic, Cyrillic, Deseret, Egyptian Hieroglyphs, Ethiopic, Georgian, Glagolitic,
|
* Buginese, Buhid, Carian, Cherokee, Coptic, Cyrillic, Deseret, Egyptian Hieroglyphs, Ethiopic, Georgian, Glagolitic,
|
||||||
* Gothic, Hangul Jamo, Hanunoo, Hiragana, Kanbun, Kaithi, Kannada, Katakana, Kharoshthi, Khmer, Lao, Lepcha, Limbu,
|
* Gothic, Hangul Jamo, Hanunoo, Hiragana, Kanbun, Kaithi, Kannada, Katakana, Kharoshthi, Khmer, Lao, Lepcha, Limbu,
|
||||||
* Lycian, Lydian, Malayalam, Mandaic, Meroitic, Miao, Mongolian, Myanmar, New Tai Lue, Ol Chiki, Old Turkic, Oriya,
|
* Lycian, Lydian, Malayalam, Mandaic, Meroitic, Miao, Mongolian, Myanmar, New Tai Lue, Ol Chiki, Old Turkic, Oriya,
|
||||||
* Osmanya, Pahlavi, Parthian, Phags-Pa, Phoenician, Samaritan, Sharada, Sinhala, Sora Sompeng, Tagalog, Tagbanwa,
|
* Osmanya, Pahlavi, Parthian, Phags-Pa, Phoenician, Samaritan, Sharada, Sinhala, Sora Sompeng, Tagalog, Tagbanwa,
|
||||||
* Takri, Tai Le, Tai Tham, Tamil, Telugu, Thai, Tibetan, Tifinagh, UCAS.
|
* Takri, Tai Le, Tai Tham, Tamil, Telugu, Thai, Tibetan, Tifinagh, UCAS.
|
||||||
* <p/>
|
*
|
||||||
* A kim object can be constructed from an ordinary UTF-16 string, or from a byte array. A kim object can produce a
|
* A kim object can be constructed from an ordinary UTF-16 string, or from a byte array. A kim object can produce a
|
||||||
* UTF-16 string.
|
* UTF-16 string.
|
||||||
* <p/>
|
*
|
||||||
* As with UTF-8, it is possible to detect character boundaries within a byte sequence. UTF-8 is one of the world's
|
* As with UTF-8, it is possible to detect character boundaries within a byte sequence. UTF-8 is one of the world's
|
||||||
* great inventions. While Kim is more efficient, it is not clear that it is worth the expense of transition.
|
* great inventions. While Kim is more efficient, it is not clear that it is worth the expense of transition.
|
||||||
*
|
*
|
||||||
@ -197,7 +197,7 @@ public class Kim {
|
|||||||
* @param at the index of the char value. The first character is at 0.
|
* @param at the index of the char value. The first character is at 0.
|
||||||
*
|
*
|
||||||
* @throws JSONException if at does not point to a valid character.
|
* @throws JSONException if at does not point to a valid character.
|
||||||
* @returns a Unicode character between 0 and 0x10FFFF.
|
* @return a Unicode character between 0 and 0x10FFFF.
|
||||||
*/
|
*/
|
||||||
public int characterAt(final int at) throws JSONException {
|
public int characterAt(final int at) throws JSONException {
|
||||||
final int c = get(at);
|
final int c = get(at);
|
||||||
@ -239,7 +239,7 @@ public class Kim {
|
|||||||
*
|
*
|
||||||
* @param obj the other kim with which to compare.
|
* @param obj the other kim with which to compare.
|
||||||
*
|
*
|
||||||
* @returns true if this and obj are both kim objects containing identical byte sequences.
|
* @return true if this and obj are both kim objects containing identical byte sequences.
|
||||||
*/
|
*/
|
||||||
@Override
|
@Override
|
||||||
public boolean equals(final Object obj) {
|
public boolean equals(final Object obj) {
|
||||||
|
@ -9,58 +9,16 @@ import java.util.Iterator;
|
|||||||
* @version 2014-05-03
|
* @version 2014-05-03
|
||||||
*/
|
*/
|
||||||
public class XML {
|
public class XML {
|
||||||
/**
|
|
||||||
* The Character '&'.
|
|
||||||
*/
|
|
||||||
public static final Character AMP = '&';
|
public static final Character AMP = '&';
|
||||||
/**
|
|
||||||
* The Character '''.
|
|
||||||
*/
|
|
||||||
public static final Character APOS = '\'';
|
public static final Character APOS = '\'';
|
||||||
/**
|
|
||||||
* The Character '!'.
|
|
||||||
*/
|
|
||||||
public static final Character BANG = '!';
|
public static final Character BANG = '!';
|
||||||
/**
|
|
||||||
* The Character '='.
|
|
||||||
*/
|
|
||||||
public static final Character EQ = '=';
|
public static final Character EQ = '=';
|
||||||
/**
|
|
||||||
* The Character '>'.
|
|
||||||
*/
|
|
||||||
public static final Character GT = '>';
|
public static final Character GT = '>';
|
||||||
/**
|
|
||||||
* The Character '<'.
|
|
||||||
*/
|
|
||||||
public static final Character LT = '<';
|
public static final Character LT = '<';
|
||||||
/**
|
|
||||||
* The Character '?'.
|
|
||||||
*/
|
|
||||||
public static final Character QUEST = '?';
|
public static final Character QUEST = '?';
|
||||||
/**
|
|
||||||
* The Character '"'.
|
|
||||||
*/
|
|
||||||
public static final Character QUOT = '"';
|
public static final Character QUOT = '"';
|
||||||
/**
|
|
||||||
* The Character '/'.
|
|
||||||
*/
|
|
||||||
public static final Character SLASH = '/';
|
public static final Character SLASH = '/';
|
||||||
|
|
||||||
/**
|
|
||||||
* Replace special characters with XML escapes:
|
|
||||||
* <p/>
|
|
||||||
* <p/>
|
|
||||||
* <pre>
|
|
||||||
* & <small>(ampersand)</small> is replaced by &amp;
|
|
||||||
* < <small>(less than)</small> is replaced by &lt;
|
|
||||||
* > <small>(greater than)</small> is replaced by &gt;
|
|
||||||
* " <small>(double quote)</small> is replaced by &quot;
|
|
||||||
* </pre>
|
|
||||||
*
|
|
||||||
* @param string The string to be escaped.
|
|
||||||
*
|
|
||||||
* @return The escaped string.
|
|
||||||
*/
|
|
||||||
public static String escape(final String string) {
|
public static String escape(final String string) {
|
||||||
final StringBuilder sb = new StringBuilder(string.length());
|
final StringBuilder sb = new StringBuilder(string.length());
|
||||||
for (int i = 0, length = string.length(); i < length; i++) {
|
for (int i = 0, length = string.length(); i < length; i++) {
|
||||||
@ -300,20 +258,6 @@ public class XML {
|
|||||||
return string;
|
return string;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* Convert a well-formed (but not necessarily valid) XML string into a JSONObject. Some information may be lost in
|
|
||||||
* this transformation because JSON is a data format and XML is a document format. XML uses elements, attributes,
|
|
||||||
* and content text, while JSON uses unordered collections of name/value pairs and arrays of values. JSON does not
|
|
||||||
* does not like to distinguish between elements and attributes. Sequences of similar elements are represented as
|
|
||||||
* JSONArrays. Content text may be placed in a "content" member. Comments, prologs, DTDs, and <code><[ [
|
|
||||||
* ]]></code> are ignored.
|
|
||||||
*
|
|
||||||
* @param string The source string.
|
|
||||||
*
|
|
||||||
* @return A JSONObject containing the structured data from the XML string.
|
|
||||||
*
|
|
||||||
* @throws JSONException
|
|
||||||
*/
|
|
||||||
public static JSONObject toJSONObject(final String string) throws JSONException {
|
public static JSONObject toJSONObject(final String string) throws JSONException {
|
||||||
final JSONObject jo = new JSONObject();
|
final JSONObject jo = new JSONObject();
|
||||||
final XMLTokener x = new XMLTokener(string);
|
final XMLTokener x = new XMLTokener(string);
|
||||||
|
@ -55,10 +55,10 @@ public class XMLTokener extends JSONTokener {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Get the next XML outer token, trimming whitespace. There are two kinds of tokens: the '<' character which begins
|
* Get the next XML outer token, trimming whitespace. There are two kinds of tokens: the '<' character which begins
|
||||||
* a markup tag, and the content text between markup tags.
|
* a markup tag, and the content text between markup tags.
|
||||||
*
|
*
|
||||||
* @return A string, or a '<' Character, or null if there is no more source text.
|
* @return A string, or a '<' Character, or null if there is no more source text.
|
||||||
*
|
*
|
||||||
* @throws JSONException
|
* @throws JSONException
|
||||||
*/
|
*/
|
||||||
@ -90,7 +90,7 @@ public class XMLTokener extends JSONTokener {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Return the next entity. These entities are translated to Characters: <code>& ' > <
|
* Return the next entity. These entities are translated to Characters: <code>& " > <
|
||||||
* "</code>.
|
* "</code>.
|
||||||
*
|
*
|
||||||
* @param ampersand An ampersand character.
|
* @param ampersand An ampersand character.
|
||||||
@ -119,7 +119,7 @@ public class XMLTokener extends JSONTokener {
|
|||||||
/**
|
/**
|
||||||
* Returns the next XML meta token. This is used for skipping over <!...> and <?...?> structures.
|
* Returns the next XML meta token. This is used for skipping over <!...> and <?...?> structures.
|
||||||
*
|
*
|
||||||
* @return Syntax characters (<code>< > / = ! ?</code>) are returned as Character, and strings and names are
|
* @return Syntax characters (<code>< > / = ! ?</code>) are returned as Character, and strings and names are
|
||||||
* returned as Boolean. We don't care what the values actually are.
|
* returned as Boolean. We don't care what the values actually are.
|
||||||
*
|
*
|
||||||
* @throws JSONException If a string is not properly closed or if the XML is badly structured.
|
* @throws JSONException If a string is not properly closed or if the XML is badly structured.
|
||||||
@ -182,7 +182,7 @@ public class XMLTokener extends JSONTokener {
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* Get the next XML Token. These tokens are found inside of angle brackets. It may be one of these characters:
|
* Get the next XML Token. These tokens are found inside of angle brackets. It may be one of these characters:
|
||||||
* <code>/ > = ! ?</code> or it may be a string wrapped in single quotes or double quotes, or it may be a name.
|
* <code>/ >= ! ?</code> or it may be a string wrapped in single quotes or double quotes, or it may be a name.
|
||||||
*
|
*
|
||||||
* @return a String or a Character.
|
* @return a String or a Character.
|
||||||
*
|
*
|
||||||
|
@ -2,6 +2,7 @@ package com.intellectualcrafters.plot;
|
|||||||
|
|
||||||
import java.io.File;
|
import java.io.File;
|
||||||
import java.util.Arrays;
|
import java.util.Arrays;
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
import net.milkbowl.vault.economy.Economy;
|
import net.milkbowl.vault.economy.Economy;
|
||||||
|
|
||||||
@ -18,24 +19,82 @@ import org.bukkit.plugin.Plugin;
|
|||||||
import org.bukkit.plugin.RegisteredServiceProvider;
|
import org.bukkit.plugin.RegisteredServiceProvider;
|
||||||
import org.bukkit.plugin.java.JavaPlugin;
|
import org.bukkit.plugin.java.JavaPlugin;
|
||||||
|
|
||||||
|
import com.intellectualcrafters.plot.commands.Auto;
|
||||||
import com.intellectualcrafters.plot.commands.BukkitCommand;
|
import com.intellectualcrafters.plot.commands.BukkitCommand;
|
||||||
import com.intellectualcrafters.plot.commands.Buy;
|
import com.intellectualcrafters.plot.commands.Buy;
|
||||||
|
import com.intellectualcrafters.plot.commands.Claim;
|
||||||
|
import com.intellectualcrafters.plot.commands.Clear;
|
||||||
|
import com.intellectualcrafters.plot.commands.Comment;
|
||||||
|
import com.intellectualcrafters.plot.commands.Condense;
|
||||||
|
import com.intellectualcrafters.plot.commands.Confirm;
|
||||||
|
import com.intellectualcrafters.plot.commands.Copy;
|
||||||
|
import com.intellectualcrafters.plot.commands.CreateRoadSchematic;
|
||||||
|
import com.intellectualcrafters.plot.commands.Database;
|
||||||
|
import com.intellectualcrafters.plot.commands.Debug;
|
||||||
|
import com.intellectualcrafters.plot.commands.DebugClaimTest;
|
||||||
|
import com.intellectualcrafters.plot.commands.DebugClear;
|
||||||
|
import com.intellectualcrafters.plot.commands.DebugExec;
|
||||||
|
import com.intellectualcrafters.plot.commands.DebugFill;
|
||||||
|
import com.intellectualcrafters.plot.commands.DebugFixFlags;
|
||||||
|
import com.intellectualcrafters.plot.commands.DebugLoadTest;
|
||||||
|
import com.intellectualcrafters.plot.commands.DebugRoadRegen;
|
||||||
|
import com.intellectualcrafters.plot.commands.DebugSaveTest;
|
||||||
|
import com.intellectualcrafters.plot.commands.DebugUUID;
|
||||||
|
import com.intellectualcrafters.plot.commands.Delete;
|
||||||
|
import com.intellectualcrafters.plot.commands.Denied;
|
||||||
|
import com.intellectualcrafters.plot.commands.FlagCmd;
|
||||||
|
import com.intellectualcrafters.plot.commands.Help;
|
||||||
|
import com.intellectualcrafters.plot.commands.Helpers;
|
||||||
|
import com.intellectualcrafters.plot.commands.Home;
|
||||||
|
import com.intellectualcrafters.plot.commands.Inbox;
|
||||||
|
import com.intellectualcrafters.plot.commands.Info;
|
||||||
|
import com.intellectualcrafters.plot.commands.Inventory;
|
||||||
|
import com.intellectualcrafters.plot.commands.Kick;
|
||||||
import com.intellectualcrafters.plot.commands.MainCommand;
|
import com.intellectualcrafters.plot.commands.MainCommand;
|
||||||
|
import com.intellectualcrafters.plot.commands.Merge;
|
||||||
|
import com.intellectualcrafters.plot.commands.Move;
|
||||||
|
import com.intellectualcrafters.plot.commands.MusicSubcommand;
|
||||||
|
import com.intellectualcrafters.plot.commands.Purge;
|
||||||
|
import com.intellectualcrafters.plot.commands.Rate;
|
||||||
|
import com.intellectualcrafters.plot.commands.RegenAllRoads;
|
||||||
|
import com.intellectualcrafters.plot.commands.Reload;
|
||||||
|
import com.intellectualcrafters.plot.commands.SchematicCmd;
|
||||||
|
import com.intellectualcrafters.plot.commands.Set;
|
||||||
|
import com.intellectualcrafters.plot.commands.SetOwner;
|
||||||
|
import com.intellectualcrafters.plot.commands.Setup;
|
||||||
|
import com.intellectualcrafters.plot.commands.Swap;
|
||||||
|
import com.intellectualcrafters.plot.commands.TP;
|
||||||
|
import com.intellectualcrafters.plot.commands.Target;
|
||||||
|
import com.intellectualcrafters.plot.commands.Template;
|
||||||
|
import com.intellectualcrafters.plot.commands.Trim;
|
||||||
|
import com.intellectualcrafters.plot.commands.Trusted;
|
||||||
|
import com.intellectualcrafters.plot.commands.Unclaim;
|
||||||
|
import com.intellectualcrafters.plot.commands.Unlink;
|
||||||
|
import com.intellectualcrafters.plot.commands.Visit;
|
||||||
import com.intellectualcrafters.plot.commands.WE_Anywhere;
|
import com.intellectualcrafters.plot.commands.WE_Anywhere;
|
||||||
|
import com.intellectualcrafters.plot.commands.list;
|
||||||
|
import com.intellectualcrafters.plot.commands.plugin;
|
||||||
import com.intellectualcrafters.plot.config.C;
|
import com.intellectualcrafters.plot.config.C;
|
||||||
import com.intellectualcrafters.plot.config.Settings;
|
import com.intellectualcrafters.plot.config.Settings;
|
||||||
import com.intellectualcrafters.plot.database.PlotMeConverter;
|
import com.intellectualcrafters.plot.database.plotme.ClassicPlotMeConnector;
|
||||||
|
import com.intellectualcrafters.plot.database.plotme.PlotMeConverter;
|
||||||
import com.intellectualcrafters.plot.flag.FlagManager;
|
import com.intellectualcrafters.plot.flag.FlagManager;
|
||||||
import com.intellectualcrafters.plot.generator.BukkitHybridUtils;
|
import com.intellectualcrafters.plot.generator.BukkitHybridUtils;
|
||||||
import com.intellectualcrafters.plot.generator.HybridGen;
|
import com.intellectualcrafters.plot.generator.HybridGen;
|
||||||
import com.intellectualcrafters.plot.generator.HybridUtils;
|
import com.intellectualcrafters.plot.generator.HybridUtils;
|
||||||
|
import com.intellectualcrafters.plot.listeners.APlotListener;
|
||||||
|
import com.intellectualcrafters.plot.listeners.ChunkListener;
|
||||||
import com.intellectualcrafters.plot.listeners.ForceFieldListener;
|
import com.intellectualcrafters.plot.listeners.ForceFieldListener;
|
||||||
import com.intellectualcrafters.plot.listeners.InventoryListener;
|
import com.intellectualcrafters.plot.listeners.InventoryListener;
|
||||||
import com.intellectualcrafters.plot.listeners.PlayerEvents;
|
import com.intellectualcrafters.plot.listeners.PlayerEvents;
|
||||||
import com.intellectualcrafters.plot.listeners.PlayerEvents_1_8;
|
import com.intellectualcrafters.plot.listeners.PlayerEvents_1_8;
|
||||||
|
import com.intellectualcrafters.plot.listeners.PlotListener;
|
||||||
import com.intellectualcrafters.plot.listeners.PlotPlusListener;
|
import com.intellectualcrafters.plot.listeners.PlotPlusListener;
|
||||||
import com.intellectualcrafters.plot.listeners.WorldEditListener;
|
import com.intellectualcrafters.plot.listeners.TNTListener;
|
||||||
import com.intellectualcrafters.plot.listeners.WorldEvents;
|
import com.intellectualcrafters.plot.listeners.WorldEvents;
|
||||||
|
import com.intellectualcrafters.plot.listeners.worldedit.WEListener;
|
||||||
|
import com.intellectualcrafters.plot.listeners.worldedit.WESubscriber;
|
||||||
|
import com.intellectualcrafters.plot.object.PlotPlayer;
|
||||||
import com.intellectualcrafters.plot.titles.AbstractTitle;
|
import com.intellectualcrafters.plot.titles.AbstractTitle;
|
||||||
import com.intellectualcrafters.plot.titles.DefaultTitle;
|
import com.intellectualcrafters.plot.titles.DefaultTitle;
|
||||||
import com.intellectualcrafters.plot.util.BlockManager;
|
import com.intellectualcrafters.plot.util.BlockManager;
|
||||||
@ -44,10 +103,12 @@ import com.intellectualcrafters.plot.util.ChunkManager;
|
|||||||
import com.intellectualcrafters.plot.util.ConsoleColors;
|
import com.intellectualcrafters.plot.util.ConsoleColors;
|
||||||
import com.intellectualcrafters.plot.util.EventUtil;
|
import com.intellectualcrafters.plot.util.EventUtil;
|
||||||
import com.intellectualcrafters.plot.util.MainUtil;
|
import com.intellectualcrafters.plot.util.MainUtil;
|
||||||
|
import com.intellectualcrafters.plot.util.PlayerManager;
|
||||||
import com.intellectualcrafters.plot.util.SetupUtils;
|
import com.intellectualcrafters.plot.util.SetupUtils;
|
||||||
import com.intellectualcrafters.plot.util.TaskManager;
|
import com.intellectualcrafters.plot.util.TaskManager;
|
||||||
import com.intellectualcrafters.plot.util.bukkit.BukkitChunkManager;
|
import com.intellectualcrafters.plot.util.bukkit.BukkitChunkManager;
|
||||||
import com.intellectualcrafters.plot.util.bukkit.BukkitEventUtil;
|
import com.intellectualcrafters.plot.util.bukkit.BukkitEventUtil;
|
||||||
|
import com.intellectualcrafters.plot.util.bukkit.BukkitPlayerManager;
|
||||||
import com.intellectualcrafters.plot.util.bukkit.BukkitSetBlockManager;
|
import com.intellectualcrafters.plot.util.bukkit.BukkitSetBlockManager;
|
||||||
import com.intellectualcrafters.plot.util.bukkit.BukkitSetupUtils;
|
import com.intellectualcrafters.plot.util.bukkit.BukkitSetupUtils;
|
||||||
import com.intellectualcrafters.plot.util.bukkit.BukkitTaskManager;
|
import com.intellectualcrafters.plot.util.bukkit.BukkitTaskManager;
|
||||||
@ -59,8 +120,10 @@ import com.intellectualcrafters.plot.util.bukkit.SetBlockFast_1_8;
|
|||||||
import com.intellectualcrafters.plot.util.bukkit.SetBlockSlow;
|
import com.intellectualcrafters.plot.util.bukkit.SetBlockSlow;
|
||||||
import com.intellectualcrafters.plot.util.bukkit.UUIDHandler;
|
import com.intellectualcrafters.plot.util.bukkit.UUIDHandler;
|
||||||
import com.intellectualcrafters.plot.uuid.DefaultUUIDWrapper;
|
import com.intellectualcrafters.plot.uuid.DefaultUUIDWrapper;
|
||||||
|
import com.intellectualcrafters.plot.uuid.LowerOfflineUUIDWrapper;
|
||||||
import com.intellectualcrafters.plot.uuid.OfflineUUIDWrapper;
|
import com.intellectualcrafters.plot.uuid.OfflineUUIDWrapper;
|
||||||
import com.intellectualcrafters.plot.uuid.UUIDWrapper;
|
import com.intellectualcrafters.plot.uuid.UUIDWrapper;
|
||||||
|
import com.sk89q.worldedit.WorldEdit;
|
||||||
import com.sk89q.worldedit.bukkit.WorldEditPlugin;
|
import com.sk89q.worldedit.bukkit.WorldEditPlugin;
|
||||||
|
|
||||||
public class BukkitMain extends JavaPlugin implements Listener, IPlotMain {
|
public class BukkitMain extends JavaPlugin implements Listener, IPlotMain {
|
||||||
@ -100,9 +163,16 @@ public class BukkitMain extends JavaPlugin implements Listener, IPlotMain {
|
|||||||
} else {
|
} else {
|
||||||
log("&dUsing metrics will allow us to improve the plugin, please consider it :)");
|
log("&dUsing metrics will allow us to improve the plugin, please consider it :)");
|
||||||
}
|
}
|
||||||
getServer().getPluginManager().registerEvents(new WorldEvents(), this);
|
List<World> worlds = Bukkit.getWorlds();
|
||||||
|
if (worlds.size() > 0) {
|
||||||
|
UUIDHandler.cacheAll(worlds.get(0).getName());
|
||||||
|
for (World world : worlds) {
|
||||||
|
Bukkit.getServer().unloadWorld(world, false);
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onDisable() {
|
public void onDisable() {
|
||||||
MAIN.disable();
|
MAIN.disable();
|
||||||
@ -112,6 +182,9 @@ public class BukkitMain extends JavaPlugin implements Listener, IPlotMain {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void log(String message) {
|
public void log(String message) {
|
||||||
|
if (message == null) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
message = message.replaceAll("\u00B2", "2");
|
message = message.replaceAll("\u00B2", "2");
|
||||||
if ((THIS == null) || (Bukkit.getServer().getConsoleSender() == null)) {
|
if ((THIS == null) || (Bukkit.getServer().getConsoleSender() == null)) {
|
||||||
System.out.println(ChatColor.stripColor(ConsoleColors.fromString(message)));
|
System.out.println(ChatColor.stripColor(ConsoleColors.fromString(message)));
|
||||||
@ -137,6 +210,57 @@ public class BukkitMain extends JavaPlugin implements Listener, IPlotMain {
|
|||||||
@Override
|
@Override
|
||||||
public void registerCommands() {
|
public void registerCommands() {
|
||||||
new MainCommand();
|
new MainCommand();
|
||||||
|
MainCommand.subCommands.add(new Template());
|
||||||
|
MainCommand.subCommands.add(new Setup());
|
||||||
|
MainCommand.subCommands.add(new DebugUUID());
|
||||||
|
MainCommand.subCommands.add(new DebugFill());
|
||||||
|
MainCommand.subCommands.add(new DebugSaveTest());
|
||||||
|
MainCommand.subCommands.add(new DebugLoadTest());
|
||||||
|
MainCommand.subCommands.add(new CreateRoadSchematic());
|
||||||
|
MainCommand.subCommands.add(new RegenAllRoads());
|
||||||
|
MainCommand.subCommands.add(new DebugClear());
|
||||||
|
MainCommand.subCommands.add(new Claim());
|
||||||
|
MainCommand.subCommands.add(new Auto());
|
||||||
|
MainCommand.subCommands.add(new Home());
|
||||||
|
MainCommand.subCommands.add(new Visit());
|
||||||
|
MainCommand.subCommands.add(new TP());
|
||||||
|
MainCommand.subCommands.add(new Set());
|
||||||
|
MainCommand.subCommands.add(new Clear());
|
||||||
|
MainCommand.subCommands.add(new Delete());
|
||||||
|
MainCommand.subCommands.add(new SetOwner());
|
||||||
|
MainCommand.subCommands.add(new Denied());
|
||||||
|
MainCommand.subCommands.add(new Helpers());
|
||||||
|
MainCommand.subCommands.add(new Trusted());
|
||||||
|
MainCommand.subCommands.add(new Info());
|
||||||
|
MainCommand.subCommands.add(new list());
|
||||||
|
MainCommand.subCommands.add(new Help());
|
||||||
|
MainCommand.subCommands.add(new Debug());
|
||||||
|
MainCommand.subCommands.add(new SchematicCmd());
|
||||||
|
MainCommand.subCommands.add(new plugin());
|
||||||
|
MainCommand.subCommands.add(new Inventory());
|
||||||
|
MainCommand.subCommands.add(new Purge());
|
||||||
|
MainCommand.subCommands.add(new Reload());
|
||||||
|
MainCommand.subCommands.add(new Merge());
|
||||||
|
MainCommand.subCommands.add(new Unlink());
|
||||||
|
MainCommand.subCommands.add(new Kick());
|
||||||
|
MainCommand.subCommands.add(new Rate());
|
||||||
|
MainCommand.subCommands.add(new DebugClaimTest());
|
||||||
|
MainCommand.subCommands.add(new Inbox());
|
||||||
|
MainCommand.subCommands.add(new Comment());
|
||||||
|
MainCommand.subCommands.add(new Database());
|
||||||
|
MainCommand.subCommands.add(new Unclaim());
|
||||||
|
MainCommand.subCommands.add(new Swap());
|
||||||
|
MainCommand.subCommands.add(new MusicSubcommand());
|
||||||
|
MainCommand.subCommands.add(new DebugRoadRegen());
|
||||||
|
MainCommand.subCommands.add(new Trim());
|
||||||
|
MainCommand.subCommands.add(new DebugExec());
|
||||||
|
MainCommand.subCommands.add(new FlagCmd());
|
||||||
|
MainCommand.subCommands.add(new Target());
|
||||||
|
MainCommand.subCommands.add(new DebugFixFlags());
|
||||||
|
MainCommand.subCommands.add(new Move());
|
||||||
|
MainCommand.subCommands.add(new Condense());
|
||||||
|
MainCommand.subCommands.add(new Confirm());
|
||||||
|
MainCommand.subCommands.add(new Copy());
|
||||||
final BukkitCommand bcmd = new BukkitCommand();
|
final BukkitCommand bcmd = new BukkitCommand();
|
||||||
final PluginCommand plotCommand = getCommand("plots");
|
final PluginCommand plotCommand = getCommand("plots");
|
||||||
plotCommand.setExecutor(bcmd);
|
plotCommand.setExecutor(bcmd);
|
||||||
@ -238,7 +362,8 @@ public class BukkitMain extends JavaPlugin implements Listener, IPlotMain {
|
|||||||
log("&cPlease use WorldEdit 6+ for masking support");
|
log("&cPlease use WorldEdit 6+ for masking support");
|
||||||
log("&c - http://builds.enginehub.org/job/worldedit");
|
log("&c - http://builds.enginehub.org/job/worldedit");
|
||||||
} else {
|
} else {
|
||||||
getServer().getPluginManager().registerEvents(new WorldEditListener(), this);
|
getServer().getPluginManager().registerEvents(new WEListener(), this);
|
||||||
|
WorldEdit.getInstance().getEventBus().register(new WESubscriber());
|
||||||
MainCommand.subCommands.add(new WE_Anywhere());
|
MainCommand.subCommands.add(new WE_Anywhere());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -269,6 +394,7 @@ public class BukkitMain extends JavaPlugin implements Listener, IPlotMain {
|
|||||||
try {
|
try {
|
||||||
BukkitSetBlockManager.setBlockManager = new SetBlockFast();
|
BukkitSetBlockManager.setBlockManager = new SetBlockFast();
|
||||||
} catch (final Throwable e) {
|
} catch (final Throwable e) {
|
||||||
|
MainUtil.canSetFast = false;
|
||||||
BukkitSetBlockManager.setBlockManager = new SetBlockSlow();
|
BukkitSetBlockManager.setBlockManager = new SetBlockSlow();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -284,11 +410,12 @@ public class BukkitMain extends JavaPlugin implements Listener, IPlotMain {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean initPlotMeConverter() {
|
public boolean initPlotMeConverter() {
|
||||||
try {
|
TaskManager.runTaskLaterAsync(new Runnable() {
|
||||||
new PlotMeConverter().runAsync();
|
@Override
|
||||||
} catch (final Exception e) {
|
public void run() {
|
||||||
e.printStackTrace();
|
new PlotMeConverter().run(new ClassicPlotMeConnector());
|
||||||
}
|
}
|
||||||
|
}, 20);
|
||||||
if (Bukkit.getPluginManager().getPlugin("PlotMe") != null) {
|
if (Bukkit.getPluginManager().getPlugin("PlotMe") != null) {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
@ -318,22 +445,39 @@ public class BukkitMain extends JavaPlugin implements Listener, IPlotMain {
|
|||||||
@Override
|
@Override
|
||||||
public UUIDWrapper initUUIDHandler() {
|
public UUIDWrapper initUUIDHandler() {
|
||||||
final boolean checkVersion = checkVersion(1, 7, 6);
|
final boolean checkVersion = checkVersion(1, 7, 6);
|
||||||
|
if (Settings.OFFLINE_MODE) {
|
||||||
|
if (Settings.UUID_LOWERCASE) {
|
||||||
|
UUIDHandler.uuidWrapper = new LowerOfflineUUIDWrapper();
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
UUIDHandler.uuidWrapper = new OfflineUUIDWrapper();
|
||||||
|
}
|
||||||
|
Settings.OFFLINE_MODE = true;
|
||||||
|
} else if (checkVersion) {
|
||||||
|
UUIDHandler.uuidWrapper = new DefaultUUIDWrapper();
|
||||||
|
Settings.OFFLINE_MODE = false;
|
||||||
|
} else {
|
||||||
|
if (Settings.UUID_LOWERCASE) {
|
||||||
|
UUIDHandler.uuidWrapper = new LowerOfflineUUIDWrapper();
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
UUIDHandler.uuidWrapper = new OfflineUUIDWrapper();
|
||||||
|
}
|
||||||
|
Settings.OFFLINE_MODE = true;
|
||||||
|
}
|
||||||
if (!checkVersion) {
|
if (!checkVersion) {
|
||||||
log(C.PREFIX.s() + " &c[WARN] Titles are disabled - please update your version of Bukkit to support this feature.");
|
log(C.PREFIX.s() + " &c[WARN] Titles are disabled - please update your version of Bukkit to support this feature.");
|
||||||
Settings.TITLES = false;
|
Settings.TITLES = false;
|
||||||
FlagManager.removeFlag(FlagManager.getFlag("titles"));
|
FlagManager.removeFlag(FlagManager.getFlag("titles"));
|
||||||
} else {
|
} else {
|
||||||
AbstractTitle.TITLE_CLASS = new DefaultTitle();
|
AbstractTitle.TITLE_CLASS = new DefaultTitle();
|
||||||
}
|
|
||||||
if (Settings.OFFLINE_MODE) {
|
if (UUIDHandler.uuidWrapper instanceof DefaultUUIDWrapper) {
|
||||||
UUIDHandler.uuidWrapper = new OfflineUUIDWrapper();
|
Settings.TWIN_MODE_UUID = true;
|
||||||
Settings.OFFLINE_MODE = true;
|
}
|
||||||
} else if (checkVersion) {
|
else if (UUIDHandler.uuidWrapper instanceof OfflineUUIDWrapper && !Bukkit.getOnlineMode()) {
|
||||||
UUIDHandler.uuidWrapper = new DefaultUUIDWrapper();
|
Settings.TWIN_MODE_UUID = true;
|
||||||
Settings.OFFLINE_MODE = false;
|
}
|
||||||
} else {
|
|
||||||
UUIDHandler.uuidWrapper = new OfflineUUIDWrapper();
|
|
||||||
Settings.OFFLINE_MODE = true;
|
|
||||||
}
|
}
|
||||||
if (Settings.OFFLINE_MODE) {
|
if (Settings.OFFLINE_MODE) {
|
||||||
log(C.PREFIX.s() + " &6PlotSquared is using Offline Mode UUIDs either because of user preference, or because you are using an old version of Bukkit");
|
log(C.PREFIX.s() + " &6PlotSquared is using Offline Mode UUIDs either because of user preference, or because you are using an old version of Bukkit");
|
||||||
@ -352,4 +496,34 @@ public class BukkitMain extends JavaPlugin implements Listener, IPlotMain {
|
|||||||
public EventUtil initEventUtil() {
|
public EventUtil initEventUtil() {
|
||||||
return new BukkitEventUtil();
|
return new BukkitEventUtil();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void registerTNTListener() {
|
||||||
|
getServer().getPluginManager().registerEvents(new TNTListener(), this);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void unregister(PlotPlayer player) {
|
||||||
|
BukkitUtil.removePlayer(player.getName());
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public APlotListener initPlotListener() {
|
||||||
|
return new PlotListener();
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void registerChunkProcessor() {
|
||||||
|
getServer().getPluginManager().registerEvents(new ChunkListener(), this);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void registerWorldEvents() {
|
||||||
|
getServer().getPluginManager().registerEvents(new WorldEvents(), this);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public PlayerManager initPlayerManager() {
|
||||||
|
return new BukkitPlayerManager();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@ -7,9 +7,12 @@ import net.milkbowl.vault.economy.Economy;
|
|||||||
import org.bukkit.generator.ChunkGenerator;
|
import org.bukkit.generator.ChunkGenerator;
|
||||||
|
|
||||||
import com.intellectualcrafters.plot.generator.HybridUtils;
|
import com.intellectualcrafters.plot.generator.HybridUtils;
|
||||||
|
import com.intellectualcrafters.plot.listeners.APlotListener;
|
||||||
|
import com.intellectualcrafters.plot.object.PlotPlayer;
|
||||||
import com.intellectualcrafters.plot.util.BlockManager;
|
import com.intellectualcrafters.plot.util.BlockManager;
|
||||||
import com.intellectualcrafters.plot.util.ChunkManager;
|
import com.intellectualcrafters.plot.util.ChunkManager;
|
||||||
import com.intellectualcrafters.plot.util.EventUtil;
|
import com.intellectualcrafters.plot.util.EventUtil;
|
||||||
|
import com.intellectualcrafters.plot.util.PlayerManager;
|
||||||
import com.intellectualcrafters.plot.util.SetupUtils;
|
import com.intellectualcrafters.plot.util.SetupUtils;
|
||||||
import com.intellectualcrafters.plot.util.TaskManager;
|
import com.intellectualcrafters.plot.util.TaskManager;
|
||||||
import com.intellectualcrafters.plot.uuid.UUIDWrapper;
|
import com.intellectualcrafters.plot.uuid.UUIDWrapper;
|
||||||
@ -39,6 +42,8 @@ public interface IPlotMain {
|
|||||||
|
|
||||||
public void registerWorldEditEvents();
|
public void registerWorldEditEvents();
|
||||||
|
|
||||||
|
public void registerTNTListener();
|
||||||
|
|
||||||
public Economy getEconomy();
|
public Economy getEconomy();
|
||||||
|
|
||||||
public BlockManager initBlockManager();
|
public BlockManager initBlockManager();
|
||||||
@ -55,5 +60,15 @@ public interface IPlotMain {
|
|||||||
|
|
||||||
public boolean initPlotMeConverter();
|
public boolean initPlotMeConverter();
|
||||||
|
|
||||||
|
public void unregister(PlotPlayer player);
|
||||||
|
|
||||||
public ChunkGenerator getGenerator(String world, String name);
|
public ChunkGenerator getGenerator(String world, String name);
|
||||||
|
|
||||||
|
public APlotListener initPlotListener();
|
||||||
|
|
||||||
|
public void registerChunkProcessor();
|
||||||
|
|
||||||
|
public void registerWorldEvents();
|
||||||
|
|
||||||
|
public PlayerManager initPlayerManager();
|
||||||
}
|
}
|
||||||
|
@ -27,6 +27,7 @@ import java.util.zip.ZipInputStream;
|
|||||||
|
|
||||||
import net.milkbowl.vault.economy.Economy;
|
import net.milkbowl.vault.economy.Economy;
|
||||||
|
|
||||||
|
import org.apache.commons.lang.StringUtils;
|
||||||
import org.bukkit.configuration.file.YamlConfiguration;
|
import org.bukkit.configuration.file.YamlConfiguration;
|
||||||
|
|
||||||
import com.intellectualcrafters.plot.commands.Cluster;
|
import com.intellectualcrafters.plot.commands.Cluster;
|
||||||
@ -35,6 +36,7 @@ import com.intellectualcrafters.plot.config.C;
|
|||||||
import com.intellectualcrafters.plot.config.Configuration;
|
import com.intellectualcrafters.plot.config.Configuration;
|
||||||
import com.intellectualcrafters.plot.config.Settings;
|
import com.intellectualcrafters.plot.config.Settings;
|
||||||
import com.intellectualcrafters.plot.database.DBFunc;
|
import com.intellectualcrafters.plot.database.DBFunc;
|
||||||
|
import com.intellectualcrafters.plot.database.Database;
|
||||||
import com.intellectualcrafters.plot.database.MySQL;
|
import com.intellectualcrafters.plot.database.MySQL;
|
||||||
import com.intellectualcrafters.plot.database.SQLManager;
|
import com.intellectualcrafters.plot.database.SQLManager;
|
||||||
import com.intellectualcrafters.plot.database.SQLite;
|
import com.intellectualcrafters.plot.database.SQLite;
|
||||||
@ -48,14 +50,17 @@ import com.intellectualcrafters.plot.generator.HybridPlotWorld;
|
|||||||
import com.intellectualcrafters.plot.generator.HybridUtils;
|
import com.intellectualcrafters.plot.generator.HybridUtils;
|
||||||
import com.intellectualcrafters.plot.generator.SquarePlotManager;
|
import com.intellectualcrafters.plot.generator.SquarePlotManager;
|
||||||
import com.intellectualcrafters.plot.generator.SquarePlotWorld;
|
import com.intellectualcrafters.plot.generator.SquarePlotWorld;
|
||||||
|
import com.intellectualcrafters.plot.listeners.APlotListener;
|
||||||
import com.intellectualcrafters.plot.object.Plot;
|
import com.intellectualcrafters.plot.object.Plot;
|
||||||
import com.intellectualcrafters.plot.object.PlotBlock;
|
import com.intellectualcrafters.plot.object.PlotBlock;
|
||||||
import com.intellectualcrafters.plot.object.PlotCluster;
|
import com.intellectualcrafters.plot.object.PlotCluster;
|
||||||
import com.intellectualcrafters.plot.object.PlotGenerator;
|
import com.intellectualcrafters.plot.object.PlotGenerator;
|
||||||
|
import com.intellectualcrafters.plot.object.PlotHandler;
|
||||||
import com.intellectualcrafters.plot.object.PlotId;
|
import com.intellectualcrafters.plot.object.PlotId;
|
||||||
import com.intellectualcrafters.plot.object.PlotManager;
|
import com.intellectualcrafters.plot.object.PlotManager;
|
||||||
import com.intellectualcrafters.plot.object.PlotPlayer;
|
import com.intellectualcrafters.plot.object.PlotPlayer;
|
||||||
import com.intellectualcrafters.plot.object.PlotWorld;
|
import com.intellectualcrafters.plot.object.PlotWorld;
|
||||||
|
import com.intellectualcrafters.plot.object.comment.CommentManager;
|
||||||
import com.intellectualcrafters.plot.util.BlockManager;
|
import com.intellectualcrafters.plot.util.BlockManager;
|
||||||
import com.intellectualcrafters.plot.util.ChunkManager;
|
import com.intellectualcrafters.plot.util.ChunkManager;
|
||||||
import com.intellectualcrafters.plot.util.ClusterManager;
|
import com.intellectualcrafters.plot.util.ClusterManager;
|
||||||
@ -64,6 +69,7 @@ import com.intellectualcrafters.plot.util.ExpireManager;
|
|||||||
import com.intellectualcrafters.plot.util.Logger;
|
import com.intellectualcrafters.plot.util.Logger;
|
||||||
import com.intellectualcrafters.plot.util.Logger.LogLevel;
|
import com.intellectualcrafters.plot.util.Logger.LogLevel;
|
||||||
import com.intellectualcrafters.plot.util.MainUtil;
|
import com.intellectualcrafters.plot.util.MainUtil;
|
||||||
|
import com.intellectualcrafters.plot.util.PlayerManager;
|
||||||
import com.intellectualcrafters.plot.util.SetupUtils;
|
import com.intellectualcrafters.plot.util.SetupUtils;
|
||||||
import com.intellectualcrafters.plot.util.TaskManager;
|
import com.intellectualcrafters.plot.util.TaskManager;
|
||||||
import com.intellectualcrafters.plot.util.bukkit.UUIDHandler;
|
import com.intellectualcrafters.plot.util.bukkit.UUIDHandler;
|
||||||
@ -89,11 +95,11 @@ public class PlotSquared {
|
|||||||
private final static HashMap<String, PlotWorld> plotworlds = new HashMap<>();
|
private final static HashMap<String, PlotWorld> plotworlds = new HashMap<>();
|
||||||
private final static HashMap<String, PlotManager> plotmanagers = new HashMap<>();
|
private final static HashMap<String, PlotManager> plotmanagers = new HashMap<>();
|
||||||
private static LinkedHashMap<String, HashMap<PlotId, Plot>> plots;
|
private static LinkedHashMap<String, HashMap<PlotId, Plot>> plots;
|
||||||
private static MySQL mySQL;
|
private static Database database;
|
||||||
public static Connection connection;
|
public static Connection connection;
|
||||||
|
|
||||||
public static MySQL getMySQL() {
|
public static Database getDatabase() {
|
||||||
return mySQL;
|
return database;
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void updatePlot(final Plot plot) {
|
public static void updatePlot(final Plot plot) {
|
||||||
@ -136,8 +142,18 @@ public class PlotSquared {
|
|||||||
|
|
||||||
public static Set<Plot> getPlots() {
|
public static Set<Plot> getPlots() {
|
||||||
final ArrayList<Plot> newplots = new ArrayList<>();
|
final ArrayList<Plot> newplots = new ArrayList<>();
|
||||||
for (final HashMap<PlotId, Plot> world : plots.values()) {
|
for (final Entry<String, HashMap<PlotId, Plot>> entry : plots.entrySet()) {
|
||||||
newplots.addAll(world.values());
|
if (isPlotWorld(entry.getKey())) {
|
||||||
|
newplots.addAll(entry.getValue().values());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return new LinkedHashSet<>(newplots);
|
||||||
|
}
|
||||||
|
|
||||||
|
public static Set<Plot> getPlotsRaw() {
|
||||||
|
final ArrayList<Plot> newplots = new ArrayList<>();
|
||||||
|
for (final Entry<String, HashMap<PlotId, Plot>> entry : plots.entrySet()) {
|
||||||
|
newplots.addAll(entry.getValue().values());
|
||||||
}
|
}
|
||||||
return new LinkedHashSet<>(newplots);
|
return new LinkedHashSet<>(newplots);
|
||||||
}
|
}
|
||||||
@ -148,7 +164,21 @@ public class PlotSquared {
|
|||||||
Collections.sort(newPlots, new Comparator<Plot>() {
|
Collections.sort(newPlots, new Comparator<Plot>() {
|
||||||
@Override
|
@Override
|
||||||
public int compare(Plot p1, Plot p2) {
|
public int compare(Plot p1, Plot p2) {
|
||||||
return p1.hashCode() + p1.world.hashCode() - p2.hashCode() + p2.world.hashCode();
|
int h1 = p1.hashCode();
|
||||||
|
int h2 = p2.hashCode();
|
||||||
|
if (h1 < 0) {
|
||||||
|
h1 = -h1*2 - 1;
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
h1*=2;
|
||||||
|
}
|
||||||
|
if (h2 < 0) {
|
||||||
|
h2 = -h2*2 - 1;
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
h2*=2;
|
||||||
|
}
|
||||||
|
return h1-h2;
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
return newPlots;
|
return newPlots;
|
||||||
@ -156,21 +186,39 @@ public class PlotSquared {
|
|||||||
|
|
||||||
public static ArrayList<Plot> sortPlots(Collection<Plot> plots, final String priorityWorld) {
|
public static ArrayList<Plot> sortPlots(Collection<Plot> plots, final String priorityWorld) {
|
||||||
ArrayList<Plot> newPlots = new ArrayList<>();
|
ArrayList<Plot> newPlots = new ArrayList<>();
|
||||||
newPlots.addAll(plots);
|
HashMap<PlotId, Plot> worldPlots = PlotSquared.plots.get(priorityWorld);
|
||||||
Collections.sort(newPlots, new Comparator<Plot>() {
|
if (worldPlots != null) {
|
||||||
@Override
|
for (Plot plot : sortPlots(worldPlots.values())) {
|
||||||
public int compare(Plot p1, Plot p2) {
|
if (plots.contains(plot)) {
|
||||||
int w1 = 0;
|
newPlots.add(plot);
|
||||||
int w2 = 0;
|
|
||||||
if (!p1.world.equals(priorityWorld)) {
|
|
||||||
w1 = p1.hashCode();
|
|
||||||
}
|
}
|
||||||
if (!p2.world.equals(priorityWorld)) {
|
|
||||||
w2 = p2.hashCode();
|
|
||||||
}
|
|
||||||
return p1.hashCode() + w1 - p2.hashCode() - w2;
|
|
||||||
}
|
}
|
||||||
});
|
}
|
||||||
|
ArrayList<String> worlds = new ArrayList<>(PlotSquared.plots.keySet());
|
||||||
|
Collections.sort(worlds);
|
||||||
|
for (String world : worlds) {
|
||||||
|
if (!world.equals(priorityWorld)) {
|
||||||
|
for (Plot plot : PlotSquared.plots.get(world).values()) {
|
||||||
|
if (plots.contains(plot)) {
|
||||||
|
newPlots.add(plot);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return newPlots;
|
||||||
|
}
|
||||||
|
|
||||||
|
public static ArrayList<Plot> sortPlotsByWorld(Collection<Plot> plots) {
|
||||||
|
ArrayList<Plot> newPlots = new ArrayList<>();
|
||||||
|
ArrayList<String> worlds = new ArrayList<>(PlotSquared.plots.keySet());
|
||||||
|
Collections.sort(worlds);
|
||||||
|
for (String world : worlds) {
|
||||||
|
for (Plot plot : PlotSquared.plots.get(world).values()) {
|
||||||
|
if (plots.contains(plot)) {
|
||||||
|
newPlots.add(plot);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
return newPlots;
|
return newPlots;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -188,7 +236,7 @@ public class PlotSquared {
|
|||||||
final ArrayList<Plot> myplots = new ArrayList<>();
|
final ArrayList<Plot> myplots = new ArrayList<>();
|
||||||
for (final Plot plot : getPlots(world).values()) {
|
for (final Plot plot : getPlots(world).values()) {
|
||||||
if (plot.hasOwner()) {
|
if (plot.hasOwner()) {
|
||||||
if (plot.getOwner().equals(uuid)) {
|
if (PlotHandler.isOwner(plot, uuid)) {
|
||||||
myplots.add(plot);
|
myplots.add(plot);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -229,7 +277,7 @@ public class PlotSquared {
|
|||||||
if (isPlotWorld(world)) {
|
if (isPlotWorld(world)) {
|
||||||
for (final Plot plot : plots.get(world).values()) {
|
for (final Plot plot : plots.get(world).values()) {
|
||||||
if (plot.hasOwner()) {
|
if (plot.hasOwner()) {
|
||||||
if (plot.getOwner().equals(uuid)) {
|
if (PlotHandler.isOwner(plot, uuid)) {
|
||||||
myplots.add(plot);
|
myplots.add(plot);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -315,18 +363,22 @@ public class PlotSquared {
|
|||||||
final PlotGenerator gen_class = generator;
|
final PlotGenerator gen_class = generator;
|
||||||
plotWorld = gen_class.getNewPlotWorld(world);
|
plotWorld = gen_class.getNewPlotWorld(world);
|
||||||
plotManager = gen_class.getPlotManager();
|
plotManager = gen_class.getPlotManager();
|
||||||
|
|
||||||
if (!config.contains(path)) {
|
if (!config.contains(path)) {
|
||||||
config.createSection(path);
|
config.createSection(path);
|
||||||
}
|
}
|
||||||
|
|
||||||
plotWorld.TYPE = 2;
|
plotWorld.TYPE = 2;
|
||||||
plotWorld.TERRAIN = 0;
|
plotWorld.TERRAIN = 0;
|
||||||
plotWorld.saveConfiguration(config.getConfigurationSection(path));
|
plotWorld.saveConfiguration(config.getConfigurationSection(path));
|
||||||
plotWorld.loadDefaultConfiguration(config.getConfigurationSection(path));
|
plotWorld.loadDefaultConfiguration(config.getConfigurationSection(path));
|
||||||
|
|
||||||
try {
|
try {
|
||||||
config.save(configFile);
|
config.save(configFile);
|
||||||
} catch (final IOException e) {
|
} catch (final IOException e) {
|
||||||
e.printStackTrace();
|
e.printStackTrace();
|
||||||
}
|
}
|
||||||
|
|
||||||
if (((plotWorld.TYPE == 2) && !Settings.ENABLE_CLUSTERS) || !(plotManager instanceof SquarePlotManager)) {
|
if (((plotWorld.TYPE == 2) && !Settings.ENABLE_CLUSTERS) || !(plotManager instanceof SquarePlotManager)) {
|
||||||
log("&c[ERROR] World '" + world + "' in settings.yml is not using PlotSquared generator! Please set the generator correctly or delete the world from the 'settings.yml'!");
|
log("&c[ERROR] World '" + world + "' in settings.yml is not using PlotSquared generator! Please set the generator correctly or delete the world from the 'settings.yml'!");
|
||||||
return;
|
return;
|
||||||
@ -466,15 +518,17 @@ public class PlotSquared {
|
|||||||
log(C.PREFIX.s() + "&cIt's really recommended to run Java 1.8, as it increases performance");
|
log(C.PREFIX.s() + "&cIt's really recommended to run Java 1.8, as it increases performance");
|
||||||
}
|
}
|
||||||
TASK = IMP.getTaskManager();
|
TASK = IMP.getTaskManager();
|
||||||
if (Settings.KILL_ROAD_MOBS) {
|
|
||||||
IMP.runEntityTask();
|
|
||||||
}
|
|
||||||
if (C.ENABLED.s().length() > 0) {
|
if (C.ENABLED.s().length() > 0) {
|
||||||
log(C.ENABLED.s());
|
log(C.ENABLED.s());
|
||||||
}
|
}
|
||||||
setupConfigs();
|
setupConfigs();
|
||||||
setupDefaultFlags();
|
setupDefaultFlags();
|
||||||
setupDatabase();
|
setupDatabase();
|
||||||
|
CommentManager.registerDefaultInboxes();
|
||||||
|
// Tasks
|
||||||
|
if (Settings.KILL_ROAD_MOBS) {
|
||||||
|
IMP.runEntityTask();
|
||||||
|
}
|
||||||
// Events
|
// Events
|
||||||
IMP.registerCommands();
|
IMP.registerCommands();
|
||||||
IMP.registerPlayerEvents();
|
IMP.registerPlayerEvents();
|
||||||
@ -482,6 +536,13 @@ public class PlotSquared {
|
|||||||
IMP.registerPlotPlusEvents();
|
IMP.registerPlotPlusEvents();
|
||||||
IMP.registerForceFieldEvents();
|
IMP.registerForceFieldEvents();
|
||||||
IMP.registerWorldEditEvents();
|
IMP.registerWorldEditEvents();
|
||||||
|
IMP.registerWorldEvents();
|
||||||
|
if (Settings.TNT_LISTENER) {
|
||||||
|
IMP.registerTNTListener();
|
||||||
|
}
|
||||||
|
if (Settings.CHUNK_PROCESSOR) {
|
||||||
|
IMP.registerChunkProcessor();
|
||||||
|
}
|
||||||
// create UUIDWrapper
|
// create UUIDWrapper
|
||||||
UUIDHandler.uuidWrapper = IMP.initUUIDHandler();
|
UUIDHandler.uuidWrapper = IMP.initUUIDHandler();
|
||||||
// create event util class
|
// create event util class
|
||||||
@ -494,35 +555,51 @@ public class PlotSquared {
|
|||||||
BlockManager.manager = IMP.initBlockManager();
|
BlockManager.manager = IMP.initBlockManager();
|
||||||
// Set chunk
|
// Set chunk
|
||||||
ChunkManager.manager = IMP.initChunkManager();
|
ChunkManager.manager = IMP.initChunkManager();
|
||||||
|
// Plot listener
|
||||||
|
APlotListener.manager = IMP.initPlotListener();
|
||||||
|
// Player manager
|
||||||
|
PlayerManager.manager = IMP.initPlayerManager();
|
||||||
|
|
||||||
// PlotMe
|
// PlotMe
|
||||||
TaskManager.runTaskLater(new Runnable() {
|
if (Settings.CONVERT_PLOTME || Settings.CACHE_PLOTME) {
|
||||||
@Override
|
TaskManager.runTaskLater(new Runnable() {
|
||||||
public void run() {
|
@Override
|
||||||
if (IMP.initPlotMeConverter()) {
|
public void run() {
|
||||||
log("&c=== IMPORTANT ===");
|
if (IMP.initPlotMeConverter()) {
|
||||||
log("&cTHIS MESSAGE MAY BE EXTREMELY HELPFUL IF YOU HAVE TROUBLE CONVERTING PLOTME!");
|
log("&c=== IMPORTANT ===");
|
||||||
log("&c - Make sure 'UUID.read-from-disk' is disabled (false)!");
|
log("&cTHIS MESSAGE MAY BE EXTREMELY HELPFUL IF YOU HAVE TROUBLE CONVERTING PLOTME!");
|
||||||
log("&c - Sometimes the database can be locked, deleting PlotMe.jar beforehand will fix the issue!");
|
log("&c - Make sure 'UUID.read-from-disk' is disabled (false)!");
|
||||||
log("&c - After the conversion is finished, please set 'plotme-convert.enabled' to false in the 'settings.yml@'");
|
log("&c - Sometimes the database can be locked, deleting PlotMe.jar beforehand will fix the issue!");
|
||||||
|
log("&c - After the conversion is finished, please set 'plotme-convert.enabled' to false in the 'settings.yml'");
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}, 200);
|
||||||
}, 200);
|
}
|
||||||
if (Settings.AUTO_CLEAR) {
|
if (Settings.AUTO_CLEAR) {
|
||||||
ExpireManager.runTask();
|
ExpireManager.runTask();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (Settings.COMMENT_NOTIFICATION_INTERVAL > 0) {
|
||||||
|
CommentManager.runTask();
|
||||||
|
}
|
||||||
|
|
||||||
// Copy files
|
// Copy files
|
||||||
copyFile("town.template");
|
copyFile("town.template", "templates");
|
||||||
copyFile("skyblock.template");
|
copyFile("skyblock.template", "templates");
|
||||||
|
copyFile("german.yml", "translations");
|
||||||
|
copyFile("s_chinese_unescaped.yml", "translations");
|
||||||
|
copyFile("s_chinese.yml", "translations");
|
||||||
|
showDebug();
|
||||||
}
|
}
|
||||||
|
|
||||||
public void copyFile(String file) {
|
public void copyFile(String file, String folder) {
|
||||||
try {
|
try {
|
||||||
byte[] buffer = new byte[2048];
|
byte[] buffer = new byte[2048];
|
||||||
File output = PlotSquared.IMP.getDirectory();
|
File output = PlotSquared.IMP.getDirectory();
|
||||||
if (!output.exists()) {
|
if (!output.exists()) {
|
||||||
output.mkdirs();
|
output.mkdirs();
|
||||||
}
|
}
|
||||||
File newFile = new File((output + File.separator + "templates" + File.separator + file));
|
File newFile = new File((output + File.separator + folder + File.separator + file));
|
||||||
if (newFile.exists()) {
|
if (newFile.exists()) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@ -555,12 +632,9 @@ public class PlotSquared {
|
|||||||
|
|
||||||
public void disable() {
|
public void disable() {
|
||||||
try {
|
try {
|
||||||
connection.close();
|
database.closeConnection();
|
||||||
mySQL.closeConnection();
|
|
||||||
} catch (NullPointerException | SQLException e) {
|
} catch (NullPointerException | SQLException e) {
|
||||||
if (connection != null) {
|
log("&cCould not close database connection!");
|
||||||
log("&cCould not close mysql connection!");
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -578,8 +652,8 @@ public class PlotSquared {
|
|||||||
}
|
}
|
||||||
if (Settings.DB.USE_MYSQL) {
|
if (Settings.DB.USE_MYSQL) {
|
||||||
try {
|
try {
|
||||||
mySQL = new MySQL(THIS, Settings.DB.HOST_NAME, Settings.DB.PORT, Settings.DB.DATABASE, Settings.DB.USER, Settings.DB.PASSWORD);
|
database = new MySQL(THIS, Settings.DB.HOST_NAME, Settings.DB.PORT, Settings.DB.DATABASE, Settings.DB.USER, Settings.DB.PASSWORD);
|
||||||
connection = mySQL.openConnection();
|
connection = database.openConnection();
|
||||||
{
|
{
|
||||||
if (DBFunc.dbManager == null) {
|
if (DBFunc.dbManager == null) {
|
||||||
DBFunc.dbManager = new SQLManager(connection, Settings.DB.PREFIX);
|
DBFunc.dbManager = new SQLManager(connection, Settings.DB.PREFIX);
|
||||||
@ -617,7 +691,8 @@ public class PlotSquared {
|
|||||||
log(C.PREFIX.s() + "MongoDB is not yet implemented");
|
log(C.PREFIX.s() + "MongoDB is not yet implemented");
|
||||||
} else if (Settings.DB.USE_SQLITE) {
|
} else if (Settings.DB.USE_SQLITE) {
|
||||||
try {
|
try {
|
||||||
connection = new SQLite(THIS, IMP.getDirectory() + File.separator + Settings.DB.SQLITE_DB + ".db").openConnection();
|
this.database = new SQLite(THIS, IMP.getDirectory() + File.separator + Settings.DB.SQLITE_DB + ".db");
|
||||||
|
connection = this.database.openConnection();
|
||||||
{
|
{
|
||||||
DBFunc.dbManager = new SQLManager(connection, Settings.DB.PREFIX);
|
DBFunc.dbManager = new SQLManager(connection, Settings.DB.PREFIX);
|
||||||
final DatabaseMetaData meta = connection.getMetaData();
|
final DatabaseMetaData meta = connection.getMetaData();
|
||||||
@ -652,9 +727,10 @@ public class PlotSquared {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public static void setupDefaultFlags() {
|
public static void setupDefaultFlags() {
|
||||||
final List<String> booleanFlags = Arrays.asList("notify-enter", "notify-leave", "item-drop", "invincible", "instabreak", "drop-protection", "forcefield", "titles", "pve", "pvp", "no-worldedit");
|
final List<String> booleanFlags = Arrays.asList("notify-enter", "notify-leave", "item-drop", "invincible", "instabreak", "drop-protection", "forcefield", "titles", "pve", "pvp", "no-worldedit", "redstone", "keep");
|
||||||
final List<String> intervalFlags = Arrays.asList("feed", "heal");
|
final List<String> intervalFlags = Arrays.asList("feed", "heal");
|
||||||
final List<String> stringFlags = Arrays.asList("greeting", "farewell");
|
final List<String> stringFlags = Arrays.asList("greeting", "farewell");
|
||||||
|
final List<String> intFlags = Arrays.asList("entity-cap", "mob-cap", "animal-cap", "hostile-cap", "vehicle-cap");
|
||||||
for (final String flag : stringFlags) {
|
for (final String flag : stringFlags) {
|
||||||
FlagManager.addFlag(new AbstractFlag(flag));
|
FlagManager.addFlag(new AbstractFlag(flag));
|
||||||
}
|
}
|
||||||
@ -664,6 +740,9 @@ public class PlotSquared {
|
|||||||
for (final String flag : booleanFlags) {
|
for (final String flag : booleanFlags) {
|
||||||
FlagManager.addFlag(new AbstractFlag(flag, new FlagValue.BooleanValue()));
|
FlagManager.addFlag(new AbstractFlag(flag, new FlagValue.BooleanValue()));
|
||||||
}
|
}
|
||||||
|
for (final String flag : intFlags) {
|
||||||
|
FlagManager.addFlag(new AbstractFlag(flag, new FlagValue.UnsignedIntegerValue()));
|
||||||
|
}
|
||||||
FlagManager.addFlag(new AbstractFlag("fly", new FlagValue.BooleanValue()));
|
FlagManager.addFlag(new AbstractFlag("fly", new FlagValue.BooleanValue()));
|
||||||
FlagManager.addFlag(new AbstractFlag("explosion", new FlagValue.BooleanValue()));
|
FlagManager.addFlag(new AbstractFlag("explosion", new FlagValue.BooleanValue()));
|
||||||
FlagManager.addFlag(new AbstractFlag("hostile-interact", new FlagValue.BooleanValue()));
|
FlagManager.addFlag(new AbstractFlag("hostile-interact", new FlagValue.BooleanValue()));
|
||||||
@ -735,72 +814,160 @@ public class PlotSquared {
|
|||||||
|
|
||||||
public static void setupConfig() {
|
public static void setupConfig() {
|
||||||
config.set("version", VERSION);
|
config.set("version", VERSION);
|
||||||
final Map<String, Object> options = new HashMap<>();
|
|
||||||
options.put("teleport.delay", 0);
|
|
||||||
options.put("auto_update", false);
|
|
||||||
|
|
||||||
|
final Map<String, Object> options = new HashMap<>();
|
||||||
|
// Command confirmation
|
||||||
options.put("confirmation.clear", Settings.CONFIRM_CLEAR);
|
options.put("confirmation.clear", Settings.CONFIRM_CLEAR);
|
||||||
options.put("confirmation.delete", Settings.CONFIRM_DELETE);
|
options.put("confirmation.delete", Settings.CONFIRM_DELETE);
|
||||||
options.put("confirmation.unlink", Settings.CONFIRM_UNLINK);
|
options.put("confirmation.unlink", Settings.CONFIRM_UNLINK);
|
||||||
|
|
||||||
|
// Protection
|
||||||
|
options.put("protection.tnt-listener.enabled", Settings.TNT_LISTENER);
|
||||||
|
options.put("protection.piston.falling-blocks", Settings.PISTON_FALLING_BLOCK_CHECK);
|
||||||
|
|
||||||
|
// Clusters
|
||||||
options.put("clusters.enabled", Settings.ENABLE_CLUSTERS);
|
options.put("clusters.enabled", Settings.ENABLE_CLUSTERS);
|
||||||
|
|
||||||
|
// PlotMe
|
||||||
options.put("plotme-alias", Settings.USE_PLOTME_ALIAS);
|
options.put("plotme-alias", Settings.USE_PLOTME_ALIAS);
|
||||||
options.put("plotme-convert.enabled", Settings.CONVERT_PLOTME);
|
options.put("plotme-convert.enabled", Settings.CONVERT_PLOTME);
|
||||||
options.put("claim.max-auto-area", Settings.MAX_AUTO_SIZE);
|
options.put("plotme-convert.cache-uuids", Settings.CACHE_PLOTME);
|
||||||
|
|
||||||
|
// UUID
|
||||||
options.put("UUID.offline", Settings.OFFLINE_MODE);
|
options.put("UUID.offline", Settings.OFFLINE_MODE);
|
||||||
|
options.put("UUID.force-lowercase", Settings.UUID_LOWERCASE);
|
||||||
|
options.put("uuid.read-from-disk", Settings.UUID_FROM_DISK);
|
||||||
|
|
||||||
|
// Mob stuff
|
||||||
options.put("kill_road_mobs", Settings.KILL_ROAD_MOBS_DEFAULT);
|
options.put("kill_road_mobs", Settings.KILL_ROAD_MOBS_DEFAULT);
|
||||||
options.put("mob_pathfinding", Settings.MOB_PATHFINDING_DEFAULT);
|
options.put("mob_pathfinding", Settings.MOB_PATHFINDING_DEFAULT);
|
||||||
options.put("console.color", Settings.CONSOLE_COLOR);
|
|
||||||
options.put("metrics", true);
|
// Clearing + Expiry
|
||||||
options.put("debug", true);
|
|
||||||
options.put("clear.auto.enabled", false);
|
options.put("clear.auto.enabled", false);
|
||||||
options.put("clear.auto.days", 365);
|
options.put("clear.auto.days", 365);
|
||||||
options.put("clear.check-disk", Settings.AUTO_CLEAR_CHECK_DISK);
|
options.put("clear.check-disk", Settings.AUTO_CLEAR_CHECK_DISK);
|
||||||
options.put("clear.on.ban", false);
|
options.put("clear.on.ban", false);
|
||||||
options.put("max_plots", Settings.MAX_PLOTS);
|
options.put("clear.fastmode", Settings.ENABLE_CLUSTERS);
|
||||||
|
|
||||||
|
// Schematics
|
||||||
options.put("schematics.save_path", Settings.SCHEMATIC_SAVE_PATH);
|
options.put("schematics.save_path", Settings.SCHEMATIC_SAVE_PATH);
|
||||||
options.put("uuid.read-from-disk", Settings.UUID_FROM_DISK);
|
|
||||||
|
// Caching
|
||||||
|
options.put("cache.permissions", Settings.PERMISSION_CACHING);
|
||||||
|
|
||||||
|
// Titles
|
||||||
options.put("titles", Settings.TITLES);
|
options.put("titles", Settings.TITLES);
|
||||||
|
|
||||||
|
// Teleportation
|
||||||
options.put("teleport.on_login", Settings.TELEPORT_ON_LOGIN);
|
options.put("teleport.on_login", Settings.TELEPORT_ON_LOGIN);
|
||||||
|
options.put("teleport.delay", 0);
|
||||||
|
|
||||||
|
// WorldEdit
|
||||||
options.put("worldedit.require-selection-in-mask", Settings.REQUIRE_SELECTION);
|
options.put("worldedit.require-selection-in-mask", Settings.REQUIRE_SELECTION);
|
||||||
|
options.put("worldedit.max-volume", Settings.WE_MAX_VOLUME);
|
||||||
|
options.put("worldedit.max-iterations", Settings.WE_MAX_ITERATIONS);
|
||||||
|
options.put("worldedit.blacklist", Arrays.asList("cs", ".s", "restore", "snapshot", "delchunks", "listchunks"));
|
||||||
|
|
||||||
|
// Chunk processor
|
||||||
|
options.put("chunk-processor.enabled", Settings.CHUNK_PROCESSOR);
|
||||||
|
options.put("chunk-processor.max-blockstates", Settings.CHUNK_PROCESSOR_MAX_BLOCKSTATES);
|
||||||
|
options.put("chunk-processor.max-entities", Settings.CHUNK_PROCESSOR_MAX_ENTITIES);
|
||||||
|
|
||||||
|
// Comments
|
||||||
|
options.put("comments.notifications.interval", Settings.COMMENT_NOTIFICATION_INTERVAL);
|
||||||
|
|
||||||
|
// Plot limits
|
||||||
|
options.put("global_limit", Settings.GLOBAL_LIMIT);
|
||||||
|
options.put("max_plots", Settings.MAX_PLOTS);
|
||||||
|
options.put("claim.max-auto-area", Settings.MAX_AUTO_SIZE);
|
||||||
|
|
||||||
|
// Misc
|
||||||
|
options.put("console.color", Settings.CONSOLE_COLOR);
|
||||||
|
options.put("metrics", true);
|
||||||
|
options.put("debug", true);
|
||||||
|
options.put("auto_update", false);
|
||||||
|
|
||||||
for (final Entry<String, Object> node : options.entrySet()) {
|
for (final Entry<String, Object> node : options.entrySet()) {
|
||||||
if (!config.contains(node.getKey())) {
|
if (!config.contains(node.getKey())) {
|
||||||
config.set(node.getKey(), node.getValue());
|
config.set(node.getKey(), node.getValue());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
Settings.ENABLE_CLUSTERS = config.getBoolean("clusters.enabled");
|
|
||||||
Settings.DEBUG = config.getBoolean("debug");
|
|
||||||
if (Settings.DEBUG) {
|
|
||||||
log(C.PREFIX.s() + "&6Debug Mode Enabled (Default). Edit the config to turn this off.");
|
|
||||||
}
|
|
||||||
|
|
||||||
|
// Command confirmation
|
||||||
Settings.CONFIRM_CLEAR = config.getBoolean("confirmation.clear");
|
Settings.CONFIRM_CLEAR = config.getBoolean("confirmation.clear");
|
||||||
Settings.CONFIRM_DELETE = config.getBoolean("confirmation.delete");
|
Settings.CONFIRM_DELETE = config.getBoolean("confirmation.delete");
|
||||||
Settings.CONFIRM_UNLINK = config.getBoolean("confirmation.unlink");
|
Settings.CONFIRM_UNLINK = config.getBoolean("confirmation.unlink");
|
||||||
|
|
||||||
Settings.TELEPORT_DELAY = config.getInt("teleport.delay");
|
// Protection
|
||||||
Settings.CONSOLE_COLOR = config.getBoolean("console.color");
|
Settings.TNT_LISTENER = config.getBoolean("protection.tnt-listener.enabled");
|
||||||
Settings.TELEPORT_ON_LOGIN = config.getBoolean("teleport.on_login");
|
Settings.PISTON_FALLING_BLOCK_CHECK = config.getBoolean("protection.piston.falling-blocks");
|
||||||
|
|
||||||
|
// Clusters
|
||||||
|
Settings.ENABLE_CLUSTERS = config.getBoolean("clusters.enabled");
|
||||||
|
|
||||||
|
// PlotMe
|
||||||
Settings.USE_PLOTME_ALIAS = config.getBoolean("plotme-alias");
|
Settings.USE_PLOTME_ALIAS = config.getBoolean("plotme-alias");
|
||||||
Settings.CONVERT_PLOTME = config.getBoolean("plotme-convert.enabled");
|
Settings.CONVERT_PLOTME = config.getBoolean("plotme-convert.enabled");
|
||||||
|
Settings.CACHE_PLOTME = config.getBoolean("plotme-convert.cache-uuids");
|
||||||
|
|
||||||
|
// UUID
|
||||||
|
Settings.OFFLINE_MODE = config.getBoolean("UUID.offline");
|
||||||
|
Settings.UUID_LOWERCASE = config.getBoolean("UUID.force-lowercase");
|
||||||
|
Settings.UUID_FROM_DISK = config.getBoolean("uuid.read-from-disk");
|
||||||
|
|
||||||
|
// Mob stuff
|
||||||
Settings.KILL_ROAD_MOBS = config.getBoolean("kill_road_mobs");
|
Settings.KILL_ROAD_MOBS = config.getBoolean("kill_road_mobs");
|
||||||
Settings.MOB_PATHFINDING = config.getBoolean("mob_pathf" + "inding");
|
Settings.MOB_PATHFINDING = config.getBoolean("mob_pathf" + "inding");
|
||||||
Settings.METRICS = config.getBoolean("metrics");
|
|
||||||
|
// Clearing + Expiry
|
||||||
|
Settings.FAST_CLEAR = config.getBoolean("clear.fastmode");
|
||||||
Settings.AUTO_CLEAR_DAYS = config.getInt("clear.auto.days");
|
Settings.AUTO_CLEAR_DAYS = config.getInt("clear.auto.days");
|
||||||
Settings.AUTO_CLEAR_CHECK_DISK = config.getBoolean("clear.check-disk");
|
Settings.AUTO_CLEAR_CHECK_DISK = config.getBoolean("clear.check-disk");
|
||||||
Settings.MAX_AUTO_SIZE = config.getInt("claim.max-auto-area");
|
|
||||||
Settings.AUTO_CLEAR = config.getBoolean("clear.auto.enabled");
|
Settings.AUTO_CLEAR = config.getBoolean("clear.auto.enabled");
|
||||||
|
|
||||||
|
// Schematics
|
||||||
|
Settings.SCHEMATIC_SAVE_PATH = config.getString("schematics.save_path");
|
||||||
|
|
||||||
|
// Caching
|
||||||
|
Settings.PERMISSION_CACHING = config.getBoolean("cache.permissions");
|
||||||
|
|
||||||
|
// Titles
|
||||||
Settings.TITLES = config.getBoolean("titles");
|
Settings.TITLES = config.getBoolean("titles");
|
||||||
|
|
||||||
|
// Teleportation
|
||||||
|
Settings.TELEPORT_DELAY = config.getInt("teleport.delay");
|
||||||
|
Settings.TELEPORT_ON_LOGIN = config.getBoolean("teleport.on_login");
|
||||||
|
|
||||||
|
// WorldEdit
|
||||||
|
Settings.REQUIRE_SELECTION = config.getBoolean("worldedit.require-selection-in-mask");
|
||||||
|
Settings.WE_MAX_VOLUME = config.getLong("worldedit.max-volume");
|
||||||
|
Settings.WE_MAX_ITERATIONS = config.getLong("worldedit.max-iterations");
|
||||||
|
Settings.WE_BLACKLIST = config.getStringList("worldedit.blacklist");
|
||||||
|
|
||||||
|
// Chunk processor
|
||||||
|
Settings.CHUNK_PROCESSOR = config.getBoolean("chunk-processor.enabled");
|
||||||
|
Settings.CHUNK_PROCESSOR_MAX_BLOCKSTATES = config.getInt("chunk-processor.max-blockstates");
|
||||||
|
Settings.CHUNK_PROCESSOR_MAX_ENTITIES= config.getInt("chunk-processor.max-entities");
|
||||||
|
|
||||||
|
// Comments
|
||||||
|
Settings.COMMENT_NOTIFICATION_INTERVAL = config.getInt("comments.notifications.interval");
|
||||||
|
|
||||||
|
// Plot limits
|
||||||
|
Settings.MAX_AUTO_SIZE = config.getInt("claim.max-auto-area");
|
||||||
Settings.MAX_PLOTS = config.getInt("max_plots");
|
Settings.MAX_PLOTS = config.getInt("max_plots");
|
||||||
if (Settings.MAX_PLOTS > 32767) {
|
if (Settings.MAX_PLOTS > 32767) {
|
||||||
log("&c`max_plots` Is set too high! This is a per player setting and does not need to be very large.");
|
log("&c`max_plots` Is set too high! This is a per player setting and does not need to be very large.");
|
||||||
Settings.MAX_PLOTS = 32767;
|
Settings.MAX_PLOTS = 32767;
|
||||||
}
|
}
|
||||||
Settings.SCHEMATIC_SAVE_PATH = config.getString("schematics.save_path");
|
Settings.GLOBAL_LIMIT = config.getBoolean("global_limit");
|
||||||
Settings.OFFLINE_MODE = config.getBoolean("UUID.offline");
|
|
||||||
Settings.UUID_FROM_DISK = config.getBoolean("uuid.read-from-disk");
|
// Misc
|
||||||
Settings.REQUIRE_SELECTION = config.getBoolean("worldedit.require-selection-in-mask");
|
Settings.DEBUG = config.getBoolean("debug");
|
||||||
|
if (Settings.DEBUG) {
|
||||||
|
log(C.PREFIX.s() + "&6Debug Mode Enabled (Default). Edit the config to turn this off.");
|
||||||
|
}
|
||||||
|
Settings.CONSOLE_COLOR = config.getBoolean("console.color");
|
||||||
|
Settings.METRICS = config.getBoolean("metrics");
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void setupConfigs() {
|
public static void setupConfigs() {
|
||||||
@ -887,9 +1054,6 @@ public class PlotSquared {
|
|||||||
Settings.AUTO_CLEAR = config.getBoolean("clear.auto.enabled");
|
Settings.AUTO_CLEAR = config.getBoolean("clear.auto.enabled");
|
||||||
Settings.AUTO_CLEAR_DAYS = config.getInt("clear.auto.days");
|
Settings.AUTO_CLEAR_DAYS = config.getInt("clear.auto.days");
|
||||||
Settings.DELETE_PLOTS_ON_BAN = config.getBoolean("clear.on.ban");
|
Settings.DELETE_PLOTS_ON_BAN = config.getBoolean("clear.on.ban");
|
||||||
Settings.API_URL = config.getString("uuid.api.location");
|
|
||||||
Settings.CUSTOM_API = config.getBoolean("uuid.api.custom");
|
|
||||||
Settings.UUID_FECTHING = config.getBoolean("uuid.fetching");
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void showDebug() {
|
public static void showDebug() {
|
||||||
@ -936,4 +1100,8 @@ public class PlotSquared {
|
|||||||
public static Set<String> getPlotWorlds() {
|
public static Set<String> getPlotWorlds() {
|
||||||
return plotworlds.keySet();
|
return plotworlds.keySet();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static Collection<PlotWorld> getPlotWorldObjects() {
|
||||||
|
return plotworlds.values();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@ -0,0 +1,671 @@
|
|||||||
|
////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||||
|
// PlotSquared - A plot manager and world generator for the Bukkit API /
|
||||||
|
// Copyright (c) 2014 IntellectualSites/IntellectualCrafters /
|
||||||
|
// /
|
||||||
|
// This program is free software; you can redistribute it and/or modify /
|
||||||
|
// it under the terms of the GNU General Public License as published by /
|
||||||
|
// the Free Software Foundation; either version 3 of the License, or /
|
||||||
|
// (at your option) any later version. /
|
||||||
|
// /
|
||||||
|
// This program is distributed in the hope that it will be useful, /
|
||||||
|
// but WITHOUT ANY WARRANTY; without even the implied warranty of /
|
||||||
|
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the /
|
||||||
|
// GNU General Public License for more details. /
|
||||||
|
// /
|
||||||
|
// You should have received a copy of the GNU General Public License /
|
||||||
|
// along with this program; if not, write to the Free Software Foundation, /
|
||||||
|
// Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA /
|
||||||
|
// /
|
||||||
|
// You can contact us via: support@intellectualsites.com /
|
||||||
|
////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||||
|
|
||||||
|
package com.intellectualcrafters.plot.api;
|
||||||
|
|
||||||
|
import java.util.ArrayList;
|
||||||
|
import java.util.Collection;
|
||||||
|
import java.util.Set;
|
||||||
|
|
||||||
|
import org.bukkit.Location;
|
||||||
|
import org.bukkit.World;
|
||||||
|
import org.bukkit.configuration.file.YamlConfiguration;
|
||||||
|
import org.bukkit.entity.Player;
|
||||||
|
import org.bukkit.plugin.java.JavaPlugin;
|
||||||
|
|
||||||
|
import com.intellectualcrafters.plot.PlotSquared;
|
||||||
|
import com.intellectualcrafters.plot.commands.MainCommand;
|
||||||
|
import com.intellectualcrafters.plot.commands.SubCommand;
|
||||||
|
import com.intellectualcrafters.plot.config.C;
|
||||||
|
import com.intellectualcrafters.plot.flag.AbstractFlag;
|
||||||
|
import com.intellectualcrafters.plot.flag.FlagManager;
|
||||||
|
import com.intellectualcrafters.plot.object.Plot;
|
||||||
|
import com.intellectualcrafters.plot.object.PlotId;
|
||||||
|
import com.intellectualcrafters.plot.object.PlotManager;
|
||||||
|
import com.intellectualcrafters.plot.object.PlotPlayer;
|
||||||
|
import com.intellectualcrafters.plot.object.PlotWorld;
|
||||||
|
import com.intellectualcrafters.plot.util.BlockManager;
|
||||||
|
import com.intellectualcrafters.plot.util.ChunkManager;
|
||||||
|
import com.intellectualcrafters.plot.util.ClusterManager;
|
||||||
|
import com.intellectualcrafters.plot.util.MainUtil;
|
||||||
|
import com.intellectualcrafters.plot.util.Permissions;
|
||||||
|
import com.intellectualcrafters.plot.util.SchematicHandler;
|
||||||
|
import com.intellectualcrafters.plot.util.bukkit.BukkitSetBlockManager;
|
||||||
|
import com.intellectualcrafters.plot.util.bukkit.BukkitUtil;
|
||||||
|
import com.intellectualcrafters.plot.util.bukkit.UUIDHandler;
|
||||||
|
import com.intellectualcrafters.plot.uuid.UUIDWrapper;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* PlotSquared API
|
||||||
|
*
|
||||||
|
* @author Citymonstret
|
||||||
|
* @author Empire92
|
||||||
|
* @version API 2.0
|
||||||
|
*/
|
||||||
|
|
||||||
|
@SuppressWarnings("unused") public class PlotAPI {
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Permission that allows for admin access, this permission node will allow the player to use any part of the
|
||||||
|
* plugin, without limitations.
|
||||||
|
*/
|
||||||
|
public static final String ADMIN_PERMISSION = "plots.admin";
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Constructor. Insert any Plugin. (Optimally the plugin that is accessing the method)
|
||||||
|
*
|
||||||
|
* @param plugin Plugin used to access this method
|
||||||
|
*
|
||||||
|
* @throws com.intellectualcrafters.plot.util.PlotSquaredException if the program fails to fetch the PlotSquared
|
||||||
|
* instance
|
||||||
|
* @see com.intellectualcrafters.plot.PlotSquared
|
||||||
|
*/
|
||||||
|
@Deprecated
|
||||||
|
public PlotAPI(final JavaPlugin plugin) {
|
||||||
|
}
|
||||||
|
|
||||||
|
public PlotAPI() {
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get all plots
|
||||||
|
*
|
||||||
|
* @return all plots
|
||||||
|
*
|
||||||
|
* @see com.intellectualcrafters.plot.PlotSquared#getPlots()
|
||||||
|
*/
|
||||||
|
public Set<Plot> getAllPlots() {
|
||||||
|
return PlotSquared.getPlots();
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Return all plots for a player
|
||||||
|
*
|
||||||
|
* @param player Player, whose plots to search for
|
||||||
|
*
|
||||||
|
* @return all plots that a player owns
|
||||||
|
*/
|
||||||
|
public Set<Plot> getPlayerPlots(final Player player) {
|
||||||
|
return PlotSquared.getPlots(BukkitUtil.getPlayer(player));
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Add a plot world
|
||||||
|
*
|
||||||
|
* @param world World Name
|
||||||
|
* @param plotWorld Plot World Object
|
||||||
|
* @param manager World Manager
|
||||||
|
*
|
||||||
|
* @see com.intellectualcrafters.plot.PlotSquared#addPlotWorld(String, com.intellectualcrafters.plot.object.PlotWorld,
|
||||||
|
* com.intellectualcrafters.plot.object.PlotManager)
|
||||||
|
*/
|
||||||
|
public void addPlotWorld(final String world, final PlotWorld plotWorld, final PlotManager manager) {
|
||||||
|
PlotSquared.addPlotWorld(world, plotWorld, manager);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @return main configuration
|
||||||
|
*
|
||||||
|
* @see com.intellectualcrafters.plot.PlotSquared#config
|
||||||
|
*/
|
||||||
|
public YamlConfiguration getConfig() {
|
||||||
|
return PlotSquared.config;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @return storage configuration
|
||||||
|
*
|
||||||
|
* @see com.intellectualcrafters.plot.PlotSquared#storage
|
||||||
|
*/
|
||||||
|
public YamlConfiguration getStorage() {
|
||||||
|
return PlotSquared.storage;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get the main class for this plugin <br> - Contains a lot of fields and methods - not very well organized <br>
|
||||||
|
* Only use this if you really need it
|
||||||
|
*
|
||||||
|
* @return PlotSquared PlotSquared Main Class
|
||||||
|
*
|
||||||
|
* @see com.intellectualcrafters.plot.PlotSquared
|
||||||
|
*/
|
||||||
|
public PlotSquared getMain() {
|
||||||
|
return PlotSquared.THIS;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* ChunkManager class contains several useful methods<br>
|
||||||
|
* - Chunk deletion<br>
|
||||||
|
* - Moving or copying regions<br>
|
||||||
|
* - plot swapping<br>
|
||||||
|
* - Entity tracking<br>
|
||||||
|
* - region regeneration<br>
|
||||||
|
*
|
||||||
|
* @return ChunkManager
|
||||||
|
*
|
||||||
|
* @see com.intellectualcrafters.plot.util.ChunkManager
|
||||||
|
*/
|
||||||
|
public ChunkManager getChunkManager() {
|
||||||
|
return ChunkManager.manager;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* BlockManager class contains useful methods relating to blocks.
|
||||||
|
*
|
||||||
|
* @return BlockManager
|
||||||
|
*
|
||||||
|
* @see com.intellectualcrafters.plot.util.BlockManager
|
||||||
|
*/
|
||||||
|
public BlockManager getBlockManager() {
|
||||||
|
return BlockManager.manager;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* BukkitSetBlockManager class contains useful methods relating to bukkit blocks.
|
||||||
|
*
|
||||||
|
* @return BukkitSetBlockManager
|
||||||
|
*
|
||||||
|
* @see com.intellectualcrafters.plot.util.bukkit.BukkitSetBlockManager
|
||||||
|
*/
|
||||||
|
public BukkitSetBlockManager getBukkitBlockManager() {
|
||||||
|
return BukkitSetBlockManager.setBlockManager;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* UUIDWrapper class has basic methods for getting UUIDS (it's recommended to use the UUIDHandler class instead)
|
||||||
|
*
|
||||||
|
* @return UUIDWrapper
|
||||||
|
*
|
||||||
|
* @see com.intellectualcrafters.plot.uuid.UUIDWrapper
|
||||||
|
*/
|
||||||
|
public UUIDWrapper getUUIDWrapper() {
|
||||||
|
return UUIDHandler.uuidWrapper;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Do not use this. Instead use FlagManager.[method] in your code.
|
||||||
|
* - Flag related stuff
|
||||||
|
*
|
||||||
|
* @return FlagManager
|
||||||
|
*
|
||||||
|
* @see com.intellectualcrafters.plot.flag.FlagManager
|
||||||
|
*/
|
||||||
|
@Deprecated
|
||||||
|
public FlagManager getFlagManager() {
|
||||||
|
return new FlagManager();
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Do not use this. Instead use ClusterManager.[method] in your code.
|
||||||
|
* - Plot cluster related stuff
|
||||||
|
*
|
||||||
|
* @return ClusterManager
|
||||||
|
*
|
||||||
|
* @see com.intellectualcrafters.plot.util.ClusterManager
|
||||||
|
*/
|
||||||
|
@Deprecated
|
||||||
|
public ClusterManager getClusterManager() {
|
||||||
|
return new ClusterManager();
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Do not use this. Instead use MainUtil.[method] in your code.
|
||||||
|
* - Basic plot management stuff
|
||||||
|
*
|
||||||
|
* @return MainUtil
|
||||||
|
*
|
||||||
|
* @see com.intellectualcrafters.plot.util.MainUtil
|
||||||
|
*/
|
||||||
|
@Deprecated
|
||||||
|
public MainUtil getMainUtil() {
|
||||||
|
return new MainUtil();
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Do not use this. Instead use Permissions.[method] in your code.
|
||||||
|
* - Basic permission management stuff
|
||||||
|
*
|
||||||
|
* @return MainUtil
|
||||||
|
*
|
||||||
|
* @see com.intellectualcrafters.plot.util.Permissions
|
||||||
|
*/
|
||||||
|
@Deprecated
|
||||||
|
public Permissions getPermissions() {
|
||||||
|
return new Permissions();
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* SchematicHandler class contains methods related to pasting, reading and writing schematics
|
||||||
|
*
|
||||||
|
* @return SchematicHandler
|
||||||
|
*
|
||||||
|
* @see com.intellectualcrafters.plot.util.SchematicHandler
|
||||||
|
*/
|
||||||
|
public SchematicHandler getSchematicHandler() {
|
||||||
|
return SchematicHandler.manager;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Use C.[caption] instead
|
||||||
|
*
|
||||||
|
* @return C
|
||||||
|
*
|
||||||
|
* @see com.intellectualcrafters.plot.config.C
|
||||||
|
*/
|
||||||
|
@Deprecated
|
||||||
|
public C[] getCaptions() {
|
||||||
|
return C.values();
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get the plot manager for a world. - Most of these methods can be accessed through the MainUtil
|
||||||
|
*
|
||||||
|
* @param world Which manager to get
|
||||||
|
*
|
||||||
|
* @return PlotManager
|
||||||
|
*
|
||||||
|
* @see com.intellectualcrafters.plot.object.PlotManager
|
||||||
|
* @see PlotSquared#getPlotManager(String)
|
||||||
|
*/
|
||||||
|
public PlotManager getPlotManager(final World world) {
|
||||||
|
return PlotSquared.getPlotManager(world.getName());
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get the plot manager for a world. - Contains useful low level methods for plot merging, clearing, and
|
||||||
|
* tessellation
|
||||||
|
*
|
||||||
|
* @param world
|
||||||
|
*
|
||||||
|
* @return PlotManager
|
||||||
|
*
|
||||||
|
* @see PlotSquared#getPlotManager(String)
|
||||||
|
* @see com.intellectualcrafters.plot.object.PlotManager
|
||||||
|
*/
|
||||||
|
public PlotManager getPlotManager(final String world) {
|
||||||
|
return PlotSquared.getPlotManager(world);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get the settings for a world (settings bundled in PlotWorld class) - You will need to downcast for the specific
|
||||||
|
* settings a Generator has. e.g. DefaultPlotWorld class implements PlotWorld
|
||||||
|
*
|
||||||
|
* @param world (to get settings of)
|
||||||
|
*
|
||||||
|
* @return PlotWorld class for that world ! will return null if not a plot world world
|
||||||
|
*
|
||||||
|
* @see PlotSquared#getPlotWorld(String)
|
||||||
|
* @see com.intellectualcrafters.plot.object.PlotWorld
|
||||||
|
*/
|
||||||
|
public PlotWorld getWorldSettings(final World world) {
|
||||||
|
return PlotSquared.getPlotWorld(world.getName());
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get the settings for a world (settings bundled in PlotWorld class)
|
||||||
|
*
|
||||||
|
* @param world (to get settings of)
|
||||||
|
*
|
||||||
|
* @return PlotWorld class for that world ! will return null if not a plot world world
|
||||||
|
*
|
||||||
|
* @see PlotSquared#getPlotWorld(String)
|
||||||
|
* @see com.intellectualcrafters.plot.object.PlotWorld
|
||||||
|
*/
|
||||||
|
public PlotWorld getWorldSettings(final String world) {
|
||||||
|
return PlotSquared.getPlotWorld(world);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Send a message to a player.
|
||||||
|
*
|
||||||
|
* @param player Player that will receive the message
|
||||||
|
* @param c (Caption)
|
||||||
|
*
|
||||||
|
* @see com.intellectualcrafters.plot.util.MainUtil#sendMessage(PlotPlayer, C, String...)
|
||||||
|
* com.intellectualcrafters.plot.config.C, String...)
|
||||||
|
*/
|
||||||
|
public void sendMessage(final Player player, final C c) {
|
||||||
|
MainUtil.sendMessage(BukkitUtil.getPlayer(player), c);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Send a message to a player. - Supports color codes
|
||||||
|
*
|
||||||
|
* @param player Player that will receive the message
|
||||||
|
* @param string The message
|
||||||
|
*
|
||||||
|
* @see com.intellectualcrafters.plot.util.MainUtil#sendMessage(PlotPlayer, String)
|
||||||
|
*/
|
||||||
|
public void sendMessage(final Player player, final String string) {
|
||||||
|
MainUtil.sendMessage(BukkitUtil.getPlayer(player), string);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Send a message to the console. - Supports color codes
|
||||||
|
*
|
||||||
|
* @param msg Message that should be sent to the console
|
||||||
|
*
|
||||||
|
* @see MainUtil#sendConsoleMessage(String)
|
||||||
|
*/
|
||||||
|
public void sendConsoleMessage(final String msg) {
|
||||||
|
MainUtil.sendConsoleMessage(msg);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Send a message to the console
|
||||||
|
*
|
||||||
|
* @param c (Caption)
|
||||||
|
*
|
||||||
|
* @see #sendConsoleMessage(String)
|
||||||
|
* @see com.intellectualcrafters.plot.config.C
|
||||||
|
*/
|
||||||
|
public void sendConsoleMessage(final C c) {
|
||||||
|
sendConsoleMessage(c.s());
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Register a flag for use in plots
|
||||||
|
*
|
||||||
|
* @param flag Flag that should be registered
|
||||||
|
*
|
||||||
|
* @see com.intellectualcrafters.plot.flag.FlagManager#addFlag(com.intellectualcrafters.plot.flag.AbstractFlag)
|
||||||
|
* @see com.intellectualcrafters.plot.flag.AbstractFlag
|
||||||
|
*/
|
||||||
|
public void addFlag(final AbstractFlag flag) {
|
||||||
|
FlagManager.addFlag(flag);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* get all the currently registered flags
|
||||||
|
*
|
||||||
|
* @return array of Flag[]
|
||||||
|
*
|
||||||
|
* @see com.intellectualcrafters.plot.flag.FlagManager#getFlags()
|
||||||
|
* @see com.intellectualcrafters.plot.flag.AbstractFlag
|
||||||
|
*/
|
||||||
|
public AbstractFlag[] getFlags() {
|
||||||
|
return FlagManager.getFlags().toArray(new AbstractFlag[FlagManager.getFlags().size()]);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get a plot based on the ID
|
||||||
|
*
|
||||||
|
* @param world World in which the plot is located
|
||||||
|
* @param x Plot Location X Co-ord
|
||||||
|
* @param z Plot Location Z Co-ord
|
||||||
|
*
|
||||||
|
* @return plot, null if ID is wrong
|
||||||
|
*
|
||||||
|
* @see MainUtil#getPlot(String, com.intellectualcrafters.plot.object.PlotId)
|
||||||
|
* @see com.intellectualcrafters.plot.object.Plot
|
||||||
|
*/
|
||||||
|
public Plot getPlot(final World world, final int x, final int z) {
|
||||||
|
return MainUtil.getPlot(world.getName(), new PlotId(x, z));
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get a plot based on the location
|
||||||
|
*
|
||||||
|
* @param l The location that you want to to retrieve the plot from
|
||||||
|
*
|
||||||
|
* @return plot if found, otherwise it creates a temporary plot-
|
||||||
|
*
|
||||||
|
* @see MainUtil#getPlot(com.intellectualcrafters.plot.object.Location)
|
||||||
|
* @see com.intellectualcrafters.plot.object.Plot
|
||||||
|
*/
|
||||||
|
public Plot getPlot(final Location l) {
|
||||||
|
return MainUtil.getPlot(BukkitUtil.getLocation(l));
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get a plot based on the player location
|
||||||
|
*
|
||||||
|
* @param player Get the current plot for the player location
|
||||||
|
*
|
||||||
|
* @return plot if found, otherwise it creates a temporary plot
|
||||||
|
*
|
||||||
|
* @see #getPlot(org.bukkit.Location)
|
||||||
|
* @see com.intellectualcrafters.plot.object.Plot
|
||||||
|
*/
|
||||||
|
public Plot getPlot(final Player player) {
|
||||||
|
return this.getPlot(player.getLocation());
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Check whether or not a player has a plot
|
||||||
|
*
|
||||||
|
* @param player Player that you want to check for
|
||||||
|
*
|
||||||
|
* @return true if player has a plot, false if not.
|
||||||
|
*
|
||||||
|
* @see #getPlots(World, Player, boolean)
|
||||||
|
*/
|
||||||
|
public boolean hasPlot(final World world, final Player player) {
|
||||||
|
return (getPlots(world, player, true) != null) && (getPlots(world, player, true).length > 0);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get all plots for the player
|
||||||
|
*
|
||||||
|
* @param plr to search for
|
||||||
|
* @param just_owner should we just search for owner? Or with rights?
|
||||||
|
*
|
||||||
|
* @see com.intellectualcrafters.plot.object.Plot
|
||||||
|
*/
|
||||||
|
public Plot[] getPlots(final World world, final Player plr, final boolean just_owner) {
|
||||||
|
final ArrayList<Plot> pPlots = new ArrayList<>();
|
||||||
|
for (final Plot plot : PlotSquared.getPlots(world.getName()).values()) {
|
||||||
|
if (just_owner) {
|
||||||
|
if ((plot.owner != null) && (plot.owner == UUIDHandler.getUUID(BukkitUtil.getPlayer(plr)))) {
|
||||||
|
pPlots.add(plot);
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
if (plot.isAdded(UUIDHandler.getUUID(BukkitUtil.getPlayer(plr)))) {
|
||||||
|
pPlots.add(plot);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return pPlots.toArray(new Plot[pPlots.size()]);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get all plots for the world
|
||||||
|
*
|
||||||
|
* @param world to get plots of
|
||||||
|
*
|
||||||
|
* @return Plot[] - array of plot objects in world
|
||||||
|
*
|
||||||
|
* @see PlotSquared#getPlots(String)
|
||||||
|
* @see com.intellectualcrafters.plot.object.Plot
|
||||||
|
*/
|
||||||
|
public Plot[] getPlots(final World world) {
|
||||||
|
Collection<Plot> plots = PlotSquared.getPlots(world.getName()).values();
|
||||||
|
return plots.toArray(new Plot[plots.size()]);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get all plot worlds
|
||||||
|
*
|
||||||
|
* @return World[] - array of plot worlds
|
||||||
|
*
|
||||||
|
* @see com.intellectualcrafters.plot.PlotSquared#getPlotWorlds()
|
||||||
|
*/
|
||||||
|
public String[] getPlotWorlds() {
|
||||||
|
Set<String> worlds = PlotSquared.getPlotWorlds();
|
||||||
|
return worlds.toArray(new String[worlds.size()]);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get if plot world
|
||||||
|
*
|
||||||
|
* @param world (to check if plot world)
|
||||||
|
*
|
||||||
|
* @return boolean (if plot world or not)
|
||||||
|
*
|
||||||
|
* @see com.intellectualcrafters.plot.PlotSquared#isPlotWorld(String)
|
||||||
|
*/
|
||||||
|
public boolean isPlotWorld(final World world) {
|
||||||
|
return PlotSquared.isPlotWorld(world.getName());
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get plot locations
|
||||||
|
*
|
||||||
|
* @param p Plot that you want to get the locations for
|
||||||
|
*
|
||||||
|
* @return [0] = bottomLc, [1] = topLoc, [2] = home
|
||||||
|
*
|
||||||
|
* @see com.intellectualcrafters.plot.util.MainUtil#getPlotBottomLoc(String,
|
||||||
|
* com.intellectualcrafters.plot.object.PlotId)
|
||||||
|
* @see com.intellectualcrafters.plot.util.MainUtil#getPlotTopLoc(String,
|
||||||
|
* com.intellectualcrafters.plot.object.PlotId)
|
||||||
|
* @see com.intellectualcrafters.plot.util.MainUtil#getPlotHome(String,
|
||||||
|
* com.intellectualcrafters.plot.object.Plot)
|
||||||
|
* @see com.intellectualcrafters.plot.object.Plot
|
||||||
|
*/
|
||||||
|
public Location[] getLocations(final Plot p) {
|
||||||
|
return new Location[]{BukkitUtil.getLocation(MainUtil.getPlotBottomLoc(p.world, p.id)), BukkitUtil.getLocation(MainUtil.getPlotTopLoc(p.world, p.id)), BukkitUtil.getLocation(MainUtil.getPlotHome(p.world, p.id))};
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get home location
|
||||||
|
*
|
||||||
|
* @param p Plot that you want to get the location for
|
||||||
|
*
|
||||||
|
* @return plot bottom location
|
||||||
|
*
|
||||||
|
* @see com.intellectualcrafters.plot.util.MainUtil#getPlotHome(String,
|
||||||
|
* com.intellectualcrafters.plot.object.Plot)
|
||||||
|
* @see com.intellectualcrafters.plot.object.Plot
|
||||||
|
*/
|
||||||
|
public Location getHomeLocation(final Plot p) {
|
||||||
|
return BukkitUtil.getLocation(MainUtil.getPlotHome(p.world, p.id));
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get Bottom Location (min, min, min)
|
||||||
|
*
|
||||||
|
* @param p Plot that you want to get the location for
|
||||||
|
*
|
||||||
|
* @return plot bottom location
|
||||||
|
*
|
||||||
|
* @see com.intellectualcrafters.plot.util.MainUtil#getPlotBottomLoc(String,
|
||||||
|
* com.intellectualcrafters.plot.object.PlotId)
|
||||||
|
* @see com.intellectualcrafters.plot.object.Plot
|
||||||
|
*/
|
||||||
|
public Location getBottomLocation(final Plot p) {
|
||||||
|
return BukkitUtil.getLocation(MainUtil.getPlotBottomLoc(p.world, p.id));
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get Top Location (max, max, max)
|
||||||
|
*
|
||||||
|
* @param p Plot that you want to get the location for
|
||||||
|
*
|
||||||
|
* @return plot top location
|
||||||
|
*
|
||||||
|
* @see MainUtil#getPlotTopLoc(String, com.intellectualcrafters.plot.object.PlotId)
|
||||||
|
* @see com.intellectualcrafters.plot.object.Plot
|
||||||
|
*/
|
||||||
|
public Location getTopLocation(final Plot p) {
|
||||||
|
return BukkitUtil.getLocation(MainUtil.getPlotTopLoc(p.world, p.id));
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Check whether or not a player is in a plot
|
||||||
|
*
|
||||||
|
* @param player who we're checking for
|
||||||
|
*
|
||||||
|
* @return true if the player is in a plot, false if not-
|
||||||
|
*
|
||||||
|
* @see com.intellectualcrafters.plot.util.MainUtil#getPlot(com.intellectualcrafters.plot.object.Location)
|
||||||
|
*/
|
||||||
|
public boolean isInPlot(final Player player) {
|
||||||
|
return MainUtil.getPlot(BukkitUtil.getLocation(player)) != null;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Register a subcommand
|
||||||
|
*
|
||||||
|
* @param c SubCommand, that we want to register
|
||||||
|
*
|
||||||
|
* @see com.intellectualcrafters.plot.commands.MainCommand#subCommands
|
||||||
|
* @see com.intellectualcrafters.plot.commands.SubCommand
|
||||||
|
*/
|
||||||
|
public void registerCommand(final SubCommand c) {
|
||||||
|
MainCommand.subCommands.add(c);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get the PlotSquared class
|
||||||
|
*
|
||||||
|
* @return PlotSquared Class
|
||||||
|
*
|
||||||
|
* @see com.intellectualcrafters.plot.PlotSquared
|
||||||
|
*/
|
||||||
|
public PlotSquared getPlotSquared() {
|
||||||
|
return PlotSquared.THIS;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get the player plot count
|
||||||
|
*
|
||||||
|
* @param world Specify the world we want to select the plots from
|
||||||
|
* @param player Player, for whom we're getting the plot count
|
||||||
|
*
|
||||||
|
* @return the number of plots the player has
|
||||||
|
*
|
||||||
|
* @see com.intellectualcrafters.plot.util.MainUtil#getPlayerPlotCount(String, PlotPlayer)
|
||||||
|
*/
|
||||||
|
public int getPlayerPlotCount(final World world, final Player player) {
|
||||||
|
return MainUtil.getPlayerPlotCount(world.getName(), BukkitUtil.getPlayer(player));
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get a collection containing the players plots
|
||||||
|
*
|
||||||
|
* @param world Specify the world we want to select the plots from
|
||||||
|
* @param player Player, for whom we're getting the plots
|
||||||
|
*
|
||||||
|
* @return a set containing the players plots
|
||||||
|
*
|
||||||
|
* @see com.intellectualcrafters.plot.PlotSquared#getPlots(String, PlotPlayer)
|
||||||
|
* org.bukkit.entity.Player)
|
||||||
|
* @see com.intellectualcrafters.plot.object.Plot
|
||||||
|
*/
|
||||||
|
public Set<Plot> getPlayerPlots(final World world, final Player player) {
|
||||||
|
return PlotSquared.getPlots(world.getName(), BukkitUtil.getPlayer(player));
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get the numbers of plots, which the player is able to build in
|
||||||
|
*
|
||||||
|
* @param player Player, for whom we're getting the plots (trusted, helper and owner)
|
||||||
|
*
|
||||||
|
* @return the number of allowed plots
|
||||||
|
*
|
||||||
|
* @see com.intellectualcrafters.plot.util.MainUtil#getAllowedPlots(PlotPlayer, int)
|
||||||
|
*/
|
||||||
|
public int getAllowedPlots(final Player player) {
|
||||||
|
PlotPlayer pp = BukkitUtil.getPlayer(player);
|
||||||
|
return MainUtil.getAllowedPlots(pp);
|
||||||
|
}
|
||||||
|
}
|
@ -119,8 +119,8 @@ public class Auto extends SubCommand {
|
|||||||
MainUtil.sendMessage(plr, C.CANT_CLAIM_MORE_PLOTS_NUM, Settings.MAX_AUTO_SIZE + "");
|
MainUtil.sendMessage(plr, C.CANT_CLAIM_MORE_PLOTS_NUM, Settings.MAX_AUTO_SIZE + "");
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
final int currentPlots = MainUtil.getPlayerPlotCount(world, plr);
|
final int currentPlots = Settings.GLOBAL_LIMIT ? MainUtil.getPlayerPlotCount(plr) : MainUtil.getPlayerPlotCount(world, plr);
|
||||||
final int diff = currentPlots - MainUtil.getAllowedPlots(plr, currentPlots);
|
final int diff = currentPlots - MainUtil.getAllowedPlots(plr);
|
||||||
if ((diff + (size_x * size_z)) > 0) {
|
if ((diff + (size_x * size_z)) > 0) {
|
||||||
if (diff < 0) {
|
if (diff < 0) {
|
||||||
MainUtil.sendMessage(plr, C.CANT_CLAIM_MORE_PLOTS_NUM, (-diff) + "");
|
MainUtil.sendMessage(plr, C.CANT_CLAIM_MORE_PLOTS_NUM, (-diff) + "");
|
||||||
@ -179,7 +179,7 @@ public class Auto extends SubCommand {
|
|||||||
for (int i = 0; i <= max; i++) {
|
for (int i = 0; i <= max; i++) {
|
||||||
final PlotId currentId = new PlotId(origin.x + id.x, origin.y + id.y);
|
final PlotId currentId = new PlotId(origin.x + id.x, origin.y + id.y);
|
||||||
final Plot current = MainUtil.getPlot(worldname, currentId);
|
final Plot current = MainUtil.getPlot(worldname, currentId);
|
||||||
if ((current != null) && (current.hasOwner() == false) && (current.settings.isMerged() == false) && cluster.equals(ClusterManager.getCluster(current))) {
|
if (MainUtil.canClaim(plr, current) && (current.settings.isMerged() == false) && cluster.equals(ClusterManager.getCluster(current))) {
|
||||||
Claim.claimPlot(plr, current, true, true);
|
Claim.claimPlot(plr, current, true, true);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
@ -193,7 +193,7 @@ public class Auto extends SubCommand {
|
|||||||
if ((size_x == 1) && (size_z == 1)) {
|
if ((size_x == 1) && (size_z == 1)) {
|
||||||
while (!br) {
|
while (!br) {
|
||||||
final Plot plot = MainUtil.getPlot(worldname, getLastPlot(worldname));
|
final Plot plot = MainUtil.getPlot(worldname, getLastPlot(worldname));
|
||||||
if ((plot.owner == null)) {
|
if (MainUtil.canClaim(plr, plot)) {
|
||||||
Claim.claimPlot(plr, plot, true, true);
|
Claim.claimPlot(plr, plot, true, true);
|
||||||
br = true;
|
br = true;
|
||||||
}
|
}
|
||||||
@ -213,7 +213,7 @@ public class Auto extends SubCommand {
|
|||||||
lastPlot = false;
|
lastPlot = false;
|
||||||
}
|
}
|
||||||
final PlotId end = new PlotId((start.x + size_x) - 1, (start.y + size_z) - 1);
|
final PlotId end = new PlotId((start.x + size_x) - 1, (start.y + size_z) - 1);
|
||||||
if (MainUtil.isUnowned(worldname, start, end)) {
|
if (MainUtil.canClaim(plr, worldname, start, end)) {
|
||||||
for (int i = start.x; i <= end.x; i++) {
|
for (int i = start.x; i <= end.x; i++) {
|
||||||
for (int j = start.y; j <= end.y; j++) {
|
for (int j = start.y; j <= end.y; j++) {
|
||||||
final Plot plot = MainUtil.getPlot(worldname, new PlotId(i, j));
|
final Plot plot = MainUtil.getPlot(worldname, new PlotId(i, j));
|
||||||
|
@ -11,6 +11,7 @@ import org.bukkit.command.TabCompleter;
|
|||||||
import org.bukkit.entity.Player;
|
import org.bukkit.entity.Player;
|
||||||
|
|
||||||
import com.intellectualcrafters.plot.object.PlotPlayer;
|
import com.intellectualcrafters.plot.object.PlotPlayer;
|
||||||
|
import com.intellectualcrafters.plot.util.StringComparison;
|
||||||
import com.intellectualcrafters.plot.util.bukkit.BukkitUtil;
|
import com.intellectualcrafters.plot.util.bukkit.BukkitUtil;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -46,13 +47,21 @@ public class BukkitCommand implements CommandExecutor, TabCompleter {
|
|||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
final List<String> tabOptions = new ArrayList<>();
|
final List<String> tabOptions = new ArrayList<>();
|
||||||
|
final String[] commands = new String[MainCommand.subCommands.size()];
|
||||||
|
for (int x = 0; x < MainCommand.subCommands.size(); x++) {
|
||||||
|
commands[x] = MainCommand.subCommands.get(x).cmd;
|
||||||
|
}
|
||||||
|
String best = new StringComparison(strings[0], commands).getBestMatch();
|
||||||
|
tabOptions.add(best);
|
||||||
final String arg = strings[0].toLowerCase();
|
final String arg = strings[0].toLowerCase();
|
||||||
for (final SubCommand cmd : MainCommand.subCommands) {
|
for (final SubCommand cmd : MainCommand.subCommands) {
|
||||||
if (cmd.permission.hasPermission(player)) {
|
if (!cmd.cmd.equalsIgnoreCase(best)) {
|
||||||
if (cmd.cmd.startsWith(arg)) {
|
if (cmd.permission.hasPermission(player)) {
|
||||||
tabOptions.add(cmd.cmd);
|
if (cmd.cmd.startsWith(arg)) {
|
||||||
} else if (cmd.alias.get(0).startsWith(arg)) {
|
tabOptions.add(cmd.cmd);
|
||||||
tabOptions.add(cmd.alias.get(0));
|
} else if (cmd.alias.size() > 0 && cmd.alias.get(0).startsWith(arg)) {
|
||||||
|
tabOptions.add(cmd.alias.get(0));
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -22,11 +22,13 @@ package com.intellectualcrafters.plot.commands;
|
|||||||
|
|
||||||
import com.intellectualcrafters.plot.PlotSquared;
|
import com.intellectualcrafters.plot.PlotSquared;
|
||||||
import com.intellectualcrafters.plot.config.C;
|
import com.intellectualcrafters.plot.config.C;
|
||||||
|
import com.intellectualcrafters.plot.config.Settings;
|
||||||
import com.intellectualcrafters.plot.database.DBFunc;
|
import com.intellectualcrafters.plot.database.DBFunc;
|
||||||
import com.intellectualcrafters.plot.flag.Flag;
|
import com.intellectualcrafters.plot.flag.Flag;
|
||||||
import com.intellectualcrafters.plot.flag.FlagManager;
|
import com.intellectualcrafters.plot.flag.FlagManager;
|
||||||
import com.intellectualcrafters.plot.object.Location;
|
import com.intellectualcrafters.plot.object.Location;
|
||||||
import com.intellectualcrafters.plot.object.Plot;
|
import com.intellectualcrafters.plot.object.Plot;
|
||||||
|
import com.intellectualcrafters.plot.object.PlotHandler;
|
||||||
import com.intellectualcrafters.plot.object.PlotId;
|
import com.intellectualcrafters.plot.object.PlotId;
|
||||||
import com.intellectualcrafters.plot.object.PlotPlayer;
|
import com.intellectualcrafters.plot.object.PlotPlayer;
|
||||||
import com.intellectualcrafters.plot.object.PlotWorld;
|
import com.intellectualcrafters.plot.object.PlotWorld;
|
||||||
@ -67,14 +69,14 @@ public class Buy extends SubCommand {
|
|||||||
if (plot == null) {
|
if (plot == null) {
|
||||||
return sendMessage(plr, C.NOT_IN_PLOT);
|
return sendMessage(plr, C.NOT_IN_PLOT);
|
||||||
}
|
}
|
||||||
final int currentPlots = MainUtil.getPlayerPlotCount(world, plr);
|
final int currentPlots = Settings.GLOBAL_LIMIT ? MainUtil.getPlayerPlotCount(plr) : MainUtil.getPlayerPlotCount(world, plr);
|
||||||
if (currentPlots >= MainUtil.getAllowedPlots(plr, currentPlots)) {
|
if (currentPlots >= MainUtil.getAllowedPlots(plr)) {
|
||||||
return sendMessage(plr, C.CANT_CLAIM_MORE_PLOTS);
|
return sendMessage(plr, C.CANT_CLAIM_MORE_PLOTS);
|
||||||
}
|
}
|
||||||
if (!plot.hasOwner()) {
|
if (!plot.hasOwner()) {
|
||||||
return sendMessage(plr, C.PLOT_UNOWNED);
|
return sendMessage(plr, C.PLOT_UNOWNED);
|
||||||
}
|
}
|
||||||
if (plot.owner.equals(plr.getUUID())) {
|
if (PlotHandler.isOwner(plot, plr.getUUID())) {
|
||||||
return sendMessage(plr, C.CANNOT_BUY_OWN);
|
return sendMessage(plr, C.CANNOT_BUY_OWN);
|
||||||
}
|
}
|
||||||
final Flag flag = FlagManager.getPlotFlag(plot, "price");
|
final Flag flag = FlagManager.getPlotFlag(plot, "price");
|
||||||
@ -104,8 +106,13 @@ public class Buy extends SubCommand {
|
|||||||
}
|
}
|
||||||
FlagManager.removePlotFlag(plot, "price");
|
FlagManager.removePlotFlag(plot, "price");
|
||||||
}
|
}
|
||||||
plot.owner = plr.getUUID();
|
Plot top = MainUtil.getTopPlot(plot);
|
||||||
DBFunc.setOwner(plot, plot.owner);
|
|
||||||
|
for (PlotId myId : MainUtil.getPlotSelectionIds(plot.id, top.id)) {
|
||||||
|
Plot myPlot = MainUtil.getPlot(plot.world, myId);
|
||||||
|
myPlot.owner = plr.getUUID();
|
||||||
|
DBFunc.setOwner(plot, myPlot.owner);
|
||||||
|
}
|
||||||
MainUtil.sendMessage(plr, C.CLAIMED);
|
MainUtil.sendMessage(plr, C.CLAIMED);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
@ -22,6 +22,7 @@ package com.intellectualcrafters.plot.commands;
|
|||||||
|
|
||||||
import com.intellectualcrafters.plot.PlotSquared;
|
import com.intellectualcrafters.plot.PlotSquared;
|
||||||
import com.intellectualcrafters.plot.config.C;
|
import com.intellectualcrafters.plot.config.C;
|
||||||
|
import com.intellectualcrafters.plot.config.Settings;
|
||||||
import com.intellectualcrafters.plot.object.Location;
|
import com.intellectualcrafters.plot.object.Location;
|
||||||
import com.intellectualcrafters.plot.object.Plot;
|
import com.intellectualcrafters.plot.object.Plot;
|
||||||
import com.intellectualcrafters.plot.object.PlotPlayer;
|
import com.intellectualcrafters.plot.object.PlotPlayer;
|
||||||
@ -74,7 +75,6 @@ public class Claim extends SubCommand {
|
|||||||
SchematicHandler.manager.paste(sch, plot2, 0, 0);
|
SchematicHandler.manager.paste(sch, plot2, 0, 0);
|
||||||
}
|
}
|
||||||
PlotSquared.getPlotManager(world).claimPlot(plotworld, plot);
|
PlotSquared.getPlotManager(world).claimPlot(plotworld, plot);
|
||||||
MainUtil.update(loc);
|
|
||||||
}
|
}
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
@ -90,11 +90,11 @@ public class Claim extends SubCommand {
|
|||||||
if (plot == null) {
|
if (plot == null) {
|
||||||
return sendMessage(plr, C.NOT_IN_PLOT);
|
return sendMessage(plr, C.NOT_IN_PLOT);
|
||||||
}
|
}
|
||||||
final int currentPlots = MainUtil.getPlayerPlotCount(loc.getWorld(), plr);
|
final int currentPlots = Settings.GLOBAL_LIMIT ? MainUtil.getPlayerPlotCount(plr) : MainUtil.getPlayerPlotCount(loc.getWorld(), plr);
|
||||||
if (currentPlots >= MainUtil.getAllowedPlots(plr, currentPlots)) {
|
if (currentPlots >= MainUtil.getAllowedPlots(plr)) {
|
||||||
return sendMessage(plr, C.CANT_CLAIM_MORE_PLOTS);
|
return sendMessage(plr, C.CANT_CLAIM_MORE_PLOTS);
|
||||||
}
|
}
|
||||||
if (plot.hasOwner()) {
|
if (!MainUtil.canClaim(plr, plot)) {
|
||||||
return sendMessage(plr, C.PLOT_IS_CLAIMED);
|
return sendMessage(plr, C.PLOT_IS_CLAIMED);
|
||||||
}
|
}
|
||||||
final PlotWorld world = PlotSquared.getPlotWorld(plot.world);
|
final PlotWorld world = PlotSquared.getPlotWorld(plot.world);
|
||||||
|
@ -62,7 +62,7 @@ public class Clear extends SubCommand {
|
|||||||
Runnable runnable = new Runnable() {
|
Runnable runnable = new Runnable() {
|
||||||
@Override
|
@Override
|
||||||
public void run() {
|
public void run() {
|
||||||
MainUtil.clear(world, plot, true, null);
|
MainUtil.clear(world, plot, plot.owner == null, null);
|
||||||
PlotSquared.log("Plot " + plot.getId().toString() + " cleared.");
|
PlotSquared.log("Plot " + plot.getId().toString() + " cleared.");
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
@ -110,7 +110,7 @@ public class Clear extends SubCommand {
|
|||||||
if (!MainUtil.getTopPlot(plot).equals(MainUtil.getBottomPlot(plot))) {
|
if (!MainUtil.getTopPlot(plot).equals(MainUtil.getBottomPlot(plot))) {
|
||||||
return sendMessage(plr, C.UNLINK_REQUIRED);
|
return sendMessage(plr, C.UNLINK_REQUIRED);
|
||||||
}
|
}
|
||||||
if (((plot == null) || !plot.hasOwner() || !plot.getOwner().equals(UUIDHandler.getUUID(plr))) && !Permissions.hasPermission(plr, "plots.admin.command.clear")) {
|
if (((plot == null) || !plot.hasOwner() || !plot.isOwner(UUIDHandler.getUUID(plr))) && !Permissions.hasPermission(plr, "plots.admin.command.clear")) {
|
||||||
return sendMessage(plr, C.NO_PLOT_PERMS);
|
return sendMessage(plr, C.NO_PLOT_PERMS);
|
||||||
}
|
}
|
||||||
assert plot != null;
|
assert plot != null;
|
||||||
@ -122,7 +122,7 @@ public class Clear extends SubCommand {
|
|||||||
@Override
|
@Override
|
||||||
public void run() {
|
public void run() {
|
||||||
final long start = System.currentTimeMillis();
|
final long start = System.currentTimeMillis();
|
||||||
final boolean result = MainUtil.clearAsPlayer(plot, false, new Runnable() {
|
final boolean result = MainUtil.clearAsPlayer(plot, plot.owner == null, new Runnable() {
|
||||||
@Override
|
@Override
|
||||||
public void run() {
|
public void run() {
|
||||||
MainUtil.sendMessage(plr, C.CLEARING_DONE, "" + (System.currentTimeMillis() - start));
|
MainUtil.sendMessage(plr, C.CLEARING_DONE, "" + (System.currentTimeMillis() - start));
|
||||||
|
@ -129,7 +129,7 @@ public class Cluster extends SubCommand {
|
|||||||
// Add any existing plots to the current cluster
|
// Add any existing plots to the current cluster
|
||||||
for (final Plot plot : PlotSquared.getPlots(plr.getLocation().getWorld()).values()) {
|
for (final Plot plot : PlotSquared.getPlots(plr.getLocation().getWorld()).values()) {
|
||||||
final PlotCluster current = ClusterManager.getCluster(plot);
|
final PlotCluster current = ClusterManager.getCluster(plot);
|
||||||
if (cluster.equals(current) && !cluster.hasRights(plot.owner)) {
|
if (cluster.equals(current) && !cluster.isAdded(plot.owner)) {
|
||||||
cluster.invited.add(plot.owner);
|
cluster.invited.add(plot.owner);
|
||||||
DBFunc.setInvited(world, cluster, plot.owner);
|
DBFunc.setInvited(world, cluster, plot.owner);
|
||||||
}
|
}
|
||||||
@ -299,10 +299,10 @@ public class Cluster extends SubCommand {
|
|||||||
// check uuid
|
// check uuid
|
||||||
final UUID uuid = UUIDHandler.getUUID(args[1]);
|
final UUID uuid = UUIDHandler.getUUID(args[1]);
|
||||||
if (uuid == null) {
|
if (uuid == null) {
|
||||||
MainUtil.sendMessage(plr, C.INVALID_PLAYER, args[1]);
|
MainUtil.sendMessage(plr, C.INVALID_PLAYER, args[2]);
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
if (!cluster.hasRights(uuid)) {
|
if (!cluster.isAdded(uuid)) {
|
||||||
// add the user if not added
|
// add the user if not added
|
||||||
cluster.invited.add(uuid);
|
cluster.invited.add(uuid);
|
||||||
final String world = plr.getLocation().getWorld();
|
final String world = plr.getLocation().getWorld();
|
||||||
@ -344,7 +344,7 @@ public class Cluster extends SubCommand {
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
// Can't kick if the player is yourself, the owner, or not added to the cluster
|
// Can't kick if the player is yourself, the owner, or not added to the cluster
|
||||||
if (uuid.equals(UUIDHandler.getUUID(plr)) || uuid.equals(cluster.owner) || !cluster.hasRights(uuid)) {
|
if (uuid.equals(UUIDHandler.getUUID(plr)) || uuid.equals(cluster.owner) || !cluster.isAdded(uuid)) {
|
||||||
MainUtil.sendMessage(plr, C.CANNOT_KICK_PLAYER, cluster.getName());
|
MainUtil.sendMessage(plr, C.CANNOT_KICK_PLAYER, cluster.getName());
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
@ -393,7 +393,7 @@ public class Cluster extends SubCommand {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
final UUID uuid = UUIDHandler.getUUID(plr);
|
final UUID uuid = UUIDHandler.getUUID(plr);
|
||||||
if (!cluster.hasRights(uuid)) {
|
if (!cluster.isAdded(uuid)) {
|
||||||
MainUtil.sendMessage(plr, C.CLUSTER_NOT_ADDED);
|
MainUtil.sendMessage(plr, C.CLUSTER_NOT_ADDED);
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
@ -435,7 +435,7 @@ public class Cluster extends SubCommand {
|
|||||||
}
|
}
|
||||||
final UUID uuid = UUIDHandler.getUUID(args[2]);
|
final UUID uuid = UUIDHandler.getUUID(args[2]);
|
||||||
if (uuid == null) {
|
if (uuid == null) {
|
||||||
MainUtil.sendMessage(plr, C.INVALID_PLAYER, args[1]);
|
MainUtil.sendMessage(plr, C.INVALID_PLAYER, args[2]);
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
if (args[1].toLowerCase().equals("add")) {
|
if (args[1].toLowerCase().equals("add")) {
|
||||||
@ -466,7 +466,7 @@ public class Cluster extends SubCommand {
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
final UUID uuid = UUIDHandler.getUUID(plr);
|
final UUID uuid = UUIDHandler.getUUID(plr);
|
||||||
if (!cluster.hasRights(uuid)) {
|
if (!cluster.isAdded(uuid)) {
|
||||||
if (!Permissions.hasPermission(plr, "plots.cluster.tp.other")) {
|
if (!Permissions.hasPermission(plr, "plots.cluster.tp.other")) {
|
||||||
MainUtil.sendMessage(plr, C.NO_PERMISSION, "plots.cluster.tp.other");
|
MainUtil.sendMessage(plr, C.NO_PERMISSION, "plots.cluster.tp.other");
|
||||||
return false;
|
return false;
|
||||||
@ -508,7 +508,7 @@ public class Cluster extends SubCommand {
|
|||||||
}
|
}
|
||||||
final String name = cluster.getName();
|
final String name = cluster.getName();
|
||||||
final String size = ((cluster.getP2().x - cluster.getP1().x) + 1) + "x" + ((cluster.getP2().y - cluster.getP1().y) + 1);
|
final String size = ((cluster.getP2().x - cluster.getP1().x) + 1) + "x" + ((cluster.getP2().y - cluster.getP1().y) + 1);
|
||||||
final String rights = cluster.hasRights(UUIDHandler.getUUID(plr)) + "";
|
final String rights = cluster.isAdded(UUIDHandler.getUUID(plr)) + "";
|
||||||
String message = C.CLUSTER_INFO.s();
|
String message = C.CLUSTER_INFO.s();
|
||||||
message = message.replaceAll("%id%", id);
|
message = message.replaceAll("%id%", id);
|
||||||
message = message.replaceAll("%owner%", owner);
|
message = message.replaceAll("%owner%", owner);
|
||||||
|
@ -34,6 +34,7 @@ public enum Command {
|
|||||||
// (Rating system) (ratings can be stored as the average, and number of
|
// (Rating system) (ratings can be stored as the average, and number of
|
||||||
// ratings)
|
// ratings)
|
||||||
// - /plot rate <number out of 10>
|
// - /plot rate <number out of 10>
|
||||||
|
MOVE("move", ""),
|
||||||
FLAG("flag", "f"),
|
FLAG("flag", "f"),
|
||||||
TARGET("target"),
|
TARGET("target"),
|
||||||
CLUSTER("cluster", "clusters"),
|
CLUSTER("cluster", "clusters"),
|
||||||
|
@ -21,18 +21,18 @@
|
|||||||
package com.intellectualcrafters.plot.commands;
|
package com.intellectualcrafters.plot.commands;
|
||||||
|
|
||||||
import java.util.Arrays;
|
import java.util.Arrays;
|
||||||
import java.util.List;
|
|
||||||
|
|
||||||
import org.apache.commons.lang.StringUtils;
|
import org.apache.commons.lang.StringUtils;
|
||||||
|
|
||||||
import com.intellectualcrafters.plot.config.C;
|
import com.intellectualcrafters.plot.config.C;
|
||||||
import com.intellectualcrafters.plot.database.DBFunc;
|
|
||||||
import com.intellectualcrafters.plot.object.Location;
|
import com.intellectualcrafters.plot.object.Location;
|
||||||
import com.intellectualcrafters.plot.object.Plot;
|
import com.intellectualcrafters.plot.object.Plot;
|
||||||
import com.intellectualcrafters.plot.object.PlotComment;
|
import com.intellectualcrafters.plot.object.PlotId;
|
||||||
import com.intellectualcrafters.plot.object.PlotPlayer;
|
import com.intellectualcrafters.plot.object.PlotPlayer;
|
||||||
|
import com.intellectualcrafters.plot.object.comment.CommentInbox;
|
||||||
|
import com.intellectualcrafters.plot.object.comment.CommentManager;
|
||||||
|
import com.intellectualcrafters.plot.object.comment.PlotComment;
|
||||||
import com.intellectualcrafters.plot.util.MainUtil;
|
import com.intellectualcrafters.plot.util.MainUtil;
|
||||||
import com.intellectualcrafters.plot.util.Permissions;
|
|
||||||
|
|
||||||
public class Comment extends SubCommand {
|
public class Comment extends SubCommand {
|
||||||
public Comment() {
|
public Comment() {
|
||||||
@ -40,27 +40,45 @@ public class Comment extends SubCommand {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean execute(final PlotPlayer plr, final String... args) {
|
public boolean execute(final PlotPlayer player, final String... args) {
|
||||||
final Location loc = plr.getLocation();
|
if (args.length < 2) {
|
||||||
final Plot plot = MainUtil.getPlot(loc);
|
sendMessage(player, C.COMMENT_SYNTAX, StringUtils.join(CommentManager.inboxes.keySet(),"|"));
|
||||||
if (plot == null) {
|
return false;
|
||||||
return sendMessage(plr, C.NOT_IN_PLOT);
|
|
||||||
}
|
}
|
||||||
if (!plot.hasOwner()) {
|
CommentInbox inbox = CommentManager.inboxes.get(args[0].toLowerCase());
|
||||||
return sendMessage(plr, C.NOT_IN_PLOT);
|
if (inbox == null) {
|
||||||
|
sendMessage(player, C.COMMENT_SYNTAX, StringUtils.join(CommentManager.inboxes.keySet(),"|"));
|
||||||
|
return false;
|
||||||
}
|
}
|
||||||
final List<String> recipients = Arrays.asList("admin", "owner", "helper", "trusted", "everyone");
|
Plot plot;
|
||||||
if ((args.length > 1) && recipients.contains(args[0].toLowerCase())) {
|
Location loc = player.getLocation();
|
||||||
if (Permissions.hasPermission(plr, "plots.comment." + args[0].toLowerCase())) {
|
PlotId id = PlotId.fromString(args[1]);
|
||||||
final String text = StringUtils.join(Arrays.copyOfRange(args, 1, args.length), " ");
|
int index;
|
||||||
final PlotComment comment = new PlotComment(text, plr.getName(), recipients.indexOf(args[0].toLowerCase()));
|
if (id != null) {
|
||||||
plot.settings.addComment(comment);
|
if (args.length < 4) {
|
||||||
DBFunc.setComment(loc.getWorld(), plot, comment);
|
sendMessage(player, C.COMMENT_SYNTAX, StringUtils.join(CommentManager.inboxes.keySet(),"|"));
|
||||||
return sendMessage(plr, C.COMMENT_ADDED);
|
return false;
|
||||||
} else {
|
|
||||||
return sendMessage(plr, C.NO_PERMISSION, "plots.comment." + args[0].toLowerCase());
|
|
||||||
}
|
}
|
||||||
|
index = 2;
|
||||||
|
plot = MainUtil.getPlot(loc.getWorld(), id);
|
||||||
}
|
}
|
||||||
return sendMessage(plr, C.COMMENT_SYNTAX);
|
else {
|
||||||
|
index = 1;
|
||||||
|
plot = MainUtil.getPlot(loc);
|
||||||
|
}
|
||||||
|
if (!inbox.canWrite(plot, player)) {
|
||||||
|
sendMessage(player, C.NO_PERM_INBOX, "");
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
String message = StringUtils.join(Arrays.copyOfRange(args,index, args.length), " ");
|
||||||
|
PlotComment comment = new PlotComment(loc.getWorld(), id, message, player.getName(), inbox.toString(), System.currentTimeMillis());
|
||||||
|
boolean result = inbox.addComment(plot, comment);
|
||||||
|
if (!result) {
|
||||||
|
sendMessage(player, C.NO_PLOT_INBOX, "");
|
||||||
|
sendMessage(player, C.COMMENT_SYNTAX, StringUtils.join(CommentManager.inboxes.keySet(),"|"));
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
sendMessage(player, C.COMMENT_ADDED);
|
||||||
|
return true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -94,7 +94,11 @@ public class Condense extends SubCommand {
|
|||||||
}
|
}
|
||||||
start = Auto.getNextPlot(start, 1);
|
start = Auto.getNextPlot(start, 1);
|
||||||
}
|
}
|
||||||
MainUtil.move(worldname, to_move.get(0), free.get(0), new Runnable() {
|
if (free.size() == 0 || to_move.size() == 0) {
|
||||||
|
MainUtil.sendMessage(plr, "NO PLOTS FOUND");
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
MainUtil.move(MainUtil.getPlot(worldname, to_move.get(0)), MainUtil.getPlot(worldname, free.get(0)), new Runnable() {
|
||||||
@Override
|
@Override
|
||||||
public void run() {
|
public void run() {
|
||||||
if (!TASK) {
|
if (!TASK) {
|
||||||
@ -136,7 +140,7 @@ public class Condense extends SubCommand {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
sendMessage("MOVING " + to_move.get(0) + " to " + free.get(0));
|
sendMessage("MOVING " + to_move.get(0) + " to " + free.get(0));
|
||||||
MainUtil.move(worldname, to_move.get(0), free.get(0), this);
|
MainUtil.move(MainUtil.getPlot(worldname, to_move.get(0)), MainUtil.getPlot(worldname, free.get(0)), this);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
TASK = true;
|
TASK = true;
|
||||||
|
@ -32,7 +32,7 @@ import com.intellectualcrafters.plot.util.TaskManager;
|
|||||||
*/
|
*/
|
||||||
public class Confirm extends SubCommand {
|
public class Confirm extends SubCommand {
|
||||||
public Confirm() {
|
public Confirm() {
|
||||||
super(Command.CONFIRM, "Confirm command execution", "confirm", CommandCategory.ACTIONS, true);
|
super("confirm", "plots.use", "Confirm an action", "confirm", "confirm", CommandCategory.ACTIONS, false);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@ -43,7 +43,7 @@ public class Confirm extends SubCommand {
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
CmdConfirm.removePending(plr);
|
CmdConfirm.removePending(plr);
|
||||||
if (System.currentTimeMillis() - command.timestamp > 10000) {
|
if (System.currentTimeMillis() - command.timestamp > 20000) {
|
||||||
MainUtil.sendMessage(plr, C.FAILED_CONFIRM);
|
MainUtil.sendMessage(plr, C.FAILED_CONFIRM);
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
@ -0,0 +1,81 @@
|
|||||||
|
////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||||
|
// PlotSquared - A plot manager and world generator for the Bukkit API /
|
||||||
|
// Copyright (c) 2014 IntellectualSites/IntellectualCrafters /
|
||||||
|
// /
|
||||||
|
// This program is free software; you can redistribute it and/or modify /
|
||||||
|
// it under the terms of the GNU General Public License as published by /
|
||||||
|
// the Free Software Foundation; either version 3 of the License, or /
|
||||||
|
// (at your option) any later version. /
|
||||||
|
// /
|
||||||
|
// This program is distributed in the hope that it will be useful, /
|
||||||
|
// but WITHOUT ANY WARRANTY; without even the implied warranty of /
|
||||||
|
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the /
|
||||||
|
// GNU General Public License for more details. /
|
||||||
|
// /
|
||||||
|
// You should have received a copy of the GNU General Public License /
|
||||||
|
// along with this program; if not, write to the Free Software Foundation, /
|
||||||
|
// Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA /
|
||||||
|
// /
|
||||||
|
// You can contact us via: support@intellectualsites.com /
|
||||||
|
////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||||
|
package com.intellectualcrafters.plot.commands;
|
||||||
|
|
||||||
|
import com.intellectualcrafters.plot.config.C;
|
||||||
|
import com.intellectualcrafters.plot.object.Location;
|
||||||
|
import com.intellectualcrafters.plot.object.Plot;
|
||||||
|
import com.intellectualcrafters.plot.object.PlotId;
|
||||||
|
import com.intellectualcrafters.plot.object.PlotPlayer;
|
||||||
|
import com.intellectualcrafters.plot.util.MainUtil;
|
||||||
|
import com.intellectualcrafters.plot.util.Permissions;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Created 2014-08-01 for PlotSquared
|
||||||
|
*
|
||||||
|
* @author Empire92
|
||||||
|
*/
|
||||||
|
public class Copy extends SubCommand {
|
||||||
|
public Copy() {
|
||||||
|
super("copy", "plots.copy", "Copy a plot", "copypaste", "", CommandCategory.ACTIONS, true);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean execute(final PlotPlayer plr, final String... args) {
|
||||||
|
if (args.length < 1) {
|
||||||
|
MainUtil.sendMessage(plr, C.NEED_PLOT_ID);
|
||||||
|
MainUtil.sendMessage(plr, C.COMMAND_SYNTAX, "/plot copy <X;Z>");
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
final Location loc = plr.getLocation();
|
||||||
|
final Plot plot1 = MainUtil.getPlot(loc);
|
||||||
|
if (plot1 == null) {
|
||||||
|
return !MainUtil.sendMessage(plr, C.NOT_IN_PLOT);
|
||||||
|
}
|
||||||
|
if (!plot1.isAdded(plr.getUUID()) && !plr.hasPermission(Permissions.ADMIN)) {
|
||||||
|
MainUtil.sendMessage(plr, C.NO_PLOT_PERMS);
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
final String world = loc.getWorld();
|
||||||
|
final PlotId plot2 = MainUtil.parseId(args[0]);
|
||||||
|
if ((plot2 == null)) {
|
||||||
|
MainUtil.sendMessage(plr, C.NOT_VALID_PLOT_ID);
|
||||||
|
MainUtil.sendMessage(plr, C.COMMAND_SYNTAX, "/plot copy <X;Z>");
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
if (plot1.id.equals(plot2)) {
|
||||||
|
MainUtil.sendMessage(plr, C.NOT_VALID_PLOT_ID);
|
||||||
|
MainUtil.sendMessage(plr, C.COMMAND_SYNTAX, "/plot copy <X;Z>");
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
if (MainUtil.copy(world, plot1.id, plot2, new Runnable() {
|
||||||
|
@Override
|
||||||
|
public void run() {
|
||||||
|
MainUtil.sendMessage(plr, C.COPY_SUCCESS);
|
||||||
|
}
|
||||||
|
})) {
|
||||||
|
return true;
|
||||||
|
} else {
|
||||||
|
MainUtil.sendMessage(plr, C.REQUIRES_UNOWNED);
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
@ -45,7 +45,6 @@ public class CreateRoadSchematic extends SubCommand {
|
|||||||
return sendMessage(player, C.NOT_IN_PLOT_WORLD);
|
return sendMessage(player, C.NOT_IN_PLOT_WORLD);
|
||||||
}
|
}
|
||||||
HybridUtils.manager.setupRoadSchematic(plot);
|
HybridUtils.manager.setupRoadSchematic(plot);
|
||||||
MainUtil.update(loc);
|
|
||||||
MainUtil.sendMessage(player, "&6Saved new road schematic");
|
MainUtil.sendMessage(player, "&6Saved new road schematic");
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
@ -53,9 +53,13 @@ public class Database extends SubCommand {
|
|||||||
for (final Plot p : plots) {
|
for (final Plot p : plots) {
|
||||||
ps.add(p);
|
ps.add(p);
|
||||||
}
|
}
|
||||||
manager.createPlots(ps);
|
sendMessageU(requester, "&6Starting...");
|
||||||
manager.createAllSettingsAndHelpers(ps);
|
manager.createPlotsAndData(ps, new Runnable() {
|
||||||
sendMessageU(requester, "&6Database conversion finished");
|
@Override
|
||||||
|
public void run() {
|
||||||
|
sendMessageU(requester, "&6Database conversion finished!");
|
||||||
|
}
|
||||||
|
});
|
||||||
} catch (final Exception e) {
|
} catch (final Exception e) {
|
||||||
sendMessageU(requester, "Failed to insert plot objects, see stacktrace for info");
|
sendMessageU(requester, "Failed to insert plot objects, see stacktrace for info");
|
||||||
e.printStackTrace();
|
e.printStackTrace();
|
||||||
|
@ -134,8 +134,12 @@ public class DebugClaimTest extends SubCommand {
|
|||||||
}
|
}
|
||||||
if (plots.size() > 0) {
|
if (plots.size() > 0) {
|
||||||
MainUtil.sendMessage(null, "&3Sign Block&8->&3PlotSquared&8: &7Updating '" + plots.size() + "' plots!");
|
MainUtil.sendMessage(null, "&3Sign Block&8->&3PlotSquared&8: &7Updating '" + plots.size() + "' plots!");
|
||||||
DBFunc.createPlots(plots);
|
DBFunc.createPlotsAndData(plots, new Runnable() {
|
||||||
DBFunc.createAllSettingsAndHelpers(plots);
|
@Override
|
||||||
|
public void run() {
|
||||||
|
MainUtil.sendMessage(null, "&6Database update finished!");
|
||||||
|
}
|
||||||
|
});
|
||||||
for (final Plot plot : plots) {
|
for (final Plot plot : plots) {
|
||||||
PlotSquared.updatePlot(plot);
|
PlotSquared.updatePlot(plot);
|
||||||
}
|
}
|
||||||
|
@ -85,7 +85,7 @@ public class DebugClear extends SubCommand {
|
|||||||
if (!MainUtil.getTopPlot(plot).equals(MainUtil.getBottomPlot(plot))) {
|
if (!MainUtil.getTopPlot(plot).equals(MainUtil.getBottomPlot(plot))) {
|
||||||
return sendMessage(plr, C.UNLINK_REQUIRED);
|
return sendMessage(plr, C.UNLINK_REQUIRED);
|
||||||
}
|
}
|
||||||
if (((plot == null) || !plot.hasOwner() || !plot.getOwner().equals(UUIDHandler.getUUID(plr))) && !Permissions.hasPermission(plr, "plots.admin.command.debugclear")) {
|
if (((plot == null) || !plot.hasOwner() || !plot.isOwner(UUIDHandler.getUUID(plr))) && !Permissions.hasPermission(plr, "plots.admin.command.debugclear")) {
|
||||||
return sendMessage(plr, C.NO_PLOT_PERMS);
|
return sendMessage(plr, C.NO_PLOT_PERMS);
|
||||||
}
|
}
|
||||||
assert plot != null;
|
assert plot != null;
|
||||||
|
@ -0,0 +1,120 @@
|
|||||||
|
////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||||
|
// PlotSquared - A plot manager and world generator for the Bukkit API /
|
||||||
|
// Copyright (c) 2014 IntellectualSites/IntellectualCrafters /
|
||||||
|
// /
|
||||||
|
// This program is free software; you can redistribute it and/or modify /
|
||||||
|
// it under the terms of the GNU General Public License as published by /
|
||||||
|
// the Free Software Foundation; either version 3 of the License, or /
|
||||||
|
// (at your option) any later version. /
|
||||||
|
// /
|
||||||
|
// This program is distributed in the hope that it will be useful, /
|
||||||
|
// but WITHOUT ANY WARRANTY; without even the implied warranty of /
|
||||||
|
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the /
|
||||||
|
// GNU General Public License for more details. /
|
||||||
|
// /
|
||||||
|
// You should have received a copy of the GNU General Public License /
|
||||||
|
// along with this program; if not, write to the Free Software Foundation, /
|
||||||
|
// Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA /
|
||||||
|
// /
|
||||||
|
// You can contact us via: support@intellectualsites.com /
|
||||||
|
////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||||
|
package com.intellectualcrafters.plot.commands;
|
||||||
|
|
||||||
|
import com.intellectualcrafters.plot.config.C;
|
||||||
|
import com.intellectualcrafters.plot.object.Location;
|
||||||
|
import com.intellectualcrafters.plot.object.Plot;
|
||||||
|
import com.intellectualcrafters.plot.object.PlotPlayer;
|
||||||
|
import com.intellectualcrafters.plot.util.MainUtil;
|
||||||
|
import com.intellectualcrafters.plot.util.Permissions;
|
||||||
|
import com.intellectualcrafters.plot.util.SetBlockQueue;
|
||||||
|
import com.intellectualcrafters.plot.util.TaskManager;
|
||||||
|
import com.intellectualcrafters.plot.util.bukkit.UUIDHandler;
|
||||||
|
import com.intellectualcrafters.plot.uuid.DefaultUUIDWrapper;
|
||||||
|
import com.intellectualcrafters.plot.uuid.LowerOfflineUUIDWrapper;
|
||||||
|
import com.intellectualcrafters.plot.uuid.OfflineUUIDWrapper;
|
||||||
|
import com.intellectualcrafters.plot.uuid.UUIDWrapper;
|
||||||
|
|
||||||
|
public class DebugFill extends SubCommand {
|
||||||
|
public DebugFill() {
|
||||||
|
super("fill", "plots.fill", "Fill or surround a plot in bedrock", "fill", "debugfill", CommandCategory.DEBUG, true);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean execute(final PlotPlayer player, final String... args) {
|
||||||
|
if (args.length != 1 || (!args[0].equalsIgnoreCase("outline") && !args[0].equalsIgnoreCase("all"))) {
|
||||||
|
MainUtil.sendMessage(player, C.COMMAND_SYNTAX, "/plot fill <outline|all>");
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
final Location loc = player.getLocation();
|
||||||
|
final Plot plot = MainUtil.getPlot(loc);
|
||||||
|
if (plot == null) {
|
||||||
|
return !sendMessage(player, C.NOT_IN_PLOT);
|
||||||
|
}
|
||||||
|
if ((plot == null) || !plot.hasOwner()) {
|
||||||
|
MainUtil.sendMessage(player, C.PLOT_UNOWNED);
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
if (!plot.isOwner(player.getUUID()) && !Permissions.hasPermission(player, "plots.admin.command.fill")) {
|
||||||
|
MainUtil.sendMessage(player, C.NO_PLOT_PERMS);
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
final Location bottom = MainUtil.getPlotBottomLoc(plot.world, plot.id).add(1, 0, 1);
|
||||||
|
final Location top = MainUtil.getPlotTopLoc(plot.world, plot.id);
|
||||||
|
MainUtil.sendMessage(player, "&cPreparing task");
|
||||||
|
TaskManager.runTaskAsync(new Runnable() {
|
||||||
|
@Override
|
||||||
|
public void run() {
|
||||||
|
MainUtil.sendMessage(player, "&7 - Starting");
|
||||||
|
if (args[0].equalsIgnoreCase("all")) {
|
||||||
|
for (int x = bottom.getX(); x <= top.getX(); x++) {
|
||||||
|
for (int y = 0; y <= 255; y++) {
|
||||||
|
for (int z = bottom.getZ(); z <= top.getZ(); z++) {
|
||||||
|
SetBlockQueue.setBlock(plot.world, x, y, z, 7);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else if (args[0].equals("outline")) {
|
||||||
|
int x, z;
|
||||||
|
z = bottom.getZ();
|
||||||
|
for (x = bottom.getX(); x <= (top.getX() - 1); x++) {
|
||||||
|
for (int y = 1; y <= 255; y++) {
|
||||||
|
SetBlockQueue.setBlock(plot.world, x, y, z, 7);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
x = top.getX();
|
||||||
|
for (z = bottom.getZ(); z <= (top.getZ() - 1); z++) {
|
||||||
|
for (int y = 1; y <= 255; y++) {
|
||||||
|
SetBlockQueue.setBlock(plot.world, x, y, z, 7);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
z = top.getZ();
|
||||||
|
for (x = top.getX(); x >= (bottom.getX() + 1); x--) {
|
||||||
|
for (int y = 1; y <= 255; y++) {
|
||||||
|
SetBlockQueue.setBlock(plot.world, x, y, z, 7);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
x = bottom.getX();
|
||||||
|
for (z = top.getZ(); z >= (bottom.getZ() + 1); z--) {
|
||||||
|
for (int y = 1; y <= 255; y++) {
|
||||||
|
SetBlockQueue.setBlock(plot.world, x, y, z, 7);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
int y = 255;
|
||||||
|
for (x = bottom.getX(); x <= top.getX(); x++) {
|
||||||
|
for (z = bottom.getZ(); z <= top.getZ(); z++) {
|
||||||
|
SetBlockQueue.setBlock(plot.world, x, y, z, 7);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
SetBlockQueue.addNotify(new Runnable() {
|
||||||
|
@Override
|
||||||
|
public void run() {
|
||||||
|
MainUtil.sendMessage(player, "&aFill task complete!");
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
});
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
}
|
@ -43,9 +43,6 @@ public class DebugRoadRegen extends SubCommand {
|
|||||||
}
|
}
|
||||||
final ChunkLoc chunk = new ChunkLoc(loc.getX() >> 4, loc.getZ() >> 4);
|
final ChunkLoc chunk = new ChunkLoc(loc.getX() >> 4, loc.getZ() >> 4);
|
||||||
final boolean result = HybridUtils.manager.regenerateRoad(world, chunk);
|
final boolean result = HybridUtils.manager.regenerateRoad(world, chunk);
|
||||||
if (result) {
|
|
||||||
MainUtil.update(loc);
|
|
||||||
}
|
|
||||||
MainUtil.sendMessage(player, "&6Regenerating chunk: " + chunk.x + "," + chunk.z + "\n&6 - Result: " + (result == true ? "&aSuccess" : "&cFailed"));
|
MainUtil.sendMessage(player, "&6Regenerating chunk: " + chunk.x + "," + chunk.z + "\n&6 - Result: " + (result == true ? "&aSuccess" : "&cFailed"));
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
@ -41,8 +41,13 @@ public class DebugSaveTest extends SubCommand {
|
|||||||
if (plr == null) {
|
if (plr == null) {
|
||||||
final ArrayList<Plot> plots = new ArrayList<Plot>();
|
final ArrayList<Plot> plots = new ArrayList<Plot>();
|
||||||
plots.addAll(PlotSquared.getPlots());
|
plots.addAll(PlotSquared.getPlots());
|
||||||
DBFunc.createPlots(plots);
|
MainUtil.sendMessage(null, "&6Starting `DEBUGSAVETEST`");
|
||||||
DBFunc.createAllSettingsAndHelpers(plots);
|
DBFunc.createPlotsAndData(plots, new Runnable() {
|
||||||
|
@Override
|
||||||
|
public void run() {
|
||||||
|
MainUtil.sendMessage(null, "&6Database sync finished!");
|
||||||
|
}
|
||||||
|
});
|
||||||
} else {
|
} else {
|
||||||
MainUtil.sendMessage(plr, "This debug command can only be executed by console as it has been deemed unsafe if abused");
|
MainUtil.sendMessage(plr, "This debug command can only be executed by console as it has been deemed unsafe if abused");
|
||||||
}
|
}
|
||||||
|
@ -0,0 +1,298 @@
|
|||||||
|
////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||||
|
// PlotSquared - A plot manager and world generator for the Bukkit API /
|
||||||
|
// Copyright (c) 2014 IntellectualSites/IntellectualCrafters /
|
||||||
|
// /
|
||||||
|
// This program is free software; you can redistribute it and/or modify /
|
||||||
|
// it under the terms of the GNU General Public License as published by /
|
||||||
|
// the Free Software Foundation; either version 3 of the License, or /
|
||||||
|
// (at your option) any later version. /
|
||||||
|
// /
|
||||||
|
// This program is distributed in the hope that it will be useful, /
|
||||||
|
// but WITHOUT ANY WARRANTY; without even the implied warranty of /
|
||||||
|
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the /
|
||||||
|
// GNU General Public License for more details. /
|
||||||
|
// /
|
||||||
|
// You should have received a copy of the GNU General Public License /
|
||||||
|
// along with this program; if not, write to the Free Software Foundation, /
|
||||||
|
// Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA /
|
||||||
|
// /
|
||||||
|
// You can contact us via: support@intellectualsites.com /
|
||||||
|
////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||||
|
package com.intellectualcrafters.plot.commands;
|
||||||
|
|
||||||
|
import java.io.File;
|
||||||
|
import java.io.FilenameFilter;
|
||||||
|
import java.util.ArrayList;
|
||||||
|
import java.util.HashMap;
|
||||||
|
import java.util.HashSet;
|
||||||
|
import java.util.Map.Entry;
|
||||||
|
import java.util.UUID;
|
||||||
|
|
||||||
|
import org.bukkit.Bukkit;
|
||||||
|
|
||||||
|
import com.intellectualcrafters.plot.PlotSquared;
|
||||||
|
import com.intellectualcrafters.plot.config.C;
|
||||||
|
import com.intellectualcrafters.plot.config.Settings;
|
||||||
|
import com.intellectualcrafters.plot.database.AbstractDB;
|
||||||
|
import com.intellectualcrafters.plot.database.DBFunc;
|
||||||
|
import com.intellectualcrafters.plot.database.SQLManager;
|
||||||
|
import com.intellectualcrafters.plot.object.OfflinePlotPlayer;
|
||||||
|
import com.intellectualcrafters.plot.object.Plot;
|
||||||
|
import com.intellectualcrafters.plot.object.PlotPlayer;
|
||||||
|
import com.intellectualcrafters.plot.object.StringWrapper;
|
||||||
|
import com.intellectualcrafters.plot.util.MainUtil;
|
||||||
|
import com.intellectualcrafters.plot.util.PlayerManager;
|
||||||
|
import com.intellectualcrafters.plot.util.TaskManager;
|
||||||
|
import com.intellectualcrafters.plot.util.bukkit.UUIDHandler;
|
||||||
|
import com.intellectualcrafters.plot.uuid.DefaultUUIDWrapper;
|
||||||
|
import com.intellectualcrafters.plot.uuid.LowerOfflineUUIDWrapper;
|
||||||
|
import com.intellectualcrafters.plot.uuid.OfflineUUIDWrapper;
|
||||||
|
import com.intellectualcrafters.plot.uuid.UUIDWrapper;
|
||||||
|
|
||||||
|
public class DebugUUID extends SubCommand {
|
||||||
|
public DebugUUID() {
|
||||||
|
super("uuidconvert", "plots.admin", "Debug uuid conversion", "debuguuid", "debuguuid", CommandCategory.DEBUG, false);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean execute(final PlotPlayer player, final String... args) {
|
||||||
|
if (player != null) {
|
||||||
|
MainUtil.sendMessage(player, C.NOT_CONSOLE);
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
if (args.length == 0) {
|
||||||
|
MainUtil.sendMessage(player, C.COMMAND_SYNTAX, "/plot uuidconvert <lower|offline|online>");
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
UUIDWrapper currentUUIDWrapper = UUIDHandler.uuidWrapper;
|
||||||
|
UUIDWrapper newWrapper = null;
|
||||||
|
|
||||||
|
switch (args[0].toLowerCase()) {
|
||||||
|
case "lower": {
|
||||||
|
newWrapper = new LowerOfflineUUIDWrapper();
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
case "offline": {
|
||||||
|
newWrapper = new OfflineUUIDWrapper();
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
case "online": {
|
||||||
|
newWrapper = new DefaultUUIDWrapper();
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
default: {
|
||||||
|
try {
|
||||||
|
Class<?> clazz = Class.forName(args[0]);
|
||||||
|
newWrapper = (UUIDWrapper) clazz.newInstance();
|
||||||
|
}
|
||||||
|
catch (Exception e) {
|
||||||
|
MainUtil.sendMessage(player, C.COMMAND_SYNTAX, "/plot uuidconvert <lower|offline|online>");
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (args.length != 2 || !args[1].equals("-o")) {
|
||||||
|
MainUtil.sendMessage(player, C.COMMAND_SYNTAX, "/plot uuidconvert " + args[0] + " - o");
|
||||||
|
MainUtil.sendMessage(player, "&cBe aware of the following!");
|
||||||
|
MainUtil.sendMessage(player, "&8 - &cIf the process is interrupted, all plots could be deleted");
|
||||||
|
MainUtil.sendMessage(player, "&8 - &cIf an error occurs, all plots could be deleted");
|
||||||
|
MainUtil.sendMessage(player, "&8 - &cPlot settings WILL be lost upon conversion");
|
||||||
|
MainUtil.sendMessage(player, "&cBACK UP YOUR DATABASE BEFORE USING THIS!!!");
|
||||||
|
MainUtil.sendMessage(player, "&7Retype the command with the override parameter when ready");
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (currentUUIDWrapper.getClass().getCanonicalName().equals(newWrapper.getClass().getCanonicalName())) {
|
||||||
|
MainUtil.sendMessage(player, "&cUUID mode already in use!");
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
MainUtil.sendConsoleMessage("&6Beginning UUID mode conversion");
|
||||||
|
MainUtil.sendConsoleMessage("&7 - Disconnecting players");
|
||||||
|
for (PlotPlayer user : UUIDHandler.players.values()) {
|
||||||
|
PlayerManager.manager.kickPlayer(user, "PlotSquared UUID conversion has been initiated. You may reconnect when finished.");
|
||||||
|
}
|
||||||
|
|
||||||
|
MainUtil.sendConsoleMessage("&7 - Initializing map");
|
||||||
|
|
||||||
|
HashMap<UUID, UUID> uCMap = new HashMap<UUID, UUID>();
|
||||||
|
HashMap<UUID, UUID> uCReverse = new HashMap<UUID, UUID>();
|
||||||
|
|
||||||
|
MainUtil.sendConsoleMessage("&7 - Collecting playerdata");
|
||||||
|
|
||||||
|
final HashSet<String> worlds = new HashSet<>();
|
||||||
|
worlds.add(Bukkit.getWorlds().get(0).getName());
|
||||||
|
worlds.add("world");
|
||||||
|
final HashSet<UUID> uuids = new HashSet<>();
|
||||||
|
final HashSet<String> names = new HashSet<>();
|
||||||
|
for (final String worldname : worlds) {
|
||||||
|
final File playerdataFolder = new File(worldname + File.separator + "playerdata");
|
||||||
|
String[] dat = playerdataFolder.list(new FilenameFilter() {
|
||||||
|
@Override
|
||||||
|
public boolean accept(final File f, final String s) {
|
||||||
|
return s.endsWith(".dat");
|
||||||
|
}
|
||||||
|
});
|
||||||
|
if (dat != null) {
|
||||||
|
for (final String current : dat) {
|
||||||
|
final String s = current.replaceAll(".dat$", "");
|
||||||
|
try {
|
||||||
|
final UUID uuid = UUID.fromString(s);
|
||||||
|
uuids.add(uuid);
|
||||||
|
} catch (final Exception e) {
|
||||||
|
PlotSquared.log(C.PREFIX.s() + "Invalid playerdata: " + current);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
final File playersFolder = new File(worldname + File.separator + "players");
|
||||||
|
dat = playersFolder.list(new FilenameFilter() {
|
||||||
|
@Override
|
||||||
|
public boolean accept(final File f, final String s) {
|
||||||
|
return s.endsWith(".dat");
|
||||||
|
}
|
||||||
|
});
|
||||||
|
if (dat != null) {
|
||||||
|
for (final String current : dat) {
|
||||||
|
names.add(current.replaceAll(".dat$", ""));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
MainUtil.sendConsoleMessage("&7 - Populating map");
|
||||||
|
UUID uuid2;
|
||||||
|
final UUIDWrapper wrapper = new DefaultUUIDWrapper();
|
||||||
|
for (UUID uuid : uuids) {
|
||||||
|
try {
|
||||||
|
final OfflinePlotPlayer op = wrapper.getOfflinePlayer(uuid);
|
||||||
|
uuid = currentUUIDWrapper.getUUID(op);
|
||||||
|
uuid2 = newWrapper.getUUID(op);
|
||||||
|
if (!uuid.equals(uuid2)) {
|
||||||
|
uCMap.put(uuid, uuid2);
|
||||||
|
uCReverse.put(uuid2, uuid);
|
||||||
|
}
|
||||||
|
} catch (final Throwable e) {
|
||||||
|
PlotSquared.log(C.PREFIX.s() + "&6Invalid playerdata: " + uuid.toString() + ".dat");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
for (final String name : names) {
|
||||||
|
final UUID uuid = currentUUIDWrapper.getUUID(name);
|
||||||
|
uuid2 = newWrapper.getUUID(name);
|
||||||
|
if (!uuid.equals(uuid2)) {
|
||||||
|
uCMap.put(uuid, uuid2);
|
||||||
|
uCReverse.put(uuid2, uuid);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (uCMap.size() == 0) {
|
||||||
|
MainUtil.sendConsoleMessage("&c - Error! Attempting to repopulate");
|
||||||
|
for (OfflinePlotPlayer op : currentUUIDWrapper.getOfflinePlayers()) {
|
||||||
|
if (op.getLastPlayed() != 0) {
|
||||||
|
String name = op.getName();
|
||||||
|
StringWrapper wrap = new StringWrapper(name);
|
||||||
|
UUID uuid = currentUUIDWrapper.getUUID(op);
|
||||||
|
uuid2 = newWrapper.getUUID(op);
|
||||||
|
if (!uuid.equals(uuid2)) {
|
||||||
|
uCMap.put(uuid, uuid2);
|
||||||
|
uCReverse.put(uuid2, uuid);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (uCMap.size() == 0) {
|
||||||
|
MainUtil.sendConsoleMessage("&cError. Failed to collect UUIDs!");
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
MainUtil.sendConsoleMessage("&a - Successfully repopulated");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
MainUtil.sendConsoleMessage("&7 - Replacing cache");
|
||||||
|
for (Entry<UUID, UUID> entry : uCMap.entrySet()) {
|
||||||
|
String name = UUIDHandler.getName(entry.getKey());
|
||||||
|
UUIDHandler.add(new StringWrapper(name), entry.getValue());
|
||||||
|
}
|
||||||
|
|
||||||
|
MainUtil.sendConsoleMessage("&7 - Replacing wrapper");
|
||||||
|
UUIDHandler.uuidWrapper = newWrapper;
|
||||||
|
|
||||||
|
MainUtil.sendConsoleMessage("&7 - Updating plot objects");
|
||||||
|
|
||||||
|
for (Plot plot : PlotSquared.getPlotsRaw()) {
|
||||||
|
UUID value = uCMap.get(plot.owner);
|
||||||
|
if (value != null) {
|
||||||
|
plot.owner = value;
|
||||||
|
}
|
||||||
|
plot.helpers = new ArrayList<>();
|
||||||
|
plot.trusted = new ArrayList<>();
|
||||||
|
plot.denied = new ArrayList<>();
|
||||||
|
}
|
||||||
|
|
||||||
|
MainUtil.sendConsoleMessage("&7 - Deleting database");
|
||||||
|
final AbstractDB database = DBFunc.dbManager;
|
||||||
|
boolean result = database.deleteTables();
|
||||||
|
|
||||||
|
MainUtil.sendConsoleMessage("&7 - Creating tables");
|
||||||
|
|
||||||
|
try {
|
||||||
|
database.createTables(Settings.DB.USE_MYSQL ? "mysql" : "sqlite", true);
|
||||||
|
if (!result) {
|
||||||
|
MainUtil.sendConsoleMessage("&cConversion failed! Attempting recovery");
|
||||||
|
for (Plot plot : PlotSquared.getPlots()) {
|
||||||
|
UUID value = uCReverse.get(plot.owner);
|
||||||
|
if (value != null) {
|
||||||
|
plot.owner = value;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
database.createPlotsAndData(new ArrayList<>(PlotSquared.getPlots()), new Runnable() {
|
||||||
|
@Override
|
||||||
|
public void run() {
|
||||||
|
MainUtil.sendMessage(null, "&6Recovery was successful!");
|
||||||
|
}
|
||||||
|
});
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
catch (Exception e) {
|
||||||
|
e.printStackTrace();
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (newWrapper instanceof OfflineUUIDWrapper) {
|
||||||
|
PlotSquared.config.set("UUID.force-lowercase", false);
|
||||||
|
PlotSquared.config.set("UUID.offline", true);
|
||||||
|
}
|
||||||
|
else if (newWrapper instanceof LowerOfflineUUIDWrapper) {
|
||||||
|
PlotSquared.config.set("UUID.force-lowercase", true);
|
||||||
|
PlotSquared.config.set("UUID.offline", true);
|
||||||
|
}
|
||||||
|
else if (newWrapper instanceof DefaultUUIDWrapper) {
|
||||||
|
PlotSquared.config.set("UUID.force-lowercase", false);
|
||||||
|
PlotSquared.config.set("UUID.offline", false);
|
||||||
|
}
|
||||||
|
try {
|
||||||
|
PlotSquared.config.save(PlotSquared.configFile);
|
||||||
|
}
|
||||||
|
catch (Exception e) {
|
||||||
|
MainUtil.sendConsoleMessage("Could not save configuration. It will need to be manuall set!");
|
||||||
|
}
|
||||||
|
|
||||||
|
MainUtil.sendConsoleMessage("&7 - Populating tables");
|
||||||
|
|
||||||
|
TaskManager.runTaskAsync(new Runnable() {
|
||||||
|
@Override
|
||||||
|
public void run() {
|
||||||
|
ArrayList<Plot> plots = new ArrayList<>(PlotSquared.getPlots());
|
||||||
|
database.createPlotsAndData(plots, new Runnable() {
|
||||||
|
@Override
|
||||||
|
public void run() {
|
||||||
|
MainUtil.sendConsoleMessage("&aConversion complete!");
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
MainUtil.sendConsoleMessage("&aIt is now safe for players to join");
|
||||||
|
MainUtil.sendConsoleMessage("&cConversion is still in progress, you will be notified when it is complete");
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
}
|
@ -50,7 +50,7 @@ public class Delete extends SubCommand {
|
|||||||
if (!MainUtil.getTopPlot(plot).equals(MainUtil.getBottomPlot(plot))) {
|
if (!MainUtil.getTopPlot(plot).equals(MainUtil.getBottomPlot(plot))) {
|
||||||
return !sendMessage(plr, C.UNLINK_REQUIRED);
|
return !sendMessage(plr, C.UNLINK_REQUIRED);
|
||||||
}
|
}
|
||||||
if ((((plot == null) || !plot.hasOwner() || !plot.getOwner().equals(UUIDHandler.uuidWrapper.getUUID(plr)))) && !Permissions.hasPermission(plr, "plots.admin.command.delete")) {
|
if ((((plot == null) || !plot.hasOwner() || !plot.isOwner(UUIDHandler.uuidWrapper.getUUID(plr)))) && !Permissions.hasPermission(plr, "plots.admin.command.delete")) {
|
||||||
return !sendMessage(plr, C.NO_PLOT_PERMS);
|
return !sendMessage(plr, C.NO_PLOT_PERMS);
|
||||||
}
|
}
|
||||||
assert plot != null;
|
assert plot != null;
|
||||||
@ -62,7 +62,7 @@ public class Delete extends SubCommand {
|
|||||||
Runnable runnable = new Runnable() {
|
Runnable runnable = new Runnable() {
|
||||||
@Override
|
@Override
|
||||||
public void run() {
|
public void run() {
|
||||||
if ((PlotSquared.economy != null) && pWorld.USE_ECONOMY && (plot != null) && plot.hasOwner() && plot.getOwner().equals(UUIDHandler.getUUID(plr))) {
|
if ((PlotSquared.economy != null) && pWorld.USE_ECONOMY && (plot != null) && plot.hasOwner() && plot.isOwner(UUIDHandler.getUUID(plr))) {
|
||||||
final double c = pWorld.SELL_PRICE;
|
final double c = pWorld.SELL_PRICE;
|
||||||
if (c > 0d) {
|
if (c > 0d) {
|
||||||
EconHandler.depositPlayer(plr, c);
|
EconHandler.depositPlayer(plr, c);
|
||||||
|
@ -20,6 +20,7 @@
|
|||||||
////////////////////////////////////////////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||||
package com.intellectualcrafters.plot.commands;
|
package com.intellectualcrafters.plot.commands;
|
||||||
|
|
||||||
|
import java.util.ArrayList;
|
||||||
import java.util.UUID;
|
import java.util.UUID;
|
||||||
|
|
||||||
import com.intellectualcrafters.plot.config.C;
|
import com.intellectualcrafters.plot.config.C;
|
||||||
@ -53,7 +54,7 @@ public class Denied extends SubCommand {
|
|||||||
MainUtil.sendMessage(plr, C.PLOT_UNOWNED);
|
MainUtil.sendMessage(plr, C.PLOT_UNOWNED);
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
if (!plot.getOwner().equals(UUIDHandler.getUUID(plr)) && !Permissions.hasPermission(plr, "plots.admin.command.denied")) {
|
if (!plot.isOwner(plr.getUUID()) && !Permissions.hasPermission(plr, "plots.admin.command.denied")) {
|
||||||
MainUtil.sendMessage(plr, C.NO_PLOT_PERMS);
|
MainUtil.sendMessage(plr, C.NO_PLOT_PERMS);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
@ -69,7 +70,7 @@ public class Denied extends SubCommand {
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
if (!plot.denied.contains(uuid)) {
|
if (!plot.denied.contains(uuid)) {
|
||||||
if (plot.owner.equals(uuid)) {
|
if (plot.isOwner(uuid)) {
|
||||||
MainUtil.sendMessage(plr, C.ALREADY_OWNER);
|
MainUtil.sendMessage(plr, C.ALREADY_OWNER);
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
@ -90,7 +91,7 @@ public class Denied extends SubCommand {
|
|||||||
}
|
}
|
||||||
final PlotPlayer player = UUIDHandler.getPlayer(uuid);
|
final PlotPlayer player = UUIDHandler.getPlayer(uuid);
|
||||||
if (!uuid.equals(DBFunc.everyone) && (player != null) && player.isOnline()) {
|
if (!uuid.equals(DBFunc.everyone) && (player != null) && player.isOnline()) {
|
||||||
final Plot pl = MainUtil.getPlot(loc);
|
final Plot pl = MainUtil.getPlot(player.getLocation());
|
||||||
if ((pl != null) && pl.id.equals(plot.id)) {
|
if ((pl != null) && pl.id.equals(plot.id)) {
|
||||||
MainUtil.sendMessage(player, C.YOU_BE_DENIED);
|
MainUtil.sendMessage(player, C.YOU_BE_DENIED);
|
||||||
player.teleport(BlockManager.manager.getSpawn(loc.getWorld()));
|
player.teleport(BlockManager.manager.getSpawn(loc.getWorld()));
|
||||||
@ -100,17 +101,22 @@ public class Denied extends SubCommand {
|
|||||||
return true;
|
return true;
|
||||||
} else if (args[0].equalsIgnoreCase("remove")) {
|
} else if (args[0].equalsIgnoreCase("remove")) {
|
||||||
if (args[1].equalsIgnoreCase("*")) {
|
if (args[1].equalsIgnoreCase("*")) {
|
||||||
final UUID uuid = DBFunc.everyone;
|
if (plot.denied.size() == 0) {
|
||||||
if (!plot.denied.contains(uuid)) {
|
|
||||||
MainUtil.sendMessage(plr, C.WAS_NOT_ADDED);
|
MainUtil.sendMessage(plr, C.WAS_NOT_ADDED);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
plot.removeDenied(uuid);
|
for (UUID uuid : plot.denied) {
|
||||||
DBFunc.removeDenied(loc.getWorld(), plot, uuid);
|
DBFunc.removeDenied(loc.getWorld(), plot, uuid);
|
||||||
|
}
|
||||||
|
plot.denied = new ArrayList<>();
|
||||||
MainUtil.sendMessage(plr, C.DENIED_REMOVED);
|
MainUtil.sendMessage(plr, C.DENIED_REMOVED);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
final UUID uuid = UUIDHandler.getUUID(args[1]);
|
final UUID uuid = UUIDHandler.getUUID(args[1]);
|
||||||
|
if (!plot.denied.contains(uuid)) {
|
||||||
|
MainUtil.sendMessage(plr, C.WAS_NOT_ADDED);
|
||||||
|
return true;
|
||||||
|
}
|
||||||
plot.removeDenied(uuid);
|
plot.removeDenied(uuid);
|
||||||
DBFunc.removeDenied(loc.getWorld(), plot, uuid);
|
DBFunc.removeDenied(loc.getWorld(), plot, uuid);
|
||||||
EventUtil.manager.callDenied(plr, plot, uuid, false);
|
EventUtil.manager.callDenied(plr, plot, uuid, false);
|
||||||
|
@ -32,7 +32,7 @@ import com.intellectualcrafters.plot.flag.AbstractFlag;
|
|||||||
import com.intellectualcrafters.plot.flag.Flag;
|
import com.intellectualcrafters.plot.flag.Flag;
|
||||||
import com.intellectualcrafters.plot.flag.FlagManager;
|
import com.intellectualcrafters.plot.flag.FlagManager;
|
||||||
import com.intellectualcrafters.plot.flag.FlagValue;
|
import com.intellectualcrafters.plot.flag.FlagValue;
|
||||||
import com.intellectualcrafters.plot.listeners.PlotListener;
|
import com.intellectualcrafters.plot.listeners.APlotListener;
|
||||||
import com.intellectualcrafters.plot.object.Location;
|
import com.intellectualcrafters.plot.object.Location;
|
||||||
import com.intellectualcrafters.plot.object.Plot;
|
import com.intellectualcrafters.plot.object.Plot;
|
||||||
import com.intellectualcrafters.plot.object.PlotPlayer;
|
import com.intellectualcrafters.plot.object.PlotPlayer;
|
||||||
@ -93,7 +93,6 @@ public class FlagCmd extends SubCommand {
|
|||||||
MainUtil.sendMessage(player, C.FLAG_TYPE, af.value.getClass().getSimpleName());
|
MainUtil.sendMessage(player, C.FLAG_TYPE, af.value.getClass().getSimpleName());
|
||||||
// Flag type description
|
// Flag type description
|
||||||
MainUtil.sendMessage(player, C.FLAG_DESC, af.getValueDesc());
|
MainUtil.sendMessage(player, C.FLAG_DESC, af.getValueDesc());
|
||||||
MainUtil.sendMessage(player, "&cNot implemented.");
|
|
||||||
}
|
}
|
||||||
case "set": {
|
case "set": {
|
||||||
if (!Permissions.hasPermission(player, "plots.set.flag")) {
|
if (!Permissions.hasPermission(player, "plots.set.flag")) {
|
||||||
@ -126,7 +125,7 @@ public class FlagCmd extends SubCommand {
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
MainUtil.sendMessage(player, C.FLAG_ADDED);
|
MainUtil.sendMessage(player, C.FLAG_ADDED);
|
||||||
PlotListener.plotEntry(player, plot);
|
APlotListener.manager.plotEntry(player, plot);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
case "remove": {
|
case "remove": {
|
||||||
@ -164,7 +163,7 @@ public class FlagCmd extends SubCommand {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
MainUtil.sendMessage(player, C.FLAG_REMOVED);
|
MainUtil.sendMessage(player, C.FLAG_REMOVED);
|
||||||
PlotListener.plotEntry(player, plot);
|
APlotListener.manager.plotEntry(player, plot);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
case "add": {
|
case "add": {
|
||||||
@ -204,7 +203,7 @@ public class FlagCmd extends SubCommand {
|
|||||||
}
|
}
|
||||||
DBFunc.setFlags(plot.world, plot, plot.settings.flags);
|
DBFunc.setFlags(plot.world, plot, plot.settings.flags);
|
||||||
MainUtil.sendMessage(player, C.FLAG_ADDED);
|
MainUtil.sendMessage(player, C.FLAG_ADDED);
|
||||||
PlotListener.plotEntry(player, plot);
|
APlotListener.manager.plotEntry(player, plot);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
case "list": {
|
case "list": {
|
||||||
|
@ -20,6 +20,7 @@
|
|||||||
////////////////////////////////////////////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||||
package com.intellectualcrafters.plot.commands;
|
package com.intellectualcrafters.plot.commands;
|
||||||
|
|
||||||
|
import java.util.ArrayList;
|
||||||
import java.util.UUID;
|
import java.util.UUID;
|
||||||
|
|
||||||
import com.intellectualcrafters.plot.config.C;
|
import com.intellectualcrafters.plot.config.C;
|
||||||
@ -52,7 +53,7 @@ public class Helpers extends SubCommand {
|
|||||||
MainUtil.sendMessage(plr, C.PLOT_UNOWNED);
|
MainUtil.sendMessage(plr, C.PLOT_UNOWNED);
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
if (!plot.getOwner().equals(UUIDHandler.getUUID(plr)) && !Permissions.hasPermission(plr, "plots.admin.command.helpers")) {
|
if (!plot.isOwner(plr.getUUID()) && !Permissions.hasPermission(plr, "plots.admin.command.helpers")) {
|
||||||
MainUtil.sendMessage(plr, C.NO_PLOT_PERMS);
|
MainUtil.sendMessage(plr, C.NO_PLOT_PERMS);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
@ -68,7 +69,7 @@ public class Helpers extends SubCommand {
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
if (!plot.helpers.contains(uuid)) {
|
if (!plot.helpers.contains(uuid)) {
|
||||||
if (plot.owner.equals(uuid)) {
|
if (plot.isOwner(uuid)) {
|
||||||
MainUtil.sendMessage(plr, C.ALREADY_OWNER);
|
MainUtil.sendMessage(plr, C.ALREADY_OWNER);
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
@ -91,17 +92,22 @@ public class Helpers extends SubCommand {
|
|||||||
return true;
|
return true;
|
||||||
} else if (args[0].equalsIgnoreCase("remove")) {
|
} else if (args[0].equalsIgnoreCase("remove")) {
|
||||||
if (args[1].equalsIgnoreCase("*")) {
|
if (args[1].equalsIgnoreCase("*")) {
|
||||||
final UUID uuid = DBFunc.everyone;
|
if (plot.helpers.size() == 0) {
|
||||||
if (!plot.helpers.contains(uuid)) {
|
|
||||||
MainUtil.sendMessage(plr, C.WAS_NOT_ADDED);
|
MainUtil.sendMessage(plr, C.WAS_NOT_ADDED);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
plot.removeHelper(uuid);
|
for (UUID uuid : plot.helpers) {
|
||||||
DBFunc.removeHelper(loc.getWorld(), plot, uuid);
|
DBFunc.removeHelper(loc.getWorld(), plot, uuid);
|
||||||
|
}
|
||||||
|
plot.helpers = new ArrayList<>();
|
||||||
MainUtil.sendMessage(plr, C.HELPER_REMOVED);
|
MainUtil.sendMessage(plr, C.HELPER_REMOVED);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
final UUID uuid = UUIDHandler.getUUID(args[1]);
|
final UUID uuid = UUIDHandler.getUUID(args[1]);
|
||||||
|
if (!plot.helpers.contains(uuid)) {
|
||||||
|
MainUtil.sendMessage(plr, C.WAS_NOT_ADDED);
|
||||||
|
return false;
|
||||||
|
}
|
||||||
plot.removeHelper(uuid);
|
plot.removeHelper(uuid);
|
||||||
DBFunc.removeHelper(loc.getWorld(), plot, uuid);
|
DBFunc.removeHelper(loc.getWorld(), plot, uuid);
|
||||||
EventUtil.manager.callHelper(plr, plot, uuid, false);
|
EventUtil.manager.callHelper(plr, plot, uuid, false);
|
||||||
|
@ -20,12 +20,13 @@
|
|||||||
////////////////////////////////////////////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||||
package com.intellectualcrafters.plot.commands;
|
package com.intellectualcrafters.plot.commands;
|
||||||
|
|
||||||
|
import java.util.ArrayList;
|
||||||
|
|
||||||
import com.intellectualcrafters.plot.PlotSquared;
|
import com.intellectualcrafters.plot.PlotSquared;
|
||||||
import com.intellectualcrafters.plot.config.C;
|
import com.intellectualcrafters.plot.config.C;
|
||||||
import com.intellectualcrafters.plot.object.Plot;
|
import com.intellectualcrafters.plot.object.Plot;
|
||||||
import com.intellectualcrafters.plot.object.PlotPlayer;
|
import com.intellectualcrafters.plot.object.PlotPlayer;
|
||||||
import com.intellectualcrafters.plot.util.MainUtil;
|
import com.intellectualcrafters.plot.util.MainUtil;
|
||||||
import com.intellectualcrafters.plot.util.bukkit.UUIDHandler;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @author Citymonstret
|
* @author Citymonstret
|
||||||
@ -46,11 +47,11 @@ public class Home extends SubCommand {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean execute(final PlotPlayer plr, String... args) {
|
public boolean execute(final PlotPlayer plr, String... args) {
|
||||||
final Plot[] plots = PlotSquared.getPlots(plr).toArray(new Plot[0]);
|
final ArrayList<Plot> plots = PlotSquared.sortPlotsByWorld(PlotSquared.getPlots(plr));
|
||||||
if (plots.length == 1) {
|
if (plots.size() == 1) {
|
||||||
MainUtil.teleportPlayer(plr, plr.getLocation(), plots[0]);
|
MainUtil.teleportPlayer(plr, plr.getLocation(), plots.get(0));
|
||||||
return true;
|
return true;
|
||||||
} else if (plots.length > 1) {
|
} else if (plots.size() > 1) {
|
||||||
if (args.length < 1) {
|
if (args.length < 1) {
|
||||||
args = new String[] { "1" };
|
args = new String[] { "1" };
|
||||||
}
|
}
|
||||||
@ -61,7 +62,7 @@ public class Home extends SubCommand {
|
|||||||
Plot temp;
|
Plot temp;
|
||||||
if ((temp = isAlias(args[0])) != null) {
|
if ((temp = isAlias(args[0])) != null) {
|
||||||
if (temp.hasOwner()) {
|
if (temp.hasOwner()) {
|
||||||
if (temp.getOwner().equals(UUIDHandler.getUUID(plr))) {
|
if (temp.isOwner(plr.getUUID())) {
|
||||||
MainUtil.teleportPlayer(plr, plr.getLocation(), temp);
|
MainUtil.teleportPlayer(plr, plr.getLocation(), temp);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
@ -72,14 +73,14 @@ public class Home extends SubCommand {
|
|||||||
MainUtil.sendMessage(plr, C.NOT_VALID_NUMBER);
|
MainUtil.sendMessage(plr, C.NOT_VALID_NUMBER);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
if ((id > (plots.length)) || (id < 1)) {
|
if ((id > (plots.size())) || (id < 1)) {
|
||||||
MainUtil.sendMessage(plr, C.NOT_VALID_NUMBER);
|
MainUtil.sendMessage(plr, C.NOT_VALID_NUMBER);
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
MainUtil.teleportPlayer(plr, plr.getLocation(), plots[id - 1]);
|
MainUtil.teleportPlayer(plr, plr.getLocation(), plots.get(id - 1));
|
||||||
return true;
|
return true;
|
||||||
} else {
|
} else {
|
||||||
MainUtil.sendMessage(plr, C.NO_PLOTS);
|
MainUtil.sendMessage(plr, C.FOUND_NO_PLOTS);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -21,171 +21,189 @@
|
|||||||
package com.intellectualcrafters.plot.commands;
|
package com.intellectualcrafters.plot.commands;
|
||||||
|
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.Arrays;
|
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.UUID;
|
|
||||||
|
import org.apache.commons.lang.StringUtils;
|
||||||
|
|
||||||
import com.intellectualcrafters.plot.config.C;
|
import com.intellectualcrafters.plot.config.C;
|
||||||
import com.intellectualcrafters.plot.database.DBFunc;
|
|
||||||
import com.intellectualcrafters.plot.object.Location;
|
|
||||||
import com.intellectualcrafters.plot.object.Plot;
|
import com.intellectualcrafters.plot.object.Plot;
|
||||||
import com.intellectualcrafters.plot.object.PlotComment;
|
|
||||||
import com.intellectualcrafters.plot.object.PlotPlayer;
|
import com.intellectualcrafters.plot.object.PlotPlayer;
|
||||||
|
import com.intellectualcrafters.plot.object.RunnableVal;
|
||||||
|
import com.intellectualcrafters.plot.object.comment.CommentInbox;
|
||||||
|
import com.intellectualcrafters.plot.object.comment.CommentManager;
|
||||||
|
import com.intellectualcrafters.plot.object.comment.PlotComment;
|
||||||
import com.intellectualcrafters.plot.util.MainUtil;
|
import com.intellectualcrafters.plot.util.MainUtil;
|
||||||
import com.intellectualcrafters.plot.util.Permissions;
|
|
||||||
import com.intellectualcrafters.plot.util.TaskManager;
|
|
||||||
import com.intellectualcrafters.plot.util.bukkit.UUIDHandler;
|
|
||||||
|
|
||||||
public class Inbox extends SubCommand {
|
public class Inbox extends SubCommand {
|
||||||
public Inbox() {
|
public Inbox() {
|
||||||
super(Command.INBOX, "Review the comments for a plot", "inbox", CommandCategory.ACTIONS, true);
|
super(Command.INBOX, "Review the comments for a plot", "inbox [inbox] [delete <index>|clear|page]", CommandCategory.ACTIONS, true);
|
||||||
|
}
|
||||||
|
|
||||||
|
public void displayComments(PlotPlayer player, List<PlotComment> oldComments, int page) {
|
||||||
|
PlotComment[] comments = oldComments.toArray(new PlotComment[oldComments.size()]);
|
||||||
|
if (page < 0) {
|
||||||
|
page = 0;
|
||||||
|
}
|
||||||
|
// Get the total pages
|
||||||
|
// int totalPages = ((int) Math.ceil(12 *
|
||||||
|
final int totalPages = (int) Math.ceil(comments.length / 12);
|
||||||
|
if (page > totalPages) {
|
||||||
|
page = totalPages;
|
||||||
|
}
|
||||||
|
// Only display 12 per page
|
||||||
|
int max = (page * 12) + 12;
|
||||||
|
if (max > comments.length) {
|
||||||
|
max = comments.length;
|
||||||
|
}
|
||||||
|
final StringBuilder string = new StringBuilder();
|
||||||
|
string.append(C.PLOT_LIST_HEADER_PAGED.s().replaceAll("plot","comment").replaceAll("%cur", page + 1 + "").replaceAll("%max", totalPages + 1 + "").replaceAll("%word%", "all")).append("\n");
|
||||||
|
PlotComment c;
|
||||||
|
// This might work xD
|
||||||
|
for (int x = (page * 12); x < max; x++) {
|
||||||
|
c = comments[x];
|
||||||
|
String color;
|
||||||
|
if (player.getName().equals(c.senderName)) {
|
||||||
|
color = "&a";
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
color = "&7";
|
||||||
|
}
|
||||||
|
string.append("&8[&7#" + x + "&8][&7" + c.world + ";" + c.id + "&8][&6" + c.senderName + "&8]" + color + c.comment + "\n");
|
||||||
|
}
|
||||||
|
MainUtil.sendMessage(player, string.toString());
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean execute(final PlotPlayer plr, final String... args) {
|
public boolean execute(final PlotPlayer player, final String... args) {
|
||||||
boolean report = false;
|
final Plot plot = MainUtil.getPlot(player.getLocation());
|
||||||
if (args.length == 1) {
|
if (args.length == 0) {
|
||||||
if (args[0].equalsIgnoreCase("reports")) {
|
sendMessage(player, C.COMMAND_SYNTAX, "/plot inbox [inbox] [delete <index>|clear|page]");
|
||||||
report = true;
|
for (final CommentInbox inbox : CommentManager.inboxes.values()) {
|
||||||
|
if (inbox.canRead(plot, player)) {
|
||||||
|
if (!inbox.getComments(plot, new RunnableVal() {
|
||||||
|
@Override
|
||||||
|
public void run() {
|
||||||
|
if (value != null) {
|
||||||
|
int total = 0;
|
||||||
|
int unread = 0;
|
||||||
|
for (PlotComment comment : (ArrayList<PlotComment>) value) {
|
||||||
|
total++;
|
||||||
|
if (comment.timestamp > player.getPreviousLogin()) {
|
||||||
|
unread++;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (total != 0) {
|
||||||
|
String color;
|
||||||
|
if (unread > 0) {
|
||||||
|
color = "&c";
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
color = "";
|
||||||
|
}
|
||||||
|
sendMessage(player, C.INBOX_ITEM, color + inbox.toString() + " (" + total + "/" + unread + ")");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
sendMessage(player, C.INBOX_ITEM, inbox.toString());
|
||||||
|
}
|
||||||
|
})) {
|
||||||
|
sendMessage(player, C.INBOX_ITEM, inbox.toString());
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
final Location loc = plr.getLocation();
|
|
||||||
final Plot plot = MainUtil.getPlot(loc);
|
|
||||||
if ((plot == null) && !report) {
|
|
||||||
return !sendMessage(plr, C.NOT_IN_PLOT);
|
|
||||||
}
|
|
||||||
if ((plot != null) && !plot.hasOwner()) {
|
|
||||||
MainUtil.sendMessage(plr, C.NOT_IN_PLOT);
|
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
Integer tier;
|
final CommentInbox inbox = CommentManager.inboxes.get(args[0].toLowerCase());
|
||||||
final UUID uuid = UUIDHandler.getUUID(plr);
|
if (inbox == null) {
|
||||||
if (Permissions.hasPermission(plr, "plots.comment.admin")) {
|
sendMessage(player, C.INVALID_INBOX, StringUtils.join(CommentManager.inboxes.keySet(),", "));
|
||||||
tier = 0;
|
return false;
|
||||||
} else if ((plot != null) && plot.owner.equals(uuid)) {
|
|
||||||
tier = 1;
|
|
||||||
} else if ((plot != null) && plot.helpers.contains(uuid)) {
|
|
||||||
tier = 2;
|
|
||||||
} else if ((plot != null) && plot.trusted.contains(uuid)) {
|
|
||||||
tier = 3;
|
|
||||||
} else {
|
|
||||||
tier = 4;
|
|
||||||
}
|
}
|
||||||
final boolean below;
|
final int page;
|
||||||
if (args.length > 0) {
|
if (args.length > 1) {
|
||||||
below = false;
|
switch (args[1].toLowerCase()) {
|
||||||
switch (args[0].toLowerCase()) {
|
case "delete": {
|
||||||
case "admin":
|
if (!inbox.canModify(plot, player)) {
|
||||||
if (tier <= 0) {
|
sendMessage(player, C.NO_PERM_INBOX_MODIFY);
|
||||||
tier = 0;
|
|
||||||
} else {
|
|
||||||
MainUtil.sendMessage(plr, C.NO_PERMISSION, "plots.inbox.admin");
|
|
||||||
return false;
|
|
||||||
}
|
}
|
||||||
break;
|
if (args.length != 3) {
|
||||||
case "owner":
|
sendMessage(player, C.COMMAND_SYNTAX, "/plot inbox " + inbox.toString() + " delete <index>");
|
||||||
if (tier <= 1) {
|
|
||||||
tier = 1;
|
|
||||||
} else {
|
|
||||||
MainUtil.sendMessage(plr, C.NO_PERMISSION, "plots.inbox.owner");
|
|
||||||
return false;
|
|
||||||
}
|
}
|
||||||
break;
|
final int index;
|
||||||
case "helper":
|
try {
|
||||||
if (tier <= 2) {
|
index = Integer.parseInt(args[2]);
|
||||||
tier = 2;
|
if (index < 1) {
|
||||||
} else {
|
sendMessage(player, C.NOT_VALID_INBOX_INDEX, index + "");
|
||||||
MainUtil.sendMessage(plr, C.NO_PERMISSION, "plots.inbox.helper");
|
return false;
|
||||||
return false;
|
|
||||||
}
|
|
||||||
break;
|
|
||||||
case "trusted":
|
|
||||||
if (tier <= 3) {
|
|
||||||
tier = 3;
|
|
||||||
} else {
|
|
||||||
MainUtil.sendMessage(plr, C.NO_PERMISSION, "plots.inbox.trusted");
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
break;
|
|
||||||
case "everyone":
|
|
||||||
if (tier <= 4) {
|
|
||||||
tier = 4;
|
|
||||||
} else {
|
|
||||||
MainUtil.sendMessage(plr, C.NO_PERMISSION, "plots.inbox.everyone");
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
break;
|
|
||||||
case "reports":
|
|
||||||
if (tier <= 0) {
|
|
||||||
tier = -1;
|
|
||||||
} else {
|
|
||||||
MainUtil.sendMessage(plr, C.NO_PERMISSION, "plots.inbox.admin");
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
break;
|
|
||||||
default:
|
|
||||||
MainUtil.sendMessage(plr, C.INVALID_INBOX, Arrays.copyOfRange(new String[] { "admin", "owner", "helper", "trusted", "everyone" }, Math.max(0, tier), 4));
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
below = true;
|
|
||||||
}
|
|
||||||
final String world = loc.getWorld();
|
|
||||||
final int tier2 = tier;
|
|
||||||
TaskManager.runTaskAsync(new Runnable() {
|
|
||||||
@Override
|
|
||||||
public void run() {
|
|
||||||
ArrayList<PlotComment> comments = null;
|
|
||||||
if (tier2 == -1) {
|
|
||||||
comments = DBFunc.getComments(world, null, 0, false);
|
|
||||||
} else {
|
|
||||||
comments = plot.settings.getComments(tier2);
|
|
||||||
}
|
|
||||||
if (comments == null) {
|
|
||||||
comments = DBFunc.getComments(world, plot, tier2, below);
|
|
||||||
plot.settings.setComments(comments);
|
|
||||||
}
|
|
||||||
if (args.length == 2) {
|
|
||||||
final String[] split = args[1].toLowerCase().split(":");
|
|
||||||
if (!split[0].equals("clear")) {
|
|
||||||
MainUtil.sendMessage(plr, "&c/plot inbox [tier] [clear][:#]");
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
if (split.length > 1) {
|
|
||||||
try {
|
|
||||||
final int index = Integer.parseInt(split[1]);
|
|
||||||
final PlotComment comment = comments.get(index - 1);
|
|
||||||
DBFunc.removeComment(world, plot, comment);
|
|
||||||
plot.settings.removeComment(comment);
|
|
||||||
MainUtil.sendMessage(plr, C.COMMENT_REMOVED, "1 comment");
|
|
||||||
return;
|
|
||||||
} catch (final Exception e) {
|
|
||||||
MainUtil.sendMessage(plr, "&cInvalid index:\n/plot inbox [tier] [clear][:#]");
|
|
||||||
return;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
for (final PlotComment comment : comments) {
|
catch (NumberFormatException e) {
|
||||||
DBFunc.removeComment(world, plot, comment);
|
sendMessage(player, C.COMMAND_SYNTAX, "/plot inbox " + inbox.toString() + " delete <index>");
|
||||||
|
return false;
|
||||||
}
|
}
|
||||||
plot.settings.removeComments(comments);
|
|
||||||
MainUtil.sendMessage(plr, C.COMMENT_REMOVED, "all comments in that category");
|
if (!inbox.getComments(plot, new RunnableVal() {
|
||||||
} else {
|
@Override
|
||||||
final List<String> recipients = Arrays.asList("A", "O", "H", "T", "E");
|
public void run() {
|
||||||
int count = 1;
|
List<PlotComment> comments = (List<PlotComment>) value;
|
||||||
final StringBuilder message = new StringBuilder();
|
if (index > comments.size()) {
|
||||||
String prefix = "";
|
sendMessage(player, C.NOT_VALID_INBOX_INDEX, index + "");
|
||||||
for (final PlotComment comment : comments) {
|
}
|
||||||
message.append(prefix).append("&c[").append(count).append("]&6[").append(recipients.get(tier2 == -1 ? 0 : tier2)).append("] &7").append(comment.senderName).append("&f: ").append(comment.comment);
|
PlotComment comment = comments.get(index - 1);
|
||||||
prefix = "\n" + C.PREFIX;
|
inbox.removeComment(plot, comment);
|
||||||
count++;
|
plot.settings.removeComment(comment);
|
||||||
|
MainUtil.sendMessage(player, C.COMMENT_REMOVED, comment.comment);
|
||||||
|
}
|
||||||
|
})) {
|
||||||
|
sendMessage(player, C.NOT_IN_PLOT);
|
||||||
|
return false;
|
||||||
}
|
}
|
||||||
if (comments.size() == 0) {
|
return true;
|
||||||
message.append("&cNo messages.");
|
}
|
||||||
|
case "clear": {
|
||||||
|
if (!inbox.canModify(plot, player)) {
|
||||||
|
sendMessage(player, C.NO_PERM_INBOX_MODIFY);
|
||||||
}
|
}
|
||||||
MainUtil.sendMessage(plr, message.toString());
|
inbox.clearInbox(plot);
|
||||||
|
ArrayList<PlotComment> comments = plot.settings.getComments(inbox.toString());
|
||||||
|
if (comments != null) {
|
||||||
|
plot.settings.removeComments(comments);
|
||||||
|
}
|
||||||
|
MainUtil.sendMessage(player, C.COMMENT_REMOVED, "*");
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
default: {
|
||||||
|
try {
|
||||||
|
page = Integer.parseInt(args[1]) ;
|
||||||
|
}
|
||||||
|
catch (NumberFormatException e) {
|
||||||
|
sendMessage(player, C.COMMAND_SYNTAX, "/plot inbox [inbox] [delete <index>|clear|page]");
|
||||||
|
return false;
|
||||||
|
};
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
});
|
}
|
||||||
|
else {
|
||||||
|
page = 1;
|
||||||
|
}
|
||||||
|
if (!inbox.canRead(plot, player)) {
|
||||||
|
sendMessage(player, C.NO_PERM_INBOX);
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
if (!inbox.getComments(plot, new RunnableVal() {
|
||||||
|
@Override
|
||||||
|
public void run() {
|
||||||
|
List<PlotComment> comments = (List<PlotComment>) value;
|
||||||
|
displayComments(player, comments, page);
|
||||||
|
}
|
||||||
|
})) {
|
||||||
|
if (plot == null) {
|
||||||
|
sendMessage(player, C.NOT_IN_PLOT);
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
sendMessage(player, C.PLOT_UNOWNED);
|
||||||
|
}
|
||||||
|
return false;
|
||||||
|
}
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -21,7 +21,9 @@
|
|||||||
package com.intellectualcrafters.plot.commands;
|
package com.intellectualcrafters.plot.commands;
|
||||||
|
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
|
import java.util.Collection;
|
||||||
import java.util.UUID;
|
import java.util.UUID;
|
||||||
|
import java.util.regex.Matcher;
|
||||||
|
|
||||||
import org.apache.commons.lang.StringUtils;
|
import org.apache.commons.lang.StringUtils;
|
||||||
|
|
||||||
@ -110,11 +112,11 @@ public class Info extends SubCommand {
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
String owner = "none";
|
String owner = "none";
|
||||||
if (plot.owner != null) {
|
if (plot.owner == null) {
|
||||||
owner = UUIDHandler.getName(plot.owner);
|
owner = "unowned";
|
||||||
}
|
}
|
||||||
if (owner == null) {
|
else {
|
||||||
owner = plot.owner.toString();
|
owner = getPlayerList(plot.getOwners());
|
||||||
}
|
}
|
||||||
String info = C.PLOT_INFO.s();
|
String info = C.PLOT_INFO.s();
|
||||||
if (args.length == 1) {
|
if (args.length == 1) {
|
||||||
@ -162,7 +164,9 @@ public class Info extends SubCommand {
|
|||||||
final PlotId id2 = MainUtil.getTopPlot(plot).id;
|
final PlotId id2 = MainUtil.getTopPlot(plot).id;
|
||||||
final int num = MainUtil.getPlotSelectionIds(id, id2).size();
|
final int num = MainUtil.getPlotSelectionIds(id, id2).size();
|
||||||
final String alias = plot.settings.getAlias().length() > 0 ? plot.settings.getAlias() : "none";
|
final String alias = plot.settings.getAlias().length() > 0 ? plot.settings.getAlias() : "none";
|
||||||
final String biome = BlockManager.manager.getBiome(MainUtil.getPlotBottomLoc(world, plot.id).add(1, 0, 1));
|
Location top = MainUtil.getPlotTopLoc(world, plot.id);
|
||||||
|
Location bot = MainUtil.getPlotBottomLoc(world, plot.id).add(1,0,1);
|
||||||
|
final String biome = BlockManager.manager.getBiome(bot.add((top.getX() - bot.getX()) / 2, 0, (top.getX() - bot.getX()) / 2));
|
||||||
final String helpers = getPlayerList(plot.helpers);
|
final String helpers = getPlayerList(plot.helpers);
|
||||||
final String trusted = getPlayerList(plot.trusted);
|
final String trusted = getPlayerList(plot.trusted);
|
||||||
final String denied = getPlayerList(plot.denied);
|
final String denied = getPlayerList(plot.denied);
|
||||||
@ -170,11 +174,11 @@ public class Info extends SubCommand {
|
|||||||
final String flags = "&6" + (StringUtils.join(FlagManager.getPlotFlags(plot), "").length() > 0 ? StringUtils.join(FlagManager.getPlotFlags(plot), "&7, &6") : "none");
|
final String flags = "&6" + (StringUtils.join(FlagManager.getPlotFlags(plot), "").length() > 0 ? StringUtils.join(FlagManager.getPlotFlags(plot), "&7, &6") : "none");
|
||||||
final boolean build = (player == null) || plot.isAdded(player.getUUID());
|
final boolean build = (player == null) || plot.isAdded(player.getUUID());
|
||||||
String owner = "none";
|
String owner = "none";
|
||||||
if (plot.owner != null) {
|
if (plot.owner == null) {
|
||||||
owner = UUIDHandler.getName(plot.owner);
|
owner = "unowned";
|
||||||
}
|
}
|
||||||
if (owner == null) {
|
else {
|
||||||
owner = plot.owner.toString();
|
owner = getPlayerList(plot.getOwners());
|
||||||
}
|
}
|
||||||
info = info.replaceAll("%alias%", alias);
|
info = info.replaceAll("%alias%", alias);
|
||||||
info = info.replaceAll("%id%", id.toString());
|
info = info.replaceAll("%id%", id.toString());
|
||||||
@ -186,13 +190,14 @@ public class Info extends SubCommand {
|
|||||||
info = info.replaceAll("%trusted%", trusted);
|
info = info.replaceAll("%trusted%", trusted);
|
||||||
info = info.replaceAll("%denied%", denied);
|
info = info.replaceAll("%denied%", denied);
|
||||||
info = info.replaceAll("%rating%", rating);
|
info = info.replaceAll("%rating%", rating);
|
||||||
info = info.replaceAll("%flags%", flags);
|
info = info.replaceAll("%flags%", Matcher.quoteReplacement(flags));
|
||||||
info = info.replaceAll("%build%", build + "");
|
info = info.replaceAll("%build%", build + "");
|
||||||
info = info.replaceAll("%desc%", "No description set.");
|
info = info.replaceAll("%desc%", "No description set.");
|
||||||
return info;
|
return info;
|
||||||
}
|
}
|
||||||
|
|
||||||
private String getPlayerList(final ArrayList<UUID> l) {
|
private String getPlayerList(final Collection<UUID> uuids) {
|
||||||
|
ArrayList<UUID> l = new ArrayList<>(uuids);
|
||||||
if ((l == null) || (l.size() < 1)) {
|
if ((l == null) || (l.size() < 1)) {
|
||||||
return " none";
|
return " none";
|
||||||
}
|
}
|
||||||
|
@ -42,7 +42,7 @@ public class Kick extends SubCommand {
|
|||||||
if (plot == null) {
|
if (plot == null) {
|
||||||
return !sendMessage(plr, C.NOT_IN_PLOT);
|
return !sendMessage(plr, C.NOT_IN_PLOT);
|
||||||
}
|
}
|
||||||
if (((plot == null) || !plot.hasOwner() || !plot.getOwner().equals(UUIDHandler.getUUID(plr))) && !Permissions.hasPermission(plr, "plots.admin.command.kick")) {
|
if (plot == null || ((!plot.hasOwner() || !plot.isOwner(plr.getUUID())) && !Permissions.hasPermission(plr, "plots.admin.command.kick"))) {
|
||||||
MainUtil.sendMessage(plr, C.NO_PLOT_PERMS);
|
MainUtil.sendMessage(plr, C.NO_PLOT_PERMS);
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
@ -55,8 +55,9 @@ public class Kick extends SubCommand {
|
|||||||
MainUtil.sendMessage(plr, C.INVALID_PLAYER, args[0]);
|
MainUtil.sendMessage(plr, C.INVALID_PLAYER, args[0]);
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
if (!player.getLocation().getWorld().equals(loc.getWorld()) || !plot.equals(MainUtil.getPlot(loc))) {
|
Location otherLoc = player.getLocation();
|
||||||
MainUtil.sendMessage(plr, C.INVALID_PLAYER.s().replaceAll("%player%", args[0]));
|
if (!plr.getLocation().getWorld().equals(otherLoc.getWorld()) || !plot.equals(MainUtil.getPlot(otherLoc))) {
|
||||||
|
MainUtil.sendMessage(plr, C.INVALID_PLAYER, args[0]);
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
player.teleport(BlockManager.manager.getSpawn(loc.getWorld()));
|
player.teleport(BlockManager.manager.getSpawn(loc.getWorld()));
|
||||||
|
@ -40,7 +40,7 @@ public class MainCommand {
|
|||||||
/**
|
/**
|
||||||
* Main Permission Node
|
* Main Permission Node
|
||||||
*/
|
*/
|
||||||
private final static SubCommand[] _subCommands = new SubCommand[] { new Template(), new Setup(), new DebugSaveTest(), new DebugLoadTest(), new CreateRoadSchematic(), new RegenAllRoads(), new DebugClear(), new Claim(), new Auto(), new Home(), new Visit(), new TP(), new Set(), new Clear(), new Delete(), new SetOwner(), new Denied(), new Helpers(), new Trusted(), new Info(), new list(), new Help(), new Debug(), new SchematicCmd(), new plugin(), new Inventory(), new Purge(), new Reload(), new Merge(), new Unlink(), new Kick(), new Rate(), new DebugClaimTest(), new Inbox(), new Comment(), new Database(), new Unclaim(), new Swap(), new MusicSubcommand(), new DebugRoadRegen(), new Trim(), new DebugExec(), new FlagCmd(), new Target(), new DebugFixFlags(), new Move(), new Condense(), new Confirm() };
|
private final static SubCommand[] _subCommands = new SubCommand[] { };
|
||||||
public final static ArrayList<SubCommand> subCommands = new ArrayList<SubCommand>() {
|
public final static ArrayList<SubCommand> subCommands = new ArrayList<SubCommand>() {
|
||||||
{
|
{
|
||||||
addAll(Arrays.asList(_subCommands));
|
addAll(Arrays.asList(_subCommands));
|
||||||
|
@ -21,6 +21,8 @@
|
|||||||
package com.intellectualcrafters.plot.commands;
|
package com.intellectualcrafters.plot.commands;
|
||||||
|
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
|
import java.util.HashSet;
|
||||||
|
import java.util.UUID;
|
||||||
|
|
||||||
import org.apache.commons.lang.StringUtils;
|
import org.apache.commons.lang.StringUtils;
|
||||||
|
|
||||||
@ -31,6 +33,7 @@ import com.intellectualcrafters.plot.object.Plot;
|
|||||||
import com.intellectualcrafters.plot.object.PlotId;
|
import com.intellectualcrafters.plot.object.PlotId;
|
||||||
import com.intellectualcrafters.plot.object.PlotPlayer;
|
import com.intellectualcrafters.plot.object.PlotPlayer;
|
||||||
import com.intellectualcrafters.plot.object.PlotWorld;
|
import com.intellectualcrafters.plot.object.PlotWorld;
|
||||||
|
import com.intellectualcrafters.plot.util.CmdConfirm;
|
||||||
import com.intellectualcrafters.plot.util.EconHandler;
|
import com.intellectualcrafters.plot.util.EconHandler;
|
||||||
import com.intellectualcrafters.plot.util.EventUtil;
|
import com.intellectualcrafters.plot.util.EventUtil;
|
||||||
import com.intellectualcrafters.plot.util.MainUtil;
|
import com.intellectualcrafters.plot.util.MainUtil;
|
||||||
@ -82,7 +85,7 @@ public class Merge extends SubCommand {
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
final boolean admin = Permissions.hasPermission(plr, "plots.admin.command.merge");
|
final boolean admin = Permissions.hasPermission(plr, "plots.admin.command.merge");
|
||||||
if (!plot.getOwner().equals(UUIDHandler.getUUID(plr)) && !admin) {
|
if (!plot.isOwner(plr.getUUID()) && !admin) {
|
||||||
MainUtil.sendMessage(plr, C.NO_PLOT_PERMS);
|
MainUtil.sendMessage(plr, C.NO_PLOT_PERMS);
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
@ -105,39 +108,98 @@ public class Merge extends SubCommand {
|
|||||||
}
|
}
|
||||||
PlotId bot = MainUtil.getBottomPlot(plot).id;
|
PlotId bot = MainUtil.getBottomPlot(plot).id;
|
||||||
PlotId top = MainUtil.getTopPlot(plot).id;
|
PlotId top = MainUtil.getTopPlot(plot).id;
|
||||||
ArrayList<PlotId> plots;
|
ArrayList<PlotId> selPlots;
|
||||||
final String world = loc.getWorld();
|
final String world = loc.getWorld();
|
||||||
switch (direction) {
|
switch (direction) {
|
||||||
case 0: // north = -y
|
case 0: // north = -y
|
||||||
plots = MainUtil.getMaxPlotSelectionIds(world, new PlotId(bot.x, bot.y - 1), new PlotId(top.x, top.y));
|
selPlots = MainUtil.getMaxPlotSelectionIds(world, new PlotId(bot.x, bot.y - 1), new PlotId(top.x, top.y));
|
||||||
break;
|
break;
|
||||||
case 1: // east = +x
|
case 1: // east = +x
|
||||||
plots = MainUtil.getMaxPlotSelectionIds(world, new PlotId(bot.x, bot.y), new PlotId(top.x + 1, top.y));
|
selPlots = MainUtil.getMaxPlotSelectionIds(world, new PlotId(bot.x, bot.y), new PlotId(top.x + 1, top.y));
|
||||||
break;
|
break;
|
||||||
case 2: // south = +y
|
case 2: // south = +y
|
||||||
plots = MainUtil.getMaxPlotSelectionIds(world, new PlotId(bot.x, bot.y), new PlotId(top.x, top.y + 1));
|
selPlots = MainUtil.getMaxPlotSelectionIds(world, new PlotId(bot.x, bot.y), new PlotId(top.x, top.y + 1));
|
||||||
break;
|
break;
|
||||||
case 3: // west = -x
|
case 3: // west = -x
|
||||||
plots = MainUtil.getMaxPlotSelectionIds(world, new PlotId(bot.x - 1, bot.y), new PlotId(top.x, top.y));
|
selPlots = MainUtil.getMaxPlotSelectionIds(world, new PlotId(bot.x - 1, bot.y), new PlotId(top.x, top.y));
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
final PlotId botId = plots.get(0);
|
final PlotId botId = selPlots.get(0);
|
||||||
final PlotId topId = plots.get(plots.size() - 1);
|
final PlotId topId = selPlots.get(selPlots.size() - 1);
|
||||||
final PlotId bot1 = MainUtil.getBottomPlot(MainUtil.getPlot(world, botId)).id;
|
final PlotId bot1 = MainUtil.getBottomPlot(MainUtil.getPlot(world, botId)).id;
|
||||||
final PlotId bot2 = MainUtil.getBottomPlot(MainUtil.getPlot(world, topId)).id;
|
final PlotId bot2 = MainUtil.getBottomPlot(MainUtil.getPlot(world, topId)).id;
|
||||||
final PlotId top1 = MainUtil.getTopPlot(MainUtil.getPlot(world, topId)).id;
|
final PlotId top1 = MainUtil.getTopPlot(MainUtil.getPlot(world, topId)).id;
|
||||||
final PlotId top2 = MainUtil.getTopPlot(MainUtil.getPlot(world, botId)).id;
|
final PlotId top2 = MainUtil.getTopPlot(MainUtil.getPlot(world, botId)).id;
|
||||||
bot = new PlotId(Math.min(bot1.x, bot2.x), Math.min(bot1.y, bot2.y));
|
bot = new PlotId(Math.min(bot1.x, bot2.x), Math.min(bot1.y, bot2.y));
|
||||||
top = new PlotId(Math.max(top1.x, top2.x), Math.max(top1.y, top2.y));
|
top = new PlotId(Math.max(top1.x, top2.x), Math.max(top1.y, top2.y));
|
||||||
plots = MainUtil.getMaxPlotSelectionIds(world, bot, top);
|
final ArrayList<PlotId> plots = MainUtil.getMaxPlotSelectionIds(world, bot, top);
|
||||||
|
boolean multiMerge = false;
|
||||||
|
final HashSet<UUID> multiUUID = new HashSet<UUID>();
|
||||||
|
HashSet<PlotId> multiPlots = new HashSet<>();
|
||||||
|
final UUID u1 = plot.owner;
|
||||||
for (final PlotId myid : plots) {
|
for (final PlotId myid : plots) {
|
||||||
final Plot myplot = PlotSquared.getPlots(world).get(myid);
|
final Plot myplot = PlotSquared.getPlots(world).get(myid);
|
||||||
if ((myplot == null) || !myplot.hasOwner() || !(myplot.getOwner().equals(UUIDHandler.getUUID(plr)) || admin)) {
|
if (myplot == null || myplot.owner == null) {
|
||||||
MainUtil.sendMessage(plr, C.NO_PERM_MERGE.s().replaceAll("%plot%", myid.toString()));
|
MainUtil.sendMessage(plr, C.NO_PERM_MERGE.s().replaceAll("%plot%", myid.toString()));
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
UUID u2 = myplot.owner;
|
||||||
|
if (u2.equals(u1)) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
PlotPlayer p2 = UUIDHandler.getPlayer(u2);
|
||||||
|
if (p2 == null) {
|
||||||
|
MainUtil.sendMessage(plr, C.NO_PERM_MERGE.s().replaceAll("%plot%", myid.toString()));
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
multiMerge = true;
|
||||||
|
multiPlots.add(myid);
|
||||||
|
multiUUID.add(u2);
|
||||||
|
}
|
||||||
|
if (multiMerge) {
|
||||||
|
for (final UUID uuid : multiUUID) {
|
||||||
|
PlotPlayer accepter = UUIDHandler.getPlayer(uuid);
|
||||||
|
CmdConfirm.addPending(accepter, C.MERGE_REQUEST_CONFIRM.s().replaceAll("%s", plr.getName()), new Runnable() {
|
||||||
|
@Override
|
||||||
|
public void run() {
|
||||||
|
PlotPlayer accepter = UUIDHandler.getPlayer(uuid);
|
||||||
|
multiUUID.remove(uuid);
|
||||||
|
if (multiUUID.size() == 0) {
|
||||||
|
PlotPlayer pp = UUIDHandler.getPlayer(u1);
|
||||||
|
if (pp == null) {
|
||||||
|
sendMessage(accepter, C.MERGE_NOT_VALID);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
final PlotWorld plotWorld = PlotSquared.getPlotWorld(world);
|
||||||
|
if ((PlotSquared.economy != null) && plotWorld.USE_ECONOMY) {
|
||||||
|
double cost = plotWorld.MERGE_PRICE;
|
||||||
|
cost = plots.size() * cost;
|
||||||
|
if (cost > 0d) {
|
||||||
|
if (EconHandler.getBalance(plr) < cost) {
|
||||||
|
sendMessage(plr, C.CANNOT_AFFORD_MERGE, cost + "");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
EconHandler.withdrawPlayer(plr, cost);
|
||||||
|
sendMessage(plr, C.REMOVED_BALANCE, cost + "");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
final boolean result = EventUtil.manager.callMerge(world, plot, plots);
|
||||||
|
if (!result) {
|
||||||
|
MainUtil.sendMessage(plr, "&cMerge has been cancelled");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
MainUtil.sendMessage(plr, C.SUCCESS_MERGE);
|
||||||
|
MainUtil.mergePlots(world, plots, true);
|
||||||
|
MainUtil.setSign(UUIDHandler.getName(plot.owner), plot);
|
||||||
|
}
|
||||||
|
MainUtil.sendMessage(accepter, C.MERGE_ACCEPTED);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
MainUtil.sendMessage(plr, C.MERGE_REQUESTED);
|
||||||
|
return true;
|
||||||
}
|
}
|
||||||
final PlotWorld plotWorld = PlotSquared.getPlotWorld(world);
|
final PlotWorld plotWorld = PlotSquared.getPlotWorld(world);
|
||||||
if ((PlotSquared.economy != null) && plotWorld.USE_ECONOMY) {
|
if ((PlotSquared.economy != null) && plotWorld.USE_ECONOMY) {
|
||||||
@ -157,10 +219,9 @@ public class Merge extends SubCommand {
|
|||||||
MainUtil.sendMessage(plr, "&cMerge has been cancelled");
|
MainUtil.sendMessage(plr, "&cMerge has been cancelled");
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
MainUtil.sendMessage(plr, "&cPlots have been merged");
|
MainUtil.sendMessage(plr, C.SUCCESS_MERGE);
|
||||||
MainUtil.mergePlots(world, plots, true);
|
MainUtil.mergePlots(world, plots, true);
|
||||||
MainUtil.setSign(UUIDHandler.getName(plot.owner), plot);
|
MainUtil.setSign(UUIDHandler.getName(plot.owner), plot);
|
||||||
MainUtil.update(loc);
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -20,11 +20,13 @@
|
|||||||
////////////////////////////////////////////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||||
package com.intellectualcrafters.plot.commands;
|
package com.intellectualcrafters.plot.commands;
|
||||||
|
|
||||||
|
import com.intellectualcrafters.plot.PlotSquared;
|
||||||
import com.intellectualcrafters.plot.config.C;
|
import com.intellectualcrafters.plot.config.C;
|
||||||
import com.intellectualcrafters.plot.object.Location;
|
import com.intellectualcrafters.plot.object.Location;
|
||||||
import com.intellectualcrafters.plot.object.Plot;
|
import com.intellectualcrafters.plot.object.Plot;
|
||||||
import com.intellectualcrafters.plot.object.PlotId;
|
import com.intellectualcrafters.plot.object.PlotId;
|
||||||
import com.intellectualcrafters.plot.object.PlotPlayer;
|
import com.intellectualcrafters.plot.object.PlotPlayer;
|
||||||
|
import com.intellectualcrafters.plot.object.PlotWorld;
|
||||||
import com.intellectualcrafters.plot.util.MainUtil;
|
import com.intellectualcrafters.plot.util.MainUtil;
|
||||||
import com.intellectualcrafters.plot.util.Permissions;
|
import com.intellectualcrafters.plot.util.Permissions;
|
||||||
|
|
||||||
@ -35,7 +37,7 @@ import com.intellectualcrafters.plot.util.Permissions;
|
|||||||
*/
|
*/
|
||||||
public class Move extends SubCommand {
|
public class Move extends SubCommand {
|
||||||
public Move() {
|
public Move() {
|
||||||
super("debugmove", "plots.move", "Move a plot", "move", "", CommandCategory.ACTIONS, true);
|
super(Command.MOVE, "Move a plot", "debugmove", CommandCategory.ACTIONS, true);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@ -55,18 +57,33 @@ public class Move extends SubCommand {
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
final String world = loc.getWorld();
|
final String world = loc.getWorld();
|
||||||
final PlotId plot2 = MainUtil.parseId(args[1]);
|
final PlotId plot2id = MainUtil.parseId(args[0]);
|
||||||
if ((plot2 == null)) {
|
if ((plot2id == null)) {
|
||||||
MainUtil.sendMessage(plr, C.NOT_VALID_PLOT_ID);
|
MainUtil.sendMessage(plr, C.NOT_VALID_PLOT_ID);
|
||||||
MainUtil.sendMessage(plr, C.COMMAND_SYNTAX, "/plot move <X;Z>");
|
MainUtil.sendMessage(plr, C.COMMAND_SYNTAX, "/plot move <X;Z>");
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
if (plot1.id.equals(plot2)) {
|
String world2;
|
||||||
|
if (args.length == 2) {
|
||||||
|
PlotWorld other = PlotSquared.getPlotWorld(args[1]);
|
||||||
|
PlotWorld current = PlotSquared.getPlotWorld(loc.getWorld());
|
||||||
|
if (other == null || current == null || !other.equals(current)) {
|
||||||
|
MainUtil.sendMessage(plr, C.PLOTWORLD_INCOMPATIBLE);
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
world2 = other.worldname;
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
world2 = world;
|
||||||
|
}
|
||||||
|
Plot plot2 = MainUtil.getPlot(world2, plot2id);
|
||||||
|
|
||||||
|
if (plot1.equals(plot2)) {
|
||||||
MainUtil.sendMessage(plr, C.NOT_VALID_PLOT_ID);
|
MainUtil.sendMessage(plr, C.NOT_VALID_PLOT_ID);
|
||||||
MainUtil.sendMessage(plr, C.COMMAND_SYNTAX, "/plot move <X;Z>");
|
MainUtil.sendMessage(plr, C.COMMAND_SYNTAX, "/plot move <X;Z>");
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
if (MainUtil.move(world, plot1.id, plot2, new Runnable() {
|
if (MainUtil.move(plot1, plot2, new Runnable() {
|
||||||
@Override
|
@Override
|
||||||
public void run() {
|
public void run() {
|
||||||
MainUtil.sendMessage(plr, C.MOVE_SUCCESS);
|
MainUtil.sendMessage(plr, C.MOVE_SUCCESS);
|
||||||
|
@ -31,7 +31,6 @@ import com.intellectualcrafters.plot.database.DBFunc;
|
|||||||
import com.intellectualcrafters.plot.object.Plot;
|
import com.intellectualcrafters.plot.object.Plot;
|
||||||
import com.intellectualcrafters.plot.object.PlotId;
|
import com.intellectualcrafters.plot.object.PlotId;
|
||||||
import com.intellectualcrafters.plot.object.PlotPlayer;
|
import com.intellectualcrafters.plot.object.PlotPlayer;
|
||||||
import com.intellectualcrafters.plot.util.BlockManager;
|
|
||||||
import com.intellectualcrafters.plot.util.MainUtil;
|
import com.intellectualcrafters.plot.util.MainUtil;
|
||||||
import com.intellectualcrafters.plot.util.bukkit.UUIDHandler;
|
import com.intellectualcrafters.plot.util.bukkit.UUIDHandler;
|
||||||
|
|
||||||
@ -92,7 +91,7 @@ public class Purge extends SubCommand {
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
final String worldname = args[1];
|
final String worldname = args[1];
|
||||||
if (!BlockManager.manager.isWorld(worldname) || !PlotSquared.isPlotWorld(worldname)) {
|
if (!PlotSquared.getAllPlotsRaw().containsKey(worldname)) {
|
||||||
MainUtil.sendMessage(plr, "INVALID WORLD");
|
MainUtil.sendMessage(plr, "INVALID WORLD");
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
@ -107,17 +106,6 @@ public class Purge extends SubCommand {
|
|||||||
DBFunc.purgeIds(worldname, ids);
|
DBFunc.purgeIds(worldname, ids);
|
||||||
return finishPurge(DBid == Integer.MAX_VALUE ? 1 : 0);
|
return finishPurge(DBid == Integer.MAX_VALUE ? 1 : 0);
|
||||||
}
|
}
|
||||||
final UUID uuid = UUIDHandler.getUUID(args[0]);
|
|
||||||
if (uuid != null) {
|
|
||||||
final Set<Plot> plots = PlotSquared.getPlots(worldname, uuid);
|
|
||||||
final Set<PlotId> ids = new HashSet<>();
|
|
||||||
for (final Plot plot : plots) {
|
|
||||||
ids.add(plot.id);
|
|
||||||
}
|
|
||||||
int length = ids.size();
|
|
||||||
DBFunc.purge(worldname, ids);
|
|
||||||
return finishPurge(length);
|
|
||||||
}
|
|
||||||
if (arg.equals("all")) {
|
if (arg.equals("all")) {
|
||||||
final Set<PlotId> ids = PlotSquared.getPlots(worldname).keySet();
|
final Set<PlotId> ids = PlotSquared.getPlots(worldname).keySet();
|
||||||
int length = ids.size();
|
int length = ids.size();
|
||||||
@ -160,6 +148,17 @@ public class Purge extends SubCommand {
|
|||||||
DBFunc.purge(worldname, ids);
|
DBFunc.purge(worldname, ids);
|
||||||
return finishPurge(length);
|
return finishPurge(length);
|
||||||
}
|
}
|
||||||
|
final UUID uuid = UUIDHandler.getUUID(args[0]);
|
||||||
|
if (uuid != null) {
|
||||||
|
final Set<Plot> plots = PlotSquared.getPlots(worldname, uuid);
|
||||||
|
final Set<PlotId> ids = new HashSet<>();
|
||||||
|
for (final Plot plot : plots) {
|
||||||
|
ids.add(plot.id);
|
||||||
|
}
|
||||||
|
int length = ids.size();
|
||||||
|
DBFunc.purge(worldname, ids);
|
||||||
|
return finishPurge(length);
|
||||||
|
}
|
||||||
MainUtil.sendMessage(plr, C.PURGE_SYNTAX);
|
MainUtil.sendMessage(plr, C.PURGE_SYNTAX);
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
@ -26,7 +26,6 @@ import com.intellectualcrafters.plot.object.Location;
|
|||||||
import com.intellectualcrafters.plot.object.Plot;
|
import com.intellectualcrafters.plot.object.Plot;
|
||||||
import com.intellectualcrafters.plot.object.PlotPlayer;
|
import com.intellectualcrafters.plot.object.PlotPlayer;
|
||||||
import com.intellectualcrafters.plot.util.MainUtil;
|
import com.intellectualcrafters.plot.util.MainUtil;
|
||||||
import com.intellectualcrafters.plot.util.bukkit.UUIDHandler;
|
|
||||||
|
|
||||||
public class Rate extends SubCommand {
|
public class Rate extends SubCommand {
|
||||||
/*
|
/*
|
||||||
@ -52,7 +51,7 @@ public class Rate extends SubCommand {
|
|||||||
sendMessage(plr, C.RATING_NOT_OWNED);
|
sendMessage(plr, C.RATING_NOT_OWNED);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
if (plot.getOwner().equals(UUIDHandler.getUUID(plr))) {
|
if (plot.isOwner(plr.getUUID())) {
|
||||||
sendMessage(plr, C.RATING_NOT_YOUR_OWN);
|
sendMessage(plr, C.RATING_NOT_YOUR_OWN);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
@ -20,13 +20,12 @@
|
|||||||
////////////////////////////////////////////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||||
package com.intellectualcrafters.plot.commands;
|
package com.intellectualcrafters.plot.commands;
|
||||||
|
|
||||||
|
import java.util.ArrayList;
|
||||||
import java.util.Collection;
|
import java.util.Collection;
|
||||||
import java.util.HashMap;
|
import java.util.HashMap;
|
||||||
|
|
||||||
import com.intellectualcrafters.jnbt.CompoundTag;
|
|
||||||
import com.intellectualcrafters.plot.PlotSquared;
|
import com.intellectualcrafters.plot.PlotSquared;
|
||||||
import com.intellectualcrafters.plot.config.C;
|
import com.intellectualcrafters.plot.config.C;
|
||||||
import com.intellectualcrafters.plot.config.Settings;
|
|
||||||
import com.intellectualcrafters.plot.object.Location;
|
import com.intellectualcrafters.plot.object.Location;
|
||||||
import com.intellectualcrafters.plot.object.Plot;
|
import com.intellectualcrafters.plot.object.Plot;
|
||||||
import com.intellectualcrafters.plot.object.PlotId;
|
import com.intellectualcrafters.plot.object.PlotId;
|
||||||
@ -40,12 +39,10 @@ import com.intellectualcrafters.plot.util.SchematicHandler.Dimension;
|
|||||||
import com.intellectualcrafters.plot.util.SchematicHandler.Schematic;
|
import com.intellectualcrafters.plot.util.SchematicHandler.Schematic;
|
||||||
import com.intellectualcrafters.plot.util.TaskManager;
|
import com.intellectualcrafters.plot.util.TaskManager;
|
||||||
import com.intellectualcrafters.plot.util.bukkit.BukkitUtil;
|
import com.intellectualcrafters.plot.util.bukkit.BukkitUtil;
|
||||||
import com.intellectualcrafters.plot.util.bukkit.UUIDHandler;
|
|
||||||
|
|
||||||
public class SchematicCmd extends SubCommand {
|
public class SchematicCmd extends SubCommand {
|
||||||
private int counter = 0;
|
private int counter = 0;
|
||||||
private boolean running = false;
|
private boolean running = false;
|
||||||
private Plot[] plots;
|
|
||||||
private int task;
|
private int task;
|
||||||
|
|
||||||
public SchematicCmd() {
|
public SchematicCmd() {
|
||||||
@ -139,7 +136,6 @@ public class SchematicCmd extends SubCommand {
|
|||||||
if (start > blen) {
|
if (start > blen) {
|
||||||
SchematicHandler.manager.pasteStates(schematic, plot, 0, 0);
|
SchematicHandler.manager.pasteStates(schematic, plot, 0, 0);
|
||||||
sendMessage(plr, C.SCHEMATIC_PASTE_SUCCESS);
|
sendMessage(plr, C.SCHEMATIC_PASTE_SUCCESS);
|
||||||
MainUtil.update(plr.getLocation());
|
|
||||||
SchematicCmd.this.running = false;
|
SchematicCmd.this.running = false;
|
||||||
PlotSquared.TASK.cancelTask(SchematicCmd.this.task);
|
PlotSquared.TASK.cancelTask(SchematicCmd.this.task);
|
||||||
return;
|
return;
|
||||||
@ -197,52 +193,24 @@ public class SchematicCmd extends SubCommand {
|
|||||||
}
|
}
|
||||||
final HashMap<PlotId, Plot> plotmap = PlotSquared.getPlots(args[1]);
|
final HashMap<PlotId, Plot> plotmap = PlotSquared.getPlots(args[1]);
|
||||||
if ((plotmap == null) || (plotmap.size() == 0)) {
|
if ((plotmap == null) || (plotmap.size() == 0)) {
|
||||||
MainUtil.sendMessage(null, "&cInvalid world. Use &7/plots sch exportall <world>");
|
MainUtil.sendMessage(plr, "&cInvalid world. Use &7/plots sch exportall <world>");
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
if (this.running) {
|
Collection<Plot> plots = plotmap.values();
|
||||||
MainUtil.sendMessage(null, "&cTask is already running.");
|
boolean result = SchematicHandler.manager.exportAll(plots, null, null, new Runnable() {
|
||||||
|
@Override
|
||||||
|
public void run() {
|
||||||
|
MainUtil.sendMessage(plr, "&aFinished mass export");
|
||||||
|
}
|
||||||
|
});
|
||||||
|
if (!result) {
|
||||||
|
MainUtil.sendMessage(plr, "&cTask is already running.");
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
PlotSquared.log("&3PlotSquared&8->&3Schemaitc&8: &7Mass export has started. This may take a while.");
|
else {
|
||||||
PlotSquared.log("&3PlotSquared&8->&3Schemaitc&8: &7Found &c" + plotmap.size() + "&7 plots...");
|
PlotSquared.log("&3PlotSquared&8->&3Schemaitc&8: &7Mass export has started. This may take a while.");
|
||||||
final String worldname = args[1];
|
PlotSquared.log("&3PlotSquared&8->&3Schemaitc&8: &7Found &c" + plotmap.size() + "&7 plots...");
|
||||||
final Collection<Plot> values = plotmap.values();
|
}
|
||||||
this.plots = values.toArray(new Plot[values.size()]);
|
|
||||||
this.running = true;
|
|
||||||
this.counter = 0;
|
|
||||||
this.task = TaskManager.runTaskRepeat(new Runnable() {
|
|
||||||
@Override
|
|
||||||
public void run() {
|
|
||||||
if (SchematicCmd.this.counter >= SchematicCmd.this.plots.length) {
|
|
||||||
PlotSquared.log("&3PlotSquared&8->&3Schemaitc&8: &aFinished!");
|
|
||||||
SchematicCmd.this.running = false;
|
|
||||||
PlotSquared.TASK.cancelTask(SchematicCmd.this.task);
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
final Plot plot = SchematicCmd.this.plots[SchematicCmd.this.counter];
|
|
||||||
final CompoundTag sch = SchematicHandler.manager.getCompoundTag(worldname, plot.id);
|
|
||||||
final String o = UUIDHandler.getName(plot.owner);
|
|
||||||
final String owner = o == null ? "unknown" : o;
|
|
||||||
if (sch == null) {
|
|
||||||
MainUtil.sendMessage(null, "&7 - Skipped plot &c" + plot.id);
|
|
||||||
} else {
|
|
||||||
TaskManager.runTaskAsync(new Runnable() {
|
|
||||||
@Override
|
|
||||||
public void run() {
|
|
||||||
MainUtil.sendMessage(null, "&6ID: " + plot.id);
|
|
||||||
final boolean result = SchematicHandler.manager.save(sch, Settings.SCHEMATIC_SAVE_PATH + "/" + plot.id.x + ";" + plot.id.y + "," + worldname + "," + owner + ".schematic");
|
|
||||||
if (!result) {
|
|
||||||
MainUtil.sendMessage(null, "&7 - Failed to save &c" + plot.id);
|
|
||||||
} else {
|
|
||||||
MainUtil.sendMessage(null, "&7 - &a success: " + plot.id);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
});
|
|
||||||
}
|
|
||||||
SchematicCmd.this.counter++;
|
|
||||||
}
|
|
||||||
}, 20);
|
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
case "export":
|
case "export":
|
||||||
@ -289,41 +257,22 @@ public class SchematicCmd extends SubCommand {
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
this.plots = new Plot[] { p2 };
|
|
||||||
this.running = true;
|
Collection<Plot> plots = new ArrayList<Plot>();
|
||||||
this.counter = 0;
|
plots.add(p2);
|
||||||
this.task = TaskManager.runTaskRepeat(new Runnable() {
|
boolean result = SchematicHandler.manager.exportAll(plots, null, null, new Runnable() {
|
||||||
@Override
|
@Override
|
||||||
public void run() {
|
public void run() {
|
||||||
if (SchematicCmd.this.counter >= SchematicCmd.this.plots.length) {
|
MainUtil.sendMessage(plr, "&aFinished export");
|
||||||
PlotSquared.log("&3PlotSquared&8->&3Schemaitc&8: &aFinished!");
|
}
|
||||||
SchematicCmd.this.running = false;
|
});
|
||||||
PlotSquared.TASK.cancelTask(SchematicCmd.this.task);
|
if (!result) {
|
||||||
return;
|
MainUtil.sendMessage(plr, "&cTask is already running.");
|
||||||
}
|
return false;
|
||||||
final Plot plot = SchematicCmd.this.plots[SchematicCmd.this.counter];
|
}
|
||||||
final CompoundTag sch = SchematicHandler.manager.getCompoundTag(world, plot.id);
|
else {
|
||||||
final String o = UUIDHandler.getName(plot.owner);
|
MainUtil.sendMessage(plr, "&7Starting export...");
|
||||||
final String owner = o == null ? "unknown" : o;
|
}
|
||||||
if (sch == null) {
|
|
||||||
MainUtil.sendMessage(plr, "&7 - Skipped plot &c" + plot.id);
|
|
||||||
} else {
|
|
||||||
TaskManager.runTaskAsync(new Runnable() {
|
|
||||||
@Override
|
|
||||||
public void run() {
|
|
||||||
MainUtil.sendMessage(plr, "&6ID: " + plot.id);
|
|
||||||
final boolean result = SchematicHandler.manager.save(sch, Settings.SCHEMATIC_SAVE_PATH + "/" + plot.id.x + ";" + plot.id.y + "," + world + "," + owner.trim() + ".schematic");
|
|
||||||
if (!result) {
|
|
||||||
MainUtil.sendMessage(plr, "&7 - Failed to save &c" + plot.id);
|
|
||||||
} else {
|
|
||||||
MainUtil.sendMessage(plr, "&7 - &aExport success: " + plot.id);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
});
|
|
||||||
}
|
|
||||||
SchematicCmd.this.counter++;
|
|
||||||
}
|
|
||||||
}, 60);
|
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
default: {
|
default: {
|
||||||
|
@ -33,7 +33,7 @@ import com.intellectualcrafters.plot.database.DBFunc;
|
|||||||
import com.intellectualcrafters.plot.flag.AbstractFlag;
|
import com.intellectualcrafters.plot.flag.AbstractFlag;
|
||||||
import com.intellectualcrafters.plot.flag.Flag;
|
import com.intellectualcrafters.plot.flag.Flag;
|
||||||
import com.intellectualcrafters.plot.flag.FlagManager;
|
import com.intellectualcrafters.plot.flag.FlagManager;
|
||||||
import com.intellectualcrafters.plot.listeners.PlotListener;
|
import com.intellectualcrafters.plot.listeners.APlotListener;
|
||||||
import com.intellectualcrafters.plot.object.BlockLoc;
|
import com.intellectualcrafters.plot.object.BlockLoc;
|
||||||
import com.intellectualcrafters.plot.object.Location;
|
import com.intellectualcrafters.plot.object.Location;
|
||||||
import com.intellectualcrafters.plot.object.Plot;
|
import com.intellectualcrafters.plot.object.Plot;
|
||||||
@ -90,8 +90,6 @@ public class Set extends SubCommand {
|
|||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
/* TODO: Implement option */
|
|
||||||
// final boolean advanced_permissions = true;
|
|
||||||
if (!Permissions.hasPermission(plr, "plots.set." + args[0].toLowerCase())) {
|
if (!Permissions.hasPermission(plr, "plots.set." + args[0].toLowerCase())) {
|
||||||
MainUtil.sendMessage(plr, C.NO_PERMISSION, "plots.set." + args[0].toLowerCase());
|
MainUtil.sendMessage(plr, C.NO_PERMISSION, "plots.set." + args[0].toLowerCase());
|
||||||
return false;
|
return false;
|
||||||
@ -127,7 +125,7 @@ public class Set extends SubCommand {
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
MainUtil.sendMessage(plr, C.FLAG_REMOVED);
|
MainUtil.sendMessage(plr, C.FLAG_REMOVED);
|
||||||
PlotListener.plotEntry(plr, plot);
|
APlotListener.manager.plotEntry(plr, plot);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
try {
|
try {
|
||||||
@ -144,7 +142,7 @@ public class Set extends SubCommand {
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
MainUtil.sendMessage(plr, C.FLAG_ADDED);
|
MainUtil.sendMessage(plr, C.FLAG_ADDED);
|
||||||
PlotListener.plotEntry(plr, plot);
|
APlotListener.manager.plotEntry(plr, plot);
|
||||||
return true;
|
return true;
|
||||||
} catch (final Exception e) {
|
} catch (final Exception e) {
|
||||||
MainUtil.sendMessage(plr, "&c" + e.getMessage());
|
MainUtil.sendMessage(plr, "&c" + e.getMessage());
|
||||||
@ -164,7 +162,7 @@ public class Set extends SubCommand {
|
|||||||
final String world = plr.getLocation().getWorld();
|
final String world = plr.getLocation().getWorld();
|
||||||
final Location base = MainUtil.getPlotBottomLoc(world, plot.id);
|
final Location base = MainUtil.getPlotBottomLoc(world, plot.id);
|
||||||
base.setY(0);
|
base.setY(0);
|
||||||
final Location relative = plr.getLocation().subtract(base.getX(), base.getZ(), base.getY());
|
final Location relative = plr.getLocation().subtract(base.getX(), base.getY(), base.getZ());
|
||||||
final BlockLoc blockloc = new BlockLoc(relative.getX(), relative.getY(), relative.getZ());
|
final BlockLoc blockloc = new BlockLoc(relative.getX(), relative.getY(), relative.getZ());
|
||||||
plot.settings.setPosition(blockloc);
|
plot.settings.setPosition(blockloc);
|
||||||
DBFunc.setPosition(loc.getWorld(), plot, relative.getX() + "," + relative.getY() + "," + relative.getZ());
|
DBFunc.setPosition(loc.getWorld(), plot, relative.getX() + "," + relative.getY() + "," + relative.getZ());
|
||||||
@ -240,13 +238,18 @@ public class Set extends SubCommand {
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
blocks = new PlotBlock[] { new PlotBlock((short) BlockManager.manager.getBlockIdFromString(args[1]), (byte) 0) };
|
blocks = new PlotBlock[] { new PlotBlock((short) BlockManager.manager.getBlockIdFromString(args[1]), (byte) 0) };
|
||||||
|
for (PlotBlock block : blocks) {
|
||||||
|
if (!BlockManager.manager.isBlockSolid(block)) {
|
||||||
|
MainUtil.sendMessage(plr, C.NOT_VALID_BLOCK);
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
}
|
||||||
} catch (final Exception e2) {
|
} catch (final Exception e2) {
|
||||||
MainUtil.sendMessage(plr, C.NOT_VALID_BLOCK);
|
MainUtil.sendMessage(plr, C.NOT_VALID_BLOCK);
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
manager.setComponent(plotworld, plot.id, component, blocks);
|
manager.setComponent(plotworld, plot.id, component, blocks);
|
||||||
MainUtil.update(loc);
|
|
||||||
MainUtil.sendMessage(plr, C.GENERATING_COMPONENT);
|
MainUtil.sendMessage(plr, C.GENERATING_COMPONENT);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
@ -290,7 +293,7 @@ public class Set extends SubCommand {
|
|||||||
|
|
||||||
private String getBiomeList(final String[] biomes) {
|
private String getBiomeList(final String[] biomes) {
|
||||||
final StringBuilder builder = new StringBuilder();
|
final StringBuilder builder = new StringBuilder();
|
||||||
builder.append(MainUtil.colorise('&', C.NOT_VALID_BLOCK_LIST_HEADER.s()));
|
builder.append(MainUtil.colorise('&', C.NEED_BIOME.s()));
|
||||||
for (final String b : biomes) {
|
for (final String b : biomes) {
|
||||||
builder.append(getString(b));
|
builder.append(getString(b));
|
||||||
}
|
}
|
||||||
|
@ -25,6 +25,7 @@ import java.util.UUID;
|
|||||||
|
|
||||||
import com.intellectualcrafters.plot.PlotSquared;
|
import com.intellectualcrafters.plot.PlotSquared;
|
||||||
import com.intellectualcrafters.plot.config.C;
|
import com.intellectualcrafters.plot.config.C;
|
||||||
|
import com.intellectualcrafters.plot.config.Settings;
|
||||||
import com.intellectualcrafters.plot.database.DBFunc;
|
import com.intellectualcrafters.plot.database.DBFunc;
|
||||||
import com.intellectualcrafters.plot.object.Location;
|
import com.intellectualcrafters.plot.object.Location;
|
||||||
import com.intellectualcrafters.plot.object.Plot;
|
import com.intellectualcrafters.plot.object.Plot;
|
||||||
@ -60,14 +61,37 @@ public class SetOwner extends SubCommand {
|
|||||||
MainUtil.sendMessage(plr, C.NEED_USER);
|
MainUtil.sendMessage(plr, C.NEED_USER);
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
if (!plot.owner.equals(UUIDHandler.getUUID(plr)) && !Permissions.hasPermission(plr, "plots.admin.command.setowner")) {
|
|
||||||
MainUtil.sendMessage(plr, C.NO_PERMISSION, "plots.admin.command.setowner");
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
final String world = loc.getWorld();
|
|
||||||
final PlotId bot = MainUtil.getBottomPlot(plot).id;
|
final PlotId bot = MainUtil.getBottomPlot(plot).id;
|
||||||
final PlotId top = MainUtil.getTopPlot(plot).id;
|
final PlotId top = MainUtil.getTopPlot(plot).id;
|
||||||
final ArrayList<PlotId> plots = MainUtil.getPlotSelectionIds(bot, top);
|
final ArrayList<PlotId> plots = MainUtil.getPlotSelectionIds(bot, top);
|
||||||
|
|
||||||
|
PlotPlayer other = UUIDHandler.getPlayer(args[0]);
|
||||||
|
if (other == null) {
|
||||||
|
if (!Permissions.hasPermission(plr, "plots.admin.command.setowner")) {
|
||||||
|
MainUtil.sendMessage(plr, C.INVALID_PLAYER, args[0]);
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
if (!Permissions.hasPermission(plr, "plots.admin.command.setowner")) {
|
||||||
|
int size = plots.size();
|
||||||
|
final int currentPlots = (Settings.GLOBAL_LIMIT ? MainUtil.getPlayerPlotCount(other) : MainUtil.getPlayerPlotCount(loc.getWorld(), other)) + size;
|
||||||
|
if (currentPlots > MainUtil.getAllowedPlots(other)) {
|
||||||
|
sendMessage(plr, C.CANT_TRANSFER_MORE_PLOTS);
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!plot.isOwner(plr.getUUID())) {
|
||||||
|
if (!Permissions.hasPermission(plr, "plots.admin.command.setowner")) {
|
||||||
|
MainUtil.sendMessage(plr, C.NO_PERMISSION, "plots.admin.command.setowner");
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
final String world = loc.getWorld();
|
||||||
for (final PlotId id : plots) {
|
for (final PlotId id : plots) {
|
||||||
final Plot current = PlotSquared.getPlots(world).get(id);
|
final Plot current = PlotSquared.getPlots(world).get(id);
|
||||||
final UUID uuid = getUUID(args[0]);
|
final UUID uuid = getUUID(args[0]);
|
||||||
@ -81,6 +105,9 @@ public class SetOwner extends SubCommand {
|
|||||||
}
|
}
|
||||||
MainUtil.setSign(args[0], plot);
|
MainUtil.setSign(args[0], plot);
|
||||||
MainUtil.sendMessage(plr, C.SET_OWNER);
|
MainUtil.sendMessage(plr, C.SET_OWNER);
|
||||||
|
if (other != null) {
|
||||||
|
MainUtil.sendMessage(other, C.NOW_OWNER, plot.world + ";" + plot.id);
|
||||||
|
}
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -20,14 +20,19 @@
|
|||||||
////////////////////////////////////////////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||||
package com.intellectualcrafters.plot.commands;
|
package com.intellectualcrafters.plot.commands;
|
||||||
|
|
||||||
|
import java.util.ArrayList;
|
||||||
import java.util.Arrays;
|
import java.util.Arrays;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
import java.util.Map.Entry;
|
||||||
|
|
||||||
import org.apache.commons.lang.StringUtils;
|
import org.apache.commons.lang.StringUtils;
|
||||||
|
import org.bukkit.generator.ChunkGenerator;
|
||||||
|
|
||||||
import com.intellectualcrafters.plot.config.C;
|
import com.intellectualcrafters.plot.config.C;
|
||||||
import com.intellectualcrafters.plot.config.ConfigurationNode;
|
import com.intellectualcrafters.plot.config.ConfigurationNode;
|
||||||
import com.intellectualcrafters.plot.config.Settings;
|
import com.intellectualcrafters.plot.config.Settings;
|
||||||
|
import com.intellectualcrafters.plot.generator.HybridGen;
|
||||||
|
import com.intellectualcrafters.plot.object.PlotGenerator;
|
||||||
import com.intellectualcrafters.plot.object.PlotPlayer;
|
import com.intellectualcrafters.plot.object.PlotPlayer;
|
||||||
import com.intellectualcrafters.plot.object.SetupObject;
|
import com.intellectualcrafters.plot.object.SetupObject;
|
||||||
import com.intellectualcrafters.plot.util.BlockManager;
|
import com.intellectualcrafters.plot.util.BlockManager;
|
||||||
@ -39,6 +44,27 @@ public class Setup extends SubCommand {
|
|||||||
super("setup", "plots.admin.command.setup", "Plotworld setup command", "setup", "create", CommandCategory.ACTIONS, true);
|
super("setup", "plots.admin.command.setup", "Plotworld setup command", "setup", "create", CommandCategory.ACTIONS, true);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void displayGenerators(PlotPlayer plr) {
|
||||||
|
StringBuffer message = new StringBuffer();
|
||||||
|
message.append("&6What generator do you want?");
|
||||||
|
for (Entry<String, ChunkGenerator> entry : SetupUtils.generators.entrySet()) {
|
||||||
|
// + prefix + StringUtils.join(SetupUtils.generators.keySet(), prefix).replaceAll("PlotSquared", "&2PlotSquared")
|
||||||
|
if (entry.getKey().equals("PlotSquared")) {
|
||||||
|
message.append("\n&8 - &2" + entry.getKey() + " (Hybrid Generator)");
|
||||||
|
}
|
||||||
|
else if (entry.getValue() instanceof HybridGen) {
|
||||||
|
message.append("\n&8 - &7" + entry.getKey() + " (Hybrid Generator)");
|
||||||
|
}
|
||||||
|
else if (entry.getValue() instanceof PlotGenerator) {
|
||||||
|
message.append("\n&8 - &7" + entry.getKey() + " (Plot Generator)");
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
message.append("\n&8 - &7" + entry.getKey() + " (Unknown structure)");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
MainUtil.sendMessage(plr, message.toString());
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean execute(final PlotPlayer plr, final String... args) {
|
public boolean execute(final PlotPlayer plr, final String... args) {
|
||||||
// going through setup
|
// going through setup
|
||||||
@ -47,9 +73,8 @@ public class Setup extends SubCommand {
|
|||||||
final SetupObject object = new SetupObject();
|
final SetupObject object = new SetupObject();
|
||||||
SetupUtils.setupMap.put(name, object);
|
SetupUtils.setupMap.put(name, object);
|
||||||
SetupUtils.manager.updateGenerators();
|
SetupUtils.manager.updateGenerators();
|
||||||
final String prefix = "\n&8 - &7";
|
|
||||||
sendMessage(plr, C.SETUP_INIT);
|
sendMessage(plr, C.SETUP_INIT);
|
||||||
MainUtil.sendMessage(plr, "&6What generator do you want?" + prefix + StringUtils.join(SetupUtils.generators.keySet(), prefix).replaceAll("PlotSquared", "&2PlotSquared"));
|
displayGenerators(plr);
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
if (args.length == 1) {
|
if (args.length == 1) {
|
||||||
@ -80,47 +105,75 @@ public class Setup extends SubCommand {
|
|||||||
sendMessage(plr, C.SETUP_INIT);
|
sendMessage(plr, C.SETUP_INIT);
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
object.generator = args[0];
|
object.setupGenerator = args[0];
|
||||||
object.current++;
|
object.current++;
|
||||||
final String partial = Settings.ENABLE_CLUSTERS ? "\n&8 - &7PARTIAL&8 - &7Vanilla with clusters of plots" : "";
|
final String partial = Settings.ENABLE_CLUSTERS ? "\n&8 - &7PARTIAL&8 - &7Vanilla with clusters of plots" : "";
|
||||||
MainUtil.sendMessage(plr, "&6What world type do you want?" + "\n&8 - &2DEFAULT&8 - &7Standard plot generation" + "\n&8 - &7AUGMENTED&8 - &7Plot generation with terrain" + partial);
|
MainUtil.sendMessage(plr, "&6What world type do you want?" + "\n&8 - &2DEFAULT&8 - &7Standard plot generation" + "\n&8 - &7AUGMENTED&8 - &7Plot generation with terrain" + partial);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
case 1: { // choose world type
|
case 1: { // choose world type
|
||||||
List<String> types;
|
List<String> allTypes = Arrays.asList(new String[] { "default", "augmented", "partial"});
|
||||||
|
List<String> allDesc = Arrays.asList(new String[] { "Standard plot generation", "Plot generation with vanilla terrain", "Vanilla with clusters of plots"});
|
||||||
|
ArrayList<String> types = new ArrayList<>();
|
||||||
|
if (SetupUtils.generators.get(object.setupGenerator) instanceof PlotGenerator) {
|
||||||
|
types.add("default");
|
||||||
|
}
|
||||||
|
types.add("augmented");
|
||||||
if (Settings.ENABLE_CLUSTERS) {
|
if (Settings.ENABLE_CLUSTERS) {
|
||||||
types = Arrays.asList(new String[] { "default", "augmented", "partial" });
|
types.add("partial");
|
||||||
} else {
|
|
||||||
types = Arrays.asList(new String[] { "default", "augmented" });
|
|
||||||
}
|
}
|
||||||
if ((args.length != 1) || !types.contains(args[0].toLowerCase())) {
|
if ((args.length != 1) || !types.contains(args[0].toLowerCase())) {
|
||||||
MainUtil.sendMessage(plr, "&cYou must choose a world type!" + "\n&8 - &2DEFAULT&8 - &7Standard plot generation" + "\n&8 - &7AUGMENTED&8 - &7Plot generation with terrain" + "\n&8 - &7PARTIAL&8 - &7Vanilla with clusters of plots");
|
MainUtil.sendMessage(plr, "&cYou must choose a world type!");
|
||||||
|
for (String type : types) {
|
||||||
|
int i = allTypes.indexOf(type);
|
||||||
|
if (type.equals("default")) {
|
||||||
|
MainUtil.sendMessage(plr, "&8 - &2" + type + " &8-&7 " + allDesc.get(i));
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
MainUtil.sendMessage(plr, "&8 - &7" + type + " &8-&7 " + allDesc.get(i));
|
||||||
|
}
|
||||||
|
}
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
object.type = types.indexOf(args[0].toLowerCase());
|
object.type = allTypes.indexOf(args[0].toLowerCase());
|
||||||
|
ChunkGenerator gen = SetupUtils.generators.get(object.setupGenerator);
|
||||||
if (object.type == 0) {
|
if (object.type == 0) {
|
||||||
object.current++;
|
object.current++;
|
||||||
if (object.step == null) {
|
if (object.step == null) {
|
||||||
object.step = SetupUtils.generators.get(object.generator).getNewPlotWorld(null).getSettingNodes();
|
object.plotManager = object.setupGenerator;
|
||||||
|
object.step = ((PlotGenerator) SetupUtils.generators.get(object.plotManager)).getNewPlotWorld(null).getSettingNodes();
|
||||||
|
((PlotGenerator) SetupUtils.generators.get(object.plotManager)).processSetup(object);
|
||||||
}
|
}
|
||||||
final ConfigurationNode step = object.step[object.setup_index];
|
final ConfigurationNode step = object.step[object.setup_index];
|
||||||
sendMessage(plr, C.SETUP_STEP, object.setup_index + 1 + "", step.getDescription(), step.getType().getType(), step.getDefaultValue() + "");
|
sendMessage(plr, C.SETUP_STEP, object.setup_index + 1 + "", step.getDescription(), step.getType().getType(), step.getDefaultValue() + "");
|
||||||
} else {
|
} else {
|
||||||
MainUtil.sendMessage(plr, "&6What terrain would you like in plots?" + "\n&8 - &2NONE&8 - &7No terrain at all" + "\n&8 - &7ORE&8 - &7Just some ore veins and trees" + "\n&8 - &7ALL&8 - &7Entirely vanilla generation");
|
if (gen instanceof PlotGenerator) {
|
||||||
|
object.plotManager = object.setupGenerator;
|
||||||
|
object.setupGenerator = null;
|
||||||
|
object.step = ((PlotGenerator) SetupUtils.generators.get(object.plotManager)).getNewPlotWorld(null).getSettingNodes();
|
||||||
|
((PlotGenerator) SetupUtils.generators.get(object.plotManager)).processSetup(object);
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
object.plotManager = "PlotSquared";
|
||||||
|
MainUtil.sendMessage(plr, "&c[WARNING] The specified generator does not identify as PlotGenerator");
|
||||||
|
MainUtil.sendMessage(plr, "&7 - You may need to manually configure the other plugin");
|
||||||
|
object.step = ((PlotGenerator) SetupUtils.generators.get(object.plotManager)).getNewPlotWorld(null).getSettingNodes();
|
||||||
|
}
|
||||||
|
MainUtil.sendMessage(plr, "&6What terrain would you like in plots?" + "\n&8 - &2NONE&8 - &7No terrain at all" + "\n&8 - &7ORE&8 - &7Just some ore veins and trees" + "\n&8 - &7ROAD&8 - &7Terrain seperated by roads" + "\n&8 - &7ALL&8 - &7Entirely vanilla generation");
|
||||||
}
|
}
|
||||||
object.current++;
|
object.current++;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
case 2: { // Choose terrain
|
case 2: { // Choose terrain
|
||||||
final List<String> terrain = Arrays.asList(new String[] { "none", "ore", "all" });
|
final List<String> terrain = Arrays.asList(new String[] { "none", "ore", "road", "all" });
|
||||||
if ((args.length != 1) || !terrain.contains(args[0].toLowerCase())) {
|
if ((args.length != 1) || !terrain.contains(args[0].toLowerCase())) {
|
||||||
MainUtil.sendMessage(plr, "&cYou must choose the terrain!" + "\n&8 - &2NONE&8 - &7No terrain at all" + "\n&8 - &7ORE&8 - &7Just some ore veins and trees" + "\n&8 - &7ALL&8 - &7Entirely vanilla generation");
|
MainUtil.sendMessage(plr, "&cYou must choose the terrain!" + "\n&8 - &2NONE&8 - &7No terrain at all" + "\n&8 - &7ORE&8 - &7Just some ore veins and trees" + "\n&8 - &7ROAD&8 - &7Terrain seperated by roads" + "\n&8 - &7ALL&8 - &7Entirely vanilla generation");
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
object.terrain = terrain.indexOf(args[0].toLowerCase());
|
object.terrain = terrain.indexOf(args[0].toLowerCase());
|
||||||
object.current++;
|
object.current++;
|
||||||
if (object.step == null) {
|
if (object.step == null) {
|
||||||
object.step = SetupUtils.generators.get(object.generator).getNewPlotWorld(null).getSettingNodes();
|
object.step = ((PlotGenerator) SetupUtils.generators.get(object.plotManager)).getNewPlotWorld(null).getSettingNodes();
|
||||||
}
|
}
|
||||||
final ConfigurationNode step = object.step[object.setup_index];
|
final ConfigurationNode step = object.step[object.setup_index];
|
||||||
sendMessage(plr, C.SETUP_STEP, object.setup_index + 1 + "", step.getDescription(), step.getType().getType(), step.getDefaultValue() + "");
|
sendMessage(plr, C.SETUP_STEP, object.setup_index + 1 + "", step.getDescription(), step.getType().getType(), step.getDefaultValue() + "");
|
||||||
@ -166,7 +219,13 @@ public class Setup extends SubCommand {
|
|||||||
}
|
}
|
||||||
object.world = args[0];
|
object.world = args[0];
|
||||||
SetupUtils.setupMap.remove(plr.getName());
|
SetupUtils.setupMap.remove(plr.getName());
|
||||||
final String world = SetupUtils.manager.setupWorld(object);
|
final String world;
|
||||||
|
if (object.setupManager == null) {
|
||||||
|
world = SetupUtils.manager.setupWorld(object);
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
world = object.setupManager.setupWorld(object);
|
||||||
|
}
|
||||||
try {
|
try {
|
||||||
plr.teleport(BlockManager.manager.getSpawn(world));
|
plr.teleport(BlockManager.manager.getSpawn(world));
|
||||||
} catch (final Exception e) {
|
} catch (final Exception e) {
|
||||||
|
@ -144,8 +144,7 @@ public abstract class SubCommand {
|
|||||||
* @param c Caption
|
* @param c Caption
|
||||||
* @param args Arguments (%s's)
|
* @param args Arguments (%s's)
|
||||||
*
|
*
|
||||||
* @see com.intellectualcrafters.plot.util.bukkit.BukkitPlayerFunctions#sendMessage(org.bukkit.entity.Player,
|
* @see com.intellectualcrafters.plot.util.MainUtil#sendMessage(PlotPlayer, C, String...)
|
||||||
* com.intellectualcrafters.plot.config.C, String...)
|
|
||||||
*/
|
*/
|
||||||
public boolean sendMessage(final PlotPlayer plr, final C c, final String... args) {
|
public boolean sendMessage(final PlotPlayer plr, final C c, final String... args) {
|
||||||
MainUtil.sendMessage(plr, c, args);
|
MainUtil.sendMessage(plr, c, args);
|
||||||
@ -161,31 +160,31 @@ public abstract class SubCommand {
|
|||||||
public enum CommandCategory {
|
public enum CommandCategory {
|
||||||
/**
|
/**
|
||||||
* Claiming Commands
|
* Claiming Commands
|
||||||
* <p/>
|
*
|
||||||
* Such as: /plot claim
|
* Such as: /plot claim
|
||||||
*/
|
*/
|
||||||
CLAIMING("Claiming"),
|
CLAIMING("Claiming"),
|
||||||
/**
|
/**
|
||||||
* Teleportation Commands
|
* Teleportation Commands
|
||||||
* <p/>
|
*
|
||||||
* Such as: /plot visit
|
* Such as: /plot visit
|
||||||
*/
|
*/
|
||||||
TELEPORT("Teleportation"),
|
TELEPORT("Teleportation"),
|
||||||
/**
|
/**
|
||||||
* Action Commands
|
* Action Commands
|
||||||
* <p/>
|
*
|
||||||
* Such as: /plot clear
|
* Such as: /plot clear
|
||||||
*/
|
*/
|
||||||
ACTIONS("Actions"),
|
ACTIONS("Actions"),
|
||||||
/**
|
/**
|
||||||
* Information Commands
|
* Information Commands
|
||||||
* <p/>
|
*
|
||||||
* Such as: /plot info
|
* Such as: /plot info
|
||||||
*/
|
*/
|
||||||
INFO("Information"),
|
INFO("Information"),
|
||||||
/**
|
/**
|
||||||
* Debug Commands
|
* Debug Commands
|
||||||
* <p/>
|
*
|
||||||
* Such as: /plot debug
|
* Such as: /plot debug
|
||||||
*/
|
*/
|
||||||
DEBUG("Debug");
|
DEBUG("Debug");
|
||||||
|
@ -20,15 +20,19 @@
|
|||||||
////////////////////////////////////////////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||||
package com.intellectualcrafters.plot.commands;
|
package com.intellectualcrafters.plot.commands;
|
||||||
|
|
||||||
import com.intellectualcrafters.plot.PlotSquared;
|
import java.util.ArrayList;
|
||||||
|
|
||||||
import com.intellectualcrafters.plot.config.C;
|
import com.intellectualcrafters.plot.config.C;
|
||||||
import com.intellectualcrafters.plot.object.Location;
|
import com.intellectualcrafters.plot.object.Location;
|
||||||
import com.intellectualcrafters.plot.object.Plot;
|
import com.intellectualcrafters.plot.object.Plot;
|
||||||
|
import com.intellectualcrafters.plot.object.PlotCluster;
|
||||||
|
import com.intellectualcrafters.plot.object.PlotClusterId;
|
||||||
import com.intellectualcrafters.plot.object.PlotId;
|
import com.intellectualcrafters.plot.object.PlotId;
|
||||||
import com.intellectualcrafters.plot.object.PlotPlayer;
|
import com.intellectualcrafters.plot.object.PlotPlayer;
|
||||||
|
import com.intellectualcrafters.plot.util.ChunkManager;
|
||||||
|
import com.intellectualcrafters.plot.util.ClusterManager;
|
||||||
import com.intellectualcrafters.plot.util.MainUtil;
|
import com.intellectualcrafters.plot.util.MainUtil;
|
||||||
import com.intellectualcrafters.plot.util.Permissions;
|
import com.intellectualcrafters.plot.util.Permissions;
|
||||||
import com.intellectualcrafters.plot.util.bukkit.UUIDHandler;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Created 2014-08-01 for PlotSquared
|
* Created 2014-08-01 for PlotSquared
|
||||||
@ -42,6 +46,7 @@ public class Swap extends SubCommand {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean execute(final PlotPlayer plr, final String... args) {
|
public boolean execute(final PlotPlayer plr, final String... args) {
|
||||||
|
MainUtil.sendMessage(plr, "&cThis command has not been optimized for large selections yet. Please bug me if this becomes an issue.");
|
||||||
if (args.length < 1) {
|
if (args.length < 1) {
|
||||||
MainUtil.sendMessage(plr, C.NEED_PLOT_ID);
|
MainUtil.sendMessage(plr, C.NEED_PLOT_ID);
|
||||||
MainUtil.sendMessage(plr, C.SWAP_SYNTAX);
|
MainUtil.sendMessage(plr, C.SWAP_SYNTAX);
|
||||||
@ -52,42 +57,79 @@ public class Swap extends SubCommand {
|
|||||||
if (plot == null) {
|
if (plot == null) {
|
||||||
return !sendMessage(plr, C.NOT_IN_PLOT);
|
return !sendMessage(plr, C.NOT_IN_PLOT);
|
||||||
}
|
}
|
||||||
if (((plot == null) || !plot.hasOwner() || !plot.getOwner().equals(UUIDHandler.getUUID(plr))) && !Permissions.hasPermission(plr, "plots.admin.command.swap")) {
|
if (((plot == null) || !plot.hasOwner() || !plot.isOwner(plr.getUUID())) && !Permissions.hasPermission(plr, "plots.admin.command.swap")) {
|
||||||
MainUtil.sendMessage(plr, C.NO_PLOT_PERMS);
|
MainUtil.sendMessage(plr, C.NO_PLOT_PERMS);
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
if ((plot != null) && plot.settings.isMerged()) {
|
|
||||||
MainUtil.sendMessage(plr, C.UNLINK_REQUIRED);
|
Plot bot1 = MainUtil.getBottomPlot(plot);
|
||||||
|
Plot top1 = MainUtil.getTopPlot(plot);
|
||||||
|
|
||||||
|
PlotId id2 = PlotId.fromString(args[0]);
|
||||||
|
if (id2 == null) {
|
||||||
|
MainUtil.sendMessage(plr, C.NOT_VALID_PLOT_ID);
|
||||||
|
MainUtil.sendMessage(plr, C.SWAP_SYNTAX);
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
final String id = args[0];
|
|
||||||
PlotId plotid;
|
|
||||||
final String world = loc.getWorld();
|
final String world = loc.getWorld();
|
||||||
try {
|
Plot plot2 = MainUtil.getPlot(world, id2);
|
||||||
plotid = new PlotId(Integer.parseInt(id.split(";")[0]), Integer.parseInt(id.split(";")[1]));
|
PlotId id3 = new PlotId(id2.x + top1.id.x - bot1.id.x, id2.y + top1.id.y - bot1.id.y);
|
||||||
final Plot plot2 = PlotSquared.getPlots(world).get(plotid);
|
Plot plot3 = MainUtil.getPlot(world, id3);
|
||||||
if (((plot2 == null) || !plot2.hasOwner() || (plot2.owner != UUIDHandler.getUUID(plr))) && !Permissions.hasPermission(plr, "plots.admin.command.swap")) {
|
|
||||||
MainUtil.sendMessage(plr, C.NO_PERM_MERGE, plotid.toString());
|
// Getting secon selection
|
||||||
return false;
|
Plot bot2 = MainUtil.getBottomPlot(plot2);
|
||||||
}
|
Plot top2 = MainUtil.getTopPlot(plot3);
|
||||||
} catch (final Exception e) {
|
|
||||||
MainUtil.sendMessage(plr, C.NOT_VALID_PLOT_ID);
|
// cancel swap if intersection
|
||||||
|
PlotCluster cluster1 = new PlotCluster(world, bot1.id, top1.id, null);
|
||||||
|
PlotClusterId cluster2id = new PlotClusterId(bot2.id, top2.id);
|
||||||
|
if (ClusterManager.intersects(cluster1, cluster2id)) {
|
||||||
|
MainUtil.sendMessage(plr, C.SWAP_OVERLAP);
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Check dimensions
|
||||||
|
if (top1.id.x - bot1.id.x != top2.id.x - bot2.id.x || top1.id.y - bot1.id.y != top2.id.y - bot2.id.y ) {
|
||||||
|
MainUtil.sendMessage(plr, C.SWAP_DIMENSIONS, "1");
|
||||||
MainUtil.sendMessage(plr, C.SWAP_SYNTAX);
|
MainUtil.sendMessage(plr, C.SWAP_SYNTAX);
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
assert plot != null;
|
|
||||||
if (plot.id.equals(plotid)) {
|
// Getting selections as ids
|
||||||
MainUtil.sendMessage(plr, C.NOT_VALID_PLOT_ID);
|
final ArrayList<PlotId> selection1 = MainUtil.getPlotSelectionIds(bot1.id, top1.id);
|
||||||
MainUtil.sendMessage(plr, C.SWAP_SYNTAX);
|
final ArrayList<PlotId> selection2 = MainUtil.getPlotSelectionIds(bot2.id, top2.id);
|
||||||
return false;
|
|
||||||
|
// Getting selections as location coordinates
|
||||||
|
Location pos1 = MainUtil.getPlotBottomLocAbs(world, bot1.id);
|
||||||
|
Location pos2 = MainUtil.getPlotTopLocAbs(world, top1.id).subtract(1, 0, 1);
|
||||||
|
Location pos3 = MainUtil.getPlotBottomLocAbs(world, bot2.id);
|
||||||
|
Location pos4 = MainUtil.getPlotTopLocAbs(world, top2.id).subtract(1, 0, 1);
|
||||||
|
|
||||||
|
if (MainUtil.getPlot(pos2) != null) {
|
||||||
|
pos1.add(1, 0, 1);
|
||||||
|
pos2.add(1, 0, 1);
|
||||||
|
pos3.add(1, 0, 1);
|
||||||
|
pos4.add(1, 0, 1);
|
||||||
}
|
}
|
||||||
MainUtil.swap(world, plot.id, plotid, new Runnable() {
|
|
||||||
@Override
|
// Swapping the blocks, states and entites
|
||||||
public void run() {
|
ChunkManager.manager.swap(world, pos1, pos2, pos3, pos4);
|
||||||
// FIXME not implemented yet
|
|
||||||
}
|
// Swapping the plot data
|
||||||
});
|
for (int i = 0; i < selection1.size(); i++) {
|
||||||
MainUtil.update(plr.getLocation());
|
final boolean last = i == selection1.size() - 1;
|
||||||
|
PlotId swaper = selection1.get(i);
|
||||||
|
PlotId swapee = selection2.get(i);
|
||||||
|
MainUtil.swapData(world, swaper, swapee, new Runnable() {
|
||||||
|
@Override
|
||||||
|
public void run() {
|
||||||
|
if (last) {
|
||||||
|
MainUtil.sendMessage(plr, C.SWAP_SUCCESS);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
MainUtil.sendMessage(plr, C.STARTED_SWAP);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -40,7 +40,7 @@ public class Target extends SubCommand {
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
if (args.length == 1) {
|
if (args.length == 1) {
|
||||||
final PlotId id = MainUtil.parseId(args[1]);
|
final PlotId id = MainUtil.parseId(args[0]);
|
||||||
if (id == null) {
|
if (id == null) {
|
||||||
MainUtil.sendMessage(plr, C.NOT_VALID_PLOT_ID);
|
MainUtil.sendMessage(plr, C.NOT_VALID_PLOT_ID);
|
||||||
return false;
|
return false;
|
||||||
|
@ -90,14 +90,21 @@ public class Template extends SubCommand {
|
|||||||
} catch (IOException e) {
|
} catch (IOException e) {
|
||||||
e.printStackTrace();
|
e.printStackTrace();
|
||||||
}
|
}
|
||||||
String generator = worldConfig.getString("generator.plugin");
|
String manager = worldConfig.getString("generator.plugin");
|
||||||
if (generator == null) {
|
if (manager == null) {
|
||||||
generator = "PlotSquared";
|
manager = "PlotSquared";
|
||||||
}
|
}
|
||||||
|
String generator = worldConfig.getString("generator.init");
|
||||||
|
if (generator == null) {
|
||||||
|
generator = manager;
|
||||||
|
}
|
||||||
|
|
||||||
int type = worldConfig.getInt("generator.type");
|
int type = worldConfig.getInt("generator.type");
|
||||||
int terrain = worldConfig.getInt("generator.terrain");
|
int terrain = worldConfig.getInt("generator.terrain");
|
||||||
|
|
||||||
SetupObject setup = new SetupObject();
|
SetupObject setup = new SetupObject();
|
||||||
setup.generator = generator;
|
setup.plotManager = manager;
|
||||||
|
setup.setupGenerator = generator;
|
||||||
setup.type = type;
|
setup.type = type;
|
||||||
setup.terrain = terrain;
|
setup.terrain = terrain;
|
||||||
setup.step = new ConfigurationNode[0];
|
setup.step = new ConfigurationNode[0];
|
||||||
@ -178,6 +185,10 @@ public class Template extends SubCommand {
|
|||||||
public static byte[] getBytes(PlotWorld plotworld) {
|
public static byte[] getBytes(PlotWorld plotworld) {
|
||||||
ConfigurationSection section = PlotSquared.config.getConfigurationSection("worlds." + plotworld.worldname);
|
ConfigurationSection section = PlotSquared.config.getConfigurationSection("worlds." + plotworld.worldname);
|
||||||
YamlConfiguration config = new YamlConfiguration();
|
YamlConfiguration config = new YamlConfiguration();
|
||||||
|
String generator = SetupUtils.manager.getGenerator(plotworld);
|
||||||
|
if (generator != null) {
|
||||||
|
config.set("generator.plugin", generator);
|
||||||
|
}
|
||||||
for (String key : section.getKeys(true)) {
|
for (String key : section.getKeys(true)) {
|
||||||
config.set(key, section.get(key));
|
config.set(key, section.get(key));
|
||||||
}
|
}
|
||||||
|
@ -20,6 +20,7 @@
|
|||||||
////////////////////////////////////////////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||||
package com.intellectualcrafters.plot.commands;
|
package com.intellectualcrafters.plot.commands;
|
||||||
|
|
||||||
|
import java.util.ArrayList;
|
||||||
import java.util.UUID;
|
import java.util.UUID;
|
||||||
|
|
||||||
import com.intellectualcrafters.plot.config.C;
|
import com.intellectualcrafters.plot.config.C;
|
||||||
@ -53,7 +54,7 @@ public class Trusted extends SubCommand {
|
|||||||
MainUtil.sendMessage(plr, C.PLOT_UNOWNED);
|
MainUtil.sendMessage(plr, C.PLOT_UNOWNED);
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
if (!plot.getOwner().equals(UUIDHandler.getUUID(plr)) && !Permissions.hasPermission(plr, "plots.admin.command.trusted")) {
|
if (!plot.isOwner(plr.getUUID()) && !Permissions.hasPermission(plr, "plots.admin.command.trusted")) {
|
||||||
MainUtil.sendMessage(plr, C.NO_PLOT_PERMS);
|
MainUtil.sendMessage(plr, C.NO_PLOT_PERMS);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
@ -69,7 +70,7 @@ public class Trusted extends SubCommand {
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
if (!plot.trusted.contains(uuid)) {
|
if (!plot.trusted.contains(uuid)) {
|
||||||
if (plot.owner.equals(uuid)) {
|
if (plot.isOwner(uuid)) {
|
||||||
MainUtil.sendMessage(plr, C.ALREADY_OWNER);
|
MainUtil.sendMessage(plr, C.ALREADY_OWNER);
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
@ -92,17 +93,22 @@ public class Trusted extends SubCommand {
|
|||||||
return true;
|
return true;
|
||||||
} else if (args[0].equalsIgnoreCase("remove")) {
|
} else if (args[0].equalsIgnoreCase("remove")) {
|
||||||
if (args[1].equalsIgnoreCase("*")) {
|
if (args[1].equalsIgnoreCase("*")) {
|
||||||
final UUID uuid = DBFunc.everyone;
|
if (plot.trusted.size() == 0) {
|
||||||
if (!plot.trusted.contains(uuid)) {
|
MainUtil.sendMessage(plr, C.WAS_NOT_ADDED);
|
||||||
MainUtil.sendMessage(plr, C.T_WAS_NOT_ADDED);
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
plot.removeTrusted(uuid);
|
for (UUID uuid : plot.trusted) {
|
||||||
DBFunc.removeTrusted(loc.getWorld(), plot, uuid);
|
DBFunc.removeTrusted(loc.getWorld(), plot, uuid);
|
||||||
|
}
|
||||||
|
plot.trusted = new ArrayList<>();
|
||||||
MainUtil.sendMessage(plr, C.TRUSTED_REMOVED);
|
MainUtil.sendMessage(plr, C.TRUSTED_REMOVED);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
final UUID uuid = UUIDHandler.getUUID(args[1]);
|
final UUID uuid = UUIDHandler.getUUID(args[1]);
|
||||||
|
if (!plot.trusted.contains(uuid)) {
|
||||||
|
MainUtil.sendMessage(plr, C.T_WAS_NOT_ADDED);
|
||||||
|
return true;
|
||||||
|
}
|
||||||
plot.removeTrusted(uuid);
|
plot.removeTrusted(uuid);
|
||||||
DBFunc.removeTrusted(loc.getWorld(), plot, uuid);
|
DBFunc.removeTrusted(loc.getWorld(), plot, uuid);
|
||||||
EventUtil.manager.callTrusted(plr, plot, uuid, false);
|
EventUtil.manager.callTrusted(plr, plot, uuid, false);
|
||||||
|
@ -30,7 +30,6 @@ import com.intellectualcrafters.plot.object.PlotWorld;
|
|||||||
import com.intellectualcrafters.plot.util.EconHandler;
|
import com.intellectualcrafters.plot.util.EconHandler;
|
||||||
import com.intellectualcrafters.plot.util.MainUtil;
|
import com.intellectualcrafters.plot.util.MainUtil;
|
||||||
import com.intellectualcrafters.plot.util.Permissions;
|
import com.intellectualcrafters.plot.util.Permissions;
|
||||||
import com.intellectualcrafters.plot.util.bukkit.UUIDHandler;
|
|
||||||
|
|
||||||
public class Unclaim extends SubCommand {
|
public class Unclaim extends SubCommand {
|
||||||
public Unclaim() {
|
public Unclaim() {
|
||||||
@ -47,7 +46,7 @@ public class Unclaim extends SubCommand {
|
|||||||
if (!MainUtil.getTopPlot(plot).equals(MainUtil.getBottomPlot(plot))) {
|
if (!MainUtil.getTopPlot(plot).equals(MainUtil.getBottomPlot(plot))) {
|
||||||
return !sendMessage(plr, C.UNLINK_REQUIRED);
|
return !sendMessage(plr, C.UNLINK_REQUIRED);
|
||||||
}
|
}
|
||||||
if ((((plot == null) || !plot.hasOwner() || !plot.getOwner().equals(UUIDHandler.getUUID(plr)))) && !Permissions.hasPermission(plr, "plots.admin.command.unclaim")) {
|
if ((((plot == null) || !plot.hasOwner() || !plot.isOwner(plr.getUUID()))) && !Permissions.hasPermission(plr, "plots.admin.command.unclaim")) {
|
||||||
return !sendMessage(plr, C.NO_PLOT_PERMS);
|
return !sendMessage(plr, C.NO_PLOT_PERMS);
|
||||||
}
|
}
|
||||||
assert plot != null;
|
assert plot != null;
|
||||||
|
@ -56,7 +56,7 @@ public class Unlink extends SubCommand {
|
|||||||
if (plot == null) {
|
if (plot == null) {
|
||||||
return !sendMessage(plr, C.NOT_IN_PLOT);
|
return !sendMessage(plr, C.NOT_IN_PLOT);
|
||||||
}
|
}
|
||||||
if (((plot == null) || !plot.hasOwner() || !plot.getOwner().equals(UUIDHandler.getUUID(plr))) && !Permissions.hasPermission(plr, "plots.admin.command.unlink")) {
|
if (((plot == null) || !plot.hasOwner() || !plot.isOwner(plr.getUUID())) && !Permissions.hasPermission(plr, "plots.admin.command.unlink")) {
|
||||||
return sendMessage(plr, C.NO_PLOT_PERMS);
|
return sendMessage(plr, C.NO_PLOT_PERMS);
|
||||||
}
|
}
|
||||||
if (MainUtil.getTopPlot(plot).equals(MainUtil.getBottomPlot(plot))) {
|
if (MainUtil.getTopPlot(plot).equals(MainUtil.getBottomPlot(plot))) {
|
||||||
@ -66,11 +66,10 @@ public class Unlink extends SubCommand {
|
|||||||
Runnable runnable = new Runnable() {
|
Runnable runnable = new Runnable() {
|
||||||
@Override
|
@Override
|
||||||
public void run() {
|
public void run() {
|
||||||
if (!unlinkPlot(plot)) {
|
if (!MainUtil.unlinkPlot(plot)) {
|
||||||
MainUtil.sendMessage(plr, "&cUnlink has been cancelled");
|
MainUtil.sendMessage(plr, "&cUnlink has been cancelled");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
MainUtil.update(plr.getLocation());
|
|
||||||
MainUtil.sendMessage(plr, C.UNLINK_SUCCESS);
|
MainUtil.sendMessage(plr, C.UNLINK_SUCCESS);
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
@ -82,61 +81,4 @@ public class Unlink extends SubCommand {
|
|||||||
}
|
}
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
public static boolean unlinkPlot(final Plot plot) {
|
|
||||||
final String world = plot.world;
|
|
||||||
final PlotId pos1 = MainUtil.getBottomPlot(plot).id;
|
|
||||||
final PlotId pos2 = MainUtil.getTopPlot(plot).id;
|
|
||||||
final ArrayList<PlotId> ids = MainUtil.getPlotSelectionIds(pos1, pos2);
|
|
||||||
final boolean result = EventUtil.manager.callUnlink(world, ids);
|
|
||||||
if (!result) {
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
final PlotManager manager = PlotSquared.getPlotManager(world);
|
|
||||||
final PlotWorld plotworld = PlotSquared.getPlotWorld(world);
|
|
||||||
manager.startPlotUnlink(plotworld, ids);
|
|
||||||
for (final PlotId id : ids) {
|
|
||||||
final Plot myplot = PlotSquared.getPlots(world).get(id);
|
|
||||||
if (plot == null) {
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
if (plot.helpers != null) {
|
|
||||||
myplot.helpers = plot.helpers;
|
|
||||||
}
|
|
||||||
if (plot.denied != null) {
|
|
||||||
myplot.denied = plot.denied;
|
|
||||||
}
|
|
||||||
myplot.deny_entry = plot.deny_entry;
|
|
||||||
myplot.settings.setMerged(new boolean[] { false, false, false, false });
|
|
||||||
DBFunc.setMerged(world, myplot, myplot.settings.getMerged());
|
|
||||||
}
|
|
||||||
for (int x = pos1.x; x <= pos2.x; x++) {
|
|
||||||
for (int y = pos1.y; y <= pos2.y; y++) {
|
|
||||||
final boolean lx = x < pos2.x;
|
|
||||||
final boolean ly = y < pos2.y;
|
|
||||||
final Plot p = MainUtil.getPlot(world, new PlotId(x, y));
|
|
||||||
if (lx) {
|
|
||||||
manager.createRoadEast(plotworld, p);
|
|
||||||
if (ly) {
|
|
||||||
manager.createRoadSouthEast(plotworld, p);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
if (ly) {
|
|
||||||
manager.createRoadSouth(plotworld, p);
|
|
||||||
}
|
|
||||||
MainUtil.setSign(UUIDHandler.getName(plot.owner), plot);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
manager.finishPlotUnlink(plotworld, ids);
|
|
||||||
for (final PlotId id : ids) {
|
|
||||||
final Plot myPlot = MainUtil.getPlot(world, id);
|
|
||||||
if (plot.hasOwner()) {
|
|
||||||
final String name = UUIDHandler.getName(myPlot.owner);
|
|
||||||
if (name != null) {
|
|
||||||
MainUtil.setSign(name, myPlot);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
@ -39,7 +39,7 @@ public class Visit extends SubCommand {
|
|||||||
public List<Plot> getPlots(final UUID uuid) {
|
public List<Plot> getPlots(final UUID uuid) {
|
||||||
final List<Plot> plots = new ArrayList<>();
|
final List<Plot> plots = new ArrayList<>();
|
||||||
for (final Plot p : PlotSquared.getPlots()) {
|
for (final Plot p : PlotSquared.getPlots()) {
|
||||||
if (p.hasOwner() && p.owner.equals(uuid)) {
|
if (p.hasOwner() && p.isOwner(uuid)) {
|
||||||
plots.add(p);
|
plots.add(p);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -55,7 +55,7 @@ public class Visit extends SubCommand {
|
|||||||
final UUID uuid = UUIDHandler.getUUID(username);
|
final UUID uuid = UUIDHandler.getUUID(username);
|
||||||
List<Plot> plots = null;
|
List<Plot> plots = null;
|
||||||
if (uuid != null) {
|
if (uuid != null) {
|
||||||
plots = getPlots(uuid);
|
plots = PlotSquared.sortPlotsByWorld(getPlots(uuid));
|
||||||
}
|
}
|
||||||
if ((uuid == null) || plots.isEmpty()) {
|
if ((uuid == null) || plots.isEmpty()) {
|
||||||
return sendMessage(plr, C.FOUND_NO_PLOTS);
|
return sendMessage(plr, C.FOUND_NO_PLOTS);
|
||||||
@ -70,10 +70,10 @@ public class Visit extends SubCommand {
|
|||||||
} catch (final Exception e) {
|
} catch (final Exception e) {
|
||||||
return sendMessage(plr, C.NOT_VALID_NUMBER);
|
return sendMessage(plr, C.NOT_VALID_NUMBER);
|
||||||
}
|
}
|
||||||
if ((i < 0) || (i >= plots.size())) {
|
if ((i < 1) || (i > plots.size())) {
|
||||||
return sendMessage(plr, C.NOT_VALID_NUMBER);
|
return sendMessage(plr, C.NOT_VALID_NUMBER);
|
||||||
}
|
}
|
||||||
MainUtil.teleportPlayer(plr, plr.getLocation(), plots.get(i));
|
MainUtil.teleportPlayer(plr, plr.getLocation(), plots.get(i - 1));
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -21,14 +21,15 @@
|
|||||||
package com.intellectualcrafters.plot.commands;
|
package com.intellectualcrafters.plot.commands;
|
||||||
|
|
||||||
import com.intellectualcrafters.plot.PlotSquared;
|
import com.intellectualcrafters.plot.PlotSquared;
|
||||||
|
import com.intellectualcrafters.plot.config.C;
|
||||||
|
import com.intellectualcrafters.plot.listeners.worldedit.WEManager;
|
||||||
import com.intellectualcrafters.plot.object.PlotPlayer;
|
import com.intellectualcrafters.plot.object.PlotPlayer;
|
||||||
import com.intellectualcrafters.plot.util.MainUtil;
|
import com.intellectualcrafters.plot.util.MainUtil;
|
||||||
import com.intellectualcrafters.plot.util.Permissions;
|
import com.intellectualcrafters.plot.util.Permissions;
|
||||||
import com.intellectualcrafters.plot.util.bukkit.PWE;
|
|
||||||
|
|
||||||
public class WE_Anywhere extends SubCommand {
|
public class WE_Anywhere extends SubCommand {
|
||||||
public WE_Anywhere() {
|
public WE_Anywhere() {
|
||||||
super("weanywhere", "plots.weanywhere", "Force bypass of WorldEdit", "weanywhere", "wea", CommandCategory.DEBUG, true);
|
super("weanywhere", "plots.worldedit.bypass", "Force bypass of WorldEdit", "weanywhere", "wea", CommandCategory.DEBUG, true);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@ -37,12 +38,15 @@ public class WE_Anywhere extends SubCommand {
|
|||||||
MainUtil.sendMessage(plr, "&cWorldEdit is not enabled on this server");
|
MainUtil.sendMessage(plr, "&cWorldEdit is not enabled on this server");
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
if (Permissions.hasPermission(plr, "plots.worldedit.bypass") && PWE.hasMask(plr)) {
|
if (Permissions.hasPermission(plr, "plots.worldedit.bypass")) {
|
||||||
PWE.removeMask(plr);
|
if (WEManager.bypass.contains(plr.getName())) {
|
||||||
MainUtil.sendMessage(plr, "&6Cleared your WorldEdit mask");
|
WEManager.bypass.remove(plr.getName());
|
||||||
} else {
|
MainUtil.sendMessage(plr, C.WORLDEDIT_RESTRICTED);
|
||||||
PWE.setMask(plr, plr.getLocation(), true);
|
}
|
||||||
MainUtil.sendMessage(plr, "&6Updated your WorldEdit mask");
|
else {
|
||||||
|
WEManager.bypass.add(plr.getName());
|
||||||
|
MainUtil.sendMessage(plr, C.WORLDEDIT_UNMASKED);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
@ -33,6 +33,7 @@ import com.intellectualcrafters.plot.flag.FlagManager;
|
|||||||
import com.intellectualcrafters.plot.object.Plot;
|
import com.intellectualcrafters.plot.object.Plot;
|
||||||
import com.intellectualcrafters.plot.object.PlotPlayer;
|
import com.intellectualcrafters.plot.object.PlotPlayer;
|
||||||
import com.intellectualcrafters.plot.util.MainUtil;
|
import com.intellectualcrafters.plot.util.MainUtil;
|
||||||
|
import com.intellectualcrafters.plot.util.Permissions;
|
||||||
import com.intellectualcrafters.plot.util.StringComparison;
|
import com.intellectualcrafters.plot.util.StringComparison;
|
||||||
import com.intellectualcrafters.plot.util.bukkit.UUIDHandler;
|
import com.intellectualcrafters.plot.util.bukkit.UUIDHandler;
|
||||||
|
|
||||||
@ -112,27 +113,54 @@ public class list extends SubCommand {
|
|||||||
if (plr == null) {
|
if (plr == null) {
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
if (!Permissions.hasPermission(plr, "plots.list.mine")) {
|
||||||
|
MainUtil.sendMessage(plr, C.NO_PERMISSION, "plots.list.mine");
|
||||||
|
return false;
|
||||||
|
}
|
||||||
plots = PlotSquared.getPlots(plr);
|
plots = PlotSquared.getPlots(plr);
|
||||||
|
break;
|
||||||
}
|
}
|
||||||
case "shared": {
|
case "shared": {
|
||||||
if (plr == null) {
|
if (plr == null) {
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
if (!Permissions.hasPermission(plr, "plots.list.shared")) {
|
||||||
|
MainUtil.sendMessage(plr, C.NO_PERMISSION, "plots.list.shared");
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
plots = new ArrayList<Plot>();
|
||||||
for (Plot plot : PlotSquared.getPlots()) {
|
for (Plot plot : PlotSquared.getPlots()) {
|
||||||
if (plot.helpers.contains(plr.getUUID()) || plot.trusted.contains(plr.getUUID())) {
|
if (plot.helpers.contains(plr.getUUID()) || plot.trusted.contains(plr.getUUID())) {
|
||||||
plots.add(plot);
|
plots.add(plot);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
break;
|
||||||
}
|
}
|
||||||
case "world": {
|
case "world": {
|
||||||
|
if (!Permissions.hasPermission(plr, "plots.list.world")) {
|
||||||
|
MainUtil.sendMessage(plr, C.NO_PERMISSION, "plots.list.world");
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
if (!Permissions.hasPermission(plr, "plots.list.world." + world)) {
|
||||||
|
MainUtil.sendMessage(plr, C.NO_PERMISSION, "plots.list.world." + world);
|
||||||
|
return false;
|
||||||
|
}
|
||||||
plots = PlotSquared.getPlots(world).values();
|
plots = PlotSquared.getPlots(world).values();
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
case "all": {
|
case "all": {
|
||||||
|
if (!Permissions.hasPermission(plr, "plots.list.all")) {
|
||||||
|
MainUtil.sendMessage(plr, C.NO_PERMISSION, "plots.list.all");
|
||||||
|
return false;
|
||||||
|
}
|
||||||
plots = PlotSquared.getPlots();
|
plots = PlotSquared.getPlots();
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
case "forsale": {
|
case "forsale": {
|
||||||
|
if (!Permissions.hasPermission(plr, "plots.list.forsale")) {
|
||||||
|
MainUtil.sendMessage(plr, C.NO_PERMISSION, "plots.list.forsale");
|
||||||
|
return false;
|
||||||
|
}
|
||||||
if (PlotSquared.economy == null) {
|
if (PlotSquared.economy == null) {
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
@ -146,6 +174,10 @@ public class list extends SubCommand {
|
|||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
case "unowned": {
|
case "unowned": {
|
||||||
|
if (!Permissions.hasPermission(plr, "plots.list.unowned")) {
|
||||||
|
MainUtil.sendMessage(plr, C.NO_PERMISSION, "plots.list.unowned");
|
||||||
|
return false;
|
||||||
|
}
|
||||||
plots = new HashSet<>();
|
plots = new HashSet<>();
|
||||||
for (Plot plot : PlotSquared.getPlots()) {
|
for (Plot plot : PlotSquared.getPlots()) {
|
||||||
if (plot.owner == null) {
|
if (plot.owner == null) {
|
||||||
@ -155,6 +187,10 @@ public class list extends SubCommand {
|
|||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
case "unknown": {
|
case "unknown": {
|
||||||
|
if (!Permissions.hasPermission(plr, "plots.list.unknown")) {
|
||||||
|
MainUtil.sendMessage(plr, C.NO_PERMISSION, "plots.list.unknown");
|
||||||
|
return false;
|
||||||
|
}
|
||||||
plots = new HashSet<>();
|
plots = new HashSet<>();
|
||||||
for (Plot plot : PlotSquared.getPlots()) {
|
for (Plot plot : PlotSquared.getPlots()) {
|
||||||
if (plot.owner == null) {
|
if (plot.owner == null) {
|
||||||
@ -168,11 +204,23 @@ public class list extends SubCommand {
|
|||||||
}
|
}
|
||||||
default: {
|
default: {
|
||||||
if (PlotSquared.isPlotWorld(args[0])) {
|
if (PlotSquared.isPlotWorld(args[0])) {
|
||||||
|
if (!Permissions.hasPermission(plr, "plots.list.world")) {
|
||||||
|
MainUtil.sendMessage(plr, C.NO_PERMISSION, "plots.list.world");
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
if (!Permissions.hasPermission(plr, "plots.list.world." + args[0])) {
|
||||||
|
MainUtil.sendMessage(plr, C.NO_PERMISSION, "plots.list.world." + args[0]);
|
||||||
|
return false;
|
||||||
|
}
|
||||||
plots = PlotSquared.getPlots(args[0]).values();
|
plots = PlotSquared.getPlots(args[0]).values();
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
UUID uuid = UUIDHandler.getUUID(args[0]);
|
UUID uuid = UUIDHandler.getUUID(args[0]);
|
||||||
if (uuid != null) {
|
if (uuid != null) {
|
||||||
|
if (!Permissions.hasPermission(plr, "plots.list.player")) {
|
||||||
|
MainUtil.sendMessage(plr, C.NO_PERMISSION, "plots.list.player");
|
||||||
|
return false;
|
||||||
|
}
|
||||||
plots = PlotSquared.getPlots(uuid);
|
plots = PlotSquared.getPlots(uuid);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
@ -185,16 +233,22 @@ public class list extends SubCommand {
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (plots.size() == 0) {
|
if (plots.size() == 0) {
|
||||||
MainUtil.sendMessage(plr, C.NO_PLOTS);
|
MainUtil.sendMessage(plr, C.FOUND_NO_PLOTS);
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
displayPlots(plr, plots, page);
|
displayPlots(plr, plots, page, world);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void displayPlots(PlotPlayer player, Collection<Plot> oldPlots, int page) {
|
public void displayPlots(PlotPlayer player, Collection<Plot> oldPlots, int page, String world) {
|
||||||
ArrayList<Plot> plots = PlotSquared.sortPlots(oldPlots);
|
ArrayList<Plot> plots;
|
||||||
|
if (world != null) {
|
||||||
|
plots = PlotSquared.sortPlots(oldPlots, world);
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
plots = PlotSquared.sortPlots(oldPlots);
|
||||||
|
}
|
||||||
if (page < 0) {
|
if (page < 0) {
|
||||||
page = 0;
|
page = 0;
|
||||||
}
|
}
|
||||||
|
@ -44,6 +44,7 @@ public enum C {
|
|||||||
* Move
|
* Move
|
||||||
*/
|
*/
|
||||||
MOVE_SUCCESS("$4Successfully moved plot."),
|
MOVE_SUCCESS("$4Successfully moved plot."),
|
||||||
|
COPY_SUCCESS("$4Successfully copied plot."),
|
||||||
REQUIRES_UNOWNED("$2The location specified is already occupied."),
|
REQUIRES_UNOWNED("$2The location specified is already occupied."),
|
||||||
/*
|
/*
|
||||||
* Compass
|
* Compass
|
||||||
@ -85,6 +86,12 @@ public enum C {
|
|||||||
* WorldEdit masks
|
* WorldEdit masks
|
||||||
*/
|
*/
|
||||||
REQUIRE_SELECTION_IN_MASK("$2%s of your selection is not within your plot mask. You can only make edits within your plot."),
|
REQUIRE_SELECTION_IN_MASK("$2%s of your selection is not within your plot mask. You can only make edits within your plot."),
|
||||||
|
WORLDEDIT_VOLUME("$2You cannot select a volume of %current%. The maximum volume you can modify is %max%."),
|
||||||
|
WORLDEDIT_ITERATIONS("$2You cannot iterate %current% times. The maximum number of iterations allowed is %max%."),
|
||||||
|
WORLDEDIT_UNSAFE("$2Access to that command has been blocked"),
|
||||||
|
WORLDEDIT_BYPASS("$2&oTo bypass your restrictions use $4/plot wea"),
|
||||||
|
WORLDEDIT_UNMASKED("$1Your WorldEdit is now unrestricted."),
|
||||||
|
WORLDEDIT_RESTRICTED("$1Your WorldEdit is now restricted."),
|
||||||
/*
|
/*
|
||||||
* Records
|
* Records
|
||||||
*/
|
*/
|
||||||
@ -94,15 +101,24 @@ public enum C {
|
|||||||
/*
|
/*
|
||||||
* Swap
|
* Swap
|
||||||
*/
|
*/
|
||||||
|
SWAP_OVERLAP("$2The proposed areas are not allowed to overlap"),
|
||||||
|
SWAP_DIMENSIONS("$2The proposed areas must have comparable dimensions"),
|
||||||
SWAP_SYNTAX("$2/plots swap <plot id>"),
|
SWAP_SYNTAX("$2/plots swap <plot id>"),
|
||||||
SWAP_SUCCESS("$4Successfully swapped plots"),
|
SWAP_SUCCESS("$4Successfully swapped plots"),
|
||||||
|
STARTED_SWAP("$2Started plot swap task. You will be notified when it finishes"),
|
||||||
/*
|
/*
|
||||||
* Comment
|
* Comment
|
||||||
*/
|
*/
|
||||||
COMMENT_SYNTAX("$2Use /plots comment <everyone|trusted|helper|owner|admin> <comment>"),
|
NOT_VALID_INBOX_INDEX("$2No comment at index %s"),
|
||||||
|
INBOX_ITEM("$2 - $4%s"),
|
||||||
|
COMMENT_SYNTAX("$2Use /plots comment [X;Z] <%s> <comment>"),
|
||||||
INVALID_INBOX("$2That is not a valid inbox.\n$1Accepted values: %s"),
|
INVALID_INBOX("$2That is not a valid inbox.\n$1Accepted values: %s"),
|
||||||
COMMENT_REMOVED("$4Successfully deleted %s."),
|
NO_PERM_INBOX("$2You do not have permission for that inbox"),
|
||||||
|
NO_PERM_INBOX_MODIFY("$2You do not have permission to modify that inbox"),
|
||||||
|
NO_PLOT_INBOX("$2You must stand in or supply a plot argument"),
|
||||||
|
COMMENT_REMOVED("$4Successfully deleted comment/s:n$2 - '$3%s$2'"),
|
||||||
COMMENT_ADDED("$4A comment has been left"),
|
COMMENT_ADDED("$4A comment has been left"),
|
||||||
|
COMMENT_HEADER("$2====== Comments ======"),
|
||||||
/*
|
/*
|
||||||
* Console
|
* Console
|
||||||
*/
|
*/
|
||||||
@ -158,7 +174,7 @@ public enum C {
|
|||||||
/*
|
/*
|
||||||
* Title Stuff
|
* Title Stuff
|
||||||
*/
|
*/
|
||||||
TITLE_ENTERED_PLOT("You entered plot %world%;%x%;%z%"),
|
TITLE_ENTERED_PLOT("Plot: %world%;%x%;%z%"),
|
||||||
TITLE_ENTERED_PLOT_COLOR("GOLD"),
|
TITLE_ENTERED_PLOT_COLOR("GOLD"),
|
||||||
TITLE_ENTERED_PLOT_SUB("Owned by %s"),
|
TITLE_ENTERED_PLOT_SUB("Owned by %s"),
|
||||||
TITLE_ENTERED_PLOT_SUB_COLOR("RED"),
|
TITLE_ENTERED_PLOT_SUB_COLOR("RED"),
|
||||||
@ -171,7 +187,7 @@ public enum C {
|
|||||||
/*
|
/*
|
||||||
* Core Stuff
|
* Core Stuff
|
||||||
*/
|
*/
|
||||||
PREFIX("$3[$1P\u00B2$3] "),
|
PREFIX("$3[$1P2$3] $2"),
|
||||||
ENABLED("$1PlotSquared is now enabled"),
|
ENABLED("$1PlotSquared is now enabled"),
|
||||||
EXAMPLE_MESSAGE("$2This is an example message &k!!!"),
|
EXAMPLE_MESSAGE("$2This is an example message &k!!!"),
|
||||||
/*
|
/*
|
||||||
@ -208,6 +224,7 @@ public enum C {
|
|||||||
NO_PERMISSION("$2You are lacking the permission node: $1%s"),
|
NO_PERMISSION("$2You are lacking the permission node: $1%s"),
|
||||||
NO_PLOT_PERMS("$2You must be the plot owner to perform this action"),
|
NO_PLOT_PERMS("$2You must be the plot owner to perform this action"),
|
||||||
CANT_CLAIM_MORE_PLOTS("$2You can't claim more plots."),
|
CANT_CLAIM_MORE_PLOTS("$2You can't claim more plots."),
|
||||||
|
CANT_TRANSFER_MORE_PLOTS("$2You can't send more plots to that user"),
|
||||||
CANT_CLAIM_MORE_PLOTS_NUM("$2You can't claim more than $1%s $2plots at once"),
|
CANT_CLAIM_MORE_PLOTS_NUM("$2You can't claim more than $1%s $2plots at once"),
|
||||||
YOU_BE_DENIED("$2You are not allowed to enter this plot"),
|
YOU_BE_DENIED("$2You are not allowed to enter this plot"),
|
||||||
NO_PERM_MERGE("$2You are not the owner of the plot: $1%plot%"),
|
NO_PERM_MERGE("$2You are not the owner of the plot: $1%plot%"),
|
||||||
@ -215,6 +232,11 @@ public enum C {
|
|||||||
UNLINK_IMPOSSIBLE("$2You can only unlink a mega-plot"),
|
UNLINK_IMPOSSIBLE("$2You can only unlink a mega-plot"),
|
||||||
UNLINK_SUCCESS("$2Successfully unlinked plots."),
|
UNLINK_SUCCESS("$2Successfully unlinked plots."),
|
||||||
NO_MERGE_TO_MEGA("$2Mega plots cannot be merged into. Please merge from the desired mega plot."),
|
NO_MERGE_TO_MEGA("$2Mega plots cannot be merged into. Please merge from the desired mega plot."),
|
||||||
|
MERGE_NOT_VALID("$2This merge request is no longer valid."),
|
||||||
|
MERGE_ACCEPTED("$2The merge request has been accepted"),
|
||||||
|
SUCCESS_MERGE("$2Plots have been merged!"),
|
||||||
|
MERGE_REQUESTED("$2Successfully sent a merge request"),
|
||||||
|
MERGE_REQUEST_CONFIRM("merge request from %s"),
|
||||||
/*
|
/*
|
||||||
* Commands
|
* Commands
|
||||||
*/
|
*/
|
||||||
@ -236,7 +258,7 @@ public enum C {
|
|||||||
* purge
|
* purge
|
||||||
*/
|
*/
|
||||||
PURGE_SYNTAX("Use /plot purge <x;z|player|unowned|unknown|all> <world>"),
|
PURGE_SYNTAX("Use /plot purge <x;z|player|unowned|unknown|all> <world>"),
|
||||||
PURGE_SUCCESS("$4Successfully purge %s plots"),
|
PURGE_SUCCESS("$4Successfully purged %s plots"),
|
||||||
/*
|
/*
|
||||||
* trim
|
* trim
|
||||||
*/
|
*/
|
||||||
@ -251,6 +273,7 @@ public enum C {
|
|||||||
NOT_IN_PLOT("$2You're not in a plot"),
|
NOT_IN_PLOT("$2You're not in a plot"),
|
||||||
NOT_IN_CLUSTER("$2You must be within a plot cluster to perform that action"),
|
NOT_IN_CLUSTER("$2You must be within a plot cluster to perform that action"),
|
||||||
NOT_IN_PLOT_WORLD("$2You're not in a plot world"),
|
NOT_IN_PLOT_WORLD("$2You're not in a plot world"),
|
||||||
|
PLOTWORLD_INCOMPATIBLE("$2The two worlds must be compatible"),
|
||||||
NOT_VALID_WORLD("$2That is not a valid world (case sensitive)"),
|
NOT_VALID_WORLD("$2That is not a valid world (case sensitive)"),
|
||||||
NOT_VALID_PLOT_WORLD("$2That is not a valid plot world (case sensitive)"),
|
NOT_VALID_PLOT_WORLD("$2That is not a valid plot world (case sensitive)"),
|
||||||
NO_PLOTS("$2You don't have any plots"),
|
NO_PLOTS("$2You don't have any plots"),
|
||||||
@ -263,7 +286,7 @@ public enum C {
|
|||||||
/*
|
/*
|
||||||
* Biome
|
* Biome
|
||||||
*/
|
*/
|
||||||
NEED_BIOME("$2You have got to specify a biome"),
|
NEED_BIOME("$2You need to specify a valid biome."),
|
||||||
BIOME_SET_TO("$2Plot biome set to $2"),
|
BIOME_SET_TO("$2Plot biome set to $2"),
|
||||||
/*
|
/*
|
||||||
* Teleport / Entry
|
* Teleport / Entry
|
||||||
@ -370,7 +393,7 @@ public enum C {
|
|||||||
/*
|
/*
|
||||||
* PlotMe
|
* PlotMe
|
||||||
*/
|
*/
|
||||||
NOT_USING_PLOTME("$2This server uses the $1PlotSquared $2plot management system. Please use the $1/plots $2instead"),
|
NOT_USING_PLOTME("$2This server uses the $1PlotSquared $2plot management system. Please use the $1/ps &2or $1/p2 $2or $1/plots $2instead"),
|
||||||
/*
|
/*
|
||||||
* Wait
|
* Wait
|
||||||
*/
|
*/
|
||||||
@ -384,7 +407,7 @@ public enum C {
|
|||||||
*/
|
*/
|
||||||
DENIED_REMOVED("$4You successfully undenied the player from this plot"),
|
DENIED_REMOVED("$4You successfully undenied the player from this plot"),
|
||||||
DENIED_ADDED("$4You successfully denied the player from this plot"),
|
DENIED_ADDED("$4You successfully denied the player from this plot"),
|
||||||
DENIED_NEED_ARGUMENT("$2Arguments are missing. $1/plot denied add <name> $2or $1/plot helpers remove <name>"),
|
DENIED_NEED_ARGUMENT("$2Arguments are missing. $1/plot denied add <name> $2or $1/plot denied remove <name>"),
|
||||||
WAS_NOT_DENIED("$2That player was not denied on this plot"),
|
WAS_NOT_DENIED("$2That player was not denied on this plot"),
|
||||||
/*
|
/*
|
||||||
* Rain
|
* Rain
|
||||||
@ -426,6 +449,7 @@ public enum C {
|
|||||||
* Set Owner
|
* Set Owner
|
||||||
*/
|
*/
|
||||||
SET_OWNER("$4You successfully set the plot owner"),
|
SET_OWNER("$4You successfully set the plot owner"),
|
||||||
|
NOW_OWNER("$4You are now owner of plot %s"),
|
||||||
/*
|
/*
|
||||||
* Signs
|
* Signs
|
||||||
*/
|
*/
|
||||||
|
@ -34,7 +34,7 @@ import com.intellectualsites.translation.bukkit.BukkitTranslation;
|
|||||||
*
|
*
|
||||||
* @author Citymonstret
|
* @author Citymonstret
|
||||||
*/
|
*/
|
||||||
public enum C {
|
public enum C_german {
|
||||||
/*
|
/*
|
||||||
* Confirm
|
* Confirm
|
||||||
*/
|
*/
|
||||||
@ -484,7 +484,7 @@ public enum C {
|
|||||||
/**
|
/**
|
||||||
* Constructor for custom strings.
|
* Constructor for custom strings.
|
||||||
*/
|
*/
|
||||||
C() {
|
C_german() {
|
||||||
/*
|
/*
|
||||||
* use setCustomString();
|
* use setCustomString();
|
||||||
*/
|
*/
|
||||||
@ -496,7 +496,7 @@ public enum C {
|
|||||||
* @param d default
|
* @param d default
|
||||||
* @param prefix use prefix
|
* @param prefix use prefix
|
||||||
*/
|
*/
|
||||||
C(final String d, final boolean prefix) {
|
C_german(final String d, final boolean prefix) {
|
||||||
this.d = d;
|
this.d = d;
|
||||||
if (this.s == null) {
|
if (this.s == null) {
|
||||||
this.s = "";
|
this.s = "";
|
||||||
@ -509,7 +509,7 @@ public enum C {
|
|||||||
*
|
*
|
||||||
* @param d default
|
* @param d default
|
||||||
*/
|
*/
|
||||||
C(final String d) {
|
C_german(final String d) {
|
||||||
this(d, true);
|
this(d, true);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -517,7 +517,7 @@ public enum C {
|
|||||||
manager = new TranslationManager();
|
manager = new TranslationManager();
|
||||||
defaultFile = new YamlTranslationFile(BukkitTranslation.getParent(), lang, "PlotSquared", manager).read();
|
defaultFile = new YamlTranslationFile(BukkitTranslation.getParent(), lang, "PlotSquared", manager).read();
|
||||||
// register everything in this class
|
// register everything in this class
|
||||||
for (final C c : values()) {
|
for (final C_german c : values()) {
|
||||||
manager.addTranslationObject(new TranslationObject(c.toString(), c.d, "", ""));
|
manager.addTranslationObject(new TranslationObject(c.toString(), c.d, "", ""));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -20,6 +20,9 @@
|
|||||||
////////////////////////////////////////////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||||
package com.intellectualcrafters.plot.config;
|
package com.intellectualcrafters.plot.config;
|
||||||
|
|
||||||
|
import java.util.ArrayList;
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Updater and DB settings
|
* Updater and DB settings
|
||||||
*
|
*
|
||||||
@ -28,24 +31,47 @@ package com.intellectualcrafters.plot.config;
|
|||||||
*/
|
*/
|
||||||
public class Settings {
|
public class Settings {
|
||||||
public static boolean ENABLE_CLUSTERS = false;
|
public static boolean ENABLE_CLUSTERS = false;
|
||||||
|
public static boolean FAST_CLEAR = false;
|
||||||
/**
|
/**
|
||||||
* Default UUID_FECTHING: false
|
* Default UUID_FECTHING: false
|
||||||
*/
|
*/
|
||||||
public static boolean UUID_FECTHING = false;
|
public static boolean PERMISSION_CACHING = false;
|
||||||
public static boolean UUID_FROM_DISK = false;
|
public static boolean UUID_FROM_DISK = false;
|
||||||
/**
|
/**
|
||||||
*
|
* PlotMe settings
|
||||||
*/
|
*/
|
||||||
public static boolean CONVERT_PLOTME = true;
|
public static boolean CONVERT_PLOTME = true;
|
||||||
|
public static boolean CACHE_PLOTME = false;
|
||||||
public static boolean USE_PLOTME_ALIAS = false;
|
public static boolean USE_PLOTME_ALIAS = false;
|
||||||
/**
|
/**
|
||||||
*
|
* Comment system
|
||||||
|
*/
|
||||||
|
public static int COMMENT_NOTIFICATION_INTERVAL = -1;
|
||||||
|
/**
|
||||||
|
* Chunk processor
|
||||||
|
*/
|
||||||
|
public static boolean CHUNK_PROCESSOR = false;
|
||||||
|
public static int CHUNK_PROCESSOR_MAX_BLOCKSTATES = 4096;
|
||||||
|
public static int CHUNK_PROCESSOR_MAX_ENTITIES = 512;
|
||||||
|
/**
|
||||||
|
* TNT listener
|
||||||
|
*/
|
||||||
|
public static boolean TNT_LISTENER = false;
|
||||||
|
/**
|
||||||
|
* Check for falling blocks when pistons extend?
|
||||||
|
*/
|
||||||
|
public static boolean PISTON_FALLING_BLOCK_CHECK = true;
|
||||||
|
/**
|
||||||
|
* Max auto claiming size
|
||||||
*/
|
*/
|
||||||
public static int MAX_AUTO_SIZE = 4;
|
public static int MAX_AUTO_SIZE = 4;
|
||||||
/**
|
/**
|
||||||
* Default worldedit-require-selection-in-mask: false
|
* Default worldedit-require-selection-in-mask: false
|
||||||
*/
|
*/
|
||||||
public static boolean REQUIRE_SELECTION = true;
|
public static boolean REQUIRE_SELECTION = true;
|
||||||
|
public static long WE_MAX_VOLUME = 500000;
|
||||||
|
public static long WE_MAX_ITERATIONS = 1000;
|
||||||
|
public static List<String> WE_BLACKLIST = new ArrayList<>();
|
||||||
/**
|
/**
|
||||||
* Default kill road mobs: true
|
* Default kill road mobs: true
|
||||||
*/
|
*/
|
||||||
@ -58,14 +84,6 @@ public class Settings {
|
|||||||
* Teleport to path on login
|
* Teleport to path on login
|
||||||
*/
|
*/
|
||||||
public static boolean TELEPORT_ON_LOGIN = false;
|
public static boolean TELEPORT_ON_LOGIN = false;
|
||||||
/**
|
|
||||||
* Mob Cap Enabled
|
|
||||||
*/
|
|
||||||
// public static boolean MOB_CAP_ENABLED = false;
|
|
||||||
/**
|
|
||||||
* The Mob Cap
|
|
||||||
*/
|
|
||||||
// public static int MOB_CAP = 20;
|
|
||||||
/**
|
/**
|
||||||
* Display titles
|
* Display titles
|
||||||
*/
|
*/
|
||||||
@ -135,13 +153,19 @@ public class Settings {
|
|||||||
/**
|
/**
|
||||||
* Use offline mode storage
|
* Use offline mode storage
|
||||||
*/
|
*/
|
||||||
|
public static boolean TWIN_MODE_UUID = false;
|
||||||
public static boolean OFFLINE_MODE = false;
|
public static boolean OFFLINE_MODE = false;
|
||||||
|
public static boolean UUID_LOWERCASE = false;
|
||||||
/**
|
/**
|
||||||
* Command confirmation
|
* Command confirmation
|
||||||
*/
|
*/
|
||||||
public static boolean CONFIRM_CLEAR = true;
|
public static boolean CONFIRM_CLEAR = true;
|
||||||
public static boolean CONFIRM_DELETE = true;
|
public static boolean CONFIRM_DELETE = true;
|
||||||
public static boolean CONFIRM_UNLINK = true;
|
public static boolean CONFIRM_UNLINK = true;
|
||||||
|
/**
|
||||||
|
* Use global plot limit?
|
||||||
|
*/
|
||||||
|
public static boolean GLOBAL_LIMIT = false;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Database settings
|
* Database settings
|
||||||
|
@ -32,8 +32,9 @@ import com.intellectualcrafters.plot.flag.Flag;
|
|||||||
import com.intellectualcrafters.plot.object.Plot;
|
import com.intellectualcrafters.plot.object.Plot;
|
||||||
import com.intellectualcrafters.plot.object.PlotCluster;
|
import com.intellectualcrafters.plot.object.PlotCluster;
|
||||||
import com.intellectualcrafters.plot.object.PlotClusterId;
|
import com.intellectualcrafters.plot.object.PlotClusterId;
|
||||||
import com.intellectualcrafters.plot.object.PlotComment;
|
|
||||||
import com.intellectualcrafters.plot.object.PlotId;
|
import com.intellectualcrafters.plot.object.PlotId;
|
||||||
|
import com.intellectualcrafters.plot.object.RunnableVal;
|
||||||
|
import com.intellectualcrafters.plot.object.comment.PlotComment;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @author Citymonstret
|
* @author Citymonstret
|
||||||
@ -59,14 +60,7 @@ public interface AbstractDB {
|
|||||||
*
|
*
|
||||||
* @param plots Plots for which the default table entries should be created
|
* @param plots Plots for which the default table entries should be created
|
||||||
*/
|
*/
|
||||||
public void createAllSettingsAndHelpers(final ArrayList<Plot> plots);
|
public void createPlotsAndData(final ArrayList<Plot> plots, Runnable whenDone);
|
||||||
|
|
||||||
/**
|
|
||||||
* Create a plot
|
|
||||||
*
|
|
||||||
* @param plots Plots that should be created
|
|
||||||
*/
|
|
||||||
public void createPlots(final ArrayList<Plot> plots);
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Create a plot
|
* Create a plot
|
||||||
@ -115,8 +109,7 @@ public interface AbstractDB {
|
|||||||
* Get the id of a given plot cluster
|
* Get the id of a given plot cluster
|
||||||
*
|
*
|
||||||
* @param world Which the plot is located in
|
* @param world Which the plot is located in
|
||||||
* @param pos1 bottom Plot ID
|
* @param id cluster id
|
||||||
* @param pos2 top Plot ID
|
|
||||||
*
|
*
|
||||||
* @return Integer = Cluster Entry Id
|
* @return Integer = Cluster Entry Id
|
||||||
*/
|
*/
|
||||||
@ -160,7 +153,6 @@ public interface AbstractDB {
|
|||||||
/**
|
/**
|
||||||
* Set cluster flags
|
* Set cluster flags
|
||||||
*
|
*
|
||||||
* @param world World in which the plot is located
|
|
||||||
* @param cluster PlotCluster Object
|
* @param cluster PlotCluster Object
|
||||||
* @param flags flags to set (flag[])
|
* @param flags flags to set (flag[])
|
||||||
*/
|
*/
|
||||||
@ -183,7 +175,7 @@ public interface AbstractDB {
|
|||||||
* Purgle a plot
|
* Purgle a plot
|
||||||
*
|
*
|
||||||
* @param world World in which the plot is located
|
* @param world World in which the plot is located
|
||||||
* @param id Plot ID
|
* @param uniqueIds list of plot id (db) to be purged
|
||||||
*/
|
*/
|
||||||
public void purgeIds(final String world, final Set<Integer> uniqueIds);
|
public void purgeIds(final String world, final Set<Integer> uniqueIds);
|
||||||
|
|
||||||
@ -219,7 +211,7 @@ public interface AbstractDB {
|
|||||||
/**
|
/**
|
||||||
*
|
*
|
||||||
* @param id
|
* @param id
|
||||||
* @return
|
* @return HashMap<String, Object>
|
||||||
*/
|
*/
|
||||||
public HashMap<String, Object> getClusterSettings(final int id);
|
public HashMap<String, Object> getClusterSettings(final int id);
|
||||||
|
|
||||||
@ -276,13 +268,13 @@ public interface AbstractDB {
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* @param plot Plot Object
|
* @param plot Plot Object
|
||||||
* @param player Player that should be added
|
* @param uuid Player uuid
|
||||||
*/
|
*/
|
||||||
public void removeDenied(final String world, final Plot plot, final UUID uuid);
|
public void removeDenied(final String world, final Plot plot, final UUID uuid);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @param plot Plot Object
|
* @param plot Plot Object
|
||||||
* @param player Player that should be added
|
* @param uuid Player uuid that should be added
|
||||||
*/
|
*/
|
||||||
public void setDenied(final String world, final Plot plot, final UUID uuid);
|
public void setDenied(final String world, final Plot plot, final UUID uuid);
|
||||||
|
|
||||||
@ -304,6 +296,13 @@ public interface AbstractDB {
|
|||||||
*/
|
*/
|
||||||
public void removeComment(final String world, final Plot plot, final PlotComment comment);
|
public void removeComment(final String world, final Plot plot, final PlotComment comment);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Clear an inbox
|
||||||
|
* @param plot
|
||||||
|
* @param inbox
|
||||||
|
*/
|
||||||
|
public void clearInbox(Plot plot, String inbox);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Set a plot comment
|
* Set a plot comment
|
||||||
*
|
*
|
||||||
@ -322,7 +321,7 @@ public interface AbstractDB {
|
|||||||
*
|
*
|
||||||
* @return Plot Comments within the specified tier
|
* @return Plot Comments within the specified tier
|
||||||
*/
|
*/
|
||||||
public ArrayList<PlotComment> getComments(final String world, final Plot plot, final int tier, boolean below);
|
public void getComments(final String world, final Plot plot, final String inbox, RunnableVal whenDone);
|
||||||
|
|
||||||
public void createPlotAndSettings(Plot plot);
|
public void createPlotAndSettings(Plot plot);
|
||||||
|
|
||||||
@ -330,5 +329,10 @@ public interface AbstractDB {
|
|||||||
|
|
||||||
public void resizeCluster(PlotCluster current, PlotClusterId resize);
|
public void resizeCluster(PlotCluster current, PlotClusterId resize);
|
||||||
|
|
||||||
public void movePlot(String world, PlotId originalPlot, PlotId newPlot);
|
public void movePlot(Plot originalPlot, Plot newPlot);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Don't fuck with this one, unless you enjoy it rough
|
||||||
|
*/
|
||||||
|
public boolean deleteTables();
|
||||||
}
|
}
|
||||||
|
@ -20,6 +20,9 @@
|
|||||||
////////////////////////////////////////////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||||
package com.intellectualcrafters.plot.database;
|
package com.intellectualcrafters.plot.database;
|
||||||
|
|
||||||
|
import java.sql.ResultSet;
|
||||||
|
import java.sql.ResultSetMetaData;
|
||||||
|
import java.sql.SQLException;
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.HashMap;
|
import java.util.HashMap;
|
||||||
import java.util.HashSet;
|
import java.util.HashSet;
|
||||||
@ -31,8 +34,9 @@ import com.intellectualcrafters.plot.flag.Flag;
|
|||||||
import com.intellectualcrafters.plot.object.Plot;
|
import com.intellectualcrafters.plot.object.Plot;
|
||||||
import com.intellectualcrafters.plot.object.PlotCluster;
|
import com.intellectualcrafters.plot.object.PlotCluster;
|
||||||
import com.intellectualcrafters.plot.object.PlotClusterId;
|
import com.intellectualcrafters.plot.object.PlotClusterId;
|
||||||
import com.intellectualcrafters.plot.object.PlotComment;
|
|
||||||
import com.intellectualcrafters.plot.object.PlotId;
|
import com.intellectualcrafters.plot.object.PlotId;
|
||||||
|
import com.intellectualcrafters.plot.object.RunnableVal;
|
||||||
|
import com.intellectualcrafters.plot.object.comment.PlotComment;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* DB Functions
|
* DB Functions
|
||||||
@ -50,10 +54,31 @@ public class DBFunc {
|
|||||||
*/
|
*/
|
||||||
public static AbstractDB dbManager;
|
public static AbstractDB dbManager;
|
||||||
|
|
||||||
public static void movePlot(final String world, final PlotId originalPlot, final PlotId newPlot) {
|
public static void movePlot(final Plot originalPlot, final Plot newPlot) {
|
||||||
dbManager.movePlot(world, originalPlot, newPlot);
|
dbManager.movePlot(originalPlot, newPlot);
|
||||||
|
}
|
||||||
|
/**
|
||||||
|
* Check if a resultset contains a column
|
||||||
|
* @param rs
|
||||||
|
* @param columnName
|
||||||
|
* @return
|
||||||
|
* @throws SQLException
|
||||||
|
*/
|
||||||
|
public static boolean hasColumn(ResultSet r, String name) {
|
||||||
|
try {
|
||||||
|
ResultSetMetaData meta = r.getMetaData();
|
||||||
|
int count = meta.getColumnCount();
|
||||||
|
for (int x = 1; x <= count; x++) {
|
||||||
|
if (name.equals(meta.getColumnName(x))) {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
catch (SQLException e) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Set the owner of a plot
|
* Set the owner of a plot
|
||||||
*
|
*
|
||||||
@ -69,17 +94,8 @@ public class DBFunc {
|
|||||||
*
|
*
|
||||||
* @param plots List containing all plot objects
|
* @param plots List containing all plot objects
|
||||||
*/
|
*/
|
||||||
public static void createAllSettingsAndHelpers(final ArrayList<Plot> plots) {
|
public static void createPlotsAndData(final ArrayList<Plot> plots, Runnable whenDone) {
|
||||||
dbManager.createAllSettingsAndHelpers(plots);
|
dbManager.createPlotsAndData(plots, whenDone);
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Create all plots
|
|
||||||
*
|
|
||||||
* @param plots A list containing plot objects
|
|
||||||
*/
|
|
||||||
public static void createPlots(final ArrayList<Plot> plots) {
|
|
||||||
dbManager.createPlots(plots);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -198,9 +214,9 @@ public class DBFunc {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @param id
|
|
||||||
*
|
*
|
||||||
* @return
|
* @param id
|
||||||
|
* @return HashMap<String, Object>
|
||||||
*/
|
*/
|
||||||
public static HashMap<String, Object> getSettings(final int id) {
|
public static HashMap<String, Object> getSettings(final int id) {
|
||||||
return dbManager.getSettings(id);
|
return dbManager.getSettings(id);
|
||||||
@ -214,6 +230,10 @@ public class DBFunc {
|
|||||||
dbManager.removeComment(world, plot, comment);
|
dbManager.removeComment(world, plot, comment);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static void clearInbox(final Plot plot, final String inbox) {
|
||||||
|
dbManager.clearInbox(plot, inbox);
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @param plot
|
* @param plot
|
||||||
* @param comment
|
* @param comment
|
||||||
@ -225,13 +245,13 @@ public class DBFunc {
|
|||||||
/**
|
/**
|
||||||
* @param plot
|
* @param plot
|
||||||
*/
|
*/
|
||||||
public static ArrayList<PlotComment> getComments(final String world, final Plot plot, final int tier, final boolean below) {
|
public static void getComments(final String world, final Plot plot, final String inbox, RunnableVal whenDone) {
|
||||||
return dbManager.getComments(world, plot, tier, below);
|
dbManager.getComments(world, plot, inbox, whenDone);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @param plot
|
* @param plot
|
||||||
* @param player
|
* @param uuid
|
||||||
*/
|
*/
|
||||||
public static void removeHelper(final String world, final Plot plot, final UUID uuid) {
|
public static void removeHelper(final String world, final Plot plot, final UUID uuid) {
|
||||||
dbManager.removeHelper(world, plot, uuid);
|
dbManager.removeHelper(world, plot, uuid);
|
||||||
@ -239,7 +259,7 @@ public class DBFunc {
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* @param cluster
|
* @param cluster
|
||||||
* @param player
|
* @param uuid
|
||||||
*/
|
*/
|
||||||
public static void removeHelper(final PlotCluster cluster, final UUID uuid) {
|
public static void removeHelper(final PlotCluster cluster, final UUID uuid) {
|
||||||
dbManager.removeHelper(cluster, uuid);
|
dbManager.removeHelper(cluster, uuid);
|
||||||
@ -248,14 +268,12 @@ public class DBFunc {
|
|||||||
/**
|
/**
|
||||||
* @param world
|
* @param world
|
||||||
* @param cluster
|
* @param cluster
|
||||||
* @param name
|
|
||||||
*/
|
*/
|
||||||
public static void createCluster(final String world, final PlotCluster cluster) {
|
public static void createCluster(final String world, final PlotCluster cluster) {
|
||||||
dbManager.createCluster(cluster);
|
dbManager.createCluster(cluster);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @param world
|
|
||||||
* @param current
|
* @param current
|
||||||
* @param resize
|
* @param resize
|
||||||
*/
|
*/
|
||||||
@ -265,7 +283,7 @@ public class DBFunc {
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* @param plot
|
* @param plot
|
||||||
* @param player
|
* @param uuid
|
||||||
*/
|
*/
|
||||||
public static void removeTrusted(final String world, final Plot plot, final UUID uuid) {
|
public static void removeTrusted(final String world, final Plot plot, final UUID uuid) {
|
||||||
dbManager.removeTrusted(world, plot, uuid);
|
dbManager.removeTrusted(world, plot, uuid);
|
||||||
@ -273,8 +291,7 @@ public class DBFunc {
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
*
|
*
|
||||||
* @param world
|
* @param cluster
|
||||||
* @param plot
|
|
||||||
* @param uuid
|
* @param uuid
|
||||||
*/
|
*/
|
||||||
public static void removeInvited(final PlotCluster cluster, final UUID uuid) {
|
public static void removeInvited(final PlotCluster cluster, final UUID uuid) {
|
||||||
@ -282,8 +299,9 @@ public class DBFunc {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
* @param world
|
||||||
* @param plot
|
* @param plot
|
||||||
* @param player
|
* @param uuid
|
||||||
*/
|
*/
|
||||||
public static void setHelper(final String world, final Plot plot, final UUID uuid) {
|
public static void setHelper(final String world, final Plot plot, final UUID uuid) {
|
||||||
dbManager.setHelper(world, plot, uuid);
|
dbManager.setHelper(world, plot, uuid);
|
||||||
@ -294,8 +312,9 @@ public class DBFunc {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
* @param world
|
||||||
* @param plot
|
* @param plot
|
||||||
* @param player
|
* @param uuid
|
||||||
*/
|
*/
|
||||||
public static void setTrusted(final String world, final Plot plot, final UUID uuid) {
|
public static void setTrusted(final String world, final Plot plot, final UUID uuid) {
|
||||||
dbManager.setTrusted(world, plot, uuid);
|
dbManager.setTrusted(world, plot, uuid);
|
||||||
@ -306,16 +325,18 @@ public class DBFunc {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
* @param world
|
||||||
* @param plot
|
* @param plot
|
||||||
* @param player
|
* @param uuid
|
||||||
*/
|
*/
|
||||||
public static void removeDenied(final String world, final Plot plot, final UUID uuid) {
|
public static void removeDenied(final String world, final Plot plot, final UUID uuid) {
|
||||||
dbManager.removeDenied(world, plot, uuid);
|
dbManager.removeDenied(world, plot, uuid);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
* @param world
|
||||||
* @param plot
|
* @param plot
|
||||||
* @param player
|
* @param uuid
|
||||||
*/
|
*/
|
||||||
public static void setDenied(final String world, final Plot plot, final UUID uuid) {
|
public static void setDenied(final String world, final Plot plot, final UUID uuid) {
|
||||||
dbManager.setDenied(world, plot, uuid);
|
dbManager.setDenied(world, plot, uuid);
|
||||||
|
@ -47,6 +47,8 @@ public abstract class Database {
|
|||||||
this.plotsquared = plotsquared;
|
this.plotsquared = plotsquared;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public abstract Connection forceConnection() throws SQLException, ClassNotFoundException ;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Opens a connection with the database
|
* Opens a connection with the database
|
||||||
*
|
*
|
||||||
|
@ -45,7 +45,6 @@ public class MySQL extends Database {
|
|||||||
/**
|
/**
|
||||||
* Creates a new MySQL instance
|
* Creates a new MySQL instance
|
||||||
*
|
*
|
||||||
* @param plugin Plugin instance
|
|
||||||
* @param hostname Name of the host
|
* @param hostname Name of the host
|
||||||
* @param port Port number
|
* @param port Port number
|
||||||
* @param database Database name
|
* @param database Database name
|
||||||
|
@ -1,325 +0,0 @@
|
|||||||
////////////////////////////////////////////////////////////////////////////////////////////////////
|
|
||||||
// PlotSquared - A plot manager and world generator for the Bukkit API /
|
|
||||||
// Copyright (c) 2014 IntellectualSites/IntellectualCrafters /
|
|
||||||
// /
|
|
||||||
// This program is free software; you can redistribute it and/or modify /
|
|
||||||
// it under the terms of the GNU General Public License as published by /
|
|
||||||
// the Free Software Foundation; either version 3 of the License, or /
|
|
||||||
// (at your option) any later version. /
|
|
||||||
// /
|
|
||||||
// This program is distributed in the hope that it will be useful, /
|
|
||||||
// but WITHOUT ANY WARRANTY; without even the implied warranty of /
|
|
||||||
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the /
|
|
||||||
// GNU General Public License for more details. /
|
|
||||||
// /
|
|
||||||
// You should have received a copy of the GNU General Public License /
|
|
||||||
// along with this program; if not, write to the Free Software Foundation, /
|
|
||||||
// Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA /
|
|
||||||
// /
|
|
||||||
// You can contact us via: support@intellectualsites.com /
|
|
||||||
////////////////////////////////////////////////////////////////////////////////////////////////////
|
|
||||||
package com.intellectualcrafters.plot.database;
|
|
||||||
|
|
||||||
import java.io.File;
|
|
||||||
import java.io.IOException;
|
|
||||||
import java.sql.Connection;
|
|
||||||
import java.sql.DriverManager;
|
|
||||||
import java.sql.ResultSet;
|
|
||||||
import java.sql.Statement;
|
|
||||||
import java.util.ArrayList;
|
|
||||||
import java.util.Arrays;
|
|
||||||
import java.util.HashMap;
|
|
||||||
import java.util.Set;
|
|
||||||
import java.util.UUID;
|
|
||||||
|
|
||||||
import org.bukkit.Bukkit;
|
|
||||||
import org.bukkit.World;
|
|
||||||
import org.bukkit.WorldCreator;
|
|
||||||
import org.bukkit.configuration.file.FileConfiguration;
|
|
||||||
import org.bukkit.configuration.file.YamlConfiguration;
|
|
||||||
|
|
||||||
import com.intellectualcrafters.plot.PlotSquared;
|
|
||||||
import com.intellectualcrafters.plot.generator.HybridGen;
|
|
||||||
import com.intellectualcrafters.plot.object.Plot;
|
|
||||||
import com.intellectualcrafters.plot.object.PlotId;
|
|
||||||
import com.intellectualcrafters.plot.util.TaskManager;
|
|
||||||
import com.intellectualcrafters.plot.util.bukkit.UUIDHandler;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Created 2014-08-17 for PlotSquared
|
|
||||||
*
|
|
||||||
* @author Citymonstret
|
|
||||||
* @author Empire92
|
|
||||||
*/
|
|
||||||
public class PlotMeConverter {
|
|
||||||
/**
|
|
||||||
* Constructor
|
|
||||||
*
|
|
||||||
* @param plugin Plugin Used to run the converter
|
|
||||||
*/
|
|
||||||
private void sendMessage(final String message) {
|
|
||||||
PlotSquared.log("&3PlotMe&8->&3PlotSquared&8: &7" + message);
|
|
||||||
}
|
|
||||||
|
|
||||||
public void runAsync() throws Exception {
|
|
||||||
// We have to make it wait a couple of seconds
|
|
||||||
TaskManager.runTaskLaterAsync(new Runnable() {
|
|
||||||
@Override
|
|
||||||
public void run() {
|
|
||||||
try {
|
|
||||||
final ArrayList<Plot> createdPlots = new ArrayList<>();
|
|
||||||
final String dataFolder = new File(".").getAbsolutePath() + File.separator + "plugins" + File.separator + "PlotMe" + File.separator;
|
|
||||||
final File plotMeFile = new File(dataFolder + "config.yml");
|
|
||||||
if (!plotMeFile.exists()) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
sendMessage("PlotMe conversion has started. To disable this, please set 'plotme-convert.enabled' in the 'settings.yml'");
|
|
||||||
sendMessage("Connecting to PlotMe DB");
|
|
||||||
final FileConfiguration plotConfig = YamlConfiguration.loadConfiguration(plotMeFile);
|
|
||||||
int count = 0;
|
|
||||||
Connection connection;
|
|
||||||
if (plotConfig.getBoolean("usemySQL")) {
|
|
||||||
final String user = plotConfig.getString("mySQLuname");
|
|
||||||
final String password = plotConfig.getString("mySQLpass");
|
|
||||||
final String con = plotConfig.getString("mySQLconn");
|
|
||||||
connection = DriverManager.getConnection(con, user, password);
|
|
||||||
} else {
|
|
||||||
connection = new SQLite(PlotSquared.THIS, dataFolder + File.separator + "plots.db").openConnection();
|
|
||||||
}
|
|
||||||
sendMessage("Collecting plot data");
|
|
||||||
sendMessage(" - plotmePlots");
|
|
||||||
ResultSet r;
|
|
||||||
Statement stmt;
|
|
||||||
final HashMap<String, Integer> plotSize = new HashMap<>();
|
|
||||||
final HashMap<String, HashMap<PlotId, Plot>> plots = new HashMap<>();
|
|
||||||
final Set<String> worlds = plotConfig.getConfigurationSection("worlds").getKeys(false);
|
|
||||||
stmt = connection.createStatement();
|
|
||||||
r = stmt.executeQuery("SELECT * FROM `plotmePlots`");
|
|
||||||
while (r.next()) {
|
|
||||||
count++;
|
|
||||||
final PlotId id = new PlotId(r.getInt("idX"), r.getInt("idZ"));
|
|
||||||
final String name = r.getString("owner");
|
|
||||||
final String world = getWorld(r.getString("world"));
|
|
||||||
if (!plotSize.containsKey(world)) {
|
|
||||||
final int size = r.getInt("topZ") - r.getInt("bottomZ");
|
|
||||||
plotSize.put(world, size);
|
|
||||||
plots.put(world, new HashMap<PlotId, Plot>());
|
|
||||||
}
|
|
||||||
UUID owner = UUIDHandler.getUUID(name);
|
|
||||||
if (owner == null) {
|
|
||||||
if (name.equals("*")) {
|
|
||||||
owner = DBFunc.everyone;
|
|
||||||
} else {
|
|
||||||
sendMessage("&cCould not identify owner for plot: " + id + " -> " + name);
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
final Plot plot = new Plot(id, owner, new ArrayList<UUID>(), new ArrayList<UUID>(), world);
|
|
||||||
plots.get(world).put(id, plot);
|
|
||||||
}
|
|
||||||
sendMessage(" - plotmeAllowed");
|
|
||||||
r = stmt.executeQuery("SELECT * FROM `plotmeAllowed`");
|
|
||||||
while (r.next()) {
|
|
||||||
final PlotId id = new PlotId(r.getInt("idX"), r.getInt("idZ"));
|
|
||||||
final String name = r.getString("player");
|
|
||||||
final String world = getWorld(r.getString("world"));
|
|
||||||
UUID helper = UUIDHandler.getUUID(name);
|
|
||||||
if (helper == null) {
|
|
||||||
if (name.equals("*")) {
|
|
||||||
helper = DBFunc.everyone;
|
|
||||||
} else {
|
|
||||||
sendMessage("&6Could not identify helper for plot: " + id);
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
if (plots.get(world).containsKey(id)) {
|
|
||||||
plots.get(world).get(id).helpers.add(helper);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
sendMessage(" - plotmeDenied");
|
|
||||||
r = stmt.executeQuery("SELECT * FROM `plotmeDenied`");
|
|
||||||
while (r.next()) {
|
|
||||||
final PlotId id = new PlotId(r.getInt("idX"), r.getInt("idZ"));
|
|
||||||
final String name = r.getString("player");
|
|
||||||
final String world = getWorld(r.getString("world"));
|
|
||||||
UUID denied = UUIDHandler.getUUID(name);
|
|
||||||
if (denied == null) {
|
|
||||||
if (name.equals("*")) {
|
|
||||||
denied = DBFunc.everyone;
|
|
||||||
} else {
|
|
||||||
sendMessage("&6Could not identify denied for plot: " + id);
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
if (plots.get(world).containsKey(id)) {
|
|
||||||
plots.get(world).get(id).denied.add(denied);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
sendMessage("Collected " + count + " plots from PlotMe");
|
|
||||||
for (final String world : plots.keySet()) {
|
|
||||||
sendMessage("Copying config for: " + world);
|
|
||||||
try {
|
|
||||||
final String plotMeWorldName = world.toLowerCase();
|
|
||||||
final Integer pathwidth = plotConfig.getInt("worlds." + plotMeWorldName + ".PathWidth"); //
|
|
||||||
PlotSquared.config.set("worlds." + world + ".road.width", pathwidth);
|
|
||||||
final Integer plotsize = plotConfig.getInt("worlds." + plotMeWorldName + ".PlotSize"); //
|
|
||||||
PlotSquared.config.set("worlds." + world + ".plot.size", plotsize);
|
|
||||||
final String wallblock = plotConfig.getString("worlds." + plotMeWorldName + ".WallBlockId"); //
|
|
||||||
PlotSquared.config.set("worlds." + world + ".wall.block", wallblock);
|
|
||||||
final String floor = plotConfig.getString("worlds." + plotMeWorldName + ".PlotFloorBlockId"); //
|
|
||||||
PlotSquared.config.set("worlds." + world + ".plot.floor", Arrays.asList(floor));
|
|
||||||
final String filling = plotConfig.getString("worlds." + plotMeWorldName + ".PlotFillingBlockId"); //
|
|
||||||
PlotSquared.config.set("worlds." + world + ".plot.filling", Arrays.asList(filling));
|
|
||||||
final String road = plotConfig.getString("worlds." + plotMeWorldName + ".RoadMainBlockId");
|
|
||||||
PlotSquared.config.set("worlds." + world + ".road.block", road);
|
|
||||||
Integer height = plotConfig.getInt("worlds." + plotMeWorldName + ".RoadHeight"); //
|
|
||||||
if (height == null) {
|
|
||||||
height = 64;
|
|
||||||
}
|
|
||||||
PlotSquared.config.set("worlds." + world + ".road.height", height);
|
|
||||||
} catch (final Exception e) {
|
|
||||||
sendMessage("&c-- &lFailed to save configuration for world '" + world + "'\nThis will need to be done using the setup command, or manually");
|
|
||||||
}
|
|
||||||
}
|
|
||||||
final File PLOTME_DG_FILE = new File(dataFolder + File.separator + "PlotMe-DefaultGenerator" + File.separator + "config.yml");
|
|
||||||
if (PLOTME_DG_FILE.exists()) {
|
|
||||||
final YamlConfiguration PLOTME_DG_YML = YamlConfiguration.loadConfiguration(PLOTME_DG_FILE);
|
|
||||||
try {
|
|
||||||
for (final String world : plots.keySet()) {
|
|
||||||
final String plotMeWorldName = world.toLowerCase();
|
|
||||||
Integer pathwidth = PLOTME_DG_YML.getInt("worlds." + plotMeWorldName + ".PathWidth"); //
|
|
||||||
if (pathwidth == null) {
|
|
||||||
pathwidth = 7;
|
|
||||||
}
|
|
||||||
PlotSquared.config.set("worlds." + world + ".road.width", pathwidth);
|
|
||||||
Integer plotsize = PLOTME_DG_YML.getInt("worlds." + plotMeWorldName + ".PlotSize"); //
|
|
||||||
if (plotsize == null) {
|
|
||||||
plotsize = 32;
|
|
||||||
}
|
|
||||||
PlotSquared.config.set("worlds." + world + ".plot.size", plotsize);
|
|
||||||
String wallblock = PLOTME_DG_YML.getString("worlds." + plotMeWorldName + ".WallBlock"); //
|
|
||||||
if (wallblock == null) {
|
|
||||||
wallblock = "44";
|
|
||||||
}
|
|
||||||
PlotSquared.config.set("worlds." + world + ".wall.block", wallblock);
|
|
||||||
String floor = PLOTME_DG_YML.getString("worlds." + plotMeWorldName + ".PlotFloorBlock"); //
|
|
||||||
if (floor == null) {
|
|
||||||
floor = "2";
|
|
||||||
}
|
|
||||||
PlotSquared.config.set("worlds." + world + ".plot.floor", Arrays.asList(floor));
|
|
||||||
String filling = PLOTME_DG_YML.getString("worlds." + plotMeWorldName + ".FillBlock"); //
|
|
||||||
if (filling == null) {
|
|
||||||
filling = "3";
|
|
||||||
}
|
|
||||||
PlotSquared.config.set("worlds." + world + ".plot.filling", Arrays.asList(filling));
|
|
||||||
String road = PLOTME_DG_YML.getString("worlds." + plotMeWorldName + ".RoadMainBlock");
|
|
||||||
if (road == null) {
|
|
||||||
road = "5";
|
|
||||||
}
|
|
||||||
PlotSquared.config.set("worlds." + world + ".road.block", road);
|
|
||||||
Integer height = PLOTME_DG_YML.getInt("worlds." + plotMeWorldName + ".RoadHeight"); //
|
|
||||||
if ((height == null) || (height == 0)) {
|
|
||||||
height = PLOTME_DG_YML.getInt("worlds." + plotMeWorldName + ".GroundHeight"); //
|
|
||||||
if ((height == null) || (height == 0)) {
|
|
||||||
height = 64;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
PlotSquared.config.set("worlds." + world + ".road.height", height);
|
|
||||||
PlotSquared.config.set("worlds." + world + ".plot.height", height);
|
|
||||||
PlotSquared.config.set("worlds." + world + ".wall.height", height);
|
|
||||||
}
|
|
||||||
} catch (final Exception e) {
|
|
||||||
}
|
|
||||||
}
|
|
||||||
for (final String world : plots.keySet()) {
|
|
||||||
int duplicate = 0;
|
|
||||||
for (final Plot plot : plots.get(world).values()) {
|
|
||||||
if (!PlotSquared.getPlots(world).containsKey(plot.id)) {
|
|
||||||
createdPlots.add(plot);
|
|
||||||
} else {
|
|
||||||
duplicate++;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
if (duplicate > 0) {
|
|
||||||
PlotSquared.log("&c[WARNING] Found " + duplicate + " duplicate plots already in DB for world: '" + world + "'. Have you run the converter already?");
|
|
||||||
}
|
|
||||||
}
|
|
||||||
sendMessage("Creating plot DB");
|
|
||||||
Thread.sleep(1000);
|
|
||||||
DBFunc.createPlots(createdPlots);
|
|
||||||
sendMessage("Creating settings/helpers DB");
|
|
||||||
DBFunc.createAllSettingsAndHelpers(createdPlots);
|
|
||||||
sendMessage("Saving configuration...");
|
|
||||||
try {
|
|
||||||
PlotSquared.config.save(PlotSquared.configFile);
|
|
||||||
} catch (final IOException e) {
|
|
||||||
sendMessage(" - &cFailed to save configuration.");
|
|
||||||
}
|
|
||||||
TaskManager.runTask(new Runnable() {
|
|
||||||
@Override
|
|
||||||
public void run() {
|
|
||||||
try {
|
|
||||||
boolean MV = false;
|
|
||||||
boolean MW = false;
|
|
||||||
if ((Bukkit.getPluginManager().getPlugin("Multiverse-Core") != null) && Bukkit.getPluginManager().getPlugin("Multiverse-Core").isEnabled()) {
|
|
||||||
MV = true;
|
|
||||||
} else if ((Bukkit.getPluginManager().getPlugin("MultiWorld") != null) && Bukkit.getPluginManager().getPlugin("MultiWorld").isEnabled()) {
|
|
||||||
MW = true;
|
|
||||||
}
|
|
||||||
for (final String worldname : worlds) {
|
|
||||||
final World world = Bukkit.getWorld(getWorld(worldname));
|
|
||||||
final String actualWorldName = world.getName();
|
|
||||||
sendMessage("Reloading generator for world: '" + actualWorldName + "'...");
|
|
||||||
PlotSquared.removePlotWorld(actualWorldName);
|
|
||||||
if (MV) {
|
|
||||||
// unload
|
|
||||||
Bukkit.getServer().dispatchCommand(Bukkit.getServer().getConsoleSender(), "mv unload " + actualWorldName);
|
|
||||||
try {
|
|
||||||
Thread.sleep(1000);
|
|
||||||
} catch (final InterruptedException ex) {
|
|
||||||
Thread.currentThread().interrupt();
|
|
||||||
}
|
|
||||||
// load
|
|
||||||
Bukkit.getServer().dispatchCommand(Bukkit.getServer().getConsoleSender(), "mv import " + actualWorldName + " normal -g PlotSquared");
|
|
||||||
} else if (MW) {
|
|
||||||
// unload
|
|
||||||
Bukkit.getServer().dispatchCommand(Bukkit.getServer().getConsoleSender(), "mw unload " + actualWorldName);
|
|
||||||
try {
|
|
||||||
Thread.sleep(1000);
|
|
||||||
} catch (final InterruptedException ex) {
|
|
||||||
Thread.currentThread().interrupt();
|
|
||||||
}
|
|
||||||
// load
|
|
||||||
Bukkit.getServer().dispatchCommand(Bukkit.getServer().getConsoleSender(), "mw create " + actualWorldName + " plugin:PlotSquared");
|
|
||||||
} else {
|
|
||||||
Bukkit.getServer().unloadWorld(world, true);
|
|
||||||
final World myworld = WorldCreator.name(actualWorldName).generator(new HybridGen()).createWorld();
|
|
||||||
myworld.save();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
PlotSquared.setAllPlotsRaw(DBFunc.getPlots());
|
|
||||||
} catch (final Exception e) {
|
|
||||||
e.printStackTrace();
|
|
||||||
}
|
|
||||||
sendMessage("Conversion has finished");
|
|
||||||
PlotSquared.log("&c - Stop the server");
|
|
||||||
PlotSquared.log("&c - Disable 'plotme-convert.enabled' in the settings.yml");
|
|
||||||
PlotSquared.log("&c - Correct any generator settings that haven't copied to 'settings.yml' properly");
|
|
||||||
PlotSquared.log("&c - Start the server");
|
|
||||||
}
|
|
||||||
});
|
|
||||||
} catch (final Exception e) {
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}, 20);
|
|
||||||
}
|
|
||||||
|
|
||||||
public String getWorld(final String world) {
|
|
||||||
for (final World newworld : Bukkit.getWorlds()) {
|
|
||||||
if (newworld.getName().equalsIgnoreCase(world)) {
|
|
||||||
return newworld.getName();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return world;
|
|
||||||
}
|
|
||||||
}
|
|
File diff suppressed because it is too large
Load Diff
@ -43,7 +43,6 @@ public class SQLite extends Database {
|
|||||||
/**
|
/**
|
||||||
* Creates a new SQLite instance
|
* Creates a new SQLite instance
|
||||||
*
|
*
|
||||||
* @param plugin Plugin instance
|
|
||||||
* @param dbLocation Location of the Database (Must end in .db)
|
* @param dbLocation Location of the Database (Must end in .db)
|
||||||
*/
|
*/
|
||||||
public SQLite(final PlotSquared plotsquared, final String dbLocation) {
|
public SQLite(final PlotSquared plotsquared, final String dbLocation) {
|
||||||
@ -108,4 +107,11 @@ public class SQLite extends Database {
|
|||||||
final Statement statement = this.connection.createStatement();
|
final Statement statement = this.connection.createStatement();
|
||||||
return statement.executeUpdate(query);
|
return statement.executeUpdate(query);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public Connection forceConnection() throws SQLException, ClassNotFoundException {
|
||||||
|
Class.forName("org.sqlite.JDBC");
|
||||||
|
this.connection = DriverManager.getConnection("jdbc:sqlite:" + this.dbLocation);
|
||||||
|
return this.connection;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@ -0,0 +1,35 @@
|
|||||||
|
package com.intellectualcrafters.plot.database;
|
||||||
|
|
||||||
|
import java.sql.PreparedStatement;
|
||||||
|
import java.sql.SQLException;
|
||||||
|
|
||||||
|
import org.apache.commons.lang.StringUtils;
|
||||||
|
|
||||||
|
public abstract class StmtMod<T> {
|
||||||
|
public abstract String getCreateMySQL(int size);
|
||||||
|
|
||||||
|
public String getCreateMySQL(int size, String query, int params) {
|
||||||
|
final StringBuilder statement = new StringBuilder(query);
|
||||||
|
for (int i = 0; i < size - 1; i++) {
|
||||||
|
statement.append(StringUtils.repeat("(?),", params));
|
||||||
|
}
|
||||||
|
statement.append(StringUtils.repeat(",(?)", params).substring(1));
|
||||||
|
return statement.toString();
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getCreateSQLite(int size, String query, int params) {
|
||||||
|
StringBuilder statement = new StringBuilder(query);
|
||||||
|
String modParams = StringUtils.repeat(",?", params).substring(1);
|
||||||
|
for (int i = 0; i < (size - 1); i++) {
|
||||||
|
statement.append("UNION SELECT " + modParams + " ");
|
||||||
|
}
|
||||||
|
return statement.toString();
|
||||||
|
}
|
||||||
|
|
||||||
|
public abstract String getCreateSQLite(int size);
|
||||||
|
public abstract String getCreateSQL();
|
||||||
|
|
||||||
|
public abstract void setMySQL(PreparedStatement stmt, int i, T obj) throws SQLException;
|
||||||
|
public abstract void setSQLite(PreparedStatement stmt, int i, T obj) throws SQLException;
|
||||||
|
public abstract void setSQL(PreparedStatement stmt, T obj) throws SQLException;
|
||||||
|
}
|
@ -0,0 +1,16 @@
|
|||||||
|
package com.intellectualcrafters.plot.database.plotme;
|
||||||
|
|
||||||
|
import java.sql.Connection;
|
||||||
|
import java.sql.SQLException;
|
||||||
|
import java.util.HashMap;
|
||||||
|
|
||||||
|
import org.bukkit.configuration.file.FileConfiguration;
|
||||||
|
|
||||||
|
import com.intellectualcrafters.plot.object.Plot;
|
||||||
|
import com.intellectualcrafters.plot.object.PlotId;
|
||||||
|
|
||||||
|
public abstract class APlotMeConnector {
|
||||||
|
public abstract Connection getPlotMeConnection(FileConfiguration plotConfig, String dataFolder);
|
||||||
|
|
||||||
|
public abstract HashMap<String, HashMap<PlotId, Plot>> getPlotMePlots(Connection connection) throws SQLException;
|
||||||
|
}
|
@ -0,0 +1,156 @@
|
|||||||
|
package com.intellectualcrafters.plot.database.plotme;
|
||||||
|
|
||||||
|
import java.io.File;
|
||||||
|
import java.sql.Connection;
|
||||||
|
import java.sql.DriverManager;
|
||||||
|
import java.sql.PreparedStatement;
|
||||||
|
import java.sql.ResultSet;
|
||||||
|
import java.sql.SQLException;
|
||||||
|
import java.sql.Statement;
|
||||||
|
import java.util.ArrayList;
|
||||||
|
import java.util.HashMap;
|
||||||
|
import java.util.UUID;
|
||||||
|
|
||||||
|
import org.bukkit.configuration.file.FileConfiguration;
|
||||||
|
|
||||||
|
import com.intellectualcrafters.plot.PlotSquared;
|
||||||
|
import com.intellectualcrafters.plot.database.DBFunc;
|
||||||
|
import com.intellectualcrafters.plot.database.MySQL;
|
||||||
|
import com.intellectualcrafters.plot.database.SQLite;
|
||||||
|
import com.intellectualcrafters.plot.object.Plot;
|
||||||
|
import com.intellectualcrafters.plot.object.PlotId;
|
||||||
|
import com.intellectualcrafters.plot.object.StringWrapper;
|
||||||
|
import com.intellectualcrafters.plot.util.MainUtil;
|
||||||
|
import com.intellectualcrafters.plot.util.bukkit.UUIDHandler;
|
||||||
|
|
||||||
|
public class ClassicPlotMeConnector extends APlotMeConnector {
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public Connection getPlotMeConnection(FileConfiguration plotConfig, String dataFolder) {
|
||||||
|
try {
|
||||||
|
if (plotConfig.getBoolean("usemySQL")) {
|
||||||
|
final String user = plotConfig.getString("mySQLuname");
|
||||||
|
final String password = plotConfig.getString("mySQLpass");
|
||||||
|
final String con = plotConfig.getString("mySQLconn");
|
||||||
|
return DriverManager.getConnection(con, user, password);
|
||||||
|
// return new MySQL(plotsquared, hostname, port, database, username, password)
|
||||||
|
} else {
|
||||||
|
return new SQLite(PlotSquared.THIS, dataFolder + File.separator + "plots.db").openConnection();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
catch (SQLException | ClassNotFoundException e) {}
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public HashMap<String, HashMap<PlotId, Plot>> getPlotMePlots(Connection connection) throws SQLException {
|
||||||
|
ResultSet r;
|
||||||
|
PreparedStatement stmt;
|
||||||
|
final HashMap<String, Integer> plotSize = new HashMap<>();
|
||||||
|
final HashMap<String, HashMap<PlotId, Plot>> plots = new HashMap<>();
|
||||||
|
stmt = connection.prepareStatement("SELECT * FROM `plotmePlots`");
|
||||||
|
r = stmt.executeQuery();
|
||||||
|
boolean checkUUID = DBFunc.hasColumn(r, "ownerid");
|
||||||
|
|
||||||
|
while (r.next()) {
|
||||||
|
final PlotId id = new PlotId(r.getInt("idX"), r.getInt("idZ"));
|
||||||
|
final String name = r.getString("owner");
|
||||||
|
final String world = PlotMeConverter.getWorld(r.getString("world"));
|
||||||
|
if (!plotSize.containsKey(world)) {
|
||||||
|
final int size = r.getInt("topZ") - r.getInt("bottomZ");
|
||||||
|
plotSize.put(world, size);
|
||||||
|
plots.put(world, new HashMap<PlotId, Plot>());
|
||||||
|
}
|
||||||
|
UUID owner = UUIDHandler.getUUID(name);
|
||||||
|
if (owner == null) {
|
||||||
|
if (name.equals("*")) {
|
||||||
|
owner = DBFunc.everyone;
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
if (checkUUID){
|
||||||
|
try {
|
||||||
|
byte[] bytes = r.getBytes("ownerid");
|
||||||
|
if (bytes != null) {
|
||||||
|
owner = UUID.nameUUIDFromBytes(bytes);
|
||||||
|
if (owner != null) {
|
||||||
|
UUIDHandler.add(new StringWrapper(name), owner);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
catch (Exception e) {
|
||||||
|
e.printStackTrace();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (owner == null) {
|
||||||
|
MainUtil.sendConsoleMessage("&cCould not identify owner for plot: " + id + " -> '" + name + "'");
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
UUIDHandler.add(new StringWrapper(name), owner);
|
||||||
|
}
|
||||||
|
final Plot plot = new Plot(id, owner, new ArrayList<UUID>(), new ArrayList<UUID>(), world);
|
||||||
|
plots.get(world).put(id, plot);
|
||||||
|
}
|
||||||
|
|
||||||
|
r.close();
|
||||||
|
stmt.close();
|
||||||
|
|
||||||
|
try {
|
||||||
|
|
||||||
|
MainUtil.sendConsoleMessage(" - plotmeDenied");
|
||||||
|
stmt = connection.prepareStatement("SELECT * FROM `plotmeDenied`");
|
||||||
|
r = stmt.executeQuery();
|
||||||
|
|
||||||
|
while (r.next()) {
|
||||||
|
final PlotId id = new PlotId(r.getInt("idX"), r.getInt("idZ"));
|
||||||
|
final String name = r.getString("player");
|
||||||
|
final String world = PlotMeConverter.getWorld(r.getString("world"));
|
||||||
|
UUID denied = UUIDHandler.getUUID(name);
|
||||||
|
if (denied == null) {
|
||||||
|
if (name.equals("*")) {
|
||||||
|
denied = DBFunc.everyone;
|
||||||
|
} else {
|
||||||
|
MainUtil.sendConsoleMessage("&6Could not identify denied for plot: " + id);
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (plots.get(world).containsKey(id)) {
|
||||||
|
plots.get(world).get(id).denied.add(denied);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
stmt = connection.prepareStatement("SELECT * FROM `plotmeAllowed`");
|
||||||
|
r = stmt.executeQuery();
|
||||||
|
|
||||||
|
while (r.next()) {
|
||||||
|
final PlotId id = new PlotId(r.getInt("idX"), r.getInt("idZ"));
|
||||||
|
final String name = r.getString("player");
|
||||||
|
final String world = PlotMeConverter.getWorld(r.getString("world"));
|
||||||
|
UUID helper = UUIDHandler.getUUID(name);
|
||||||
|
if (helper == null) {
|
||||||
|
if (name.equals("*")) {
|
||||||
|
helper = DBFunc.everyone;
|
||||||
|
} else {
|
||||||
|
MainUtil.sendConsoleMessage("&6Could not identify helper for plot: " + id);
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (plots.get(world).containsKey(id)) {
|
||||||
|
plots.get(world).get(id).helpers.add(helper);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
r.close();
|
||||||
|
stmt.close();
|
||||||
|
|
||||||
|
}
|
||||||
|
catch (Exception e) {
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
return plots;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
@ -0,0 +1,297 @@
|
|||||||
|
////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||||
|
// PlotSquared - A plot manager and world generator for the Bukkit API /
|
||||||
|
// Copyright (c) 2014 IntellectualSites/IntellectualCrafters /
|
||||||
|
// /
|
||||||
|
// This program is free software; you can redistribute it and/or modify /
|
||||||
|
// it under the terms of the GNU General Public License as published by /
|
||||||
|
// the Free Software Foundation; either version 3 of the License, or /
|
||||||
|
// (at your option) any later version. /
|
||||||
|
// /
|
||||||
|
// This program is distributed in the hope that it will be useful, /
|
||||||
|
// but WITHOUT ANY WARRANTY; without even the implied warranty of /
|
||||||
|
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the /
|
||||||
|
// GNU General Public License for more details. /
|
||||||
|
// /
|
||||||
|
// You should have received a copy of the GNU General Public License /
|
||||||
|
// along with this program; if not, write to the Free Software Foundation, /
|
||||||
|
// Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA /
|
||||||
|
// /
|
||||||
|
// You can contact us via: support@intellectualsites.com /
|
||||||
|
////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||||
|
package com.intellectualcrafters.plot.database.plotme;
|
||||||
|
|
||||||
|
import java.io.File;
|
||||||
|
import java.io.IOException;
|
||||||
|
import java.sql.Connection;
|
||||||
|
import java.sql.DriverManager;
|
||||||
|
import java.sql.ResultSet;
|
||||||
|
import java.sql.SQLException;
|
||||||
|
import java.sql.Statement;
|
||||||
|
import java.util.ArrayList;
|
||||||
|
import java.util.Arrays;
|
||||||
|
import java.util.HashMap;
|
||||||
|
import java.util.Map.Entry;
|
||||||
|
import java.util.Set;
|
||||||
|
import java.util.UUID;
|
||||||
|
|
||||||
|
import org.bukkit.Bukkit;
|
||||||
|
import org.bukkit.World;
|
||||||
|
import org.bukkit.WorldCreator;
|
||||||
|
import org.bukkit.configuration.file.FileConfiguration;
|
||||||
|
import org.bukkit.configuration.file.YamlConfiguration;
|
||||||
|
|
||||||
|
import com.intellectualcrafters.plot.PlotSquared;
|
||||||
|
import com.intellectualcrafters.plot.config.Settings;
|
||||||
|
import com.intellectualcrafters.plot.database.DBFunc;
|
||||||
|
import com.intellectualcrafters.plot.database.SQLite;
|
||||||
|
import com.intellectualcrafters.plot.generator.HybridGen;
|
||||||
|
import com.intellectualcrafters.plot.object.Plot;
|
||||||
|
import com.intellectualcrafters.plot.object.PlotId;
|
||||||
|
import com.intellectualcrafters.plot.object.StringWrapper;
|
||||||
|
import com.intellectualcrafters.plot.util.TaskManager;
|
||||||
|
import com.intellectualcrafters.plot.util.bukkit.UUIDHandler;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Created 2014-08-17 for PlotSquared
|
||||||
|
*
|
||||||
|
* @author Citymonstret
|
||||||
|
* @author Empire92
|
||||||
|
*/
|
||||||
|
public class PlotMeConverter {
|
||||||
|
/**
|
||||||
|
* Constructor
|
||||||
|
*
|
||||||
|
* @param plugin Plugin Used to run the converter
|
||||||
|
*/
|
||||||
|
private void sendMessage(final String message) {
|
||||||
|
PlotSquared.log("&3PlotMe&8->&3PlotSquared&8: &7" + message);
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getPlotMePath() {
|
||||||
|
return new File(".").getAbsolutePath() + File.separator + "plugins" + File.separator + "PlotMe" + File.separator;
|
||||||
|
}
|
||||||
|
|
||||||
|
public FileConfiguration getPlotMeConfig(String dataFolder) {
|
||||||
|
final File plotMeFile = new File(dataFolder + "config.yml");
|
||||||
|
if (!plotMeFile.exists()) {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
return YamlConfiguration.loadConfiguration(plotMeFile);
|
||||||
|
}
|
||||||
|
|
||||||
|
public Set<String> getPlotMeWorlds(FileConfiguration plotConfig) {
|
||||||
|
return plotConfig.getConfigurationSection("worlds").getKeys(false);
|
||||||
|
}
|
||||||
|
|
||||||
|
public void run(final APlotMeConnector connector) {
|
||||||
|
try {
|
||||||
|
String dataFolder = getPlotMePath();
|
||||||
|
FileConfiguration plotConfig = getPlotMeConfig(dataFolder);
|
||||||
|
|
||||||
|
if (plotConfig == null) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
Connection connection = connector.getPlotMeConnection(plotConfig, dataFolder);
|
||||||
|
|
||||||
|
if (connection == null) {
|
||||||
|
sendMessage("Cannot connect to PlotMe DB. Conversion process will not continue");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
sendMessage("PlotMe conversion has started. To disable this, please set 'plotme-convert.enabled' in the 'settings.yml'");
|
||||||
|
sendMessage("Connecting to PlotMe DB");
|
||||||
|
|
||||||
|
int plotCount = 0;
|
||||||
|
final ArrayList<Plot> createdPlots = new ArrayList<>();
|
||||||
|
|
||||||
|
sendMessage("Collecting plot data");
|
||||||
|
sendMessage(" - plotmePlots");
|
||||||
|
final Set<String> worlds = getPlotMeWorlds(plotConfig);
|
||||||
|
HashMap<String, HashMap<PlotId, Plot>> plots = connector.getPlotMePlots(connection);
|
||||||
|
for (Entry<String, HashMap<PlotId, Plot>> entry : plots.entrySet()) {
|
||||||
|
plotCount += entry.getValue().size();
|
||||||
|
}
|
||||||
|
if (!Settings.CONVERT_PLOTME) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
sendMessage(" - plotmeAllowed");
|
||||||
|
|
||||||
|
sendMessage("Collected " + plotCount + " plots from PlotMe");
|
||||||
|
for (final String world : plots.keySet()) {
|
||||||
|
sendMessage("Copying config for: " + world);
|
||||||
|
try {
|
||||||
|
final String plotMeWorldName = world.toLowerCase();
|
||||||
|
final Integer pathwidth = plotConfig.getInt("worlds." + plotMeWorldName + ".PathWidth"); //
|
||||||
|
PlotSquared.config.set("worlds." + world + ".road.width", pathwidth);
|
||||||
|
final Integer plotsize = plotConfig.getInt("worlds." + plotMeWorldName + ".PlotSize"); //
|
||||||
|
PlotSquared.config.set("worlds." + world + ".plot.size", plotsize);
|
||||||
|
final String wallblock = plotConfig.getString("worlds." + plotMeWorldName + ".WallBlockId"); //
|
||||||
|
PlotSquared.config.set("worlds." + world + ".wall.block", wallblock);
|
||||||
|
final String floor = plotConfig.getString("worlds." + plotMeWorldName + ".PlotFloorBlockId"); //
|
||||||
|
PlotSquared.config.set("worlds." + world + ".plot.floor", Arrays.asList(floor));
|
||||||
|
final String filling = plotConfig.getString("worlds." + plotMeWorldName + ".PlotFillingBlockId"); //
|
||||||
|
PlotSquared.config.set("worlds." + world + ".plot.filling", Arrays.asList(filling));
|
||||||
|
final String road = plotConfig.getString("worlds." + plotMeWorldName + ".RoadMainBlockId");
|
||||||
|
PlotSquared.config.set("worlds." + world + ".road.block", road);
|
||||||
|
Integer height = plotConfig.getInt("worlds." + plotMeWorldName + ".RoadHeight"); //
|
||||||
|
if (height == null) {
|
||||||
|
height = 64;
|
||||||
|
}
|
||||||
|
PlotSquared.config.set("worlds." + world + ".road.height", height);
|
||||||
|
PlotSquared.config.save(PlotSquared.configFile);
|
||||||
|
} catch (final Exception e) {
|
||||||
|
sendMessage("&c-- &lFailed to save configuration for world '" + world + "'\nThis will need to be done using the setup command, or manually");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
final File PLOTME_DG_FILE = new File(dataFolder + File.separator + "PlotMe-DefaultGenerator" + File.separator + "config.yml");
|
||||||
|
if (PLOTME_DG_FILE.exists()) {
|
||||||
|
final YamlConfiguration PLOTME_DG_YML = YamlConfiguration.loadConfiguration(PLOTME_DG_FILE);
|
||||||
|
try {
|
||||||
|
for (final String world : plots.keySet()) {
|
||||||
|
final String plotMeWorldName = world.toLowerCase();
|
||||||
|
Integer pathwidth = PLOTME_DG_YML.getInt("worlds." + plotMeWorldName + ".PathWidth"); //
|
||||||
|
if (pathwidth == null) {
|
||||||
|
pathwidth = 7;
|
||||||
|
}
|
||||||
|
PlotSquared.config.set("worlds." + world + ".road.width", pathwidth);
|
||||||
|
Integer plotsize = PLOTME_DG_YML.getInt("worlds." + plotMeWorldName + ".PlotSize"); //
|
||||||
|
if (plotsize == null) {
|
||||||
|
plotsize = 32;
|
||||||
|
}
|
||||||
|
PlotSquared.config.set("worlds." + world + ".plot.size", plotsize);
|
||||||
|
String wallblock = PLOTME_DG_YML.getString("worlds." + plotMeWorldName + ".WallBlock"); //
|
||||||
|
if (wallblock == null) {
|
||||||
|
wallblock = "44";
|
||||||
|
}
|
||||||
|
PlotSquared.config.set("worlds." + world + ".wall.block", wallblock);
|
||||||
|
String floor = PLOTME_DG_YML.getString("worlds." + plotMeWorldName + ".PlotFloorBlock"); //
|
||||||
|
if (floor == null) {
|
||||||
|
floor = "2";
|
||||||
|
}
|
||||||
|
PlotSquared.config.set("worlds." + world + ".plot.floor", Arrays.asList(floor));
|
||||||
|
String filling = PLOTME_DG_YML.getString("worlds." + plotMeWorldName + ".FillBlock"); //
|
||||||
|
if (filling == null) {
|
||||||
|
filling = "3";
|
||||||
|
}
|
||||||
|
PlotSquared.config.set("worlds." + world + ".plot.filling", Arrays.asList(filling));
|
||||||
|
String road = PLOTME_DG_YML.getString("worlds." + plotMeWorldName + ".RoadMainBlock");
|
||||||
|
if (road == null) {
|
||||||
|
road = "5";
|
||||||
|
}
|
||||||
|
PlotSquared.config.set("worlds." + world + ".road.block", road);
|
||||||
|
Integer height = PLOTME_DG_YML.getInt("worlds." + plotMeWorldName + ".RoadHeight"); //
|
||||||
|
if ((height == null) || (height == 0)) {
|
||||||
|
height = PLOTME_DG_YML.getInt("worlds." + plotMeWorldName + ".GroundHeight"); //
|
||||||
|
if ((height == null) || (height == 0)) {
|
||||||
|
height = 64;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
PlotSquared.config.set("worlds." + world + ".road.height", height);
|
||||||
|
PlotSquared.config.set("worlds." + world + ".plot.height", height);
|
||||||
|
PlotSquared.config.set("worlds." + world + ".wall.height", height);
|
||||||
|
PlotSquared.config.save(PlotSquared.configFile);
|
||||||
|
}
|
||||||
|
} catch (final Exception e) {
|
||||||
|
}
|
||||||
|
}
|
||||||
|
for (final String world : plots.keySet()) {
|
||||||
|
int duplicate = 0;
|
||||||
|
for (final Plot plot : plots.get(world).values()) {
|
||||||
|
if (!PlotSquared.getPlots(world).containsKey(plot.id)) {
|
||||||
|
createdPlots.add(plot);
|
||||||
|
} else {
|
||||||
|
duplicate++;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (duplicate > 0) {
|
||||||
|
PlotSquared.log("&c[WARNING] Found " + duplicate + " duplicate plots already in DB for world: '" + world + "'. Have you run the converter already?");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
sendMessage("Creating plot DB");
|
||||||
|
Thread.sleep(1000);
|
||||||
|
DBFunc.createPlotsAndData(createdPlots, new Runnable() {
|
||||||
|
@Override
|
||||||
|
public void run() {
|
||||||
|
sendMessage("&aDatabase conversion is now complete!");
|
||||||
|
}
|
||||||
|
});
|
||||||
|
sendMessage("Saving configuration...");
|
||||||
|
try {
|
||||||
|
PlotSquared.config.save(PlotSquared.configFile);
|
||||||
|
} catch (final IOException e) {
|
||||||
|
sendMessage(" - &cFailed to save configuration.");
|
||||||
|
}
|
||||||
|
TaskManager.runTask(new Runnable() {
|
||||||
|
@Override
|
||||||
|
public void run() {
|
||||||
|
try {
|
||||||
|
boolean MV = false;
|
||||||
|
boolean MW = false;
|
||||||
|
if ((Bukkit.getPluginManager().getPlugin("Multiverse-Core") != null) && Bukkit.getPluginManager().getPlugin("Multiverse-Core").isEnabled()) {
|
||||||
|
MV = true;
|
||||||
|
} else if ((Bukkit.getPluginManager().getPlugin("MultiWorld") != null) && Bukkit.getPluginManager().getPlugin("MultiWorld").isEnabled()) {
|
||||||
|
MW = true;
|
||||||
|
}
|
||||||
|
for (final String worldname : worlds) {
|
||||||
|
final World world = Bukkit.getWorld(getWorld(worldname));
|
||||||
|
if (world == null) {
|
||||||
|
sendMessage("&cInvalid world in PlotMe configuration: " + worldname);
|
||||||
|
}
|
||||||
|
final String actualWorldName = world.getName();
|
||||||
|
sendMessage("Reloading generator for world: '" + actualWorldName + "'...");
|
||||||
|
PlotSquared.removePlotWorld(actualWorldName);
|
||||||
|
if (MV) {
|
||||||
|
// unload world with MV
|
||||||
|
Bukkit.getServer().dispatchCommand(Bukkit.getServer().getConsoleSender(), "mv unload " + actualWorldName);
|
||||||
|
try {
|
||||||
|
Thread.sleep(1000);
|
||||||
|
} catch (final InterruptedException ex) {
|
||||||
|
Thread.currentThread().interrupt();
|
||||||
|
}
|
||||||
|
// load world with MV
|
||||||
|
Bukkit.getServer().dispatchCommand(Bukkit.getServer().getConsoleSender(), "mv import " + actualWorldName + " normal -g PlotSquared");
|
||||||
|
} else if (MW) {
|
||||||
|
// unload world with MW
|
||||||
|
Bukkit.getServer().dispatchCommand(Bukkit.getServer().getConsoleSender(), "mw unload " + actualWorldName);
|
||||||
|
try {
|
||||||
|
Thread.sleep(1000);
|
||||||
|
} catch (final InterruptedException ex) {
|
||||||
|
Thread.currentThread().interrupt();
|
||||||
|
}
|
||||||
|
// load world with MW
|
||||||
|
Bukkit.getServer().dispatchCommand(Bukkit.getServer().getConsoleSender(), "mw create " + actualWorldName + " plugin:PlotSquared");
|
||||||
|
} else {
|
||||||
|
// Load using Bukkit API
|
||||||
|
// - User must set generator manually
|
||||||
|
Bukkit.getServer().unloadWorld(world, true);
|
||||||
|
final World myworld = WorldCreator.name(actualWorldName).generator(new HybridGen()).createWorld();
|
||||||
|
myworld.save();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
PlotSquared.setAllPlotsRaw(DBFunc.getPlots());
|
||||||
|
} catch (final Exception e) {
|
||||||
|
e.printStackTrace();
|
||||||
|
}
|
||||||
|
sendMessage("&cPlease wait until database conversion is complete. You will be notified when this happens");
|
||||||
|
PlotSquared.log("&c - Stop the server");
|
||||||
|
PlotSquared.log("&c - Disable 'plotme-convert.enabled' in the settings.yml");
|
||||||
|
PlotSquared.log("&c - Correct any generator settings that haven't copied to 'settings.yml' properly");
|
||||||
|
PlotSquared.log("&c - Start the server");
|
||||||
|
}
|
||||||
|
});
|
||||||
|
} catch (final Exception e) {
|
||||||
|
PlotSquared.log("&/end/");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public static String getWorld(final String world) {
|
||||||
|
for (final World newworld : Bukkit.getWorlds()) {
|
||||||
|
if (newworld.getName().equalsIgnoreCase(world)) {
|
||||||
|
return newworld.getName();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return world;
|
||||||
|
}
|
||||||
|
}
|
@ -38,7 +38,7 @@ public class AbstractFlag {
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* AbstractFlag is a parameter used in creating a new Flag<br>
|
* AbstractFlag is a parameter used in creating a new Flag<br>
|
||||||
* The key must be alphabetical characters and <= 16 characters in length
|
* The key must be alphabetical characters and <= 16 characters in length
|
||||||
* @param key
|
* @param key
|
||||||
*/
|
*/
|
||||||
public AbstractFlag(final String key, final FlagValue<?> value) {
|
public AbstractFlag(final String key, final FlagValue<?> value) {
|
||||||
|
@ -31,21 +31,16 @@ public class Flag {
|
|||||||
* player, you need to register it with PlotSquared.
|
* player, you need to register it with PlotSquared.
|
||||||
*
|
*
|
||||||
* @param key AbstractFlag
|
* @param key AbstractFlag
|
||||||
* @param value Value must be alphanumerical (can have spaces) and be <= 48 characters
|
* @param value Value must be alphanumerical (can have spaces) and be <= 48 characters
|
||||||
*
|
*
|
||||||
* @throws IllegalArgumentException if you provide inadequate inputs
|
* @throws IllegalArgumentException if you provide inadequate inputs
|
||||||
*/
|
*/
|
||||||
public Flag(final AbstractFlag key, final String value) {
|
public Flag(final AbstractFlag key, final String value) {
|
||||||
final char[] allowedCharacters = new char[] { '[', ']', '(', ')', ',', '_', '-', '.', ',', '?', '!', '&', ':', '\u00A7' };
|
if (!StringUtils.isAsciiPrintable(value)) {
|
||||||
String tempValue = value;
|
throw new IllegalArgumentException("Flag must be ascii");
|
||||||
for (final char c : allowedCharacters) {
|
|
||||||
tempValue = tempValue.replace(c, 'c');
|
|
||||||
}
|
}
|
||||||
if (!StringUtils.isAlphanumericSpace(tempValue)) {
|
if (value.length() > 128) {
|
||||||
throw new IllegalArgumentException("Flag must be alphanumerical (colours and some special characters are allowed)");
|
throw new IllegalArgumentException("Value must be <= 128 characters");
|
||||||
}
|
|
||||||
if (value.length() > 48) {
|
|
||||||
throw new IllegalArgumentException("Value must be <= 48 characters");
|
|
||||||
}
|
}
|
||||||
this.key = key;
|
this.key = key;
|
||||||
this.value = key.parseValueRaw(value);
|
this.value = key.parseValueRaw(value);
|
||||||
|
@ -53,15 +53,21 @@ public class FlagManager {
|
|||||||
/**
|
/**
|
||||||
* Register an AbstractFlag with PlotSquared
|
* Register an AbstractFlag with PlotSquared
|
||||||
*
|
*
|
||||||
* @param flag Flag to register
|
* @param af Flag to register
|
||||||
*
|
*
|
||||||
* @return success?
|
* @return boolean success
|
||||||
*/
|
*/
|
||||||
public static boolean addFlag(final AbstractFlag af) {
|
public static boolean addFlag(final AbstractFlag af) {
|
||||||
PlotSquared.log(C.PREFIX.s() + "&8 - Adding flag: &7" + af);
|
PlotSquared.log(C.PREFIX.s() + "&8 - Adding flag: &7" + af);
|
||||||
af.getKey();
|
for (PlotWorld plotworld : PlotSquared.getPlotWorldObjects()) {
|
||||||
|
for (final Flag flag : plotworld.DEFAULT_FLAGS) {
|
||||||
|
if (flag.getAbstractFlag().getKey().equals(af.getKey())) {
|
||||||
|
flag.setKey(af);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
if (PlotSquared.getAllPlotsRaw() != null) {
|
if (PlotSquared.getAllPlotsRaw() != null) {
|
||||||
for (final Plot plot : PlotSquared.getPlots()) {
|
for (final Plot plot : PlotSquared.getPlotsRaw()) {
|
||||||
for (final Flag flag : plot.settings.flags) {
|
for (final Flag flag : plot.settings.flags) {
|
||||||
if (flag.getAbstractFlag().getKey().equals(af.getKey())) {
|
if (flag.getAbstractFlag().getKey().equals(af.getKey())) {
|
||||||
flag.setKey(af);
|
flag.setKey(af);
|
||||||
@ -89,11 +95,23 @@ public class FlagManager {
|
|||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static boolean isBooleanFlag(final Plot plot, final String key, final boolean defaultValue) {
|
||||||
|
final Flag flag = FlagManager.getPlotFlag(plot, key);
|
||||||
|
if (flag == null) {
|
||||||
|
return defaultValue;
|
||||||
|
}
|
||||||
|
final Object value = flag.getValue();
|
||||||
|
if (value instanceof Boolean) {
|
||||||
|
return (boolean) value;
|
||||||
|
}
|
||||||
|
return defaultValue;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Get the value of a flag for a plot (respects flag defaults)
|
* Get the value of a flag for a plot (respects flag defaults)
|
||||||
* @param plot
|
* @param plot
|
||||||
* @param flag
|
* @param flag
|
||||||
* @return
|
* @return Flag
|
||||||
*/
|
*/
|
||||||
public static Flag getPlotFlag(final Plot plot, final String flag) {
|
public static Flag getPlotFlag(final Plot plot, final String flag) {
|
||||||
return getSettingFlag(plot.world, plot.settings, flag);
|
return getSettingFlag(plot.world, plot.settings, flag);
|
||||||
@ -110,11 +128,22 @@ public class FlagManager {
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static boolean isPlotFlagFalse(final Plot plot, final String strFlag) {
|
||||||
|
final Flag flag = getPlotFlag(plot, strFlag);
|
||||||
|
if (flag == null) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
if (flag.getValue() instanceof Boolean) {
|
||||||
|
return !(boolean) flag.getValue();
|
||||||
|
}
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Get the value of a flag for a plot (ignores flag defaults)
|
* Get the value of a flag for a plot (ignores flag defaults)
|
||||||
* @param plot
|
* @param plot
|
||||||
* @param flag
|
* @param flag
|
||||||
* @return
|
* @return Flag
|
||||||
*/
|
*/
|
||||||
public static Flag getPlotFlagAbs(final Plot plot, final String flag) {
|
public static Flag getPlotFlagAbs(final Plot plot, final String flag) {
|
||||||
return getSettingFlagAbs(plot.settings, flag);
|
return getSettingFlagAbs(plot.settings, flag);
|
||||||
@ -165,7 +194,7 @@ public class FlagManager {
|
|||||||
/**
|
/**
|
||||||
*
|
*
|
||||||
* @param plot
|
* @param plot
|
||||||
* @return
|
* @return set of flags
|
||||||
*/
|
*/
|
||||||
public static Set<Flag> getPlotFlags(final Plot plot) {
|
public static Set<Flag> getPlotFlags(final Plot plot) {
|
||||||
return getSettingFlags(plot.world, plot.settings);
|
return getSettingFlags(plot.world, plot.settings);
|
||||||
@ -313,7 +342,6 @@ public class FlagManager {
|
|||||||
public static AbstractFlag getFlag(final String string, final boolean create) {
|
public static AbstractFlag getFlag(final String string, final boolean create) {
|
||||||
if ((getFlag(string) == null) && create) {
|
if ((getFlag(string) == null) && create) {
|
||||||
final AbstractFlag flag = new AbstractFlag(string);
|
final AbstractFlag flag = new AbstractFlag(string);
|
||||||
addFlag(flag);
|
|
||||||
return flag;
|
return flag;
|
||||||
}
|
}
|
||||||
return getFlag(string);
|
return getFlag(string);
|
||||||
@ -333,7 +361,13 @@ public class FlagManager {
|
|||||||
public static Flag[] parseFlags(final List<String> flagstrings) {
|
public static Flag[] parseFlags(final List<String> flagstrings) {
|
||||||
final Flag[] flags = new Flag[flagstrings.size()];
|
final Flag[] flags = new Flag[flagstrings.size()];
|
||||||
for (int i = 0; i < flagstrings.size(); i++) {
|
for (int i = 0; i < flagstrings.size(); i++) {
|
||||||
final String[] split = flagstrings.get(i).split(";");
|
final String[] split;
|
||||||
|
if (flagstrings.get(i).contains(";")) {
|
||||||
|
split = flagstrings.get(i).split(";");
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
split = flagstrings.get(i).split(":");
|
||||||
|
}
|
||||||
if (split.length == 1) {
|
if (split.length == 1) {
|
||||||
flags[i] = new Flag(getFlag(split[0], true), "");
|
flags[i] = new Flag(getFlag(split[0], true), "");
|
||||||
} else {
|
} else {
|
||||||
|
@ -48,10 +48,22 @@ public abstract class FlagValue<T> {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Boolean parse(final String t) {
|
public Boolean parse(final String t) {
|
||||||
try {
|
switch (t.toLowerCase()) {
|
||||||
return Boolean.parseBoolean(t);
|
case "1":
|
||||||
} catch (final IllegalArgumentException e) {
|
case "yes":
|
||||||
return null;
|
case "allow":
|
||||||
|
case "true": {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
case "0":
|
||||||
|
case "no":
|
||||||
|
case "deny":
|
||||||
|
case "false": {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
default: {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -133,7 +145,7 @@ public abstract class FlagValue<T> {
|
|||||||
public Integer parse(final String t) {
|
public Integer parse(final String t) {
|
||||||
try {
|
try {
|
||||||
final int value = Integer.parseInt(t);
|
final int value = Integer.parseInt(t);
|
||||||
if (value >= 0) {
|
if (value < 0) {
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
return value;
|
return value;
|
||||||
|
@ -1,7 +1,8 @@
|
|||||||
package com.intellectualcrafters.plot.generator;
|
package com.intellectualcrafters.plot.generator;
|
||||||
|
|
||||||
import java.util.Arrays;
|
import java.util.HashMap;
|
||||||
import java.util.Iterator;
|
import java.util.Iterator;
|
||||||
|
import java.util.Map.Entry;
|
||||||
import java.util.Random;
|
import java.util.Random;
|
||||||
|
|
||||||
import org.bukkit.Bukkit;
|
import org.bukkit.Bukkit;
|
||||||
@ -12,14 +13,17 @@ import org.bukkit.generator.BlockPopulator;
|
|||||||
|
|
||||||
import com.intellectualcrafters.plot.PlotSquared;
|
import com.intellectualcrafters.plot.PlotSquared;
|
||||||
import com.intellectualcrafters.plot.object.BlockWrapper;
|
import com.intellectualcrafters.plot.object.BlockWrapper;
|
||||||
|
import com.intellectualcrafters.plot.object.ChunkLoc;
|
||||||
import com.intellectualcrafters.plot.object.Location;
|
import com.intellectualcrafters.plot.object.Location;
|
||||||
import com.intellectualcrafters.plot.object.PlotCluster;
|
import com.intellectualcrafters.plot.object.PlotCluster;
|
||||||
import com.intellectualcrafters.plot.object.PlotGenerator;
|
import com.intellectualcrafters.plot.object.PlotGenerator;
|
||||||
import com.intellectualcrafters.plot.object.PlotId;
|
import com.intellectualcrafters.plot.object.PlotId;
|
||||||
|
import com.intellectualcrafters.plot.object.PlotLoc;
|
||||||
import com.intellectualcrafters.plot.object.PlotManager;
|
import com.intellectualcrafters.plot.object.PlotManager;
|
||||||
import com.intellectualcrafters.plot.object.PlotWorld;
|
import com.intellectualcrafters.plot.object.PlotWorld;
|
||||||
import com.intellectualcrafters.plot.object.RegionWrapper;
|
import com.intellectualcrafters.plot.object.RegionWrapper;
|
||||||
import com.intellectualcrafters.plot.util.ChunkManager;
|
import com.intellectualcrafters.plot.util.ChunkManager;
|
||||||
|
import com.intellectualcrafters.plot.util.MainUtil;
|
||||||
import com.intellectualcrafters.plot.util.TaskManager;
|
import com.intellectualcrafters.plot.util.TaskManager;
|
||||||
import com.intellectualcrafters.plot.util.bukkit.BukkitChunkManager;
|
import com.intellectualcrafters.plot.util.bukkit.BukkitChunkManager;
|
||||||
import com.intellectualcrafters.plot.util.bukkit.BukkitSetBlockManager;
|
import com.intellectualcrafters.plot.util.bukkit.BukkitSetBlockManager;
|
||||||
@ -50,19 +54,44 @@ public class AugmentedPopulator extends BlockPopulator {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public BlockWrapper get(final int X, final int Z, final int i, final int j, final short[][] r, final boolean c) {
|
public BlockWrapper get(final int x, final int z, final int i, final int j, final short[][] r, final boolean c) {
|
||||||
final int y = (i << 4) + (j >> 8);
|
final int y = (i << 4) + (j >> 8);
|
||||||
final int a = (j - ((y & 0xF) << 8));
|
final int a = (j - ((y & 0xF) << 8));
|
||||||
final int z = (a >> 4);
|
final int z1 = (a >> 4);
|
||||||
final int x = a - (z << 4);
|
final int x1 = a - (z1 << 4);
|
||||||
if (r[i] == null) {
|
if (r[i] == null) {
|
||||||
return (c && (((Z + z) < this.bz) || ((Z + z) > this.tz) || ((X + x) < this.bx) || ((X + x) > this.tx))) ? null : new BlockWrapper(x, y, z, (short) 0, (byte) 0);
|
return (c && (((z + z1) < this.bz) || ((z + z1) > this.tz) || ((x + x1) < this.bx) || ((x + x1) > this.tx))) ? null : new BlockWrapper(x1, y, z1, (short) 0, (byte) 0);
|
||||||
} else {
|
} else {
|
||||||
return (c && (((Z + z) < this.bz) || ((Z + z) > this.tz) || ((X + x) < this.bx) || ((X + x) > this.tx))) ? null : new BlockWrapper(x, y, z, r[i][j], (byte) 0);
|
return (c && (((z + z1) < this.bz) || ((z + z1) > this.tz) || ((x + x1) < this.bx) || ((x + x1) > this.tx))) ? null : new BlockWrapper(x1, y, z1, r[i][j], (byte) 0);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public static short[][] x_loc;
|
||||||
|
public static short[][] y_loc;
|
||||||
|
public static short[][] z_loc;
|
||||||
|
|
||||||
|
public static void initCache() {
|
||||||
|
if (x_loc == null) {
|
||||||
|
x_loc = new short[16][4096];
|
||||||
|
y_loc = new short[16][4096];
|
||||||
|
z_loc = new short[16][4096];
|
||||||
|
for (int i = 0; i < 16; i++) {
|
||||||
|
int i4 = i << 4;
|
||||||
|
for (int j = 0; j < 4096; j++) {
|
||||||
|
final int y = (i4) + (j >> 8);
|
||||||
|
final int a = (j - ((y & 0xF) << 8));
|
||||||
|
final int z1 = (a >> 4);
|
||||||
|
final int x1 = a - (z1 << 4);
|
||||||
|
x_loc[i][j] = (short) x1;
|
||||||
|
y_loc[i][j] = (short) y;
|
||||||
|
z_loc[i][j] = (short) z1;
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public AugmentedPopulator(final String world, final PlotGenerator generator, final PlotCluster cluster, final boolean p, final boolean b) {
|
public AugmentedPopulator(final String world, final PlotGenerator generator, final PlotCluster cluster, final boolean p, final boolean b) {
|
||||||
|
initCache();
|
||||||
this.cluster = cluster;
|
this.cluster = cluster;
|
||||||
this.generator = generator;
|
this.generator = generator;
|
||||||
this.plotworld = PlotSquared.getPlotWorld(world);
|
this.plotworld = PlotSquared.getPlotWorld(world);
|
||||||
@ -94,6 +123,56 @@ public class AugmentedPopulator extends BlockPopulator {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void populate(final World world, final Random rand, final Chunk chunk) {
|
public void populate(final World world, final Random rand, final Chunk chunk) {
|
||||||
|
if (this.plotworld.TERRAIN == 3) {
|
||||||
|
int X = chunk.getX() << 4;
|
||||||
|
int Z = chunk.getZ() << 4;
|
||||||
|
if (ChunkManager.FORCE_PASTE) {
|
||||||
|
for (short x = 0; x < 16; x++) {
|
||||||
|
for (short z = 0; z < 16; z++) {
|
||||||
|
final PlotLoc loc = new PlotLoc((short) (X + x), (short) (Z + z));
|
||||||
|
final HashMap<Short, Short> blocks = ChunkManager.GENERATE_BLOCKS.get(loc);
|
||||||
|
HashMap<Short, Byte> datas = ChunkManager.GENERATE_DATA.get(loc);
|
||||||
|
for (final Entry<Short, Short> entry : blocks.entrySet()) {
|
||||||
|
int y = entry.getKey();
|
||||||
|
byte data;
|
||||||
|
if (datas != null) {
|
||||||
|
data = datas.get(y);
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
data = 0;
|
||||||
|
}
|
||||||
|
BukkitSetBlockManager.setBlockManager.set(world, x, y, z, blocks.get(y), (byte) data);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
if (ChunkManager.CURRENT_PLOT_CLEAR != null) {
|
||||||
|
PlotLoc loc;
|
||||||
|
for (Entry<PlotLoc, HashMap<Short, Byte>> entry : ChunkManager.GENERATE_DATA.entrySet()) {
|
||||||
|
HashMap<Short, Byte> datas = ChunkManager.GENERATE_DATA.get(entry.getKey());
|
||||||
|
for (Entry<Short, Byte> entry2 : entry.getValue().entrySet()) {
|
||||||
|
Short y = entry2.getKey();
|
||||||
|
byte data;
|
||||||
|
if (datas != null) {
|
||||||
|
data = datas.get(y);
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
data = 0;
|
||||||
|
}
|
||||||
|
loc = entry.getKey();
|
||||||
|
int xx = loc.x - X;
|
||||||
|
int zz = loc.z - Z;
|
||||||
|
if (xx >= 0 && xx < 16) {
|
||||||
|
if (zz >= 0 && zz < 16) {
|
||||||
|
BukkitSetBlockManager.setBlockManager.set(world, xx, y, zz, entry2.getValue(), (byte) data);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return;
|
||||||
|
}
|
||||||
final int X = chunk.getX();
|
final int X = chunk.getX();
|
||||||
final int Z = chunk.getZ();
|
final int Z = chunk.getZ();
|
||||||
final int x = X << 4;
|
final int x = X << 4;
|
||||||
@ -115,7 +194,7 @@ public class AugmentedPopulator extends BlockPopulator {
|
|||||||
} else {
|
} else {
|
||||||
check = false;
|
check = false;
|
||||||
}
|
}
|
||||||
if (this.plotworld.TERRAIN == 2) {
|
if (this.plotworld.TERRAIN > 1) {
|
||||||
final PlotId plot1 = this.manager.getPlotIdAbs(this.plotworld, x, 0, z);
|
final PlotId plot1 = this.manager.getPlotIdAbs(this.plotworld, x, 0, z);
|
||||||
final PlotId plot2 = this.manager.getPlotIdAbs(this.plotworld, x2, 0, z2);
|
final PlotId plot2 = this.manager.getPlotIdAbs(this.plotworld, x2, 0, z2);
|
||||||
if ((plot1 != null) && (plot2 != null) && plot1.equals(plot2)) {
|
if ((plot1 != null) && (plot2 != null) && plot1.equals(plot2)) {
|
||||||
@ -123,16 +202,7 @@ public class AugmentedPopulator extends BlockPopulator {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (this.o) {
|
if (this.o) {
|
||||||
chunk.load(true);
|
|
||||||
populateBlocks(world, rand, X, Z, x, z, check);
|
populateBlocks(world, rand, X, Z, x, z, check);
|
||||||
TaskManager.runTaskLater(new Runnable() {
|
|
||||||
@Override
|
|
||||||
public void run() {
|
|
||||||
populateBiome(world, x, z);
|
|
||||||
chunk.unload(true, true);
|
|
||||||
BukkitSetBlockManager.setBlockManager.update(Arrays.asList(new Chunk[] { chunk }));
|
|
||||||
}
|
|
||||||
}, 20);
|
|
||||||
} else {
|
} else {
|
||||||
TaskManager.runTaskLater(new Runnable() {
|
TaskManager.runTaskLater(new Runnable() {
|
||||||
@Override
|
@Override
|
||||||
@ -145,8 +215,6 @@ public class AugmentedPopulator extends BlockPopulator {
|
|||||||
public void run() {
|
public void run() {
|
||||||
chunk.load(true);
|
chunk.load(true);
|
||||||
populateBlocks(world, rand, X, Z, x, z, check);
|
populateBlocks(world, rand, X, Z, x, z, check);
|
||||||
chunk.unload(true, true);
|
|
||||||
BukkitSetBlockManager.setBlockManager.update(Arrays.asList(new Chunk[] { chunk }));
|
|
||||||
}
|
}
|
||||||
}, 40 + rand.nextInt(40));
|
}, 40 + rand.nextInt(40));
|
||||||
}
|
}
|
||||||
@ -165,29 +233,58 @@ public class AugmentedPopulator extends BlockPopulator {
|
|||||||
|
|
||||||
private void populateBlocks(final World world, final Random rand, final int X, final int Z, final int x, final int z, final boolean check) {
|
private void populateBlocks(final World world, final Random rand, final int X, final int Z, final int x, final int z, final boolean check) {
|
||||||
final short[][] result = this.generator.generateExtBlockSections(world, rand, X, Z, null);
|
final short[][] result = this.generator.generateExtBlockSections(world, rand, X, Z, null);
|
||||||
final int length = result[0].length;
|
|
||||||
for (int i = 0; i < result.length; i++) {
|
for (int i = 0; i < result.length; i++) {
|
||||||
for (int j = 0; j < length; j++) {
|
if (result[i] != null) {
|
||||||
final BlockWrapper blockInfo = get(x, z, i, j, result, check);
|
for (int j = 0; j < 4096; j++) {
|
||||||
if (blockInfo == null) {
|
int x1 = x_loc[i][j];
|
||||||
continue;
|
int y = y_loc[i][j];
|
||||||
}
|
int z1 = z_loc[i][j];
|
||||||
final int xx = x + blockInfo.x;
|
short id = result[i][j];
|
||||||
final int zz = z + blockInfo.z;
|
final int xx = x + x1;
|
||||||
if (this.p) {
|
final int zz = z + z1;
|
||||||
if (ChunkManager.CURRENT_PLOT_CLEAR != null) {
|
if (check && (((zz) < this.bz) || ((zz) > this.tz) || ((xx) < this.bx) || ((xx) > this.tx))) {
|
||||||
if (BukkitChunkManager.isIn(ChunkManager.CURRENT_PLOT_CLEAR, xx, zz)) {
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
} else if (this.manager.getPlotIdAbs(this.plotworld, xx, 0, zz) != null) {
|
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
if (this.p) {
|
||||||
|
if (ChunkManager.CURRENT_PLOT_CLEAR != null) {
|
||||||
|
if (BukkitChunkManager.isIn(ChunkManager.CURRENT_PLOT_CLEAR, xx, zz)) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
} else if (this.manager.getPlotIdAbs(this.plotworld, xx, 0, zz) != null) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
BukkitSetBlockManager.setBlockManager.set(world, xx, y, zz, id, (byte) 0);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
short y_min = y_loc[i][0];
|
||||||
|
if (y_min < 128) {
|
||||||
|
for (int x1 = x; x1 < x + 16; x1++) {
|
||||||
|
for (int z1 = z; z1 < z + 16; z1++) {
|
||||||
|
if (check && (((z1) < this.bz) || ((z1) > this.tz) || ((x1) < this.bx) || ((x1) > this.tx))) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
if (this.p) {
|
||||||
|
if (ChunkManager.CURRENT_PLOT_CLEAR != null) {
|
||||||
|
if (BukkitChunkManager.isIn(ChunkManager.CURRENT_PLOT_CLEAR, x1, z1)) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
} else if (this.manager.getPlotIdAbs(this.plotworld, x1, 0, z1) != null) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
for (int y = y_min; y < y_min + 16; y++) {
|
||||||
|
BukkitSetBlockManager.setBlockManager.set(world, x1, y, z1, 0, (byte) 0);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
BukkitSetBlockManager.setBlockManager.set(world, xx, blockInfo.y, zz, blockInfo.id, (byte) 0);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
for (final BlockPopulator populator : this.generator.getDefaultPopulators(world)) {
|
for (final BlockPopulator populator : this.generator.getDefaultPopulators(world)) {
|
||||||
populator.populate(world, this.r, world.getChunkAt(X, Z));
|
Chunk chunk = world.getChunkAt(X, Z);
|
||||||
|
populator.populate(world, this.r, chunk);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1,8 +1,11 @@
|
|||||||
package com.intellectualcrafters.plot.generator;
|
package com.intellectualcrafters.plot.generator;
|
||||||
|
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
|
import java.util.HashSet;
|
||||||
|
import java.util.Iterator;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
|
import org.apache.commons.lang.mutable.MutableInt;
|
||||||
import org.bukkit.Bukkit;
|
import org.bukkit.Bukkit;
|
||||||
import org.bukkit.Chunk;
|
import org.bukkit.Chunk;
|
||||||
import org.bukkit.World;
|
import org.bukkit.World;
|
||||||
@ -13,15 +16,80 @@ import com.intellectualcrafters.plot.BukkitMain;
|
|||||||
import com.intellectualcrafters.plot.PlotSquared;
|
import com.intellectualcrafters.plot.PlotSquared;
|
||||||
import com.intellectualcrafters.plot.config.C;
|
import com.intellectualcrafters.plot.config.C;
|
||||||
import com.intellectualcrafters.plot.object.ChunkLoc;
|
import com.intellectualcrafters.plot.object.ChunkLoc;
|
||||||
|
import com.intellectualcrafters.plot.object.Location;
|
||||||
|
import com.intellectualcrafters.plot.object.Plot;
|
||||||
import com.intellectualcrafters.plot.object.PlotBlock;
|
import com.intellectualcrafters.plot.object.PlotBlock;
|
||||||
|
import com.intellectualcrafters.plot.object.PlotWorld;
|
||||||
|
import com.intellectualcrafters.plot.object.RunnableVal;
|
||||||
import com.intellectualcrafters.plot.util.ChunkManager;
|
import com.intellectualcrafters.plot.util.ChunkManager;
|
||||||
import com.intellectualcrafters.plot.util.bukkit.BukkitSetBlockManager;
|
import com.intellectualcrafters.plot.util.MainUtil;
|
||||||
|
import com.intellectualcrafters.plot.util.TaskManager;
|
||||||
import com.intellectualcrafters.plot.util.bukkit.BukkitUtil;
|
import com.intellectualcrafters.plot.util.bukkit.BukkitUtil;
|
||||||
|
|
||||||
public class BukkitHybridUtils extends HybridUtils {
|
public class BukkitHybridUtils extends HybridUtils {
|
||||||
|
|
||||||
|
public void checkModified(final Plot plot, final RunnableVal whenDone) {
|
||||||
|
TaskManager.index.increment();
|
||||||
|
|
||||||
|
final Location bot = MainUtil.getPlotBottomLoc(plot.world, plot.id).add(1, 0, 1);
|
||||||
|
final Location top = MainUtil.getPlotTopLoc(plot.world, plot.id);
|
||||||
|
|
||||||
|
int bx = bot.getX() >> 4;
|
||||||
|
int bz = bot.getZ() >> 4;
|
||||||
|
|
||||||
|
int tx = top.getX() >> 4;
|
||||||
|
int tz = top.getZ() >> 4;
|
||||||
|
|
||||||
|
World world = BukkitUtil.getWorld(plot.world);
|
||||||
|
|
||||||
|
final HashSet<Chunk> chunks = new HashSet<>();
|
||||||
|
for (int X = bx; X <= tx; X++) {
|
||||||
|
for (int Z = bz; Z <= tz; Z++) {
|
||||||
|
chunks.add(world.getChunkAt(X,Z));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
PlotWorld plotworld = PlotSquared.getPlotWorld(plot.world);
|
||||||
|
if (!(plotworld instanceof ClassicPlotWorld)) {
|
||||||
|
whenDone.value = -1;
|
||||||
|
TaskManager.runTaskLater(whenDone, 1);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
final ClassicPlotWorld cpw = (ClassicPlotWorld) plotworld;
|
||||||
|
|
||||||
|
final MutableInt count = new MutableInt(0);
|
||||||
|
|
||||||
|
final Integer currentIndex = TaskManager.index.toInteger();
|
||||||
|
final Integer task = TaskManager.runTaskRepeat(new Runnable() {
|
||||||
|
@Override
|
||||||
|
public void run() {
|
||||||
|
if (chunks.size() == 0) {
|
||||||
|
whenDone.value = count.intValue();
|
||||||
|
TaskManager.runTaskLater(whenDone, 1);
|
||||||
|
Bukkit.getScheduler().cancelTask(TaskManager.tasks.get(currentIndex));
|
||||||
|
TaskManager.tasks.remove(currentIndex);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
Iterator<Chunk> iter = chunks.iterator();
|
||||||
|
final Chunk chunk = iter.next();
|
||||||
|
iter.remove();
|
||||||
|
int bx = Math.max(chunk.getX() << 4, bot.getX());
|
||||||
|
int bz = Math.max(chunk.getZ() << 4, bot.getZ());
|
||||||
|
int ex = Math.min((chunk.getX() << 4) + 15, top.getX());
|
||||||
|
int ez = Math.min((chunk.getZ() << 4) + 15, top.getZ());
|
||||||
|
// count changes
|
||||||
|
count.add(checkModified(plot.world, bx, ex, 1, cpw.PLOT_HEIGHT - 1, bz, ez, cpw.MAIN_BLOCK));
|
||||||
|
count.add(checkModified(plot.world, bx, ex, cpw.PLOT_HEIGHT, cpw.PLOT_HEIGHT, bz, ez, cpw.TOP_BLOCK));
|
||||||
|
count.add(checkModified(plot.world, bx, ex, cpw.PLOT_HEIGHT + 1, 255, bz, ez, new PlotBlock[] { new PlotBlock((short) 0, (byte) 0) }));
|
||||||
|
}
|
||||||
|
}, 1);
|
||||||
|
TaskManager.tasks.put(currentIndex, task);
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public int checkModified(final int threshhold, final String worldname, final int x1, final int x2, final int y1, final int y2, final int z1, final int z2, final PlotBlock[] blocks) {
|
public int checkModified(final String worldname, final int x1, final int x2, final int y1, final int y2, final int z1, final int z2, final PlotBlock[] blocks) {
|
||||||
final World world = BukkitUtil.getWorld(worldname);
|
final World world = BukkitUtil.getWorld(worldname);
|
||||||
int count = 0;
|
int count = 0;
|
||||||
for (int y = y1; y <= y2; y++) {
|
for (int y = y1; y <= y2; y++) {
|
||||||
@ -38,9 +106,6 @@ public class BukkitHybridUtils extends HybridUtils {
|
|||||||
}
|
}
|
||||||
if (!same) {
|
if (!same) {
|
||||||
count++;
|
count++;
|
||||||
if (count > threshhold) {
|
|
||||||
return -1;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -68,7 +133,6 @@ public class BukkitHybridUtils extends HybridUtils {
|
|||||||
return ey;
|
return ey;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
|
||||||
public void regenerateChunkChunk(final String worldname, final ChunkLoc loc) {
|
public void regenerateChunkChunk(final String worldname, final ChunkLoc loc) {
|
||||||
final World world = BukkitUtil.getWorld(worldname);
|
final World world = BukkitUtil.getWorld(worldname);
|
||||||
final int sx = loc.x << 5;
|
final int sx = loc.x << 5;
|
||||||
@ -85,45 +149,104 @@ public class BukkitHybridUtils extends HybridUtils {
|
|||||||
final Chunk chunk = world.getChunkAt(x, z);
|
final Chunk chunk = world.getChunkAt(x, z);
|
||||||
chunks2.add(chunk);
|
chunks2.add(chunk);
|
||||||
regenerateRoad(worldname, new ChunkLoc(x, z));
|
regenerateRoad(worldname, new ChunkLoc(x, z));
|
||||||
|
MainUtil.update(world.getName(), new ChunkLoc(chunk.getX(), chunk.getZ()));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
BukkitSetBlockManager.setBlockManager.update(chunks2);
|
}
|
||||||
|
|
||||||
|
public final ArrayList<ChunkLoc> getChunks(ChunkLoc region) {
|
||||||
|
ArrayList<ChunkLoc> chunks = new ArrayList<ChunkLoc>();
|
||||||
|
final int sx = region.x << 5;
|
||||||
|
final int sz = region.z << 5;
|
||||||
|
for (int x = sx; x < (sx + 32); x++) {
|
||||||
|
for (int z = sz; z < (sz + 32); z++) {
|
||||||
|
chunks.add(new ChunkLoc(x, z));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return chunks;
|
||||||
}
|
}
|
||||||
|
|
||||||
private static boolean UPDATE = false;
|
private static boolean UPDATE = false;
|
||||||
private int task;
|
private int task;
|
||||||
|
private long last;
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean scheduleRoadUpdate(final String world) {
|
public boolean scheduleRoadUpdate(final String world) {
|
||||||
if (BukkitHybridUtils.UPDATE) {
|
if (BukkitHybridUtils.UPDATE) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
final List<ChunkLoc> chunks = ChunkManager.manager.getChunkChunks(world);
|
BukkitHybridUtils.UPDATE = true;
|
||||||
|
final List<ChunkLoc> regions = ChunkManager.manager.getChunkChunks(world);
|
||||||
|
return scheduleRoadUpdate(world, regions);
|
||||||
|
}
|
||||||
|
|
||||||
|
public boolean scheduleRoadUpdate(final String world, final List<ChunkLoc> regions) {
|
||||||
|
final List<ChunkLoc> chunks = new ArrayList<ChunkLoc>();
|
||||||
final Plugin plugin = BukkitMain.THIS;
|
final Plugin plugin = BukkitMain.THIS;
|
||||||
this.task = Bukkit.getScheduler().scheduleSyncRepeatingTask(plugin, new Runnable() {
|
this.task = Bukkit.getScheduler().scheduleSyncRepeatingTask(plugin, new Runnable() {
|
||||||
@Override
|
@Override
|
||||||
public void run() {
|
public void run() {
|
||||||
if (chunks.size() == 0) {
|
if (regions.size() == 0) {
|
||||||
BukkitHybridUtils.UPDATE = false;
|
BukkitHybridUtils.UPDATE = false;
|
||||||
PlotSquared.log(C.PREFIX.s() + "Finished road conversion");
|
PlotSquared.log(C.PREFIX.s() + "Finished road conversion");
|
||||||
Bukkit.getScheduler().cancelTask(BukkitHybridUtils.this.task);
|
Bukkit.getScheduler().cancelTask(BukkitHybridUtils.this.task);
|
||||||
return;
|
return;
|
||||||
} else {
|
} else {
|
||||||
try {
|
try {
|
||||||
final ChunkLoc loc = chunks.get(0);
|
if (chunks.size() < 1024) {
|
||||||
PlotSquared.log("Updating .mcr: " + loc.x + ", " + loc.z + " (aprrox 256 chunks)");
|
final ChunkLoc loc = regions.get(0);
|
||||||
PlotSquared.log("Remaining regions: " + chunks.size());
|
PlotSquared.log("&3Updating .mcr: " + loc.x + ", " + loc.z + " (aprrox 1024 chunks)");
|
||||||
regenerateChunkChunk(world, loc);
|
PlotSquared.log(" - Remaining: " + regions.size());
|
||||||
chunks.remove(0);
|
chunks.addAll(getChunks(regions.get(0)));
|
||||||
|
regions.remove(0);
|
||||||
|
System.gc();
|
||||||
|
}
|
||||||
|
if (chunks.size() > 0) {
|
||||||
|
long diff = System.currentTimeMillis() + 25;
|
||||||
|
if (System.currentTimeMillis() - last > 1000 && last != 0) {
|
||||||
|
last = 0;
|
||||||
|
PlotSquared.log(C.PREFIX.s() + "Detected low TPS. Rescheduling in 30s");
|
||||||
|
while (chunks.size() > 0) {
|
||||||
|
ChunkLoc chunk = chunks.get(0);
|
||||||
|
chunks.remove(0);
|
||||||
|
regenerateRoad(world, chunk);
|
||||||
|
ChunkManager.manager.unloadChunk(world, chunk);
|
||||||
|
}
|
||||||
|
Bukkit.getScheduler().cancelTask(BukkitHybridUtils.this.task);
|
||||||
|
TaskManager.runTaskLater(new Runnable() {
|
||||||
|
@Override
|
||||||
|
public void run() {
|
||||||
|
scheduleRoadUpdate(world, regions);
|
||||||
|
}
|
||||||
|
}, 600);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
if (System.currentTimeMillis() - last < 50) {
|
||||||
|
while (System.currentTimeMillis() < diff) {
|
||||||
|
ChunkLoc chunk = chunks.get(0);
|
||||||
|
chunks.remove(0);
|
||||||
|
regenerateRoad(world, chunk);
|
||||||
|
ChunkManager.manager.unloadChunk(world, chunk);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
last = System.currentTimeMillis();
|
||||||
|
}
|
||||||
} catch (final Exception e) {
|
} catch (final Exception e) {
|
||||||
final ChunkLoc loc = chunks.get(0);
|
final ChunkLoc loc = regions.get(0);
|
||||||
PlotSquared.log("&c[ERROR]&7 Could not update '" + world + "/region/r." + loc.x + "." + loc.z + ".mca' (Corrupt chunk?)");
|
PlotSquared.log("&c[ERROR]&7 Could not update '" + world + "/region/r." + loc.x + "." + loc.z + ".mca' (Corrupt chunk?)");
|
||||||
PlotSquared.log("&d - Potentially skipping 256 chunks");
|
final int sx = loc.x << 5;
|
||||||
|
final int sz = loc.z << 5;
|
||||||
|
for (int x = sx; x < (sx + 32); x++) {
|
||||||
|
for (int z = sz; z < (sz + 32); z++) {
|
||||||
|
ChunkManager.manager.unloadChunk(world, new ChunkLoc(x, z));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
PlotSquared.log("&d - Potentially skipping 1024 chunks");
|
||||||
PlotSquared.log("&d - TODO: recommend chunkster if corrupt");
|
PlotSquared.log("&d - TODO: recommend chunkster if corrupt");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}, 20, 20);
|
}, 1, 1);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -61,12 +61,13 @@ public abstract class ClassicPlotManager extends SquarePlotManager {
|
|||||||
final int[] zl = new int[size];
|
final int[] zl = new int[size];
|
||||||
final PlotBlock[] bl = new PlotBlock[size];
|
final PlotBlock[] bl = new PlotBlock[size];
|
||||||
int i = 0;
|
int i = 0;
|
||||||
|
PseudoRandom random = new PseudoRandom();
|
||||||
for (x = bottom.getX(); x <= (top.getX() - 1); x++) {
|
for (x = bottom.getX(); x <= (top.getX() - 1); x++) {
|
||||||
for (int y = 1; y <= dpw.WALL_HEIGHT; y++) {
|
for (int y = 1; y <= dpw.WALL_HEIGHT; y++) {
|
||||||
xl[i] = x;
|
xl[i] = x;
|
||||||
zl[i] = z;
|
zl[i] = z;
|
||||||
yl[i] = y;
|
yl[i] = y;
|
||||||
bl[i] = blocks[PseudoRandom.random(blocks.length)];
|
bl[i] = blocks[random.random(blocks.length)];
|
||||||
i++;
|
i++;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -76,7 +77,7 @@ public abstract class ClassicPlotManager extends SquarePlotManager {
|
|||||||
xl[i] = x;
|
xl[i] = x;
|
||||||
zl[i] = z;
|
zl[i] = z;
|
||||||
yl[i] = y;
|
yl[i] = y;
|
||||||
bl[i] = blocks[PseudoRandom.random(blocks.length)];
|
bl[i] = blocks[random.random(blocks.length)];
|
||||||
i++;
|
i++;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -86,7 +87,7 @@ public abstract class ClassicPlotManager extends SquarePlotManager {
|
|||||||
xl[i] = x;
|
xl[i] = x;
|
||||||
zl[i] = z;
|
zl[i] = z;
|
||||||
yl[i] = y;
|
yl[i] = y;
|
||||||
bl[i] = blocks[PseudoRandom.random(blocks.length)];
|
bl[i] = blocks[random.random(blocks.length)];
|
||||||
i++;
|
i++;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -96,7 +97,7 @@ public abstract class ClassicPlotManager extends SquarePlotManager {
|
|||||||
xl[i] = x;
|
xl[i] = x;
|
||||||
zl[i] = z;
|
zl[i] = z;
|
||||||
yl[i] = y;
|
yl[i] = y;
|
||||||
bl[i] = blocks[PseudoRandom.random(blocks.length)];
|
bl[i] = blocks[random.random(blocks.length)];
|
||||||
i++;
|
i++;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -121,12 +122,13 @@ public abstract class ClassicPlotManager extends SquarePlotManager {
|
|||||||
int x, z;
|
int x, z;
|
||||||
z = bottom.getZ();
|
z = bottom.getZ();
|
||||||
int i = 0;
|
int i = 0;
|
||||||
|
PseudoRandom random = new PseudoRandom();
|
||||||
final int y = dpw.WALL_HEIGHT + 1;
|
final int y = dpw.WALL_HEIGHT + 1;
|
||||||
for (x = bottom.getX(); x <= (top.getX() - 1); x++) {
|
for (x = bottom.getX(); x <= (top.getX() - 1); x++) {
|
||||||
xl[i] = x;
|
xl[i] = x;
|
||||||
zl[i] = z;
|
zl[i] = z;
|
||||||
yl[i] = y;
|
yl[i] = y;
|
||||||
bl[i] = blocks[PseudoRandom.random(blocks.length)];
|
bl[i] = blocks[random.random(blocks.length)];
|
||||||
i++;
|
i++;
|
||||||
}
|
}
|
||||||
x = top.getX();
|
x = top.getX();
|
||||||
@ -134,7 +136,7 @@ public abstract class ClassicPlotManager extends SquarePlotManager {
|
|||||||
xl[i] = x;
|
xl[i] = x;
|
||||||
zl[i] = z;
|
zl[i] = z;
|
||||||
yl[i] = y;
|
yl[i] = y;
|
||||||
bl[i] = blocks[PseudoRandom.random(blocks.length)];
|
bl[i] = blocks[random.random(blocks.length)];
|
||||||
i++;
|
i++;
|
||||||
}
|
}
|
||||||
z = top.getZ();
|
z = top.getZ();
|
||||||
@ -142,7 +144,7 @@ public abstract class ClassicPlotManager extends SquarePlotManager {
|
|||||||
xl[i] = x;
|
xl[i] = x;
|
||||||
zl[i] = z;
|
zl[i] = z;
|
||||||
yl[i] = y;
|
yl[i] = y;
|
||||||
bl[i] = blocks[PseudoRandom.random(blocks.length)];
|
bl[i] = blocks[random.random(blocks.length)];
|
||||||
i++;
|
i++;
|
||||||
}
|
}
|
||||||
x = bottom.getX();
|
x = bottom.getX();
|
||||||
@ -150,7 +152,7 @@ public abstract class ClassicPlotManager extends SquarePlotManager {
|
|||||||
xl[i] = x;
|
xl[i] = x;
|
||||||
zl[i] = z;
|
zl[i] = z;
|
||||||
yl[i] = y;
|
yl[i] = y;
|
||||||
bl[i] = blocks[PseudoRandom.random(blocks.length)];
|
bl[i] = blocks[random.random(blocks.length)];
|
||||||
i++;
|
i++;
|
||||||
}
|
}
|
||||||
BlockManager.setBlocks(plotworld.worldname, xl, yl, zl, bl);
|
BlockManager.setBlocks(plotworld.worldname, xl, yl, zl, bl);
|
||||||
@ -188,7 +190,7 @@ public abstract class ClassicPlotManager extends SquarePlotManager {
|
|||||||
final int ez = (sz + dpw.ROAD_WIDTH) - 1;
|
final int ez = (sz + dpw.ROAD_WIDTH) - 1;
|
||||||
final int sx = pos1.getX() - 1;
|
final int sx = pos1.getX() - 1;
|
||||||
final int ex = pos2.getX() + 2;
|
final int ex = pos2.getX() + 2;
|
||||||
MainUtil.setSimpleCuboid(plotworld.worldname, new Location(plotworld.worldname, sx, Math.min(dpw.WALL_HEIGHT, dpw.ROAD_HEIGHT) + 1, sz + 1), new Location(plotworld.worldname, ex + 1, 257, ez), new PlotBlock((short) 0, (byte) 0));
|
MainUtil.setSimpleCuboid(plotworld.worldname, new Location(plotworld.worldname, sx, Math.min(dpw.WALL_HEIGHT, dpw.ROAD_HEIGHT) + 1, sz), new Location(plotworld.worldname, ex + 1, 257, ez + 1), new PlotBlock((short) 0, (byte) 0));
|
||||||
MainUtil.setSimpleCuboid(plotworld.worldname, new Location(plotworld.worldname, sx + 1, 0, sz), new Location(plotworld.worldname, ex, 1, ez + 1), new PlotBlock((short) 7, (byte) 0));
|
MainUtil.setSimpleCuboid(plotworld.worldname, new Location(plotworld.worldname, sx + 1, 0, sz), new Location(plotworld.worldname, ex, 1, ez + 1), new PlotBlock((short) 7, (byte) 0));
|
||||||
MainUtil.setSimpleCuboid(plotworld.worldname, new Location(plotworld.worldname, sx + 1, 1, sz), new Location(plotworld.worldname, ex, dpw.WALL_HEIGHT + 1, sz + 1), dpw.WALL_FILLING);
|
MainUtil.setSimpleCuboid(plotworld.worldname, new Location(plotworld.worldname, sx + 1, 1, sz), new Location(plotworld.worldname, ex, dpw.WALL_HEIGHT + 1, sz + 1), dpw.WALL_FILLING);
|
||||||
MainUtil.setSimpleCuboid(plotworld.worldname, new Location(plotworld.worldname, sx + 1, dpw.WALL_HEIGHT + 1, sz), new Location(plotworld.worldname, ex, dpw.WALL_HEIGHT + 2, sz + 1), dpw.WALL_BLOCK);
|
MainUtil.setSimpleCuboid(plotworld.worldname, new Location(plotworld.worldname, sx + 1, dpw.WALL_HEIGHT + 1, sz), new Location(plotworld.worldname, ex, dpw.WALL_HEIGHT + 2, sz + 1), dpw.WALL_BLOCK);
|
||||||
@ -275,7 +277,7 @@ public abstract class ClassicPlotManager extends SquarePlotManager {
|
|||||||
final PlotBlock block = ((ClassicPlotWorld) plotworld).CLAIMED_WALL_BLOCK;
|
final PlotBlock block = ((ClassicPlotWorld) plotworld).CLAIMED_WALL_BLOCK;
|
||||||
final PlotBlock unclaim = ((ClassicPlotWorld) plotworld).WALL_BLOCK;
|
final PlotBlock unclaim = ((ClassicPlotWorld) plotworld).WALL_BLOCK;
|
||||||
for (final PlotId id : plotIds) {
|
for (final PlotId id : plotIds) {
|
||||||
if (!block.equals(unclaim)) {
|
if (block.id != 0 || !block.equals(unclaim)) {
|
||||||
setWall(plotworld, id, new PlotBlock[] { block });
|
setWall(plotworld, id, new PlotBlock[] { block });
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -296,7 +298,7 @@ public abstract class ClassicPlotManager extends SquarePlotManager {
|
|||||||
public boolean claimPlot(final PlotWorld plotworld, final Plot plot) {
|
public boolean claimPlot(final PlotWorld plotworld, final Plot plot) {
|
||||||
final PlotBlock unclaim = ((ClassicPlotWorld) plotworld).WALL_BLOCK;
|
final PlotBlock unclaim = ((ClassicPlotWorld) plotworld).WALL_BLOCK;
|
||||||
final PlotBlock claim = ((ClassicPlotWorld) plotworld).CLAIMED_WALL_BLOCK;
|
final PlotBlock claim = ((ClassicPlotWorld) plotworld).CLAIMED_WALL_BLOCK;
|
||||||
if (!claim.equals(unclaim)) {
|
if (claim.id != 0 || !claim.equals(unclaim)) {
|
||||||
setWall(plotworld, plot.id, new PlotBlock[] { claim });
|
setWall(plotworld, plot.id, new PlotBlock[] { claim });
|
||||||
}
|
}
|
||||||
return true;
|
return true;
|
||||||
@ -306,9 +308,10 @@ public abstract class ClassicPlotManager extends SquarePlotManager {
|
|||||||
public boolean unclaimPlot(final PlotWorld plotworld, final Plot plot) {
|
public boolean unclaimPlot(final PlotWorld plotworld, final Plot plot) {
|
||||||
final PlotBlock unclaim = ((ClassicPlotWorld) plotworld).WALL_BLOCK;
|
final PlotBlock unclaim = ((ClassicPlotWorld) plotworld).WALL_BLOCK;
|
||||||
final PlotBlock claim = ((ClassicPlotWorld) plotworld).CLAIMED_WALL_BLOCK;
|
final PlotBlock claim = ((ClassicPlotWorld) plotworld).CLAIMED_WALL_BLOCK;
|
||||||
if (!claim.equals(unclaim)) {
|
if (unclaim.id != 0 || !claim.equals(unclaim)) {
|
||||||
setWall(plotworld, plot.id, new PlotBlock[] { unclaim });
|
setWall(plotworld, plot.id, new PlotBlock[] { unclaim });
|
||||||
}
|
}
|
||||||
|
MainUtil.removeSign(plot);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -31,7 +31,7 @@ public abstract class ClassicPlotWorld extends SquarePlotWorld {
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* CONFIG NODE | DEFAULT VALUE | DESCRIPTION | CONFIGURATION TYPE | REQUIRED FOR INITIAL SETUP
|
* CONFIG NODE | DEFAULT VALUE | DESCRIPTION | CONFIGURATION TYPE | REQUIRED FOR INITIAL SETUP
|
||||||
* <p/>
|
*
|
||||||
* Set the last boolean to false if you do not require a specific config node to be set while using the setup
|
* Set the last boolean to false if you do not require a specific config node to be set while using the setup
|
||||||
* command - this may be useful if a config value can be changed at a later date, and has no impact on the actual
|
* command - this may be useful if a config value can be changed at a later date, and has no impact on the actual
|
||||||
* world generation
|
* world generation
|
||||||
|
@ -24,20 +24,18 @@ import java.util.Arrays;
|
|||||||
import java.util.HashMap;
|
import java.util.HashMap;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Map.Entry;
|
import java.util.Map.Entry;
|
||||||
import java.util.Random;
|
|
||||||
|
|
||||||
import org.bukkit.Bukkit;
|
import org.bukkit.Bukkit;
|
||||||
import org.bukkit.Location;
|
|
||||||
import org.bukkit.World;
|
import org.bukkit.World;
|
||||||
import org.bukkit.block.Biome;
|
import org.bukkit.block.Biome;
|
||||||
import org.bukkit.generator.BlockPopulator;
|
|
||||||
|
|
||||||
import com.intellectualcrafters.plot.object.PlotGenerator;
|
import com.intellectualcrafters.plot.object.PlotGenerator;
|
||||||
import com.intellectualcrafters.plot.object.PlotLoc;
|
import com.intellectualcrafters.plot.object.PlotLoc;
|
||||||
import com.intellectualcrafters.plot.object.PlotManager;
|
import com.intellectualcrafters.plot.object.PlotManager;
|
||||||
|
import com.intellectualcrafters.plot.object.PlotPopulator;
|
||||||
import com.intellectualcrafters.plot.object.PlotWorld;
|
import com.intellectualcrafters.plot.object.PlotWorld;
|
||||||
|
import com.intellectualcrafters.plot.object.PseudoRandom;
|
||||||
import com.intellectualcrafters.plot.object.RegionWrapper;
|
import com.intellectualcrafters.plot.object.RegionWrapper;
|
||||||
import com.intellectualcrafters.plot.util.ChunkManager;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The default generator is very messy, as we have decided to try externalize all calculations from within the loop. -
|
* The default generator is very messy, as we have decided to try externalize all calculations from within the loop. -
|
||||||
@ -75,22 +73,11 @@ public class HybridGen extends PlotGenerator {
|
|||||||
short pathWidthUpper;
|
short pathWidthUpper;
|
||||||
boolean doState = false;
|
boolean doState = false;
|
||||||
int maxY = 0;
|
int maxY = 0;
|
||||||
/**
|
|
||||||
* result object is returned for each generated chunk, do stuff to it
|
|
||||||
*/
|
|
||||||
short[][] result;
|
|
||||||
/**
|
|
||||||
* Faster sudo-random number generator than java.util.random
|
|
||||||
*/
|
|
||||||
private long state = 13;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Initialize variables, and create plotworld object used in calculations
|
* Initialize variables, and create plotworld object used in calculations
|
||||||
*/
|
*/
|
||||||
public void init(PlotWorld plotworld) {
|
public void init(PlotWorld plotworld) {
|
||||||
if (this.plotworld == null) {
|
|
||||||
this.plotworld = (HybridPlotWorld) plotworld;
|
|
||||||
}
|
|
||||||
this.plotsize = this.plotworld.PLOT_WIDTH;
|
this.plotsize = this.plotworld.PLOT_WIDTH;
|
||||||
this.pathsize = this.plotworld.ROAD_WIDTH;
|
this.pathsize = this.plotworld.ROAD_WIDTH;
|
||||||
this.roadblock = this.plotworld.ROAD_BLOCK.id;
|
this.roadblock = this.plotworld.ROAD_BLOCK.id;
|
||||||
@ -111,12 +98,18 @@ public class HybridGen extends PlotGenerator {
|
|||||||
this.wallheight = this.plotworld.WALL_HEIGHT;
|
this.wallheight = this.plotworld.WALL_HEIGHT;
|
||||||
this.roadheight = this.plotworld.ROAD_HEIGHT;
|
this.roadheight = this.plotworld.ROAD_HEIGHT;
|
||||||
this.plotheight = this.plotworld.PLOT_HEIGHT;
|
this.plotheight = this.plotworld.PLOT_HEIGHT;
|
||||||
if ((this.pathsize % 2) == 0) {
|
if (this.pathsize == 0) {
|
||||||
this.pathWidthLower = (short) (Math.floor(this.pathsize / 2) - 1);
|
this.pathWidthLower = (short) -1;
|
||||||
} else {
|
this.pathWidthUpper = (short) (this.plotsize + 1);
|
||||||
this.pathWidthLower = (short) (Math.floor(this.pathsize / 2));
|
}
|
||||||
|
else {
|
||||||
|
if ((this.pathsize % 2) == 0) {
|
||||||
|
this.pathWidthLower = (short) (Math.floor(this.pathsize / 2) - 1);
|
||||||
|
} else {
|
||||||
|
this.pathWidthLower = (short) (Math.floor(this.pathsize / 2));
|
||||||
|
}
|
||||||
|
this.pathWidthUpper = (short) (this.pathWidthLower + this.plotsize + 1);
|
||||||
}
|
}
|
||||||
this.pathWidthUpper = (short) (this.pathWidthLower + this.plotsize + 1);
|
|
||||||
this.biome = Biome.valueOf(this.plotworld.PLOT_BIOME);
|
this.biome = Biome.valueOf(this.plotworld.PLOT_BIOME);
|
||||||
try {
|
try {
|
||||||
this.maxY = Bukkit.getWorld(plotworld.worldname).getMaxHeight();
|
this.maxY = Bukkit.getWorld(plotworld.worldname).getMaxHeight();
|
||||||
@ -124,14 +117,12 @@ public class HybridGen extends PlotGenerator {
|
|||||||
if (this.maxY == 0) {
|
if (this.maxY == 0) {
|
||||||
this.maxY = 256;
|
this.maxY = 256;
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Return the plot manager for this type of generator, or create one For square plots you may as well use the
|
* Return the plot manager for this type of generator, or create one For square plots you may as well use the
|
||||||
* default plot manager which comes with PlotSquared
|
* default plot manager which comes with PlotSquared
|
||||||
*/
|
*/
|
||||||
@Override
|
|
||||||
public PlotManager getPlotManager() {
|
public PlotManager getPlotManager() {
|
||||||
if (HybridGen.manager == null) {
|
if (HybridGen.manager == null) {
|
||||||
HybridGen.manager = new HybridPlotManager();
|
HybridGen.manager = new HybridPlotManager();
|
||||||
@ -139,18 +130,9 @@ public class HybridGen extends PlotGenerator {
|
|||||||
return HybridGen.manager;
|
return HybridGen.manager;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* Allow spawning everywhere
|
|
||||||
*/
|
|
||||||
@Override
|
|
||||||
public boolean canSpawn(final World world, final int x, final int z) {
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Get a new plotworld class For square plots you can use the DefaultPlotWorld class which comes with PlotSquared
|
* Get a new plotworld class For square plots you can use the DefaultPlotWorld class which comes with PlotSquared
|
||||||
*/
|
*/
|
||||||
@Override
|
|
||||||
public PlotWorld getNewPlotWorld(final String world) {
|
public PlotWorld getNewPlotWorld(final String world) {
|
||||||
if (this.plotworld == null) {
|
if (this.plotworld == null) {
|
||||||
this.plotworld = new HybridPlotWorld(world);
|
this.plotworld = new HybridPlotWorld(world);
|
||||||
@ -158,103 +140,29 @@ public class HybridGen extends PlotGenerator {
|
|||||||
return this.plotworld;
|
return this.plotworld;
|
||||||
}
|
}
|
||||||
|
|
||||||
public final long nextLong() {
|
|
||||||
final long a = this.state;
|
|
||||||
this.state = xorShift64(a);
|
|
||||||
return a;
|
|
||||||
}
|
|
||||||
|
|
||||||
public final long xorShift64(long a) {
|
|
||||||
a ^= (a << 21);
|
|
||||||
a ^= (a >>> 35);
|
|
||||||
a ^= (a << 4);
|
|
||||||
return a;
|
|
||||||
}
|
|
||||||
|
|
||||||
public final int random(final int n) {
|
|
||||||
final long r = ((nextLong() >>> 32) * n) >> 32;
|
|
||||||
return (int) r;
|
|
||||||
}
|
|
||||||
|
|
||||||
private void setBlock(final short[][] result, final int x, final int y, final int z, final short[] blkids) {
|
|
||||||
if (blkids.length == 1) {
|
|
||||||
setBlock(result, x, y, z, blkids[0]);
|
|
||||||
} else {
|
|
||||||
final int i = random(blkids.length);
|
|
||||||
setBlock(result, x, y, z, blkids[i]);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Standard setblock method for world generation
|
|
||||||
*/
|
|
||||||
private void setBlock(final short[][] result, final int x, final int y, final int z, final short blkid) {
|
|
||||||
if (result[y >> 4] == null) {
|
|
||||||
result[y >> 4] = new short[4096];
|
|
||||||
}
|
|
||||||
result[y >> 4][((y & 0xF) << 8) | (z << 4) | x] = blkid;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Return the block populator
|
* Return the block populator
|
||||||
*/
|
*/
|
||||||
public List<BlockPopulator> getPopulators(final World world) {
|
public List<PlotPopulator> getPopulators(final String world) {
|
||||||
// disabling spawning for this world
|
|
||||||
if (!this.plotworld.MOB_SPAWNING) {
|
|
||||||
if (!this.plotworld.SPAWN_EGGS) {
|
|
||||||
world.setSpawnFlags(false, false);
|
|
||||||
}
|
|
||||||
world.setAmbientSpawnLimit(0);
|
|
||||||
world.setAnimalSpawnLimit(0);
|
|
||||||
world.setMonsterSpawnLimit(0);
|
|
||||||
world.setWaterAnimalSpawnLimit(0);
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
world.setSpawnFlags(true, true);
|
|
||||||
world.setAmbientSpawnLimit(-1);
|
|
||||||
world.setAnimalSpawnLimit(-1);
|
|
||||||
world.setMonsterSpawnLimit(-1);
|
|
||||||
world.setWaterAnimalSpawnLimit(-1);
|
|
||||||
}
|
|
||||||
// You can have as many populators as you would like, e.g. tree
|
// You can have as many populators as you would like, e.g. tree
|
||||||
// populator, ore populator
|
// populator, ore populator
|
||||||
return Arrays.asList((BlockPopulator) new HybridPop(this.plotworld));
|
return Arrays.asList((PlotPopulator) new HybridPop(this.plotworld));
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* Return the default spawn location for this world
|
|
||||||
*/
|
|
||||||
@Override
|
|
||||||
public Location getFixedSpawnLocation(final World world, final Random random) {
|
|
||||||
if (this.plotworld == null) {
|
|
||||||
return new Location(world, 0, 128, 0);
|
|
||||||
}
|
|
||||||
return new Location(world, 0, this.plotworld.ROAD_HEIGHT + 2, 0);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* This part is a fucking mess. - Refer to a proper tutorial if you would like to learn how to make a world
|
* This part is a fucking mess. - Refer to a proper tutorial if you would like to learn how to make a world
|
||||||
* generator
|
* generator
|
||||||
*/
|
*/
|
||||||
@Override
|
public void generateChunk(final World world, RegionWrapper region, final PseudoRandom random, final int cx, final int cz, final BiomeGrid biomes) {
|
||||||
public short[][] generateExtBlockSections(final World world, final Random random, final int cx, final int cz, final BiomeGrid biomes) {
|
|
||||||
if (this.doState) {
|
|
||||||
final int prime = 13;
|
|
||||||
int h = 1;
|
|
||||||
h = (prime * h) + cx;
|
|
||||||
h = (prime * h) + cz;
|
|
||||||
this.state = h;
|
|
||||||
}
|
|
||||||
this.result = new short[this.maxY / 16][];
|
|
||||||
if (this.plotworld.PLOT_BEDROCK) {
|
if (this.plotworld.PLOT_BEDROCK) {
|
||||||
for (short x = 0; x < 16; x++) {
|
for (short x = 0; x < 16; x++) {
|
||||||
for (short z = 0; z < 16; z++) {
|
for (short z = 0; z < 16; z++) {
|
||||||
setBlock(this.result, x, 0, z, (short) 7);
|
setBlock(x, 0, z, (short) 7);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
final RegionWrapper plot = ChunkManager.CURRENT_PLOT_CLEAR;
|
if (region != null) {
|
||||||
if (plot != null) {
|
|
||||||
final int X = cx << 4;
|
final int X = cx << 4;
|
||||||
final int Z = cz << 4;
|
final int Z = cz << 4;
|
||||||
int sx = ((X) % this.size);
|
int sx = ((X) % this.size);
|
||||||
@ -270,39 +178,32 @@ public class HybridGen extends PlotGenerator {
|
|||||||
if (biomes != null) {
|
if (biomes != null) {
|
||||||
biomes.setBiome(x, z, this.biome);
|
biomes.setBiome(x, z, this.biome);
|
||||||
}
|
}
|
||||||
if (isIn(plot, X + x, Z + z)) {
|
if (contains(region, x, z)) {
|
||||||
for (short y = 1; y < this.plotheight; y++) {
|
for (short y = 1; y < this.plotheight; y++) {
|
||||||
setBlock(this.result, x, y, z, this.filling);
|
setBlock(x, y, z, this.filling);
|
||||||
}
|
}
|
||||||
setBlock(this.result, x, this.plotheight, z, this.plotfloors);
|
setBlock(x, this.plotheight, z, this.plotfloors);
|
||||||
final PlotLoc loc = new PlotLoc((short) (X + x), (short) (Z + z));
|
final PlotLoc loc = new PlotLoc((X + x), (Z + z));
|
||||||
final HashMap<Short, Short> blocks = plotworld.G_SCH.get(loc);
|
final HashMap<Short, Short> blocks = plotworld.G_SCH.get(loc);
|
||||||
if (blocks != null) {
|
if (blocks != null) {
|
||||||
for (final Entry<Short, Short> entry : blocks.entrySet()) {
|
for (final Entry<Short, Short> entry : blocks.entrySet()) {
|
||||||
setBlock(this.result, x, this.plotheight + entry.getKey(), z, entry.getValue());
|
setBlock(x, this.plotheight + entry.getKey(), z, entry.getValue());
|
||||||
}
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
final PlotLoc loc = new PlotLoc((short) (X + x), (short) (Z + z));
|
|
||||||
final HashMap<Short, Short> blocks = ChunkManager.GENERATE_BLOCKS.get(loc);
|
|
||||||
if (blocks != null) {
|
|
||||||
for (final Entry<Short, Short> entry : blocks.entrySet()) {
|
|
||||||
setBlock(this.result, x, entry.getKey(), z, entry.getValue());
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return this.result;
|
return;
|
||||||
}
|
}
|
||||||
int sx = ((cx << 4) % this.size);
|
int sx = (short) ((this.X) % this.size);
|
||||||
int sz = ((cz << 4) % this.size);
|
int sz = (short) ((this.Z) % this.size);
|
||||||
if (sx < 0) {
|
if (sx < 0) {
|
||||||
sx += this.size;
|
sx += this.size;
|
||||||
}
|
}
|
||||||
if (sz < 0) {
|
if (sz < 0) {
|
||||||
sz += this.size;
|
sz += this.size;
|
||||||
}
|
}
|
||||||
|
|
||||||
for (short x = 0; x < 16; x++) {
|
for (short x = 0; x < 16; x++) {
|
||||||
for (short z = 0; z < 16; z++) {
|
for (short z = 0; z < 16; z++) {
|
||||||
if (biomes != null) {
|
if (biomes != null) {
|
||||||
@ -317,50 +218,46 @@ public class HybridGen extends PlotGenerator {
|
|||||||
// inside plot
|
// inside plot
|
||||||
if (gx && gz && lx && lz) {
|
if (gx && gz && lx && lz) {
|
||||||
for (short y = 1; y < this.plotheight; y++) {
|
for (short y = 1; y < this.plotheight; y++) {
|
||||||
setBlock(this.result, x, y, z, this.filling);
|
setBlock(x, y, z, this.filling);
|
||||||
}
|
}
|
||||||
setBlock(this.result, x, this.plotheight, z, this.plotfloors);
|
setBlock(x, this.plotheight, z, this.plotfloors);
|
||||||
if (this.plotworld.PLOT_SCHEMATIC) {
|
if (this.plotworld.PLOT_SCHEMATIC) {
|
||||||
final PlotLoc loc = new PlotLoc((short) absX, (short) absZ);
|
final PlotLoc loc = new PlotLoc(absX, absZ);
|
||||||
final HashMap<Short, Short> blocks = this.plotworld.G_SCH.get(loc);
|
final HashMap<Short, Short> blocks = this.plotworld.G_SCH.get(loc);
|
||||||
if (blocks != null) {
|
if (blocks != null) {
|
||||||
for (final Entry<Short, Short> entry : blocks.entrySet()) {
|
for (final Entry<Short, Short> entry : blocks.entrySet()) {
|
||||||
setBlock(this.result, x, this.plotheight + entry.getKey(), z, entry.getValue());
|
setBlock(x, this.plotheight + entry.getKey(), z, entry.getValue());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} else {
|
} else if (pathsize != 0) {
|
||||||
// wall
|
// wall
|
||||||
if (((absX >= this.pathWidthLower) && (absX <= this.pathWidthUpper) && (absZ >= this.pathWidthLower) && (absZ <= this.pathWidthUpper))) {
|
if (((absX >= this.pathWidthLower) && (absX <= this.pathWidthUpper) && (absZ >= this.pathWidthLower) && (absZ <= this.pathWidthUpper))) {
|
||||||
for (short y = 1; y <= this.wallheight; y++) {
|
for (short y = 1; y <= this.wallheight; y++) {
|
||||||
setBlock(this.result, x, y, z, this.wallfilling);
|
setBlock(x, y, z, this.wallfilling);
|
||||||
}
|
}
|
||||||
if (!this.plotworld.ROAD_SCHEMATIC_ENABLED) {
|
if (!this.plotworld.ROAD_SCHEMATIC_ENABLED) {
|
||||||
setBlock(this.result, x, this.wallheight + 1, z, this.wall);
|
setBlock(x, this.wallheight + 1, z, this.wall);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
// road
|
// road
|
||||||
else {
|
else {
|
||||||
for (short y = 1; y <= this.roadheight; y++) {
|
for (short y = 1; y <= this.roadheight; y++) {
|
||||||
setBlock(this.result, x, y, z, this.roadblock);
|
setBlock(x, y, z, this.roadblock);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (this.plotworld.ROAD_SCHEMATIC_ENABLED) {
|
if (this.plotworld.ROAD_SCHEMATIC_ENABLED) {
|
||||||
final PlotLoc loc = new PlotLoc((short) absX, (short) absZ);
|
final PlotLoc loc = new PlotLoc(absX, absZ);
|
||||||
final HashMap<Short, Short> blocks = this.plotworld.G_SCH.get(loc);
|
final HashMap<Short, Short> blocks = this.plotworld.G_SCH.get(loc);
|
||||||
if (blocks != null) {
|
if (blocks != null) {
|
||||||
for (final Entry<Short, Short> entry : blocks.entrySet()) {
|
for (final Entry<Short, Short> entry : blocks.entrySet()) {
|
||||||
setBlock(this.result, x, this.roadheight + entry.getKey(), z, entry.getValue());
|
setBlock(x, this.roadheight + entry.getKey(), z, entry.getValue());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return this.result;
|
return;
|
||||||
}
|
|
||||||
|
|
||||||
public boolean isIn(final RegionWrapper plot, final int x, final int z) {
|
|
||||||
return ((x >= plot.minX) && (x <= plot.maxX) && (z >= plot.minZ) && (z <= plot.maxZ));
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -24,6 +24,7 @@ import java.io.File;
|
|||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
import java.nio.file.Files;
|
import java.nio.file.Files;
|
||||||
import java.util.Arrays;
|
import java.util.Arrays;
|
||||||
|
import java.util.HashMap;
|
||||||
import java.util.HashSet;
|
import java.util.HashSet;
|
||||||
|
|
||||||
import com.intellectualcrafters.plot.PlotSquared;
|
import com.intellectualcrafters.plot.PlotSquared;
|
||||||
@ -32,42 +33,134 @@ import com.intellectualcrafters.plot.object.FileBytes;
|
|||||||
import com.intellectualcrafters.plot.object.Location;
|
import com.intellectualcrafters.plot.object.Location;
|
||||||
import com.intellectualcrafters.plot.object.Plot;
|
import com.intellectualcrafters.plot.object.Plot;
|
||||||
import com.intellectualcrafters.plot.object.PlotBlock;
|
import com.intellectualcrafters.plot.object.PlotBlock;
|
||||||
|
import com.intellectualcrafters.plot.object.PlotId;
|
||||||
|
import com.intellectualcrafters.plot.object.PlotLoc;
|
||||||
import com.intellectualcrafters.plot.object.PlotWorld;
|
import com.intellectualcrafters.plot.object.PlotWorld;
|
||||||
import com.intellectualcrafters.plot.object.PseudoRandom;
|
import com.intellectualcrafters.plot.util.BlockManager;
|
||||||
import com.intellectualcrafters.plot.util.MainUtil;
|
import com.intellectualcrafters.plot.util.MainUtil;
|
||||||
|
import com.intellectualcrafters.plot.util.SetBlockQueue;
|
||||||
import com.intellectualcrafters.plot.util.TaskManager;
|
import com.intellectualcrafters.plot.util.TaskManager;
|
||||||
import com.intellectualcrafters.plot.util.bukkit.BukkitUtil;
|
import com.intellectualcrafters.plot.util.bukkit.BukkitUtil;
|
||||||
|
|
||||||
public class HybridPlotManager extends ClassicPlotManager {
|
public class HybridPlotManager extends ClassicPlotManager {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void exportTemplate(PlotWorld plotworld) throws IOException {
|
public void exportTemplate(final PlotWorld plotworld) throws IOException {
|
||||||
HashSet<FileBytes> files = new HashSet<>(Arrays.asList(new FileBytes("templates/" + "tmp-data.yml", Template.getBytes(plotworld))));
|
final HashSet<FileBytes> files = new HashSet<>(Arrays.asList(new FileBytes("templates/" + "tmp-data.yml", Template.getBytes(plotworld))));
|
||||||
String psRoot = PlotSquared.IMP.getDirectory() + File.separator;
|
final String psRoot = PlotSquared.IMP.getDirectory() + File.separator;
|
||||||
String dir = "schematics" + File.separator + "GEN_ROAD_SCHEMATIC" + File.separator + plotworld.worldname + File.separator;
|
final String dir = "schematics" + File.separator + "GEN_ROAD_SCHEMATIC" + File.separator + plotworld.worldname + File.separator;
|
||||||
String newDir = "schematics" + File.separator + "GEN_ROAD_SCHEMATIC" + File.separator + "__TEMP_DIR__" + File.separator;
|
final String newDir = "schematics" + File.separator + "GEN_ROAD_SCHEMATIC" + File.separator + "__TEMP_DIR__" + File.separator;
|
||||||
try {
|
try {
|
||||||
File sideroad = new File(psRoot + dir + "sideroad.schematic");
|
final File sideroad = new File(psRoot + dir + "sideroad.schematic");
|
||||||
if (sideroad.exists()) {
|
if (sideroad.exists()) {
|
||||||
files.add(new FileBytes(newDir + "sideroad.schematic", Files.readAllBytes(sideroad.toPath())));
|
files.add(new FileBytes(newDir + "sideroad.schematic", Files.readAllBytes(sideroad.toPath())));
|
||||||
|
}
|
||||||
|
final File intersection = new File(psRoot + dir + "intersection.schematic");
|
||||||
|
if (intersection.exists()) {
|
||||||
|
files.add(new FileBytes(newDir + "intersection.schematic", Files.readAllBytes(intersection.toPath())));
|
||||||
|
}
|
||||||
|
final File plot = new File(psRoot + dir + "plot.schematic");
|
||||||
|
if (plot.exists()) {
|
||||||
|
files.add(new FileBytes(newDir + "plot.schematic", Files.readAllBytes(plot.toPath())));
|
||||||
|
}
|
||||||
}
|
}
|
||||||
File intersection = new File(psRoot + dir + "intersection.schematic");
|
catch (final Exception e) {
|
||||||
if (intersection.exists()) {
|
|
||||||
files.add(new FileBytes(newDir + "intersection.schematic", Files.readAllBytes(intersection.toPath())));
|
|
||||||
}
|
|
||||||
File plot = new File(psRoot + dir + "plot.schematic");
|
|
||||||
if (plot.exists()) {
|
|
||||||
files.add(new FileBytes(newDir + "plot.schematic", Files.readAllBytes(plot.toPath())));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
catch (Exception e) {
|
|
||||||
e.printStackTrace();
|
e.printStackTrace();
|
||||||
}
|
}
|
||||||
Template.zipAll(plotworld.worldname, files);
|
Template.zipAll(plotworld.worldname, files);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean createRoadEast(PlotWorld plotworld, Plot plot) {
|
||||||
|
super.createRoadEast(plotworld, plot);
|
||||||
|
HybridPlotWorld hpw = (HybridPlotWorld) plotworld;
|
||||||
|
if (!hpw.ROAD_SCHEMATIC_ENABLED) {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
PlotId id = plot.id;
|
||||||
|
PlotId id2 = new PlotId(id.x + 1, id.y);
|
||||||
|
Location bot = getPlotBottomLocAbs(hpw, id2);
|
||||||
|
Location top = getPlotTopLocAbs(hpw, id);
|
||||||
|
Location pos1 = new Location(plot.world, top.getX() + 1, 0, bot.getZ());
|
||||||
|
Location pos2 = new Location(plot.world, bot.getX(), 256, top.getZ() + 1);
|
||||||
|
createRoadAbs(hpw, pos1, pos2);
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
public static void createRoadAbs(HybridPlotWorld hpw, Location pos1, Location pos2) {
|
||||||
|
final int sy = hpw.ROAD_HEIGHT;
|
||||||
|
final int size = hpw.SIZE;
|
||||||
|
for (int x = pos1.getX(); x <= pos2.getX(); x++) {
|
||||||
|
for (int z = pos1.getZ(); z <= pos2.getZ(); z++) {
|
||||||
|
short absX = (short) (x % size);
|
||||||
|
short absZ = (short) (z % size);
|
||||||
|
if (absX < 0) {
|
||||||
|
absX += size;
|
||||||
|
}
|
||||||
|
if (absZ < 0) {
|
||||||
|
absZ += size;
|
||||||
|
}
|
||||||
|
final PlotLoc loc = new PlotLoc(absX, absZ);
|
||||||
|
final HashMap<Short, Short> blocks = hpw.G_SCH.get(loc);
|
||||||
|
for (short y = (short) (hpw.ROAD_HEIGHT); y <= (hpw.ROAD_HEIGHT + hpw.SCHEMATIC_HEIGHT); y++) {
|
||||||
|
SetBlockQueue.setBlock(hpw.worldname, x, y + y, z, 0);
|
||||||
|
}
|
||||||
|
if (blocks != null) {
|
||||||
|
final HashMap<Short, Byte> datas = hpw.G_SCH_DATA.get(loc);
|
||||||
|
if (datas == null) {
|
||||||
|
for (final Short y : blocks.keySet()) {
|
||||||
|
SetBlockQueue.setBlock(hpw.worldname, x, sy + y, z, blocks.get(y));
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
for (final Short y : blocks.keySet()) {
|
||||||
|
Byte data = datas.get(y);
|
||||||
|
if (data == null) {
|
||||||
|
data = 0;
|
||||||
|
}
|
||||||
|
SetBlockQueue.setBlock(hpw.worldname, x, sy + y, z, new PlotBlock(blocks.get(y), data));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean createRoadSouth(PlotWorld plotworld, Plot plot) {
|
||||||
|
super.createRoadSouth(plotworld, plot);
|
||||||
|
HybridPlotWorld hpw = (HybridPlotWorld) plotworld;
|
||||||
|
if (!hpw.ROAD_SCHEMATIC_ENABLED) {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
PlotId id = plot.id;
|
||||||
|
PlotId id2 = new PlotId(id.x, id.y + 1);
|
||||||
|
Location bot = getPlotBottomLocAbs(hpw, id2);
|
||||||
|
Location top = getPlotTopLocAbs(hpw, id);
|
||||||
|
Location pos1 = new Location(plot.world, bot.getX(), 0, top.getZ() + 1);
|
||||||
|
Location pos2 = new Location(plot.world, top.getX() + 1, 256, bot.getZ());
|
||||||
|
createRoadAbs(hpw, pos1, pos2);
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean createRoadSouthEast(PlotWorld plotworld, Plot plot) {
|
||||||
|
super.createRoadSouthEast(plotworld, plot);
|
||||||
|
HybridPlotWorld hpw = (HybridPlotWorld) plotworld;
|
||||||
|
if (!hpw.ROAD_SCHEMATIC_ENABLED) {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
PlotId id = plot.id;
|
||||||
|
PlotId id2 = new PlotId(id.x + 1, id.y + 1);
|
||||||
|
Location pos1 = getPlotTopLocAbs(hpw, id).add(1, 0, 1);
|
||||||
|
Location pos2 = getPlotBottomLocAbs(hpw, id2);
|
||||||
|
pos1.setY(0);
|
||||||
|
pos2.setY(256);
|
||||||
|
createRoadAbs(hpw, pos1, pos2);
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Clearing the plot needs to only consider removing the blocks - This implementation has used the SetCuboid
|
* Clearing the plot needs to only consider removing the blocks - This implementation has used the setCuboidAsync
|
||||||
* function, as it is fast, and uses NMS code - It also makes use of the fact that deleting chunks is a lot faster
|
* function, as it is fast, and uses NMS code - It also makes use of the fact that deleting chunks is a lot faster
|
||||||
* than block updates This code is very messy, but you don't need to do something quite as complex unless you happen
|
* than block updates This code is very messy, but you don't need to do something quite as complex unless you happen
|
||||||
* to have 512x512 sized plots
|
* to have 512x512 sized plots
|
||||||
@ -75,19 +168,11 @@ public class HybridPlotManager extends ClassicPlotManager {
|
|||||||
@Override
|
@Override
|
||||||
public boolean clearPlot(final PlotWorld plotworld, final Plot plot, final boolean isDelete, final Runnable whenDone) {
|
public boolean clearPlot(final PlotWorld plotworld, final Plot plot, final boolean isDelete, final Runnable whenDone) {
|
||||||
final String world = plotworld.worldname;
|
final String world = plotworld.worldname;
|
||||||
MainUtil.runners.put(plot, 1);
|
|
||||||
TaskManager.runTaskLater(new Runnable() {
|
|
||||||
@Override
|
|
||||||
public void run() {
|
|
||||||
MainUtil.runners.remove(plot);
|
|
||||||
}
|
|
||||||
}, 90);
|
|
||||||
final HybridPlotWorld dpw = ((HybridPlotWorld) plotworld);
|
final HybridPlotWorld dpw = ((HybridPlotWorld) plotworld);
|
||||||
final Location pos1 = MainUtil.getPlotBottomLocAbs(world, plot.id).add(1, 0, 1);
|
final Location pos1 = MainUtil.getPlotBottomLocAbs(world, plot.id).add(1, 0, 1);
|
||||||
final Location pos2 = MainUtil.getPlotTopLocAbs(world, plot.id);
|
final Location pos2 = MainUtil.getPlotTopLocAbs(world, plot.id);
|
||||||
final PlotBlock[] plotfloor = dpw.TOP_BLOCK;
|
final PlotBlock[] plotfloor = dpw.TOP_BLOCK;
|
||||||
final PlotBlock[] filling = dpw.MAIN_BLOCK;
|
final PlotBlock[] filling = dpw.MAIN_BLOCK;
|
||||||
// PlotBlock wall = dpw.WALL_BLOCK;
|
|
||||||
final PlotBlock wall;
|
final PlotBlock wall;
|
||||||
if (isDelete) {
|
if (isDelete) {
|
||||||
wall = dpw.WALL_BLOCK;
|
wall = dpw.WALL_BLOCK;
|
||||||
@ -97,298 +182,116 @@ public class HybridPlotManager extends ClassicPlotManager {
|
|||||||
final PlotBlock wall_filling = dpw.WALL_FILLING;
|
final PlotBlock wall_filling = dpw.WALL_FILLING;
|
||||||
setWallFilling(dpw, plot.id, new PlotBlock[] { wall_filling });
|
setWallFilling(dpw, plot.id, new PlotBlock[] { wall_filling });
|
||||||
final int maxy = BukkitUtil.getMaxHeight(world);
|
final int maxy = BukkitUtil.getMaxHeight(world);
|
||||||
TaskManager.runTaskLater(new Runnable() {
|
final short bedrock = (short) (dpw.PLOT_BEDROCK ? 7 : 0);
|
||||||
|
final int startX = (pos1.getX() / 16) * 16;
|
||||||
|
final int startZ = (pos1.getZ() / 16) * 16;
|
||||||
|
final int chunkX = 16 + pos2.getX();
|
||||||
|
final int chunkZ = 16 + pos2.getZ();
|
||||||
|
final Location l1 = MainUtil.getPlotBottomLoc(world, plot.id);
|
||||||
|
final Location l2 = MainUtil.getPlotTopLoc(world, plot.id);
|
||||||
|
final int plotMinX = l1.getX() + 1;
|
||||||
|
final int plotMinZ = l1.getZ() + 1;
|
||||||
|
final int plotMaxX = l2.getX();
|
||||||
|
final int plotMaxZ = l2.getZ();
|
||||||
|
Location mn = null;
|
||||||
|
Location mx = null;
|
||||||
|
for (int i = startX; i < chunkX; i += 16) {
|
||||||
|
for (int j = startZ; j < chunkZ; j += 16) {
|
||||||
|
final Plot plot1 = MainUtil.getPlot(new Location(world, i, 0, j));
|
||||||
|
if ((plot1 != null) && (!plot1.getId().equals(plot.getId()))) {
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
final Plot plot2 = MainUtil.getPlot(new Location(world, i + 15, 0, j));
|
||||||
|
if ((plot2 != null) && (!plot2.getId().equals(plot.getId()))) {
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
final Plot plot3 = MainUtil.getPlot(new Location(world, i + 15, 0, j + 15));
|
||||||
|
if ((plot3 != null) && (!plot3.getId().equals(plot.getId()))) {
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
final Plot plot4 = MainUtil.getPlot(new Location(world, i, 0, j + 15));
|
||||||
|
if ((plot4 != null) && (!plot4.getId().equals(plot.getId()))) {
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
final Plot plot5 = MainUtil.getPlot(new Location(world, i + 15, 0, j + 15));
|
||||||
|
if ((plot5 != null) && (!plot5.getId().equals(plot.getId()))) {
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
if (mn == null) {
|
||||||
|
mn = new Location(world, Math.max(i - 1, plotMinX), 0, Math.max(j - 1, plotMinZ));
|
||||||
|
mx = new Location(world, Math.min(i + 16, plotMaxX), 0, Math.min(j + 16, plotMaxZ));
|
||||||
|
} else if ((mx.getZ() < (j + 15)) || (mx.getX() < (i + 15))) {
|
||||||
|
mx = new Location(world, Math.min(i + 16, plotMaxX), 0, Math.min(j + 16, plotMaxZ));
|
||||||
|
}
|
||||||
|
final int I = i;
|
||||||
|
final int J = j;
|
||||||
|
BukkitUtil.regenerateChunk(world, I / 16, J / 16);
|
||||||
|
if (!MainUtil.canSendChunk) {
|
||||||
|
BukkitUtil.refreshChunk(world, I / 16, J / 16);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
setWall(dpw, plot.id, new PlotBlock[] { wall });
|
||||||
|
final Location max = mx;
|
||||||
|
final Location min = mn;
|
||||||
|
TaskManager.runTaskAsync(new Runnable() {
|
||||||
@Override
|
@Override
|
||||||
public void run() {
|
public void run() {
|
||||||
setWall(dpw, plot.id, new PlotBlock[] { wall });
|
if (min == null) {
|
||||||
TaskManager.runTaskLater(new Runnable() {
|
MainUtil.setSimpleCuboidAsync(world, new Location(world, pos1.getX(), 0, pos1.getZ()), new Location(world, pos2.getX() + 1, 1, pos2.getZ() + 1), new PlotBlock(bedrock, (byte) 0));
|
||||||
@Override
|
MainUtil.setSimpleCuboidAsync(world, new Location(world, pos1.getX(), dpw.PLOT_HEIGHT + 1, pos1.getZ()), new Location(world, pos2.getX() + 1, maxy + 1, pos2.getZ() + 1), new PlotBlock((short) 0, (byte) 0));
|
||||||
public void run() {
|
MainUtil.setCuboidAsync(world, new Location(world, pos1.getX(), 1, pos1.getZ()), new Location(world, pos2.getX() + 1, dpw.PLOT_HEIGHT, pos2.getZ() + 1), filling);
|
||||||
final short bedrock = (short) (dpw.PLOT_BEDROCK ? 7 : 0);
|
MainUtil.setCuboidAsync(world, new Location(world, pos1.getX(), dpw.PLOT_HEIGHT, pos1.getZ()), new Location(world, pos2.getX() + 1, dpw.PLOT_HEIGHT + 1, pos2.getZ() + 1), plotfloor);
|
||||||
final int startX = (pos1.getX() / 16) * 16;
|
SetBlockQueue.addNotify(whenDone);
|
||||||
final int startZ = (pos1.getZ() / 16) * 16;
|
return;
|
||||||
final int chunkX = 16 + pos2.getX();
|
}
|
||||||
final int chunkZ = 16 + pos2.getZ();
|
if (min.getX() < plotMinX) {
|
||||||
final Location l1 = MainUtil.getPlotBottomLoc(world, plot.id);
|
min.setX(plotMinX);
|
||||||
final Location l2 = MainUtil.getPlotTopLoc(world, plot.id);
|
}
|
||||||
final int plotMinX = l1.getX() + 1;
|
if (min.getZ() < plotMinZ) {
|
||||||
final int plotMinZ = l1.getZ() + 1;
|
min.setZ(plotMinZ);
|
||||||
final int plotMaxX = l2.getX();
|
}
|
||||||
final int plotMaxZ = l2.getZ();
|
if (max.getX() > plotMaxX) {
|
||||||
Location mn = null;
|
max.setX(plotMaxX);
|
||||||
Location mx = null;
|
}
|
||||||
for (int i = startX; i < chunkX; i += 16) {
|
if (max.getZ() > plotMaxZ) {
|
||||||
for (int j = startZ; j < chunkZ; j += 16) {
|
max.setZ(plotMaxZ);
|
||||||
final Plot plot1 = MainUtil.getPlot(new Location(world, i, 0, j));
|
}
|
||||||
if ((plot1 != null) && (!plot1.getId().equals(plot.getId()))) {
|
MainUtil.setSimpleCuboidAsync(world, new Location(world, plotMinX, 0, plotMinZ), new Location(world, min.getX() + 1, 1, min.getZ() + 1), new PlotBlock(bedrock, (byte) 0));
|
||||||
break;
|
MainUtil.setSimpleCuboidAsync(world, new Location(world, plotMinX, dpw.PLOT_HEIGHT + 1, plotMinZ), new Location(world, min.getX() + 1, maxy + 1, min.getZ() + 1), new PlotBlock((short) 0, (byte) 0));
|
||||||
}
|
MainUtil.setCuboidAsync(world, new Location(world, plotMinX, 1, plotMinZ), new Location(world, min.getX() + 1, dpw.PLOT_HEIGHT + 1, min.getZ() + 1), filling);
|
||||||
final Plot plot2 = MainUtil.getPlot(new Location(world, i + 15, 0, j));
|
MainUtil.setCuboidAsync(world, new Location(world, plotMinX, dpw.PLOT_HEIGHT, plotMinZ), new Location(world, min.getX() + 1, dpw.PLOT_HEIGHT + 1, min.getZ() + 1), plotfloor);
|
||||||
if ((plot2 != null) && (!plot2.getId().equals(plot.getId()))) {
|
MainUtil.setSimpleCuboidAsync(world, new Location(world, min.getX(), 0, plotMinZ), new Location(world, max.getX() + 1, 1, min.getZ() + 1), new PlotBlock(bedrock, (byte) 0));
|
||||||
break;
|
MainUtil.setSimpleCuboidAsync(world, new Location(world, min.getX(), dpw.PLOT_HEIGHT + 1, plotMinZ), new Location(world, max.getX() + 1, maxy + 1, min.getZ() + 1), new PlotBlock((short) 0, (byte) 0));
|
||||||
}
|
MainUtil.setCuboidAsync(world, new Location(world, min.getX(), 1, plotMinZ), new Location(world, max.getX() + 1, dpw.PLOT_HEIGHT, min.getZ() + 1), filling);
|
||||||
final Plot plot3 = MainUtil.getPlot(new Location(world, i + 15, 0, j + 15));
|
MainUtil.setCuboidAsync(world, new Location(world, min.getX(), dpw.PLOT_HEIGHT, plotMinZ), new Location(world, max.getX() + 1, dpw.PLOT_HEIGHT + 1, min.getZ() + 1), plotfloor);
|
||||||
if ((plot3 != null) && (!plot3.getId().equals(plot.getId()))) {
|
MainUtil.setSimpleCuboidAsync(world, new Location(world, max.getX(), 0, plotMinZ), new Location(world, plotMaxX + 1, 1, min.getZ() + 1), new PlotBlock(bedrock, (byte) 0));
|
||||||
break;
|
MainUtil.setSimpleCuboidAsync(world, new Location(world, max.getX(), dpw.PLOT_HEIGHT + 1, plotMinZ), new Location(world, plotMaxX + 1, maxy + 1, min.getZ() + 1), new PlotBlock((short) 0, (byte) 0));
|
||||||
}
|
MainUtil.setCuboidAsync(world, new Location(world, max.getX(), 1, plotMinZ), new Location(world, plotMaxX + 1, dpw.PLOT_HEIGHT, min.getZ() + 1), filling);
|
||||||
final Plot plot4 = MainUtil.getPlot(new Location(world, i, 0, j + 15));
|
MainUtil.setCuboidAsync(world, new Location(world, max.getX(), dpw.PLOT_HEIGHT, plotMinZ), new Location(world, plotMaxX + 1, dpw.PLOT_HEIGHT + 1, min.getZ() + 1), plotfloor);
|
||||||
if ((plot4 != null) && (!plot4.getId().equals(plot.getId()))) {
|
MainUtil.setSimpleCuboidAsync(world, new Location(world, plotMinX, 0, min.getZ()), new Location(world, min.getX() + 1, 1, max.getZ() + 1), new PlotBlock(bedrock, (byte) 0));
|
||||||
break;
|
MainUtil.setSimpleCuboidAsync(world, new Location(world, plotMinX, dpw.PLOT_HEIGHT + 1, min.getZ()), new Location(world, min.getX() + 1, maxy + 1, max.getZ() + 1), new PlotBlock((short) 0, (byte) 0));
|
||||||
}
|
MainUtil.setCuboidAsync(world, new Location(world, plotMinX, 1, min.getZ()), new Location(world, min.getX() + 1, dpw.PLOT_HEIGHT, max.getZ() + 1), filling);
|
||||||
final Plot plot5 = MainUtil.getPlot(new Location(world, i + 15, 0, j + 15));
|
MainUtil.setCuboidAsync(world, new Location(world, plotMinX, dpw.PLOT_HEIGHT, min.getZ()), new Location(world, min.getX() + 1, dpw.PLOT_HEIGHT + 1, max.getZ() + 1), plotfloor);
|
||||||
if ((plot5 != null) && (!plot5.getId().equals(plot.getId()))) {
|
MainUtil.setSimpleCuboidAsync(world, new Location(world, plotMinX, 0, max.getZ()), new Location(world, min.getX() + 1, 1, plotMaxZ + 1), new PlotBlock(bedrock, (byte) 0));
|
||||||
break;
|
MainUtil.setSimpleCuboidAsync(world, new Location(world, plotMinX, dpw.PLOT_HEIGHT + 1, max.getZ()), new Location(world, min.getX() + 1, maxy + 1, plotMaxZ + 1), new PlotBlock((short) 0, (byte) 0));
|
||||||
}
|
MainUtil.setCuboidAsync(world, new Location(world, plotMinX, 1, max.getZ()), new Location(world, min.getX() + 1, dpw.PLOT_HEIGHT, plotMaxZ + 1), filling);
|
||||||
if (mn == null) {
|
MainUtil.setCuboidAsync(world, new Location(world, plotMinX, dpw.PLOT_HEIGHT, max.getZ()), new Location(world, min.getX() + 1, dpw.PLOT_HEIGHT + 1, plotMaxZ + 1), plotfloor);
|
||||||
mn = new Location(world, Math.max(i - 1, plotMinX), 0, Math.max(j - 1, plotMinZ));
|
MainUtil.setSimpleCuboidAsync(world, new Location(world, min.getX(), 0, max.getZ()), new Location(world, max.getX() + 1, 1, plotMaxZ + 1), new PlotBlock(bedrock, (byte) 0));
|
||||||
mx = new Location(world, Math.min(i + 16, plotMaxX), 0, Math.min(j + 16, plotMaxZ));
|
MainUtil.setSimpleCuboidAsync(world, new Location(world, min.getX(), dpw.PLOT_HEIGHT + 1, max.getZ()), new Location(world, max.getX() + 1, maxy + 1, plotMaxZ + 1), new PlotBlock((short) 0, (byte) 0));
|
||||||
} else if ((mx.getZ() < (j + 15)) || (mx.getX() < (i + 15))) {
|
MainUtil.setCuboidAsync(world, new Location(world, min.getX(), 1, max.getZ()), new Location(world, max.getX() + 1, dpw.PLOT_HEIGHT, plotMaxZ + 1), filling);
|
||||||
mx = new Location(world, Math.min(i + 16, plotMaxX), 0, Math.min(j + 16, plotMaxZ));
|
MainUtil.setCuboidAsync(world, new Location(world, min.getX(), dpw.PLOT_HEIGHT, max.getZ()), new Location(world, max.getX() + 1, dpw.PLOT_HEIGHT + 1, plotMaxZ + 1), plotfloor);
|
||||||
}
|
MainUtil.setSimpleCuboidAsync(world, new Location(world, max.getX(), 0, min.getZ()), new Location(world, plotMaxX + 1, 1, max.getZ() + 1), new PlotBlock(bedrock, (byte) 0));
|
||||||
final int I = i;
|
MainUtil.setSimpleCuboidAsync(world, new Location(world, max.getX(), dpw.PLOT_HEIGHT + 1, min.getZ()), new Location(world, plotMaxX + 1, maxy + 1, max.getZ() + 1), new PlotBlock((short) 0, (byte) 0));
|
||||||
final int J = j;
|
MainUtil.setCuboidAsync(world, new Location(world, max.getX(), 1, min.getZ()), new Location(world, plotMaxX + 1, dpw.PLOT_HEIGHT, max.getZ() + 1), filling);
|
||||||
TaskManager.runTaskLater(new Runnable() {
|
MainUtil.setCuboidAsync(world, new Location(world, max.getX(), dpw.PLOT_HEIGHT, min.getZ()), new Location(world, plotMaxX + 1, dpw.PLOT_HEIGHT + 1, max.getZ() + 1), plotfloor);
|
||||||
@Override
|
MainUtil.setSimpleCuboidAsync(world, new Location(world, max.getX(), 0, max.getZ()), new Location(world, plotMaxX + 1, 1, plotMaxZ + 1), new PlotBlock(bedrock, (byte) 0));
|
||||||
public void run() {
|
MainUtil.setSimpleCuboidAsync(world, new Location(world, max.getX(), dpw.PLOT_HEIGHT + 1, max.getZ()), new Location(world, plotMaxX + 1, maxy + 1, plotMaxZ + 1), new PlotBlock((short) 0, (byte) 0));
|
||||||
BukkitUtil.regenerateChunk(world, I / 16, J / 16);
|
MainUtil.setCuboidAsync(world, new Location(world, max.getX(), 1, max.getZ()), new Location(world, plotMaxX + 1, dpw.PLOT_HEIGHT, plotMaxZ + 1), filling);
|
||||||
}
|
MainUtil.setCuboidAsync(world, new Location(world, max.getX(), dpw.PLOT_HEIGHT, max.getZ()), new Location(world, plotMaxX + 1, dpw.PLOT_HEIGHT + 1, plotMaxZ + 1), plotfloor);
|
||||||
}, PseudoRandom.random(40));
|
SetBlockQueue.addNotify(whenDone);
|
||||||
}
|
|
||||||
}
|
|
||||||
final Location max = mx;
|
|
||||||
final Location min = mn;
|
|
||||||
if (min == null) {
|
|
||||||
MainUtil.setSimpleCuboid(world, new Location(world, pos1.getX(), 0, pos1.getZ()), new Location(world, pos2.getX() + 1, 1, pos2.getZ() + 1), new PlotBlock(bedrock, (byte) 0));
|
|
||||||
TaskManager.runTaskLater(new Runnable() {
|
|
||||||
@Override
|
|
||||||
public void run() {
|
|
||||||
MainUtil.setSimpleCuboid(world, new Location(world, pos1.getX(), dpw.PLOT_HEIGHT + 1, pos1.getZ()), new Location(world, pos2.getX() + 1, maxy + 1, pos2.getZ() + 1), new PlotBlock((short) 0, (byte) 0));
|
|
||||||
TaskManager.runTaskLater(new Runnable() {
|
|
||||||
@Override
|
|
||||||
public void run() {
|
|
||||||
MainUtil.setCuboid(world, new Location(world, pos1.getX(), 1, pos1.getZ()), new Location(world, pos2.getX() + 1, dpw.PLOT_HEIGHT, pos2.getZ() + 1), filling);
|
|
||||||
TaskManager.runTaskLater(new Runnable() {
|
|
||||||
@Override
|
|
||||||
public void run() {
|
|
||||||
MainUtil.setCuboid(world, new Location(world, pos1.getX(), dpw.PLOT_HEIGHT, pos1.getZ()), new Location(world, pos2.getX() + 1, dpw.PLOT_HEIGHT + 1, pos2.getZ() + 1), plotfloor);
|
|
||||||
}
|
|
||||||
}, 5);
|
|
||||||
}
|
|
||||||
}, 5);
|
|
||||||
}
|
|
||||||
}, 5);
|
|
||||||
return;
|
|
||||||
} else {
|
|
||||||
if (min.getX() < plotMinX) {
|
|
||||||
min.setX(plotMinX);
|
|
||||||
}
|
|
||||||
if (min.getZ() < plotMinZ) {
|
|
||||||
min.setZ(plotMinZ);
|
|
||||||
}
|
|
||||||
if (max.getX() > plotMaxX) {
|
|
||||||
max.setX(plotMaxX);
|
|
||||||
}
|
|
||||||
if (max.getZ() > plotMaxZ) {
|
|
||||||
max.setZ(plotMaxZ);
|
|
||||||
}
|
|
||||||
TaskManager.runTaskLater(new Runnable() {
|
|
||||||
@Override
|
|
||||||
public void run() {
|
|
||||||
MainUtil.setSimpleCuboid(world, new Location(world, plotMinX, 0, plotMinZ), new Location(world, min.getX() + 1, 1, min.getZ() + 1), new PlotBlock(bedrock, (byte) 0));
|
|
||||||
TaskManager.runTaskLater(new Runnable() {
|
|
||||||
@Override
|
|
||||||
public void run() {
|
|
||||||
MainUtil.setSimpleCuboid(world, new Location(world, plotMinX, dpw.PLOT_HEIGHT + 1, plotMinZ), new Location(world, min.getX() + 1, maxy + 1, min.getZ() + 1), new PlotBlock((short) 0, (byte) 0));
|
|
||||||
TaskManager.runTaskLater(new Runnable() {
|
|
||||||
@Override
|
|
||||||
public void run() {
|
|
||||||
MainUtil.setCuboid(world, new Location(world, plotMinX, 1, plotMinZ), new Location(world, min.getX() + 1, dpw.PLOT_HEIGHT + 1, min.getZ() + 1), filling);
|
|
||||||
TaskManager.runTaskLater(new Runnable() {
|
|
||||||
@Override
|
|
||||||
public void run() {
|
|
||||||
MainUtil.setCuboid(world, new Location(world, plotMinX, dpw.PLOT_HEIGHT, plotMinZ), new Location(world, min.getX() + 1, dpw.PLOT_HEIGHT + 1, min.getZ() + 1), plotfloor);
|
|
||||||
}
|
|
||||||
}, 1);
|
|
||||||
}
|
|
||||||
}, 1);
|
|
||||||
}
|
|
||||||
}, 1);
|
|
||||||
}
|
|
||||||
}, 21);
|
|
||||||
TaskManager.runTaskLater(new Runnable() {
|
|
||||||
@Override
|
|
||||||
public void run() {
|
|
||||||
MainUtil.setSimpleCuboid(world, new Location(world, min.getX(), 0, plotMinZ), new Location(world, max.getX() + 1, 1, min.getZ() + 1), new PlotBlock(bedrock, (byte) 0));
|
|
||||||
TaskManager.runTaskLater(new Runnable() {
|
|
||||||
@Override
|
|
||||||
public void run() {
|
|
||||||
MainUtil.setSimpleCuboid(world, new Location(world, min.getX(), dpw.PLOT_HEIGHT + 1, plotMinZ), new Location(world, max.getX() + 1, maxy + 1, min.getZ() + 1), new PlotBlock((short) 0, (byte) 0));
|
|
||||||
TaskManager.runTaskLater(new Runnable() {
|
|
||||||
@Override
|
|
||||||
public void run() {
|
|
||||||
MainUtil.setCuboid(world, new Location(world, min.getX(), 1, plotMinZ), new Location(world, max.getX() + 1, dpw.PLOT_HEIGHT, min.getZ() + 1), filling);
|
|
||||||
TaskManager.runTaskLater(new Runnable() {
|
|
||||||
@Override
|
|
||||||
public void run() {
|
|
||||||
MainUtil.setCuboid(world, new Location(world, min.getX(), dpw.PLOT_HEIGHT, plotMinZ), new Location(world, max.getX() + 1, dpw.PLOT_HEIGHT + 1, min.getZ() + 1), plotfloor);
|
|
||||||
}
|
|
||||||
}, 1);
|
|
||||||
}
|
|
||||||
}, 1);
|
|
||||||
}
|
|
||||||
}, 1);
|
|
||||||
}
|
|
||||||
}, 25);
|
|
||||||
TaskManager.runTaskLater(new Runnable() {
|
|
||||||
@Override
|
|
||||||
public void run() {
|
|
||||||
MainUtil.setSimpleCuboid(world, new Location(world, max.getX(), 0, plotMinZ), new Location(world, plotMaxX + 1, 1, min.getZ() + 1), new PlotBlock(bedrock, (byte) 0));
|
|
||||||
TaskManager.runTaskLater(new Runnable() {
|
|
||||||
@Override
|
|
||||||
public void run() {
|
|
||||||
MainUtil.setSimpleCuboid(world, new Location(world, max.getX(), dpw.PLOT_HEIGHT + 1, plotMinZ), new Location(world, plotMaxX + 1, maxy + 1, min.getZ() + 1), new PlotBlock((short) 0, (byte) 0));
|
|
||||||
TaskManager.runTaskLater(new Runnable() {
|
|
||||||
@Override
|
|
||||||
public void run() {
|
|
||||||
MainUtil.setCuboid(world, new Location(world, max.getX(), 1, plotMinZ), new Location(world, plotMaxX + 1, dpw.PLOT_HEIGHT, min.getZ() + 1), filling);
|
|
||||||
TaskManager.runTaskLater(new Runnable() {
|
|
||||||
@Override
|
|
||||||
public void run() {
|
|
||||||
MainUtil.setCuboid(world, new Location(world, max.getX(), dpw.PLOT_HEIGHT, plotMinZ), new Location(world, plotMaxX + 1, dpw.PLOT_HEIGHT + 1, min.getZ() + 1), plotfloor);
|
|
||||||
}
|
|
||||||
}, 1);
|
|
||||||
}
|
|
||||||
}, 1);
|
|
||||||
}
|
|
||||||
}, 1);
|
|
||||||
}
|
|
||||||
}, 29);
|
|
||||||
TaskManager.runTaskLater(new Runnable() {
|
|
||||||
@Override
|
|
||||||
public void run() {
|
|
||||||
MainUtil.setSimpleCuboid(world, new Location(world, plotMinX, 0, min.getZ()), new Location(world, min.getX() + 1, 1, max.getZ() + 1), new PlotBlock(bedrock, (byte) 0));
|
|
||||||
TaskManager.runTaskLater(new Runnable() {
|
|
||||||
@Override
|
|
||||||
public void run() {
|
|
||||||
MainUtil.setSimpleCuboid(world, new Location(world, plotMinX, dpw.PLOT_HEIGHT + 1, min.getZ()), new Location(world, min.getX() + 1, maxy + 1, max.getZ() + 1), new PlotBlock((short) 0, (byte) 0));
|
|
||||||
TaskManager.runTaskLater(new Runnable() {
|
|
||||||
@Override
|
|
||||||
public void run() {
|
|
||||||
MainUtil.setCuboid(world, new Location(world, plotMinX, 1, min.getZ()), new Location(world, min.getX() + 1, dpw.PLOT_HEIGHT, max.getZ() + 1), filling);
|
|
||||||
TaskManager.runTaskLater(new Runnable() {
|
|
||||||
@Override
|
|
||||||
public void run() {
|
|
||||||
MainUtil.setCuboid(world, new Location(world, plotMinX, dpw.PLOT_HEIGHT, min.getZ()), new Location(world, min.getX() + 1, dpw.PLOT_HEIGHT + 1, max.getZ() + 1), plotfloor);
|
|
||||||
}
|
|
||||||
}, 1);
|
|
||||||
}
|
|
||||||
}, 1);
|
|
||||||
}
|
|
||||||
}, 1);
|
|
||||||
}
|
|
||||||
}, 33);
|
|
||||||
TaskManager.runTaskLater(new Runnable() {
|
|
||||||
@Override
|
|
||||||
public void run() {
|
|
||||||
MainUtil.setSimpleCuboid(world, new Location(world, plotMinX, 0, max.getZ()), new Location(world, min.getX() + 1, 1, plotMaxZ + 1), new PlotBlock(bedrock, (byte) 0));
|
|
||||||
TaskManager.runTaskLater(new Runnable() {
|
|
||||||
@Override
|
|
||||||
public void run() {
|
|
||||||
MainUtil.setSimpleCuboid(world, new Location(world, plotMinX, dpw.PLOT_HEIGHT + 1, max.getZ()), new Location(world, min.getX() + 1, maxy + 1, plotMaxZ + 1), new PlotBlock((short) 0, (byte) 0));
|
|
||||||
TaskManager.runTaskLater(new Runnable() {
|
|
||||||
@Override
|
|
||||||
public void run() {
|
|
||||||
MainUtil.setCuboid(world, new Location(world, plotMinX, 1, max.getZ()), new Location(world, min.getX() + 1, dpw.PLOT_HEIGHT, plotMaxZ + 1), filling);
|
|
||||||
TaskManager.runTaskLater(new Runnable() {
|
|
||||||
@Override
|
|
||||||
public void run() {
|
|
||||||
MainUtil.setCuboid(world, new Location(world, plotMinX, dpw.PLOT_HEIGHT, max.getZ()), new Location(world, min.getX() + 1, dpw.PLOT_HEIGHT + 1, plotMaxZ + 1), plotfloor);
|
|
||||||
}
|
|
||||||
}, 1);
|
|
||||||
}
|
|
||||||
}, 1);
|
|
||||||
}
|
|
||||||
}, 1);
|
|
||||||
}
|
|
||||||
}, 37);
|
|
||||||
TaskManager.runTaskLater(new Runnable() {
|
|
||||||
@Override
|
|
||||||
public void run() {
|
|
||||||
MainUtil.setSimpleCuboid(world, new Location(world, min.getX(), 0, max.getZ()), new Location(world, max.getX() + 1, 1, plotMaxZ + 1), new PlotBlock(bedrock, (byte) 0));
|
|
||||||
TaskManager.runTaskLater(new Runnable() {
|
|
||||||
@Override
|
|
||||||
public void run() {
|
|
||||||
MainUtil.setSimpleCuboid(world, new Location(world, min.getX(), dpw.PLOT_HEIGHT + 1, max.getZ()), new Location(world, max.getX() + 1, maxy + 1, plotMaxZ + 1), new PlotBlock((short) 0, (byte) 0));
|
|
||||||
TaskManager.runTaskLater(new Runnable() {
|
|
||||||
@Override
|
|
||||||
public void run() {
|
|
||||||
MainUtil.setCuboid(world, new Location(world, min.getX(), 1, max.getZ()), new Location(world, max.getX() + 1, dpw.PLOT_HEIGHT, plotMaxZ + 1), filling);
|
|
||||||
TaskManager.runTaskLater(new Runnable() {
|
|
||||||
@Override
|
|
||||||
public void run() {
|
|
||||||
MainUtil.setCuboid(world, new Location(world, min.getX(), dpw.PLOT_HEIGHT, max.getZ()), new Location(world, max.getX() + 1, dpw.PLOT_HEIGHT + 1, plotMaxZ + 1), plotfloor);
|
|
||||||
}
|
|
||||||
}, 1);
|
|
||||||
}
|
|
||||||
}, 1);
|
|
||||||
}
|
|
||||||
}, 1);
|
|
||||||
}
|
|
||||||
}, 41);
|
|
||||||
TaskManager.runTaskLater(new Runnable() {
|
|
||||||
@Override
|
|
||||||
public void run() {
|
|
||||||
MainUtil.setSimpleCuboid(world, new Location(world, max.getX(), 0, min.getZ()), new Location(world, plotMaxX + 1, 1, max.getZ() + 1), new PlotBlock(bedrock, (byte) 0));
|
|
||||||
TaskManager.runTaskLater(new Runnable() {
|
|
||||||
@Override
|
|
||||||
public void run() {
|
|
||||||
MainUtil.setSimpleCuboid(world, new Location(world, max.getX(), dpw.PLOT_HEIGHT + 1, min.getZ()), new Location(world, plotMaxX + 1, maxy + 1, max.getZ() + 1), new PlotBlock((short) 0, (byte) 0));
|
|
||||||
TaskManager.runTaskLater(new Runnable() {
|
|
||||||
@Override
|
|
||||||
public void run() {
|
|
||||||
MainUtil.setCuboid(world, new Location(world, max.getX(), 1, min.getZ()), new Location(world, plotMaxX + 1, dpw.PLOT_HEIGHT, max.getZ() + 1), filling);
|
|
||||||
TaskManager.runTaskLater(new Runnable() {
|
|
||||||
@Override
|
|
||||||
public void run() {
|
|
||||||
MainUtil.setCuboid(world, new Location(world, max.getX(), dpw.PLOT_HEIGHT, min.getZ()), new Location(world, plotMaxX + 1, dpw.PLOT_HEIGHT + 1, max.getZ() + 1), plotfloor);
|
|
||||||
}
|
|
||||||
}, 1);
|
|
||||||
}
|
|
||||||
}, 1);
|
|
||||||
}
|
|
||||||
}, 1);
|
|
||||||
}
|
|
||||||
}, 45);
|
|
||||||
TaskManager.runTaskLater(new Runnable() {
|
|
||||||
@Override
|
|
||||||
public void run() {
|
|
||||||
MainUtil.setSimpleCuboid(world, new Location(world, max.getX(), 0, max.getZ()), new Location(world, plotMaxX + 1, 1, plotMaxZ + 1), new PlotBlock(bedrock, (byte) 0));
|
|
||||||
TaskManager.runTaskLater(new Runnable() {
|
|
||||||
@Override
|
|
||||||
public void run() {
|
|
||||||
MainUtil.setSimpleCuboid(world, new Location(world, max.getX(), dpw.PLOT_HEIGHT + 1, max.getZ()), new Location(world, plotMaxX + 1, maxy + 1, plotMaxZ + 1), new PlotBlock((short) 0, (byte) 0));
|
|
||||||
TaskManager.runTaskLater(new Runnable() {
|
|
||||||
@Override
|
|
||||||
public void run() {
|
|
||||||
MainUtil.setCuboid(world, new Location(world, max.getX(), 1, max.getZ()), new Location(world, plotMaxX + 1, dpw.PLOT_HEIGHT, plotMaxZ + 1), filling);
|
|
||||||
TaskManager.runTaskLater(new Runnable() {
|
|
||||||
@Override
|
|
||||||
public void run() {
|
|
||||||
MainUtil.setCuboid(world, new Location(world, max.getX(), dpw.PLOT_HEIGHT, max.getZ()), new Location(world, plotMaxX + 1, dpw.PLOT_HEIGHT + 1, plotMaxZ + 1), plotfloor);
|
|
||||||
TaskManager.runTask(whenDone);
|
|
||||||
}
|
|
||||||
}, 1);
|
|
||||||
}
|
|
||||||
}, 1);
|
|
||||||
}
|
|
||||||
}, 1);
|
|
||||||
}
|
|
||||||
}, 49);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}, 20);
|
|
||||||
}
|
}
|
||||||
}, 20);
|
});
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -24,6 +24,7 @@ import java.util.HashMap;
|
|||||||
import java.util.HashSet;
|
import java.util.HashSet;
|
||||||
|
|
||||||
import org.apache.commons.lang.StringUtils;
|
import org.apache.commons.lang.StringUtils;
|
||||||
|
import org.bukkit.Material;
|
||||||
import org.bukkit.configuration.ConfigurationSection;
|
import org.bukkit.configuration.ConfigurationSection;
|
||||||
|
|
||||||
import com.intellectualcrafters.plot.PlotSquared;
|
import com.intellectualcrafters.plot.PlotSquared;
|
||||||
@ -88,7 +89,6 @@ public class HybridPlotWorld extends ClassicPlotWorld {
|
|||||||
setupSchematics();
|
setupSchematics();
|
||||||
} catch (final Exception e) {
|
} catch (final Exception e) {
|
||||||
PlotSquared.log("&c - road schematics are disabled for this world.");
|
PlotSquared.log("&c - road schematics are disabled for this world.");
|
||||||
this.ROAD_SCHEMATIC_ENABLED = false;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -143,7 +143,7 @@ public class HybridPlotWorld extends ClassicPlotWorld {
|
|||||||
int x = item.x;
|
int x = item.x;
|
||||||
int y = item.y;
|
int y = item.y;
|
||||||
int z = item.z;
|
int z = item.z;
|
||||||
PlotLoc loc = new PlotLoc((short) x, (short) z);
|
PlotLoc loc = new PlotLoc(x, z);
|
||||||
if (!G_SCH_STATE.containsKey(loc)) {
|
if (!G_SCH_STATE.containsKey(loc)) {
|
||||||
G_SCH_STATE.put(loc, new HashSet<PlotItem>());
|
G_SCH_STATE.put(loc, new HashSet<PlotItem>());
|
||||||
}
|
}
|
||||||
@ -196,120 +196,109 @@ public class HybridPlotWorld extends ClassicPlotWorld {
|
|||||||
this.ROAD_SCHEMATIC_ENABLED = true;
|
this.ROAD_SCHEMATIC_ENABLED = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
public static boolean isRotate(final short id) {
|
public static byte wrap(byte data, int start) {
|
||||||
|
if (data >= start && data < start + 4) {
|
||||||
|
data = (byte) ((((data - start) + 2) % 4) + start);
|
||||||
|
}
|
||||||
|
return data;
|
||||||
|
}
|
||||||
|
|
||||||
|
public static byte wrap2(byte data, int start) {
|
||||||
|
if (data >= start && data < start + 2) {
|
||||||
|
data = (byte) ((((data - start) + 1) % 2) + start);
|
||||||
|
}
|
||||||
|
return data;
|
||||||
|
}
|
||||||
|
|
||||||
|
public static byte rotate(final short id, byte data) {
|
||||||
switch (id) {
|
switch (id) {
|
||||||
case 23:
|
|
||||||
return true;
|
|
||||||
case 26:
|
|
||||||
return true;
|
|
||||||
case 27:
|
|
||||||
return true;
|
|
||||||
case 28:
|
|
||||||
return true;
|
|
||||||
case 29:
|
|
||||||
return true;
|
|
||||||
case 33:
|
|
||||||
return true;
|
|
||||||
case 53:
|
|
||||||
return true;
|
|
||||||
case 54:
|
|
||||||
return true;
|
|
||||||
case 55:
|
|
||||||
return true;
|
|
||||||
case 61:
|
|
||||||
return true;
|
|
||||||
case 62:
|
|
||||||
return true;
|
|
||||||
case 64:
|
|
||||||
return true;
|
|
||||||
case 65:
|
|
||||||
return true;
|
|
||||||
case 68:
|
|
||||||
return true;
|
|
||||||
case 71:
|
|
||||||
return true;
|
|
||||||
case 77:
|
|
||||||
return true;
|
|
||||||
case 86:
|
|
||||||
return true;
|
|
||||||
case 84:
|
|
||||||
return true;
|
|
||||||
case 93:
|
|
||||||
return true;
|
|
||||||
case 94:
|
|
||||||
return true;
|
|
||||||
case 96:
|
|
||||||
return true;
|
|
||||||
case 107:
|
|
||||||
return true;
|
|
||||||
case 108:
|
|
||||||
return true;
|
|
||||||
case 109:
|
|
||||||
return true;
|
|
||||||
case 111:
|
|
||||||
return true;
|
|
||||||
case 119:
|
|
||||||
return true;
|
|
||||||
case 128:
|
|
||||||
return true;
|
|
||||||
case 130:
|
|
||||||
return true;
|
|
||||||
case 131:
|
|
||||||
return true;
|
|
||||||
case 134:
|
|
||||||
return true;
|
|
||||||
case 135:
|
|
||||||
return true;
|
|
||||||
case 136:
|
|
||||||
return true;
|
|
||||||
case 143:
|
|
||||||
return true;
|
|
||||||
case 144:
|
|
||||||
return true;
|
|
||||||
case 145:
|
|
||||||
return true;
|
|
||||||
case 146:
|
|
||||||
return true;
|
|
||||||
case 149:
|
|
||||||
return true;
|
|
||||||
case 150:
|
|
||||||
return true;
|
|
||||||
case 156:
|
|
||||||
return true;
|
|
||||||
case 157:
|
|
||||||
return true;
|
|
||||||
case 158:
|
|
||||||
return true;
|
|
||||||
case 163:
|
|
||||||
return true;
|
|
||||||
case 164:
|
|
||||||
return true;
|
|
||||||
case 167:
|
|
||||||
return true;
|
|
||||||
case 180:
|
|
||||||
return true;
|
|
||||||
case 183:
|
case 183:
|
||||||
return true;
|
|
||||||
case 184:
|
case 184:
|
||||||
return true;
|
|
||||||
case 185:
|
case 185:
|
||||||
return true;
|
|
||||||
case 186:
|
case 186:
|
||||||
return true;
|
|
||||||
case 187:
|
case 187:
|
||||||
return true;
|
case 107:
|
||||||
|
case 53:
|
||||||
|
case 67:
|
||||||
|
case 108:
|
||||||
|
case 109:
|
||||||
|
case 114:
|
||||||
|
case 128:
|
||||||
|
case 134:
|
||||||
|
case 135:
|
||||||
|
case 136:
|
||||||
|
case 156:
|
||||||
|
case 163:
|
||||||
|
case 164:
|
||||||
|
case 180: {
|
||||||
|
data = wrap(data, 0);
|
||||||
|
data = wrap(data, 4);
|
||||||
|
return data;
|
||||||
|
}
|
||||||
|
|
||||||
|
case 26:
|
||||||
|
case 86: {
|
||||||
|
data = wrap(data, 0);
|
||||||
|
return data;
|
||||||
|
}
|
||||||
|
case 64:
|
||||||
|
case 71:
|
||||||
case 193:
|
case 193:
|
||||||
return true;
|
|
||||||
case 194:
|
case 194:
|
||||||
return true;
|
|
||||||
case 195:
|
case 195:
|
||||||
return true;
|
|
||||||
case 196:
|
case 196:
|
||||||
return true;
|
|
||||||
case 197:
|
case 197:
|
||||||
return true;
|
case 93:
|
||||||
|
case 94:
|
||||||
|
case 131:
|
||||||
|
case 145:
|
||||||
|
case 149:
|
||||||
|
case 150:
|
||||||
|
case 96:
|
||||||
|
case 167: {
|
||||||
|
data = wrap(data, 0);
|
||||||
|
data = wrap(data, 4);
|
||||||
|
data = wrap(data, 8);
|
||||||
|
data = wrap(data, 12);
|
||||||
|
return data;
|
||||||
|
}
|
||||||
|
case 28:
|
||||||
|
case 66:
|
||||||
|
case 157:
|
||||||
|
case 27: {
|
||||||
|
data = wrap2(data, 0);
|
||||||
|
data = wrap2(data, 3);
|
||||||
|
if (data == 2) {
|
||||||
|
data = 5;
|
||||||
|
}
|
||||||
|
else if (data == 5) {
|
||||||
|
data = 2;
|
||||||
|
}
|
||||||
|
return data;
|
||||||
|
}
|
||||||
|
|
||||||
|
case 23:
|
||||||
|
case 29:
|
||||||
|
case 33:
|
||||||
|
case 158:
|
||||||
|
case 54:
|
||||||
|
case 130:
|
||||||
|
case 146:
|
||||||
|
case 61:
|
||||||
|
case 62:
|
||||||
|
case 65:
|
||||||
|
case 68:
|
||||||
|
case 144: {
|
||||||
|
data = wrap(data, 2);
|
||||||
|
return data;
|
||||||
|
}
|
||||||
|
case 143:
|
||||||
|
case 77: {
|
||||||
|
data = wrap(data, 1);
|
||||||
|
return data;
|
||||||
|
}
|
||||||
default:
|
default:
|
||||||
return false;
|
return data;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -325,12 +314,12 @@ public class HybridPlotWorld extends ClassicPlotWorld {
|
|||||||
this.G_SCH.put(loc, new HashMap<Short, Short>());
|
this.G_SCH.put(loc, new HashMap<Short, Short>());
|
||||||
}
|
}
|
||||||
this.G_SCH.get(loc).put(y, id);
|
this.G_SCH.get(loc).put(y, id);
|
||||||
if (isRotate(id)) {
|
if (rotate) {
|
||||||
if (rotate) {
|
byte newdata = rotate(id, data);
|
||||||
data = (byte) ((data + 2) % 4);
|
if (data == 0 && newdata == 0) {
|
||||||
|
return;
|
||||||
}
|
}
|
||||||
} else if (data == 0) {
|
data = newdata;
|
||||||
return;
|
|
||||||
}
|
}
|
||||||
if (!this.G_SCH_DATA.containsKey(loc)) {
|
if (!this.G_SCH_DATA.containsKey(loc)) {
|
||||||
this.G_SCH_DATA.put(loc, new HashMap<Short, Byte>());
|
this.G_SCH_DATA.put(loc, new HashMap<Short, Byte>());
|
||||||
|
@ -2,25 +2,23 @@ package com.intellectualcrafters.plot.generator;
|
|||||||
|
|
||||||
import java.util.HashMap;
|
import java.util.HashMap;
|
||||||
import java.util.HashSet;
|
import java.util.HashSet;
|
||||||
import java.util.Random;
|
|
||||||
|
|
||||||
import org.bukkit.Chunk;
|
|
||||||
import org.bukkit.World;
|
import org.bukkit.World;
|
||||||
import org.bukkit.block.Biome;
|
import org.bukkit.block.Biome;
|
||||||
import org.bukkit.generator.BlockPopulator;
|
|
||||||
|
|
||||||
import com.intellectualcrafters.plot.PlotSquared;
|
import com.intellectualcrafters.plot.PlotSquared;
|
||||||
import com.intellectualcrafters.plot.object.PlotLoc;
|
import com.intellectualcrafters.plot.object.PlotLoc;
|
||||||
|
import com.intellectualcrafters.plot.object.PlotPopulator;
|
||||||
import com.intellectualcrafters.plot.object.PlotWorld;
|
import com.intellectualcrafters.plot.object.PlotWorld;
|
||||||
|
import com.intellectualcrafters.plot.object.PseudoRandom;
|
||||||
import com.intellectualcrafters.plot.object.RegionWrapper;
|
import com.intellectualcrafters.plot.object.RegionWrapper;
|
||||||
import com.intellectualcrafters.plot.object.schematic.PlotItem;
|
import com.intellectualcrafters.plot.object.schematic.PlotItem;
|
||||||
import com.intellectualcrafters.plot.util.BlockManager;
|
import com.intellectualcrafters.plot.util.BlockManager;
|
||||||
import com.intellectualcrafters.plot.util.ChunkManager;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @author Citymonstret
|
* @author Citymonstret
|
||||||
*/
|
*/
|
||||||
public class HybridPop extends BlockPopulator {
|
public class HybridPop extends PlotPopulator {
|
||||||
/*
|
/*
|
||||||
* Sorry, this isn't well documented at the moment.
|
* Sorry, this isn't well documented at the moment.
|
||||||
* We advise you to take a look at a world generation tutorial for
|
* We advise you to take a look at a world generation tutorial for
|
||||||
@ -41,8 +39,6 @@ public class HybridPop extends BlockPopulator {
|
|||||||
final short pathWidthLower;
|
final short pathWidthLower;
|
||||||
final short pathWidthUpper;
|
final short pathWidthUpper;
|
||||||
Biome biome;
|
Biome biome;
|
||||||
private int X;
|
|
||||||
private int Z;
|
|
||||||
private long state;
|
private long state;
|
||||||
private boolean doFilling = false;
|
private boolean doFilling = false;
|
||||||
private boolean doFloor = false;
|
private boolean doFloor = false;
|
||||||
@ -81,12 +77,18 @@ public class HybridPop extends BlockPopulator {
|
|||||||
this.wallheight = this.plotworld.WALL_HEIGHT;
|
this.wallheight = this.plotworld.WALL_HEIGHT;
|
||||||
this.roadheight = this.plotworld.ROAD_HEIGHT;
|
this.roadheight = this.plotworld.ROAD_HEIGHT;
|
||||||
this.plotheight = this.plotworld.PLOT_HEIGHT;
|
this.plotheight = this.plotworld.PLOT_HEIGHT;
|
||||||
if ((this.pathsize % 2) == 0) {
|
if (this.pathsize == 0) {
|
||||||
this.pathWidthLower = (short) (Math.floor(this.pathsize / 2) - 1);
|
this.pathWidthLower = (short) -1;
|
||||||
} else {
|
this.pathWidthUpper = (short) (this.plotsize + 1);
|
||||||
this.pathWidthLower = (short) (Math.floor(this.pathsize / 2));
|
}
|
||||||
|
else {
|
||||||
|
if ((this.pathsize % 2) == 0) {
|
||||||
|
this.pathWidthLower = (short) (Math.floor(this.pathsize / 2) - 1);
|
||||||
|
} else {
|
||||||
|
this.pathWidthLower = (short) (Math.floor(this.pathsize / 2));
|
||||||
|
}
|
||||||
|
this.pathWidthUpper = (short) (this.pathWidthLower + this.plotsize + 1);
|
||||||
}
|
}
|
||||||
this.pathWidthUpper = (short) (this.pathWidthLower + this.plotsize + 1);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public final long nextLong() {
|
public final long nextLong() {
|
||||||
@ -108,20 +110,9 @@ public class HybridPop extends BlockPopulator {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void populate(final World w, final Random r, final Chunk c) {
|
public void populate(World world, RegionWrapper requiredRegion, PseudoRandom random, int cx, int cz) {
|
||||||
final int cx = c.getX(), cz = c.getZ();
|
PlotSquared.getPlotManager(world.getName());
|
||||||
if (this.doState) {
|
if (requiredRegion != null) {
|
||||||
final int prime = 13;
|
|
||||||
int h = 1;
|
|
||||||
h = (prime * h) + cx;
|
|
||||||
h = (prime * h) + cz;
|
|
||||||
this.state = h;
|
|
||||||
}
|
|
||||||
this.X = cx << 4;
|
|
||||||
this.Z = cz << 4;
|
|
||||||
PlotSquared.getPlotManager(w.getName());
|
|
||||||
final RegionWrapper plot = ChunkManager.CURRENT_PLOT_CLEAR;
|
|
||||||
if (plot != null) {
|
|
||||||
short sx = (short) ((this.X) % this.size);
|
short sx = (short) ((this.X) % this.size);
|
||||||
short sz = (short) ((this.Z) % this.size);
|
short sz = (short) ((this.Z) % this.size);
|
||||||
if (sx < 0) {
|
if (sx < 0) {
|
||||||
@ -130,23 +121,24 @@ public class HybridPop extends BlockPopulator {
|
|||||||
if (sz < 0) {
|
if (sz < 0) {
|
||||||
sz += this.size;
|
sz += this.size;
|
||||||
}
|
}
|
||||||
|
|
||||||
for (short x = 0; x < 16; x++) {
|
for (short x = 0; x < 16; x++) {
|
||||||
for (short z = 0; z < 16; z++) {
|
for (short z = 0; z < 16; z++) {
|
||||||
if (isIn(plot, this.X + x, this.Z + z)) {
|
if (contains(requiredRegion, x, z)) {
|
||||||
if (this.doFilling) {
|
if (this.doFilling) {
|
||||||
for (short y = 1; y < this.plotheight; y++) {
|
for (short y = 1; y < this.plotheight; y++) {
|
||||||
setBlock(w, x, y, z, this.filling);
|
setBlock(x, y, z, this.filling);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (this.doFloor) {
|
if (this.doFloor) {
|
||||||
setBlock(w, x, (short) this.plotheight, z, this.plotfloors);
|
setBlock(x, (short) this.plotheight, z, this.plotfloors);
|
||||||
}
|
}
|
||||||
if (this.plotworld.PLOT_SCHEMATIC) {
|
if (this.plotworld.PLOT_SCHEMATIC) {
|
||||||
final PlotLoc loc = new PlotLoc((short) (this.X + x), (short) (this.Z + z));
|
final PlotLoc loc = new PlotLoc((short) (this.X + x), (short) (this.Z + z));
|
||||||
final HashMap<Short, Byte> blocks = this.plotworld.G_SCH_DATA.get(loc);
|
final HashMap<Short, Byte> blocks = this.plotworld.G_SCH_DATA.get(loc);
|
||||||
if (blocks != null) {
|
if (blocks != null) {
|
||||||
for (final short y : blocks.keySet()) {
|
for (final short y : blocks.keySet()) {
|
||||||
setBlock(w, x, (short) (this.plotheight + y), z, blocks.get(y));
|
setBlockAbs(x, (short) (this.plotheight + y), z, blocks.get(y));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (this.plotworld.G_SCH_STATE != null) {
|
if (this.plotworld.G_SCH_STATE != null) {
|
||||||
@ -158,52 +150,40 @@ public class HybridPop extends BlockPopulator {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} else {
|
|
||||||
final PlotLoc loc = new PlotLoc((short) (this.X + x), (short) (this.Z + z));
|
|
||||||
final HashMap<Short, Byte> data = ChunkManager.GENERATE_DATA.get(loc);
|
|
||||||
if (data != null) {
|
|
||||||
for (final short y : data.keySet()) {
|
|
||||||
setBlock(w, x, y, z, data.get(y).byteValue());
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
short sx = (short) ((this.X) % this.size);
|
int sx = (short) ((this.X) % this.size);
|
||||||
short sz = (short) ((this.Z) % this.size);
|
int sz = (short) ((this.Z) % this.size);
|
||||||
if (sx < 0) {
|
if (sx < 0) {
|
||||||
sx += this.size;
|
sx += this.size;
|
||||||
}
|
}
|
||||||
if (sz < 0) {
|
if (sz < 0) {
|
||||||
sz += this.size;
|
sz += this.size;
|
||||||
}
|
}
|
||||||
// Setting biomes
|
|
||||||
for (short x = 0; x < 16; x++) {
|
for (short x = 0; x < 16; x++) {
|
||||||
for (short z = 0; z < 16; z++) {
|
for (short z = 0; z < 16; z++) {
|
||||||
final short absX = (short) ((sx + x) % this.size);
|
final int absX = ((sx + x) % this.size);
|
||||||
final short absZ = (short) ((sz + z) % this.size);
|
final int absZ = ((sz + z) % this.size);
|
||||||
final boolean gx = absX > this.pathWidthLower;
|
final boolean gx = absX > this.pathWidthLower;
|
||||||
final boolean gz = absZ > this.pathWidthLower;
|
final boolean gz = absZ > this.pathWidthLower;
|
||||||
final boolean lx = absX < this.pathWidthUpper;
|
final boolean lx = absX < this.pathWidthUpper;
|
||||||
final boolean lz = absZ < this.pathWidthUpper;
|
final boolean lz = absZ < this.pathWidthUpper;
|
||||||
// inside plot
|
// inside plot
|
||||||
if (gx && gz && lx && lz) {
|
if (gx && gz && lx && lz) {
|
||||||
if (this.doFilling) {
|
for (short y = 1; y < this.plotheight; y++) {
|
||||||
for (short y = 1; y < this.plotheight; y++) {
|
setBlock(x, y, z, this.filling);
|
||||||
setBlock(w, x, y, z, this.filling);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
if (this.doFloor) {
|
|
||||||
setBlock(w, x, (short) this.plotheight, z, this.plotfloors);
|
|
||||||
}
|
}
|
||||||
|
setBlock(x, (short) this.plotheight, z, this.plotfloors);
|
||||||
if (this.plotworld.PLOT_SCHEMATIC) {
|
if (this.plotworld.PLOT_SCHEMATIC) {
|
||||||
final PlotLoc loc = new PlotLoc(absX, absZ);
|
final PlotLoc loc = new PlotLoc(absX, absZ);
|
||||||
final HashMap<Short, Byte> blocks = this.plotworld.G_SCH_DATA.get(loc);
|
final HashMap<Short, Byte> blocks = this.plotworld.G_SCH_DATA.get(loc);
|
||||||
if (blocks != null) {
|
if (blocks != null) {
|
||||||
for (final short y : blocks.keySet()) {
|
for (final short y : blocks.keySet()) {
|
||||||
setBlock(w, x, (short) (this.plotheight + y), z, blocks.get(y));
|
setBlockAbs(x, (short) (this.plotheight + y), z, blocks.get(y));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (this.plotworld.G_SCH_STATE != null) {
|
if (this.plotworld.G_SCH_STATE != null) {
|
||||||
@ -217,24 +197,20 @@ public class HybridPop extends BlockPopulator {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} else {
|
} else if (pathsize != 0) {
|
||||||
// wall
|
// wall
|
||||||
if (((absX >= this.pathWidthLower) && (absX <= this.pathWidthUpper) && (absZ >= this.pathWidthLower) && (absZ <= this.pathWidthUpper))) {
|
if (((absX >= this.pathWidthLower) && (absX <= this.pathWidthUpper) && (absZ >= this.pathWidthLower) && (absZ <= this.pathWidthUpper))) {
|
||||||
if (this.wallfilling != 0) {
|
for (short y = 1; y <= this.wallheight; y++) {
|
||||||
for (short y = 1; y <= this.wallheight; y++) {
|
setBlock(x, y, z, this.wallfilling);
|
||||||
setBlock(w, x, y, z, this.wallfilling);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
if ((this.wall != 0) && !this.plotworld.ROAD_SCHEMATIC_ENABLED) {
|
if (!this.plotworld.ROAD_SCHEMATIC_ENABLED) {
|
||||||
setBlock(w, x, (short) (this.wallheight + 1), z, this.wall);
|
setBlock(x, this.wallheight + 1, z, this.wall);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
// road
|
// road
|
||||||
else {
|
else {
|
||||||
if (this.roadblock != 0) {
|
for (short y = 1; y <= this.roadheight; y++) {
|
||||||
for (short y = 1; y <= this.roadheight; y++) {
|
setBlock(x, y, z, this.roadblock);
|
||||||
setBlock(w, x, y, z, this.roadblock);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (this.plotworld.ROAD_SCHEMATIC_ENABLED) {
|
if (this.plotworld.ROAD_SCHEMATIC_ENABLED) {
|
||||||
@ -242,7 +218,7 @@ public class HybridPop extends BlockPopulator {
|
|||||||
final HashMap<Short, Byte> blocks = this.plotworld.G_SCH_DATA.get(loc);
|
final HashMap<Short, Byte> blocks = this.plotworld.G_SCH_DATA.get(loc);
|
||||||
if (blocks != null) {
|
if (blocks != null) {
|
||||||
for (final short y : blocks.keySet()) {
|
for (final short y : blocks.keySet()) {
|
||||||
setBlock(w, x, (short) (this.roadheight + y), z, blocks.get(y));
|
setBlockAbs(x, (short) (this.roadheight + y), z, blocks.get(y));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -251,21 +227,12 @@ public class HybridPop extends BlockPopulator {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private void setBlock(final World w, final short x, final short y, final short z, final byte[] blkids) {
|
private void setBlock(final short x, final short y, final short z, final byte[] blkids) {
|
||||||
if (blkids.length == 1) {
|
if (blkids.length == 1) {
|
||||||
setBlock(w, x, y, z, blkids[0]);
|
setBlock(x, y, z, blkids[0]);
|
||||||
} else {
|
} else {
|
||||||
final int i = random(blkids.length);
|
final int i = random(blkids.length);
|
||||||
setBlock(w, x, y, z, blkids[i]);
|
setBlock(x, y, z, blkids[i]);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@SuppressWarnings("deprecation")
|
|
||||||
private void setBlock(final World w, final short x, final short y, final short z, final byte val) {
|
|
||||||
w.getBlockAt(this.X + x, y, this.Z + z).setData(val, false);
|
|
||||||
}
|
|
||||||
|
|
||||||
public boolean isIn(final RegionWrapper plot, final int x, final int z) {
|
|
||||||
return ((x >= plot.minX) && (x <= plot.maxX) && (z >= plot.minZ) && (z <= plot.maxZ));
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
@ -12,45 +12,19 @@ import com.intellectualcrafters.plot.object.PlotBlock;
|
|||||||
import com.intellectualcrafters.plot.object.PlotId;
|
import com.intellectualcrafters.plot.object.PlotId;
|
||||||
import com.intellectualcrafters.plot.object.PlotLoc;
|
import com.intellectualcrafters.plot.object.PlotLoc;
|
||||||
import com.intellectualcrafters.plot.object.PlotManager;
|
import com.intellectualcrafters.plot.object.PlotManager;
|
||||||
|
import com.intellectualcrafters.plot.object.RunnableVal;
|
||||||
import com.intellectualcrafters.plot.util.BlockManager;
|
import com.intellectualcrafters.plot.util.BlockManager;
|
||||||
import com.intellectualcrafters.plot.util.ChunkManager;
|
import com.intellectualcrafters.plot.util.ChunkManager;
|
||||||
import com.intellectualcrafters.plot.util.MainUtil;
|
import com.intellectualcrafters.plot.util.MainUtil;
|
||||||
import com.intellectualcrafters.plot.util.SchematicHandler;
|
import com.intellectualcrafters.plot.util.SchematicHandler;
|
||||||
import com.intellectualcrafters.plot.util.bukkit.BukkitUtil;
|
|
||||||
|
|
||||||
public abstract class HybridUtils {
|
public abstract class HybridUtils {
|
||||||
|
|
||||||
public static HybridUtils manager;
|
public static HybridUtils manager;
|
||||||
|
|
||||||
public boolean checkModified(final Plot plot, int requiredChanges) {
|
public abstract void checkModified(final Plot plot, final RunnableVal whenDone);
|
||||||
final Location bottom = MainUtil.getPlotBottomLoc(plot.world, plot.id).add(1, 0, 1);
|
|
||||||
final Location top = MainUtil.getPlotTopLoc(plot.world, plot.id);
|
|
||||||
final int botx = bottom.getX();
|
|
||||||
final int botz = bottom.getZ();
|
|
||||||
final int topx = top.getX();
|
|
||||||
final int topz = top.getZ();
|
|
||||||
final HybridPlotWorld hpw = (HybridPlotWorld) PlotSquared.getPlotWorld(plot.world);
|
|
||||||
final PlotBlock[] air = new PlotBlock[] { new PlotBlock((short) 0, (byte) 0) };
|
|
||||||
int changes = checkModified(requiredChanges, plot.world, botx, topx, hpw.PLOT_HEIGHT, hpw.PLOT_HEIGHT, botz, topz, hpw.TOP_BLOCK);
|
|
||||||
if (changes == -1) {
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
requiredChanges -= changes;
|
|
||||||
changes = checkModified(requiredChanges, plot.world, botx, topx, hpw.PLOT_HEIGHT + 1, hpw.PLOT_HEIGHT + 1, botz, topz, air);
|
|
||||||
if (changes == -1) {
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
requiredChanges -= changes;
|
|
||||||
changes = checkModified(requiredChanges, plot.world, botx, topx, hpw.PLOT_HEIGHT + 2, BukkitUtil.getMaxHeight(plot.world) - 1, botz, topz, air);
|
|
||||||
if (changes == -1) {
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
requiredChanges -= changes;
|
|
||||||
changes = checkModified(requiredChanges, plot.world, botx, topx, 1, hpw.PLOT_HEIGHT - 1, botz, topz, hpw.MAIN_BLOCK);
|
|
||||||
return changes == -1;
|
|
||||||
}
|
|
||||||
|
|
||||||
public abstract int checkModified(final int threshhold, final String world, final int x1, final int x2, final int y1, final int y2, final int z1, final int z2, final PlotBlock[] blocks);
|
public abstract int checkModified(final String world, final int x1, final int x2, final int y1, final int y2, final int z1, final int z2, final PlotBlock[] blocks);
|
||||||
|
|
||||||
public boolean setupRoadSchematic(final Plot plot) {
|
public boolean setupRoadSchematic(final Plot plot) {
|
||||||
final String world = plot.world;
|
final String world = plot.world;
|
||||||
@ -85,8 +59,6 @@ public abstract class HybridUtils {
|
|||||||
|
|
||||||
public abstract int get_ey(final String world, final int sx, final int ex, final int sz, final int ez, final int sy);
|
public abstract int get_ey(final String world, final int sx, final int ex, final int sz, final int ez, final int sy);
|
||||||
|
|
||||||
public abstract void regenerateChunkChunk(final String world, final ChunkLoc loc);
|
|
||||||
|
|
||||||
public abstract boolean scheduleRoadUpdate(final String world);
|
public abstract boolean scheduleRoadUpdate(final String world);
|
||||||
|
|
||||||
public boolean regenerateRoad(final String world, final ChunkLoc chunk) {
|
public boolean regenerateRoad(final String world, final ChunkLoc chunk) {
|
||||||
@ -164,7 +136,6 @@ public abstract class HybridUtils {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
ChunkManager.manager.unloadChunk(world, chunk);
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -35,10 +35,18 @@ public abstract class SquarePlotManager extends GridPlotManager {
|
|||||||
public PlotId getPlotIdAbs(final PlotWorld plotworld, int x, final int y, int z) {
|
public PlotId getPlotIdAbs(final PlotWorld plotworld, int x, final int y, int z) {
|
||||||
final SquarePlotWorld dpw = ((SquarePlotWorld) plotworld);
|
final SquarePlotWorld dpw = ((SquarePlotWorld) plotworld);
|
||||||
int pathWidthLower;
|
int pathWidthLower;
|
||||||
if ((dpw.ROAD_WIDTH % 2) == 0) {
|
int end;
|
||||||
pathWidthLower = (dpw.ROAD_WIDTH / 2) - 1;
|
if (dpw.ROAD_WIDTH == 0) {
|
||||||
} else {
|
pathWidthLower = -1;
|
||||||
pathWidthLower = dpw.ROAD_WIDTH / 2;
|
end = dpw.PLOT_WIDTH;
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
if ((dpw.ROAD_WIDTH % 2) == 0) {
|
||||||
|
pathWidthLower = (dpw.ROAD_WIDTH / 2) - 1;
|
||||||
|
} else {
|
||||||
|
pathWidthLower = dpw.ROAD_WIDTH / 2;
|
||||||
|
}
|
||||||
|
end = pathWidthLower + dpw.PLOT_WIDTH;
|
||||||
}
|
}
|
||||||
final int size = dpw.PLOT_WIDTH + dpw.ROAD_WIDTH;
|
final int size = dpw.PLOT_WIDTH + dpw.ROAD_WIDTH;
|
||||||
int idx;
|
int idx;
|
||||||
@ -59,7 +67,6 @@ public abstract class SquarePlotManager extends GridPlotManager {
|
|||||||
idz = (z/size) + 1;
|
idz = (z/size) + 1;
|
||||||
z = (z % size);
|
z = (z % size);
|
||||||
}
|
}
|
||||||
final int end = pathWidthLower + dpw.PLOT_WIDTH;
|
|
||||||
final boolean northSouth = (z <= pathWidthLower) || (z > end);
|
final boolean northSouth = (z <= pathWidthLower) || (z > end);
|
||||||
final boolean eastWest = (x <= pathWidthLower) || (x > end);
|
final boolean eastWest = (x <= pathWidthLower) || (x > end);
|
||||||
if (northSouth || eastWest) {
|
if (northSouth || eastWest) {
|
||||||
@ -76,10 +83,18 @@ public abstract class SquarePlotManager extends GridPlotManager {
|
|||||||
}
|
}
|
||||||
final int size = dpw.PLOT_WIDTH + dpw.ROAD_WIDTH;
|
final int size = dpw.PLOT_WIDTH + dpw.ROAD_WIDTH;
|
||||||
int pathWidthLower;
|
int pathWidthLower;
|
||||||
if ((dpw.ROAD_WIDTH % 2) == 0) {
|
final int end;
|
||||||
pathWidthLower = (dpw.ROAD_WIDTH / 2) - 1;
|
if (dpw.ROAD_WIDTH == 0) {
|
||||||
} else {
|
pathWidthLower = -1;
|
||||||
pathWidthLower = dpw.ROAD_WIDTH / 2;
|
end = dpw.PLOT_WIDTH;
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
if ((dpw.ROAD_WIDTH % 2) == 0) {
|
||||||
|
pathWidthLower = (dpw.ROAD_WIDTH / 2) - 1;
|
||||||
|
} else {
|
||||||
|
pathWidthLower = dpw.ROAD_WIDTH / 2;
|
||||||
|
}
|
||||||
|
end = pathWidthLower + dpw.PLOT_WIDTH;
|
||||||
}
|
}
|
||||||
int dx;
|
int dx;
|
||||||
int dz;
|
int dz;
|
||||||
@ -101,7 +116,6 @@ public abstract class SquarePlotManager extends GridPlotManager {
|
|||||||
dz = (z/size) + 1;
|
dz = (z/size) + 1;
|
||||||
rz = (z % size);
|
rz = (z % size);
|
||||||
}
|
}
|
||||||
final int end = pathWidthLower + dpw.PLOT_WIDTH;
|
|
||||||
final boolean northSouth = (rz <= pathWidthLower) || (rz > end);
|
final boolean northSouth = (rz <= pathWidthLower) || (rz > end);
|
||||||
final boolean eastWest = (rx <= pathWidthLower) || (rx > end);
|
final boolean eastWest = (rx <= pathWidthLower) || (rx > end);
|
||||||
if (northSouth && eastWest) {
|
if (northSouth && eastWest) {
|
||||||
|
@ -0,0 +1,13 @@
|
|||||||
|
package com.intellectualcrafters.plot.listeners;
|
||||||
|
|
||||||
|
import com.intellectualcrafters.plot.object.Plot;
|
||||||
|
import com.intellectualcrafters.plot.object.PlotPlayer;
|
||||||
|
|
||||||
|
public abstract class APlotListener {
|
||||||
|
|
||||||
|
public static APlotListener manager;
|
||||||
|
|
||||||
|
public abstract void plotExit(final PlotPlayer player, final Plot plot);
|
||||||
|
|
||||||
|
public abstract void plotEntry(final PlotPlayer player, final Plot plot);
|
||||||
|
}
|
@ -0,0 +1,149 @@
|
|||||||
|
package com.intellectualcrafters.plot.listeners;
|
||||||
|
|
||||||
|
import org.bukkit.Bukkit;
|
||||||
|
import org.bukkit.Chunk;
|
||||||
|
import org.bukkit.Material;
|
||||||
|
import org.bukkit.block.BlockState;
|
||||||
|
import org.bukkit.entity.Entity;
|
||||||
|
import org.bukkit.entity.Item;
|
||||||
|
import org.bukkit.entity.LivingEntity;
|
||||||
|
import org.bukkit.entity.Player;
|
||||||
|
import org.bukkit.event.EventHandler;
|
||||||
|
import org.bukkit.event.Listener;
|
||||||
|
import org.bukkit.event.entity.CreatureSpawnEvent;
|
||||||
|
import org.bukkit.event.entity.ItemSpawnEvent;
|
||||||
|
import org.bukkit.event.world.ChunkLoadEvent;
|
||||||
|
import org.bukkit.event.world.ChunkUnloadEvent;
|
||||||
|
|
||||||
|
import com.intellectualcrafters.plot.PlotSquared;
|
||||||
|
import com.intellectualcrafters.plot.config.Settings;
|
||||||
|
import com.intellectualcrafters.plot.util.TaskManager;
|
||||||
|
|
||||||
|
public class ChunkListener implements Listener {
|
||||||
|
|
||||||
|
@EventHandler
|
||||||
|
public void onChunkUnload(ChunkUnloadEvent event) {
|
||||||
|
if (processChunk(event.getChunk(), true)) {
|
||||||
|
event.setCancelled(true);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@EventHandler
|
||||||
|
public void onChunkLoad(ChunkLoadEvent event) {
|
||||||
|
processChunk(event.getChunk(), false);
|
||||||
|
}
|
||||||
|
|
||||||
|
private Chunk lastChunk = null;
|
||||||
|
|
||||||
|
@EventHandler
|
||||||
|
public void onItemSpawn(ItemSpawnEvent event) {
|
||||||
|
Item entity = event.getEntity();
|
||||||
|
Chunk chunk = entity.getLocation().getChunk();
|
||||||
|
if (chunk == lastChunk) {
|
||||||
|
event.getEntity().remove();
|
||||||
|
event.setCancelled(true);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
if (!PlotSquared.isPlotWorld(chunk.getWorld().getName())) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
Entity[] entities = chunk.getEntities();
|
||||||
|
if (entities.length > Settings.CHUNK_PROCESSOR_MAX_ENTITIES) {
|
||||||
|
event.getEntity().remove();
|
||||||
|
event.setCancelled(true);
|
||||||
|
lastChunk = chunk;
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
lastChunk = null;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@EventHandler
|
||||||
|
public void onEntitySpawn(CreatureSpawnEvent event) {
|
||||||
|
LivingEntity entity = event.getEntity();
|
||||||
|
Chunk chunk = entity.getLocation().getChunk();
|
||||||
|
if (chunk == lastChunk) {
|
||||||
|
event.getEntity().remove();
|
||||||
|
event.setCancelled(true);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
if (!PlotSquared.isPlotWorld(chunk.getWorld().getName())) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
Entity[] entities = chunk.getEntities();
|
||||||
|
if (entities.length > Settings.CHUNK_PROCESSOR_MAX_ENTITIES) {
|
||||||
|
event.getEntity().remove();
|
||||||
|
event.setCancelled(true);
|
||||||
|
lastChunk = chunk;
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
lastChunk = null;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public void cleanChunk(final Chunk chunk) {
|
||||||
|
TaskManager.index.increment();
|
||||||
|
final Integer currentIndex = TaskManager.index.toInteger();
|
||||||
|
final Integer task = TaskManager.runTaskRepeat(new Runnable() {
|
||||||
|
@Override
|
||||||
|
public void run() {
|
||||||
|
if (!chunk.isLoaded()) {
|
||||||
|
Bukkit.getScheduler().cancelTask(TaskManager.tasks.get(currentIndex));
|
||||||
|
TaskManager.tasks.remove(currentIndex);
|
||||||
|
PlotSquared.log("[PlotSquared] &aSuccessfully processed and unloaded chunk!");
|
||||||
|
chunk.unload(true, true);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
BlockState[] tiles = chunk.getTileEntities();
|
||||||
|
if (tiles.length == 0) {
|
||||||
|
Bukkit.getScheduler().cancelTask(TaskManager.tasks.get(currentIndex));
|
||||||
|
TaskManager.tasks.remove(currentIndex);
|
||||||
|
PlotSquared.log("[PlotSquared] &aSuccessfully processed and unloaded chunk!");
|
||||||
|
chunk.unload(true, true);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
long start = System.currentTimeMillis();
|
||||||
|
int i = 0;
|
||||||
|
while (System.currentTimeMillis() - start < 250) {
|
||||||
|
if (i >= tiles.length) {
|
||||||
|
Bukkit.getScheduler().cancelTask(TaskManager.tasks.get(currentIndex));
|
||||||
|
TaskManager.tasks.remove(currentIndex);
|
||||||
|
PlotSquared.log("[PlotSquared] &aSuccessfully processed and unloaded chunk!");
|
||||||
|
chunk.unload(true, true);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
tiles[i].getBlock().setType(Material.AIR, false);
|
||||||
|
i++;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}, 5);
|
||||||
|
TaskManager.tasks.put(currentIndex, task);
|
||||||
|
}
|
||||||
|
|
||||||
|
public boolean processChunk(Chunk chunk, boolean unload) {
|
||||||
|
if (!PlotSquared.isPlotWorld(chunk.getWorld().getName())) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
Entity[] entities = chunk.getEntities();
|
||||||
|
BlockState[] tiles = chunk.getTileEntities();
|
||||||
|
if (entities.length > Settings.CHUNK_PROCESSOR_MAX_ENTITIES) {
|
||||||
|
for (Entity ent : entities) {
|
||||||
|
if (!(ent instanceof Player)) {
|
||||||
|
ent.remove();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
PlotSquared.log("[PlotSquared] &a detected unsafe chunk and processed: " + (chunk.getX() << 4) + "," + (chunk.getX() << 4));
|
||||||
|
}
|
||||||
|
if (tiles.length > Settings.CHUNK_PROCESSOR_MAX_BLOCKSTATES) {
|
||||||
|
if (unload) {
|
||||||
|
PlotSquared.log("[PlotSquared] &c detected unsafe chunk: " + (chunk.getX() << 4) + "," + (chunk.getX() << 4));
|
||||||
|
cleanChunk(chunk);
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
for (BlockState tile : tiles) {
|
||||||
|
tile.getBlock().setType(Material.AIR, false);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
}
|
@ -105,7 +105,7 @@ public class ForceFieldListener implements Listener {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
if ((FlagManager.getPlotFlag(plot, "forcefield") != null) && FlagManager.getPlotFlag(plot, "forcefield").getValue().equals("true")) {
|
if ((FlagManager.getPlotFlag(plot, "forcefield") != null) && FlagManager.getPlotFlag(plot, "forcefield").getValue().equals("true")) {
|
||||||
if (!PlotListener.booleanFlag(plot, "forcefield", false)) {
|
if (!FlagManager.isBooleanFlag(plot, "forcefield", false)) {
|
||||||
final UUID uuid = pp.getUUID();
|
final UUID uuid = pp.getUUID();
|
||||||
if (plot.isAdded(uuid)) {
|
if (plot.isAdded(uuid)) {
|
||||||
final Set<Player> players = getNearbyPlayers(player, plot);
|
final Set<Player> players = getNearbyPlayers(player, plot);
|
||||||
|
Some files were not shown because too many files have changed in this diff Show More
Loading…
Reference in New Issue
Block a user