mirror of
https://github.com/IntellectualSites/PlotSquared.git
synced 2025-07-04 14:44:43 +02:00
Compare commits
128 Commits
Author | SHA1 | Date | |
---|---|---|---|
005e13a216 | |||
3558105789 | |||
f651607d2f | |||
6b95e57d9e | |||
98d0819383 | |||
30da060f83 | |||
e4408d56ec | |||
f07ac646f3 | |||
ef3380dc0a | |||
749ab83e5d | |||
daea9cf60d | |||
2f74368879 | |||
63d4476d97 | |||
db69da5b07 | |||
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 | |||
9fa28e1179 | |||
c3dd28caeb | |||
0888940307 | |||
ce7468e63a | |||
f5e7d08ace | |||
3ce225c044 | |||
c2f10a7065 |
@ -1,7 +1,12 @@
|
|||||||
|
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"}
|
||||||
|
}
|
||||||
|
|
||||||
dependencies {
|
dependencies {
|
||||||
compile project(':Core')
|
compile project(':Core')
|
||||||
compile 'org.bukkit:bukkit:1.10-R0.1-SNAPSHOT'
|
compile 'org.spigotmc:spigot-api:1.10.2-R0.1-SNAPSHOT'
|
||||||
compile 'org.mcstats.bukkit:metrics:R7'
|
|
||||||
compile 'net.milkbowl.vault:VaultAPI:1.6'
|
compile 'net.milkbowl.vault:VaultAPI:1.6'
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -17,19 +22,18 @@ processResources {
|
|||||||
)
|
)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
apply plugin: 'com.github.johnrengelman.shadow'
|
|
||||||
// We only want the shadow jar produced
|
// We only want the shadow jar produced
|
||||||
jar.enabled = false
|
jar.enabled = false
|
||||||
|
|
||||||
shadowJar {
|
shadowJar {
|
||||||
dependencies {
|
dependencies {
|
||||||
include(dependency(':Core'))
|
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"
|
archiveName = "${parent.name}-${project.name}-${parent.version}.jar"
|
||||||
destinationDir = file '../target'
|
destinationDir = file '../target'
|
||||||
}
|
}
|
||||||
|
|
||||||
shadowJar.doLast {
|
shadowJar.doLast {
|
||||||
task ->
|
task ->
|
||||||
ant.checksum file: task.archivePath
|
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.util.block.GlobalBlockQueue;
|
||||||
import com.intellectualcrafters.plot.uuid.UUIDWrapper;
|
import com.intellectualcrafters.plot.uuid.UUIDWrapper;
|
||||||
import com.plotsquared.bukkit.util.BukkitUtil;
|
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.ArrayList;
|
||||||
import java.util.Collection;
|
import java.util.Collection;
|
||||||
import java.util.Collections;
|
import java.util.Collections;
|
||||||
import java.util.HashSet;
|
import java.util.HashSet;
|
||||||
import java.util.Set;
|
import java.util.Set;
|
||||||
import java.util.UUID;
|
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.
|
* 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) {
|
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 world the world the plot is located in
|
||||||
* @param x The PlotID x coordinate
|
* @param x The PlotID x coordinate
|
||||||
@ -617,7 +618,7 @@ public class PlotAPI {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Get the PlotSquared class.
|
* Gets the PlotSquared class.
|
||||||
*
|
*
|
||||||
* @return 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 world Specify the world we want to select the plots from
|
||||||
* @param player Player, for whom we're getting the plot count
|
* @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 world Specify the world we want to select the plots from
|
||||||
* @param player Player, for whom we're getting the plots
|
* @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
|
* @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.
|
* will provide useful functions relating to players.
|
||||||
*
|
*
|
||||||
* @see PlotPlayer#wrap(Object)
|
* @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.PlotPlayer;
|
||||||
import com.intellectualcrafters.plot.object.RunnableVal;
|
import com.intellectualcrafters.plot.object.RunnableVal;
|
||||||
import com.intellectualcrafters.plot.object.SetupObject;
|
import com.intellectualcrafters.plot.object.SetupObject;
|
||||||
|
import com.intellectualcrafters.plot.object.chat.PlainChatManager;
|
||||||
import com.intellectualcrafters.plot.util.AbstractTitle;
|
import com.intellectualcrafters.plot.util.AbstractTitle;
|
||||||
import com.intellectualcrafters.plot.util.ChatManager;
|
import com.intellectualcrafters.plot.util.ChatManager;
|
||||||
import com.intellectualcrafters.plot.util.ChunkManager;
|
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.database.plotme.PlotMeConnector_017;
|
||||||
import com.plotsquared.bukkit.generator.BukkitPlotGenerator;
|
import com.plotsquared.bukkit.generator.BukkitPlotGenerator;
|
||||||
import com.plotsquared.bukkit.listeners.ChunkListener;
|
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.PlayerEvents;
|
||||||
import com.plotsquared.bukkit.listeners.PlayerEvents183;
|
import com.plotsquared.bukkit.listeners.PlayerEvents183;
|
||||||
import com.plotsquared.bukkit.listeners.PlayerEvents_1_8;
|
import com.plotsquared.bukkit.listeners.PlayerEvents_1_8;
|
||||||
@ -52,7 +53,6 @@ import com.plotsquared.bukkit.util.BukkitEconHandler;
|
|||||||
import com.plotsquared.bukkit.util.BukkitEventUtil;
|
import com.plotsquared.bukkit.util.BukkitEventUtil;
|
||||||
import com.plotsquared.bukkit.util.BukkitHybridUtils;
|
import com.plotsquared.bukkit.util.BukkitHybridUtils;
|
||||||
import com.plotsquared.bukkit.util.BukkitInventoryUtil;
|
import com.plotsquared.bukkit.util.BukkitInventoryUtil;
|
||||||
import com.plotsquared.bukkit.util.BukkitPlainChatManager;
|
|
||||||
import com.plotsquared.bukkit.util.BukkitSchematicHandler;
|
import com.plotsquared.bukkit.util.BukkitSchematicHandler;
|
||||||
import com.plotsquared.bukkit.util.BukkitSetupUtils;
|
import com.plotsquared.bukkit.util.BukkitSetupUtils;
|
||||||
import com.plotsquared.bukkit.util.BukkitTaskManager;
|
import com.plotsquared.bukkit.util.BukkitTaskManager;
|
||||||
@ -71,12 +71,6 @@ import com.plotsquared.bukkit.uuid.LowerOfflineUUIDWrapper;
|
|||||||
import com.plotsquared.bukkit.uuid.OfflineUUIDWrapper;
|
import com.plotsquared.bukkit.uuid.OfflineUUIDWrapper;
|
||||||
import com.plotsquared.bukkit.uuid.SQLUUIDHandler;
|
import com.plotsquared.bukkit.uuid.SQLUUIDHandler;
|
||||||
import com.sk89q.worldedit.WorldEdit;
|
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.Bukkit;
|
||||||
import org.bukkit.ChatColor;
|
import org.bukkit.ChatColor;
|
||||||
import org.bukkit.Location;
|
import org.bukkit.Location;
|
||||||
@ -92,6 +86,13 @@ import org.bukkit.metadata.MetadataValue;
|
|||||||
import org.bukkit.plugin.Plugin;
|
import org.bukkit.plugin.Plugin;
|
||||||
import org.bukkit.plugin.java.JavaPlugin;
|
import org.bukkit.plugin.java.JavaPlugin;
|
||||||
|
|
||||||
|
import java.io.File;
|
||||||
|
import java.util.ArrayList;
|
||||||
|
import java.util.Arrays;
|
||||||
|
import java.util.Iterator;
|
||||||
|
import java.util.List;
|
||||||
|
import java.util.UUID;
|
||||||
|
|
||||||
public final class BukkitMain extends JavaPlugin implements Listener, IPlotMain {
|
public final class BukkitMain extends JavaPlugin implements Listener, IPlotMain {
|
||||||
|
|
||||||
public static WorldEdit worldEdit;
|
public static WorldEdit worldEdit;
|
||||||
@ -113,7 +114,7 @@ public final class BukkitMain extends JavaPlugin implements Listener, IPlotMain
|
|||||||
e.printStackTrace();
|
e.printStackTrace();
|
||||||
PS.debug(StringMan.getString(Bukkit.getBukkitVersion()));
|
PS.debug(StringMan.getString(Bukkit.getBukkitVersion()));
|
||||||
PS.debug(StringMan.getString(Bukkit.getBukkitVersion().split("-")[0].split("\\.")));
|
PS.debug(StringMan.getString(Bukkit.getBukkitVersion().split("-")[0].split("\\.")));
|
||||||
return new int[]{1, 9, 2};
|
return new int[]{1, 10, 0};
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return this.version;
|
return this.version;
|
||||||
@ -121,7 +122,14 @@ public final class BukkitMain extends JavaPlugin implements Listener, IPlotMain
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onEnable() {
|
public void onEnable() {
|
||||||
|
getServer().getName();
|
||||||
new PS(this, "Bukkit");
|
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);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@ -158,6 +166,10 @@ public final class BukkitMain extends JavaPlugin implements Listener, IPlotMain
|
|||||||
return new int[]{Integer.parseInt(split[0]), Integer.parseInt(split[1]), Integer.parseInt(split[2])};
|
return new int[]{Integer.parseInt(split[0]), Integer.parseInt(split[1]), Integer.parseInt(split[2])};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override public String getPluginVersionString() {
|
||||||
|
return getDescription().getVersion();
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void registerCommands() {
|
public void registerCommands() {
|
||||||
BukkitCommand bukkitCommand = new BukkitCommand();
|
BukkitCommand bukkitCommand = new BukkitCommand();
|
||||||
@ -202,7 +214,6 @@ public final class BukkitMain extends JavaPlugin implements Listener, IPlotMain
|
|||||||
Entity entity = iterator.next();
|
Entity entity = iterator.next();
|
||||||
switch (entity.getType()) {
|
switch (entity.getType()) {
|
||||||
case EGG:
|
case EGG:
|
||||||
case ENDER_CRYSTAL:
|
|
||||||
case COMPLEX_PART:
|
case COMPLEX_PART:
|
||||||
case FISHING_HOOK:
|
case FISHING_HOOK:
|
||||||
case ENDER_SIGNAL:
|
case ENDER_SIGNAL:
|
||||||
@ -233,18 +244,17 @@ public final class BukkitMain extends JavaPlugin implements Listener, IPlotMain
|
|||||||
// Not vehicles
|
// Not vehicles
|
||||||
continue;
|
continue;
|
||||||
case ARMOR_STAND:
|
case ARMOR_STAND:
|
||||||
// Tempirarily classify as vehicle
|
// Temporarily classify as vehicle
|
||||||
case MINECART:
|
case MINECART:
|
||||||
case MINECART_CHEST:
|
case MINECART_CHEST:
|
||||||
case MINECART_COMMAND:
|
case MINECART_COMMAND:
|
||||||
case MINECART_FURNACE:
|
case MINECART_FURNACE:
|
||||||
case MINECART_HOPPER:
|
case MINECART_HOPPER:
|
||||||
case MINECART_MOB_SPAWNER:
|
case MINECART_MOB_SPAWNER:
|
||||||
|
case ENDER_CRYSTAL:
|
||||||
case MINECART_TNT:
|
case MINECART_TNT:
|
||||||
case BOAT: {
|
case BOAT: {
|
||||||
if (!Settings.Enabled_Components.KILL_ROAD_VEHICLES) {
|
if (Settings.Enabled_Components.KILL_ROAD_VEHICLES) {
|
||||||
continue;
|
|
||||||
}
|
|
||||||
com.intellectualcrafters.plot.object.Location location = BukkitUtil.getLocation(entity.getLocation());
|
com.intellectualcrafters.plot.object.Location location = BukkitUtil.getLocation(entity.getLocation());
|
||||||
Plot plot = location.getPlot();
|
Plot plot = location.getPlot();
|
||||||
if (plot == null) {
|
if (plot == null) {
|
||||||
@ -264,6 +274,9 @@ public final class BukkitMain extends JavaPlugin implements Listener, IPlotMain
|
|||||||
entity.remove();
|
entity.remove();
|
||||||
}
|
}
|
||||||
continue;
|
continue;
|
||||||
|
} else {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
case SMALL_FIREBALL:
|
case SMALL_FIREBALL:
|
||||||
case FIREBALL:
|
case FIREBALL:
|
||||||
@ -275,6 +288,7 @@ public final class BukkitMain extends JavaPlugin implements Listener, IPlotMain
|
|||||||
case FALLING_BLOCK:
|
case FALLING_BLOCK:
|
||||||
// managed elsewhere
|
// managed elsewhere
|
||||||
continue;
|
continue;
|
||||||
|
case POLAR_BEAR:
|
||||||
case BAT:
|
case BAT:
|
||||||
case BLAZE:
|
case BLAZE:
|
||||||
case CAVE_SPIDER:
|
case CAVE_SPIDER:
|
||||||
@ -309,9 +323,7 @@ public final class BukkitMain extends JavaPlugin implements Listener, IPlotMain
|
|||||||
case ZOMBIE:
|
case ZOMBIE:
|
||||||
case SHULKER:
|
case SHULKER:
|
||||||
default:
|
default:
|
||||||
if (!Settings.Enabled_Components.KILL_ROAD_MOBS) {
|
if (Settings.Enabled_Components.KILL_ROAD_MOBS) {
|
||||||
continue;
|
|
||||||
}
|
|
||||||
Location location = entity.getLocation();
|
Location location = entity.getLocation();
|
||||||
if (BukkitUtil.getLocation(location).isPlotRoad()) {
|
if (BukkitUtil.getLocation(location).isPlotRoad()) {
|
||||||
if (entity instanceof LivingEntity) {
|
if (entity instanceof LivingEntity) {
|
||||||
@ -333,6 +345,7 @@ public final class BukkitMain extends JavaPlugin implements Listener, IPlotMain
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
} catch (Throwable e) {
|
} catch (Throwable e) {
|
||||||
e.printStackTrace();
|
e.printStackTrace();
|
||||||
}
|
}
|
||||||
@ -355,6 +368,12 @@ public final class BukkitMain extends JavaPlugin implements Listener, IPlotMain
|
|||||||
public void registerPlayerEvents() {
|
public void registerPlayerEvents() {
|
||||||
PlayerEvents main = new PlayerEvents();
|
PlayerEvents main = new PlayerEvents();
|
||||||
getServer().getPluginManager().registerEvents(main, this);
|
getServer().getPluginManager().registerEvents(main, this);
|
||||||
|
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(), 1, 8, 0)) {
|
if (PS.get().checkVersion(getServerVersion(), 1, 8, 0)) {
|
||||||
try {
|
try {
|
||||||
getServer().getPluginManager().registerEvents(new PlayerEvents_1_8(), this);
|
getServer().getPluginManager().registerEvents(new PlayerEvents_1_8(), this);
|
||||||
@ -391,7 +410,6 @@ public final class BukkitMain extends JavaPlugin implements Listener, IPlotMain
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void registerForceFieldEvents() {
|
public void registerForceFieldEvents() {
|
||||||
getServer().getPluginManager().registerEvents(new ForceFieldListener(), this);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@ -422,7 +440,7 @@ public final class BukkitMain extends JavaPlugin implements Listener, IPlotMain
|
|||||||
new SendChunk();
|
new SendChunk();
|
||||||
MainUtil.canSendChunk = true;
|
MainUtil.canSendChunk = true;
|
||||||
} catch (ClassNotFoundException | NoSuchFieldException | NoSuchMethodException e) {
|
} catch (ClassNotFoundException | NoSuchFieldException | NoSuchMethodException e) {
|
||||||
e.printStackTrace();
|
PS.debug(SendChunk.class + " does not support " + StringMan.getString(getServerVersion()));
|
||||||
MainUtil.canSendChunk = false;
|
MainUtil.canSendChunk = false;
|
||||||
}
|
}
|
||||||
if (PS.get().checkVersion(getServerVersion(), 1, 9, 0)) {
|
if (PS.get().checkVersion(getServerVersion(), 1, 9, 0)) {
|
||||||
@ -560,15 +578,9 @@ public final class BukkitMain extends JavaPlugin implements Listener, IPlotMain
|
|||||||
return new BukkitInventoryUtil();
|
return new BukkitInventoryUtil();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
|
||||||
public String getServerName() {
|
|
||||||
return Bukkit.getServerName();
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void startMetrics() {
|
public void startMetrics() {
|
||||||
Metrics metrics = new Metrics(this);
|
new Metrics(this).start();
|
||||||
metrics.start();
|
|
||||||
PS.log(C.PREFIX + "&6Metrics enabled.");
|
PS.log(C.PREFIX + "&6Metrics enabled.");
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -647,7 +659,7 @@ public final class BukkitMain extends JavaPlugin implements Listener, IPlotMain
|
|||||||
if (Settings.Chat.INTERACTIVE) {
|
if (Settings.Chat.INTERACTIVE) {
|
||||||
return new BukkitChatManager();
|
return new BukkitChatManager();
|
||||||
} else {
|
} else {
|
||||||
return new BukkitPlainChatManager();
|
return new PlainChatManager();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1,10 +1,25 @@
|
|||||||
package com.plotsquared.bukkit.chat;
|
package com.plotsquared.bukkit.chat;
|
||||||
|
|
||||||
|
import static com.plotsquared.bukkit.chat.TextualComponent.rawText;
|
||||||
|
|
||||||
import com.google.gson.JsonArray;
|
import com.google.gson.JsonArray;
|
||||||
import com.google.gson.JsonElement;
|
import com.google.gson.JsonElement;
|
||||||
import com.google.gson.JsonObject;
|
import com.google.gson.JsonObject;
|
||||||
import com.google.gson.JsonParser;
|
import com.google.gson.JsonParser;
|
||||||
import com.google.gson.stream.JsonWriter;
|
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.IOException;
|
||||||
import java.io.StringWriter;
|
import java.io.StringWriter;
|
||||||
import java.lang.reflect.Constructor;
|
import java.lang.reflect.Constructor;
|
||||||
@ -19,21 +34,6 @@ import java.util.Iterator;
|
|||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
import java.util.logging.Level;
|
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>.
|
* 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
|
@Override
|
||||||
public FancyMessage clone() throws CloneNotSupportedException {
|
public FancyMessage clone() throws CloneNotSupportedException {
|
||||||
FancyMessage instance = (FancyMessage) super.clone();
|
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++) {
|
for (int i = 0; i < messageParts.size(); i++) {
|
||||||
instance.messageParts.add(i, messageParts.get(i).clone());
|
instance.messageParts.add(i, messageParts.get(i).clone());
|
||||||
}
|
}
|
||||||
@ -78,15 +78,15 @@ public class FancyMessage implements JsonRepresentedObject, Cloneable, Iterable<
|
|||||||
this(rawText(firstPartText));
|
this(rawText(firstPartText));
|
||||||
}
|
}
|
||||||
|
|
||||||
public FancyMessage(final com.plotsquared.bukkit.chat.TextualComponent firstPartText) {
|
public FancyMessage(final TextualComponent firstPartText) {
|
||||||
messageParts = new ArrayList<MessagePart>();
|
messageParts = new ArrayList<>();
|
||||||
messageParts.add(new MessagePart(firstPartText));
|
messageParts.add(new MessagePart(firstPartText));
|
||||||
jsonString = null;
|
jsonString = null;
|
||||||
dirty = false;
|
dirty = false;
|
||||||
|
|
||||||
if (nmsPacketPlayOutChatConstructor == null) {
|
if (nmsPacketPlayOutChatConstructor == null) {
|
||||||
try {
|
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);
|
nmsPacketPlayOutChatConstructor.setAccessible(true);
|
||||||
} catch (NoSuchMethodException e) {
|
} catch (NoSuchMethodException e) {
|
||||||
Bukkit.getLogger().log(Level.SEVERE, "Could not find Minecraft method or constructor.", e);
|
Bukkit.getLogger().log(Level.SEVERE, "Could not find Minecraft method or constructor.", e);
|
||||||
@ -100,7 +100,7 @@ public class FancyMessage implements JsonRepresentedObject, Cloneable, Iterable<
|
|||||||
* Creates a JSON message without text.
|
* Creates a JSON message without text.
|
||||||
*/
|
*/
|
||||||
public FancyMessage() {
|
public FancyMessage() {
|
||||||
this((com.plotsquared.bukkit.chat.TextualComponent) null);
|
this((TextualComponent) null);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -122,7 +122,7 @@ public class FancyMessage implements JsonRepresentedObject, Cloneable, Iterable<
|
|||||||
* @param text The new text of the current editing component.
|
* @param text The new text of the current editing component.
|
||||||
* @return This builder instance.
|
* @return This builder instance.
|
||||||
*/
|
*/
|
||||||
public FancyMessage text(com.plotsquared.bukkit.chat.TextualComponent text) {
|
public FancyMessage text(TextualComponent text) {
|
||||||
MessagePart latest = latest();
|
MessagePart latest = latest();
|
||||||
latest.text = text;
|
latest.text = text;
|
||||||
dirty = true;
|
dirty = true;
|
||||||
@ -243,8 +243,8 @@ public class FancyMessage implements JsonRepresentedObject, Cloneable, Iterable<
|
|||||||
*/
|
*/
|
||||||
public FancyMessage achievementTooltip(final Achievement which) {
|
public FancyMessage achievementTooltip(final Achievement which) {
|
||||||
try {
|
try {
|
||||||
Object achievement = com.plotsquared.bukkit.chat.Reflection.getMethod(com.plotsquared.bukkit.chat.Reflection.getOBCClass("CraftStatistic"), "getNMSAchievement", Achievement.class).invoke(null, which);
|
Object achievement = Reflection.getMethod(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));
|
return achievementTooltip((String) Reflection.getField(Reflection.getNMSClass("Achievement"), "name").get(achievement));
|
||||||
} catch (IllegalAccessException e) {
|
} catch (IllegalAccessException e) {
|
||||||
Bukkit.getLogger().log(Level.WARNING, "Could not access method.", e);
|
Bukkit.getLogger().log(Level.WARNING, "Could not access method.", e);
|
||||||
return this;
|
return this;
|
||||||
@ -252,7 +252,7 @@ public class FancyMessage implements JsonRepresentedObject, Cloneable, Iterable<
|
|||||||
Bukkit.getLogger().log(Level.WARNING, "Argument could not be passed.", e);
|
Bukkit.getLogger().log(Level.WARNING, "Argument could not be passed.", e);
|
||||||
return this;
|
return this;
|
||||||
} catch (InvocationTargetException 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);
|
||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -271,8 +271,8 @@ public class FancyMessage implements JsonRepresentedObject, Cloneable, Iterable<
|
|||||||
throw new IllegalArgumentException("That statistic requires an additional " + type + " parameter!");
|
throw new IllegalArgumentException("That statistic requires an additional " + type + " parameter!");
|
||||||
}
|
}
|
||||||
try {
|
try {
|
||||||
Object statistic = com.plotsquared.bukkit.chat.Reflection.getMethod(com.plotsquared.bukkit.chat.Reflection.getOBCClass("CraftStatistic"), "getNMSStatistic", Statistic.class).invoke(null, which);
|
Object statistic = Reflection.getMethod(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));
|
return achievementTooltip((String) Reflection.getField(Reflection.getNMSClass("Statistic"), "name").get(statistic));
|
||||||
} catch (IllegalAccessException e) {
|
} catch (IllegalAccessException e) {
|
||||||
Bukkit.getLogger().log(Level.WARNING, "Could not access method.", e);
|
Bukkit.getLogger().log(Level.WARNING, "Could not access method.", e);
|
||||||
return this;
|
return this;
|
||||||
@ -280,7 +280,7 @@ public class FancyMessage implements JsonRepresentedObject, Cloneable, Iterable<
|
|||||||
Bukkit.getLogger().log(Level.WARNING, "Argument could not be passed.", e);
|
Bukkit.getLogger().log(Level.WARNING, "Argument could not be passed.", e);
|
||||||
return this;
|
return this;
|
||||||
} catch (InvocationTargetException 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);
|
||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -303,8 +303,8 @@ public class FancyMessage implements JsonRepresentedObject, Cloneable, Iterable<
|
|||||||
throw new IllegalArgumentException("Wrong parameter type for that statistic - needs " + type + "!");
|
throw new IllegalArgumentException("Wrong parameter type for that statistic - needs " + type + "!");
|
||||||
}
|
}
|
||||||
try {
|
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);
|
Object statistic = Reflection.getMethod(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));
|
return achievementTooltip((String) Reflection.getField(Reflection.getNMSClass("Statistic"), "name").get(statistic));
|
||||||
} catch (IllegalAccessException e) {
|
} catch (IllegalAccessException e) {
|
||||||
Bukkit.getLogger().log(Level.WARNING, "Could not access method.", e);
|
Bukkit.getLogger().log(Level.WARNING, "Could not access method.", e);
|
||||||
return this;
|
return this;
|
||||||
@ -312,7 +312,7 @@ public class FancyMessage implements JsonRepresentedObject, Cloneable, Iterable<
|
|||||||
Bukkit.getLogger().log(Level.WARNING, "Argument could not be passed.", e);
|
Bukkit.getLogger().log(Level.WARNING, "Argument could not be passed.", e);
|
||||||
return this;
|
return this;
|
||||||
} catch (InvocationTargetException 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);
|
||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -335,8 +335,8 @@ public class FancyMessage implements JsonRepresentedObject, Cloneable, Iterable<
|
|||||||
throw new IllegalArgumentException("Wrong parameter type for that statistic - needs " + type + "!");
|
throw new IllegalArgumentException("Wrong parameter type for that statistic - needs " + type + "!");
|
||||||
}
|
}
|
||||||
try {
|
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);
|
Object statistic = Reflection.getMethod(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));
|
return achievementTooltip((String) Reflection.getField(Reflection.getNMSClass("Statistic"), "name").get(statistic));
|
||||||
} catch (IllegalAccessException e) {
|
} catch (IllegalAccessException e) {
|
||||||
Bukkit.getLogger().log(Level.WARNING, "Could not access method.", e);
|
Bukkit.getLogger().log(Level.WARNING, "Could not access method.", e);
|
||||||
return this;
|
return this;
|
||||||
@ -344,7 +344,7 @@ public class FancyMessage implements JsonRepresentedObject, Cloneable, Iterable<
|
|||||||
Bukkit.getLogger().log(Level.WARNING, "Argument could not be passed.", e);
|
Bukkit.getLogger().log(Level.WARNING, "Argument could not be passed.", e);
|
||||||
return this;
|
return this;
|
||||||
} catch (InvocationTargetException 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);
|
||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -370,8 +370,8 @@ public class FancyMessage implements JsonRepresentedObject, Cloneable, Iterable<
|
|||||||
*/
|
*/
|
||||||
public FancyMessage itemTooltip(final ItemStack itemStack) {
|
public FancyMessage itemTooltip(final ItemStack itemStack) {
|
||||||
try {
|
try {
|
||||||
Object nmsItem = com.plotsquared.bukkit.chat.Reflection.getMethod(com.plotsquared.bukkit.chat.Reflection.getOBCClass("inventory.CraftItemStack"), "asNMSCopy", ItemStack.class).invoke(null, itemStack);
|
Object nmsItem = Reflection.getMethod(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());
|
return itemTooltip(Reflection.getMethod(Reflection.getNMSClass("ItemStack"), "save", Reflection.getNMSClass("NBTTagCompound")).invoke(nmsItem, Reflection.getNMSClass("NBTTagCompound").newInstance()).toString());
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
e.printStackTrace();
|
e.printStackTrace();
|
||||||
return this;
|
return this;
|
||||||
@ -565,7 +565,7 @@ public class FancyMessage implements JsonRepresentedObject, Cloneable, Iterable<
|
|||||||
* @param text The text which will populate the new message component.
|
* @param text The text which will populate the new message component.
|
||||||
* @return This builder instance.
|
* @return This builder instance.
|
||||||
*/
|
*/
|
||||||
public FancyMessage then(final com.plotsquared.bukkit.chat.TextualComponent text) {
|
public FancyMessage then(final TextualComponent text) {
|
||||||
if (!latest().hasText()) {
|
if (!latest().hasText()) {
|
||||||
throw new IllegalStateException("previous message part has no text");
|
throw new IllegalStateException("previous message part has no text");
|
||||||
}
|
}
|
||||||
@ -641,9 +641,9 @@ public class FancyMessage implements JsonRepresentedObject, Cloneable, Iterable<
|
|||||||
}
|
}
|
||||||
Player player = (Player) sender;
|
Player player = (Player) sender;
|
||||||
try {
|
try {
|
||||||
Object handle = com.plotsquared.bukkit.chat.Reflection.getHandle(player);
|
Object handle = Reflection.getHandle(player);
|
||||||
Object connection = com.plotsquared.bukkit.chat.Reflection.getField(handle.getClass(), "playerConnection").get(handle);
|
Object connection = 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));
|
Reflection.getMethod(connection.getClass(), "sendPacket", Reflection.getNMSClass("Packet")).invoke(connection, createChatPacket(jsonString));
|
||||||
} catch (IllegalArgumentException e) {
|
} catch (IllegalArgumentException e) {
|
||||||
Bukkit.getLogger().log(Level.WARNING, "Argument could not be passed.", e);
|
Bukkit.getLogger().log(Level.WARNING, "Argument could not be passed.", e);
|
||||||
} catch (IllegalAccessException e) {
|
} catch (IllegalAccessException e) {
|
||||||
@ -651,7 +651,7 @@ public class FancyMessage implements JsonRepresentedObject, Cloneable, Iterable<
|
|||||||
} catch (InstantiationException e) {
|
} catch (InstantiationException e) {
|
||||||
Bukkit.getLogger().log(Level.WARNING, "Underlying class is abstract.", e);
|
Bukkit.getLogger().log(Level.WARNING, "Underlying class is abstract.", e);
|
||||||
} catch (InvocationTargetException 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) {
|
} catch (NoSuchMethodException e) {
|
||||||
Bukkit.getLogger().log(Level.WARNING, "Could not find method.", e);
|
Bukkit.getLogger().log(Level.WARNING, "Could not find method.", e);
|
||||||
} catch (ClassNotFoundException e) {
|
} catch (ClassNotFoundException e) {
|
||||||
@ -673,16 +673,16 @@ public class FancyMessage implements JsonRepresentedObject, Cloneable, Iterable<
|
|||||||
// X = major
|
// X = major
|
||||||
// Y = minor
|
// Y = minor
|
||||||
// Z = revision
|
// 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
|
String[] split = version.substring(1, version.length() - 1).split("_"); // Remove trailing dot
|
||||||
//int majorVersion = Integer.parseInt(split[0]);
|
//int majorVersion = Integer.parseInt(split[0]);
|
||||||
int minorVersion = Integer.parseInt(split[1]);
|
int minorVersion = Integer.parseInt(split[1]);
|
||||||
int revisionVersion = Integer.parseInt(split[2].substring(1)); // Substring to ignore R
|
int revisionVersion = Integer.parseInt(split[2].substring(1)); // Substring to ignore R
|
||||||
|
|
||||||
if (minorVersion < 8 || (minorVersion == 8 && revisionVersion == 1)) {
|
if (minorVersion < 8 || (minorVersion == 8 && revisionVersion == 1)) {
|
||||||
chatSerializerClazz = com.plotsquared.bukkit.chat.Reflection.getNMSClass("ChatSerializer");
|
chatSerializerClazz = Reflection.getNMSClass("ChatSerializer");
|
||||||
} else {
|
} else {
|
||||||
chatSerializerClazz = com.plotsquared.bukkit.chat.Reflection.getNMSClass("IChatBaseComponent$ChatSerializer");
|
chatSerializerClazz = Reflection.getNMSClass("IChatBaseComponent$ChatSerializer");
|
||||||
}
|
}
|
||||||
|
|
||||||
if (chatSerializerClazz == null) {
|
if (chatSerializerClazz == null) {
|
||||||
@ -702,7 +702,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
|
// 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
|
// 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);
|
return nmsPacketPlayOutChatConstructor.newInstance(serializedChatComponent);
|
||||||
}
|
}
|
||||||
@ -781,7 +781,7 @@ public class FancyMessage implements JsonRepresentedObject, Cloneable, Iterable<
|
|||||||
|
|
||||||
// Doc copied from interface
|
// Doc copied from interface
|
||||||
public Map<String, Object> serialize() {
|
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("messageParts", messageParts);
|
||||||
// map.put("JSON", toJSONString());
|
// map.put("JSON", toJSONString());
|
||||||
return map;
|
return map;
|
||||||
@ -829,9 +829,9 @@ public class FancyMessage implements JsonRepresentedObject, Cloneable, Iterable<
|
|||||||
JsonObject messagePart = mPrt.getAsJsonObject();
|
JsonObject messagePart = mPrt.getAsJsonObject();
|
||||||
for (Map.Entry<String, JsonElement> entry : messagePart.entrySet()) {
|
for (Map.Entry<String, JsonElement> entry : messagePart.entrySet()) {
|
||||||
// Deserialize text
|
// 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
|
// 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());
|
serializedMapForm.put("key", entry.getKey());
|
||||||
if (entry.getValue().isJsonPrimitive()) {
|
if (entry.getValue().isJsonPrimitive()) {
|
||||||
// Assume string
|
// Assume string
|
||||||
@ -842,7 +842,7 @@ public class FancyMessage implements JsonRepresentedObject, Cloneable, Iterable<
|
|||||||
serializedMapForm.put("value." + compositeNestedElement.getKey(), compositeNestedElement.getValue().getAsString());
|
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())) {
|
} else if (MessagePart.stylesToNames.inverse().containsKey(entry.getKey())) {
|
||||||
if (entry.getValue().getAsBoolean()) {
|
if (entry.getValue().getAsBoolean()) {
|
||||||
component.styles.add(MessagePart.stylesToNames.inverse().get(entry.getKey()));
|
component.styles.add(MessagePart.stylesToNames.inverse().get(entry.getKey()));
|
||||||
|
@ -20,12 +20,14 @@ import java.util.logging.Level;
|
|||||||
final class MessagePart implements JsonRepresentedObject, ConfigurationSerializable, Cloneable {
|
final class MessagePart implements JsonRepresentedObject, ConfigurationSerializable, Cloneable {
|
||||||
|
|
||||||
ChatColor color = ChatColor.WHITE;
|
ChatColor color = ChatColor.WHITE;
|
||||||
ArrayList<ChatColor> styles = new ArrayList<ChatColor>();
|
ArrayList<ChatColor> styles = new ArrayList<>();
|
||||||
String clickActionName = null, clickActionData = null, hoverActionName = null;
|
String clickActionName = null;
|
||||||
|
String clickActionData = null;
|
||||||
|
String hoverActionName = null;
|
||||||
JsonRepresentedObject hoverActionData = null;
|
JsonRepresentedObject hoverActionData = null;
|
||||||
TextualComponent text = null;
|
TextualComponent text = null;
|
||||||
String insertionData = null;
|
String insertionData = null;
|
||||||
ArrayList<JsonRepresentedObject> translationReplacements = new ArrayList<JsonRepresentedObject>();
|
ArrayList<JsonRepresentedObject> translationReplacements = new ArrayList<>();
|
||||||
|
|
||||||
MessagePart(final TextualComponent text) {
|
MessagePart(final TextualComponent text) {
|
||||||
this.text = text;
|
this.text = text;
|
||||||
@ -121,7 +123,7 @@ final class MessagePart implements JsonRepresentedObject, ConfigurationSerializa
|
|||||||
}
|
}
|
||||||
|
|
||||||
public Map<String, Object> serialize() {
|
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("text", text);
|
||||||
map.put("styles", styles);
|
map.put("styles", styles);
|
||||||
map.put("color", color.getChar());
|
map.put("color", color.getChar());
|
||||||
|
@ -3,6 +3,7 @@ package com.plotsquared.bukkit.chat;
|
|||||||
import org.bukkit.Bukkit;
|
import org.bukkit.Bukkit;
|
||||||
|
|
||||||
import java.lang.reflect.Field;
|
import java.lang.reflect.Field;
|
||||||
|
import java.lang.reflect.InvocationTargetException;
|
||||||
import java.lang.reflect.Method;
|
import java.lang.reflect.Method;
|
||||||
import java.util.Arrays;
|
import java.util.Arrays;
|
||||||
import java.util.HashMap;
|
import java.util.HashMap;
|
||||||
@ -14,6 +15,20 @@ import java.util.Map;
|
|||||||
*/
|
*/
|
||||||
public final class Reflection {
|
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 static String _versionString;
|
||||||
|
|
||||||
private Reflection() { }
|
private Reflection() { }
|
||||||
@ -37,16 +52,6 @@ public final class Reflection {
|
|||||||
return _versionString;
|
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.
|
* 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).
|
* 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;
|
String fullName = "net.minecraft.server." + getVersion() + className;
|
||||||
Class<?> clazz = null;
|
Class<?> clazz;
|
||||||
try {
|
try {
|
||||||
clazz = Class.forName(fullName);
|
clazz = Class.forName(fullName);
|
||||||
} catch (Exception e) {
|
} catch (ClassNotFoundException e) {
|
||||||
e.printStackTrace();
|
|
||||||
_loadedNMSClasses.put(className, null);
|
_loadedNMSClasses.put(className, null);
|
||||||
return null;
|
throw new RuntimeException(e);
|
||||||
}
|
}
|
||||||
_loadedNMSClasses.put(className, clazz);
|
_loadedNMSClasses.put(className, clazz);
|
||||||
return clazz;
|
return clazz;
|
||||||
@ -85,13 +89,12 @@ public final class Reflection {
|
|||||||
}
|
}
|
||||||
|
|
||||||
String fullName = "org.bukkit.craftbukkit." + getVersion() + className;
|
String fullName = "org.bukkit.craftbukkit." + getVersion() + className;
|
||||||
Class<?> clazz = null;
|
Class<?> clazz;
|
||||||
try {
|
try {
|
||||||
clazz = Class.forName(fullName);
|
clazz = Class.forName(fullName);
|
||||||
} catch (Exception e) {
|
} catch (ClassNotFoundException e) {
|
||||||
e.printStackTrace();
|
|
||||||
_loadedOBCClasses.put(className, null);
|
_loadedOBCClasses.put(className, null);
|
||||||
return null;
|
throw new RuntimeException(e);
|
||||||
}
|
}
|
||||||
_loadedOBCClasses.put(className, clazz);
|
_loadedOBCClasses.put(className, clazz);
|
||||||
return clazz;
|
return clazz;
|
||||||
@ -106,16 +109,9 @@ public final class Reflection {
|
|||||||
* @param obj The object for which to retrieve an NMS handle.
|
* @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()}.
|
* @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) {
|
public synchronized static Object getHandle(Object obj) throws InvocationTargetException, IllegalAccessException, IllegalArgumentException {
|
||||||
try {
|
|
||||||
return getMethod(obj.getClass(), "getHandle").invoke(obj);
|
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.
|
* 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) {
|
public synchronized static Field getField(Class<?> clazz, String name) {
|
||||||
Map<String, Field> loaded;
|
Map<String, Field> loaded;
|
||||||
if (!_loadedFields.containsKey(clazz)) {
|
if (!_loadedFields.containsKey(clazz)) {
|
||||||
loaded = new HashMap<String, Field>();
|
loaded = new HashMap<>();
|
||||||
_loadedFields.put(clazz, loaded);
|
_loadedFields.put(clazz, loaded);
|
||||||
} else {
|
} else {
|
||||||
loaded = _loadedFields.get(clazz);
|
loaded = _loadedFields.get(clazz);
|
||||||
@ -152,7 +148,7 @@ public final class Reflection {
|
|||||||
field.setAccessible(true);
|
field.setAccessible(true);
|
||||||
loaded.put(name, field);
|
loaded.put(name, field);
|
||||||
return field;
|
return field;
|
||||||
} catch (Exception e) {
|
} catch (NoSuchFieldException | SecurityException e) {
|
||||||
// Error loading
|
// Error loading
|
||||||
e.printStackTrace();
|
e.printStackTrace();
|
||||||
// Cache field as not existing
|
// 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.
|
* 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
|
* 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>
|
* <p>
|
||||||
* A global caching mechanism within this class is used to store method. Combined with synchronization, this guarantees that
|
* 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.
|
* no method will be reflectively looked up twice.
|
||||||
* </p>
|
|
||||||
* <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.
|
* 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.
|
* This ensures that callers do not have to check or worry about Java access modifiers when dealing with the returned instance.
|
||||||
* </p>
|
|
||||||
* <p>
|
* <p>
|
||||||
* This method does <em>not</em> search superclasses of the specified type for methods with the specified signature.
|
* 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...)}.
|
* 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);
|
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)) {
|
if (loadedSignatures.containsKey(wrappedArg)) {
|
||||||
return loadedSignatures.get(wrappedArg);
|
return loadedSignatures.get(wrappedArg);
|
||||||
}
|
}
|
||||||
|
@ -23,6 +23,119 @@ public abstract class TextualComponent implements Cloneable {
|
|||||||
ConfigurationSerialization.registerClass(TextualComponent.ComplexTextTypeComponent.class);
|
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
|
@Override
|
||||||
public String toString() {
|
public String toString() {
|
||||||
return getReadableString();
|
return getReadableString();
|
||||||
@ -54,59 +167,43 @@ public abstract class TextualComponent implements Cloneable {
|
|||||||
*/
|
*/
|
||||||
public abstract void writeJson(JsonWriter writer) throws IOException;
|
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.
|
* Internal class used to represent all types of text components.
|
||||||
* Exception validating done is on keys and values.
|
* Exception validating done is on keys and values.
|
||||||
*/
|
*/
|
||||||
private static final class ArbitraryTextTypeComponent extends TextualComponent implements ConfigurationSerializable {
|
private static final class ArbitraryTextTypeComponent extends TextualComponent implements ConfigurationSerializable {
|
||||||
|
|
||||||
|
private String key;
|
||||||
|
private String value;
|
||||||
|
|
||||||
public ArbitraryTextTypeComponent(String key, String value) {
|
public ArbitraryTextTypeComponent(String key, String value) {
|
||||||
setKey(key);
|
setKey(key);
|
||||||
setValue(value);
|
setValue(value);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static ArbitraryTextTypeComponent deserialize(Map<String, Object> map) {
|
||||||
|
return new ArbitraryTextTypeComponent(map.get("key").toString(), map.get("value").toString());
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String getKey() {
|
public String getKey() {
|
||||||
return _key;
|
return key;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setKey(String key) {
|
public void setKey(String key) {
|
||||||
Preconditions.checkArgument(key != null && !key.isEmpty(), "The key must be specified.");
|
Preconditions.checkArgument(key != null && !key.isEmpty(), "The key must be specified.");
|
||||||
_key = key;
|
this.key = key;
|
||||||
}
|
}
|
||||||
|
|
||||||
public String getValue() {
|
public String getValue() {
|
||||||
return _value;
|
return value;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setValue(String value) {
|
public void setValue(String value) {
|
||||||
Preconditions.checkArgument(value != null, "The value must be specified.");
|
Preconditions.checkArgument(value != null, "The value must be specified.");
|
||||||
_value = value;
|
this.value = value;
|
||||||
}
|
}
|
||||||
|
|
||||||
private String _key;
|
|
||||||
private String _value;
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public TextualComponent clone() throws CloneNotSupportedException {
|
public TextualComponent clone() throws CloneNotSupportedException {
|
||||||
// Since this is a private and final class, we can just reinstantiate this class instead of casting super.clone
|
// 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());
|
writer.name(getKey()).value(getValue());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
@SuppressWarnings("serial")
|
@SuppressWarnings("serial")
|
||||||
public Map<String, Object> serialize() {
|
public Map<String, Object> serialize() {
|
||||||
return new HashMap<String, Object>() {{
|
return new HashMap<String, Object>() {
|
||||||
|
{
|
||||||
put("key", getKey());
|
put("key", getKey());
|
||||||
put("value", getValue());
|
put("value", getValue());
|
||||||
}};
|
|
||||||
}
|
}
|
||||||
|
};
|
||||||
public static ArbitraryTextTypeComponent deserialize(Map<String, Object> map) {
|
|
||||||
return new ArbitraryTextTypeComponent(map.get("key").toString(), map.get("value").toString());
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@ -137,40 +233,55 @@ public abstract class TextualComponent implements Cloneable {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Internal class used to represent a text component with a nested JSON value.
|
* Internal class used to represent a text component with a nested JSON
|
||||||
* Exception validating done is on keys and values.
|
* value.
|
||||||
|
*
|
||||||
|
* <p>Exception validating done is on keys and values.
|
||||||
*/
|
*/
|
||||||
private static final class ComplexTextTypeComponent extends TextualComponent implements ConfigurationSerializable {
|
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) {
|
public ComplexTextTypeComponent(String key, Map<String, String> values) {
|
||||||
setKey(key);
|
setKey(key);
|
||||||
setValue(values);
|
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
|
@Override
|
||||||
public String getKey() {
|
public String getKey() {
|
||||||
return _key;
|
return key;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setKey(String key) {
|
public void setKey(String key) {
|
||||||
Preconditions.checkArgument(key != null && !key.isEmpty(), "The key must be specified.");
|
Preconditions.checkArgument(key != null && !key.isEmpty(), "The key must be specified.");
|
||||||
_key = key;
|
this.key = key;
|
||||||
}
|
}
|
||||||
|
|
||||||
public Map<String, String> getValue() {
|
public Map<String, String> getValue() {
|
||||||
return _value;
|
return value;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setValue(Map<String, String> value) {
|
public void setValue(Map<String, String> value) {
|
||||||
Preconditions.checkArgument(value != null, "The value must be specified.");
|
Preconditions.checkArgument(value != null, "The value must be specified.");
|
||||||
_value = value;
|
this.value = value;
|
||||||
}
|
}
|
||||||
|
|
||||||
private String _key;
|
|
||||||
private Map<String, String> _value;
|
|
||||||
|
|
||||||
@Override
|
@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
|
// Since this is a private and final class, we can just reinstantiate this class instead of casting super.clone
|
||||||
return new ComplexTextTypeComponent(getKey(), getValue());
|
return new ComplexTextTypeComponent(getKey(), getValue());
|
||||||
}
|
}
|
||||||
@ -179,33 +290,23 @@ public abstract class TextualComponent implements Cloneable {
|
|||||||
public void writeJson(JsonWriter writer) throws IOException {
|
public void writeJson(JsonWriter writer) throws IOException {
|
||||||
writer.name(getKey());
|
writer.name(getKey());
|
||||||
writer.beginObject();
|
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.name(jsonPair.getKey()).value(jsonPair.getValue());
|
||||||
}
|
}
|
||||||
writer.endObject();
|
writer.endObject();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
@SuppressWarnings("serial")
|
@SuppressWarnings("serial")
|
||||||
public Map<String, Object> serialize() {
|
public Map<String, Object> serialize() {
|
||||||
return new java.util.HashMap<String, Object>() {{
|
return new java.util.HashMap<String, Object>() {
|
||||||
|
{
|
||||||
put("key", getKey());
|
put("key", getKey());
|
||||||
for (Map.Entry<String, String> valEntry : getValue().entrySet()) {
|
for (Map.Entry<String, String> valEntry : getValue().entrySet()) {
|
||||||
put("value." + valEntry.getKey(), valEntry.getValue());
|
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
|
@Override
|
||||||
@ -213,85 +314,4 @@ public abstract class TextualComponent implements Cloneable {
|
|||||||
return getKey();
|
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);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
@ -13,7 +13,7 @@ import java.util.HashMap;
|
|||||||
|
|
||||||
public abstract class APlotMeConnector {
|
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;
|
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 {
|
public class ClassicPlotMeConnector extends APlotMeConnector {
|
||||||
|
|
||||||
private String plugin;
|
private String plugin = "PlotMe";
|
||||||
private String prefix;
|
private String prefix;
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Connection getPlotMeConnection(FileConfiguration plotConfig, String dataFolder) {
|
public Connection getPlotMeConnection(String plugin, FileConfiguration plotConfig, String dataFolder) {
|
||||||
this.plugin = this.plugin.toLowerCase();
|
this.plugin = plugin.toLowerCase();
|
||||||
this.prefix = plotConfig.getString("mySQLprefix", this.plugin.toLowerCase());
|
this.prefix = plotConfig.getString("mySQLprefix", this.plugin.toLowerCase());
|
||||||
try {
|
try {
|
||||||
if (plotConfig.getBoolean("usemySQL")) {
|
if (plotConfig.getBoolean("usemySQL")) {
|
||||||
|
@ -123,7 +123,7 @@ public class LikePlotMeConverter {
|
|||||||
|
|
||||||
PS.debug("&3Using connector: " + connector.getClass().getCanonicalName());
|
PS.debug("&3Using connector: " + connector.getClass().getCanonicalName());
|
||||||
|
|
||||||
Connection connection = connector.getPlotMeConnection(plotConfig, dataFolder);
|
Connection connection = connector.getPlotMeConnection(plugin,plotConfig, dataFolder);
|
||||||
|
|
||||||
if (!connector.isValidConnection(connection)) {
|
if (!connector.isValidConnection(connection)) {
|
||||||
sendMessage("Cannot connect to PlotMe DB. Conversion process will not continue");
|
sendMessage("Cannot connect to PlotMe DB. Conversion process will not continue");
|
||||||
|
@ -26,8 +26,8 @@ public class PlotMeConnector_017 extends APlotMeConnector {
|
|||||||
private String plugin;
|
private String plugin;
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Connection getPlotMeConnection(FileConfiguration plotConfig, String dataFolder) {
|
public Connection getPlotMeConnection(String plugin, FileConfiguration plotConfig, String dataFolder) {
|
||||||
this.plugin = this.plugin.toLowerCase();
|
this.plugin = plugin.toLowerCase();
|
||||||
try {
|
try {
|
||||||
if (plotConfig.getBoolean("usemySQL")) {
|
if (plotConfig.getBoolean("usemySQL")) {
|
||||||
String user = plotConfig.getString("mySQLuname");
|
String user = plotConfig.getString("mySQLuname");
|
||||||
|
@ -20,17 +20,18 @@ import com.intellectualcrafters.plot.util.block.LocalBlockQueue;
|
|||||||
import com.intellectualcrafters.plot.util.block.ScopedLocalBlockQueue;
|
import com.intellectualcrafters.plot.util.block.ScopedLocalBlockQueue;
|
||||||
import com.plotsquared.bukkit.util.BukkitUtil;
|
import com.plotsquared.bukkit.util.BukkitUtil;
|
||||||
import com.plotsquared.bukkit.util.block.GenChunk;
|
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.Chunk;
|
||||||
import org.bukkit.World;
|
import org.bukkit.World;
|
||||||
import org.bukkit.block.Biome;
|
import org.bukkit.block.Biome;
|
||||||
import org.bukkit.generator.BlockPopulator;
|
import org.bukkit.generator.BlockPopulator;
|
||||||
import org.bukkit.generator.ChunkGenerator;
|
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> {
|
public class BukkitPlotGenerator extends ChunkGenerator implements GeneratorWrapper<ChunkGenerator> {
|
||||||
|
|
||||||
private final GenChunk chunkSetter;
|
private final GenChunk chunkSetter;
|
||||||
@ -255,7 +256,7 @@ public class BukkitPlotGenerator extends ChunkGenerator implements GeneratorWrap
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public ChunkData generateChunkData(World world, Random random, int cx, int cz, BiomeGrid grid) {
|
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
|
// Set the chunk location
|
||||||
result.setChunk(new ChunkWrapper(world.getName(), cx, cz));
|
result.setChunk(new ChunkWrapper(world.getName(), cx, cz));
|
||||||
// Set the result data
|
// Set the result data
|
||||||
@ -303,7 +304,7 @@ public class BukkitPlotGenerator extends ChunkGenerator implements GeneratorWrap
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public short[][] generateExtBlockSections(World world, Random r, int cx, int cz, BiomeGrid grid) {
|
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
|
// Set the chunk location
|
||||||
result.setChunk(new ChunkWrapper(world.getName(), cx, cz));
|
result.setChunk(new ChunkWrapper(world.getName(), cx, cz));
|
||||||
// Set the result data
|
// Set the result data
|
||||||
|
@ -1,7 +1,5 @@
|
|||||||
package com.plotsquared.bukkit.listeners;
|
package com.plotsquared.bukkit.listeners;
|
||||||
|
|
||||||
import static com.intellectualcrafters.plot.util.ReflectionUtils.getRefClass;
|
|
||||||
|
|
||||||
import com.intellectualcrafters.plot.PS;
|
import com.intellectualcrafters.plot.PS;
|
||||||
import com.intellectualcrafters.plot.config.Settings;
|
import com.intellectualcrafters.plot.config.Settings;
|
||||||
import com.intellectualcrafters.plot.object.Location;
|
import com.intellectualcrafters.plot.object.Location;
|
||||||
@ -10,6 +8,8 @@ import com.intellectualcrafters.plot.util.ReflectionUtils.RefClass;
|
|||||||
import com.intellectualcrafters.plot.util.ReflectionUtils.RefField;
|
import com.intellectualcrafters.plot.util.ReflectionUtils.RefField;
|
||||||
import com.intellectualcrafters.plot.util.ReflectionUtils.RefMethod;
|
import com.intellectualcrafters.plot.util.ReflectionUtils.RefMethod;
|
||||||
import com.intellectualcrafters.plot.util.TaskManager;
|
import com.intellectualcrafters.plot.util.TaskManager;
|
||||||
|
import java.lang.reflect.Method;
|
||||||
|
import java.util.HashSet;
|
||||||
import org.bukkit.Bukkit;
|
import org.bukkit.Bukkit;
|
||||||
import org.bukkit.Chunk;
|
import org.bukkit.Chunk;
|
||||||
import org.bukkit.Material;
|
import org.bukkit.Material;
|
||||||
@ -28,8 +28,8 @@ import org.bukkit.event.entity.ItemSpawnEvent;
|
|||||||
import org.bukkit.event.world.ChunkLoadEvent;
|
import org.bukkit.event.world.ChunkLoadEvent;
|
||||||
import org.bukkit.event.world.ChunkUnloadEvent;
|
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 {
|
public class ChunkListener implements Listener {
|
||||||
|
|
||||||
@ -100,14 +100,21 @@ public class ChunkListener implements Listener {
|
|||||||
}, 1);
|
}, 1);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private boolean ignoreUnload = false;
|
||||||
|
|
||||||
public boolean unloadChunk(String world, Chunk chunk, boolean safe) {
|
public boolean unloadChunk(String world, Chunk chunk, boolean safe) {
|
||||||
if (safe && shouldSave(world, chunk.getX(), chunk.getZ())) {
|
if (safe && shouldSave(world, chunk.getX(), chunk.getZ())) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
Object c = this.methodGetHandleChunk.of(chunk).call();
|
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()) {
|
if (chunk.isLoaded()) {
|
||||||
|
ignoreUnload = true;
|
||||||
chunk.unload(false, false);
|
chunk.unload(false, false);
|
||||||
|
ignoreUnload = false;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
@ -139,6 +146,9 @@ public class ChunkListener implements Listener {
|
|||||||
|
|
||||||
@EventHandler
|
@EventHandler
|
||||||
public void onChunkUnload(ChunkUnloadEvent event) {
|
public void onChunkUnload(ChunkUnloadEvent event) {
|
||||||
|
if (ignoreUnload) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
if (Settings.Chunk_Processor.AUTO_TRIM) {
|
if (Settings.Chunk_Processor.AUTO_TRIM) {
|
||||||
Chunk chunk = event.getChunk();
|
Chunk chunk = event.getChunk();
|
||||||
String world = chunk.getWorld().getName();
|
String world = chunk.getWorld().getName();
|
||||||
|
@ -0,0 +1,41 @@
|
|||||||
|
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 (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;
|
package com.plotsquared.bukkit.listeners;
|
||||||
|
|
||||||
|
import com.google.common.collect.Iterables;
|
||||||
import com.intellectualcrafters.plot.flag.Flags;
|
import com.intellectualcrafters.plot.flag.Flags;
|
||||||
import com.intellectualcrafters.plot.object.Location;
|
import com.intellectualcrafters.plot.object.Location;
|
||||||
import com.intellectualcrafters.plot.object.Plot;
|
import com.intellectualcrafters.plot.object.Plot;
|
||||||
import com.intellectualcrafters.plot.object.PlotPlayer;
|
import com.intellectualcrafters.plot.object.PlotPlayer;
|
||||||
import com.plotsquared.bukkit.object.BukkitPlayer;
|
import com.plotsquared.bukkit.object.BukkitPlayer;
|
||||||
import com.plotsquared.bukkit.util.BukkitUtil;
|
import com.plotsquared.bukkit.util.BukkitUtil;
|
||||||
import org.bukkit.entity.Entity;
|
|
||||||
import org.bukkit.entity.Player;
|
import org.bukkit.entity.Player;
|
||||||
import org.bukkit.event.Listener;
|
|
||||||
import org.bukkit.util.Vector;
|
import org.bukkit.util.Vector;
|
||||||
|
|
||||||
import java.util.HashSet;
|
import java.util.HashSet;
|
||||||
import java.util.Set;
|
import java.util.Set;
|
||||||
import java.util.UUID;
|
import java.util.UUID;
|
||||||
|
|
||||||
public class ForceFieldListener implements Listener {
|
public class ForceFieldListener {
|
||||||
|
|
||||||
private static Set<PlotPlayer> getNearbyPlayers(Player player, Plot plot) {
|
private static Set<PlotPlayer> getNearbyPlayers(Player player, Plot plot) {
|
||||||
Set<PlotPlayer> players = new HashSet<>();
|
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;
|
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;
|
continue;
|
||||||
}
|
}
|
||||||
if (!plot.isAdded(plotPlayer.getUUID())) {
|
if (!plot.isAdded(plotPlayer.getUUID())) {
|
||||||
@ -32,15 +31,9 @@ public class ForceFieldListener implements Listener {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private static PlotPlayer hasNearbyPermitted(Player player, Plot plot) {
|
private static PlotPlayer hasNearbyPermitted(Player player, Plot plot) {
|
||||||
for (Entity entity : player.getNearbyEntities(5d, 5d, 5d)) {
|
for (Player nearPlayer : Iterables.filter(player.getNearbyEntities(5d, 5d, 5d),Player.class)) {
|
||||||
if (!(entity instanceof Player)) {
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
PlotPlayer plotPlayer;
|
PlotPlayer plotPlayer;
|
||||||
if ((plotPlayer = BukkitUtil.getPlayer((Player) entity)) == null) {
|
if ((plotPlayer = BukkitUtil.getPlayer(nearPlayer)) == null || !plot.equals(plotPlayer.getCurrentPlot())) {
|
||||||
continue;
|
|
||||||
}
|
|
||||||
if (!plot.equals(plotPlayer.getCurrentPlot())) {
|
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
if (plot.isAdded(plotPlayer.getUUID())) {
|
if (plot.isAdded(plotPlayer.getUUID())) {
|
||||||
|
@ -28,16 +28,6 @@ import com.plotsquared.bukkit.object.BukkitPlayer;
|
|||||||
import com.plotsquared.bukkit.util.BukkitUtil;
|
import com.plotsquared.bukkit.util.BukkitUtil;
|
||||||
import com.plotsquared.listener.PlayerBlockEventType;
|
import com.plotsquared.listener.PlayerBlockEventType;
|
||||||
import com.plotsquared.listener.PlotListener;
|
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.Bukkit;
|
||||||
import org.bukkit.ChatColor;
|
import org.bukkit.ChatColor;
|
||||||
import org.bukkit.Material;
|
import org.bukkit.Material;
|
||||||
@ -86,7 +76,9 @@ import org.bukkit.event.block.BlockSpreadEvent;
|
|||||||
import org.bukkit.event.block.EntityBlockFormEvent;
|
import org.bukkit.event.block.EntityBlockFormEvent;
|
||||||
import org.bukkit.event.entity.CreatureSpawnEvent;
|
import org.bukkit.event.entity.CreatureSpawnEvent;
|
||||||
import org.bukkit.event.entity.EntityChangeBlockEvent;
|
import org.bukkit.event.entity.EntityChangeBlockEvent;
|
||||||
|
import org.bukkit.event.entity.EntityCombustByEntityEvent;
|
||||||
import org.bukkit.event.entity.EntityDamageByEntityEvent;
|
import org.bukkit.event.entity.EntityDamageByEntityEvent;
|
||||||
|
import org.bukkit.event.entity.EntityDamageEvent;
|
||||||
import org.bukkit.event.entity.EntityExplodeEvent;
|
import org.bukkit.event.entity.EntityExplodeEvent;
|
||||||
import org.bukkit.event.entity.ExplosionPrimeEvent;
|
import org.bukkit.event.entity.ExplosionPrimeEvent;
|
||||||
import org.bukkit.event.entity.PotionSplashEvent;
|
import org.bukkit.event.entity.PotionSplashEvent;
|
||||||
@ -121,6 +113,17 @@ import org.bukkit.projectiles.BlockProjectileSource;
|
|||||||
import org.bukkit.projectiles.ProjectileSource;
|
import org.bukkit.projectiles.ProjectileSource;
|
||||||
import org.bukkit.util.Vector;
|
import org.bukkit.util.Vector;
|
||||||
|
|
||||||
|
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;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Player Events involving plots.
|
* Player Events involving plots.
|
||||||
*
|
*
|
||||||
@ -279,8 +282,7 @@ public class PlayerEvents extends PlotListener implements Listener {
|
|||||||
if (!(shooter instanceof Player)) {
|
if (!(shooter instanceof Player)) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
ThrownPotion potion = (ThrownPotion) entity;
|
Location l = BukkitUtil.getLocation(entity);
|
||||||
Location l = BukkitUtil.getLocation(potion);
|
|
||||||
if (!PS.get().hasPlotArea(l.getWorld())) {
|
if (!PS.get().hasPlotArea(l.getWorld())) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@ -410,7 +412,6 @@ public class PlayerEvents extends PlotListener implements Listener {
|
|||||||
pattern = RegExUtil.compiledPatterns.get(s);
|
pattern = RegExUtil.compiledPatterns.get(s);
|
||||||
}
|
}
|
||||||
if (pattern.matcher(msg).matches()) {
|
if (pattern.matcher(msg).matches()) {
|
||||||
MainUtil.sendMessage(pp, C.COMMAND_BLOCKED);
|
|
||||||
String perm;
|
String perm;
|
||||||
if (plot.isAdded(pp.getUUID())) {
|
if (plot.isAdded(pp.getUUID())) {
|
||||||
perm = "plots.admin.command.blocked-cmds.shared";
|
perm = "plots.admin.command.blocked-cmds.shared";
|
||||||
@ -418,6 +419,7 @@ public class PlayerEvents extends PlotListener implements Listener {
|
|||||||
perm = "plots.admin.command.blocked-cmds.other";
|
perm = "plots.admin.command.blocked-cmds.other";
|
||||||
}
|
}
|
||||||
if (!Permissions.hasPermission(pp, perm)) {
|
if (!Permissions.hasPermission(pp, perm)) {
|
||||||
|
MainUtil.sendMessage(pp, C.COMMAND_BLOCKED);
|
||||||
event.setCancelled(true);
|
event.setCancelled(true);
|
||||||
}
|
}
|
||||||
return;
|
return;
|
||||||
@ -699,7 +701,7 @@ public class PlayerEvents extends PlotListener implements Listener {
|
|||||||
if (this.lastRadius != 0) {
|
if (this.lastRadius != 0) {
|
||||||
List<Entity> nearby = event.getEntity().getNearbyEntities(this.lastRadius, this.lastRadius, this.lastRadius);
|
List<Entity> nearby = event.getEntity().getNearbyEntities(this.lastRadius, this.lastRadius, this.lastRadius);
|
||||||
for (Entity near : nearby) {
|
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")) {
|
if (!near.hasMetadata("plot")) {
|
||||||
near.setMetadata("plot", new FixedMetadataValue((Plugin) PS.get().IMP, plot));
|
near.setMetadata("plot", new FixedMetadataValue((Plugin) PS.get().IMP, plot));
|
||||||
}
|
}
|
||||||
@ -898,8 +900,19 @@ public class PlayerEvents extends PlotListener implements Listener {
|
|||||||
if (plot != null) {
|
if (plot != null) {
|
||||||
if (Flags.DISABLE_PHYSICS.isFalse(plot)) {
|
if (Flags.DISABLE_PHYSICS.isFalse(plot)) {
|
||||||
event.setCancelled(true);
|
event.setCancelled(true);
|
||||||
|
return;
|
||||||
} else if (!area.contains(fLocation.getX(), fLocation.getZ()) || !Objects.equals(plot, area.getOwnedPlot(fLocation))) {
|
} else if (!area.contains(fLocation.getX(), fLocation.getZ()) || !Objects.equals(plot, area.getOwnedPlot(fLocation))) {
|
||||||
event.setCancelled(true);
|
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))) {
|
} else if (!area.contains(fLocation.getX(), fLocation.getZ()) || !Objects.equals(plot, area.getOwnedPlot(fLocation))) {
|
||||||
event.setCancelled(true);
|
event.setCancelled(true);
|
||||||
@ -941,12 +954,12 @@ public class PlayerEvents extends PlotListener implements Listener {
|
|||||||
}
|
}
|
||||||
List<Block> blocks = event.getBlocks();
|
List<Block> blocks = event.getBlocks();
|
||||||
for (Block b : blocks) {
|
for (Block b : blocks) {
|
||||||
Location bloc = BukkitUtil.getLocation(b.getLocation().add(relative));
|
Location bloc = BukkitUtil.getLocation(b.getLocation());
|
||||||
if (!area.contains(bloc.getX(), bloc.getZ())) {
|
if (!area.contains(bloc.getX(), bloc.getZ()) || !area.contains(bloc.getX() + relative.getBlockX(), bloc.getZ() + relative.getBlockZ())) {
|
||||||
event.setCancelled(true);
|
event.setCancelled(true);
|
||||||
return;
|
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);
|
event.setCancelled(true);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@ -1087,7 +1100,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) {
|
public void onInteract(PlayerInteractEvent event) {
|
||||||
Player player = event.getPlayer();
|
Player player = event.getPlayer();
|
||||||
PlotPlayer pp = BukkitUtil.getPlayer(player);
|
PlotPlayer pp = BukkitUtil.getPlayer(player);
|
||||||
@ -1174,14 +1187,13 @@ public class PlayerEvents extends PlotListener implements Listener {
|
|||||||
}
|
}
|
||||||
lb = new BukkitLazyBlock(blockId, block);
|
lb = new BukkitLazyBlock(blockId, block);
|
||||||
ItemStack hand = player.getItemInHand();
|
ItemStack hand = player.getItemInHand();
|
||||||
if (eventType != null) {
|
if (eventType != null && (eventType != PlayerBlockEventType.INTERACT_BLOCK || !player.isSneaking())) {
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
Material type = (hand == null) ? null : hand.getType();
|
Material type = (hand == null) ? null : hand.getType();
|
||||||
int id = (type == null) ? 0 : type.getId();
|
int id = (type == null) ? 0 : type.getId();
|
||||||
if (id == 0) {
|
if (id == 0) {
|
||||||
eventType = PlayerBlockEventType.INTERACT_BLOCK;
|
eventType = PlayerBlockEventType.INTERACT_BLOCK;
|
||||||
lb = new BukkitLazyBlock(0, block);
|
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
if (id < 198) {
|
if (id < 198) {
|
||||||
@ -1272,7 +1284,7 @@ public class PlayerEvents extends PlotListener implements Listener {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@EventHandler(priority = EventPriority.HIGHEST, ignoreCancelled = true)
|
@EventHandler(priority = EventPriority.HIGHEST, ignoreCancelled = true)
|
||||||
public void MobSpawn(CreatureSpawnEvent event) {
|
public void creatureSpawnEvent(CreatureSpawnEvent event) {
|
||||||
Entity entity = event.getEntity();
|
Entity entity = event.getEntity();
|
||||||
Location location = BukkitUtil.getLocation(entity.getLocation());
|
Location location = BukkitUtil.getLocation(entity.getLocation());
|
||||||
PlotArea area = location.getPlotArea();
|
PlotArea area = location.getPlotArea();
|
||||||
@ -1318,10 +1330,6 @@ public class PlayerEvents extends PlotListener implements Listener {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
if (checkEntity(entity, plot)) {
|
if (checkEntity(entity, plot)) {
|
||||||
PlotPlayer owner = UUIDHandler.getPlayer(plot.owner);
|
|
||||||
if (owner != null) {
|
|
||||||
C.ENTITY_CAP.send(owner);
|
|
||||||
}
|
|
||||||
event.setCancelled(true);
|
event.setCancelled(true);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -1368,7 +1376,10 @@ public class PlayerEvents extends PlotListener implements Listener {
|
|||||||
this.lastRadius = event.getRadius() + 1;
|
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;
|
int[] mobs = null;
|
||||||
for (IntegerFlag flag : flags) {
|
for (IntegerFlag flag : flags) {
|
||||||
int i;
|
int i;
|
||||||
@ -1398,17 +1409,52 @@ public class PlayerEvents extends PlotListener implements Listener {
|
|||||||
if (cap == Integer.MAX_VALUE) {
|
if (cap == Integer.MAX_VALUE) {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
if (cap == 0) {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
if (mobs == null) {
|
if (mobs == null) {
|
||||||
mobs = plot.countEntities();
|
mobs = plot.countEntities();
|
||||||
}
|
}
|
||||||
if (mobs[i] >= cap) {
|
if (mobs[i] >= cap) {
|
||||||
|
plot.setMeta("EntityCount", mobs);
|
||||||
|
plot.setMeta("EntityCountTime", System.currentTimeMillis());
|
||||||
return true;
|
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;
|
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()) {
|
if (plot == null || !plot.hasOwner() || plot.getFlags().isEmpty() && plot.getArea().DEFAULT_FLAGS.isEmpty()) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
@ -1461,6 +1507,7 @@ public class PlayerEvents extends PlotListener implements Listener {
|
|||||||
case MINECART_TNT:
|
case MINECART_TNT:
|
||||||
case BOAT:
|
case BOAT:
|
||||||
return checkEntity(plot, Flags.ENTITY_CAP, Flags.VEHICLE_CAP);
|
return checkEntity(plot, Flags.ENTITY_CAP, Flags.VEHICLE_CAP);
|
||||||
|
case POLAR_BEAR:
|
||||||
case RABBIT:
|
case RABBIT:
|
||||||
case SHEEP:
|
case SHEEP:
|
||||||
case MUSHROOM_COW:
|
case MUSHROOM_COW:
|
||||||
@ -1641,7 +1688,7 @@ public class PlayerEvents extends PlotListener implements Listener {
|
|||||||
if (area == null) {
|
if (area == null) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
Plot now = area.getPlotAbs(loc);
|
Plot now = area.getPlot(loc);
|
||||||
Plot lastPlot = pp.getMeta("lastplot");
|
Plot lastPlot = pp.getMeta("lastplot");
|
||||||
if (now == null) {
|
if (now == null) {
|
||||||
if (lastPlot != null && !plotExit(pp, lastPlot) && this.tmpTeleport) {
|
if (lastPlot != null && !plotExit(pp, lastPlot) && this.tmpTeleport) {
|
||||||
@ -1662,6 +1709,9 @@ public class PlayerEvents extends PlotListener implements Listener {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
} else if (lastPlot != null && now.equals(lastPlot)) {
|
} else if (lastPlot != null && now.equals(lastPlot)) {
|
||||||
|
if (!Flags.DENY_TELEPORT.allowsTeleport(pp, lastPlot)) {
|
||||||
|
event.setTo(BukkitUtil.getLocation(lastPlot.getSide()));
|
||||||
|
}
|
||||||
return;
|
return;
|
||||||
} else if (!plotEntry(pp, now) && this.tmpTeleport) {
|
} else if (!plotEntry(pp, now) && this.tmpTeleport) {
|
||||||
MainUtil.sendMessage(pp, C.NO_PERMISSION_EVENT, C.PERMISSION_ADMIN_ENTRY_DENIED);
|
MainUtil.sendMessage(pp, C.NO_PERMISSION_EVENT, C.PERMISSION_ADMIN_ENTRY_DENIED);
|
||||||
@ -1711,7 +1761,7 @@ public class PlayerEvents extends PlotListener implements Listener {
|
|||||||
if (area == null) {
|
if (area == null) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
Plot now = area.getPlotAbs(loc);
|
Plot now = area.getPlot(loc);
|
||||||
Plot lastPlot = pp.getMeta("lastplot");
|
Plot lastPlot = pp.getMeta("lastplot");
|
||||||
if (now == null) {
|
if (now == null) {
|
||||||
if (lastPlot != null && !plotExit(pp, lastPlot) && this.tmpTeleport) {
|
if (lastPlot != null && !plotExit(pp, lastPlot) && this.tmpTeleport) {
|
||||||
@ -1732,6 +1782,9 @@ public class PlayerEvents extends PlotListener implements Listener {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
} else if (lastPlot != null && now.equals(lastPlot)) {
|
} else if (lastPlot != null && now.equals(lastPlot)) {
|
||||||
|
if (!Flags.DENY_TELEPORT.allowsTeleport(pp, lastPlot)) {
|
||||||
|
event.setTo(BukkitUtil.getLocation(lastPlot.getSide()));
|
||||||
|
}
|
||||||
return;
|
return;
|
||||||
} else if (!plotEntry(pp, now) && this.tmpTeleport) {
|
} else if (!plotEntry(pp, now) && this.tmpTeleport) {
|
||||||
MainUtil.sendMessage(pp, C.NO_PERMISSION_EVENT, C.PERMISSION_ADMIN_ENTRY_DENIED);
|
MainUtil.sendMessage(pp, C.NO_PERMISSION_EVENT, C.PERMISSION_ADMIN_ENTRY_DENIED);
|
||||||
@ -1833,6 +1886,9 @@ public class PlayerEvents extends PlotListener implements Listener {
|
|||||||
|
|
||||||
@EventHandler(priority = EventPriority.MONITOR)
|
@EventHandler(priority = EventPriority.MONITOR)
|
||||||
public void onLeave(PlayerQuitEvent event) {
|
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());
|
PlotPlayer pp = BukkitUtil.getPlayer(event.getPlayer());
|
||||||
pp.unregister();
|
pp.unregister();
|
||||||
}
|
}
|
||||||
@ -2097,6 +2153,13 @@ public class PlayerEvents extends PlotListener implements Listener {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@SuppressWarnings("deprecation")
|
||||||
|
@EventHandler(priority = EventPriority.HIGHEST)
|
||||||
|
public void onEntityCombustByEntity(EntityCombustByEntityEvent event) {
|
||||||
|
EntityDamageByEntityEvent eventChange = new EntityDamageByEntityEvent(event.getCombuster(), event.getEntity(), EntityDamageEvent.DamageCause.FIRE_TICK, event.getDuration());
|
||||||
|
onEntityDamageByEntityEvent(eventChange);
|
||||||
|
}
|
||||||
|
|
||||||
@EventHandler(priority = EventPriority.HIGHEST)
|
@EventHandler(priority = EventPriority.HIGHEST)
|
||||||
public void onEntityDamageByEntityEvent(EntityDamageByEntityEvent event) {
|
public void onEntityDamageByEntityEvent(EntityDamageByEntityEvent event) {
|
||||||
Entity damager = event.getDamager();
|
Entity damager = event.getDamager();
|
||||||
|
@ -12,9 +12,12 @@ import org.bukkit.Effect;
|
|||||||
import org.bukkit.GameMode;
|
import org.bukkit.GameMode;
|
||||||
import org.bukkit.WeatherType;
|
import org.bukkit.WeatherType;
|
||||||
import org.bukkit.entity.Player;
|
import org.bukkit.entity.Player;
|
||||||
|
import org.bukkit.event.EventException;
|
||||||
|
import org.bukkit.event.player.PlayerTeleportEvent;
|
||||||
import org.bukkit.event.player.PlayerTeleportEvent.TeleportCause;
|
import org.bukkit.event.player.PlayerTeleportEvent.TeleportCause;
|
||||||
|
|
||||||
import java.util.UUID;
|
import java.util.UUID;
|
||||||
|
import org.bukkit.plugin.RegisteredListener;
|
||||||
|
|
||||||
public class BukkitPlayer extends PlotPlayer {
|
public class BukkitPlayer extends PlotPlayer {
|
||||||
|
|
||||||
@ -57,6 +60,39 @@ public class BukkitPlayer extends PlotPlayer {
|
|||||||
return this.player.getLastPlayed();
|
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("PlotSquared")) {
|
||||||
|
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("PlotSquared")) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
try {
|
||||||
|
listener.callEvent(event);
|
||||||
|
} catch (EventException e) {
|
||||||
|
e.printStackTrace();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean hasPermission(String permission) {
|
public boolean hasPermission(String permission) {
|
||||||
if (this.offline && EconHandler.manager != null) {
|
if (this.offline && EconHandler.manager != null) {
|
||||||
@ -67,8 +103,9 @@ public class BukkitPlayer extends PlotPlayer {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void sendMessage(String message) {
|
public void sendMessage(String message) {
|
||||||
if (!StringMan.isEqual(this.<String>getMeta("lastMessage"), message)) {
|
if (!StringMan.isEqual(this.<String>getMeta("lastMessage"), message) || (System.currentTimeMillis() - this.<Long>getMeta("lastMessageTime") > 5000)) {
|
||||||
setMeta("lastMessage", message);
|
setMeta("lastMessage", message);
|
||||||
|
setMeta("lastMessageTime", System.currentTimeMillis());
|
||||||
this.player.sendMessage(message);
|
this.player.sendMessage(message);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -366,7 +366,11 @@ public class EntityWrapper {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private void restoreInventory(InventoryHolder entity) {
|
private void restoreInventory(InventoryHolder entity) {
|
||||||
|
try {
|
||||||
entity.getInventory().setContents(this.inventory);
|
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) {
|
public void storeLiving(LivingEntity lived) {
|
||||||
|
@ -30,7 +30,6 @@ public class DefaultTitleManager_183 extends DefaultTitleManager {
|
|||||||
this.chatBaseComponent = Reflection.getNMSClass("IChatBaseComponent");
|
this.chatBaseComponent = Reflection.getNMSClass("IChatBaseComponent");
|
||||||
this.packetActions = Reflection.getNMSClass("PacketPlayOutTitle$EnumTitleAction");
|
this.packetActions = Reflection.getNMSClass("PacketPlayOutTitle$EnumTitleAction");
|
||||||
this.nmsChatSerializer = Reflection.getNMSClass("IChatBaseComponent$ChatSerializer");
|
this.nmsChatSerializer = Reflection.getNMSClass("IChatBaseComponent$ChatSerializer");
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -52,7 +52,7 @@ public abstract class TitleManager {
|
|||||||
abstract void loadClasses();
|
abstract void loadClasses();
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Get title text.
|
* Gets title text.
|
||||||
*
|
*
|
||||||
* @return 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
|
* @param title Title
|
||||||
*/
|
*/
|
||||||
@ -70,7 +70,7 @@ public abstract class TitleManager {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Get subtitle text.
|
* Gets the subtitle text.
|
||||||
*
|
*
|
||||||
* @return Subtitle text
|
* @return Subtitle text
|
||||||
*/
|
*/
|
||||||
@ -79,7 +79,7 @@ public abstract class TitleManager {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Set subtitle text.
|
* Sets subtitle text.
|
||||||
*
|
*
|
||||||
* @param subtitle 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
|
* @param color Chat color
|
||||||
*/
|
*/
|
||||||
@ -97,7 +97,7 @@ public abstract class TitleManager {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Set the subtitle color.
|
* Sets the subtitle color.
|
||||||
*
|
*
|
||||||
* @param color Chat 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
|
* @param time Time
|
||||||
*/
|
*/
|
||||||
@ -115,7 +115,7 @@ public abstract class TitleManager {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Set title fade out time.
|
* Sets title fade out time.
|
||||||
*
|
*
|
||||||
* @param time Time
|
* @param time Time
|
||||||
*/
|
*/
|
||||||
@ -124,7 +124,7 @@ public abstract class TitleManager {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Set title stay time.
|
* Sets title stay time.
|
||||||
*
|
*
|
||||||
* @param time Time
|
* @param time Time
|
||||||
*/
|
*/
|
||||||
@ -133,21 +133,21 @@ public abstract class TitleManager {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Set timings to ticks.
|
* Sets timings to ticks.
|
||||||
*/
|
*/
|
||||||
public final void setTimingsToTicks() {
|
public final void setTimingsToTicks() {
|
||||||
this.ticks = true;
|
this.ticks = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Set timings to seconds.
|
* Sets timings to seconds.
|
||||||
*/
|
*/
|
||||||
public final void setTimingsToSeconds() {
|
public final void setTimingsToSeconds() {
|
||||||
this.ticks = false;
|
this.ticks = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Send the title to a player.
|
* Sends the title to a player.
|
||||||
*
|
*
|
||||||
* @param player Player
|
* @param player Player
|
||||||
* @throws IllegalArgumentException
|
* @throws IllegalArgumentException
|
||||||
@ -157,18 +157,18 @@ public abstract class TitleManager {
|
|||||||
public abstract void send(Player player) throws IllegalArgumentException, ReflectiveOperationException, SecurityException;
|
public abstract void send(Player player) throws IllegalArgumentException, ReflectiveOperationException, SecurityException;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Broadcast the title to all players.
|
* Broadcasts the title to all players.
|
||||||
*
|
*
|
||||||
* @throws Exception
|
* @throws Exception
|
||||||
*/
|
*/
|
||||||
public final void broadcast() throws Exception {
|
public final void broadcast() throws Exception {
|
||||||
for (Player p : Bukkit.getOnlinePlayers()) {
|
for (Player player : Bukkit.getOnlinePlayers()) {
|
||||||
send(p);
|
send(player);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Clear the title.
|
* Clears the title.
|
||||||
*
|
*
|
||||||
* @param player Player
|
* @param player Player
|
||||||
* @throws IllegalArgumentException
|
* @throws IllegalArgumentException
|
||||||
@ -178,7 +178,7 @@ public abstract class TitleManager {
|
|||||||
public abstract void clearTitle(Player player) throws IllegalArgumentException, ReflectiveOperationException, SecurityException;
|
public abstract void clearTitle(Player player) throws IllegalArgumentException, ReflectiveOperationException, SecurityException;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Reset the title settings.
|
* Resets the title settings.
|
||||||
*
|
*
|
||||||
* @param player Player
|
* @param player Player
|
||||||
* @throws IllegalArgumentException
|
* @throws IllegalArgumentException
|
||||||
@ -195,7 +195,7 @@ public abstract class TitleManager {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
final Class<?>[] toPrimitiveTypeArray(Class<?>[] classes) {
|
private Class<?>[] toPrimitiveTypeArray(Class<?>[] classes) {
|
||||||
int a;
|
int a;
|
||||||
if (classes != null) {
|
if (classes != null) {
|
||||||
a = classes.length;
|
a = classes.length;
|
||||||
@ -229,7 +229,7 @@ public abstract class TitleManager {
|
|||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
final boolean equalsTypeArray(Class<?>[] a, Class<?>[] o) {
|
private boolean equalsTypeArray(Class<?>[] a, Class<?>[] o) {
|
||||||
if (a.length != o.length) {
|
if (a.length != o.length) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
@ -17,14 +17,6 @@ import com.intellectualcrafters.plot.util.block.GlobalBlockQueue;
|
|||||||
import com.intellectualcrafters.plot.util.block.LocalBlockQueue;
|
import com.intellectualcrafters.plot.util.block.LocalBlockQueue;
|
||||||
import com.intellectualcrafters.plot.util.block.ScopedLocalBlockQueue;
|
import com.intellectualcrafters.plot.util.block.ScopedLocalBlockQueue;
|
||||||
import com.plotsquared.bukkit.object.entity.EntityWrapper;
|
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.Bukkit;
|
||||||
import org.bukkit.Chunk;
|
import org.bukkit.Chunk;
|
||||||
import org.bukkit.DyeColor;
|
import org.bukkit.DyeColor;
|
||||||
@ -57,6 +49,15 @@ import org.bukkit.entity.Player;
|
|||||||
import org.bukkit.inventory.InventoryHolder;
|
import org.bukkit.inventory.InventoryHolder;
|
||||||
import org.bukkit.inventory.ItemStack;
|
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 class BukkitChunkManager extends ChunkManager {
|
||||||
|
|
||||||
public static boolean isIn(RegionWrapper region, int x, int z) {
|
public static boolean isIn(RegionWrapper region, int x, int z) {
|
||||||
@ -424,6 +425,10 @@ public class BukkitChunkManager extends ChunkManager {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public int[] countEntities(Plot plot) {
|
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();
|
PlotArea area = plot.getArea();
|
||||||
World world = BukkitUtil.getWorld(area.worldname);
|
World world = BukkitUtil.getWorld(area.worldname);
|
||||||
|
|
||||||
@ -448,9 +453,9 @@ public class BukkitChunkManager extends ChunkManager {
|
|||||||
|
|
||||||
boolean doWhole = false;
|
boolean doWhole = false;
|
||||||
List<Entity> entities = null;
|
List<Entity> entities = null;
|
||||||
if (size > 200) {
|
if (size > 200 && chunks.size() > 200) {
|
||||||
entities = world.getEntities();
|
entities = world.getEntities();
|
||||||
if (entities.size() < 16 + size * size / 64) {
|
if (entities.size() < 16 + size / 8) {
|
||||||
doWhole = true;
|
doWhole = true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -534,6 +539,7 @@ public class BukkitChunkManager extends ChunkManager {
|
|||||||
case PAINTING:
|
case PAINTING:
|
||||||
case ARMOR_STAND:
|
case ARMOR_STAND:
|
||||||
count[5]++;
|
count[5]++;
|
||||||
|
break;
|
||||||
// misc
|
// misc
|
||||||
case MINECART:
|
case MINECART:
|
||||||
case MINECART_CHEST:
|
case MINECART_CHEST:
|
||||||
@ -545,6 +551,7 @@ public class BukkitChunkManager extends ChunkManager {
|
|||||||
case BOAT:
|
case BOAT:
|
||||||
count[4]++;
|
count[4]++;
|
||||||
break;
|
break;
|
||||||
|
case POLAR_BEAR:
|
||||||
case RABBIT:
|
case RABBIT:
|
||||||
case SHEEP:
|
case SHEEP:
|
||||||
case MUSHROOM_COW:
|
case MUSHROOM_COW:
|
||||||
|
@ -1,6 +1,5 @@
|
|||||||
package com.plotsquared.bukkit.util;
|
package com.plotsquared.bukkit.util;
|
||||||
|
|
||||||
import com.intellectualcrafters.plot.PS;
|
|
||||||
import org.bukkit.Bukkit;
|
import org.bukkit.Bukkit;
|
||||||
import org.bukkit.entity.Player;
|
import org.bukkit.entity.Player;
|
||||||
import org.bukkit.plugin.Plugin;
|
import org.bukkit.plugin.Plugin;
|
||||||
@ -9,71 +8,38 @@ import org.bukkit.scheduler.BukkitTask;
|
|||||||
|
|
||||||
import java.io.BufferedReader;
|
import java.io.BufferedReader;
|
||||||
import java.io.ByteArrayOutputStream;
|
import java.io.ByteArrayOutputStream;
|
||||||
import java.io.File;
|
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
import java.io.InputStreamReader;
|
import java.io.InputStreamReader;
|
||||||
import java.io.OutputStream;
|
import java.io.OutputStream;
|
||||||
import java.io.UnsupportedEncodingException;
|
import java.io.UnsupportedEncodingException;
|
||||||
import java.lang.reflect.InvocationTargetException;
|
import java.lang.reflect.InvocationTargetException;
|
||||||
import java.net.Proxy;
|
|
||||||
import java.net.URL;
|
import java.net.URL;
|
||||||
import java.net.URLConnection;
|
import java.net.URLConnection;
|
||||||
import java.net.URLEncoder;
|
import java.net.URLEncoder;
|
||||||
import java.util.Collection;
|
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.UUID;
|
||||||
import java.util.logging.Level;
|
|
||||||
import java.util.zip.GZIPOutputStream;
|
import java.util.zip.GZIPOutputStream;
|
||||||
|
|
||||||
public class Metrics {
|
public class Metrics {
|
||||||
|
|
||||||
/**
|
/** The current revision number. */
|
||||||
* The current revision number.
|
|
||||||
*/
|
|
||||||
private static final int REVISION = 7;
|
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";
|
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";
|
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;
|
private static final int PING_INTERVAL = 15;
|
||||||
/**
|
/** The plugin this metrics submits for. */
|
||||||
* The plugin this metrics submits for.
|
|
||||||
*/
|
|
||||||
private final Plugin plugin;
|
private final Plugin plugin;
|
||||||
/**
|
/** Unique server id. */
|
||||||
* All of the custom graphs to submit to metrics.
|
|
||||||
*/
|
|
||||||
private final Set<Graph> graphs = Collections.synchronizedSet(new HashSet<Graph>());
|
|
||||||
/**
|
|
||||||
* Unique server id.
|
|
||||||
*/
|
|
||||||
private final String guid;
|
private final String guid;
|
||||||
/**
|
/** The scheduled task. */
|
||||||
* Debug mode.
|
|
||||||
*/
|
|
||||||
private final boolean debug;
|
|
||||||
/**
|
|
||||||
* The scheduled task.
|
|
||||||
*/
|
|
||||||
private volatile BukkitTask task = null;
|
private volatile BukkitTask task = null;
|
||||||
|
|
||||||
public Metrics(Plugin plugin) {
|
public Metrics(Plugin plugin) {
|
||||||
if (plugin == null) {
|
|
||||||
throw new IllegalArgumentException("Plugin cannot be null");
|
|
||||||
}
|
|
||||||
this.plugin = plugin;
|
this.plugin = plugin;
|
||||||
this.guid = UUID.randomUUID().toString();
|
this.guid = UUID.randomUUID().toString();
|
||||||
this.debug = false;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -186,38 +152,6 @@ public class Metrics {
|
|||||||
return URLEncoder.encode(text, "UTF-8");
|
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
|
* 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
|
* 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;
|
this.firstPost = false;
|
||||||
} catch (IOException e) {
|
} catch (IOException e) {
|
||||||
e.printStackTrace();
|
e.printStackTrace();
|
||||||
if (Metrics.this.debug) {
|
|
||||||
Bukkit.getLogger().log(Level.INFO, "[Metrics] " + e.getMessage());
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}, 0, PING_INTERVAL * 1200);
|
}, 0, PING_INTERVAL * 1200);
|
||||||
return true;
|
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.
|
* Generic method that posts a plugin to the metrics website.
|
||||||
*/
|
*/
|
||||||
@ -342,46 +234,12 @@ public class Metrics {
|
|||||||
if (isPing) {
|
if (isPing) {
|
||||||
appendJSONPair(json, "ping", "1");
|
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
|
// close json
|
||||||
json.append('}');
|
json.append('}');
|
||||||
// Create the url
|
// Create the url
|
||||||
URL url = new URL(BASE_URL + String.format(REPORT_URL, urlEncode(pluginName)));
|
URL url = new URL(BASE_URL + String.format(REPORT_URL, urlEncode(pluginName)));
|
||||||
// Connect to the website
|
// Connect to the website
|
||||||
URLConnection connection;
|
URLConnection connection = url.openConnection();
|
||||||
// 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();
|
|
||||||
}
|
|
||||||
byte[] uncompressed = json.toString().getBytes();
|
byte[] uncompressed = json.toString().getBytes();
|
||||||
byte[] compressed = gzip(json.toString());
|
byte[] compressed = gzip(json.toString());
|
||||||
// Headers
|
// Headers
|
||||||
@ -392,9 +250,6 @@ public class Metrics {
|
|||||||
connection.addRequestProperty("Accept", "application/json");
|
connection.addRequestProperty("Accept", "application/json");
|
||||||
connection.addRequestProperty("Connection", "close");
|
connection.addRequestProperty("Connection", "close");
|
||||||
connection.setDoOutput(true);
|
connection.setDoOutput(true);
|
||||||
if (this.debug) {
|
|
||||||
PS.debug("[Metrics] Prepared request for " + pluginName + " uncompressed=" + uncompressed.length + " compressed=" + compressed.length);
|
|
||||||
}
|
|
||||||
try {
|
try {
|
||||||
try (OutputStream os = connection.getOutputStream()) {
|
try (OutputStream os = connection.getOutputStream()) {
|
||||||
os.write(compressed);
|
os.write(compressed);
|
||||||
@ -403,9 +258,6 @@ public class Metrics {
|
|||||||
String response;
|
String response;
|
||||||
try (BufferedReader reader = new BufferedReader(new InputStreamReader(connection.getInputStream()))) {
|
try (BufferedReader reader = new BufferedReader(new InputStreamReader(connection.getInputStream()))) {
|
||||||
response = reader.readLine();
|
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 || response.startsWith("ERR") || response.startsWith("7")) {
|
||||||
if (response == null) {
|
if (response == null) {
|
||||||
@ -414,171 +266,7 @@ public class Metrics {
|
|||||||
response = response.substring(response.startsWith("7,") ? 2 : 1);
|
response = response.substring(response.startsWith("7,") ? 2 : 1);
|
||||||
}
|
}
|
||||||
throw new IOException(response);
|
throw new IOException(response);
|
||||||
} else {
|
}
|
||||||
// Is this the first update this hour?
|
} catch (IOException ignored) {}
|
||||||
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();
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
@ -26,9 +26,8 @@ import java.util.HashSet;
|
|||||||
import java.util.Map.Entry;
|
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 {
|
public class SendChunk {
|
||||||
|
|
||||||
@ -40,7 +39,7 @@ public class SendChunk {
|
|||||||
private final RefMethod methodInitLighting;
|
private final RefMethod methodInitLighting;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Constructor
|
* Constructor.
|
||||||
*/
|
*/
|
||||||
public SendChunk() throws ClassNotFoundException, NoSuchMethodException, NoSuchFieldException {
|
public SendChunk() throws ClassNotFoundException, NoSuchMethodException, NoSuchFieldException {
|
||||||
RefConstructor tempMapChunk;
|
RefConstructor tempMapChunk;
|
||||||
|
@ -82,9 +82,10 @@ public class BukkitLocalQueue<T> extends BasicLocalBlockQueue<T> {
|
|||||||
if (blocksLayer != null) {
|
if (blocksLayer != null) {
|
||||||
for (int j = 0; j < blocksLayer.length; j++) {
|
for (int j = 0; j < blocksLayer.length; j++) {
|
||||||
PlotBlock block = blocksLayer[j];
|
PlotBlock block = blocksLayer[j];
|
||||||
|
if (block != null) {
|
||||||
int x = MainUtil.x_loc[layer][j];
|
int x = MainUtil.x_loc[layer][j];
|
||||||
int y = MainUtil.y_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);
|
Block existing = chunk.getBlock(x, y, z);
|
||||||
int existingId = existing.getTypeId();
|
int existingId = existing.getTypeId();
|
||||||
if (existingId == block.id) {
|
if (existingId == block.id) {
|
||||||
@ -100,6 +101,7 @@ public class BukkitLocalQueue<T> extends BasicLocalBlockQueue<T> {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
public void setBiomes(LocalChunk<T> lc) {
|
public void setBiomes(LocalChunk<T> lc) {
|
||||||
if (lc.biomes != null) {
|
if (lc.biomes != null) {
|
||||||
|
@ -80,8 +80,8 @@ public class FileUUIDHandler extends UUIDHandlerImplementation {
|
|||||||
e.printStackTrace();
|
e.printStackTrace();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (Settings.UUID.NATIVE_UUID_PROVIDER) {
|
|
||||||
HashBiMap<StringWrapper, UUID> toAdd = HashBiMap.create(new HashMap<StringWrapper, UUID>());
|
HashBiMap<StringWrapper, UUID> toAdd = HashBiMap.create(new HashMap<StringWrapper, UUID>());
|
||||||
|
if (Settings.UUID.NATIVE_UUID_PROVIDER) {
|
||||||
HashSet<UUID> all = UUIDHandler.getAllUUIDS();
|
HashSet<UUID> all = UUIDHandler.getAllUUIDS();
|
||||||
PS.debug("&aFast mode UUID caching enabled!");
|
PS.debug("&aFast mode UUID caching enabled!");
|
||||||
File playerDataFolder = new File(container, world + File.separator + "playerdata");
|
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);
|
ByteSource is = com.google.common.io.Files.asByteSource(file);
|
||||||
NbtFactory.NbtCompound compound = NbtFactory.fromStream(is, NbtFactory.StreamOptions.GZIP_COMPRESSION);
|
NbtFactory.NbtCompound compound = NbtFactory.fromStream(is, NbtFactory.StreamOptions.GZIP_COMPRESSION);
|
||||||
if (!compound.containsKey("bukkit")) {
|
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 {
|
} else {
|
||||||
NbtFactory.NbtCompound bukkit = (NbtFactory.NbtCompound) compound.get("bukkit");
|
NbtFactory.NbtCompound bukkit = (NbtFactory.NbtCompound) compound.get("bukkit");
|
||||||
String name = (String) bukkit.get("lastKnownName");
|
String name = (String) bukkit.get("lastKnownName");
|
||||||
@ -108,7 +108,7 @@ public class FileUUIDHandler extends UUIDHandlerImplementation {
|
|||||||
toAdd.put(new StringWrapper(name), uuid);
|
toAdd.put(new StringWrapper(name), uuid);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} catch (IOException e) {
|
} catch (Exception e) {
|
||||||
e.printStackTrace();
|
e.printStackTrace();
|
||||||
PS.debug(C.PREFIX + "Invalid playerdata: " + current);
|
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");
|
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<String> worlds = Sets.newHashSet(world, "world");
|
||||||
HashSet<UUID> uuids = new HashSet<>();
|
HashSet<UUID> uuids = new HashSet<>();
|
||||||
HashSet<String> names = 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);
|
ByteSource is = com.google.common.io.Files.asByteSource(file);
|
||||||
NbtFactory.NbtCompound compound = NbtFactory.fromStream(is, NbtFactory.StreamOptions.GZIP_COMPRESSION);
|
NbtFactory.NbtCompound compound = NbtFactory.fromStream(is, NbtFactory.StreamOptions.GZIP_COMPRESSION);
|
||||||
if (!compound.containsKey("bukkit")) {
|
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 {
|
} else {
|
||||||
NbtFactory.NbtCompound bukkit = (NbtFactory.NbtCompound) compound.get("bukkit");
|
NbtFactory.NbtCompound bukkit = (NbtFactory.NbtCompound) compound.get("bukkit");
|
||||||
String name = (String) bukkit.get("lastKnownName");
|
String name = (String) bukkit.get("lastKnownName");
|
||||||
|
StringWrapper wrap = new StringWrapper(name);
|
||||||
|
if (!toAdd.containsKey(wrap)) {
|
||||||
long last = (long) bukkit.get("lastPlayed");
|
long last = (long) bukkit.get("lastPlayed");
|
||||||
if (Settings.UUID.OFFLINE) {
|
if (Settings.UUID.OFFLINE) {
|
||||||
if (Settings.UUID.FORCE_LOWERCASE && !name.toLowerCase().equals(name)) {
|
if (Settings.UUID.FORCE_LOWERCASE && !name.toLowerCase().equals(name)) {
|
||||||
@ -181,7 +182,8 @@ public class FileUUIDHandler extends UUIDHandlerImplementation {
|
|||||||
if (ExpireManager.IMP != null) {
|
if (ExpireManager.IMP != null) {
|
||||||
ExpireManager.IMP.storeDate(uuid, last);
|
ExpireManager.IMP.storeDate(uuid, last);
|
||||||
}
|
}
|
||||||
toAdd.put(new StringWrapper(name), uuid);
|
toAdd.put(wrap, uuid);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
} catch (Exception ignored) {
|
} catch (Exception ignored) {
|
||||||
PS.debug(C.PREFIX + "&6Invalid PlayerData: " + uuid.toString() + ".dat");
|
PS.debug(C.PREFIX + "&6Invalid PlayerData: " + uuid.toString() + ".dat");
|
||||||
@ -199,6 +201,7 @@ public class FileUUIDHandler extends UUIDHandlerImplementation {
|
|||||||
if (last != 0) {
|
if (last != 0) {
|
||||||
String name = op.getName();
|
String name = op.getName();
|
||||||
StringWrapper wrap = new StringWrapper(name);
|
StringWrapper wrap = new StringWrapper(name);
|
||||||
|
if (!toAdd.containsKey(wrap)) {
|
||||||
UUID uuid = FileUUIDHandler.this.uuidWrapper.getUUID(op);
|
UUID uuid = FileUUIDHandler.this.uuidWrapper.getUUID(op);
|
||||||
toAdd.put(wrap, uuid);
|
toAdd.put(wrap, uuid);
|
||||||
if (ExpireManager.IMP != null) {
|
if (ExpireManager.IMP != null) {
|
||||||
@ -207,6 +210,7 @@ public class FileUUIDHandler extends UUIDHandlerImplementation {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
add(toAdd);
|
add(toAdd);
|
||||||
if (whenDone != null) {
|
if (whenDone != null) {
|
||||||
whenDone.run();
|
whenDone.run();
|
||||||
|
@ -2,14 +2,14 @@ package com.intellectualcrafters.configuration;
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* Various settings for controlling the input and output of a {@link
|
* Various settings for controlling the input and output of a {@link
|
||||||
* Configuration}
|
* Configuration}.
|
||||||
*/
|
*/
|
||||||
class ConfigurationOptions {
|
class ConfigurationOptions {
|
||||||
private final Configuration configuration;
|
private final Configuration configuration;
|
||||||
private char pathSeparator = '.';
|
private char pathSeparator = '.';
|
||||||
private boolean copyDefaults = false;
|
private boolean copyDefaults = false;
|
||||||
|
|
||||||
protected ConfigurationOptions(final Configuration configuration) {
|
protected ConfigurationOptions(Configuration configuration) {
|
||||||
this.configuration = configuration;
|
this.configuration = configuration;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -24,9 +24,9 @@ class ConfigurationOptions {
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* Gets the char that will be used to separate {@link
|
* Gets the char that will be used to separate {@link
|
||||||
* ConfigurationSection}s
|
* ConfigurationSection}s.
|
||||||
* <p>
|
*
|
||||||
* This value does not affect how the {@link Configuration} is stored,
|
* <p>This value does not affect how the {@link Configuration} is stored,
|
||||||
* only in how you access the data. The default value is '.'.
|
* only in how you access the data. The default value is '.'.
|
||||||
*
|
*
|
||||||
* @return Path separator
|
* @return Path separator
|
||||||
@ -37,15 +37,15 @@ class ConfigurationOptions {
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* Sets the char that will be used to separate {@link
|
* Sets the char that will be used to separate {@link
|
||||||
* ConfigurationSection}s
|
* ConfigurationSection}s.
|
||||||
* <p>
|
*
|
||||||
* This value does not affect how the {@link Configuration} is stored,
|
* <p>This value does not affect how the {@link Configuration} is stored,
|
||||||
* only in how you access the data. The default value is '.'.
|
* only in how you access the data. The default value is '.'.
|
||||||
*
|
*
|
||||||
* @param value Path separator
|
* @param value Path separator
|
||||||
* @return This object, for chaining
|
* @return This object, for chaining
|
||||||
*/
|
*/
|
||||||
public ConfigurationOptions pathSeparator(final char value) {
|
public ConfigurationOptions pathSeparator(char value) {
|
||||||
pathSeparator = value;
|
pathSeparator = value;
|
||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
@ -53,8 +53,8 @@ class ConfigurationOptions {
|
|||||||
/**
|
/**
|
||||||
* Checks if the {@link Configuration} should copy values from its default
|
* Checks if the {@link Configuration} should copy values from its default
|
||||||
* {@link Configuration} directly.
|
* {@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
|
* directly copied, making it impossible to distinguish between values
|
||||||
* that were set and values that are provided by default. As a result,
|
* that were set and values that are provided by default. As a result,
|
||||||
* {@link ConfigurationSection#contains(String)} will always
|
* {@link ConfigurationSection#contains(String)} will always
|
||||||
@ -71,8 +71,8 @@ class ConfigurationOptions {
|
|||||||
/**
|
/**
|
||||||
* Sets if the {@link Configuration} should copy values from its default
|
* Sets if the {@link Configuration} should copy values from its default
|
||||||
* {@link Configuration} directly.
|
* {@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
|
* directly copied, making it impossible to distinguish between values
|
||||||
* that were set and values that are provided by default. As a result,
|
* that were set and values that are provided by default. As a result,
|
||||||
* {@link ConfigurationSection#contains(String)} will always
|
* {@link ConfigurationSection#contains(String)} will always
|
||||||
@ -83,7 +83,7 @@ class ConfigurationOptions {
|
|||||||
* @param value Whether or not defaults are directly copied
|
* @param value Whether or not defaults are directly copied
|
||||||
* @return This object, for chaining
|
* @return This object, for chaining
|
||||||
*/
|
*/
|
||||||
public ConfigurationOptions copyDefaults(final boolean value) {
|
public ConfigurationOptions copyDefaults(boolean value) {
|
||||||
copyDefaults = value;
|
copyDefaults = value;
|
||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
|
@ -5,18 +5,18 @@ import java.util.Map;
|
|||||||
import java.util.Set;
|
import java.util.Set;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Represents a section of a {@link Configuration}
|
* Represents a section of a {@link Configuration}.
|
||||||
*/
|
*/
|
||||||
public interface ConfigurationSection {
|
public interface ConfigurationSection {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Gets a set containing all keys in this section.
|
* 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
|
* child {@link ConfigurationSection}s (and their children, etc). These
|
||||||
* will be in a valid path notation for you to use.
|
* 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.
|
* direct children, and not their own children.
|
||||||
*
|
*
|
||||||
* @param deep Whether or not to get a deep list, as opposed to a shallow
|
* @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.
|
* 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,
|
* within any child {@link ConfigurationSection}s (and their children,
|
||||||
* etc). These keys will be in a valid path notation for you to use.
|
* 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.
|
* 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
|
* @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.
|
* 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.
|
* has been specified, this will return true.
|
||||||
*
|
*
|
||||||
* @param path Path to check for existence.
|
* @param path Path to check for existence.
|
||||||
* @return True if this section contains the requested path, either via
|
* @return True if this section contains the requested path, either via
|
||||||
* default or being set.
|
* default or being set.
|
||||||
* @throws IllegalArgumentException Thrown when path is null.
|
* @throws IllegalArgumentException Thrown when path is {@code null}.
|
||||||
*/
|
*/
|
||||||
boolean contains(String path);
|
boolean contains(String path);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Checks if this {@link ConfigurationSection} has a value set for the
|
* Checks if this {@link ConfigurationSection} has a value set for the
|
||||||
* given path.
|
* 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.
|
* has been specified, this will still return false.
|
||||||
*
|
*
|
||||||
* @param path Path to check for existence.
|
* @param path Path to check for existence.
|
||||||
* @return True if this section contains the requested path, regardless of
|
* @return True if this section contains the requested path, regardless of
|
||||||
* having a default.
|
* having a default.
|
||||||
* @throws IllegalArgumentException Thrown when path is null.
|
* @throws IllegalArgumentException Thrown when path is {@code null}.
|
||||||
*/
|
*/
|
||||||
boolean isSet(String path);
|
boolean isSet(String path);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Gets the path of this {@link ConfigurationSection} from its root {@link
|
* Gets the path of this {@link ConfigurationSection} from its root {@link
|
||||||
* Configuration}
|
* Configuration}.
|
||||||
* <p>
|
*
|
||||||
* For any {@link Configuration} themselves, this will return an empty
|
* <p>For any {@link Configuration} themselves, this will return an empty
|
||||||
* string.
|
* string.
|
||||||
* <p>
|
*
|
||||||
* If the section is no longer contained within its root for any reason,
|
* <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.
|
* such as being replaced with a different value,
|
||||||
* <p>
|
* this may return {@code null}.
|
||||||
* 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>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
|
* @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
|
* Gets the name of this individual {@link ConfigurationSection}, in the
|
||||||
* path.
|
* 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.
|
* the section is orphaned.
|
||||||
*
|
*
|
||||||
* @return Name of this section
|
* @return Name of this section
|
||||||
@ -99,12 +100,13 @@ public interface ConfigurationSection {
|
|||||||
/**
|
/**
|
||||||
* Gets the root {@link Configuration} that contains this {@link
|
* Gets the root {@link Configuration} that contains this {@link
|
||||||
* ConfigurationSection}
|
* ConfigurationSection}
|
||||||
* <p>
|
*
|
||||||
* For any {@link Configuration} themselves, this will return its own
|
* <p>For any {@link Configuration} themselves, this will return its own
|
||||||
* object.
|
* object.
|
||||||
* <p>
|
*
|
||||||
* If the section is no longer contained within its root for any reason,
|
* <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.
|
* such as being replaced with a different value,
|
||||||
|
* this may return {@code null}.
|
||||||
*
|
*
|
||||||
* @return Root configuration containing this section.
|
* @return Root configuration containing this section.
|
||||||
*/
|
*/
|
||||||
@ -113,11 +115,13 @@ public interface ConfigurationSection {
|
|||||||
/**
|
/**
|
||||||
* Gets the parent {@link ConfigurationSection} that directly contains
|
* Gets the parent {@link ConfigurationSection} that directly contains
|
||||||
* this {@link ConfigurationSection}.
|
* this {@link ConfigurationSection}.
|
||||||
* <p>
|
*
|
||||||
* For any {@link Configuration} themselves, this will return null.
|
* <p>For any {@link Configuration} themselves, this will return
|
||||||
* <p>
|
* {@code null}.
|
||||||
* 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>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.
|
* @return Parent section containing this section.
|
||||||
*/
|
*/
|
||||||
@ -125,10 +129,10 @@ public interface ConfigurationSection {
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* Gets the requested Object by path.
|
* 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
|
* 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.
|
* @param path Path of the Object to get.
|
||||||
* @return Requested Object.
|
* @return Requested Object.
|
||||||
@ -138,8 +142,8 @@ public interface ConfigurationSection {
|
|||||||
/**
|
/**
|
||||||
* Gets the requested Object by path, returning a default value if not
|
* Gets the requested Object by path, returning a default value if not
|
||||||
* found.
|
* 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
|
* returned regardless of if a default has been identified in the root
|
||||||
* {@link Configuration}.
|
* {@link Configuration}.
|
||||||
*
|
*
|
||||||
@ -151,11 +155,11 @@ public interface ConfigurationSection {
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* Sets the specified path to the given value.
|
* Sets the specified path to the given value.
|
||||||
* <p>
|
*
|
||||||
* If value is null, the entry will be removed. Any existing entry will be
|
* <p>If value is {@code null}, the entry will be removed. Any
|
||||||
* replaced, regardless of what the new value is.
|
* 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>Some implementations may have limitations on what you may store. See
|
||||||
* their individual javadoc for details. No implementations should allow
|
* their individual javadoc for details. No implementations should allow
|
||||||
* you to store {@link Configuration}s or {@link ConfigurationSection}s,
|
* you to store {@link Configuration}s or {@link ConfigurationSection}s,
|
||||||
* please use {@link #createSection(String)} for that.
|
* please use {@link #createSection(String)} for that.
|
||||||
@ -167,8 +171,8 @@ public interface ConfigurationSection {
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* Creates an empty {@link ConfigurationSection} at the specified path.
|
* 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
|
* the previous value was itself a {@link ConfigurationSection}, it will
|
||||||
* be orphaned.
|
* be orphaned.
|
||||||
*
|
*
|
||||||
@ -180,8 +184,8 @@ public interface ConfigurationSection {
|
|||||||
/**
|
/**
|
||||||
* Creates a {@link ConfigurationSection} at the specified path, with
|
* Creates a {@link ConfigurationSection} at the specified path, with
|
||||||
* specified values.
|
* 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
|
* the previous value was itself a {@link ConfigurationSection}, it will
|
||||||
* be orphaned.
|
* be orphaned.
|
||||||
*
|
*
|
||||||
@ -195,10 +199,10 @@ public interface ConfigurationSection {
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* Gets the requested String by path.
|
* 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
|
* 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.
|
* @param path Path of the String to get.
|
||||||
* @return Requested String.
|
* @return Requested String.
|
||||||
@ -208,8 +212,8 @@ public interface ConfigurationSection {
|
|||||||
/**
|
/**
|
||||||
* Gets the requested String by path, returning a default value if not
|
* Gets the requested String by path, returning a default value if not
|
||||||
* found.
|
* 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
|
* returned regardless of if a default has been identified in the root
|
||||||
* {@link Configuration}.
|
* {@link Configuration}.
|
||||||
*
|
*
|
||||||
@ -223,10 +227,10 @@ public interface ConfigurationSection {
|
|||||||
/**
|
/**
|
||||||
* Checks if the specified path is a String.
|
* Checks if the specified path is a String.
|
||||||
*
|
*
|
||||||
* <p> If the path exists but is not a String, this will return false. If the
|
* <p>If the path exists but is not a String, this will return false. If
|
||||||
* path does not exist, this will return false. If the path does not exist
|
* the path does not exist, this will return false. If the path does not
|
||||||
* but a default value has been specified, this will check if that default
|
* exist but a default value has been specified, this will check if that
|
||||||
* value is a String and return appropriately.</p>
|
* defaultvalue is a String and return appropriately.
|
||||||
*
|
*
|
||||||
* @param path Path of the String to check.
|
* @param path Path of the String to check.
|
||||||
* @return Whether or not the specified path is a String.
|
* @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
|
* <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
|
* 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.
|
* @param path Path of the int to get.
|
||||||
* @return Requested int.
|
* @return Requested int.
|
||||||
@ -250,7 +254,7 @@ public interface ConfigurationSection {
|
|||||||
*
|
*
|
||||||
* <p>If the int does not exist then the specified default value will
|
* <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
|
* 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 path Path of the int to get.
|
||||||
* @param def The default value to return if the path is not found or is
|
* @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
|
* <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
|
* 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
|
* 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.
|
* @param path Path of the int to check.
|
||||||
* @return Whether or not the specified path is an int.
|
* @return Whether or not the specified path is an int.
|
||||||
@ -274,8 +278,8 @@ public interface ConfigurationSection {
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* Gets the requested boolean by path.
|
* 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
|
* this will return the default value. If the boolean does not exist and
|
||||||
* no default value was specified, this will return false.
|
* 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
|
* Gets the requested boolean by path, returning a default value if not
|
||||||
* found.
|
* 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
|
* returned regardless of if a default has been identified in the root
|
||||||
* {@link Configuration}.
|
* {@link Configuration}.
|
||||||
*
|
*
|
||||||
@ -301,8 +305,8 @@ public interface ConfigurationSection {
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* Checks if the specified path is a boolean.
|
* 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
|
* 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
|
* but a default value has been specified, this will check if that default
|
||||||
* value is a boolean and return appropriately.
|
* value is a boolean and return appropriately.
|
||||||
@ -314,8 +318,8 @@ public interface ConfigurationSection {
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* Gets the requested double by path.
|
* 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
|
* this will return the default value. If the double does not exist and no
|
||||||
* default value was specified, this will return 0.
|
* 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
|
* Gets the requested double by path, returning a default value if not
|
||||||
* found.
|
* 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
|
* returned regardless of if a default has been identified in the root
|
||||||
* {@link Configuration}.
|
* {@link Configuration}.
|
||||||
*
|
*
|
||||||
@ -341,8 +345,8 @@ public interface ConfigurationSection {
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* Checks if the specified path is a double.
|
* 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
|
* 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
|
* but a default value has been specified, this will check if that default
|
||||||
* value is a double and return appropriately.
|
* value is a double and return appropriately.
|
||||||
@ -354,8 +358,8 @@ public interface ConfigurationSection {
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* Gets the requested long by path.
|
* 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
|
* will return the default value. If the long does not exist and no
|
||||||
* default value was specified, this will return 0.
|
* 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
|
* Gets the requested long by path, returning a default value if not
|
||||||
* found.
|
* 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
|
* returned regardless of if a default has been identified in the root
|
||||||
* {@link Configuration}.
|
* {@link Configuration}.
|
||||||
*
|
*
|
||||||
@ -381,8 +385,8 @@ public interface ConfigurationSection {
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* Checks if the specified path is a long.
|
* 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
|
* 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
|
* but a default value has been specified, this will check if that default
|
||||||
* value is a long and return appropriately.
|
* value is a long and return appropriately.
|
||||||
@ -396,8 +400,8 @@ public interface ConfigurationSection {
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* Gets the requested List by path.
|
* 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
|
* will return the default value. If the List does not exist and no
|
||||||
* default value was specified, this will return null.
|
* 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
|
* Gets the requested List by path, returning a default value if not
|
||||||
* found.
|
* 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
|
* returned regardless of if a default has been identified in the root
|
||||||
* {@link Configuration}.
|
* {@link Configuration}.
|
||||||
*
|
*
|
||||||
@ -423,8 +427,8 @@ public interface ConfigurationSection {
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* Checks if the specified path is a List.
|
* 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
|
* 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
|
* but a default value has been specified, this will check if that default
|
||||||
* value is a List and return appropriately.
|
* value is a List and return appropriately.
|
||||||
@ -436,12 +440,12 @@ public interface ConfigurationSection {
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* Gets the requested List of String by path.
|
* Gets the requested List of String 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,
|
||||||
* will return the default value. If the List does not exist and no
|
* this will return the default value. If the List does not exist and no
|
||||||
* default value was specified, this will return an empty List.
|
* 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.
|
* but may miss any values out if they are not compatible.
|
||||||
*
|
*
|
||||||
* @param path Path of the List to get.
|
* @param path Path of the List to get.
|
||||||
@ -451,13 +455,13 @@ public interface ConfigurationSection {
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* Gets the requested List of Integer by path.
|
* Gets the requested List of Integer 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,
|
||||||
* will return the default value. If the List does not exist and no
|
* this will return the default value. If the List does not exist and no
|
||||||
* default value was specified, this will return an empty List.
|
* default value was specified, this will return an empty List.
|
||||||
* <p>
|
*
|
||||||
* This method will attempt to cast any values into a Integer if possible,
|
* <p>This method will attempt to cast any values into a Integer if
|
||||||
* but may miss any values out if they are not compatible.
|
* possible, but may miss any values out if they are not compatible.
|
||||||
*
|
*
|
||||||
* @param path Path of the List to get.
|
* @param path Path of the List to get.
|
||||||
* @return Requested List of Integer.
|
* @return Requested List of Integer.
|
||||||
@ -466,13 +470,13 @@ public interface ConfigurationSection {
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* Gets the requested List of Boolean by path.
|
* Gets the requested List of Boolean 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,
|
||||||
* will return the default value. If the List does not exist and no
|
* this will return the default value. If the List does not exist and no
|
||||||
* default value was specified, this will return an empty List.
|
* default value was specified, this will return an empty List.
|
||||||
* <p>
|
*
|
||||||
* This method will attempt to cast any values into a Boolean if possible,
|
* <p>This method will attempt to cast any values into a Boolean if
|
||||||
* but may miss any values out if they are not compatible.
|
* possible, but may miss any values out if they are not compatible.
|
||||||
*
|
*
|
||||||
* @param path Path of the List to get.
|
* @param path Path of the List to get.
|
||||||
* @return Requested List of Boolean.
|
* @return Requested List of Boolean.
|
||||||
@ -481,12 +485,12 @@ public interface ConfigurationSection {
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* Gets the requested List of Double by path.
|
* Gets the requested List of Double 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,
|
||||||
* will return the default value. If the List does not exist and no
|
* this will return the default value. If the List does not exist and no
|
||||||
* default value was specified, this will return an empty List.
|
* 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.
|
* but may miss any values out if they are not compatible.
|
||||||
*
|
*
|
||||||
* @param path Path of the List to get.
|
* @param path Path of the List to get.
|
||||||
@ -496,12 +500,12 @@ public interface ConfigurationSection {
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* Gets the requested List of Float by path.
|
* Gets the requested List of Float 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,
|
||||||
* will return the default value. If the List does not exist and no
|
* this will return the default value. If the List does not exist and no
|
||||||
* default value was specified, this will return an empty List.
|
* 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.
|
* but may miss any values out if they are not compatible.
|
||||||
*
|
*
|
||||||
* @param path Path of the List to get.
|
* @param path Path of the List to get.
|
||||||
@ -511,12 +515,12 @@ public interface ConfigurationSection {
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* Gets the requested List of Long by path.
|
* Gets the requested List of Long 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,
|
||||||
* will return the default value. If the List does not exist and no
|
* this will return the default value. If the List does not exist and no
|
||||||
* default value was specified, this will return an empty List.
|
* 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.
|
* but may miss any values out if they are not compatible.
|
||||||
*
|
*
|
||||||
* @param path Path of the List to get.
|
* @param path Path of the List to get.
|
||||||
@ -526,12 +530,12 @@ public interface ConfigurationSection {
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* Gets the requested List of Byte by path.
|
* Gets the requested List of Byte 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,
|
||||||
* will return the default value. If the List does not exist and no
|
* this will return the default value. If the List does not exist and no
|
||||||
* default value was specified, this will return an empty List.
|
* 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.
|
* but may miss any values out if they are not compatible.
|
||||||
*
|
*
|
||||||
* @param path Path of the List to get.
|
* @param path Path of the List to get.
|
||||||
@ -541,12 +545,12 @@ public interface ConfigurationSection {
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* Gets the requested List of Character by path.
|
* Gets the requested List of Character 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,
|
||||||
* will return the default value. If the List does not exist and no
|
* this will return the default value. If the List does not exist and no
|
||||||
* default value was specified, this will return an empty List.
|
* 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.
|
* possible, but may miss any values out if they are not compatible.
|
||||||
*
|
*
|
||||||
* @param path Path of the List to get.
|
* @param path Path of the List to get.
|
||||||
@ -556,13 +560,13 @@ public interface ConfigurationSection {
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* Gets the requested List of Short by path.
|
* Gets the requested List of Short 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,
|
||||||
* will return the default value. If the List does not exist and no
|
* this will return the default value. If the List does not exist and no
|
||||||
* default value was specified, this will return an empty List.
|
* default value was specified, this will return an empty List.
|
||||||
* <p>
|
*
|
||||||
* This method will attempt to cast any values into a Short if possible,
|
* <p>This method will attempt to cast any values into a Short if
|
||||||
* but may miss any values out if they are not compatible.
|
* possible, but may miss any values out if they are not compatible.
|
||||||
*
|
*
|
||||||
* @param path Path of the List to get.
|
* @param path Path of the List to get.
|
||||||
* @return Requested List of Short.
|
* @return Requested List of Short.
|
||||||
@ -571,13 +575,12 @@ public interface ConfigurationSection {
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* Gets the requested List of Maps by path.
|
* Gets the requested List of Maps 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,
|
||||||
* will return the default value. If the List does not exist and no
|
* this will return the default value. If the List does not exist and no
|
||||||
* default value was specified, this will return an empty List.
|
* default value was specified, this will return an empty List.
|
||||||
* <p>
|
* <p>This method will attempt to cast any values into a Map if possible,
|
||||||
* This method will attempt to cast any values into a Map if possible, but
|
* but may miss any values out if they are not compatible.
|
||||||
* may miss any values out if they are not compatible.
|
|
||||||
*
|
*
|
||||||
* @param path Path of the List to get.
|
* @param path Path of the List to get.
|
||||||
* @return Requested List of Maps.
|
* @return Requested List of Maps.
|
||||||
@ -586,11 +589,11 @@ public interface ConfigurationSection {
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* Gets the requested ConfigurationSection by path.
|
* Gets the requested ConfigurationSection by path.
|
||||||
* <p>
|
*
|
||||||
* If the ConfigurationSection does not exist but a default value has been
|
* <p>If the ConfigurationSection does not exist but a default value has
|
||||||
* specified, this will return the default value. If the
|
* been specified, this will return the default value. If the
|
||||||
* ConfigurationSection does not exist and no default value was specified,
|
* 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.
|
* @param path Path of the ConfigurationSection to get.
|
||||||
* @return Requested ConfigurationSection.
|
* @return Requested ConfigurationSection.
|
||||||
@ -599,8 +602,8 @@ public interface ConfigurationSection {
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* Checks if the specified path is a 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
|
* 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
|
* does not exist but a default value has been specified, this will check
|
||||||
* if that default value is a ConfigurationSection and return
|
* if that default value is a ConfigurationSection and return
|
||||||
@ -614,10 +617,10 @@ public interface ConfigurationSection {
|
|||||||
/**
|
/**
|
||||||
* Gets the equivalent {@link ConfigurationSection} from the default
|
* Gets the equivalent {@link ConfigurationSection} from the default
|
||||||
* {@link Configuration} defined in {@link #getRoot()}.
|
* {@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
|
* 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
|
* @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.
|
* 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
|
* collection, then a new {@link MemoryConfiguration} will be created to
|
||||||
* hold the new default value.
|
* 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.
|
* <p>If value is {@code null}, the value will be removed from the
|
||||||
* @param value Value to set the default to.
|
* default Configuration source.
|
||||||
* @throws IllegalArgumentException Thrown if path is null.
|
*
|
||||||
|
* <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);
|
void addDefault(String path, Object value);
|
||||||
}
|
}
|
||||||
|
@ -1,7 +1,7 @@
|
|||||||
package com.intellectualcrafters.configuration;
|
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")
|
@SuppressWarnings("serial")
|
||||||
public class InvalidConfigurationException extends Exception {
|
public class InvalidConfigurationException extends Exception {
|
||||||
@ -18,7 +18,7 @@ public class InvalidConfigurationException extends Exception {
|
|||||||
*
|
*
|
||||||
* @param msg The details of the exception.
|
* @param msg The details of the exception.
|
||||||
*/
|
*/
|
||||||
public InvalidConfigurationException(final String msg) {
|
public InvalidConfigurationException(String msg) {
|
||||||
super(msg);
|
super(msg);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -28,7 +28,7 @@ public class InvalidConfigurationException extends Exception {
|
|||||||
*
|
*
|
||||||
* @param cause The cause of the exception.
|
* @param cause The cause of the exception.
|
||||||
*/
|
*/
|
||||||
public InvalidConfigurationException(final Throwable cause) {
|
public InvalidConfigurationException(Throwable cause) {
|
||||||
super(cause);
|
super(cause);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -39,7 +39,7 @@ public class InvalidConfigurationException extends Exception {
|
|||||||
* @param cause The cause of the exception.
|
* @param cause The cause of the exception.
|
||||||
* @param msg The details 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);
|
super(msg, cause);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -2,10 +2,10 @@ package com.intellectualcrafters.configuration;
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* Various settings for controlling the input and output of a {@link
|
* Various settings for controlling the input and output of a {@link
|
||||||
* MemoryConfiguration}
|
* MemoryConfiguration}.
|
||||||
*/
|
*/
|
||||||
public class MemoryConfigurationOptions extends ConfigurationOptions {
|
public class MemoryConfigurationOptions extends ConfigurationOptions {
|
||||||
protected MemoryConfigurationOptions(final MemoryConfiguration configuration) {
|
protected MemoryConfigurationOptions(MemoryConfiguration configuration) {
|
||||||
super(configuration);
|
super(configuration);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -15,13 +15,13 @@ public class MemoryConfigurationOptions extends ConfigurationOptions {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public MemoryConfigurationOptions copyDefaults(final boolean value) {
|
public MemoryConfigurationOptions copyDefaults(boolean value) {
|
||||||
super.copyDefaults(value);
|
super.copyDefaults(value);
|
||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public MemoryConfigurationOptions pathSeparator(final char value) {
|
public MemoryConfigurationOptions pathSeparator(char value) {
|
||||||
super.pathSeparator(value);
|
super.pathSeparator(value);
|
||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
|
@ -21,8 +21,8 @@ public class MemorySection implements ConfigurationSection {
|
|||||||
/**
|
/**
|
||||||
* Creates an empty MemorySection for use as a root {@link Configuration}
|
* Creates an empty MemorySection for use as a root {@link Configuration}
|
||||||
* section.
|
* 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!
|
* will throw an exception!
|
||||||
*
|
*
|
||||||
* @throws IllegalStateException Thrown if this is not a {@link
|
* @throws IllegalStateException Thrown if this is not a {@link
|
||||||
@ -74,7 +74,8 @@ public class MemorySection implements ConfigurationSection {
|
|||||||
if (obj instanceof String) {
|
if (obj instanceof String) {
|
||||||
try {
|
try {
|
||||||
return Double.parseDouble((String) obj);
|
return Double.parseDouble((String) obj);
|
||||||
} catch (NumberFormatException ignored) {}
|
} catch (NumberFormatException ignored) {
|
||||||
|
}
|
||||||
} else if (obj instanceof List) {
|
} else if (obj instanceof List) {
|
||||||
List<?> val = (List<?>) obj;
|
List<?> val = (List<?>) obj;
|
||||||
if (!val.isEmpty()) {
|
if (!val.isEmpty()) {
|
||||||
@ -91,7 +92,8 @@ public class MemorySection implements ConfigurationSection {
|
|||||||
if (obj instanceof String) {
|
if (obj instanceof String) {
|
||||||
try {
|
try {
|
||||||
return Integer.parseInt((String) obj);
|
return Integer.parseInt((String) obj);
|
||||||
} catch (NumberFormatException ignored) {}
|
} catch (NumberFormatException ignored) {
|
||||||
|
}
|
||||||
} else if (obj instanceof List) {
|
} else if (obj instanceof List) {
|
||||||
List<?> val = (List<?>) obj;
|
List<?> val = (List<?>) obj;
|
||||||
if (!val.isEmpty()) {
|
if (!val.isEmpty()) {
|
||||||
@ -108,7 +110,8 @@ public class MemorySection implements ConfigurationSection {
|
|||||||
if (obj instanceof String) {
|
if (obj instanceof String) {
|
||||||
try {
|
try {
|
||||||
return Long.parseLong((String) obj);
|
return Long.parseLong((String) obj);
|
||||||
} catch (NumberFormatException ignored) {}
|
} catch (NumberFormatException ignored) {
|
||||||
|
}
|
||||||
} else if (obj instanceof List) {
|
} else if (obj instanceof List) {
|
||||||
List<?> val = (List<?>) obj;
|
List<?> val = (List<?>) obj;
|
||||||
if (!val.isEmpty()) {
|
if (!val.isEmpty()) {
|
||||||
@ -121,8 +124,8 @@ public class MemorySection implements ConfigurationSection {
|
|||||||
/**
|
/**
|
||||||
* Creates a full path to the given {@link ConfigurationSection} from its
|
* Creates a full path to the given {@link ConfigurationSection} from its
|
||||||
* root {@link Configuration}.
|
* 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}.
|
* only {@link MemorySection}.
|
||||||
*
|
*
|
||||||
* @param section Section to create a path for.
|
* @param section Section to create a path for.
|
||||||
@ -136,8 +139,8 @@ public class MemorySection implements ConfigurationSection {
|
|||||||
/**
|
/**
|
||||||
* Creates a relative path to the given {@link ConfigurationSection} from
|
* Creates a relative path to the given {@link ConfigurationSection} from
|
||||||
* the given relative section.
|
* 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}.
|
* only {@link MemorySection}.
|
||||||
*
|
*
|
||||||
* @param section Section to create a path for.
|
* @param section Section to create a path for.
|
||||||
@ -292,7 +295,8 @@ public class MemorySection implements ConfigurationSection {
|
|||||||
char separator = root.options().pathSeparator();
|
char separator = root.options().pathSeparator();
|
||||||
// i1 is the leading (higher) index
|
// i1 is the leading (higher) index
|
||||||
// i2 is the trailing (lower) index
|
// i2 is the trailing (lower) index
|
||||||
int i1 = -1, i2;
|
int i1 = -1;
|
||||||
|
int i2;
|
||||||
ConfigurationSection section = this;
|
ConfigurationSection section = this;
|
||||||
while ((i1 = path.indexOf(separator, i2 = i1 + 1)) != -1) {
|
while ((i1 = path.indexOf(separator, i2 = i1 + 1)) != -1) {
|
||||||
String node = path.substring(i2, i1);
|
String node = path.substring(i2, i1);
|
||||||
@ -374,7 +378,8 @@ public class MemorySection implements ConfigurationSection {
|
|||||||
char separator = root.options().pathSeparator();
|
char separator = root.options().pathSeparator();
|
||||||
// i1 is the leading (higher) index
|
// i1 is the leading (higher) index
|
||||||
// i2 is the trailing (lower) index
|
// i2 is the trailing (lower) index
|
||||||
int i1 = -1, i2;
|
int i1 = -1;
|
||||||
|
int i2;
|
||||||
ConfigurationSection section = this;
|
ConfigurationSection section = this;
|
||||||
while ((i1 = path.indexOf(separator, i2 = i1 + 1)) != -1) {
|
while ((i1 = path.indexOf(separator, i2 = i1 + 1)) != -1) {
|
||||||
String node = path.substring(i2, i1);
|
String node = path.substring(i2, i1);
|
||||||
@ -563,7 +568,8 @@ public class MemorySection implements ConfigurationSection {
|
|||||||
} else if (object instanceof String) {
|
} else if (object instanceof String) {
|
||||||
try {
|
try {
|
||||||
result.add(Integer.valueOf((String) object));
|
result.add(Integer.valueOf((String) object));
|
||||||
} catch (NumberFormatException ignored) {}
|
} catch (NumberFormatException ignored) {
|
||||||
|
}
|
||||||
} else if (object instanceof Character) {
|
} else if (object instanceof Character) {
|
||||||
result.add((int) (Character) object);
|
result.add((int) (Character) object);
|
||||||
} else if (object instanceof Number) {
|
} else if (object instanceof Number) {
|
||||||
@ -607,7 +613,8 @@ public class MemorySection implements ConfigurationSection {
|
|||||||
} else if (object instanceof String) {
|
} else if (object instanceof String) {
|
||||||
try {
|
try {
|
||||||
result.add(Double.valueOf((String) object));
|
result.add(Double.valueOf((String) object));
|
||||||
} catch (NumberFormatException ignored) {}
|
} catch (NumberFormatException ignored) {
|
||||||
|
}
|
||||||
} else if (object instanceof Character) {
|
} else if (object instanceof Character) {
|
||||||
result.add((double) (Character) object);
|
result.add((double) (Character) object);
|
||||||
} else if (object instanceof Number) {
|
} else if (object instanceof Number) {
|
||||||
@ -630,7 +637,8 @@ public class MemorySection implements ConfigurationSection {
|
|||||||
} else if (object instanceof String) {
|
} else if (object instanceof String) {
|
||||||
try {
|
try {
|
||||||
result.add(Float.valueOf((String) object));
|
result.add(Float.valueOf((String) object));
|
||||||
} catch (NumberFormatException ignored) {}
|
} catch (NumberFormatException ignored) {
|
||||||
|
}
|
||||||
} else if (object instanceof Character) {
|
} else if (object instanceof Character) {
|
||||||
result.add((float) (Character) object);
|
result.add((float) (Character) object);
|
||||||
} else if (object instanceof Number) {
|
} else if (object instanceof Number) {
|
||||||
@ -653,7 +661,8 @@ public class MemorySection implements ConfigurationSection {
|
|||||||
} else if (object instanceof String) {
|
} else if (object instanceof String) {
|
||||||
try {
|
try {
|
||||||
result.add(Long.valueOf((String) object));
|
result.add(Long.valueOf((String) object));
|
||||||
} catch (NumberFormatException ignored) {}
|
} catch (NumberFormatException ignored) {
|
||||||
|
}
|
||||||
} else if (object instanceof Character) {
|
} else if (object instanceof Character) {
|
||||||
result.add((long) (Character) object);
|
result.add((long) (Character) object);
|
||||||
} else if (object instanceof Number) {
|
} else if (object instanceof Number) {
|
||||||
@ -676,7 +685,8 @@ public class MemorySection implements ConfigurationSection {
|
|||||||
} else if (object instanceof String) {
|
} else if (object instanceof String) {
|
||||||
try {
|
try {
|
||||||
result.add(Byte.valueOf((String) object));
|
result.add(Byte.valueOf((String) object));
|
||||||
} catch (NumberFormatException ignored) {}
|
} catch (NumberFormatException ignored) {
|
||||||
|
}
|
||||||
} else if (object instanceof Character) {
|
} else if (object instanceof Character) {
|
||||||
result.add((byte) ((Character) object).charValue());
|
result.add((byte) ((Character) object).charValue());
|
||||||
} else if (object instanceof Number) {
|
} else if (object instanceof Number) {
|
||||||
@ -722,7 +732,8 @@ public class MemorySection implements ConfigurationSection {
|
|||||||
} else if (object instanceof String) {
|
} else if (object instanceof String) {
|
||||||
try {
|
try {
|
||||||
result.add(Short.valueOf((String) object));
|
result.add(Short.valueOf((String) object));
|
||||||
} catch (NumberFormatException ignored) {}
|
} catch (NumberFormatException ignored) {
|
||||||
|
}
|
||||||
} else if (object instanceof Character) {
|
} else if (object instanceof Character) {
|
||||||
result.add((short) ((Character) object).charValue());
|
result.add((short) ((Character) object).charValue());
|
||||||
} else if (object instanceof Number) {
|
} else if (object instanceof Number) {
|
||||||
@ -831,7 +842,10 @@ public class MemorySection implements ConfigurationSection {
|
|||||||
@Override
|
@Override
|
||||||
public String toString() {
|
public String toString() {
|
||||||
Configuration root = getRoot();
|
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
|
* This is a base class for all File based implementations of {@link
|
||||||
* Configuration}
|
* Configuration}.
|
||||||
*/
|
*/
|
||||||
public abstract class FileConfiguration extends MemoryConfiguration {
|
public abstract class FileConfiguration extends MemoryConfiguration {
|
||||||
|
|
||||||
@ -39,18 +39,17 @@ public abstract class FileConfiguration extends MemoryConfiguration {
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* Saves this {@link FileConfiguration} to the specified location.
|
* 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
|
* will be overwritten. If it cannot be overwritten or created, an
|
||||||
* exception will be thrown.
|
* 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.
|
* using UTF8.
|
||||||
*
|
*
|
||||||
* @param file File to save to.
|
* @param file File to save to.
|
||||||
* @throws IOException Thrown when the given file cannot be written to for
|
* @throws IOException Thrown when the given file cannot be written to for
|
||||||
* any reason.
|
* any reason.
|
||||||
* @throws IllegalArgumentException Thrown when file is null.
|
|
||||||
*/
|
*/
|
||||||
public void save(File file) throws IOException {
|
public void save(File file) throws IOException {
|
||||||
file.getParentFile().mkdirs();
|
file.getParentFile().mkdirs();
|
||||||
@ -71,14 +70,13 @@ public abstract class FileConfiguration extends MemoryConfiguration {
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* Loads this {@link FileConfiguration} from the specified location.
|
* 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
|
* leaving only settings and defaults, and the new values will be loaded
|
||||||
* from the given file.
|
* 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.
|
* thrown.
|
||||||
* <p>
|
|
||||||
*
|
*
|
||||||
* @param file File to load from.
|
* @param file File to load from.
|
||||||
* @throws FileNotFoundException Thrown when the given file cannot be
|
* @throws FileNotFoundException Thrown when the given file cannot be
|
||||||
@ -100,8 +98,8 @@ public abstract class FileConfiguration extends MemoryConfiguration {
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* Loads this {@link FileConfiguration} from the specified reader.
|
* 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
|
* leaving only settings and defaults, and the new values will be loaded
|
||||||
* from the given stream.
|
* from the given stream.
|
||||||
*
|
*
|
||||||
@ -109,7 +107,6 @@ public abstract class FileConfiguration extends MemoryConfiguration {
|
|||||||
* @throws IOException thrown when underlying reader throws an IOException
|
* @throws IOException thrown when underlying reader throws an IOException
|
||||||
* @throws InvalidConfigurationException thrown when the reader does not
|
* @throws InvalidConfigurationException thrown when the reader does not
|
||||||
* represent a valid Configuration
|
* represent a valid Configuration
|
||||||
* @throws IllegalArgumentException thrown when reader is null
|
|
||||||
*/
|
*/
|
||||||
public void load(Reader reader) throws IOException, InvalidConfigurationException {
|
public void load(Reader reader) throws IOException, InvalidConfigurationException {
|
||||||
|
|
||||||
@ -129,12 +126,12 @@ public abstract class FileConfiguration extends MemoryConfiguration {
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* Loads this {@link FileConfiguration} from the specified location.
|
* 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
|
* leaving only settings and defaults, and the new values will be loaded
|
||||||
* from the given file.
|
* 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.
|
* thrown.
|
||||||
*
|
*
|
||||||
* @param file File to load from.
|
* @param file File to load from.
|
||||||
@ -156,25 +153,24 @@ public abstract class FileConfiguration extends MemoryConfiguration {
|
|||||||
/**
|
/**
|
||||||
* Loads this {@link FileConfiguration} from the specified string, as
|
* Loads this {@link FileConfiguration} from the specified string, as
|
||||||
* opposed to from file.
|
* 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
|
* leaving only settings and defaults, and the new values will be loaded
|
||||||
* from the given string.
|
* 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.
|
* @param contents Contents of a Configuration to load.
|
||||||
* @throws InvalidConfigurationException Thrown if the specified string is
|
* @throws InvalidConfigurationException Thrown if the specified string is
|
||||||
* invalid.
|
* invalid.
|
||||||
* @throws IllegalArgumentException Thrown if contents is null.
|
|
||||||
*/
|
*/
|
||||||
public abstract void loadFromString(String contents) throws InvalidConfigurationException;
|
public abstract void loadFromString(String contents) throws InvalidConfigurationException;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Compiles the header for this {@link FileConfiguration} and returns the
|
* Compiles the header for this {@link FileConfiguration} and returns the
|
||||||
* result.
|
* 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#header()}, respecting the rules of {@link
|
||||||
* FileConfigurationOptions#copyHeader()} if set.
|
* FileConfigurationOptions#copyHeader()} if set.
|
||||||
*
|
*
|
||||||
|
@ -6,13 +6,13 @@ import com.intellectualcrafters.configuration.MemoryConfigurationOptions;
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* Various settings for controlling the input and output of a {@link
|
* Various settings for controlling the input and output of a {@link
|
||||||
* FileConfiguration}
|
* FileConfiguration}.
|
||||||
*/
|
*/
|
||||||
public class FileConfigurationOptions extends MemoryConfigurationOptions {
|
public class FileConfigurationOptions extends MemoryConfigurationOptions {
|
||||||
private String header = null;
|
private String header = null;
|
||||||
private boolean copyHeader = true;
|
private boolean copyHeader = true;
|
||||||
|
|
||||||
protected FileConfigurationOptions(final MemoryConfiguration configuration) {
|
protected FileConfigurationOptions(MemoryConfiguration configuration) {
|
||||||
super(configuration);
|
super(configuration);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -22,28 +22,28 @@ public class FileConfigurationOptions extends MemoryConfigurationOptions {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public FileConfigurationOptions copyDefaults(final boolean value) {
|
public FileConfigurationOptions copyDefaults(boolean value) {
|
||||||
super.copyDefaults(value);
|
super.copyDefaults(value);
|
||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public FileConfigurationOptions pathSeparator(final char value) {
|
public FileConfigurationOptions pathSeparator(char value) {
|
||||||
super.pathSeparator(value);
|
super.pathSeparator(value);
|
||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Gets the header that will be applied to the top of the saved output.
|
* 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
|
* the generated output of the {@link FileConfiguration}. It is not
|
||||||
* required to include a newline at the end of the header as it will
|
* 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
|
* automatically be applied, but you may include one if you wish for extra
|
||||||
* spacing.
|
* spacing.
|
||||||
* <p>
|
*
|
||||||
* Null is a valid value which will indicate that no header is to be
|
* <p>{@code null} is a valid value which will indicate that no header]
|
||||||
* applied. The default value is null.
|
* is to be applied. The default value is {@code null}.
|
||||||
*
|
*
|
||||||
* @return Header
|
* @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.
|
* 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
|
* the generated output of the {@link FileConfiguration}. It is not
|
||||||
* required to include a newline at the end of the header as it will
|
* 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
|
* automatically be applied, but you may include one if you wish for extra
|
||||||
* spacing.
|
* spacing.
|
||||||
* <p>
|
*
|
||||||
* Null is a valid value which will indicate that no header is to be
|
* <p>{@code null} is a valid value which will indicate that no header
|
||||||
* applied.
|
* is to be applied.
|
||||||
*
|
*
|
||||||
* @param value New header
|
* @param value New header
|
||||||
* @return This object, for chaining
|
* @return This object, for chaining
|
||||||
*/
|
*/
|
||||||
public FileConfigurationOptions header(final String value) {
|
public FileConfigurationOptions header(String value) {
|
||||||
header = value;
|
header = value;
|
||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Gets whether or not the header should be copied from a default source.
|
* 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
|
* <p>If this is true, if a default {@link FileConfiguration} is passed to
|
||||||
* {@link
|
* {@link FileConfiguration#setDefaults(Configuration)}
|
||||||
* FileConfiguration#setDefaults(Configuration)}
|
|
||||||
* then upon saving it will use the header from that config, instead of
|
* then upon saving it will use the header from that config, instead of
|
||||||
* the one provided here.
|
* 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()}
|
* type FileConfiguration, or that config has no header ({@link #header()}
|
||||||
* returns null) then the header specified in this configuration will be
|
* returns null) then the header specified in this configuration will be
|
||||||
* used.
|
* used.
|
||||||
* <p>
|
*
|
||||||
* Defaults to true.
|
* <p>Defaults to true.
|
||||||
*
|
*
|
||||||
* @return Whether or not to copy the header
|
* @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.
|
* 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
|
* <p>If this is true, if a default {@link FileConfiguration} is passed to
|
||||||
* {@link
|
* {@link FileConfiguration#setDefaults(Configuration)}
|
||||||
* FileConfiguration#setDefaults(Configuration)}
|
|
||||||
* then upon saving it will use the header from that config, instead of
|
* then upon saving it will use the header from that config, instead of
|
||||||
* the one provided here.
|
* 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()}
|
* type FileConfiguration, or that config has no header ({@link #header()}
|
||||||
* returns null) then the header specified in this configuration will be
|
* returns null) then the header specified in this configuration will be
|
||||||
* used.
|
* used.
|
||||||
* <p>
|
*
|
||||||
* Defaults to true.
|
* <p>Defaults to true.
|
||||||
*
|
*
|
||||||
* @param value Whether or not to copy the header
|
* @param value Whether or not to copy the header
|
||||||
* @return This object, for chaining
|
* @return This object, for chaining
|
||||||
*/
|
*/
|
||||||
public FileConfigurationOptions copyHeader(final boolean value) {
|
public FileConfigurationOptions copyHeader(boolean value) {
|
||||||
copyHeader = value;
|
copyHeader = value;
|
||||||
|
|
||||||
return this;
|
return this;
|
||||||
|
@ -29,12 +29,12 @@ public class YamlConfiguration extends FileConfiguration {
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* Creates a new {@link YamlConfiguration}, loading from the given file.
|
* 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
|
* If the specified input is not a valid config, a blank config will be
|
||||||
* returned.
|
* 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
|
* @param file Input file
|
||||||
* @return Resulting configuration
|
* @return Resulting configuration
|
||||||
@ -45,7 +45,7 @@ public class YamlConfiguration extends FileConfiguration {
|
|||||||
throw new NullPointerException("File cannot be null");
|
throw new NullPointerException("File cannot be null");
|
||||||
}
|
}
|
||||||
|
|
||||||
final YamlConfiguration config = new YamlConfiguration();
|
YamlConfiguration config = new YamlConfiguration();
|
||||||
|
|
||||||
try {
|
try {
|
||||||
config.load(file);
|
config.load(file);
|
||||||
@ -62,7 +62,7 @@ public class YamlConfiguration extends FileConfiguration {
|
|||||||
PS.debug("&c============ Full stacktrace ============");
|
PS.debug("&c============ Full stacktrace ============");
|
||||||
ex.printStackTrace();
|
ex.printStackTrace();
|
||||||
PS.debug("&c=========================================");
|
PS.debug("&c=========================================");
|
||||||
} catch (final IOException e) {
|
} catch (IOException e) {
|
||||||
e.printStackTrace();
|
e.printStackTrace();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -72,8 +72,8 @@ public class YamlConfiguration extends FileConfiguration {
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* Creates a new {@link YamlConfiguration}, loading from the given reader.
|
* Creates a new {@link YamlConfiguration}, loading from the given reader.
|
||||||
* <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
|
* If the specified input is not a valid config, a blank config will be
|
||||||
* returned.
|
* returned.
|
||||||
*
|
*
|
||||||
@ -81,16 +81,16 @@ public class YamlConfiguration extends FileConfiguration {
|
|||||||
* @return resulting configuration
|
* @return resulting configuration
|
||||||
* @throws IllegalArgumentException Thrown if stream is null
|
* @throws IllegalArgumentException Thrown if stream is null
|
||||||
*/
|
*/
|
||||||
public static YamlConfiguration loadConfiguration(final Reader reader) {
|
public static YamlConfiguration loadConfiguration(Reader reader) {
|
||||||
if (reader == null) {
|
if (reader == null) {
|
||||||
throw new NullPointerException("Reader cannot be null");
|
throw new NullPointerException("Reader cannot be null");
|
||||||
}
|
}
|
||||||
|
|
||||||
final YamlConfiguration config = new YamlConfiguration();
|
YamlConfiguration config = new YamlConfiguration();
|
||||||
|
|
||||||
try {
|
try {
|
||||||
config.load(reader);
|
config.load(reader);
|
||||||
} catch (final IOException | InvalidConfigurationException ex) {
|
} catch (IOException | InvalidConfigurationException ex) {
|
||||||
PS.debug("Cannot load configuration from stream");
|
PS.debug("Cannot load configuration from stream");
|
||||||
ex.printStackTrace();
|
ex.printStackTrace();
|
||||||
}
|
}
|
||||||
@ -104,7 +104,7 @@ public class YamlConfiguration extends FileConfiguration {
|
|||||||
yamlOptions.setDefaultFlowStyle(DumperOptions.FlowStyle.BLOCK);
|
yamlOptions.setDefaultFlowStyle(DumperOptions.FlowStyle.BLOCK);
|
||||||
yamlRepresenter.setDefaultFlowStyle(DumperOptions.FlowStyle.BLOCK);
|
yamlRepresenter.setDefaultFlowStyle(DumperOptions.FlowStyle.BLOCK);
|
||||||
|
|
||||||
final String header = buildHeader();
|
String header = buildHeader();
|
||||||
String dump = yaml.dump(getValues(false));
|
String dump = yaml.dump(getValues(false));
|
||||||
|
|
||||||
if (dump.equals(BLANK_CONFIG)) {
|
if (dump.equals(BLANK_CONFIG)) {
|
||||||
@ -115,7 +115,7 @@ public class YamlConfiguration extends FileConfiguration {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void loadFromString(final String contents) throws InvalidConfigurationException {
|
public void loadFromString(String contents) throws InvalidConfigurationException {
|
||||||
if (contents == null) {
|
if (contents == null) {
|
||||||
throw new NullPointerException("Contents cannot be null");
|
throw new NullPointerException("Contents cannot be null");
|
||||||
}
|
}
|
||||||
@ -123,13 +123,13 @@ public class YamlConfiguration extends FileConfiguration {
|
|||||||
Map<?, ?> input;
|
Map<?, ?> input;
|
||||||
try {
|
try {
|
||||||
input = (Map<?, ?>) yaml.load(contents);
|
input = (Map<?, ?>) yaml.load(contents);
|
||||||
} catch (final YAMLException e) {
|
} catch (YAMLException e) {
|
||||||
throw new InvalidConfigurationException(e);
|
throw new InvalidConfigurationException(e);
|
||||||
} catch (final ClassCastException ignored) {
|
} catch (ClassCastException ignored) {
|
||||||
throw new InvalidConfigurationException("Top level is not a Map.");
|
throw new InvalidConfigurationException("Top level is not a Map.");
|
||||||
}
|
}
|
||||||
|
|
||||||
final String header = parseHeader(contents);
|
String header = parseHeader(contents);
|
||||||
if (!header.isEmpty()) {
|
if (!header.isEmpty()) {
|
||||||
options().header(header);
|
options().header(header);
|
||||||
}
|
}
|
||||||
@ -139,10 +139,10 @@ public class YamlConfiguration extends FileConfiguration {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
protected void convertMapsToSections(final Map<?, ?> input, final ConfigurationSection section) {
|
protected void convertMapsToSections(Map<?, ?> input, ConfigurationSection section) {
|
||||||
for (final Map.Entry<?, ?> entry : input.entrySet()) {
|
for (Map.Entry<?, ?> entry : input.entrySet()) {
|
||||||
final String key = entry.getKey().toString();
|
String key = entry.getKey().toString();
|
||||||
final Object value = entry.getValue();
|
Object value = entry.getValue();
|
||||||
|
|
||||||
if (value instanceof Map) {
|
if (value instanceof Map) {
|
||||||
convertMapsToSections((Map<?, ?>) value, section.createSection(key));
|
convertMapsToSections((Map<?, ?>) value, section.createSection(key));
|
||||||
@ -152,14 +152,14 @@ public class YamlConfiguration extends FileConfiguration {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
protected String parseHeader(final String input) {
|
protected String parseHeader(String input) {
|
||||||
final String[] lines = input.split("\r?\n", -1);
|
String[] lines = input.split("\r?\n", -1);
|
||||||
final StringBuilder result = new StringBuilder();
|
StringBuilder result = new StringBuilder();
|
||||||
boolean readingHeader = true;
|
boolean readingHeader = true;
|
||||||
boolean foundHeader = false;
|
boolean foundHeader = false;
|
||||||
|
|
||||||
for (int i = 0; (i < lines.length) && readingHeader; i++) {
|
for (int i = 0; (i < lines.length) && readingHeader; i++) {
|
||||||
final String line = lines[i];
|
String line = lines[i];
|
||||||
|
|
||||||
if (line.startsWith(COMMENT_PREFIX)) {
|
if (line.startsWith(COMMENT_PREFIX)) {
|
||||||
if (i > 0) {
|
if (i > 0) {
|
||||||
@ -183,14 +183,14 @@ public class YamlConfiguration extends FileConfiguration {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected String buildHeader() {
|
protected String buildHeader() {
|
||||||
final String header = options().header();
|
String header = options().header();
|
||||||
|
|
||||||
if (options().copyHeader()) {
|
if (options().copyHeader()) {
|
||||||
final Configuration def = getDefaults();
|
Configuration def = getDefaults();
|
||||||
|
|
||||||
if (def instanceof FileConfiguration) {
|
if (def instanceof FileConfiguration) {
|
||||||
final FileConfiguration fileDefaults = (FileConfiguration) def;
|
FileConfiguration fileDefaults = (FileConfiguration) def;
|
||||||
final String defaultsHeader = fileDefaults.buildHeader();
|
String defaultsHeader = fileDefaults.buildHeader();
|
||||||
|
|
||||||
if ((defaultsHeader != null) && !defaultsHeader.isEmpty()) {
|
if ((defaultsHeader != null) && !defaultsHeader.isEmpty()) {
|
||||||
return defaultsHeader;
|
return defaultsHeader;
|
||||||
@ -202,8 +202,8 @@ public class YamlConfiguration extends FileConfiguration {
|
|||||||
return "";
|
return "";
|
||||||
}
|
}
|
||||||
|
|
||||||
final StringBuilder builder = new StringBuilder();
|
StringBuilder builder = new StringBuilder();
|
||||||
final String[] lines = header.split("\r?\n", -1);
|
String[] lines = header.split("\r?\n", -1);
|
||||||
boolean startedHeader = false;
|
boolean startedHeader = false;
|
||||||
|
|
||||||
for (int i = lines.length - 1; i >= 0; i--) {
|
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
|
* Various settings for controlling the input and output of a {@link
|
||||||
* YamlConfiguration}
|
* YamlConfiguration}.
|
||||||
*/
|
*/
|
||||||
public class YamlConfigurationOptions extends FileConfigurationOptions {
|
public class YamlConfigurationOptions extends FileConfigurationOptions {
|
||||||
private int indent = 2;
|
private int indent = 2;
|
||||||
|
|
||||||
YamlConfigurationOptions(final YamlConfiguration configuration) {
|
YamlConfigurationOptions(YamlConfiguration configuration) {
|
||||||
super(configuration);
|
super(configuration);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -17,33 +17,33 @@ public class YamlConfigurationOptions extends FileConfigurationOptions {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public YamlConfigurationOptions copyDefaults(final boolean value) {
|
public YamlConfigurationOptions copyDefaults(boolean value) {
|
||||||
super.copyDefaults(value);
|
super.copyDefaults(value);
|
||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public YamlConfigurationOptions pathSeparator(final char value) {
|
public YamlConfigurationOptions pathSeparator(char value) {
|
||||||
super.pathSeparator(value);
|
super.pathSeparator(value);
|
||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public YamlConfigurationOptions header(final String value) {
|
public YamlConfigurationOptions header(String value) {
|
||||||
super.header(value);
|
super.header(value);
|
||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public YamlConfigurationOptions copyHeader(final boolean value) {
|
public YamlConfigurationOptions copyHeader(boolean value) {
|
||||||
super.copyHeader(value);
|
super.copyHeader(value);
|
||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Gets how much spaces should be used to indent each line.
|
* 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
|
* @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.
|
* 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
|
* @param value New indent
|
||||||
* @return This object, for chaining
|
* @return This object, for chaining
|
||||||
*/
|
*/
|
||||||
public YamlConfigurationOptions indent(final int value) {
|
public YamlConfigurationOptions indent(int value) {
|
||||||
if (value < 2) {
|
if (value < 2) {
|
||||||
throw new IllegalArgumentException("Indent must be at least 2 characters");
|
throw new IllegalArgumentException("Indent must be at least 2 characters");
|
||||||
}
|
}
|
||||||
|
@ -11,7 +11,7 @@ import java.util.Map;
|
|||||||
|
|
||||||
class YamlRepresenter extends Representer {
|
class YamlRepresenter extends Representer {
|
||||||
|
|
||||||
public YamlRepresenter() {
|
YamlRepresenter() {
|
||||||
this.multiRepresenters.put(ConfigurationSection.class, new RepresentConfigurationSection());
|
this.multiRepresenters.put(ConfigurationSection.class, new RepresentConfigurationSection());
|
||||||
this.multiRepresenters.put(ConfigurationSerializable.class, new RepresentConfigurationSerializable());
|
this.multiRepresenters.put(ConfigurationSerializable.class, new RepresentConfigurationSerializable());
|
||||||
}
|
}
|
||||||
|
@ -4,9 +4,8 @@ import java.util.Map;
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* Represents an object that may be serialized.
|
* Represents an object that may be serialized.
|
||||||
* <p>
|
* <p>These objects MUST implement one of the following, in addition to
|
||||||
* These objects MUST implement one of the following, in addition to the
|
* the methods as defined by this interface:
|
||||||
* methods as defined by this interface:
|
|
||||||
* <ul>
|
* <ul>
|
||||||
* <li>A static method "deserialize" that accepts a single {@link Map}<
|
* <li>A static method "deserialize" that accepts a single {@link Map}<
|
||||||
* {@link String}, {@link Object}> and returns the class.</li>
|
* {@link String}, {@link Object}> and returns the class.</li>
|
||||||
@ -25,8 +24,8 @@ public interface ConfigurationSerializable {
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* Creates a Map representation of this class.
|
* 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.
|
* the {@link ConfigurationSerializable} interface javadoc.
|
||||||
*
|
*
|
||||||
* @return Map containing the current state of this class
|
* @return Map containing the current state of this class
|
||||||
|
@ -7,10 +7,11 @@ import java.io.OutputStream;
|
|||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* <p> This class writes <strong>NBT</strong>, or <strong>Named Binary Tag</strong> <code>Tag</code> objects to an
|
* This class writes <strong>NBT</strong>, or <strong>Named Binary Tag</strong>
|
||||||
* underlying <code>OutputStream</code>. </p> <p> The NBT format was created by Markus Persson, and the
|
* {@code Tag} objects to an underlying {@code OutputStream}.
|
||||||
* specification may be found at
|
*
|
||||||
* @linktourl http://www.minecraft.net/docs/NBT.txt
|
* <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>
|
* </p>
|
||||||
*
|
*
|
||||||
* @author Graham Edgecombe
|
* @author Graham Edgecombe
|
||||||
@ -23,7 +24,8 @@ public final class NBTOutputStream implements Closeable {
|
|||||||
private final DataOutputStream os;
|
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.
|
* @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.
|
* @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.
|
* @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.
|
* @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.
|
* @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.
|
* @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.
|
* @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.
|
* @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.
|
* @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.
|
* @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.
|
* @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.
|
* @param tag The tag.
|
||||||
*/
|
*/
|
||||||
@ -251,7 +253,7 @@ public final class NBTOutputStream implements Closeable {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Flush output
|
* Flush output.
|
||||||
* @throws IOException
|
* @throws IOException
|
||||||
*/
|
*/
|
||||||
public void flush() 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.
|
* sequences.
|
||||||
*
|
*
|
||||||
* @return The unescaped string.
|
* @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
|
* 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
|
* 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</code> methods for adding or replacing values. The values can be any of
|
* 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>, <code>JSONArray</code>, <code>JSONObject</code>, <code>Number</code>,
|
* these types: {@code Boolean}, {@code JSONArray}, {@code JSONObject}, {@code Number},
|
||||||
* <code>String</code>, or the <code>JSONObject.NULL object</code>.
|
* {@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
|
* <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</code> method returns a default value instead of throwing an exception, and so is useful for obtaining
|
* {@code opt} method returns a default value instead of throwing an exception, and so is useful for obtaining
|
||||||
* optional values.
|
* optional values.
|
||||||
*
|
*
|
||||||
* The generic <code>get()</code> and <code>opt()</code> methods return an object which you can cast or query for type.
|
* <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</code> and <code>opt</code> methods that do type checking and type coercion for you.
|
* 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
|
* <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>,</code> <small>(comma)</small> may appear
|
* 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</code> value will be inserted when there is <code>,</code>
|
* 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>'</code> <small>(single
|
* <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,
|
* 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>{ }
|
* 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>,
|
* [ ] / \ : , #} and if they do not look like numbers and if they are not the reserved words {@code true},
|
||||||
* <code>false</code>, or <code>null</code>.</li> </ul>
|
* {@code false}, or {@code null}.</li> </ul>
|
||||||
*
|
*
|
||||||
* @author JSON.org
|
* @author JSON.org
|
||||||
* @version 2014-05-03
|
* @version 2014-05-03
|
||||||
@ -90,8 +90,8 @@ public class JSONArray {
|
|||||||
/**
|
/**
|
||||||
* Construct a JSONArray from a source JSON text.
|
* Construct a JSONArray from a source JSON text.
|
||||||
*
|
*
|
||||||
* @param source A string that begins with <code>[</code> <small>(left bracket)</small> and ends with
|
* @param source A string that begins with {@code [} <small>(left bracket)</small> and ends with
|
||||||
* <code>]</code> <small>(right bracket)</small>.
|
* {@code ]} <small>(right bracket)</small>.
|
||||||
*
|
*
|
||||||
* @throws JSONException If there is a syntax error.
|
* @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.
|
* element. Warning: This method assumes that the data structure is acyclical.
|
||||||
*
|
*
|
||||||
* @param separator A string that will be inserted between the elements.
|
* @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
|
* Get the optional long value associated with an index. The defaultValue
|
||||||
* index, or if the value is not a number and cannot be converted to a number.
|
* 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 index The index must be between 0 and length() - 1.
|
||||||
* @param defaultValue The default value.
|
* @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
|
* Get the optional string value associated with an index. It returns an
|
||||||
* index. If the value is not a string and is not null, then it is converted to a string.
|
* 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.
|
* @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 index The index must be between 0 and length() - 1.
|
||||||
* @param defaultValue The default value.
|
* @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.
|
* @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.
|
* @param value A Map value.
|
||||||
*
|
*
|
||||||
@ -569,8 +574,8 @@ public class JSONArray {
|
|||||||
/**
|
/**
|
||||||
* Append an object value. This increases the array's length by one.
|
* 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
|
* @param value An object value. The value should be a Boolean, Double,
|
||||||
* String, or the JSONObject.NULL object.
|
* Integer, JSONArray, JSONObject, Long, or String, or the JSONObject.NULL object.
|
||||||
*
|
*
|
||||||
* @return this.
|
* @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 index The subscript.
|
||||||
* @param value A Collection value.
|
* @param value A Collection value.
|
||||||
*
|
*
|
||||||
* @return this.
|
* @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 {
|
public JSONArray put(int index, Collection<Object> value) throws JSONException {
|
||||||
this.put(index, new JSONArray(value));
|
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
|
* Put or replace a double value. If the index is greater than the length
|
||||||
* be added as necessary to pad it out.
|
* of the JSONArray, then null elements will be added as necessary to pad
|
||||||
|
* it out.
|
||||||
*
|
*
|
||||||
* @param index The subscript.
|
* @param index The subscript.
|
||||||
* @param value A double value.
|
* @param value A double value.
|
||||||
*
|
*
|
||||||
* @return this.
|
* @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 {
|
public JSONArray put(int index, double value) throws JSONException {
|
||||||
this.put(index, new Double(value));
|
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 index The subscript.
|
||||||
* @param value The Map value.
|
* @param value The Map value.
|
||||||
*
|
*
|
||||||
* @return this.
|
* @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 {
|
public JSONArray put(int index, Map<String, Object> value) throws JSONException {
|
||||||
this.put(index, new JSONObject(value));
|
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.
|
* @param indentFactor The number of spaces to add to each level of indentation.
|
||||||
*
|
*
|
||||||
* @return a printable, displayable, transmittable representation of the object, beginning with
|
* @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>.
|
* bracket)</small>.
|
||||||
*
|
*
|
||||||
* @throws JSONException
|
* @throws JSONException
|
||||||
|
@ -17,6 +17,7 @@ import com.intellectualcrafters.plot.util.TaskManager;
|
|||||||
import com.intellectualcrafters.plot.util.UUIDHandlerImplementation;
|
import com.intellectualcrafters.plot.util.UUIDHandlerImplementation;
|
||||||
import com.intellectualcrafters.plot.util.WorldUtil;
|
import com.intellectualcrafters.plot.util.WorldUtil;
|
||||||
import com.intellectualcrafters.plot.util.block.QueueProvider;
|
import com.intellectualcrafters.plot.util.block.QueueProvider;
|
||||||
|
|
||||||
import java.io.File;
|
import java.io.File;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
@ -51,17 +52,23 @@ public interface IPlotMain extends ILogger {
|
|||||||
* Disable the implementation.
|
* Disable the implementation.
|
||||||
*
|
*
|
||||||
* <ul>
|
* <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>
|
* </ul>
|
||||||
*/
|
*/
|
||||||
void disable();
|
void disable();
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Get the version of the PlotSquared being used.
|
* Get the version of the PlotSquared being used.
|
||||||
* @return
|
* @return the plugin version
|
||||||
*/
|
*/
|
||||||
int[] getPluginVersion();
|
int[] getPluginVersion();
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get the version of the PlotSquared being used as a string.
|
||||||
|
* @return the plugin version as a string
|
||||||
|
*/
|
||||||
|
String getPluginVersionString();
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Get the version of Minecraft that is running.
|
* Get the version of Minecraft that is running.
|
||||||
* @return
|
* @return
|
||||||
@ -229,12 +236,6 @@ public interface IPlotMain extends ILogger {
|
|||||||
*/
|
*/
|
||||||
void registerWorldEvents();
|
void registerWorldEvents();
|
||||||
|
|
||||||
/**
|
|
||||||
* Get the name of the server.
|
|
||||||
* @return The server name
|
|
||||||
*/
|
|
||||||
String getServerName();
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Get the class that will manage player titles.
|
* Get the class that will manage player titles.
|
||||||
* @return
|
* @return
|
||||||
|
@ -171,7 +171,6 @@ public class PS {
|
|||||||
this.IMP.registerPlayerEvents();
|
this.IMP.registerPlayerEvents();
|
||||||
this.IMP.registerInventoryEvents();
|
this.IMP.registerInventoryEvents();
|
||||||
this.IMP.registerPlotPlusEvents();
|
this.IMP.registerPlotPlusEvents();
|
||||||
this.IMP.registerForceFieldEvents();
|
|
||||||
}
|
}
|
||||||
// Required
|
// Required
|
||||||
this.IMP.registerWorldEvents();
|
this.IMP.registerWorldEvents();
|
||||||
@ -370,13 +369,16 @@ public class PS {
|
|||||||
@Override
|
@Override
|
||||||
public void run() {
|
public void run() {
|
||||||
UUIDHandler.add(new StringWrapper("*"), DBFunc.everyone);
|
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 (plot.hasOwner() && plot.temp != -1) {
|
||||||
if (UUIDHandler.getName(plot.owner) == null) {
|
if (UUIDHandler.getName(plot.owner) == null) {
|
||||||
UUIDHandler.implementation.unknown.add(plot.owner);
|
UUIDHandler.implementation.unknown.add(plot.owner);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
});
|
||||||
startExpiryTasks();
|
startExpiryTasks();
|
||||||
startPlotMeConversion();
|
startPlotMeConversion();
|
||||||
}
|
}
|
||||||
@ -726,6 +728,7 @@ public class PS {
|
|||||||
this.plotAreaGrid.put(plotArea.worldname, map);
|
this.plotAreaGrid.put(plotArea.worldname, map);
|
||||||
}
|
}
|
||||||
map.add(plotArea);
|
map.add(plotArea);
|
||||||
|
plotArea.setupBorder();
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -1077,14 +1080,15 @@ public class PS {
|
|||||||
public void run(PlotArea value) {
|
public void run(PlotArea value) {
|
||||||
for (PlotFilter filter : filters) {
|
for (PlotFilter filter : filters) {
|
||||||
if (!filter.allowsArea(value)) {
|
if (!filter.allowsArea(value)) {
|
||||||
continue;
|
return;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
loop:
|
||||||
for (Entry<PlotId, Plot> entry2 : value.getPlotEntries()) {
|
for (Entry<PlotId, Plot> entry2 : value.getPlotEntries()) {
|
||||||
Plot plot = entry2.getValue();
|
Plot plot = entry2.getValue();
|
||||||
for (PlotFilter filter : filters) {
|
for (PlotFilter filter : filters) {
|
||||||
if (!filter.allowsPlot(plot)) {
|
if (!filter.allowsPlot(plot)) {
|
||||||
continue;
|
continue loop;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
set.add(plot);
|
set.add(plot);
|
||||||
@ -1445,7 +1449,6 @@ public class PS {
|
|||||||
// Now add it
|
// Now add it
|
||||||
addPlotArea(plotArea);
|
addPlotArea(plotArea);
|
||||||
plotGenerator.initialize(plotArea);
|
plotGenerator.initialize(plotArea);
|
||||||
plotArea.setupBorder();
|
|
||||||
} else {
|
} else {
|
||||||
if (!worlds.contains(world)) {
|
if (!worlds.contains(world)) {
|
||||||
return;
|
return;
|
||||||
|
@ -0,0 +1,9 @@
|
|||||||
|
package com.intellectualcrafters.plot;
|
||||||
|
|
||||||
|
public enum Platform {
|
||||||
|
Bukkit,
|
||||||
|
Sponge,
|
||||||
|
Spigot,
|
||||||
|
Cauldron
|
||||||
|
|
||||||
|
}
|
@ -1,5 +1,7 @@
|
|||||||
package com.intellectualcrafters.plot;
|
package com.intellectualcrafters.plot;
|
||||||
|
|
||||||
|
import static com.intellectualcrafters.plot.PS.log;
|
||||||
|
|
||||||
import com.intellectualcrafters.json.JSONArray;
|
import com.intellectualcrafters.json.JSONArray;
|
||||||
import com.intellectualcrafters.json.JSONObject;
|
import com.intellectualcrafters.json.JSONObject;
|
||||||
import com.intellectualcrafters.plot.util.HttpUtil;
|
import com.intellectualcrafters.plot.util.HttpUtil;
|
||||||
@ -7,8 +9,7 @@ import com.intellectualcrafters.plot.util.StringMan;
|
|||||||
|
|
||||||
import java.net.MalformedURLException;
|
import java.net.MalformedURLException;
|
||||||
import java.net.URL;
|
import java.net.URL;
|
||||||
|
import java.util.Arrays;
|
||||||
import static com.intellectualcrafters.plot.PS.log;
|
|
||||||
|
|
||||||
public class Updater {
|
public class Updater {
|
||||||
|
|
||||||
@ -31,9 +32,11 @@ public class Updater {
|
|||||||
}
|
}
|
||||||
// If current version >= update
|
// If current version >= update
|
||||||
if (PS.get().checkVersion(PS.get().getVersion(), version)) {
|
if (PS.get().checkVersion(PS.get().getVersion(), version)) {
|
||||||
|
if (!PS.get().IMP.getPluginVersionString().contains("-SNAPSHOT") || !Arrays.equals(PS.get().getVersion(), version)) {
|
||||||
PS.debug("&7PlotSquared is already up to date!");
|
PS.debug("&7PlotSquared is already up to date!");
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
}
|
||||||
log("&6PlotSquared " + StringMan.join(split, ".") + " is available:");
|
log("&6PlotSquared " + StringMan.join(split, ".") + " is available:");
|
||||||
log("&8 - &3Use: &7/plot update");
|
log("&8 - &3Use: &7/plot update");
|
||||||
log("&8 - &3Or: &7" + downloadURL);
|
log("&8 - &3Or: &7" + downloadURL);
|
||||||
|
@ -23,7 +23,7 @@ import java.util.UUID;
|
|||||||
usage = "/plot add <player>",
|
usage = "/plot add <player>",
|
||||||
category = CommandCategory.SETTINGS,
|
category = CommandCategory.SETTINGS,
|
||||||
permission = "plots.add",
|
permission = "plots.add",
|
||||||
requiredType = RequiredType.PLAYER)
|
requiredType = RequiredType.NONE)
|
||||||
public class Add extends Command {
|
public class Add extends Command {
|
||||||
|
|
||||||
public Add() {
|
public Add() {
|
||||||
|
@ -118,7 +118,7 @@ public class Auto extends SubCommand {
|
|||||||
}
|
}
|
||||||
if (EconHandler.manager != null && plotarea.USE_ECONOMY) {
|
if (EconHandler.manager != null && plotarea.USE_ECONOMY) {
|
||||||
Expression<Double> costExp = plotarea.PRICES.get("claim");
|
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;
|
cost = (size_x * size_z) * cost;
|
||||||
if (cost > 0d) {
|
if (cost > 0d) {
|
||||||
if (EconHandler.manager.getMoney(player) < cost) {
|
if (EconHandler.manager.getMoney(player) < cost) {
|
||||||
|
@ -12,6 +12,7 @@ import com.intellectualcrafters.plot.util.MainUtil;
|
|||||||
import com.intellectualcrafters.plot.util.UUIDHandler;
|
import com.intellectualcrafters.plot.util.UUIDHandler;
|
||||||
import com.plotsquared.general.commands.Command;
|
import com.plotsquared.general.commands.Command;
|
||||||
import com.plotsquared.general.commands.CommandDeclaration;
|
import com.plotsquared.general.commands.CommandDeclaration;
|
||||||
|
|
||||||
import java.util.Set;
|
import java.util.Set;
|
||||||
|
|
||||||
@CommandDeclaration(
|
@CommandDeclaration(
|
||||||
@ -43,7 +44,9 @@ public class Buy extends Command {
|
|||||||
Set<Plot> plots = plot.getConnectedPlots();
|
Set<Plot> plots = plot.getConnectedPlots();
|
||||||
checkTrue(player.getPlotCount() + plots.size() <= player.getAllowedPlots(), C.CANT_CLAIM_MORE_PLOTS);
|
checkTrue(player.getPlotCount() + plots.size() <= player.getAllowedPlots(), C.CANT_CLAIM_MORE_PLOTS);
|
||||||
Optional<Double> flag = plot.getFlag(Flags.PRICE);
|
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();
|
final double price = flag.get();
|
||||||
checkTrue(player.getMoney() >= price, C.CANNOT_AFFORD_PLOT);
|
checkTrue(player.getMoney() >= price, C.CANNOT_AFFORD_PLOT);
|
||||||
player.withdraw(price);
|
player.withdraw(price);
|
||||||
|
@ -16,7 +16,7 @@ import com.plotsquared.general.commands.CommandDeclaration;
|
|||||||
aliases = "c",
|
aliases = "c",
|
||||||
description = "Claim the current plot you're standing on",
|
description = "Claim the current plot you're standing on",
|
||||||
category = CommandCategory.CLAIMING,
|
category = CommandCategory.CLAIMING,
|
||||||
requiredType = RequiredType.PLAYER,
|
requiredType = RequiredType.NONE,
|
||||||
permission = "plots.claim", usage = "/plot claim")
|
permission = "plots.claim", usage = "/plot claim")
|
||||||
public class Claim extends SubCommand {
|
public class Claim extends SubCommand {
|
||||||
|
|
||||||
@ -50,7 +50,7 @@ public class Claim extends SubCommand {
|
|||||||
PlotArea world = plot.getArea();
|
PlotArea world = plot.getArea();
|
||||||
if ((EconHandler.manager != null) && world.USE_ECONOMY) {
|
if ((EconHandler.manager != null) && world.USE_ECONOMY) {
|
||||||
Expression<Double> costExr = world.PRICES.get("claim");
|
Expression<Double> costExr = world.PRICES.get("claim");
|
||||||
double cost = costExr.evalute((double) currentPlots);
|
double cost = costExr.evaluate((double) currentPlots);
|
||||||
if (cost > 0d) {
|
if (cost > 0d) {
|
||||||
if (EconHandler.manager.getMoney(player) < cost) {
|
if (EconHandler.manager.getMoney(player) < cost) {
|
||||||
return sendMessage(player, C.CANNOT_AFFORD_PLOT, "" + cost);
|
return sendMessage(player, C.CANNOT_AFFORD_PLOT, "" + cost);
|
||||||
|
@ -36,7 +36,7 @@ public class Clear extends Command {
|
|||||||
final Plot plot = check(player.getCurrentPlot(), C.NOT_IN_PLOT);
|
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, "plots.admin.command.clear"), C.NO_PLOT_PERMS);
|
||||||
checkTrue(plot.getRunning() == 0, C.WAIT_FOR_TIMER);
|
checkTrue(plot.getRunning() == 0, C.WAIT_FOR_TIMER);
|
||||||
checkTrue((!Flags.DONE.isSet(plot) || Permissions.hasPermission(player, "plots.continue")) && (!Settings.Done.COUNTS_TOWARDS_LIMIT || player.getAllowedPlots() >= player.getPlotCount() + plot.getConnectedPlots().size()), C.DONE_ALREADY_DONE);
|
checkTrue(!Settings.Done.RESTRICT_BUILDING || !Flags.DONE.isSet(plot) || Permissions.hasPermission(player, "plots.continue"), C.DONE_ALREADY_DONE);
|
||||||
confirm.run(this, new Runnable() {
|
confirm.run(this, new Runnable() {
|
||||||
@Override
|
@Override
|
||||||
public void run() {
|
public void run() {
|
||||||
|
@ -84,6 +84,9 @@ public class DebugExec extends SubCommand {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public ScriptEngine getEngine() {
|
public ScriptEngine getEngine() {
|
||||||
|
if (this.engine == null) {
|
||||||
|
init();
|
||||||
|
}
|
||||||
return this.engine;
|
return this.engine;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -15,7 +15,7 @@ import java.io.IOException;
|
|||||||
|
|
||||||
@CommandDeclaration(command = "debugpaste",
|
@CommandDeclaration(command = "debugpaste",
|
||||||
aliases = "dp", usage = "/plot debugpaste",
|
aliases = "dp", usage = "/plot debugpaste",
|
||||||
description = "Upload settings.yml & latest.log to HasteBin",
|
description = "Upload settings.yml, worlds.yml, commands.yml and latest.log to www.hastebin.com",
|
||||||
permission = "plots.debugpaste",
|
permission = "plots.debugpaste",
|
||||||
category = CommandCategory.DEBUG)
|
category = CommandCategory.DEBUG)
|
||||||
public class DebugPaste extends SubCommand {
|
public class DebugPaste extends SubCommand {
|
||||||
|
@ -56,7 +56,7 @@ public class Delete extends SubCommand {
|
|||||||
plot.removeRunning();
|
plot.removeRunning();
|
||||||
if ((EconHandler.manager != null) && plotArea.USE_ECONOMY) {
|
if ((EconHandler.manager != null) && plotArea.USE_ECONOMY) {
|
||||||
Expression<Double> valueExr = plotArea.PRICES.get("sell");
|
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) {
|
if (value > 0d) {
|
||||||
EconHandler.manager.depositMoney(player, value);
|
EconHandler.manager.depositMoney(player, value);
|
||||||
sendMessage(player, C.ADDED_BALANCE, String.valueOf(value));
|
sendMessage(player, C.ADDED_BALANCE, String.valueOf(value));
|
||||||
|
@ -23,7 +23,7 @@ import java.util.UUID;
|
|||||||
description = "Deny a user from a plot",
|
description = "Deny a user from a plot",
|
||||||
usage = "/plot deny <player>",
|
usage = "/plot deny <player>",
|
||||||
category = CommandCategory.SETTINGS,
|
category = CommandCategory.SETTINGS,
|
||||||
requiredType = RequiredType.PLAYER)
|
requiredType = RequiredType.NONE)
|
||||||
public class Deny extends SubCommand {
|
public class Deny extends SubCommand {
|
||||||
|
|
||||||
public Deny() {
|
public Deny() {
|
||||||
|
@ -19,7 +19,7 @@ import com.plotsquared.general.commands.CommandDeclaration;
|
|||||||
description = "Mark a plot as done",
|
description = "Mark a plot as done",
|
||||||
permission = "plots.done",
|
permission = "plots.done",
|
||||||
category = CommandCategory.SETTINGS,
|
category = CommandCategory.SETTINGS,
|
||||||
requiredType = RequiredType.PLAYER)
|
requiredType = RequiredType.NONE)
|
||||||
public class Done extends SubCommand {
|
public class Done extends SubCommand {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -22,7 +22,7 @@ import java.net.URL;
|
|||||||
command = "download",
|
command = "download",
|
||||||
aliases = {"dl"},
|
aliases = {"dl"},
|
||||||
category = CommandCategory.SCHEMATIC,
|
category = CommandCategory.SCHEMATIC,
|
||||||
requiredType = RequiredType.PLAYER,
|
requiredType = RequiredType.NONE,
|
||||||
description = "Download your plot",
|
description = "Download your plot",
|
||||||
permission = "plots.download")
|
permission = "plots.download")
|
||||||
public class Download extends SubCommand {
|
public class Download extends SubCommand {
|
||||||
|
@ -28,7 +28,7 @@ import java.util.Map;
|
|||||||
usage = "/plot flag <set|remove|add|list|info> <flag> <value>",
|
usage = "/plot flag <set|remove|add|list|info> <flag> <value>",
|
||||||
description = "Set plot flags",
|
description = "Set plot flags",
|
||||||
category = CommandCategory.SETTINGS,
|
category = CommandCategory.SETTINGS,
|
||||||
requiredType = RequiredType.PLAYER,
|
requiredType = RequiredType.NONE,
|
||||||
permission = "plots.flag")
|
permission = "plots.flag")
|
||||||
public class FlagCmd extends SubCommand {
|
public class FlagCmd extends SubCommand {
|
||||||
|
|
||||||
@ -166,6 +166,9 @@ public class FlagCmd extends SubCommand {
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
if(flag == Flags.TIME) {
|
||||||
|
player.setTime(Long.MAX_VALUE);
|
||||||
|
}
|
||||||
MainUtil.sendMessage(player, C.FLAG_REMOVED);
|
MainUtil.sendMessage(player, C.FLAG_REMOVED);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
@ -4,12 +4,14 @@ import com.intellectualcrafters.plot.config.C;
|
|||||||
import com.intellectualcrafters.plot.database.DBFunc;
|
import com.intellectualcrafters.plot.database.DBFunc;
|
||||||
import com.intellectualcrafters.plot.object.PlotPlayer;
|
import com.intellectualcrafters.plot.object.PlotPlayer;
|
||||||
import com.intellectualcrafters.plot.object.RunnableVal;
|
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.ByteArrayUtilities;
|
||||||
import com.intellectualcrafters.plot.util.MainUtil;
|
import com.intellectualcrafters.plot.util.MainUtil;
|
||||||
import com.intellectualcrafters.plot.util.Permissions;
|
import com.intellectualcrafters.plot.util.Permissions;
|
||||||
import com.intellectualcrafters.plot.util.UUIDHandler;
|
import com.intellectualcrafters.plot.util.UUIDHandler;
|
||||||
|
import com.plotsquared.general.commands.Command;
|
||||||
import com.plotsquared.general.commands.CommandDeclaration;
|
import com.plotsquared.general.commands.CommandDeclaration;
|
||||||
|
|
||||||
import java.util.UUID;
|
import java.util.UUID;
|
||||||
|
|
||||||
@CommandDeclaration(
|
@CommandDeclaration(
|
||||||
@ -18,17 +20,22 @@ import java.util.UUID;
|
|||||||
usage = "/plot grant <check|add> [player]",
|
usage = "/plot grant <check|add> [player]",
|
||||||
permission = "plots.grant",
|
permission = "plots.grant",
|
||||||
requiredType = RequiredType.NONE)
|
requiredType = RequiredType.NONE)
|
||||||
public class Grant extends SubCommand {
|
public class Grant extends Command {
|
||||||
|
|
||||||
|
public Grant() {
|
||||||
|
super(MainCommand.getInstance(), true);
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@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();
|
final String arg0 = args[0].toLowerCase();
|
||||||
switch (arg0) {
|
switch (arg0) {
|
||||||
case "add":
|
case "add":
|
||||||
case "check":
|
case "check":
|
||||||
if (Permissions.hasPermission(player, "plots.grant." + arg0)) {
|
if (Permissions.hasPermission(player, "plots.grant." + arg0)) {
|
||||||
C.NO_PERMISSION.send(player, "plots.grant." + arg0);
|
C.NO_PERMISSION.send(player, "plots.grant." + arg0);
|
||||||
return false;
|
return;
|
||||||
}
|
}
|
||||||
if (args.length > 2) {
|
if (args.length > 2) {
|
||||||
break;
|
break;
|
||||||
@ -36,7 +43,7 @@ public class Grant extends SubCommand {
|
|||||||
final UUID uuid = args.length == 2 ? UUIDHandler.getUUIDFromString(args[1]) : player.getUUID();
|
final UUID uuid = args.length == 2 ? UUIDHandler.getUUIDFromString(args[1]) : player.getUUID();
|
||||||
if (uuid == null) {
|
if (uuid == null) {
|
||||||
C.INVALID_PLAYER.send(player, args[1]);
|
C.INVALID_PLAYER.send(player, args[1]);
|
||||||
return false;
|
return;
|
||||||
}
|
}
|
||||||
MainUtil.getPersistentMeta(uuid, "grantedPlots", new RunnableVal<byte[]>() {
|
MainUtil.getPersistentMeta(uuid, "grantedPlots", new RunnableVal<byte[]>() {
|
||||||
@Override
|
@Override
|
||||||
@ -51,10 +58,7 @@ public class Grant extends SubCommand {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
return true;
|
|
||||||
}
|
}
|
||||||
C.COMMAND_SYNTAX.send(player, getUsage());
|
C.COMMAND_SYNTAX.send(player, getUsage());
|
||||||
return false;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -8,6 +8,7 @@ import com.intellectualcrafters.plot.object.PlotItemStack;
|
|||||||
import com.intellectualcrafters.plot.object.PlotPlayer;
|
import com.intellectualcrafters.plot.object.PlotPlayer;
|
||||||
import com.intellectualcrafters.plot.object.RunnableVal;
|
import com.intellectualcrafters.plot.object.RunnableVal;
|
||||||
import com.intellectualcrafters.plot.util.MainUtil;
|
import com.intellectualcrafters.plot.util.MainUtil;
|
||||||
|
import com.intellectualcrafters.plot.util.expiry.ExpireManager;
|
||||||
import com.plotsquared.general.commands.CommandDeclaration;
|
import com.plotsquared.general.commands.CommandDeclaration;
|
||||||
|
|
||||||
import java.util.UUID;
|
import java.util.UUID;
|
||||||
@ -35,6 +36,7 @@ public class Info extends SubCommand {
|
|||||||
case "id":
|
case "id":
|
||||||
case "size":
|
case "size":
|
||||||
case "members":
|
case "members":
|
||||||
|
case "seen":
|
||||||
case "owner":
|
case "owner":
|
||||||
case "rating":
|
case "rating":
|
||||||
plot = MainUtil.getPlotFromString(player, null, false);
|
plot = MainUtil.getPlotFromString(player, null, false);
|
||||||
@ -82,7 +84,7 @@ public class Info extends SubCommand {
|
|||||||
"&cAlias: &6" + plot.getAlias(),
|
"&cAlias: &6" + plot.getAlias(),
|
||||||
"&cBiome: &6" + plot.getBiome().replaceAll("_", "").toLowerCase(),
|
"&cBiome: &6" + plot.getBiome().replaceAll("_", "").toLowerCase(),
|
||||||
"&cCan Build: &6" + plot.isAdded(uuid),
|
"&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)));
|
"&cIs Denied: &6" + plot.isDenied(uuid)));
|
||||||
inv.setItem(1, new PlotItemStack(388, (short) 0, 1, "&cTrusted", "&cAmount: &6" + plot.getTrusted().size(),
|
inv.setItem(1, new PlotItemStack(388, (short) 0, 1, "&cTrusted", "&cAmount: &6" + plot.getTrusted().size(),
|
||||||
"&8Click to view a list of the trusted users"));
|
"&8Click to view a list of the trusted users"));
|
||||||
@ -110,7 +112,7 @@ public class Info extends SubCommand {
|
|||||||
info = getCaption(arg);
|
info = getCaption(arg);
|
||||||
if (info == null) {
|
if (info == null) {
|
||||||
MainUtil.sendMessage(player,
|
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");
|
+ "&aowner&7, &arating");
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
@ -149,8 +151,8 @@ public class Info extends SubCommand {
|
|||||||
return C.PLOT_INFO_OWNER.s();
|
return C.PLOT_INFO_OWNER.s();
|
||||||
case "rating":
|
case "rating":
|
||||||
return C.PLOT_INFO_RATING.s();
|
return C.PLOT_INFO_RATING.s();
|
||||||
case "expires":
|
case "seen":
|
||||||
return C.PLOT_INFO_EXPIRES.s();
|
return C.PLOT_INFO_SEEN.s();
|
||||||
default:
|
default:
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
@ -22,7 +22,7 @@ import java.util.UUID;
|
|||||||
permission = "plots.kick",
|
permission = "plots.kick",
|
||||||
usage = "<player>",
|
usage = "<player>",
|
||||||
category = CommandCategory.TELEPORT,
|
category = CommandCategory.TELEPORT,
|
||||||
requiredType = RequiredType.PLAYER)
|
requiredType = RequiredType.NONE)
|
||||||
public class Kick extends SubCommand {
|
public class Kick extends SubCommand {
|
||||||
|
|
||||||
public Kick() {
|
public Kick() {
|
||||||
@ -48,8 +48,13 @@ public class Kick extends SubCommand {
|
|||||||
Set<PlotPlayer> players = new HashSet<>();
|
Set<PlotPlayer> players = new HashSet<>();
|
||||||
for (UUID uuid : uuids) {
|
for (UUID uuid : uuids) {
|
||||||
if (uuid == DBFunc.everyone) {
|
if (uuid == DBFunc.everyone) {
|
||||||
players.addAll(plot.getPlayersInPlot());
|
for (PlotPlayer pp : plot.getPlayersInPlot()) {
|
||||||
break;
|
if (pp == player || pp.hasPermission("plots.admin.entry.denied")) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
players.add(pp);
|
||||||
|
}
|
||||||
|
continue;
|
||||||
}
|
}
|
||||||
PlotPlayer pp = UUIDHandler.getPlayer(uuid);
|
PlotPlayer pp = UUIDHandler.getPlayer(uuid);
|
||||||
if (pp != null) {
|
if (pp != null) {
|
||||||
@ -62,13 +67,12 @@ public class Kick extends SubCommand {
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
for (PlotPlayer player2 : players) {
|
for (PlotPlayer player2 : players) {
|
||||||
Location location2 = player2.getLocation();
|
if (!plot.equals(player2.getCurrentPlot())) {
|
||||||
if (!player2.getLocation().getWorld().equals(location2.getWorld()) || !plot.equals(location2.getPlot())) {
|
MainUtil.sendMessage(player, C.INVALID_PLAYER, args[0]);
|
||||||
MainUtil.sendMessage(player2, C.INVALID_PLAYER, args[0]);
|
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
if (player2.hasPermission("plots.admin.entry.denied")) {
|
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;
|
return false;
|
||||||
}
|
}
|
||||||
Location spawn = WorldUtil.IMP.getSpawn(location.getWorld());
|
Location spawn = WorldUtil.IMP.getSpawn(location.getWorld());
|
||||||
|
@ -148,13 +148,7 @@ public class Load extends SubCommand {
|
|||||||
String world = split[1];
|
String world = split[1];
|
||||||
PlotId id = PlotId.fromString(split[2] + ';' + split[3]);
|
PlotId id = PlotId.fromString(split[2] + ';' + split[3]);
|
||||||
String size = split[4];
|
String size = split[4];
|
||||||
String server = split[5].replaceAll(".schematic", "");
|
String color = "$4";
|
||||||
String color;
|
|
||||||
if (PS.get().IMP.getServerName().replaceAll("[^A-Za-z0-9]", "").equals(server)) {
|
|
||||||
color = "$4";
|
|
||||||
} else {
|
|
||||||
color = "$1";
|
|
||||||
}
|
|
||||||
MainUtil.sendMessage(player,
|
MainUtil.sendMessage(player,
|
||||||
"$3[$2" + (i + 1) + "$3] " + color + time + "$3 | " + color + world + ';' + id + "$3 | " + color + size + 'x' + size);
|
"$3[$2" + (i + 1) + "$3] " + color + time + "$3 | " + color + world + ';' + id + "$3 | " + color + size + 'x' + size);
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
@ -191,7 +185,7 @@ public class Load extends SubCommand {
|
|||||||
time -= minutes * 60;
|
time -= minutes * 60;
|
||||||
toreturn.append(minutes + "m ");
|
toreturn.append(minutes + "m ");
|
||||||
}
|
}
|
||||||
if (toreturn.equals("") || (time > 0)) {
|
if (toreturn.length() == 0 || (time > 0)) {
|
||||||
toreturn.append(time + "s ");
|
toreturn.append(time + "s ");
|
||||||
}
|
}
|
||||||
return toreturn.toString().trim();
|
return toreturn.toString().trim();
|
||||||
|
@ -3,6 +3,7 @@ package com.intellectualcrafters.plot.commands;
|
|||||||
import com.intellectualcrafters.plot.PS;
|
import com.intellectualcrafters.plot.PS;
|
||||||
import com.intellectualcrafters.plot.config.C;
|
import com.intellectualcrafters.plot.config.C;
|
||||||
import com.intellectualcrafters.plot.object.ConsolePlayer;
|
import com.intellectualcrafters.plot.object.ConsolePlayer;
|
||||||
|
import com.intellectualcrafters.plot.object.Expression;
|
||||||
import com.intellectualcrafters.plot.object.Location;
|
import com.intellectualcrafters.plot.object.Location;
|
||||||
import com.intellectualcrafters.plot.object.Plot;
|
import com.intellectualcrafters.plot.object.Plot;
|
||||||
import com.intellectualcrafters.plot.object.PlotArea;
|
import com.intellectualcrafters.plot.object.PlotArea;
|
||||||
@ -139,7 +140,8 @@ public class MainCommand extends Command {
|
|||||||
if (EconHandler.manager != null) {
|
if (EconHandler.manager != null) {
|
||||||
PlotArea area = player.getApplicablePlotArea();
|
PlotArea area = player.getApplicablePlotArea();
|
||||||
if (area != null) {
|
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 (price != null && EconHandler.manager.getMoney(player) < price) {
|
||||||
if (failure != null) {
|
if (failure != null) {
|
||||||
failure.run();
|
failure.run();
|
||||||
@ -158,8 +160,9 @@ public class MainCommand extends Command {
|
|||||||
if (EconHandler.manager != null) {
|
if (EconHandler.manager != null) {
|
||||||
PlotArea area = player.getApplicablePlotArea();
|
PlotArea area = player.getApplicablePlotArea();
|
||||||
if (area != null) {
|
if (area != null) {
|
||||||
Double price = area.PRICES.get(cmd.getFullId()).evalute(0d);
|
Expression<Double> priceEval = area.PRICES.get(cmd.getFullId());
|
||||||
if (price != null && EconHandler.manager.getMoney(player) < price) {
|
Double price = priceEval != null ? priceEval.evaluate(0d) : 0d;
|
||||||
|
if (price != 0d && EconHandler.manager.getMoney(player) < price) {
|
||||||
if (failure != null) {
|
if (failure != null) {
|
||||||
failure.run();
|
failure.run();
|
||||||
}
|
}
|
||||||
@ -204,18 +207,35 @@ public class MainCommand extends Command {
|
|||||||
PlotArea area = player.getApplicablePlotArea();
|
PlotArea area = player.getApplicablePlotArea();
|
||||||
Plot newPlot = Plot.fromString(area, args[0]);
|
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())) {
|
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
|
// Save meta
|
||||||
loc = player.getMeta("location");
|
loc = player.getMeta("location");
|
||||||
plot = player.getMeta("lastplot");
|
plot = player.getMeta("lastplot");
|
||||||
tp = true;
|
tp = true;
|
||||||
// Set loc
|
// Set loc
|
||||||
player.setMeta("location", newPlot.getBottomAbs());
|
player.setMeta("location", newLoc);
|
||||||
player.setMeta("lastplot", newPlot);
|
player.setMeta("lastplot", newPlot);
|
||||||
|
} else {
|
||||||
|
C.BORDER.send(player);
|
||||||
|
}
|
||||||
// Trim command
|
// Trim command
|
||||||
args = Arrays.copyOfRange(args, 1, args.length);
|
args = Arrays.copyOfRange(args, 1, args.length);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
try {
|
||||||
super.execute(player, args, confirm, whenDone);
|
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 //
|
// Reset command scope //
|
||||||
if (tp && !(player instanceof ConsolePlayer)) {
|
if (tp && !(player instanceof ConsolePlayer)) {
|
||||||
if (loc == null) {
|
if (loc == null) {
|
||||||
|
@ -22,7 +22,7 @@ import java.util.UUID;
|
|||||||
description = "Merge the plot you are standing on, with another plot",
|
description = "Merge the plot you are standing on, with another plot",
|
||||||
permission = "plots.merge", usage = "/plot merge <all|n|e|s|w> [removeroads]",
|
permission = "plots.merge", usage = "/plot merge <all|n|e|s|w> [removeroads]",
|
||||||
category = CommandCategory.SETTINGS,
|
category = CommandCategory.SETTINGS,
|
||||||
requiredType = RequiredType.PLAYER,
|
requiredType = RequiredType.NONE,
|
||||||
confirmation = true)
|
confirmation = true)
|
||||||
public class Merge extends SubCommand {
|
public class Merge extends SubCommand {
|
||||||
|
|
||||||
@ -74,7 +74,7 @@ public class Merge extends SubCommand {
|
|||||||
final PlotArea plotArea = plot.getArea();
|
final PlotArea plotArea = plot.getArea();
|
||||||
Expression<Double> priceExr = plotArea.PRICES.containsKey("merge") ? plotArea.PRICES.get("merge") : null;
|
Expression<Double> priceExr = plotArea.PRICES.containsKey("merge") ? plotArea.PRICES.get("merge") : null;
|
||||||
final int size = plot.getConnectedPlots().size();
|
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) {
|
if (EconHandler.manager != null && plotArea.USE_ECONOMY && price > 0d && EconHandler.manager.getMoney(player) < price) {
|
||||||
sendMessage(player, C.CANNOT_AFFORD_MERGE, String.valueOf(price));
|
sendMessage(player, C.CANNOT_AFFORD_MERGE, String.valueOf(price));
|
||||||
return false;
|
return false;
|
||||||
|
@ -7,17 +7,15 @@ import com.intellectualcrafters.plot.object.PlotPlayer;
|
|||||||
import com.plotsquared.general.commands.CommandDeclaration;
|
import com.plotsquared.general.commands.CommandDeclaration;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Legally stolen from https://github.com/manuelgu/PlotSquaredMiddle
|
|
||||||
*
|
|
||||||
* @author manuelgu, altered by Citymonstret
|
* @author manuelgu, altered by Citymonstret
|
||||||
*/
|
*/
|
||||||
@CommandDeclaration(
|
@CommandDeclaration(
|
||||||
command = "middle",
|
command = "middle",
|
||||||
aliases = {"center"},
|
aliases = {"center", "centre"},
|
||||||
description = "Teleports you to the center of the current plot",
|
description = "Teleports you to the center of the plot",
|
||||||
usage = "/plot middle",
|
usage = "/plot middle",
|
||||||
category = CommandCategory.TELEPORT,
|
category = CommandCategory.TELEPORT,
|
||||||
requiredType = RequiredType.PLAYER)
|
requiredType = RequiredType.NONE)
|
||||||
public class Middle extends SubCommand {
|
public class Middle extends SubCommand {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -40,8 +40,8 @@ public class Owner extends SetCommand {
|
|||||||
name = UUIDHandler.getName(uuid);
|
name = UUIDHandler.getName(uuid);
|
||||||
name = name == null ? value : name;
|
name = name == null ? value : name;
|
||||||
}
|
}
|
||||||
if (uuid == null) {
|
if (uuid == null || value.equalsIgnoreCase("-")) {
|
||||||
if (value.equalsIgnoreCase("none")) {
|
if (value.equalsIgnoreCase("none") || value.equalsIgnoreCase("null") || value.equalsIgnoreCase("-")) {
|
||||||
Set<Plot> connected = plot.getConnectedPlots();
|
Set<Plot> connected = plot.getConnectedPlots();
|
||||||
plot.unlinkPlot(false, false);
|
plot.unlinkPlot(false, false);
|
||||||
for (Plot current : connected) {
|
for (Plot current : connected) {
|
||||||
|
@ -1,6 +1,7 @@
|
|||||||
package com.intellectualcrafters.plot.commands;
|
package com.intellectualcrafters.plot.commands;
|
||||||
|
|
||||||
import com.intellectualcrafters.plot.config.C;
|
import com.intellectualcrafters.plot.config.C;
|
||||||
|
import com.intellectualcrafters.plot.database.DBFunc;
|
||||||
import com.intellectualcrafters.plot.object.Location;
|
import com.intellectualcrafters.plot.object.Location;
|
||||||
import com.intellectualcrafters.plot.object.Plot;
|
import com.intellectualcrafters.plot.object.Plot;
|
||||||
import com.intellectualcrafters.plot.object.PlotPlayer;
|
import com.intellectualcrafters.plot.object.PlotPlayer;
|
||||||
@ -21,7 +22,7 @@ import java.util.UUID;
|
|||||||
description = "Remove a player from a plot",
|
description = "Remove a player from a plot",
|
||||||
usage = "/plot remove <player>",
|
usage = "/plot remove <player>",
|
||||||
category = CommandCategory.SETTINGS,
|
category = CommandCategory.SETTINGS,
|
||||||
requiredType = RequiredType.PLAYER,
|
requiredType = RequiredType.NONE,
|
||||||
permission = "plots.remove")
|
permission = "plots.remove")
|
||||||
public class Remove extends SubCommand {
|
public class Remove extends SubCommand {
|
||||||
|
|
||||||
@ -69,7 +70,12 @@ public class Remove extends SubCommand {
|
|||||||
Set<UUID> uuids = MainUtil.getUUIDsFromString(args[0]);
|
Set<UUID> uuids = MainUtil.getUUIDsFromString(args[0]);
|
||||||
if (!uuids.isEmpty()) {
|
if (!uuids.isEmpty()) {
|
||||||
for (UUID uuid : uuids) {
|
for (UUID uuid : uuids) {
|
||||||
if (plot.getTrusted().contains(uuid)) {
|
if (uuid == DBFunc.everyone) {
|
||||||
|
if (plot.removeTrusted(uuid) | plot.removeMember(uuid) | plot.removeDenied(uuid)) {
|
||||||
|
count++;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else if (plot.getTrusted().contains(uuid)) {
|
||||||
if (plot.removeTrusted(uuid)) {
|
if (plot.removeTrusted(uuid)) {
|
||||||
count++;
|
count++;
|
||||||
}
|
}
|
||||||
|
@ -63,12 +63,11 @@ public class Save extends SubCommand {
|
|||||||
@Override
|
@Override
|
||||||
public void run() {
|
public void run() {
|
||||||
String time = (System.currentTimeMillis() / 1000) + "";
|
String time = (System.currentTimeMillis() / 1000) + "";
|
||||||
String name = PS.get().IMP.getServerName().replaceAll("[^A-Za-z0-9]", "");
|
|
||||||
Location[] corners = plot.getCorners();
|
Location[] corners = plot.getCorners();
|
||||||
int size = (corners[1].getX() - corners[0].getX()) + 1;
|
int size = (corners[1].getX() - corners[0].getX()) + 1;
|
||||||
PlotId id = plot.getId();
|
PlotId id = plot.getId();
|
||||||
String world = plot.getArea().toString().replaceAll(";", "-").replaceAll("[^A-Za-z0-9]", "");
|
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();
|
UUID uuid = player.getUUID();
|
||||||
SchematicHandler.manager.upload(value, uuid, file, new RunnableVal<URL>() {
|
SchematicHandler.manager.upload(value, uuid, file, new RunnableVal<URL>() {
|
||||||
@Override
|
@Override
|
||||||
|
@ -19,7 +19,7 @@ import java.util.UUID;
|
|||||||
@CommandDeclaration(
|
@CommandDeclaration(
|
||||||
command = "trust",
|
command = "trust",
|
||||||
aliases = {"t"},
|
aliases = {"t"},
|
||||||
requiredType = RequiredType.PLAYER,
|
requiredType = RequiredType.NONE,
|
||||||
usage = "/plot trust <player>",
|
usage = "/plot trust <player>",
|
||||||
description = "Allow a player to build in a plot",
|
description = "Allow a player to build in a plot",
|
||||||
category = CommandCategory.SETTINGS)
|
category = CommandCategory.SETTINGS)
|
||||||
|
@ -4,10 +4,13 @@ import com.intellectualcrafters.plot.PS;
|
|||||||
import com.intellectualcrafters.plot.config.C;
|
import com.intellectualcrafters.plot.config.C;
|
||||||
import com.intellectualcrafters.plot.object.Plot;
|
import com.intellectualcrafters.plot.object.Plot;
|
||||||
import com.intellectualcrafters.plot.object.PlotPlayer;
|
import com.intellectualcrafters.plot.object.PlotPlayer;
|
||||||
|
import com.intellectualcrafters.plot.object.RunnableVal2;
|
||||||
|
import com.intellectualcrafters.plot.object.RunnableVal3;
|
||||||
import com.intellectualcrafters.plot.util.MainUtil;
|
import com.intellectualcrafters.plot.util.MainUtil;
|
||||||
import com.intellectualcrafters.plot.util.MathMan;
|
import com.intellectualcrafters.plot.util.MathMan;
|
||||||
import com.intellectualcrafters.plot.util.Permissions;
|
import com.intellectualcrafters.plot.util.Permissions;
|
||||||
import com.intellectualcrafters.plot.util.UUIDHandler;
|
import com.intellectualcrafters.plot.util.UUIDHandler;
|
||||||
|
import com.plotsquared.general.commands.Command;
|
||||||
import com.plotsquared.general.commands.CommandDeclaration;
|
import com.plotsquared.general.commands.CommandDeclaration;
|
||||||
|
|
||||||
import java.util.Collection;
|
import java.util.Collection;
|
||||||
@ -20,14 +23,23 @@ import java.util.UUID;
|
|||||||
command = "visit",
|
command = "visit",
|
||||||
permission = "plots.visit",
|
permission = "plots.visit",
|
||||||
description = "Visit someones plot",
|
description = "Visit someones plot",
|
||||||
usage = "/plot visit [player|alias|world|id] [#]",
|
usage = "/plot visit [<player>|<alias>|<world>|<id>] [#]",
|
||||||
aliases = {"v", "tp", "teleport", "goto", "home", "h"},
|
aliases = {"v", "tp", "teleport", "goto", "home", "h"},
|
||||||
requiredType = RequiredType.PLAYER,
|
requiredType = RequiredType.NONE,
|
||||||
category = CommandCategory.TELEPORT)
|
category = CommandCategory.TELEPORT)
|
||||||
public class Visit extends SubCommand {
|
public class Visit extends Command {
|
||||||
|
|
||||||
|
public Visit() {
|
||||||
|
super(MainCommand.getInstance(), true);
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean onCommand(PlotPlayer player, String[] args) {
|
public Collection<Command> tab(PlotPlayer player, String[] args, boolean space) {
|
||||||
|
return tabOf(player, args, space, getUsage());
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void execute(final PlotPlayer player, String[] args, RunnableVal3<Command, Runnable, Runnable> confirm, final RunnableVal2<Command, CommandResult> whenDone) throws CommandException {
|
||||||
if (args.length == 1 && args[0].contains(":")) {
|
if (args.length == 1 && args[0].contains(":")) {
|
||||||
args = args[0].split(":");
|
args = args[0].split(":");
|
||||||
}
|
}
|
||||||
@ -36,9 +48,9 @@ public class Visit extends SubCommand {
|
|||||||
switch (args.length) {
|
switch (args.length) {
|
||||||
case 2:
|
case 2:
|
||||||
if (!MathMan.isInteger(args[1])) {
|
if (!MathMan.isInteger(args[1])) {
|
||||||
sendMessage(player, C.NOT_VALID_NUMBER, "(1, ∞)");
|
C.NOT_VALID_NUMBER.send(player, "(1, ∞)");
|
||||||
sendMessage(player, C.COMMAND_SYNTAX, "/plot visit " + args[0] + " [#]");
|
C.COMMAND_SYNTAX.send(player, getUsage());;
|
||||||
return false;
|
return;
|
||||||
}
|
}
|
||||||
page = Integer.parseInt(args[1]);
|
page = Integer.parseInt(args[1]);
|
||||||
case 1:
|
case 1:
|
||||||
@ -68,8 +80,8 @@ public class Visit extends SubCommand {
|
|||||||
page = 1;
|
page = 1;
|
||||||
}
|
}
|
||||||
if (unsorted == null || unsorted.isEmpty()) {
|
if (unsorted == null || unsorted.isEmpty()) {
|
||||||
sendMessage(player, C.FOUND_NO_PLOTS);
|
C.FOUND_NO_PLOTS.send(player);
|
||||||
return false;
|
return;
|
||||||
}
|
}
|
||||||
Iterator<Plot> iterator = unsorted.iterator();
|
Iterator<Plot> iterator = unsorted.iterator();
|
||||||
while (iterator.hasNext()) {
|
while (iterator.hasNext()) {
|
||||||
@ -78,34 +90,47 @@ public class Visit extends SubCommand {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (page < 1 || page > unsorted.size()) {
|
if (page < 1 || page > unsorted.size()) {
|
||||||
sendMessage(player, C.NOT_VALID_NUMBER, "(1, " + unsorted.size() + ')');
|
C.NOT_VALID_NUMBER.send(player, "(1, " + unsorted.size() + ")");
|
||||||
return false;
|
return;
|
||||||
}
|
}
|
||||||
List<Plot> plots = PS.get().sortPlotsByTemp(unsorted);
|
List<Plot> plots = PS.get().sortPlotsByTemp(unsorted);
|
||||||
Plot plot = plots.get(page - 1);
|
final Plot plot = plots.get(page - 1);
|
||||||
if (!plot.hasOwner()) {
|
if (!plot.hasOwner()) {
|
||||||
if (!Permissions.hasPermission(player, "plots.visit.unowned")) {
|
if (!Permissions.hasPermission(player, "plots.visit.unowned")) {
|
||||||
sendMessage(player, C.NO_PERMISSION, "plots.visit.unowned");
|
C.NO_PERMISSION.send(player, "plots.visit.unowned");
|
||||||
return false;
|
return;
|
||||||
}
|
}
|
||||||
} else if (plot.isOwner(player.getUUID())) {
|
} else if (plot.isOwner(player.getUUID())) {
|
||||||
if (!Permissions.hasPermission(player, "plots.visit.owned") && !Permissions.hasPermission(player, "plots.home")) {
|
if (!Permissions.hasPermission(player, "plots.visit.owned") && !Permissions.hasPermission(player, "plots.home")) {
|
||||||
sendMessage(player, C.NO_PERMISSION, "plots.visit.owned, plots.home");
|
C.NO_PERMISSION.send(player, "plots.visit.owned, plots.home");
|
||||||
return false;
|
return;
|
||||||
}
|
}
|
||||||
} else if (plot.isAdded(player.getUUID())) {
|
} else if (plot.isAdded(player.getUUID())) {
|
||||||
if (!Permissions.hasPermission(player, "plots.visit.shared")) {
|
if (!Permissions.hasPermission(player, "plots.visit.shared")) {
|
||||||
sendMessage(player, C.NO_PERMISSION, "plots.visit.shared");
|
C.NO_PERMISSION.send(player, "plots.visit.shared");
|
||||||
return false;
|
return;
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
if (!Permissions.hasPermission(player, "plots.visit.other")) {
|
if (!Permissions.hasPermission(player, "plots.visit.other")) {
|
||||||
sendMessage(player, C.NO_PERMISSION, "plots.visit.other");
|
C.NO_PERMISSION.send(player, "plots.visit.other");
|
||||||
return false;
|
return;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
plot.teleportPlayer(player);
|
confirm.run(this, new Runnable() {
|
||||||
return true;
|
@Override
|
||||||
|
public void run() {
|
||||||
|
if (plot.teleportPlayer(player)) {
|
||||||
|
whenDone.run(Visit.this, CommandResult.SUCCESS);
|
||||||
|
} else {
|
||||||
|
whenDone.run(Visit.this, CommandResult.FAILURE);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}, new Runnable() {
|
||||||
|
@Override
|
||||||
|
public void run() {
|
||||||
|
whenDone.run(Visit.this, CommandResult.FAILURE);
|
||||||
|
}
|
||||||
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -75,7 +75,7 @@ public enum C {
|
|||||||
*/
|
*/
|
||||||
CONSOLE_JAVA_OUTDATED_1_8("&cYour version of java is outdated. It is highly recommended that you update to Java 8 as it increases performance "
|
CONSOLE_JAVA_OUTDATED_1_8("&cYour version of java is outdated. It is highly recommended that you update to Java 8 as it increases performance "
|
||||||
+ "and security. PlotSquared will require Java 9 in a future update.", "static.console"),
|
+ "and security. PlotSquared will require Java 9 in a future update.", "static.console"),
|
||||||
CONSOLE_PLEASE_ENABLE_METRICS("&dPlease enable metrics for PlotSquared. Using metrics improves plugin stabability, performance, and features. "
|
CONSOLE_PLEASE_ENABLE_METRICS("&dPlease enable metrics for PlotSquared. Using metrics improves plugin stability, performance, and features. "
|
||||||
+ "Bug fixes and new features are influenced on metrics.", "static.console"),
|
+ "Bug fixes and new features are influenced on metrics.", "static.console"),
|
||||||
/*
|
/*
|
||||||
* Confirm
|
* Confirm
|
||||||
@ -365,6 +365,10 @@ public enum C {
|
|||||||
INVALID_PLAYER_WAIT("$2Player not found: $1%s$2, fetching it. Try again soon.", "Errors"),
|
INVALID_PLAYER_WAIT("$2Player not found: $1%s$2, fetching it. Try again soon.", "Errors"),
|
||||||
INVALID_PLAYER("$2Player not found: $1%s$2.", "Errors"),
|
INVALID_PLAYER("$2Player not found: $1%s$2.", "Errors"),
|
||||||
INVALID_PLAYER_OFFLINE("$2The player must be online: $1%s.", "Errors"),
|
INVALID_PLAYER_OFFLINE("$2The player must be online: $1%s.", "Errors"),
|
||||||
|
/*
|
||||||
|
* Unknown Error
|
||||||
|
*/
|
||||||
|
ERROR("$2An error occurred: %s", "Errors"),
|
||||||
// SETTINGS_PASTE_UPLOADED("$2settings.yml was uploaded to: $1%url%", "Paste"),
|
// SETTINGS_PASTE_UPLOADED("$2settings.yml was uploaded to: $1%url%", "Paste"),
|
||||||
// LATEST_LOG_UPLOADED("$2latest.log was uploaded to: $1%url%", "Paste"),
|
// LATEST_LOG_UPLOADED("$2latest.log was uploaded to: $1%url%", "Paste"),
|
||||||
DEBUG_REPORT_CREATED("$1Uploaded a full debug to: $1%url%", "Paste"),
|
DEBUG_REPORT_CREATED("$1Uploaded a full debug to: $1%url%", "Paste"),
|
||||||
@ -454,6 +458,7 @@ public enum C {
|
|||||||
* Info
|
* Info
|
||||||
*/
|
*/
|
||||||
NONE("None", "Info"),
|
NONE("None", "Info"),
|
||||||
|
NOW("Now", "Info"),
|
||||||
NEVER("Never", "Info"),
|
NEVER("Never", "Info"),
|
||||||
UNKNOWN("Unknown", "Info"),
|
UNKNOWN("Unknown", "Info"),
|
||||||
EVERYONE("Everyone", "Info"),
|
EVERYONE("Everyone", "Info"),
|
||||||
@ -466,7 +471,7 @@ public enum C {
|
|||||||
+ "$1Biome: $2%biome%$1&-"
|
+ "$1Biome: $2%biome%$1&-"
|
||||||
+ "$1Can Build: $2%build%$1&-"
|
+ "$1Can Build: $2%build%$1&-"
|
||||||
+ "$1Rating: $2%rating%&-"
|
+ "$1Rating: $2%rating%&-"
|
||||||
+ "$1Expires: $2%expires%&-"
|
+ "$1Seen: $2%seen%&-"
|
||||||
+ "$1Trusted: $2%trusted%$1&-"
|
+ "$1Trusted: $2%trusted%$1&-"
|
||||||
+ "$1Members: $2%members%$1&-"
|
+ "$1Members: $2%members%$1&-"
|
||||||
+ "$1Denied: $2%denied%$1&-"
|
+ "$1Denied: $2%denied%$1&-"
|
||||||
@ -482,7 +487,7 @@ public enum C {
|
|||||||
PLOT_INFO_ID("$1ID:$2 %id%", "Info"),
|
PLOT_INFO_ID("$1ID:$2 %id%", "Info"),
|
||||||
PLOT_INFO_ALIAS("$1Alias:$2 %alias%", "Info"),
|
PLOT_INFO_ALIAS("$1Alias:$2 %alias%", "Info"),
|
||||||
PLOT_INFO_SIZE("$1Size:$2 %size%", "Info"),
|
PLOT_INFO_SIZE("$1Size:$2 %size%", "Info"),
|
||||||
PLOT_INFO_EXPIRES("$1Expires:$2 %expires%", "Info"),
|
PLOT_INFO_SEEN("$1Seen:$2 %seen%", "Info"),
|
||||||
PLOT_USER_LIST(" $1%user%$2,", "Info"),
|
PLOT_USER_LIST(" $1%user%$2,", "Info"),
|
||||||
PLOT_FLAG_LIST("$1%s0:%s1$2", "Info"),
|
PLOT_FLAG_LIST("$1%s0:%s1$2", "Info"),
|
||||||
INFO_SYNTAX_CONSOLE("$2/plot info X;Y", "Info"),
|
INFO_SYNTAX_CONSOLE("$2/plot info X;Y", "Info"),
|
||||||
@ -665,7 +670,7 @@ public enum C {
|
|||||||
Map<String, String> map = new LinkedHashMap<>();
|
Map<String, String> map = new LinkedHashMap<>();
|
||||||
if (args.length > 0) {
|
if (args.length > 0) {
|
||||||
for (int i = args.length - 1; i >= 0; i--) {
|
for (int i = args.length - 1; i >= 0; i--) {
|
||||||
String arg = args[i].toString();
|
String arg = "" + args[i];
|
||||||
if (arg == null || arg.isEmpty()) {
|
if (arg == null || arg.isEmpty()) {
|
||||||
map.put("%s" + i, "");
|
map.put("%s" + i, "");
|
||||||
} else {
|
} else {
|
||||||
@ -682,7 +687,7 @@ public enum C {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public static String format(C caption, Object... args) {
|
public static String format(C caption, Object... args) {
|
||||||
if (caption.usePrefix()) {
|
if (caption.usePrefix() && caption.s.length() > 0) {
|
||||||
return C.PREFIX.s() + format(caption.s, args);
|
return C.PREFIX.s() + format(caption.s, args);
|
||||||
} else {
|
} else {
|
||||||
return format(caption.s, args);
|
return format(caption.s, args);
|
||||||
|
@ -65,9 +65,13 @@ public class Config {
|
|||||||
if (field.getAnnotation(Final.class) != null) {
|
if (field.getAnnotation(Final.class) != null) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
if (field.getType() == String.class && !(value instanceof String)) {
|
||||||
|
value = value + "";
|
||||||
|
}
|
||||||
field.set(instance, value);
|
field.set(instance, value);
|
||||||
return;
|
return;
|
||||||
} catch (IllegalAccessException e) {
|
} catch (Throwable e) {
|
||||||
|
PS.debug("Invalid configuration value: " + key + ": " + value + " in " + root.getSimpleName());
|
||||||
e.printStackTrace();
|
e.printStackTrace();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -261,10 +261,6 @@ public class Settings extends Config {
|
|||||||
public static boolean DISABLE_OFFLINE = false;
|
public static boolean DISABLE_OFFLINE = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
|
||||||
END OF CONFIGURATION SECTION:
|
|
||||||
*/
|
|
||||||
|
|
||||||
public static final class Claim {
|
public static final class Claim {
|
||||||
@Comment("The max plots claimed in a single `/plot auto <size>` command")
|
@Comment("The max plots claimed in a single `/plot auto <size>` command")
|
||||||
public static int MAX_AUTO_AREA = 4;
|
public static int MAX_AUTO_AREA = 4;
|
||||||
@ -300,7 +296,7 @@ public class Settings extends Config {
|
|||||||
public static boolean WORLDEDIT_RESTRICTIONS = true;
|
public static boolean WORLDEDIT_RESTRICTIONS = true;
|
||||||
@Comment("Allow economy to be used")
|
@Comment("Allow economy to be used")
|
||||||
public static boolean ECONOMY = true;
|
public static boolean ECONOMY = true;
|
||||||
@Comment("Send anonymous usage statistics")
|
@Comment("Send anonymous usage statistics. Bukkit only setting.")
|
||||||
public static boolean METRICS = true;
|
public static boolean METRICS = true;
|
||||||
@Comment("Expiry will clear old or simplistic plots")
|
@Comment("Expiry will clear old or simplistic plots")
|
||||||
public static boolean PLOT_EXPIRY = false;
|
public static boolean PLOT_EXPIRY = false;
|
||||||
|
@ -1583,7 +1583,7 @@ public class SQLManager implements AbstractDB {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Load all plots, helpers, denied, trusted, and every setting from DB into a hashmap
|
* Load all plots, helpers, denied, trusted, and every setting from DB into a {@link HashMap}.
|
||||||
*/
|
*/
|
||||||
@Override
|
@Override
|
||||||
public HashMap<String, HashMap<PlotId, Plot>> getPlots() {
|
public HashMap<String, HashMap<PlotId, Plot>> getPlots() {
|
||||||
@ -1816,14 +1816,7 @@ public class SQLManager implements AbstractDB {
|
|||||||
String[] split = element.split(":");
|
String[] split = element.split(":");
|
||||||
try {
|
try {
|
||||||
String flag_str = split[1].replaceAll("¯", ":").replaceAll("\u00B4", ",");
|
String flag_str = split[1].replaceAll("¯", ":").replaceAll("\u00B4", ",");
|
||||||
Flag<?> flag = FlagManager.getFlag(split[0],true);
|
Flag<?> flag = FlagManager.getOrCreateFlag(split[0]);
|
||||||
if (flag == null) {
|
|
||||||
flag = new StringFlag(split[0]) {
|
|
||||||
@Override public String getValueDescription() {
|
|
||||||
return "Generic Filler Flag";
|
|
||||||
}
|
|
||||||
};
|
|
||||||
}
|
|
||||||
flags.put(flag, flag.parseValue(flag_str));
|
flags.put(flag, flag.parseValue(flag_str));
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
e.printStackTrace();
|
e.printStackTrace();
|
||||||
@ -1832,7 +1825,7 @@ public class SQLManager implements AbstractDB {
|
|||||||
} else {
|
} else {
|
||||||
element = element.replaceAll("\u00AF", ":").replaceAll("\u00B4", ",");
|
element = element.replaceAll("\u00AF", ":").replaceAll("\u00B4", ",");
|
||||||
if (StringMan.isAlpha(element.replaceAll("_", "").replaceAll("-", ""))) {
|
if (StringMan.isAlpha(element.replaceAll("_", "").replaceAll("-", ""))) {
|
||||||
Flag flag = FlagManager.getFlag(element,true);
|
Flag flag = FlagManager.getOrCreateFlag(element);
|
||||||
if (flag == null) {
|
if (flag == null) {
|
||||||
flag = new StringFlag(element) {
|
flag = new StringFlag(element) {
|
||||||
@Override public String getValueDescription() {
|
@Override public String getValueDescription() {
|
||||||
@ -2560,9 +2553,7 @@ public class SQLManager implements AbstractDB {
|
|||||||
}
|
}
|
||||||
set.add(cluster);
|
set.add(cluster);
|
||||||
}
|
}
|
||||||
/*
|
//Getting helpers
|
||||||
* Getting helpers
|
|
||||||
*/
|
|
||||||
resultSet = stmt.executeQuery("SELECT `user_uuid`, `cluster_id` FROM `" + this.prefix + "cluster_helpers`");
|
resultSet = stmt.executeQuery("SELECT `user_uuid`, `cluster_id` FROM `" + this.prefix + "cluster_helpers`");
|
||||||
while (resultSet.next()) {
|
while (resultSet.next()) {
|
||||||
id = resultSet.getInt("cluster_id");
|
id = resultSet.getInt("cluster_id");
|
||||||
@ -2579,9 +2570,7 @@ public class SQLManager implements AbstractDB {
|
|||||||
PS.debug("&cCluster " + id + " in cluster_helpers does not exist. Please create the cluster or remove this entry.");
|
PS.debug("&cCluster " + id + " in cluster_helpers does not exist. Please create the cluster or remove this entry.");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
/*
|
// Getting invited
|
||||||
* Getting invited
|
|
||||||
*/
|
|
||||||
resultSet = stmt.executeQuery("SELECT `user_uuid`, `cluster_id` FROM `" + this.prefix + "cluster_invited`");
|
resultSet = stmt.executeQuery("SELECT `user_uuid`, `cluster_id` FROM `" + this.prefix + "cluster_invited`");
|
||||||
while (resultSet.next()) {
|
while (resultSet.next()) {
|
||||||
id = resultSet.getInt("cluster_id");
|
id = resultSet.getInt("cluster_id");
|
||||||
@ -2638,7 +2627,7 @@ public class SQLManager implements AbstractDB {
|
|||||||
if (element.contains(":")) {
|
if (element.contains(":")) {
|
||||||
String[] split = element.split(":");
|
String[] split = element.split(":");
|
||||||
String flag_str = split[1].replaceAll("\u00AF", ":").replaceAll("<EFBFBD>", ",");
|
String flag_str = split[1].replaceAll("\u00AF", ":").replaceAll("<EFBFBD>", ",");
|
||||||
Flag flag = FlagManager.getFlag(split[0],true);
|
Flag flag = FlagManager.getOrCreateFlag(split[0]);
|
||||||
if (flag == null) {
|
if (flag == null) {
|
||||||
flag = new StringFlag(split[0]) {
|
flag = new StringFlag(split[0]) {
|
||||||
@Override public String getValueDescription() {
|
@Override public String getValueDescription() {
|
||||||
@ -2648,7 +2637,7 @@ public class SQLManager implements AbstractDB {
|
|||||||
}
|
}
|
||||||
flags.put(flag, flag.parseValue(flag_str));
|
flags.put(flag, flag.parseValue(flag_str));
|
||||||
} else {
|
} else {
|
||||||
Flag flag = FlagManager.getFlag(element,true);
|
Flag flag = FlagManager.getOrCreateFlag(element);
|
||||||
if (flag == null) {
|
if (flag == null) {
|
||||||
flag = new StringFlag(element) {
|
flag = new StringFlag(element) {
|
||||||
@Override public String getValueDescription() {
|
@Override public String getValueDescription() {
|
||||||
|
@ -9,11 +9,7 @@ public class BooleanFlag extends Flag<Boolean> {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override public String valueToString(Object value) {
|
@Override public String valueToString(Object value) {
|
||||||
if (((boolean) value)) {
|
return value + "";
|
||||||
return "true";
|
|
||||||
} else {
|
|
||||||
return "false";
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override public Boolean parseValue(String value) {
|
@Override public Boolean parseValue(String value) {
|
||||||
|
@ -0,0 +1,31 @@
|
|||||||
|
package com.intellectualcrafters.plot.flag;
|
||||||
|
|
||||||
|
import com.intellectualcrafters.plot.util.StringMan;
|
||||||
|
import java.util.Arrays;
|
||||||
|
import java.util.HashSet;
|
||||||
|
|
||||||
|
public class EnumFlag extends Flag<String> {
|
||||||
|
private final HashSet<String> values;
|
||||||
|
|
||||||
|
public EnumFlag(String name, String... values) {
|
||||||
|
super(name);
|
||||||
|
this.values = new HashSet<>(Arrays.asList(values));
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String valueToString(Object value) {
|
||||||
|
return value.toString();
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override public String parseValue(String value) {
|
||||||
|
value = value.toLowerCase();
|
||||||
|
if (values.contains(value)) {
|
||||||
|
return value;
|
||||||
|
}
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override public String getValueDescription() {
|
||||||
|
return "Must be one of: " + StringMan.getString(values);
|
||||||
|
}
|
||||||
|
}
|
@ -112,12 +112,17 @@ public class FlagManager {
|
|||||||
StringBuilder flag_string = new StringBuilder();
|
StringBuilder flag_string = new StringBuilder();
|
||||||
int i = 0;
|
int i = 0;
|
||||||
for (Map.Entry<Flag<?>, Object> entry : flags.entrySet()) {
|
for (Map.Entry<Flag<?>, Object> entry : flags.entrySet()) {
|
||||||
|
try {
|
||||||
Flag flag = entry.getKey();
|
Flag flag = entry.getKey();
|
||||||
if (i != 0) {
|
if (i != 0) {
|
||||||
flag_string.append(',');
|
flag_string.append(',');
|
||||||
}
|
}
|
||||||
flag_string.append(flag.getName() + ':' + flag.valueToString(entry.getValue()).replaceAll(":", "¯").replaceAll(",", "´"));
|
flag_string.append(flag.getName() + ':' + flag.valueToString(entry.getValue()).replaceAll(":", "¯").replaceAll(",", "´"));
|
||||||
i++;
|
i++;
|
||||||
|
} catch (Exception e) {
|
||||||
|
PS.debug("Failed to parse flag: " + entry.getKey() + "->" + entry.getValue());
|
||||||
|
e.printStackTrace();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
return flag_string.toString();
|
return flag_string.toString();
|
||||||
}
|
}
|
||||||
@ -213,7 +218,7 @@ public class FlagManager {
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* Removes a flag from a certain plot.
|
* Removes a flag from a certain plot.
|
||||||
* @param plot the plot to remove the flag from
|
* @param origin the plot to remove the flag from
|
||||||
* @param id the flag to remove
|
* @param id the flag to remove
|
||||||
* @return true if the plot contained the flag and was removed successfully
|
* @return true if the plot contained the flag and was removed successfully
|
||||||
*/
|
*/
|
||||||
@ -317,6 +322,19 @@ public class FlagManager {
|
|||||||
return flag;
|
return flag;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static Flag<?> getOrCreateFlag(String string) {
|
||||||
|
Flag<?> flag = Flags.getFlag(string);
|
||||||
|
if (flag == null) {
|
||||||
|
flag = new StringFlag(string) {
|
||||||
|
@Override public String getValueDescription() {
|
||||||
|
return "Generic Filler Flag";
|
||||||
|
}
|
||||||
|
};
|
||||||
|
flag.register();
|
||||||
|
}
|
||||||
|
return flag;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
public static Map<Flag<?>, Object> parseFlags(List<String> flagStrings) {
|
public static Map<Flag<?>, Object> parseFlags(List<String> flagStrings) {
|
||||||
HashMap<Flag<?>, Object> map = new HashMap<>();
|
HashMap<Flag<?>, Object> map = new HashMap<>();
|
||||||
@ -328,7 +346,7 @@ public class FlagManager {
|
|||||||
} else {
|
} else {
|
||||||
split = key.split(":");
|
split = key.split(":");
|
||||||
}
|
}
|
||||||
Flag<?> flag = getFlag(split[0]);
|
Flag<?> flag = getOrCreateFlag(split[0]);
|
||||||
Object value = flag.parseValue(split[1]);
|
Object value = flag.parseValue(split[1]);
|
||||||
map.put(flag, value);
|
map.put(flag, value);
|
||||||
}
|
}
|
||||||
|
@ -6,7 +6,6 @@ import com.intellectualcrafters.plot.object.PlotArea;
|
|||||||
import com.intellectualcrafters.plot.object.RunnableVal;
|
import com.intellectualcrafters.plot.object.RunnableVal;
|
||||||
import com.intellectualcrafters.plot.util.MainUtil;
|
import com.intellectualcrafters.plot.util.MainUtil;
|
||||||
import com.intellectualcrafters.plot.util.MathMan;
|
import com.intellectualcrafters.plot.util.MathMan;
|
||||||
|
|
||||||
import java.lang.reflect.Field;
|
import java.lang.reflect.Field;
|
||||||
import java.util.Collection;
|
import java.util.Collection;
|
||||||
import java.util.Collections;
|
import java.util.Collections;
|
||||||
@ -22,6 +21,7 @@ public final class Flags {
|
|||||||
public static final IntervalFlag FEED = new IntervalFlag("feed");
|
public static final IntervalFlag FEED = new IntervalFlag("feed");
|
||||||
public static final IntervalFlag HEAL = new IntervalFlag("heal");
|
public static final IntervalFlag HEAL = new IntervalFlag("heal");
|
||||||
public static final GameModeFlag GAMEMODE = new GameModeFlag("gamemode");
|
public static final GameModeFlag GAMEMODE = new GameModeFlag("gamemode");
|
||||||
|
public static final GameModeFlag GUEST_GAMEMODE = new GameModeFlag("guest-gamemode");
|
||||||
public static final StringFlag DONE = (StringFlag) new StringFlag("done").reserve();
|
public static final StringFlag DONE = (StringFlag) new StringFlag("done").reserve();
|
||||||
public static final BooleanFlag REDSTONE = new BooleanFlag("redstone");
|
public static final BooleanFlag REDSTONE = new BooleanFlag("redstone");
|
||||||
public static final BooleanFlag FLY = new BooleanFlag("fly");
|
public static final BooleanFlag FLY = new BooleanFlag("fly");
|
||||||
@ -47,6 +47,7 @@ public final class Flags {
|
|||||||
public static final BooleanFlag VINE_GROW = new BooleanFlag("vine-grow");
|
public static final BooleanFlag VINE_GROW = new BooleanFlag("vine-grow");
|
||||||
public static final BooleanFlag MYCEL_GROW = new BooleanFlag("mycel-grow");
|
public static final BooleanFlag MYCEL_GROW = new BooleanFlag("mycel-grow");
|
||||||
public static final BooleanFlag DISABLE_PHYSICS = new BooleanFlag("disable-physics");
|
public static final BooleanFlag DISABLE_PHYSICS = new BooleanFlag("disable-physics");
|
||||||
|
public static final BooleanFlag LIQUID_FLOW = new BooleanFlag("liquid-flow");
|
||||||
public static final BooleanFlag SNOW_MELT = new BooleanFlag("snow-melt");
|
public static final BooleanFlag SNOW_MELT = new BooleanFlag("snow-melt");
|
||||||
public static final BooleanFlag ICE_MELT = new BooleanFlag("ice-melt");
|
public static final BooleanFlag ICE_MELT = new BooleanFlag("ice-melt");
|
||||||
public static final BooleanFlag FIRE_SPREAD = new BooleanFlag("fire-spread");
|
public static final BooleanFlag FIRE_SPREAD = new BooleanFlag("fire-spread");
|
||||||
@ -113,6 +114,9 @@ public final class Flags {
|
|||||||
}
|
}
|
||||||
};
|
};
|
||||||
public static final BooleanFlag SLEEP = new BooleanFlag("sleep");
|
public static final BooleanFlag SLEEP = new BooleanFlag("sleep");
|
||||||
|
public static final TeleportDenyFlag DENY_TELEPORT = new TeleportDenyFlag("deny-teleport");
|
||||||
|
public static final BooleanFlag DENY_EXIT = new BooleanFlag("deny-exit");
|
||||||
|
|
||||||
|
|
||||||
private static final HashMap<String, Flag<?>> flags;
|
private static final HashMap<String, Flag<?>> flags;
|
||||||
static {
|
static {
|
||||||
@ -150,35 +154,24 @@ public final class Flags {
|
|||||||
|
|
||||||
public static void registerFlag(final Flag<?> flag) {
|
public static void registerFlag(final Flag<?> flag) {
|
||||||
final Flag<?> duplicate = flags.put(flag.getName(), flag);
|
final Flag<?> duplicate = flags.put(flag.getName(), flag);
|
||||||
|
if (duplicate != null) {
|
||||||
PS.get().foreachPlotArea(new RunnableVal<PlotArea>() {
|
PS.get().foreachPlotArea(new RunnableVal<PlotArea>() {
|
||||||
@Override public void run(PlotArea value) {
|
@Override public void run(PlotArea value) {
|
||||||
if (duplicate != null) {
|
|
||||||
Object remove;
|
Object remove;
|
||||||
if (value.DEFAULT_FLAGS.containsKey(duplicate)) {
|
if (value.DEFAULT_FLAGS.containsKey(duplicate)) {
|
||||||
remove = value.DEFAULT_FLAGS.remove(duplicate);
|
remove = value.DEFAULT_FLAGS.remove(duplicate);
|
||||||
if (!(remove instanceof String)) {
|
value.DEFAULT_FLAGS.put(flag,flag.parseValue("" + remove));
|
||||||
//error message? maybe?
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
value.DEFAULT_FLAGS.put(flag,flag.parseValue((String) remove));
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
PS.get().foreachPlotRaw(new RunnableVal<Plot>() {
|
PS.get().foreachPlotRaw(new RunnableVal<Plot>() {
|
||||||
@Override public void run(Plot value) {
|
@Override public void run(Plot value) {
|
||||||
if (duplicate != null) {
|
|
||||||
Object remove = null;
|
|
||||||
if (value.getFlags().containsKey(duplicate)) {
|
if (value.getFlags().containsKey(duplicate)) {
|
||||||
remove = value.getFlags().remove(duplicate);
|
Object remove = value.getFlags().remove(duplicate);
|
||||||
}
|
value.getFlags().put(flag,flag.parseValue("" + remove));
|
||||||
if (!(remove instanceof String)) {
|
|
||||||
//error message? maybe?
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
value.getFlags().put(flag,flag.parseValue((String) remove));
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
@ -0,0 +1,38 @@
|
|||||||
|
package com.intellectualcrafters.plot.flag;
|
||||||
|
|
||||||
|
import com.intellectualcrafters.plot.object.Plot;
|
||||||
|
import com.intellectualcrafters.plot.object.PlotPlayer;
|
||||||
|
|
||||||
|
public class TeleportDenyFlag extends EnumFlag {
|
||||||
|
public TeleportDenyFlag(String name) {
|
||||||
|
super(name, "trusted", "members", "nonmembers", "nontrusted", "nonowners");
|
||||||
|
}
|
||||||
|
|
||||||
|
public boolean allowsTeleport(PlotPlayer player, Plot plot) {
|
||||||
|
String value = plot.getFlag(this, null);
|
||||||
|
if (value == null || !plot.hasOwner()) {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
boolean result;
|
||||||
|
switch (plot.getFlag(this, null)) {
|
||||||
|
case "trusted":
|
||||||
|
result = !plot.getTrusted().contains(player.getUUID());
|
||||||
|
break;
|
||||||
|
case "members":
|
||||||
|
result =!plot.getMembers().contains(player.getUUID());
|
||||||
|
break;
|
||||||
|
case "nonmembers":
|
||||||
|
result =!plot.isAdded(player.getUUID());
|
||||||
|
break;
|
||||||
|
case "nontrusted":
|
||||||
|
result =!plot.getTrusted().contains(player.getUUID()) && !plot.isOwner(player.getUUID());
|
||||||
|
break;
|
||||||
|
case "nonowners":
|
||||||
|
result =!plot.isOwner(player.getUUID());
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
return result || player.hasPermission("plots.admin.entry.denied");
|
||||||
|
}
|
||||||
|
}
|
@ -140,7 +140,9 @@ public class AugmentedUtils {
|
|||||||
generator.generateChunk(scoped, area, r);
|
generator.generateChunk(scoped, area, r);
|
||||||
generator.populateChunk(scoped, area, r);
|
generator.populateChunk(scoped, area, r);
|
||||||
}
|
}
|
||||||
|
if (queue != null) {
|
||||||
queue.flush();
|
queue.flush();
|
||||||
|
}
|
||||||
return toReturn;
|
return toReturn;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -66,13 +66,14 @@ public class HybridPlotManager extends ClassicPlotManager {
|
|||||||
if (!hpw.ROAD_SCHEMATIC_ENABLED) {
|
if (!hpw.ROAD_SCHEMATIC_ENABLED) {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
createSchemAbs(hpw, pos1, pos2, true);
|
LocalBlockQueue queue = hpw.getQueue(false);
|
||||||
|
createSchemAbs(hpw, queue, pos1, pos2, true);
|
||||||
|
queue.enqueue();
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
private void createSchemAbs(HybridPlotWorld hpw, Location pos1, Location pos2, boolean clear) {
|
private void createSchemAbs(HybridPlotWorld hpw, LocalBlockQueue queue, Location pos1, Location pos2, boolean clear) {
|
||||||
int size = hpw.SIZE;
|
int size = hpw.SIZE;
|
||||||
LocalBlockQueue queue = hpw.getQueue(false);
|
|
||||||
for (int x = pos1.getX(); x <= pos2.getX(); x++) {
|
for (int x = pos1.getX(); x <= pos2.getX(); x++) {
|
||||||
short absX = (short) ((x - hpw.ROAD_OFFSET_X) % size);
|
short absX = (short) ((x - hpw.ROAD_OFFSET_X) % size);
|
||||||
if (absX < 0) {
|
if (absX < 0) {
|
||||||
@ -96,7 +97,6 @@ public class HybridPlotManager extends ClassicPlotManager {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
queue.enqueue();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@ -113,7 +113,9 @@ public class HybridPlotManager extends ClassicPlotManager {
|
|||||||
if (!hpw.ROAD_SCHEMATIC_ENABLED) {
|
if (!hpw.ROAD_SCHEMATIC_ENABLED) {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
createSchemAbs(hpw, pos1, pos2, true);
|
LocalBlockQueue queue = hpw.getQueue(false);
|
||||||
|
createSchemAbs(hpw, queue, pos1, pos2, true);
|
||||||
|
queue.enqueue();
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -127,11 +129,12 @@ public class HybridPlotManager extends ClassicPlotManager {
|
|||||||
Location pos2 = getPlotBottomLocAbs(hpw, id2);
|
Location pos2 = getPlotBottomLocAbs(hpw, id2);
|
||||||
pos1.setY(0);
|
pos1.setY(0);
|
||||||
pos2.setY(256);
|
pos2.setY(256);
|
||||||
createSchemAbs(hpw, pos1, pos2, true);
|
LocalBlockQueue queue = hpw.getQueue(false);
|
||||||
if (!hpw.ROAD_SCHEMATIC_ENABLED) {
|
createSchemAbs(hpw, queue, pos1, pos2, true);
|
||||||
return true;
|
if (hpw.ROAD_SCHEMATIC_ENABLED) {
|
||||||
|
createSchemAbs(hpw, queue, pos1, pos2, true);
|
||||||
}
|
}
|
||||||
createSchemAbs(hpw, pos1, pos2, true);
|
queue.enqueue();
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -189,7 +192,7 @@ public class HybridPlotManager extends ClassicPlotManager {
|
|||||||
top.setY(256);
|
top.setY(256);
|
||||||
queue.setCuboid(bot, top, air);
|
queue.setCuboid(bot, top, air);
|
||||||
// And finally set the schematic, the y value is unimportant for this function
|
// And finally set the schematic, the y value is unimportant for this function
|
||||||
pastePlotSchematic(dpw, bot, top);
|
pastePlotSchematic(dpw, queue, bot, top);
|
||||||
}
|
}
|
||||||
}, new Runnable() {
|
}, new Runnable() {
|
||||||
@Override
|
@Override
|
||||||
@ -202,10 +205,10 @@ public class HybridPlotManager extends ClassicPlotManager {
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void pastePlotSchematic(HybridPlotWorld plotWorld, Location l1, Location l2) {
|
public void pastePlotSchematic(HybridPlotWorld plotWorld, LocalBlockQueue queue, Location l1, Location l2) {
|
||||||
if (!plotWorld.PLOT_SCHEMATIC) {
|
if (!plotWorld.PLOT_SCHEMATIC) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
createSchemAbs(plotWorld, l1, l2, false);
|
createSchemAbs(plotWorld, queue, l1, l2, false);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -21,6 +21,7 @@ import com.intellectualcrafters.plot.util.TaskManager;
|
|||||||
import com.intellectualcrafters.plot.util.block.GlobalBlockQueue;
|
import com.intellectualcrafters.plot.util.block.GlobalBlockQueue;
|
||||||
import com.intellectualcrafters.plot.util.block.LocalBlockQueue;
|
import com.intellectualcrafters.plot.util.block.LocalBlockQueue;
|
||||||
import com.intellectualcrafters.plot.util.expiry.PlotAnalysis;
|
import com.intellectualcrafters.plot.util.expiry.PlotAnalysis;
|
||||||
|
|
||||||
import java.io.File;
|
import java.io.File;
|
||||||
import java.util.ArrayDeque;
|
import java.util.ArrayDeque;
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
@ -446,10 +447,10 @@ public abstract class HybridUtils {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
queue.enqueue();
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
queue.enqueue();
|
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -32,9 +32,14 @@ public class ConsolePlayer extends PlotPlayer {
|
|||||||
return instance;
|
return instance;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean canTeleport(Location loc) {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Location getLocation() {
|
public Location getLocation() {
|
||||||
return this.<Location>getMeta("location");
|
return this.getMeta("location");
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@ -110,14 +115,14 @@ public class ConsolePlayer extends PlotPlayer {
|
|||||||
@Override
|
@Override
|
||||||
public void setTime(long time) {}
|
public void setTime(long time) {}
|
||||||
|
|
||||||
@Override
|
|
||||||
public void setFlight(boolean fly) {}
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean getFlight() {
|
public boolean getFlight() {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void setFlight(boolean fly) {}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void playMusic(Location location, int id) {}
|
public void playMusic(Location location, int id) {}
|
||||||
|
|
||||||
|
@ -6,12 +6,12 @@ import com.intellectualcrafters.plot.commands.MainCommand;
|
|||||||
import javax.script.ScriptException;
|
import javax.script.ScriptException;
|
||||||
|
|
||||||
public abstract class Expression<T> {
|
public abstract class Expression<T> {
|
||||||
public abstract T evalute(T arg);
|
public abstract T evaluate(T arg);
|
||||||
|
|
||||||
public static <U> Expression<U> constant(final U value) {
|
public static <U> Expression<U> constant(final U value) {
|
||||||
return new Expression<U>() {
|
return new Expression<U>() {
|
||||||
@Override
|
@Override
|
||||||
public U evalute(U arg) {
|
public U evaluate(U arg) {
|
||||||
return value;
|
return value;
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
@ -20,8 +20,8 @@ public abstract class Expression<T> {
|
|||||||
public static Expression<Double> linearDouble(final Double value) {
|
public static Expression<Double> linearDouble(final Double value) {
|
||||||
return new Expression<Double>() {
|
return new Expression<Double>() {
|
||||||
@Override
|
@Override
|
||||||
public Double evalute(Double arg) {
|
public Double evaluate(Double arg) {
|
||||||
return (arg.doubleValue() * value.doubleValue());
|
return (arg * value);
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
@ -29,15 +29,15 @@ public abstract class Expression<T> {
|
|||||||
public static Expression<Double> doubleExpression(final String expression) {
|
public static Expression<Double> doubleExpression(final String expression) {
|
||||||
try {
|
try {
|
||||||
return constant(Double.parseDouble(expression));
|
return constant(Double.parseDouble(expression));
|
||||||
} catch (Exception ignore) {}
|
} catch (NumberFormatException ignore) {}
|
||||||
if (expression.endsWith("*{arg}")) {
|
if (expression.endsWith("*{arg}")) {
|
||||||
try {
|
try {
|
||||||
return linearDouble(Double.parseDouble(expression.substring(0, expression.length() - 6)));
|
return linearDouble(Double.parseDouble(expression.substring(0, expression.length() - 6)));
|
||||||
} catch (Exception ignore) {}
|
} catch (NumberFormatException ignore) {}
|
||||||
}
|
}
|
||||||
return new Expression<Double>() {
|
return new Expression<Double>() {
|
||||||
@Override
|
@Override
|
||||||
public Double evalute(Double arg) {
|
public Double evaluate(Double arg) {
|
||||||
DebugExec exec = (DebugExec) MainCommand.getInstance().getCommand(DebugExec.class);
|
DebugExec exec = (DebugExec) MainCommand.getInstance().getCommand(DebugExec.class);
|
||||||
try {
|
try {
|
||||||
return (Double) exec.getEngine().eval(expression.replace("{arg}", "" + arg));
|
return (Double) exec.getEngine().eval(expression.replace("{arg}", "" + arg));
|
||||||
|
@ -25,6 +25,7 @@ import com.intellectualcrafters.plot.util.block.GlobalBlockQueue;
|
|||||||
import com.intellectualcrafters.plot.util.block.LocalBlockQueue;
|
import com.intellectualcrafters.plot.util.block.LocalBlockQueue;
|
||||||
import com.intellectualcrafters.plot.util.expiry.PlotAnalysis;
|
import com.intellectualcrafters.plot.util.expiry.PlotAnalysis;
|
||||||
import com.plotsquared.listener.PlotListener;
|
import com.plotsquared.listener.PlotListener;
|
||||||
|
|
||||||
import java.awt.Rectangle;
|
import java.awt.Rectangle;
|
||||||
import java.awt.geom.Area;
|
import java.awt.geom.Area;
|
||||||
import java.awt.geom.PathIterator;
|
import java.awt.geom.PathIterator;
|
||||||
@ -738,8 +739,7 @@ public class Plot {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Clear a plot
|
* Clear a plot.
|
||||||
* @see this#clear(Runnable)
|
|
||||||
* @see this#clear(boolean, boolean, Runnable)
|
* @see this#clear(boolean, boolean, Runnable)
|
||||||
* @see #deletePlot(Runnable) to clear and delete a plot
|
* @see #deletePlot(Runnable) to clear and delete a plot
|
||||||
* @param whenDone A runnable to execute when clearing finishes, or null
|
* @param whenDone A runnable to execute when clearing finishes, or null
|
||||||
@ -1109,6 +1109,15 @@ public class Plot {
|
|||||||
return loc;
|
return loc;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public Location getSide() {
|
||||||
|
RegionWrapper largest = getLargestRegion();
|
||||||
|
int x = (largest.maxX >> 1) - (largest.minX >> 1) + largest.minX;
|
||||||
|
int z = largest.minZ - 1;
|
||||||
|
PlotManager manager = getManager();
|
||||||
|
int y = Math.max(WorldUtil.IMP.getHighestBlock(area.worldname, x, z), manager.getSignLoc(area, this).getY());
|
||||||
|
return new Location(area.worldname, x, y + 1, z);
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Return the home location for the plot
|
* Return the home location for the plot
|
||||||
* @return Home location
|
* @return Home location
|
||||||
@ -1169,12 +1178,7 @@ public class Plot {
|
|||||||
return new Location(plot.area.worldname, x, y + 1, z);
|
return new Location(plot.area.worldname, x, y + 1, z);
|
||||||
}
|
}
|
||||||
// Side
|
// Side
|
||||||
RegionWrapper largest = plot.getLargestRegion();
|
return plot.getSide();
|
||||||
int x = (largest.maxX >> 1) - (largest.minX >> 1) + largest.minX;
|
|
||||||
int z = largest.minZ - 1;
|
|
||||||
PlotManager manager = plot.getManager();
|
|
||||||
int y = Math.max(WorldUtil.IMP.getHighestBlock(plot.area.worldname, x, z), manager.getSignLoc(plot.area, plot).getY());
|
|
||||||
return new Location(plot.area.worldname, x, y + 1, z);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public double getVolume() {
|
public double getVolume() {
|
||||||
@ -1397,7 +1401,7 @@ public class Plot {
|
|||||||
* @return the name of the biome
|
* @return the name of the biome
|
||||||
*/
|
*/
|
||||||
public String getBiome() {
|
public String getBiome() {
|
||||||
Location loc = this.getBottomAbs();
|
Location loc = this.getCenter();
|
||||||
return WorldUtil.IMP.getBiome(loc.getWorld(), loc.getX(), loc.getZ());
|
return WorldUtil.IMP.getBiome(loc.getWorld(), loc.getX(), loc.getZ());
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1650,7 +1654,7 @@ public class Plot {
|
|||||||
if (uuid == DBFunc.everyone) {
|
if (uuid == DBFunc.everyone) {
|
||||||
boolean result = false;
|
boolean result = false;
|
||||||
for (UUID other : new HashSet<>(getDenied())) {
|
for (UUID other : new HashSet<>(getDenied())) {
|
||||||
result = result || rmvDenied(other);
|
result = rmvDenied(other) || result;
|
||||||
}
|
}
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
@ -1677,7 +1681,7 @@ public class Plot {
|
|||||||
if (uuid == DBFunc.everyone) {
|
if (uuid == DBFunc.everyone) {
|
||||||
boolean result = false;
|
boolean result = false;
|
||||||
for (UUID other : new HashSet<>(getTrusted())) {
|
for (UUID other : new HashSet<>(getTrusted())) {
|
||||||
result = result || rmvTrusted(other);
|
result = rmvTrusted(other) || result;
|
||||||
}
|
}
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
@ -1707,7 +1711,7 @@ public class Plot {
|
|||||||
if (uuid == DBFunc.everyone) {
|
if (uuid == DBFunc.everyone) {
|
||||||
boolean result = false;
|
boolean result = false;
|
||||||
for (UUID other : new HashSet<>(this.members)) {
|
for (UUID other : new HashSet<>(this.members)) {
|
||||||
result = result || rmvMember(other);
|
result = rmvMember(other) || result;
|
||||||
}
|
}
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
@ -2681,7 +2685,7 @@ public class Plot {
|
|||||||
greaterPlot.setMerged(3, true);
|
greaterPlot.setMerged(3, true);
|
||||||
lesserPlot.mergeData(greaterPlot);
|
lesserPlot.mergeData(greaterPlot);
|
||||||
if (removeRoads) {
|
if (removeRoads) {
|
||||||
Plot diagonal = greaterPlot.getRelative(1);
|
Plot diagonal = greaterPlot.getRelative(2);
|
||||||
if (diagonal.getMerged(7)) {
|
if (diagonal.getMerged(7)) {
|
||||||
lesserPlot.removeRoadSouthEast();
|
lesserPlot.removeRoadSouthEast();
|
||||||
}
|
}
|
||||||
|
@ -18,6 +18,7 @@ import com.intellectualcrafters.plot.util.StringMan;
|
|||||||
import com.intellectualcrafters.plot.util.area.QuadMap;
|
import com.intellectualcrafters.plot.util.area.QuadMap;
|
||||||
import com.intellectualcrafters.plot.util.block.GlobalBlockQueue;
|
import com.intellectualcrafters.plot.util.block.GlobalBlockQueue;
|
||||||
import com.intellectualcrafters.plot.util.block.LocalBlockQueue;
|
import com.intellectualcrafters.plot.util.block.LocalBlockQueue;
|
||||||
|
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.Collection;
|
import java.util.Collection;
|
||||||
import java.util.HashMap;
|
import java.util.HashMap;
|
||||||
@ -91,10 +92,6 @@ public abstract class PlotArea {
|
|||||||
this.worldhash = worldName.hashCode();
|
this.worldhash = worldName.hashCode();
|
||||||
}
|
}
|
||||||
|
|
||||||
public LocalBlockQueue getQueue(boolean autoQueue) {
|
|
||||||
return GlobalBlockQueue.IMP.getNewQueue(worldname, autoQueue);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Create a new PlotArea object with no functionality/information.
|
* Create a new PlotArea object with no functionality/information.
|
||||||
* - Mainly used during startup before worlds are created as a temporary object
|
* - Mainly used during startup before worlds are created as a temporary object
|
||||||
@ -106,10 +103,16 @@ public abstract class PlotArea {
|
|||||||
@Override
|
@Override
|
||||||
public void loadConfiguration(ConfigurationSection config) {}
|
public void loadConfiguration(ConfigurationSection config) {}
|
||||||
@Override
|
@Override
|
||||||
public ConfigurationNode[] getSettingNodes() {return null;}
|
public ConfigurationNode[] getSettingNodes() {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public LocalBlockQueue getQueue(boolean autoQueue) {
|
||||||
|
return GlobalBlockQueue.IMP.getNewQueue(worldname, autoQueue);
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Returns the region for this PlotArea or a RegionWrapper encompassing
|
* Returns the region for this PlotArea or a RegionWrapper encompassing
|
||||||
* the whole world if none exists.
|
* the whole world if none exists.
|
||||||
@ -142,7 +145,7 @@ public abstract class PlotArea {
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* Returns the minimum value of a {@link PlotId}.
|
* Returns the minimum value of a {@link PlotId}.
|
||||||
* @return
|
* @return the minimum value for a {@link PlotId}
|
||||||
*/
|
*/
|
||||||
public PlotId getMin() {
|
public PlotId getMin() {
|
||||||
return this.min == null ? new PlotId(Integer.MIN_VALUE, Integer.MIN_VALUE) : this.min;
|
return this.min == null ? new PlotId(Integer.MIN_VALUE, Integer.MIN_VALUE) : this.min;
|
||||||
@ -150,7 +153,7 @@ public abstract class PlotArea {
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* Returns the max PlotId.
|
* Returns the max PlotId.
|
||||||
* @return
|
* @return the maximum value for a {@link PlotId}
|
||||||
*/
|
*/
|
||||||
public PlotId getMax() {
|
public PlotId getMax() {
|
||||||
return this.max == null ? new PlotId(Integer.MAX_VALUE, Integer.MAX_VALUE) : this.max;
|
return this.max == null ? new PlotId(Integer.MAX_VALUE, Integer.MAX_VALUE) : this.max;
|
||||||
@ -159,7 +162,7 @@ public abstract class PlotArea {
|
|||||||
/**
|
/**
|
||||||
* Get the implementation independent generator for this area.
|
* Get the implementation independent generator for this area.
|
||||||
*
|
*
|
||||||
* @return
|
* @return the {@link IndependentPlotGenerator}
|
||||||
*/
|
*/
|
||||||
public IndependentPlotGenerator getGenerator() {
|
public IndependentPlotGenerator getGenerator() {
|
||||||
return this.generator;
|
return this.generator;
|
||||||
@ -183,8 +186,8 @@ public abstract class PlotArea {
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* Check if a PlotArea is compatible (move/copy etc).
|
* Check if a PlotArea is compatible (move/copy etc).
|
||||||
* @param plotArea
|
* @param plotArea the {@code PlotArea} to compare
|
||||||
* @return
|
* @return true if both areas are compatible
|
||||||
*/
|
*/
|
||||||
public boolean isCompatible(PlotArea plotArea) {
|
public boolean isCompatible(PlotArea plotArea) {
|
||||||
ConfigurationSection section = PS.get().worlds.getConfigurationSection("worlds");
|
ConfigurationSection section = PS.get().worlds.getConfigurationSection("worlds");
|
||||||
@ -303,7 +306,7 @@ public abstract class PlotArea {
|
|||||||
public abstract void loadConfiguration(ConfigurationSection config);
|
public abstract void loadConfiguration(ConfigurationSection config);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Saving core PlotArea settings
|
* Saving core PlotArea settings.
|
||||||
*
|
*
|
||||||
* @param config Configuration Section
|
* @param config Configuration Section
|
||||||
*/
|
*/
|
||||||
@ -381,9 +384,9 @@ public abstract class PlotArea {
|
|||||||
public abstract ConfigurationNode[] getSettingNodes();
|
public abstract ConfigurationNode[] getSettingNodes();
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Get the Plot at a location.
|
* Gets the {@code Plot} at a location.
|
||||||
* @param location
|
* @param location the location
|
||||||
* @return Plot
|
* @return the {@code Plot} or null if none exists
|
||||||
*/
|
*/
|
||||||
public Plot getPlotAbs(Location location) {
|
public Plot getPlotAbs(Location location) {
|
||||||
PlotId pid = this.manager.getPlotId(this, location.getX(), location.getY(), location.getZ());
|
PlotId pid = this.manager.getPlotId(this, location.getX(), location.getY(), location.getZ());
|
||||||
@ -394,8 +397,8 @@ public abstract class PlotArea {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Get the base plot at a location.
|
* Gets the base plot at a location.
|
||||||
* @param location
|
* @param location the location
|
||||||
* @return base Plot
|
* @return base Plot
|
||||||
*/
|
*/
|
||||||
public Plot getPlot(Location location) {
|
public Plot getPlot(Location location) {
|
||||||
@ -407,9 +410,9 @@ public abstract class PlotArea {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Get the base owned plot at a location.
|
* Get the owned base plot at a location.
|
||||||
* @param location
|
* @param location the location
|
||||||
* @return base Plot or null
|
* @return the base plot or null
|
||||||
*/
|
*/
|
||||||
public Plot getOwnedPlot(Location location) {
|
public Plot getOwnedPlot(Location location) {
|
||||||
PlotId pid = this.manager.getPlotId(this, location.getX(), location.getY(), location.getZ());
|
PlotId pid = this.manager.getPlotId(this, location.getX(), location.getY(), location.getZ());
|
||||||
@ -422,7 +425,7 @@ public abstract class PlotArea {
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* Get the owned plot at a location.
|
* Get the owned plot at a location.
|
||||||
* @param location
|
* @param location the location
|
||||||
* @return Plot or null
|
* @return Plot or null
|
||||||
*/
|
*/
|
||||||
public Plot getOwnedPlotAbs(Location location) {
|
public Plot getOwnedPlotAbs(Location location) {
|
||||||
@ -435,8 +438,8 @@ public abstract class PlotArea {
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* Get the owned Plot at a PlotId.
|
* Get the owned Plot at a PlotId.
|
||||||
* @param id
|
* @param id the {@code PlotId}
|
||||||
* @return Plot or null
|
* @return the plot or null
|
||||||
*/
|
*/
|
||||||
public Plot getOwnedPlotAbs(PlotId id) {
|
public Plot getOwnedPlotAbs(PlotId id) {
|
||||||
return this.plots.get(id);
|
return this.plots.get(id);
|
||||||
@ -473,8 +476,8 @@ public abstract class PlotArea {
|
|||||||
return myPlots;
|
return myPlots;
|
||||||
}
|
}
|
||||||
|
|
||||||
public Set<Plot> getPlots(final UUID uuid) {
|
public Set<Plot> getPlots(UUID uuid) {
|
||||||
final HashSet<Plot> myplots = new HashSet<>();
|
HashSet<Plot> myplots = new HashSet<>();
|
||||||
for (Plot plot : getPlots()) {
|
for (Plot plot : getPlots()) {
|
||||||
if (plot.isBasePlot()) {
|
if (plot.isBasePlot()) {
|
||||||
if (plot.isOwner(uuid)) {
|
if (plot.isOwner(uuid)) {
|
||||||
@ -489,6 +492,14 @@ public abstract class PlotArea {
|
|||||||
return getPlots(player.getUUID());
|
return getPlots(player.getUUID());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* A collection of the claimed plots in this {@code PlotArea}.
|
||||||
|
* @return a collection of claimed plots
|
||||||
|
*/
|
||||||
|
public Collection<Plot> getPlots() {
|
||||||
|
return this.plots.values();
|
||||||
|
}
|
||||||
|
|
||||||
public Set<Plot> getPlotsAbs(PlotPlayer player) {
|
public Set<Plot> getPlotsAbs(PlotPlayer player) {
|
||||||
return player != null ? getPlotsAbs(player.getUUID()) : new HashSet<Plot>();
|
return player != null ? getPlotsAbs(player.getUUID()) : new HashSet<Plot>();
|
||||||
}
|
}
|
||||||
@ -570,7 +581,7 @@ public abstract class PlotArea {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Session only plot metadata (session is until the server stops)<br>
|
* Session only plot metadata (session is until the server stops).
|
||||||
* <br>
|
* <br>
|
||||||
* For persistent metadata use the flag system
|
* For persistent metadata use the flag system
|
||||||
* @see FlagManager
|
* @see FlagManager
|
||||||
@ -598,14 +609,6 @@ public abstract class PlotArea {
|
|||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* A collection of the claimed plots in this {@code PlotArea}.
|
|
||||||
* @return
|
|
||||||
*/
|
|
||||||
public Collection<Plot> getPlots() {
|
|
||||||
return this.plots.values();
|
|
||||||
}
|
|
||||||
|
|
||||||
public Set<Plot> getBasePlots() {
|
public Set<Plot> getBasePlots() {
|
||||||
HashSet<Plot> myPlots = new HashSet<>(getPlots());
|
HashSet<Plot> myPlots = new HashSet<>(getPlots());
|
||||||
Iterator<Plot> iterator = myPlots.iterator();
|
Iterator<Plot> iterator = myPlots.iterator();
|
||||||
@ -662,10 +665,10 @@ public abstract class PlotArea {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Check if the plots in a selection are unowned
|
* Check if the plots in a selection are unowned.
|
||||||
* @param pos1
|
* @param pos1 first corner of selection
|
||||||
* @param pos2
|
* @param pos2 second corner of selection
|
||||||
* @return
|
* @return are plots in selection unowned
|
||||||
*/
|
*/
|
||||||
public boolean isUnowned(PlotId pos1, PlotId pos2) {
|
public boolean isUnowned(PlotId pos1, PlotId pos2) {
|
||||||
int area = (pos2.x - pos1.x + 1) * (pos2.y - pos1.y + 1);
|
int area = (pos2.x - pos1.x + 1) * (pos2.y - pos1.y + 1);
|
||||||
@ -706,7 +709,7 @@ public abstract class PlotArea {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Setup the plot border for a world (usually done when the world is created)
|
* Setup the plot border for a world (usually done when the world is created).
|
||||||
*/
|
*/
|
||||||
public void setupBorder() {
|
public void setupBorder() {
|
||||||
if (!this.WORLD_BORDER) {
|
if (!this.WORLD_BORDER) {
|
||||||
@ -722,7 +725,7 @@ public abstract class PlotArea {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Delete the metadata for a key<br>
|
* Delete the metadata for a key.
|
||||||
* - metadata is session only
|
* - metadata is session only
|
||||||
* - deleting other plugin's metadata may cause issues
|
* - deleting other plugin's metadata may cause issues
|
||||||
* @param key
|
* @param key
|
||||||
@ -819,11 +822,11 @@ public abstract class PlotArea {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Get a set of owned plots within a selection (chooses the best algorithm based on selection size.<br>
|
* Get a set of owned plots within a selection (chooses the best algorithm based on selection size.
|
||||||
* i.e. A selection of billions of plots will work fine
|
* i.e. A selection of billions of plots will work fine
|
||||||
* @param pos1
|
* @param pos1 first corner of selection
|
||||||
* @param pos2
|
* @param pos2 second corner of selection
|
||||||
* @return
|
* @return the plots in the selection which are owned
|
||||||
*/
|
*/
|
||||||
public HashSet<Plot> getPlotSelectionOwned(PlotId pos1, PlotId pos2) {
|
public HashSet<Plot> getPlotSelectionOwned(PlotId pos1, PlotId pos2) {
|
||||||
int size = (1 + pos2.x - pos1.x) * (1 + pos2.y - pos1.y);
|
int size = (1 + pos2.x - pos1.x) * (1 + pos2.y - pos1.y);
|
||||||
|
@ -1,6 +1,8 @@
|
|||||||
package com.intellectualcrafters.plot.object;
|
package com.intellectualcrafters.plot.object;
|
||||||
|
|
||||||
|
import com.intellectualcrafters.plot.PS;
|
||||||
import com.intellectualcrafters.plot.config.C;
|
import com.intellectualcrafters.plot.config.C;
|
||||||
|
import com.intellectualcrafters.plot.object.chat.PlainChatManager;
|
||||||
import com.intellectualcrafters.plot.util.ChatManager;
|
import com.intellectualcrafters.plot.util.ChatManager;
|
||||||
|
|
||||||
public class PlotMessage {
|
public class PlotMessage {
|
||||||
@ -8,7 +10,13 @@ public class PlotMessage {
|
|||||||
private Object builder;
|
private Object builder;
|
||||||
|
|
||||||
public PlotMessage() {
|
public PlotMessage() {
|
||||||
|
try {
|
||||||
reset(ChatManager.manager);
|
reset(ChatManager.manager);
|
||||||
|
} catch (Throwable e) {
|
||||||
|
PS.debug("PlotSquared doesn't support fancy chat for " + PS.get().IMP.getServerVersion());
|
||||||
|
ChatManager.manager = new PlainChatManager();
|
||||||
|
reset(ChatManager.manager);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public PlotMessage(String text) {
|
public PlotMessage(String text) {
|
||||||
|
@ -55,7 +55,7 @@ public abstract class PlotPlayer implements CommandCaller, OfflinePlotPlayer {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Set some session only metadata for the player.
|
* Set some session only metadata for this player.
|
||||||
* @param key
|
* @param key
|
||||||
* @param value
|
* @param value
|
||||||
*/
|
*/
|
||||||
@ -102,7 +102,7 @@ public abstract class PlotPlayer implements CommandCaller, OfflinePlotPlayer {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The player's name.
|
* This player's name.
|
||||||
*
|
*
|
||||||
* @return the name of the player
|
* @return the name of the player
|
||||||
*/
|
*/
|
||||||
@ -112,11 +112,11 @@ public abstract class PlotPlayer implements CommandCaller, OfflinePlotPlayer {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Get the player's current plot.
|
* Get this player's current plot.
|
||||||
* @return the plot the player is standing on or null if standing on a road or not in a {@link PlotArea}
|
* @return the plot the player is standing on or null if standing on a road or not in a {@link PlotArea}
|
||||||
*/
|
*/
|
||||||
public Plot getCurrentPlot() {
|
public Plot getCurrentPlot() {
|
||||||
Plot value = (Plot) getMeta("lastplot");
|
Plot value = getMeta("lastplot");
|
||||||
if (value == null && !Settings.Enabled_Components.EVENTS) {
|
if (value == null && !Settings.Enabled_Components.EVENTS) {
|
||||||
return getLocation().getPlot();
|
return getLocation().getPlot();
|
||||||
}
|
}
|
||||||
@ -133,7 +133,7 @@ public abstract class PlotPlayer implements CommandCaller, OfflinePlotPlayer {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Get the number of plots the player owns.
|
* Get the number of plots this player owns.
|
||||||
*
|
*
|
||||||
* @see #getPlotCount(String);
|
* @see #getPlotCount(String);
|
||||||
* @see #getPlots()
|
* @see #getPlots()
|
||||||
@ -164,7 +164,7 @@ public abstract class PlotPlayer implements CommandCaller, OfflinePlotPlayer {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Get the number of plots the player owns in the world.
|
* Get the number of plots this player owns in the world.
|
||||||
* @param world the name of the plotworld to check.
|
* @param world the name of the plotworld to check.
|
||||||
* @return
|
* @return
|
||||||
*/
|
*/
|
||||||
@ -196,7 +196,7 @@ public abstract class PlotPlayer implements CommandCaller, OfflinePlotPlayer {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Return the PlotArea the player is currently in, or null.
|
* Return the PlotArea this player is currently in, or null.
|
||||||
* @return
|
* @return
|
||||||
*/
|
*/
|
||||||
public PlotArea getPlotAreaAbs() {
|
public PlotArea getPlotAreaAbs() {
|
||||||
@ -216,7 +216,7 @@ public abstract class PlotPlayer implements CommandCaller, OfflinePlotPlayer {
|
|||||||
|
|
||||||
////////////// PARTIALLY IMPLEMENTED ///////////
|
////////////// PARTIALLY IMPLEMENTED ///////////
|
||||||
/**
|
/**
|
||||||
* Get the player's last recorded location or null if they don't any plot relevant location.
|
* Get this player's last recorded location or null if they don't any plot relevant location.
|
||||||
* @return The location
|
* @return The location
|
||||||
*/
|
*/
|
||||||
public Location getLocation() {
|
public Location getLocation() {
|
||||||
@ -235,29 +235,40 @@ public abstract class PlotPlayer implements CommandCaller, OfflinePlotPlayer {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Get the player's full location (including yaw/pitch)
|
* Get this player's full location (including yaw/pitch)
|
||||||
* @return
|
* @return
|
||||||
*/
|
*/
|
||||||
public abstract Location getLocationFull();
|
public abstract Location getLocationFull();
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Get the player's UUID.
|
* Get this player's UUID.
|
||||||
* === !IMPORTANT ===<br>
|
* === !IMPORTANT ===<br>
|
||||||
* The UUID is dependent on the mode chosen in the settings.yml and may not be the same as Bukkit has
|
* The UUID is dependent on the mode chosen in the settings.yml and may not be the same as Bukkit has
|
||||||
* (especially if using an old version of Bukkit that does not support UUIDs)
|
* (especially if using an old version of Bukkit that does not support UUIDs)
|
||||||
*
|
*
|
||||||
* @return UUID
|
* @return UUID
|
||||||
*/
|
*/
|
||||||
public abstract UUID getUUID();
|
@Override public abstract UUID getUUID();
|
||||||
|
|
||||||
|
public boolean canTeleport(Location loc) {
|
||||||
|
Location current = getLocationFull();
|
||||||
|
teleport(loc);
|
||||||
|
boolean result = true;
|
||||||
|
if (!getLocation().equals(loc)) {
|
||||||
|
result = false;
|
||||||
|
}
|
||||||
|
teleport(current);
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Teleport the player to a location.
|
* Teleport this player to a location.
|
||||||
* @param location the target location
|
* @param location the target location
|
||||||
*/
|
*/
|
||||||
public abstract void teleport(Location location);
|
public abstract void teleport(Location location);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Set the compass target.
|
* Set this compass target.
|
||||||
* @param location the target location
|
* @param location the target location
|
||||||
*/
|
*/
|
||||||
public abstract void setCompassTarget(Location location);
|
public abstract void setCompassTarget(Location location);
|
||||||
@ -274,7 +285,7 @@ public abstract class PlotPlayer implements CommandCaller, OfflinePlotPlayer {
|
|||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Retrieves the player attribute.
|
* Retrieves the attribute of this player.
|
||||||
*
|
*
|
||||||
* @param key
|
* @param key
|
||||||
* @return the attribute will be either true or false
|
* @return the attribute will be either true or false
|
||||||
@ -295,58 +306,58 @@ public abstract class PlotPlayer implements CommandCaller, OfflinePlotPlayer {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Set the player's local weather.
|
* Sets the local weather for this Player.
|
||||||
* @param weather the weather visible to the player
|
* @param weather the weather visible to the player
|
||||||
*/
|
*/
|
||||||
public abstract void setWeather(PlotWeather weather);
|
public abstract void setWeather(PlotWeather weather);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Get the player's gamemode.
|
* Get this player's gamemode.
|
||||||
* @return the gamemode of the player.
|
* @return the gamemode of the player.
|
||||||
*/
|
*/
|
||||||
public abstract PlotGameMode getGameMode();
|
public abstract PlotGameMode getGameMode();
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Set the player's gameMode.
|
* Set this player's gameMode.
|
||||||
* @param gameMode the gamemode to set
|
* @param gameMode the gamemode to set
|
||||||
*/
|
*/
|
||||||
public abstract void setGameMode(PlotGameMode gameMode);
|
public abstract void setGameMode(PlotGameMode gameMode);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Set the player's local time (ticks).
|
* Set this player's local time (ticks).
|
||||||
* @param time the time visible to the player
|
* @param time the time visible to the player
|
||||||
*/
|
*/
|
||||||
public abstract void setTime(long time);
|
public abstract void setTime(long time);
|
||||||
|
|
||||||
|
public abstract boolean getFlight();
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Set the player's fly mode.
|
* Set this player's fly mode.
|
||||||
* @param fly if the player can fly
|
* @param fly if the player can fly
|
||||||
*/
|
*/
|
||||||
public abstract void setFlight(boolean fly);
|
public abstract void setFlight(boolean fly);
|
||||||
|
|
||||||
public abstract boolean getFlight();
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Play music at a location for the player.
|
* Play music at a location for this player.
|
||||||
* @param location where to play the music
|
* @param location where to play the music
|
||||||
* @param id the numerical record item id
|
* @param id the numerical record item id
|
||||||
*/
|
*/
|
||||||
public abstract void playMusic(Location location, int id);
|
public abstract void playMusic(Location location, int id);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Check if the player is banned.
|
* Check if this player is banned.
|
||||||
* @return true if the player is banned, false otherwise.
|
* @return true if the player is banned, false otherwise.
|
||||||
*/
|
*/
|
||||||
public abstract boolean isBanned();
|
public abstract boolean isBanned();
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Kick the player from the game.
|
* Kick this player from the game.
|
||||||
* @param message the reason for the kick
|
* @param message the reason for the kick
|
||||||
*/
|
*/
|
||||||
public abstract void kick(String message);
|
public abstract void kick(String message);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Called when the player quits.
|
* Called when this player quits.
|
||||||
*/
|
*/
|
||||||
public void unregister() {
|
public void unregister() {
|
||||||
Plot plot = getCurrentPlot();
|
Plot plot = getCurrentPlot();
|
||||||
@ -368,7 +379,7 @@ public abstract class PlotPlayer implements CommandCaller, OfflinePlotPlayer {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Get the amount of clusters a player owns in the specific world.
|
* Get the amount of clusters this player owns in the specific world.
|
||||||
* @param world
|
* @param world
|
||||||
* @return
|
* @return
|
||||||
*/
|
*/
|
||||||
@ -384,7 +395,7 @@ public abstract class PlotPlayer implements CommandCaller, OfflinePlotPlayer {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Get the amount of clusters a player owns.
|
* Get the amount of clusters this player owns.
|
||||||
* @return the number of clusters this player owns
|
* @return the number of clusters this player owns
|
||||||
*/
|
*/
|
||||||
public int getPlayerClusterCount() {
|
public int getPlayerClusterCount() {
|
||||||
@ -399,9 +410,9 @@ public abstract class PlotPlayer implements CommandCaller, OfflinePlotPlayer {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Return a {@code Set} of all plots a player owns in a certain world.
|
* Return a {@code Set} of all plots this player owns in a certain world.
|
||||||
* @param world the world to retrieve plots from
|
* @param world the world to retrieve plots from
|
||||||
* @return a {@code Set} of plots the player owns in the provided world
|
* @return a {@code Set} of plots this player owns in the provided world
|
||||||
*/
|
*/
|
||||||
public Set<Plot> getPlots(String world) {
|
public Set<Plot> getPlots(String world) {
|
||||||
UUID uuid = getUUID();
|
UUID uuid = getUUID();
|
||||||
@ -453,7 +464,7 @@ public abstract class PlotPlayer implements CommandCaller, OfflinePlotPlayer {
|
|||||||
public abstract void stopSpectating();
|
public abstract void stopSpectating();
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The amount of money this player has
|
* The amount of money this Player has.
|
||||||
* @return
|
* @return
|
||||||
*/
|
*/
|
||||||
public double getMoney() {
|
public double getMoney() {
|
||||||
|
@ -1,14 +1,14 @@
|
|||||||
package com.plotsquared.bukkit.util;
|
package com.intellectualcrafters.plot.object.chat;
|
||||||
|
|
||||||
|
import com.intellectualcrafters.plot.config.C;
|
||||||
import com.intellectualcrafters.plot.object.PlotMessage;
|
import com.intellectualcrafters.plot.object.PlotMessage;
|
||||||
import com.intellectualcrafters.plot.object.PlotPlayer;
|
import com.intellectualcrafters.plot.object.PlotPlayer;
|
||||||
import com.intellectualcrafters.plot.util.ChatManager;
|
import com.intellectualcrafters.plot.util.ChatManager;
|
||||||
import org.bukkit.ChatColor;
|
|
||||||
|
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
public class BukkitPlainChatManager extends ChatManager<List<StringBuilder>> {
|
public class PlainChatManager extends ChatManager<List<StringBuilder>> {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public List<StringBuilder> builder() {
|
public List<StringBuilder> builder() {
|
||||||
@ -29,7 +29,7 @@ public class BukkitPlainChatManager extends ChatManager<List<StringBuilder>> {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void text(PlotMessage message, String text) {
|
public void text(PlotMessage message, String text) {
|
||||||
message.$(this).add(new StringBuilder(ChatColor.stripColor(text)));
|
message.$(this).add(new StringBuilder(C.color(text)));
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
@ -68,6 +68,7 @@ public abstract class EventUtil {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (PS.get().update != null && Permissions.hasPermission(player, C.PERMISSION_ADMIN_UPDATE) && Settings.Enabled_Components.UPDATER) {
|
if (PS.get().update != null && Permissions.hasPermission(player, C.PERMISSION_ADMIN_UPDATE) && Settings.Enabled_Components.UPDATER) {
|
||||||
|
MainUtil.sendMessage(player,C.CONSOLE_JAVA_OUTDATED_1_8.s());
|
||||||
MainUtil.sendMessage(player, "&6An update for PlotSquared is available: &7/plot update");
|
MainUtil.sendMessage(player, "&6An update for PlotSquared is available: &7/plot update");
|
||||||
}
|
}
|
||||||
final Plot plot = player.getCurrentPlot();
|
final Plot plot = player.getCurrentPlot();
|
||||||
@ -238,7 +239,7 @@ public abstract class EventUtil {
|
|||||||
value = null;
|
value = null;
|
||||||
}
|
}
|
||||||
if (value == null || !value.contains(PlotBlock.EVERYTHING) && !value.contains(block.getPlotBlock())) {
|
if (value == null || !value.contains(PlotBlock.EVERYTHING) && !value.contains(block.getPlotBlock())) {
|
||||||
if (Permissions.hasPermission(player, C.PERMISSION_ADMIN_BUILD_OTHER.s(), false)) {
|
if (Permissions.hasPermission(player, C.PERMISSION_ADMIN_INTERACT_OTHER.s(), false)) {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
return false;
|
return false;
|
||||||
|
@ -16,6 +16,8 @@ import com.intellectualcrafters.plot.object.PlotId;
|
|||||||
import com.intellectualcrafters.plot.object.PlotPlayer;
|
import com.intellectualcrafters.plot.object.PlotPlayer;
|
||||||
import com.intellectualcrafters.plot.object.RegionWrapper;
|
import com.intellectualcrafters.plot.object.RegionWrapper;
|
||||||
import com.intellectualcrafters.plot.object.RunnableVal;
|
import com.intellectualcrafters.plot.object.RunnableVal;
|
||||||
|
import com.intellectualcrafters.plot.util.expiry.ExpireManager;
|
||||||
|
|
||||||
import java.io.File;
|
import java.io.File;
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
import java.io.OutputStream;
|
import java.io.OutputStream;
|
||||||
@ -37,7 +39,6 @@ import java.util.Map;
|
|||||||
import java.util.Map.Entry;
|
import java.util.Map.Entry;
|
||||||
import java.util.Set;
|
import java.util.Set;
|
||||||
import java.util.UUID;
|
import java.util.UUID;
|
||||||
import java.util.concurrent.TimeUnit;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* plot functions
|
* plot functions
|
||||||
@ -206,6 +207,39 @@ public class MainUtil {
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static String secToTime(long time) {
|
||||||
|
StringBuilder toreturn = new StringBuilder();
|
||||||
|
if (time >= 33868800) {
|
||||||
|
int years = (int) (time / 33868800);
|
||||||
|
time -= years * 33868800;
|
||||||
|
toreturn.append(years+"y ");
|
||||||
|
}
|
||||||
|
if (time >= 604800) {
|
||||||
|
int weeks = (int) (time / 604800);
|
||||||
|
time -= weeks * 604800;
|
||||||
|
toreturn.append(weeks+"w ");
|
||||||
|
}
|
||||||
|
if (time >= 86400) {
|
||||||
|
int days = (int) (time / 86400);
|
||||||
|
time -= days * 86400;
|
||||||
|
toreturn.append(days+"d ");
|
||||||
|
}
|
||||||
|
if (time >= 3600) {
|
||||||
|
int hours = (int) (time / 3600);
|
||||||
|
time -= hours * 3600;
|
||||||
|
toreturn.append(hours+"h ");
|
||||||
|
}
|
||||||
|
if (time>=60) {
|
||||||
|
int minutes = (int) (time / 60);
|
||||||
|
time -= minutes * 60;
|
||||||
|
toreturn.append(minutes+"m ");
|
||||||
|
}
|
||||||
|
if (toreturn.equals("")||time>0){
|
||||||
|
toreturn.append((time)+"s ");
|
||||||
|
}
|
||||||
|
return toreturn.toString().trim();
|
||||||
|
}
|
||||||
|
|
||||||
public static long timeToSec(String string) {
|
public static long timeToSec(String string) {
|
||||||
if (MathMan.isInteger(string)) {
|
if (MathMan.isInteger(string)) {
|
||||||
return Long.parseLong(string);
|
return Long.parseLong(string);
|
||||||
@ -686,31 +720,20 @@ public class MainUtil {
|
|||||||
String trusted = getPlayerList(plot.getTrusted());
|
String trusted = getPlayerList(plot.getTrusted());
|
||||||
String members = getPlayerList(plot.getMembers());
|
String members = getPlayerList(plot.getMembers());
|
||||||
String denied = getPlayerList(plot.getDenied());
|
String denied = getPlayerList(plot.getDenied());
|
||||||
String expires = C.UNKNOWN.s();
|
String seen;
|
||||||
if (Settings.Enabled_Components.PLOT_EXPIRY) {
|
if (Settings.Enabled_Components.PLOT_EXPIRY) {
|
||||||
if (plot.hasOwner()) {
|
if (plot.isOnline()) {
|
||||||
Optional<?> keep = plot.getFlag(Flags.KEEP);
|
seen = C.NOW.s();
|
||||||
if (keep.isPresent()) {
|
} else {
|
||||||
Object value = keep.get();
|
int time = (int) (ExpireManager.IMP.getAge(plot) / 1000);
|
||||||
if (value instanceof Boolean) {
|
if (time != 0) {
|
||||||
if (Boolean.TRUE.equals(value)) {
|
seen = MainUtil.secToTime(time);
|
||||||
expires = C.NONE.s();
|
} else {
|
||||||
}
|
seen = C.UNKNOWN.s();
|
||||||
} else if (value instanceof Long) {
|
|
||||||
if ((Long) value > System.currentTimeMillis()) {
|
|
||||||
long l = System.currentTimeMillis() - (long) value;
|
|
||||||
expires = String.format("%d days", TimeUnit.MILLISECONDS.toDays(l));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
// } else if (ExpireManager.IMP != null) {
|
|
||||||
// long timestamp = ExpireManager.IMP.getTimestamp(plot.owner);
|
|
||||||
// long compared = System.currentTimeMillis() - timestamp;
|
|
||||||
// long l = Settings.AUTO_CLEAR_DAYS - TimeUnit.MILLISECONDS.toDays(compared);
|
|
||||||
// expires = String.format("%d days", l);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
expires = C.NEVER.s();
|
seen = C.NEVER.s();
|
||||||
}
|
}
|
||||||
Optional<String> descriptionFlag = plot.getFlag(Flags.DESCRIPTION);
|
Optional<String> descriptionFlag = plot.getFlag(Flags.DESCRIPTION);
|
||||||
String description = !descriptionFlag.isPresent() ? C.NONE.s() : Flags.DESCRIPTION.valueToString(descriptionFlag.get());
|
String description = !descriptionFlag.isPresent() ? C.NONE.s() : Flags.DESCRIPTION.valueToString(descriptionFlag.get());
|
||||||
@ -727,9 +750,7 @@ public class MainUtil {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
boolean build = plot.isAdded(player.getUUID());
|
boolean build = plot.isAdded(player.getUUID());
|
||||||
|
|
||||||
String owner = plot.getOwners().isEmpty() ? "unowned" : getPlayerList(plot.getOwners());
|
String owner = plot.getOwners().isEmpty() ? "unowned" : getPlayerList(plot.getOwners());
|
||||||
|
|
||||||
info = info.replace("%id%", plot.getId().toString());
|
info = info.replace("%id%", plot.getId().toString());
|
||||||
info = info.replace("%alias%", alias);
|
info = info.replace("%alias%", alias);
|
||||||
info = info.replace("%num%", String.valueOf(num));
|
info = info.replace("%num%", String.valueOf(num));
|
||||||
@ -741,7 +762,7 @@ public class MainUtil {
|
|||||||
info = info.replace("%trusted%", trusted);
|
info = info.replace("%trusted%", trusted);
|
||||||
info = info.replace("%helpers%", members);
|
info = info.replace("%helpers%", members);
|
||||||
info = info.replace("%denied%", denied);
|
info = info.replace("%denied%", denied);
|
||||||
info = info.replace("%expires%", expires);
|
info = info.replace("%seen%", seen);
|
||||||
info = info.replace("%flags%", flags);
|
info = info.replace("%flags%", flags);
|
||||||
info = info.replace("%build%", String.valueOf(build));
|
info = info.replace("%build%", String.valueOf(build));
|
||||||
info = info.replace("%desc%", "No description set.");
|
info = info.replace("%desc%", "No description set.");
|
||||||
@ -757,10 +778,6 @@ public class MainUtil {
|
|||||||
String info;
|
String info;
|
||||||
if (full && Settings.Ratings.CATEGORIES != null && Settings.Ratings.CATEGORIES.size() > 1) {
|
if (full && Settings.Ratings.CATEGORIES != null && Settings.Ratings.CATEGORIES.size() > 1) {
|
||||||
double[] ratings = MainUtil.getAverageRatings(plot);
|
double[] ratings = MainUtil.getAverageRatings(plot);
|
||||||
for (double v : ratings) {
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
String rating = "";
|
String rating = "";
|
||||||
String prefix = "";
|
String prefix = "";
|
||||||
for (int i = 0; i < ratings.length; i++) {
|
for (int i = 0; i < ratings.length; i++) {
|
||||||
|
@ -9,19 +9,7 @@ public class MathMan {
|
|||||||
private static final int ATAN2_DIM = (int) Math.sqrt(ATAN2_COUNT);
|
private static final int ATAN2_DIM = (int) Math.sqrt(ATAN2_COUNT);
|
||||||
private static final float INV_ATAN2_DIM_MINUS_1 = 1.0f / (ATAN2_DIM - 1);
|
private static final float INV_ATAN2_DIM_MINUS_1 = 1.0f / (ATAN2_DIM - 1);
|
||||||
private static final float[] atan2 = new float[ATAN2_COUNT];
|
private static final float[] atan2 = new float[ATAN2_COUNT];
|
||||||
|
private static final int[] table = {
|
||||||
static {
|
|
||||||
for (int i = 0; i < ATAN2_DIM; i++) {
|
|
||||||
for (int j = 0; j < ATAN2_DIM; j++) {
|
|
||||||
float x0 = (float) i / ATAN2_DIM;
|
|
||||||
float y0 = (float) j / ATAN2_DIM;
|
|
||||||
|
|
||||||
atan2[(j * ATAN2_DIM) + i] = (float) Math.atan2(y0, x0);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
private final static int[] table = {
|
|
||||||
0, 16, 22, 27, 32, 35, 39, 42, 45, 48, 50, 53, 55, 57,
|
0, 16, 22, 27, 32, 35, 39, 42, 45, 48, 50, 53, 55, 57,
|
||||||
59, 61, 64, 65, 67, 69, 71, 73, 75, 76, 78, 80, 81, 83,
|
59, 61, 64, 65, 67, 69, 71, 73, 75, 76, 78, 80, 81, 83,
|
||||||
84, 86, 87, 89, 90, 91, 93, 94, 96, 97, 98, 99, 101, 102,
|
84, 86, 87, 89, 90, 91, 93, 94, 96, 97, 98, 99, 101, 102,
|
||||||
@ -43,6 +31,17 @@ public class MathMan {
|
|||||||
253, 254, 254, 255
|
253, 254, 254, 255
|
||||||
};
|
};
|
||||||
|
|
||||||
|
static {
|
||||||
|
for (int i = 0; i < ATAN2_DIM; i++) {
|
||||||
|
for (int j = 0; j < ATAN2_DIM; j++) {
|
||||||
|
float x0 = (float) i / ATAN2_DIM;
|
||||||
|
float y0 = (float) j / ATAN2_DIM;
|
||||||
|
|
||||||
|
atan2[(j * ATAN2_DIM) + i] = (float) Math.atan2(y0, x0);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
public static long pairInt(int x, int y) {
|
public static long pairInt(int x, int y) {
|
||||||
return (((long)x) << 32) | (y & 0xffffffffL);
|
return (((long)x) << 32) | (y & 0xffffffffL);
|
||||||
}
|
}
|
||||||
@ -191,7 +190,8 @@ public class MathMan {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public static final float atan2(float y, float x) {
|
public static final float atan2(float y, float x) {
|
||||||
float add, mul;
|
float add;
|
||||||
|
float mul;
|
||||||
|
|
||||||
if (x < 0.0f) {
|
if (x < 0.0f) {
|
||||||
if (y < 0.0f) {
|
if (y < 0.0f) {
|
||||||
@ -229,7 +229,7 @@ public class MathMan {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public static double sqrtApprox(double d) {
|
public static double sqrtApprox(double d) {
|
||||||
return Double.longBitsToDouble(((Double.doubleToLongBits(d) - (1l << 52)) >> 1) + (1l << 61));
|
return Double.longBitsToDouble(((Double.doubleToLongBits(d) - (1L << 52)) >> 1) + (1L << 61));
|
||||||
}
|
}
|
||||||
|
|
||||||
public static float invSqrt(float x) {
|
public static float invSqrt(float x) {
|
||||||
@ -302,7 +302,7 @@ public class MathMan {
|
|||||||
return x % y;
|
return x % y;
|
||||||
}
|
}
|
||||||
|
|
||||||
public static boolean isPowerOfTwo(int x) {
|
public static boolean isPowerOfTwo(int number) {
|
||||||
return (x & (x - 1)) == 0;
|
return (number & (number - 1)) == 0;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -265,7 +265,7 @@ public class StringMan {
|
|||||||
return sb.toString();
|
return sb.toString();
|
||||||
}
|
}
|
||||||
|
|
||||||
public Collection match(Collection col, String startsWith) {
|
public <T> Collection<T> match(Collection<T> col, String startsWith) {
|
||||||
if (col == null) {
|
if (col == null) {
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
@ -59,8 +59,10 @@ public class UUIDHandler {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public static HashSet<UUID> getAllUUIDS() {
|
public static HashSet<UUID> getAllUUIDS() {
|
||||||
HashSet<UUID> uuids = new HashSet<>();
|
final HashSet<UUID> uuids = new HashSet<>();
|
||||||
for (Plot plot : PS.get().getPlots()) {
|
PS.get().foreachPlotRaw(new RunnableVal<Plot>() {
|
||||||
|
@Override
|
||||||
|
public void run(Plot plot) {
|
||||||
if (plot.hasOwner()) {
|
if (plot.hasOwner()) {
|
||||||
uuids.add(plot.owner);
|
uuids.add(plot.owner);
|
||||||
uuids.addAll(plot.getTrusted());
|
uuids.addAll(plot.getTrusted());
|
||||||
@ -68,6 +70,7 @@ public class UUIDHandler {
|
|||||||
uuids.addAll(plot.getDenied());
|
uuids.addAll(plot.getDenied());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
});
|
||||||
return uuids;
|
return uuids;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -291,7 +291,7 @@ public class GlobalBlockQueue {
|
|||||||
if (this.runnables.isEmpty()) {
|
if (this.runnables.isEmpty()) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
final ConcurrentLinkedDeque<Runnable> tmp = new ConcurrentLinkedDeque<>(this.runnables);
|
final ArrayList<Runnable> tmp = new ArrayList<>(this.runnables);
|
||||||
this.runnables.clear();
|
this.runnables.clear();
|
||||||
for (final Runnable runnable : tmp) {
|
for (final Runnable runnable : tmp) {
|
||||||
runnable.run();
|
runnable.run();
|
||||||
|
@ -18,7 +18,6 @@ import com.intellectualcrafters.plot.object.RunnableVal3;
|
|||||||
import com.intellectualcrafters.plot.util.MainUtil;
|
import com.intellectualcrafters.plot.util.MainUtil;
|
||||||
import com.intellectualcrafters.plot.util.TaskManager;
|
import com.intellectualcrafters.plot.util.TaskManager;
|
||||||
import com.intellectualcrafters.plot.util.UUIDHandler;
|
import com.intellectualcrafters.plot.util.UUIDHandler;
|
||||||
|
|
||||||
import java.util.ArrayDeque;
|
import java.util.ArrayDeque;
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.Collection;
|
import java.util.Collection;
|
||||||
@ -26,9 +25,9 @@ import java.util.Collections;
|
|||||||
import java.util.HashSet;
|
import java.util.HashSet;
|
||||||
import java.util.Iterator;
|
import java.util.Iterator;
|
||||||
import java.util.Objects;
|
import java.util.Objects;
|
||||||
import java.util.Set;
|
|
||||||
import java.util.UUID;
|
import java.util.UUID;
|
||||||
import java.util.concurrent.ConcurrentHashMap;
|
import java.util.concurrent.ConcurrentHashMap;
|
||||||
|
import java.util.concurrent.ConcurrentLinkedDeque;
|
||||||
|
|
||||||
public class ExpireManager {
|
public class ExpireManager {
|
||||||
|
|
||||||
@ -217,23 +216,22 @@ public class ExpireManager {
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
this.running = 2;
|
this.running = 2;
|
||||||
final Set<Plot> plots = PS.get().getPlots();
|
final ConcurrentLinkedDeque<Plot> plots = new ConcurrentLinkedDeque<Plot>(PS.get().getPlots());
|
||||||
TaskManager.runTaskAsync(new Runnable() {
|
TaskManager.runTaskAsync(new Runnable() {
|
||||||
@Override
|
@Override
|
||||||
public void run() {
|
public void run() {
|
||||||
|
final Runnable task = this;
|
||||||
if (ExpireManager.this.running != 2) {
|
if (ExpireManager.this.running != 2) {
|
||||||
ExpireManager.this.running = 0;
|
ExpireManager.this.running = 0;
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
long start = System.currentTimeMillis();
|
long start = System.currentTimeMillis();
|
||||||
Iterator<Plot> iterator = plots.iterator();
|
while (!plots.isEmpty()) {
|
||||||
while (iterator.hasNext() && System.currentTimeMillis() - start < 2) {
|
|
||||||
if (ExpireManager.this.running != 2) {
|
if (ExpireManager.this.running != 2) {
|
||||||
ExpireManager.this.running = 0;
|
ExpireManager.this.running = 0;
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
final Plot plot = iterator.next();
|
final Plot plot = plots.poll();
|
||||||
iterator.remove();
|
|
||||||
PlotArea area = plot.getArea();
|
PlotArea area = plot.getArea();
|
||||||
final ArrayDeque<ExpiryTask> applicable = new ArrayDeque<>(tasks);
|
final ArrayDeque<ExpiryTask> applicable = new ArrayDeque<>(tasks);
|
||||||
final Collection<ExpiryTask> expired = isExpired(applicable, plot);
|
final Collection<ExpiryTask> expired = isExpired(applicable, plot);
|
||||||
@ -242,17 +240,27 @@ public class ExpireManager {
|
|||||||
}
|
}
|
||||||
for (ExpiryTask expiryTask : expired) {
|
for (ExpiryTask expiryTask : expired) {
|
||||||
if (!expiryTask.needsAnalysis()) {
|
if (!expiryTask.needsAnalysis()) {
|
||||||
expiredTask.run(plot, this, expiryTask.requiresConfirmation());
|
expiredTask.run(plot, new Runnable() {
|
||||||
|
@Override
|
||||||
|
public void run() {
|
||||||
|
TaskManager.IMP.taskLaterAsync(task, 1);
|
||||||
|
}
|
||||||
|
}, expiryTask.requiresConfirmation());
|
||||||
|
return;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
final Runnable task = this;
|
|
||||||
final RunnableVal<PlotAnalysis> handleAnalysis = new RunnableVal<PlotAnalysis>() {
|
final RunnableVal<PlotAnalysis> handleAnalysis = new RunnableVal<PlotAnalysis>() {
|
||||||
@Override
|
@Override
|
||||||
public void run(final PlotAnalysis changed) {
|
public void run(final PlotAnalysis changed) {
|
||||||
passesComplexity(changed, expired, new RunnableVal<Boolean>() {
|
passesComplexity(changed, expired, new RunnableVal<Boolean>() {
|
||||||
@Override
|
@Override
|
||||||
public void run(Boolean confirmation) {
|
public void run(Boolean confirmation) {
|
||||||
expiredTask.run(plot, task, confirmation);
|
expiredTask.run(plot, new Runnable() {
|
||||||
|
@Override
|
||||||
|
public void run() {
|
||||||
|
TaskManager.IMP.taskLaterAsync(task, 1);
|
||||||
|
}
|
||||||
|
}, confirmation);
|
||||||
}
|
}
|
||||||
}, new Runnable() {
|
}, new Runnable() {
|
||||||
@Override
|
@Override
|
||||||
@ -280,7 +288,7 @@ public class ExpireManager {
|
|||||||
}, new Runnable() {
|
}, new Runnable() {
|
||||||
@Override
|
@Override
|
||||||
public void run() {
|
public void run() {
|
||||||
task.run();
|
TaskManager.IMP.taskLaterAsync(task, 1);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
} else {
|
} else {
|
||||||
@ -300,7 +308,7 @@ public class ExpireManager {
|
|||||||
}
|
}
|
||||||
}, 86400000);
|
}, 86400000);
|
||||||
} else {
|
} else {
|
||||||
TaskManager.runTaskLaterAsync(this, 20);
|
TaskManager.runTaskLaterAsync(task, 20 * 10);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
@ -1,5 +1,6 @@
|
|||||||
package com.plotsquared.general.commands;
|
package com.plotsquared.general.commands;
|
||||||
|
|
||||||
|
import com.intellectualcrafters.configuration.file.YamlConfiguration;
|
||||||
import com.intellectualcrafters.plot.PS;
|
import com.intellectualcrafters.plot.PS;
|
||||||
import com.intellectualcrafters.plot.commands.CommandCategory;
|
import com.intellectualcrafters.plot.commands.CommandCategory;
|
||||||
import com.intellectualcrafters.plot.commands.MainCommand;
|
import com.intellectualcrafters.plot.commands.MainCommand;
|
||||||
@ -176,25 +177,26 @@ public abstract class Command {
|
|||||||
options.put("usage", declaration.usage());
|
options.put("usage", declaration.usage());
|
||||||
options.put("confirmation", declaration.confirmation());
|
options.put("confirmation", declaration.confirmation());
|
||||||
boolean set = false;
|
boolean set = false;
|
||||||
|
YamlConfiguration commands = PS.get() == null ? new YamlConfiguration() : PS.get().commands;
|
||||||
for (Map.Entry<String, Object> entry : options.entrySet()) {
|
for (Map.Entry<String, Object> entry : options.entrySet()) {
|
||||||
String key = this.getFullId() + "." + entry.getKey();
|
String key = this.getFullId() + "." + entry.getKey();
|
||||||
if (!PS.get().commands.contains(key)) {
|
if (!commands.contains(key)) {
|
||||||
PS.get().commands.set(key, entry.getValue());
|
commands.set(key, entry.getValue());
|
||||||
set = true;
|
set = true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (set) {
|
if (set && PS.get() != null) {
|
||||||
try {
|
try {
|
||||||
PS.get().commands.save(PS.get().commandsFile);
|
commands.save(PS.get().commandsFile);
|
||||||
} catch (IOException e) {
|
} catch (IOException e) {
|
||||||
e.printStackTrace();
|
e.printStackTrace();
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
this.aliases = PS.get().commands.getStringList(this.getFullId() + ".aliases");
|
this.aliases = commands.getStringList(this.getFullId() + ".aliases");
|
||||||
this.description = PS.get().commands.getString(this.getFullId() + ".description");
|
this.description = commands.getString(this.getFullId() + ".description");
|
||||||
this.usage = PS.get().commands.getString(this.getFullId() + ".usage");
|
this.usage = commands.getString(this.getFullId() + ".usage");
|
||||||
this.confirmation = PS.get().commands.getBoolean(this.getFullId() + ".confirmation");
|
this.confirmation = commands.getBoolean(this.getFullId() + ".confirmation");
|
||||||
if (this.parent != null) {
|
if (this.parent != null) {
|
||||||
this.parent.register(this);
|
this.parent.register(this);
|
||||||
}
|
}
|
||||||
@ -331,7 +333,11 @@ public abstract class Command {
|
|||||||
if (!cmd.checkArgs(player, newArgs) || !cmd.canExecute(player, true)) {
|
if (!cmd.checkArgs(player, newArgs) || !cmd.canExecute(player, true)) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
try {
|
||||||
cmd.execute(player, newArgs, confirm, whenDone);
|
cmd.execute(player, newArgs, confirm, whenDone);
|
||||||
|
} catch (CommandException e) {
|
||||||
|
e.perform(player);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean checkArgs(PlotPlayer player, String[] args) {
|
public boolean checkArgs(PlotPlayer player, String[] args) {
|
||||||
@ -432,6 +438,9 @@ public abstract class Command {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public boolean canExecute(PlotPlayer player, boolean message) {
|
public boolean canExecute(PlotPlayer player, boolean message) {
|
||||||
|
if (player == null) {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
if (!this.required.allows(player)) {
|
if (!this.required.allows(player)) {
|
||||||
if (message) {
|
if (message) {
|
||||||
MainUtil.sendMessage(player, this.required == RequiredType.PLAYER ? C.IS_CONSOLE : C.NOT_CONSOLE);
|
MainUtil.sendMessage(player, this.required == RequiredType.PLAYER ? C.IS_CONSOLE : C.NOT_CONSOLE);
|
||||||
@ -479,6 +488,25 @@ public abstract class Command {
|
|||||||
return getCommandString() + " " + args + "]";
|
return getCommandString() + " " + args + "]";
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public Collection<Command> tabOf(PlotPlayer player, String[] input, boolean space, String... args) {
|
||||||
|
if (!space) {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
List<Command> result = new ArrayList<>();
|
||||||
|
int index = input.length - (space ? 0 : 1);
|
||||||
|
for (String arg : args) {
|
||||||
|
arg = arg.replace(getCommandString() + " ", "");
|
||||||
|
String[] split = arg.split(" ");
|
||||||
|
if (split.length <= index) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
arg = StringMan.join(Arrays.copyOfRange(split, index, split.length), " ");
|
||||||
|
Command cmd = new Command(null, false, arg, getPermission(), getRequiredType(), null) {};
|
||||||
|
result.add(cmd);
|
||||||
|
}
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
public Collection<Command> tab(PlotPlayer player, String[] args, boolean space) {
|
public Collection<Command> tab(PlotPlayer player, String[] args, boolean space) {
|
||||||
switch (args.length) {
|
switch (args.length) {
|
||||||
case 0:
|
case 0:
|
||||||
|
@ -75,11 +75,11 @@ public class PlotListener {
|
|||||||
Optional<Boolean> flyFlag = plot.getFlag(Flags.FLY);
|
Optional<Boolean> flyFlag = plot.getFlag(Flags.FLY);
|
||||||
if (flyFlag.isPresent()) {
|
if (flyFlag.isPresent()) {
|
||||||
boolean flight = player.getFlight();
|
boolean flight = player.getFlight();
|
||||||
if (flyFlag.get() != player.getFlight()) {
|
|
||||||
PlotGameMode gamemode = player.getGameMode();
|
PlotGameMode gamemode = player.getGameMode();
|
||||||
if (flight != (gamemode == PlotGameMode.CREATIVE || gamemode == PlotGameMode.SPECTATOR)) {
|
if (flight != (gamemode == PlotGameMode.CREATIVE || gamemode == PlotGameMode.SPECTATOR)) {
|
||||||
player.setPersistentMeta("flight", ByteArrayUtilities.booleanToBytes(player.getFlight()));
|
player.setPersistentMeta("flight", ByteArrayUtilities.booleanToBytes(player.getFlight()));
|
||||||
}
|
}
|
||||||
|
if (flyFlag.get() != player.getFlight()) {
|
||||||
player.setFlight(flyFlag.get());
|
player.setFlight(flyFlag.get());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -94,6 +94,17 @@ public class PlotListener {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Optional<PlotGameMode> guestGamemodeFlag = plot.getFlag(Flags.GUEST_GAMEMODE);
|
||||||
|
if (gamemodeFlag.isPresent()) {
|
||||||
|
if (player.getGameMode() != gamemodeFlag.get() && !plot.isAdded(player.getUUID())) {
|
||||||
|
if (!Permissions.hasPermission(player, "plots.gamemode.bypass")) {
|
||||||
|
player.setGameMode(gamemodeFlag.get());
|
||||||
|
} else {
|
||||||
|
MainUtil.sendMessage(player,
|
||||||
|
StringMan.replaceAll(C.GAMEMODE_WAS_BYPASSED.s(), "{plot}", plot.getId(), "{gamemode}", gamemodeFlag.get()));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
Optional<Long> timeFlag = plot.getFlag(Flags.TIME);
|
Optional<Long> timeFlag = plot.getFlag(Flags.TIME);
|
||||||
if (timeFlag.isPresent()) {
|
if (timeFlag.isPresent()) {
|
||||||
try {
|
try {
|
||||||
@ -171,7 +182,10 @@ public class PlotListener {
|
|||||||
if (pw == null) {
|
if (pw == null) {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
if (plot.getFlag(Flags.GAMEMODE).isPresent()) {
|
if (Flags.DENY_EXIT.isTrue(plot)) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
if (plot.getFlag(Flags.GAMEMODE).isPresent() || plot.getFlag(Flags.GUEST_GAMEMODE).isPresent()) {
|
||||||
if (player.getGameMode() != pw.GAMEMODE) {
|
if (player.getGameMode() != pw.GAMEMODE) {
|
||||||
if (!Permissions.hasPermission(player, "plots.gamemode.bypass")) {
|
if (!Permissions.hasPermission(player, "plots.gamemode.bypass")) {
|
||||||
player.setGameMode(pw.GAMEMODE);
|
player.setGameMode(pw.GAMEMODE);
|
||||||
@ -196,7 +210,8 @@ public class PlotListener {
|
|||||||
for (UUID uuid : plot.getOwners()) {
|
for (UUID uuid : plot.getOwners()) {
|
||||||
PlotPlayer owner = UUIDHandler.getPlayer(uuid);
|
PlotPlayer owner = UUIDHandler.getPlayer(uuid);
|
||||||
if ((owner != null) && !owner.getUUID().equals(player.getUUID())) {
|
if ((owner != null) && !owner.getUUID().equals(player.getUUID())) {
|
||||||
MainUtil.sendMessage(player, C.NOTIFY_LEAVE.s().replace("%player", player.getName()).replace("%plot", plot.getId().toString()));
|
MainUtil.sendMessage(owner, C.NOTIFY_LEAVE.s().replace("%player", player.getName()).replace("%plot", plot.getId()
|
||||||
|
.toString()));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -209,6 +224,8 @@ public class PlotListener {
|
|||||||
PlotGameMode gameMode = player.getGameMode();
|
PlotGameMode gameMode = player.getGameMode();
|
||||||
if (gameMode == PlotGameMode.SURVIVAL || gameMode == PlotGameMode.ADVENTURE) {
|
if (gameMode == PlotGameMode.SURVIVAL || gameMode == PlotGameMode.ADVENTURE) {
|
||||||
player.setFlight(false);
|
player.setFlight(false);
|
||||||
|
} else if (!player.getFlight()) {
|
||||||
|
player.setFlight(true);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -48,11 +48,11 @@ public class WEManager {
|
|||||||
if (area == null) {
|
if (area == null) {
|
||||||
return regions;
|
return regions;
|
||||||
}
|
}
|
||||||
|
boolean allowMember = player.hasPermission("plots.worldedit.member");
|
||||||
for (Plot plot : area.getPlots()) {
|
for (Plot plot : area.getPlots()) {
|
||||||
if (!plot.isBasePlot() || (Settings.Done.RESTRICT_BUILDING && (plot.getFlag(Flags.DONE).isPresent()))) {
|
if (!plot.isBasePlot() || (Settings.Done.RESTRICT_BUILDING && (plot.getFlag(Flags.DONE).isPresent()))) {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
boolean allowMember = player.hasPermission("plots.worldedit.member");
|
|
||||||
if (allowMember && plot.isAdded(uuid) || !allowMember && (plot.isOwner(uuid) || plot.getTrusted().contains(uuid))) {
|
if (allowMember && plot.isAdded(uuid) || !allowMember && (plot.isOwner(uuid) || plot.getTrusted().contains(uuid))) {
|
||||||
regions.addAll(plot.getRegions());
|
regions.addAll(plot.getRegions());
|
||||||
}
|
}
|
||||||
|
@ -1,18 +1,15 @@
|
|||||||
package com.intellectualcrafters.plot;
|
package com.intellectualcrafters.plot;
|
||||||
|
|
||||||
import static com.intellectualcrafters.plot.PS.log;
|
|
||||||
|
|
||||||
import com.intellectualcrafters.json.JSONArray;
|
import com.intellectualcrafters.json.JSONArray;
|
||||||
import com.intellectualcrafters.json.JSONObject;
|
import com.intellectualcrafters.json.JSONObject;
|
||||||
import com.intellectualcrafters.plot.util.StringMan;
|
import com.intellectualcrafters.plot.util.StringMan;
|
||||||
import org.junit.Test;
|
|
||||||
|
|
||||||
import java.io.BufferedReader;
|
import java.io.BufferedReader;
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
import java.io.InputStreamReader;
|
import java.io.InputStreamReader;
|
||||||
import java.net.MalformedURLException;
|
import java.net.MalformedURLException;
|
||||||
import java.net.URL;
|
import java.net.URL;
|
||||||
import java.util.Arrays;
|
import java.util.Arrays;
|
||||||
|
import org.junit.Test;
|
||||||
|
|
||||||
public class UpdaterTest {
|
public class UpdaterTest {
|
||||||
|
|
||||||
@ -30,7 +27,7 @@ public class UpdaterTest {
|
|||||||
|
|
||||||
return buffer.toString();
|
return buffer.toString();
|
||||||
} catch (IOException e) {
|
} catch (IOException e) {
|
||||||
log("&dCould not check for updates (0)");
|
System.out.println("&dCould not check for updates (0)");
|
||||||
e.printStackTrace();
|
e.printStackTrace();
|
||||||
} finally {
|
} finally {
|
||||||
try {
|
try {
|
||||||
|
@ -17,7 +17,7 @@ is to provide a lag-free and smooth experience.
|
|||||||
|
|
||||||
### Developer Resources
|
### Developer Resources
|
||||||
* [JavaDocs] Link Temporarily Unavailable
|
* [JavaDocs] Link Temporarily Unavailable
|
||||||
* [Build Server] Link Temporarily Unavailable
|
* [Build Server] [](http://ci.athion.net/job/PlotSquared/)
|
||||||
* [Maven Repo] Link Temporarily Unavailable
|
* [Maven Repo] Link Temporarily Unavailable
|
||||||
|
|
||||||
# Building
|
# Building
|
||||||
|
@ -15,17 +15,22 @@ buildscript {
|
|||||||
}
|
}
|
||||||
|
|
||||||
apply plugin: 'net.minecrell.vanilla.server.library'
|
apply plugin: 'net.minecrell.vanilla.server.library'
|
||||||
apply plugin: 'com.github.johnrengelman.shadow'
|
|
||||||
|
|
||||||
dependencies {
|
dependencies {
|
||||||
compile project(':Core')
|
compile project(':Core')
|
||||||
compile 'org.spongepowered:spongeapi:5.0.0-SNAPSHOT'
|
compile 'org.spongepowered:spongeapi:5.0.0-SNAPSHOT'
|
||||||
|
compile 'net.minecrell.mcstats:statslite-sponge:0.2.2'
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
sourceCompatibility = 1.8
|
sourceCompatibility = 1.8
|
||||||
targetCompatibility = 1.8
|
targetCompatibility = 1.8
|
||||||
|
|
||||||
repositories {
|
repositories {
|
||||||
|
maven {
|
||||||
|
name = 'minecrell'
|
||||||
|
url = 'http://repo.minecrell.net/releases'
|
||||||
|
}
|
||||||
maven {
|
maven {
|
||||||
name = 'forge'
|
name = 'forge'
|
||||||
url = 'http://files.minecraftforge.net/maven'
|
url = 'http://files.minecraftforge.net/maven'
|
||||||
@ -34,14 +39,10 @@ repositories {
|
|||||||
name = "Sponge"
|
name = "Sponge"
|
||||||
url = "https://repo.spongepowered.org/maven"
|
url = "https://repo.spongepowered.org/maven"
|
||||||
}
|
}
|
||||||
maven {
|
|
||||||
name = "Sponge Metrics"
|
|
||||||
url = "http://repo.mcstats.org/content/repositories/releases/"
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
minecraft {
|
minecraft {
|
||||||
version = "1.9.4"
|
version = "1.10.2"
|
||||||
mappings = "snapshot_20160530"
|
mappings = "snapshot_20160629"
|
||||||
runDir = 'run'
|
runDir = 'run'
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -56,9 +57,9 @@ processResources {
|
|||||||
shadowJar {
|
shadowJar {
|
||||||
dependencies {
|
dependencies {
|
||||||
include(dependency(':Core'))
|
include(dependency(':Core'))
|
||||||
//include(dependency('org.mcstats.sponge:metrics:R8-SNAPSHOT'))
|
include dependency('net.minecrell.mcstats:statslite-sponge')
|
||||||
}
|
}
|
||||||
//relocate 'org.mcstats', 'com.plotsquared.stats'
|
relocate 'net.minecrell.mcstats', 'com.plotsquared.util.mcstats'
|
||||||
archiveName = "${parent.name}-${project.name}-${parent.version}.jar"
|
archiveName = "${parent.name}-${project.name}-${parent.version}.jar"
|
||||||
destinationDir = file '../target'
|
destinationDir = file '../target'
|
||||||
}
|
}
|
||||||
|
@ -41,7 +41,6 @@ import com.plotsquared.sponge.util.SpongeEconHandler;
|
|||||||
import com.plotsquared.sponge.util.SpongeEventUtil;
|
import com.plotsquared.sponge.util.SpongeEventUtil;
|
||||||
import com.plotsquared.sponge.util.SpongeHybridUtils;
|
import com.plotsquared.sponge.util.SpongeHybridUtils;
|
||||||
import com.plotsquared.sponge.util.SpongeInventoryUtil;
|
import com.plotsquared.sponge.util.SpongeInventoryUtil;
|
||||||
import com.plotsquared.sponge.util.SpongeMetrics;
|
|
||||||
import com.plotsquared.sponge.util.SpongeSchematicHandler;
|
import com.plotsquared.sponge.util.SpongeSchematicHandler;
|
||||||
import com.plotsquared.sponge.util.SpongeSetupUtils;
|
import com.plotsquared.sponge.util.SpongeSetupUtils;
|
||||||
import com.plotsquared.sponge.util.SpongeTaskManager;
|
import com.plotsquared.sponge.util.SpongeTaskManager;
|
||||||
@ -51,13 +50,7 @@ import com.plotsquared.sponge.util.block.SpongeLocalQueue;
|
|||||||
import com.plotsquared.sponge.uuid.SpongeLowerOfflineUUIDWrapper;
|
import com.plotsquared.sponge.uuid.SpongeLowerOfflineUUIDWrapper;
|
||||||
import com.plotsquared.sponge.uuid.SpongeOnlineUUIDWrapper;
|
import com.plotsquared.sponge.uuid.SpongeOnlineUUIDWrapper;
|
||||||
import com.plotsquared.sponge.uuid.SpongeUUIDHandler;
|
import com.plotsquared.sponge.uuid.SpongeUUIDHandler;
|
||||||
import java.io.File;
|
import net.minecrell.mcstats.SpongeStatsLite;
|
||||||
import java.nio.file.Path;
|
|
||||||
import java.util.ArrayList;
|
|
||||||
import java.util.Collection;
|
|
||||||
import java.util.List;
|
|
||||||
import java.util.UUID;
|
|
||||||
import java.util.stream.Collectors;
|
|
||||||
import org.slf4j.Logger;
|
import org.slf4j.Logger;
|
||||||
import org.spongepowered.api.Game;
|
import org.spongepowered.api.Game;
|
||||||
import org.spongepowered.api.Server;
|
import org.spongepowered.api.Server;
|
||||||
@ -66,6 +59,7 @@ import org.spongepowered.api.config.ConfigDir;
|
|||||||
import org.spongepowered.api.entity.living.player.Player;
|
import org.spongepowered.api.entity.living.player.Player;
|
||||||
import org.spongepowered.api.event.Listener;
|
import org.spongepowered.api.event.Listener;
|
||||||
import org.spongepowered.api.event.game.state.GameAboutToStartServerEvent;
|
import org.spongepowered.api.event.game.state.GameAboutToStartServerEvent;
|
||||||
|
import org.spongepowered.api.event.game.state.GamePreInitializationEvent;
|
||||||
import org.spongepowered.api.plugin.Plugin;
|
import org.spongepowered.api.plugin.Plugin;
|
||||||
import org.spongepowered.api.plugin.PluginContainer;
|
import org.spongepowered.api.plugin.PluginContainer;
|
||||||
import org.spongepowered.api.profile.GameProfileManager;
|
import org.spongepowered.api.profile.GameProfileManager;
|
||||||
@ -74,8 +68,16 @@ import org.spongepowered.api.world.gen.GenerationPopulator;
|
|||||||
import org.spongepowered.api.world.gen.WorldGenerator;
|
import org.spongepowered.api.world.gen.WorldGenerator;
|
||||||
import org.spongepowered.api.world.gen.WorldGeneratorModifier;
|
import org.spongepowered.api.world.gen.WorldGeneratorModifier;
|
||||||
|
|
||||||
|
import java.io.File;
|
||||||
|
import java.nio.file.Path;
|
||||||
|
import java.util.ArrayList;
|
||||||
|
import java.util.Collection;
|
||||||
|
import java.util.List;
|
||||||
|
import java.util.UUID;
|
||||||
|
import java.util.stream.Collectors;
|
||||||
|
|
||||||
@Plugin(id = "plotsquared", name = "PlotSquared", description = "Easy, yet powerful Plot World generation and management.",
|
@Plugin(id = "plotsquared", name = "PlotSquared", description = "Easy, yet powerful Plot World generation and management.",
|
||||||
url = "https://github.com/IntellectualSites/PlotSquared", version = "3.3.3")
|
url = "https://github.com/IntellectualSites/PlotSquared", version = "3.5.0-SNAPSHOT")
|
||||||
public class SpongeMain implements IPlotMain {
|
public class SpongeMain implements IPlotMain {
|
||||||
|
|
||||||
public static SpongeMain THIS;
|
public static SpongeMain THIS;
|
||||||
@ -89,6 +91,9 @@ public class SpongeMain implements IPlotMain {
|
|||||||
@Inject
|
@Inject
|
||||||
private Game game;
|
private Game game;
|
||||||
|
|
||||||
|
@Inject
|
||||||
|
public SpongeStatsLite stats;
|
||||||
|
|
||||||
private Server server;
|
private Server server;
|
||||||
|
|
||||||
@Inject
|
@Inject
|
||||||
@ -97,8 +102,7 @@ public class SpongeMain implements IPlotMain {
|
|||||||
|
|
||||||
private GameProfileManager resolver;
|
private GameProfileManager resolver;
|
||||||
|
|
||||||
// @Override
|
private Logger getLogger() {
|
||||||
public Logger getLogger() {
|
|
||||||
return this.logger;
|
return this.logger;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -121,6 +125,12 @@ public class SpongeMain implements IPlotMain {
|
|||||||
return THIS;
|
return THIS;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Listener
|
||||||
|
public void onPreInitialize(GamePreInitializationEvent event) {
|
||||||
|
getLogger().info("The metrics section in PlotSquared is ignored in favor of the actual metrics reporter configurations.");
|
||||||
|
this.stats.start();
|
||||||
|
}
|
||||||
|
|
||||||
@Listener
|
@Listener
|
||||||
public void onServerAboutToStart(GameAboutToStartServerEvent event) {
|
public void onServerAboutToStart(GameAboutToStartServerEvent event) {
|
||||||
THIS = this;
|
THIS = this;
|
||||||
@ -165,6 +175,10 @@ public class SpongeMain implements IPlotMain {
|
|||||||
return new int[]{Integer.parseInt(split[0]), Integer.parseInt(split[1]), split.length == 3 ? Integer.parseInt(split[2]) : 0};
|
return new int[]{Integer.parseInt(split[0]), Integer.parseInt(split[1]), split.length == 3 ? Integer.parseInt(split[2]) : 0};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override public String getPluginVersionString() {
|
||||||
|
return this.plugin.getVersion().orElse("");
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public int[] getServerVersion() {
|
public int[] getServerVersion() {
|
||||||
PS.log("Checking minecraft version: Sponge: ");
|
PS.log("Checking minecraft version: Sponge: ");
|
||||||
@ -237,14 +251,11 @@ public class SpongeMain implements IPlotMain {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void registerPlotPlusEvents() {
|
public void registerPlotPlusEvents() {
|
||||||
// TODO Auto-generated method stub
|
|
||||||
PS.log("registerPlotPlusEvents is not implemented!");
|
PS.log("registerPlotPlusEvents is not implemented!");
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void registerForceFieldEvents() {
|
public void registerForceFieldEvents() {
|
||||||
// TODO Auto-generated method stub
|
|
||||||
PS.log("registerForceFieldEvents is not implemented!");
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@ -288,16 +299,8 @@ public class SpongeMain implements IPlotMain {
|
|||||||
Sponge.getEventManager().registerListeners(this, new WorldEvents());
|
Sponge.getEventManager().registerListeners(this, new WorldEvents());
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
|
||||||
public String getServerName() {
|
|
||||||
throw new UnsupportedOperationException("NOT IMPLEMENTED YET");
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void startMetrics() {
|
public void startMetrics() {
|
||||||
SpongeMetrics metrics = new SpongeMetrics(this.game, this.plugin);
|
|
||||||
metrics.start();
|
|
||||||
PS.log(C.PREFIX.s() + "&6Metrics enabled.");
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@ -328,7 +331,7 @@ public class SpongeMain implements IPlotMain {
|
|||||||
if (gen instanceof SpongePlotGenerator) {
|
if (gen instanceof SpongePlotGenerator) {
|
||||||
PS.get().loadWorld(worldName, (SpongePlotGenerator) gen);
|
PS.get().loadWorld(worldName, (SpongePlotGenerator) gen);
|
||||||
} else {
|
} else {
|
||||||
throw new UnsupportedOperationException("NOT IMPLEMENTED YET!");
|
throw new UnsupportedOperationException("NOT IMPLEMENTED YET! " + worldName + " | " + gen);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -341,6 +344,8 @@ public class SpongeMain implements IPlotMain {
|
|||||||
public PlotPlayer wrapPlayer(Object player) {
|
public PlotPlayer wrapPlayer(Object player) {
|
||||||
if (player instanceof Player) {
|
if (player instanceof Player) {
|
||||||
return SpongeUtil.getPlayer((Player) player);
|
return SpongeUtil.getPlayer((Player) player);
|
||||||
|
} else if (UUIDHandler.implementation == null) {
|
||||||
|
return null;
|
||||||
} else if (player instanceof String) {
|
} else if (player instanceof String) {
|
||||||
return UUIDHandler.getPlayer((String) player);
|
return UUIDHandler.getPlayer((String) player);
|
||||||
} else if (player instanceof UUID) {
|
} else if (player instanceof UUID) {
|
||||||
|
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user