mirror of
https://github.com/IntellectualSites/PlotSquared.git
synced 2025-07-03 22:24:43 +02:00
Compare commits
222 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 | |||
005e13a216 | |||
3558105789 | |||
f651607d2f | |||
6b95e57d9e | |||
98d0819383 | |||
30da060f83 | |||
e4408d56ec | |||
f07ac646f3 | |||
ef3380dc0a | |||
749ab83e5d | |||
daea9cf60d | |||
2f74368879 | |||
63d4476d97 | |||
db69da5b07 | |||
634802ef98 | |||
37e4a652dd | |||
d22f7b8781 | |||
112da17614 | |||
91c78407cd | |||
395d6364be | |||
facd43700d | |||
1ae694ff5b | |||
c99dd1e74a | |||
f408ac82be | |||
9b95990ba6 | |||
77fb329c9e | |||
a13b9fb31b | |||
ea3306d070 | |||
bcbcd6d916 | |||
415c6fb0d4 | |||
e801c6d7e8 | |||
409456e895 | |||
e8f4eae6f7 | |||
c8419f4a4a | |||
09994724db | |||
610e204d12 | |||
1f341e6ba9 | |||
ffddf5c187 | |||
b5ec6232f9 | |||
34c2da55ca | |||
33ec80c2cb | |||
48064da1ee | |||
adc021109f | |||
d23d8c2fd8 | |||
3498f309e8 | |||
0b5177f192 | |||
07dc6a46fb | |||
0b19cc7d9d | |||
4e019ab796 | |||
b2fdcad317 | |||
80ea3e9ce7 | |||
5f8c77a6cd | |||
290e5c68dc | |||
5d92701100 | |||
1a86d5fb9e | |||
30d18c917d | |||
b91eab2f0c | |||
770b9be160 | |||
14b2b11bf3 | |||
975a5765c1 | |||
2b9c2959cf | |||
07977ac2ce | |||
9e5ac80435 | |||
dda6849412 | |||
85d6e42462 | |||
b1ee223b0a | |||
98e865cdf0 | |||
8b084839fd | |||
c1d4c481fb | |||
269e409e3e | |||
8538170cba | |||
76bce7c0ef | |||
ba568a3f60 | |||
a43430b722 | |||
e2c57cea52 | |||
ca776b2912 | |||
e859a7f56c | |||
ad2db9b836 | |||
279084b043 | |||
8b0e59209c | |||
ca8b82dcbe | |||
cf5d2a5e86 | |||
b9ad75ad84 | |||
185352d3cf | |||
f4fe762135 | |||
06682b18a5 | |||
f8e97f14d6 | |||
a579df00db | |||
29a0b68dcb | |||
d2581bf38b | |||
817a5bc16e | |||
047f9a75b9 | |||
96d0bb0e5e | |||
7da0b9877f | |||
f20ef15774 | |||
3a973342ae | |||
6e25aab51f | |||
a49492aae3 | |||
dbe965e901 | |||
2c82d1106a | |||
5b9dc59abf | |||
b587b430b8 | |||
8fd2599686 | |||
56000d60e7 | |||
1643399fc6 | |||
532fd09800 | |||
e6387419f7 | |||
30d49880b6 | |||
16d191db2c | |||
7dc7714261 | |||
9e1f6d8748 | |||
7fb2631421 | |||
718831e8e0 | |||
df4585a847 | |||
88d8339cfd | |||
e08db3d12b | |||
2ff4e07919 | |||
f6fec56677 | |||
3fabfa10d7 | |||
a2ca9a52ea | |||
e5e3600206 | |||
7ad50b6314 | |||
01d508edf4 |
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
|
||||
|
6
.gitignore
vendored
6
.gitignore
vendored
@ -1,5 +1,4 @@
|
||||
### Others ###
|
||||
*.bat
|
||||
*.cmd
|
||||
*.sh
|
||||
*.prefs
|
||||
@ -132,3 +131,8 @@ local.properties
|
||||
# STS (Spring Tool Suite)
|
||||
.springBeans
|
||||
/target/
|
||||
Nukkit/build/classes/
|
||||
Nukkit/build/dependency-cache/
|
||||
checkstyle.xml
|
||||
classes/
|
||||
p2error.txt
|
@ -1,8 +1,16 @@
|
||||
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.bukkit:bukkit:1.10-R0.1-SNAPSHOT'
|
||||
compile 'org.mcstats.bukkit:metrics:R7'
|
||||
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
|
||||
@ -17,19 +25,18 @@ processResources {
|
||||
)
|
||||
}
|
||||
}
|
||||
|
||||
apply plugin: 'com.github.johnrengelman.shadow'
|
||||
// We only want the shadow jar produced
|
||||
jar.enabled = false
|
||||
|
||||
shadowJar {
|
||||
dependencies {
|
||||
include(dependency(':Core'))
|
||||
include(dependency('org.mcstats.bukkit:metrics:R7'))
|
||||
}
|
||||
relocate 'org.mcstats', 'com.plotsquared.stats'
|
||||
relocate('org.mcstats', 'com.plotsquared.stats')
|
||||
archiveName = "${parent.name}-${project.name}-${parent.version}.jar"
|
||||
destinationDir = file '../target'
|
||||
}
|
||||
|
||||
shadowJar.doLast {
|
||||
task ->
|
||||
ant.checksum file: task.archivePath
|
||||
|
@ -20,17 +20,18 @@ import com.intellectualcrafters.plot.util.UUIDHandler;
|
||||
import com.intellectualcrafters.plot.util.block.GlobalBlockQueue;
|
||||
import com.intellectualcrafters.plot.uuid.UUIDWrapper;
|
||||
import com.plotsquared.bukkit.util.BukkitUtil;
|
||||
import org.bukkit.Location;
|
||||
import org.bukkit.OfflinePlayer;
|
||||
import org.bukkit.World;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.plugin.java.JavaPlugin;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collection;
|
||||
import java.util.Collections;
|
||||
import java.util.HashSet;
|
||||
import java.util.Set;
|
||||
import java.util.UUID;
|
||||
import org.bukkit.Location;
|
||||
import org.bukkit.OfflinePlayer;
|
||||
import org.bukkit.World;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.plugin.java.JavaPlugin;
|
||||
|
||||
/**
|
||||
* PlotSquared API.
|
||||
@ -378,9 +379,9 @@ public class PlotAPI {
|
||||
}
|
||||
|
||||
/**
|
||||
* Register a flag for use in plots.
|
||||
* Registers a flag for use in plots.
|
||||
*
|
||||
* @param flag the flag being registered
|
||||
* @param flag the flag to register
|
||||
*
|
||||
*/
|
||||
public void addFlag(Flag<?> flag) {
|
||||
@ -388,7 +389,7 @@ public class PlotAPI {
|
||||
}
|
||||
|
||||
/**
|
||||
* Get a plot based on the ID.
|
||||
* Gets a plot based on the ID.
|
||||
*
|
||||
* @param world the world the plot is located in
|
||||
* @param x The PlotID x coordinate
|
||||
@ -617,7 +618,7 @@ public class PlotAPI {
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the PlotSquared class.
|
||||
* Gets the PlotSquared class.
|
||||
*
|
||||
* @return PlotSquared Class
|
||||
*
|
||||
@ -628,7 +629,7 @@ public class PlotAPI {
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the player plot count.
|
||||
* Gets the player plot count.
|
||||
*
|
||||
* @param world Specify the world we want to select the plots from
|
||||
* @param player Player, for whom we're getting the plot count
|
||||
@ -644,7 +645,7 @@ public class PlotAPI {
|
||||
}
|
||||
|
||||
/**
|
||||
* Get a collection containing the players plots.
|
||||
* Gets a collection containing the players plots.
|
||||
*
|
||||
* @param world Specify the world we want to select the plots from
|
||||
* @param player Player, for whom we're getting the plots
|
||||
@ -663,7 +664,7 @@ public class PlotAPI {
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the numbers of plots, which the player is able to build in.
|
||||
* Gets the number of plots, which the player is able to build in.
|
||||
*
|
||||
* @param player player, for whom we're getting the plots
|
||||
*
|
||||
@ -676,7 +677,7 @@ public class PlotAPI {
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the PlotPlayer for a player. The PlotPlayer is usually cached and
|
||||
* Gets the PlotPlayer for a player. The PlotPlayer is usually cached and
|
||||
* will provide useful functions relating to players.
|
||||
*
|
||||
* @see PlotPlayer#wrap(Object)
|
||||
|
@ -15,6 +15,7 @@ import com.intellectualcrafters.plot.object.PlotArea;
|
||||
import com.intellectualcrafters.plot.object.PlotPlayer;
|
||||
import com.intellectualcrafters.plot.object.RunnableVal;
|
||||
import com.intellectualcrafters.plot.object.SetupObject;
|
||||
import com.intellectualcrafters.plot.object.chat.PlainChatManager;
|
||||
import com.intellectualcrafters.plot.util.AbstractTitle;
|
||||
import com.intellectualcrafters.plot.util.ChatManager;
|
||||
import com.intellectualcrafters.plot.util.ChunkManager;
|
||||
@ -37,7 +38,7 @@ import com.plotsquared.bukkit.database.plotme.LikePlotMeConverter;
|
||||
import com.plotsquared.bukkit.database.plotme.PlotMeConnector_017;
|
||||
import com.plotsquared.bukkit.generator.BukkitPlotGenerator;
|
||||
import com.plotsquared.bukkit.listeners.ChunkListener;
|
||||
import com.plotsquared.bukkit.listeners.ForceFieldListener;
|
||||
import com.plotsquared.bukkit.listeners.EntitySpawnListener;
|
||||
import com.plotsquared.bukkit.listeners.PlayerEvents;
|
||||
import com.plotsquared.bukkit.listeners.PlayerEvents183;
|
||||
import com.plotsquared.bukkit.listeners.PlayerEvents_1_8;
|
||||
@ -52,11 +53,11 @@ import com.plotsquared.bukkit.util.BukkitEconHandler;
|
||||
import com.plotsquared.bukkit.util.BukkitEventUtil;
|
||||
import com.plotsquared.bukkit.util.BukkitHybridUtils;
|
||||
import com.plotsquared.bukkit.util.BukkitInventoryUtil;
|
||||
import com.plotsquared.bukkit.util.BukkitPlainChatManager;
|
||||
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;
|
||||
@ -71,12 +72,6 @@ import com.plotsquared.bukkit.uuid.LowerOfflineUUIDWrapper;
|
||||
import com.plotsquared.bukkit.uuid.OfflineUUIDWrapper;
|
||||
import com.plotsquared.bukkit.uuid.SQLUUIDHandler;
|
||||
import com.sk89q.worldedit.WorldEdit;
|
||||
import java.io.File;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
import java.util.Iterator;
|
||||
import java.util.List;
|
||||
import java.util.UUID;
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.ChatColor;
|
||||
import org.bukkit.Location;
|
||||
@ -90,13 +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() {
|
||||
@ -113,7 +167,7 @@ public final class BukkitMain extends JavaPlugin implements Listener, IPlotMain
|
||||
e.printStackTrace();
|
||||
PS.debug(StringMan.getString(Bukkit.getBukkitVersion()));
|
||||
PS.debug(StringMan.getString(Bukkit.getBukkitVersion().split("-")[0].split("\\.")));
|
||||
return new int[]{1, 9, 2};
|
||||
return new int[]{1, 10, 0};
|
||||
}
|
||||
}
|
||||
return this.version;
|
||||
@ -121,7 +175,18 @@ 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.f(getPluginName()));
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
@ -158,6 +223,15 @@ public final class BukkitMain extends JavaPlugin implements Listener, IPlotMain
|
||||
return new int[]{Integer.parseInt(split[0]), Integer.parseInt(split[1]), Integer.parseInt(split[2])};
|
||||
}
|
||||
|
||||
@Override public String getPluginVersionString() {
|
||||
return getDescription().getVersion();
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getPluginName() {
|
||||
return name;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void registerCommands() {
|
||||
BukkitCommand bukkitCommand = new BukkitCommand();
|
||||
@ -202,7 +276,6 @@ public final class BukkitMain extends JavaPlugin implements Listener, IPlotMain
|
||||
Entity entity = iterator.next();
|
||||
switch (entity.getType()) {
|
||||
case EGG:
|
||||
case ENDER_CRYSTAL:
|
||||
case COMPLEX_PART:
|
||||
case FISHING_HOOK:
|
||||
case ENDER_SIGNAL:
|
||||
@ -226,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:
|
||||
@ -233,18 +307,17 @@ public final class BukkitMain extends JavaPlugin implements Listener, IPlotMain
|
||||
// Not vehicles
|
||||
continue;
|
||||
case ARMOR_STAND:
|
||||
// Tempirarily classify as vehicle
|
||||
// Temporarily classify as vehicle
|
||||
case MINECART:
|
||||
case MINECART_CHEST:
|
||||
case MINECART_COMMAND:
|
||||
case MINECART_FURNACE:
|
||||
case MINECART_HOPPER:
|
||||
case MINECART_MOB_SPAWNER:
|
||||
case ENDER_CRYSTAL:
|
||||
case MINECART_TNT:
|
||||
case BOAT: {
|
||||
if (!Settings.Enabled_Components.KILL_ROAD_VEHICLES) {
|
||||
continue;
|
||||
}
|
||||
case BOAT:
|
||||
if (Settings.Enabled_Components.KILL_ROAD_VEHICLES) {
|
||||
com.intellectualcrafters.plot.object.Location location = BukkitUtil.getLocation(entity.getLocation());
|
||||
Plot plot = location.getPlot();
|
||||
if (plot == null) {
|
||||
@ -264,6 +337,8 @@ public final class BukkitMain extends JavaPlugin implements Listener, IPlotMain
|
||||
entity.remove();
|
||||
}
|
||||
continue;
|
||||
} else {
|
||||
continue;
|
||||
}
|
||||
case SMALL_FIREBALL:
|
||||
case FIREBALL:
|
||||
@ -275,6 +350,21 @@ 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:
|
||||
case CAVE_SPIDER:
|
||||
@ -309,9 +399,7 @@ public final class BukkitMain extends JavaPlugin implements Listener, IPlotMain
|
||||
case ZOMBIE:
|
||||
case SHULKER:
|
||||
default:
|
||||
if (!Settings.Enabled_Components.KILL_ROAD_MOBS) {
|
||||
continue;
|
||||
}
|
||||
if (Settings.Enabled_Components.KILL_ROAD_MOBS) {
|
||||
Location location = entity.getLocation();
|
||||
if (BukkitUtil.getLocation(location).isPlotRoad()) {
|
||||
if (entity instanceof LivingEntity) {
|
||||
@ -333,6 +421,7 @@ public final class BukkitMain extends JavaPlugin implements Listener, IPlotMain
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
} catch (Throwable e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
@ -344,32 +433,42 @@ 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
|
||||
public void registerPlayerEvents() {
|
||||
PlayerEvents main = new PlayerEvents();
|
||||
getServer().getPluginManager().registerEvents(main, this);
|
||||
if (PS.get().checkVersion(getServerVersion(), 1, 8, 0)) {
|
||||
try {
|
||||
getServer().getClass().getMethod("spigot");
|
||||
getServer().getPluginManager().registerEvents(new EntitySpawnListener(), this);
|
||||
} catch (NoSuchMethodException ignored) {
|
||||
PS.debug("Not running Spigot. Skipping EntitySpawnListener event.");
|
||||
}
|
||||
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) {
|
||||
@ -391,7 +490,6 @@ public final class BukkitMain extends JavaPlugin implements Listener, IPlotMain
|
||||
|
||||
@Override
|
||||
public void registerForceFieldEvents() {
|
||||
getServer().getPluginManager().registerEvents(new ForceFieldListener(), this);
|
||||
}
|
||||
|
||||
@Override
|
||||
@ -422,16 +520,16 @@ public final class BukkitMain extends JavaPlugin implements Listener, IPlotMain
|
||||
new SendChunk();
|
||||
MainUtil.canSendChunk = true;
|
||||
} catch (ClassNotFoundException | NoSuchFieldException | NoSuchMethodException e) {
|
||||
e.printStackTrace();
|
||||
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);
|
||||
@ -444,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;
|
||||
return true;
|
||||
} else if (new LikePlotMeConverter("PlotMe").run(new PlotMeConnector_017())) {
|
||||
return true;
|
||||
}
|
||||
if (new LikePlotMeConverter("PlotMe").run(new PlotMeConnector_017())) {
|
||||
return;
|
||||
}
|
||||
}
|
||||
}, 20);
|
||||
return Bukkit.getPluginManager().getPlugin("PlotMe") != null;
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
@ -471,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());
|
||||
}
|
||||
}
|
||||
|
||||
@ -487,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) {
|
||||
@ -518,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);
|
||||
@ -555,20 +647,19 @@ 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();
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getServerName() {
|
||||
return Bukkit.getServerName();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void startMetrics() {
|
||||
Metrics metrics = new Metrics(this);
|
||||
metrics.start();
|
||||
new Metrics(this).start();
|
||||
PS.log(C.PREFIX + "&6Metrics enabled.");
|
||||
}
|
||||
|
||||
@ -578,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);
|
||||
@ -587,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);
|
||||
@ -647,12 +739,12 @@ public final class BukkitMain extends JavaPlugin implements Listener, IPlotMain
|
||||
if (Settings.Chat.INTERACTIVE) {
|
||||
return new BukkitChatManager();
|
||||
} else {
|
||||
return new BukkitPlainChatManager();
|
||||
return new PlainChatManager();
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public GeneratorWrapper<?> wrapPlotGenerator(IndependentPlotGenerator generator) {
|
||||
public GeneratorWrapper<?> wrapPlotGenerator(String world, IndependentPlotGenerator generator) {
|
||||
return new BukkitPlotGenerator(generator);
|
||||
}
|
||||
|
||||
|
@ -1,10 +1,25 @@
|
||||
package com.plotsquared.bukkit.chat;
|
||||
|
||||
import static com.plotsquared.bukkit.chat.TextualComponent.rawText;
|
||||
|
||||
import com.google.gson.JsonArray;
|
||||
import com.google.gson.JsonElement;
|
||||
import com.google.gson.JsonObject;
|
||||
import com.google.gson.JsonParser;
|
||||
import com.google.gson.stream.JsonWriter;
|
||||
import org.bukkit.Achievement;
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.ChatColor;
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.Statistic;
|
||||
import org.bukkit.Statistic.Type;
|
||||
import org.bukkit.command.CommandSender;
|
||||
import org.bukkit.configuration.serialization.ConfigurationSerializable;
|
||||
import org.bukkit.configuration.serialization.ConfigurationSerialization;
|
||||
import org.bukkit.entity.EntityType;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.inventory.ItemStack;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.io.StringWriter;
|
||||
import java.lang.reflect.Constructor;
|
||||
@ -19,21 +34,6 @@ import java.util.Iterator;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.logging.Level;
|
||||
import org.bukkit.Achievement;
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.ChatColor;
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.Statistic;
|
||||
import org.bukkit.Statistic.Type;
|
||||
import org.bukkit.command.CommandSender;
|
||||
import org.bukkit.configuration.serialization.ConfigurationSerializable;
|
||||
import org.bukkit.configuration.serialization.ConfigurationSerialization;
|
||||
import org.bukkit.entity.EntityType;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.inventory.ItemStack;
|
||||
|
||||
|
||||
import static com.plotsquared.bukkit.chat.TextualComponent.rawText;
|
||||
|
||||
/**
|
||||
* Represents a formattable message. Such messages can use elements such as colors, formatting codes, hover and click data, and other features provided by the vanilla Minecraft <a href="http://minecraft.gamepedia.com/Tellraw#Raw_JSON_Text">JSON message formatter</a>.
|
||||
@ -60,7 +60,7 @@ public class FancyMessage implements JsonRepresentedObject, Cloneable, Iterable<
|
||||
@Override
|
||||
public FancyMessage clone() throws CloneNotSupportedException {
|
||||
FancyMessage instance = (FancyMessage) super.clone();
|
||||
instance.messageParts = new ArrayList<MessagePart>(messageParts.size());
|
||||
instance.messageParts = new ArrayList<>(messageParts.size());
|
||||
for (int i = 0; i < messageParts.size(); i++) {
|
||||
instance.messageParts.add(i, messageParts.get(i).clone());
|
||||
}
|
||||
@ -78,15 +78,14 @@ public class FancyMessage implements JsonRepresentedObject, Cloneable, Iterable<
|
||||
this(rawText(firstPartText));
|
||||
}
|
||||
|
||||
public FancyMessage(final com.plotsquared.bukkit.chat.TextualComponent firstPartText) {
|
||||
messageParts = new ArrayList<MessagePart>();
|
||||
private FancyMessage(final TextualComponent firstPartText) {
|
||||
messageParts = new ArrayList<>();
|
||||
messageParts.add(new MessagePart(firstPartText));
|
||||
jsonString = null;
|
||||
dirty = false;
|
||||
|
||||
if (nmsPacketPlayOutChatConstructor == null) {
|
||||
try {
|
||||
nmsPacketPlayOutChatConstructor = com.plotsquared.bukkit.chat.Reflection.getNMSClass("PacketPlayOutChat").getDeclaredConstructor(com.plotsquared.bukkit.chat.Reflection.getNMSClass("IChatBaseComponent"));
|
||||
nmsPacketPlayOutChatConstructor = Reflection.getNMSClass("PacketPlayOutChat").getDeclaredConstructor(Reflection.getNMSClass("IChatBaseComponent"));
|
||||
nmsPacketPlayOutChatConstructor.setAccessible(true);
|
||||
} catch (NoSuchMethodException e) {
|
||||
Bukkit.getLogger().log(Level.SEVERE, "Could not find Minecraft method or constructor.", e);
|
||||
@ -100,7 +99,7 @@ public class FancyMessage implements JsonRepresentedObject, Cloneable, Iterable<
|
||||
* Creates a JSON message without text.
|
||||
*/
|
||||
public FancyMessage() {
|
||||
this((com.plotsquared.bukkit.chat.TextualComponent) null);
|
||||
this((TextualComponent) null);
|
||||
}
|
||||
|
||||
/**
|
||||
@ -122,7 +121,7 @@ public class FancyMessage implements JsonRepresentedObject, Cloneable, Iterable<
|
||||
* @param text The new text of the current editing component.
|
||||
* @return This builder instance.
|
||||
*/
|
||||
public FancyMessage text(com.plotsquared.bukkit.chat.TextualComponent text) {
|
||||
public FancyMessage text(TextualComponent text) {
|
||||
MessagePart latest = latest();
|
||||
latest.text = text;
|
||||
dirty = true;
|
||||
@ -243,8 +242,8 @@ public class FancyMessage implements JsonRepresentedObject, Cloneable, Iterable<
|
||||
*/
|
||||
public FancyMessage achievementTooltip(final Achievement which) {
|
||||
try {
|
||||
Object achievement = com.plotsquared.bukkit.chat.Reflection.getMethod(com.plotsquared.bukkit.chat.Reflection.getOBCClass("CraftStatistic"), "getNMSAchievement", Achievement.class).invoke(null, which);
|
||||
return achievementTooltip((String) com.plotsquared.bukkit.chat.Reflection.getField(com.plotsquared.bukkit.chat.Reflection.getNMSClass("Achievement"), "name").get(achievement));
|
||||
Object achievement = Reflection.getMethod(Reflection.getOBCClass("CraftStatistic"), "getNMSAchievement", Achievement.class).invoke(null, which);
|
||||
return achievementTooltip((String) Reflection.getField(Reflection.getNMSClass("Achievement"), "name").get(achievement));
|
||||
} catch (IllegalAccessException e) {
|
||||
Bukkit.getLogger().log(Level.WARNING, "Could not access method.", e);
|
||||
return this;
|
||||
@ -252,7 +251,7 @@ public class FancyMessage implements JsonRepresentedObject, Cloneable, Iterable<
|
||||
Bukkit.getLogger().log(Level.WARNING, "Argument could not be passed.", e);
|
||||
return this;
|
||||
} catch (InvocationTargetException e) {
|
||||
Bukkit.getLogger().log(Level.WARNING, "A error has occured durring invoking of method.", e);
|
||||
Bukkit.getLogger().log(Level.WARNING, "A error has occurred during invoking of method.", e);
|
||||
return this;
|
||||
}
|
||||
}
|
||||
@ -271,8 +270,8 @@ public class FancyMessage implements JsonRepresentedObject, Cloneable, Iterable<
|
||||
throw new IllegalArgumentException("That statistic requires an additional " + type + " parameter!");
|
||||
}
|
||||
try {
|
||||
Object statistic = com.plotsquared.bukkit.chat.Reflection.getMethod(com.plotsquared.bukkit.chat.Reflection.getOBCClass("CraftStatistic"), "getNMSStatistic", Statistic.class).invoke(null, which);
|
||||
return achievementTooltip((String) com.plotsquared.bukkit.chat.Reflection.getField(com.plotsquared.bukkit.chat.Reflection.getNMSClass("Statistic"), "name").get(statistic));
|
||||
Object statistic = Reflection.getMethod(Reflection.getOBCClass("CraftStatistic"), "getNMSStatistic", Statistic.class).invoke(null, which);
|
||||
return achievementTooltip((String) Reflection.getField(Reflection.getNMSClass("Statistic"), "name").get(statistic));
|
||||
} catch (IllegalAccessException e) {
|
||||
Bukkit.getLogger().log(Level.WARNING, "Could not access method.", e);
|
||||
return this;
|
||||
@ -280,7 +279,7 @@ public class FancyMessage implements JsonRepresentedObject, Cloneable, Iterable<
|
||||
Bukkit.getLogger().log(Level.WARNING, "Argument could not be passed.", e);
|
||||
return this;
|
||||
} catch (InvocationTargetException e) {
|
||||
Bukkit.getLogger().log(Level.WARNING, "A error has occured durring invoking of method.", e);
|
||||
Bukkit.getLogger().log(Level.WARNING, "A error has occurred during invoking of method.", e);
|
||||
return this;
|
||||
}
|
||||
}
|
||||
@ -303,8 +302,8 @@ public class FancyMessage implements JsonRepresentedObject, Cloneable, Iterable<
|
||||
throw new IllegalArgumentException("Wrong parameter type for that statistic - needs " + type + "!");
|
||||
}
|
||||
try {
|
||||
Object statistic = com.plotsquared.bukkit.chat.Reflection.getMethod(com.plotsquared.bukkit.chat.Reflection.getOBCClass("CraftStatistic"), "getMaterialStatistic", Statistic.class, Material.class).invoke(null, which, item);
|
||||
return achievementTooltip((String) com.plotsquared.bukkit.chat.Reflection.getField(com.plotsquared.bukkit.chat.Reflection.getNMSClass("Statistic"), "name").get(statistic));
|
||||
Object statistic = Reflection.getMethod(Reflection.getOBCClass("CraftStatistic"), "getMaterialStatistic", Statistic.class, Material.class).invoke(null, which, item);
|
||||
return achievementTooltip((String) Reflection.getField(Reflection.getNMSClass("Statistic"), "name").get(statistic));
|
||||
} catch (IllegalAccessException e) {
|
||||
Bukkit.getLogger().log(Level.WARNING, "Could not access method.", e);
|
||||
return this;
|
||||
@ -312,7 +311,7 @@ public class FancyMessage implements JsonRepresentedObject, Cloneable, Iterable<
|
||||
Bukkit.getLogger().log(Level.WARNING, "Argument could not be passed.", e);
|
||||
return this;
|
||||
} catch (InvocationTargetException e) {
|
||||
Bukkit.getLogger().log(Level.WARNING, "A error has occured durring invoking of method.", e);
|
||||
Bukkit.getLogger().log(Level.WARNING, "A error has occurred during invoking of method.", e);
|
||||
return this;
|
||||
}
|
||||
}
|
||||
@ -335,8 +334,8 @@ public class FancyMessage implements JsonRepresentedObject, Cloneable, Iterable<
|
||||
throw new IllegalArgumentException("Wrong parameter type for that statistic - needs " + type + "!");
|
||||
}
|
||||
try {
|
||||
Object statistic = com.plotsquared.bukkit.chat.Reflection.getMethod(com.plotsquared.bukkit.chat.Reflection.getOBCClass("CraftStatistic"), "getEntityStatistic", Statistic.class, EntityType.class).invoke(null, which, entity);
|
||||
return achievementTooltip((String) com.plotsquared.bukkit.chat.Reflection.getField(com.plotsquared.bukkit.chat.Reflection.getNMSClass("Statistic"), "name").get(statistic));
|
||||
Object statistic = Reflection.getMethod(Reflection.getOBCClass("CraftStatistic"), "getEntityStatistic", Statistic.class, EntityType.class).invoke(null, which, entity);
|
||||
return achievementTooltip((String) Reflection.getField(Reflection.getNMSClass("Statistic"), "name").get(statistic));
|
||||
} catch (IllegalAccessException e) {
|
||||
Bukkit.getLogger().log(Level.WARNING, "Could not access method.", e);
|
||||
return this;
|
||||
@ -344,7 +343,7 @@ public class FancyMessage implements JsonRepresentedObject, Cloneable, Iterable<
|
||||
Bukkit.getLogger().log(Level.WARNING, "Argument could not be passed.", e);
|
||||
return this;
|
||||
} catch (InvocationTargetException e) {
|
||||
Bukkit.getLogger().log(Level.WARNING, "A error has occured durring invoking of method.", e);
|
||||
Bukkit.getLogger().log(Level.WARNING, "A error has occurred during invoking of method.", e);
|
||||
return this;
|
||||
}
|
||||
}
|
||||
@ -370,8 +369,8 @@ public class FancyMessage implements JsonRepresentedObject, Cloneable, Iterable<
|
||||
*/
|
||||
public FancyMessage itemTooltip(final ItemStack itemStack) {
|
||||
try {
|
||||
Object nmsItem = com.plotsquared.bukkit.chat.Reflection.getMethod(com.plotsquared.bukkit.chat.Reflection.getOBCClass("inventory.CraftItemStack"), "asNMSCopy", ItemStack.class).invoke(null, itemStack);
|
||||
return itemTooltip(com.plotsquared.bukkit.chat.Reflection.getMethod(com.plotsquared.bukkit.chat.Reflection.getNMSClass("ItemStack"), "save", com.plotsquared.bukkit.chat.Reflection.getNMSClass("NBTTagCompound")).invoke(nmsItem, com.plotsquared.bukkit.chat.Reflection.getNMSClass("NBTTagCompound").newInstance()).toString());
|
||||
Object nmsItem = Reflection.getMethod(Reflection.getOBCClass("inventory.CraftItemStack"), "asNMSCopy", ItemStack.class).invoke(null, itemStack);
|
||||
return itemTooltip(Reflection.getMethod(Reflection.getNMSClass("ItemStack"), "save", Reflection.getNMSClass("NBTTagCompound")).invoke(nmsItem, Reflection.getNMSClass("NBTTagCompound").newInstance()).toString());
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
return this;
|
||||
@ -565,7 +564,7 @@ public class FancyMessage implements JsonRepresentedObject, Cloneable, Iterable<
|
||||
* @param text The text which will populate the new message component.
|
||||
* @return This builder instance.
|
||||
*/
|
||||
public FancyMessage then(final com.plotsquared.bukkit.chat.TextualComponent text) {
|
||||
public FancyMessage then(final TextualComponent text) {
|
||||
if (!latest().hasText()) {
|
||||
throw new IllegalStateException("previous message part has no text");
|
||||
}
|
||||
@ -641,9 +640,9 @@ public class FancyMessage implements JsonRepresentedObject, Cloneable, Iterable<
|
||||
}
|
||||
Player player = (Player) sender;
|
||||
try {
|
||||
Object handle = com.plotsquared.bukkit.chat.Reflection.getHandle(player);
|
||||
Object connection = com.plotsquared.bukkit.chat.Reflection.getField(handle.getClass(), "playerConnection").get(handle);
|
||||
com.plotsquared.bukkit.chat.Reflection.getMethod(connection.getClass(), "sendPacket", com.plotsquared.bukkit.chat.Reflection.getNMSClass("Packet")).invoke(connection, createChatPacket(jsonString));
|
||||
Object handle = Reflection.getHandle(player);
|
||||
Object connection = Reflection.getField(handle.getClass(), "playerConnection").get(handle);
|
||||
Reflection.getMethod(connection.getClass(), "sendPacket", Reflection.getNMSClass("Packet")).invoke(connection, createChatPacket(jsonString));
|
||||
} catch (IllegalArgumentException e) {
|
||||
Bukkit.getLogger().log(Level.WARNING, "Argument could not be passed.", e);
|
||||
} catch (IllegalAccessException e) {
|
||||
@ -651,7 +650,7 @@ public class FancyMessage implements JsonRepresentedObject, Cloneable, Iterable<
|
||||
} catch (InstantiationException e) {
|
||||
Bukkit.getLogger().log(Level.WARNING, "Underlying class is abstract.", e);
|
||||
} catch (InvocationTargetException e) {
|
||||
Bukkit.getLogger().log(Level.WARNING, "A error has occured durring invoking of method.", e);
|
||||
Bukkit.getLogger().log(Level.WARNING, "A error has occurred during invoking of method.", e);
|
||||
} catch (NoSuchMethodException e) {
|
||||
Bukkit.getLogger().log(Level.WARNING, "Could not find method.", e);
|
||||
} catch (ClassNotFoundException e) {
|
||||
@ -673,16 +672,16 @@ public class FancyMessage implements JsonRepresentedObject, Cloneable, Iterable<
|
||||
// X = major
|
||||
// Y = minor
|
||||
// Z = revision
|
||||
final String version = com.plotsquared.bukkit.chat.Reflection.getVersion();
|
||||
final String version = Reflection.getVersion();
|
||||
String[] split = version.substring(1, version.length() - 1).split("_"); // Remove trailing dot
|
||||
//int majorVersion = Integer.parseInt(split[0]);
|
||||
int minorVersion = Integer.parseInt(split[1]);
|
||||
int revisionVersion = Integer.parseInt(split[2].substring(1)); // Substring to ignore R
|
||||
|
||||
if (minorVersion < 8 || (minorVersion == 8 && revisionVersion == 1)) {
|
||||
chatSerializerClazz = com.plotsquared.bukkit.chat.Reflection.getNMSClass("ChatSerializer");
|
||||
chatSerializerClazz = Reflection.getNMSClass("ChatSerializer");
|
||||
} else {
|
||||
chatSerializerClazz = com.plotsquared.bukkit.chat.Reflection.getNMSClass("IChatBaseComponent$ChatSerializer");
|
||||
chatSerializerClazz = Reflection.getNMSClass("IChatBaseComponent$ChatSerializer");
|
||||
}
|
||||
|
||||
if (chatSerializerClazz == null) {
|
||||
@ -702,7 +701,7 @@ public class FancyMessage implements JsonRepresentedObject, Cloneable, Iterable<
|
||||
|
||||
// Since the method is so simple, and all the obfuscated methods have the same name, it's easier to reimplement 'IChatBaseComponent a(String)' than to reflectively call it
|
||||
// Of course, the implementation may change, but fuzzy matches might break with signature changes
|
||||
Object serializedChatComponent = fromJsonMethod.invoke(nmsChatSerializerGsonInstance, json, com.plotsquared.bukkit.chat.Reflection.getNMSClass("IChatBaseComponent"));
|
||||
Object serializedChatComponent = fromJsonMethod.invoke(nmsChatSerializerGsonInstance, json, Reflection.getNMSClass("IChatBaseComponent"));
|
||||
|
||||
return nmsPacketPlayOutChatConstructor.newInstance(serializedChatComponent);
|
||||
}
|
||||
@ -781,7 +780,7 @@ public class FancyMessage implements JsonRepresentedObject, Cloneable, Iterable<
|
||||
|
||||
// Doc copied from interface
|
||||
public Map<String, Object> serialize() {
|
||||
HashMap<String, Object> map = new HashMap<String, Object>();
|
||||
HashMap<String, Object> map = new HashMap<>();
|
||||
map.put("messageParts", messageParts);
|
||||
// map.put("JSON", toJSONString());
|
||||
return map;
|
||||
@ -829,9 +828,9 @@ public class FancyMessage implements JsonRepresentedObject, Cloneable, Iterable<
|
||||
JsonObject messagePart = mPrt.getAsJsonObject();
|
||||
for (Map.Entry<String, JsonElement> entry : messagePart.entrySet()) {
|
||||
// Deserialize text
|
||||
if (com.plotsquared.bukkit.chat.TextualComponent.isTextKey(entry.getKey())) {
|
||||
if (TextualComponent.isTextKey(entry.getKey())) {
|
||||
// The map mimics the YAML serialization, which has a "key" field and one or more "value" fields
|
||||
Map<String, Object> serializedMapForm = new HashMap<String, Object>(); // Must be object due to Bukkit serializer API compliance
|
||||
Map<String, Object> serializedMapForm = new HashMap<>(); // Must be object due to Bukkit serializer API compliance
|
||||
serializedMapForm.put("key", entry.getKey());
|
||||
if (entry.getValue().isJsonPrimitive()) {
|
||||
// Assume string
|
||||
@ -842,7 +841,7 @@ public class FancyMessage implements JsonRepresentedObject, Cloneable, Iterable<
|
||||
serializedMapForm.put("value." + compositeNestedElement.getKey(), compositeNestedElement.getValue().getAsString());
|
||||
}
|
||||
}
|
||||
component.text = com.plotsquared.bukkit.chat.TextualComponent.deserialize(serializedMapForm);
|
||||
component.text = TextualComponent.deserialize(serializedMapForm);
|
||||
} else if (MessagePart.stylesToNames.inverse().containsKey(entry.getKey())) {
|
||||
if (entry.getValue().getAsBoolean()) {
|
||||
component.styles.add(MessagePart.stylesToNames.inverse().get(entry.getKey()));
|
||||
|
@ -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.
|
||||
|
@ -20,12 +20,14 @@ import java.util.logging.Level;
|
||||
final class MessagePart implements JsonRepresentedObject, ConfigurationSerializable, Cloneable {
|
||||
|
||||
ChatColor color = ChatColor.WHITE;
|
||||
ArrayList<ChatColor> styles = new ArrayList<ChatColor>();
|
||||
String clickActionName = null, clickActionData = null, hoverActionName = null;
|
||||
ArrayList<ChatColor> styles = new ArrayList<>();
|
||||
String clickActionName = null;
|
||||
String clickActionData = null;
|
||||
String hoverActionName = null;
|
||||
JsonRepresentedObject hoverActionData = null;
|
||||
TextualComponent text = null;
|
||||
String insertionData = null;
|
||||
ArrayList<JsonRepresentedObject> translationReplacements = new ArrayList<JsonRepresentedObject>();
|
||||
ArrayList<JsonRepresentedObject> translationReplacements = new ArrayList<>();
|
||||
|
||||
MessagePart(final TextualComponent text) {
|
||||
this.text = text;
|
||||
@ -121,7 +123,7 @@ final class MessagePart implements JsonRepresentedObject, ConfigurationSerializa
|
||||
}
|
||||
|
||||
public Map<String, Object> serialize() {
|
||||
HashMap<String, Object> map = new HashMap<String, Object>();
|
||||
HashMap<String, Object> map = new HashMap<>();
|
||||
map.put("text", text);
|
||||
map.put("styles", styles);
|
||||
map.put("color", color.getChar());
|
||||
|
@ -3,6 +3,7 @@ package com.plotsquared.bukkit.chat;
|
||||
import org.bukkit.Bukkit;
|
||||
|
||||
import java.lang.reflect.Field;
|
||||
import java.lang.reflect.InvocationTargetException;
|
||||
import java.lang.reflect.Method;
|
||||
import java.util.Arrays;
|
||||
import java.util.HashMap;
|
||||
@ -14,6 +15,20 @@ 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;
|
||||
|
||||
private Reflection() { }
|
||||
@ -37,16 +52,6 @@ public final class Reflection {
|
||||
return _versionString;
|
||||
}
|
||||
|
||||
/**
|
||||
* Stores loaded classes from the {@code net.minecraft.server} package.
|
||||
*/
|
||||
private static final Map<String, Class<?>> _loadedNMSClasses = new HashMap<String, Class<?>>();
|
||||
|
||||
/**
|
||||
* Stores loaded classes from the {@code org.bukkit.craftbukkit} package (and subpackages).
|
||||
*/
|
||||
private static final Map<String, Class<?>> _loadedOBCClasses = new HashMap<String, Class<?>>();
|
||||
|
||||
/**
|
||||
* 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).
|
||||
@ -60,13 +65,12 @@ public final class Reflection {
|
||||
}
|
||||
|
||||
String fullName = "net.minecraft.server." + getVersion() + className;
|
||||
Class<?> clazz = null;
|
||||
Class<?> clazz;
|
||||
try {
|
||||
clazz = Class.forName(fullName);
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
} catch (ClassNotFoundException e) {
|
||||
_loadedNMSClasses.put(className, null);
|
||||
return null;
|
||||
throw new RuntimeException(e);
|
||||
}
|
||||
_loadedNMSClasses.put(className, clazz);
|
||||
return clazz;
|
||||
@ -85,13 +89,12 @@ public final class Reflection {
|
||||
}
|
||||
|
||||
String fullName = "org.bukkit.craftbukkit." + getVersion() + className;
|
||||
Class<?> clazz = null;
|
||||
Class<?> clazz;
|
||||
try {
|
||||
clazz = Class.forName(fullName);
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
} catch (ClassNotFoundException e) {
|
||||
_loadedOBCClasses.put(className, null);
|
||||
return null;
|
||||
throw new RuntimeException(e);
|
||||
}
|
||||
_loadedOBCClasses.put(className, clazz);
|
||||
return clazz;
|
||||
@ -106,16 +109,9 @@ public final class Reflection {
|
||||
* @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) {
|
||||
try {
|
||||
public synchronized static Object getHandle(Object obj) throws InvocationTargetException, IllegalAccessException, IllegalArgumentException {
|
||||
return getMethod(obj.getClass(), "getHandle").invoke(obj);
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
private static final Map<Class<?>, Map<String, Field>> _loadedFields = new HashMap<Class<?>, Map<String, Field>>();
|
||||
|
||||
/**
|
||||
* Retrieves a {@link Field} instance declared by the specified class with the specified name.
|
||||
@ -138,7 +134,7 @@ public final class Reflection {
|
||||
public synchronized static Field getField(Class<?> clazz, String name) {
|
||||
Map<String, Field> loaded;
|
||||
if (!_loadedFields.containsKey(clazz)) {
|
||||
loaded = new HashMap<String, Field>();
|
||||
loaded = new HashMap<>();
|
||||
_loadedFields.put(clazz, loaded);
|
||||
} else {
|
||||
loaded = _loadedFields.get(clazz);
|
||||
@ -152,7 +148,7 @@ public final class Reflection {
|
||||
field.setAccessible(true);
|
||||
loaded.put(name, field);
|
||||
return field;
|
||||
} catch (Exception e) {
|
||||
} catch (NoSuchFieldException | SecurityException e) {
|
||||
// Error loading
|
||||
e.printStackTrace();
|
||||
// Cache field as not existing
|
||||
@ -161,12 +157,6 @@ public final class Reflection {
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 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<Class<?>, Map<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
|
||||
@ -174,11 +164,9 @@ public final class Reflection {
|
||||
* <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>
|
||||
* <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>
|
||||
* <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...)}.
|
||||
@ -199,7 +187,7 @@ public final class Reflection {
|
||||
}
|
||||
|
||||
Map<ArrayWrapper<Class<?>>, Method> loadedSignatures = loadedMethodNames.get(name);
|
||||
ArrayWrapper<Class<?>> wrappedArg = new ArrayWrapper<Class<?>>(args);
|
||||
ArrayWrapper<Class<?>> wrappedArg = new ArrayWrapper<>(args);
|
||||
if (loadedSignatures.containsKey(wrappedArg)) {
|
||||
return loadedSignatures.get(wrappedArg);
|
||||
}
|
||||
|
@ -23,6 +23,119 @@ public abstract class TextualComponent implements Cloneable {
|
||||
ConfigurationSerialization.registerClass(TextualComponent.ComplexTextTypeComponent.class);
|
||||
}
|
||||
|
||||
static TextualComponent deserialize(Map<String, Object> map) {
|
||||
if (map.containsKey("key") && map.size() == 2 && map.containsKey("value")) {
|
||||
// Arbitrary text component
|
||||
return ArbitraryTextTypeComponent.deserialize(map);
|
||||
} else if (map.size() >= 2 && map.containsKey("key") && !map.containsKey("value") /* It contains keys that START WITH value */) {
|
||||
// Complex JSON object
|
||||
return ComplexTextTypeComponent.deserialize(map);
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
static boolean isTextKey(String key) {
|
||||
return key.equals("translate") || key.equals("text") || key.equals("score") || key.equals("selector");
|
||||
}
|
||||
|
||||
static boolean isTranslatableText(TextualComponent component) {
|
||||
return component instanceof ComplexTextTypeComponent && component.getKey().equals("translate");
|
||||
}
|
||||
|
||||
/**
|
||||
* Create a textual component representing a string literal.
|
||||
*
|
||||
* <p>This is the default type of textual component when a single string
|
||||
* literal is given to a method.
|
||||
*
|
||||
* @param textValue The text which will be represented.
|
||||
* @return The text component representing the specified literal text.
|
||||
*/
|
||||
public static TextualComponent rawText(String textValue) {
|
||||
return new ArbitraryTextTypeComponent("text", textValue);
|
||||
}
|
||||
|
||||
/**
|
||||
* Create a textual component representing a localized string.
|
||||
* The client will see this text component as their localized version of the specified string <em>key</em>, which can be overridden by a
|
||||
* resource pack.
|
||||
* <p>
|
||||
* If the specified translation key is not present on the client resource pack, the translation key will be displayed as a string literal to
|
||||
* the client.
|
||||
* </p>
|
||||
*
|
||||
* @param translateKey The string key which maps to localized text.
|
||||
* @return The text component representing the specified localized text.
|
||||
*/
|
||||
public static TextualComponent localizedText(String translateKey) {
|
||||
return new ArbitraryTextTypeComponent("translate", translateKey);
|
||||
}
|
||||
|
||||
private static void throwUnsupportedSnapshot() {
|
||||
throw new UnsupportedOperationException("This feature is only supported in snapshot releases.");
|
||||
}
|
||||
|
||||
/**
|
||||
* Create a textual component representing a scoreboard value.
|
||||
* The client will see their own score for the specified objective as the text represented by this component.
|
||||
* <p>
|
||||
* <b>This method is currently guaranteed to throw an {@code UnsupportedOperationException} as it is only supported on snapshot clients.</b>
|
||||
* </p>
|
||||
*
|
||||
* @param scoreboardObjective The name of the objective for which to display the score.
|
||||
* @return The text component representing the specified scoreboard score (for the viewing player), or {@code null} if an error occurs during
|
||||
* JSON serialization.
|
||||
*/
|
||||
public static TextualComponent objectiveScore(String scoreboardObjective) {
|
||||
return objectiveScore("*", scoreboardObjective);
|
||||
}
|
||||
|
||||
/**
|
||||
* Create a textual component representing a scoreboard value.
|
||||
* The client will see the score of the specified player for the specified objective as the text represented by this component.
|
||||
*
|
||||
* <p><b>This method is currently guaranteed to throw an {@code UnsupportedOperationException}
|
||||
* as it is only supported on snapshot clients.</b>
|
||||
*
|
||||
* @param playerName The name of the player whos score will be shown. If
|
||||
* this string represents the single-character sequence
|
||||
* "*", the viewing player's score will be displayed.
|
||||
* Standard minecraft selectors (@a, @p, etc)
|
||||
* are <em>not</em> supported.
|
||||
* @param scoreboardObjective The name of the objective for
|
||||
* which to display the score.
|
||||
* @return The text component representing the specified scoreboard score
|
||||
* for the specified player, or {@code null} if an error occurs during JSON serialization.
|
||||
*/
|
||||
public static TextualComponent objectiveScore(String playerName, String scoreboardObjective) {
|
||||
throwUnsupportedSnapshot(); // Remove this line when the feature is released to non-snapshot versions, in addition to updating ALL THE
|
||||
// OVERLOADS documentation accordingly
|
||||
|
||||
return new ComplexTextTypeComponent("score", ImmutableMap.<String, String>builder()
|
||||
.put("name", playerName)
|
||||
.put("objective", scoreboardObjective)
|
||||
.build());
|
||||
}
|
||||
|
||||
/**
|
||||
* Create a textual component representing a player name, retrievable by using a standard minecraft selector.
|
||||
* The client will see the players or entities captured by the specified selector as the text represented by this component.
|
||||
* <p>
|
||||
* <b>This method is currently guaranteed to throw an {@code UnsupportedOperationException} as it is only supported on snapshot clients.</b>
|
||||
* </p>
|
||||
*
|
||||
* @param selector The minecraft player or entity selector which will capture the entities whose string representations will be displayed in
|
||||
* the place of this text component.
|
||||
* @return The text component representing the name of the entities captured by the selector.
|
||||
*/
|
||||
public static TextualComponent selector(String selector) {
|
||||
throwUnsupportedSnapshot(); // Remove this line when the feature is released to non-snapshot versions, in addition to updating ALL THE
|
||||
// OVERLOADS documentation accordingly
|
||||
|
||||
return new ArbitraryTextTypeComponent("selector", selector);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return getReadableString();
|
||||
@ -54,59 +167,43 @@ public abstract class TextualComponent implements Cloneable {
|
||||
*/
|
||||
public abstract void writeJson(JsonWriter writer) throws IOException;
|
||||
|
||||
static TextualComponent deserialize(Map<String, Object> map) {
|
||||
if (map.containsKey("key") && map.size() == 2 && map.containsKey("value")) {
|
||||
// Arbitrary text component
|
||||
return ArbitraryTextTypeComponent.deserialize(map);
|
||||
} else if (map.size() >= 2 && map.containsKey("key") && !map.containsKey("value") /* It contains keys that START WITH value */) {
|
||||
// Complex JSON object
|
||||
return ComplexTextTypeComponent.deserialize(map);
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
static boolean isTextKey(String key) {
|
||||
return key.equals("translate") || key.equals("text") || key.equals("score") || key.equals("selector");
|
||||
}
|
||||
|
||||
static boolean isTranslatableText(TextualComponent component) {
|
||||
return component instanceof ComplexTextTypeComponent && ((ComplexTextTypeComponent) component).getKey().equals("translate");
|
||||
}
|
||||
|
||||
/**
|
||||
* Internal class used to represent all types of text components.
|
||||
* Exception validating done is on keys and values.
|
||||
*/
|
||||
private static final class ArbitraryTextTypeComponent extends TextualComponent implements ConfigurationSerializable {
|
||||
|
||||
private String key;
|
||||
private String value;
|
||||
|
||||
public ArbitraryTextTypeComponent(String key, String value) {
|
||||
setKey(key);
|
||||
setValue(value);
|
||||
}
|
||||
|
||||
public static ArbitraryTextTypeComponent deserialize(Map<String, Object> map) {
|
||||
return new ArbitraryTextTypeComponent(map.get("key").toString(), map.get("value").toString());
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getKey() {
|
||||
return _key;
|
||||
return key;
|
||||
}
|
||||
|
||||
public void setKey(String key) {
|
||||
Preconditions.checkArgument(key != null && !key.isEmpty(), "The key must be specified.");
|
||||
_key = key;
|
||||
this.key = key;
|
||||
}
|
||||
|
||||
public String getValue() {
|
||||
return _value;
|
||||
return value;
|
||||
}
|
||||
|
||||
public void setValue(String value) {
|
||||
Preconditions.checkArgument(value != null, "The value must be specified.");
|
||||
_value = value;
|
||||
this.value = value;
|
||||
}
|
||||
|
||||
private String _key;
|
||||
private String _value;
|
||||
|
||||
@Override
|
||||
public TextualComponent clone() throws CloneNotSupportedException {
|
||||
// Since this is a private and final class, we can just reinstantiate this class instead of casting super.clone
|
||||
@ -118,16 +215,15 @@ public abstract class TextualComponent implements Cloneable {
|
||||
writer.name(getKey()).value(getValue());
|
||||
}
|
||||
|
||||
@Override
|
||||
@SuppressWarnings("serial")
|
||||
public Map<String, Object> serialize() {
|
||||
return new HashMap<String, Object>() {{
|
||||
return new HashMap<String, Object>() {
|
||||
{
|
||||
put("key", getKey());
|
||||
put("value", getValue());
|
||||
}};
|
||||
}
|
||||
|
||||
public static ArbitraryTextTypeComponent deserialize(Map<String, Object> map) {
|
||||
return new ArbitraryTextTypeComponent(map.get("key").toString(), map.get("value").toString());
|
||||
};
|
||||
}
|
||||
|
||||
@Override
|
||||
@ -137,40 +233,55 @@ public abstract class TextualComponent implements Cloneable {
|
||||
}
|
||||
|
||||
/**
|
||||
* Internal class used to represent a text component with a nested JSON value.
|
||||
* Exception validating done is on keys and values.
|
||||
* Internal class used to represent a text component with a nested JSON
|
||||
* value.
|
||||
*
|
||||
* <p>Exception validating done is on keys and values.
|
||||
*/
|
||||
private static final class ComplexTextTypeComponent extends TextualComponent implements ConfigurationSerializable {
|
||||
|
||||
private String key;
|
||||
private Map<String, String> value;
|
||||
|
||||
public ComplexTextTypeComponent(String key, Map<String, String> values) {
|
||||
setKey(key);
|
||||
setValue(values);
|
||||
}
|
||||
|
||||
public static ComplexTextTypeComponent deserialize(Map<String, Object> map) {
|
||||
String key = null;
|
||||
Map<String, String> value = new HashMap<>();
|
||||
for (Map.Entry<String, Object> valEntry : map.entrySet()) {
|
||||
if (valEntry.getKey().equals("key")) {
|
||||
key = (String) valEntry.getValue();
|
||||
} else if (valEntry.getKey().startsWith("value.")) {
|
||||
value.put(valEntry.getKey().substring(6) /* Strips out the value prefix */, valEntry.getValue().toString());
|
||||
}
|
||||
}
|
||||
return new ComplexTextTypeComponent(key, value);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getKey() {
|
||||
return _key;
|
||||
return key;
|
||||
}
|
||||
|
||||
public void setKey(String key) {
|
||||
Preconditions.checkArgument(key != null && !key.isEmpty(), "The key must be specified.");
|
||||
_key = key;
|
||||
this.key = key;
|
||||
}
|
||||
|
||||
public Map<String, String> getValue() {
|
||||
return _value;
|
||||
return value;
|
||||
}
|
||||
|
||||
public void setValue(Map<String, String> value) {
|
||||
Preconditions.checkArgument(value != null, "The value must be specified.");
|
||||
_value = value;
|
||||
this.value = value;
|
||||
}
|
||||
|
||||
private String _key;
|
||||
private Map<String, String> _value;
|
||||
|
||||
@Override
|
||||
public TextualComponent clone() throws CloneNotSupportedException {
|
||||
public TextualComponent clone() {
|
||||
// Since this is a private and final class, we can just reinstantiate this class instead of casting super.clone
|
||||
return new ComplexTextTypeComponent(getKey(), getValue());
|
||||
}
|
||||
@ -179,33 +290,23 @@ public abstract class TextualComponent implements Cloneable {
|
||||
public void writeJson(JsonWriter writer) throws IOException {
|
||||
writer.name(getKey());
|
||||
writer.beginObject();
|
||||
for (Map.Entry<String, String> jsonPair : _value.entrySet()) {
|
||||
for (Map.Entry<String, String> jsonPair : value.entrySet()) {
|
||||
writer.name(jsonPair.getKey()).value(jsonPair.getValue());
|
||||
}
|
||||
writer.endObject();
|
||||
}
|
||||
|
||||
@Override
|
||||
@SuppressWarnings("serial")
|
||||
public Map<String, Object> serialize() {
|
||||
return new java.util.HashMap<String, Object>() {{
|
||||
return new java.util.HashMap<String, Object>() {
|
||||
{
|
||||
put("key", getKey());
|
||||
for (Map.Entry<String, String> valEntry : getValue().entrySet()) {
|
||||
put("value." + valEntry.getKey(), valEntry.getValue());
|
||||
}
|
||||
}};
|
||||
}
|
||||
|
||||
public static ComplexTextTypeComponent deserialize(Map<String, Object> map) {
|
||||
String key = null;
|
||||
Map<String, String> value = new HashMap<String, String>();
|
||||
for (Map.Entry<String, Object> valEntry : map.entrySet()) {
|
||||
if (valEntry.getKey().equals("key")) {
|
||||
key = (String) valEntry.getValue();
|
||||
} else if (valEntry.getKey().startsWith("value.")) {
|
||||
value.put(((String) valEntry.getKey()).substring(6) /* Strips out the value prefix */, valEntry.getValue().toString());
|
||||
}
|
||||
}
|
||||
return new ComplexTextTypeComponent(key, value);
|
||||
};
|
||||
}
|
||||
|
||||
@Override
|
||||
@ -213,85 +314,4 @@ public abstract class TextualComponent implements Cloneable {
|
||||
return getKey();
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Create a textual component representing a string literal.
|
||||
* This is the default type of textual component when a single string literal is given to a method.
|
||||
*
|
||||
* @param textValue The text which will be represented.
|
||||
* @return The text component representing the specified literal text.
|
||||
*/
|
||||
public static TextualComponent rawText(String textValue) {
|
||||
return new ArbitraryTextTypeComponent("text", textValue);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Create a textual component representing a localized string.
|
||||
* The client will see this text component as their localized version of the specified string <em>key</em>, which can be overridden by a resource pack.
|
||||
* <p>
|
||||
* If the specified translation key is not present on the client resource pack, the translation key will be displayed as a string literal to the client.
|
||||
* </p>
|
||||
*
|
||||
* @param translateKey The string key which maps to localized text.
|
||||
* @return The text component representing the specified localized text.
|
||||
*/
|
||||
public static TextualComponent localizedText(String translateKey) {
|
||||
return new ArbitraryTextTypeComponent("translate", translateKey);
|
||||
}
|
||||
|
||||
private static void throwUnsupportedSnapshot() {
|
||||
throw new UnsupportedOperationException("This feature is only supported in snapshot releases.");
|
||||
}
|
||||
|
||||
/**
|
||||
* Create a textual component representing a scoreboard value.
|
||||
* The client will see their own score for the specified objective as the text represented by this component.
|
||||
* <p>
|
||||
* <b>This method is currently guaranteed to throw an {@code UnsupportedOperationException} as it is only supported on snapshot clients.</b>
|
||||
* </p>
|
||||
*
|
||||
* @param scoreboardObjective The name of the objective for which to display the score.
|
||||
* @return The text component representing the specified scoreboard score (for the viewing player), or {@code null} if an error occurs during JSON serialization.
|
||||
*/
|
||||
public static TextualComponent objectiveScore(String scoreboardObjective) {
|
||||
return objectiveScore("*", scoreboardObjective);
|
||||
}
|
||||
|
||||
/**
|
||||
* Create a textual component representing a scoreboard value.
|
||||
* The client will see the score of the specified player for the specified objective as the text represented by this component.
|
||||
* <p>
|
||||
* <b>This method is currently guaranteed to throw an {@code UnsupportedOperationException} as it is only supported on snapshot clients.</b>
|
||||
* </p>
|
||||
*
|
||||
* @param playerName The name of the player whos score will be shown. If this string represents the single-character sequence "*", the viewing player's score will be displayed.
|
||||
* Standard minecraft selectors (@a, @p, etc) are <em>not</em> supported.
|
||||
* @param scoreboardObjective The name of the objective for which to display the score.
|
||||
* @return The text component representing the specified scoreboard score for the specified player, or {@code null} if an error occurs during JSON serialization.
|
||||
*/
|
||||
public static TextualComponent objectiveScore(String playerName, String scoreboardObjective) {
|
||||
throwUnsupportedSnapshot(); // Remove this line when the feature is released to non-snapshot versions, in addition to updating ALL THE OVERLOADS documentation accordingly
|
||||
|
||||
return new ComplexTextTypeComponent("score", ImmutableMap.<String, String>builder()
|
||||
.put("name", playerName)
|
||||
.put("objective", scoreboardObjective)
|
||||
.build());
|
||||
}
|
||||
|
||||
/**
|
||||
* Create a textual component representing a player name, retrievable by using a standard minecraft selector.
|
||||
* The client will see the players or entities captured by the specified selector as the text represented by this component.
|
||||
* <p>
|
||||
* <b>This method is currently guaranteed to throw an {@code UnsupportedOperationException} as it is only supported on snapshot clients.</b>
|
||||
* </p>
|
||||
*
|
||||
* @param selector The minecraft player or entity selector which will capture the entities whose string representations will be displayed in the place of this text component.
|
||||
* @return The text component representing the name of the entities captured by the selector.
|
||||
*/
|
||||
public static TextualComponent selector(String selector) {
|
||||
throwUnsupportedSnapshot(); // Remove this line when the feature is released to non-snapshot versions, in addition to updating ALL THE OVERLOADS documentation accordingly
|
||||
|
||||
return new ArbitraryTextTypeComponent("selector", selector);
|
||||
}
|
||||
}
|
||||
|
@ -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);
|
||||
|
@ -13,7 +13,7 @@ import java.util.HashMap;
|
||||
|
||||
public abstract class APlotMeConnector {
|
||||
|
||||
public abstract Connection getPlotMeConnection(FileConfiguration plotConfig, String dataFolder);
|
||||
public abstract Connection getPlotMeConnection(String plugin, FileConfiguration plotConfig, String dataFolder);
|
||||
|
||||
public abstract HashMap<String, HashMap<PlotId, Plot>> getPlotMePlots(Connection connection) throws SQLException;
|
||||
|
||||
|
@ -26,12 +26,12 @@ import java.util.UUID;
|
||||
|
||||
public class ClassicPlotMeConnector extends APlotMeConnector {
|
||||
|
||||
private String plugin;
|
||||
private String plugin = "PlotMe";
|
||||
private String prefix;
|
||||
|
||||
@Override
|
||||
public Connection getPlotMeConnection(FileConfiguration plotConfig, String dataFolder) {
|
||||
this.plugin = this.plugin.toLowerCase();
|
||||
public Connection getPlotMeConnection(String plugin, FileConfiguration plotConfig, String dataFolder) {
|
||||
this.plugin = plugin.toLowerCase();
|
||||
this.prefix = plotConfig.getString("mySQLprefix", this.plugin.toLowerCase());
|
||||
try {
|
||||
if (plotConfig.getBoolean("usemySQL")) {
|
||||
|
@ -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();
|
||||
@ -123,14 +151,14 @@ public class LikePlotMeConverter {
|
||||
|
||||
PS.debug("&3Using connector: " + connector.getClass().getCanonicalName());
|
||||
|
||||
Connection connection = connector.getPlotMeConnection(plotConfig, dataFolder);
|
||||
Connection connection = connector.getPlotMeConnection(plugin,plotConfig, dataFolder);
|
||||
|
||||
if (!connector.isValidConnection(connection)) {
|
||||
sendMessage("Cannot connect to PlotMe DB. Conversion process will not continue");
|
||||
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); //
|
||||
HashSet<String> allWorlds = new HashSet<>(plots.keySet());
|
||||
allWorlds.addAll(worlds);
|
||||
for (String world : allWorlds) {
|
||||
copyConfig(plotmeDgYml, world);
|
||||
}
|
||||
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);
|
||||
} catch (IOException ignored) {
|
||||
ignored.printStackTrace();
|
||||
}
|
||||
} catch (IOException ignored) {}
|
||||
}
|
||||
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,9 +294,13 @@ 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 + "'...");
|
||||
if (!Bukkit.getWorlds().isEmpty() && Bukkit.getWorlds().get(0).getName().equals(worldName)) {
|
||||
sendMessage("&cYou need to stop the server to reload this world properly");
|
||||
} else {
|
||||
PS.get().removePlotAreas(actualWorldName);
|
||||
if (mv) {
|
||||
// unload world with MV
|
||||
@ -302,7 +312,7 @@ public class LikePlotMeConverter {
|
||||
}
|
||||
// load world with MV
|
||||
Bukkit.getServer().dispatchCommand(Bukkit.getServer().getConsoleSender(),
|
||||
"mv import " + actualWorldName + " normal -g PlotSquared");
|
||||
"mv import " + actualWorldName + " normal -g " + PS.imp().getPluginName());
|
||||
} else if (mw) {
|
||||
// unload world with MW
|
||||
Bukkit.getServer().dispatchCommand(Bukkit.getServer().getConsoleSender(), "mw unload " + actualWorldName);
|
||||
@ -313,15 +323,16 @@ public class LikePlotMeConverter {
|
||||
}
|
||||
// load world with MW
|
||||
Bukkit.getServer().dispatchCommand(Bukkit.getServer().getConsoleSender(),
|
||||
"mw create " + actualWorldName + " plugin:PlotSquared");
|
||||
"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(new HybridGen())).createWorld();
|
||||
World myWorld = WorldCreator.name(actualWorldName).generator(new BukkitPlotGenerator(PS.get().IMP.getDefaultGenerator())).createWorld();
|
||||
myWorld.save();
|
||||
}
|
||||
}
|
||||
}
|
||||
} catch (CommandException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
@ -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 {
|
||||
|
@ -26,8 +26,8 @@ public class PlotMeConnector_017 extends APlotMeConnector {
|
||||
private String plugin;
|
||||
|
||||
@Override
|
||||
public Connection getPlotMeConnection(FileConfiguration plotConfig, String dataFolder) {
|
||||
this.plugin = this.plugin.toLowerCase();
|
||||
public Connection getPlotMeConnection(String plugin, FileConfiguration plotConfig, String dataFolder) {
|
||||
this.plugin = plugin.toLowerCase();
|
||||
try {
|
||||
if (plotConfig.getBoolean("usemySQL")) {
|
||||
String user = plotConfig.getString("mySQLuname");
|
||||
@ -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;
|
||||
@ -20,23 +19,24 @@ import com.intellectualcrafters.plot.util.block.LocalBlockQueue;
|
||||
import com.intellectualcrafters.plot.util.block.ScopedLocalBlockQueue;
|
||||
import com.plotsquared.bukkit.util.BukkitUtil;
|
||||
import com.plotsquared.bukkit.util.block.GenChunk;
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Random;
|
||||
import java.util.Set;
|
||||
import org.bukkit.Chunk;
|
||||
import org.bukkit.World;
|
||||
import org.bukkit.block.Biome;
|
||||
import org.bukkit.generator.BlockPopulator;
|
||||
import org.bukkit.generator.ChunkGenerator;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Random;
|
||||
import java.util.Set;
|
||||
|
||||
public class BukkitPlotGenerator extends ChunkGenerator implements GeneratorWrapper<ChunkGenerator> {
|
||||
|
||||
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<>();
|
||||
@ -48,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;
|
||||
@ -118,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
|
||||
@ -128,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
|
||||
@ -187,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();
|
||||
}
|
||||
|
||||
@ -245,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);
|
||||
@ -255,7 +256,7 @@ public class BukkitPlotGenerator extends ChunkGenerator implements GeneratorWrap
|
||||
|
||||
@Override
|
||||
public ChunkData generateChunkData(World world, Random random, int cx, int cz, BiomeGrid grid) {
|
||||
GenChunk result = (GenChunk) this.chunkSetter;
|
||||
GenChunk result = this.chunkSetter;
|
||||
// Set the chunk location
|
||||
result.setChunk(new ChunkWrapper(world.getName(), cx, cz));
|
||||
// Set the result data
|
||||
@ -303,7 +304,7 @@ public class BukkitPlotGenerator extends ChunkGenerator implements GeneratorWrap
|
||||
|
||||
@Override
|
||||
public short[][] generateExtBlockSections(World world, Random r, int cx, int cz, BiomeGrid grid) {
|
||||
GenChunk result = (GenChunk) this.chunkSetter;
|
||||
GenChunk result = this.chunkSetter;
|
||||
// Set the chunk location
|
||||
result.setChunk(new ChunkWrapper(world.getName(), cx, cz));
|
||||
// Set the result data
|
||||
|
@ -1,8 +1,7 @@
|
||||
package com.plotsquared.bukkit.listeners;
|
||||
|
||||
import static com.intellectualcrafters.plot.util.ReflectionUtils.getRefClass;
|
||||
|
||||
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;
|
||||
@ -10,6 +9,8 @@ import com.intellectualcrafters.plot.util.ReflectionUtils.RefClass;
|
||||
import com.intellectualcrafters.plot.util.ReflectionUtils.RefField;
|
||||
import com.intellectualcrafters.plot.util.ReflectionUtils.RefMethod;
|
||||
import com.intellectualcrafters.plot.util.TaskManager;
|
||||
import java.lang.reflect.Method;
|
||||
import java.util.HashSet;
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.Chunk;
|
||||
import org.bukkit.Material;
|
||||
@ -28,8 +29,8 @@ import org.bukkit.event.entity.ItemSpawnEvent;
|
||||
import org.bukkit.event.world.ChunkLoadEvent;
|
||||
import org.bukkit.event.world.ChunkUnloadEvent;
|
||||
|
||||
import java.lang.reflect.Method;
|
||||
import java.util.HashSet;
|
||||
|
||||
import static com.intellectualcrafters.plot.util.ReflectionUtils.getRefClass;
|
||||
|
||||
public class ChunkListener implements Listener {
|
||||
|
||||
@ -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;
|
||||
}
|
||||
}
|
||||
@ -100,14 +101,21 @@ public class ChunkListener implements Listener {
|
||||
}, 1);
|
||||
}
|
||||
|
||||
private boolean ignoreUnload = false;
|
||||
|
||||
public boolean unloadChunk(String world, Chunk chunk, boolean safe) {
|
||||
if (safe && shouldSave(world, chunk.getX(), chunk.getZ())) {
|
||||
return false;
|
||||
}
|
||||
Object c = this.methodGetHandleChunk.of(chunk).call();
|
||||
this.mustSave.of(c).set(false);
|
||||
RefField.RefExecutor field = this.mustSave.of(c);
|
||||
if ((Boolean) field.get() == true) {
|
||||
field.set(false);
|
||||
if (chunk.isLoaded()) {
|
||||
ignoreUnload = true;
|
||||
chunk.unload(false, false);
|
||||
ignoreUnload = false;
|
||||
}
|
||||
}
|
||||
return true;
|
||||
}
|
||||
@ -139,6 +147,9 @@ public class ChunkListener implements Listener {
|
||||
|
||||
@EventHandler
|
||||
public void onChunkUnload(ChunkUnloadEvent event) {
|
||||
if (ignoreUnload) {
|
||||
return;
|
||||
}
|
||||
if (Settings.Chunk_Processor.AUTO_TRIM) {
|
||||
Chunk chunk = event.getChunk();
|
||||
String world = chunk.getWorld().getName();
|
||||
@ -218,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;
|
||||
}
|
||||
@ -226,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;
|
||||
}
|
||||
@ -236,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;
|
||||
}
|
||||
@ -260,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;
|
||||
}
|
||||
|
@ -0,0 +1,44 @@
|
||||
package com.plotsquared.bukkit.listeners;
|
||||
|
||||
import com.intellectualcrafters.plot.config.Settings;
|
||||
import com.intellectualcrafters.plot.flag.Flags;
|
||||
import com.intellectualcrafters.plot.object.Location;
|
||||
import com.intellectualcrafters.plot.object.Plot;
|
||||
import com.intellectualcrafters.plot.object.PlotArea;
|
||||
import com.plotsquared.bukkit.util.BukkitUtil;
|
||||
import org.bukkit.entity.Entity;
|
||||
import org.bukkit.event.EventHandler;
|
||||
import org.bukkit.event.EventPriority;
|
||||
import org.bukkit.event.Listener;
|
||||
import org.bukkit.event.entity.EntitySpawnEvent;
|
||||
|
||||
public class EntitySpawnListener implements Listener {
|
||||
@EventHandler(priority = EventPriority.HIGHEST, ignoreCancelled = true)
|
||||
public void creatureSpawnEvent(EntitySpawnEvent event) {
|
||||
Entity entity = event.getEntity();
|
||||
Location location = BukkitUtil.getLocation(entity.getLocation());
|
||||
PlotArea area = location.getPlotArea();
|
||||
if (area == null) {
|
||||
return;
|
||||
}
|
||||
Plot plot = area.getOwnedPlotAbs(location);
|
||||
if (plot == null) {
|
||||
return;
|
||||
}
|
||||
if (Settings.Done.RESTRICT_BUILDING && plot.hasFlag(Flags.DONE)) {
|
||||
event.setCancelled(true);
|
||||
}
|
||||
switch (entity.getType()) {
|
||||
case ENDER_CRYSTAL:
|
||||
if (plot == null) {
|
||||
if (!area.MOB_SPAWNING) {
|
||||
event.setCancelled(true);
|
||||
}
|
||||
return;
|
||||
}
|
||||
if (PlayerEvents.checkEntity(entity, plot)) {
|
||||
event.setCancelled(true);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
@ -1,27 +1,26 @@
|
||||
package com.plotsquared.bukkit.listeners;
|
||||
|
||||
import com.google.common.collect.Iterables;
|
||||
import com.intellectualcrafters.plot.flag.Flags;
|
||||
import com.intellectualcrafters.plot.object.Location;
|
||||
import com.intellectualcrafters.plot.object.Plot;
|
||||
import com.intellectualcrafters.plot.object.PlotPlayer;
|
||||
import com.plotsquared.bukkit.object.BukkitPlayer;
|
||||
import com.plotsquared.bukkit.util.BukkitUtil;
|
||||
import org.bukkit.entity.Entity;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.event.Listener;
|
||||
import org.bukkit.util.Vector;
|
||||
|
||||
import java.util.HashSet;
|
||||
import java.util.Set;
|
||||
import java.util.UUID;
|
||||
|
||||
public class ForceFieldListener implements Listener {
|
||||
public class ForceFieldListener {
|
||||
|
||||
private static Set<PlotPlayer> getNearbyPlayers(Player player, Plot plot) {
|
||||
Set<PlotPlayer> players = new HashSet<>();
|
||||
for (Entity entity : player.getNearbyEntities(5d, 5d, 5d)) {
|
||||
for (Player nearPlayer : Iterables.filter(player.getNearbyEntities(5d, 5d, 5d),Player.class)) {
|
||||
PlotPlayer plotPlayer;
|
||||
if (!(entity instanceof Player) || ((plotPlayer = BukkitUtil.getPlayer((Player) entity)) == null) || !plot.equals(plotPlayer.getCurrentPlot())) {
|
||||
if ((plotPlayer = BukkitUtil.getPlayer(nearPlayer)) == null || !plot.equals(plotPlayer.getCurrentPlot())) {
|
||||
continue;
|
||||
}
|
||||
if (!plot.isAdded(plotPlayer.getUUID())) {
|
||||
@ -32,15 +31,9 @@ public class ForceFieldListener implements Listener {
|
||||
}
|
||||
|
||||
private static PlotPlayer hasNearbyPermitted(Player player, Plot plot) {
|
||||
for (Entity entity : player.getNearbyEntities(5d, 5d, 5d)) {
|
||||
if (!(entity instanceof Player)) {
|
||||
continue;
|
||||
}
|
||||
for (Player nearPlayer : Iterables.filter(player.getNearbyEntities(5d, 5d, 5d),Player.class)) {
|
||||
PlotPlayer plotPlayer;
|
||||
if ((plotPlayer = BukkitUtil.getPlayer((Player) entity)) == null) {
|
||||
continue;
|
||||
}
|
||||
if (!plot.equals(plotPlayer.getCurrentPlot())) {
|
||||
if ((plotPlayer = BukkitUtil.getPlayer(nearPlayer)) == null || !plot.equals(plotPlayer.getCurrentPlot())) {
|
||||
continue;
|
||||
}
|
||||
if (plot.isAdded(plotPlayer.getUUID())) {
|
||||
|
@ -20,24 +20,14 @@ 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 java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
import java.util.HashSet;
|
||||
import java.util.Iterator;
|
||||
import java.util.List;
|
||||
import java.util.Map.Entry;
|
||||
import java.util.Objects;
|
||||
import java.util.Set;
|
||||
import java.util.UUID;
|
||||
import java.util.regex.Pattern;
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.ChatColor;
|
||||
import org.bukkit.Material;
|
||||
@ -65,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;
|
||||
@ -74,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;
|
||||
@ -86,7 +78,9 @@ import org.bukkit.event.block.BlockSpreadEvent;
|
||||
import org.bukkit.event.block.EntityBlockFormEvent;
|
||||
import org.bukkit.event.entity.CreatureSpawnEvent;
|
||||
import org.bukkit.event.entity.EntityChangeBlockEvent;
|
||||
import org.bukkit.event.entity.EntityCombustByEntityEvent;
|
||||
import org.bukkit.event.entity.EntityDamageByEntityEvent;
|
||||
import org.bukkit.event.entity.EntityDamageEvent;
|
||||
import org.bukkit.event.entity.EntityExplodeEvent;
|
||||
import org.bukkit.event.entity.ExplosionPrimeEvent;
|
||||
import org.bukkit.event.entity.PotionSplashEvent;
|
||||
@ -121,6 +115,18 @@ 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.HashSet;
|
||||
import java.util.Iterator;
|
||||
import java.util.List;
|
||||
import java.util.Map.Entry;
|
||||
import java.util.Objects;
|
||||
import java.util.Set;
|
||||
import java.util.UUID;
|
||||
import java.util.regex.Pattern;
|
||||
|
||||
/**
|
||||
* Player Events involving plots.
|
||||
*
|
||||
@ -158,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:
|
||||
@ -192,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;
|
||||
}
|
||||
@ -201,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;
|
||||
@ -279,8 +297,7 @@ public class PlayerEvents extends PlotListener implements Listener {
|
||||
if (!(shooter instanceof Player)) {
|
||||
return;
|
||||
}
|
||||
ThrownPotion potion = (ThrownPotion) entity;
|
||||
Location l = BukkitUtil.getLocation(potion);
|
||||
Location l = BukkitUtil.getLocation(entity);
|
||||
if (!PS.get().hasPlotArea(l.getWorld())) {
|
||||
return;
|
||||
}
|
||||
@ -303,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);
|
||||
@ -345,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();
|
||||
@ -410,7 +413,6 @@ public class PlayerEvents extends PlotListener implements Listener {
|
||||
pattern = RegExUtil.compiledPatterns.get(s);
|
||||
}
|
||||
if (pattern.matcher(msg).matches()) {
|
||||
MainUtil.sendMessage(pp, C.COMMAND_BLOCKED);
|
||||
String perm;
|
||||
if (plot.isAdded(pp.getUUID())) {
|
||||
perm = "plots.admin.command.blocked-cmds.shared";
|
||||
@ -418,6 +420,7 @@ public class PlayerEvents extends PlotListener implements Listener {
|
||||
perm = "plots.admin.command.blocked-cmds.other";
|
||||
}
|
||||
if (!Permissions.hasPermission(pp, perm)) {
|
||||
MainUtil.sendMessage(pp, C.COMMAND_BLOCKED);
|
||||
event.setCancelled(true);
|
||||
}
|
||||
return;
|
||||
@ -466,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();
|
||||
@ -487,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;
|
||||
}
|
||||
@ -538,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);
|
||||
}
|
||||
}
|
||||
@ -575,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);
|
||||
@ -607,6 +641,7 @@ public class PlayerEvents extends PlotListener implements Listener {
|
||||
for (Player receiver : recipients) {
|
||||
receiver.sendMessage(full);
|
||||
}
|
||||
PS.debug(full);
|
||||
}
|
||||
|
||||
@EventHandler(priority = EventPriority.LOWEST)
|
||||
@ -617,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) {
|
||||
@ -699,7 +734,7 @@ public class PlayerEvents extends PlotListener implements Listener {
|
||||
if (this.lastRadius != 0) {
|
||||
List<Entity> nearby = event.getEntity().getNearbyEntities(this.lastRadius, this.lastRadius, this.lastRadius);
|
||||
for (Entity near : nearby) {
|
||||
if (near instanceof TNTPrimed || near.getType() == EntityType.MINECART_TNT) {
|
||||
if (near instanceof TNTPrimed || near.getType().equals(EntityType.MINECART_TNT)) {
|
||||
if (!near.hasMetadata("plot")) {
|
||||
near.setMetadata("plot", new FixedMetadataValue((Plugin) PS.get().IMP, plot));
|
||||
}
|
||||
@ -804,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();
|
||||
@ -818,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);
|
||||
@ -898,8 +954,19 @@ public class PlayerEvents extends PlotListener implements Listener {
|
||||
if (plot != null) {
|
||||
if (Flags.DISABLE_PHYSICS.isFalse(plot)) {
|
||||
event.setCancelled(true);
|
||||
return;
|
||||
} else if (!area.contains(fLocation.getX(), fLocation.getZ()) || !Objects.equals(plot, area.getOwnedPlot(fLocation))) {
|
||||
event.setCancelled(true);
|
||||
return;
|
||||
}
|
||||
if (Flags.LIQUID_FLOW.isFalse(plot)) {
|
||||
switch (to.getType()) {
|
||||
case WATER:
|
||||
case STATIONARY_WATER:
|
||||
case LAVA:
|
||||
case STATIONARY_LAVA:
|
||||
event.setCancelled(true);
|
||||
}
|
||||
}
|
||||
} else if (!area.contains(fLocation.getX(), fLocation.getZ()) || !Objects.equals(plot, area.getOwnedPlot(fLocation))) {
|
||||
event.setCancelled(true);
|
||||
@ -941,12 +1008,12 @@ public class PlayerEvents extends PlotListener implements Listener {
|
||||
}
|
||||
List<Block> blocks = event.getBlocks();
|
||||
for (Block b : blocks) {
|
||||
Location bloc = BukkitUtil.getLocation(b.getLocation().add(relative));
|
||||
if (!area.contains(bloc.getX(), bloc.getZ())) {
|
||||
Location bloc = BukkitUtil.getLocation(b.getLocation());
|
||||
if (!area.contains(bloc.getX(), bloc.getZ()) || !area.contains(bloc.getX() + relative.getBlockX(), bloc.getZ() + relative.getBlockZ())) {
|
||||
event.setCancelled(true);
|
||||
return;
|
||||
}
|
||||
if (!plot.equals(area.getOwnedPlot(bloc))) {
|
||||
if (!plot.equals(area.getOwnedPlot(bloc)) || !plot.equals(area.getOwnedPlot(bloc.add(relative.getBlockX(), relative.getBlockY(), relative.getBlockZ())))) {
|
||||
event.setCancelled(true);
|
||||
return;
|
||||
}
|
||||
@ -1067,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;
|
||||
@ -1087,7 +1154,7 @@ public class PlayerEvents extends PlotListener implements Listener {
|
||||
}
|
||||
}
|
||||
|
||||
@EventHandler(priority = EventPriority.LOWEST, ignoreCancelled = true)
|
||||
@EventHandler(priority = EventPriority.LOW, ignoreCancelled = true)
|
||||
public void onInteract(PlayerInteractEvent event) {
|
||||
Player player = event.getPlayer();
|
||||
PlotPlayer pp = BukkitUtil.getPlayer(player);
|
||||
@ -1161,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:
|
||||
@ -1174,14 +1260,13 @@ public class PlayerEvents extends PlotListener implements Listener {
|
||||
}
|
||||
lb = new BukkitLazyBlock(blockId, block);
|
||||
ItemStack hand = player.getItemInHand();
|
||||
if (eventType != null) {
|
||||
if (eventType != null && (eventType != PlayerBlockEventType.INTERACT_BLOCK || !player.isSneaking())) {
|
||||
break;
|
||||
}
|
||||
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;
|
||||
lb = new BukkitLazyBlock(0, block);
|
||||
break;
|
||||
}
|
||||
if (id < 198) {
|
||||
@ -1197,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:
|
||||
@ -1272,7 +1354,7 @@ public class PlayerEvents extends PlotListener implements Listener {
|
||||
}
|
||||
|
||||
@EventHandler(priority = EventPriority.HIGHEST, ignoreCancelled = true)
|
||||
public void MobSpawn(CreatureSpawnEvent event) {
|
||||
public void creatureSpawnEvent(CreatureSpawnEvent event) {
|
||||
Entity entity = event.getEntity();
|
||||
Location location = BukkitUtil.getLocation(entity.getLocation());
|
||||
PlotArea area = location.getPlotArea();
|
||||
@ -1318,10 +1400,6 @@ public class PlayerEvents extends PlotListener implements Listener {
|
||||
return;
|
||||
}
|
||||
if (checkEntity(entity, plot)) {
|
||||
PlotPlayer owner = UUIDHandler.getPlayer(plot.owner);
|
||||
if (owner != null) {
|
||||
C.ENTITY_CAP.send(owner);
|
||||
}
|
||||
event.setCancelled(true);
|
||||
}
|
||||
}
|
||||
@ -1368,7 +1446,10 @@ public class PlayerEvents extends PlotListener implements Listener {
|
||||
this.lastRadius = event.getRadius() + 1;
|
||||
}
|
||||
|
||||
public boolean checkEntity(Plot plot, IntegerFlag... flags) {
|
||||
public static boolean checkEntity(Plot plot, IntegerFlag... flags) {
|
||||
if (Settings.Done.RESTRICT_BUILDING && Flags.DONE.isSet(plot)) {
|
||||
return true;
|
||||
}
|
||||
int[] mobs = null;
|
||||
for (IntegerFlag flag : flags) {
|
||||
int i;
|
||||
@ -1398,23 +1479,59 @@ public class PlayerEvents extends PlotListener implements Listener {
|
||||
if (cap == Integer.MAX_VALUE) {
|
||||
continue;
|
||||
}
|
||||
if (cap == 0) {
|
||||
return true;
|
||||
}
|
||||
if (mobs == null) {
|
||||
mobs = plot.countEntities();
|
||||
}
|
||||
if (mobs[i] >= cap) {
|
||||
plot.setMeta("EntityCount", mobs);
|
||||
plot.setMeta("EntityCountTime", System.currentTimeMillis());
|
||||
return true;
|
||||
}
|
||||
}
|
||||
if (mobs != null) {
|
||||
for (IntegerFlag flag : flags) {
|
||||
int i;
|
||||
switch (flag.getName()) {
|
||||
case "entity-cap":
|
||||
i = 0;
|
||||
break;
|
||||
case "mob-cap":
|
||||
i = 3;
|
||||
break;
|
||||
case "hostile-cap":
|
||||
i = 2;
|
||||
break;
|
||||
case "animal-cap":
|
||||
i = 1;
|
||||
break;
|
||||
case "vehicle-cap":
|
||||
i = 4;
|
||||
break;
|
||||
case "misc-cap":
|
||||
i = 5;
|
||||
break;
|
||||
default:
|
||||
i = 0;
|
||||
}
|
||||
mobs[i]++;
|
||||
}
|
||||
plot.setMeta("EntityCount", mobs);
|
||||
plot.setMeta("EntityCountTime", System.currentTimeMillis());
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
public boolean checkEntity(Entity entity, Plot plot) {
|
||||
public static boolean checkEntity(Entity entity, Plot plot) {
|
||||
if (plot == null || !plot.hasOwner() || plot.getFlags().isEmpty() && plot.getArea().DEFAULT_FLAGS.isEmpty()) {
|
||||
return false;
|
||||
}
|
||||
switch (entity.getType()) {
|
||||
case PLAYER:
|
||||
return false;
|
||||
case LLAMA_SPIT:
|
||||
case SMALL_FIREBALL:
|
||||
case FIREBALL:
|
||||
case DROPPED_ITEM:
|
||||
@ -1444,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);
|
||||
@ -1461,6 +1579,7 @@ public class PlayerEvents extends PlotListener implements Listener {
|
||||
case MINECART_TNT:
|
||||
case BOAT:
|
||||
return checkEntity(plot, Flags.ENTITY_CAP, Flags.VEHICLE_CAP);
|
||||
case POLAR_BEAR:
|
||||
case RABBIT:
|
||||
case SHEEP:
|
||||
case MUSHROOM_COW:
|
||||
@ -1475,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:
|
||||
@ -1496,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:
|
||||
@ -1622,153 +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.getPlotAbs(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)) {
|
||||
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.getPlotAbs(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)) {
|
||||
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();
|
||||
@ -1779,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;
|
||||
@ -1833,6 +1818,9 @@ public class PlayerEvents extends PlotListener implements Listener {
|
||||
|
||||
@EventHandler(priority = EventPriority.MONITOR)
|
||||
public void onLeave(PlayerQuitEvent event) {
|
||||
if (TaskManager.TELEPORT_QUEUE.contains(event.getPlayer().getName())) {
|
||||
TaskManager.TELEPORT_QUEUE.remove(event.getPlayer().getName());
|
||||
}
|
||||
PlotPlayer pp = BukkitUtil.getPlayer(event.getPlayer());
|
||||
pp.unregister();
|
||||
}
|
||||
@ -1847,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;
|
||||
@ -1902,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);
|
||||
@ -1943,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);
|
||||
@ -1973,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)) {
|
||||
@ -2004,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);
|
||||
@ -2032,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);
|
||||
@ -2050,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");
|
||||
@ -2097,6 +2088,29 @@ public class PlayerEvents extends PlotListener implements Listener {
|
||||
}
|
||||
}
|
||||
|
||||
@SuppressWarnings("deprecation")
|
||||
@EventHandler(priority = EventPriority.HIGHEST)
|
||||
public void onEntityCombustByEntity(EntityCombustByEntityEvent event) {
|
||||
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);
|
||||
}
|
||||
|
||||
@EventHandler(priority = EventPriority.HIGHEST)
|
||||
public void onEntityDamageByEntityEvent(EntityDamageByEntityEvent event) {
|
||||
Entity damager = event.getDamager();
|
||||
@ -2294,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)) {
|
||||
@ -2333,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;
|
||||
@ -12,9 +13,12 @@ import org.bukkit.Effect;
|
||||
import org.bukkit.GameMode;
|
||||
import org.bukkit.WeatherType;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.event.EventException;
|
||||
import org.bukkit.event.player.PlayerTeleportEvent;
|
||||
import org.bukkit.event.player.PlayerTeleportEvent.TeleportCause;
|
||||
|
||||
import java.util.UUID;
|
||||
import org.bukkit.plugin.RegisteredListener;
|
||||
|
||||
public class BukkitPlayer extends PlotPlayer {
|
||||
|
||||
@ -57,6 +61,39 @@ public class BukkitPlayer extends PlotPlayer {
|
||||
return this.player.getLastPlayed();
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean canTeleport(Location loc) {
|
||||
org.bukkit.Location to = BukkitUtil.getLocation(loc);
|
||||
org.bukkit.Location from = player.getLocation();
|
||||
PlayerTeleportEvent event = new PlayerTeleportEvent(player, from, to);
|
||||
RegisteredListener[] listeners = event.getHandlers().getRegisteredListeners();
|
||||
for (RegisteredListener listener : listeners) {
|
||||
if (listener.getPlugin().getName().equals(PS.imp().getPluginName())) {
|
||||
continue;
|
||||
}
|
||||
try {
|
||||
listener.callEvent(event);
|
||||
} catch (EventException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
if (event.isCancelled() || !event.getTo().equals(to)) {
|
||||
return false;
|
||||
}
|
||||
event = new PlayerTeleportEvent(player, to, from);
|
||||
for (RegisteredListener listener : listeners) {
|
||||
if (listener.getPlugin().getName().equals(PS.imp().getPluginName())) {
|
||||
continue;
|
||||
}
|
||||
try {
|
||||
listener.callEvent(event);
|
||||
} catch (EventException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean hasPermission(String permission) {
|
||||
if (this.offline && EconHandler.manager != null) {
|
||||
|
@ -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 {
|
||||
@ -366,7 +367,11 @@ public class EntityWrapper {
|
||||
}
|
||||
|
||||
private void restoreInventory(InventoryHolder entity) {
|
||||
try {
|
||||
entity.getInventory().setContents(this.inventory);
|
||||
} catch (IllegalArgumentException e) {
|
||||
PS.debug("&c[WARN] Failed to restore inventory.\n Reason: " + e.getMessage());
|
||||
}
|
||||
}
|
||||
|
||||
public void storeLiving(LivingEntity lived) {
|
||||
@ -393,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 {
|
||||
@ -483,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);
|
||||
}
|
||||
@ -491,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);
|
||||
}
|
||||
|
||||
@ -30,7 +30,6 @@ public class DefaultTitleManager_183 extends DefaultTitleManager {
|
||||
this.chatBaseComponent = Reflection.getNMSClass("IChatBaseComponent");
|
||||
this.packetActions = Reflection.getNMSClass("PacketPlayOutTitle$EnumTitleAction");
|
||||
this.nmsChatSerializer = Reflection.getNMSClass("IChatBaseComponent$ChatSerializer");
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
@ -68,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;
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -52,7 +52,7 @@ public abstract class TitleManager {
|
||||
abstract void loadClasses();
|
||||
|
||||
/**
|
||||
* Get title text.
|
||||
* Gets title text.
|
||||
*
|
||||
* @return Title text
|
||||
*/
|
||||
@ -61,7 +61,7 @@ public abstract class TitleManager {
|
||||
}
|
||||
|
||||
/**
|
||||
* Set title text.
|
||||
* Sets the text for the title.
|
||||
*
|
||||
* @param title Title
|
||||
*/
|
||||
@ -70,7 +70,7 @@ public abstract class TitleManager {
|
||||
}
|
||||
|
||||
/**
|
||||
* Get subtitle text.
|
||||
* Gets the subtitle text.
|
||||
*
|
||||
* @return Subtitle text
|
||||
*/
|
||||
@ -79,7 +79,7 @@ public abstract class TitleManager {
|
||||
}
|
||||
|
||||
/**
|
||||
* Set subtitle text.
|
||||
* Sets subtitle text.
|
||||
*
|
||||
* @param subtitle Subtitle text
|
||||
*/
|
||||
@ -88,7 +88,7 @@ public abstract class TitleManager {
|
||||
}
|
||||
|
||||
/**
|
||||
* Set the title color.
|
||||
* Sets the title color.
|
||||
*
|
||||
* @param color Chat color
|
||||
*/
|
||||
@ -97,7 +97,7 @@ public abstract class TitleManager {
|
||||
}
|
||||
|
||||
/**
|
||||
* Set the subtitle color.
|
||||
* Sets the subtitle color.
|
||||
*
|
||||
* @param color Chat color
|
||||
*/
|
||||
@ -106,7 +106,7 @@ public abstract class TitleManager {
|
||||
}
|
||||
|
||||
/**
|
||||
* Set title fade in time.
|
||||
* Sets title fade in time.
|
||||
*
|
||||
* @param time Time
|
||||
*/
|
||||
@ -115,7 +115,7 @@ public abstract class TitleManager {
|
||||
}
|
||||
|
||||
/**
|
||||
* Set title fade out time.
|
||||
* Sets title fade out time.
|
||||
*
|
||||
* @param time Time
|
||||
*/
|
||||
@ -124,7 +124,7 @@ public abstract class TitleManager {
|
||||
}
|
||||
|
||||
/**
|
||||
* Set title stay time.
|
||||
* Sets title stay time.
|
||||
*
|
||||
* @param time Time
|
||||
*/
|
||||
@ -133,21 +133,21 @@ public abstract class TitleManager {
|
||||
}
|
||||
|
||||
/**
|
||||
* Set timings to ticks.
|
||||
* Sets timings to ticks.
|
||||
*/
|
||||
public final void setTimingsToTicks() {
|
||||
this.ticks = true;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set timings to seconds.
|
||||
* Sets timings to seconds.
|
||||
*/
|
||||
public final void setTimingsToSeconds() {
|
||||
this.ticks = false;
|
||||
}
|
||||
|
||||
/**
|
||||
* Send the title to a player.
|
||||
* Sends the title to a player.
|
||||
*
|
||||
* @param player Player
|
||||
* @throws IllegalArgumentException
|
||||
@ -157,18 +157,18 @@ public abstract class TitleManager {
|
||||
public abstract void send(Player player) throws IllegalArgumentException, ReflectiveOperationException, SecurityException;
|
||||
|
||||
/**
|
||||
* Broadcast the title to all players.
|
||||
* Broadcasts the title to all players.
|
||||
*
|
||||
* @throws Exception
|
||||
*/
|
||||
public final void broadcast() throws Exception {
|
||||
for (Player p : Bukkit.getOnlinePlayers()) {
|
||||
send(p);
|
||||
for (Player player : Bukkit.getOnlinePlayers()) {
|
||||
send(player);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Clear the title.
|
||||
* Clears the title.
|
||||
*
|
||||
* @param player Player
|
||||
* @throws IllegalArgumentException
|
||||
@ -178,7 +178,7 @@ public abstract class TitleManager {
|
||||
public abstract void clearTitle(Player player) throws IllegalArgumentException, ReflectiveOperationException, SecurityException;
|
||||
|
||||
/**
|
||||
* Reset the title settings.
|
||||
* Resets the title settings.
|
||||
*
|
||||
* @param player Player
|
||||
* @throws IllegalArgumentException
|
||||
@ -195,7 +195,7 @@ public abstract class TitleManager {
|
||||
}
|
||||
}
|
||||
|
||||
final Class<?>[] toPrimitiveTypeArray(Class<?>[] classes) {
|
||||
private Class<?>[] toPrimitiveTypeArray(Class<?>[] classes) {
|
||||
int a;
|
||||
if (classes != null) {
|
||||
a = classes.length;
|
||||
@ -229,7 +229,7 @@ public abstract class TitleManager {
|
||||
return null;
|
||||
}
|
||||
|
||||
final boolean equalsTypeArray(Class<?>[] a, Class<?>[] o) {
|
||||
private boolean equalsTypeArray(Class<?>[] a, Class<?>[] o) {
|
||||
if (a.length != o.length) {
|
||||
return false;
|
||||
}
|
||||
@ -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;
|
||||
}
|
||||
}
|
||||
|
@ -17,14 +17,6 @@ import com.intellectualcrafters.plot.util.block.GlobalBlockQueue;
|
||||
import com.intellectualcrafters.plot.util.block.LocalBlockQueue;
|
||||
import com.intellectualcrafters.plot.util.block.ScopedLocalBlockQueue;
|
||||
import com.plotsquared.bukkit.object.entity.EntityWrapper;
|
||||
import java.util.ArrayDeque;
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashMap;
|
||||
import java.util.HashSet;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Map.Entry;
|
||||
import java.util.Set;
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.Chunk;
|
||||
import org.bukkit.DyeColor;
|
||||
@ -57,6 +49,15 @@ import org.bukkit.entity.Player;
|
||||
import org.bukkit.inventory.InventoryHolder;
|
||||
import org.bukkit.inventory.ItemStack;
|
||||
|
||||
import java.util.ArrayDeque;
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashMap;
|
||||
import java.util.HashSet;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Map.Entry;
|
||||
import java.util.Set;
|
||||
|
||||
public class BukkitChunkManager extends ChunkManager {
|
||||
|
||||
public static boolean isIn(RegionWrapper region, int x, int z) {
|
||||
@ -424,6 +425,10 @@ public class BukkitChunkManager extends ChunkManager {
|
||||
|
||||
@Override
|
||||
public int[] countEntities(Plot plot) {
|
||||
int[] existing = (int[]) plot.getMeta("EntityCount");
|
||||
if (existing != null && (System.currentTimeMillis() - (long) plot.getMeta("EntityCountTime") < 1000)) {
|
||||
return existing;
|
||||
}
|
||||
PlotArea area = plot.getArea();
|
||||
World world = BukkitUtil.getWorld(area.worldname);
|
||||
|
||||
@ -448,9 +453,9 @@ public class BukkitChunkManager extends ChunkManager {
|
||||
|
||||
boolean doWhole = false;
|
||||
List<Entity> entities = null;
|
||||
if (size > 200) {
|
||||
if (size > 200 && chunks.size() > 200) {
|
||||
entities = world.getEntities();
|
||||
if (entities.size() < 16 + size * size / 64) {
|
||||
if (entities.size() < 16 + size / 8) {
|
||||
doWhole = true;
|
||||
}
|
||||
}
|
||||
@ -511,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:
|
||||
@ -528,12 +534,14 @@ public class BukkitChunkManager extends ChunkManager {
|
||||
case UNKNOWN:
|
||||
case AREA_EFFECT_CLOUD:
|
||||
case LINGERING_POTION:
|
||||
case EVOKER_FANGS:
|
||||
// non moving / unremovable
|
||||
break;
|
||||
case ITEM_FRAME:
|
||||
case PAINTING:
|
||||
case ARMOR_STAND:
|
||||
count[5]++;
|
||||
break;
|
||||
// misc
|
||||
case MINECART:
|
||||
case MINECART_CHEST:
|
||||
@ -545,6 +553,7 @@ public class BukkitChunkManager extends ChunkManager {
|
||||
case BOAT:
|
||||
count[4]++;
|
||||
break;
|
||||
case POLAR_BEAR:
|
||||
case RABBIT:
|
||||
case SHEEP:
|
||||
case MUSHROOM_COW:
|
||||
@ -559,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]++;
|
||||
@ -582,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]++;
|
||||
@ -603,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,6 +31,7 @@ public class BukkitSetupUtils extends SetupUtils {
|
||||
}
|
||||
String testWorld = "CheckingPlotSquaredGenerator";
|
||||
for (Plugin plugin : Bukkit.getPluginManager().getPlugins()) {
|
||||
try {
|
||||
if (plugin.isEnabled()) {
|
||||
ChunkGenerator generator = plugin.getDefaultWorldGenerator(testWorld, "");
|
||||
if (generator != null) {
|
||||
@ -45,6 +46,9 @@ public class BukkitSetupUtils extends SetupUtils {
|
||||
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};
|
||||
}
|
@ -1,6 +1,5 @@
|
||||
package com.plotsquared.bukkit.util;
|
||||
|
||||
import com.intellectualcrafters.plot.PS;
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.plugin.Plugin;
|
||||
@ -9,71 +8,38 @@ import org.bukkit.scheduler.BukkitTask;
|
||||
|
||||
import java.io.BufferedReader;
|
||||
import java.io.ByteArrayOutputStream;
|
||||
import java.io.File;
|
||||
import java.io.IOException;
|
||||
import java.io.InputStreamReader;
|
||||
import java.io.OutputStream;
|
||||
import java.io.UnsupportedEncodingException;
|
||||
import java.lang.reflect.InvocationTargetException;
|
||||
import java.net.Proxy;
|
||||
import java.net.URL;
|
||||
import java.net.URLConnection;
|
||||
import java.net.URLEncoder;
|
||||
import java.util.Collection;
|
||||
import java.util.Collections;
|
||||
import java.util.HashSet;
|
||||
import java.util.LinkedHashSet;
|
||||
import java.util.Set;
|
||||
import java.util.UUID;
|
||||
import java.util.logging.Level;
|
||||
import java.util.zip.GZIPOutputStream;
|
||||
|
||||
public class Metrics {
|
||||
|
||||
/**
|
||||
* The current revision number.
|
||||
*/
|
||||
/** The current revision number. */
|
||||
private static final int REVISION = 7;
|
||||
/**
|
||||
* The base url of the metrics domain.
|
||||
*/
|
||||
/** The base url of the metrics domain.*/
|
||||
private static final String BASE_URL = "http://report.mcstats.org";
|
||||
/**
|
||||
* The url used to report a server's status.
|
||||
*/
|
||||
/** The url used to report a server's status. */
|
||||
private static final String REPORT_URL = "/plugin/%s";
|
||||
/**
|
||||
* Interval of time to ping (in minutes).
|
||||
*/
|
||||
/** Interval of time to ping (in minutes). */
|
||||
private static final int PING_INTERVAL = 15;
|
||||
/**
|
||||
* The plugin this metrics submits for.
|
||||
*/
|
||||
/** The plugin this metrics submits for. */
|
||||
private final Plugin plugin;
|
||||
/**
|
||||
* All of the custom graphs to submit to metrics.
|
||||
*/
|
||||
private final Set<Graph> graphs = Collections.synchronizedSet(new HashSet<Graph>());
|
||||
/**
|
||||
* Unique server id.
|
||||
*/
|
||||
/** Unique server id. */
|
||||
private final String guid;
|
||||
/**
|
||||
* Debug mode.
|
||||
*/
|
||||
private final boolean debug;
|
||||
/**
|
||||
* The scheduled task.
|
||||
*/
|
||||
/** The scheduled task. */
|
||||
private volatile BukkitTask task = null;
|
||||
|
||||
public Metrics(Plugin plugin) {
|
||||
if (plugin == null) {
|
||||
throw new IllegalArgumentException("Plugin cannot be null");
|
||||
}
|
||||
this.plugin = plugin;
|
||||
this.guid = UUID.randomUUID().toString();
|
||||
this.debug = false;
|
||||
}
|
||||
|
||||
/**
|
||||
@ -186,38 +152,6 @@ public class Metrics {
|
||||
return URLEncoder.encode(text, "UTF-8");
|
||||
}
|
||||
|
||||
/**
|
||||
* Construct and create a Graph that can be used to separate specific plotters to their own graphs on the metrics
|
||||
* website. Plotters can be added to the graph object returned.
|
||||
*
|
||||
* @param name The name of the graph
|
||||
*
|
||||
* @return Graph object created. Will never return NULL under normal circumstances unless bad parameters are given
|
||||
*/
|
||||
public Graph createGraph(String name) {
|
||||
if (name == null) {
|
||||
throw new IllegalArgumentException("Graph name cannot be null");
|
||||
}
|
||||
// Construct the graph object
|
||||
Graph graph = new Graph(name);
|
||||
// Now we can add our graph
|
||||
this.graphs.add(graph);
|
||||
// and return back
|
||||
return graph;
|
||||
}
|
||||
|
||||
/**
|
||||
* Add a Graph object to BukkitMetrics that represents data for the plugin that should be sent to the backend
|
||||
*
|
||||
* @param graph The name of the graph
|
||||
*/
|
||||
public void addGraph(Graph graph) {
|
||||
if (graph == null) {
|
||||
throw new IllegalArgumentException("Graph cannot be null");
|
||||
}
|
||||
this.graphs.add(graph);
|
||||
}
|
||||
|
||||
/**
|
||||
* Start measuring statistics. This will immediately create an async repeating task as the plugin and send the
|
||||
* initial data to the metrics backend, and then after that it will post in increments of PING_INTERVAL * 1200
|
||||
@ -244,54 +178,12 @@ public class Metrics {
|
||||
this.firstPost = false;
|
||||
} catch (IOException e) {
|
||||
e.printStackTrace();
|
||||
if (Metrics.this.debug) {
|
||||
Bukkit.getLogger().log(Level.INFO, "[Metrics] " + e.getMessage());
|
||||
}
|
||||
}
|
||||
}
|
||||
}, 0, PING_INTERVAL * 1200);
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* Enables metrics for the server by setting "opt-out" to false in the config file and starting the metrics task.
|
||||
*/
|
||||
public void enable() {
|
||||
// Enable Task, if it is not running
|
||||
if (this.task == null) {
|
||||
start();
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Disables metrics for the server by setting "opt-out" to true in the config file and canceling the metrics task.
|
||||
*/
|
||||
public void disable() {
|
||||
// Disable Task, if it is running
|
||||
if (this.task != null) {
|
||||
this.task.cancel();
|
||||
this.task = null;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the File object of the config file that should be used to store
|
||||
* data such as the GUID and opt-out status.
|
||||
*
|
||||
* @return the File object for the config file
|
||||
*/
|
||||
public File getConfigFile() {
|
||||
// I believe the easiest way to get the base folder (e.g craftbukkit set
|
||||
// via -P) for plugins to use
|
||||
// is to abuse the plugin object we already have
|
||||
// plugin.getDataFolder() => base/plugins/PluginA/
|
||||
// pluginsFolder => base/plugins/
|
||||
// The base is not necessarily relative to the startup directory.
|
||||
File pluginsFolder = this.plugin.getDataFolder().getParentFile();
|
||||
// return => base/plugins/PluginMetrics/config.yml
|
||||
return new File(new File(pluginsFolder, "PluginMetrics"), "config.yml");
|
||||
}
|
||||
|
||||
/**
|
||||
* Generic method that posts a plugin to the metrics website.
|
||||
*/
|
||||
@ -342,46 +234,12 @@ public class Metrics {
|
||||
if (isPing) {
|
||||
appendJSONPair(json, "ping", "1");
|
||||
}
|
||||
if (!this.graphs.isEmpty()) {
|
||||
synchronized (this.graphs) {
|
||||
json.append(',');
|
||||
json.append('"');
|
||||
json.append("graphs");
|
||||
json.append('"');
|
||||
json.append(':');
|
||||
json.append('{');
|
||||
boolean firstGraph = true;
|
||||
for (Graph graph : this.graphs) {
|
||||
StringBuilder graphJson = new StringBuilder();
|
||||
graphJson.append('{');
|
||||
for (Plotter plotter : graph.getPlotters()) {
|
||||
appendJSONPair(graphJson, plotter.getColumnName(), Integer.toString(plotter.getValue()));
|
||||
}
|
||||
graphJson.append('}');
|
||||
if (!firstGraph) {
|
||||
json.append(',');
|
||||
}
|
||||
json.append(escapeJSON(graph.getName()));
|
||||
json.append(':');
|
||||
json.append(graphJson);
|
||||
firstGraph = false;
|
||||
}
|
||||
json.append('}');
|
||||
}
|
||||
}
|
||||
// close json
|
||||
json.append('}');
|
||||
// Create the url
|
||||
URL url = new URL(BASE_URL + String.format(REPORT_URL, urlEncode(pluginName)));
|
||||
// Connect to the website
|
||||
URLConnection connection;
|
||||
// Mineshafter creates a socks proxy, so we can safely bypass it
|
||||
// It does not reroute POST requests so we need to go around it
|
||||
if (isMineshafterPresent()) {
|
||||
connection = url.openConnection(Proxy.NO_PROXY);
|
||||
} else {
|
||||
connection = url.openConnection();
|
||||
}
|
||||
URLConnection connection = url.openConnection();
|
||||
byte[] uncompressed = json.toString().getBytes();
|
||||
byte[] compressed = gzip(json.toString());
|
||||
// Headers
|
||||
@ -392,9 +250,6 @@ public class Metrics {
|
||||
connection.addRequestProperty("Accept", "application/json");
|
||||
connection.addRequestProperty("Connection", "close");
|
||||
connection.setDoOutput(true);
|
||||
if (this.debug) {
|
||||
PS.debug("[Metrics] Prepared request for " + pluginName + " uncompressed=" + uncompressed.length + " compressed=" + compressed.length);
|
||||
}
|
||||
try {
|
||||
try (OutputStream os = connection.getOutputStream()) {
|
||||
os.write(compressed);
|
||||
@ -403,9 +258,6 @@ public class Metrics {
|
||||
String response;
|
||||
try (BufferedReader reader = new BufferedReader(new InputStreamReader(connection.getInputStream()))) {
|
||||
response = reader.readLine();
|
||||
if (this.debug) {
|
||||
PS.debug("[Metrics] Response for " + pluginName + ": " + response);
|
||||
}
|
||||
}
|
||||
if (response == null || response.startsWith("ERR") || response.startsWith("7")) {
|
||||
if (response == null) {
|
||||
@ -414,171 +266,7 @@ public class Metrics {
|
||||
response = response.substring(response.startsWith("7,") ? 2 : 1);
|
||||
}
|
||||
throw new IOException(response);
|
||||
} else {
|
||||
// Is this the first update this hour?
|
||||
if ("1".equals(response) || response.contains("This is your first update this hour")) {
|
||||
synchronized (this.graphs) {
|
||||
for (Graph graph : this.graphs) {
|
||||
for (Plotter plotter : graph.getPlotters()) {
|
||||
plotter.reset();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
} catch (Exception e) {
|
||||
if (this.debug) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Check if mineshafter is present. If it is, we need to bypass it to send POST requests
|
||||
*
|
||||
* @return true if mineshafter is installed on the server
|
||||
*/
|
||||
private boolean isMineshafterPresent() {
|
||||
try {
|
||||
Class.forName("mineshafter.MineServer");
|
||||
return true;
|
||||
} catch (ClassNotFoundException ignored) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Represents a custom graph on the website
|
||||
*/
|
||||
public static class Graph {
|
||||
|
||||
/**
|
||||
* The graph's name, alphanumeric and spaces only :) If it does not comply to the above when submitted, it is
|
||||
* rejected
|
||||
*/
|
||||
private final String name;
|
||||
/**
|
||||
* The set of plotters that are contained within this graph
|
||||
*/
|
||||
private final Set<Plotter> plotters = new LinkedHashSet<>();
|
||||
|
||||
private Graph(String name) {
|
||||
this.name = name;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the graph's name
|
||||
*
|
||||
* @return the Graph's name
|
||||
*/
|
||||
public String getName() {
|
||||
return this.name;
|
||||
}
|
||||
|
||||
/**
|
||||
* Add a plotter to the graph, which will be used to plot entries
|
||||
*
|
||||
* @param plotter the plotter to add to the graph
|
||||
*/
|
||||
public void addPlotter(Plotter plotter) {
|
||||
this.plotters.add(plotter);
|
||||
}
|
||||
|
||||
/**
|
||||
* Remove a plotter from the graph
|
||||
*
|
||||
* @param plotter the plotter to remove from the graph
|
||||
*/
|
||||
public void removePlotter(Plotter plotter) {
|
||||
this.plotters.remove(plotter);
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets an <b>unmodifiable</b> set of the plotter objects in the graph
|
||||
*
|
||||
* @return an unmodifiable {@link Set} of the plotter objects
|
||||
*/
|
||||
public Set<Plotter> getPlotters() {
|
||||
return Collections.unmodifiableSet(this.plotters);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int hashCode() {
|
||||
return this.name.hashCode();
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean equals(Object object) {
|
||||
if (!(object instanceof Graph)) {
|
||||
return false;
|
||||
}
|
||||
Graph graph = (Graph) object;
|
||||
return graph.name.equals(this.name);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Interface used to collect custom data for a plugin
|
||||
*/
|
||||
public abstract static class Plotter {
|
||||
|
||||
/**
|
||||
* The plot's name
|
||||
*/
|
||||
private final String name;
|
||||
|
||||
/**
|
||||
* Construct a plotter with the default plot name
|
||||
*/
|
||||
public Plotter() {
|
||||
this("Default");
|
||||
}
|
||||
|
||||
/**
|
||||
* Construct a plotter with a specific plot name
|
||||
*
|
||||
* @param name the name of the plotter to use, which will show up on the website
|
||||
*/
|
||||
public Plotter(String name) {
|
||||
this.name = name;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the current value for the plotted point. Since this function defers to an external function it may or may
|
||||
* not return immediately thus cannot be guaranteed to be thread friendly or safe. This function can be called
|
||||
* from any thread so care should be taken when accessing resources that need to be synchronized.
|
||||
*
|
||||
* @return the current value for the point to be plotted.
|
||||
*/
|
||||
public abstract int getValue();
|
||||
|
||||
/**
|
||||
* Get the column name for the plotted point
|
||||
*
|
||||
* @return the plotted point's column name
|
||||
*/
|
||||
public String getColumnName() {
|
||||
return this.name;
|
||||
}
|
||||
|
||||
/**
|
||||
* Called after the website graphs have been updated
|
||||
*/
|
||||
public void reset() {}
|
||||
|
||||
@Override
|
||||
public int hashCode() {
|
||||
return getColumnName().hashCode();
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean equals(Object object) {
|
||||
if (!(object instanceof Plotter)) {
|
||||
return false;
|
||||
}
|
||||
Plotter plotter = (Plotter) object;
|
||||
return plotter.name.equals(this.name) && plotter.getValue() == getValue();
|
||||
}
|
||||
} catch (IOException ignored) {}
|
||||
}
|
||||
}
|
@ -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.
|
||||
|
@ -26,9 +26,8 @@ import java.util.HashSet;
|
||||
import java.util.Map.Entry;
|
||||
|
||||
/**
|
||||
* An utility that can be used to send chunks, rather than using bukkit code to do so (uses heavy NMS)
|
||||
*
|
||||
|
||||
* An utility that can be used to send chunks, rather than using bukkit code
|
||||
* to do so (uses heavy NMS).
|
||||
*/
|
||||
public class SendChunk {
|
||||
|
||||
@ -40,7 +39,7 @@ public class SendChunk {
|
||||
private final RefMethod methodInitLighting;
|
||||
|
||||
/**
|
||||
* Constructor
|
||||
* Constructor.
|
||||
*/
|
||||
public SendChunk() throws ClassNotFoundException, NoSuchMethodException, NoSuchFieldException {
|
||||
RefConstructor tempMapChunk;
|
||||
@ -51,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 {
|
||||
@ -117,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;
|
||||
@ -82,9 +84,10 @@ public class BukkitLocalQueue<T> extends BasicLocalBlockQueue<T> {
|
||||
if (blocksLayer != null) {
|
||||
for (int j = 0; j < blocksLayer.length; j++) {
|
||||
PlotBlock block = blocksLayer[j];
|
||||
if (block != null) {
|
||||
int x = MainUtil.x_loc[layer][j];
|
||||
int y = MainUtil.y_loc[layer][j];
|
||||
int z = MainUtil.y_loc[layer][j];
|
||||
int z = MainUtil.z_loc[layer][j];
|
||||
Block existing = chunk.getBlock(x, y, z);
|
||||
int existingId = existing.getTypeId();
|
||||
if (existingId == block.id) {
|
||||
@ -100,6 +103,7 @@ public class BukkitLocalQueue<T> extends BasicLocalBlockQueue<T> {
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public void setBiomes(LocalChunk<T> lc) {
|
||||
if (lc.biomes != null) {
|
||||
@ -124,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,33 +378,17 @@ 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();
|
||||
|
||||
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];
|
||||
@ -461,6 +443,8 @@ public class BukkitLocalQueue_1_9 extends BukkitLocalQueue<char[]> {
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
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;
|
||||
|
@ -80,8 +80,8 @@ public class FileUUIDHandler extends UUIDHandlerImplementation {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
if (Settings.UUID.NATIVE_UUID_PROVIDER) {
|
||||
HashBiMap<StringWrapper, UUID> toAdd = HashBiMap.create(new HashMap<StringWrapper, UUID>());
|
||||
if (Settings.UUID.NATIVE_UUID_PROVIDER) {
|
||||
HashSet<UUID> all = UUIDHandler.getAllUUIDS();
|
||||
PS.debug("&aFast mode UUID caching enabled!");
|
||||
File playerDataFolder = new File(container, world + File.separator + "playerdata");
|
||||
@ -97,7 +97,7 @@ public class FileUUIDHandler extends UUIDHandlerImplementation {
|
||||
ByteSource is = com.google.common.io.Files.asByteSource(file);
|
||||
NbtFactory.NbtCompound compound = NbtFactory.fromStream(is, NbtFactory.StreamOptions.GZIP_COMPRESSION);
|
||||
if (!compound.containsKey("bukkit")) {
|
||||
PS.debug("ERROR: Player data does not contain the the key \"bukkit\"");
|
||||
PS.debug("ERROR: Player data (" + uuid.toString() + ".dat) does not contain the the key \"bukkit\"");
|
||||
} else {
|
||||
NbtFactory.NbtCompound bukkit = (NbtFactory.NbtCompound) compound.get("bukkit");
|
||||
String name = (String) bukkit.get("lastKnownName");
|
||||
@ -108,7 +108,7 @@ public class FileUUIDHandler extends UUIDHandlerImplementation {
|
||||
toAdd.put(new StringWrapper(name), uuid);
|
||||
}
|
||||
}
|
||||
} catch (IOException e) {
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
PS.debug(C.PREFIX + "Invalid playerdata: " + current);
|
||||
}
|
||||
@ -124,7 +124,6 @@ public class FileUUIDHandler extends UUIDHandlerImplementation {
|
||||
PS.debug("Failed to cache: " + all.size() + " uuids - slowly processing all files");
|
||||
}
|
||||
}
|
||||
HashBiMap<StringWrapper, UUID> toAdd = HashBiMap.create(new HashMap<StringWrapper, UUID>());
|
||||
HashSet<String> worlds = Sets.newHashSet(world, "world");
|
||||
HashSet<UUID> uuids = new HashSet<>();
|
||||
HashSet<String> names = new HashSet<>();
|
||||
@ -164,10 +163,12 @@ public class FileUUIDHandler extends UUIDHandlerImplementation {
|
||||
ByteSource is = com.google.common.io.Files.asByteSource(file);
|
||||
NbtFactory.NbtCompound compound = NbtFactory.fromStream(is, NbtFactory.StreamOptions.GZIP_COMPRESSION);
|
||||
if (!compound.containsKey("bukkit")) {
|
||||
PS.debug("ERROR: Player data does not contain the the key \"bukkit\"");
|
||||
PS.debug("ERROR: Player data (" + uuid.toString() + ".dat) does not contain the the key \"bukkit\"");
|
||||
} else {
|
||||
NbtFactory.NbtCompound bukkit = (NbtFactory.NbtCompound) compound.get("bukkit");
|
||||
String name = (String) bukkit.get("lastKnownName");
|
||||
StringWrapper wrap = new StringWrapper(name);
|
||||
if (!toAdd.containsKey(wrap)) {
|
||||
long last = (long) bukkit.get("lastPlayed");
|
||||
if (Settings.UUID.OFFLINE) {
|
||||
if (Settings.UUID.FORCE_LOWERCASE && !name.toLowerCase().equals(name)) {
|
||||
@ -181,7 +182,8 @@ public class FileUUIDHandler extends UUIDHandlerImplementation {
|
||||
if (ExpireManager.IMP != null) {
|
||||
ExpireManager.IMP.storeDate(uuid, last);
|
||||
}
|
||||
toAdd.put(new StringWrapper(name), uuid);
|
||||
toAdd.put(wrap, uuid);
|
||||
}
|
||||
}
|
||||
} catch (Exception ignored) {
|
||||
PS.debug(C.PREFIX + "&6Invalid PlayerData: " + uuid.toString() + ".dat");
|
||||
@ -199,6 +201,7 @@ public class FileUUIDHandler extends UUIDHandlerImplementation {
|
||||
if (last != 0) {
|
||||
String name = op.getName();
|
||||
StringWrapper wrap = new StringWrapper(name);
|
||||
if (!toAdd.containsKey(wrap)) {
|
||||
UUID uuid = FileUUIDHandler.this.uuidWrapper.getUUID(op);
|
||||
toAdd.put(wrap, uuid);
|
||||
if (ExpireManager.IMP != null) {
|
||||
@ -207,6 +210,7 @@ public class FileUUIDHandler extends UUIDHandlerImplementation {
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
add(toAdd);
|
||||
if (whenDone != null) {
|
||||
whenDone.run();
|
||||
|
@ -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'
|
@ -2,14 +2,14 @@ package com.intellectualcrafters.configuration;
|
||||
|
||||
/**
|
||||
* Various settings for controlling the input and output of a {@link
|
||||
* Configuration}
|
||||
* Configuration}.
|
||||
*/
|
||||
class ConfigurationOptions {
|
||||
private final Configuration configuration;
|
||||
private char pathSeparator = '.';
|
||||
private boolean copyDefaults = false;
|
||||
|
||||
protected ConfigurationOptions(final Configuration configuration) {
|
||||
protected ConfigurationOptions(Configuration configuration) {
|
||||
this.configuration = configuration;
|
||||
}
|
||||
|
||||
@ -24,9 +24,9 @@ class ConfigurationOptions {
|
||||
|
||||
/**
|
||||
* Gets the char that will be used to separate {@link
|
||||
* ConfigurationSection}s
|
||||
* <p>
|
||||
* This value does not affect how the {@link Configuration} is stored,
|
||||
* ConfigurationSection}s.
|
||||
*
|
||||
* <p>This value does not affect how the {@link Configuration} is stored,
|
||||
* only in how you access the data. The default value is '.'.
|
||||
*
|
||||
* @return Path separator
|
||||
@ -37,15 +37,15 @@ class ConfigurationOptions {
|
||||
|
||||
/**
|
||||
* Sets the char that will be used to separate {@link
|
||||
* ConfigurationSection}s
|
||||
* <p>
|
||||
* This value does not affect how the {@link Configuration} is stored,
|
||||
* ConfigurationSection}s.
|
||||
*
|
||||
* <p>This value does not affect how the {@link Configuration} is stored,
|
||||
* only in how you access the data. The default value is '.'.
|
||||
*
|
||||
* @param value Path separator
|
||||
* @return This object, for chaining
|
||||
*/
|
||||
public ConfigurationOptions pathSeparator(final char value) {
|
||||
public ConfigurationOptions pathSeparator(char value) {
|
||||
pathSeparator = value;
|
||||
return this;
|
||||
}
|
||||
@ -53,8 +53,8 @@ class ConfigurationOptions {
|
||||
/**
|
||||
* Checks if the {@link Configuration} should copy values from its default
|
||||
* {@link Configuration} directly.
|
||||
* <p>
|
||||
* If this is true, all values in the default Configuration will be
|
||||
*
|
||||
* <p>If this is true, all values in the default Configuration will be
|
||||
* directly copied, making it impossible to distinguish between values
|
||||
* that were set and values that are provided by default. As a result,
|
||||
* {@link ConfigurationSection#contains(String)} will always
|
||||
@ -71,8 +71,8 @@ class ConfigurationOptions {
|
||||
/**
|
||||
* Sets if the {@link Configuration} should copy values from its default
|
||||
* {@link Configuration} directly.
|
||||
* <p>
|
||||
* If this is true, all values in the default Configuration will be
|
||||
*
|
||||
* <p>If this is true, all values in the default Configuration will be
|
||||
* directly copied, making it impossible to distinguish between values
|
||||
* that were set and values that are provided by default. As a result,
|
||||
* {@link ConfigurationSection#contains(String)} will always
|
||||
@ -83,7 +83,7 @@ class ConfigurationOptions {
|
||||
* @param value Whether or not defaults are directly copied
|
||||
* @return This object, for chaining
|
||||
*/
|
||||
public ConfigurationOptions copyDefaults(final boolean value) {
|
||||
public ConfigurationOptions copyDefaults(boolean value) {
|
||||
copyDefaults = value;
|
||||
return this;
|
||||
}
|
||||
|
@ -5,18 +5,18 @@ import java.util.Map;
|
||||
import java.util.Set;
|
||||
|
||||
/**
|
||||
* Represents a section of a {@link Configuration}
|
||||
* Represents a section of a {@link Configuration}.
|
||||
*/
|
||||
public interface ConfigurationSection {
|
||||
|
||||
/**
|
||||
* Gets a set containing all keys in this section.
|
||||
* <p>
|
||||
* If deep is set to true, then this will contain all the keys within any
|
||||
*
|
||||
* <p>If deep is set to true, then this will contain all the keys within any
|
||||
* child {@link ConfigurationSection}s (and their children, etc). These
|
||||
* will be in a valid path notation for you to use.
|
||||
* <p>
|
||||
* If deep is set to false, then this will contain only the keys of any
|
||||
*
|
||||
* <p>If deep is set to false, then this will contain only the keys of any
|
||||
* direct children, and not their own children.
|
||||
*
|
||||
* @param deep Whether or not to get a deep list, as opposed to a shallow
|
||||
@ -27,12 +27,12 @@ public interface ConfigurationSection {
|
||||
|
||||
/**
|
||||
* Gets a Map containing all keys and their values for this section.
|
||||
* <p>
|
||||
* If deep is set to true, then this will contain all the keys and values
|
||||
*
|
||||
* <p>If deep is set to true, then this will contain all the keys and values
|
||||
* within any child {@link ConfigurationSection}s (and their children,
|
||||
* etc). These keys will be in a valid path notation for you to use.
|
||||
* <p>
|
||||
* If deep is set to false, then this will contain only the keys and
|
||||
*
|
||||
* <p>If deep is set to false, then this will contain only the keys and
|
||||
* values of any direct children, and not their own children.
|
||||
*
|
||||
* @param deep Whether or not to get a deep list, as opposed to a shallow
|
||||
@ -43,43 +43,44 @@ public interface ConfigurationSection {
|
||||
|
||||
/**
|
||||
* Checks if this {@link ConfigurationSection} contains the given path.
|
||||
* <p>
|
||||
* If the value for the requested path does not exist but a default value
|
||||
*
|
||||
* <p>If the value for the requested path does not exist but a default value
|
||||
* has been specified, this will return true.
|
||||
*
|
||||
* @param path Path to check for existence.
|
||||
* @return True if this section contains the requested path, either via
|
||||
* default or being set.
|
||||
* @throws IllegalArgumentException Thrown when path is null.
|
||||
* @throws IllegalArgumentException Thrown when path is {@code null}.
|
||||
*/
|
||||
boolean contains(String path);
|
||||
|
||||
/**
|
||||
* Checks if this {@link ConfigurationSection} has a value set for the
|
||||
* given path.
|
||||
* <p>
|
||||
* If the value for the requested path does not exist but a default value
|
||||
*
|
||||
* <p>If the value for the requested path does not exist but a default value
|
||||
* has been specified, this will still return false.
|
||||
*
|
||||
* @param path Path to check for existence.
|
||||
* @return True if this section contains the requested path, regardless of
|
||||
* having a default.
|
||||
* @throws IllegalArgumentException Thrown when path is null.
|
||||
* @throws IllegalArgumentException Thrown when path is {@code null}.
|
||||
*/
|
||||
boolean isSet(String path);
|
||||
|
||||
/**
|
||||
* Gets the path of this {@link ConfigurationSection} from its root {@link
|
||||
* Configuration}
|
||||
* <p>
|
||||
* For any {@link Configuration} themselves, this will return an empty
|
||||
* Configuration}.
|
||||
*
|
||||
* <p>For any {@link Configuration} themselves, this will return an empty
|
||||
* string.
|
||||
* <p>
|
||||
* If the section is no longer contained within its root for any reason,
|
||||
* such as being replaced with a different value, this may return null.
|
||||
* <p>
|
||||
* To retrieve the single name of this section, that is, the final part of
|
||||
* the path returned by this method, you may use {@link #getName()}.
|
||||
*
|
||||
* <p>If the section is no longer contained within its root for any reason,
|
||||
* such as being replaced with a different value,
|
||||
* this may return {@code null}.
|
||||
*
|
||||
* <p>To retrieve the single name of this section, that is, the final part
|
||||
* of the path returned by this method, you may use {@link #getName()}.
|
||||
*
|
||||
* @return Path of this section relative to its root
|
||||
*/
|
||||
@ -88,8 +89,8 @@ public interface ConfigurationSection {
|
||||
/**
|
||||
* Gets the name of this individual {@link ConfigurationSection}, in the
|
||||
* path.
|
||||
* <p>
|
||||
* This will always be the final part of {@link #getCurrentPath()}, unless
|
||||
*
|
||||
* <p>This will always be the final part of {@link #getCurrentPath()}, unless
|
||||
* the section is orphaned.
|
||||
*
|
||||
* @return Name of this section
|
||||
@ -99,12 +100,13 @@ public interface ConfigurationSection {
|
||||
/**
|
||||
* Gets the root {@link Configuration} that contains this {@link
|
||||
* ConfigurationSection}
|
||||
* <p>
|
||||
* For any {@link Configuration} themselves, this will return its own
|
||||
*
|
||||
* <p>For any {@link Configuration} themselves, this will return its own
|
||||
* object.
|
||||
* <p>
|
||||
* If the section is no longer contained within its root for any reason,
|
||||
* such as being replaced with a different value, this may return null.
|
||||
*
|
||||
* <p>If the section is no longer contained within its root for any reason,
|
||||
* such as being replaced with a different value,
|
||||
* this may return {@code null}.
|
||||
*
|
||||
* @return Root configuration containing this section.
|
||||
*/
|
||||
@ -113,11 +115,13 @@ public interface ConfigurationSection {
|
||||
/**
|
||||
* Gets the parent {@link ConfigurationSection} that directly contains
|
||||
* this {@link ConfigurationSection}.
|
||||
* <p>
|
||||
* For any {@link Configuration} themselves, this will return null.
|
||||
* <p>
|
||||
* If the section is no longer contained within its parent for any reason,
|
||||
* such as being replaced with a different value, this may return null.
|
||||
*
|
||||
* <p>For any {@link Configuration} themselves, this will return
|
||||
* {@code null}.
|
||||
*
|
||||
* <p>If the section is no longer contained within its parent for any
|
||||
* reason, such as being replaced with a different value, this may
|
||||
* return {@code null}.
|
||||
*
|
||||
* @return Parent section containing this section.
|
||||
*/
|
||||
@ -125,10 +129,10 @@ public interface ConfigurationSection {
|
||||
|
||||
/**
|
||||
* Gets the requested Object by path.
|
||||
* <p>
|
||||
* If the Object does not exist but a default value has been specified,
|
||||
*
|
||||
* <p>If the Object does not exist but a default value has been specified,
|
||||
* this will return the default value. If the Object does not exist and no
|
||||
* default value was specified, this will return null.
|
||||
* default value was specified, this will return {@code null}.
|
||||
*
|
||||
* @param path Path of the Object to get.
|
||||
* @return Requested Object.
|
||||
@ -138,8 +142,8 @@ public interface ConfigurationSection {
|
||||
/**
|
||||
* Gets the requested Object by path, returning a default value if not
|
||||
* found.
|
||||
* <p>
|
||||
* If the Object does not exist then the specified default value will
|
||||
*
|
||||
* <p>If the Object does not exist then the specified default value will
|
||||
* returned regardless of if a default has been identified in the root
|
||||
* {@link Configuration}.
|
||||
*
|
||||
@ -151,11 +155,11 @@ public interface ConfigurationSection {
|
||||
|
||||
/**
|
||||
* Sets the specified path to the given value.
|
||||
* <p>
|
||||
* If value is null, the entry will be removed. Any existing entry will be
|
||||
* replaced, regardless of what the new value is.
|
||||
* <p>
|
||||
* Some implementations may have limitations on what you may store. See
|
||||
*
|
||||
* <p>If value is {@code null}, the entry will be removed. Any
|
||||
* existing entry will be replaced, regardless of what the new value is.
|
||||
*
|
||||
* <p>Some implementations may have limitations on what you may store. See
|
||||
* their individual javadoc for details. No implementations should allow
|
||||
* you to store {@link Configuration}s or {@link ConfigurationSection}s,
|
||||
* please use {@link #createSection(String)} for that.
|
||||
@ -167,8 +171,8 @@ public interface ConfigurationSection {
|
||||
|
||||
/**
|
||||
* Creates an empty {@link ConfigurationSection} at the specified path.
|
||||
* <p>
|
||||
* Any value that was previously set at this path will be overwritten. If
|
||||
*
|
||||
* <p>Any value that was previously set at this path will be overwritten. If
|
||||
* the previous value was itself a {@link ConfigurationSection}, it will
|
||||
* be orphaned.
|
||||
*
|
||||
@ -180,8 +184,8 @@ public interface ConfigurationSection {
|
||||
/**
|
||||
* Creates a {@link ConfigurationSection} at the specified path, with
|
||||
* specified values.
|
||||
* <p>
|
||||
* Any value that was previously set at this path will be overwritten. If
|
||||
*
|
||||
* <p>Any value that was previously set at this path will be overwritten. If
|
||||
* the previous value was itself a {@link ConfigurationSection}, it will
|
||||
* be orphaned.
|
||||
*
|
||||
@ -195,10 +199,10 @@ public interface ConfigurationSection {
|
||||
|
||||
/**
|
||||
* Gets the requested String by path.
|
||||
* <p>
|
||||
* If the String does not exist but a default value has been specified,
|
||||
*
|
||||
* <p>If the String does not exist but a default value has been specified,
|
||||
* this will return the default value. If the String does not exist and no
|
||||
* default value was specified, this will return null.
|
||||
* default value was specified, this will return {@code null}.
|
||||
*
|
||||
* @param path Path of the String to get.
|
||||
* @return Requested String.
|
||||
@ -208,8 +212,8 @@ public interface ConfigurationSection {
|
||||
/**
|
||||
* Gets the requested String by path, returning a default value if not
|
||||
* found.
|
||||
* <p>
|
||||
* If the String does not exist then the specified default value will
|
||||
*
|
||||
* <p>If the String does not exist then the specified default value will
|
||||
* returned regardless of if a default has been identified in the root
|
||||
* {@link Configuration}.
|
||||
*
|
||||
@ -223,10 +227,10 @@ public interface ConfigurationSection {
|
||||
/**
|
||||
* Checks if the specified path is a String.
|
||||
*
|
||||
* <p> If the path exists but is not a String, this will return false. If the
|
||||
* path does not exist, this will return false. If the path does not exist
|
||||
* but a default value has been specified, this will check if that default
|
||||
* value is a String and return appropriately.</p>
|
||||
* <p>If the path exists but is not a String, this will return false. If
|
||||
* the path does not exist, this will return false. If the path does not
|
||||
* exist but a default value has been specified, this will check if that
|
||||
* defaultvalue is a String and return appropriately.
|
||||
*
|
||||
* @param path Path of the String to check.
|
||||
* @return Whether or not the specified path is a String.
|
||||
@ -238,7 +242,7 @@ public interface ConfigurationSection {
|
||||
*
|
||||
* <p>If the int does not exist but a default value has been specified, this
|
||||
* will return the default value. If the int does not exist and no default
|
||||
* value was specified, this will return 0.</p>
|
||||
* value was specified, this will return 0.
|
||||
*
|
||||
* @param path Path of the int to get.
|
||||
* @return Requested int.
|
||||
@ -250,7 +254,7 @@ public interface ConfigurationSection {
|
||||
*
|
||||
* <p>If the int does not exist then the specified default value will
|
||||
* returned regardless of if a default has been identified in the root
|
||||
* {@link Configuration}.</p>
|
||||
* {@link Configuration}.
|
||||
*
|
||||
* @param path Path of the int to get.
|
||||
* @param def The default value to return if the path is not found or is
|
||||
@ -265,7 +269,7 @@ public interface ConfigurationSection {
|
||||
* <p>If the path exists but is not a int, this will return false. If the
|
||||
* path does not exist, this will return false. If the path does not exist
|
||||
* but a default value has been specified, this will check if that default
|
||||
* value is a int and return appropriately.</p>
|
||||
* value is a int and return appropriately.
|
||||
*
|
||||
* @param path Path of the int to check.
|
||||
* @return Whether or not the specified path is an int.
|
||||
@ -274,8 +278,8 @@ public interface ConfigurationSection {
|
||||
|
||||
/**
|
||||
* Gets the requested boolean by path.
|
||||
* <p>
|
||||
* If the boolean does not exist but a default value has been specified,
|
||||
*
|
||||
* <p>If the boolean does not exist but a default value has been specified,
|
||||
* this will return the default value. If the boolean does not exist and
|
||||
* no default value was specified, this will return false.
|
||||
*
|
||||
@ -287,8 +291,8 @@ public interface ConfigurationSection {
|
||||
/**
|
||||
* Gets the requested boolean by path, returning a default value if not
|
||||
* found.
|
||||
* <p>
|
||||
* If the boolean does not exist then the specified default value will
|
||||
*
|
||||
* <p>If the boolean does not exist then the specified default value will
|
||||
* returned regardless of if a default has been identified in the root
|
||||
* {@link Configuration}.
|
||||
*
|
||||
@ -301,8 +305,8 @@ public interface ConfigurationSection {
|
||||
|
||||
/**
|
||||
* Checks if the specified path is a boolean.
|
||||
* <p>
|
||||
* If the path exists but is not a boolean, this will return false. If the
|
||||
*
|
||||
* <p>If the path exists but is not a boolean, this will return false. If the
|
||||
* path does not exist, this will return false. If the path does not exist
|
||||
* but a default value has been specified, this will check if that default
|
||||
* value is a boolean and return appropriately.
|
||||
@ -314,8 +318,8 @@ public interface ConfigurationSection {
|
||||
|
||||
/**
|
||||
* Gets the requested double by path.
|
||||
* <p>
|
||||
* If the double does not exist but a default value has been specified,
|
||||
*
|
||||
* <p>If the double does not exist but a default value has been specified,
|
||||
* this will return the default value. If the double does not exist and no
|
||||
* default value was specified, this will return 0.
|
||||
*
|
||||
@ -327,8 +331,8 @@ public interface ConfigurationSection {
|
||||
/**
|
||||
* Gets the requested double by path, returning a default value if not
|
||||
* found.
|
||||
* <p>
|
||||
* If the double does not exist then the specified default value will
|
||||
*
|
||||
* <p>If the double does not exist then the specified default value will
|
||||
* returned regardless of if a default has been identified in the root
|
||||
* {@link Configuration}.
|
||||
*
|
||||
@ -341,8 +345,8 @@ public interface ConfigurationSection {
|
||||
|
||||
/**
|
||||
* Checks if the specified path is a double.
|
||||
* <p>
|
||||
* If the path exists but is not a double, this will return false. If the
|
||||
*
|
||||
* <p>If the path exists but is not a double, this will return false. If the
|
||||
* path does not exist, this will return false. If the path does not exist
|
||||
* but a default value has been specified, this will check if that default
|
||||
* value is a double and return appropriately.
|
||||
@ -354,8 +358,8 @@ public interface ConfigurationSection {
|
||||
|
||||
/**
|
||||
* Gets the requested long by path.
|
||||
* <p>
|
||||
* If the long does not exist but a default value has been specified, this
|
||||
*
|
||||
* <p>If the long does not exist but a default value has been specified, this
|
||||
* will return the default value. If the long does not exist and no
|
||||
* default value was specified, this will return 0.
|
||||
*
|
||||
@ -367,8 +371,8 @@ public interface ConfigurationSection {
|
||||
/**
|
||||
* Gets the requested long by path, returning a default value if not
|
||||
* found.
|
||||
* <p>
|
||||
* If the long does not exist then the specified default value will
|
||||
*
|
||||
* <p>If the long does not exist then the specified default value will
|
||||
* returned regardless of if a default has been identified in the root
|
||||
* {@link Configuration}.
|
||||
*
|
||||
@ -381,8 +385,8 @@ public interface ConfigurationSection {
|
||||
|
||||
/**
|
||||
* Checks if the specified path is a long.
|
||||
* <p>
|
||||
* If the path exists but is not a long, this will return false. If the
|
||||
*
|
||||
* <p>If the path exists but is not a long, this will return false. If the
|
||||
* path does not exist, this will return false. If the path does not exist
|
||||
* but a default value has been specified, this will check if that default
|
||||
* value is a long and return appropriately.
|
||||
@ -396,8 +400,8 @@ public interface ConfigurationSection {
|
||||
|
||||
/**
|
||||
* Gets the requested List by path.
|
||||
* <p>
|
||||
* If the List does not exist but a default value has been specified, this
|
||||
*
|
||||
* <p>If the List does not exist but a default value has been specified, this
|
||||
* will return the default value. If the List does not exist and no
|
||||
* default value was specified, this will return null.
|
||||
*
|
||||
@ -409,8 +413,8 @@ public interface ConfigurationSection {
|
||||
/**
|
||||
* Gets the requested List by path, returning a default value if not
|
||||
* found.
|
||||
* <p>
|
||||
* If the List does not exist then the specified default value will
|
||||
*
|
||||
* <p>If the List does not exist then the specified default value will
|
||||
* returned regardless of if a default has been identified in the root
|
||||
* {@link Configuration}.
|
||||
*
|
||||
@ -423,8 +427,8 @@ public interface ConfigurationSection {
|
||||
|
||||
/**
|
||||
* Checks if the specified path is a List.
|
||||
* <p>
|
||||
* If the path exists but is not a List, this will return false. If the
|
||||
*
|
||||
* <p>If the path exists but is not a List, this will return false. If the
|
||||
* path does not exist, this will return false. If the path does not exist
|
||||
* but a default value has been specified, this will check if that default
|
||||
* value is a List and return appropriately.
|
||||
@ -436,12 +440,12 @@ public interface ConfigurationSection {
|
||||
|
||||
/**
|
||||
* Gets the requested List of String by path.
|
||||
* <p>
|
||||
* If the List does not exist but a default value has been specified, this
|
||||
* will return the default value. If the List does not exist and no
|
||||
*
|
||||
* <p>If the List does not exist but a default value has been specified,
|
||||
* this will return the default value. If the List does not exist and no
|
||||
* default value was specified, this will return an empty List.
|
||||
* <p>
|
||||
* This method will attempt to cast any values into a String if possible,
|
||||
*
|
||||
* <p>This method will attempt to cast any values into a String if possible,
|
||||
* but may miss any values out if they are not compatible.
|
||||
*
|
||||
* @param path Path of the List to get.
|
||||
@ -451,13 +455,13 @@ public interface ConfigurationSection {
|
||||
|
||||
/**
|
||||
* Gets the requested List of Integer by path.
|
||||
* <p>
|
||||
* If the List does not exist but a default value has been specified, this
|
||||
* will return the default value. If the List does not exist and no
|
||||
*
|
||||
* <p>If the List does not exist but a default value has been specified,
|
||||
* this will return the default value. If the List does not exist and no
|
||||
* default value was specified, this will return an empty List.
|
||||
* <p>
|
||||
* This method will attempt to cast any values into a Integer if possible,
|
||||
* but may miss any values out if they are not compatible.
|
||||
*
|
||||
* <p>This method will attempt to cast any values into a Integer if
|
||||
* possible, but may miss any values out if they are not compatible.
|
||||
*
|
||||
* @param path Path of the List to get.
|
||||
* @return Requested List of Integer.
|
||||
@ -466,13 +470,13 @@ public interface ConfigurationSection {
|
||||
|
||||
/**
|
||||
* Gets the requested List of Boolean by path.
|
||||
* <p>
|
||||
* If the List does not exist but a default value has been specified, this
|
||||
* will return the default value. If the List does not exist and no
|
||||
*
|
||||
* <p>If the List does not exist but a default value has been specified,
|
||||
* this will return the default value. If the List does not exist and no
|
||||
* default value was specified, this will return an empty List.
|
||||
* <p>
|
||||
* This method will attempt to cast any values into a Boolean if possible,
|
||||
* but may miss any values out if they are not compatible.
|
||||
*
|
||||
* <p>This method will attempt to cast any values into a Boolean if
|
||||
* possible, but may miss any values out if they are not compatible.
|
||||
*
|
||||
* @param path Path of the List to get.
|
||||
* @return Requested List of Boolean.
|
||||
@ -481,12 +485,12 @@ public interface ConfigurationSection {
|
||||
|
||||
/**
|
||||
* Gets the requested List of Double by path.
|
||||
* <p>
|
||||
* If the List does not exist but a default value has been specified, this
|
||||
* will return the default value. If the List does not exist and no
|
||||
*
|
||||
* <p>If the List does not exist but a default value has been specified,
|
||||
* this will return the default value. If the List does not exist and no
|
||||
* default value was specified, this will return an empty List.
|
||||
* <p>
|
||||
* This method will attempt to cast any values into a Double if possible,
|
||||
*
|
||||
* <p>This method will attempt to cast any values into a Double if possible,
|
||||
* but may miss any values out if they are not compatible.
|
||||
*
|
||||
* @param path Path of the List to get.
|
||||
@ -496,12 +500,12 @@ public interface ConfigurationSection {
|
||||
|
||||
/**
|
||||
* Gets the requested List of Float by path.
|
||||
* <p>
|
||||
* If the List does not exist but a default value has been specified, this
|
||||
* will return the default value. If the List does not exist and no
|
||||
*
|
||||
* <p>If the List does not exist but a default value has been specified,
|
||||
* this will return the default value. If the List does not exist and no
|
||||
* default value was specified, this will return an empty List.
|
||||
* <p>
|
||||
* This method will attempt to cast any values into a Float if possible,
|
||||
*
|
||||
* <p>This method will attempt to cast any values into a Float if possible,
|
||||
* but may miss any values out if they are not compatible.
|
||||
*
|
||||
* @param path Path of the List to get.
|
||||
@ -511,12 +515,12 @@ public interface ConfigurationSection {
|
||||
|
||||
/**
|
||||
* Gets the requested List of Long by path.
|
||||
* <p>
|
||||
* If the List does not exist but a default value has been specified, this
|
||||
* will return the default value. If the List does not exist and no
|
||||
*
|
||||
* <p>If the List does not exist but a default value has been specified,
|
||||
* this will return the default value. If the List does not exist and no
|
||||
* default value was specified, this will return an empty List.
|
||||
* <p>
|
||||
* This method will attempt to cast any values into a Long if possible,
|
||||
*
|
||||
* <p>This method will attempt to cast any values into a Long if possible,
|
||||
* but may miss any values out if they are not compatible.
|
||||
*
|
||||
* @param path Path of the List to get.
|
||||
@ -526,12 +530,12 @@ public interface ConfigurationSection {
|
||||
|
||||
/**
|
||||
* Gets the requested List of Byte by path.
|
||||
* <p>
|
||||
* If the List does not exist but a default value has been specified, this
|
||||
* will return the default value. If the List does not exist and no
|
||||
*
|
||||
* <p>If the List does not exist but a default value has been specified,
|
||||
* this will return the default value. If the List does not exist and no
|
||||
* default value was specified, this will return an empty List.
|
||||
* <p>
|
||||
* This method will attempt to cast any values into a Byte if possible,
|
||||
*
|
||||
* <p>This method will attempt to cast any values into a Byte if possible,
|
||||
* but may miss any values out if they are not compatible.
|
||||
*
|
||||
* @param path Path of the List to get.
|
||||
@ -541,12 +545,12 @@ public interface ConfigurationSection {
|
||||
|
||||
/**
|
||||
* Gets the requested List of Character by path.
|
||||
* <p>
|
||||
* If the List does not exist but a default value has been specified, this
|
||||
* will return the default value. If the List does not exist and no
|
||||
*
|
||||
* <p>If the List does not exist but a default value has been specified,
|
||||
* this will return the default value. If the List does not exist and no
|
||||
* default value was specified, this will return an empty List.
|
||||
* <p>
|
||||
* This method will attempt to cast any values into a Character if
|
||||
*
|
||||
* <p>This method will attempt to cast any values into a Character if
|
||||
* possible, but may miss any values out if they are not compatible.
|
||||
*
|
||||
* @param path Path of the List to get.
|
||||
@ -556,13 +560,13 @@ public interface ConfigurationSection {
|
||||
|
||||
/**
|
||||
* Gets the requested List of Short by path.
|
||||
* <p>
|
||||
* If the List does not exist but a default value has been specified, this
|
||||
* will return the default value. If the List does not exist and no
|
||||
*
|
||||
* <p>If the List does not exist but a default value has been specified,
|
||||
* this will return the default value. If the List does not exist and no
|
||||
* default value was specified, this will return an empty List.
|
||||
* <p>
|
||||
* This method will attempt to cast any values into a Short if possible,
|
||||
* but may miss any values out if they are not compatible.
|
||||
*
|
||||
* <p>This method will attempt to cast any values into a Short if
|
||||
* possible, but may miss any values out if they are not compatible.
|
||||
*
|
||||
* @param path Path of the List to get.
|
||||
* @return Requested List of Short.
|
||||
@ -571,13 +575,12 @@ public interface ConfigurationSection {
|
||||
|
||||
/**
|
||||
* Gets the requested List of Maps by path.
|
||||
* <p>
|
||||
* If the List does not exist but a default value has been specified, this
|
||||
* will return the default value. If the List does not exist and no
|
||||
*
|
||||
* <p>If the List does not exist but a default value has been specified,
|
||||
* this will return the default value. If the List does not exist and no
|
||||
* default value was specified, this will return an empty List.
|
||||
* <p>
|
||||
* This method will attempt to cast any values into a Map if possible, but
|
||||
* may miss any values out if they are not compatible.
|
||||
* <p>This method will attempt to cast any values into a Map if possible,
|
||||
* but may miss any values out if they are not compatible.
|
||||
*
|
||||
* @param path Path of the List to get.
|
||||
* @return Requested List of Maps.
|
||||
@ -586,11 +589,11 @@ public interface ConfigurationSection {
|
||||
|
||||
/**
|
||||
* Gets the requested ConfigurationSection by path.
|
||||
* <p>
|
||||
* If the ConfigurationSection does not exist but a default value has been
|
||||
* specified, this will return the default value. If the
|
||||
*
|
||||
* <p>If the ConfigurationSection does not exist but a default value has
|
||||
* been specified, this will return the default value. If the
|
||||
* ConfigurationSection does not exist and no default value was specified,
|
||||
* this will return null.
|
||||
* this will return {@code null}.
|
||||
*
|
||||
* @param path Path of the ConfigurationSection to get.
|
||||
* @return Requested ConfigurationSection.
|
||||
@ -599,8 +602,8 @@ public interface ConfigurationSection {
|
||||
|
||||
/**
|
||||
* Checks if the specified path is a ConfigurationSection.
|
||||
* <p>
|
||||
* If the path exists but is not a ConfigurationSection, this will return
|
||||
*
|
||||
* <p>If the path exists but is not a ConfigurationSection, this will return
|
||||
* false. If the path does not exist, this will return false. If the path
|
||||
* does not exist but a default value has been specified, this will check
|
||||
* if that default value is a ConfigurationSection and return
|
||||
@ -614,10 +617,10 @@ public interface ConfigurationSection {
|
||||
/**
|
||||
* Gets the equivalent {@link ConfigurationSection} from the default
|
||||
* {@link Configuration} defined in {@link #getRoot()}.
|
||||
* <p>
|
||||
* If the root contains no defaults, or the defaults doesn't contain a
|
||||
*
|
||||
* <p>If the root contains no defaults, or the defaults doesn't contain a
|
||||
* value for this path, or the value at this path is not a {@link
|
||||
* ConfigurationSection} then this will return null.
|
||||
* ConfigurationSection} then this will return {@code null}.
|
||||
*
|
||||
* @return Equivalent section in root configuration
|
||||
*/
|
||||
@ -625,21 +628,21 @@ public interface ConfigurationSection {
|
||||
|
||||
/**
|
||||
* Sets the default value in the root at the given path as provided.
|
||||
* <p>
|
||||
* If no source {@link Configuration} was provided as a default
|
||||
*
|
||||
* <p>If no source {@link Configuration} was provided as a default
|
||||
* collection, then a new {@link MemoryConfiguration} will be created to
|
||||
* hold the new default value.
|
||||
* <p>
|
||||
* If value is null, the value will be removed from the default
|
||||
* Configuration source.
|
||||
* <p>
|
||||
* If the value as returned by {@link #getDefaultSection()} is null, then
|
||||
* this will create a new section at the path, replacing anything that may
|
||||
* have existed there previously.
|
||||
*
|
||||
* @param path Path of the value to set.
|
||||
* @param value Value to set the default to.
|
||||
* @throws IllegalArgumentException Thrown if path is null.
|
||||
* <p>If value is {@code null}, the value will be removed from the
|
||||
* default Configuration source.
|
||||
*
|
||||
* <p>If the value as returned by {@link #getDefaultSection()} is
|
||||
* {@code null}, then this will create a new section at the path,
|
||||
* replacing anything that may have existed there previously.
|
||||
*
|
||||
* @param path Path of the value to set
|
||||
* @param value Value to set the default to
|
||||
* @throws IllegalArgumentException Thrown if path is {@code null}
|
||||
*/
|
||||
void addDefault(String path, Object value);
|
||||
}
|
||||
|
@ -1,7 +1,7 @@
|
||||
package com.intellectualcrafters.configuration;
|
||||
|
||||
/**
|
||||
* Exception thrown when attempting to load an invalid {@link Configuration}
|
||||
* Exception thrown when attempting to load an invalid {@link Configuration}.
|
||||
*/
|
||||
@SuppressWarnings("serial")
|
||||
public class InvalidConfigurationException extends Exception {
|
||||
@ -18,7 +18,7 @@ public class InvalidConfigurationException extends Exception {
|
||||
*
|
||||
* @param msg The details of the exception.
|
||||
*/
|
||||
public InvalidConfigurationException(final String msg) {
|
||||
public InvalidConfigurationException(String msg) {
|
||||
super(msg);
|
||||
}
|
||||
|
||||
@ -28,7 +28,7 @@ public class InvalidConfigurationException extends Exception {
|
||||
*
|
||||
* @param cause The cause of the exception.
|
||||
*/
|
||||
public InvalidConfigurationException(final Throwable cause) {
|
||||
public InvalidConfigurationException(Throwable cause) {
|
||||
super(cause);
|
||||
}
|
||||
|
||||
@ -39,7 +39,7 @@ public class InvalidConfigurationException extends Exception {
|
||||
* @param cause The cause of the exception.
|
||||
* @param msg The details of the exception.
|
||||
*/
|
||||
public InvalidConfigurationException(final String msg, final Throwable cause) {
|
||||
public InvalidConfigurationException(String msg, Throwable cause) {
|
||||
super(msg, cause);
|
||||
}
|
||||
}
|
||||
|
@ -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));
|
||||
}
|
||||
|
||||
|
@ -2,10 +2,10 @@ package com.intellectualcrafters.configuration;
|
||||
|
||||
/**
|
||||
* Various settings for controlling the input and output of a {@link
|
||||
* MemoryConfiguration}
|
||||
* MemoryConfiguration}.
|
||||
*/
|
||||
public class MemoryConfigurationOptions extends ConfigurationOptions {
|
||||
protected MemoryConfigurationOptions(final MemoryConfiguration configuration) {
|
||||
protected MemoryConfigurationOptions(MemoryConfiguration configuration) {
|
||||
super(configuration);
|
||||
}
|
||||
|
||||
@ -15,13 +15,13 @@ public class MemoryConfigurationOptions extends ConfigurationOptions {
|
||||
}
|
||||
|
||||
@Override
|
||||
public MemoryConfigurationOptions copyDefaults(final boolean value) {
|
||||
public MemoryConfigurationOptions copyDefaults(boolean value) {
|
||||
super.copyDefaults(value);
|
||||
return this;
|
||||
}
|
||||
|
||||
@Override
|
||||
public MemoryConfigurationOptions pathSeparator(final char value) {
|
||||
public MemoryConfigurationOptions pathSeparator(char value) {
|
||||
super.pathSeparator(value);
|
||||
return this;
|
||||
}
|
||||
|
@ -21,8 +21,8 @@ public class MemorySection implements ConfigurationSection {
|
||||
/**
|
||||
* Creates an empty MemorySection for use as a root {@link Configuration}
|
||||
* section.
|
||||
* <p>
|
||||
* Note that calling this without being yourself a {@link Configuration}
|
||||
*
|
||||
* <p>Note that calling this without being yourself a {@link Configuration}
|
||||
* will throw an exception!
|
||||
*
|
||||
* @throws IllegalStateException Thrown if this is not a {@link
|
||||
@ -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();
|
||||
@ -74,7 +67,8 @@ public class MemorySection implements ConfigurationSection {
|
||||
if (obj instanceof String) {
|
||||
try {
|
||||
return Double.parseDouble((String) obj);
|
||||
} catch (NumberFormatException ignored) {}
|
||||
} catch (NumberFormatException ignored) {
|
||||
}
|
||||
} else if (obj instanceof List) {
|
||||
List<?> val = (List<?>) obj;
|
||||
if (!val.isEmpty()) {
|
||||
@ -91,7 +85,8 @@ public class MemorySection implements ConfigurationSection {
|
||||
if (obj instanceof String) {
|
||||
try {
|
||||
return Integer.parseInt((String) obj);
|
||||
} catch (NumberFormatException ignored) {}
|
||||
} catch (NumberFormatException ignored) {
|
||||
}
|
||||
} else if (obj instanceof List) {
|
||||
List<?> val = (List<?>) obj;
|
||||
if (!val.isEmpty()) {
|
||||
@ -108,7 +103,8 @@ public class MemorySection implements ConfigurationSection {
|
||||
if (obj instanceof String) {
|
||||
try {
|
||||
return Long.parseLong((String) obj);
|
||||
} catch (NumberFormatException ignored) {}
|
||||
} catch (NumberFormatException ignored) {
|
||||
}
|
||||
} else if (obj instanceof List) {
|
||||
List<?> val = (List<?>) obj;
|
||||
if (!val.isEmpty()) {
|
||||
@ -121,8 +117,8 @@ public class MemorySection implements ConfigurationSection {
|
||||
/**
|
||||
* Creates a full path to the given {@link ConfigurationSection} from its
|
||||
* root {@link Configuration}.
|
||||
* <p>
|
||||
* You may use this method for any given {@link ConfigurationSection}, not
|
||||
*
|
||||
* <p>You may use this method for any given {@link ConfigurationSection}, not
|
||||
* only {@link MemorySection}.
|
||||
*
|
||||
* @param section Section to create a path for.
|
||||
@ -130,14 +126,14 @@ 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());
|
||||
}
|
||||
|
||||
/**
|
||||
* Creates a relative path to the given {@link ConfigurationSection} from
|
||||
* the given relative section.
|
||||
* <p>
|
||||
* You may use this method for any given {@link ConfigurationSection}, not
|
||||
*
|
||||
* <p>You may use this method for any given {@link ConfigurationSection}, not
|
||||
* only {@link MemorySection}.
|
||||
*
|
||||
* @param section Section to create a path for.
|
||||
@ -146,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");
|
||||
@ -250,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");
|
||||
@ -280,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");
|
||||
@ -292,7 +277,8 @@ public class MemorySection implements ConfigurationSection {
|
||||
char separator = root.options().pathSeparator();
|
||||
// i1 is the leading (higher) index
|
||||
// i2 is the trailing (lower) index
|
||||
int i1 = -1, i2;
|
||||
int i1 = -1;
|
||||
int i2;
|
||||
ConfigurationSection section = this;
|
||||
while ((i1 = path.indexOf(separator, i2 = i1 + 1)) != -1) {
|
||||
String node = path.substring(i2, i1);
|
||||
@ -363,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");
|
||||
@ -374,7 +357,8 @@ public class MemorySection implements ConfigurationSection {
|
||||
char separator = root.options().pathSeparator();
|
||||
// i1 is the leading (higher) index
|
||||
// i2 is the trailing (lower) index
|
||||
int i1 = -1, i2;
|
||||
int i1 = -1;
|
||||
int i2;
|
||||
ConfigurationSection section = this;
|
||||
while ((i1 = path.indexOf(separator, i2 = i1 + 1)) != -1) {
|
||||
String node = path.substring(i2, i1);
|
||||
@ -563,7 +547,8 @@ public class MemorySection implements ConfigurationSection {
|
||||
} else if (object instanceof String) {
|
||||
try {
|
||||
result.add(Integer.valueOf((String) object));
|
||||
} catch (NumberFormatException ignored) {}
|
||||
} catch (NumberFormatException ignored) {
|
||||
}
|
||||
} else if (object instanceof Character) {
|
||||
result.add((int) (Character) object);
|
||||
} else if (object instanceof Number) {
|
||||
@ -607,7 +592,8 @@ public class MemorySection implements ConfigurationSection {
|
||||
} else if (object instanceof String) {
|
||||
try {
|
||||
result.add(Double.valueOf((String) object));
|
||||
} catch (NumberFormatException ignored) {}
|
||||
} catch (NumberFormatException ignored) {
|
||||
}
|
||||
} else if (object instanceof Character) {
|
||||
result.add((double) (Character) object);
|
||||
} else if (object instanceof Number) {
|
||||
@ -630,7 +616,8 @@ public class MemorySection implements ConfigurationSection {
|
||||
} else if (object instanceof String) {
|
||||
try {
|
||||
result.add(Float.valueOf((String) object));
|
||||
} catch (NumberFormatException ignored) {}
|
||||
} catch (NumberFormatException ignored) {
|
||||
}
|
||||
} else if (object instanceof Character) {
|
||||
result.add((float) (Character) object);
|
||||
} else if (object instanceof Number) {
|
||||
@ -653,7 +640,8 @@ public class MemorySection implements ConfigurationSection {
|
||||
} else if (object instanceof String) {
|
||||
try {
|
||||
result.add(Long.valueOf((String) object));
|
||||
} catch (NumberFormatException ignored) {}
|
||||
} catch (NumberFormatException ignored) {
|
||||
}
|
||||
} else if (object instanceof Character) {
|
||||
result.add((long) (Character) object);
|
||||
} else if (object instanceof Number) {
|
||||
@ -676,7 +664,8 @@ public class MemorySection implements ConfigurationSection {
|
||||
} else if (object instanceof String) {
|
||||
try {
|
||||
result.add(Byte.valueOf((String) object));
|
||||
} catch (NumberFormatException ignored) {}
|
||||
} catch (NumberFormatException ignored) {
|
||||
}
|
||||
} else if (object instanceof Character) {
|
||||
result.add((byte) ((Character) object).charValue());
|
||||
} else if (object instanceof Number) {
|
||||
@ -722,7 +711,8 @@ public class MemorySection implements ConfigurationSection {
|
||||
} else if (object instanceof String) {
|
||||
try {
|
||||
result.add(Short.valueOf((String) object));
|
||||
} catch (NumberFormatException ignored) {}
|
||||
} catch (NumberFormatException ignored) {
|
||||
}
|
||||
} else if (object instanceof Character) {
|
||||
result.add((short) ((Character) object).charValue());
|
||||
} else if (object instanceof Number) {
|
||||
@ -776,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));
|
||||
@ -831,7 +817,10 @@ public class MemorySection implements ConfigurationSection {
|
||||
@Override
|
||||
public String toString() {
|
||||
Configuration root = getRoot();
|
||||
return getClass().getSimpleName() + "[path='" + getCurrentPath() + "', root='" + (root == null ? null : root.getClass().getSimpleName()) +
|
||||
"']";
|
||||
if (root == null) {
|
||||
return getClass().getSimpleName() + "[path='" + getCurrentPath() + "', root='" + null + "']";
|
||||
} else {
|
||||
return getClass().getSimpleName() + "[path='" + getCurrentPath() + "', root='" + root.getClass().getSimpleName() + "']";
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -18,7 +18,7 @@ import java.nio.charset.StandardCharsets;
|
||||
|
||||
/**
|
||||
* This is a base class for all File based implementations of {@link
|
||||
* Configuration}
|
||||
* Configuration}.
|
||||
*/
|
||||
public abstract class FileConfiguration extends MemoryConfiguration {
|
||||
|
||||
@ -39,21 +39,23 @@ public abstract class FileConfiguration extends MemoryConfiguration {
|
||||
|
||||
/**
|
||||
* Saves this {@link FileConfiguration} to the specified location.
|
||||
* <p>
|
||||
* If the file does not exist, it will be created. If already exists, it
|
||||
*
|
||||
* <p>If the file does not exist, it will be created. If already exists, it
|
||||
* will be overwritten. If it cannot be overwritten or created, an
|
||||
* exception will be thrown.
|
||||
* <p>
|
||||
* This method will save using the system default encoding, or possibly
|
||||
*
|
||||
* <p>This method will save using the system default encoding, or possibly
|
||||
* using UTF8.
|
||||
*
|
||||
* @param file File to save to.
|
||||
* @throws IOException Thrown when the given file cannot be written to for
|
||||
* any reason.
|
||||
* @throws IllegalArgumentException Thrown when file is null.
|
||||
*/
|
||||
public void save(File file) throws IOException {
|
||||
file.getParentFile().mkdirs();
|
||||
File parent = file.getParentFile();
|
||||
if (parent != null) {
|
||||
parent.mkdirs();
|
||||
}
|
||||
|
||||
String data = saveToString();
|
||||
|
||||
@ -71,14 +73,13 @@ public abstract class FileConfiguration extends MemoryConfiguration {
|
||||
|
||||
/**
|
||||
* Loads this {@link FileConfiguration} from the specified location.
|
||||
* <p>
|
||||
* All the values contained within this configuration will be removed,
|
||||
*
|
||||
* <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
|
||||
*
|
||||
* <p>If the file cannot be loaded for any reason, an exception will be
|
||||
* thrown.
|
||||
* <p>
|
||||
*
|
||||
* @param file File to load from.
|
||||
* @throws FileNotFoundException Thrown when the given file cannot be
|
||||
@ -89,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);
|
||||
|
||||
@ -100,8 +98,8 @@ public abstract class FileConfiguration extends MemoryConfiguration {
|
||||
|
||||
/**
|
||||
* Loads this {@link FileConfiguration} from the specified reader.
|
||||
* <p>
|
||||
* All the values contained within this configuration will be removed,
|
||||
*
|
||||
* <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 stream.
|
||||
*
|
||||
@ -109,7 +107,6 @@ public abstract class FileConfiguration extends MemoryConfiguration {
|
||||
* @throws IOException thrown when underlying reader throws an IOException
|
||||
* @throws InvalidConfigurationException thrown when the reader does not
|
||||
* represent a valid Configuration
|
||||
* @throws IllegalArgumentException thrown when reader is null
|
||||
*/
|
||||
public void load(Reader reader) throws IOException, InvalidConfigurationException {
|
||||
|
||||
@ -127,54 +124,27 @@ 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.
|
||||
* <p>
|
||||
* All the values contained within this configuration will be removed,
|
||||
*
|
||||
* <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 string.
|
||||
* <p>
|
||||
* If the string is invalid in any way, an exception will be thrown.
|
||||
*
|
||||
* <p>If the string is invalid in any way, an exception will be thrown.
|
||||
*
|
||||
* @param contents Contents of a Configuration to load.
|
||||
* @throws InvalidConfigurationException Thrown if the specified string is
|
||||
* invalid.
|
||||
* @throws IllegalArgumentException Thrown if contents is null.
|
||||
*/
|
||||
public abstract void loadFromString(String contents) throws InvalidConfigurationException;
|
||||
|
||||
/**
|
||||
* Compiles the header for this {@link FileConfiguration} and returns the
|
||||
* result.
|
||||
* <p>
|
||||
* This will use the header from {@link #options()} -> {@link
|
||||
*
|
||||
* <p>This will use the header from {@link #options()} -> {@link
|
||||
* FileConfigurationOptions#header()}, respecting the rules of {@link
|
||||
* FileConfigurationOptions#copyHeader()} if set.
|
||||
*
|
||||
|
@ -6,13 +6,13 @@ import com.intellectualcrafters.configuration.MemoryConfigurationOptions;
|
||||
|
||||
/**
|
||||
* Various settings for controlling the input and output of a {@link
|
||||
* FileConfiguration}
|
||||
* FileConfiguration}.
|
||||
*/
|
||||
public class FileConfigurationOptions extends MemoryConfigurationOptions {
|
||||
private String header = null;
|
||||
private boolean copyHeader = true;
|
||||
|
||||
protected FileConfigurationOptions(final MemoryConfiguration configuration) {
|
||||
protected FileConfigurationOptions(MemoryConfiguration configuration) {
|
||||
super(configuration);
|
||||
}
|
||||
|
||||
@ -22,28 +22,28 @@ public class FileConfigurationOptions extends MemoryConfigurationOptions {
|
||||
}
|
||||
|
||||
@Override
|
||||
public FileConfigurationOptions copyDefaults(final boolean value) {
|
||||
public FileConfigurationOptions copyDefaults(boolean value) {
|
||||
super.copyDefaults(value);
|
||||
return this;
|
||||
}
|
||||
|
||||
@Override
|
||||
public FileConfigurationOptions pathSeparator(final char value) {
|
||||
public FileConfigurationOptions pathSeparator(char value) {
|
||||
super.pathSeparator(value);
|
||||
return this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the header that will be applied to the top of the saved output.
|
||||
* <p>
|
||||
* This header will be commented out and applied directly at the top of
|
||||
*
|
||||
* <p>This header will be commented out and applied directly at the top of
|
||||
* the generated output of the {@link FileConfiguration}. It is not
|
||||
* required to include a newline at the end of the header as it will
|
||||
* automatically be applied, but you may include one if you wish for extra
|
||||
* spacing.
|
||||
* <p>
|
||||
* Null is a valid value which will indicate that no header is to be
|
||||
* applied. The default value is null.
|
||||
*
|
||||
* <p>{@code null} is a valid value which will indicate that no header]
|
||||
* is to be applied. The default value is {@code null}.
|
||||
*
|
||||
* @return Header
|
||||
*/
|
||||
@ -53,39 +53,38 @@ public class FileConfigurationOptions extends MemoryConfigurationOptions {
|
||||
|
||||
/**
|
||||
* Sets the header that will be applied to the top of the saved output.
|
||||
* <p>
|
||||
* This header will be commented out and applied directly at the top of
|
||||
*
|
||||
* <p>This header will be commented out and applied directly at the top of
|
||||
* the generated output of the {@link FileConfiguration}. It is not
|
||||
* required to include a newline at the end of the header as it will
|
||||
* automatically be applied, but you may include one if you wish for extra
|
||||
* spacing.
|
||||
* <p>
|
||||
* Null is a valid value which will indicate that no header is to be
|
||||
* applied.
|
||||
*
|
||||
* <p>{@code null} is a valid value which will indicate that no header
|
||||
* is to be applied.
|
||||
*
|
||||
* @param value New header
|
||||
* @return This object, for chaining
|
||||
*/
|
||||
public FileConfigurationOptions header(final String value) {
|
||||
public FileConfigurationOptions header(String value) {
|
||||
header = value;
|
||||
return this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets whether or not the header should be copied from a default source.
|
||||
* <p>
|
||||
* If this is true, if a default {@link FileConfiguration} is passed to
|
||||
* {@link
|
||||
* FileConfiguration#setDefaults(Configuration)}
|
||||
*
|
||||
* <p>If this is true, if a default {@link FileConfiguration} is passed to
|
||||
* {@link FileConfiguration#setDefaults(Configuration)}
|
||||
* then upon saving it will use the header from that config, instead of
|
||||
* the one provided here.
|
||||
* <p>
|
||||
* If no default is set on the configuration, or the default is not of
|
||||
*
|
||||
* <p>If no default is set on the configuration, or the default is not of
|
||||
* type FileConfiguration, or that config has no header ({@link #header()}
|
||||
* returns null) then the header specified in this configuration will be
|
||||
* used.
|
||||
* <p>
|
||||
* Defaults to true.
|
||||
*
|
||||
* <p>Defaults to true.
|
||||
*
|
||||
* @return Whether or not to copy the header
|
||||
*/
|
||||
@ -95,24 +94,23 @@ public class FileConfigurationOptions extends MemoryConfigurationOptions {
|
||||
|
||||
/**
|
||||
* Sets whether or not the header should be copied from a default source.
|
||||
* <p>
|
||||
* If this is true, if a default {@link FileConfiguration} is passed to
|
||||
* {@link
|
||||
* FileConfiguration#setDefaults(Configuration)}
|
||||
*
|
||||
* <p>If this is true, if a default {@link FileConfiguration} is passed to
|
||||
* {@link FileConfiguration#setDefaults(Configuration)}
|
||||
* then upon saving it will use the header from that config, instead of
|
||||
* the one provided here.
|
||||
* <p>
|
||||
* If no default is set on the configuration, or the default is not of
|
||||
*
|
||||
* <p>If no default is set on the configuration, or the default is not of
|
||||
* type FileConfiguration, or that config has no header ({@link #header()}
|
||||
* returns null) then the header specified in this configuration will be
|
||||
* used.
|
||||
* <p>
|
||||
* Defaults to true.
|
||||
*
|
||||
* <p>Defaults to true.
|
||||
*
|
||||
* @param value Whether or not to copy the header
|
||||
* @return This object, for chaining
|
||||
*/
|
||||
public FileConfigurationOptions copyHeader(final boolean value) {
|
||||
public FileConfigurationOptions copyHeader(boolean value) {
|
||||
copyHeader = value;
|
||||
|
||||
return this;
|
||||
|
@ -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;
|
||||
@ -29,23 +28,18 @@ public class YamlConfiguration extends FileConfiguration {
|
||||
|
||||
/**
|
||||
* Creates a new {@link YamlConfiguration}, loading from the given file.
|
||||
* <p>
|
||||
* Any errors loading the Configuration will be logged and then ignored.
|
||||
*
|
||||
* <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.
|
||||
* <p>
|
||||
* The encoding used may follow the system dependent default.
|
||||
*
|
||||
* <p>The encoding used may follow the system dependent default.
|
||||
*
|
||||
* @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");
|
||||
}
|
||||
|
||||
final YamlConfiguration config = new YamlConfiguration();
|
||||
YamlConfiguration config = new YamlConfiguration();
|
||||
|
||||
try {
|
||||
config.load(file);
|
||||
@ -62,7 +56,7 @@ public class YamlConfiguration extends FileConfiguration {
|
||||
PS.debug("&c============ Full stacktrace ============");
|
||||
ex.printStackTrace();
|
||||
PS.debug("&c=========================================");
|
||||
} catch (final IOException e) {
|
||||
} catch (IOException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
@ -70,41 +64,13 @@ 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(final Reader reader) {
|
||||
if (reader == null) {
|
||||
throw new NullPointerException("Reader cannot be null");
|
||||
}
|
||||
|
||||
final YamlConfiguration config = new YamlConfiguration();
|
||||
|
||||
try {
|
||||
config.load(reader);
|
||||
} catch (final IOException | InvalidConfigurationException ex) {
|
||||
PS.debug("Cannot load configuration from stream");
|
||||
ex.printStackTrace();
|
||||
}
|
||||
|
||||
return config;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String saveToString() {
|
||||
yamlOptions.setIndent(options().indent());
|
||||
yamlOptions.setDefaultFlowStyle(DumperOptions.FlowStyle.BLOCK);
|
||||
yamlRepresenter.setDefaultFlowStyle(DumperOptions.FlowStyle.BLOCK);
|
||||
|
||||
final String header = buildHeader();
|
||||
String header = buildHeader();
|
||||
String dump = yaml.dump(getValues(false));
|
||||
|
||||
if (dump.equals(BLANK_CONFIG)) {
|
||||
@ -115,21 +81,18 @@ public class YamlConfiguration extends FileConfiguration {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void loadFromString(final String contents) throws InvalidConfigurationException {
|
||||
if (contents == null) {
|
||||
throw new NullPointerException("Contents cannot be null");
|
||||
}
|
||||
public void loadFromString(String contents) throws InvalidConfigurationException {
|
||||
|
||||
Map<?, ?> input;
|
||||
try {
|
||||
input = (Map<?, ?>) yaml.load(contents);
|
||||
} catch (final YAMLException e) {
|
||||
} catch (YAMLException e) {
|
||||
throw new InvalidConfigurationException(e);
|
||||
} catch (final ClassCastException ignored) {
|
||||
} catch (ClassCastException ignored) {
|
||||
throw new InvalidConfigurationException("Top level is not a Map.");
|
||||
}
|
||||
|
||||
final String header = parseHeader(contents);
|
||||
String header = parseHeader(contents);
|
||||
if (!header.isEmpty()) {
|
||||
options().header(header);
|
||||
}
|
||||
@ -139,10 +102,10 @@ public class YamlConfiguration extends FileConfiguration {
|
||||
}
|
||||
}
|
||||
|
||||
protected void convertMapsToSections(final Map<?, ?> input, final ConfigurationSection section) {
|
||||
for (final Map.Entry<?, ?> entry : input.entrySet()) {
|
||||
final String key = entry.getKey().toString();
|
||||
final Object value = entry.getValue();
|
||||
protected void convertMapsToSections(Map<?, ?> input, ConfigurationSection section) {
|
||||
for (Map.Entry<?, ?> entry : input.entrySet()) {
|
||||
String key = entry.getKey().toString();
|
||||
Object value = entry.getValue();
|
||||
|
||||
if (value instanceof Map) {
|
||||
convertMapsToSections((Map<?, ?>) value, section.createSection(key));
|
||||
@ -152,14 +115,14 @@ public class YamlConfiguration extends FileConfiguration {
|
||||
}
|
||||
}
|
||||
|
||||
protected String parseHeader(final String input) {
|
||||
final String[] lines = input.split("\r?\n", -1);
|
||||
final StringBuilder result = new StringBuilder();
|
||||
protected String parseHeader(String input) {
|
||||
String[] lines = input.split("\r?\n", -1);
|
||||
StringBuilder result = new StringBuilder();
|
||||
boolean readingHeader = true;
|
||||
boolean foundHeader = false;
|
||||
|
||||
for (int i = 0; (i < lines.length) && readingHeader; i++) {
|
||||
final String line = lines[i];
|
||||
String line = lines[i];
|
||||
|
||||
if (line.startsWith(COMMENT_PREFIX)) {
|
||||
if (i > 0) {
|
||||
@ -183,14 +146,14 @@ public class YamlConfiguration extends FileConfiguration {
|
||||
|
||||
@Override
|
||||
protected String buildHeader() {
|
||||
final String header = options().header();
|
||||
String header = options().header();
|
||||
|
||||
if (options().copyHeader()) {
|
||||
final Configuration def = getDefaults();
|
||||
Configuration def = getDefaults();
|
||||
|
||||
if (def instanceof FileConfiguration) {
|
||||
final FileConfiguration fileDefaults = (FileConfiguration) def;
|
||||
final String defaultsHeader = fileDefaults.buildHeader();
|
||||
FileConfiguration fileDefaults = (FileConfiguration) def;
|
||||
String defaultsHeader = fileDefaults.buildHeader();
|
||||
|
||||
if ((defaultsHeader != null) && !defaultsHeader.isEmpty()) {
|
||||
return defaultsHeader;
|
||||
@ -202,8 +165,8 @@ public class YamlConfiguration extends FileConfiguration {
|
||||
return "";
|
||||
}
|
||||
|
||||
final StringBuilder builder = new StringBuilder();
|
||||
final String[] lines = header.split("\r?\n", -1);
|
||||
StringBuilder builder = new StringBuilder();
|
||||
String[] lines = header.split("\r?\n", -1);
|
||||
boolean startedHeader = false;
|
||||
|
||||
for (int i = lines.length - 1; i >= 0; i--) {
|
||||
|
@ -2,12 +2,12 @@ package com.intellectualcrafters.configuration.file;
|
||||
|
||||
/**
|
||||
* Various settings for controlling the input and output of a {@link
|
||||
* YamlConfiguration}
|
||||
* YamlConfiguration}.
|
||||
*/
|
||||
public class YamlConfigurationOptions extends FileConfigurationOptions {
|
||||
private int indent = 2;
|
||||
|
||||
YamlConfigurationOptions(final YamlConfiguration configuration) {
|
||||
YamlConfigurationOptions(YamlConfiguration configuration) {
|
||||
super(configuration);
|
||||
}
|
||||
|
||||
@ -17,33 +17,33 @@ public class YamlConfigurationOptions extends FileConfigurationOptions {
|
||||
}
|
||||
|
||||
@Override
|
||||
public YamlConfigurationOptions copyDefaults(final boolean value) {
|
||||
public YamlConfigurationOptions copyDefaults(boolean value) {
|
||||
super.copyDefaults(value);
|
||||
return this;
|
||||
}
|
||||
|
||||
@Override
|
||||
public YamlConfigurationOptions pathSeparator(final char value) {
|
||||
public YamlConfigurationOptions pathSeparator(char value) {
|
||||
super.pathSeparator(value);
|
||||
return this;
|
||||
}
|
||||
|
||||
@Override
|
||||
public YamlConfigurationOptions header(final String value) {
|
||||
public YamlConfigurationOptions header(String value) {
|
||||
super.header(value);
|
||||
return this;
|
||||
}
|
||||
|
||||
@Override
|
||||
public YamlConfigurationOptions copyHeader(final boolean value) {
|
||||
public YamlConfigurationOptions copyHeader(boolean value) {
|
||||
super.copyHeader(value);
|
||||
return this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets how much spaces should be used to indent each line.
|
||||
* <p>
|
||||
* The minimum value this may be is 2, and the maximum is 9.
|
||||
*
|
||||
* <p>The minimum value this may be is 2, and the maximum is 9.
|
||||
*
|
||||
* @return How much to indent by
|
||||
*/
|
||||
@ -53,13 +53,13 @@ public class YamlConfigurationOptions extends FileConfigurationOptions {
|
||||
|
||||
/**
|
||||
* Sets how much spaces should be used to indent each line.
|
||||
* <p>
|
||||
* The minimum value this may be is 2, and the maximum is 9.
|
||||
*
|
||||
* <p>The minimum value this may be is 2, and the maximum is 9.
|
||||
*
|
||||
* @param value New indent
|
||||
* @return This object, for chaining
|
||||
*/
|
||||
public YamlConfigurationOptions indent(final int value) {
|
||||
public YamlConfigurationOptions indent(int value) {
|
||||
if (value < 2) {
|
||||
throw new IllegalArgumentException("Indent must be at least 2 characters");
|
||||
}
|
||||
|
@ -11,7 +11,7 @@ import java.util.Map;
|
||||
|
||||
class YamlRepresenter extends Representer {
|
||||
|
||||
public YamlRepresenter() {
|
||||
YamlRepresenter() {
|
||||
this.multiRepresenters.put(ConfigurationSection.class, new RepresentConfigurationSection());
|
||||
this.multiRepresenters.put(ConfigurationSerializable.class, new RepresentConfigurationSerializable());
|
||||
}
|
||||
|
@ -4,9 +4,8 @@ import java.util.Map;
|
||||
|
||||
/**
|
||||
* Represents an object that may be serialized.
|
||||
* <p>
|
||||
* These objects MUST implement one of the following, in addition to the
|
||||
* methods as defined by this interface:
|
||||
* <p>These objects MUST implement one of the following, in addition to
|
||||
* the methods as defined by this interface:
|
||||
* <ul>
|
||||
* <li>A static method "deserialize" that accepts a single {@link Map}<
|
||||
* {@link String}, {@link Object}> and returns the class.</li>
|
||||
@ -25,8 +24,8 @@ public interface ConfigurationSerializable {
|
||||
|
||||
/**
|
||||
* Creates a Map representation of this class.
|
||||
* <p>
|
||||
* This class must provide a method to restore this class, as defined in
|
||||
*
|
||||
* <p>This class must provide a method to restore this class, as defined in
|
||||
* the {@link ConfigurationSerializable} interface javadoc.
|
||||
*
|
||||
* @return Map containing the current state of this class
|
||||
|
@ -7,10 +7,11 @@ import java.io.OutputStream;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* <p> This class writes <strong>NBT</strong>, or <strong>Named Binary Tag</strong> <code>Tag</code> objects to an
|
||||
* underlying <code>OutputStream</code>. </p> <p> The NBT format was created by Markus Persson, and the
|
||||
* specification may be found at
|
||||
* @linktourl http://www.minecraft.net/docs/NBT.txt
|
||||
* This class writes <strong>NBT</strong>, or <strong>Named Binary Tag</strong>
|
||||
* {@code Tag} objects to an underlying {@code OutputStream}.
|
||||
*
|
||||
* <p> The NBT format was created by Markus Persson, and the specification may
|
||||
* be found at @linktourl http://www.minecraft.net/docs/NBT.txt
|
||||
* </p>
|
||||
*
|
||||
* @author Graham Edgecombe
|
||||
@ -23,7 +24,8 @@ public final class NBTOutputStream implements Closeable {
|
||||
private final DataOutputStream os;
|
||||
|
||||
/**
|
||||
* Creates a new <code>NBTOutputStream</code>, which will write data to the specified underlying output stream.
|
||||
* Creates a new {@code NBTOutputStream}, which will write data to the
|
||||
* specified underlying output stream.
|
||||
*
|
||||
* @param os The output stream.
|
||||
*
|
||||
@ -105,7 +107,7 @@ public final class NBTOutputStream implements Closeable {
|
||||
}
|
||||
|
||||
/**
|
||||
* Writes a <code>TAG_Byte</code> tag.
|
||||
* Writes a {@code TAG_Byte} tag.
|
||||
*
|
||||
* @param tag The tag.
|
||||
*
|
||||
@ -116,7 +118,7 @@ public final class NBTOutputStream implements Closeable {
|
||||
}
|
||||
|
||||
/**
|
||||
* Writes a <code>TAG_Byte_Array</code> tag.
|
||||
* Writes a {@code TAG_Byte_Array} tag.
|
||||
*
|
||||
* @param tag The tag.
|
||||
*
|
||||
@ -129,7 +131,7 @@ public final class NBTOutputStream implements Closeable {
|
||||
}
|
||||
|
||||
/**
|
||||
* Writes a <code>TAG_Compound</code> tag.
|
||||
* Writes a {@code TAG_Compound} tag.
|
||||
*
|
||||
* @param tag The tag.
|
||||
*
|
||||
@ -143,7 +145,7 @@ public final class NBTOutputStream implements Closeable {
|
||||
}
|
||||
|
||||
/**
|
||||
* Writes a <code>TAG_List</code> tag.
|
||||
* Writes a {@code TAG_List} tag.
|
||||
*
|
||||
* @param tag The tag.
|
||||
*
|
||||
@ -161,7 +163,7 @@ public final class NBTOutputStream implements Closeable {
|
||||
}
|
||||
|
||||
/**
|
||||
* Writes a <code>TAG_String</code> tag.
|
||||
* Writes a {@code TAG_String} tag.
|
||||
*
|
||||
* @param tag The tag.
|
||||
*
|
||||
@ -174,7 +176,7 @@ public final class NBTOutputStream implements Closeable {
|
||||
}
|
||||
|
||||
/**
|
||||
* Writes a <code>TAG_Double</code> tag.
|
||||
* Writes a {@code TAG_Double} tag.
|
||||
*
|
||||
* @param tag The tag.
|
||||
*
|
||||
@ -185,7 +187,7 @@ public final class NBTOutputStream implements Closeable {
|
||||
}
|
||||
|
||||
/**
|
||||
* Writes a <code>TAG_Float</code> tag.
|
||||
* Writes a {@code TAG_Float} tag.
|
||||
*
|
||||
* @param tag The tag.
|
||||
*
|
||||
@ -196,7 +198,7 @@ public final class NBTOutputStream implements Closeable {
|
||||
}
|
||||
|
||||
/**
|
||||
* Writes a <code>TAG_Long</code> tag.
|
||||
* Writes a {@code TAG_Long} tag.
|
||||
*
|
||||
* @param tag The tag.
|
||||
*
|
||||
@ -207,7 +209,7 @@ public final class NBTOutputStream implements Closeable {
|
||||
}
|
||||
|
||||
/**
|
||||
* Writes a <code>TAG_Int</code> tag.
|
||||
* Writes a {@code TAG_Int} tag.
|
||||
*
|
||||
* @param tag The tag.
|
||||
*
|
||||
@ -218,7 +220,7 @@ public final class NBTOutputStream implements Closeable {
|
||||
}
|
||||
|
||||
/**
|
||||
* Writes a <code>TAG_Short</code> tag.
|
||||
* Writes a {@code TAG_Short} tag.
|
||||
*
|
||||
* @param tag The tag.
|
||||
*
|
||||
@ -229,7 +231,7 @@ public final class NBTOutputStream implements Closeable {
|
||||
}
|
||||
|
||||
/**
|
||||
* Writes a <code>TAG_Empty</code> tag.
|
||||
* Writes a {@code TAG_Empty} tag.
|
||||
*
|
||||
* @param tag The tag.
|
||||
*/
|
||||
@ -251,7 +253,7 @@ public final class NBTOutputStream implements Closeable {
|
||||
}
|
||||
|
||||
/**
|
||||
* Flush output
|
||||
* Flush output.
|
||||
* @throws IOException
|
||||
*/
|
||||
public void flush() throws IOException {
|
||||
|
@ -107,9 +107,9 @@ public class Cookie {
|
||||
}
|
||||
|
||||
/**
|
||||
* Convert <code>%</code><i>hh</i> sequences to single characters, and convert plus to space.
|
||||
* Convert {@code %}<i>hh</i> sequences to single characters, and convert plus to space.
|
||||
*
|
||||
* @param string A string that may contain <code>+</code> <small>(plus)</small> and <code>%</code><i>hh</i>
|
||||
* @param string A string that may contain {@code +} <small>(plus)</small> and <code>%</code><i>hh</i>
|
||||
* sequences.
|
||||
*
|
||||
* @return The unescaped string.
|
||||
|
@ -10,28 +10,28 @@ import java.util.Map;
|
||||
|
||||
/**
|
||||
* A JSONArray is an ordered sequence of values. Its external text form is a string wrapped in square brackets with
|
||||
* commas separating the values. The internal form is an object having <code>get</code> and <code>opt</code> methods for
|
||||
* accessing the values by index, and <code>put</code> methods for adding or replacing values. The values can be any of
|
||||
* these types: <code>Boolean</code>, <code>JSONArray</code>, <code>JSONObject</code>, <code>Number</code>,
|
||||
* <code>String</code>, or the <code>JSONObject.NULL object</code>.
|
||||
* commas separating the values. The internal form is an object having {@code get} and {@code opt} methods for
|
||||
* accessing the values by index, and {@code put} methods for adding or replacing values. The values can be any of
|
||||
* these types: {@code Boolean}, {@code JSONArray}, {@code JSONObject}, {@code Number},
|
||||
* {@code String}, or the {@code JSONObject.NULL object}.
|
||||
*
|
||||
* The constructor can convert a JSON text into a Java object. The <code>toString</code> method converts to JSON text.
|
||||
* <p>The constructor can convert a JSON text into a Java object. The {@code toString} method converts to JSON text.
|
||||
*
|
||||
* A <code>get</code> method returns a value if one can be found, and throws an exception if one cannot be found. An
|
||||
* <code>opt</code> method returns a default value instead of throwing an exception, and so is useful for obtaining
|
||||
* <p>A {@code get} method returns a value if one can be found, and throws an exception if one cannot be found. An
|
||||
* {@code opt} method returns a default value instead of throwing an exception, and so is useful for obtaining
|
||||
* optional values.
|
||||
*
|
||||
* The generic <code>get()</code> and <code>opt()</code> methods return an object which you can cast or query for type.
|
||||
* There are also typed <code>get</code> and <code>opt</code> methods that do type checking and type coercion for you.
|
||||
* <p>The generic {@code get()} and {@code opt()} methods return an object which you can cast or query for type.
|
||||
* There are also typed {@code get} and {@code opt} methods that do type checking and type coercion for you.
|
||||
*
|
||||
* The texts produced by the <code>toString</code> methods strictly conform to JSON syntax rules. The constructors are
|
||||
* more forgiving in the texts they will accept: <ul> <li>An extra <code>,</code> <small>(comma)</small> may appear
|
||||
* just before the closing bracket.</li> <li>The <code>null</code> value will be inserted when there is <code>,</code>
|
||||
* <small>(comma)</small> elision.</li> <li>Strings may be quoted with <code>'</code> <small>(single
|
||||
* <p>The texts produced by the {@code toString} methods strictly conform to JSON syntax rules. The constructors are
|
||||
* more forgiving in the texts they will accept: <ul> <li>An extra {@code ,} <small>(comma)</small> may appear
|
||||
* just before the closing bracket.</li> <li>The {@code null} value will be inserted when there is {@code ,}
|
||||
* <small>(comma)</small> elision.</li> <li>Strings may be quoted with {@code '} <small>(single
|
||||
* quote)</small>.</li> <li>Strings do not need to be quoted at all if they do not begin with a quote or single quote,
|
||||
* and if they do not contain leading or trailing spaces, and if they do not contain any of these characters: <code>{ }
|
||||
* [ ] / \ : , #</code> and if they do not look like numbers and if they are not the reserved words <code>true</code>,
|
||||
* <code>false</code>, or <code>null</code>.</li> </ul>
|
||||
* and if they do not contain leading or trailing spaces, and if they do not contain any of these characters: {@code { }
|
||||
* [ ] / \ : , #} and if they do not look like numbers and if they are not the reserved words {@code true},
|
||||
* {@code false}, or {@code null}.</li> </ul>
|
||||
*
|
||||
* @author JSON.org
|
||||
* @version 2014-05-03
|
||||
@ -90,8 +90,8 @@ public class JSONArray {
|
||||
/**
|
||||
* Construct a JSONArray from a source JSON text.
|
||||
*
|
||||
* @param source A string that begins with <code>[</code> <small>(left bracket)</small> and ends with
|
||||
* <code>]</code> <small>(right bracket)</small>.
|
||||
* @param source A string that begins with {@code [} <small>(left bracket)</small> and ends with
|
||||
* {@code ]} <small>(right bracket)</small>.
|
||||
*
|
||||
* @throws JSONException If there is a syntax error.
|
||||
*/
|
||||
@ -283,7 +283,7 @@ public class JSONArray {
|
||||
}
|
||||
|
||||
/**
|
||||
* Make a string from the contents of this JSONArray. The <code>separator</code> string is inserted between each
|
||||
* Make a string from the contents of this JSONArray. The {@code separator} string is inserted between each
|
||||
* element. Warning: This method assumes that the data structure is acyclical.
|
||||
*
|
||||
* @param separator A string that will be inserted between the elements.
|
||||
@ -449,8 +449,9 @@ public class JSONArray {
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the optional long value associated with an index. The defaultValue is returned if there is no value for the
|
||||
* index, or if the value is not a number and cannot be converted to a number.
|
||||
* Get the optional long value associated with an index. The defaultValue
|
||||
* is returned if there is no value for the index, or if the value is not a
|
||||
* number and cannot be converted to a number.
|
||||
*
|
||||
* @param index The index must be between 0 and length() - 1.
|
||||
* @param defaultValue The default value.
|
||||
@ -466,8 +467,9 @@ public class JSONArray {
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the optional string value associated with an index. It returns an empty string if there is no value at that
|
||||
* index. If the value is not a string and is not null, then it is converted to a string.
|
||||
* Get the optional string value associated with an index. It returns an
|
||||
* empty string if there is no value at that index. If the value is not a
|
||||
* string and is not null, then it is converted to a string.
|
||||
*
|
||||
* @param index The index must be between 0 and length() - 1.
|
||||
*
|
||||
@ -478,7 +480,8 @@ public class JSONArray {
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the optional string associated with an index. The defaultValue is returned if the key is not found.
|
||||
* Get the optional string associated with an index. The defaultValue is
|
||||
* returned if the key is not found.
|
||||
*
|
||||
* @param index The index must be between 0 and length() - 1.
|
||||
* @param defaultValue The default value.
|
||||
@ -503,7 +506,8 @@ public class JSONArray {
|
||||
}
|
||||
|
||||
/**
|
||||
* Put a value in the JSONArray, where the value will be a JSONArray which is produced from a Collection.
|
||||
* Put a value in the JSONArray, where the value will be a JSONArray which
|
||||
* is produced from a Collection.
|
||||
*
|
||||
* @param value A Collection value.
|
||||
*
|
||||
@ -555,7 +559,8 @@ public class JSONArray {
|
||||
}
|
||||
|
||||
/**
|
||||
* Put a value in the JSONArray, where the value will be a JSONObject which is produced from a Map.
|
||||
* Put a value in the JSONArray, where the value will be a JSONObject which
|
||||
* is produced from a Map.
|
||||
*
|
||||
* @param value A Map value.
|
||||
*
|
||||
@ -569,8 +574,8 @@ public class JSONArray {
|
||||
/**
|
||||
* Append an object value. This increases the array's length by one.
|
||||
*
|
||||
* @param value An object value. The value should be a Boolean, Double, Integer, JSONArray, JSONObject, Long, or
|
||||
* String, or the JSONObject.NULL object.
|
||||
* @param value An object value. The value should be a Boolean, Double,
|
||||
* Integer, JSONArray, JSONObject, Long, or String, or the JSONObject.NULL object.
|
||||
*
|
||||
* @return this.
|
||||
*/
|
||||
@ -596,14 +601,16 @@ public class JSONArray {
|
||||
}
|
||||
|
||||
/**
|
||||
* Put a value in the JSONArray, where the value will be a JSONArray which is produced from a Collection.
|
||||
* Put a value in the JSONArray, where the value will be a JSONArray which
|
||||
* is produced from a Collection.
|
||||
*
|
||||
* @param index The subscript.
|
||||
* @param value A Collection value.
|
||||
*
|
||||
* @return this.
|
||||
*
|
||||
* @throws JSONException If the index is negative or if the value is not finite.
|
||||
* @throws JSONException If the index is negative or if the value is not
|
||||
* finite.
|
||||
*/
|
||||
public JSONArray put(int index, Collection<Object> value) throws JSONException {
|
||||
this.put(index, new JSONArray(value));
|
||||
@ -611,15 +618,17 @@ public class JSONArray {
|
||||
}
|
||||
|
||||
/**
|
||||
* Put or replace a double value. If the index is greater than the length of the JSONArray, then null elements will
|
||||
* be added as necessary to pad it out.
|
||||
* Put or replace a double value. If the index is greater than the length
|
||||
* of the JSONArray, then null elements will be added as necessary to pad
|
||||
* it out.
|
||||
*
|
||||
* @param index The subscript.
|
||||
* @param value A double value.
|
||||
*
|
||||
* @return this.
|
||||
*
|
||||
* @throws JSONException If the index is negative or if the value is not finite.
|
||||
* @throws JSONException If the index is negative or if the value is not
|
||||
* finite.
|
||||
*/
|
||||
public JSONArray put(int index, double value) throws JSONException {
|
||||
this.put(index, new Double(value));
|
||||
@ -659,14 +668,16 @@ public class JSONArray {
|
||||
}
|
||||
|
||||
/**
|
||||
* Put a value in the JSONArray, where the value will be a JSONObject that is produced from a Map.
|
||||
* Put a value in the JSONArray, where the value will be a JSONObject that
|
||||
* is produced from a Map.
|
||||
*
|
||||
* @param index The subscript.
|
||||
* @param value The Map value.
|
||||
*
|
||||
* @return this.
|
||||
*
|
||||
* @throws JSONException If the index is negative or if the the value is an invalid number.
|
||||
* @throws JSONException If the index is negative or if the the value is an
|
||||
* invalid number.
|
||||
*/
|
||||
public JSONArray put(int index, Map<String, Object> value) throws JSONException {
|
||||
this.put(index, new JSONObject(value));
|
||||
@ -790,7 +801,7 @@ public class JSONArray {
|
||||
* @param indentFactor The number of spaces to add to each level of indentation.
|
||||
*
|
||||
* @return a printable, displayable, transmittable representation of the object, beginning with
|
||||
* <code>[</code> <small>(left bracket)</small> and ending with <code>]</code> <small>(right
|
||||
* {@code [} <small>(left bracket)</small> and ending with {@code ]} <small>(right
|
||||
* bracket)</small>.
|
||||
*
|
||||
* @throws JSONException
|
||||
|
@ -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.
|
||||
|
@ -17,6 +17,7 @@ import com.intellectualcrafters.plot.util.TaskManager;
|
||||
import com.intellectualcrafters.plot.util.UUIDHandlerImplementation;
|
||||
import com.intellectualcrafters.plot.util.WorldUtil;
|
||||
import com.intellectualcrafters.plot.util.block.QueueProvider;
|
||||
|
||||
import java.io.File;
|
||||
import java.util.List;
|
||||
|
||||
@ -51,17 +52,29 @@ public interface IPlotMain extends ILogger {
|
||||
* Disable the implementation.
|
||||
*
|
||||
* <ul>
|
||||
* <li>If a full disable isn't feasibly, just disable what it can.</li>
|
||||
* <li>If a full disable isn't feasibly, just disable what it can.
|
||||
* </ul>
|
||||
*/
|
||||
void disable();
|
||||
|
||||
/**
|
||||
* Get the version of the PlotSquared being used.
|
||||
* @return
|
||||
* @return the plugin version
|
||||
*/
|
||||
int[] getPluginVersion();
|
||||
|
||||
/**
|
||||
* Get the version of the PlotSquared being used as a string.
|
||||
* @return the plugin version as a string
|
||||
*/
|
||||
String getPluginVersionString();
|
||||
|
||||
/**
|
||||
* Usually PlotSquared
|
||||
* @return
|
||||
*/
|
||||
String getPluginName();
|
||||
|
||||
/**
|
||||
* Get the version of Minecraft that is running.
|
||||
* @return
|
||||
@ -215,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
|
||||
@ -230,10 +243,10 @@ public interface IPlotMain extends ILogger {
|
||||
void registerWorldEvents();
|
||||
|
||||
/**
|
||||
* Get the name of the server.
|
||||
* @return The server name
|
||||
* Usually HybridGen
|
||||
* @return Default implementation generator
|
||||
*/
|
||||
String getServerName();
|
||||
IndependentPlotGenerator getDefaultGenerator();
|
||||
|
||||
/**
|
||||
* Get the class that will manage player titles.
|
||||
|
@ -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
|
||||
@ -171,14 +171,13 @@ public class PS {
|
||||
this.IMP.registerPlayerEvents();
|
||||
this.IMP.registerInventoryEvents();
|
||||
this.IMP.registerPlotPlusEvents();
|
||||
this.IMP.registerForceFieldEvents();
|
||||
}
|
||||
// Required
|
||||
this.IMP.registerWorldEvents();
|
||||
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();
|
||||
@ -222,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) {
|
||||
@ -253,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, ".") + "!");
|
||||
@ -282,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");
|
||||
@ -306,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()));
|
||||
}
|
||||
|
||||
/**
|
||||
@ -320,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.
|
||||
*
|
||||
@ -327,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));
|
||||
}
|
||||
|
||||
@ -370,13 +377,16 @@ public class PS {
|
||||
@Override
|
||||
public void run() {
|
||||
UUIDHandler.add(new StringWrapper("*"), DBFunc.everyone);
|
||||
for (Plot plot : getPlots()) {
|
||||
foreachPlotRaw(new RunnableVal<Plot>() {
|
||||
@Override
|
||||
public void run(Plot plot) {
|
||||
if (plot.hasOwner() && plot.temp != -1) {
|
||||
if (UUIDHandler.getName(plot.owner) == null) {
|
||||
UUIDHandler.implementation.unknown.add(plot.owner);
|
||||
}
|
||||
}
|
||||
}
|
||||
});
|
||||
startExpiryTasks();
|
||||
startPlotMeConversion();
|
||||
}
|
||||
@ -398,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()) {
|
||||
@ -406,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);
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
@ -726,6 +737,7 @@ public class PS {
|
||||
this.plotAreaGrid.put(plotArea.worldname, map);
|
||||
}
|
||||
map.add(plotArea);
|
||||
plotArea.setupBorder();
|
||||
}
|
||||
|
||||
/**
|
||||
@ -734,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()) {
|
||||
@ -749,9 +761,11 @@ public class PS {
|
||||
|
||||
public void removePlotAreas(String world) {
|
||||
for (PlotArea area : getPlotAreas(world)) {
|
||||
if (area.worldname.equals(world)) {
|
||||
removePlotArea(area);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private void setPlotsTmp(PlotArea area) {
|
||||
if (this.plots_tmp == null) {
|
||||
@ -1077,14 +1091,15 @@ public class PS {
|
||||
public void run(PlotArea value) {
|
||||
for (PlotFilter filter : filters) {
|
||||
if (!filter.allowsArea(value)) {
|
||||
continue;
|
||||
return;
|
||||
}
|
||||
}
|
||||
loop:
|
||||
for (Entry<PlotId, Plot> entry2 : value.getPlotEntries()) {
|
||||
Plot plot = entry2.getValue();
|
||||
for (PlotFilter filter : filters) {
|
||||
if (!filter.allowsPlot(plot)) {
|
||||
continue;
|
||||
continue loop;
|
||||
}
|
||||
}
|
||||
set.add(plot);
|
||||
@ -1445,7 +1460,6 @@ public class PS {
|
||||
// Now add it
|
||||
addPlotArea(plotArea);
|
||||
plotGenerator.initialize(plotArea);
|
||||
plotArea.setupBorder();
|
||||
} else {
|
||||
if (!worlds.contains(world)) {
|
||||
return;
|
||||
@ -1457,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) {
|
||||
@ -1523,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>`");
|
||||
}
|
||||
@ -1557,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);
|
||||
@ -1705,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");
|
||||
}
|
||||
@ -1714,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();
|
||||
@ -1845,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();
|
||||
}
|
||||
}
|
||||
@ -1868,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();
|
||||
}
|
||||
}
|
||||
|
@ -0,0 +1,9 @@
|
||||
package com.intellectualcrafters.plot;
|
||||
|
||||
public enum Platform {
|
||||
Bukkit,
|
||||
Sponge,
|
||||
Spigot,
|
||||
Cauldron
|
||||
|
||||
}
|
@ -4,9 +4,10 @@ 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;
|
||||
|
||||
@ -16,7 +17,7 @@ public class Updater {
|
||||
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");
|
||||
@ -31,10 +32,12 @@ public class Updater {
|
||||
}
|
||||
// If current version >= update
|
||||
if (PS.get().checkVersion(PS.get().getVersion(), version)) {
|
||||
PS.debug("&7PlotSquared is already up to date!");
|
||||
if (!PS.get().IMP.getPluginVersionString().contains("-SNAPSHOT") || !Arrays.equals(PS.get().getVersion(), version)) {
|
||||
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"));
|
||||
@ -45,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,12 +18,11 @@ 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,
|
||||
permission = "plots.add",
|
||||
requiredType = RequiredType.PLAYER)
|
||||
requiredType = RequiredType.NONE)
|
||||
public class Add extends Command {
|
||||
|
||||
public Add() {
|
||||
@ -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]);
|
||||
@ -118,7 +119,7 @@ public class Auto extends SubCommand {
|
||||
}
|
||||
if (EconHandler.manager != null && plotarea.USE_ECONOMY) {
|
||||
Expression<Double> costExp = plotarea.PRICES.get("claim");
|
||||
double cost = costExp.evalute((double) currentPlots);
|
||||
double cost = costExp.evaluate((double) currentPlots);
|
||||
cost = (size_x * size_z) * cost;
|
||||
if (cost > 0d) {
|
||||
if (EconHandler.manager.getMoney(player) < cost) {
|
||||
@ -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;
|
||||
}
|
||||
|
@ -12,11 +12,11 @@ import com.intellectualcrafters.plot.util.MainUtil;
|
||||
import com.intellectualcrafters.plot.util.UUIDHandler;
|
||||
import com.plotsquared.general.commands.Command;
|
||||
import com.plotsquared.general.commands.CommandDeclaration;
|
||||
|
||||
import java.util.Set;
|
||||
|
||||
@CommandDeclaration(
|
||||
command = "buy",
|
||||
aliases = {"b"},
|
||||
description = "Buy the plot you are standing on",
|
||||
usage = "/plot buy",
|
||||
permission = "plots.buy",
|
||||
@ -43,7 +43,9 @@ public class Buy extends Command {
|
||||
Set<Plot> plots = plot.getConnectedPlots();
|
||||
checkTrue(player.getPlotCount() + plots.size() <= player.getAllowedPlots(), C.CANT_CLAIM_MORE_PLOTS);
|
||||
Optional<Double> flag = plot.getFlag(Flags.PRICE);
|
||||
checkTrue(flag.isPresent(), C.NOT_FOR_SALE);
|
||||
if (!flag.isPresent()) {
|
||||
throw new CommandException(C.NOT_FOR_SALE);
|
||||
}
|
||||
final double price = flag.get();
|
||||
checkTrue(player.getMoney() >= price, C.CANNOT_AFFORD_PLOT);
|
||||
player.withdraw(price);
|
||||
|
@ -16,7 +16,7 @@ import com.plotsquared.general.commands.CommandDeclaration;
|
||||
aliases = "c",
|
||||
description = "Claim the current plot you're standing on",
|
||||
category = CommandCategory.CLAIMING,
|
||||
requiredType = RequiredType.PLAYER,
|
||||
requiredType = RequiredType.NONE,
|
||||
permission = "plots.claim", usage = "/plot claim")
|
||||
public class Claim extends SubCommand {
|
||||
|
||||
@ -50,7 +50,7 @@ public class Claim extends SubCommand {
|
||||
PlotArea world = plot.getArea();
|
||||
if ((EconHandler.manager != null) && world.USE_ECONOMY) {
|
||||
Expression<Double> costExr = world.PRICES.get("claim");
|
||||
double cost = costExr.evalute((double) currentPlots);
|
||||
double cost = costExr.evaluate((double) currentPlots);
|
||||
if (cost > 0d) {
|
||||
if (EconHandler.manager.getMoney(player) < cost) {
|
||||
return sendMessage(player, C.CANNOT_AFFORD_PLOT, "" + cost);
|
||||
@ -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.");
|
||||
}
|
||||
|
@ -84,6 +84,9 @@ public class DebugExec extends SubCommand {
|
||||
}
|
||||
|
||||
public ScriptEngine getEngine() {
|
||||
if (this.engine == null) {
|
||||
init();
|
||||
}
|
||||
return this.engine;
|
||||
}
|
||||
|
||||
@ -148,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;
|
||||
@ -193,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();
|
||||
@ -56,13 +56,13 @@ public class Delete extends SubCommand {
|
||||
plot.removeRunning();
|
||||
if ((EconHandler.manager != null) && plotArea.USE_ECONOMY) {
|
||||
Expression<Double> valueExr = plotArea.PRICES.get("sell");
|
||||
double value = plots.size() * valueExr.evalute((double) currentPlots);
|
||||
double value = plots.size() * valueExr.evaluate((double) currentPlots);
|
||||
if (value > 0d) {
|
||||
EconHandler.manager.depositMoney(player, value);
|
||||
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) {
|
||||
|
@ -23,7 +23,7 @@ import java.util.UUID;
|
||||
description = "Deny a user from a plot",
|
||||
usage = "/plot deny <player>",
|
||||
category = CommandCategory.SETTINGS,
|
||||
requiredType = RequiredType.PLAYER)
|
||||
requiredType = RequiredType.NONE)
|
||||
public class Deny extends SubCommand {
|
||||
|
||||
public Deny() {
|
||||
@ -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;
|
||||
}
|
||||
|
@ -19,7 +19,7 @@ import com.plotsquared.general.commands.CommandDeclaration;
|
||||
description = "Mark a plot as done",
|
||||
permission = "plots.done",
|
||||
category = CommandCategory.SETTINGS,
|
||||
requiredType = RequiredType.PLAYER)
|
||||
requiredType = RequiredType.NONE)
|
||||
public class Done extends SubCommand {
|
||||
|
||||
@Override
|
||||
@ -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;
|
||||
}
|
||||
|
@ -22,7 +22,7 @@ import java.net.URL;
|
||||
command = "download",
|
||||
aliases = {"dl"},
|
||||
category = CommandCategory.SCHEMATIC,
|
||||
requiredType = RequiredType.PLAYER,
|
||||
requiredType = RequiredType.NONE,
|
||||
description = "Download your plot",
|
||||
permission = "plots.download")
|
||||
public class Download extends SubCommand {
|
||||
@ -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();
|
||||
|
@ -28,7 +28,7 @@ import java.util.Map;
|
||||
usage = "/plot flag <set|remove|add|list|info> <flag> <value>",
|
||||
description = "Set plot flags",
|
||||
category = CommandCategory.SETTINGS,
|
||||
requiredType = RequiredType.PLAYER,
|
||||
requiredType = RequiredType.NONE,
|
||||
permission = "plots.flag")
|
||||
public class FlagCmd extends SubCommand {
|
||||
|
||||
@ -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;
|
||||
}
|
||||
}
|
||||
@ -166,12 +166,15 @@ public class FlagCmd extends SubCommand {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
if(flag == Flags.TIME) {
|
||||
player.setTime(Long.MAX_VALUE);
|
||||
}
|
||||
MainUtil.sendMessage(player, C.FLAG_REMOVED);
|
||||
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) {
|
||||
@ -179,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;
|
||||
}
|
||||
}
|
||||
@ -212,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) {
|
||||
|
@ -4,12 +4,14 @@ import com.intellectualcrafters.plot.config.C;
|
||||
import com.intellectualcrafters.plot.database.DBFunc;
|
||||
import com.intellectualcrafters.plot.object.PlotPlayer;
|
||||
import com.intellectualcrafters.plot.object.RunnableVal;
|
||||
import com.intellectualcrafters.plot.object.RunnableVal2;
|
||||
import com.intellectualcrafters.plot.object.RunnableVal3;
|
||||
import com.intellectualcrafters.plot.util.ByteArrayUtilities;
|
||||
import com.intellectualcrafters.plot.util.MainUtil;
|
||||
import com.intellectualcrafters.plot.util.Permissions;
|
||||
import com.intellectualcrafters.plot.util.UUIDHandler;
|
||||
import com.plotsquared.general.commands.Command;
|
||||
import com.plotsquared.general.commands.CommandDeclaration;
|
||||
|
||||
import java.util.UUID;
|
||||
|
||||
@CommandDeclaration(
|
||||
@ -18,17 +20,22 @@ import java.util.UUID;
|
||||
usage = "/plot grant <check|add> [player]",
|
||||
permission = "plots.grant",
|
||||
requiredType = RequiredType.NONE)
|
||||
public class Grant extends SubCommand {
|
||||
public class Grant extends Command {
|
||||
|
||||
public Grant() {
|
||||
super(MainCommand.getInstance(), true);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean onCommand(final PlotPlayer player, String[] args) {
|
||||
public void execute(final PlotPlayer player, String[] args, RunnableVal3<Command, Runnable, Runnable> confirm, RunnableVal2<Command, CommandResult> whenDone) throws CommandException {
|
||||
checkTrue(args.length >= 1 && args.length <= 2, C.COMMAND_SYNTAX, getUsage());
|
||||
final String arg0 = args[0].toLowerCase();
|
||||
switch (arg0) {
|
||||
case "add":
|
||||
case "check":
|
||||
if (Permissions.hasPermission(player, "plots.grant." + arg0)) {
|
||||
C.NO_PERMISSION.send(player, "plots.grant." + arg0);
|
||||
return false;
|
||||
if (!Permissions.hasPermission(player, C.PERMISSION_GRANT.f(arg0))) {
|
||||
C.NO_PERMISSION.send(player, C.PERMISSION_GRANT.f(arg0));
|
||||
return;
|
||||
}
|
||||
if (args.length > 2) {
|
||||
break;
|
||||
@ -36,7 +43,7 @@ public class Grant extends SubCommand {
|
||||
final UUID uuid = args.length == 2 ? UUIDHandler.getUUIDFromString(args[1]) : player.getUUID();
|
||||
if (uuid == null) {
|
||||
C.INVALID_PLAYER.send(player, args[1]);
|
||||
return false;
|
||||
return;
|
||||
}
|
||||
MainUtil.getPersistentMeta(uuid, "grantedPlots", new RunnableVal<byte[]>() {
|
||||
@Override
|
||||
@ -51,10 +58,7 @@ public class Grant extends SubCommand {
|
||||
}
|
||||
}
|
||||
});
|
||||
return true;
|
||||
}
|
||||
C.COMMAND_SYNTAX.send(player, getUsage());
|
||||
return false;
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -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;
|
||||
|
@ -8,6 +8,7 @@ import com.intellectualcrafters.plot.object.PlotItemStack;
|
||||
import com.intellectualcrafters.plot.object.PlotPlayer;
|
||||
import com.intellectualcrafters.plot.object.RunnableVal;
|
||||
import com.intellectualcrafters.plot.util.MainUtil;
|
||||
import com.intellectualcrafters.plot.util.expiry.ExpireManager;
|
||||
import com.plotsquared.general.commands.CommandDeclaration;
|
||||
|
||||
import java.util.UUID;
|
||||
@ -35,6 +36,7 @@ public class Info extends SubCommand {
|
||||
case "id":
|
||||
case "size":
|
||||
case "members":
|
||||
case "seen":
|
||||
case "owner":
|
||||
case "rating":
|
||||
plot = MainUtil.getPlotFromString(player, null, false);
|
||||
@ -82,7 +84,7 @@ public class Info extends SubCommand {
|
||||
"&cAlias: &6" + plot.getAlias(),
|
||||
"&cBiome: &6" + plot.getBiome().replaceAll("_", "").toLowerCase(),
|
||||
"&cCan Build: &6" + plot.isAdded(uuid),
|
||||
"&cExpires: &6" + plot.isAdded(uuid),
|
||||
"&cSeen: &6" + MainUtil.secToTime((int) (ExpireManager.IMP.getAge(plot) / 1000)),
|
||||
"&cIs Denied: &6" + plot.isDenied(uuid)));
|
||||
inv.setItem(1, new PlotItemStack(388, (short) 0, 1, "&cTrusted", "&cAmount: &6" + plot.getTrusted().size(),
|
||||
"&8Click to view a list of the trusted users"));
|
||||
@ -110,7 +112,7 @@ public class Info extends SubCommand {
|
||||
info = getCaption(arg);
|
||||
if (info == null) {
|
||||
MainUtil.sendMessage(player,
|
||||
"&6Categories&7: &amembers&7, &aalias&7, &abiome&7, &aexpires&7, &adenied&7, &aflags&7, &aid&7, &asize&7, &atrusted&7, "
|
||||
"&6Categories&7: &amembers&7, &aalias&7, &abiome&7, &aseen&7, &adenied&7, &aflags&7, &aid&7, &asize&7, &atrusted&7, "
|
||||
+ "&aowner&7, &arating");
|
||||
return false;
|
||||
}
|
||||
@ -149,8 +151,8 @@ public class Info extends SubCommand {
|
||||
return C.PLOT_INFO_OWNER.s();
|
||||
case "rating":
|
||||
return C.PLOT_INFO_RATING.s();
|
||||
case "expires":
|
||||
return C.PLOT_INFO_EXPIRES.s();
|
||||
case "seen":
|
||||
return C.PLOT_INFO_SEEN.s();
|
||||
default:
|
||||
return null;
|
||||
}
|
||||
|
@ -22,7 +22,7 @@ import java.util.UUID;
|
||||
permission = "plots.kick",
|
||||
usage = "<player>",
|
||||
category = CommandCategory.TELEPORT,
|
||||
requiredType = RequiredType.PLAYER)
|
||||
requiredType = RequiredType.NONE)
|
||||
public class Kick extends SubCommand {
|
||||
|
||||
public Kick() {
|
||||
@ -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;
|
||||
}
|
||||
@ -48,8 +48,13 @@ public class Kick extends SubCommand {
|
||||
Set<PlotPlayer> players = new HashSet<>();
|
||||
for (UUID uuid : uuids) {
|
||||
if (uuid == DBFunc.everyone) {
|
||||
players.addAll(plot.getPlayersInPlot());
|
||||
break;
|
||||
for (PlotPlayer pp : plot.getPlayersInPlot()) {
|
||||
if (pp == player || Permissions.hasPermission(pp, C.PERMISSION_ADMIN_ENTRY_DENIED)) {
|
||||
continue;
|
||||
}
|
||||
players.add(pp);
|
||||
}
|
||||
continue;
|
||||
}
|
||||
PlotPlayer pp = UUIDHandler.getPlayer(uuid);
|
||||
if (pp != null) {
|
||||
@ -62,13 +67,12 @@ public class Kick extends SubCommand {
|
||||
return false;
|
||||
}
|
||||
for (PlotPlayer player2 : players) {
|
||||
Location location2 = player2.getLocation();
|
||||
if (!player2.getLocation().getWorld().equals(location2.getWorld()) || !plot.equals(location2.getPlot())) {
|
||||
MainUtil.sendMessage(player2, C.INVALID_PLAYER, args[0]);
|
||||
if (!plot.equals(player2.getCurrentPlot())) {
|
||||
MainUtil.sendMessage(player, C.INVALID_PLAYER, args[0]);
|
||||
return false;
|
||||
}
|
||||
if (player2.hasPermission("plots.admin.entry.denied")) {
|
||||
C.CANNOT_KICK_PLAYER.send(player2, player2.getName());
|
||||
C.CANNOT_KICK_PLAYER.send(player, player2.getName());
|
||||
return false;
|
||||
}
|
||||
Location spawn = WorldUtil.IMP.getSpawn(location.getWorld());
|
||||
|
@ -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;
|
||||
}
|
||||
@ -148,13 +148,7 @@ public class Load extends SubCommand {
|
||||
String world = split[1];
|
||||
PlotId id = PlotId.fromString(split[2] + ';' + split[3]);
|
||||
String size = split[4];
|
||||
String server = split[5].replaceAll(".schematic", "");
|
||||
String color;
|
||||
if (PS.get().IMP.getServerName().replaceAll("[^A-Za-z0-9]", "").equals(server)) {
|
||||
color = "$4";
|
||||
} else {
|
||||
color = "$1";
|
||||
}
|
||||
String color = "$4";
|
||||
MainUtil.sendMessage(player,
|
||||
"$3[$2" + (i + 1) + "$3] " + color + time + "$3 | " + color + world + ';' + id + "$3 | " + color + size + 'x' + size);
|
||||
} catch (Exception e) {
|
||||
@ -191,7 +185,7 @@ public class Load extends SubCommand {
|
||||
time -= minutes * 60;
|
||||
toreturn.append(minutes + "m ");
|
||||
}
|
||||
if (toreturn.equals("") || (time > 0)) {
|
||||
if (toreturn.length() == 0 || (time > 0)) {
|
||||
toreturn.append(time + "s ");
|
||||
}
|
||||
return toreturn.toString().trim();
|
||||
|
@ -64,6 +64,7 @@ public class MainCommand extends Command {
|
||||
new Deny();
|
||||
new Remove();
|
||||
new Info();
|
||||
new Near();
|
||||
new ListCmd();
|
||||
new Debug();
|
||||
new SchematicCmd();
|
||||
@ -140,7 +141,8 @@ public class MainCommand extends Command {
|
||||
if (EconHandler.manager != null) {
|
||||
PlotArea area = player.getApplicablePlotArea();
|
||||
if (area != null) {
|
||||
Double price = area.PRICES.get(cmd.getFullId()).evalute(0d);
|
||||
Expression<Double> priceEval = area.PRICES.get(cmd.getFullId());
|
||||
Double price = priceEval != null ? priceEval.evaluate(0d) : 0d;
|
||||
if (price != null && EconHandler.manager.getMoney(player) < price) {
|
||||
if (failure != null) {
|
||||
failure.run();
|
||||
@ -160,7 +162,7 @@ public class MainCommand extends Command {
|
||||
PlotArea area = player.getApplicablePlotArea();
|
||||
if (area != null) {
|
||||
Expression<Double> priceEval = area.PRICES.get(cmd.getFullId());
|
||||
Double price = priceEval != null ? priceEval.evalute(0d) : 0d;
|
||||
Double price = priceEval != null ? priceEval.evaluate(0d) : 0d;
|
||||
if (price != 0d && EconHandler.manager.getMoney(player) < price) {
|
||||
if (failure != null) {
|
||||
failure.run();
|
||||
@ -195,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 //
|
||||
@ -206,18 +208,66 @@ public class MainCommand extends Command {
|
||||
PlotArea area = player.getApplicablePlotArea();
|
||||
Plot newPlot = Plot.fromString(area, args[0]);
|
||||
if (newPlot != null && (player instanceof ConsolePlayer || newPlot.getArea().equals(area) || Permissions.hasPermission(player, C.PERMISSION_ADMIN)) && !newPlot.isDenied(player.getUUID())) {
|
||||
Location newLoc = newPlot.getCenter();
|
||||
if (player.canTeleport(newLoc)) {
|
||||
// Save meta
|
||||
loc = player.getMeta("location");
|
||||
plot = player.getMeta("lastplot");
|
||||
tp = true;
|
||||
// Set loc
|
||||
player.setMeta("location", newPlot.getBottomAbs());
|
||||
player.setMeta("location", newLoc);
|
||||
player.setMeta("lastplot", newPlot);
|
||||
} else {
|
||||
C.BORDER.send(player);
|
||||
}
|
||||
// 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);
|
||||
} catch (CommandException e) {
|
||||
throw e;
|
||||
} catch (Throwable e) {
|
||||
e.printStackTrace();
|
||||
String message = e.getLocalizedMessage();
|
||||
if (message != null) {
|
||||
C.ERROR.send(player, message);
|
||||
} else {
|
||||
C.ERROR.send(player);
|
||||
}
|
||||
}
|
||||
// Reset command scope //
|
||||
if (tp && !(player instanceof ConsolePlayer)) {
|
||||
if (loc == null) {
|
||||
|
@ -22,7 +22,7 @@ import java.util.UUID;
|
||||
description = "Merge the plot you are standing on, with another plot",
|
||||
permission = "plots.merge", usage = "/plot merge <all|n|e|s|w> [removeroads]",
|
||||
category = CommandCategory.SETTINGS,
|
||||
requiredType = RequiredType.PLAYER,
|
||||
requiredType = RequiredType.NONE,
|
||||
confirmation = true)
|
||||
public class Merge extends SubCommand {
|
||||
|
||||
@ -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 {
|
||||
@ -74,7 +74,7 @@ public class Merge extends SubCommand {
|
||||
final PlotArea plotArea = plot.getArea();
|
||||
Expression<Double> priceExr = plotArea.PRICES.containsKey("merge") ? plotArea.PRICES.get("merge") : null;
|
||||
final int size = plot.getConnectedPlots().size();
|
||||
final double price = priceExr == null ? 0d : priceExr.evalute((double) size);
|
||||
final double price = priceExr == null ? 0d : priceExr.evaluate((double) size);
|
||||
if (EconHandler.manager != null && plotArea.USE_ECONOMY && price > 0d && EconHandler.manager.getMoney(player) < price) {
|
||||
sendMessage(player, C.CANNOT_AFFORD_MERGE, String.valueOf(price));
|
||||
return false;
|
||||
|
@ -7,17 +7,15 @@ import com.intellectualcrafters.plot.object.PlotPlayer;
|
||||
import com.plotsquared.general.commands.CommandDeclaration;
|
||||
|
||||
/**
|
||||
* Legally stolen from https://github.com/manuelgu/PlotSquaredMiddle
|
||||
*
|
||||
* @author manuelgu, altered by Citymonstret
|
||||
*/
|
||||
@CommandDeclaration(
|
||||
command = "middle",
|
||||
aliases = {"center"},
|
||||
description = "Teleports you to the center of the current plot",
|
||||
aliases = {"center", "centre"},
|
||||
description = "Teleports you to the center of the plot",
|
||||
usage = "/plot middle",
|
||||
category = CommandCategory.TELEPORT,
|
||||
requiredType = RequiredType.PLAYER)
|
||||
requiredType = RequiredType.NONE)
|
||||
public class Middle extends SubCommand {
|
||||
|
||||
@Override
|
||||
|
@ -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(), ", "));
|
||||
}
|
||||
}
|
@ -40,8 +40,8 @@ public class Owner extends SetCommand {
|
||||
name = UUIDHandler.getName(uuid);
|
||||
name = name == null ? value : name;
|
||||
}
|
||||
if (uuid == null) {
|
||||
if (value.equalsIgnoreCase("none")) {
|
||||
if (uuid == null || value.equalsIgnoreCase("-")) {
|
||||
if (value.equalsIgnoreCase("none") || value.equalsIgnoreCase("null") || value.equalsIgnoreCase("-")) {
|
||||
Set<Plot> connected = plot.getConnectedPlots();
|
||||
plot.unlinkPlot(false, false);
|
||||
for (Plot current : connected) {
|
||||
@ -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);
|
||||
|
@ -1,9 +1,11 @@
|
||||
package com.intellectualcrafters.plot.commands;
|
||||
|
||||
import com.intellectualcrafters.plot.config.C;
|
||||
import com.intellectualcrafters.plot.database.DBFunc;
|
||||
import com.intellectualcrafters.plot.object.Location;
|
||||
import com.intellectualcrafters.plot.object.Plot;
|
||||
import com.intellectualcrafters.plot.object.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;
|
||||
@ -21,7 +23,7 @@ import java.util.UUID;
|
||||
description = "Remove a player from a plot",
|
||||
usage = "/plot remove <player>",
|
||||
category = CommandCategory.SETTINGS,
|
||||
requiredType = RequiredType.PLAYER,
|
||||
requiredType = RequiredType.NONE,
|
||||
permission = "plots.remove")
|
||||
public class Remove extends SubCommand {
|
||||
|
||||
@ -40,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;
|
||||
}
|
||||
@ -69,16 +71,31 @@ public class Remove extends SubCommand {
|
||||
Set<UUID> uuids = MainUtil.getUUIDsFromString(args[0]);
|
||||
if (!uuids.isEmpty()) {
|
||||
for (UUID uuid : uuids) {
|
||||
if (plot.getTrusted().contains(uuid)) {
|
||||
if (uuid == DBFunc.everyone) {
|
||||
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;
|
||||
}
|
||||
@ -63,12 +63,11 @@ public class Save extends SubCommand {
|
||||
@Override
|
||||
public void run() {
|
||||
String time = (System.currentTimeMillis() / 1000) + "";
|
||||
String name = PS.get().IMP.getServerName().replaceAll("[^A-Za-z0-9]", "");
|
||||
Location[] corners = plot.getCorners();
|
||||
int size = (corners[1].getX() - corners[0].getX()) + 1;
|
||||
PlotId id = plot.getId();
|
||||
String world = plot.getArea().toString().replaceAll(";", "-").replaceAll("[^A-Za-z0-9]", "");
|
||||
final String file = time + '_' + world + '_' + id.x + '_' + id.y + '_' + size + '_' + name;
|
||||
final String file = time + '_' + world + '_' + id.x + '_' + id.y + '_' + size;
|
||||
UUID uuid = player.getUUID();
|
||||
SchematicHandler.manager.upload(value, uuid, file, new RunnableVal<URL>() {
|
||||
@Override
|
||||
|
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user