mirror of
https://github.com/IntellectualSites/PlotSquared.git
synced 2025-07-03 06:04:43 +02:00
Compare commits
101 Commits
Author | SHA1 | Date | |
---|---|---|---|
ff401b65c4 | |||
11913bfbe5 | |||
62b353f82d | |||
8d442f58d4 | |||
5cbd2f44bd | |||
dc673f9715 | |||
deb5441bcf | |||
8ebf71c87f | |||
9fd53af483 | |||
fb729df59e | |||
ce6e1be13e | |||
e126054053 | |||
77281017d4 | |||
e0208aa369 | |||
fdc42a3d5c | |||
3070557a3a | |||
2ec0b55482 | |||
10dd9b6371 | |||
1ac0a7dad0 | |||
f8b1fcffa1 | |||
17762f5ae7 | |||
1d7cdde84a | |||
c950b0021f | |||
e4bc2b30b1 | |||
e0c4c944bb | |||
dd09ef18e6 | |||
68011f43cd | |||
93c4854454 | |||
e594227d95 | |||
d6be5703ae | |||
c97544d083 | |||
a05fd2dd11 | |||
5978c9c3c0 | |||
5d3e096501 | |||
39e99c0593 | |||
cd33aaa1b6 | |||
0244c0241c | |||
5ed2190cb3 | |||
c533f0bae9 | |||
cd2b6c8ccc | |||
6f2c7de0ff | |||
62373c0737 | |||
499120963a | |||
f1d581a8d8 | |||
6074fc8033 | |||
e4d7270c28 | |||
b6df07f723 | |||
177b33154f | |||
6bf2fbcfcf | |||
12f8861d07 | |||
c99e23bd3c | |||
1b6d08b3fe | |||
3b4490c1c6 | |||
04c011164a | |||
86b776f742 | |||
61022b717a | |||
9e5af7a642 | |||
364b4347d1 | |||
d89274ce09 | |||
264114332b | |||
a4363bdb27 | |||
8e7e5dcb25 | |||
56227a6d7d | |||
63259ec269 | |||
0286a7b046 | |||
b6dac54677 | |||
bf1d487508 | |||
a95b68b73c | |||
85ff8bf639 | |||
0557671b80 | |||
d75ab130da | |||
6a12a6ba64 | |||
22901bf9f2 | |||
07ee19b4bb | |||
27c21b9ab6 | |||
da7a12bc00 | |||
3b73b2e9d8 | |||
970c80cb15 | |||
dd665ed9ce | |||
572da7d436 | |||
ab05b026e9 | |||
2fcb59f8cf | |||
20250bc989 | |||
5e4798165b | |||
7fc3fb097e | |||
3a08e5c091 | |||
50770a78d7 | |||
1266eed86a | |||
c0996299b4 | |||
90d48b2cd0 | |||
a95d18499e | |||
61d00e51ef | |||
b5349e16f0 | |||
a801127036 | |||
2806f8b20c | |||
7d11147836 | |||
74a6df1fa7 | |||
bc0c0abe7e | |||
56907e4580 | |||
634802ef98 | |||
37e4a652dd |
2
.github/ISSUE_TEMPLATE.md
vendored
2
.github/ISSUE_TEMPLATE.md
vendored
@ -8,5 +8,5 @@
|
||||
Make sure you've completed the following steps (put an X between of brackets):
|
||||
- [] Include `/plot debugpaste`
|
||||
- [] Made sure there aren't duplicates of this report [(Use Search)](https://github.com/IntellectualSites/PlotSquared/issues?utf8=%E2%9C%93&q=is%3Aissue)
|
||||
- [] Made sure you're using an updated version of PlotSquared
|
||||
- [] Made sure you're using an up-to-date version of PlotSquared
|
||||
- [] Made sure the bug/error isn't caused by any other plugin
|
||||
|
8
.gitignore
vendored
8
.gitignore
vendored
@ -1,5 +1,4 @@
|
||||
### Others ###
|
||||
*.bat
|
||||
*.cmd
|
||||
*.sh
|
||||
*.prefs
|
||||
@ -131,4 +130,9 @@ local.properties
|
||||
|
||||
# STS (Spring Tool Suite)
|
||||
.springBeans
|
||||
/target/
|
||||
/target/
|
||||
Nukkit/build/classes/
|
||||
Nukkit/build/dependency-cache/
|
||||
checkstyle.xml
|
||||
classes/
|
||||
p2error.txt
|
@ -2,12 +2,15 @@ repositories {
|
||||
maven {url "https://hub.spigotmc.org/nexus/content/groups/public/"}
|
||||
maven { url = "https://oss.sonatype.org/content/repositories/snapshots/"}
|
||||
maven {url "http://nexus.hc.to/content/repositories/pub_releases"}
|
||||
mavenLocal()
|
||||
}
|
||||
|
||||
dependencies {
|
||||
compile project(':Core')
|
||||
compile 'org.spigotmc:spigot-api:1.10.2-R0.1-SNAPSHOT'
|
||||
compile 'net.milkbowl.vault:VaultAPI:1.6'
|
||||
compile 'org.spigotmc:spigot-api:1.11-R0.1-SNAPSHOT'
|
||||
compile("net.milkbowl.vault:VaultAPI:1.6") {
|
||||
exclude module: 'bukkit'
|
||||
}
|
||||
}
|
||||
|
||||
sourceCompatibility = 1.7
|
||||
|
@ -57,6 +57,7 @@ import com.plotsquared.bukkit.util.BukkitSchematicHandler;
|
||||
import com.plotsquared.bukkit.util.BukkitSetupUtils;
|
||||
import com.plotsquared.bukkit.util.BukkitTaskManager;
|
||||
import com.plotsquared.bukkit.util.BukkitUtil;
|
||||
import com.plotsquared.bukkit.util.BukkitVersion;
|
||||
import com.plotsquared.bukkit.util.Metrics;
|
||||
import com.plotsquared.bukkit.util.SendChunk;
|
||||
import com.plotsquared.bukkit.util.SetGenCB;
|
||||
@ -84,20 +85,72 @@ import org.bukkit.event.Listener;
|
||||
import org.bukkit.generator.ChunkGenerator;
|
||||
import org.bukkit.metadata.MetadataValue;
|
||||
import org.bukkit.plugin.Plugin;
|
||||
import org.bukkit.plugin.PluginManager;
|
||||
import org.bukkit.plugin.java.JavaPlugin;
|
||||
|
||||
import java.io.File;
|
||||
import java.lang.reflect.Field;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
import java.util.Iterator;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.UUID;
|
||||
import java.util.concurrent.ConcurrentHashMap;
|
||||
|
||||
public final class BukkitMain extends JavaPlugin implements Listener, IPlotMain {
|
||||
|
||||
private static ConcurrentHashMap<String, Plugin> pluginMap;
|
||||
|
||||
static {
|
||||
// Disable AWE as otherwise both fail to load
|
||||
PluginManager manager = Bukkit.getPluginManager();
|
||||
try {
|
||||
Settings.load(new File("plugins/PlotSquared/config/settings.yml"));
|
||||
if (Settings.Enabled_Components.PLOTME_CONVERTER) { // Only disable PlotMe if conversion is enabled
|
||||
Field pluginsField = manager.getClass().getDeclaredField("plugins");
|
||||
Field lookupNamesField = manager.getClass().getDeclaredField("lookupNames");
|
||||
pluginsField.setAccessible(true);
|
||||
lookupNamesField.setAccessible(true);
|
||||
List<Plugin> plugins = (List<Plugin>) pluginsField.get(manager);
|
||||
Iterator<Plugin> iter = plugins.iterator();
|
||||
while (iter.hasNext()) {
|
||||
if (iter.next().getName().startsWith("PlotMe")) {
|
||||
iter.remove();
|
||||
}
|
||||
}
|
||||
Map<String, Plugin> lookupNames = (Map<String, Plugin>) lookupNamesField.get(manager);
|
||||
lookupNames.remove("PlotMe");
|
||||
lookupNames.remove("PlotMe-DefaultGenerator");
|
||||
pluginsField.set(manager, new ArrayList<Plugin>(plugins) {
|
||||
@Override
|
||||
public boolean add(Plugin plugin) {
|
||||
if (plugin.getName().startsWith("PlotMe")) {
|
||||
System.out.print("Disabling `" + plugin.getName() + "` for PlotMe conversion (configure in PlotSquared settings.yml)");
|
||||
} else {
|
||||
return super.add(plugin);
|
||||
}
|
||||
return false;
|
||||
}
|
||||
});
|
||||
pluginMap = new ConcurrentHashMap<String, Plugin>(lookupNames) {
|
||||
@Override
|
||||
public Plugin put(String key, Plugin plugin) {
|
||||
if (!plugin.getName().startsWith("PlotMe")) {
|
||||
return super.put(key, plugin);
|
||||
}
|
||||
return null;
|
||||
}
|
||||
};
|
||||
lookupNamesField.set(manager, pluginMap);
|
||||
}
|
||||
} catch (Throwable ignore) {}
|
||||
}
|
||||
|
||||
public static WorldEdit worldEdit;
|
||||
|
||||
private int[] version;
|
||||
private String name;
|
||||
|
||||
@Override
|
||||
public int[] getServerVersion() {
|
||||
@ -122,13 +175,17 @@ public final class BukkitMain extends JavaPlugin implements Listener, IPlotMain
|
||||
|
||||
@Override
|
||||
public void onEnable() {
|
||||
if (pluginMap != null) {
|
||||
pluginMap.put("PlotMe-DefaultGenerator", this);
|
||||
}
|
||||
this.name = getDescription().getName();
|
||||
getServer().getName();
|
||||
new PS(this, "Bukkit");
|
||||
if (Settings.Enabled_Components.METRICS) {
|
||||
new Metrics(this).start();
|
||||
PS.log(C.PREFIX + "&6Metrics enabled.");
|
||||
} else {
|
||||
PS.log(C.CONSOLE_PLEASE_ENABLE_METRICS);
|
||||
PS.log(C.CONSOLE_PLEASE_ENABLE_METRICS.f(getPluginName()));
|
||||
}
|
||||
}
|
||||
|
||||
@ -170,6 +227,11 @@ public final class BukkitMain extends JavaPlugin implements Listener, IPlotMain
|
||||
return getDescription().getVersion();
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getPluginName() {
|
||||
return name;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void registerCommands() {
|
||||
BukkitCommand bukkitCommand = new BukkitCommand();
|
||||
@ -237,6 +299,7 @@ public final class BukkitMain extends JavaPlugin implements Listener, IPlotMain
|
||||
case TIPPED_ARROW:
|
||||
case ENDER_PEARL:
|
||||
case ARROW:
|
||||
case LLAMA_SPIT:
|
||||
// managed elsewhere | projectile
|
||||
continue;
|
||||
case ITEM_FRAME:
|
||||
@ -253,7 +316,7 @@ public final class BukkitMain extends JavaPlugin implements Listener, IPlotMain
|
||||
case MINECART_MOB_SPAWNER:
|
||||
case ENDER_CRYSTAL:
|
||||
case MINECART_TNT:
|
||||
case BOAT: {
|
||||
case BOAT:
|
||||
if (Settings.Enabled_Components.KILL_ROAD_VEHICLES) {
|
||||
com.intellectualcrafters.plot.object.Location location = BukkitUtil.getLocation(entity.getLocation());
|
||||
Plot plot = location.getPlot();
|
||||
@ -277,7 +340,6 @@ public final class BukkitMain extends JavaPlugin implements Listener, IPlotMain
|
||||
} else {
|
||||
continue;
|
||||
}
|
||||
}
|
||||
case SMALL_FIREBALL:
|
||||
case FIREBALL:
|
||||
case DRAGON_FIREBALL:
|
||||
@ -288,6 +350,20 @@ public final class BukkitMain extends JavaPlugin implements Listener, IPlotMain
|
||||
case FALLING_BLOCK:
|
||||
// managed elsewhere
|
||||
continue;
|
||||
case LLAMA:
|
||||
case DONKEY:
|
||||
case MULE:
|
||||
case ZOMBIE_HORSE:
|
||||
case SKELETON_HORSE:
|
||||
case HUSK:
|
||||
case ELDER_GUARDIAN:
|
||||
case WITHER_SKELETON:
|
||||
case STRAY:
|
||||
case ZOMBIE_VILLAGER:
|
||||
case EVOKER:
|
||||
case EVOKER_FANGS:
|
||||
case VEX:
|
||||
case VINDICATOR:
|
||||
case POLAR_BEAR:
|
||||
case BAT:
|
||||
case BLAZE:
|
||||
@ -357,11 +433,15 @@ public final class BukkitMain extends JavaPlugin implements Listener, IPlotMain
|
||||
|
||||
@Override
|
||||
public final ChunkGenerator getDefaultWorldGenerator(String world, String id) {
|
||||
HybridGen result = new HybridGen();
|
||||
if (Settings.Enabled_Components.PLOTME_CONVERTER) {
|
||||
initPlotMeConverter();
|
||||
Settings.Enabled_Components.PLOTME_CONVERTER = false;
|
||||
}
|
||||
IndependentPlotGenerator result = PS.get().IMP.getDefaultGenerator();
|
||||
if (!PS.get().setupPlotWorld(world, id, result)) {
|
||||
return null;
|
||||
}
|
||||
return (ChunkGenerator) result.specify();
|
||||
return (ChunkGenerator) result.specify(world);
|
||||
}
|
||||
|
||||
@Override
|
||||
@ -374,21 +454,21 @@ public final class BukkitMain extends JavaPlugin implements Listener, IPlotMain
|
||||
} catch (NoSuchMethodException ignored) {
|
||||
PS.debug("Not running Spigot. Skipping EntitySpawnListener event.");
|
||||
}
|
||||
if (PS.get().checkVersion(getServerVersion(), 1, 8, 0)) {
|
||||
if (PS.get().checkVersion(getServerVersion(), BukkitVersion.v1_8_0)) {
|
||||
try {
|
||||
getServer().getPluginManager().registerEvents(new PlayerEvents_1_8(), this);
|
||||
} catch (Throwable e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
if (PS.get().checkVersion(getServerVersion(), 1, 8, 3)) {
|
||||
if (PS.get().checkVersion(getServerVersion(), BukkitVersion.v1_8_3)) {
|
||||
try {
|
||||
getServer().getPluginManager().registerEvents(new PlayerEvents183(), this);
|
||||
} catch (Throwable e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
if (PS.get().checkVersion(getServerVersion(), 1, 9, 0)) {
|
||||
if (PS.get().checkVersion(getServerVersion(), BukkitVersion.v1_9_0)) {
|
||||
try {
|
||||
getServer().getPluginManager().registerEvents(new PlayerEvents_1_9(main), this);
|
||||
} catch (Throwable e) {
|
||||
@ -443,13 +523,13 @@ public final class BukkitMain extends JavaPlugin implements Listener, IPlotMain
|
||||
PS.debug(SendChunk.class + " does not support " + StringMan.getString(getServerVersion()));
|
||||
MainUtil.canSendChunk = false;
|
||||
}
|
||||
if (PS.get().checkVersion(getServerVersion(), 1, 9, 0)) {
|
||||
if (PS.get().checkVersion(getServerVersion(), BukkitVersion.v1_9_0)) {
|
||||
return QueueProvider.of(BukkitLocalQueue_1_9.class, BukkitLocalQueue.class);
|
||||
}
|
||||
if (PS.get().checkVersion(getServerVersion(), 1, 8, 3)) {
|
||||
if (PS.get().checkVersion(getServerVersion(), BukkitVersion.v1_8_3)) {
|
||||
return QueueProvider.of(BukkitLocalQueue_1_8_3.class, BukkitLocalQueue.class);
|
||||
}
|
||||
if (PS.get().checkVersion(getServerVersion(), 1, 8, 0)) {
|
||||
if (PS.get().checkVersion(getServerVersion(), BukkitVersion.v1_8_0)) {
|
||||
return QueueProvider.of(BukkitLocalQueue_1_8.class, BukkitLocalQueue.class);
|
||||
}
|
||||
return QueueProvider.of(BukkitLocalQueue_1_7.class, BukkitLocalQueue.class);
|
||||
@ -462,18 +542,12 @@ public final class BukkitMain extends JavaPlugin implements Listener, IPlotMain
|
||||
|
||||
@Override
|
||||
public boolean initPlotMeConverter() {
|
||||
TaskManager.runTaskLaterAsync(new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
if (new LikePlotMeConverter("PlotMe").run(new ClassicPlotMeConnector())) {
|
||||
return;
|
||||
}
|
||||
if (new LikePlotMeConverter("PlotMe").run(new PlotMeConnector_017())) {
|
||||
return;
|
||||
}
|
||||
}
|
||||
}, 20);
|
||||
return Bukkit.getPluginManager().getPlugin("PlotMe") != null;
|
||||
if (new LikePlotMeConverter("PlotMe").run(new ClassicPlotMeConnector())) {
|
||||
return true;
|
||||
} else if (new LikePlotMeConverter("PlotMe").run(new PlotMeConnector_017())) {
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
@ -489,7 +563,7 @@ public final class BukkitMain extends JavaPlugin implements Listener, IPlotMain
|
||||
}
|
||||
return new BukkitPlotGenerator(world, gen);
|
||||
} else {
|
||||
return new BukkitPlotGenerator(new HybridGen());
|
||||
return new BukkitPlotGenerator(PS.get().IMP.getDefaultGenerator());
|
||||
}
|
||||
}
|
||||
|
||||
@ -505,7 +579,7 @@ public final class BukkitMain extends JavaPlugin implements Listener, IPlotMain
|
||||
|
||||
@Override
|
||||
public UUIDHandlerImplementation initUUIDHandler() {
|
||||
boolean checkVersion = PS.get().checkVersion(getServerVersion(), 1, 7, 6);
|
||||
boolean checkVersion = PS.get().checkVersion(getServerVersion(), BukkitVersion.v1_7_6);
|
||||
UUIDWrapper wrapper;
|
||||
if (Settings.UUID.OFFLINE) {
|
||||
if (Settings.UUID.FORCE_LOWERCASE) {
|
||||
@ -536,10 +610,10 @@ public final class BukkitMain extends JavaPlugin implements Listener, IPlotMain
|
||||
}
|
||||
if (Settings.UUID.OFFLINE) {
|
||||
PS.log(C.PREFIX
|
||||
+ " &6PlotSquared is using Offline Mode UUIDs either because of user preference, or because you are using an old version of "
|
||||
+ " &6" + getPluginName() + " is using Offline Mode UUIDs either because of user preference, or because you are using an old version of "
|
||||
+ "Bukkit");
|
||||
} else {
|
||||
PS.log(C.PREFIX + " &6PlotSquared is using online UUIDs");
|
||||
PS.log(C.PREFIX + " &6" + getPluginName() + " is using online UUIDs");
|
||||
}
|
||||
if (Settings.UUID.USE_SQLUUIDHANDLER) {
|
||||
return new SQLUUIDHandler(wrapper);
|
||||
@ -573,6 +647,11 @@ public final class BukkitMain extends JavaPlugin implements Listener, IPlotMain
|
||||
getServer().getPluginManager().registerEvents(new WorldEvents(), this);
|
||||
}
|
||||
|
||||
@Override
|
||||
public IndependentPlotGenerator getDefaultGenerator() {
|
||||
return new HybridGen();
|
||||
}
|
||||
|
||||
@Override
|
||||
public InventoryUtil initInventoryUtil() {
|
||||
return new BukkitInventoryUtil();
|
||||
@ -590,7 +669,7 @@ public final class BukkitMain extends JavaPlugin implements Listener, IPlotMain
|
||||
if (world == null) {
|
||||
// create world
|
||||
ConfigurationSection worldConfig = PS.get().worlds.getConfigurationSection("worlds." + worldName);
|
||||
String manager = worldConfig.getString("generator.plugin", "PlotSquared");
|
||||
String manager = worldConfig.getString("generator.plugin", getPluginName());
|
||||
SetupObject setup = new SetupObject();
|
||||
setup.plotManager = manager;
|
||||
setup.setupGenerator = worldConfig.getString("generator.init", manager);
|
||||
@ -599,17 +678,18 @@ public final class BukkitMain extends JavaPlugin implements Listener, IPlotMain
|
||||
setup.step = new ConfigurationNode[0];
|
||||
setup.world = worldName;
|
||||
SetupUtils.manager.setupWorld(setup);
|
||||
world = Bukkit.getWorld(worldName);
|
||||
} else {
|
||||
try {
|
||||
if (!PS.get().hasPlotArea(worldName)) {
|
||||
SetGenCB.setGenerator(BukkitUtil.getWorld(worldName));
|
||||
}
|
||||
} catch (Exception ignored) {
|
||||
PS.log("Failed to reload world: " + world);
|
||||
PS.log("Failed to reload world: " + world + " | " + ignored.getMessage());
|
||||
Bukkit.getServer().unloadWorld(world, false);
|
||||
return;
|
||||
}
|
||||
}
|
||||
world = Bukkit.getWorld(worldName);
|
||||
ChunkGenerator gen = world.getGenerator();
|
||||
if (gen instanceof BukkitPlotGenerator) {
|
||||
PS.get().loadWorld(worldName, (BukkitPlotGenerator) gen);
|
||||
@ -664,7 +744,7 @@ public final class BukkitMain extends JavaPlugin implements Listener, IPlotMain
|
||||
}
|
||||
|
||||
@Override
|
||||
public GeneratorWrapper<?> wrapPlotGenerator(IndependentPlotGenerator generator) {
|
||||
public GeneratorWrapper<?> wrapPlotGenerator(String world, IndependentPlotGenerator generator) {
|
||||
return new BukkitPlotGenerator(generator);
|
||||
}
|
||||
|
||||
|
@ -19,93 +19,93 @@ import java.util.Collection;
|
||||
*/
|
||||
public final class ArrayWrapper<E> {
|
||||
|
||||
/**
|
||||
* Creates an array wrapper with some elements.
|
||||
*
|
||||
* @param elements The elements of the array.
|
||||
*/
|
||||
public ArrayWrapper(E... elements) {
|
||||
setArray(elements);
|
||||
}
|
||||
/**
|
||||
* Creates an array wrapper with some elements.
|
||||
*
|
||||
* @param elements The elements of the array.
|
||||
*/
|
||||
public ArrayWrapper(E... elements) {
|
||||
setArray(elements);
|
||||
}
|
||||
|
||||
private E[] _array;
|
||||
private E[] _array;
|
||||
|
||||
/**
|
||||
* Retrieves a reference to the wrapped array instance.
|
||||
*
|
||||
* @return The array wrapped by this instance.
|
||||
*/
|
||||
public E[] getArray() {
|
||||
return _array;
|
||||
}
|
||||
/**
|
||||
* Retrieves a reference to the wrapped array instance.
|
||||
*
|
||||
* @return The array wrapped by this instance.
|
||||
*/
|
||||
public E[] getArray() {
|
||||
return _array;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set this wrapper to wrap a new array instance.
|
||||
*
|
||||
* @param array The new wrapped array.
|
||||
*/
|
||||
public void setArray(E[] array) {
|
||||
Validate.notNull(array, "The array must not be null.");
|
||||
_array = array;
|
||||
}
|
||||
/**
|
||||
* Set this wrapper to wrap a new array instance.
|
||||
*
|
||||
* @param array The new wrapped array.
|
||||
*/
|
||||
public void setArray(E[] array) {
|
||||
Validate.notNull(array, "The array must not be null.");
|
||||
_array = array;
|
||||
}
|
||||
|
||||
/**
|
||||
* Determines if this object has a value equivalent to another object.
|
||||
*
|
||||
* @see Arrays#equals(Object[], Object[])
|
||||
*/
|
||||
@SuppressWarnings("rawtypes")
|
||||
@Override
|
||||
public boolean equals(Object other) {
|
||||
if (!(other instanceof ArrayWrapper)) {
|
||||
return false;
|
||||
}
|
||||
return Arrays.equals(_array, ((ArrayWrapper) other)._array);
|
||||
}
|
||||
/**
|
||||
* Determines if this object has a value equivalent to another object.
|
||||
*
|
||||
* @see Arrays#equals(Object[], Object[])
|
||||
*/
|
||||
@SuppressWarnings("rawtypes")
|
||||
@Override
|
||||
public boolean equals(Object other) {
|
||||
if (!(other instanceof ArrayWrapper)) {
|
||||
return false;
|
||||
}
|
||||
return Arrays.equals(_array, ((ArrayWrapper) other)._array);
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the hash code represented by this objects value.
|
||||
*
|
||||
* @return This object's hash code.
|
||||
* @see Arrays#hashCode(Object[])
|
||||
*/
|
||||
@Override
|
||||
public int hashCode() {
|
||||
return Arrays.hashCode(_array);
|
||||
}
|
||||
/**
|
||||
* Gets the hash code represented by this objects value.
|
||||
*
|
||||
* @return This object's hash code.
|
||||
* @see Arrays#hashCode(Object[])
|
||||
*/
|
||||
@Override
|
||||
public int hashCode() {
|
||||
return Arrays.hashCode(_array);
|
||||
}
|
||||
|
||||
/**
|
||||
* Converts an iterable element collection to an array of elements.
|
||||
* The iteration order of the specified object will be used as the array element order.
|
||||
*
|
||||
* @param list The iterable of objects which will be converted to an array.
|
||||
* @param c The type of the elements of the array.
|
||||
* @return An array of elements in the specified iterable.
|
||||
*/
|
||||
@SuppressWarnings("unchecked")
|
||||
public static <T> T[] toArray(Iterable<? extends T> list, Class<T> c) {
|
||||
int size = -1;
|
||||
if (list instanceof Collection<?>) {
|
||||
@SuppressWarnings("rawtypes")
|
||||
Collection coll = (Collection) list;
|
||||
size = coll.size();
|
||||
}
|
||||
/**
|
||||
* Converts an iterable element collection to an array of elements.
|
||||
* The iteration order of the specified object will be used as the array element order.
|
||||
*
|
||||
* @param list The iterable of objects which will be converted to an array.
|
||||
* @param c The type of the elements of the array.
|
||||
* @return An array of elements in the specified iterable.
|
||||
*/
|
||||
@SuppressWarnings("unchecked")
|
||||
public static <T> T[] toArray(Iterable<? extends T> list, Class<T> c) {
|
||||
int size = -1;
|
||||
if (list instanceof Collection<?>) {
|
||||
@SuppressWarnings("rawtypes")
|
||||
Collection coll = (Collection) list;
|
||||
size = coll.size();
|
||||
}
|
||||
|
||||
|
||||
if (size < 0) {
|
||||
size = 0;
|
||||
// Ugly hack: Count it ourselves
|
||||
for (@SuppressWarnings("unused") T element : list) {
|
||||
size++;
|
||||
}
|
||||
}
|
||||
if (size < 0) {
|
||||
size = 0;
|
||||
// Ugly hack: Count it ourselves
|
||||
for (@SuppressWarnings("unused") T element : list) {
|
||||
size++;
|
||||
}
|
||||
}
|
||||
|
||||
T[] result = (T[]) Array.newInstance(c, size);
|
||||
int i = 0;
|
||||
for (T element : list) { // Assumes iteration order is consistent
|
||||
result[i++] = element; // Assign array element at index THEN increment counter
|
||||
}
|
||||
return result;
|
||||
}
|
||||
T[] result = (T[]) Array.newInstance(c, size);
|
||||
int i = 0;
|
||||
for (T element : list) { // Assumes iteration order is consistent
|
||||
result[i++] = element; // Assign array element at index THEN increment counter
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
}
|
||||
|
File diff suppressed because it is too large
Load Diff
@ -9,11 +9,11 @@ import java.io.IOException;
|
||||
*/
|
||||
interface JsonRepresentedObject {
|
||||
|
||||
/**
|
||||
* Writes the JSON representation of this object to the specified writer.
|
||||
* @param writer The JSON writer which will receive the object.
|
||||
* @throws IOException If an error occurs writing to the stream.
|
||||
*/
|
||||
public void writeJson(JsonWriter writer) throws IOException;
|
||||
|
||||
/**
|
||||
* Writes the JSON representation of this object to the specified writer.
|
||||
* @param writer The JSON writer which will receive the object.
|
||||
* @throws IOException If an error occurs writing to the stream.
|
||||
*/
|
||||
public void writeJson(JsonWriter writer) throws IOException;
|
||||
|
||||
}
|
||||
|
@ -1,12 +1,12 @@
|
||||
package com.plotsquared.bukkit.chat;
|
||||
|
||||
import com.google.gson.stream.JsonWriter;
|
||||
import org.bukkit.configuration.serialization.ConfigurationSerializable;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
|
||||
import com.google.gson.stream.JsonWriter;
|
||||
import org.bukkit.configuration.serialization.ConfigurationSerializable;
|
||||
|
||||
/**
|
||||
* Represents a JSON string value.
|
||||
* Writes by this object will not write name values nor begin/end objects in the JSON stream.
|
||||
@ -14,34 +14,34 @@ import org.bukkit.configuration.serialization.ConfigurationSerializable;
|
||||
*/
|
||||
final class JsonString implements JsonRepresentedObject, ConfigurationSerializable {
|
||||
|
||||
private String _value;
|
||||
private String _value;
|
||||
|
||||
public JsonString(CharSequence value) {
|
||||
_value = value == null ? null : value.toString();
|
||||
}
|
||||
public JsonString(CharSequence value) {
|
||||
_value = value == null ? null : value.toString();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void writeJson(JsonWriter writer) throws IOException {
|
||||
writer.value(getValue());
|
||||
}
|
||||
@Override
|
||||
public void writeJson(JsonWriter writer) throws IOException {
|
||||
writer.value(getValue());
|
||||
}
|
||||
|
||||
public String getValue() {
|
||||
return _value;
|
||||
}
|
||||
public String getValue() {
|
||||
return _value;
|
||||
}
|
||||
|
||||
public Map<String, Object> serialize() {
|
||||
HashMap<String, Object> theSingleValue = new HashMap<String, Object>();
|
||||
theSingleValue.put("stringValue", _value);
|
||||
return theSingleValue;
|
||||
}
|
||||
public Map<String, Object> serialize() {
|
||||
HashMap<String, Object> theSingleValue = new HashMap<String, Object>();
|
||||
theSingleValue.put("stringValue", _value);
|
||||
return theSingleValue;
|
||||
}
|
||||
|
||||
public static JsonString deserialize(Map<String, Object> map) {
|
||||
return new JsonString(map.get("stringValue").toString());
|
||||
}
|
||||
public static JsonString deserialize(Map<String, Object> map) {
|
||||
return new JsonString(map.get("stringValue").toString());
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return _value;
|
||||
}
|
||||
@Override
|
||||
public String toString() {
|
||||
return _value;
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -15,134 +15,134 @@ import java.util.Map;
|
||||
*/
|
||||
public final class Reflection {
|
||||
|
||||
/**
|
||||
* Stores loaded classes from the {@code net.minecraft.server} package.
|
||||
*/
|
||||
private static final Map<String, Class<?>> _loadedNMSClasses = new HashMap<>();
|
||||
/**
|
||||
* Stores loaded classes from the {@code org.bukkit.craftbukkit} package (and subpackages).
|
||||
*/
|
||||
private static final Map<String, Class<?>> _loadedOBCClasses = new HashMap<>();
|
||||
private static final Map<Class<?>, Map<String, Field>> _loadedFields = new HashMap<>();
|
||||
/**
|
||||
* Contains loaded methods in a cache.
|
||||
* The map maps [types to maps of [method names to maps of [parameter types to method instances]]].
|
||||
*/
|
||||
private static final Map<Class<?>, Map<String, Map<ArrayWrapper<Class<?>>, Method>>> _loadedMethods = new HashMap<>();
|
||||
private static String _versionString;
|
||||
/**
|
||||
* Stores loaded classes from the {@code net.minecraft.server} package.
|
||||
*/
|
||||
private static final Map<String, Class<?>> _loadedNMSClasses = new HashMap<>();
|
||||
/**
|
||||
* Stores loaded classes from the {@code org.bukkit.craftbukkit} package (and subpackages).
|
||||
*/
|
||||
private static final Map<String, Class<?>> _loadedOBCClasses = new HashMap<>();
|
||||
private static final Map<Class<?>, Map<String, Field>> _loadedFields = new HashMap<>();
|
||||
/**
|
||||
* Contains loaded methods in a cache.
|
||||
* The map maps [types to maps of [method names to maps of [parameter types to method instances]]].
|
||||
*/
|
||||
private static final Map<Class<?>, Map<String, Map<ArrayWrapper<Class<?>>, Method>>> _loadedMethods = new HashMap<>();
|
||||
private static String _versionString;
|
||||
|
||||
private Reflection() { }
|
||||
private Reflection() { }
|
||||
|
||||
/**
|
||||
* Gets the version string from the package name of the CraftBukkit server implementation.
|
||||
* This is needed to bypass the JAR package name changing on each update.
|
||||
*
|
||||
* @return The version string of the OBC and NMS packages, <em>including the trailing dot</em>.
|
||||
*/
|
||||
public synchronized static String getVersion() {
|
||||
if (_versionString == null) {
|
||||
if (Bukkit.getServer() == null) {
|
||||
// The server hasn't started, static initializer call?
|
||||
return null;
|
||||
}
|
||||
String name = Bukkit.getServer().getClass().getPackage().getName();
|
||||
_versionString = name.substring(name.lastIndexOf('.') + 1) + ".";
|
||||
}
|
||||
/**
|
||||
* Gets the version string from the package name of the CraftBukkit server implementation.
|
||||
* This is needed to bypass the JAR package name changing on each update.
|
||||
*
|
||||
* @return The version string of the OBC and NMS packages, <em>including the trailing dot</em>.
|
||||
*/
|
||||
public synchronized static String getVersion() {
|
||||
if (_versionString == null) {
|
||||
if (Bukkit.getServer() == null) {
|
||||
// The server hasn't started, static initializer call?
|
||||
return null;
|
||||
}
|
||||
String name = Bukkit.getServer().getClass().getPackage().getName();
|
||||
_versionString = name.substring(name.lastIndexOf('.') + 1) + ".";
|
||||
}
|
||||
|
||||
return _versionString;
|
||||
}
|
||||
return _versionString;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets a {@link Class} object representing a type contained within the {@code net.minecraft.server} versioned package.
|
||||
* The class instances returned by this method are cached, such that no lookup will be done twice (unless multiple threads are accessing this method simultaneously).
|
||||
*
|
||||
* @param className The name of the class, excluding the package, within NMS.
|
||||
* @return The class instance representing the specified NMS class, or {@code null} if it could not be loaded.
|
||||
*/
|
||||
public synchronized static Class<?> getNMSClass(String className) {
|
||||
if (_loadedNMSClasses.containsKey(className)) {
|
||||
return _loadedNMSClasses.get(className);
|
||||
}
|
||||
/**
|
||||
* Gets a {@link Class} object representing a type contained within the {@code net.minecraft.server} versioned package.
|
||||
* The class instances returned by this method are cached, such that no lookup will be done twice (unless multiple threads are accessing this method simultaneously).
|
||||
*
|
||||
* @param className The name of the class, excluding the package, within NMS.
|
||||
* @return The class instance representing the specified NMS class, or {@code null} if it could not be loaded.
|
||||
*/
|
||||
public synchronized static Class<?> getNMSClass(String className) {
|
||||
if (_loadedNMSClasses.containsKey(className)) {
|
||||
return _loadedNMSClasses.get(className);
|
||||
}
|
||||
|
||||
String fullName = "net.minecraft.server." + getVersion() + className;
|
||||
Class<?> clazz;
|
||||
try {
|
||||
clazz = Class.forName(fullName);
|
||||
} catch (ClassNotFoundException e) {
|
||||
_loadedNMSClasses.put(className, null);
|
||||
throw new RuntimeException(e);
|
||||
}
|
||||
_loadedNMSClasses.put(className, clazz);
|
||||
return clazz;
|
||||
}
|
||||
String fullName = "net.minecraft.server." + getVersion() + className;
|
||||
Class<?> clazz;
|
||||
try {
|
||||
clazz = Class.forName(fullName);
|
||||
} catch (ClassNotFoundException e) {
|
||||
_loadedNMSClasses.put(className, null);
|
||||
throw new RuntimeException(e);
|
||||
}
|
||||
_loadedNMSClasses.put(className, clazz);
|
||||
return clazz;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets a {@link Class} object representing a type contained within the {@code org.bukkit.craftbukkit} versioned package.
|
||||
* The class instances returned by this method are cached, such that no lookup will be done twice (unless multiple threads are accessing this method simultaneously).
|
||||
*
|
||||
* @param className The name of the class, excluding the package, within OBC. This name may contain a subpackage name, such as {@code inventory.CraftItemStack}.
|
||||
* @return The class instance representing the specified OBC class, or {@code null} if it could not be loaded.
|
||||
*/
|
||||
public synchronized static Class<?> getOBCClass(String className) {
|
||||
if (_loadedOBCClasses.containsKey(className)) {
|
||||
return _loadedOBCClasses.get(className);
|
||||
}
|
||||
/**
|
||||
* Gets a {@link Class} object representing a type contained within the {@code org.bukkit.craftbukkit} versioned package.
|
||||
* The class instances returned by this method are cached, such that no lookup will be done twice (unless multiple threads are accessing this method simultaneously).
|
||||
*
|
||||
* @param className The name of the class, excluding the package, within OBC. This name may contain a subpackage name, such as {@code inventory.CraftItemStack}.
|
||||
* @return The class instance representing the specified OBC class, or {@code null} if it could not be loaded.
|
||||
*/
|
||||
public synchronized static Class<?> getOBCClass(String className) {
|
||||
if (_loadedOBCClasses.containsKey(className)) {
|
||||
return _loadedOBCClasses.get(className);
|
||||
}
|
||||
|
||||
String fullName = "org.bukkit.craftbukkit." + getVersion() + className;
|
||||
Class<?> clazz;
|
||||
try {
|
||||
clazz = Class.forName(fullName);
|
||||
} catch (ClassNotFoundException e) {
|
||||
_loadedOBCClasses.put(className, null);
|
||||
throw new RuntimeException(e);
|
||||
}
|
||||
_loadedOBCClasses.put(className, clazz);
|
||||
return clazz;
|
||||
}
|
||||
String fullName = "org.bukkit.craftbukkit." + getVersion() + className;
|
||||
Class<?> clazz;
|
||||
try {
|
||||
clazz = Class.forName(fullName);
|
||||
} catch (ClassNotFoundException e) {
|
||||
_loadedOBCClasses.put(className, null);
|
||||
throw new RuntimeException(e);
|
||||
}
|
||||
_loadedOBCClasses.put(className, clazz);
|
||||
return clazz;
|
||||
}
|
||||
|
||||
/**
|
||||
* Attempts to get the NMS handle of a CraftBukkit object.
|
||||
* <p>
|
||||
* The only match currently attempted by this method is a retrieval by using a parameterless {@code getHandle()} method implemented by the runtime type of the specified object.
|
||||
* </p>
|
||||
*
|
||||
* @param obj The object for which to retrieve an NMS handle.
|
||||
* @return The NMS handle of the specified object, or {@code null} if it could not be retrieved using {@code getHandle()}.
|
||||
*/
|
||||
public synchronized static Object getHandle(Object obj) throws InvocationTargetException, IllegalAccessException, IllegalArgumentException {
|
||||
return getMethod(obj.getClass(), "getHandle").invoke(obj);
|
||||
}
|
||||
/**
|
||||
* Attempts to get the NMS handle of a CraftBukkit object.
|
||||
* <p>
|
||||
* The only match currently attempted by this method is a retrieval by using a parameterless {@code getHandle()} method implemented by the runtime type of the specified object.
|
||||
* </p>
|
||||
*
|
||||
* @param obj The object for which to retrieve an NMS handle.
|
||||
* @return The NMS handle of the specified object, or {@code null} if it could not be retrieved using {@code getHandle()}.
|
||||
*/
|
||||
public synchronized static Object getHandle(Object obj) throws InvocationTargetException, IllegalAccessException, IllegalArgumentException {
|
||||
return getMethod(obj.getClass(), "getHandle").invoke(obj);
|
||||
}
|
||||
|
||||
/**
|
||||
* Retrieves a {@link Field} instance declared by the specified class with the specified name.
|
||||
* Java access modifiers are ignored during this retrieval. No guarantee is made as to whether the field
|
||||
* returned will be an instance or static field.
|
||||
* <p>
|
||||
* A global caching mechanism within this class is used to store fields. Combined with synchronization, this guarantees that
|
||||
* no field will be reflectively looked up twice.
|
||||
* </p>
|
||||
* <p>
|
||||
* If a field is deemed suitable for return, {@link Field#setAccessible(boolean) setAccessible} will be invoked with an argument of {@code true} before it is returned.
|
||||
* This ensures that callers do not have to check or worry about Java access modifiers when dealing with the returned instance.
|
||||
* </p>
|
||||
*
|
||||
* @param clazz The class which contains the field to retrieve.
|
||||
* @param name The declared name of the field in the class.
|
||||
* @return A field object with the specified name declared by the specified class.
|
||||
* @see Class#getDeclaredField(String)
|
||||
*/
|
||||
public synchronized static Field getField(Class<?> clazz, String name) {
|
||||
Map<String, Field> loaded;
|
||||
if (!_loadedFields.containsKey(clazz)) {
|
||||
loaded = new HashMap<>();
|
||||
_loadedFields.put(clazz, loaded);
|
||||
} else {
|
||||
loaded = _loadedFields.get(clazz);
|
||||
}
|
||||
if (loaded.containsKey(name)) {
|
||||
// If the field is loaded (or cached as not existing), return the relevant value, which might be null
|
||||
return loaded.get(name);
|
||||
}
|
||||
/**
|
||||
* Retrieves a {@link Field} instance declared by the specified class with the specified name.
|
||||
* Java access modifiers are ignored during this retrieval. No guarantee is made as to whether the field
|
||||
* returned will be an instance or static field.
|
||||
* <p>
|
||||
* A global caching mechanism within this class is used to store fields. Combined with synchronization, this guarantees that
|
||||
* no field will be reflectively looked up twice.
|
||||
* </p>
|
||||
* <p>
|
||||
* If a field is deemed suitable for return, {@link Field#setAccessible(boolean) setAccessible} will be invoked with an argument of {@code true} before it is returned.
|
||||
* This ensures that callers do not have to check or worry about Java access modifiers when dealing with the returned instance.
|
||||
* </p>
|
||||
*
|
||||
* @param clazz The class which contains the field to retrieve.
|
||||
* @param name The declared name of the field in the class.
|
||||
* @return A field object with the specified name declared by the specified class.
|
||||
* @see Class#getDeclaredField(String)
|
||||
*/
|
||||
public synchronized static Field getField(Class<?> clazz, String name) {
|
||||
Map<String, Field> loaded;
|
||||
if (!_loadedFields.containsKey(clazz)) {
|
||||
loaded = new HashMap<>();
|
||||
_loadedFields.put(clazz, loaded);
|
||||
} else {
|
||||
loaded = _loadedFields.get(clazz);
|
||||
}
|
||||
if (loaded.containsKey(name)) {
|
||||
// If the field is loaded (or cached as not existing), return the relevant value, which might be null
|
||||
return loaded.get(name);
|
||||
}
|
||||
try {
|
||||
Field field = clazz.getDeclaredField(name);
|
||||
field.setAccessible(true);
|
||||
@ -157,50 +157,50 @@ public final class Reflection {
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Retrieves a {@link Method} instance declared by the specified class with the specified name and argument types.
|
||||
* Java access modifiers are ignored during this retrieval. No guarantee is made as to whether the field
|
||||
* returned will be an instance or static field.
|
||||
* <p>
|
||||
* A global caching mechanism within this class is used to store method. Combined with synchronization, this guarantees that
|
||||
* no method will be reflectively looked up twice.
|
||||
* <p>
|
||||
* If a method is deemed suitable for return, {@link Method#setAccessible(boolean) setAccessible} will be invoked with an argument of {@code true} before it is returned.
|
||||
* This ensures that callers do not have to check or worry about Java access modifiers when dealing with the returned instance.
|
||||
* <p>
|
||||
* This method does <em>not</em> search superclasses of the specified type for methods with the specified signature.
|
||||
* Callers wishing this behavior should use {@link Class#getDeclaredMethod(String, Class...)}.
|
||||
*
|
||||
* @param clazz The class which contains the method to retrieve.
|
||||
* @param name The declared name of the method in the class.
|
||||
* @param args The formal argument types of the method.
|
||||
* @return A method object with the specified name declared by the specified class.
|
||||
*/
|
||||
public synchronized static Method getMethod(Class<?> clazz, String name, Class<?>... args) {
|
||||
if (!_loadedMethods.containsKey(clazz)) {
|
||||
_loadedMethods.put(clazz, new HashMap<String, Map<ArrayWrapper<Class<?>>, Method>>());
|
||||
}
|
||||
/**
|
||||
* Retrieves a {@link Method} instance declared by the specified class with the specified name and argument types.
|
||||
* Java access modifiers are ignored during this retrieval. No guarantee is made as to whether the field
|
||||
* returned will be an instance or static field.
|
||||
* <p>
|
||||
* A global caching mechanism within this class is used to store method. Combined with synchronization, this guarantees that
|
||||
* no method will be reflectively looked up twice.
|
||||
* <p>
|
||||
* If a method is deemed suitable for return, {@link Method#setAccessible(boolean) setAccessible} will be invoked with an argument of {@code true} before it is returned.
|
||||
* This ensures that callers do not have to check or worry about Java access modifiers when dealing with the returned instance.
|
||||
* <p>
|
||||
* This method does <em>not</em> search superclasses of the specified type for methods with the specified signature.
|
||||
* Callers wishing this behavior should use {@link Class#getDeclaredMethod(String, Class...)}.
|
||||
*
|
||||
* @param clazz The class which contains the method to retrieve.
|
||||
* @param name The declared name of the method in the class.
|
||||
* @param args The formal argument types of the method.
|
||||
* @return A method object with the specified name declared by the specified class.
|
||||
*/
|
||||
public synchronized static Method getMethod(Class<?> clazz, String name, Class<?>... args) {
|
||||
if (!_loadedMethods.containsKey(clazz)) {
|
||||
_loadedMethods.put(clazz, new HashMap<String, Map<ArrayWrapper<Class<?>>, Method>>());
|
||||
}
|
||||
|
||||
Map<String, Map<ArrayWrapper<Class<?>>, Method>> loadedMethodNames = _loadedMethods.get(clazz);
|
||||
if (!loadedMethodNames.containsKey(name)) {
|
||||
loadedMethodNames.put(name, new HashMap<ArrayWrapper<Class<?>>, Method>());
|
||||
}
|
||||
Map<String, Map<ArrayWrapper<Class<?>>, Method>> loadedMethodNames = _loadedMethods.get(clazz);
|
||||
if (!loadedMethodNames.containsKey(name)) {
|
||||
loadedMethodNames.put(name, new HashMap<ArrayWrapper<Class<?>>, Method>());
|
||||
}
|
||||
|
||||
Map<ArrayWrapper<Class<?>>, Method> loadedSignatures = loadedMethodNames.get(name);
|
||||
ArrayWrapper<Class<?>> wrappedArg = new ArrayWrapper<>(args);
|
||||
if (loadedSignatures.containsKey(wrappedArg)) {
|
||||
return loadedSignatures.get(wrappedArg);
|
||||
}
|
||||
Map<ArrayWrapper<Class<?>>, Method> loadedSignatures = loadedMethodNames.get(name);
|
||||
ArrayWrapper<Class<?>> wrappedArg = new ArrayWrapper<>(args);
|
||||
if (loadedSignatures.containsKey(wrappedArg)) {
|
||||
return loadedSignatures.get(wrappedArg);
|
||||
}
|
||||
|
||||
for (Method m : clazz.getMethods()) {
|
||||
if (m.getName().equals(name) && Arrays.equals(args, m.getParameterTypes())) {
|
||||
m.setAccessible(true);
|
||||
loadedSignatures.put(wrappedArg, m);
|
||||
return m;
|
||||
}
|
||||
}
|
||||
loadedSignatures.put(wrappedArg, null);
|
||||
return null;
|
||||
}
|
||||
for (Method m : clazz.getMethods()) {
|
||||
if (m.getName().equals(name) && Arrays.equals(args, m.getParameterTypes())) {
|
||||
m.setAccessible(true);
|
||||
loadedSignatures.put(wrappedArg, m);
|
||||
return m;
|
||||
}
|
||||
}
|
||||
loadedSignatures.put(wrappedArg, null);
|
||||
return null;
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -91,7 +91,7 @@ public class DebugUUID extends SubCommand {
|
||||
MainUtil.sendMessage(player, "&6Beginning UUID mode conversion");
|
||||
MainUtil.sendMessage(player, "&7 - Disconnecting players");
|
||||
for (Entry<String, PlotPlayer> entry : UUIDHandler.getPlayers().entrySet()) {
|
||||
entry.getValue().kick("PlotSquared UUID conversion has been initiated. You may reconnect when finished.");
|
||||
entry.getValue().kick("UUID conversion has been initiated. You may reconnect when finished.");
|
||||
}
|
||||
|
||||
MainUtil.sendMessage(player, "&7 - Initializing map");
|
||||
@ -155,7 +155,7 @@ public class DebugUUID extends SubCommand {
|
||||
MainUtil.sendMessage(player, "&c - Error! Attempting to repopulate");
|
||||
for (OfflinePlotPlayer op : currentUUIDWrapper.getOfflinePlayers()) {
|
||||
if (op.getLastPlayed() != 0) {
|
||||
// String name = op.getName();
|
||||
// String name = op.getPluginName();
|
||||
// StringWrapper wrap = new StringWrapper(name);
|
||||
UUID uuid = currentUUIDWrapper.getUUID(op);
|
||||
uuid2 = newWrapper.getUUID(op);
|
||||
|
@ -1,22 +1,17 @@
|
||||
package com.plotsquared.bukkit.database.plotme;
|
||||
|
||||
import com.intellectualcrafters.configuration.ConfigurationSection;
|
||||
import com.intellectualcrafters.configuration.MemorySection;
|
||||
import com.intellectualcrafters.configuration.file.FileConfiguration;
|
||||
import com.intellectualcrafters.configuration.file.YamlConfiguration;
|
||||
import com.intellectualcrafters.plot.PS;
|
||||
import com.intellectualcrafters.plot.config.Settings;
|
||||
import com.intellectualcrafters.plot.database.DBFunc;
|
||||
import com.intellectualcrafters.plot.generator.HybridGen;
|
||||
import com.intellectualcrafters.plot.object.Plot;
|
||||
import com.intellectualcrafters.plot.object.PlotArea;
|
||||
import com.intellectualcrafters.plot.object.PlotId;
|
||||
import com.intellectualcrafters.plot.util.TaskManager;
|
||||
import com.plotsquared.bukkit.generator.BukkitPlotGenerator;
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.World;
|
||||
import org.bukkit.WorldCreator;
|
||||
import org.bukkit.command.CommandException;
|
||||
|
||||
import java.io.File;
|
||||
import java.io.IOException;
|
||||
import java.nio.charset.StandardCharsets;
|
||||
@ -28,9 +23,14 @@ import java.sql.SQLException;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collections;
|
||||
import java.util.HashMap;
|
||||
import java.util.HashSet;
|
||||
import java.util.Map.Entry;
|
||||
import java.util.Set;
|
||||
import java.util.concurrent.atomic.AtomicBoolean;
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.World;
|
||||
import org.bukkit.WorldCreator;
|
||||
import org.bukkit.command.CommandException;
|
||||
|
||||
public class LikePlotMeConverter {
|
||||
|
||||
@ -50,7 +50,7 @@ public class LikePlotMeConverter {
|
||||
}
|
||||
|
||||
private void sendMessage(String message) {
|
||||
PS.debug("&3PlotMe&8->&3PlotSquared&8: &7" + message);
|
||||
PS.debug("&3PlotMe&8->&3" + PS.imp().getPluginName() + "&8: &7" + message);
|
||||
}
|
||||
|
||||
public String getPlotMePath() {
|
||||
@ -97,14 +97,42 @@ public class LikePlotMeConverter {
|
||||
return;
|
||||
}
|
||||
String content = new String(Files.readAllBytes(path), StandardCharsets.UTF_8);
|
||||
content = content.replace("PlotMe-DefaultGenerator", "PlotSquared");
|
||||
content = content.replace("PlotMe", "PlotSquared");
|
||||
content = content.replace("AthionPlots", "PlotSquared");
|
||||
content = content.replace("PlotZWorld", "PlotSquared");
|
||||
String pluginName = PS.imp().getPluginName();
|
||||
content = content.replace("PlotMe-DefaultGenerator", pluginName);
|
||||
content = content.replace("PlotMe", pluginName);
|
||||
content = content.replace("AthionPlots", pluginName);
|
||||
content = content.replace("PlotZWorld", pluginName);
|
||||
Files.write(path, content.getBytes(StandardCharsets.UTF_8));
|
||||
} catch (IOException ignored) {}
|
||||
}
|
||||
|
||||
private void copyConfig(ConfigurationSection plotmeDgYml, String world) throws IOException {
|
||||
String actualWorldName = getWorld(world);
|
||||
String plotMeWorldName = world.toLowerCase();
|
||||
Integer pathWidth = plotmeDgYml.getInt("worlds." + plotMeWorldName + ".PathWidth"); //
|
||||
PS.get().worlds.set("worlds." + world + ".road.width", pathWidth);
|
||||
int height = plotmeDgYml.getInt("worlds." + plotMeWorldName + ".RoadHeight", plotmeDgYml.getInt("worlds." + plotMeWorldName + ".GroundHeight", 64)); //
|
||||
PS.get().worlds.set("worlds." + world + ".road.height", height);
|
||||
PS.get().worlds.set("worlds." + world + ".wall.height", height);
|
||||
PS.get().worlds.set("worlds." + world + ".plot.height", height);
|
||||
int plotSize = plotmeDgYml.getInt("worlds." + plotMeWorldName + ".PlotSize", 32); //
|
||||
PS.get().worlds.set("worlds." + world + ".plot.size", plotSize);
|
||||
String wallblock = plotmeDgYml.getString("worlds." + plotMeWorldName + ".UnclaimedBorder", plotmeDgYml.getString("worlds." + plotMeWorldName + ".WallBlock", "44")); //
|
||||
PS.get().worlds.set("worlds." + world + ".wall.block", wallblock);
|
||||
String claimed = plotmeDgYml.getString("worlds." + plotMeWorldName + ".ProtectedWallBlock", "44:1"); //
|
||||
PS.get().worlds.set("worlds." + world + ".wall.block_claimed", claimed);
|
||||
String floor = plotmeDgYml.getString("worlds." + plotMeWorldName + ".PlotFloorBlock", "2"); //
|
||||
PS.get().worlds.set("worlds." + world + ".plot.floor", Collections.singletonList(floor));
|
||||
String filling = plotmeDgYml.getString("worlds." + plotMeWorldName + ".FillBlock", "3"); //
|
||||
PS.get().worlds.set("worlds." + world + ".plot.filling", Collections.singletonList(filling));
|
||||
String road = plotmeDgYml.getString("worlds." + plotMeWorldName + ".RoadMainBlock", "5");
|
||||
PS.get().worlds.set("worlds." + world + ".road.block", road);
|
||||
PS.get().worlds.set("worlds." + actualWorldName + ".road.height", height);
|
||||
PS.get().worlds.set("worlds." + actualWorldName + ".plot.height", height);
|
||||
PS.get().worlds.set("worlds." + actualWorldName + ".wall.height", height);
|
||||
PS.get().worlds.save(PS.get().worldsFile);
|
||||
}
|
||||
|
||||
public boolean run(APlotMeConnector connector) {
|
||||
try {
|
||||
String dataFolder = getPlotMePath();
|
||||
@ -130,7 +158,7 @@ public class LikePlotMeConverter {
|
||||
return false;
|
||||
}
|
||||
|
||||
sendMessage("PlotMe conversion has started. To disable this, please set 'plotme-convert.enabled' to false in the 'settings.yml'");
|
||||
sendMessage("PlotMe conversion has started. To disable this, please set 'enabled-components -> plotme-converter' to false in the 'settings.yml'");
|
||||
|
||||
mergeWorldYml(plotConfig);
|
||||
|
||||
@ -177,36 +205,14 @@ public class LikePlotMeConverter {
|
||||
if (plotmeDgFile.exists()) {
|
||||
YamlConfiguration plotmeDgYml = YamlConfiguration.loadConfiguration(plotmeDgFile);
|
||||
try {
|
||||
for (String world : plots.keySet()) {
|
||||
String actualWorldName = getWorld(world);
|
||||
String plotMeWorldName = world.toLowerCase();
|
||||
Integer pathWidth = plotmeDgYml.getInt("worlds." + plotMeWorldName + ".PathWidth"); //
|
||||
PS.get().worlds.set("worlds." + world + ".road.width", pathWidth);
|
||||
|
||||
int pathHeight = plotmeDgYml.getInt("worlds." + plotMeWorldName + ".RoadHeight", 64); //
|
||||
PS.get().worlds.set("worlds." + world + ".road.height", pathHeight);
|
||||
PS.get().worlds.set("worlds." + world + ".wall.height", pathHeight);
|
||||
PS.get().worlds.set("worlds." + world + ".plot.height", pathHeight);
|
||||
int plotSize = plotmeDgYml.getInt("worlds." + plotMeWorldName + ".PlotSize", 32); //
|
||||
PS.get().worlds.set("worlds." + world + ".plot.size", plotSize);
|
||||
String wallblock = plotmeDgYml.getString("worlds." + plotMeWorldName + ".WallBlock", "44"); //
|
||||
PS.get().worlds.set("worlds." + world + ".wall.block", wallblock);
|
||||
String floor = plotmeDgYml.getString("worlds." + plotMeWorldName + ".PlotFloorBlock", "2"); //
|
||||
PS.get().worlds.set("worlds." + world + ".plot.floor", Collections.singletonList(floor));
|
||||
String filling = plotmeDgYml.getString("worlds." + plotMeWorldName + ".FillBlock", "3"); //
|
||||
PS.get().worlds.set("worlds." + world + ".plot.filling", Collections.singletonList(filling));
|
||||
String road = plotmeDgYml.getString("worlds." + plotMeWorldName + ".RoadMainBlock", "5");
|
||||
PS.get().worlds.set("worlds." + world + ".road.block", road);
|
||||
int height = plotmeDgYml.getInt("worlds." + plotMeWorldName + ".RoadHeight"); //
|
||||
if (height == 0) {
|
||||
height = plotmeDgYml.getInt("worlds." + plotMeWorldName + ".GroundHeight", 64); //
|
||||
}
|
||||
PS.get().worlds.set("worlds." + actualWorldName + ".road.height", height);
|
||||
PS.get().worlds.set("worlds." + actualWorldName + ".plot.height", height);
|
||||
PS.get().worlds.set("worlds." + actualWorldName + ".wall.height", height);
|
||||
PS.get().worlds.save(PS.get().worldsFile);
|
||||
HashSet<String> allWorlds = new HashSet<>(plots.keySet());
|
||||
allWorlds.addAll(worlds);
|
||||
for (String world : allWorlds) {
|
||||
copyConfig(plotmeDgYml, world);
|
||||
}
|
||||
} catch (IOException ignored) {}
|
||||
} catch (IOException ignored) {
|
||||
ignored.printStackTrace();
|
||||
}
|
||||
}
|
||||
for (Entry<String, HashMap<PlotId, Plot>> entry : plots.entrySet()) {
|
||||
String world = entry.getKey();
|
||||
@ -255,7 +261,7 @@ public class LikePlotMeConverter {
|
||||
done();
|
||||
sendMessage("&aDatabase conversion is now complete!");
|
||||
PS.debug("&c - Stop the server");
|
||||
PS.debug("&c - Disable 'plotme-convert.enabled' and 'plotme-convert.cache-uuids' in the settings.yml");
|
||||
PS.debug("&c - Disable 'plotme-converter' and 'plotme-convert.cache-uuids' in the settings.yml");
|
||||
PS.debug("&c - Correct any generator settings that haven't copied to 'settings.yml' properly");
|
||||
PS.debug("&c - Start the server");
|
||||
PS.get().setPlots(DBFunc.getPlots());
|
||||
@ -288,38 +294,43 @@ public class LikePlotMeConverter {
|
||||
World world = Bukkit.getWorld(getWorld(worldName));
|
||||
if (world == null) {
|
||||
sendMessage("&cInvalid world in PlotMe configuration: " + worldName);
|
||||
continue;
|
||||
}
|
||||
String actualWorldName = world.getName();
|
||||
sendMessage("Reloading generator for world: '" + actualWorldName + "'...");
|
||||
PS.get().removePlotAreas(actualWorldName);
|
||||
if (mv) {
|
||||
// unload world with MV
|
||||
Bukkit.getServer().dispatchCommand(Bukkit.getServer().getConsoleSender(), "mv unload " + actualWorldName);
|
||||
try {
|
||||
Thread.sleep(1000);
|
||||
} catch (InterruptedException ignored) {
|
||||
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 (InterruptedException ignored) {
|
||||
Thread.currentThread().interrupt();
|
||||
}
|
||||
// load world with MW
|
||||
Bukkit.getServer().dispatchCommand(Bukkit.getServer().getConsoleSender(),
|
||||
"mw create " + actualWorldName + " plugin:PlotSquared");
|
||||
if (!Bukkit.getWorlds().isEmpty() && Bukkit.getWorlds().get(0).getName().equals(worldName)) {
|
||||
sendMessage("&cYou need to stop the server to reload this world properly");
|
||||
} else {
|
||||
// Load using Bukkit API
|
||||
// - User must set generator manually
|
||||
Bukkit.getServer().unloadWorld(world, true);
|
||||
World myWorld = WorldCreator.name(actualWorldName).generator(new BukkitPlotGenerator(new HybridGen())).createWorld();
|
||||
myWorld.save();
|
||||
PS.get().removePlotAreas(actualWorldName);
|
||||
if (mv) {
|
||||
// unload world with MV
|
||||
Bukkit.getServer().dispatchCommand(Bukkit.getServer().getConsoleSender(), "mv unload " + actualWorldName);
|
||||
try {
|
||||
Thread.sleep(1000);
|
||||
} catch (InterruptedException ignored) {
|
||||
Thread.currentThread().interrupt();
|
||||
}
|
||||
// load world with MV
|
||||
Bukkit.getServer().dispatchCommand(Bukkit.getServer().getConsoleSender(),
|
||||
"mv import " + actualWorldName + " normal -g " + PS.imp().getPluginName());
|
||||
} else if (mw) {
|
||||
// unload world with MW
|
||||
Bukkit.getServer().dispatchCommand(Bukkit.getServer().getConsoleSender(), "mw unload " + actualWorldName);
|
||||
try {
|
||||
Thread.sleep(1000);
|
||||
} catch (InterruptedException ignored) {
|
||||
Thread.currentThread().interrupt();
|
||||
}
|
||||
// load world with MW
|
||||
Bukkit.getServer().dispatchCommand(Bukkit.getServer().getConsoleSender(),
|
||||
"mw create " + actualWorldName + " plugin:" + PS.imp().getPluginName());
|
||||
} else {
|
||||
// Load using Bukkit API
|
||||
// - User must set generator manually
|
||||
Bukkit.getServer().unloadWorld(world, true);
|
||||
World myWorld = WorldCreator.name(actualWorldName).generator(new BukkitPlotGenerator(PS.get().IMP.getDefaultGenerator())).createWorld();
|
||||
myWorld.save();
|
||||
}
|
||||
}
|
||||
}
|
||||
} catch (CommandException e) {
|
||||
@ -329,7 +340,7 @@ public class LikePlotMeConverter {
|
||||
done();
|
||||
sendMessage("&aDatabase conversion is now complete!");
|
||||
PS.debug("&c - Stop the server");
|
||||
PS.debug("&c - Disable 'plotme-convert.enabled' and 'plotme-convert.cache-uuids' in the settings.yml");
|
||||
PS.debug("&c - Disable 'plotme-converter' and 'plotme-convert.cache-uuids' in the settings.yml");
|
||||
PS.debug("&c - Correct any generator settings that haven't copied to 'settings.yml' properly");
|
||||
PS.debug("&c - Start the server");
|
||||
} else {
|
||||
|
@ -67,7 +67,7 @@ public class PlotMeConnector_017 extends APlotMeConnector {
|
||||
return null;
|
||||
}
|
||||
boolean checkUUID = DBFunc.hasColumn(resultSet, "ownerID");
|
||||
boolean merge = !this.plugin.equals("plotme") && Settings.Enabled_Components.PLOTME_CONVERTER;
|
||||
boolean merge = !"plotme".equals(this.plugin) && Settings.Enabled_Components.PLOTME_CONVERTER;
|
||||
while (resultSet.next()) {
|
||||
int key = resultSet.getInt("plot_id");
|
||||
PlotId id = new PlotId(resultSet.getInt("plotX"), resultSet.getInt("plotZ"));
|
||||
|
@ -2,7 +2,6 @@ package com.plotsquared.bukkit.generator;
|
||||
|
||||
import com.intellectualcrafters.plot.PS;
|
||||
import com.intellectualcrafters.plot.generator.GeneratorWrapper;
|
||||
import com.intellectualcrafters.plot.generator.HybridGen;
|
||||
import com.intellectualcrafters.plot.generator.IndependentPlotGenerator;
|
||||
import com.intellectualcrafters.plot.object.ChunkLoc;
|
||||
import com.intellectualcrafters.plot.object.ChunkWrapper;
|
||||
@ -37,7 +36,7 @@ public class BukkitPlotGenerator extends ChunkGenerator implements GeneratorWrap
|
||||
private final GenChunk chunkSetter;
|
||||
private final PseudoRandom random = new PseudoRandom();
|
||||
private final IndependentPlotGenerator plotGenerator;
|
||||
private final List<BlockPopulator> populators = new ArrayList<>();
|
||||
private List<BlockPopulator> populators;
|
||||
private final ChunkGenerator platformGenerator;
|
||||
private final boolean full;
|
||||
private final HashMap<ChunkLoc, byte[][]> dataMap = new HashMap<>();
|
||||
@ -49,6 +48,7 @@ public class BukkitPlotGenerator extends ChunkGenerator implements GeneratorWrap
|
||||
}
|
||||
this.plotGenerator = generator;
|
||||
this.platformGenerator = this;
|
||||
populators = new ArrayList<>();
|
||||
this.populators.add(new BlockPopulator() {
|
||||
|
||||
private LocalBlockQueue queue;
|
||||
@ -119,7 +119,7 @@ public class BukkitPlotGenerator extends ChunkGenerator implements GeneratorWrap
|
||||
|
||||
@Override
|
||||
public PlotManager getNewPlotManager() {
|
||||
return new HybridGen().getNewPlotManager();
|
||||
return PS.get().IMP.getDefaultGenerator().getNewPlotManager();
|
||||
}
|
||||
|
||||
@Override
|
||||
@ -129,7 +129,7 @@ public class BukkitPlotGenerator extends ChunkGenerator implements GeneratorWrap
|
||||
|
||||
@Override
|
||||
public PlotArea getNewPlotArea(String world, String id, PlotId min, PlotId max) {
|
||||
return new HybridGen().getNewPlotArea(world, id, min, max);
|
||||
return PS.get().IMP.getDefaultGenerator().getNewPlotArea(world, id, min, max);
|
||||
}
|
||||
|
||||
@Override
|
||||
@ -188,9 +188,6 @@ public class BukkitPlotGenerator extends ChunkGenerator implements GeneratorWrap
|
||||
}
|
||||
};
|
||||
this.chunkSetter = new GenChunk(null, new ChunkWrapper(world, 0, 0));
|
||||
if (cg != null) {
|
||||
this.populators.addAll(cg.getDefaultPopulators(BukkitUtil.getWorld(world)));
|
||||
}
|
||||
MainUtil.initCache();
|
||||
}
|
||||
|
||||
@ -246,6 +243,9 @@ public class BukkitPlotGenerator extends ChunkGenerator implements GeneratorWrap
|
||||
}
|
||||
ArrayList<BlockPopulator> toAdd = new ArrayList<>();
|
||||
List<BlockPopulator> existing = world.getPopulators();
|
||||
if (populators == null && platformGenerator != null) {
|
||||
populators = new ArrayList<>(platformGenerator.getDefaultPopulators(world));
|
||||
}
|
||||
for (BlockPopulator populator : this.populators) {
|
||||
if (!existing.contains(populator)) {
|
||||
toAdd.add(populator);
|
||||
|
@ -1,6 +1,7 @@
|
||||
package com.plotsquared.bukkit.listeners;
|
||||
|
||||
import com.intellectualcrafters.plot.PS;
|
||||
import com.intellectualcrafters.plot.config.C;
|
||||
import com.intellectualcrafters.plot.config.Settings;
|
||||
import com.intellectualcrafters.plot.object.Location;
|
||||
import com.intellectualcrafters.plot.object.Plot;
|
||||
@ -46,7 +47,7 @@ public class ChunkListener implements Listener {
|
||||
this.mustSave = classChunk.getField("mustSave");
|
||||
this.methodGetHandleChunk = classCraftChunk.getMethod("getHandle");
|
||||
} catch (Throwable ignored) {
|
||||
PS.debug("PlotSquared/Server not compatible for chunk processor trim/gc");
|
||||
PS.debug(PS.imp().getPluginName() + "/Server not compatible for chunk processor trim/gc");
|
||||
Settings.Chunk_Processor.AUTO_TRIM = false;
|
||||
}
|
||||
}
|
||||
@ -228,7 +229,7 @@ public class ChunkListener implements Listener {
|
||||
if (!chunk.isLoaded()) {
|
||||
Bukkit.getScheduler().cancelTask(TaskManager.tasks.get(currentIndex));
|
||||
TaskManager.tasks.remove(currentIndex);
|
||||
PS.debug("[PlotSquared] &aSuccessfully processed and unloaded chunk!");
|
||||
PS.debug(C.PREFIX.s() + "&aSuccessfully processed and unloaded chunk!");
|
||||
chunk.unload(true, true);
|
||||
return;
|
||||
}
|
||||
@ -236,7 +237,7 @@ public class ChunkListener implements Listener {
|
||||
if (tiles.length == 0) {
|
||||
Bukkit.getScheduler().cancelTask(TaskManager.tasks.get(currentIndex));
|
||||
TaskManager.tasks.remove(currentIndex);
|
||||
PS.debug("[PlotSquared] &aSuccessfully processed and unloaded chunk!");
|
||||
PS.debug(C.PREFIX.s() + "&aSuccessfully processed and unloaded chunk!");
|
||||
chunk.unload(true, true);
|
||||
return;
|
||||
}
|
||||
@ -246,7 +247,7 @@ public class ChunkListener implements Listener {
|
||||
if (i >= tiles.length) {
|
||||
Bukkit.getScheduler().cancelTask(TaskManager.tasks.get(currentIndex));
|
||||
TaskManager.tasks.remove(currentIndex);
|
||||
PS.debug("[PlotSquared] &aSuccessfully processed and unloaded chunk!");
|
||||
PS.debug(C.PREFIX.s() + "&aSuccessfully processed and unloaded chunk!");
|
||||
chunk.unload(true, true);
|
||||
return;
|
||||
}
|
||||
@ -270,11 +271,11 @@ public class ChunkListener implements Listener {
|
||||
ent.remove();
|
||||
}
|
||||
}
|
||||
PS.debug("[PlotSquared] &a detected unsafe chunk and processed: " + (chunk.getX() << 4) + "," + (chunk.getX() << 4));
|
||||
PS.debug(C.PREFIX.s() + "&a detected unsafe chunk and processed: " + (chunk.getX() << 4) + "," + (chunk.getX() << 4));
|
||||
}
|
||||
if (tiles.length > Settings.Chunk_Processor.MAX_TILES) {
|
||||
if (unload) {
|
||||
PS.debug("[PlotSquared] &c detected unsafe chunk: " + (chunk.getX() << 4) + "," + (chunk.getX() << 4));
|
||||
PS.debug(C.PREFIX.s() + "&c detected unsafe chunk: " + (chunk.getX() << 4) + "," + (chunk.getX() << 4));
|
||||
cleanChunk(chunk);
|
||||
return true;
|
||||
}
|
||||
|
@ -22,6 +22,9 @@ public class EntitySpawnListener implements Listener {
|
||||
return;
|
||||
}
|
||||
Plot plot = area.getOwnedPlotAbs(location);
|
||||
if (plot == null) {
|
||||
return;
|
||||
}
|
||||
if (Settings.Done.RESTRICT_BUILDING && plot.hasFlag(Flags.DONE)) {
|
||||
event.setCancelled(true);
|
||||
}
|
||||
|
@ -20,12 +20,12 @@ import com.intellectualcrafters.plot.util.MainUtil;
|
||||
import com.intellectualcrafters.plot.util.MathMan;
|
||||
import com.intellectualcrafters.plot.util.Permissions;
|
||||
import com.intellectualcrafters.plot.util.RegExUtil;
|
||||
import com.intellectualcrafters.plot.util.StringMan;
|
||||
import com.intellectualcrafters.plot.util.TaskManager;
|
||||
import com.intellectualcrafters.plot.util.UUIDHandler;
|
||||
import com.plotsquared.bukkit.object.BukkitLazyBlock;
|
||||
import com.plotsquared.bukkit.object.BukkitPlayer;
|
||||
import com.plotsquared.bukkit.util.BukkitUtil;
|
||||
import com.plotsquared.bukkit.util.BukkitVersion;
|
||||
import com.plotsquared.listener.PlayerBlockEventType;
|
||||
import com.plotsquared.listener.PlotListener;
|
||||
import org.bukkit.Bukkit;
|
||||
@ -55,6 +55,7 @@ import org.bukkit.entity.TNTPrimed;
|
||||
import org.bukkit.entity.Tameable;
|
||||
import org.bukkit.entity.ThrownPotion;
|
||||
import org.bukkit.entity.Vehicle;
|
||||
import org.bukkit.entity.Villager;
|
||||
import org.bukkit.event.EventHandler;
|
||||
import org.bukkit.event.EventPriority;
|
||||
import org.bukkit.event.Listener;
|
||||
@ -64,6 +65,7 @@ import org.bukkit.event.block.BlockBurnEvent;
|
||||
import org.bukkit.event.block.BlockDamageEvent;
|
||||
import org.bukkit.event.block.BlockDispenseEvent;
|
||||
import org.bukkit.event.block.BlockFadeEvent;
|
||||
import org.bukkit.event.block.BlockFormEvent;
|
||||
import org.bukkit.event.block.BlockFromToEvent;
|
||||
import org.bukkit.event.block.BlockGrowEvent;
|
||||
import org.bukkit.event.block.BlockIgniteEvent;
|
||||
@ -113,8 +115,9 @@ import org.bukkit.projectiles.BlockProjectileSource;
|
||||
import org.bukkit.projectiles.ProjectileSource;
|
||||
import org.bukkit.util.Vector;
|
||||
|
||||
import java.lang.reflect.Constructor;
|
||||
import java.lang.reflect.InvocationTargetException;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
import java.util.HashSet;
|
||||
import java.util.Iterator;
|
||||
import java.util.List;
|
||||
@ -161,6 +164,7 @@ public class PlayerEvents extends PlotListener implements Listener {
|
||||
public void onRedstoneEvent(BlockRedstoneEvent event) {
|
||||
Block block = event.getBlock();
|
||||
switch (block.getType()) {
|
||||
case OBSERVER:
|
||||
case REDSTONE_LAMP_OFF:
|
||||
case REDSTONE_WIRE:
|
||||
case REDSTONE_LAMP_ON:
|
||||
@ -195,7 +199,7 @@ public class PlayerEvents extends PlotListener implements Listener {
|
||||
if (area == null) {
|
||||
return;
|
||||
}
|
||||
Plot plot = area.getOwnedPlotAbs(loc);
|
||||
Plot plot = area.getOwnedPlot(loc);
|
||||
if (plot == null) {
|
||||
return;
|
||||
}
|
||||
@ -204,8 +208,19 @@ public class PlayerEvents extends PlotListener implements Listener {
|
||||
return;
|
||||
}
|
||||
if (Settings.Redstone.DISABLE_OFFLINE) {
|
||||
if (UUIDHandler.getPlayer(plot.owner) == null) {
|
||||
boolean disable = true;
|
||||
boolean disable;
|
||||
if (plot.isMerged()) {
|
||||
disable = true;
|
||||
for (UUID owner : plot.getOwners()) {
|
||||
if (UUIDHandler.getPlayer(owner) != null) {
|
||||
disable = false;
|
||||
break;
|
||||
}
|
||||
}
|
||||
} else {
|
||||
disable = UUIDHandler.getPlayer(plot.owner) == null;
|
||||
}
|
||||
if (disable) {
|
||||
for (UUID trusted : plot.getTrusted()) {
|
||||
if (UUIDHandler.getPlayer(trusted) != null) {
|
||||
disable = false;
|
||||
@ -305,7 +320,7 @@ public class PlayerEvents extends PlotListener implements Listener {
|
||||
if (area == null) {
|
||||
return true;
|
||||
}
|
||||
Plot plot = area.getPlotAbs(loc);
|
||||
Plot plot = area.getPlot(loc);
|
||||
ProjectileSource shooter = entity.getShooter();
|
||||
if (shooter instanceof Player) {
|
||||
PlotPlayer pp = BukkitUtil.getPlayer((Player) shooter);
|
||||
@ -347,20 +362,6 @@ public class PlayerEvents extends PlotListener implements Listener {
|
||||
if (msg.isEmpty()) {
|
||||
return;
|
||||
}
|
||||
String[] split = msg.split(" ");
|
||||
PluginCommand cmd = Bukkit.getServer().getPluginCommand(split[0]);
|
||||
if (cmd == null) {
|
||||
if (split[0].equals("plotme") || split[0].equals("ap")) {
|
||||
Player player = event.getPlayer();
|
||||
if (Settings.PlotMe.ALIAS) {
|
||||
player.performCommand("plots " + StringMan.join(Arrays.copyOfRange(split, 1, split.length), " "));
|
||||
} else {
|
||||
MainUtil.sendMessage(BukkitUtil.getPlayer(player), C.NOT_USING_PLOTME);
|
||||
}
|
||||
event.setCancelled(true);
|
||||
return;
|
||||
}
|
||||
}
|
||||
Player player = event.getPlayer();
|
||||
PlotPlayer pp = BukkitUtil.getPlayer(player);
|
||||
Plot plot = pp.getCurrentPlot();
|
||||
@ -468,6 +469,16 @@ public class PlayerEvents extends PlotListener implements Listener {
|
||||
EventUtil.manager.doRespawnTask(pp);
|
||||
}
|
||||
|
||||
@EventHandler(priority = EventPriority.HIGHEST, ignoreCancelled = true)
|
||||
public void onTeleport(PlayerTeleportEvent event) {
|
||||
if (event.getTo() == null || event.getFrom() == null) {
|
||||
BukkitUtil.getPlayer(event.getPlayer()).deleteMeta("location");
|
||||
BukkitUtil.getPlayer(event.getPlayer()).deleteMeta("lastplot");
|
||||
return;
|
||||
}
|
||||
playerMove(event);
|
||||
}
|
||||
|
||||
@EventHandler(priority = EventPriority.HIGHEST, ignoreCancelled = true)
|
||||
public void playerMove(PlayerMoveEvent event) {
|
||||
org.bukkit.Location from = event.getFrom();
|
||||
@ -489,35 +500,45 @@ public class PlayerEvents extends PlotListener implements Listener {
|
||||
Plot now = area.getPlot(loc);
|
||||
Plot lastPlot = pp.getMeta("lastplot");
|
||||
if (now == null) {
|
||||
if (lastPlot != null && !plotExit(pp, lastPlot)) {
|
||||
if (lastPlot != null && !plotExit(pp, lastPlot) && this.tmpTeleport) {
|
||||
MainUtil.sendMessage(pp, C.NO_PERMISSION_EVENT, C.PERMISSION_ADMIN_EXIT_DENIED);
|
||||
this.tmpTeleport = false;
|
||||
if (lastPlot.equals(BukkitUtil.getLocation(from).getPlot())) {
|
||||
player.teleport(from);
|
||||
} else {
|
||||
player.teleport(player.getWorld().getSpawnLocation());
|
||||
}
|
||||
this.tmpTeleport = true;
|
||||
event.setCancelled(true);
|
||||
return;
|
||||
}
|
||||
} else if (now.equals(lastPlot)) {
|
||||
ForceFieldListener.handleForcefield(player, pp, now);
|
||||
return;
|
||||
} else if (!plotEntry(pp, now)) {
|
||||
} else if (!plotEntry(pp, now) && this.tmpTeleport) {
|
||||
MainUtil.sendMessage(pp, C.NO_PERMISSION_EVENT, C.PERMISSION_ADMIN_ENTRY_DENIED);
|
||||
player.teleport(from);
|
||||
event.setCancelled(true);
|
||||
this.tmpTeleport = false;
|
||||
to.setX(from.getBlockX());
|
||||
to.setY(from.getBlockY());
|
||||
to.setZ(from.getBlockZ());
|
||||
player.teleport(event.getTo());
|
||||
this.tmpTeleport = true;
|
||||
return;
|
||||
}
|
||||
Integer border = area.getBorder();
|
||||
if (x2 > border) {
|
||||
to.setX(border - 4);
|
||||
this.tmpTeleport = false;
|
||||
player.teleport(event.getTo());
|
||||
this.tmpTeleport = true;
|
||||
MainUtil.sendMessage(pp, C.BORDER);
|
||||
return;
|
||||
}
|
||||
if (x2 < -border) {
|
||||
to.setX(-border + 4);
|
||||
this.tmpTeleport = false;
|
||||
player.teleport(event.getTo());
|
||||
this.tmpTeleport = true;
|
||||
MainUtil.sendMessage(pp, C.BORDER);
|
||||
return;
|
||||
}
|
||||
@ -540,33 +561,44 @@ public class PlayerEvents extends PlotListener implements Listener {
|
||||
Plot now = area.getPlot(loc);
|
||||
Plot lastPlot = pp.getMeta("lastplot");
|
||||
if (now == null) {
|
||||
if (lastPlot != null && !plotExit(pp, lastPlot)) {
|
||||
if (lastPlot != null && !plotExit(pp, lastPlot) && this.tmpTeleport) {
|
||||
MainUtil.sendMessage(pp, C.NO_PERMISSION_EVENT, C.PERMISSION_ADMIN_EXIT_DENIED);
|
||||
this.tmpTeleport = false;
|
||||
if (lastPlot.equals(BukkitUtil.getLocation(from).getPlot())) {
|
||||
player.teleport(from);
|
||||
} else {
|
||||
player.teleport(player.getWorld().getSpawnLocation());
|
||||
}
|
||||
this.tmpTeleport = true;
|
||||
event.setCancelled(true);
|
||||
return;
|
||||
}
|
||||
} else if (now.equals(lastPlot)) {
|
||||
ForceFieldListener.handleForcefield(player, pp, now);
|
||||
return;
|
||||
} else if (!plotEntry(pp, now)) {
|
||||
} else if (!plotEntry(pp, now) && this.tmpTeleport) {
|
||||
MainUtil.sendMessage(pp, C.NO_PERMISSION_EVENT, C.PERMISSION_ADMIN_ENTRY_DENIED);
|
||||
this.tmpTeleport = false;
|
||||
player.teleport(from);
|
||||
event.setCancelled(true);
|
||||
to.setX(from.getBlockX());
|
||||
to.setY(from.getBlockY());
|
||||
to.setZ(from.getBlockZ());
|
||||
player.teleport(event.getTo());
|
||||
this.tmpTeleport = true;
|
||||
return;
|
||||
}
|
||||
Integer border = area.getBorder();
|
||||
if (z2 > border) {
|
||||
to.setZ(border - 4);
|
||||
this.tmpTeleport = false;
|
||||
player.teleport(event.getTo());
|
||||
this.tmpTeleport = true;
|
||||
MainUtil.sendMessage(pp, C.BORDER);
|
||||
} else if (z2 < -border) {
|
||||
to.setZ(-border + 4);
|
||||
this.tmpTeleport = false;
|
||||
player.teleport(event.getTo());
|
||||
this.tmpTeleport = true;
|
||||
MainUtil.sendMessage(pp, C.BORDER);
|
||||
}
|
||||
}
|
||||
@ -577,7 +609,7 @@ public class PlayerEvents extends PlotListener implements Listener {
|
||||
PlotPlayer plotPlayer = BukkitUtil.getPlayer(event.getPlayer());
|
||||
Location location = plotPlayer.getLocation();
|
||||
PlotArea area = location.getPlotArea();
|
||||
if (area == null || (!area.PLOT_CHAT && !plotPlayer.getAttribute("chat"))) {
|
||||
if (area == null || (area.PLOT_CHAT == plotPlayer.getAttribute("chat"))) {
|
||||
return;
|
||||
}
|
||||
Plot plot = area.getPlot(location);
|
||||
@ -609,6 +641,7 @@ public class PlayerEvents extends PlotListener implements Listener {
|
||||
for (Player receiver : recipients) {
|
||||
receiver.sendMessage(full);
|
||||
}
|
||||
PS.debug(full);
|
||||
}
|
||||
|
||||
@EventHandler(priority = EventPriority.LOWEST)
|
||||
@ -619,7 +652,7 @@ public class PlayerEvents extends PlotListener implements Listener {
|
||||
if (area == null) {
|
||||
return;
|
||||
}
|
||||
Plot plot = area.getPlotAbs(location);
|
||||
Plot plot = area.getPlot(location);
|
||||
if (plot != null) {
|
||||
PlotPlayer plotPlayer = BukkitUtil.getPlayer(player);
|
||||
if (event.getBlock().getY() == 0) {
|
||||
@ -806,6 +839,27 @@ public class PlayerEvents extends PlotListener implements Listener {
|
||||
}
|
||||
}
|
||||
|
||||
@EventHandler(priority = EventPriority.HIGHEST, ignoreCancelled = true)
|
||||
public void onBlockSpread(BlockFormEvent event) {
|
||||
Block block = event.getBlock();
|
||||
Location location = BukkitUtil.getLocation(block.getLocation());
|
||||
if (location.isPlotRoad()) {
|
||||
event.setCancelled(true);
|
||||
return;
|
||||
}
|
||||
PlotArea area = location.getPlotArea();
|
||||
if (area == null) {
|
||||
return;
|
||||
}
|
||||
Plot plot = area.getOwnedPlot(location);
|
||||
if (plot == null) {
|
||||
return;
|
||||
}
|
||||
if (Flags.SNOW_FORM.isFalse(plot)) {
|
||||
event.setCancelled(true);
|
||||
}
|
||||
}
|
||||
|
||||
@EventHandler(priority = EventPriority.HIGHEST, ignoreCancelled = true)
|
||||
public void onBlockDamage(BlockDamageEvent event) {
|
||||
Player player = event.getPlayer();
|
||||
@ -820,7 +874,7 @@ public class PlayerEvents extends PlotListener implements Listener {
|
||||
if (area == null) {
|
||||
return;
|
||||
}
|
||||
Plot plot = area.getPlotAbs(location);
|
||||
Plot plot = area.getPlot(location);
|
||||
if (plot != null) {
|
||||
if (location.getY() == 0) {
|
||||
event.setCancelled(true);
|
||||
@ -1080,7 +1134,7 @@ public class PlayerEvents extends PlotListener implements Listener {
|
||||
}
|
||||
}
|
||||
}
|
||||
Plot origin = area.getPlotAbs(location);
|
||||
Plot origin = area.getPlot(location);
|
||||
if (origin == null) {
|
||||
event.setCancelled(true);
|
||||
return;
|
||||
@ -1174,6 +1228,25 @@ public class PlayerEvents extends PlotListener implements Listener {
|
||||
case NOTE_BLOCK:
|
||||
case JUKEBOX:
|
||||
case WORKBENCH:
|
||||
case SILVER_SHULKER_BOX:
|
||||
case BLACK_SHULKER_BOX:
|
||||
case BLUE_SHULKER_BOX:
|
||||
case RED_SHULKER_BOX:
|
||||
case PINK_SHULKER_BOX:
|
||||
case ORANGE_SHULKER_BOX:
|
||||
case WHITE_SHULKER_BOX:
|
||||
case YELLOW_SHULKER_BOX:
|
||||
case BROWN_SHULKER_BOX:
|
||||
case CYAN_SHULKER_BOX:
|
||||
case GREEN_SHULKER_BOX:
|
||||
case PURPLE_SHULKER_BOX:
|
||||
case GRAY_SHULKER_BOX:
|
||||
case LIME_SHULKER_BOX:
|
||||
case LIGHT_BLUE_SHULKER_BOX:
|
||||
case MAGENTA_SHULKER_BOX:
|
||||
case COMMAND_REPEATING:
|
||||
case COMMAND_CHAIN:
|
||||
|
||||
eventType = PlayerBlockEventType.INTERACT_BLOCK;
|
||||
break;
|
||||
case DRAGON_EGG:
|
||||
@ -1192,7 +1265,7 @@ public class PlayerEvents extends PlotListener implements Listener {
|
||||
}
|
||||
Material type = (hand == null) ? null : hand.getType();
|
||||
int id = (type == null) ? 0 : type.getId();
|
||||
if (id == 0) {
|
||||
if (type == Material.AIR) {
|
||||
eventType = PlayerBlockEventType.INTERACT_BLOCK;
|
||||
break;
|
||||
}
|
||||
@ -1209,18 +1282,15 @@ public class PlayerEvents extends PlotListener implements Listener {
|
||||
case MONSTER_EGGS:
|
||||
eventType = PlayerBlockEventType.SPAWN_MOB;
|
||||
break;
|
||||
|
||||
case ARMOR_STAND:
|
||||
location = BukkitUtil.getLocation(block.getRelative(event.getBlockFace()).getLocation());
|
||||
eventType = PlayerBlockEventType.PLACE_MISC;
|
||||
break;
|
||||
|
||||
case WRITTEN_BOOK:
|
||||
case BOOK_AND_QUILL:
|
||||
case BOOK:
|
||||
eventType = PlayerBlockEventType.READ;
|
||||
break;
|
||||
|
||||
case APPLE:
|
||||
case BAKED_POTATO:
|
||||
case MUSHROOM_SOUP:
|
||||
@ -1461,6 +1531,7 @@ public class PlayerEvents extends PlotListener implements Listener {
|
||||
switch (entity.getType()) {
|
||||
case PLAYER:
|
||||
return false;
|
||||
case LLAMA_SPIT:
|
||||
case SMALL_FIREBALL:
|
||||
case FIREBALL:
|
||||
case DROPPED_ITEM:
|
||||
@ -1490,6 +1561,7 @@ public class PlayerEvents extends PlotListener implements Listener {
|
||||
case AREA_EFFECT_CLOUD:
|
||||
case LIGHTNING:
|
||||
case WITHER_SKULL:
|
||||
case EVOKER_FANGS:
|
||||
case UNKNOWN:
|
||||
// non moving / unmovable
|
||||
return checkEntity(plot, Flags.ENTITY_CAP);
|
||||
@ -1522,6 +1594,11 @@ public class PlayerEvents extends PlotListener implements Listener {
|
||||
case SNOWMAN:
|
||||
case BAT:
|
||||
case HORSE:
|
||||
case DONKEY:
|
||||
case LLAMA:
|
||||
case MULE:
|
||||
case ZOMBIE_HORSE:
|
||||
case SKELETON_HORSE:
|
||||
// animal
|
||||
return checkEntity(plot, Flags.ENTITY_CAP, Flags.MOB_CAP, Flags.ANIMAL_CAP);
|
||||
case BLAZE:
|
||||
@ -1543,6 +1620,14 @@ public class PlayerEvents extends PlotListener implements Listener {
|
||||
case WITHER:
|
||||
case ZOMBIE:
|
||||
case SHULKER:
|
||||
case HUSK:
|
||||
case STRAY:
|
||||
case ELDER_GUARDIAN:
|
||||
case WITHER_SKELETON:
|
||||
case VINDICATOR:
|
||||
case EVOKER:
|
||||
case VEX:
|
||||
case ZOMBIE_VILLAGER:
|
||||
// monster
|
||||
return checkEntity(plot, Flags.ENTITY_CAP, Flags.MOB_CAP, Flags.HOSTILE_CAP);
|
||||
default:
|
||||
@ -1669,159 +1754,6 @@ public class PlayerEvents extends PlotListener implements Listener {
|
||||
}
|
||||
}
|
||||
|
||||
@EventHandler(priority = EventPriority.HIGHEST, ignoreCancelled = true)
|
||||
public void onTeleport(PlayerTeleportEvent event) {
|
||||
if (event.getTo() == null || event.getFrom() == null) {
|
||||
BukkitUtil.getPlayer(event.getPlayer()).deleteMeta("location");
|
||||
BukkitUtil.getPlayer(event.getPlayer()).deleteMeta("lastplot");
|
||||
return;
|
||||
}
|
||||
org.bukkit.Location from = event.getFrom();
|
||||
org.bukkit.Location to = event.getTo();
|
||||
int x2;
|
||||
if (MathMan.roundInt(from.getX()) != (x2 = MathMan.roundInt(to.getX()))) {
|
||||
Player player = event.getPlayer();
|
||||
PlotPlayer pp = BukkitUtil.getPlayer(player);
|
||||
Location loc = BukkitUtil.getLocation(to);
|
||||
pp.setMeta("location", loc);
|
||||
PlotArea area = loc.getPlotArea();
|
||||
if (area == null) {
|
||||
return;
|
||||
}
|
||||
Plot now = area.getPlot(loc);
|
||||
Plot lastPlot = pp.getMeta("lastplot");
|
||||
if (now == null) {
|
||||
if (lastPlot != null && !plotExit(pp, lastPlot) && this.tmpTeleport) {
|
||||
MainUtil.sendMessage(pp, C.NO_PERMISSION_EVENT, C.PERMISSION_ADMIN_EXIT_DENIED);
|
||||
if (lastPlot.equals(area.getPlot(BukkitUtil.getLocation(from)))) {
|
||||
this.tmpTeleport = false;
|
||||
player.teleport(from);
|
||||
this.tmpTeleport = true;
|
||||
} else {
|
||||
Location spawn = BukkitUtil.getLocation(player.getWorld().getSpawnLocation());
|
||||
if (spawn.getEuclideanDistanceSquared(pp.getLocation()) > 2) {
|
||||
this.tmpTeleport = false;
|
||||
player.teleport(player.getWorld().getSpawnLocation());
|
||||
this.tmpTeleport = true;
|
||||
}
|
||||
}
|
||||
event.setCancelled(true);
|
||||
return;
|
||||
}
|
||||
} else if (lastPlot != null && now.equals(lastPlot)) {
|
||||
if (!Flags.DENY_TELEPORT.allowsTeleport(pp, lastPlot)) {
|
||||
event.setTo(BukkitUtil.getLocation(lastPlot.getSide()));
|
||||
}
|
||||
return;
|
||||
} else if (!plotEntry(pp, now) && this.tmpTeleport) {
|
||||
MainUtil.sendMessage(pp, C.NO_PERMISSION_EVENT, C.PERMISSION_ADMIN_ENTRY_DENIED);
|
||||
if (!now.equals(area.getPlot(BukkitUtil.getLocation(from)))) {
|
||||
this.tmpTeleport = false;
|
||||
player.teleport(from);
|
||||
this.tmpTeleport = true;
|
||||
} else {
|
||||
Location spawn = BukkitUtil.getLocation(player.getWorld().getSpawnLocation());
|
||||
if (spawn.getEuclideanDistanceSquared(pp.getLocation()) > 2) {
|
||||
this.tmpTeleport = false;
|
||||
player.teleport(player.getWorld().getSpawnLocation());
|
||||
this.tmpTeleport = true;
|
||||
}
|
||||
}
|
||||
event.setCancelled(true);
|
||||
return;
|
||||
}
|
||||
Integer border = area.getBorder();
|
||||
if (this.tmpTeleport) {
|
||||
if (x2 > border) {
|
||||
to.setX(border - 4);
|
||||
this.tmpTeleport = false;
|
||||
player.teleport(event.getTo());
|
||||
this.tmpTeleport = true;
|
||||
MainUtil.sendMessage(pp, C.BORDER);
|
||||
return;
|
||||
} else if (x2 < -border) {
|
||||
to.setX(-border + 4);
|
||||
this.tmpTeleport = false;
|
||||
player.teleport(event.getTo());
|
||||
this.tmpTeleport = true;
|
||||
MainUtil.sendMessage(pp, C.BORDER);
|
||||
return;
|
||||
}
|
||||
}
|
||||
return;
|
||||
}
|
||||
int z2;
|
||||
if (MathMan.roundInt(from.getZ()) != (z2 = MathMan.roundInt(to.getZ()))) {
|
||||
Player player = event.getPlayer();
|
||||
PlotPlayer pp = BukkitUtil.getPlayer(player);
|
||||
// Set last location
|
||||
Location loc = BukkitUtil.getLocation(to);
|
||||
pp.setMeta("location", loc);
|
||||
PlotArea area = loc.getPlotArea();
|
||||
if (area == null) {
|
||||
return;
|
||||
}
|
||||
Plot now = area.getPlot(loc);
|
||||
Plot lastPlot = pp.getMeta("lastplot");
|
||||
if (now == null) {
|
||||
if (lastPlot != null && !plotExit(pp, lastPlot) && this.tmpTeleport) {
|
||||
MainUtil.sendMessage(pp, C.NO_PERMISSION_EVENT, C.PERMISSION_ADMIN_EXIT_DENIED);
|
||||
if (lastPlot.equals(area.getPlot(BukkitUtil.getLocation(from)))) {
|
||||
this.tmpTeleport = false;
|
||||
player.teleport(from);
|
||||
this.tmpTeleport = true;
|
||||
} else {
|
||||
Location spawn = BukkitUtil.getLocation(player.getWorld().getSpawnLocation());
|
||||
if (spawn.getEuclideanDistanceSquared(pp.getLocation()) > 2) {
|
||||
this.tmpTeleport = false;
|
||||
player.teleport(player.getWorld().getSpawnLocation());
|
||||
this.tmpTeleport = true;
|
||||
}
|
||||
}
|
||||
event.setCancelled(true);
|
||||
return;
|
||||
}
|
||||
} else if (lastPlot != null && now.equals(lastPlot)) {
|
||||
if (!Flags.DENY_TELEPORT.allowsTeleport(pp, lastPlot)) {
|
||||
event.setTo(BukkitUtil.getLocation(lastPlot.getSide()));
|
||||
}
|
||||
return;
|
||||
} else if (!plotEntry(pp, now) && this.tmpTeleport) {
|
||||
MainUtil.sendMessage(pp, C.NO_PERMISSION_EVENT, C.PERMISSION_ADMIN_ENTRY_DENIED);
|
||||
if (!now.equals(area.getPlot(BukkitUtil.getLocation(from)))) {
|
||||
this.tmpTeleport = false;
|
||||
player.teleport(from);
|
||||
this.tmpTeleport = true;
|
||||
} else {
|
||||
Location spawn = BukkitUtil.getLocation(player.getWorld().getSpawnLocation());
|
||||
if (spawn.getEuclideanDistanceSquared(pp.getLocation()) > 2) {
|
||||
this.tmpTeleport = false;
|
||||
player.teleport(player.getWorld().getSpawnLocation());
|
||||
this.tmpTeleport = true;
|
||||
}
|
||||
}
|
||||
event.setCancelled(true);
|
||||
return;
|
||||
}
|
||||
Integer border = area.getBorder();
|
||||
if (this.tmpTeleport) {
|
||||
if (z2 > border) {
|
||||
to.setZ(border - 4);
|
||||
this.tmpTeleport = false;
|
||||
player.teleport(event.getTo());
|
||||
this.tmpTeleport = true;
|
||||
MainUtil.sendMessage(pp, C.BORDER);
|
||||
} else if (z2 < -border) {
|
||||
to.setZ(-border + 4);
|
||||
this.tmpTeleport = false;
|
||||
player.teleport(event.getTo());
|
||||
this.tmpTeleport = true;
|
||||
MainUtil.sendMessage(pp, C.BORDER);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@EventHandler(priority = EventPriority.HIGHEST, ignoreCancelled = true)
|
||||
public void onBucketEmpty(PlayerBucketEmptyEvent event) {
|
||||
BlockFace bf = event.getBlockFace();
|
||||
@ -1832,7 +1764,7 @@ public class PlayerEvents extends PlotListener implements Listener {
|
||||
return;
|
||||
}
|
||||
PlotPlayer pp = BukkitUtil.getPlayer(event.getPlayer());
|
||||
Plot plot = area.getPlotAbs(location);
|
||||
Plot plot = area.getPlot(location);
|
||||
if (plot == null) {
|
||||
if (Permissions.hasPermission(pp, C.PERMISSION_ADMIN_BUILD_ROAD)) {
|
||||
return;
|
||||
@ -1903,7 +1835,7 @@ public class PlayerEvents extends PlotListener implements Listener {
|
||||
}
|
||||
Player player = event.getPlayer();
|
||||
PlotPlayer plotPlayer = BukkitUtil.getPlayer(player);
|
||||
Plot plot = area.getPlotAbs(location);
|
||||
Plot plot = area.getPlot(location);
|
||||
if (plot == null) {
|
||||
if (Permissions.hasPermission(plotPlayer, C.PERMISSION_ADMIN_BUILD_ROAD)) {
|
||||
return;
|
||||
@ -1958,7 +1890,7 @@ public class PlayerEvents extends PlotListener implements Listener {
|
||||
}
|
||||
Player p = event.getPlayer();
|
||||
PlotPlayer pp = BukkitUtil.getPlayer(p);
|
||||
Plot plot = area.getPlotAbs(location);
|
||||
Plot plot = area.getPlot(location);
|
||||
if (plot == null) {
|
||||
if (!Permissions.hasPermission(pp, C.PERMISSION_ADMIN_BUILD_ROAD)) {
|
||||
MainUtil.sendMessage(pp, C.NO_PERMISSION_EVENT, C.PERMISSION_ADMIN_BUILD_ROAD);
|
||||
@ -1999,7 +1931,7 @@ public class PlayerEvents extends PlotListener implements Listener {
|
||||
return;
|
||||
}
|
||||
PlotPlayer pp = BukkitUtil.getPlayer(p);
|
||||
Plot plot = area.getPlotAbs(location);
|
||||
Plot plot = area.getPlot(location);
|
||||
if (plot == null) {
|
||||
if (!Permissions.hasPermission(pp, C.PERMISSION_ADMIN_DESTROY_ROAD)) {
|
||||
MainUtil.sendMessage(pp, C.NO_PERMISSION_EVENT, C.PERMISSION_ADMIN_DESTROY_ROAD);
|
||||
@ -2029,7 +1961,7 @@ public class PlayerEvents extends PlotListener implements Listener {
|
||||
return;
|
||||
}
|
||||
PlotPlayer player = BukkitUtil.getPlayer(shooter);
|
||||
Plot plot = area.getPlotAbs(BukkitUtil.getLocation(event.getEntity()));
|
||||
Plot plot = area.getPlot(BukkitUtil.getLocation(event.getEntity()));
|
||||
if (plot != null) {
|
||||
if (!plot.hasOwner()) {
|
||||
if (!Permissions.hasPermission(player, C.PERMISSION_ADMIN_DESTROY_UNOWNED)) {
|
||||
@ -2060,7 +1992,7 @@ public class PlayerEvents extends PlotListener implements Listener {
|
||||
}
|
||||
Player p = event.getPlayer();
|
||||
PlotPlayer pp = BukkitUtil.getPlayer(p);
|
||||
Plot plot = area.getPlotAbs(location);
|
||||
Plot plot = area.getPlot(location);
|
||||
if (plot == null) {
|
||||
if (!Permissions.hasPermission(pp, C.PERMISSION_ADMIN_INTERACT_ROAD)) {
|
||||
MainUtil.sendMessage(pp, C.NO_PERMISSION_EVENT, C.PERMISSION_ADMIN_INTERACT_ROAD);
|
||||
@ -2088,6 +2020,9 @@ public class PlayerEvents extends PlotListener implements Listener {
|
||||
if (entity instanceof Player && plot.getFlag(Flags.PLAYER_INTERACT, false)) {
|
||||
return;
|
||||
}
|
||||
if (entity instanceof Villager && plot.getFlag(Flags.VILLAGER_INTERACT, false)) {
|
||||
return;
|
||||
}
|
||||
if (!Permissions.hasPermission(pp, C.PERMISSION_ADMIN_INTERACT_OTHER)) {
|
||||
MainUtil.sendMessage(pp, C.NO_PERMISSION_EVENT, C.PERMISSION_ADMIN_INTERACT_OTHER);
|
||||
event.setCancelled(true);
|
||||
@ -2106,7 +2041,7 @@ public class PlayerEvents extends PlotListener implements Listener {
|
||||
if (d instanceof Player) {
|
||||
Player p = (Player) d;
|
||||
PlotPlayer pp = BukkitUtil.getPlayer(p);
|
||||
Plot plot = area.getPlotAbs(l);
|
||||
Plot plot = area.getPlot(l);
|
||||
if (plot == null) {
|
||||
if (!Permissions.hasPermission(pp, "plots.admin.vehicle.break.road")) {
|
||||
MainUtil.sendMessage(pp, C.NO_PERMISSION_EVENT, "plots.admin.vehicle.break.road");
|
||||
@ -2156,7 +2091,23 @@ public class PlayerEvents extends PlotListener implements Listener {
|
||||
@SuppressWarnings("deprecation")
|
||||
@EventHandler(priority = EventPriority.HIGHEST)
|
||||
public void onEntityCombustByEntity(EntityCombustByEntityEvent event) {
|
||||
EntityDamageByEntityEvent eventChange = new EntityDamageByEntityEvent(event.getCombuster(), event.getEntity(), EntityDamageEvent.DamageCause.FIRE_TICK, event.getDuration());
|
||||
EntityDamageByEntityEvent eventChange = null;
|
||||
if (PS.get().checkVersion(PS.get().IMP.getServerVersion(), BukkitVersion.v1_11_0)) {
|
||||
eventChange = new EntityDamageByEntityEvent(event.getCombuster(), event.getEntity(),
|
||||
EntityDamageEvent.DamageCause.FIRE_TICK, (double)event.getDuration());
|
||||
} else {
|
||||
try {
|
||||
Constructor<EntityDamageByEntityEvent> constructor = EntityDamageByEntityEvent.class.getConstructor(Entity.class,
|
||||
Entity.class, EntityDamageEvent.DamageCause.class, Integer.TYPE);
|
||||
eventChange = constructor.newInstance(event.getCombuster(), event.getEntity(),
|
||||
EntityDamageEvent.DamageCause.FIRE_TICK, event.getDuration());
|
||||
} catch (NoSuchMethodException | IllegalAccessException | InstantiationException | InvocationTargetException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
if (eventChange == null) {
|
||||
return;
|
||||
}
|
||||
onEntityDamageByEntityEvent(eventChange);
|
||||
}
|
||||
|
||||
@ -2357,7 +2308,7 @@ public class PlayerEvents extends PlotListener implements Listener {
|
||||
}
|
||||
Player player = event.getPlayer();
|
||||
PlotPlayer pp = BukkitUtil.getPlayer(player);
|
||||
Plot plot = area.getPlotAbs(location);
|
||||
Plot plot = area.getPlot(location);
|
||||
if (plot != null) {
|
||||
if (!plot.hasOwner()) {
|
||||
if (!Permissions.hasPermission(pp, C.PERMISSION_ADMIN_BUILD_UNOWNED)) {
|
||||
@ -2396,7 +2347,7 @@ public class PlayerEvents extends PlotListener implements Listener {
|
||||
event.setCancelled(true);
|
||||
MainUtil.sendMessage(pp, C.HEIGHT_LIMIT.s().replace("{limit}", String.valueOf(area.MAX_BUILD_HEIGHT)));
|
||||
}
|
||||
} else if (!Permissions.hasPermission(pp, C.PERMISSION_ADMIN_BUILD_OTHER)) {
|
||||
} else if (!Permissions.hasPermission(pp, C.PERMISSION_ADMIN_BUILD_ROAD)) {
|
||||
MainUtil.sendMessage(pp, C.NO_PERMISSION_EVENT, C.PERMISSION_ADMIN_BUILD_ROAD);
|
||||
event.setCancelled(true);
|
||||
}
|
||||
|
@ -2,6 +2,7 @@ package com.plotsquared.bukkit.listeners;
|
||||
|
||||
import com.intellectualcrafters.plot.PS;
|
||||
import com.intellectualcrafters.plot.config.C;
|
||||
import com.intellectualcrafters.plot.flag.Flags;
|
||||
import com.intellectualcrafters.plot.object.Location;
|
||||
import com.intellectualcrafters.plot.object.Plot;
|
||||
import com.intellectualcrafters.plot.object.PlotArea;
|
||||
@ -66,7 +67,7 @@ public class PlayerEvents_1_8 extends PlotListener implements Listener {
|
||||
oldLore = lore.toString();
|
||||
}
|
||||
}
|
||||
if (!newLore.equals("[(+NBT)]") || (current.equals(newItem) && newLore.equals(oldLore))) {
|
||||
if (!"[(+NBT)]".equals(newLore) || (current.equals(newItem) && newLore.equals(oldLore))) {
|
||||
return;
|
||||
}
|
||||
HashSet<Byte> blocks = null;
|
||||
@ -141,6 +142,9 @@ public class PlayerEvents_1_8 extends PlotListener implements Listener {
|
||||
} else {
|
||||
UUID uuid = pp.getUUID();
|
||||
if (!plot.isAdded(uuid)) {
|
||||
if (Flags.MISC_INTERACT.isTrue(plot)) {
|
||||
return;
|
||||
}
|
||||
if (!Permissions.hasPermission(pp, "plots.admin.interact.other")) {
|
||||
MainUtil.sendMessage(pp, C.NO_PERMISSION_EVENT, "plots.admin.interact.other");
|
||||
e.setCancelled(true);
|
||||
|
@ -1,5 +1,6 @@
|
||||
package com.plotsquared.bukkit.object;
|
||||
|
||||
import com.intellectualcrafters.plot.PS;
|
||||
import com.intellectualcrafters.plot.object.Location;
|
||||
import com.intellectualcrafters.plot.object.PlotPlayer;
|
||||
import com.intellectualcrafters.plot.util.EconHandler;
|
||||
@ -67,7 +68,7 @@ public class BukkitPlayer extends PlotPlayer {
|
||||
PlayerTeleportEvent event = new PlayerTeleportEvent(player, from, to);
|
||||
RegisteredListener[] listeners = event.getHandlers().getRegisteredListeners();
|
||||
for (RegisteredListener listener : listeners) {
|
||||
if (listener.getPlugin().getName().equals("PlotSquared")) {
|
||||
if (listener.getPlugin().getName().equals(PS.imp().getPluginName())) {
|
||||
continue;
|
||||
}
|
||||
try {
|
||||
@ -81,7 +82,7 @@ public class BukkitPlayer extends PlotPlayer {
|
||||
}
|
||||
event = new PlayerTeleportEvent(player, to, from);
|
||||
for (RegisteredListener listener : listeners) {
|
||||
if (listener.getPlugin().getName().equals("PlotSquared")) {
|
||||
if (listener.getPlugin().getName().equals(PS.imp().getPluginName())) {
|
||||
continue;
|
||||
}
|
||||
try {
|
||||
|
@ -1,6 +1,7 @@
|
||||
package com.plotsquared.bukkit.object.entity;
|
||||
|
||||
import com.intellectualcrafters.plot.PS;
|
||||
import com.plotsquared.bukkit.util.BukkitVersion;
|
||||
import org.bukkit.Art;
|
||||
import org.bukkit.DyeColor;
|
||||
import org.bukkit.Location;
|
||||
@ -86,7 +87,7 @@ public class EntityWrapper {
|
||||
if (depth == 1) {
|
||||
return;
|
||||
}
|
||||
if (PS.get().checkVersion(PS.get().IMP.getServerVersion(), 1, 10, 0) || entity instanceof ArmorStand) {
|
||||
if (PS.get().checkVersion(PS.get().IMP.getServerVersion(), BukkitVersion.v1_10_0) || entity instanceof ArmorStand) {
|
||||
if (!entity.hasGravity()) {
|
||||
this.noGravity = true;
|
||||
}
|
||||
@ -94,7 +95,7 @@ public class EntityWrapper {
|
||||
switch (entity.getType()) {
|
||||
case ARROW:
|
||||
case BOAT:
|
||||
if (PS.get().checkVersion(PS.get().IMP.getServerVersion(), 1, 9, 0)) {
|
||||
if (PS.get().checkVersion(PS.get().IMP.getServerVersion(), BukkitVersion.v1_9_0)) {
|
||||
Boat boat = (Boat) entity;
|
||||
this.dataByte = getOrdinal(TreeSpecies.values(), boat.getWoodType());
|
||||
}
|
||||
@ -353,7 +354,7 @@ public class EntityWrapper {
|
||||
|
||||
void restoreEquipment(LivingEntity entity) {
|
||||
EntityEquipment equipment = entity.getEquipment();
|
||||
if (PS.get().checkVersion(PS.get().IMP.getServerVersion(), 1, 9, 0)) {
|
||||
if (PS.get().checkVersion(PS.get().IMP.getServerVersion(), BukkitVersion.v1_9_0)) {
|
||||
equipment.setItemInMainHand(this.lived.mainHand);
|
||||
equipment.setItemInOffHand(this.lived.offHand);
|
||||
} else {
|
||||
@ -397,7 +398,7 @@ public class EntityWrapper {
|
||||
}
|
||||
|
||||
void storeEquipment(EntityEquipment equipment) {
|
||||
if (PS.get().checkVersion(PS.get().IMP.getServerVersion(), 1, 9, 0)) {
|
||||
if (PS.get().checkVersion(PS.get().IMP.getServerVersion(), BukkitVersion.v1_9_0)) {
|
||||
this.lived.mainHand = equipment.getItemInMainHand().clone();
|
||||
this.lived.offHand = equipment.getItemInOffHand().clone();
|
||||
} else {
|
||||
@ -487,7 +488,7 @@ public class EntityWrapper {
|
||||
if (this.depth == 1) {
|
||||
return entity;
|
||||
}
|
||||
if (PS.get().checkVersion(PS.get().IMP.getServerVersion(), 1, 10, 0) || entity instanceof ArmorStand) {
|
||||
if (PS.get().checkVersion(PS.get().IMP.getServerVersion(), BukkitVersion.v1_10_0) || entity instanceof ArmorStand) {
|
||||
if (this.noGravity) {
|
||||
entity.setGravity(false);
|
||||
}
|
||||
@ -495,7 +496,7 @@ public class EntityWrapper {
|
||||
switch (entity.getType()) {
|
||||
case ARROW:
|
||||
case BOAT:
|
||||
if (PS.get().checkVersion(PS.get().IMP.getServerVersion(), 1, 9, 0)) {
|
||||
if (PS.get().checkVersion(PS.get().IMP.getServerVersion(), BukkitVersion.v1_9_0)) {
|
||||
Boat boat = (Boat) entity;
|
||||
boat.setWoodType(TreeSpecies.values()[dataByte]);
|
||||
}
|
||||
|
@ -18,7 +18,7 @@ public class DefaultTitleManager extends TitleManager {
|
||||
* @param stayTime Stay on screen time
|
||||
* @param fadeOutTime Fade out time
|
||||
*/
|
||||
public DefaultTitleManager(String title, String subtitle, int fadeInTime, int stayTime, int fadeOutTime) {
|
||||
DefaultTitleManager(String title, String subtitle, int fadeInTime, int stayTime, int fadeOutTime) {
|
||||
super(title, subtitle, fadeInTime, stayTime, fadeOutTime);
|
||||
}
|
||||
|
||||
@ -106,9 +106,9 @@ public class DefaultTitleManager extends TitleManager {
|
||||
}
|
||||
}
|
||||
|
||||
private Method getMethod(Class<?> clazz, String name, Class<?>... args) {
|
||||
Method getMethod(Class<?> clazz, String name, Class<?>... args) {
|
||||
for (Method m : clazz.getMethods()) {
|
||||
if (m.getName().equals(name) && (args.length == 0 || ClassListEqual(args, m.getParameterTypes()))) {
|
||||
if (m.getName().equals(name) && (args.length == 0 || classListEqual(args, m.getParameterTypes()))) {
|
||||
m.setAccessible(true);
|
||||
return m;
|
||||
}
|
||||
@ -116,17 +116,4 @@ public class DefaultTitleManager extends TitleManager {
|
||||
return null;
|
||||
}
|
||||
|
||||
boolean ClassListEqual(Class<?>[] l1, Class<?>[] l2) {
|
||||
if (l1.length != l2.length) {
|
||||
return false;
|
||||
}
|
||||
boolean equal = true;
|
||||
for (int i = 0; i < l1.length; i++) {
|
||||
if (l1[i] != l2[i]) {
|
||||
equal = false;
|
||||
break;
|
||||
}
|
||||
}
|
||||
return equal;
|
||||
}
|
||||
}
|
||||
|
@ -17,7 +17,7 @@ public class DefaultTitleManager_183 extends DefaultTitleManager {
|
||||
* @param stayTime Stay on screen time
|
||||
* @param fadeOutTime Fade out time
|
||||
*/
|
||||
public DefaultTitleManager_183(String title, String subtitle, int fadeInTime, int stayTime, int fadeOutTime) {
|
||||
DefaultTitleManager_183(String title, String subtitle, int fadeInTime, int stayTime, int fadeOutTime) {
|
||||
super(title, subtitle, fadeInTime, stayTime, fadeOutTime);
|
||||
}
|
||||
|
||||
@ -67,15 +67,4 @@ public class DefaultTitleManager_183 extends DefaultTitleManager {
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private Method getMethod(Class<?> clazz, String name, Class<?>... args) {
|
||||
for (Method m : clazz.getMethods()) {
|
||||
if (m.getName().equals(name) && ((args.length == 0) || ClassListEqual(args, m.getParameterTypes()))) {
|
||||
m.setAccessible(true);
|
||||
return m;
|
||||
}
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -6,6 +6,7 @@ import com.intellectualcrafters.plot.util.TaskManager;
|
||||
import com.plotsquared.bukkit.object.BukkitPlayer;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
@SuppressWarnings("deprecation")
|
||||
public class DefaultTitle_19 extends AbstractTitle {
|
||||
|
||||
@Override
|
||||
|
@ -19,7 +19,7 @@ public class HackTitleManager extends TitleManager {
|
||||
* @param stayTime Stay on screen time
|
||||
* @param fadeOutTime Fade out time
|
||||
*/
|
||||
public HackTitleManager(String title, String subtitle, int fadeInTime, int stayTime, int fadeOutTime) {
|
||||
HackTitleManager(String title, String subtitle, int fadeInTime, int stayTime, int fadeOutTime) {
|
||||
super(title, subtitle, fadeInTime, stayTime, fadeOutTime);
|
||||
}
|
||||
|
||||
@ -162,18 +162,4 @@ public class HackTitleManager extends TitleManager {
|
||||
return null;
|
||||
}
|
||||
|
||||
private boolean classListEqual(Class<?>[] l1, Class<?>[] l2) {
|
||||
if (l1.length != l2.length) {
|
||||
return false;
|
||||
}
|
||||
boolean equal = true;
|
||||
for (int i = 0; i < l1.length; i++) {
|
||||
if (l1[i] != l2[i]) {
|
||||
equal = false;
|
||||
break;
|
||||
}
|
||||
}
|
||||
return equal;
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -241,4 +241,17 @@ public abstract class TitleManager {
|
||||
return true;
|
||||
}
|
||||
|
||||
boolean classListEqual(Class<?>[] l1, Class<?>[] l2) {
|
||||
if (l1.length != l2.length) {
|
||||
return false;
|
||||
}
|
||||
boolean equal = true;
|
||||
for (int i = 0; i < l1.length; i++) {
|
||||
if (l1[i] != l2[i]) {
|
||||
equal = false;
|
||||
break;
|
||||
}
|
||||
}
|
||||
return equal;
|
||||
}
|
||||
}
|
||||
|
@ -516,6 +516,7 @@ public class BukkitChunkManager extends ChunkManager {
|
||||
case SHULKER_BULLET:
|
||||
case SPECTRAL_ARROW:
|
||||
case DRAGON_FIREBALL:
|
||||
case LLAMA_SPIT:
|
||||
// projectile
|
||||
case PRIMED_TNT:
|
||||
case FALLING_BLOCK:
|
||||
@ -533,6 +534,7 @@ public class BukkitChunkManager extends ChunkManager {
|
||||
case UNKNOWN:
|
||||
case AREA_EFFECT_CLOUD:
|
||||
case LINGERING_POTION:
|
||||
case EVOKER_FANGS:
|
||||
// non moving / unremovable
|
||||
break;
|
||||
case ITEM_FRAME:
|
||||
@ -566,6 +568,11 @@ public class BukkitChunkManager extends ChunkManager {
|
||||
case COW:
|
||||
case SNOWMAN:
|
||||
case BAT:
|
||||
case DONKEY:
|
||||
case LLAMA:
|
||||
case SKELETON_HORSE:
|
||||
case ZOMBIE_HORSE:
|
||||
case MULE:
|
||||
// animal
|
||||
count[3]++;
|
||||
count[1]++;
|
||||
@ -589,6 +596,14 @@ public class BukkitChunkManager extends ChunkManager {
|
||||
case WITHER:
|
||||
case ZOMBIE:
|
||||
case SHULKER:
|
||||
case ELDER_GUARDIAN:
|
||||
case STRAY:
|
||||
case HUSK:
|
||||
case EVOKER:
|
||||
case VEX:
|
||||
case WITHER_SKELETON:
|
||||
case ZOMBIE_VILLAGER:
|
||||
case VINDICATOR:
|
||||
// monster
|
||||
count[3]++;
|
||||
count[2]++;
|
||||
@ -610,27 +625,27 @@ public class BukkitChunkManager extends ChunkManager {
|
||||
|
||||
public static class ContentMap {
|
||||
|
||||
public final Map<BlockLoc, ItemStack[]> chestContents;
|
||||
public final Map<BlockLoc, ItemStack[]> furnaceContents;
|
||||
public final Map<BlockLoc, ItemStack[]> dispenserContents;
|
||||
public final Map<BlockLoc, ItemStack[]> dropperContents;
|
||||
public final Map<BlockLoc, ItemStack[]> brewingStandContents;
|
||||
public final Map<BlockLoc, ItemStack[]> beaconContents;
|
||||
public final Map<BlockLoc, ItemStack[]> hopperContents;
|
||||
public final Map<BlockLoc, Short[]> furnaceTime;
|
||||
public final Map<BlockLoc, Object[]> skullData;
|
||||
public final Map<BlockLoc, Material> jukeboxDisc;
|
||||
public final Map<BlockLoc, Short> brewTime;
|
||||
public final Map<BlockLoc, EntityType> spawnerData;
|
||||
public final Map<BlockLoc, String> cmdData;
|
||||
public final Map<BlockLoc, String[]> signContents;
|
||||
public final Map<BlockLoc, Note> noteBlockContents;
|
||||
public final Map<BlockLoc, List<Pattern>> bannerPatterns;
|
||||
public final Map<BlockLoc, DyeColor> bannerBase;
|
||||
public final Set<EntityWrapper> entities;
|
||||
public final Map<PlotLoc, PlotBlock[]> allBlocks;
|
||||
final Map<BlockLoc, ItemStack[]> chestContents;
|
||||
final Map<BlockLoc, ItemStack[]> furnaceContents;
|
||||
final Map<BlockLoc, ItemStack[]> dispenserContents;
|
||||
final Map<BlockLoc, ItemStack[]> dropperContents;
|
||||
final Map<BlockLoc, ItemStack[]> brewingStandContents;
|
||||
final Map<BlockLoc, ItemStack[]> beaconContents;
|
||||
final Map<BlockLoc, ItemStack[]> hopperContents;
|
||||
final Map<BlockLoc, Short[]> furnaceTime;
|
||||
final Map<BlockLoc, Object[]> skullData;
|
||||
final Map<BlockLoc, Material> jukeboxDisc;
|
||||
final Map<BlockLoc, Short> brewTime;
|
||||
final Map<BlockLoc, EntityType> spawnerData;
|
||||
final Map<BlockLoc, String> cmdData;
|
||||
final Map<BlockLoc, String[]> signContents;
|
||||
final Map<BlockLoc, Note> noteBlockContents;
|
||||
final Map<BlockLoc, List<Pattern>> bannerPatterns;
|
||||
final Map<BlockLoc, DyeColor> bannerBase;
|
||||
final Set<EntityWrapper> entities;
|
||||
final Map<PlotLoc, PlotBlock[]> allBlocks;
|
||||
|
||||
public ContentMap() {
|
||||
ContentMap() {
|
||||
this.chestContents = new HashMap<>();
|
||||
this.furnaceContents = new HashMap<>();
|
||||
this.dispenserContents = new HashMap<>();
|
||||
|
@ -110,12 +110,12 @@ public class BukkitEventUtil extends EventUtil {
|
||||
|
||||
@Override
|
||||
public void callTrusted(PlotPlayer initiator, Plot plot, UUID player, boolean added) {
|
||||
callEvent(new PlayerPlotHelperEvent(getPlayer(initiator), plot, player, added));
|
||||
callEvent(new PlayerPlotTrustedEvent(getPlayer(initiator), plot, player, added));
|
||||
}
|
||||
|
||||
@Override
|
||||
public void callMember(PlotPlayer initiator, Plot plot, UUID player, boolean added) {
|
||||
callEvent(new PlayerPlotTrustedEvent(getPlayer(initiator), plot, player, added));
|
||||
callEvent(new PlayerPlotHelperEvent(getPlayer(initiator), plot, player, added));
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -12,8 +12,6 @@ import com.intellectualcrafters.plot.util.TaskManager;
|
||||
import com.intellectualcrafters.plot.util.block.GlobalBlockQueue;
|
||||
import com.intellectualcrafters.plot.util.block.LocalBlockQueue;
|
||||
import com.intellectualcrafters.plot.util.expiry.PlotAnalysis;
|
||||
import java.util.HashSet;
|
||||
import java.util.Random;
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.World;
|
||||
@ -23,6 +21,9 @@ import org.bukkit.generator.ChunkGenerator.BiomeGrid;
|
||||
import org.bukkit.material.Directional;
|
||||
import org.bukkit.material.MaterialData;
|
||||
|
||||
import java.util.HashSet;
|
||||
import java.util.Random;
|
||||
|
||||
public class BukkitHybridUtils extends HybridUtils {
|
||||
|
||||
@Override
|
||||
@ -50,7 +51,8 @@ public class BukkitHybridUtils extends HybridUtils {
|
||||
}
|
||||
final BiomeGrid nullBiomeGrid = new BiomeGrid() {
|
||||
@Override
|
||||
public void setBiome(int a, int b, Biome c) {}
|
||||
public void setBiome(int a, int b, Biome c) {
|
||||
}
|
||||
|
||||
@Override
|
||||
public Biome getBiome(int a, int b) {
|
||||
|
@ -31,19 +31,23 @@ public class BukkitSetupUtils extends SetupUtils {
|
||||
}
|
||||
String testWorld = "CheckingPlotSquaredGenerator";
|
||||
for (Plugin plugin : Bukkit.getPluginManager().getPlugins()) {
|
||||
if (plugin.isEnabled()) {
|
||||
ChunkGenerator generator = plugin.getDefaultWorldGenerator(testWorld, "");
|
||||
if (generator != null) {
|
||||
PS.get().removePlotAreas(testWorld);
|
||||
String name = plugin.getDescription().getName();
|
||||
GeneratorWrapper<?> wrapped;
|
||||
if (generator instanceof GeneratorWrapper<?>) {
|
||||
wrapped = (GeneratorWrapper<?>) generator;
|
||||
} else {
|
||||
wrapped = new BukkitPlotGenerator(testWorld, generator);
|
||||
try {
|
||||
if (plugin.isEnabled()) {
|
||||
ChunkGenerator generator = plugin.getDefaultWorldGenerator(testWorld, "");
|
||||
if (generator != null) {
|
||||
PS.get().removePlotAreas(testWorld);
|
||||
String name = plugin.getDescription().getName();
|
||||
GeneratorWrapper<?> wrapped;
|
||||
if (generator instanceof GeneratorWrapper<?>) {
|
||||
wrapped = (GeneratorWrapper<?>) generator;
|
||||
} else {
|
||||
wrapped = new BukkitPlotGenerator(testWorld, generator);
|
||||
}
|
||||
SetupUtils.generators.put(name, wrapped);
|
||||
}
|
||||
SetupUtils.generators.put(name, wrapped);
|
||||
}
|
||||
} catch (Throwable e) { // Recover from third party generator error
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -178,7 +178,14 @@ public class BukkitUtil extends WorldUtil {
|
||||
|
||||
@Override
|
||||
public int getHighestBlock(String world, int x, int z) {
|
||||
return getWorld(world).getHighestBlockAt(x, z).getY();
|
||||
World bukkitWorld = getWorld(world);
|
||||
for (int y = bukkitWorld.getMaxHeight() - 1; y > 0; y--) {
|
||||
Block block = bukkitWorld.getBlockAt(x, y, z);
|
||||
if (block != null && block.getType().isSolid()) {
|
||||
return y+1;
|
||||
}
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -0,0 +1,14 @@
|
||||
package com.plotsquared.bukkit.util;
|
||||
|
||||
public class BukkitVersion {
|
||||
public static int[] v1_11_0 = {1, 11, 0};
|
||||
public static int[] v1_10_2 = {1, 10, 2};
|
||||
public static int[] v1_10_0 = {1, 10, 0};
|
||||
public static int[] v1_9_4 = {1, 9, 4};
|
||||
public static int[] v1_9_0 = {1, 9, 0};
|
||||
public static int[] v1_8_3 = {1, 8, 3};
|
||||
public static int[] v1_8_0 = {1, 8, 0};
|
||||
public static int[] v1_7_6 = {1, 7, 6};
|
||||
public static int[] v1_7_0 = {1, 7, 0};
|
||||
public static int[] v1_6_0 = {1, 6, 0};
|
||||
}
|
@ -8,7 +8,6 @@ import com.google.common.collect.MapMaker;
|
||||
import com.google.common.io.ByteSink;
|
||||
import com.google.common.io.ByteSource;
|
||||
import com.google.common.io.Closeables;
|
||||
import com.google.common.io.Files;
|
||||
import com.google.common.primitives.Primitives;
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.Material;
|
||||
@ -20,7 +19,6 @@ import java.io.DataInput;
|
||||
import java.io.DataInputStream;
|
||||
import java.io.DataOutput;
|
||||
import java.io.DataOutputStream;
|
||||
import java.io.File;
|
||||
import java.io.IOException;
|
||||
import java.io.InputStream;
|
||||
import java.io.OutputStream;
|
||||
@ -161,7 +159,6 @@ public class NbtFactory {
|
||||
/**
|
||||
* Load the content of a file from a stream.
|
||||
*
|
||||
* Use {@link Files#newInputStreamSupplier(File)} to provide a stream from a file.
|
||||
* @param stream - the stream supplier.
|
||||
* @param option - whether or not to decompress the input stream.
|
||||
* @return The decoded NBT compound.
|
||||
@ -196,7 +193,6 @@ public class NbtFactory {
|
||||
/**
|
||||
* Save the content of a NBT compound to a stream.
|
||||
*
|
||||
* Use {@link Files#newOutputStreamSupplier(File)} to provide a stream supplier to a file.
|
||||
* @param source - the NBT compound to save.
|
||||
* @param stream - the stream.
|
||||
* @param option - whether or not to compress the output.
|
||||
@ -445,8 +441,7 @@ public class NbtFactory {
|
||||
|
||||
/**
|
||||
* Convert a given NBT element to a primitive wrapper or List/Map equivalent.
|
||||
* <p>
|
||||
* All changes to any mutable objects will be reflected in the underlying NBT element(s).
|
||||
* <p> All changes to any mutable objects will be reflected in the underlying NBT element(s).
|
||||
* @param nms - the NBT element.
|
||||
* @return The wrapper equivalent.
|
||||
*/
|
||||
@ -605,7 +600,7 @@ public class NbtFactory {
|
||||
*/
|
||||
private static class LoadMethodWorldUpdate extends LoadCompoundMethod {
|
||||
|
||||
public LoadMethodWorldUpdate(Class<?> streamClass) {
|
||||
LoadMethodWorldUpdate(Class<?> streamClass) {
|
||||
setMethod(getMethod(Modifier.STATIC, 0, streamClass, null, DataInput.class));
|
||||
}
|
||||
|
||||
@ -622,7 +617,7 @@ public class NbtFactory {
|
||||
|
||||
private Object readLimiter;
|
||||
|
||||
public LoadMethodSkinUpdate(Class<?> streamClass, Class<?> readLimiterClass) {
|
||||
LoadMethodSkinUpdate(Class<?> streamClass, Class<?> readLimiterClass) {
|
||||
setMethod(getMethod(Modifier.STATIC, 0, streamClass, null, DataInput.class, readLimiterClass));
|
||||
|
||||
// Find the unlimited read limiter
|
||||
@ -645,8 +640,7 @@ public class NbtFactory {
|
||||
|
||||
/**
|
||||
* Represents a root NBT compound.
|
||||
* <p>
|
||||
* All changes to this map will be reflected in the underlying NBT compound. Values may only be one of the following:
|
||||
* <p> All changes to this map will be reflected in the underlying NBT compound. Values may only be one of the following:
|
||||
* <ul>
|
||||
* <li>Primitive types</li>
|
||||
* <li>{@link String String}</li>
|
||||
@ -769,8 +763,6 @@ public class NbtFactory {
|
||||
|
||||
/**
|
||||
* Save the content of a NBT compound to a stream.
|
||||
* <p>
|
||||
* Use {@link Files#newOutputStreamSupplier(File)} to provide a stream supplier to a file.
|
||||
* @param stream - the output stream.
|
||||
* @param option - whether or not to compress the output.
|
||||
* @throws IOException If anything went wrong.
|
||||
|
@ -50,7 +50,7 @@ public class SendChunk {
|
||||
RefClass classChunk = getRefClass("{nms}.Chunk");
|
||||
this.methodInitLighting = classChunk.getMethod("initLighting");
|
||||
RefClass classMapChunk = getRefClass("{nms}.PacketPlayOutMapChunk");
|
||||
if (PS.get().checkVersion(PS.get().IMP.getServerVersion(), 1, 9, 4)) {
|
||||
if (PS.get().checkVersion(PS.get().IMP.getServerVersion(), BukkitVersion.v1_9_4)) {
|
||||
//this works for 1.9.4 and 1.10
|
||||
tempMapChunk = classMapChunk.getConstructor(classChunk.getRealClass(),int.class);
|
||||
} else {
|
||||
@ -116,7 +116,7 @@ public class SendChunk {
|
||||
chunks.remove(chunk);
|
||||
Object con = this.connection.of(entity).get();
|
||||
Object packet = null;
|
||||
if (PS.get().checkVersion(PS.get().IMP.getServerVersion(), 1, 9, 4)) {
|
||||
if (PS.get().checkVersion(PS.get().IMP.getServerVersion(), BukkitVersion.v1_9_4)) {
|
||||
try {
|
||||
packet = this.mapChunk.create(c,65535);
|
||||
} catch (Exception ignored) {}
|
||||
|
@ -4,6 +4,8 @@ import com.intellectualcrafters.plot.object.PlotBlock;
|
||||
import com.intellectualcrafters.plot.util.MainUtil;
|
||||
import com.intellectualcrafters.plot.util.StringMan;
|
||||
import com.intellectualcrafters.plot.util.block.BasicLocalBlockQueue;
|
||||
import java.lang.reflect.Field;
|
||||
import java.lang.reflect.Method;
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.Chunk;
|
||||
import org.bukkit.World;
|
||||
@ -126,4 +128,60 @@ public class BukkitLocalQueue<T> extends BasicLocalBlockQueue<T> {
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private Field fieldNeighbors;
|
||||
private Method chunkGetHandle;
|
||||
|
||||
/**
|
||||
* Exploiting a bug in the vanilla lighting algorithm for faster block placement
|
||||
* - Could have been achieved without reflection by force unloading specific chunks
|
||||
* - Much faster just setting the variable manually though
|
||||
* @param chunk
|
||||
* @return
|
||||
*/
|
||||
protected Object[] disableLighting(Chunk chunk) {
|
||||
try {
|
||||
if (chunkGetHandle == null) {
|
||||
chunkGetHandle = chunk.getClass().getDeclaredMethod("getHandle");
|
||||
chunkGetHandle.setAccessible(true);
|
||||
}
|
||||
Object nmsChunk = chunkGetHandle.invoke(chunk);
|
||||
if (fieldNeighbors == null) {
|
||||
fieldNeighbors = nmsChunk.getClass().getDeclaredField("neighbors");
|
||||
fieldNeighbors.setAccessible(true);
|
||||
}
|
||||
Object value = fieldNeighbors.get(nmsChunk);
|
||||
fieldNeighbors.set(nmsChunk, 0);
|
||||
return new Object[] {nmsChunk, value};
|
||||
} catch (Throwable ignore) {}
|
||||
return null;
|
||||
}
|
||||
|
||||
protected void disableLighting(Object[] disableResult) {
|
||||
if (disableResult != null) {
|
||||
try {
|
||||
fieldNeighbors.set(disableResult[0], 0);
|
||||
} catch (IllegalAccessException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
protected void resetLighting(Object[] disableResult) {
|
||||
if (disableResult != null) {
|
||||
try {
|
||||
fieldNeighbors.set(disableResult[0], disableResult[1]);
|
||||
} catch (Throwable ignore) {
|
||||
ignore.printStackTrace();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
protected void enableLighting(Object[] disableResult) {
|
||||
if (disableResult != null) {
|
||||
try {
|
||||
fieldNeighbors.set(disableResult[0], 0x739C0);
|
||||
} catch (Throwable ignore) {}
|
||||
}
|
||||
}
|
||||
}
|
@ -1,5 +1,7 @@
|
||||
package com.plotsquared.bukkit.util.block;
|
||||
|
||||
import static com.intellectualcrafters.plot.util.ReflectionUtils.getRefClass;
|
||||
|
||||
import com.intellectualcrafters.plot.object.ChunkLoc;
|
||||
import com.intellectualcrafters.plot.object.ChunkWrapper;
|
||||
import com.intellectualcrafters.plot.object.PseudoRandom;
|
||||
@ -9,6 +11,11 @@ import com.intellectualcrafters.plot.util.ReflectionUtils;
|
||||
import com.intellectualcrafters.plot.util.TaskManager;
|
||||
import com.intellectualcrafters.plot.util.block.BasicLocalBlockQueue;
|
||||
import com.plotsquared.bukkit.util.SendChunk;
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.Chunk;
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.World;
|
||||
|
||||
import java.lang.reflect.Field;
|
||||
import java.lang.reflect.Method;
|
||||
import java.util.ArrayList;
|
||||
@ -18,13 +25,6 @@ import java.util.HashMap;
|
||||
import java.util.Iterator;
|
||||
import java.util.Map;
|
||||
import java.util.Set;
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.Chunk;
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.World;
|
||||
|
||||
|
||||
import static com.intellectualcrafters.plot.util.ReflectionUtils.getRefClass;
|
||||
|
||||
public class BukkitLocalQueue_1_8_3 extends BukkitLocalQueue<char[]> {
|
||||
|
||||
@ -403,11 +403,11 @@ public class BukkitLocalQueue_1_8_3 extends BukkitLocalQueue<char[]> {
|
||||
}
|
||||
}
|
||||
}
|
||||
/*
|
||||
/*
|
||||
if (!(boolean) methodAreNeighborsLoaded.of(c).call(1)) {
|
||||
return false;
|
||||
}
|
||||
*/
|
||||
*/
|
||||
}
|
||||
|
||||
this.methodInitLighting.of(c).call();
|
||||
|
@ -1,9 +1,7 @@
|
||||
package com.plotsquared.bukkit.util.block;
|
||||
|
||||
import com.intellectualcrafters.plot.object.ChunkLoc;
|
||||
import com.intellectualcrafters.plot.object.ChunkWrapper;
|
||||
import com.intellectualcrafters.plot.object.PseudoRandom;
|
||||
import com.intellectualcrafters.plot.util.ChunkManager;
|
||||
import com.intellectualcrafters.plot.util.MainUtil;
|
||||
import com.intellectualcrafters.plot.util.ReflectionUtils;
|
||||
import com.intellectualcrafters.plot.util.block.BasicLocalBlockQueue;
|
||||
@ -380,87 +378,73 @@ public class BukkitLocalQueue_1_9 extends BukkitLocalQueue<char[]> {
|
||||
Object c = this.methodGetHandleChunk.of(chunk).call();
|
||||
|
||||
ChunkWrapper wrapper = new ChunkWrapper(getWorld(), bc.getX(), bc.getZ());
|
||||
if (fixAll && !(boolean) this.methodAreNeighborsLoaded.of(c).call(1)) {
|
||||
World world = chunk.getWorld();
|
||||
for (int x = wrapper.x - 1; x <= wrapper.x + 1; x++) {
|
||||
for (int z = wrapper.z - 1; z <= wrapper.z + 1; z++) {
|
||||
if (x != 0 && z != 0) {
|
||||
Chunk other = world.getChunkAt(x, z);
|
||||
while (!other.isLoaded()) {
|
||||
other.load(true);
|
||||
}
|
||||
ChunkManager.manager.loadChunk(getWorld(), new ChunkLoc(x, z), true);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
Object[] result = disableLighting(chunk);
|
||||
enableLighting(result);
|
||||
|
||||
this.methodInitLighting.of(c).call();
|
||||
|
||||
if (bc.getTotalRelight() == 0 && !fixAll) {
|
||||
return true;
|
||||
}
|
||||
if (bc.getTotalRelight() != 0 || fixAll) {
|
||||
Object[] sections = (Object[]) this.fieldSections.of(c).get();
|
||||
Object w = this.fieldWorld.of(c).get();
|
||||
|
||||
Object[] sections = (Object[]) this.fieldSections.of(c).get();
|
||||
Object w = this.fieldWorld.of(c).get();
|
||||
|
||||
int X = chunk.getX() << 4;
|
||||
int Z = chunk.getZ() << 4;
|
||||
|
||||
ReflectionUtils.RefMethod.RefExecutor relight = this.methodW.of(w);
|
||||
for (int j = 0; j < sections.length; j++) {
|
||||
Object section = sections[j];
|
||||
if (section == null) {
|
||||
continue;
|
||||
}
|
||||
if (bc.getRelight(j) == 0 && !fixAll || bc.getCount(j) == 0 || bc.getCount(j) >= 4096 && bc.getAir(j) == 0) {
|
||||
continue;
|
||||
}
|
||||
char[] array = bc.getIdArray(j);
|
||||
if (array != null) {
|
||||
int l = PseudoRandom.random.random(2);
|
||||
for (int k = 0; k < array.length; k++) {
|
||||
int i = array[k];
|
||||
if (i < 16) {
|
||||
continue;
|
||||
}
|
||||
short id = (short) (i >> 4);
|
||||
switch (id) { // Lighting
|
||||
default:
|
||||
if (!fixAll) {
|
||||
continue;
|
||||
}
|
||||
if ((k & 1) == l) {
|
||||
l = 1 - l;
|
||||
continue;
|
||||
}
|
||||
case 10:
|
||||
case 11:
|
||||
case 39:
|
||||
case 40:
|
||||
case 50:
|
||||
case 51:
|
||||
case 62:
|
||||
case 74:
|
||||
case 76:
|
||||
case 89:
|
||||
case 122:
|
||||
case 124:
|
||||
case 130:
|
||||
case 138:
|
||||
case 169:
|
||||
int x = MainUtil.x_loc[j][k];
|
||||
int y = MainUtil.y_loc[j][k];
|
||||
int z = MainUtil.z_loc[j][k];
|
||||
if (isSurrounded(bc.blocks, x, y, z)) {
|
||||
continue;
|
||||
}
|
||||
Object pos = this.classBlockPositionConstructor.create(X + x, y, Z + z);
|
||||
relight.call(pos);
|
||||
int X = chunk.getX() << 4;
|
||||
int Z = chunk.getZ() << 4;
|
||||
ReflectionUtils.RefMethod.RefExecutor relight = this.methodW.of(w);
|
||||
for (int j = 0; j < sections.length; j++) {
|
||||
Object section = sections[j];
|
||||
if (section == null) {
|
||||
continue;
|
||||
}
|
||||
if (bc.getRelight(j) == 0 && !fixAll || bc.getCount(j) == 0 || bc.getCount(j) >= 4096 && bc.getAir(j) == 0) {
|
||||
continue;
|
||||
}
|
||||
char[] array = bc.getIdArray(j);
|
||||
if (array != null) {
|
||||
int l = PseudoRandom.random.random(2);
|
||||
for (int k = 0; k < array.length; k++) {
|
||||
int i = array[k];
|
||||
if (i < 16) {
|
||||
continue;
|
||||
}
|
||||
short id = (short) (i >> 4);
|
||||
switch (id) { // Lighting
|
||||
default:
|
||||
if (!fixAll) {
|
||||
continue;
|
||||
}
|
||||
if ((k & 1) == l) {
|
||||
l = 1 - l;
|
||||
continue;
|
||||
}
|
||||
case 10:
|
||||
case 11:
|
||||
case 39:
|
||||
case 40:
|
||||
case 50:
|
||||
case 51:
|
||||
case 62:
|
||||
case 74:
|
||||
case 76:
|
||||
case 89:
|
||||
case 122:
|
||||
case 124:
|
||||
case 130:
|
||||
case 138:
|
||||
case 169:
|
||||
int x = MainUtil.x_loc[j][k];
|
||||
int y = MainUtil.y_loc[j][k];
|
||||
int z = MainUtil.z_loc[j][k];
|
||||
if (isSurrounded(bc.blocks, x, y, z)) {
|
||||
continue;
|
||||
}
|
||||
Object pos = this.classBlockPositionConstructor.create(X + x, y, Z + z);
|
||||
relight.call(pos);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
resetLighting(result);
|
||||
return true;
|
||||
} catch (Throwable e) {
|
||||
e.printStackTrace();
|
||||
|
@ -28,12 +28,6 @@ public class GenChunk extends ScopedLocalBlockQueue {
|
||||
|
||||
public GenChunk(Chunk chunk, ChunkWrapper wrap) {
|
||||
super(null, new Location(null, 0, 0, 0), new Location(null, 15, 255, 15));
|
||||
if ((this.chunk = chunk) == null && (wrap) != null) {
|
||||
World world = BukkitUtil.getWorld(wrap.world);
|
||||
if (world != null) {
|
||||
this.chunk = world.getChunkAt(wrap.x, wrap.z);
|
||||
}
|
||||
}
|
||||
this.biomes = Biome.values();
|
||||
}
|
||||
|
||||
@ -168,8 +162,6 @@ public class GenChunk extends ScopedLocalBlockQueue {
|
||||
return new Location(getWorld(), getX() << 4, 0, getZ() << 4);
|
||||
}
|
||||
|
||||
|
||||
|
||||
public GenChunk clone() {
|
||||
GenChunk toReturn = new GenChunk(chunk, new ChunkWrapper(getWorld(), chunk.getX(), chunk.getZ()));
|
||||
if (this.result != null) {
|
||||
@ -193,7 +185,7 @@ public class GenChunk extends ScopedLocalBlockQueue {
|
||||
}
|
||||
|
||||
public GenChunk shallowClone() {
|
||||
GenChunk toReturn = new GenChunk(chunk, new ChunkWrapper(getWorld(), chunk.getX(), chunk.getZ()));
|
||||
GenChunk toReturn = new GenChunk(chunk, new ChunkWrapper(getWorld(), getX(), getZ()));
|
||||
toReturn.result = this.result;
|
||||
toReturn.result_data = this.result_data;
|
||||
toReturn.cd = this.cd;
|
||||
|
@ -10,8 +10,8 @@ loadbefore: [MultiWorld, Multiverse-Core]
|
||||
database: false
|
||||
commands:
|
||||
plots:
|
||||
description: PlotSquared PlotSquared command.
|
||||
aliases: [p,plot,ps,plotsquared,p2,2]
|
||||
description: Plot command.
|
||||
aliases: [p,plot,ps,plotsquared,p2,2,plotme]
|
||||
permission: plots.use
|
||||
permission-message: "You are lacking the permission node 'plots.use'"
|
||||
permissions:
|
||||
@ -153,3 +153,156 @@ permissions:
|
||||
default: op
|
||||
plots.confirm.bypass:
|
||||
default: false
|
||||
plotme.use:
|
||||
description: Gives default user commands
|
||||
children:
|
||||
plots.permpack.basic: true
|
||||
plots.plot.1: true
|
||||
plotme.admin:
|
||||
description: Gives default administrator commands
|
||||
children:
|
||||
plots.admin: true
|
||||
plotme.use.middle:
|
||||
children:
|
||||
plots.middle: true
|
||||
plotme.use.buy:
|
||||
children:
|
||||
plots.buy: true
|
||||
plotme.use.sell:
|
||||
children:
|
||||
plots.set: true
|
||||
plots.flag: true
|
||||
plots.set.flag: true
|
||||
plots.set.price.*: true
|
||||
plotme.use.dispose:
|
||||
children:
|
||||
plots.delete: true
|
||||
plotme.use.done:
|
||||
children:
|
||||
plots.done: true
|
||||
plotme.use.claim:
|
||||
children:
|
||||
plots.claim: true
|
||||
plotme.use.auto:
|
||||
children:
|
||||
plots.auto: true
|
||||
plotme.use.reset:
|
||||
children:
|
||||
plots.delete: true
|
||||
plotme.use.home:
|
||||
children:
|
||||
plots.home: true
|
||||
plotme.use.info:
|
||||
children:
|
||||
plots.info: true
|
||||
plotme.use.biome:
|
||||
children:
|
||||
plots.set: true
|
||||
plots.set.biome: true
|
||||
plotme.use.clear:
|
||||
children:
|
||||
plots.clear: true
|
||||
plotme.use.list:
|
||||
children:
|
||||
plots.list: true
|
||||
plots.list.forsale: true
|
||||
plots.list.mine: true
|
||||
plots.list.shared: true
|
||||
plotme.use.add:
|
||||
children:
|
||||
plots.add: true
|
||||
plots.trust: true
|
||||
plots.add.everyone: true
|
||||
plots.trust.everyone: true
|
||||
plotme.use.deny:
|
||||
children:
|
||||
plots.deny: true
|
||||
plots.deny.everyone: true
|
||||
plotme.use.remove:
|
||||
children:
|
||||
plots.remove: true
|
||||
plotme.use.undeny:
|
||||
children:
|
||||
plots.remove: true
|
||||
plotme.use.protect:
|
||||
children:
|
||||
plots.set: true
|
||||
plots.flag: true
|
||||
plots.set.flag: true
|
||||
plots.set.keep.*: true
|
||||
plotme.use.nameplot:
|
||||
children:
|
||||
plots.set.alias: true
|
||||
plotme.limit.*:
|
||||
children:
|
||||
plots.plot.*: true
|
||||
plotme.limit.1:
|
||||
children:
|
||||
plots.plot.1: true
|
||||
plotme.limit.5:
|
||||
children:
|
||||
plots.plot.5: true
|
||||
plotme.limit.10:
|
||||
children:
|
||||
plots.plot.10: true
|
||||
plotme.admin.home.other:
|
||||
children:
|
||||
plots.plot.: true
|
||||
plotme.admin.clear:
|
||||
children:
|
||||
plots.admin.command.clear: true
|
||||
plotme.admin.reset:
|
||||
children:
|
||||
plots.admin.command.delete: true
|
||||
plotme.admin.add:
|
||||
children:
|
||||
plots.admin.command.add: true
|
||||
plotme.admin.deny:
|
||||
children:
|
||||
plots.admin.command.deny: true
|
||||
plotme.admin.remove:
|
||||
children:
|
||||
plots.admin.command.remove: true
|
||||
plotme.admin.undeny:
|
||||
children:
|
||||
plots.admin.command.remove: true
|
||||
plotme.admin.bypassdeny:
|
||||
children:
|
||||
plots.admin.entry.denied: true
|
||||
plotme.admin.setowner:
|
||||
children:
|
||||
plots.admin.command.setowner: true
|
||||
plotme.admin.move:
|
||||
children:
|
||||
plots.admin.command.move: true
|
||||
plotme.admin.weanywhere:
|
||||
children:
|
||||
plots.worldedit.bypass: true
|
||||
plotme.admin.list:
|
||||
children:
|
||||
plots.list.world: true
|
||||
plots.list.world.*: true
|
||||
plots.list.top: true
|
||||
plots.list.all: true
|
||||
plots.list.unowned: true
|
||||
plots.list.unknown: true
|
||||
plots.list.player: true
|
||||
plots.list.done: true
|
||||
plots.list.expired: true
|
||||
plots.list.fuzzy: true
|
||||
plots.list.area: true
|
||||
plotme.admin.dispose:
|
||||
children:
|
||||
plots.admin.command.delete: true
|
||||
plotme.admin.done:
|
||||
children:
|
||||
plots.admin.command.done: true
|
||||
plotme.admin.expired:
|
||||
children:
|
||||
plots.list.expired: true
|
||||
plotme.admin.buildanywhere:
|
||||
children:
|
||||
plots.admin.vehicle.*: true
|
||||
plots.admin.interact.*: true
|
||||
plots.admin.build.*: true
|
||||
plots.admin.destroy.*: true
|
@ -7,5 +7,5 @@ dependencies {
|
||||
sourceCompatibility = 1.7
|
||||
targetCompatibility = 1.7
|
||||
|
||||
jar.archiveName = "PlotSquared-Core-${parent.version}.jar"
|
||||
jar.archiveName = rootProject.name + "-Core-${parent.version}.jar"
|
||||
jar.destinationDir = file '../target'
|
@ -29,9 +29,6 @@ public class MemoryConfiguration extends MemorySection implements Configuration
|
||||
|
||||
@Override
|
||||
public void addDefault(String path, Object value) {
|
||||
if (path == null) {
|
||||
throw new NullPointerException("Path may not be null");
|
||||
}
|
||||
if (this.defaults == null) {
|
||||
this.defaults = new MemoryConfiguration();
|
||||
}
|
||||
@ -41,10 +38,6 @@ public class MemoryConfiguration extends MemorySection implements Configuration
|
||||
|
||||
@Override
|
||||
public void addDefaults(Map<String, Object> defaults) {
|
||||
if (defaults == null) {
|
||||
throw new NullPointerException("Defaults may not be null");
|
||||
}
|
||||
|
||||
for (Map.Entry<String, Object> entry : defaults.entrySet()) {
|
||||
addDefault(entry.getKey(), entry.getValue());
|
||||
}
|
||||
@ -52,10 +45,6 @@ public class MemoryConfiguration extends MemorySection implements Configuration
|
||||
|
||||
@Override
|
||||
public void addDefaults(Configuration defaults) {
|
||||
if (defaults == null) {
|
||||
throw new NullPointerException("Defaults may not be null");
|
||||
}
|
||||
|
||||
addDefaults(defaults.getValues(true));
|
||||
}
|
||||
|
||||
|
@ -49,13 +49,6 @@ public class MemorySection implements ConfigurationSection {
|
||||
* if parent contains no root Configuration.
|
||||
*/
|
||||
protected MemorySection(ConfigurationSection parent, String path) {
|
||||
if (parent == null) {
|
||||
throw new NullPointerException("Parent may not be null");
|
||||
}
|
||||
if (path == null) {
|
||||
throw new NullPointerException("Path may not be null");
|
||||
}
|
||||
|
||||
this.path = path;
|
||||
this.parent = parent;
|
||||
this.root = parent.getRoot();
|
||||
@ -133,7 +126,7 @@ public class MemorySection implements ConfigurationSection {
|
||||
* @return Full path of the section from its root.
|
||||
*/
|
||||
public static String createPath(ConfigurationSection section, String key) {
|
||||
return createPath(section, key, (section == null) ? null : section.getRoot());
|
||||
return createPath(section, key, section.getRoot());
|
||||
}
|
||||
|
||||
/**
|
||||
@ -149,9 +142,6 @@ public class MemorySection implements ConfigurationSection {
|
||||
* @return Full path of the section from its root.
|
||||
*/
|
||||
public static String createPath(ConfigurationSection section, String key, ConfigurationSection relativeTo) {
|
||||
if (section == null) {
|
||||
throw new NullPointerException("Cannot create path without a section");
|
||||
}
|
||||
Configuration root = section.getRoot();
|
||||
if (root == null) {
|
||||
throw new IllegalStateException("Cannot create path without a root");
|
||||
@ -253,10 +243,6 @@ public class MemorySection implements ConfigurationSection {
|
||||
|
||||
@Override
|
||||
public void addDefault(String path, Object value) {
|
||||
if (path == null) {
|
||||
throw new NullPointerException("Path cannot be null");
|
||||
}
|
||||
|
||||
Configuration root = getRoot();
|
||||
if (root == null) {
|
||||
throw new IllegalStateException("Cannot add default without root");
|
||||
@ -283,10 +269,6 @@ public class MemorySection implements ConfigurationSection {
|
||||
|
||||
@Override
|
||||
public void set(String path, Object value) {
|
||||
if (path == null) {
|
||||
throw new NullPointerException("Cannot set to an empty path");
|
||||
}
|
||||
|
||||
Configuration root = getRoot();
|
||||
if (root == null) {
|
||||
throw new IllegalStateException("Cannot use section without a root");
|
||||
@ -367,9 +349,6 @@ public class MemorySection implements ConfigurationSection {
|
||||
|
||||
@Override
|
||||
public ConfigurationSection createSection(String path) {
|
||||
if (path == null) {
|
||||
throw new NullPointerException("Cannot create section at empty path");
|
||||
}
|
||||
Configuration root = getRoot();
|
||||
if (root == null) {
|
||||
throw new IllegalStateException("Cannot create section without a root");
|
||||
@ -787,10 +766,6 @@ public class MemorySection implements ConfigurationSection {
|
||||
}
|
||||
|
||||
protected Object getDefault(String path) {
|
||||
if (path == null) {
|
||||
throw new NullPointerException("Path may not be null");
|
||||
}
|
||||
|
||||
Configuration root = getRoot();
|
||||
Configuration defaults = root == null ? null : root.getDefaults();
|
||||
return (defaults == null) ? null : defaults.get(createPath(this, path));
|
||||
|
@ -52,7 +52,10 @@ public abstract class FileConfiguration extends MemoryConfiguration {
|
||||
* any reason.
|
||||
*/
|
||||
public void save(File file) throws IOException {
|
||||
file.getParentFile().mkdirs();
|
||||
File parent = file.getParentFile();
|
||||
if (parent != null) {
|
||||
parent.mkdirs();
|
||||
}
|
||||
|
||||
String data = saveToString();
|
||||
|
||||
@ -87,9 +90,6 @@ public abstract class FileConfiguration extends MemoryConfiguration {
|
||||
* @throws IllegalArgumentException Thrown when file is null.
|
||||
*/
|
||||
public void load(File file) throws IOException, InvalidConfigurationException {
|
||||
if (file == null) {
|
||||
throw new NullPointerException("File cannot be null");
|
||||
}
|
||||
|
||||
FileInputStream stream = new FileInputStream(file);
|
||||
|
||||
@ -123,33 +123,7 @@ public abstract class FileConfiguration extends MemoryConfiguration {
|
||||
|
||||
loadFromString(builder.toString());
|
||||
}
|
||||
|
||||
/**
|
||||
* Loads this {@link FileConfiguration} from the specified location.
|
||||
*
|
||||
* <p>All the values contained within this configuration will be removed,
|
||||
* leaving only settings and defaults, and the new values will be loaded
|
||||
* from the given file.
|
||||
*
|
||||
* <p>If the file cannot be loaded for any reason, an exception will be
|
||||
* thrown.
|
||||
*
|
||||
* @param file File to load from.
|
||||
* @throws FileNotFoundException Thrown when the given file cannot be
|
||||
* opened.
|
||||
* @throws IOException Thrown when the given file cannot be read.
|
||||
* @throws InvalidConfigurationException Thrown when the given file is not
|
||||
* a valid Configuration.
|
||||
* @throws IllegalArgumentException Thrown when file is null.
|
||||
*/
|
||||
public void load(String file) throws IOException, InvalidConfigurationException {
|
||||
if (file == null) {
|
||||
throw new NullPointerException("File cannot be null");
|
||||
}
|
||||
|
||||
load(new File(file));
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Loads this {@link FileConfiguration} from the specified string, as
|
||||
* opposed to from file.
|
||||
|
@ -11,7 +11,6 @@ import org.yaml.snakeyaml.representer.Representer;
|
||||
|
||||
import java.io.File;
|
||||
import java.io.IOException;
|
||||
import java.io.Reader;
|
||||
import java.nio.file.Files;
|
||||
import java.nio.file.StandardCopyOption;
|
||||
import java.util.Map;
|
||||
@ -38,13 +37,8 @@ public class YamlConfiguration extends FileConfiguration {
|
||||
*
|
||||
* @param file Input file
|
||||
* @return Resulting configuration
|
||||
* @throws IllegalArgumentException Thrown if file is null
|
||||
*/
|
||||
public static YamlConfiguration loadConfiguration(File file) {
|
||||
if (file == null) {
|
||||
throw new NullPointerException("File cannot be null");
|
||||
}
|
||||
|
||||
YamlConfiguration config = new YamlConfiguration();
|
||||
|
||||
try {
|
||||
@ -70,34 +64,6 @@ public class YamlConfiguration extends FileConfiguration {
|
||||
return config;
|
||||
}
|
||||
|
||||
/**
|
||||
* Creates a new {@link YamlConfiguration}, loading from the given reader.
|
||||
*
|
||||
* <p>Any errors loading the Configuration will be logged and then ignored.
|
||||
* If the specified input is not a valid config, a blank config will be
|
||||
* returned.
|
||||
*
|
||||
* @param reader input
|
||||
* @return resulting configuration
|
||||
* @throws IllegalArgumentException Thrown if stream is null
|
||||
*/
|
||||
public static YamlConfiguration loadConfiguration(Reader reader) {
|
||||
if (reader == null) {
|
||||
throw new NullPointerException("Reader cannot be null");
|
||||
}
|
||||
|
||||
YamlConfiguration config = new YamlConfiguration();
|
||||
|
||||
try {
|
||||
config.load(reader);
|
||||
} catch (IOException | InvalidConfigurationException ex) {
|
||||
PS.debug("Cannot load configuration from stream");
|
||||
ex.printStackTrace();
|
||||
}
|
||||
|
||||
return config;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String saveToString() {
|
||||
yamlOptions.setIndent(options().indent());
|
||||
@ -116,9 +82,6 @@ public class YamlConfiguration extends FileConfiguration {
|
||||
|
||||
@Override
|
||||
public void loadFromString(String contents) throws InvalidConfigurationException {
|
||||
if (contents == null) {
|
||||
throw new NullPointerException("Contents cannot be null");
|
||||
}
|
||||
|
||||
Map<?, ?> input;
|
||||
try {
|
||||
|
@ -168,8 +168,8 @@ public class JSONObject {
|
||||
* 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.
|
||||
*
|
||||
* 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
|
||||
* For example, if an object has a method named <code>"getPluginName"</code>, and if the result of calling
|
||||
* <code>object.getPluginName()</code> is <code>"Larry Fine"</code>, then the JSONObject will contain <code>"name": "Larry
|
||||
* Fine"</code>.
|
||||
*
|
||||
* @param bean An object that has getter methods that should be used to make a JSONObject.
|
||||
|
@ -69,6 +69,12 @@ public interface IPlotMain extends ILogger {
|
||||
*/
|
||||
String getPluginVersionString();
|
||||
|
||||
/**
|
||||
* Usually PlotSquared
|
||||
* @return
|
||||
*/
|
||||
String getPluginName();
|
||||
|
||||
/**
|
||||
* Get the version of Minecraft that is running.
|
||||
* @return
|
||||
@ -222,7 +228,7 @@ public interface IPlotMain extends ILogger {
|
||||
*/
|
||||
GeneratorWrapper<?> getGenerator(String world, String name);
|
||||
|
||||
GeneratorWrapper<?> wrapPlotGenerator(IndependentPlotGenerator generator);
|
||||
GeneratorWrapper<?> wrapPlotGenerator(String world, IndependentPlotGenerator generator);
|
||||
|
||||
/**
|
||||
* Register the chunk processor which will clean out chunks that have too
|
||||
@ -236,6 +242,12 @@ public interface IPlotMain extends ILogger {
|
||||
*/
|
||||
void registerWorldEvents();
|
||||
|
||||
/**
|
||||
* Usually HybridGen
|
||||
* @return Default implementation generator
|
||||
*/
|
||||
IndependentPlotGenerator getDefaultGenerator();
|
||||
|
||||
/**
|
||||
* Get the class that will manage player titles.
|
||||
* @return
|
||||
|
@ -149,12 +149,12 @@ public class PS {
|
||||
}
|
||||
}
|
||||
if (getJavaVersion() < 1.8) {
|
||||
PS.log(C.CONSOLE_JAVA_OUTDATED_1_8);
|
||||
PS.log(C.CONSOLE_JAVA_OUTDATED_1_8.f(IMP.getPluginName()));
|
||||
}
|
||||
TaskManager.IMP = this.IMP.getTaskManager();
|
||||
setupConfigs();
|
||||
this.translationFile =
|
||||
MainUtil.getFile(this.IMP.getDirectory(), Settings.Paths.TRANSLATIONS + File.separator + "PlotSquared.use_THIS.yml");
|
||||
MainUtil.getFile(this.IMP.getDirectory(), Settings.Paths.TRANSLATIONS + File.separator + IMP.getPluginName() + ".use_THIS.yml");
|
||||
C.load(this.translationFile);
|
||||
|
||||
// Database
|
||||
@ -177,7 +177,7 @@ public class PS {
|
||||
if (Settings.Enabled_Components.METRICS) {
|
||||
this.IMP.startMetrics();
|
||||
} else {
|
||||
PS.log(C.CONSOLE_PLEASE_ENABLE_METRICS);
|
||||
PS.log(C.CONSOLE_PLEASE_ENABLE_METRICS.f(IMP.getPluginName()));
|
||||
}
|
||||
if (Settings.Enabled_Components.CHUNK_PROCESSOR) {
|
||||
this.IMP.registerChunkProcessor();
|
||||
@ -221,7 +221,7 @@ public class PS {
|
||||
if (Settings.Enabled_Components.WORLDEDIT_RESTRICTIONS) {
|
||||
try {
|
||||
if (this.IMP.initWorldEdit()) {
|
||||
PS.debug("PlotSquared hooked into WorldEdit.");
|
||||
PS.debug(IMP.getPluginName() + " hooked into WorldEdit.");
|
||||
this.worldedit = WorldEdit.getInstance();
|
||||
WorldEdit.getInstance().getEventBus().register(new WESubscriber());
|
||||
if (Settings.Enabled_Components.COMMANDS) {
|
||||
@ -252,7 +252,7 @@ public class PS {
|
||||
if (url != null) {
|
||||
PS.this.update = url;
|
||||
} else if (PS.this.lastVersion == null) {
|
||||
PS.log("&aThanks for installing PlotSquared!");
|
||||
PS.log("&aThanks for installing " + IMP.getPluginName() + "!");
|
||||
} else if (!get().checkVersion(PS.this.lastVersion, PS.this.version)) {
|
||||
PS.log("&aThanks for updating from " + StringMan.join(PS.this.lastVersion, ".") + " to " + StringMan
|
||||
.join(PS.this.version, ".") + "!");
|
||||
@ -281,7 +281,7 @@ public class PS {
|
||||
continue;
|
||||
}
|
||||
if (!WorldUtil.IMP.isWorld(world)) {
|
||||
debug("&c`" + world + "` was not properly loaded - PlotSquared will now try to load it properly: ");
|
||||
debug("&c`" + world + "` was not properly loaded - " + IMP.getPluginName() + " will now try to load it properly: ");
|
||||
debug(
|
||||
"&8 - &7Are you trying to delete this world? Remember to remove it from the settings.yml, bukkit.yml and "
|
||||
+ "multiverse worlds.yml");
|
||||
@ -305,9 +305,7 @@ public class PS {
|
||||
} catch (Throwable e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
if (!C.ENABLED.s().isEmpty()) {
|
||||
PS.log(C.ENABLED);
|
||||
}
|
||||
PS.log(C.ENABLED.f(IMP.getPluginName()));
|
||||
}
|
||||
|
||||
/**
|
||||
@ -319,6 +317,13 @@ public class PS {
|
||||
return PS.instance;
|
||||
}
|
||||
|
||||
public static IPlotMain imp() {
|
||||
if (instance != null) {
|
||||
return instance.IMP;
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
/**
|
||||
* Log a message to the IPlotMain logger.
|
||||
*
|
||||
@ -326,6 +331,9 @@ public class PS {
|
||||
* @see IPlotMain#log(String)
|
||||
*/
|
||||
public static void log(Object message) {
|
||||
if (message == null || message.toString().isEmpty()) {
|
||||
return;
|
||||
}
|
||||
PS.get().getLogger().log(StringMan.getString(message));
|
||||
}
|
||||
|
||||
@ -400,7 +408,7 @@ public class PS {
|
||||
|
||||
private void startPlotMeConversion() {
|
||||
if (Settings.Enabled_Components.PLOTME_CONVERTER || Settings.PlotMe.CACHE_UUDS) {
|
||||
TaskManager.runTaskLater(new Runnable() {
|
||||
TaskManager.IMP.taskAsync(new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
if (PS.this.IMP.initPlotMeConverter()) {
|
||||
@ -408,11 +416,12 @@ public class PS {
|
||||
PS.log("&cTHIS MESSAGE MAY BE EXTREMELY HELPFUL IF YOU HAVE TROUBLE CONVERTING PlotMe!");
|
||||
PS.log("&c - Make sure 'UUID.read-from-disk' is disabled (false)!");
|
||||
PS.log("&c - Sometimes the database can be locked, deleting PlotMe.jar beforehand will fix the issue!");
|
||||
PS.log("&c - After the conversion is finished, please set 'plotme-convert.enabled' to false in the "
|
||||
PS.log("&c - After the conversion is finished, please set 'plotme-converter' to false in the "
|
||||
+ "'settings.yml'");
|
||||
}
|
||||
Settings.Enabled_Components.PLOTME_CONVERTER = false;
|
||||
}
|
||||
}, 20);
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
@ -737,7 +746,7 @@ public class PS {
|
||||
* @param area the {@code PlotArea} to remove
|
||||
*/
|
||||
public void removePlotArea(PlotArea area) {
|
||||
Set<PlotArea> areas = getPlotAreas(area.worldname);
|
||||
Set<PlotArea> areas = getPlotAreas();
|
||||
areas.remove(area);
|
||||
this.plotAreas = areas.toArray(new PlotArea[areas.size()]);
|
||||
if (areas.isEmpty()) {
|
||||
@ -752,7 +761,9 @@ public class PS {
|
||||
|
||||
public void removePlotAreas(String world) {
|
||||
for (PlotArea area : getPlotAreas(world)) {
|
||||
removePlotArea(area);
|
||||
if (area.worldname.equals(world)) {
|
||||
removePlotArea(area);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@ -1460,7 +1471,7 @@ public class PS {
|
||||
return;
|
||||
}
|
||||
PS.log(C.PREFIX + "&aDetected world load for '" + world + "'");
|
||||
String gen_string = worldSection.getString("generator.plugin", "PlotSquared");
|
||||
String gen_string = worldSection.getString("generator.plugin", IMP.getPluginName());
|
||||
if (type == 2) {
|
||||
Set<PlotCluster> clusters = this.clusters_tmp != null ? this.clusters_tmp.get(world) : new HashSet<PlotCluster>();
|
||||
if (clusters == null) {
|
||||
@ -1526,16 +1537,13 @@ public class PS {
|
||||
}
|
||||
for (String areaId : areasSection.getKeys(false)) {
|
||||
PS.log(C.PREFIX + "&3 - " + areaId);
|
||||
int i1 = areaId.indexOf('-');
|
||||
int i2 = areaId.indexOf(';');
|
||||
if (i1 == -1 || i2 == -1) {
|
||||
String[] split = areaId.split("(?<=[^;-])-");
|
||||
if (split.length != 3) {
|
||||
throw new IllegalArgumentException("Invalid Area identifier: " + areaId + ". Expected form `<name>-<pos1>-<pos2>`");
|
||||
}
|
||||
String name = areaId.substring(0, i1);
|
||||
String rest = areaId.substring(i1 + 1);
|
||||
int i3 = rest.indexOf('-', i2 - name.length() - 1);
|
||||
PlotId pos1 = PlotId.fromString(rest.substring(0, i3));
|
||||
PlotId pos2 = PlotId.fromString(rest.substring(i3 + 1));
|
||||
String name = split[0];
|
||||
PlotId pos1 = PlotId.fromString(split[1]);
|
||||
PlotId pos2 = PlotId.fromString(split[2]);
|
||||
if (pos1 == null || pos2 == null || name.isEmpty()) {
|
||||
throw new IllegalArgumentException("Invalid Area identifier: " + areaId + ". Expected form `<name>-<x1;z1>-<x2;z2>`");
|
||||
}
|
||||
@ -1560,7 +1568,7 @@ public class PS {
|
||||
clone.set(key, worldSection.get(key));
|
||||
}
|
||||
}
|
||||
String gen_string = clone.getString("generator.plugin", "PlotSquared");
|
||||
String gen_string = clone.getString("generator.plugin", IMP.getPluginName());
|
||||
GeneratorWrapper<?> areaGen = this.IMP.getGenerator(world, gen_string);
|
||||
if (areaGen == null) {
|
||||
throw new IllegalArgumentException("Invalid Generator: " + gen_string);
|
||||
@ -1708,7 +1716,7 @@ public class PS {
|
||||
}
|
||||
MainUtil.sendMessage(sender, "$2 - Output: " + newJar);
|
||||
if (!newJar.delete()) {
|
||||
MainUtil.sendMessage(sender, "Failed to update PlotSquared");
|
||||
MainUtil.sendMessage(sender, "Failed to update " + IMP.getPluginName() + "");
|
||||
MainUtil.sendMessage(sender, "Jar file failed to delete.");
|
||||
MainUtil.sendMessage(sender, " - Please update manually");
|
||||
}
|
||||
@ -1717,7 +1725,7 @@ public class PS {
|
||||
MainUtil.sendMessage(sender, "$1The update will take effect when the server is restarted next");
|
||||
return true;
|
||||
} catch (IOException e) {
|
||||
MainUtil.sendMessage(sender, "Failed to update PlotSquared");
|
||||
MainUtil.sendMessage(sender, "Failed to update " + IMP.getPluginName() + "");
|
||||
MainUtil.sendMessage(sender, " - Please update manually");
|
||||
PS.log("============ Stacktrace ============");
|
||||
e.printStackTrace();
|
||||
@ -1848,7 +1856,7 @@ public class PS {
|
||||
PS.log("&d==== Here is an ugly stacktrace, if you are interested in those things ===");
|
||||
e.printStackTrace();
|
||||
PS.log("&d==== End of stacktrace ====");
|
||||
PS.log("&6Please go to the PlotSquared 'storage.yml' and configure the database correctly.");
|
||||
PS.log("&6Please go to the " + IMP.getPluginName() + " 'storage.yml' and configure the database correctly.");
|
||||
this.IMP.disable();
|
||||
}
|
||||
}
|
||||
@ -1871,7 +1879,7 @@ public class PS {
|
||||
try {
|
||||
worlds.save(worldsFile);
|
||||
} catch (IOException e) {
|
||||
PS.debug("Failed to save PlotSquared worlds.yml");
|
||||
PS.debug("Failed to save " + IMP.getPluginName() + " worlds.yml");
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
|
@ -1,23 +1,23 @@
|
||||
package com.intellectualcrafters.plot;
|
||||
|
||||
import static com.intellectualcrafters.plot.PS.log;
|
||||
|
||||
import com.intellectualcrafters.json.JSONArray;
|
||||
import com.intellectualcrafters.json.JSONObject;
|
||||
import com.intellectualcrafters.plot.util.HttpUtil;
|
||||
import com.intellectualcrafters.plot.util.StringMan;
|
||||
|
||||
import java.net.MalformedURLException;
|
||||
import java.net.URL;
|
||||
import java.util.Arrays;
|
||||
|
||||
|
||||
import static com.intellectualcrafters.plot.PS.log;
|
||||
|
||||
public class Updater {
|
||||
|
||||
public static URL getUpdate() {
|
||||
String str = HttpUtil.readUrl("https://api.github.com/repos/IntellectualSites/PlotSquared/releases/latest");
|
||||
JSONObject release = new JSONObject(str);
|
||||
JSONArray assets = (JSONArray) release.get("assets");
|
||||
String downloadURL = String.format("PlotSquared-%s.jar", PS.get().getPlatform());
|
||||
String downloadURL = String.format(PS.imp().getPluginName() + "-%s.jar", PS.get().getPlatform());
|
||||
for (int i = 0; i < assets.length(); i++) {
|
||||
JSONObject asset = assets.getJSONObject(i);
|
||||
String name = asset.getString("name");
|
||||
@ -33,11 +33,11 @@ public class Updater {
|
||||
// If current version >= update
|
||||
if (PS.get().checkVersion(PS.get().getVersion(), version)) {
|
||||
if (!PS.get().IMP.getPluginVersionString().contains("-SNAPSHOT") || !Arrays.equals(PS.get().getVersion(), version)) {
|
||||
PS.debug("&7PlotSquared is already up to date!");
|
||||
PS.debug("&7" + PS.imp().getPluginName() + " is already up to date!");
|
||||
return null;
|
||||
}
|
||||
}
|
||||
log("&6PlotSquared " + StringMan.join(split, ".") + " is available:");
|
||||
log("&6" + PS.imp().getPluginName() + " " + StringMan.join(split, ".") + " is available:");
|
||||
log("&8 - &3Use: &7/plot update");
|
||||
log("&8 - &3Or: &7" + downloadURL);
|
||||
return new URL(asset.getString("browser_download_url"));
|
||||
@ -48,7 +48,7 @@ public class Updater {
|
||||
}
|
||||
}
|
||||
}
|
||||
log("You are running the latest version of PlotSquared");
|
||||
log("You are running the latest version of " + PS.imp().getPluginName() + "!");
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
@ -18,7 +18,6 @@ import java.util.UUID;
|
||||
|
||||
@CommandDeclaration(
|
||||
command = "add",
|
||||
aliases = {"a"},
|
||||
description = "Allow a user to build while you are online",
|
||||
usage = "/plot add <player>",
|
||||
category = CommandCategory.SETTINGS,
|
||||
@ -34,7 +33,7 @@ public class Add extends Command {
|
||||
public void execute(final PlotPlayer player, String[] args, RunnableVal3<Command, Runnable, Runnable> confirm, RunnableVal2<Command, CommandResult> whenDone) throws CommandException {
|
||||
final Plot plot = check(player.getCurrentPlot(), C.NOT_IN_PLOT);
|
||||
checkTrue(plot.hasOwner(), C.PLOT_UNOWNED);
|
||||
checkTrue(plot.isOwner(player.getUUID()) || Permissions.hasPermission(player, "plots.admin.command.trust"), C.NO_PLOT_PERMS);
|
||||
checkTrue(plot.isOwner(player.getUUID()) || Permissions.hasPermission(player, C.PERMISSION_ADMIN_COMMAND_TRUST), C.NO_PLOT_PERMS);
|
||||
checkTrue(args.length == 1, C.COMMAND_SYNTAX, getUsage());
|
||||
final Set<UUID> uuids = MainUtil.getUUIDsFromString(args[0]);
|
||||
checkTrue(!uuids.isEmpty(), C.INVALID_PLAYER, args[0]);
|
||||
@ -42,7 +41,7 @@ public class Add extends Command {
|
||||
int size = plot.getTrusted().size() + plot.getMembers().size();
|
||||
while (iter.hasNext()) {
|
||||
UUID uuid = iter.next();
|
||||
if (uuid == DBFunc.everyone && !(Permissions.hasPermission(player, "plots.trust.everyone") || Permissions.hasPermission(player, "plots.admin.command.trust"))) {
|
||||
if (uuid == DBFunc.everyone && !(Permissions.hasPermission(player, C.PERMISSION_TRUST_EVERYONE) || Permissions.hasPermission(player, C.PERMISSION_ADMIN_COMMAND_TRUST))) {
|
||||
MainUtil.sendMessage(player, C.INVALID_PLAYER, MainUtil.getName(uuid));
|
||||
iter.remove();
|
||||
continue;
|
||||
@ -60,7 +59,7 @@ public class Add extends Command {
|
||||
size += plot.getTrusted().contains(uuid) ? 0 : 1;
|
||||
}
|
||||
checkTrue(!uuids.isEmpty(), null);
|
||||
checkTrue(size <= plot.getArea().MAX_PLOT_MEMBERS || Permissions.hasPermission(player, "plots.admin.command.trust"), C.PLOT_MAX_MEMBERS);
|
||||
checkTrue(size <= plot.getArea().MAX_PLOT_MEMBERS || Permissions.hasPermission(player, C.PERMISSION_ADMIN_COMMAND_TRUST), C.PLOT_MAX_MEMBERS);
|
||||
confirm.run(this, new Runnable() {
|
||||
@Override // Success
|
||||
public void run() {
|
||||
|
@ -15,7 +15,7 @@ import com.plotsquared.general.commands.CommandDeclaration;
|
||||
permission = "plots.set.alias",
|
||||
description = "Set the plot name",
|
||||
usage = "/plot alias <alias>",
|
||||
aliases = {"alias", "sa", "name", "rename", "setname", "seta"},
|
||||
aliases = {"alias", "sa", "name", "rename", "setname", "seta", "nameplot"},
|
||||
category = CommandCategory.SETTINGS,
|
||||
requiredType = RequiredType.NONE)
|
||||
public class Alias extends SetCommand {
|
||||
|
@ -5,7 +5,6 @@ import com.intellectualcrafters.plot.PS;
|
||||
import com.intellectualcrafters.plot.config.C;
|
||||
import com.intellectualcrafters.plot.config.Configuration;
|
||||
import com.intellectualcrafters.plot.generator.AugmentedUtils;
|
||||
import com.intellectualcrafters.plot.generator.HybridGen;
|
||||
import com.intellectualcrafters.plot.generator.HybridPlotWorld;
|
||||
import com.intellectualcrafters.plot.object.ChunkLoc;
|
||||
import com.intellectualcrafters.plot.object.Location;
|
||||
@ -26,7 +25,6 @@ import com.intellectualcrafters.plot.util.SetupUtils;
|
||||
import com.intellectualcrafters.plot.util.StringMan;
|
||||
import com.intellectualcrafters.plot.util.WorldUtil;
|
||||
import com.plotsquared.general.commands.CommandDeclaration;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Objects;
|
||||
@ -52,8 +50,8 @@ public class Area extends SubCommand {
|
||||
case "c":
|
||||
case "setup":
|
||||
case "create":
|
||||
if (!Permissions.hasPermission(player, "plots.area.create")) {
|
||||
C.NO_PERMISSION.send(player, "plots.area.create");
|
||||
if (!Permissions.hasPermission(player, C.PERMISSION_AREA_CREATE)) {
|
||||
C.NO_PERMISSION.send(player, C.PERMISSION_AREA_CREATE);
|
||||
return false;
|
||||
}
|
||||
switch (args.length) {
|
||||
@ -109,8 +107,8 @@ public class Area extends SubCommand {
|
||||
object.type = area.TYPE;
|
||||
object.min = new PlotId(1, 1);
|
||||
object.max = new PlotId(numX, numZ);
|
||||
object.plotManager = "PlotSquared";
|
||||
object.setupGenerator = "PlotSquared";
|
||||
object.plotManager = PS.imp().getPluginName();
|
||||
object.setupGenerator = PS.imp().getPluginName();
|
||||
object.step = area.getSettingNodes();
|
||||
final String path = "worlds." + area.worldname + ".areas." + area.id + '-' + object.min + '-' + object.max;
|
||||
Runnable run = new Runnable() {
|
||||
@ -157,7 +155,7 @@ public class Area extends SubCommand {
|
||||
id = null;
|
||||
}
|
||||
object.world = split[0];
|
||||
final HybridPlotWorld pa = new HybridPlotWorld(object.world, id, new HybridGen(), null, null);
|
||||
final HybridPlotWorld pa = new HybridPlotWorld(object.world, id, PS.get().IMP.getDefaultGenerator(), null, null);
|
||||
PlotArea other = PS.get().getPlotArea(pa.worldname, id);
|
||||
if (other != null && Objects.equals(pa.id, other.id)) {
|
||||
C.SETUP_WORLD_TAKEN.send(player, pa.toString());
|
||||
@ -237,8 +235,8 @@ public class Area extends SubCommand {
|
||||
ConfigurationSection section = PS.get().worlds.getConfigurationSection(path);
|
||||
pa.saveConfiguration(section);
|
||||
pa.loadConfiguration(section);
|
||||
object.plotManager = "PlotSquared";
|
||||
object.setupGenerator = "PlotSquared";
|
||||
object.plotManager = PS.imp().getPluginName();
|
||||
object.setupGenerator = PS.imp().getPluginName();
|
||||
String world = SetupUtils.manager.setupWorld(object);
|
||||
if (WorldUtil.IMP.isWorld(world)) {
|
||||
C.SETUP_FINISHED.send(player);
|
||||
@ -281,8 +279,8 @@ public class Area extends SubCommand {
|
||||
return true;
|
||||
case "i":
|
||||
case "info": {
|
||||
if (!Permissions.hasPermission(player, "plots.area.info")) {
|
||||
C.NO_PERMISSION.send(player, "plots.area.info");
|
||||
if (!Permissions.hasPermission(player, C.PERMISSION_AREA_INFO)) {
|
||||
C.NO_PERMISSION.send(player, C.PERMISSION_AREA_INFO);
|
||||
return false;
|
||||
}
|
||||
PlotArea area;
|
||||
@ -336,8 +334,8 @@ public class Area extends SubCommand {
|
||||
}
|
||||
case "l":
|
||||
case "list":
|
||||
if (!Permissions.hasPermission(player, "plots.area.list")) {
|
||||
C.NO_PERMISSION.send(player, "plots.area.list");
|
||||
if (!Permissions.hasPermission(player, C.PERMISSION_AREA_LIST)) {
|
||||
C.NO_PERMISSION.send(player, C.PERMISSION_AREA_LIST);
|
||||
return false;
|
||||
}
|
||||
int page;
|
||||
@ -398,8 +396,8 @@ public class Area extends SubCommand {
|
||||
case "clear":
|
||||
case "reset":
|
||||
case "regenerate": {
|
||||
if (!Permissions.hasPermission(player, "plots.area.regen")) {
|
||||
C.NO_PERMISSION.send(player, "plots.area.regen");
|
||||
if (!Permissions.hasPermission(player, C.PERMISSION_AREA_REGEN)) {
|
||||
C.NO_PERMISSION.send(player, C.PERMISSION_AREA_REGEN);
|
||||
return false;
|
||||
}
|
||||
final PlotArea area = player.getApplicablePlotArea();
|
||||
@ -424,8 +422,8 @@ public class Area extends SubCommand {
|
||||
case "teleport":
|
||||
case "visit":
|
||||
case "tp":
|
||||
if (!Permissions.hasPermission(player, "plots.area.tp")) {
|
||||
C.NO_PERMISSION.send(player, "plots.area.tp");
|
||||
if (!Permissions.hasPermission(player, C.PERMISSION_AREA_TP)) {
|
||||
C.NO_PERMISSION.send(player, C.PERMISSION_AREA_TP);
|
||||
return false;
|
||||
}
|
||||
if (args.length != 2) {
|
||||
@ -452,7 +450,7 @@ public class Area extends SubCommand {
|
||||
case "remove":
|
||||
MainUtil.sendMessage(player, "$1World creation settings may be stored in multiple locations:"
|
||||
+ "\n$3 - $2Bukkit bukkit.yml"
|
||||
+ "\n$3 - $2PlotSquared settings.yml"
|
||||
+ "\n$3 - $2" + PS.imp().getPluginName() + " settings.yml"
|
||||
+ "\n$3 - $2Multiverse worlds.yml (or any world management plugin)"
|
||||
+ "\n$1Stop the server and delete it from these locations.");
|
||||
return true;
|
||||
|
@ -10,6 +10,7 @@ import com.intellectualcrafters.plot.object.PlotPlayer;
|
||||
import com.intellectualcrafters.plot.util.ByteArrayUtilities;
|
||||
import com.intellectualcrafters.plot.util.EconHandler;
|
||||
import com.intellectualcrafters.plot.util.MainUtil;
|
||||
import com.intellectualcrafters.plot.util.MathMan;
|
||||
import com.intellectualcrafters.plot.util.Permissions;
|
||||
import com.plotsquared.general.commands.CommandDeclaration;
|
||||
|
||||
@ -62,7 +63,7 @@ public class Auto extends SubCommand {
|
||||
int size_z = 1;
|
||||
String schematic = null;
|
||||
if (args.length > 0) {
|
||||
if (Permissions.hasPermission(player, "plots.auto.mega")) {
|
||||
if (Permissions.hasPermission(player, C.PERMISSION_AUTO_MEGA)) {
|
||||
try {
|
||||
String[] split = args[0].split(",|;");
|
||||
size_x = Integer.parseInt(split[0]);
|
||||
@ -134,8 +135,8 @@ public class Auto extends SubCommand {
|
||||
sendMessage(player, C.SCHEMATIC_INVALID, "non-existent: " + schematic);
|
||||
return true;
|
||||
}
|
||||
if (!Permissions.hasPermission(player, "plots.claim." + schematic) && !Permissions.hasPermission(player, "plots.admin.command.schematic")) {
|
||||
MainUtil.sendMessage(player, C.NO_SCHEMATIC_PERMISSION, schematic);
|
||||
if (!Permissions.hasPermission(player, C.PERMISSION_CLAIM_SCHEMATIC.f(schematic)) && !Permissions.hasPermission(player, C.PERMISSION_ADMIN_COMMAND_SCHEMATIC)) {
|
||||
MainUtil.sendMessage(player, C.NO_PERMISSION, C.PERMISSION_CLAIM_SCHEMATIC.f(schematic));
|
||||
return true;
|
||||
}
|
||||
}
|
||||
@ -143,7 +144,7 @@ public class Auto extends SubCommand {
|
||||
if (plotarea.TYPE == 2) {
|
||||
PlotId bot = plotarea.getMin();
|
||||
PlotId top = plotarea.getMax();
|
||||
PlotId origin = new PlotId((bot.x + top.x) / 2, (bot.y + top.y) / 2);
|
||||
PlotId origin = new PlotId(MathMan.average(bot.x, top.x), MathMan.average(bot.y, top.y));
|
||||
PlotId id = new PlotId(0, 0);
|
||||
int width = Math.max(top.x - bot.x + 1, top.y - bot.y + 1);
|
||||
int max = width * width;
|
||||
|
@ -29,7 +29,7 @@ public class BO3 extends SubCommand {
|
||||
if (plot == null || !plot.hasOwner()) {
|
||||
return !sendMessage(player, C.NOT_IN_PLOT);
|
||||
}
|
||||
if (!plot.isOwner(player.getUUID()) && !Permissions.hasPermission(player, "plots.admin.command.bo3")) {
|
||||
if (!plot.isOwner(player.getUUID()) && !Permissions.hasPermission(player, C.PERMISSION_ADMIN_COMMAND_BO3)) {
|
||||
MainUtil.sendMessage(player, C.NO_PLOT_PERMS);
|
||||
return false;
|
||||
}
|
||||
|
@ -17,7 +17,6 @@ import java.util.Set;
|
||||
|
||||
@CommandDeclaration(
|
||||
command = "buy",
|
||||
aliases = {"b"},
|
||||
description = "Buy the plot you are standing on",
|
||||
usage = "/plot buy",
|
||||
permission = "plots.buy",
|
||||
|
@ -72,7 +72,7 @@ public class Claim extends SubCommand {
|
||||
if (!world.SCHEMATICS.contains(schematic.toLowerCase())) {
|
||||
return sendMessage(player, C.SCHEMATIC_INVALID, "non-existent: " + schematic);
|
||||
}
|
||||
if (!Permissions.hasPermission(player, "plots.claim." + schematic) && !Permissions.hasPermission(player, "plots.admin.command.schematic")) {
|
||||
if (!Permissions.hasPermission(player, C.PERMISSION_CLAIM_SCHEMATIC.f(schematic)) && !Permissions.hasPermission(player, C.PERMISSION_ADMIN_COMMAND_SCHEMATIC)) {
|
||||
return sendMessage(player, C.NO_SCHEMATIC_PERMISSION, schematic);
|
||||
}
|
||||
}
|
||||
|
@ -34,9 +34,9 @@ public class Clear extends Command {
|
||||
public void execute(final PlotPlayer player, String[] args, RunnableVal3<Command, Runnable, Runnable> confirm, RunnableVal2<Command, CommandResult> whenDone) throws CommandException {
|
||||
checkTrue(args.length == 0, C.COMMAND_SYNTAX, getUsage());
|
||||
final Plot plot = check(player.getCurrentPlot(), C.NOT_IN_PLOT);
|
||||
checkTrue(plot.isOwner(player.getUUID()) || Permissions.hasPermission(player, "plots.admin.command.clear"), C.NO_PLOT_PERMS);
|
||||
checkTrue(plot.isOwner(player.getUUID()) || Permissions.hasPermission(player, C.PERMISSION_ADMIN_COMMAND_CLEAR), C.NO_PLOT_PERMS);
|
||||
checkTrue(plot.getRunning() == 0, C.WAIT_FOR_TIMER);
|
||||
checkTrue(!Settings.Done.RESTRICT_BUILDING || !Flags.DONE.isSet(plot) || Permissions.hasPermission(player, "plots.continue"), C.DONE_ALREADY_DONE);
|
||||
checkTrue(!Settings.Done.RESTRICT_BUILDING || !Flags.DONE.isSet(plot) || Permissions.hasPermission(player, C.PERMISSION_CONTINUE), C.DONE_ALREADY_DONE);
|
||||
confirm.run(this, new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
|
@ -15,7 +15,6 @@ import com.intellectualcrafters.plot.util.MainUtil;
|
||||
import com.intellectualcrafters.plot.util.Permissions;
|
||||
import com.intellectualcrafters.plot.util.UUIDHandler;
|
||||
import com.plotsquared.general.commands.CommandDeclaration;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashSet;
|
||||
import java.util.Set;
|
||||
@ -42,8 +41,8 @@ public class Cluster extends SubCommand {
|
||||
switch (sub) {
|
||||
case "l":
|
||||
case "list": {
|
||||
if (!Permissions.hasPermission(player, "plots.cluster.list")) {
|
||||
MainUtil.sendMessage(player, C.NO_PERMISSION, "plots.cluster.list");
|
||||
if (!Permissions.hasPermission(player, C.PERMISSION_CLUSTER_LIST)) {
|
||||
MainUtil.sendMessage(player, C.NO_PERMISSION, C.PERMISSION_CLUSTER_LIST);
|
||||
return false;
|
||||
}
|
||||
if (args.length != 1) {
|
||||
@ -74,8 +73,8 @@ public class Cluster extends SubCommand {
|
||||
}
|
||||
case "c":
|
||||
case "create": {
|
||||
if (!Permissions.hasPermission(player, "plots.cluster.create")) {
|
||||
MainUtil.sendMessage(player, C.NO_PERMISSION, "plots.cluster.create");
|
||||
if (!Permissions.hasPermission(player, C.PERMISSION_CLUSTER_CREATE)) {
|
||||
MainUtil.sendMessage(player, C.NO_PERMISSION, C.PERMISSION_CLUSTER_CREATE);
|
||||
return false;
|
||||
}
|
||||
PlotArea area = player.getApplicablePlotArea();
|
||||
@ -87,6 +86,10 @@ public class Cluster extends SubCommand {
|
||||
MainUtil.sendMessage(player, C.COMMAND_SYNTAX, "/plot cluster create <name> <id-bot> <id-top>");
|
||||
return false;
|
||||
}
|
||||
int currentClusters = Settings.Limit.GLOBAL ? player.getClusterCount() : player.getPlotCount(player.getLocation().getWorld());
|
||||
if (currentClusters >= player.getAllowedPlots()) {
|
||||
return sendMessage(player, C.CANT_CLAIM_MORE_CLUSTERS);
|
||||
}
|
||||
// check pos1 / pos2
|
||||
PlotId pos1 = PlotId.fromString(args[2]);
|
||||
PlotId pos2 = PlotId.fromString(args[3]);
|
||||
@ -112,13 +115,17 @@ public class Cluster extends SubCommand {
|
||||
return false;
|
||||
}
|
||||
// Check if it occupies existing plots
|
||||
if (!area.contains(pos1) || !area.contains(pos2)) {
|
||||
C.CLUSTER_OUTSIDE.send(player, area);
|
||||
return false;
|
||||
}
|
||||
Set<Plot> plots = area.getPlotSelectionOwned(pos1, pos2);
|
||||
if (!plots.isEmpty()) {
|
||||
if (!Permissions.hasPermission(player, "plots.cluster.create.other")) {
|
||||
if (!Permissions.hasPermission(player, C.PERMISSION_CLUSTER_CREATE_OTHER)) {
|
||||
UUID uuid = player.getUUID();
|
||||
for (Plot plot : plots) {
|
||||
if (!plot.isOwner(uuid)) {
|
||||
MainUtil.sendMessage(player, C.NO_PERMISSION, "plots.cluster.create.other");
|
||||
MainUtil.sendMessage(player, C.NO_PERMISSION, C.PERMISSION_CLUSTER_CREATE_OTHER);
|
||||
return false;
|
||||
}
|
||||
}
|
||||
@ -132,9 +139,9 @@ public class Cluster extends SubCommand {
|
||||
} else {
|
||||
current = player.getPlayerClusterCount(player.getLocation().getWorld());
|
||||
}
|
||||
int allowed = Permissions.hasPermissionRange(player, "plots.cluster", Settings.Limit.MAX_PLOTS);
|
||||
int allowed = Permissions.hasPermissionRange(player, C.PERMISSION_CLUSTER_SIZE, Settings.Limit.MAX_PLOTS);
|
||||
if (current + cluster.getArea() > allowed) {
|
||||
MainUtil.sendMessage(player, C.NO_PERMISSION, "plots.cluster." + (current + cluster.getArea()));
|
||||
MainUtil.sendMessage(player, C.NO_PERMISSION, C.PERMISSION_CLUSTER_SIZE + "." + (current + cluster.getArea()));
|
||||
return false;
|
||||
}
|
||||
// create cluster
|
||||
@ -156,8 +163,8 @@ public class Cluster extends SubCommand {
|
||||
case "disband":
|
||||
case "del":
|
||||
case "delete": {
|
||||
if (!Permissions.hasPermission(player, "plots.cluster.delete")) {
|
||||
MainUtil.sendMessage(player, C.NO_PERMISSION, "plots.cluster.delete");
|
||||
if (!Permissions.hasPermission(player, C.PERMISSION_CLUSTER_DELETE)) {
|
||||
MainUtil.sendMessage(player, C.NO_PERMISSION, C.PERMISSION_CLUSTER_DELETE);
|
||||
return false;
|
||||
}
|
||||
if (args.length != 1 && args.length != 2) {
|
||||
@ -184,8 +191,8 @@ public class Cluster extends SubCommand {
|
||||
}
|
||||
}
|
||||
if (!cluster.owner.equals(player.getUUID())) {
|
||||
if (!Permissions.hasPermission(player, "plots.cluster.delete.other")) {
|
||||
MainUtil.sendMessage(player, C.NO_PERMISSION, "plots.cluster.delete.other");
|
||||
if (!Permissions.hasPermission(player, C.PERMISSION_CLUSTER_DELETE_OTHER)) {
|
||||
MainUtil.sendMessage(player, C.NO_PERMISSION, C.PERMISSION_CLUSTER_DELETE_OTHER);
|
||||
return false;
|
||||
}
|
||||
}
|
||||
@ -195,8 +202,8 @@ public class Cluster extends SubCommand {
|
||||
}
|
||||
case "res":
|
||||
case "resize": {
|
||||
if (!Permissions.hasPermission(player, "plots.cluster.resize")) {
|
||||
MainUtil.sendMessage(player, C.NO_PERMISSION, "plots.cluster.resize");
|
||||
if (!Permissions.hasPermission(player, C.PERMISSION_CLUSTER_RESIZE)) {
|
||||
MainUtil.sendMessage(player, C.NO_PERMISSION, C.PERMISSION_CLUSTER_RESIZE);
|
||||
return false;
|
||||
}
|
||||
if (args.length != 3) {
|
||||
@ -226,8 +233,8 @@ public class Cluster extends SubCommand {
|
||||
return false;
|
||||
}
|
||||
if (!cluster.hasHelperRights(player.getUUID())) {
|
||||
if (!Permissions.hasPermission(player, "plots.cluster.resize.other")) {
|
||||
MainUtil.sendMessage(player, C.NO_PERMISSION, "plots.cluster.resize.other");
|
||||
if (!Permissions.hasPermission(player, C.PERMISSION_CLUSTER_RESIZE_OTHER)) {
|
||||
MainUtil.sendMessage(player, C.NO_PERMISSION, C.PERMISSION_CLUSTER_RESIZE_OTHER);
|
||||
return false;
|
||||
}
|
||||
}
|
||||
@ -243,15 +250,15 @@ public class Cluster extends SubCommand {
|
||||
removed.removeAll(newPlots);
|
||||
// Check expand / shrink
|
||||
if (!removed.isEmpty()) {
|
||||
if (!Permissions.hasPermission(player, "plots.cluster.resize.shrink")) {
|
||||
MainUtil.sendMessage(player, C.NO_PERMISSION, "plots.cluster.resize.shrink");
|
||||
if (!Permissions.hasPermission(player, C.PERMISSION_CLUSTER_RESIZE_SHRINK)) {
|
||||
MainUtil.sendMessage(player, C.NO_PERMISSION, C.PERMISSION_CLUSTER_RESIZE_SHRINK);
|
||||
return false;
|
||||
}
|
||||
}
|
||||
newPlots.removeAll(existing);
|
||||
if (!newPlots.isEmpty()) {
|
||||
if (!Permissions.hasPermission(player, "plots.cluster.resize.expand")) {
|
||||
MainUtil.sendMessage(player, C.NO_PERMISSION, "plots.cluster.resize.expand");
|
||||
if (!Permissions.hasPermission(player, C.PERMISSION_CLUSTER_RESIZE_EXPAND)) {
|
||||
MainUtil.sendMessage(player, C.NO_PERMISSION, C.PERMISSION_CLUSTER_RESIZE_EXPAND);
|
||||
return false;
|
||||
}
|
||||
}
|
||||
@ -263,9 +270,9 @@ public class Cluster extends SubCommand {
|
||||
current = player.getPlayerClusterCount(player.getLocation().getWorld());
|
||||
}
|
||||
current -= cluster.getArea() + (1 + pos2.x - pos1.x) * (1 + pos2.y - pos1.y);
|
||||
int allowed = Permissions.hasPermissionRange(player, "plots.cluster", Settings.Limit.MAX_PLOTS);
|
||||
int allowed = Permissions.hasPermissionRange(player, C.PERMISSION_CLUSTER, Settings.Limit.MAX_PLOTS);
|
||||
if (current + cluster.getArea() > allowed) {
|
||||
MainUtil.sendMessage(player, C.NO_PERMISSION, "plots.cluster." + (current + cluster.getArea()));
|
||||
MainUtil.sendMessage(player, C.NO_PERMISSION, C.PERMISSION_CLUSTER.s() + "." + (current + cluster.getArea()));
|
||||
return false;
|
||||
}
|
||||
// resize cluster
|
||||
@ -276,8 +283,8 @@ public class Cluster extends SubCommand {
|
||||
case "add":
|
||||
case "inv":
|
||||
case "invite": {
|
||||
if (!Permissions.hasPermission(player, "plots.cluster.invite")) {
|
||||
MainUtil.sendMessage(player, C.NO_PERMISSION, "plots.cluster.invite");
|
||||
if (!Permissions.hasPermission(player, C.PERMISSION_CLUSTER_INVITE)) {
|
||||
MainUtil.sendMessage(player, C.NO_PERMISSION, C.PERMISSION_CLUSTER_INVITE);
|
||||
return false;
|
||||
}
|
||||
if (args.length != 2) {
|
||||
@ -295,8 +302,8 @@ public class Cluster extends SubCommand {
|
||||
return false;
|
||||
}
|
||||
if (!cluster.hasHelperRights(player.getUUID())) {
|
||||
if (!Permissions.hasPermission(player, "plots.cluster.invite.other")) {
|
||||
MainUtil.sendMessage(player, C.NO_PERMISSION, "plots.cluster.invite.other");
|
||||
if (!Permissions.hasPermission(player, C.PERMISSION_CLUSTER_INVITE_OTHER)) {
|
||||
MainUtil.sendMessage(player, C.NO_PERMISSION, C.PERMISSION_CLUSTER_INVITE_OTHER);
|
||||
return false;
|
||||
}
|
||||
}
|
||||
@ -321,8 +328,8 @@ public class Cluster extends SubCommand {
|
||||
case "k":
|
||||
case "remove":
|
||||
case "kick": {
|
||||
if (!Permissions.hasPermission(player, "plots.cluster.kick")) {
|
||||
MainUtil.sendMessage(player, C.NO_PERMISSION, "plots.cluster.kick");
|
||||
if (!Permissions.hasPermission(player, C.PERMISSION_CLUSTER_KICK)) {
|
||||
MainUtil.sendMessage(player, C.NO_PERMISSION, C.PERMISSION_CLUSTER_KICK);
|
||||
return false;
|
||||
}
|
||||
if (args.length != 2) {
|
||||
@ -339,8 +346,8 @@ public class Cluster extends SubCommand {
|
||||
return false;
|
||||
}
|
||||
if (!cluster.hasHelperRights(player.getUUID())) {
|
||||
if (!Permissions.hasPermission(player, "plots.cluster.kick.other")) {
|
||||
MainUtil.sendMessage(player, C.NO_PERMISSION, "plots.cluster.kick.other");
|
||||
if (!Permissions.hasPermission(player, C.PERMISSION_CLUSTER_KICK_OTHER)) {
|
||||
MainUtil.sendMessage(player, C.NO_PERMISSION, C.PERMISSION_CLUSTER_KICK_OTHER);
|
||||
return false;
|
||||
}
|
||||
}
|
||||
@ -376,8 +383,8 @@ public class Cluster extends SubCommand {
|
||||
}
|
||||
case "quit":
|
||||
case "leave": {
|
||||
if (!Permissions.hasPermission(player, "plots.cluster.leave")) {
|
||||
MainUtil.sendMessage(player, C.NO_PERMISSION, "plots.cluster.leave");
|
||||
if (!Permissions.hasPermission(player, C.PERMISSION_CLUSTER_LEAVE)) {
|
||||
MainUtil.sendMessage(player, C.NO_PERMISSION, C.PERMISSION_CLUSTER_LEAVE);
|
||||
return false;
|
||||
}
|
||||
if (args.length != 1 && args.length != 2) {
|
||||
@ -427,11 +434,12 @@ public class Cluster extends SubCommand {
|
||||
}
|
||||
return true;
|
||||
}
|
||||
case "members":
|
||||
case "admin":
|
||||
case "helper":
|
||||
case "helpers": {
|
||||
if (!Permissions.hasPermission(player, "plots.cluster.helpers")) {
|
||||
MainUtil.sendMessage(player, C.NO_PERMISSION, "plots.cluster.helpers");
|
||||
if (!Permissions.hasPermission(player, C.PERMISSION_CLUSTER_HELPERS)) {
|
||||
MainUtil.sendMessage(player, C.NO_PERMISSION, C.PERMISSION_CLUSTER_HELPERS);
|
||||
return false;
|
||||
}
|
||||
if (args.length != 3) {
|
||||
@ -468,8 +476,8 @@ public class Cluster extends SubCommand {
|
||||
case "spawn":
|
||||
case "home":
|
||||
case "tp": {
|
||||
if (!Permissions.hasPermission(player, "plots.cluster.tp")) {
|
||||
MainUtil.sendMessage(player, C.NO_PERMISSION, "plots.cluster.tp");
|
||||
if (!Permissions.hasPermission(player, C.PERMISSION_CLUSTER_TP)) {
|
||||
MainUtil.sendMessage(player, C.NO_PERMISSION, C.PERMISSION_CLUSTER_TP);
|
||||
return false;
|
||||
}
|
||||
if (args.length != 2) {
|
||||
@ -488,8 +496,8 @@ public class Cluster extends SubCommand {
|
||||
}
|
||||
UUID uuid = player.getUUID();
|
||||
if (!cluster.isAdded(uuid)) {
|
||||
if (!Permissions.hasPermission(player, "plots.cluster.tp.other")) {
|
||||
MainUtil.sendMessage(player, C.NO_PERMISSION, "plots.cluster.tp.other");
|
||||
if (!Permissions.hasPermission(player, C.PERMISSION_CLUSTER_TP_OTHER)) {
|
||||
MainUtil.sendMessage(player, C.NO_PERMISSION, C.PERMISSION_CLUSTER_TP_OTHER);
|
||||
return false;
|
||||
}
|
||||
}
|
||||
@ -500,8 +508,8 @@ public class Cluster extends SubCommand {
|
||||
case "info":
|
||||
case "show":
|
||||
case "information": {
|
||||
if (!Permissions.hasPermission(player, "plots.cluster.info")) {
|
||||
MainUtil.sendMessage(player, C.NO_PERMISSION, "plots.cluster.info");
|
||||
if (!Permissions.hasPermission(player, C.PERMISSION_CLUSTER_INFO)) {
|
||||
MainUtil.sendMessage(player, C.NO_PERMISSION, C.PERMISSION_CLUSTER_INFO);
|
||||
return false;
|
||||
}
|
||||
if (args.length != 1 && args.length != 2) {
|
||||
@ -546,8 +554,8 @@ public class Cluster extends SubCommand {
|
||||
case "sh":
|
||||
case "setspawn":
|
||||
case "sethome":
|
||||
if (!Permissions.hasPermission(player, "plots.cluster.sethome")) {
|
||||
MainUtil.sendMessage(player, C.NO_PERMISSION, "plots.cluster.sethome");
|
||||
if (!Permissions.hasPermission(player, C.PERMISSION_CLUSTER_SETHOME)) {
|
||||
MainUtil.sendMessage(player, C.NO_PERMISSION, C.PERMISSION_CLUSTER_SETHOME);
|
||||
return false;
|
||||
}
|
||||
if (args.length != 1 && args.length != 2) {
|
||||
@ -564,8 +572,8 @@ public class Cluster extends SubCommand {
|
||||
return false;
|
||||
}
|
||||
if (!cluster.hasHelperRights(player.getUUID())) {
|
||||
if (!Permissions.hasPermission(player, "plots.cluster.sethome.other")) {
|
||||
MainUtil.sendMessage(player, C.NO_PERMISSION, "plots.cluster.sethome.other");
|
||||
if (!Permissions.hasPermission(player, C.PERMISSION_CLUSTER_SETHOME_OTHER)) {
|
||||
MainUtil.sendMessage(player, C.NO_PERMISSION, C.PERMISSION_CLUSTER_SETHOME_OTHER);
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
@ -1,30 +0,0 @@
|
||||
package com.intellectualcrafters.plot.commands;
|
||||
|
||||
import com.intellectualcrafters.plot.object.PlotPlayer;
|
||||
import com.intellectualcrafters.plot.util.Permissions;
|
||||
|
||||
public class CommandPermission {
|
||||
|
||||
/**
|
||||
* Permission Node.
|
||||
*/
|
||||
public final String permission;
|
||||
|
||||
/**
|
||||
* Command Permission
|
||||
* @param permission Command Permission
|
||||
*/
|
||||
public CommandPermission(String permission) {
|
||||
this.permission = permission.toLowerCase();
|
||||
}
|
||||
|
||||
/**
|
||||
* Check the permissions of a player.
|
||||
* @param player The player to check permissions for
|
||||
*
|
||||
* @return true of player has the required permission node
|
||||
*/
|
||||
public boolean hasPermission(PlotPlayer player) {
|
||||
return Permissions.hasPermission(player, this.permission);
|
||||
}
|
||||
}
|
@ -23,7 +23,7 @@ public class Continue extends SubCommand {
|
||||
if ((plot == null) || !plot.hasOwner()) {
|
||||
return !sendMessage(player, C.NOT_IN_PLOT);
|
||||
}
|
||||
if (!plot.isOwner(player.getUUID()) && !Permissions.hasPermission(player, "plots.admin.command.continue")) {
|
||||
if (!plot.isOwner(player.getUUID()) && !Permissions.hasPermission(player, C.PERMISSION_ADMIN_COMMAND_CONTINUE)) {
|
||||
MainUtil.sendMessage(player, C.NO_PLOT_PERMS);
|
||||
return false;
|
||||
}
|
||||
@ -33,7 +33,7 @@ public class Continue extends SubCommand {
|
||||
}
|
||||
int size = plot.getConnectedPlots().size();
|
||||
if (Settings.Done.COUNTS_TOWARDS_LIMIT && (player.getAllowedPlots() < player.getPlotCount() + size)) {
|
||||
MainUtil.sendMessage(player, C.NO_PERMISSION, "plots.admin.command.continue");
|
||||
MainUtil.sendMessage(player, C.NO_PERMISSION, C.PERMISSION_ADMIN_COMMAND_CONTINUE);
|
||||
return false;
|
||||
}
|
||||
if (plot.getRunning() > 0) {
|
||||
|
@ -28,7 +28,7 @@ import java.util.Map.Entry;
|
||||
permission = "plots.database",
|
||||
description = "Convert/Backup Storage",
|
||||
requiredType = RequiredType.CONSOLE,
|
||||
usage = "/plots database [area] <sqlite|mysql|import>")
|
||||
usage = "/plot database [area] <sqlite|mysql|import>")
|
||||
public class Database extends SubCommand {
|
||||
|
||||
public static void insertPlots(final SQLManager manager, final List<Plot> plots, final PlotPlayer player) {
|
||||
|
@ -56,8 +56,8 @@ public class DebugClaimTest extends SubCommand {
|
||||
"&cInvalid min/max values. &7The values are to Plot IDs in the format &cX;Y &7where X;Y are the plot coords\nThe conversion "
|
||||
+ "will only check the plots in the selected area.");
|
||||
}
|
||||
MainUtil.sendMessage(player, "&3Sign Block&8->&3PlotSquared&8: &7Beginning sign to plot conversion. This may take a while...");
|
||||
MainUtil.sendMessage(player, "&3Sign Block&8->&3PlotSquared&8: Found an excess of 250,000 chunks. Limiting search radius... (~3.8 min)");
|
||||
MainUtil.sendMessage(player, "&3Sign Block&8->&3Plot&8: &7Beginning sign to plot conversion. This may take a while...");
|
||||
MainUtil.sendMessage(player, "&3Sign Block&8->&3Plot&8: Found an excess of 250,000 chunks. Limiting search radius... (~3.8 min)");
|
||||
PlotManager manager = area.getPlotManager();
|
||||
ArrayList<Plot> plots = new ArrayList<>();
|
||||
for (PlotId id : MainUtil.getPlotSelectionIds(min, max)) {
|
||||
@ -101,7 +101,7 @@ public class DebugClaimTest extends SubCommand {
|
||||
}
|
||||
}
|
||||
if (!plots.isEmpty()) {
|
||||
MainUtil.sendMessage(player, "&3Sign Block&8->&3PlotSquared&8: &7Updating '" + plots.size() + "' plots!");
|
||||
MainUtil.sendMessage(player, "&3Sign Block&8->&3Plot&8: &7Updating '" + plots.size() + "' plots!");
|
||||
DBFunc.createPlotsAndData(plots, new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
@ -111,7 +111,7 @@ public class DebugClaimTest extends SubCommand {
|
||||
for (Plot plot : plots) {
|
||||
plot.create();
|
||||
}
|
||||
MainUtil.sendMessage(player, "&3Sign Block&8->&3PlotSquared&8: &7Complete!");
|
||||
MainUtil.sendMessage(player, "&3Sign Block&8->&3Plot&8: &7Complete!");
|
||||
} else {
|
||||
MainUtil.sendMessage(player, "No plots were found for the given search.");
|
||||
}
|
||||
|
@ -151,7 +151,7 @@ public class DebugExec extends SubCommand {
|
||||
@Override
|
||||
public boolean onCommand(final PlotPlayer player, String[] args) {
|
||||
List<String> allowed_params =
|
||||
Arrays.asList("calibrate-analysis", "remove-flag", "stop-expire", "start-expire", "show-expired", "update-expired", "seen", "list-scripts");
|
||||
Arrays.asList("calibrate-analysis", "remove-flag", "stop-expire", "start-expire", "show-expired", "seen", "list-scripts");
|
||||
if (args.length > 0) {
|
||||
String arg = args[0].toLowerCase();
|
||||
String script;
|
||||
@ -196,7 +196,7 @@ public class DebugExec extends SubCommand {
|
||||
PlotAnalysis.calcOptimalModifiers(new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
MainUtil.sendMessage(player, "$1Thank you for calibrating PlotSquared plot expiry");
|
||||
MainUtil.sendMessage(player, "$1Thank you for calibrating plot expiry");
|
||||
}
|
||||
}, threshold);
|
||||
return true;
|
||||
|
@ -19,7 +19,7 @@ import com.plotsquared.general.commands.CommandDeclaration;
|
||||
permission = "plots.delete",
|
||||
description = "Delete a plot",
|
||||
usage = "/plot delete",
|
||||
aliases = {"dispose", "del"},
|
||||
aliases = {"dispose", "del", "reset"},
|
||||
category = CommandCategory.CLAIMING,
|
||||
requiredType = RequiredType.NONE,
|
||||
confirmation = true)
|
||||
@ -36,7 +36,7 @@ public class Delete extends SubCommand {
|
||||
if (!plot.hasOwner()) {
|
||||
return !sendMessage(player, C.PLOT_UNOWNED);
|
||||
}
|
||||
if (!plot.isOwner(player.getUUID()) && !Permissions.hasPermission(player, "plots.admin.command.delete")) {
|
||||
if (!plot.isOwner(player.getUUID()) && !Permissions.hasPermission(player, C.PERMISSION_ADMIN_COMMAND_DELETE)) {
|
||||
return !sendMessage(player, C.NO_PLOT_PERMS);
|
||||
}
|
||||
final PlotArea plotArea = plot.getArea();
|
||||
@ -62,7 +62,7 @@ public class Delete extends SubCommand {
|
||||
sendMessage(player, C.ADDED_BALANCE, String.valueOf(value));
|
||||
}
|
||||
}
|
||||
MainUtil.sendMessage(player, C.CLEARING_DONE, System.currentTimeMillis() - start);
|
||||
MainUtil.sendMessage(player, C.DELETING_DONE, System.currentTimeMillis() - start);
|
||||
}
|
||||
});
|
||||
if (result) {
|
||||
|
@ -42,7 +42,7 @@ public class Deny extends SubCommand {
|
||||
MainUtil.sendMessage(player, C.PLOT_UNOWNED);
|
||||
return false;
|
||||
}
|
||||
if (!plot.isOwner(player.getUUID()) && !Permissions.hasPermission(player, "plots.admin.command.deny")) {
|
||||
if (!plot.isOwner(player.getUUID()) && !Permissions.hasPermission(player, C.PERMISSION_ADMIN_COMMAND_DENY)) {
|
||||
MainUtil.sendMessage(player, C.NO_PLOT_PERMS);
|
||||
return true;
|
||||
}
|
||||
@ -54,7 +54,7 @@ public class Deny extends SubCommand {
|
||||
Iterator<UUID> iter = uuids.iterator();
|
||||
while (iter.hasNext()) {
|
||||
UUID uuid = iter.next();
|
||||
if (uuid == DBFunc.everyone && !(Permissions.hasPermission(player, "plots.deny.everyone") || Permissions.hasPermission(player, "plots.admin.command.deny"))) {
|
||||
if (uuid == DBFunc.everyone && !(Permissions.hasPermission(player, C.PERMISSION_DENY_EVERYONE) || Permissions.hasPermission(player, C.PERMISSION_ADMIN_COMMAND_DENY))) {
|
||||
MainUtil.sendMessage(player, C.INVALID_PLAYER, MainUtil.getName(uuid));
|
||||
continue;
|
||||
}
|
||||
|
@ -29,7 +29,7 @@ public class Done extends SubCommand {
|
||||
if ((plot == null) || !plot.hasOwner()) {
|
||||
return !sendMessage(player, C.NOT_IN_PLOT);
|
||||
}
|
||||
if (!plot.isOwner(player.getUUID()) && !Permissions.hasPermission(player, "plots.admin.command.done")) {
|
||||
if (!plot.isOwner(player.getUUID()) && !Permissions.hasPermission(player, C.PERMISSION_ADMIN_COMMAND_DONE)) {
|
||||
MainUtil.sendMessage(player, C.NO_PLOT_PERMS);
|
||||
return false;
|
||||
}
|
||||
|
@ -42,7 +42,7 @@ public class Download extends SubCommand {
|
||||
return false;
|
||||
}
|
||||
if ((Settings.Done.REQUIRED_FOR_DOWNLOAD && (!plot.getFlag(Flags.DONE).isPresent())) && !Permissions
|
||||
.hasPermission(player, "plots.admin.command.download")) {
|
||||
.hasPermission(player, C.PERMISSION_ADMIN_COMMAND_DOWNLOAD)) {
|
||||
MainUtil.sendMessage(player, C.DONE_NOT_DONE);
|
||||
return false;
|
||||
}
|
||||
@ -73,8 +73,9 @@ public class Download extends SubCommand {
|
||||
}
|
||||
});
|
||||
} else if (args.length == 1 && StringMan.isEqualIgnoreCaseToAny(args[0], "bo3", "bo2", "b03", "b02")) {
|
||||
if (!Permissions.hasPermission(player, "plots.download.bo3")) {
|
||||
C.NO_PERMISSION.send(player, "plots.download.bo3");
|
||||
if (!Permissions.hasPermission(player, C.PERMISSION_DOWNLOAD_BO3)) {
|
||||
C.NO_PERMISSION.send(player, C.PERMISSION_DOWNLOAD_BO3);
|
||||
return false;
|
||||
}
|
||||
if (plot.getVolume() > 128d * 128d * 256) {
|
||||
C.SCHEMATIC_TOO_LARGE.send(player);
|
||||
@ -93,8 +94,9 @@ public class Download extends SubCommand {
|
||||
}
|
||||
});
|
||||
} else if (args.length == 1 && StringMan.isEqualIgnoreCaseToAny(args[0], "mcr", "world", "mca")) {
|
||||
if (!Permissions.hasPermission(player, "plots.download.world")) {
|
||||
C.NO_PERMISSION.send(player, "plots.download.world");
|
||||
if (!Permissions.hasPermission(player, C.PERMISSION_DOWNLOAD_WORLD)) {
|
||||
C.NO_PERMISSION.send(player, C.PERMISSION_DOWNLOAD_WORLD);
|
||||
return false;
|
||||
}
|
||||
MainUtil.sendMessage(player, "&cNote: The `.mca` files are 512x512");
|
||||
plot.addRunning();
|
||||
|
@ -56,8 +56,8 @@ public class FlagCmd extends SubCommand {
|
||||
sendMessage(player, C.PLOT_NOT_CLAIMED);
|
||||
return false;
|
||||
}
|
||||
if (!plot.isOwner(player.getUUID()) && !Permissions.hasPermission(player, "plots.set.flag.other")) {
|
||||
MainUtil.sendMessage(player, C.NO_PERMISSION, "plots.set.flag.other");
|
||||
if (!plot.isOwner(player.getUUID()) && !Permissions.hasPermission(player, C.PERMISSION_SET_FLAG_OTHER)) {
|
||||
MainUtil.sendMessage(player, C.NO_PERMISSION, C.PERMISSION_SET_FLAG_OTHER);
|
||||
return false;
|
||||
}
|
||||
Flag<?> flag = null;
|
||||
@ -81,7 +81,7 @@ public class FlagCmd extends SubCommand {
|
||||
}
|
||||
switch (args[0].toLowerCase()) {
|
||||
case "info": {
|
||||
if (!Permissions.hasPermission(player, "plots.set.flag")) {
|
||||
if (!Permissions.hasPermission(player, C.PERMISSION_SET_FLAG)) {
|
||||
MainUtil.sendMessage(player, C.NO_PERMISSION, "plots.flag.info");
|
||||
return false;
|
||||
}
|
||||
@ -98,8 +98,8 @@ public class FlagCmd extends SubCommand {
|
||||
return true;
|
||||
}
|
||||
case "set": {
|
||||
if (!Permissions.hasPermission(player, "plots.set.flag")) {
|
||||
MainUtil.sendMessage(player, C.NO_PERMISSION, "plots.set.flag");
|
||||
if (!Permissions.hasPermission(player, C.PERMISSION_SET_FLAG)) {
|
||||
MainUtil.sendMessage(player, C.NO_PERMISSION, C.PERMISSION_SET_FLAG);
|
||||
return false;
|
||||
}
|
||||
if (args.length < 3) {
|
||||
@ -107,8 +107,8 @@ public class FlagCmd extends SubCommand {
|
||||
return false;
|
||||
}
|
||||
String value = StringMan.join(Arrays.copyOfRange(args, 2, args.length), " ");
|
||||
if (!Permissions.hasPermission(player, "plots.set.flag." + args[1].toLowerCase() + '.' + value.toLowerCase())) {
|
||||
MainUtil.sendMessage(player, C.NO_PERMISSION, "plots.set.flag." + args[1].toLowerCase() + '.' + value.toLowerCase());
|
||||
if (!Permissions.hasPermission(player, C.PERMISSION_SET_FLAG_KEY_VALUE.f(args[1].toLowerCase(), value.toLowerCase()))) {
|
||||
MainUtil.sendMessage(player, C.NO_PERMISSION, C.PERMISSION_SET_FLAG_KEY_VALUE.f(args[1].toLowerCase(), value.toLowerCase()));
|
||||
return false;
|
||||
}
|
||||
Object parsed = flag.parseValue(value);
|
||||
@ -125,22 +125,22 @@ public class FlagCmd extends SubCommand {
|
||||
return true;
|
||||
}
|
||||
case "remove": {
|
||||
if (!Permissions.hasPermission(player, "plots.flag.remove")) {
|
||||
MainUtil.sendMessage(player, C.NO_PERMISSION, "plots.flag.remove");
|
||||
if (!Permissions.hasPermission(player, C.PERMISSION_FLAG_REMOVE)) {
|
||||
MainUtil.sendMessage(player, C.NO_PERMISSION, C.PERMISSION_FLAG_REMOVE);
|
||||
return false;
|
||||
}
|
||||
if (args.length != 2 && args.length != 3) {
|
||||
MainUtil.sendMessage(player, C.COMMAND_SYNTAX, "/plot flag remove <flag> [values]");
|
||||
return false;
|
||||
}
|
||||
if (!Permissions.hasPermission(player, "plots.set.flag." + args[1].toLowerCase())) {
|
||||
if (args.length != 2) {
|
||||
MainUtil.sendMessage(player, C.NO_PERMISSION, "plots.set.flag." + args[1].toLowerCase());
|
||||
if (!Permissions.hasPermission(player, C.PERMISSION_SET_FLAG_KEY.f(args[1].toLowerCase()))) {
|
||||
if (args.length != 3) {
|
||||
MainUtil.sendMessage(player, C.NO_PERMISSION, C.PERMISSION_SET_FLAG_KEY.f(args[1].toLowerCase()));
|
||||
return false;
|
||||
}
|
||||
for (String entry : args[2].split(",")) {
|
||||
if (!Permissions.hasPermission(player, "plots.set.flag." + args[1].toLowerCase() + '.' + entry)) {
|
||||
MainUtil.sendMessage(player, C.NO_PERMISSION, "plots.set.flag." + args[1].toLowerCase() + '.' + entry);
|
||||
if (!Permissions.hasPermission(player, C.PERMISSION_SET_FLAG_KEY_VALUE.f(args[1].toLowerCase(), entry))) {
|
||||
MainUtil.sendMessage(player, C.NO_PERMISSION, C.PERMISSION_SET_FLAG_KEY_VALUE.f(args[1].toLowerCase(), entry));
|
||||
return false;
|
||||
}
|
||||
}
|
||||
@ -173,8 +173,8 @@ public class FlagCmd extends SubCommand {
|
||||
return true;
|
||||
}
|
||||
case "add":
|
||||
if (!Permissions.hasPermission(player, "plots.flag.add")) {
|
||||
MainUtil.sendMessage(player, C.NO_PERMISSION, "plots.flag.add");
|
||||
if (!Permissions.hasPermission(player, C.PERMISSION_FLAG_ADD)) {
|
||||
MainUtil.sendMessage(player, C.NO_PERMISSION, C.PERMISSION_FLAG_ADD);
|
||||
return false;
|
||||
}
|
||||
if (args.length < 3) {
|
||||
@ -182,8 +182,8 @@ public class FlagCmd extends SubCommand {
|
||||
return false;
|
||||
}
|
||||
for (String entry : args[2].split(",")) {
|
||||
if (!Permissions.hasPermission(player, "plots.set.flag." + args[1].toLowerCase() + '.' + entry)) {
|
||||
MainUtil.sendMessage(player, C.NO_PERMISSION, "plots.set.flag." + args[1].toLowerCase() + '.' + entry);
|
||||
if (!Permissions.hasPermission(player, C.PERMISSION_SET_FLAG_KEY_VALUE.f(args[1].toLowerCase(), entry))) {
|
||||
MainUtil.sendMessage(player, C.NO_PERMISSION, C.PERMISSION_SET_FLAG_KEY_VALUE.f(args[1].toLowerCase(), entry));
|
||||
return false;
|
||||
}
|
||||
}
|
||||
@ -215,8 +215,8 @@ public class FlagCmd extends SubCommand {
|
||||
MainUtil.sendMessage(player, C.FLAG_ADDED);
|
||||
return true;
|
||||
case "list":
|
||||
if (!Permissions.hasPermission(player, "plots.flag.list")) {
|
||||
MainUtil.sendMessage(player, C.NO_PERMISSION, "plots.flag.list");
|
||||
if (!Permissions.hasPermission(player, C.PERMISSION_FLAG_LIST)) {
|
||||
MainUtil.sendMessage(player, C.NO_PERMISSION, C.PERMISSION_FLAG_LIST);
|
||||
return false;
|
||||
}
|
||||
if (args.length > 1) {
|
||||
|
@ -33,8 +33,8 @@ public class Grant extends Command {
|
||||
switch (arg0) {
|
||||
case "add":
|
||||
case "check":
|
||||
if (Permissions.hasPermission(player, "plots.grant." + arg0)) {
|
||||
C.NO_PERMISSION.send(player, "plots.grant." + arg0);
|
||||
if (!Permissions.hasPermission(player, C.PERMISSION_GRANT.f(arg0))) {
|
||||
C.NO_PERMISSION.send(player, C.PERMISSION_GRANT.f(arg0));
|
||||
return;
|
||||
}
|
||||
if (args.length > 2) {
|
||||
|
@ -47,9 +47,9 @@ public class Help extends Command {
|
||||
case 2:
|
||||
if (MathMan.isInteger(args[1])) {
|
||||
try {
|
||||
displayHelp(player, args[1], Integer.parseInt(args[1]));
|
||||
displayHelp(player, args[0], Integer.parseInt(args[1]));
|
||||
} catch (NumberFormatException ignored) {
|
||||
displayHelp(player, args[1], 1);
|
||||
displayHelp(player, args[0], 1);
|
||||
}
|
||||
}
|
||||
return;
|
||||
|
@ -36,7 +36,7 @@ public class Kick extends SubCommand {
|
||||
if (plot == null) {
|
||||
return !sendMessage(player, C.NOT_IN_PLOT);
|
||||
}
|
||||
if ((!plot.hasOwner() || !plot.isOwner(player.getUUID())) && !Permissions.hasPermission(player, "plots.admin.command.kick")) {
|
||||
if ((!plot.hasOwner() || !plot.isOwner(player.getUUID())) && !Permissions.hasPermission(player, C.PERMISSION_ADMIN_COMMAND_KICK)) {
|
||||
MainUtil.sendMessage(player, C.NO_PLOT_PERMS);
|
||||
return false;
|
||||
}
|
||||
@ -49,7 +49,7 @@ public class Kick extends SubCommand {
|
||||
for (UUID uuid : uuids) {
|
||||
if (uuid == DBFunc.everyone) {
|
||||
for (PlotPlayer pp : plot.getPlayersInPlot()) {
|
||||
if (pp == player || pp.hasPermission("plots.admin.entry.denied")) {
|
||||
if (pp == player || Permissions.hasPermission(pp, C.PERMISSION_ADMIN_ENTRY_DENIED)) {
|
||||
continue;
|
||||
}
|
||||
players.add(pp);
|
||||
|
@ -0,0 +1,35 @@
|
||||
package com.intellectualcrafters.plot.commands;
|
||||
|
||||
import com.intellectualcrafters.plot.config.C;
|
||||
import com.intellectualcrafters.plot.object.Plot;
|
||||
import com.intellectualcrafters.plot.object.PlotPlayer;
|
||||
import com.intellectualcrafters.plot.object.RunnableVal2;
|
||||
import com.intellectualcrafters.plot.object.RunnableVal3;
|
||||
import com.plotsquared.general.commands.Command;
|
||||
import com.plotsquared.general.commands.CommandDeclaration;
|
||||
import java.util.*;
|
||||
import java.util.Set;
|
||||
|
||||
@CommandDeclaration(command = "leave",
|
||||
description = "Leave a plot",
|
||||
permission = "plots.leave",
|
||||
category = CommandCategory.CLAIMING,
|
||||
requiredType = RequiredType.NONE)
|
||||
public class Leave extends Command {
|
||||
public Leave(Command parent, boolean isStatic) {
|
||||
super(MainCommand.getInstance(), true);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void execute(PlotPlayer player, String[] args, RunnableVal3<Command, Runnable, Runnable> confirm, RunnableVal2<Command, CommandResult> whenDone) throws CommandException {
|
||||
final Plot plot = check(player.getCurrentPlot(), C.NOT_IN_PLOT);
|
||||
checkTrue(plot.hasOwner(), C.PLOT_UNOWNED);
|
||||
checkTrue(plot.isAdded(player.getUUID()), C.NO_PLOT_PERMS);
|
||||
checkTrue(args.length == 0, C.COMMAND_SYNTAX, getUsage());
|
||||
if (plot.isOwner(player.getUUID())) {
|
||||
Set<UUID> owners = plot.getOwners();
|
||||
} else {
|
||||
|
||||
}
|
||||
}
|
||||
}
|
@ -41,43 +41,43 @@ public class ListCmd extends SubCommand {
|
||||
|
||||
private String[] getArgumentList(PlotPlayer player) {
|
||||
List<String> args = new ArrayList<>();
|
||||
if (EconHandler.manager != null && Permissions.hasPermission(player, "plots.list.forsale")) {
|
||||
if (EconHandler.manager != null && Permissions.hasPermission(player, C.PERMISSION_LIST_FORSALE)) {
|
||||
args.add("forsale");
|
||||
}
|
||||
if (Permissions.hasPermission(player, "plots.list.mine")) {
|
||||
if (Permissions.hasPermission(player, C.PERMISSION_LIST_MINE)) {
|
||||
args.add("mine");
|
||||
}
|
||||
if (Permissions.hasPermission(player, "plots.list.shared")) {
|
||||
if (Permissions.hasPermission(player, C.PERMISSION_LIST_SHARED)) {
|
||||
args.add("shared");
|
||||
}
|
||||
if (Permissions.hasPermission(player, "plots.list.world")) {
|
||||
if (Permissions.hasPermission(player, C.PERMISSION_LIST_WORLD)) {
|
||||
args.add("world");
|
||||
}
|
||||
if (Permissions.hasPermission(player, "plots.list.top")) {
|
||||
if (Permissions.hasPermission(player, C.PERMISSION_LIST_TOP)) {
|
||||
args.add("top");
|
||||
}
|
||||
if (Permissions.hasPermission(player, "plots.list.all")) {
|
||||
if (Permissions.hasPermission(player, C.PERMISSION_LIST_ALL)) {
|
||||
args.add("all");
|
||||
}
|
||||
if (Permissions.hasPermission(player, "plots.list.unowned")) {
|
||||
if (Permissions.hasPermission(player, C.PERMISSION_LIST_UNOWNED)) {
|
||||
args.add("unowned");
|
||||
}
|
||||
if (Permissions.hasPermission(player, "plots.list.unknown")) {
|
||||
if (Permissions.hasPermission(player, C.PERMISSION_LIST_UNKNOWN)) {
|
||||
args.add("unknown");
|
||||
}
|
||||
if (Permissions.hasPermission(player, "plots.list.player")) {
|
||||
if (Permissions.hasPermission(player, C.PERMISSION_LIST_PLAYER)) {
|
||||
args.add("<player>");
|
||||
}
|
||||
if (Permissions.hasPermission(player, "plots.list.world")) {
|
||||
if (Permissions.hasPermission(player, C.PERMISSION_LIST_WORLD)) {
|
||||
args.add("<world>");
|
||||
}
|
||||
if (Permissions.hasPermission(player, "plots.list.done")) {
|
||||
if (Permissions.hasPermission(player, C.PERMISSION_LIST_DONE)) {
|
||||
args.add("done");
|
||||
}
|
||||
if (Permissions.hasPermission(player, "plots.list.expired")) {
|
||||
if (Permissions.hasPermission(player, C.PERMISSION_LIST_EXPIRED)) {
|
||||
args.add("expired");
|
||||
}
|
||||
if (Permissions.hasPermission(player, "plots.list.fuzzy")) {
|
||||
if (Permissions.hasPermission(player, C.PERMISSION_LIST_FUZZY)) {
|
||||
args.add("fuzzy <search...>");
|
||||
}
|
||||
return args.toArray(new String[args.size()]);
|
||||
@ -114,16 +114,16 @@ public class ListCmd extends SubCommand {
|
||||
boolean sort = true;
|
||||
switch (arg) {
|
||||
case "mine":
|
||||
if (!Permissions.hasPermission(player, "plots.list.mine")) {
|
||||
MainUtil.sendMessage(player, C.NO_PERMISSION, "plots.list.mine");
|
||||
if (!Permissions.hasPermission(player, C.PERMISSION_LIST_MINE)) {
|
||||
MainUtil.sendMessage(player, C.NO_PERMISSION, C.PERMISSION_LIST_MINE);
|
||||
return false;
|
||||
}
|
||||
sort = false;
|
||||
plots = PS.get().sortPlotsByTemp(PS.get().getBasePlots(player));
|
||||
break;
|
||||
case "shared":
|
||||
if (!Permissions.hasPermission(player, "plots.list.shared")) {
|
||||
MainUtil.sendMessage(player, C.NO_PERMISSION, "plots.list.shared");
|
||||
if (!Permissions.hasPermission(player, C.PERMISSION_LIST_SHARED)) {
|
||||
MainUtil.sendMessage(player, C.NO_PERMISSION, C.PERMISSION_LIST_SHARED);
|
||||
return false;
|
||||
}
|
||||
plots = new ArrayList<>();
|
||||
@ -134,44 +134,44 @@ public class ListCmd extends SubCommand {
|
||||
}
|
||||
break;
|
||||
case "world":
|
||||
if (!Permissions.hasPermission(player, "plots.list.world")) {
|
||||
MainUtil.sendMessage(player, C.NO_PERMISSION, "plots.list.world");
|
||||
if (!Permissions.hasPermission(player, C.PERMISSION_LIST_WORLD)) {
|
||||
MainUtil.sendMessage(player, C.NO_PERMISSION, C.PERMISSION_LIST_WORLD);
|
||||
return false;
|
||||
}
|
||||
if (!Permissions.hasPermission(player, "plots.list.world." + world)) {
|
||||
MainUtil.sendMessage(player, C.NO_PERMISSION, "plots.list.world." + world);
|
||||
if (!Permissions.hasPermission(player, C.PERMISSION_LIST_WORLD_NAME.f(world))) {
|
||||
MainUtil.sendMessage(player, C.NO_PERMISSION, C.PERMISSION_LIST_WORLD_NAME.f(world));
|
||||
return false;
|
||||
}
|
||||
plots = new ArrayList<>(PS.get().getPlots(world));
|
||||
break;
|
||||
case "expired":
|
||||
if (!Permissions.hasPermission(player, "plots.list.expired")) {
|
||||
MainUtil.sendMessage(player, C.NO_PERMISSION, "plots.list.expired");
|
||||
if (!Permissions.hasPermission(player, C.PERMISSION_LIST_EXPIRED)) {
|
||||
MainUtil.sendMessage(player, C.NO_PERMISSION, C.PERMISSION_LIST_EXPIRED);
|
||||
return false;
|
||||
}
|
||||
plots = ExpireManager.IMP == null ? new ArrayList<Plot>() : new ArrayList<>(ExpireManager.IMP.getPendingExpired());
|
||||
break;
|
||||
case "area":
|
||||
if (!Permissions.hasPermission(player, "plots.list.area")) {
|
||||
MainUtil.sendMessage(player, C.NO_PERMISSION, "plots.list.area");
|
||||
if (!Permissions.hasPermission(player, C.PERMISSION_LIST_AREA)) {
|
||||
MainUtil.sendMessage(player, C.NO_PERMISSION, C.PERMISSION_LIST_AREA);
|
||||
return false;
|
||||
}
|
||||
if (!Permissions.hasPermission(player, "plots.list.world." + world)) {
|
||||
MainUtil.sendMessage(player, C.NO_PERMISSION, "plots.list.world." + world);
|
||||
if (!Permissions.hasPermission(player, C.PERMISSION_LIST_WORLD_NAME.f(world))) {
|
||||
MainUtil.sendMessage(player, C.NO_PERMISSION, C.PERMISSION_LIST_WORLD_NAME.f(world));
|
||||
return false;
|
||||
}
|
||||
plots = area == null ? new ArrayList<Plot>() : new ArrayList<>(area.getPlots());
|
||||
break;
|
||||
case "all":
|
||||
if (!Permissions.hasPermission(player, "plots.list.all")) {
|
||||
MainUtil.sendMessage(player, C.NO_PERMISSION, "plots.list.all");
|
||||
if (!Permissions.hasPermission(player, C.PERMISSION_LIST_ALL)) {
|
||||
MainUtil.sendMessage(player, C.NO_PERMISSION, C.PERMISSION_LIST_ALL);
|
||||
return false;
|
||||
}
|
||||
plots = new ArrayList<>(PS.get().getPlots());
|
||||
break;
|
||||
case "done":
|
||||
if (!Permissions.hasPermission(player, "plots.list.done")) {
|
||||
MainUtil.sendMessage(player, C.NO_PERMISSION, "plots.list.done");
|
||||
if (!Permissions.hasPermission(player, C.PERMISSION_LIST_DONE)) {
|
||||
MainUtil.sendMessage(player, C.NO_PERMISSION, C.PERMISSION_LIST_DONE);
|
||||
return false;
|
||||
}
|
||||
plots = new ArrayList<>();
|
||||
@ -199,8 +199,8 @@ public class ListCmd extends SubCommand {
|
||||
sort = false;
|
||||
break;
|
||||
case "top":
|
||||
if (!Permissions.hasPermission(player, "plots.list.top")) {
|
||||
MainUtil.sendMessage(player, C.NO_PERMISSION, "plots.list.top");
|
||||
if (!Permissions.hasPermission(player, C.PERMISSION_LIST_TOP)) {
|
||||
MainUtil.sendMessage(player, C.NO_PERMISSION, C.PERMISSION_LIST_TOP);
|
||||
return false;
|
||||
}
|
||||
plots = new ArrayList<>(PS.get().getPlots());
|
||||
@ -236,8 +236,8 @@ public class ListCmd extends SubCommand {
|
||||
sort = false;
|
||||
break;
|
||||
case "forsale":
|
||||
if (!Permissions.hasPermission(player, "plots.list.forsale")) {
|
||||
MainUtil.sendMessage(player, C.NO_PERMISSION, "plots.list.forsale");
|
||||
if (!Permissions.hasPermission(player, C.PERMISSION_LIST_FORSALE)) {
|
||||
MainUtil.sendMessage(player, C.NO_PERMISSION, C.PERMISSION_LIST_FORSALE);
|
||||
return false;
|
||||
}
|
||||
if (EconHandler.manager == null) {
|
||||
@ -252,8 +252,8 @@ public class ListCmd extends SubCommand {
|
||||
}
|
||||
break;
|
||||
case "unowned":
|
||||
if (!Permissions.hasPermission(player, "plots.list.unowned")) {
|
||||
MainUtil.sendMessage(player, C.NO_PERMISSION, "plots.list.unowned");
|
||||
if (!Permissions.hasPermission(player, C.PERMISSION_LIST_UNOWNED)) {
|
||||
MainUtil.sendMessage(player, C.NO_PERMISSION, C.PERMISSION_LIST_UNOWNED);
|
||||
return false;
|
||||
}
|
||||
plots = new ArrayList<>();
|
||||
@ -264,8 +264,8 @@ public class ListCmd extends SubCommand {
|
||||
}
|
||||
break;
|
||||
case "unknown":
|
||||
if (!Permissions.hasPermission(player, "plots.list.unknown")) {
|
||||
MainUtil.sendMessage(player, C.NO_PERMISSION, "plots.list.unknown");
|
||||
if (!Permissions.hasPermission(player, C.PERMISSION_LIST_UNKNOWN)) {
|
||||
MainUtil.sendMessage(player, C.NO_PERMISSION, C.PERMISSION_LIST_UNKNOWN);
|
||||
return false;
|
||||
}
|
||||
plots = new ArrayList<>();
|
||||
@ -279,8 +279,8 @@ public class ListCmd extends SubCommand {
|
||||
}
|
||||
break;
|
||||
case "fuzzy":
|
||||
if (!Permissions.hasPermission(player, "plots.list.fuzzy")) {
|
||||
MainUtil.sendMessage(player, C.NO_PERMISSION, "plots.list.fuzzy");
|
||||
if (!Permissions.hasPermission(player, C.PERMISSION_LIST_FUZZY)) {
|
||||
MainUtil.sendMessage(player, C.NO_PERMISSION, C.PERMISSION_LIST_FUZZY);
|
||||
return false;
|
||||
}
|
||||
if (args.length < (page == -1 ? 2 : 3)) {
|
||||
@ -298,12 +298,12 @@ public class ListCmd extends SubCommand {
|
||||
break;
|
||||
default:
|
||||
if (PS.get().hasPlotArea(args[0])) {
|
||||
if (!Permissions.hasPermission(player, "plots.list.world")) {
|
||||
MainUtil.sendMessage(player, C.NO_PERMISSION, "plots.list.world");
|
||||
if (!Permissions.hasPermission(player, C.PERMISSION_LIST_WORLD)) {
|
||||
MainUtil.sendMessage(player, C.NO_PERMISSION, C.PERMISSION_LIST_WORLD);
|
||||
return false;
|
||||
}
|
||||
if (!Permissions.hasPermission(player, "plots.list.world." + args[0])) {
|
||||
MainUtil.sendMessage(player, C.NO_PERMISSION, "plots.list.world." + args[0]);
|
||||
if (!Permissions.hasPermission(player, C.PERMISSION_LIST_WORLD_NAME.f(args[0]))) {
|
||||
MainUtil.sendMessage(player, C.NO_PERMISSION, C.PERMISSION_LIST_WORLD_NAME.f(args[0]));
|
||||
return false;
|
||||
}
|
||||
plots = new ArrayList<>(PS.get().getPlots(args[0]));
|
||||
@ -316,8 +316,8 @@ public class ListCmd extends SubCommand {
|
||||
} catch (Exception ignored) {}
|
||||
}
|
||||
if (uuid != null) {
|
||||
if (!Permissions.hasPermission(player, "plots.list.player")) {
|
||||
MainUtil.sendMessage(player, C.NO_PERMISSION, "plots.list.player");
|
||||
if (!Permissions.hasPermission(player, C.PERMISSION_LIST_PLAYER)) {
|
||||
MainUtil.sendMessage(player, C.NO_PERMISSION, C.PERMISSION_LIST_PLAYER);
|
||||
return false;
|
||||
}
|
||||
sort = false;
|
||||
|
@ -47,7 +47,7 @@ public class Load extends SubCommand {
|
||||
MainUtil.sendMessage(player, C.PLOT_UNOWNED);
|
||||
return false;
|
||||
}
|
||||
if (!plot.isOwner(player.getUUID()) && !Permissions.hasPermission(player, "plots.admin.command.load")) {
|
||||
if (!plot.isOwner(player.getUUID()) && !Permissions.hasPermission(player, C.PERMISSION_ADMIN_COMMAND_LOAD)) {
|
||||
MainUtil.sendMessage(player, C.NO_PLOT_PERMS);
|
||||
return false;
|
||||
}
|
||||
|
@ -64,6 +64,7 @@ public class MainCommand extends Command {
|
||||
new Deny();
|
||||
new Remove();
|
||||
new Info();
|
||||
new Near();
|
||||
new ListCmd();
|
||||
new Debug();
|
||||
new SchematicCmd();
|
||||
@ -196,7 +197,7 @@ public class MainCommand extends Command {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void execute(PlotPlayer player, String[] args, RunnableVal3<Command, Runnable, Runnable> confirm, RunnableVal2<Command, CommandResult> whenDone) {
|
||||
public void execute(final PlotPlayer player, String[] args, RunnableVal3<Command, Runnable, Runnable> confirm, RunnableVal2<Command, CommandResult> whenDone) {
|
||||
// Clear perm caching //
|
||||
player.deleteMeta("perm");
|
||||
// Optional command scope //
|
||||
@ -222,6 +223,37 @@ public class MainCommand extends Command {
|
||||
// Trim command
|
||||
args = Arrays.copyOfRange(args, 1, args.length);
|
||||
}
|
||||
if (args.length >= 2 && args[0].charAt(0) == '-') {
|
||||
switch (args[0].substring(1)) {
|
||||
case "f":
|
||||
confirm = new RunnableVal3<Command, Runnable, Runnable>() {
|
||||
@Override
|
||||
public void run(final Command cmd, final Runnable success, final Runnable failure) {
|
||||
if (EconHandler.manager != null) {
|
||||
PlotArea area = player.getApplicablePlotArea();
|
||||
if (area != null) {
|
||||
Expression<Double> priceEval = area.PRICES.get(cmd.getFullId());
|
||||
Double price = priceEval != null ? priceEval.evaluate(0d) : 0d;
|
||||
if (price != 0d && EconHandler.manager.getMoney(player) < price) {
|
||||
if (failure != null) {
|
||||
failure.run();
|
||||
}
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
if (success != null) {
|
||||
success.run();
|
||||
}
|
||||
}
|
||||
};
|
||||
args = Arrays.copyOfRange(args, 1, args.length);
|
||||
break;
|
||||
default:
|
||||
C.INVALID_COMMAND_FLAG.send(player);
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
try {
|
||||
super.execute(player, args, confirm, whenDone);
|
||||
|
@ -64,7 +64,7 @@ public class Merge extends SubCommand {
|
||||
}
|
||||
UUID uuid = player.getUUID();
|
||||
if (!plot.isOwner(uuid)) {
|
||||
if (!Permissions.hasPermission(player, "plots.admin.command.merge")) {
|
||||
if (!Permissions.hasPermission(player, C.PERMISSION_ADMIN_COMMAND_MERGE)) {
|
||||
MainUtil.sendMessage(player, C.NO_PLOT_PERMS);
|
||||
return false;
|
||||
} else {
|
||||
|
@ -0,0 +1,27 @@
|
||||
package com.intellectualcrafters.plot.commands;
|
||||
|
||||
import com.intellectualcrafters.plot.config.C;
|
||||
import com.intellectualcrafters.plot.object.Plot;
|
||||
import com.intellectualcrafters.plot.object.PlotPlayer;
|
||||
import com.intellectualcrafters.plot.object.RunnableVal2;
|
||||
import com.intellectualcrafters.plot.object.RunnableVal3;
|
||||
import com.intellectualcrafters.plot.util.StringMan;
|
||||
import com.plotsquared.general.commands.Command;
|
||||
import com.plotsquared.general.commands.CommandDeclaration;
|
||||
|
||||
@CommandDeclaration(command = "near",
|
||||
aliases = "n",
|
||||
description = "Display nearby players",
|
||||
usage = "/plot near",
|
||||
category = CommandCategory.INFO)
|
||||
public class Near extends Command {
|
||||
public Near() {
|
||||
super(MainCommand.getInstance(), true);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void execute(PlotPlayer player, String[] args, RunnableVal3<Command, Runnable, Runnable> confirm, RunnableVal2<Command, CommandResult> whenDone) throws CommandException {
|
||||
final Plot plot = check(player.getCurrentPlot(), C.NOT_IN_PLOT);
|
||||
C.PLOT_NEAR.send(player, StringMan.join(plot.getPlayersInPlot(), ", "));
|
||||
}
|
||||
}
|
@ -54,12 +54,12 @@ public class Owner extends SetCommand {
|
||||
C.INVALID_PLAYER.send(player, value);
|
||||
return false;
|
||||
}
|
||||
final PlotPlayer other = UUIDHandler.getPlayer(uuid);
|
||||
if (plot.isOwner(uuid)) {
|
||||
C.ALREADY_OWNER.send(player);
|
||||
C.ALREADY_OWNER.send(player, MainUtil.getName(uuid));
|
||||
return false;
|
||||
}
|
||||
final PlotPlayer other = UUIDHandler.getPlayer(uuid);
|
||||
if (!Permissions.hasPermission(player, "plots.admin.command.setowner")) {
|
||||
if (!Permissions.hasPermission(player, C.PERMISSION_ADMIN_COMMAND_SETOWNER)) {
|
||||
if (other == null) {
|
||||
C.INVALID_PLAYER_OFFLINE.send(player, value);
|
||||
return false;
|
||||
|
@ -17,7 +17,7 @@ public class PluginCmd extends SubCommand {
|
||||
|
||||
@Override
|
||||
public boolean onCommand(PlotPlayer player, String[] args) {
|
||||
MainUtil.sendMessage(player, String.format("$2>> $1&lPlotSquared $2($1Version$2: $1%s$2)", StringMan.join(PS.get().getVersion(), ".")));
|
||||
MainUtil.sendMessage(player, String.format("$2>> $1&l" + PS.imp().getPluginName() + " $2($1Version$2: $1%s$2)", StringMan.join(PS.get().getVersion(), ".")));
|
||||
MainUtil.sendMessage(player, "$2>> $1&lAuthors$2: $1Citymonstret $2& $1Empire92 $2& $1MattBDev");
|
||||
MainUtil.sendMessage(player, "$2>> $1&lWiki$2: $1https://github.com/IntellectualCrafters/PlotSquared/wiki");
|
||||
MainUtil.sendMessage(player, "$2>> $1&lNewest Version$2: $1" + getNewestVersionString());
|
||||
|
@ -110,7 +110,7 @@ public class Rate extends SubCommand {
|
||||
Rating result = EventUtil.manager.callRating(this.player, plot, new Rating(rV));
|
||||
plot.addRating(this.player.getUUID(), result);
|
||||
sendMessage(this.player, C.RATING_APPLIED, plot.getId().toString());
|
||||
if (Permissions.hasPermission(this.player, "plots.comment")) {
|
||||
if (Permissions.hasPermission(this.player, C.PERMISSION_COMMENT)) {
|
||||
Command command = MainCommand.getInstance().getCommand(Comment.class);
|
||||
if (command != null) {
|
||||
MainUtil.sendMessage(this.player, C.COMMENT_THIS, command.getUsage());
|
||||
|
@ -31,6 +31,9 @@ public class Reload extends SubCommand {
|
||||
@Override
|
||||
public void run(PlotArea area) {
|
||||
ConfigurationSection worldSection = PS.get().worlds.getConfigurationSection("worlds." + area.worldname);
|
||||
if (worldSection == null) {
|
||||
return;
|
||||
}
|
||||
if (area.TYPE != 2 || !worldSection.contains("areas")) {
|
||||
area.saveConfiguration(worldSection);
|
||||
area.loadDefaultConfiguration(worldSection);
|
||||
|
@ -5,6 +5,7 @@ import com.intellectualcrafters.plot.database.DBFunc;
|
||||
import com.intellectualcrafters.plot.object.Location;
|
||||
import com.intellectualcrafters.plot.object.Plot;
|
||||
import com.intellectualcrafters.plot.object.PlotPlayer;
|
||||
import com.intellectualcrafters.plot.util.EventUtil;
|
||||
import com.intellectualcrafters.plot.util.MainUtil;
|
||||
import com.intellectualcrafters.plot.util.Permissions;
|
||||
import com.intellectualcrafters.plot.util.UUIDHandler;
|
||||
@ -41,7 +42,7 @@ public class Remove extends SubCommand {
|
||||
MainUtil.sendMessage(player, C.PLOT_UNOWNED);
|
||||
return false;
|
||||
}
|
||||
if (!plot.isOwner(player.getUUID()) && !Permissions.hasPermission(player, "plots.admin.command.remove")) {
|
||||
if (!plot.isOwner(player.getUUID()) && !Permissions.hasPermission(player, C.PERMISSION_ADMIN_COMMAND_REMOVE)) {
|
||||
MainUtil.sendMessage(player, C.NO_PLOT_PERMS);
|
||||
return true;
|
||||
}
|
||||
@ -71,20 +72,30 @@ public class Remove extends SubCommand {
|
||||
if (!uuids.isEmpty()) {
|
||||
for (UUID uuid : uuids) {
|
||||
if (uuid == DBFunc.everyone) {
|
||||
if (plot.removeTrusted(uuid) | plot.removeMember(uuid) | plot.removeDenied(uuid)) {
|
||||
if (plot.removeTrusted(uuid)){
|
||||
EventUtil.manager.callTrusted(player, plot, uuid, false);
|
||||
count++;
|
||||
}else if (plot.removeMember(uuid)) {
|
||||
EventUtil.manager.callMember(player, plot, uuid, false);
|
||||
count++;
|
||||
}else if (plot.removeDenied(uuid)) {
|
||||
EventUtil.manager.callDenied(player, plot, uuid, false);
|
||||
count++;
|
||||
}
|
||||
}
|
||||
else if (plot.getTrusted().contains(uuid)) {
|
||||
if (plot.removeTrusted(uuid)) {
|
||||
EventUtil.manager.callTrusted(player, plot, uuid, false);
|
||||
count++;
|
||||
}
|
||||
} else if (plot.getMembers().contains(uuid)) {
|
||||
if (plot.removeMember(uuid)) {
|
||||
EventUtil.manager.callMember(player, plot, uuid, false);
|
||||
count++;
|
||||
}
|
||||
} else if (plot.getDenied().contains(uuid)) {
|
||||
if (plot.removeDenied(uuid)) {
|
||||
EventUtil.manager.callDenied(player, plot, uuid, false);
|
||||
count++;
|
||||
}
|
||||
}
|
||||
|
@ -47,7 +47,7 @@ public class Save extends SubCommand {
|
||||
MainUtil.sendMessage(player, C.PLOT_UNOWNED);
|
||||
return false;
|
||||
}
|
||||
if (!plot.isOwner(player.getUUID()) && !Permissions.hasPermission(player, "plots.admin.command.save")) {
|
||||
if (!plot.isOwner(player.getUUID()) && !Permissions.hasPermission(player, C.PERMISSION_ADMIN_COMMAND_SAVE)) {
|
||||
MainUtil.sendMessage(player, C.NO_PLOT_PERMS);
|
||||
return false;
|
||||
}
|
||||
|
@ -41,8 +41,8 @@ public class SchematicCmd extends SubCommand {
|
||||
String arg = args[0].toLowerCase();
|
||||
switch (arg) {
|
||||
case "paste": {
|
||||
if (!Permissions.hasPermission(player, "plots.schematic.paste")) {
|
||||
MainUtil.sendMessage(player, C.NO_PERMISSION, "plots.schematic.paste");
|
||||
if (!Permissions.hasPermission(player, C.PERMISSION_SCHEMATIC_PASTE)) {
|
||||
MainUtil.sendMessage(player, C.NO_PERMISSION, C.PERMISSION_SCHEMATIC_PASTE);
|
||||
return false;
|
||||
}
|
||||
if (args.length < 2) {
|
||||
@ -58,7 +58,7 @@ public class SchematicCmd extends SubCommand {
|
||||
MainUtil.sendMessage(player, C.PLOT_UNOWNED);
|
||||
return false;
|
||||
}
|
||||
if (!plot.isOwner(player.getUUID()) && !Permissions.hasPermission(player, "plots.admin.command.schematic.paste")) {
|
||||
if (!plot.isOwner(player.getUUID()) && !Permissions.hasPermission(player, C.PERMISSION_ADMIN_COMMAND_SCHEMATIC_PASTE)) {
|
||||
MainUtil.sendMessage(player, C.NO_PLOT_PERMS);
|
||||
return false;
|
||||
}
|
||||
@ -146,7 +146,7 @@ public class SchematicCmd extends SubCommand {
|
||||
return false;
|
||||
}
|
||||
if (args.length != 2) {
|
||||
MainUtil.sendMessage(player, "&cNeed world argument. Use &7/plots sch exportall <area>");
|
||||
MainUtil.sendMessage(player, "&cNeed world argument. Use &7/plot sch exportall <area>");
|
||||
return false;
|
||||
}
|
||||
PlotArea area = PS.get().getPlotAreaByString(args[1]);
|
||||
@ -156,7 +156,7 @@ public class SchematicCmd extends SubCommand {
|
||||
}
|
||||
Collection<Plot> plots = area.getPlots();
|
||||
if (plots.isEmpty()) {
|
||||
MainUtil.sendMessage(player, "&cInvalid world. Use &7/plots sch exportall <area>");
|
||||
MainUtil.sendMessage(player, "&cInvalid world. Use &7/plot sch exportall <area>");
|
||||
return false;
|
||||
}
|
||||
boolean result = SchematicHandler.manager.exportAll(plots, null, null, new Runnable() {
|
||||
@ -169,15 +169,15 @@ public class SchematicCmd extends SubCommand {
|
||||
MainUtil.sendMessage(player, "&cTask is already running.");
|
||||
return false;
|
||||
} else {
|
||||
MainUtil.sendMessage(player, "&3PlotSquared&8->&3Schematic&8: &7Mass export has started. This may take a while.");
|
||||
MainUtil.sendMessage(player, "&3PlotSquared&8->&3Schematic&8: &7Found &c" + plots.size() + "&7 plots...");
|
||||
MainUtil.sendMessage(player, "&3Plot&8->&3Schematic&8: &7Mass export has started. This may take a while.");
|
||||
MainUtil.sendMessage(player, "&3Plot&8->&3Schematic&8: &7Found &c" + plots.size() + "&7 plots...");
|
||||
}
|
||||
break;
|
||||
}
|
||||
case "export":
|
||||
case "save":
|
||||
if (!Permissions.hasPermission(player, "plots.schematic.save")) {
|
||||
MainUtil.sendMessage(player, C.NO_PERMISSION, "plots.schematic.save");
|
||||
if (!Permissions.hasPermission(player, C.PERMISSION_SCHEMATIC_SAVE)) {
|
||||
MainUtil.sendMessage(player, C.NO_PERMISSION, C.PERMISSION_SCHEMATIC_SAVE);
|
||||
return false;
|
||||
}
|
||||
if (this.running) {
|
||||
@ -193,7 +193,7 @@ public class SchematicCmd extends SubCommand {
|
||||
MainUtil.sendMessage(player, C.PLOT_UNOWNED);
|
||||
return false;
|
||||
}
|
||||
if (!plot.isOwner(player.getUUID()) && !Permissions.hasPermission(player, "plots.admin.command.schematic.save")) {
|
||||
if (!plot.isOwner(player.getUUID()) && !Permissions.hasPermission(player, C.PERMISSION_ADMIN_COMMAND_SCHEMATIC_SAVE)) {
|
||||
MainUtil.sendMessage(player, C.NO_PLOT_PERMS);
|
||||
return false;
|
||||
}
|
||||
|
@ -58,8 +58,8 @@ public class Set extends SubCommand {
|
||||
|
||||
for (String component : components) {
|
||||
if (component.equalsIgnoreCase(args[0])) {
|
||||
if (!Permissions.hasPermission(player, "plots.set." + component)) {
|
||||
MainUtil.sendMessage(player, C.NO_PERMISSION, "plots.set." + component);
|
||||
if (!Permissions.hasPermission(player, C.PERMISSION_SET_COMPONENT.f(component))) {
|
||||
MainUtil.sendMessage(player, C.NO_PERMISSION, C.PERMISSION_SET_COMPONENT.f(component));
|
||||
return false;
|
||||
}
|
||||
PlotBlock[] blocks;
|
||||
|
@ -18,15 +18,15 @@ public abstract class SetCommand extends SubCommand {
|
||||
return !sendMessage(player, C.NOT_IN_PLOT);
|
||||
}
|
||||
if (!plot.hasOwner()) {
|
||||
if (!Permissions.hasPermission(player, "plots.admin.command." + getFullId())) {
|
||||
MainUtil.sendMessage(player, C.NO_PERMISSION, "plots.admin.command." + getFullId());
|
||||
if (!Permissions.hasPermission(player, C.PERMISSION_ADMIN_COMMAND.f(getFullId()))) {
|
||||
MainUtil.sendMessage(player, C.NO_PERMISSION, C.PERMISSION_ADMIN_COMMAND.f(getFullId()));
|
||||
MainUtil.sendMessage(player, C.PLOT_NOT_CLAIMED);
|
||||
return false;
|
||||
}
|
||||
}
|
||||
if (!plot.isOwner(player.getUUID())) {
|
||||
if (!Permissions.hasPermission(player, "plots.admin.command." + getFullId())) {
|
||||
MainUtil.sendMessage(player, C.NO_PERMISSION, "plots.admin.command." + getFullId());
|
||||
if (!Permissions.hasPermission(player, C.PERMISSION_ADMIN_COMMAND.f(getFullId()))) {
|
||||
MainUtil.sendMessage(player, C.NO_PERMISSION, C.PERMISSION_ADMIN_COMMAND.f(getFullId()));
|
||||
MainUtil.sendMessage(player, C.NO_PLOT_PERMS);
|
||||
return false;
|
||||
}
|
||||
|
@ -32,7 +32,7 @@ public class Setup extends SubCommand {
|
||||
StringBuilder message = new StringBuilder();
|
||||
message.append("&6What generator do you want?");
|
||||
for (Entry<String, GeneratorWrapper<?>> entry : SetupUtils.generators.entrySet()) {
|
||||
if (entry.getKey().equals("PlotSquared")) {
|
||||
if (entry.getKey().equals(PS.imp().getPluginName())) {
|
||||
message.append("\n&8 - &2").append(entry.getKey()).append(" (Default Generator)");
|
||||
} else if (entry.getValue().isFull()) {
|
||||
message.append("\n&8 - &7").append(entry.getKey()).append(" (Plot Generator)");
|
||||
@ -79,7 +79,7 @@ public class Setup extends SubCommand {
|
||||
if (args.length != 1 || !SetupUtils.generators.containsKey(args[0])) {
|
||||
String prefix = "\n&8 - &7";
|
||||
MainUtil.sendMessage(player, "&cYou must choose a generator!" + prefix + StringMan.join(SetupUtils.generators.keySet(), prefix)
|
||||
.replaceAll("PlotSquared", "&2PlotSquared"));
|
||||
.replaceAll(PS.imp().getPluginName(), "&2" + PS.imp().getPluginName()));
|
||||
sendMessage(player, C.SETUP_INIT);
|
||||
return false;
|
||||
}
|
||||
@ -137,7 +137,7 @@ public class Setup extends SubCommand {
|
||||
.getNewPlotArea("CheckingPlotSquaredGenerator", null, null, null).getSettingNodes();
|
||||
SetupUtils.generators.get(object.plotManager).getPlotGenerator().processSetup(object);
|
||||
} else {
|
||||
object.plotManager = "PlotSquared";
|
||||
object.plotManager = PS.imp().getPluginName();
|
||||
MainUtil.sendMessage(player, "&c[WARNING] The specified generator does not identify as BukkitPlotGenerator");
|
||||
MainUtil.sendMessage(player, "&7 - You may need to manually configure the other plugin");
|
||||
object.step = SetupUtils.generators.get(object.plotManager).getPlotGenerator()
|
||||
@ -263,7 +263,7 @@ public class Setup extends SubCommand {
|
||||
return false;
|
||||
}
|
||||
MainUtil.sendMessage(player,
|
||||
"&cThe world you specified already exists. After restarting, new terrain will use PlotSquared, however you may need to "
|
||||
"&cThe world you specified already exists. After restarting, new terrain will use " + PS.imp().getPluginName() + ", however you may need to "
|
||||
+ "reset the world for it to generate correctly!");
|
||||
}
|
||||
object.world = args[0];
|
||||
|
@ -51,13 +51,18 @@ public class Template extends SubCommand {
|
||||
ZipEntry ze = zis.getNextEntry();
|
||||
byte[] buffer = new byte[2048];
|
||||
while (ze != null) {
|
||||
String name = ze.getName().replace('\\', File.separatorChar).replace('/', File.separatorChar);
|
||||
File newFile = new File((output + File.separator + name).replaceAll("__TEMP_DIR__", world));
|
||||
new File(newFile.getParent()).mkdirs();
|
||||
try (FileOutputStream fos = new FileOutputStream(newFile)) {
|
||||
int len;
|
||||
while ((len = zis.read(buffer)) > 0) {
|
||||
fos.write(buffer, 0, len);
|
||||
if (!ze.isDirectory()) {
|
||||
String name = ze.getName().replace('\\', File.separatorChar).replace('/', File.separatorChar);
|
||||
File newFile = new File((output + File.separator + name).replaceAll("__TEMP_DIR__", world));
|
||||
File parent = newFile.getParentFile();
|
||||
if (parent != null) {
|
||||
parent.mkdirs();
|
||||
}
|
||||
try (FileOutputStream fos = new FileOutputStream(newFile)) {
|
||||
int len;
|
||||
while ((len = zis.read(buffer)) > 0) {
|
||||
fos.write(buffer, 0, len);
|
||||
}
|
||||
}
|
||||
}
|
||||
ze = zis.getNextEntry();
|
||||
@ -142,7 +147,7 @@ public class Template extends SubCommand {
|
||||
} catch (InvalidConfigurationException | IOException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
String manager = worldConfig.getString("generator.plugin", "PlotSquared");
|
||||
String manager = worldConfig.getString("generator.plugin", PS.imp().getPluginName());
|
||||
String generator = worldConfig.getString("generator.init", manager);
|
||||
int type = worldConfig.getInt("generator.type");
|
||||
int terrain = worldConfig.getInt("generator.terrain");
|
||||
|
@ -1,6 +1,7 @@
|
||||
package com.intellectualcrafters.plot.commands;
|
||||
|
||||
import com.intellectualcrafters.plot.config.C;
|
||||
import com.intellectualcrafters.plot.object.PlotArea;
|
||||
import com.intellectualcrafters.plot.object.PlotPlayer;
|
||||
import com.intellectualcrafters.plot.object.RunnableVal2;
|
||||
import com.intellectualcrafters.plot.object.RunnableVal3;
|
||||
@ -53,7 +54,7 @@ public class Toggle extends Command {
|
||||
permission = "plots.toggle.chat",
|
||||
description = "Toggle plot chat")
|
||||
public void chat(Command command, PlotPlayer player, String[] args, RunnableVal3<Command, Runnable, Runnable> confirm,
|
||||
RunnableVal2<Command, CommandResult> whenDone) {
|
||||
RunnableVal2<Command, CommandResult> whenDone) {
|
||||
if (toggle(player, "chat")) {
|
||||
MainUtil.sendMessage(player, C.TOGGLE_DISABLED, command.toString());
|
||||
} else {
|
||||
@ -61,13 +62,28 @@ public class Toggle extends Command {
|
||||
}
|
||||
}
|
||||
|
||||
@CommandDeclaration(
|
||||
command = "clear-confirmation",
|
||||
permission = "plots.admin.command.autoclear",
|
||||
description = "Toggle autoclear confirmation")
|
||||
public void clearConfirmation(Command command, PlotPlayer player, String[] args, RunnableVal3<Command, Runnable, Runnable> confirm,
|
||||
RunnableVal2<Command, CommandResult> whenDone) {
|
||||
if (toggle(player, "ignoreExpireTask")) {
|
||||
MainUtil.sendMessage(player, C.TOGGLE_DISABLED, command.toString());
|
||||
} else {
|
||||
MainUtil.sendMessage(player, C.TOGGLE_ENABLED, command.toString());
|
||||
}
|
||||
}
|
||||
|
||||
@CommandDeclaration(
|
||||
command = "titles",
|
||||
permission = "plots.toggle.titles",
|
||||
description = "Toggle plot title messages")
|
||||
public void titles(Command command, PlotPlayer player, String[] args, RunnableVal3<Command, Runnable, Runnable> confirm,
|
||||
RunnableVal2<Command, CommandResult> whenDone) {
|
||||
if (toggle(player, "disabletitles")) {
|
||||
PlotArea area = player.getApplicablePlotArea();
|
||||
boolean chat = area == null ? false : area.PLOT_CHAT;
|
||||
if (toggle(player, "disabletitles") != chat) {
|
||||
MainUtil.sendMessage(player, C.TOGGLE_ENABLED, command.toString());
|
||||
} else {
|
||||
MainUtil.sendMessage(player, C.TOGGLE_DISABLED, command.toString());
|
||||
|
@ -15,6 +15,7 @@ import com.intellectualcrafters.plot.util.TaskManager;
|
||||
import com.intellectualcrafters.plot.util.WorldUtil;
|
||||
import com.intellectualcrafters.plot.util.block.GlobalBlockQueue;
|
||||
import com.intellectualcrafters.plot.util.block.LocalBlockQueue;
|
||||
import com.intellectualcrafters.plot.util.expiry.ExpireManager;
|
||||
import com.plotsquared.general.commands.CommandDeclaration;
|
||||
|
||||
import java.io.File;
|
||||
@ -101,6 +102,9 @@ public class Trim extends SubCommand {
|
||||
MainUtil.sendMessage(null, "Collecting region data...");
|
||||
ArrayList<Plot> plots = new ArrayList<>();
|
||||
plots.addAll(PS.get().getPlots(world));
|
||||
if (ExpireManager.IMP != null) {
|
||||
plots.removeAll(ExpireManager.IMP.getPendingExpired());
|
||||
}
|
||||
result.value1 = new HashSet<>(ChunkManager.manager.getChunkChunks(world));
|
||||
result.value2 = new HashSet<>();
|
||||
MainUtil.sendMessage(null, " - MCA #: " + result.value1.size());
|
||||
|
@ -33,7 +33,7 @@ public class Trust extends Command {
|
||||
public void execute(final PlotPlayer player, String[] args, RunnableVal3<Command, Runnable, Runnable> confirm, RunnableVal2<Command, CommandResult> whenDone) throws CommandException {
|
||||
final Plot plot = check(player.getCurrentPlot(), C.NOT_IN_PLOT);
|
||||
checkTrue(plot.hasOwner(), C.PLOT_UNOWNED);
|
||||
checkTrue(plot.isOwner(player.getUUID()) || Permissions.hasPermission(player, "plots.admin.command.trust"), C.NO_PLOT_PERMS);
|
||||
checkTrue(plot.isOwner(player.getUUID()) || Permissions.hasPermission(player, C.PERMISSION_ADMIN_COMMAND_TRUST), C.NO_PLOT_PERMS);
|
||||
checkTrue(args.length == 1, C.COMMAND_SYNTAX, getUsage());
|
||||
final Set<UUID> uuids = MainUtil.getUUIDsFromString(args[0]);
|
||||
checkTrue(!uuids.isEmpty(), C.INVALID_PLAYER, args[0]);
|
||||
@ -41,7 +41,7 @@ public class Trust extends Command {
|
||||
int size = plot.getTrusted().size() + plot.getMembers().size();
|
||||
while (iter.hasNext()) {
|
||||
UUID uuid = iter.next();
|
||||
if (uuid == DBFunc.everyone && !(Permissions.hasPermission(player, "plots.trust.everyone") || Permissions.hasPermission(player, "plots.admin.command.trust"))) {
|
||||
if (uuid == DBFunc.everyone && !(Permissions.hasPermission(player, C.PERMISSION_TRUST_EVERYONE) || Permissions.hasPermission(player, C.PERMISSION_ADMIN_COMMAND_TRUST))) {
|
||||
MainUtil.sendMessage(player, C.INVALID_PLAYER, MainUtil.getName(uuid));
|
||||
iter.remove();
|
||||
continue;
|
||||
@ -59,7 +59,7 @@ public class Trust extends Command {
|
||||
size += plot.getMembers().contains(uuid) ? 0 : 1;
|
||||
}
|
||||
checkTrue(!uuids.isEmpty(), null);
|
||||
checkTrue(size <= plot.getArea().MAX_PLOT_MEMBERS || Permissions.hasPermission(player, "plots.admin.command.trust"), C.PLOT_MAX_MEMBERS);
|
||||
checkTrue(size <= plot.getArea().MAX_PLOT_MEMBERS || Permissions.hasPermission(player, C.PERMISSION_ADMIN_COMMAND_TRUST), C.PLOT_MAX_MEMBERS);
|
||||
confirm.run(this, new Runnable() {
|
||||
@Override // Success
|
||||
public void run() {
|
||||
|
@ -31,7 +31,7 @@ public class Unlink extends SubCommand {
|
||||
if (!plot.hasOwner()) {
|
||||
return !sendMessage(player, C.PLOT_UNOWNED);
|
||||
}
|
||||
if (!plot.isOwner(player.getUUID()) && !Permissions.hasPermission(player, "plots.admin.command.unlink")) {
|
||||
if (!plot.isOwner(player.getUUID()) && !Permissions.hasPermission(player, C.PERMISSION_ADMIN_COMMAND_UNLINK)) {
|
||||
return sendMessage(player, C.NO_PLOT_PERMS);
|
||||
}
|
||||
if (!plot.isMerged()) {
|
||||
|
@ -13,7 +13,7 @@ import java.net.URL;
|
||||
@CommandDeclaration(
|
||||
command = "update",
|
||||
permission = "plots.admin.command.update",
|
||||
description = "Update PlotSquared",
|
||||
description = "Update the plugin",
|
||||
usage = "/plot update",
|
||||
requiredType = RequiredType.NONE,
|
||||
aliases = {"updateplugin"},
|
||||
|
@ -2,7 +2,9 @@ package com.intellectualcrafters.plot.commands;
|
||||
|
||||
import com.intellectualcrafters.plot.PS;
|
||||
import com.intellectualcrafters.plot.config.C;
|
||||
import com.intellectualcrafters.plot.config.Settings;
|
||||
import com.intellectualcrafters.plot.object.Plot;
|
||||
import com.intellectualcrafters.plot.object.PlotArea;
|
||||
import com.intellectualcrafters.plot.object.PlotPlayer;
|
||||
import com.intellectualcrafters.plot.object.RunnableVal2;
|
||||
import com.intellectualcrafters.plot.object.RunnableVal3;
|
||||
@ -45,16 +47,36 @@ public class Visit extends Command {
|
||||
}
|
||||
int page = Integer.MIN_VALUE;
|
||||
Collection<Plot> unsorted = null;
|
||||
PlotArea sortByArea = player.getApplicablePlotArea();
|
||||
boolean shouldSortByArea = Settings.Teleport.PER_WORLD_VISIT;
|
||||
switch (args.length) {
|
||||
case 2:
|
||||
case 3:
|
||||
if (!MathMan.isInteger(args[1])) {
|
||||
C.NOT_VALID_NUMBER.send(player, "(1, ∞)");
|
||||
C.COMMAND_SYNTAX.send(player, getUsage());;
|
||||
C.COMMAND_SYNTAX.send(player, getUsage());
|
||||
return;
|
||||
}
|
||||
page = Integer.parseInt(args[2]);
|
||||
case 2:
|
||||
if (!MathMan.isInteger(args[1])) {
|
||||
sortByArea = PS.get().getPlotAreaByString(args[1]);
|
||||
if (sortByArea == null) {
|
||||
C.NOT_VALID_NUMBER.send(player, "(1, ∞)");
|
||||
C.COMMAND_SYNTAX.send(player, getUsage());
|
||||
return;
|
||||
}
|
||||
UUID user = UUIDHandler.getUUIDFromString(args[0]);
|
||||
if (user == null) {
|
||||
C.COMMAND_SYNTAX.send(player, getUsage());
|
||||
return;
|
||||
}
|
||||
unsorted = PS.get().getBasePlots(user);
|
||||
shouldSortByArea = true;
|
||||
break;
|
||||
}
|
||||
page = Integer.parseInt(args[1]);
|
||||
case 1:
|
||||
UUID user = (args.length == 2 || !MathMan.isInteger(args[0])) ? UUIDHandler.getCachedUUID(args[0], null) : null;
|
||||
UUID user = (args.length == 2 || !MathMan.isInteger(args[0])) ? UUIDHandler.getUUIDFromString(args[0]) : null;
|
||||
if (page == Integer.MIN_VALUE && user == null && MathMan.isInteger(args[0])) {
|
||||
page = Integer.parseInt(args[0]);
|
||||
unsorted = PS.get().getBasePlots(player);
|
||||
@ -93,26 +115,31 @@ public class Visit extends Command {
|
||||
C.NOT_VALID_NUMBER.send(player, "(1, " + unsorted.size() + ")");
|
||||
return;
|
||||
}
|
||||
List<Plot> plots = PS.get().sortPlotsByTemp(unsorted);
|
||||
List<Plot> plots;
|
||||
if (shouldSortByArea) {
|
||||
plots = PS.get().sortPlots(unsorted, PS.SortType.CREATION_DATE, sortByArea);
|
||||
} else {
|
||||
plots = PS.get().sortPlotsByTemp(unsorted);
|
||||
}
|
||||
final Plot plot = plots.get(page - 1);
|
||||
if (!plot.hasOwner()) {
|
||||
if (!Permissions.hasPermission(player, "plots.visit.unowned")) {
|
||||
C.NO_PERMISSION.send(player, "plots.visit.unowned");
|
||||
if (!Permissions.hasPermission(player, C.PERMISSION_VISIT_UNOWNED)) {
|
||||
C.NO_PERMISSION.send(player, C.PERMISSION_VISIT_UNOWNED);
|
||||
return;
|
||||
}
|
||||
} else if (plot.isOwner(player.getUUID())) {
|
||||
if (!Permissions.hasPermission(player, "plots.visit.owned") && !Permissions.hasPermission(player, "plots.home")) {
|
||||
C.NO_PERMISSION.send(player, "plots.visit.owned, plots.home");
|
||||
if (!Permissions.hasPermission(player, C.PERMISSION_VISIT_OWNED) && !Permissions.hasPermission(player, C.PERMISSION_HOME)) {
|
||||
C.NO_PERMISSION.send(player, C.PERMISSION_VISIT_OWNED);
|
||||
return;
|
||||
}
|
||||
} else if (plot.isAdded(player.getUUID())) {
|
||||
if (!Permissions.hasPermission(player, "plots.visit.shared")) {
|
||||
C.NO_PERMISSION.send(player, "plots.visit.shared");
|
||||
if (!Permissions.hasPermission(player, C.PERMISSION_SHARED)) {
|
||||
C.NO_PERMISSION.send(player, C.PERMISSION_SHARED);
|
||||
return;
|
||||
}
|
||||
} else {
|
||||
if (!Permissions.hasPermission(player, "plots.visit.other")) {
|
||||
C.NO_PERMISSION.send(player, "plots.visit.other");
|
||||
if (!Permissions.hasPermission(player, C.PERMISSION_VISIT_OTHER)) {
|
||||
C.NO_PERMISSION.send(player, C.PERMISSION_VISIT_OTHER);
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
@ -70,12 +70,97 @@ public enum C {
|
||||
PERMISSION_ADMIN_INTERACT_OTHER("plots.admin.interact.other", "static.permissions"),
|
||||
PERMISSION_ADMIN_BUILD_HEIGHTLIMIT("plots.admin.build.heightlimit", "static.permissions"),
|
||||
PERMISSION_ADMIN_UPDATE("plots.admin.command.update", "static.permissions"),
|
||||
PERMISSION_ADMIN_COMMAND_TRUST("plots.admin.command.trust", "static.permissions"),
|
||||
PERMISSION_TRUST_EVERYONE("plots.trust.everyone", "static.permissions"),
|
||||
PERMISSION_AREA_CREATE("plots.area.create", "static.permissions"),
|
||||
PERMISSION_AREA_INFO("plots.area.info", "static.permissions"),
|
||||
PERMISSION_AREA_LIST("plots.area.list", "static.permissions"),
|
||||
PERMISSION_AREA_REGEN("plots.area.regen", "static.permissions"),
|
||||
PERMISSION_AREA_TP("plots.area.tp", "static.permissions"),
|
||||
PERMISSION_AUTO_MEGA("plots.atuo.mega", "static.permissions"),
|
||||
PERMISSION_CLAIM_SCHEMATIC("plots.claim.%s0", "static.permissions"),
|
||||
PERMISSION_ADMIN_COMMAND_SCHEMATIC("plots.admin.command.schematic", "static.permissions"),
|
||||
PERMISSION_ADMIN_COMMAND_BO3("plots.admin.command.bo3", "static.permissions"),
|
||||
PERMISSION_ADMIN_COMMAND_CLEAR("plots.admin.command.clear", "static.permissions"),
|
||||
PERMISSION_CONTINUE("plots.continue", "static.permissions"),
|
||||
PERMISSION_CLUSTER_LIST("plots.cluster.list", "static.permissions"),
|
||||
PERMISSION_CLUSTER_CREATE("plots.cluster.create", "static.permissions"),
|
||||
PERMISSION_CLUSTER_CREATE_OTHER("plots.cluster.create.other", "static.permissions"),
|
||||
PERMISSION_CLUSTER_SIZE("plots.cluster.size", "static.permissions"),
|
||||
PERMISSION_CLUSTER_DELETE("plots.cluster.delete", "static.permissions"),
|
||||
PERMISSION_CLUSTER_DELETE_OTHER("plots.cluster.delete.other", "static.permissions"),
|
||||
PERMISSION_CLUSTER_RESIZE("plots.cluster.resize", "static.permissions"),
|
||||
PERMISSION_CLUSTER_RESIZE_OTHER("plots.cluster.resize.other", "static.permissions"),
|
||||
PERMISSION_CLUSTER_RESIZE_SHRINK("plots.cluster.resize.shrink", "static.permissions"),
|
||||
PERMISSION_CLUSTER_RESIZE_EXPAND("plots.cluster.resize.expand", "static.permissions"),
|
||||
PERMISSION_CLUSTER("plots.cluster", "static.permissions"),
|
||||
PERMISSION_CLUSTER_INVITE("plots.cluster.invite", "static.permissions"),
|
||||
PERMISSION_CLUSTER_INVITE_OTHER("plots.cluster.invite.other", "static.permissions"),
|
||||
PERMISSION_CLUSTER_KICK("plots.cluster.kick", "static.permissions"),
|
||||
PERMISSION_CLUSTER_KICK_OTHER("plots.cluster.kick.other", "static.permissions"),
|
||||
PERMISSION_CLUSTER_LEAVE("plots.cluster.leave", "static.permissions"),
|
||||
PERMISSION_CLUSTER_HELPERS("plots.cluster.helpers", "static.permissions"),
|
||||
PERMISSION_CLUSTER_TP("plots.cluster.tp", "static.permissions"),
|
||||
PERMISSION_CLUSTER_TP_OTHER("plots.cluster.tp.other", "static.permissions"),
|
||||
PERMISSION_CLUSTER_INFO("plots.cluster.info", "static.permissions"),
|
||||
PERMISSION_CLUSTER_SETHOME("plots.cluster.sethome", "static.permissions"),
|
||||
PERMISSION_CLUSTER_SETHOME_OTHER("plots.cluster.sethome.other", "static.permissions"),
|
||||
PERMISSION_ADMIN_COMMAND_CONTINUE("plots.admin.command.continue", "static.permissions"),
|
||||
PERMISSION_ADMIN_COMMAND_DELETE("plots.admin.command.delete", "static.permissions"),
|
||||
PERMISSION_ADMIN_COMMAND_DENY("plots.admin.command.deny", "static.permissions"),
|
||||
PERMISSION_DENY_EVERYONE("plots.deny.everyone", "static.permissions"),
|
||||
PERMISSION_ADMIN_COMMAND_DONE("plots.admin.command.done", "static.permissions"),
|
||||
PERMISSION_ADMIN_COMMAND_DOWNLOAD("plots.admin.command.download", "static.permissions"),
|
||||
PERMISSION_DOWNLOAD_BO3("plots.download.bo3", "static.permissions"),
|
||||
PERMISSION_DOWNLOAD_WORLD("plots.download.world", "static.permissions"),
|
||||
PERMISSION_SET_FLAG_OTHER("plots.set.flag.other", "static.permissions"),
|
||||
PERMISSION_SET_FLAG("plots.set.flag", "static.permissions"),
|
||||
PERMISSION_SET_FLAG_KEY("plots.set.flag.%s0", "static.permissions"),
|
||||
PERMISSION_SET_FLAG_KEY_VALUE("plots.set.flag.%s0.%s1", "static.permissions"),
|
||||
PERMISSION_FLAG_REMOVE("plots.flag.remove", "static.permissions"),
|
||||
PERMISSION_FLAG_ADD("plots.flag.add", "static.permissions"),
|
||||
PERMISSION_FLAG_LIST("plots.flag.list", "static.permissions"),
|
||||
PERMISSION_ADMIN_COMMAND_KICK("plots.admin.command.kick", "static.permissions"),
|
||||
PERMISSION_GRANT("plots.grant.%s0", "static.permissions"),
|
||||
PERMISSION_LIST_FORSALE("plots.list.forsale", "static.permissions"),
|
||||
PERMISSION_LIST_MINE("plots.list.mine", "static.permissions"),
|
||||
PERMISSION_LIST_SHARED("plots.list.shared", "static.permissions"),
|
||||
PERMISSION_LIST_WORLD("plots.list.world", "static.permissions"),
|
||||
PERMISSION_LIST_WORLD_NAME("plots.list.world.%s0", "static.permissions"),
|
||||
PERMISSION_LIST_TOP("plots.list.top", "static.permissions"),
|
||||
PERMISSION_LIST_ALL("plots.list.all", "static.permissions"),
|
||||
PERMISSION_LIST_UNOWNED("plots.list.unowned", "static.permissions"),
|
||||
PERMISSION_LIST_UNKNOWN("plots.list.unknown", "static.permissions"),
|
||||
PERMISSION_LIST_PLAYER("plots.list.player", "static.permissions"),
|
||||
PERMISSION_LIST_DONE("plots.list.done", "static.permissions"),
|
||||
PERMISSION_LIST_EXPIRED("plots.list.expired", "static.permissions"),
|
||||
PERMISSION_LIST_FUZZY("plots.list.fuzzy", "static.permissions"),
|
||||
PERMISSION_LIST_AREA("plots.list.area", "static.permissions"),
|
||||
PERMISSION_ADMIN_COMMAND_LOAD("plots.admin.command.load", "static.permissions"),
|
||||
PERMISSION_ADMIN_COMMAND_MERGE("plots.admin.command.merge", "static.permissions"),
|
||||
PERMISSION_ADMIN_COMMAND_SETOWNER("plots.admin.command.setowner", "static.permissions"),
|
||||
PERMISSION_COMMENT("plots.comment", "static.permissions"),
|
||||
PERMISSION_ADMIN_COMMAND_REMOVE("plots.admin.command.remove", "static.permissions"),
|
||||
PERMISSION_ADMIN_COMMAND_SAVE("plots.admin.command.save", "static.permissions"),
|
||||
PERMISSION_ADMIN_COMMAND_SCHEMATIC_PASTE("plots.admin.command.schematic.paste", "static.permissions"),
|
||||
PERMISSION_SCHEMATIC_PASTE("plots.schematic.paste", "static.permissions"),
|
||||
PERMISSION_SCHEMATIC_SAVE("plots.schematic.save", "static.permissions"),
|
||||
PERMISSION_ADMIN_COMMAND_SCHEMATIC_SAVE("plots.admin.command.schematic.save", "static.permissions"),
|
||||
PERMISSION_SET_COMPONENT("plots.set.%s0", "static.permissions"),
|
||||
PERMISSION_ADMIN_COMMAND("plots.admin.command.%s0", "static.permissions"),
|
||||
PERMISSION_ADMIN_COMMAND_UNLINK("", "static.permissions"),
|
||||
PERMISSION_VISIT_UNOWNED("plots.visit.unowned", "static.permissions"),
|
||||
PERMISSION_VISIT_OWNED("plots.visit.owned", "static.permissions"),
|
||||
PERMISSION_SHARED("plots.visit.shared", "static.permissions"),
|
||||
PERMISSION_VISIT_OTHER("plots.visit.other", "static.permissions"),
|
||||
PERMISSION_HOME("plots.home", "static.permissions"),
|
||||
|
||||
/*
|
||||
* Static console
|
||||
*/
|
||||
CONSOLE_JAVA_OUTDATED_1_8("&cYour version of java is outdated. It is highly recommended that you update to Java 8 as it increases performance "
|
||||
+ "and security. PlotSquared will require Java 9 in a future update.", "static.console"),
|
||||
CONSOLE_PLEASE_ENABLE_METRICS("&dPlease enable metrics for PlotSquared. Using metrics improves plugin stability, performance, and features. "
|
||||
+ "and security. %s0 will require Java 9 in a future update.", "static.console"),
|
||||
CONSOLE_PLEASE_ENABLE_METRICS("&dPlease enable metrics for %s0. Using metrics improves plugin stability, performance, and features. "
|
||||
+ "Bug fixes and new features are influenced on metrics.", "static.console"),
|
||||
/*
|
||||
* Confirm
|
||||
@ -115,6 +200,7 @@ public enum C {
|
||||
CLUSTER_LIST_HEADING("$2There are $1%s$2 clusters in this world", "Cluster"),
|
||||
CLUSTER_LIST_ELEMENT("$2 - $1%s&-", "Cluster"),
|
||||
CLUSTER_INTERSECTION("$2The proposed area overlaps with: %s0", "Cluster"),
|
||||
CLUSTER_OUTSIDE("$2The proposed area is outside the plot area: %s0", "Cluster"),
|
||||
CLUSTER_ADDED("$4Successfully created the cluster.", "Cluster"),
|
||||
CLUSTER_DELETED("$4Successfully deleted the cluster.", "Cluster"),
|
||||
CLUSTER_RESIZED("$4Successfully resized the cluster.", "Cluster"),
|
||||
@ -167,7 +253,7 @@ public enum C {
|
||||
*/
|
||||
SWAP_OVERLAP("$2The proposed areas are not allowed to overlap", "Swap"),
|
||||
SWAP_DIMENSIONS("$2The proposed areas must have comparable dimensions", "Swap"),
|
||||
SWAP_SYNTAX("$2/plots swap <id>", "Swap"),
|
||||
SWAP_SYNTAX("$2/plot swap <id>", "Swap"),
|
||||
SWAP_SUCCESS("$4Successfully swapped plots", "Swap"),
|
||||
STARTED_SWAP("$2Started plot swap task. You will be notified when it finishes", "Swap"),
|
||||
/*
|
||||
@ -176,7 +262,7 @@ public enum C {
|
||||
INBOX_NOTIFICATION("%s unread messages. Use /plot inbox", "Comment"),
|
||||
NOT_VALID_INBOX_INDEX("$2No comment at index %s", "Comment"),
|
||||
INBOX_ITEM("$2 - $4%s", "Comment"),
|
||||
COMMENT_SYNTAX("$2Use /plots comment [X;Z] <%s> <comment>", "Comment"),
|
||||
COMMENT_SYNTAX("$2Use /plot comment [X;Z] <%s> <comment>", "Comment"),
|
||||
INVALID_INBOX("$2That is not a valid inbox.&-$1Accepted values: %s", "Comment"),
|
||||
NO_PERM_INBOX("$2You do not have permission for that inbox", "Comment"),
|
||||
NO_PERM_INBOX_MODIFY("$2You do not have permission to modify that inbox", "Comment"),
|
||||
@ -258,7 +344,7 @@ public enum C {
|
||||
"$4You should have been teleported to the created world. Otherwise you will need to set the generator manually using the bukkit.yml or "
|
||||
+ "your chosen world management plugin.",
|
||||
"Setup"),
|
||||
SETUP_WORLD_TAKEN("$2%s is already a registered plotworld", "Setup"),
|
||||
SETUP_WORLD_TAKEN("$2%s is already a world", "Setup"),
|
||||
SETUP_MISSING_WORLD(
|
||||
"$2You need to specify a world name ($1/plot setup &l<world>$1 <generator>$2)&-$1Additional commands:&-$2 - $1/plot setup <value>&-$2 -"
|
||||
+ " $1/plot setup back&-$2 - $1/plot setup cancel", "Setup"),
|
||||
@ -287,7 +373,7 @@ public enum C {
|
||||
*/
|
||||
TASK_START("Starting task...", "Core"),
|
||||
PREFIX("$3[$1P2$3] $2", "Core"),
|
||||
ENABLED("$1PlotSquared is now enabled", "Core"),
|
||||
ENABLED("$1%s0 is now enabled", "Core"),
|
||||
/*
|
||||
* Reload
|
||||
*/
|
||||
@ -332,6 +418,7 @@ public enum C {
|
||||
NO_PERMISSION_EVENT("$2You are lacking the permission node: $1%s", "Permission"),
|
||||
NO_PLOT_PERMS("$2You must be the plot owner to perform this action", "Permission"),
|
||||
CANT_CLAIM_MORE_PLOTS("$2You can't claim more plots.", "Permission"),
|
||||
CANT_CLAIM_MORE_CLUSTERS("$2You can't claim more clusters.", "Permission"),
|
||||
CANT_TRANSFER_MORE_PLOTS("$2You can't send more plots to that user", "Permission"),
|
||||
CANT_CLAIM_MORE_PLOTS_NUM("$2You can't claim more than $1%s $2plots at once", "Permission"),
|
||||
YOU_BE_DENIED("$2You are not allowed to enter this plot", "Permission"),
|
||||
@ -365,6 +452,10 @@ public enum C {
|
||||
INVALID_PLAYER_WAIT("$2Player not found: $1%s$2, fetching it. Try again soon.", "Errors"),
|
||||
INVALID_PLAYER("$2Player not found: $1%s$2.", "Errors"),
|
||||
INVALID_PLAYER_OFFLINE("$2The player must be online: $1%s.", "Errors"),
|
||||
/*
|
||||
* Command flag
|
||||
*/
|
||||
INVALID_COMMAND_FLAG("$2Invalid command flag: %s0", "Errors"),
|
||||
/*
|
||||
* Unknown Error
|
||||
*/
|
||||
@ -454,6 +545,10 @@ public enum C {
|
||||
NEED_PLOT_ID("$2You've got to specify a plot id.", "Need"),
|
||||
NEED_PLOT_WORLD("$2You've got to specify a plot area.", "Need"),
|
||||
NEED_USER("$2You need to specify a username", "Need"),
|
||||
/*
|
||||
* Near
|
||||
*/
|
||||
PLOT_NEAR("$1Players: %s0", "Near"),
|
||||
/*
|
||||
* Info
|
||||
*/
|
||||
@ -500,6 +595,7 @@ public enum C {
|
||||
*/
|
||||
CLEARING_PLOT("$2Clearing plot async.", "Working"),
|
||||
CLEARING_DONE("$4Clear completed! Took %sms.", "Working"),
|
||||
DELETING_DONE("$4Delete completed! Took %sms.", "Working"),
|
||||
/*
|
||||
* Claiming
|
||||
*/
|
||||
@ -521,12 +617,6 @@ public enum C {
|
||||
* Left
|
||||
*/
|
||||
LEFT_PLOT("$2You left a plot", "Left"),
|
||||
/*
|
||||
* PlotMe
|
||||
*/
|
||||
NOT_USING_PLOTME(
|
||||
"$2This server uses the far superior $1PlotSquared $2plot management system. Please use the $1/ps $2or $1/p2 $2or $1/plots $2instead",
|
||||
"Errors"),
|
||||
/*
|
||||
* Wait
|
||||
*/
|
||||
@ -606,7 +696,7 @@ public enum C {
|
||||
HELP_PAGE_HEADER("$1Category: $2%category%$2,$1 Page: $2%current%$3/$2%max%$2", "Help"),
|
||||
HELP_FOOTER("$3&m---------&r $1Plot\u00B2 Help $3&m---------", "Help"),
|
||||
|
||||
HELP_INFO_ITEM("$1/plots help %category% $3- $2%category_desc%", "Help"),
|
||||
HELP_INFO_ITEM("$1/plot help %category% $3- $2%category_desc%", "Help"),
|
||||
HELP_ITEM("$1%usage% [%alias%]&- $3- $2%desc%&-", "Help"),
|
||||
/*
|
||||
* Direction
|
||||
|
@ -51,7 +51,6 @@ public class Settings extends Config {
|
||||
Redstone.DISABLE_UNOCCUPIED = config.getBoolean("protection.redstone.disable-unoccupied", Redstone.DISABLE_UNOCCUPIED);
|
||||
|
||||
// PlotMe
|
||||
PlotMe.ALIAS = config.getBoolean("plotme-alias", PlotMe.ALIAS);
|
||||
Enabled_Components.PLOTME_CONVERTER = config.getBoolean("plotme-convert.enabled", Enabled_Components.PLOTME_CONVERTER);
|
||||
PlotMe.CACHE_UUDS = config.getBoolean("plotme-convert.cache-uuids", PlotMe.CACHE_UUDS);
|
||||
|
||||
@ -185,9 +184,9 @@ public class Settings extends Config {
|
||||
}
|
||||
|
||||
public static class UUID {
|
||||
@Comment("Force PlotSquared to use offline UUIDs (it usually detects the right mode)")
|
||||
@Comment("Force using offline UUIDs (it usually detects the right mode)")
|
||||
public static boolean OFFLINE = false;
|
||||
@Comment("Force PlotSquared to use lowercase UUIDs")
|
||||
@Comment("Force using lowercase UUIDs")
|
||||
public static boolean FORCE_LOWERCASE = false;
|
||||
@Comment("Use a database to store UUID/name info")
|
||||
public static boolean USE_SQLUUIDHANDLER = false;
|
||||
@ -195,7 +194,7 @@ public class Settings extends Config {
|
||||
public static boolean NATIVE_UUID_PROVIDER = false;
|
||||
}
|
||||
|
||||
@Comment("Configure the paths PlotSquared will use")
|
||||
@Comment("Configure the paths that will be used")
|
||||
public static final class Paths {
|
||||
public static String SCHEMATICS = "schematics";
|
||||
public static String BO3 = "bo3";
|
||||
@ -241,8 +240,6 @@ public class Settings extends Config {
|
||||
public static final class PlotMe {
|
||||
@Comment("Cache the uuids from the PlotMe database")
|
||||
public static boolean CACHE_UUDS = false;
|
||||
@Comment("Have `/plotme` as a command alias")
|
||||
public static boolean ALIAS = false;
|
||||
}
|
||||
|
||||
public static final class Teleport {
|
||||
@ -252,6 +249,8 @@ public class Settings extends Config {
|
||||
public static boolean ON_LOGIN = false;
|
||||
@Comment("Add a teleportation delay to all commands")
|
||||
public static int DELAY = 0;
|
||||
@Comment("The visit command is ordered by world instead of globally")
|
||||
public static boolean PER_WORLD_VISIT = false;
|
||||
}
|
||||
|
||||
public static final class Redstone {
|
||||
|
@ -18,7 +18,6 @@ import com.intellectualcrafters.plot.object.comment.PlotComment;
|
||||
import com.intellectualcrafters.plot.util.MainUtil;
|
||||
import com.intellectualcrafters.plot.util.StringMan;
|
||||
import com.intellectualcrafters.plot.util.TaskManager;
|
||||
|
||||
import java.sql.Connection;
|
||||
import java.sql.DatabaseMetaData;
|
||||
import java.sql.PreparedStatement;
|
||||
@ -26,7 +25,10 @@ import java.sql.ResultSet;
|
||||
import java.sql.SQLException;
|
||||
import java.sql.Statement;
|
||||
import java.sql.Timestamp;
|
||||
import java.text.ParseException;
|
||||
import java.text.SimpleDateFormat;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Date;
|
||||
import java.util.HashMap;
|
||||
import java.util.HashSet;
|
||||
import java.util.Iterator;
|
||||
@ -108,45 +110,7 @@ public class SQLManager implements AbstractDB {
|
||||
this.plotTasks = new ConcurrentHashMap<>();
|
||||
this.playerTasks = new ConcurrentHashMap<>();
|
||||
this.clusterTasks = new ConcurrentHashMap<>();
|
||||
TaskManager.runTaskAsync(new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
long last = System.currentTimeMillis();
|
||||
while (true) {
|
||||
if (SQLManager.this.closed) {
|
||||
break;
|
||||
}
|
||||
// schedule reconnect
|
||||
if (SQLManager.this.mySQL && System.currentTimeMillis() - last > 550000) {
|
||||
last = System.currentTimeMillis();
|
||||
try {
|
||||
close();
|
||||
SQLManager.this.closed = false;
|
||||
SQLManager.this.connection = database.forceConnection();
|
||||
} catch (SQLException | ClassNotFoundException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
if (!sendBatch()) {
|
||||
try {
|
||||
if (!getNotifyTasks().isEmpty()) {
|
||||
for (Runnable task : getNotifyTasks()) {
|
||||
TaskManager.runTask(task);
|
||||
}
|
||||
getNotifyTasks().clear();
|
||||
}
|
||||
Thread.sleep(50);
|
||||
} catch (InterruptedException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
});
|
||||
this.prefix = p;
|
||||
// Set timout
|
||||
// setTimout();
|
||||
// Public final
|
||||
this.SET_OWNER = "UPDATE `" + this.prefix + "plot` SET `owner` = ? WHERE `plot_id_x` = ? AND `plot_id_z` = ? AND `world` = ?";
|
||||
this.GET_ALL_PLOTS = "SELECT `id`, `plot_id_x`, `plot_id_z`, `world` FROM `" + this.prefix + "plot`";
|
||||
this.CREATE_PLOTS = "INSERT INTO `" + this.prefix + "plot`(`plot_id_x`, `plot_id_z`, `owner`, `world`, `timestamp`) values ";
|
||||
@ -155,7 +119,67 @@ public class SQLManager implements AbstractDB {
|
||||
this.CREATE_PLOT = "INSERT INTO `" + this.prefix + "plot`(`plot_id_x`, `plot_id_z`, `owner`, `world`, `timestamp`) VALUES(?, ?, ?, ?, ?)";
|
||||
this.CREATE_CLUSTER =
|
||||
"INSERT INTO `" + this.prefix + "cluster`(`pos1_x`, `pos1_z`, `pos2_x`, `pos2_z`, `owner`, `world`) VALUES(?, ?, ?, ?, ?, ?)";
|
||||
createTables();
|
||||
TaskManager.runTaskAsync(new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
try {
|
||||
createTables();
|
||||
} catch (SQLException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
long last = System.currentTimeMillis();
|
||||
while (true) {
|
||||
if (SQLManager.this.closed) {
|
||||
break;
|
||||
}
|
||||
boolean hasTask = !globalTasks.isEmpty() || !playerTasks.isEmpty() || !plotTasks.isEmpty() || !clusterTasks.isEmpty();
|
||||
if (hasTask) {
|
||||
if (SQLManager.this.mySQL && System.currentTimeMillis() - last > 550000 || !isValid()) {
|
||||
last = System.currentTimeMillis();
|
||||
reconnect();
|
||||
}
|
||||
if (!sendBatch()) {
|
||||
try {
|
||||
if (!getNotifyTasks().isEmpty()) {
|
||||
for (Runnable task : getNotifyTasks()) {
|
||||
TaskManager.runTask(task);
|
||||
}
|
||||
getNotifyTasks().clear();
|
||||
}
|
||||
Thread.sleep(50);
|
||||
} catch (InterruptedException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
} else {
|
||||
try {
|
||||
Thread.sleep(5000);
|
||||
} catch (InterruptedException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
public boolean isValid() {
|
||||
try (PreparedStatement stmt = this.connection.prepareStatement("SELECT 1")) {
|
||||
stmt.executeQuery();
|
||||
return true;
|
||||
} catch (Throwable e) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
public void reconnect() {
|
||||
try {
|
||||
close();
|
||||
SQLManager.this.closed = false;
|
||||
SQLManager.this.connection = database.forceConnection();
|
||||
} catch (SQLException | ClassNotFoundException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
|
||||
public synchronized Queue<Runnable> getGlobalTasks() {
|
||||
@ -1644,8 +1668,19 @@ public class SQLManager implements AbstractDB {
|
||||
user = UUID.fromString(o);
|
||||
uuids.put(o, user);
|
||||
}
|
||||
Timestamp timestamp = resultSet.getTimestamp("timestamp");
|
||||
long time = timestamp.getTime();
|
||||
long time;
|
||||
try {
|
||||
Timestamp timestamp = resultSet.getTimestamp("timestamp");
|
||||
time = timestamp.getTime();
|
||||
} catch (SQLException exception) {
|
||||
String parsable = resultSet.getString("timestamp");
|
||||
try {
|
||||
time = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss").parse(parsable).getTime();
|
||||
} catch (ParseException e) {
|
||||
PS.debug("Could not parse date for plot: " + id + " (" + parsable + ")");
|
||||
time = System.currentTimeMillis() + id;
|
||||
}
|
||||
}
|
||||
Plot p = new Plot(plot_id, user, new HashSet<UUID>(), new HashSet<UUID>(), new HashSet<UUID>(), "", null, null, null,
|
||||
new boolean[]{false, false, false, false}, time, id);
|
||||
HashMap<PlotId, Plot> map = newPlots.get(areaid);
|
||||
|
@ -6,6 +6,7 @@ import com.intellectualcrafters.plot.object.PlotArea;
|
||||
import com.intellectualcrafters.plot.object.RunnableVal;
|
||||
import com.intellectualcrafters.plot.util.MainUtil;
|
||||
import com.intellectualcrafters.plot.util.MathMan;
|
||||
import com.intellectualcrafters.plot.util.StringMan;
|
||||
import java.lang.reflect.Field;
|
||||
import java.util.Collection;
|
||||
import java.util.Collections;
|
||||
@ -49,6 +50,7 @@ public final class Flags {
|
||||
public static final BooleanFlag DISABLE_PHYSICS = new BooleanFlag("disable-physics");
|
||||
public static final BooleanFlag LIQUID_FLOW = new BooleanFlag("liquid-flow");
|
||||
public static final BooleanFlag SNOW_MELT = new BooleanFlag("snow-melt");
|
||||
public static final BooleanFlag SNOW_FORM = new BooleanFlag("snow-form");
|
||||
public static final BooleanFlag ICE_MELT = new BooleanFlag("ice-melt");
|
||||
public static final BooleanFlag FIRE_SPREAD = new BooleanFlag("fire-spread");
|
||||
public static final BooleanFlag BLOCK_BURN = new BooleanFlag("block-burn");
|
||||
@ -68,6 +70,7 @@ public final class Flags {
|
||||
public static final BooleanFlag MISC_PLACE = new BooleanFlag("misc-place");
|
||||
public static final BooleanFlag MISC_BREAK = new BooleanFlag("misc-break");
|
||||
public static final BooleanFlag MISC_INTERACT = new BooleanFlag("misc-interact");
|
||||
public static final BooleanFlag VILLAGER_INTERACT = new BooleanFlag("villager-interact");
|
||||
public static final BooleanFlag PLAYER_INTERACT = new BooleanFlag("player-interact");
|
||||
public static final BooleanFlag TAMED_ATTACK = new BooleanFlag("tamed-attack");
|
||||
public static final BooleanFlag TAMED_INTERACT = new BooleanFlag("tamed-interact");
|
||||
@ -160,7 +163,15 @@ public final class Flags {
|
||||
Object remove;
|
||||
if (value.DEFAULT_FLAGS.containsKey(duplicate)) {
|
||||
remove = value.DEFAULT_FLAGS.remove(duplicate);
|
||||
value.DEFAULT_FLAGS.put(flag,flag.parseValue("" + remove));
|
||||
try {
|
||||
if (remove instanceof Collection && remove.getClass().getMethod("toString").getDeclaringClass() == Object.class) {
|
||||
value.DEFAULT_FLAGS.put(flag, flag.parseValue(StringMan.join((Collection) remove, ',')));
|
||||
} else {
|
||||
value.DEFAULT_FLAGS.put(flag, flag.parseValue("" + remove));
|
||||
}
|
||||
} catch (NoSuchMethodException neverHappens) {
|
||||
neverHappens.printStackTrace();
|
||||
}
|
||||
}
|
||||
}
|
||||
});
|
||||
@ -168,7 +179,15 @@ public final class Flags {
|
||||
@Override public void run(Plot value) {
|
||||
if (value.getFlags().containsKey(duplicate)) {
|
||||
Object remove = value.getFlags().remove(duplicate);
|
||||
value.getFlags().put(flag,flag.parseValue("" + remove));
|
||||
try {
|
||||
if (remove instanceof Collection && remove.getClass().getMethod("toString").getDeclaringClass() == Object.class) {
|
||||
value.getFlags().put(flag, flag.parseValue(StringMan.join((Collection) remove, ',')));
|
||||
} else {
|
||||
value.getFlags().put(flag, flag.parseValue("" + remove));
|
||||
}
|
||||
} catch (NoSuchMethodException neverHappens) {
|
||||
neverHappens.printStackTrace();
|
||||
}
|
||||
}
|
||||
}
|
||||
});
|
||||
|
@ -19,16 +19,16 @@ public class TeleportDenyFlag extends EnumFlag {
|
||||
result = !plot.getTrusted().contains(player.getUUID());
|
||||
break;
|
||||
case "members":
|
||||
result =!plot.getMembers().contains(player.getUUID());
|
||||
result = !plot.getMembers().contains(player.getUUID());
|
||||
break;
|
||||
case "nonmembers":
|
||||
result =!plot.isAdded(player.getUUID());
|
||||
result = !plot.isAdded(player.getUUID());
|
||||
break;
|
||||
case "nontrusted":
|
||||
result =!plot.getTrusted().contains(player.getUUID()) && !plot.isOwner(player.getUUID());
|
||||
result = !plot.getTrusted().contains(player.getUUID()) && !plot.isOwner(player.getUUID());
|
||||
break;
|
||||
case "nonowners":
|
||||
result =!plot.isOwner(player.getUUID());
|
||||
result = !plot.isOwner(player.getUUID());
|
||||
break;
|
||||
default:
|
||||
return true;
|
||||
|
@ -7,6 +7,7 @@ import com.intellectualcrafters.plot.object.PlotBlock;
|
||||
import com.intellectualcrafters.plot.object.PlotId;
|
||||
import com.intellectualcrafters.plot.object.PseudoRandom;
|
||||
import com.intellectualcrafters.plot.object.RegionWrapper;
|
||||
import com.intellectualcrafters.plot.util.MathMan;
|
||||
import com.intellectualcrafters.plot.util.block.GlobalBlockQueue;
|
||||
import com.intellectualcrafters.plot.util.block.LocalBlockQueue;
|
||||
import java.util.ArrayList;
|
||||
@ -79,9 +80,10 @@ public class ClassicPlotManager extends SquarePlotManager {
|
||||
return false;
|
||||
}
|
||||
LocalBlockQueue queue = plotArea.getQueue(false);
|
||||
int maxY = plotArea.getPlotManager().getWorldHeight();
|
||||
for (RegionWrapper region : plot.getRegions()) {
|
||||
Location pos1 = new Location(plotArea.worldname, region.minX, 1, region.minZ);
|
||||
Location pos2 = new Location(plotArea.worldname, region.maxX, 255, region.maxZ);
|
||||
Location pos2 = new Location(plotArea.worldname, region.maxX, maxY, region.maxZ);
|
||||
queue.setCuboid(pos1, pos2, blocks);
|
||||
}
|
||||
queue.enqueue();
|
||||
@ -95,9 +97,10 @@ public class ClassicPlotManager extends SquarePlotManager {
|
||||
}
|
||||
ClassicPlotWorld dpw = (ClassicPlotWorld) plotArea;
|
||||
LocalBlockQueue queue = plotArea.getQueue(false);
|
||||
int maxY = plotArea.getPlotManager().getWorldHeight();
|
||||
for (RegionWrapper region : plot.getRegions()) {
|
||||
Location pos1 = new Location(plotArea.worldname, region.minX, dpw.PLOT_HEIGHT + 1, region.minZ);
|
||||
Location pos2 = new Location(plotArea.worldname, region.maxX, 255, region.maxZ);
|
||||
Location pos2 = new Location(plotArea.worldname, region.maxX,maxY, region.maxZ);
|
||||
queue.setCuboid(pos1, pos2, blocks);
|
||||
}
|
||||
queue.enqueue();
|
||||
@ -128,8 +131,10 @@ public class ClassicPlotManager extends SquarePlotManager {
|
||||
Location[] corners = plot.getCorners();
|
||||
ClassicPlotWorld dpw = (ClassicPlotWorld) plotArea;
|
||||
LocalBlockQueue queue = plotArea.getQueue(false);
|
||||
queue.setBlock((corners[0].getX() + corners[1].getX()) / 2, dpw.PLOT_HEIGHT,
|
||||
(corners[0].getZ() + corners[1].getZ()) / 2, blocks[0]);
|
||||
|
||||
int x = MathMan.average(corners[0].getX(), corners[1].getX());
|
||||
int z = MathMan.average(corners[0].getZ(), corners[1].getZ());
|
||||
queue.setBlock(x, dpw.PLOT_HEIGHT,z, blocks[0]);
|
||||
queue.enqueue();
|
||||
return true;
|
||||
}
|
||||
@ -144,10 +149,11 @@ public class ClassicPlotManager extends SquarePlotManager {
|
||||
Location top = plot.getExtendedTopAbs();
|
||||
PseudoRandom random = new PseudoRandom();
|
||||
LocalBlockQueue queue = plotArea.getQueue(false);
|
||||
int maxY = plotArea.getPlotManager().getWorldHeight();
|
||||
if (!plot.getMerged(0)) {
|
||||
int z = bottom.getZ();
|
||||
for (int x = bottom.getX(); x <= top.getX(); x++) {
|
||||
for (int y = dpw.PLOT_HEIGHT; y <= 255; y++) {
|
||||
for (int y = dpw.PLOT_HEIGHT; y <= maxY; y++) {
|
||||
queue.setBlock(x, y, z, blocks[random.random(blocks.length)]);
|
||||
}
|
||||
}
|
||||
@ -155,7 +161,7 @@ public class ClassicPlotManager extends SquarePlotManager {
|
||||
if (!plot.getMerged(3)) {
|
||||
int x = bottom.getX();
|
||||
for (int z = bottom.getZ(); z <= top.getZ(); z++) {
|
||||
for (int y = dpw.PLOT_HEIGHT; y <= 255; y++) {
|
||||
for (int y = dpw.PLOT_HEIGHT; y <= maxY; y++) {
|
||||
queue.setBlock(x, y, z, blocks[random.random(blocks.length)]);
|
||||
}
|
||||
}
|
||||
@ -164,7 +170,7 @@ public class ClassicPlotManager extends SquarePlotManager {
|
||||
if (!plot.getMerged(2)) {
|
||||
int z = top.getZ();
|
||||
for (int x = bottom.getX(); x <= top.getX(); x++) {
|
||||
for (int y = dpw.PLOT_HEIGHT; y <= 255; y++) {
|
||||
for (int y = dpw.PLOT_HEIGHT; y <= maxY; y++) {
|
||||
queue.setBlock(x, y, z, blocks[random.random(blocks.length)]);
|
||||
}
|
||||
}
|
||||
@ -172,15 +178,15 @@ public class ClassicPlotManager extends SquarePlotManager {
|
||||
if (!plot.getMerged(1)) {
|
||||
int x = top.getX();
|
||||
for (int z = bottom.getZ(); z <= top.getZ(); z++) {
|
||||
for (int y = dpw.PLOT_HEIGHT; y <= 255; y++) {
|
||||
for (int y = dpw.PLOT_HEIGHT; y <= maxY; y++) {
|
||||
queue.setBlock(x, y, z, blocks[random.random(blocks.length)]);
|
||||
}
|
||||
}
|
||||
}
|
||||
if (plot.isBasePlot()) {
|
||||
for (RegionWrapper region : plot.getRegions()) {
|
||||
Location pos1 = new Location(plotArea.worldname, region.minX, 255, region.minZ);
|
||||
Location pos2 = new Location(plotArea.worldname, region.maxX, 255, region.maxZ);
|
||||
Location pos1 = new Location(plotArea.worldname, region.minX, maxY, region.minZ);
|
||||
Location pos2 = new Location(plotArea.worldname, region.maxX, maxY, region.maxZ);
|
||||
queue.setCuboid(pos1, pos2, blocks);
|
||||
}
|
||||
}
|
||||
@ -286,9 +292,10 @@ public class ClassicPlotManager extends SquarePlotManager {
|
||||
int sz = pos1.getZ() - 2;
|
||||
int ez = pos2.getZ() + 2;
|
||||
LocalBlockQueue queue = plotArea.getQueue(false);
|
||||
int maxY = plotArea.getPlotManager().getWorldHeight();
|
||||
queue.setCuboid(
|
||||
new Location(plotArea.worldname, sx, Math.min(dpw.WALL_HEIGHT, dpw.ROAD_HEIGHT) + 1, sz + 1),
|
||||
new Location(plotArea.worldname, ex, 255, ez - 1), PlotBlock.get((short) 0, (byte) 0));
|
||||
new Location(plotArea.worldname, ex, maxY, ez - 1), PlotBlock.get((short) 0, (byte) 0));
|
||||
queue.setCuboid(new Location(plotArea.worldname, sx, 0, sz + 1),
|
||||
new Location(plotArea.worldname, ex, 0, ez - 1), PlotBlock.get((short) 7,
|
||||
(byte) 0));
|
||||
@ -320,7 +327,7 @@ public class ClassicPlotManager extends SquarePlotManager {
|
||||
LocalBlockQueue queue = plotArea.getQueue(false);
|
||||
queue.setCuboid(
|
||||
new Location(plotArea.worldname, sx + 1, Math.min(dpw.WALL_HEIGHT, dpw.ROAD_HEIGHT) + 1, sz),
|
||||
new Location(plotArea.worldname, ex - 1, 255, ez), PlotBlock.get((short) 0, (byte) 0));
|
||||
new Location(plotArea.worldname, ex - 1, plotArea.getPlotManager().getWorldHeight(), ez), PlotBlock.get((short) 0, (byte) 0));
|
||||
queue.setCuboid(new Location(plotArea.worldname, sx + 1, 0, sz),
|
||||
new Location(plotArea.worldname, ex - 1, 0, ez), PlotBlock.get((short) 7, (byte) 0));
|
||||
queue.setCuboid(new Location(plotArea.worldname, sx + 1, 1, sz),
|
||||
@ -349,7 +356,7 @@ public class ClassicPlotManager extends SquarePlotManager {
|
||||
int ez = sz + dpw.ROAD_WIDTH - 1;
|
||||
LocalBlockQueue queue = plotArea.getQueue(false);
|
||||
queue.setCuboid(new Location(plotArea.worldname, sx + 1, dpw.ROAD_HEIGHT + 1, sz + 1),
|
||||
new Location(plotArea.worldname, ex - 1, 255, ez - 1), PlotBlock.get(
|
||||
new Location(plotArea.worldname, ex - 1, dpw.getPlotManager().getWorldHeight(), ez - 1), PlotBlock.get(
|
||||
(short) 0, (byte) 0));
|
||||
queue.setCuboid(new Location(plotArea.worldname, sx + 1, 0, sz + 1),
|
||||
new Location(plotArea.worldname, ex - 1, 0, ez - 1), PlotBlock.get((short) 7, (byte) 0));
|
||||
@ -370,7 +377,7 @@ public class ClassicPlotManager extends SquarePlotManager {
|
||||
int ez = pos2.getZ() + 1;
|
||||
LocalBlockQueue queue = plotArea.getQueue(false);
|
||||
queue.setCuboid(new Location(plotArea.worldname, sx, Math.min(dpw.PLOT_HEIGHT, dpw.ROAD_HEIGHT) + 1, sz),
|
||||
new Location(plotArea.worldname, ex, 255, ez), PlotBlock.get((short) 0, (byte) 0));
|
||||
new Location(plotArea.worldname, ex, plotArea.getPlotManager().getWorldHeight(), ez), PlotBlock.get((short) 0, (byte) 0));
|
||||
queue.setCuboid(new Location(plotArea.worldname, sx, 1, sz + 1),
|
||||
new Location(plotArea.worldname, ex, dpw.PLOT_HEIGHT - 1, ez - 1), dpw.MAIN_BLOCK);
|
||||
queue.setCuboid(new Location(plotArea.worldname, sx, dpw.PLOT_HEIGHT, sz + 1),
|
||||
@ -390,7 +397,7 @@ public class ClassicPlotManager extends SquarePlotManager {
|
||||
int ex = pos2.getX() + 1;
|
||||
LocalBlockQueue queue = plotArea.getQueue(false);
|
||||
queue.setCuboid(new Location(plotArea.worldname, sx, Math.min(dpw.PLOT_HEIGHT, dpw.ROAD_HEIGHT) + 1, sz),
|
||||
new Location(plotArea.worldname, ex, 255, ez), PlotBlock.get((short) 0, (byte) 0));
|
||||
new Location(plotArea.worldname, ex, plotArea.getPlotManager().getWorldHeight(), ez), PlotBlock.get((short) 0, (byte) 0));
|
||||
queue.setCuboid(new Location(plotArea.worldname, sx + 1, 1, sz),
|
||||
new Location(plotArea.worldname, ex - 1, dpw.PLOT_HEIGHT - 1, ez), dpw.MAIN_BLOCK);
|
||||
queue.setCuboid(new Location(plotArea.worldname, sx + 1, dpw.PLOT_HEIGHT, sz),
|
||||
@ -409,7 +416,7 @@ public class ClassicPlotManager extends SquarePlotManager {
|
||||
int ez = sz + dpw.ROAD_WIDTH - 1;
|
||||
LocalBlockQueue queue = plotArea.getQueue(false);
|
||||
queue.setCuboid(new Location(plotArea.worldname, sx, dpw.ROAD_HEIGHT + 1, sz),
|
||||
new Location(plotArea.worldname, ex, 255, ez), PlotBlock.get((short) 0, (byte) 0));
|
||||
new Location(plotArea.worldname, ex, plotArea.getPlotManager().getWorldHeight(), ez), PlotBlock.get((short) 0, (byte) 0));
|
||||
queue.setCuboid(new Location(plotArea.worldname, sx, 1, sz),
|
||||
new Location(plotArea.worldname, ex, dpw.ROAD_HEIGHT - 1, ez), dpw.MAIN_BLOCK);
|
||||
queue.setCuboid(new Location(plotArea.worldname, sx, dpw.ROAD_HEIGHT, sz),
|
||||
|
@ -1,6 +1,7 @@
|
||||
package com.intellectualcrafters.plot.generator;
|
||||
|
||||
import com.intellectualcrafters.jnbt.CompoundTag;
|
||||
import com.intellectualcrafters.plot.PS;
|
||||
import com.intellectualcrafters.plot.object.Location;
|
||||
import com.intellectualcrafters.plot.object.PlotArea;
|
||||
import com.intellectualcrafters.plot.object.PlotBlock;
|
||||
@ -19,18 +20,14 @@ public class HybridGen extends IndependentPlotGenerator {
|
||||
|
||||
@Override
|
||||
public String getName() {
|
||||
return "PlotSquared";
|
||||
return PS.imp().getPluginName();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void generateChunk(ScopedLocalBlockQueue result, PlotArea settings, PseudoRandom random) {
|
||||
HybridPlotWorld hpw = (HybridPlotWorld) settings;
|
||||
// Biome
|
||||
for (short x = 0; x < 16; x++) {
|
||||
for (short z = 0; z < 16; z++) {
|
||||
result.fillBiome(hpw.PLOT_BIOME);
|
||||
}
|
||||
}
|
||||
result.fillBiome(hpw.PLOT_BIOME);
|
||||
// Bedrock
|
||||
if (hpw.PLOT_BEDROCK) {
|
||||
for (short x = 0; x < 16; x++) {
|
||||
@ -251,7 +248,7 @@ public class HybridGen extends IndependentPlotGenerator {
|
||||
|
||||
@Override
|
||||
public PlotManager getNewPlotManager() {
|
||||
return new HybridPlotManager();
|
||||
return new HybridPlotManager();
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -61,7 +61,7 @@ public class HybridPlotManager extends ClassicPlotManager {
|
||||
Location bot = getPlotBottomLocAbs(hpw, id2);
|
||||
Location top = getPlotTopLocAbs(hpw, id);
|
||||
Location pos1 = new Location(plotArea.worldname, top.getX() + 1, 0, bot.getZ() - 1);
|
||||
Location pos2 = new Location(plotArea.worldname, bot.getX(), 255, top.getZ() + 1);
|
||||
Location pos2 = new Location(plotArea.worldname, bot.getX(), Math.min(getWorldHeight(), 255), top.getZ() + 1);
|
||||
MainUtil.resetBiome(plotArea, pos1, pos2);
|
||||
if (!hpw.ROAD_SCHEMATIC_ENABLED) {
|
||||
return true;
|
||||
@ -108,7 +108,7 @@ public class HybridPlotManager extends ClassicPlotManager {
|
||||
Location bot = getPlotBottomLocAbs(hpw, id2);
|
||||
Location top = getPlotTopLocAbs(hpw, id);
|
||||
Location pos1 = new Location(plotArea.worldname, bot.getX() - 1, 0, top.getZ() + 1);
|
||||
Location pos2 = new Location(plotArea.worldname, top.getX() + 1, 255, bot.getZ());
|
||||
Location pos2 = new Location(plotArea.worldname, top.getX() + 1, Math.min(getWorldHeight(), 255), bot.getZ());
|
||||
MainUtil.resetBiome(plotArea, pos1, pos2);
|
||||
if (!hpw.ROAD_SCHEMATIC_ENABLED) {
|
||||
return true;
|
||||
@ -128,7 +128,7 @@ public class HybridPlotManager extends ClassicPlotManager {
|
||||
Location pos1 = getPlotTopLocAbs(hpw, id).add(1, 0, 1);
|
||||
Location pos2 = getPlotBottomLocAbs(hpw, id2);
|
||||
pos1.setY(0);
|
||||
pos2.setY(256);
|
||||
pos2.setY(Math.min(getWorldHeight(), 255));
|
||||
LocalBlockQueue queue = hpw.getQueue(false);
|
||||
createSchemAbs(hpw, queue, pos1, pos2, true);
|
||||
if (hpw.ROAD_SCHEMATIC_ENABLED) {
|
||||
@ -145,7 +145,7 @@ public class HybridPlotManager extends ClassicPlotManager {
|
||||
* to have 512x512 sized plots. </p>
|
||||
*/
|
||||
@Override
|
||||
public boolean clearPlot(PlotArea plotArea, Plot plot, final Runnable whenDone) {
|
||||
public boolean clearPlot(final PlotArea plotArea, Plot plot, final Runnable whenDone) {
|
||||
final String world = plotArea.worldname;
|
||||
final HybridPlotWorld dpw = (HybridPlotWorld) plotArea;
|
||||
Location pos1 = plot.getBottomAbs();
|
||||
@ -189,7 +189,7 @@ public class HybridPlotManager extends ClassicPlotManager {
|
||||
top.setY(dpw.PLOT_HEIGHT + 1);
|
||||
queue.setCuboid(bot, top, plotfloor);
|
||||
bot.setY(dpw.PLOT_HEIGHT + 1);
|
||||
top.setY(256);
|
||||
top.setY(getWorldHeight());
|
||||
queue.setCuboid(bot, top, air);
|
||||
// And finally set the schematic, the y value is unimportant for this function
|
||||
pastePlotSchematic(dpw, queue, bot, top);
|
||||
|
@ -59,12 +59,20 @@ public class HybridPlotWorld extends ClassicPlotWorld {
|
||||
return (byte) (data + 4);
|
||||
}
|
||||
return data;
|
||||
case 183:
|
||||
case 26: // bed
|
||||
case 86: // pumpkin
|
||||
case 91:
|
||||
case 183: // fence gate
|
||||
case 184:
|
||||
case 185:
|
||||
case 186:
|
||||
case 187:
|
||||
case 107:
|
||||
data = wrap2(data, 0);
|
||||
data = wrap2(data, 2);
|
||||
data = wrap2(data, 4);
|
||||
data = wrap2(data, 6);
|
||||
return data;
|
||||
case 53:
|
||||
case 67:
|
||||
case 108:
|
||||
@ -98,11 +106,6 @@ public class HybridPlotWorld extends ClassicPlotWorld {
|
||||
data = wrap(data, 8);
|
||||
data = wrap(data, 12);
|
||||
return data;
|
||||
|
||||
case 26:
|
||||
case 86:
|
||||
data = wrap(data, 0);
|
||||
return data;
|
||||
case 28:
|
||||
case 66:
|
||||
case 157:
|
||||
|
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user