Modify Setting and Storage class names.

This commit is contained in:
MattBDev 2016-06-10 13:00:34 -04:00
parent 8fe381d098
commit 482f4d6815
50 changed files with 432 additions and 403 deletions

View File

@ -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.Chunk; import org.bukkit.Chunk;
@ -93,6 +87,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;
@ -135,7 +136,7 @@ public final class BukkitMain extends JavaPlugin implements Listener, IPlotMain
public void log(String message) { public void log(String message) {
try { try {
message = C.color(message); message = C.color(message);
if (!Settings.CHAT.CONSOLE_COLOR) { if (!Settings.Chat.CONSOLE_COLOR) {
message = ChatColor.stripColor(message); message = ChatColor.stripColor(message);
} }
this.getServer().getConsoleSender().sendMessage(message); this.getServer().getConsoleSender().sendMessage(message);
@ -241,7 +242,7 @@ public final class BukkitMain extends JavaPlugin implements Listener, IPlotMain
case MINECART_MOB_SPAWNER: case MINECART_MOB_SPAWNER:
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; continue;
} }
com.intellectualcrafters.plot.object.Location location = BukkitUtil.getLocation(entity.getLocation()); com.intellectualcrafters.plot.object.Location location = BukkitUtil.getLocation(entity.getLocation());
@ -308,7 +309,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; continue;
} }
Location location = entity.getLocation(); Location location = entity.getLocation();
@ -660,7 +661,7 @@ public final class BukkitMain extends JavaPlugin implements Listener, IPlotMain
@Override @Override
public ChatManager<?> initChatManager() { public ChatManager<?> initChatManager() {
if (Settings.CHAT.INTERACTIVE) { if (Settings.Chat.INTERACTIVE) {
return new BukkitChatManager(); return new BukkitChatManager();
} else { } else {
return new BukkitPlainChatManager(); return new BukkitPlainChatManager();

View File

@ -64,7 +64,7 @@ public class ClassicPlotMeConnector extends APlotMeConnector {
} else if (checkUUID2) { } else if (checkUUID2) {
column = "ownerId"; column = "ownerId";
} }
boolean merge = !"plotme".equalsIgnoreCase(this.plugin) && Settings.ENABLED_COMPONENTS.PLOTME_CONVERTER; boolean merge = !"plotme".equalsIgnoreCase(this.plugin) && Settings.Enabled_Components.PLOTME_CONVERTER;
int missing = 0; int missing = 0;
while (resultSet.next()) { while (resultSet.next()) {
PlotId id = new PlotId(resultSet.getInt("idX"), resultSet.getInt("idZ")); PlotId id = new PlotId(resultSet.getInt("idX"), resultSet.getInt("idZ"));

View File

@ -144,7 +144,7 @@ public class LikePlotMeConverter {
sendMessage(" - " + dbPrefix + "Plots"); sendMessage(" - " + dbPrefix + "Plots");
final Set<String> worlds = getPlotMeWorlds(plotConfig); final Set<String> worlds = getPlotMeWorlds(plotConfig);
if (Settings.ENABLED_COMPONENTS.PLOTME_CONVERTER) { if (Settings.Enabled_Components.PLOTME_CONVERTER) {
sendMessage("Updating bukkit.yml"); sendMessage("Updating bukkit.yml");
updateWorldYml("bukkit.yml"); updateWorldYml("bukkit.yml");
updateWorldYml("plugins/Multiverse-Core/worlds.yml"); updateWorldYml("plugins/Multiverse-Core/worlds.yml");
@ -166,7 +166,7 @@ public class LikePlotMeConverter {
for (Entry<String, HashMap<PlotId, Plot>> entry : plots.entrySet()) { for (Entry<String, HashMap<PlotId, Plot>> entry : plots.entrySet()) {
plotCount += entry.getValue().size(); plotCount += entry.getValue().size();
} }
if (!Settings.ENABLED_COMPONENTS.PLOTME_CONVERTER) { if (!Settings.Enabled_Components.PLOTME_CONVERTER) {
return false; return false;
} }

View File

@ -67,7 +67,7 @@ public class PlotMeConnector_017 extends APlotMeConnector {
return null; return null;
} }
boolean checkUUID = DBFunc.hasColumn(resultSet, "ownerID"); boolean checkUUID = DBFunc.hasColumn(resultSet, "ownerID");
boolean merge = !this.plugin.equals("plotme") && Settings.ENABLED_COMPONENTS.PLOTME_CONVERTER; boolean merge = !this.plugin.equals("plotme") && Settings.Enabled_Components.PLOTME_CONVERTER;
while (resultSet.next()) { while (resultSet.next()) {
int key = resultSet.getInt("plot_id"); int key = resultSet.getInt("plot_id");
PlotId id = new PlotId(resultSet.getInt("plotX"), resultSet.getInt("plotZ")); PlotId id = new PlotId(resultSet.getInt("plotX"), resultSet.getInt("plotZ"));

View File

@ -1,5 +1,7 @@
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;
@ -8,8 +10,6 @@ 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 static com.intellectualcrafters.plot.util.ReflectionUtils.getRefClass; import java.util.HashSet;
public class ChunkListener implements Listener { public class ChunkListener implements Listener {
@ -39,7 +39,7 @@ public class ChunkListener implements Listener {
public ChunkListener() { public ChunkListener() {
if (Settings.CHUNK_PROCESSOR.AUTO_TRIM) { if (Settings.Chunk_Processor.AUTO_TRIM) {
try { try {
RefClass classChunk = getRefClass("{nms}.Chunk"); RefClass classChunk = getRefClass("{nms}.Chunk");
RefClass classCraftChunk = getRefClass("{cb}.CraftChunk"); RefClass classCraftChunk = getRefClass("{cb}.CraftChunk");
@ -47,10 +47,10 @@ public class ChunkListener implements Listener {
this.methodGetHandleChunk = classCraftChunk.getMethod("getHandle"); this.methodGetHandleChunk = classCraftChunk.getMethod("getHandle");
} catch (Throwable ignored) { } catch (Throwable ignored) {
PS.debug("PlotSquared/Server not compatible for chunk processor trim/gc"); PS.debug("PlotSquared/Server not compatible for chunk processor trim/gc");
Settings.CHUNK_PROCESSOR.AUTO_TRIM = false; Settings.Chunk_Processor.AUTO_TRIM = false;
} }
} }
if (!Settings.CHUNK_PROCESSOR.AUTO_TRIM) { if (!Settings.Chunk_Processor.AUTO_TRIM) {
return; return;
} }
for (World world : Bukkit.getWorlds()) { for (World world : Bukkit.getWorlds()) {
@ -139,7 +139,7 @@ public class ChunkListener implements Listener {
@EventHandler @EventHandler
public void onChunkUnload(ChunkUnloadEvent event) { public void onChunkUnload(ChunkUnloadEvent event) {
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();
if (PS.get().hasPlotArea(world)) { if (PS.get().hasPlotArea(world)) {
@ -171,7 +171,7 @@ public class ChunkListener implements Listener {
return; return;
} }
Entity[] entities = chunk.getEntities(); Entity[] entities = chunk.getEntities();
if (entities.length > Settings.CHUNK_PROCESSOR.MAX_ENTITIES) { if (entities.length > Settings.Chunk_Processor.MAX_ENTITIES) {
event.getEntity().remove(); event.getEntity().remove();
event.setCancelled(true); event.setCancelled(true);
this.lastChunk = chunk; this.lastChunk = chunk;
@ -182,7 +182,7 @@ public class ChunkListener implements Listener {
@EventHandler(priority = EventPriority.HIGHEST, ignoreCancelled = true) @EventHandler(priority = EventPriority.HIGHEST, ignoreCancelled = true)
public void onBlockPhysics(BlockPhysicsEvent event) { public void onBlockPhysics(BlockPhysicsEvent event) {
if (Settings.CHUNK_PROCESSOR.DISABLE_PHYSICS) { if (Settings.Chunk_Processor.DISABLE_PHYSICS) {
event.setCancelled(true); event.setCancelled(true);
} }
} }
@ -200,7 +200,7 @@ public class ChunkListener implements Listener {
return; return;
} }
Entity[] entities = chunk.getEntities(); Entity[] entities = chunk.getEntities();
if (entities.length > Settings.CHUNK_PROCESSOR.MAX_ENTITIES) { if (entities.length > Settings.Chunk_Processor.MAX_ENTITIES) {
event.getEntity().remove(); event.getEntity().remove();
event.setCancelled(true); event.setCancelled(true);
this.lastChunk = chunk; this.lastChunk = chunk;
@ -254,7 +254,7 @@ public class ChunkListener implements Listener {
} }
Entity[] entities = chunk.getEntities(); Entity[] entities = chunk.getEntities();
BlockState[] tiles = chunk.getTileEntities(); BlockState[] tiles = chunk.getTileEntities();
if (entities.length > Settings.CHUNK_PROCESSOR.MAX_ENTITIES) { if (entities.length > Settings.Chunk_Processor.MAX_ENTITIES) {
for (Entity ent : entities) { for (Entity ent : entities) {
if (!(ent instanceof Player)) { if (!(ent instanceof Player)) {
ent.remove(); ent.remove();
@ -262,7 +262,7 @@ public class ChunkListener implements Listener {
} }
PS.debug("[PlotSquared] &a detected unsafe chunk and processed: " + (chunk.getX() << 4) + "," + (chunk.getX() << 4)); PS.debug("[PlotSquared] &a detected unsafe chunk and processed: " + (chunk.getX() << 4) + "," + (chunk.getX() << 4));
} }
if (tiles.length > Settings.CHUNK_PROCESSOR.MAX_TILES) { if (tiles.length > Settings.Chunk_Processor.MAX_TILES) {
if (unload) { if (unload) {
PS.debug("[PlotSquared] &c detected unsafe chunk: " + (chunk.getX() << 4) + "," + (chunk.getX() << 4)); PS.debug("[PlotSquared] &c detected unsafe chunk: " + (chunk.getX() << 4) + "," + (chunk.getX() << 4));
cleanChunk(chunk); cleanChunk(chunk);

View File

@ -200,7 +200,7 @@ public class PlayerEvents extends PlotListener implements Listener {
event.setNewCurrent(0); event.setNewCurrent(0);
return; return;
} }
if (Settings.REDSTONE.DISABLE_OFFLINE) { if (Settings.Redstone.DISABLE_OFFLINE) {
if (UUIDHandler.getPlayer(plot.owner) == null) { if (UUIDHandler.getPlayer(plot.owner) == null) {
boolean disable = true; boolean disable = true;
for (UUID trusted : plot.getTrusted()) { for (UUID trusted : plot.getTrusted()) {
@ -215,7 +215,7 @@ public class PlayerEvents extends PlotListener implements Listener {
} }
} }
} }
if (Settings.REDSTONE.DISABLE_UNOCCUPIED) { if (Settings.Redstone.DISABLE_UNOCCUPIED) {
for (Entry<String, PlotPlayer> entry : UUIDHandler.getPlayers().entrySet()) { for (Entry<String, PlotPlayer> entry : UUIDHandler.getPlayers().entrySet()) {
if (plot.equals(entry.getValue().getCurrentPlot())) { if (plot.equals(entry.getValue().getCurrentPlot())) {
return; return;
@ -350,7 +350,7 @@ public class PlayerEvents extends PlotListener implements Listener {
if (cmd == null) { if (cmd == null) {
if (split[0].equals("plotme") || split[0].equals("ap")) { if (split[0].equals("plotme") || split[0].equals("ap")) {
Player player = event.getPlayer(); Player player = event.getPlayer();
if (Settings.PLOTME.ALIAS) { if (Settings.PlotMe.ALIAS) {
player.performCommand("plots " + StringMan.join(Arrays.copyOfRange(split, 1, split.length), " ")); player.performCommand("plots " + StringMan.join(Arrays.copyOfRange(split, 1, split.length), " "));
} else { } else {
MainUtil.sendMessage(BukkitUtil.getPlayer(player), C.NOT_USING_PLOTME); MainUtil.sendMessage(BukkitUtil.getPlayer(player), C.NOT_USING_PLOTME);
@ -647,7 +647,7 @@ public class PlayerEvents extends PlotListener implements Listener {
} }
MainUtil.sendMessage(plotPlayer, C.NO_PERMISSION_EVENT, C.PERMISSION_ADMIN_DESTROY_OTHER); MainUtil.sendMessage(plotPlayer, C.NO_PERMISSION_EVENT, C.PERMISSION_ADMIN_DESTROY_OTHER);
event.setCancelled(true); event.setCancelled(true);
} else if (Settings.DONE.RESTRICT_BUILDING && plot.getFlags().containsKey(Flags.DONE)) { } else if (Settings.Done.RESTRICT_BUILDING && plot.getFlags().containsKey(Flags.DONE)) {
if (!Permissions.hasPermission(plotPlayer, C.PERMISSION_ADMIN_BUILD_OTHER)) { if (!Permissions.hasPermission(plotPlayer, C.PERMISSION_ADMIN_BUILD_OTHER)) {
MainUtil.sendMessage(plotPlayer, C.NO_PERMISSION_EVENT, C.PERMISSION_ADMIN_BUILD_OTHER); MainUtil.sendMessage(plotPlayer, C.NO_PERMISSION_EVENT, C.PERMISSION_ADMIN_BUILD_OTHER);
event.setCancelled(true); event.setCancelled(true);
@ -741,7 +741,7 @@ public class PlayerEvents extends PlotListener implements Listener {
} }
} }
} }
if (Settings.ENABLED_COMPONENTS.PERMISSION_CACHE) { if (Settings.Enabled_Components.PERMISSION_CACHE) {
pp.deleteMeta("perm"); pp.deleteMeta("perm");
} }
} }
@ -1883,7 +1883,7 @@ public class PlayerEvents extends PlotListener implements Listener {
entity.remove(); entity.remove();
return; return;
} }
if (Settings.ENABLED_COMPONENTS.KILL_ROAD_VEHICLES) { if (Settings.Enabled_Components.KILL_ROAD_VEHICLES) {
entity.setMetadata("plot", new FixedMetadataValue((Plugin) PS.get().IMP, plot)); entity.setMetadata("plot", new FixedMetadataValue((Plugin) PS.get().IMP, plot));
} }
} }
@ -2302,7 +2302,7 @@ public class PlayerEvents extends PlotListener implements Listener {
event.setCancelled(true); event.setCancelled(true);
return; return;
} }
} else if (Settings.DONE.RESTRICT_BUILDING && plot.getFlags().containsKey(Flags.DONE)) { } else if (Settings.Done.RESTRICT_BUILDING && plot.getFlags().containsKey(Flags.DONE)) {
if (!Permissions.hasPermission(pp, C.PERMISSION_ADMIN_BUILD_OTHER)) { if (!Permissions.hasPermission(pp, C.PERMISSION_ADMIN_BUILD_OTHER)) {
MainUtil.sendMessage(pp, C.NO_PERMISSION_EVENT, C.PERMISSION_ADMIN_BUILD_OTHER); MainUtil.sendMessage(pp, C.NO_PERMISSION_EVENT, C.PERMISSION_ADMIN_BUILD_OTHER);
event.setCancelled(true); event.setCancelled(true);

View File

@ -10,9 +10,7 @@ import com.intellectualcrafters.plot.config.Settings;
import com.intellectualcrafters.plot.config.Storage; import com.intellectualcrafters.plot.config.Storage;
import com.intellectualcrafters.plot.database.DBFunc; import com.intellectualcrafters.plot.database.DBFunc;
import com.intellectualcrafters.plot.database.Database; import com.intellectualcrafters.plot.database.Database;
import com.intellectualcrafters.plot.database.MySQL;
import com.intellectualcrafters.plot.database.SQLManager; import com.intellectualcrafters.plot.database.SQLManager;
import com.intellectualcrafters.plot.database.SQLite;
import com.intellectualcrafters.plot.generator.GeneratorWrapper; import com.intellectualcrafters.plot.generator.GeneratorWrapper;
import com.intellectualcrafters.plot.generator.HybridPlotWorld; import com.intellectualcrafters.plot.generator.HybridPlotWorld;
import com.intellectualcrafters.plot.generator.HybridUtils; import com.intellectualcrafters.plot.generator.HybridUtils;
@ -52,6 +50,7 @@ import com.intellectualcrafters.plot.util.expiry.ExpireManager;
import com.intellectualcrafters.plot.util.expiry.ExpiryTask; import com.intellectualcrafters.plot.util.expiry.ExpiryTask;
import com.plotsquared.listener.WESubscriber; import com.plotsquared.listener.WESubscriber;
import com.sk89q.worldedit.WorldEdit; import com.sk89q.worldedit.WorldEdit;
import java.io.File; import java.io.File;
import java.io.FileInputStream; import java.io.FileInputStream;
import java.io.FileOutputStream; import java.io.FileOutputStream;
@ -156,21 +155,21 @@ public class PS {
} }
this.TASK = this.IMP.getTaskManager(); this.TASK = this.IMP.getTaskManager();
setupConfigs(); setupConfigs();
this.translationFile = MainUtil.getFile(this.IMP.getDirectory(), Settings.PATHS.TRANSLATIONS + File.separator + "PlotSquared.use_THIS.yml"); this.translationFile = MainUtil.getFile(this.IMP.getDirectory(), Settings.Paths.TRANSLATIONS + File.separator + "PlotSquared.use_THIS.yml");
C.load(this.translationFile); C.load(this.translationFile);
// Database // Database
if (Settings.ENABLED_COMPONENTS.DATABASE) { if (Settings.Enabled_Components.DATABASE) {
setupDatabase(); setupDatabase();
} }
// Comments // Comments
CommentManager.registerDefaultInboxes(); CommentManager.registerDefaultInboxes();
// Kill entities // Kill entities
if (Settings.ENABLED_COMPONENTS.KILL_ROAD_MOBS || Settings.ENABLED_COMPONENTS.KILL_ROAD_VEHICLES) { if (Settings.Enabled_Components.KILL_ROAD_MOBS || Settings.Enabled_Components.KILL_ROAD_VEHICLES) {
this.IMP.runEntityTask(); this.IMP.runEntityTask();
} }
// WorldEdit // WorldEdit
if (Settings.ENABLED_COMPONENTS.WORLDEDIT_RESTRICTIONS) { if (Settings.Enabled_Components.WORLDEDIT_RESTRICTIONS) {
try { try {
if (this.IMP.initWorldEdit()) { if (this.IMP.initWorldEdit()) {
this.worldedit = WorldEdit.getInstance(); this.worldedit = WorldEdit.getInstance();
@ -183,10 +182,10 @@ public class PS {
} }
} }
// Commands // Commands
if (Settings.ENABLED_COMPONENTS.COMMANDS) { if (Settings.Enabled_Components.COMMANDS) {
this.IMP.registerCommands(); this.IMP.registerCommands();
} }
if (Settings.ENABLED_COMPONENTS.EVENTS) { if (Settings.Enabled_Components.EVENTS) {
this.IMP.registerPlayerEvents(); this.IMP.registerPlayerEvents();
this.IMP.registerInventoryEvents(); this.IMP.registerInventoryEvents();
this.IMP.registerPlotPlusEvents(); this.IMP.registerPlotPlusEvents();
@ -194,17 +193,17 @@ public class PS {
} }
// Required // Required
this.IMP.registerWorldEvents(); this.IMP.registerWorldEvents();
if (Settings.ENABLED_COMPONENTS.METRICS) { if (Settings.Enabled_Components.METRICS) {
this.IMP.startMetrics(); this.IMP.startMetrics();
} else { } else {
PS.log(C.CONSOLE_PLEASE_ENABLE_METRICS); PS.log(C.CONSOLE_PLEASE_ENABLE_METRICS);
} }
if (Settings.ENABLED_COMPONENTS.CHUNK_PROCESSOR) { if (Settings.Enabled_Components.CHUNK_PROCESSOR) {
this.IMP.registerChunkProcessor(); this.IMP.registerChunkProcessor();
} }
// create UUIDWrapper // create UUIDWrapper
UUIDHandler.implementation = this.IMP.initUUIDHandler(); UUIDHandler.implementation = this.IMP.initUUIDHandler();
if (Settings.ENABLED_COMPONENTS.UUID_CACHE) { if (Settings.Enabled_Components.UUID_CACHE) {
startUuidCatching(); startUuidCatching();
} else { } else {
// Start these separately // Start these separately
@ -233,7 +232,7 @@ public class PS {
// Chat // Chat
ChatManager.manager = this.IMP.initChatManager(); ChatManager.manager = this.IMP.initChatManager();
// Economy // Economy
if (Settings.ENABLED_COMPONENTS.ECONOMY) { if (Settings.Enabled_Components.ECONOMY) {
TaskManager.runTask(new Runnable() { TaskManager.runTask(new Runnable() {
@Override @Override
public void run() { public void run() {
@ -243,7 +242,7 @@ public class PS {
} }
// Check for updates // Check for updates
if (Settings.ENABLED_COMPONENTS.UPDATER) { if (Settings.Enabled_Components.UPDATER) {
TaskManager.runTaskAsync(new Runnable() { TaskManager.runTaskAsync(new Runnable() {
@Override @Override
public void run() { public void run() {
@ -293,13 +292,13 @@ public class PS {
} }
// Copy files // Copy files
copyFile("automerge.js", Settings.PATHS.SCRIPTS); copyFile("automerge.js", Settings.Paths.SCRIPTS);
copyFile("town.template", Settings.PATHS.TEMPLATES); copyFile("town.template", Settings.Paths.TEMPLATES);
copyFile("skyblock.template", Settings.PATHS.TEMPLATES); copyFile("skyblock.template", Settings.Paths.TEMPLATES);
copyFile("german.yml", Settings.PATHS.TRANSLATIONS); copyFile("german.yml", Settings.Paths.TRANSLATIONS);
copyFile("s_chinese_unescaped.yml", Settings.PATHS.TRANSLATIONS); copyFile("s_chinese_unescaped.yml", Settings.Paths.TRANSLATIONS);
copyFile("s_chinese.yml", Settings.PATHS.TRANSLATIONS); copyFile("s_chinese.yml", Settings.Paths.TRANSLATIONS);
copyFile("italian.yml", Settings.PATHS.TRANSLATIONS); copyFile("italian.yml", Settings.Paths.TRANSLATIONS);
showDebug(); showDebug();
} catch (Throwable e) { } catch (Throwable e) {
e.printStackTrace(); e.printStackTrace();
@ -384,10 +383,10 @@ public class PS {
} }
private void startExpiryTasks() { private void startExpiryTasks() {
if (Settings.ENABLED_COMPONENTS.PLOT_EXPIRY) { if (Settings.Enabled_Components.PLOT_EXPIRY) {
ExpireManager.IMP = new ExpireManager(); ExpireManager.IMP = new ExpireManager();
ExpireManager.IMP.runAutomatedTask(); ExpireManager.IMP.runAutomatedTask();
for (Settings.AUTO_CLEAR settings : Settings.AUTO_CLEAR.getInstances()) { for (Settings.Auto_Clear settings : Settings.AUTO_CLEAR.getInstances()) {
ExpiryTask task = new ExpiryTask(settings); ExpiryTask task = new ExpiryTask(settings);
ExpireManager.IMP.addTask(task); ExpireManager.IMP.addTask(task);
} }
@ -395,13 +394,13 @@ public class PS {
} }
private void startPlotMeConversion() { private void startPlotMeConversion() {
if (Settings.ENABLED_COMPONENTS.PLOTME_CONVERTER || Settings.PLOTME.CACHE_UUDS) { if (Settings.Enabled_Components.PLOTME_CONVERTER || Settings.PlotMe.CACHE_UUDS) {
TaskManager.runTaskLater(new Runnable() { TaskManager.runTaskLater(new Runnable() {
@Override @Override
public void run() { public void run() {
if (PS.this.IMP.initPlotMeConverter()) { if (PS.this.IMP.initPlotMeConverter()) {
PS.log("&c=== IMPORTANT ==="); PS.log("&c=== IMPORTANT ===");
PS.log("&cTHIS MESSAGE MAY BE EXTREMELY HELPFUL IF YOU HAVE TROUBLE CONVERTING PLOTME!"); PS.log("&cTHIS MESSAGE MAY BE EXTREMELY HELPFUL IF YOU HAVE TROUBLE CONVERTING PlotMe!");
PS.log("&c - Make sure 'UUID.read-from-disk' is disabled (false)!"); PS.log("&c - Make sure 'UUID.read-from-disk' is disabled (false)!");
PS.log("&c - Sometimes the database can be locked, deleting PlotMe.jar beforehand will fix the issue!"); PS.log("&c - Sometimes the database can be locked, deleting PlotMe.jar beforehand will fix the issue!");
PS.log("&c - After the conversion is finished, please set 'plotme-convert.enabled' to false in the " PS.log("&c - After the conversion is finished, please set 'plotme-convert.enabled' to false in the "
@ -1816,11 +1815,11 @@ public class PS {
public void setupDatabase() { public void setupDatabase() {
try { try {
if (DBFunc.dbManager == null) { if (DBFunc.dbManager == null) {
if (Storage.MYSQL.USE) { if (Storage.MySQL.USE) {
this.database = new MySQL(Storage.MYSQL.HOST, Storage.MYSQL.PORT, Storage.MYSQL.DATABASE, Storage.MYSQL.USER, Storage.MYSQL.PASSWORD); this.database = new com.intellectualcrafters.plot.database.MySQL(Storage.MySQL.HOST, Storage.MySQL.PORT, Storage.MySQL.DATABASE, Storage.MySQL.USER, Storage.MySQL.PASSWORD);
} else if (Storage.SQLITE.USE) { } else if (Storage.SQLite.USE) {
File file = MainUtil.getFile(IMP.getDirectory(), Storage.SQLITE.DB + ".db"); File file = MainUtil.getFile(IMP.getDirectory(), Storage.SQLite.DB + ".db");
this.database = new SQLite(file); this.database = new com.intellectualcrafters.plot.database.SQLite(file);
} else { } else {
PS.log(C.PREFIX + "&cNo storage type is set!"); PS.log(C.PREFIX + "&cNo storage type is set!");
this.IMP.disable(); this.IMP.disable();
@ -1832,9 +1831,9 @@ public class PS {
this.clusters_tmp = DBFunc.getClusters(); this.clusters_tmp = DBFunc.getClusters();
} catch (ClassNotFoundException | SQLException e) { } catch (ClassNotFoundException | SQLException e) {
PS.log(C.PREFIX + "&cFailed to open DATABASE connection. The plugin will disable itself."); PS.log(C.PREFIX + "&cFailed to open DATABASE connection. The plugin will disable itself.");
if (Storage.MYSQL.USE) { if (Storage.MySQL.USE) {
PS.log("$4MYSQL"); PS.log("$4MYSQL");
} else if (Storage.SQLITE.USE) { } else if (Storage.SQLite.USE) {
PS.log("$4SQLITE"); PS.log("$4SQLITE");
} }
PS.log("&d==== Here is an ugly stacktrace, if you are interested in those things ==="); PS.log("&d==== Here is an ugly stacktrace, if you are interested in those things ===");
@ -1906,7 +1905,7 @@ public class PS {
PS.log("Failed to save settings.yml"); PS.log("Failed to save settings.yml");
} }
try { try {
this.styleFile = MainUtil.getFile(IMP.getDirectory(), Settings.PATHS.TRANSLATIONS +File.separator + "style.yml" ); this.styleFile = MainUtil.getFile(IMP.getDirectory(), Settings.Paths.TRANSLATIONS +File.separator + "style.yml" );
if (!this.styleFile.exists()) { if (!this.styleFile.exists()) {
if (!this.styleFile.getParentFile().exists()) { if (!this.styleFile.getParentFile().exists()) {
this.styleFile.getParentFile().mkdirs(); this.styleFile.getParentFile().mkdirs();
@ -1963,7 +1962,7 @@ public class PS {
*/ */
private void showDebug() { private void showDebug() {
if (Settings.DEBUG) { if (Settings.DEBUG) {
Map<String, Object> components = Settings.getFields(Settings.ENABLED_COMPONENTS.class); Map<String, Object> components = Settings.getFields(Settings.Enabled_Components.class);
for (Entry<String, Object> component : components.entrySet()) { for (Entry<String, Object> component : components.entrySet()) {
PS.log(C.PREFIX + String.format("&cKey: &6%s&c, Value: &6%s", component.getKey(), component.getValue())); PS.log(C.PREFIX + String.format("&cKey: &6%s&c, Value: &6%s", component.getKey(), component.getValue()));
} }

View File

@ -86,11 +86,11 @@ public class Auto extends SubCommand {
// return false; // return false;
} }
} }
if (size_x * size_z > Settings.CLAIM.MAX_AUTO_AREA) { if (size_x * size_z > Settings.Claim.MAX_AUTO_AREA) {
MainUtil.sendMessage(player, C.CANT_CLAIM_MORE_PLOTS_NUM, Settings.CLAIM.MAX_AUTO_AREA + ""); MainUtil.sendMessage(player, C.CANT_CLAIM_MORE_PLOTS_NUM, Settings.Claim.MAX_AUTO_AREA + "");
return false; return false;
} }
int currentPlots = Settings.LIMIT.GLOBAL ? player.getPlotCount() : player.getPlotCount(plotarea.worldname); int currentPlots = Settings.Limit.GLOBAL ? player.getPlotCount() : player.getPlotCount(plotarea.worldname);
int diff = currentPlots - player.getAllowedPlots(); int diff = currentPlots - player.getAllowedPlots();
if (diff + size_x * size_z > 0) { if (diff + size_x * size_z > 0) {
if (diff < 0) { if (diff < 0) {

View File

@ -30,7 +30,7 @@ public class Claim extends SubCommand {
if (plot == null) { if (plot == null) {
return sendMessage(player, C.NOT_IN_PLOT); return sendMessage(player, C.NOT_IN_PLOT);
} }
int currentPlots = Settings.LIMIT.GLOBAL ? player.getPlotCount() : player.getPlotCount(loc.getWorld()); int currentPlots = Settings.Limit.GLOBAL ? player.getPlotCount() : player.getPlotCount(loc.getWorld());
int grants = 0; int grants = 0;
if (currentPlots >= player.getAllowedPlots()) { if (currentPlots >= player.getAllowedPlots()) {
if (player.hasPersistentMeta("grantedPlots")) { if (player.hasPersistentMeta("grantedPlots")) {

View File

@ -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((!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);
confirm.run(this, new Runnable() { confirm.run(this, new Runnable() {
@Override @Override
public void run() { public void run() {

View File

@ -127,12 +127,12 @@ public class Cluster extends SubCommand {
// Check allowed cluster size // Check allowed cluster size
cluster = new PlotCluster(area, pos1, pos2, player.getUUID()); cluster = new PlotCluster(area, pos1, pos2, player.getUUID());
int current; int current;
if (Settings.LIMIT.GLOBAL) { if (Settings.Limit.GLOBAL) {
current = player.getPlayerClusterCount(); current = player.getPlayerClusterCount();
} else { } else {
current = player.getPlayerClusterCount(player.getLocation().getWorld()); current = player.getPlayerClusterCount(player.getLocation().getWorld());
} }
int allowed = Permissions.hasPermissionRange(player, "plots.cluster", Settings.LIMIT.MAX_PLOTS); int allowed = Permissions.hasPermissionRange(player, "plots.cluster", Settings.Limit.MAX_PLOTS);
if (current + cluster.getArea() > allowed) { if (current + cluster.getArea() > allowed) {
MainUtil.sendMessage(player, C.NO_PERMISSION, "plots.cluster." + (current + cluster.getArea())); MainUtil.sendMessage(player, C.NO_PERMISSION, "plots.cluster." + (current + cluster.getArea()));
return false; return false;
@ -257,13 +257,13 @@ public class Cluster extends SubCommand {
} }
// Check allowed cluster size // Check allowed cluster size
int current; int current;
if (Settings.LIMIT.GLOBAL) { if (Settings.Limit.GLOBAL) {
current = player.getPlayerClusterCount(); current = player.getPlayerClusterCount();
} else { } else {
current = player.getPlayerClusterCount(player.getLocation().getWorld()); current = player.getPlayerClusterCount(player.getLocation().getWorld());
} }
current -= cluster.getArea() + (1 + pos2.x - pos1.x) * (1 + pos2.y - pos1.y); current -= cluster.getArea() + (1 + pos2.x - pos1.x) * (1 + pos2.y - pos1.y);
int allowed = Permissions.hasPermissionRange(player, "plots.cluster", Settings.LIMIT.MAX_PLOTS); int allowed = Permissions.hasPermissionRange(player, "plots.cluster", Settings.Limit.MAX_PLOTS);
if (current + cluster.getArea() > allowed) { if (current + cluster.getArea() > allowed) {
MainUtil.sendMessage(player, C.NO_PERMISSION, "plots.cluster." + (current + cluster.getArea())); MainUtil.sendMessage(player, C.NO_PERMISSION, "plots.cluster." + (current + cluster.getArea()));
return false; return false;

View File

@ -32,7 +32,7 @@ public class Continue extends SubCommand {
return false; return false;
} }
int size = plot.getConnectedPlots().size(); int size = plot.getConnectedPlots().size();
if (Settings.DONE.COUNTS_TOWARDS_LIMIT && (player.getAllowedPlots() < player.getPlotCount() + size)) { if (Settings.Done.COUNTS_TOWARDS_LIMIT && (player.getAllowedPlots() < player.getPlotCount() + size)) {
MainUtil.sendMessage(player, C.NO_PERMISSION, "plots.admin.command.continue"); MainUtil.sendMessage(player, C.NO_PERMISSION, "plots.admin.command.continue");
return false; return false;
} }

View File

@ -12,7 +12,6 @@ import com.intellectualcrafters.plot.object.ConsolePlayer;
import com.intellectualcrafters.plot.object.Location; import com.intellectualcrafters.plot.object.Location;
import com.intellectualcrafters.plot.object.OfflinePlotPlayer; import com.intellectualcrafters.plot.object.OfflinePlotPlayer;
import com.intellectualcrafters.plot.object.Plot; import com.intellectualcrafters.plot.object.Plot;
import com.intellectualcrafters.plot.util.expiry.PlotAnalysis;
import com.intellectualcrafters.plot.object.PlotArea; import com.intellectualcrafters.plot.object.PlotArea;
import com.intellectualcrafters.plot.object.PlotBlock; import com.intellectualcrafters.plot.object.PlotBlock;
import com.intellectualcrafters.plot.object.PlotId; import com.intellectualcrafters.plot.object.PlotId;
@ -25,7 +24,6 @@ import com.intellectualcrafters.plot.util.AbstractTitle;
import com.intellectualcrafters.plot.util.ChunkManager; import com.intellectualcrafters.plot.util.ChunkManager;
import com.intellectualcrafters.plot.util.EconHandler; import com.intellectualcrafters.plot.util.EconHandler;
import com.intellectualcrafters.plot.util.EventUtil; import com.intellectualcrafters.plot.util.EventUtil;
import com.intellectualcrafters.plot.util.expiry.ExpireManager;
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.SchematicHandler; import com.intellectualcrafters.plot.util.SchematicHandler;
@ -35,6 +33,8 @@ import com.intellectualcrafters.plot.util.StringMan;
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 com.intellectualcrafters.plot.util.WorldUtil; import com.intellectualcrafters.plot.util.WorldUtil;
import com.intellectualcrafters.plot.util.expiry.ExpireManager;
import com.intellectualcrafters.plot.util.expiry.PlotAnalysis;
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 com.plotsquared.listener.WEManager; import com.plotsquared.listener.WEManager;
@ -68,11 +68,11 @@ public class DebugExec extends SubCommand {
public DebugExec() { public DebugExec() {
try { try {
if (PS.get() != null) { if (PS.get() != null) {
File file = new File(PS.get().IMP.getDirectory(), Settings.PATHS.SCRIPTS + File.separator + "start.js"); File file = new File(PS.get().IMP.getDirectory(), Settings.Paths.SCRIPTS + File.separator + "start.js");
if (file.exists()) { if (file.exists()) {
init(); init();
String script = StringMan.join(Files String script = StringMan.join(Files
.readLines(new File(new File(PS.get().IMP.getDirectory() + File.separator + Settings.PATHS.SCRIPTS), "start.js"), .readLines(new File(new File(PS.get().IMP.getDirectory() + File.separator + Settings.Paths.SCRIPTS), "start.js"),
StandardCharsets.UTF_8), StandardCharsets.UTF_8),
System.getProperty("line.separator")); System.getProperty("line.separator"));
this.scope.put("THIS", this); this.scope.put("THIS", this);
@ -283,7 +283,8 @@ public class DebugExec extends SubCommand {
case "addcmd": case "addcmd":
try { try {
final String cmd = StringMan.join(Files final String cmd = StringMan.join(Files
.readLines(MainUtil.getFile(new File(PS.get().IMP.getDirectory() + File.separator + Settings.PATHS.SCRIPTS), args[1]), .readLines(MainUtil.getFile(new File(PS.get().IMP.getDirectory() + File.separator + Settings.Paths.SCRIPTS),
args[1]),
StandardCharsets.UTF_8), StandardCharsets.UTF_8),
System.getProperty("line.separator")); System.getProperty("line.separator"));
new Command(MainCommand.getInstance(), true, args[1].split("\\.")[0], null, RequiredType.NONE, CommandCategory.DEBUG) { new Command(MainCommand.getInstance(), true, args[1].split("\\.")[0], null, RequiredType.NONE, CommandCategory.DEBUG) {
@ -310,7 +311,8 @@ public class DebugExec extends SubCommand {
case "run": case "run":
try { try {
script = StringMan.join(Files script = StringMan.join(Files
.readLines(MainUtil.getFile(new File(PS.get().IMP.getDirectory() + File.separator + Settings.PATHS.SCRIPTS), args[1]), .readLines(MainUtil.getFile(new File(PS.get().IMP.getDirectory() + File.separator + Settings.Paths.SCRIPTS),
args[1]),
StandardCharsets.UTF_8), StandardCharsets.UTF_8),
System.getProperty("line.separator")); System.getProperty("line.separator"));
if (args.length > 2) { if (args.length > 2) {
@ -326,7 +328,7 @@ public class DebugExec extends SubCommand {
} }
break; break;
case "list-scripts": case "list-scripts":
String path = PS.get().IMP.getDirectory() + File.separator + Settings.PATHS.SCRIPTS; String path = PS.get().IMP.getDirectory() + File.separator + Settings.Paths.SCRIPTS;
File folder = new File(path); File folder = new File(path);
File[] filesArray = folder.listFiles(); File[] filesArray = folder.listFiles();

View File

@ -43,7 +43,7 @@ public class Done extends SubCommand {
} }
plot.addRunning(); plot.addRunning();
MainUtil.sendMessage(player, C.GENERATING_LINK); MainUtil.sendMessage(player, C.GENERATING_LINK);
final Settings.AUTO_CLEAR doneRequirements = Settings.AUTO_CLEAR.get("done"); final Settings.Auto_Clear doneRequirements = Settings.AUTO_CLEAR.get("done");
if (ExpireManager.IMP == null || doneRequirements == null) { if (ExpireManager.IMP == null || doneRequirements == null) {
finish(plot, player, true); finish(plot, player, true);
plot.removeRunning(); plot.removeRunning();

View File

@ -41,7 +41,7 @@ public class Download extends SubCommand {
MainUtil.sendMessage(player, C.PLOT_UNOWNED); MainUtil.sendMessage(player, C.PLOT_UNOWNED);
return false; return false;
} }
if ((Settings.DONE.REQUIRED_FOR_DOWNLOAD && (!plot.getFlag(Flags.DONE).isPresent())) && !Permissions if ((Settings.Done.REQUIRED_FOR_DOWNLOAD && (!plot.getFlag(Flags.DONE).isPresent())) && !Permissions
.hasPermission(player, "plots.admin.command.download")) { .hasPermission(player, "plots.admin.command.download")) {
MainUtil.sendMessage(player, C.DONE_NOT_DONE); MainUtil.sendMessage(player, C.DONE_NOT_DONE);
return false; return false;

View File

@ -31,7 +31,7 @@ public class Load extends SubCommand {
@Override @Override
public boolean onCommand(final PlotPlayer player, String[] args) { public boolean onCommand(final PlotPlayer player, String[] args) {
if (!Settings.ENABLED_COMPONENTS.METRICS) { if (!Settings.Enabled_Components.METRICS) {
MainUtil.sendMessage(player, MainUtil.sendMessage(player,
"&cPlease enable metrics in order to use this command.\n&7 - Or host it yourself if you don't like the free service"); "&cPlease enable metrics in order to use this command.\n&7 - Or host it yourself if you don't like the free service");
return false; return false;
@ -75,7 +75,7 @@ public class Load extends SubCommand {
} }
final URL url; final URL url;
try { try {
url = new URL(Settings.WEB.URL + "saves/" + player.getUUID() + '/' + schematic + ".schematic"); url = new URL(Settings.Web.URL + "saves/" + player.getUUID() + '/' + schematic + ".schematic");
} catch (MalformedURLException e) { } catch (MalformedURLException e) {
e.printStackTrace(); e.printStackTrace();
MainUtil.sendMessage(player, C.LOAD_FAILED); MainUtil.sendMessage(player, C.LOAD_FAILED);

View File

@ -77,7 +77,7 @@ public class Merge extends SubCommand {
return false; return false;
} }
final int size = plot.getConnectedPlots().size(); final int size = plot.getConnectedPlots().size();
final int maxSize = Permissions.hasPermissionRange(player, "plots.merge", Settings.LIMIT.MAX_PLOTS); final int maxSize = Permissions.hasPermissionRange(player, "plots.merge", Settings.Limit.MAX_PLOTS);
if (size - 1 > maxSize) { if (size - 1 > maxSize) {
MainUtil.sendMessage(player, C.NO_PERMISSION, "plots.merge." + (size + 1)); MainUtil.sendMessage(player, C.NO_PERMISSION, "plots.merge." + (size + 1));
return false; return false;

View File

@ -65,7 +65,7 @@ public class Owner extends SetCommand {
return false; return false;
} }
int size = plots.size(); int size = plots.size();
int currentPlots = (Settings.LIMIT.GLOBAL ? other.getPlotCount() : other.getPlotCount(plot.getArea().worldname)) + size; int currentPlots = (Settings.Limit.GLOBAL ? other.getPlotCount() : other.getPlotCount(plot.getArea().worldname)) + size;
if (currentPlots > other.getAllowedPlots()) { if (currentPlots > other.getAllowedPlots()) {
sendMessage(player, C.CANT_TRANSFER_MORE_PLOTS); sendMessage(player, C.CANT_TRANSFER_MORE_PLOTS);
return false; return false;

View File

@ -62,7 +62,7 @@ public class Rate extends SubCommand {
}); });
UUID uuid = player.getUUID(); UUID uuid = player.getUUID();
for (Plot p : plots) { for (Plot p : plots) {
if ((!Settings.DONE.REQUIRED_FOR_RATINGS || p.hasFlag(Flags.DONE)) && p.isBasePlot() && (p.hasRatings() || !p.getRatings() if ((!Settings.Done.REQUIRED_FOR_RATINGS || p.hasFlag(Flags.DONE)) && p.isBasePlot() && (p.hasRatings() || !p.getRatings()
.containsKey(uuid)) && !p.isAdded(uuid)) { .containsKey(uuid)) && !p.isAdded(uuid)) {
p.teleportPlayer(player); p.teleportPlayer(player);
MainUtil.sendMessage(player, C.RATE_THIS); MainUtil.sendMessage(player, C.RATE_THIS);
@ -85,11 +85,11 @@ public class Rate extends SubCommand {
sendMessage(player, C.RATING_NOT_YOUR_OWN); sendMessage(player, C.RATING_NOT_YOUR_OWN);
return false; return false;
} }
if (Settings.DONE.REQUIRED_FOR_RATINGS && !plot.hasFlag(Flags.DONE)) { if (Settings.Done.REQUIRED_FOR_RATINGS && !plot.hasFlag(Flags.DONE)) {
sendMessage(player, C.RATING_NOT_DONE); sendMessage(player, C.RATING_NOT_DONE);
return false; return false;
} }
if (Settings.RATINGS.CATEGORIES != null && !Settings.RATINGS.CATEGORIES.isEmpty()) { if (Settings.Ratings.CATEGORIES != null && !Settings.Ratings.CATEGORIES.isEmpty()) {
final Runnable run = new Runnable() { final Runnable run = new Runnable() {
@Override @Override
public void run() { public void run() {
@ -99,13 +99,13 @@ public class Rate extends SubCommand {
} }
final MutableInt index = new MutableInt(0); final MutableInt index = new MutableInt(0);
final MutableInt rating = new MutableInt(0); final MutableInt rating = new MutableInt(0);
String title = Settings.RATINGS.CATEGORIES.get(0); String title = Settings.Ratings.CATEGORIES.get(0);
PlotInventory inventory = new PlotInventory(player, 1, title) { PlotInventory inventory = new PlotInventory(player, 1, title) {
@Override @Override
public boolean onClick(int i) { public boolean onClick(int i) {
rating.add((i + 1) * Math.pow(10, index.getValue())); rating.add((i + 1) * Math.pow(10, index.getValue()));
index.increment(); index.increment();
if (index.getValue() >= Settings.RATINGS.CATEGORIES.size()) { if (index.getValue() >= Settings.Ratings.CATEGORIES.size()) {
int rV = rating.getValue(); int rV = rating.getValue();
Rating result = EventUtil.manager.callRating(this.player, plot, new Rating(rV)); Rating result = EventUtil.manager.callRating(this.player, plot, new Rating(rV));
plot.addRating(this.player.getUUID(), result); plot.addRating(this.player.getUUID(), result);
@ -118,7 +118,7 @@ public class Rate extends SubCommand {
} }
return false; return false;
} }
setTitle(Settings.RATINGS.CATEGORIES.get(index.getValue())); setTitle(Settings.Ratings.CATEGORIES.get(index.getValue()));
return true; return true;
} }
}; };
@ -135,7 +135,7 @@ public class Rate extends SubCommand {
} }
}; };
if (plot.getSettings().ratings == null) { if (plot.getSettings().ratings == null) {
if (!Settings.ENABLED_COMPONENTS.RATING_CACHE) { if (!Settings.Enabled_Components.RATING_CACHE) {
TaskManager.runTaskAsync(new Runnable() { TaskManager.runTaskAsync(new Runnable() {
@Override @Override
public void run() { public void run() {
@ -180,7 +180,7 @@ public class Rate extends SubCommand {
} }
}; };
if (plot.getSettings().ratings == null) { if (plot.getSettings().ratings == null) {
if (!Settings.ENABLED_COMPONENTS.RATING_CACHE) { if (!Settings.Enabled_Components.RATING_CACHE) {
TaskManager.runTaskAsync(new Runnable() { TaskManager.runTaskAsync(new Runnable() {
@Override @Override
public void run() { public void run() {

View File

@ -30,7 +30,7 @@ public class Save extends SubCommand {
@Override @Override
public boolean onCommand(final PlotPlayer player, String[] args) { public boolean onCommand(final PlotPlayer player, String[] args) {
if (!Settings.ENABLED_COMPONENTS.METRICS) { if (!Settings.Enabled_Components.METRICS) {
MainUtil.sendMessage(player, MainUtil.sendMessage(player,
"&cPlease enable metrics in order to use this command.\n&7 - Or host it yourself if you don't like the free service"); "&cPlease enable metrics in order to use this command.\n&7 - Or host it yourself if you don't like the free service");
return false; return false;

View File

@ -75,7 +75,7 @@ public class SchematicCmd extends SubCommand {
if (location.startsWith("url:")) { if (location.startsWith("url:")) {
try { try {
UUID uuid = UUID.fromString(location.substring(4)); UUID uuid = UUID.fromString(location.substring(4));
URL base = new URL(Settings.WEB.URL); URL base = new URL(Settings.Web.URL);
URL url = new URL(base, "uploads/" + uuid + ".schematic"); URL url = new URL(base, "uploads/" + uuid + ".schematic");
schematic = SchematicHandler.manager.getSchematic(url); schematic = SchematicHandler.manager.getSchematic(url);
} catch (Exception e) { } catch (Exception e) {

View File

@ -39,7 +39,7 @@ public class Template extends SubCommand {
public static boolean extractAllFiles(String world, String template) { public static boolean extractAllFiles(String world, String template) {
try { try {
File folder = MainUtil.getFile(PS.get().IMP.getDirectory(), Settings.PATHS.TEMPLATES); File folder = MainUtil.getFile(PS.get().IMP.getDirectory(), Settings.Paths.TEMPLATES);
if (!folder.exists()) { if (!folder.exists()) {
return false; return false;
} }
@ -89,7 +89,7 @@ public class Template extends SubCommand {
} }
public static void zipAll(String world, Set<FileBytes> files) throws IOException { public static void zipAll(String world, Set<FileBytes> files) throws IOException {
File output = MainUtil.getFile(PS.get().IMP.getDirectory(), Settings.PATHS.TEMPLATES); File output = MainUtil.getFile(PS.get().IMP.getDirectory(), Settings.Paths.TEMPLATES);
output.mkdirs(); output.mkdirs();
try (FileOutputStream fos = new FileOutputStream(output + File.separator + world + ".template"); try (FileOutputStream fos = new FileOutputStream(output + File.separator + world + ".template");
ZipOutputStream zos = new ZipOutputStream(fos)) { ZipOutputStream zos = new ZipOutputStream(fos)) {
@ -134,7 +134,7 @@ public class Template extends SubCommand {
MainUtil.sendMessage(player, "&cInvalid template file: " + args[2] + ".template"); MainUtil.sendMessage(player, "&cInvalid template file: " + args[2] + ".template");
return false; return false;
} }
File worldFile = MainUtil.getFile(PS.get().IMP.getDirectory(), Settings.PATHS.TEMPLATES + File.separator + "tmp-data.yml"); File worldFile = MainUtil.getFile(PS.get().IMP.getDirectory(), Settings.Paths.TEMPLATES + File.separator + "tmp-data.yml");
YamlConfiguration worldConfig = YamlConfiguration.loadConfiguration(worldFile); YamlConfiguration worldConfig = YamlConfiguration.loadConfiguration(worldFile);
PS.get().worlds.set("worlds." + world, worldConfig.get("")); PS.get().worlds.set("worlds." + world, worldConfig.get(""));
try { try {

View File

@ -26,6 +26,7 @@ public class Config {
* Get the value for a node<br> * Get the value for a node<br>
* Probably throws some error if you try to get a non existent key * Probably throws some error if you try to get a non existent key
* @param key * @param key
* @param root
* @param <T> * @param <T>
* @return * @return
*/ */
@ -51,6 +52,7 @@ public class Config {
* Probably throws some error if you supply non existing keys or invalid values * Probably throws some error if you supply non existing keys or invalid values
* @param key config node * @param key config node
* @param value value * @param value value
* @param root
* *
*/ */
public static void set(String key, Object value, Class root) { public static void set(String key, Object value, Class root) {
@ -91,6 +93,7 @@ public class Config {
/** /**
* Set all values in the file (load first to avoid overwriting) * Set all values in the file (load first to avoid overwriting)
* @param file * @param file
* @param root
*/ */
public static void save(File file, Class root) { public static void save(File file, Class root) {
try { try {
@ -108,7 +111,7 @@ public class Config {
} }
/** /**
* Get the static fields in a section * Get the static fields in a section.
* @param clazz * @param clazz
* @return * @return
*/ */
@ -150,7 +153,7 @@ public class Config {
private static void save(PrintWriter writer, Class clazz, Object instance, int indent) { private static void save(PrintWriter writer, Class clazz, Object instance, int indent) {
try { try {
String CTRF = System.lineSeparator(); String lineSeparator = System.lineSeparator();
String spacing = StringMan.repeat(" ", indent); String spacing = StringMan.repeat(" ", indent);
for (Field field : clazz.getFields()) { for (Field field : clazz.getFields()) {
if (field.getAnnotation(Ignore.class) != null) { if (field.getAnnotation(Ignore.class) != null) {
@ -159,7 +162,7 @@ public class Config {
Comment comment = field.getAnnotation(Comment.class); Comment comment = field.getAnnotation(Comment.class);
if (comment != null) { if (comment != null) {
for (String commentLine : comment.value()) { for (String commentLine : comment.value()) {
writer.write(spacing + "# " + commentLine + CTRF); writer.write(spacing + "# " + commentLine + lineSeparator);
} }
} }
Create create = field.getAnnotation(Create.class); Create create = field.getAnnotation(Create.class);
@ -177,7 +180,7 @@ public class Config {
} }
continue; continue;
} else { } else {
writer.write(spacing + toNodeName(field.getName() + ": ") + toYamlString(field.get(instance), spacing) + CTRF); writer.write(spacing + toNodeName(field.getName() + ": ") + toYamlString(field.get(instance), spacing) + lineSeparator);
} }
} }
for (Class<?> current : clazz.getClasses()) { for (Class<?> current : clazz.getClasses()) {
@ -185,15 +188,15 @@ public class Config {
continue; continue;
} }
if (indent == 0) { if (indent == 0) {
writer.write(CTRF); writer.write(lineSeparator);
} }
Comment comment = current.getAnnotation(Comment.class); Comment comment = current.getAnnotation(Comment.class);
if (comment != null) { if (comment != null) {
for (String commentLine : comment.value()) { for (String commentLine : comment.value()) {
writer.write(spacing + "# " + commentLine + CTRF); writer.write(spacing + "# " + commentLine + lineSeparator);
} }
} }
writer.write(spacing + toNodeName(current.getSimpleName()) + ":" + CTRF); writer.write(spacing + toNodeName(current.getSimpleName()) + ":" + lineSeparator);
BlockName blockNames = current.getAnnotation(BlockName.class); BlockName blockNames = current.getAnnotation(BlockName.class);
if (blockNames != null) { if (blockNames != null) {
Field instanceField = clazz.getDeclaredField(toFieldName(current.getSimpleName())); Field instanceField = clazz.getDeclaredField(toFieldName(current.getSimpleName()));
@ -209,7 +212,7 @@ public class Config {
// Save each instance // Save each instance
for (Map.Entry<String, Object> entry: ((Map<String, Object>) value.getRaw()).entrySet()) { for (Map.Entry<String, Object> entry: ((Map<String, Object>) value.getRaw()).entrySet()) {
String key = entry.getKey(); String key = entry.getKey();
writer.write(spacing + " " + toNodeName(key) + ":" + CTRF); writer.write(spacing + " " + toNodeName(key) + ":" + lineSeparator);
save(writer, current, entry.getValue(), indent + 4); save(writer, current, entry.getValue(), indent + 4);
} }
continue; continue;
@ -223,8 +226,9 @@ public class Config {
} }
/** /**
* Get the field for a specific config node * Get the field for a specific config node.
* @param split the node (split by period) * @param split the node (split by period)
* @param root
* @return * @return
*/ */
private static Field getField(String[] split, Class root) { private static Field getField(String[] split, Class root) {
@ -254,8 +258,9 @@ public class Config {
} }
/** /**
* Get the instance for a specific config node * Get the instance for a specific config node.
* @param split the node (split by period) * @param split the node (split by period)
* @param root
* @return The instance or null * @return The instance or null
*/ */
private static Object getInstance(String[] split, Class root) { private static Object getInstance(String[] split, Class root) {
@ -270,7 +275,7 @@ public class Config {
Class found = null; Class found = null;
Class<?>[] classes = clazz.getDeclaredClasses(); Class<?>[] classes = clazz.getDeclaredClasses();
for (Class current : classes) { for (Class current : classes) {
if (StringMan.isEqual(current.getSimpleName(), toFieldName(split[0]))) { if (current.getSimpleName().equalsIgnoreCase(toFieldName(split[0]))) {
found = current; found = current;
break; break;
} }
@ -302,7 +307,7 @@ public class Config {
clazz = found; clazz = found;
split = Arrays.copyOfRange(split, 2, split.length); split = Arrays.copyOfRange(split, 2, split.length);
continue; continue;
} catch (NoSuchFieldException ignore) {} } catch (NoSuchFieldException ignore) { }
if (found != null) { if (found != null) {
split = Arrays.copyOfRange(split, 1, split.length); split = Arrays.copyOfRange(split, 1, split.length);
clazz = found; clazz = found;
@ -319,7 +324,7 @@ public class Config {
} }
/** /**
* Translate a node to a java field name * Translate a node to a java field name.
* @param node * @param node
* @return * @return
*/ */
@ -328,7 +333,7 @@ public class Config {
} }
/** /**
* Translate a field to a config node * Translate a field to a config node.
* @param field * @param field
* @return * @return
*/ */
@ -337,7 +342,7 @@ public class Config {
} }
/** /**
* Set some field to be accesible * Set some field to be accessible.
* @param field * @param field
* @throws NoSuchFieldException * @throws NoSuchFieldException
* @throws IllegalAccessException * @throws IllegalAccessException
@ -350,21 +355,21 @@ public class Config {
} }
/** /**
* Indicates that a field should be instantiated / created * Indicates that a field should be instantiated / created.
*/ */
@Retention(RetentionPolicy.RUNTIME) @Retention(RetentionPolicy.RUNTIME)
@Target({ElementType.FIELD}) @Target({ElementType.FIELD})
public @interface Create {} public @interface Create {}
/** /**
* Indicates that a field cannot be modified * Indicates that a field cannot be modified.
*/ */
@Retention(RetentionPolicy.RUNTIME) @Retention(RetentionPolicy.RUNTIME)
@Target({ElementType.FIELD}) @Target({ElementType.FIELD})
public @interface Final {} public @interface Final {}
/** /**
* Creates a comment * Creates a comment.
*/ */
@Retention(RetentionPolicy.RUNTIME) @Retention(RetentionPolicy.RUNTIME)
@Target({ElementType.FIELD,ElementType.TYPE}) @Target({ElementType.FIELD,ElementType.TYPE})
@ -373,7 +378,7 @@ public class Config {
} }
/** /**
* The names of any default blocks * The names of any default blocks.
*/ */
@Retention(RetentionPolicy.RUNTIME) @Retention(RetentionPolicy.RUNTIME)
@Target({ElementType.FIELD,ElementType.TYPE}) @Target({ElementType.FIELD,ElementType.TYPE})
@ -382,7 +387,7 @@ public class Config {
} }
/** /**
* Any field or class with is not part of the config * Any field or class with is not part of the config.
*/ */
@Retention(RetentionPolicy.RUNTIME) @Retention(RetentionPolicy.RUNTIME)
@Target({ElementType.FIELD,ElementType.TYPE}) @Target({ElementType.FIELD,ElementType.TYPE})

View File

@ -1,9 +1,10 @@
package com.intellectualcrafters.plot.config; package com.intellectualcrafters.plot.config;
import com.intellectualcrafters.configuration.file.YamlConfiguration; import com.intellectualcrafters.configuration.file.YamlConfiguration;
import java.io.File; import java.io.File;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.Arrays; import java.util.Collections;
import java.util.List; import java.util.List;
public class Settings extends Config { public class Settings extends Config {
@ -29,13 +30,132 @@ public class Settings extends Config {
public static boolean TITLES = true; public static boolean TITLES = true;
@Create // This value will be generated automatically @Create // This value will be generated automatically
public static ConfigBlock<AUTO_CLEAR> AUTO_CLEAR = null; // A ConfigBlock is a section that can have multiple instances e.g. multiple expiry tasks public static ConfigBlock<Auto_Clear> AUTO_CLEAR = null; // A ConfigBlock is a section that can have multiple instances e.g. multiple expiry tasks
public static void save(File file) {
save(file, Settings.class);
}
public static void load(File file) {
load(file, Settings.class);
}
public static boolean convertLegacy(File file) {
if (!file.exists()) {
return false;
}
YamlConfiguration config = YamlConfiguration.loadConfiguration(file);
// Protection
Redstone.DISABLE_OFFLINE = config.getBoolean("protection.redstone.disable-offline");
Redstone.DISABLE_UNOCCUPIED = config.getBoolean("protection.redstone.disable-unoccupied", Redstone.DISABLE_UNOCCUPIED);
// PlotMe
PlotMe.ALIAS = config.getBoolean("plotme-alias", PlotMe.ALIAS);
Enabled_Components.PLOTME_CONVERTER = config.getBoolean("plotme-convert.enabled", Enabled_Components.PLOTME_CONVERTER);
PlotMe.CACHE_UUDS = config.getBoolean("plotme-convert.cache-uuids", PlotMe.CACHE_UUDS);
// UUID
UUID.USE_SQLUUIDHANDLER = config.getBoolean("uuid.use_sqluuidhandler", UUID.USE_SQLUUIDHANDLER);
UUID.OFFLINE = config.getBoolean("UUID.offline", UUID.OFFLINE);
UUID.FORCE_LOWERCASE = config.getBoolean("UUID.force-lowercase", UUID.FORCE_LOWERCASE);
// Mob stuff
Enabled_Components.KILL_ROAD_MOBS = config.getBoolean("kill_road_mobs", Enabled_Components.KILL_ROAD_MOBS);
Enabled_Components.KILL_ROAD_VEHICLES = config.getBoolean("kill_road_vehicles", Enabled_Components.KILL_ROAD_VEHICLES);
// Clearing + Expiry
// FAST_CLEAR = config.getBoolean("clear.fastmode");
Enabled_Components.PLOT_EXPIRY = config.getBoolean("clear.auto.enabled", Enabled_Components.PLOT_EXPIRY);
if (Enabled_Components.PLOT_EXPIRY) {
Enabled_Components.BAN_DELETER = config.getBoolean("clear.on.ban");
AUTO_CLEAR = new ConfigBlock<>();
AUTO_CLEAR.put("task1", new Auto_Clear());
Auto_Clear task = AUTO_CLEAR.get("task1");
task.CALIBRATION = new Auto_Clear.CALIBRATION();
task.DAYS = config.getInt("clear.auto.days", task.DAYS);
task.THRESHOLD = config.getInt("clear.auto.threshold", task.THRESHOLD);
task.CONFIRMATION = config.getBoolean("clear.auto.confirmation", task.CONFIRMATION);
task.CALIBRATION.CHANGES = config.getInt("clear.auto.calibration.changes", task.CALIBRATION.CHANGES);
task.CALIBRATION.FACES = config.getInt("clear.auto.calibration.faces", task.CALIBRATION.FACES);
task.CALIBRATION.DATA = config.getInt("clear.auto.calibration.data", task.CALIBRATION.DATA);
task.CALIBRATION.AIR = config.getInt("clear.auto.calibration.air", task.CALIBRATION.AIR);
task.CALIBRATION.VARIETY = config.getInt("clear.auto.calibration.variety", task.CALIBRATION.VARIETY);
task.CALIBRATION.CHANGES_SD = config.getInt("clear.auto.calibration.changes_sd", task.CALIBRATION.CHANGES_SD);
task.CALIBRATION.FACES_SD = config.getInt("clear.auto.calibration.faces_sd", task.CALIBRATION.FACES_SD);
task.CALIBRATION.DATA_SD = config.getInt("clear.auto.calibration.data_sd", task.CALIBRATION.DATA_SD);
task.CALIBRATION.AIR_SD = config.getInt("clear.auto.calibration.air_sd", task.CALIBRATION.AIR_SD);
task.CALIBRATION.VARIETY_SD = config.getInt("clear.auto.calibration.variety_sd", task.CALIBRATION.VARIETY_SD);
}
// Done
Done.REQUIRED_FOR_RATINGS = config.getBoolean("approval.ratings.check-done", Done.REQUIRED_FOR_RATINGS);
Done.COUNTS_TOWARDS_LIMIT = config.getBoolean("approval.done.counts-towards-limit", Done.COUNTS_TOWARDS_LIMIT);
Done.RESTRICT_BUILDING = config.getBoolean("approval.done.restrict-building", Done.RESTRICT_BUILDING);
Done.REQUIRED_FOR_DOWNLOAD = config.getBoolean("approval.done.required-for-download", Done.REQUIRED_FOR_DOWNLOAD);
// Schematics
Paths.SCHEMATICS = config.getString("schematics.save_path", Paths.SCHEMATICS);
Paths.BO3 = config.getString("bo3.save_path", Paths.BO3);
// Web
Web.URL = config.getString("web.url", Web.URL);
Web.SERVER_IP = config.getString("web.server-ip", Web.SERVER_IP);
// Caching
Enabled_Components.PERMISSION_CACHE = config.getBoolean("cache.permissions", Enabled_Components.PERMISSION_CACHE);
Enabled_Components.RATING_CACHE = config.getBoolean("cache.ratings", Enabled_Components.RATING_CACHE);
// Rating system
Ratings.CATEGORIES = config.contains("ratings.categories") ? config.getStringList("ratings.categories") : Ratings.CATEGORIES;
// Titles
TITLES = config.getBoolean("titles", TITLES);
// Teleportation
Teleport.DELAY = config.getInt("teleport.delay", Teleport.DELAY);
Teleport.ON_LOGIN = config.getBoolean("teleport.on_login", Teleport.ON_LOGIN);
Teleport.ON_DEATH = config.getBoolean("teleport.on_death", Teleport.ON_DEATH);
// WorldEdit
// WE_ALLOW_HELPER = config.getBoolean("worldedit.enable-for-helpers");
// Chunk processor
Enabled_Components.CHUNK_PROCESSOR = config.getBoolean("chunk-processor.enabled", Enabled_Components.CHUNK_PROCESSOR);
Chunk_Processor.AUTO_TRIM = config.getBoolean("chunk-processor.auto-unload", Chunk_Processor.AUTO_TRIM);
Chunk_Processor.MAX_TILES = config.getInt("chunk-processor.max-blockstates", Chunk_Processor.MAX_TILES);
Chunk_Processor.MAX_ENTITIES = config.getInt("chunk-processor.max-entities", Chunk_Processor.MAX_ENTITIES);
Chunk_Processor.DISABLE_PHYSICS = config.getBoolean("chunk-processor.disable-physics", Chunk_Processor.DISABLE_PHYSICS);
// Comments
Enabled_Components.COMMENT_NOTIFIER = config.getBoolean("comments.notifications.enabled", Enabled_Components.COMMENT_NOTIFIER);
// Plot limits
Claim.MAX_AUTO_AREA = config.getInt("claim.max-auto-area", Claim.MAX_AUTO_AREA);
Limit.MAX_PLOTS = config.getInt("max_plots", Limit.MAX_PLOTS);
Limit.GLOBAL = config.getBoolean("global_limit", Limit.GLOBAL);
// Misc
DEBUG = config.getBoolean("debug", DEBUG);
Chat.CONSOLE_COLOR = config.getBoolean("console.color", Chat.CONSOLE_COLOR);
Chat.INTERACTIVE = config.getBoolean("chat.fancy", Chat.INTERACTIVE);
Enabled_Components.METRICS = config.getBoolean("metrics", Enabled_Components.METRICS);
Enabled_Components.UPDATER = config.getBoolean("update-notifications", Enabled_Components.UPDATER);
Enabled_Components.DATABASE_PURGER = config.getBoolean("auto-purge", Enabled_Components.DATABASE_PURGER);
return true;
}
@Comment("This is an auto clearing task called `task1`") @Comment("This is an auto clearing task called `task1`")
@BlockName("task1") // The name for the default block @BlockName("task1") // The name for the default block
public static final class AUTO_CLEAR extends ConfigBlock { public static final class Auto_Clear extends ConfigBlock {
@Create // This value has to be generated since an instance isn't static @Create // This value has to be generated since an instance isn't static
public CALIBRATION CALIBRATION = null; public CALIBRATION CALIBRATION = null;
public int THRESHOLD = 1;
public boolean CONFIRMATION = true;
public int DAYS = 7;
public List<String> WORLDS = new ArrayList<>(Collections.singletonList("*"));
@Comment("See: https://github.com/IntellectualSites/PlotSquared/wiki/Plot-analysis") @Comment("See: https://github.com/IntellectualSites/PlotSquared/wiki/Plot-analysis")
public static final class CALIBRATION { public static final class CALIBRATION {
@ -50,14 +170,9 @@ public class Settings extends Config {
public int AIR_SD = 0; public int AIR_SD = 0;
public int DATA = 0; public int DATA = 0;
} }
public int THRESHOLD = 1;
public boolean CONFIRMATION = true;
public int DAYS = 7;
public List<String> WORLDS = new ArrayList<>(Arrays.asList("*"));
} }
public static class CHUNK_PROCESSOR { public static class Chunk_Processor {
@Comment("Auto trim will not save chunks which aren't claimed") @Comment("Auto trim will not save chunks which aren't claimed")
public static boolean AUTO_TRIM = false; public static boolean AUTO_TRIM = false;
@Comment("Max tile entities per chunk") @Comment("Max tile entities per chunk")
@ -80,7 +195,7 @@ public class Settings extends Config {
} }
@Comment("Configure the paths PlotSquared will use") @Comment("Configure the paths PlotSquared will use")
public static final class PATHS { public static final class Paths {
public static String SCHEMATICS = "schematics"; public static String SCHEMATICS = "schematics";
public static String BO3 = "bo3"; public static String BO3 = "bo3";
public static String SCRIPTS = "scripts"; public static String SCRIPTS = "scripts";
@ -88,14 +203,14 @@ public class Settings extends Config {
public static String TRANSLATIONS = "translations"; public static String TRANSLATIONS = "translations";
} }
public static class WEB { public static class Web {
@Comment("We are already hosting a web interface for you:") @Comment("We are already hosting a web interface for you:")
public static String URL = "http://empcraft.com/plots/"; public static String URL = "http://empcraft.com/plots/";
@Comment("The ip that will show up in the interface") @Comment("The ip that will show up in the interface")
public static String SERVER_IP = "your.ip.here"; public static String SERVER_IP = "your.ip.here";
} }
public static final class DONE { public static final class Done {
@Comment("Require a done plot to download") @Comment("Require a done plot to download")
public static boolean REQUIRED_FOR_DOWNLOAD = false; public static boolean REQUIRED_FOR_DOWNLOAD = false;
@Comment("Only done plots can be rated") @Comment("Only done plots can be rated")
@ -106,7 +221,7 @@ public class Settings extends Config {
public static boolean COUNTS_TOWARDS_LIMIT = true; public static boolean COUNTS_TOWARDS_LIMIT = true;
} }
public static final class CHAT { public static final class Chat {
@Comment("Sometimes console color doesn't work, you can disable it here") @Comment("Sometimes console color doesn't work, you can disable it here")
public static boolean CONSOLE_COLOR = true; public static boolean CONSOLE_COLOR = true;
@Comment("Should chat be interactive") @Comment("Should chat be interactive")
@ -114,7 +229,7 @@ public class Settings extends Config {
} }
@Comment("Relating to how many plots someone can claim ") @Comment("Relating to how many plots someone can claim ")
public static final class LIMIT { public static final class Limit {
@Comment("Should the limit be global (over multiple worlds)") @Comment("Should the limit be global (over multiple worlds)")
public static boolean GLOBAL = false; public static boolean GLOBAL = false;
@Comment("The range of permissions to check e.g. plots.plot.127") @Comment("The range of permissions to check e.g. plots.plot.127")
@ -122,14 +237,14 @@ public class Settings extends Config {
} }
@Comment("Switching from PlotMe?") @Comment("Switching from PlotMe?")
public static final class PLOTME { public static final class PlotMe {
@Comment("Cache the uuids from the PlotMe database") @Comment("Cache the uuids from the PlotMe database")
public static boolean CACHE_UUDS = false; public static boolean CACHE_UUDS = false;
@Comment("Have `/plotme` as a command alias") @Comment("Have `/plotme` as a command alias")
public static boolean ALIAS = false; public static boolean ALIAS = false;
} }
public static final class TELEPORT { public static final class Teleport {
@Comment("Teleport to your plot on death") @Comment("Teleport to your plot on death")
public static boolean ON_DEATH = false; public static boolean ON_DEATH = false;
@Comment("Teleport to your plot on login") @Comment("Teleport to your plot on login")
@ -138,24 +253,28 @@ public class Settings extends Config {
public static int DELAY = 0; public static int DELAY = 0;
} }
public static final class REDSTONE { public static final class Redstone {
@Comment("Disable redstone in unoccupied plots") @Comment("Disable redstone in unoccupied plots")
public static boolean DISABLE_UNOCCUPIED = false; public static boolean DISABLE_UNOCCUPIED = false;
@Comment("Disable redstone when all owners/trusted/members are offline") @Comment("Disable redstone when all owners/trusted/members are offline")
public static boolean DISABLE_OFFLINE = false; public static boolean DISABLE_OFFLINE = false;
} }
public static final class CLAIM { /*
END OF CONFIGURATION SECTION:
*/
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;
} }
public static final class RATINGS { public static final class Ratings {
public static List<String> CATEGORIES = new ArrayList<>(); public static List<String> CATEGORIES = new ArrayList<>();
} }
@Comment({"Enable or disable part of the plugin","Note: A cache will use some memory if enabled"}) @Comment({"Enable or disable part of the plugin","Note: A cache will use some memory if enabled"})
public static final class ENABLED_COMPONENTS { // Group the following values into a new config section public static final class Enabled_Components { // Group the following values into a new config section
@Comment("The database stores all the plots") @Comment("The database stores all the plots")
public static boolean DATABASE = true; public static boolean DATABASE = true;
@Comment("Events are needed to track a lot of things") @Comment("Events are needed to track a lot of things")
@ -194,123 +313,4 @@ public class Settings extends Config {
@Comment("Delete plots when a player is banned") @Comment("Delete plots when a player is banned")
public static boolean BAN_DELETER = false; public static boolean BAN_DELETER = false;
} }
/*
END OF CONFIGURATION SECTION:
*/
public static void save(File file) {
save(file, Settings.class);
}
public static void load(File file) {
load(file, Settings.class);
}
public static boolean convertLegacy(File file) {
if (!file.exists()) {
return false;
}
YamlConfiguration config = YamlConfiguration.loadConfiguration(file);
// Protection
REDSTONE.DISABLE_OFFLINE = config.getBoolean("protection.redstone.disable-offline");
REDSTONE.DISABLE_UNOCCUPIED = config.getBoolean("protection.redstone.disable-unoccupied", REDSTONE.DISABLE_UNOCCUPIED);
// PlotMe
PLOTME.ALIAS = config.getBoolean("plotme-alias", PLOTME.ALIAS);
ENABLED_COMPONENTS.PLOTME_CONVERTER = config.getBoolean("plotme-convert.enabled", ENABLED_COMPONENTS.PLOTME_CONVERTER);
PLOTME.CACHE_UUDS = config.getBoolean("plotme-convert.cache-uuids", PLOTME.CACHE_UUDS);
// UUID
UUID.USE_SQLUUIDHANDLER = config.getBoolean("uuid.use_sqluuidhandler", UUID.USE_SQLUUIDHANDLER);
UUID.OFFLINE = config.getBoolean("UUID.offline", UUID.OFFLINE);
UUID.FORCE_LOWERCASE = config.getBoolean("UUID.force-lowercase", UUID.FORCE_LOWERCASE);
// Mob stuff
ENABLED_COMPONENTS.KILL_ROAD_MOBS = config.getBoolean("kill_road_mobs", ENABLED_COMPONENTS.KILL_ROAD_MOBS);
ENABLED_COMPONENTS.KILL_ROAD_VEHICLES = config.getBoolean("kill_road_vehicles", ENABLED_COMPONENTS.KILL_ROAD_VEHICLES);
// Clearing + Expiry
// FAST_CLEAR = config.getBoolean("clear.fastmode");
ENABLED_COMPONENTS.PLOT_EXPIRY = config.getBoolean("clear.auto.enabled", ENABLED_COMPONENTS.PLOT_EXPIRY);
if (ENABLED_COMPONENTS.PLOT_EXPIRY) {
ENABLED_COMPONENTS.BAN_DELETER = config.getBoolean("clear.on.ban");
AUTO_CLEAR = new ConfigBlock<>();
AUTO_CLEAR.put("task1", new AUTO_CLEAR());
AUTO_CLEAR task = AUTO_CLEAR.get("task1");
task.CALIBRATION = new AUTO_CLEAR.CALIBRATION();
task.DAYS = config.getInt("clear.auto.days", task.DAYS);
task.THRESHOLD = config.getInt("clear.auto.threshold", task.THRESHOLD);
task.CONFIRMATION = config.getBoolean("clear.auto.confirmation", task.CONFIRMATION);
task.CALIBRATION.CHANGES = config.getInt("clear.auto.calibration.changes", task.CALIBRATION.CHANGES);
task.CALIBRATION.FACES = config.getInt("clear.auto.calibration.faces", task.CALIBRATION.FACES);
task.CALIBRATION.DATA = config.getInt("clear.auto.calibration.data", task.CALIBRATION.DATA);
task.CALIBRATION.AIR = config.getInt("clear.auto.calibration.air", task.CALIBRATION.AIR);
task.CALIBRATION.VARIETY = config.getInt("clear.auto.calibration.variety", task.CALIBRATION.VARIETY);
task.CALIBRATION.CHANGES_SD = config.getInt("clear.auto.calibration.changes_sd", task.CALIBRATION.CHANGES_SD);
task.CALIBRATION.FACES_SD = config.getInt("clear.auto.calibration.faces_sd", task.CALIBRATION.FACES_SD);
task.CALIBRATION.DATA_SD = config.getInt("clear.auto.calibration.data_sd", task.CALIBRATION.DATA_SD);
task.CALIBRATION.AIR_SD = config.getInt("clear.auto.calibration.air_sd", task.CALIBRATION.AIR_SD);
task.CALIBRATION.VARIETY_SD = config.getInt("clear.auto.calibration.variety_sd", task.CALIBRATION.VARIETY_SD);
}
// Done
DONE.REQUIRED_FOR_RATINGS = config.getBoolean("approval.ratings.check-done", DONE.REQUIRED_FOR_RATINGS);
DONE.COUNTS_TOWARDS_LIMIT = config.getBoolean("approval.done.counts-towards-limit", DONE.COUNTS_TOWARDS_LIMIT);
DONE.RESTRICT_BUILDING = config.getBoolean("approval.done.restrict-building", DONE.RESTRICT_BUILDING);
DONE.REQUIRED_FOR_DOWNLOAD = config.getBoolean("approval.done.required-for-download", DONE.REQUIRED_FOR_DOWNLOAD);
// Schematics
PATHS.SCHEMATICS = config.getString("schematics.save_path", PATHS.SCHEMATICS);
PATHS.BO3 = config.getString("bo3.save_path", PATHS.BO3);
// Web
WEB.URL = config.getString("web.url", WEB.URL);
WEB.SERVER_IP = config.getString("web.server-ip", WEB.SERVER_IP);
// Caching
ENABLED_COMPONENTS.PERMISSION_CACHE = config.getBoolean("cache.permissions", ENABLED_COMPONENTS.PERMISSION_CACHE);
ENABLED_COMPONENTS.RATING_CACHE = config.getBoolean("cache.ratings", ENABLED_COMPONENTS.RATING_CACHE);
// Rating system
RATINGS.CATEGORIES = config.contains("ratings.categories") ? config.getStringList("ratings.categories") : RATINGS.CATEGORIES;
// Titles
TITLES = config.getBoolean("titles", TITLES);
// Teleportation
TELEPORT.DELAY = config.getInt("teleport.delay", TELEPORT.DELAY);
TELEPORT.ON_LOGIN = config.getBoolean("teleport.on_login", TELEPORT.ON_LOGIN);
TELEPORT.ON_DEATH = config.getBoolean("teleport.on_death", TELEPORT.ON_DEATH);
// WorldEdit
// WE_ALLOW_HELPER = config.getBoolean("worldedit.enable-for-helpers");
// Chunk processor
ENABLED_COMPONENTS.CHUNK_PROCESSOR = config.getBoolean("chunk-processor.enabled", ENABLED_COMPONENTS.CHUNK_PROCESSOR);
CHUNK_PROCESSOR.AUTO_TRIM = config.getBoolean("chunk-processor.auto-unload", CHUNK_PROCESSOR.AUTO_TRIM);
CHUNK_PROCESSOR.MAX_TILES = config.getInt("chunk-processor.max-blockstates", CHUNK_PROCESSOR.MAX_TILES);
CHUNK_PROCESSOR.MAX_ENTITIES = config.getInt("chunk-processor.max-entities", CHUNK_PROCESSOR.MAX_ENTITIES);
CHUNK_PROCESSOR.DISABLE_PHYSICS = config.getBoolean("chunk-processor.disable-physics", CHUNK_PROCESSOR.DISABLE_PHYSICS);
// Comments
ENABLED_COMPONENTS.COMMENT_NOTIFIER = config.getBoolean("comments.notifications.enabled", ENABLED_COMPONENTS.COMMENT_NOTIFIER);
// Plot limits
CLAIM.MAX_AUTO_AREA = config.getInt("claim.max-auto-area", CLAIM.MAX_AUTO_AREA);
LIMIT.MAX_PLOTS = config.getInt("max_plots", LIMIT.MAX_PLOTS);
LIMIT.GLOBAL = config.getBoolean("global_limit", LIMIT.GLOBAL);
// Misc
DEBUG = config.getBoolean("debug", DEBUG);
CHAT.CONSOLE_COLOR = config.getBoolean("console.color", CHAT.CONSOLE_COLOR);
CHAT.INTERACTIVE = config.getBoolean("chat.fancy", CHAT.INTERACTIVE);
ENABLED_COMPONENTS.METRICS = config.getBoolean("metrics", ENABLED_COMPONENTS.METRICS);
ENABLED_COMPONENTS.UPDATER = config.getBoolean("update-notifications", ENABLED_COMPONENTS.UPDATER);
ENABLED_COMPONENTS.DATABASE_PURGER = config.getBoolean("auto-purge", ENABLED_COMPONENTS.DATABASE_PURGER);
return true;
}
} }

View File

@ -4,25 +4,6 @@ import java.io.File;
public class Storage extends Config { public class Storage extends Config {
@Comment("MySQL section")
public static final class MYSQL {
@Comment("Should MySQL be used?")
public static boolean USE = false;
public static String HOST = "localhost";
public static String PORT = "3306";
public static String USER = "root";
public static String PASSWORD = "password";
public static String DATABASE = "plot_db";
}
@Comment("SQLite section")
public static final class SQLITE {
@Comment("Should SQLite be used?")
public static boolean USE = true;
@Comment("The file to use")
public static String DB = "storage";
}
public static final String PREFIX = ""; public static final String PREFIX = "";
public static void save(File file) { public static void save(File file) {
@ -33,4 +14,23 @@ public class Storage extends Config {
load(file, Storage.class); load(file, Storage.class);
} }
@Comment("MySQL section")
public static final class MySQL {
@Comment("Should MySQL be used?")
public static boolean USE = false;
public static String HOST = "localhost";
public static String PORT = "3306";
public static String USER = "root";
public static String PASSWORD = "password";
public static String DATABASE = "plot_db";
}
@Comment("SQLite section")
public static final class SQLite {
@Comment("Should SQLite be used?")
public static boolean USE = true;
@Comment("The file to use")
public static String DB = "storage";
}
} }

View File

@ -24,8 +24,8 @@ public interface AbstractDB {
/** /**
* Set Plot owner. * Set Plot owner.
* *
* @param plot Plot in which the owner should be set * @param plot the plot
* @param uuid The uuid of the new owner * @param uuid the uuid of the new owner
*/ */
void setOwner(Plot plot, UUID uuid); void setOwner(Plot plot, UUID uuid);
@ -33,14 +33,14 @@ public interface AbstractDB {
* Create all settings, and create default helpers, trusted + denied lists. * Create all settings, and create default helpers, trusted + denied lists.
* *
* @param plots Plots for which the default table entries should be created * @param plots Plots for which the default table entries should be created
* @param whenDone * @param whenDone the task to run when the method is finished executing
*/ */
void createPlotsAndData(List<Plot> plots, Runnable whenDone); void createPlotsAndData(List<Plot> plots, Runnable whenDone);
/** /**
* Create a plot * Create a plot.
* *
* @param plot That should be created * @param plot the plot to create
*/ */
void createPlot(Plot plot); void createPlot(Plot plot);
@ -54,7 +54,7 @@ public interface AbstractDB {
/** /**
* Delete a plot. * Delete a plot.
* *
* @param plot The plot to delete. * @param plot the plot to delete
*/ */
void delete(Plot plot); void delete(Plot plot);
@ -63,9 +63,17 @@ public interface AbstractDB {
void deleteHelpers(Plot plot); void deleteHelpers(Plot plot);
void deleteTrusted(Plot plot); void deleteTrusted(Plot plot);
/**
* Remove all denied players from the plot.
* @param plot the plot
*/
void deleteDenied(Plot plot); void deleteDenied(Plot plot);
/**
* Delete all comments from the plot.
* @param plot the plot
*/
void deleteComments(Plot plot); void deleteComments(Plot plot);
void deleteRatings(Plot plot); void deleteRatings(Plot plot);
@ -79,19 +87,19 @@ public interface AbstractDB {
void getPersistentMeta(UUID uuid, RunnableVal<Map<String, byte[]>> result); void getPersistentMeta(UUID uuid, RunnableVal<Map<String, byte[]>> result);
/** /**
* Create plot settings. * Create the plot settings.
* *
* @param id Plot Entry ID * @param id the plot entry id
* @param plot Plot Object * @param plot the plot
*/ */
void createPlotSettings(int id, Plot plot); void createPlotSettings(int id, Plot plot);
/** /**
* Get the table entry ID. * Get the table entry ID.
* *
* @param plot Plot Object * @param plot the plot
* *
* @return Integer = Plot Entry Id * @return {@code Integer} = Plot Entry Id
*/ */
int getId(Plot plot); int getId(Plot plot);
@ -138,7 +146,7 @@ public interface AbstractDB {
/** /**
* Set plot flags. * Set plot flags.
* @param plot Plot Object * @param plot Plot Object
* @param flags flags to set (flag[]) * @param flags flags to set
*/ */
void setFlags(Plot plot, HashMap<Flag<?>, Object> flags); void setFlags(Plot plot, HashMap<Flag<?>, Object> flags);
@ -149,9 +157,11 @@ public interface AbstractDB {
* @param flags flags to set (flag[]) * @param flags flags to set (flag[])
*/ */
void setFlags(PlotCluster cluster, HashMap<Flag<?>, Object> flags); void setFlags(PlotCluster cluster, HashMap<Flag<?>, Object> flags);
/** /**
* Rename a cluster. * Rename a cluster to the given name.
* @param cluster the cluster to rename
* @param name the new cluster name
*/ */
void setClusterName(PlotCluster cluster, String name); void setClusterName(PlotCluster cluster, String name);
@ -174,15 +184,15 @@ public interface AbstractDB {
* Purge a whole world. * Purge a whole world.
* *
* @param area World in which the plots should be purged * @param area World in which the plots should be purged
* @param plotIds * @param plotIds the {@code PlotId}s of {@code Plot}s to purge
*/ */
void purge(PlotArea area, Set<PlotId> plotIds); void purge(PlotArea area, Set<PlotId> plotIds);
/** /**
* Set Plot Home Position. * Set the plot home position.
* *
* @param plot Plot Object * @param plot the plot
* @param position Plot Home Position * @param position the position of plot home
*/ */
void setPosition(Plot plot, String position); void setPosition(Plot plot, String position);
@ -194,11 +204,12 @@ public interface AbstractDB {
void setPosition(PlotCluster cluster, String position); void setPosition(PlotCluster cluster, String position);
/** /**
* @param plot Plot Object * Remove the specified player from the trust list of the specified plot.
* @param uuid Player that should be removed * @param plot the plot
* @param uuid the uuid of the player to remove
*/ */
void removeTrusted(Plot plot, UUID uuid); void removeTrusted(Plot plot, UUID uuid);
/** /**
* @param cluster PlotCluster Object * @param cluster PlotCluster Object
* @param uuid Player that should be removed * @param uuid Player that should be removed
@ -206,7 +217,7 @@ public interface AbstractDB {
void removeHelper(PlotCluster cluster, UUID uuid); void removeHelper(PlotCluster cluster, UUID uuid);
/** /**
* @param plot Plot Object * @param plot the plot
* @param uuid Player that should be removed * @param uuid Player that should be removed
*/ */
void removeMember(Plot plot, UUID uuid); void removeMember(Plot plot, UUID uuid);
@ -242,25 +253,27 @@ public interface AbstractDB {
* @param uuid * @param uuid
*/ */
void setInvited(PlotCluster cluster, UUID uuid); void setInvited(PlotCluster cluster, UUID uuid);
/** /**
* @param plot Plot Object * Remove the specified player from the denied list of the specified plot.
* @param uuid Player uuid * @param plot the plot
* @param uuid the uuid of the player to remove
*/ */
void removeDenied(Plot plot, UUID uuid); void removeDenied(Plot plot, UUID uuid);
/** /**
* Deny the specified player from the given plot.
* @param plot the plot * @param plot the plot
* @param uuid the uuid of the player to deny * @param uuid the uuid of the player to deny
*/ */
void setDenied(Plot plot, UUID uuid); void setDenied(Plot plot, UUID uuid);
/** /**
* Get Plots ratings. * Get the ratings from the specified plot.
* *
* @param plot Plot Object * @param plot the plot
* *
* @return Plot Ratings (pre-calculated) * @return the plot ratings (pre-calculated)
*/ */
HashMap<UUID, Integer> getRatings(Plot plot); HashMap<UUID, Integer> getRatings(Plot plot);
@ -273,26 +286,26 @@ public interface AbstractDB {
void setRating(Plot plot, UUID rater, int value); void setRating(Plot plot, UUID rater, int value);
/** /**
* Remove a plot comment. * Remove the specified comment from the given plot.
* *
* @param plot Plot Object * @param plot the plot
* @param comment Comment to remove * @param comment the comment to remove
*/ */
void removeComment(Plot plot, PlotComment comment); void removeComment(Plot plot, PlotComment comment);
/** /**
* Clear an inbox. * Clear the specified inbox on the given plot.
* *
* @param plot * @param plot the plot
* @param inbox * @param inbox the inbox to clear
*/ */
void clearInbox(Plot plot, String inbox); void clearInbox(Plot plot, String inbox);
/** /**
* Set a plot comment. * Add the specified comment to the given plot.
* *
* @param plot Plot Object * @param plot the plot
* @param comment Comment to add * @param comment the comment to add
*/ */
void setComment(Plot plot, PlotComment comment); void setComment(Plot plot, PlotComment comment);
@ -328,7 +341,10 @@ public interface AbstractDB {
* @return true if the tables were deleted, false when an error is encountered * @return true if the tables were deleted, false when an error is encountered
*/ */
boolean deleteTables(); boolean deleteTables();
/**
* Close the database. Generally not recommended to be used by add-ons.
*/
void close(); void close();
void replaceWorld(String oldWorld, String newWorld, PlotId min, PlotId max); void replaceWorld(String oldWorld, String newWorld, PlotId min, PlotId max);

View File

@ -18,6 +18,7 @@ import com.intellectualcrafters.plot.object.comment.PlotComment;
import com.intellectualcrafters.plot.util.MainUtil; import com.intellectualcrafters.plot.util.MainUtil;
import com.intellectualcrafters.plot.util.StringMan; import com.intellectualcrafters.plot.util.StringMan;
import com.intellectualcrafters.plot.util.TaskManager; import com.intellectualcrafters.plot.util.TaskManager;
import java.sql.Connection; import java.sql.Connection;
import java.sql.DatabaseMetaData; import java.sql.DatabaseMetaData;
import java.sql.PreparedStatement; import java.sql.PreparedStatement;
@ -1321,7 +1322,7 @@ public class SQLManager implements AbstractDB {
@Override @Override
public void deleteRatings(final Plot plot) { public void deleteRatings(final Plot plot) {
if (Settings.ENABLED_COMPONENTS.RATING_CACHE && plot.getSettings().getRatings().isEmpty()) { if (Settings.Enabled_Components.RATING_CACHE && plot.getSettings().getRatings().isEmpty()) {
return; return;
} }
addPlotTask(plot, new UniqueStatement("delete_plot_ratings") { addPlotTask(plot, new UniqueStatement("delete_plot_ratings") {
@ -1479,7 +1480,7 @@ public class SQLManager implements AbstractDB {
rs.close(); rs.close();
try (Statement statement = this.connection.createStatement()) { try (Statement statement = this.connection.createStatement()) {
statement.addBatch("DROP TABLE `" + this.prefix + "plot_comments`"); statement.addBatch("DROP TABLE `" + this.prefix + "plot_comments`");
if (Storage.MYSQL.USE) { if (Storage.MySQL.USE) {
statement.addBatch("CREATE TABLE IF NOT EXISTS `" statement.addBatch("CREATE TABLE IF NOT EXISTS `"
+ this.prefix + this.prefix
+ "plot_comments` (" + "plot_comments` ("
@ -1625,7 +1626,7 @@ public class SQLManager implements AbstractDB {
id = resultSet.getInt("id"); id = resultSet.getInt("id");
String areaid = resultSet.getString("world"); String areaid = resultSet.getString("world");
if (!areas.contains(areaid)) { if (!areas.contains(areaid)) {
if (Settings.ENABLED_COMPONENTS.DATABASE_PURGER) { if (Settings.Enabled_Components.DATABASE_PURGER) {
toDelete.add(id); toDelete.add(id);
continue; continue;
} else { } else {
@ -1652,7 +1653,7 @@ public class SQLManager implements AbstractDB {
Plot last = map.put(p.getId(), p); Plot last = map.put(p.getId(), p);
if (last != null) { if (last != null) {
map.put(last.getId(), last); map.put(last.getId(), last);
if (Settings.ENABLED_COMPONENTS.DATABASE_PURGER) { if (Settings.Enabled_Components.DATABASE_PURGER) {
toDelete.add(id); toDelete.add(id);
} else { } else {
PS.debug("&cPLOT " + id + " in `" + this.prefix PS.debug("&cPLOT " + id + " in `" + this.prefix
@ -1669,7 +1670,7 @@ public class SQLManager implements AbstractDB {
} }
deleteRows(toDelete, this.prefix + "plot", "id"); deleteRows(toDelete, this.prefix + "plot", "id");
} }
if (Settings.ENABLED_COMPONENTS.RATING_CACHE) { if (Settings.Enabled_Components.RATING_CACHE) {
try (ResultSet r = statement.executeQuery("SELECT `plot_plot_id`, `player`, `rating` FROM `" + this.prefix + "plot_rating`")) { try (ResultSet r = statement.executeQuery("SELECT `plot_plot_id`, `player`, `rating` FROM `" + this.prefix + "plot_rating`")) {
ArrayList<Integer> toDelete = new ArrayList<>(); ArrayList<Integer> toDelete = new ArrayList<>();
while (r.next()) { while (r.next()) {
@ -1683,7 +1684,7 @@ public class SQLManager implements AbstractDB {
Plot plot = plots.get(id); Plot plot = plots.get(id);
if (plot != null) { if (plot != null) {
plot.getSettings().getRatings().put(user, r.getInt("rating")); plot.getSettings().getRatings().put(user, r.getInt("rating"));
} else if (Settings.ENABLED_COMPONENTS.DATABASE_PURGER) { } else if (Settings.Enabled_Components.DATABASE_PURGER) {
toDelete.add(id); toDelete.add(id);
} else { } else {
PS.debug("&cENTRY " + id + " in `plot_rating` does not exist. Create this plot or set `auto-purge: true` in the " PS.debug("&cENTRY " + id + " in `plot_rating` does not exist. Create this plot or set `auto-purge: true` in the "
@ -1710,7 +1711,7 @@ public class SQLManager implements AbstractDB {
Plot plot = plots.get(id); Plot plot = plots.get(id);
if (plot != null) { if (plot != null) {
plot.getTrusted().add(user); plot.getTrusted().add(user);
} else if (Settings.ENABLED_COMPONENTS.DATABASE_PURGER) { } else if (Settings.Enabled_Components.DATABASE_PURGER) {
toDelete.add(id); toDelete.add(id);
} else { } else {
PS.debug("&cENTRY " + id + " in `plot_helpers` does not exist. Create this plot or set `auto-purge: true` in the settings" PS.debug("&cENTRY " + id + " in `plot_helpers` does not exist. Create this plot or set `auto-purge: true` in the settings"
@ -1736,7 +1737,7 @@ public class SQLManager implements AbstractDB {
Plot plot = plots.get(id); Plot plot = plots.get(id);
if (plot != null) { if (plot != null) {
plot.getMembers().add(user); plot.getMembers().add(user);
} else if (Settings.ENABLED_COMPONENTS.DATABASE_PURGER) { } else if (Settings.Enabled_Components.DATABASE_PURGER) {
toDelete.add(id); toDelete.add(id);
} else { } else {
PS.debug("&cENTRY " + id + " in `plot_trusted` does not exist. Create this plot or set `auto-purge: true` in the settings" PS.debug("&cENTRY " + id + " in `plot_trusted` does not exist. Create this plot or set `auto-purge: true` in the settings"
@ -1762,7 +1763,7 @@ public class SQLManager implements AbstractDB {
Plot plot = plots.get(id); Plot plot = plots.get(id);
if (plot != null) { if (plot != null) {
plot.getDenied().add(user); plot.getDenied().add(user);
} else if (Settings.ENABLED_COMPONENTS.DATABASE_PURGER) { } else if (Settings.Enabled_Components.DATABASE_PURGER) {
toDelete.add(id); toDelete.add(id);
} else { } else {
PS.debug("&cENTRY " + id PS.debug("&cENTRY " + id
@ -1851,7 +1852,7 @@ public class SQLManager implements AbstractDB {
this.setFlags(plot, flags); this.setFlags(plot, flags);
} }
plot.getSettings().flags = flags; plot.getSettings().flags = flags;
} else if (Settings.ENABLED_COMPONENTS.DATABASE_PURGER) { } else if (Settings.Enabled_Components.DATABASE_PURGER) {
toDelete.add(id); toDelete.add(id);
} else { } else {
PS.debug( PS.debug(

View File

@ -30,7 +30,7 @@ public class HybridPlotManager extends ClassicPlotManager {
@Override @Override
public void exportTemplate(PlotArea plotArea) throws IOException { public void exportTemplate(PlotArea plotArea) throws IOException {
HashSet<FileBytes> files = new HashSet<>( HashSet<FileBytes> files = new HashSet<>(
Collections.singletonList(new FileBytes(Settings.PATHS.TEMPLATES + "/tmp-data.yml", Template.getBytes(plotArea)))); Collections.singletonList(new FileBytes(Settings.Paths.TEMPLATES + "/tmp-data.yml", Template.getBytes(plotArea))));
String dir = "schematics" + File.separator + "GEN_ROAD_SCHEMATIC" + File.separator + plotArea.worldname + File.separator; String dir = "schematics" + File.separator + "GEN_ROAD_SCHEMATIC" + File.separator + plotArea.worldname + File.separator;
String newDir = "schematics" + File.separator + "GEN_ROAD_SCHEMATIC" + File.separator + "__TEMP_DIR__" + File.separator; String newDir = "schematics" + File.separator + "GEN_ROAD_SCHEMATIC" + File.separator + "__TEMP_DIR__" + File.separator;
try { try {

View File

@ -59,7 +59,7 @@ public class BO3 {
} }
public File getFile() { public File getFile() {
return MainUtil.getFile(PS.get().IMP.getDirectory(), Settings.PATHS.BO3 + File.separator + getWorld() + File.separator + getFilename()); return MainUtil.getFile(PS.get().IMP.getDirectory(), Settings.Paths.BO3 + File.separator + getWorld() + File.separator + getFilename());
} }
public String getFilename() { public String getFilename() {

View File

@ -926,7 +926,7 @@ public class Plot {
* This will return null if the plot hasn't been analyzed * This will return null if the plot hasn't been analyzed
* @return analysis of plot * @return analysis of plot
*/ */
public PlotAnalysis getComplexity(Settings.AUTO_CLEAR settings) { public PlotAnalysis getComplexity(Settings.Auto_Clear settings) {
return PlotAnalysis.getAnalysis(this, settings); return PlotAnalysis.getAnalysis(this, settings);
} }
@ -1737,7 +1737,7 @@ public class Plot {
public void run() { public void run() {
String name = Plot.this.id + "," + Plot.this.area + ',' + MainUtil.getName(Plot.this.owner); String name = Plot.this.id + "," + Plot.this.area + ',' + MainUtil.getName(Plot.this.owner);
boolean result = boolean result =
SchematicHandler.manager.save(value, Settings.PATHS.SCHEMATICS + File.separator + name + ".schematic"); SchematicHandler.manager.save(value, Settings.Paths.SCHEMATICS + File.separator + name + ".schematic");
if (whenDone != null) { if (whenDone != null) {
whenDone.value = result; whenDone.value = result;
TaskManager.runTask(whenDone); TaskManager.runTask(whenDone);
@ -2549,12 +2549,12 @@ public class Plot {
} else { } else {
location = this.getDefaultHome(); location = this.getDefaultHome();
} }
if (Settings.TELEPORT.DELAY == 0 || Permissions.hasPermission(player, "plots.teleport.delay.bypass")) { if (Settings.Teleport.DELAY == 0 || Permissions.hasPermission(player, "plots.teleport.delay.bypass")) {
MainUtil.sendMessage(player, C.TELEPORTED_TO_PLOT); MainUtil.sendMessage(player, C.TELEPORTED_TO_PLOT);
player.teleport(location); player.teleport(location);
return true; return true;
} }
MainUtil.sendMessage(player, C.TELEPORT_IN_SECONDS, Settings.TELEPORT.DELAY + ""); MainUtil.sendMessage(player, C.TELEPORT_IN_SECONDS, Settings.Teleport.DELAY + "");
final String name = player.getName(); final String name = player.getName();
TaskManager.TELEPORT_QUEUE.add(name); TaskManager.TELEPORT_QUEUE.add(name);
TaskManager.runTaskLater(new Runnable() { TaskManager.runTaskLater(new Runnable() {
@ -2570,7 +2570,7 @@ public class Plot {
player.teleport(location); player.teleport(location);
} }
} }
}, Settings.TELEPORT.DELAY * 20); }, Settings.Teleport.DELAY * 20);
return true; return true;
} }
return false; return false;

View File

@ -491,7 +491,7 @@ public abstract class PlotArea {
} }
public int getPlotCount(UUID uuid) { public int getPlotCount(UUID uuid) {
if (!Settings.DONE.COUNTS_TOWARDS_LIMIT) { if (!Settings.Done.COUNTS_TOWARDS_LIMIT) {
int count = 0; int count = 0;
for (Plot plot : getPlotsAbs(uuid)) { for (Plot plot : getPlotsAbs(uuid)) {
if (!plot.hasFlag(Flags.DONE)) { if (!plot.hasFlag(Flags.DONE)) {

View File

@ -14,18 +14,17 @@ public class PlotBlock {
} }
} }
public static PlotBlock get(int id, int data) {
return Settings.ENABLED_COMPONENTS.BLOCK_CACHE && data > 0 ? CACHE[(id << 4) + data] : new PlotBlock((short) id, (byte) data);
}
public final short id; public final short id;
public final byte data; public final byte data;
public PlotBlock(short id, byte data) { public PlotBlock(short id, byte data) {
this.id = id; this.id = id;
this.data = data; this.data = data;
} }
public static PlotBlock get(int id, int data) {
return Settings.Enabled_Components.BLOCK_CACHE && data > 0 ? CACHE[(id << 4) + data] : new PlotBlock((short) id, (byte) data);
}
@Override @Override
public boolean equals(Object obj) { public boolean equals(Object obj) {
if (this == obj) { if (this == obj) {

View File

@ -1,8 +1,8 @@
package com.intellectualcrafters.plot.object; package com.intellectualcrafters.plot.object;
import com.intellectualcrafters.plot.commands.Template; import com.intellectualcrafters.plot.commands.Template;
import com.intellectualcrafters.plot.config.Settings; import com.intellectualcrafters.plot.config.Settings;
import java.io.IOException; import java.io.IOException;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.Collections; import java.util.Collections;
@ -69,7 +69,7 @@ public abstract class PlotManager {
public void exportTemplate(PlotArea plotArea) throws IOException { public void exportTemplate(PlotArea plotArea) throws IOException {
HashSet<FileBytes> files = new HashSet<>( HashSet<FileBytes> files = new HashSet<>(
Collections.singletonList(new FileBytes(Settings.PATHS.TEMPLATES + "/tmp-data.yml", Template.getBytes(plotArea)))); Collections.singletonList(new FileBytes(Settings.Paths.TEMPLATES + "/tmp-data.yml", Template.getBytes(plotArea))));
Template.zipAll(plotArea.worldname, files); Template.zipAll(plotArea.worldname, files);
} }

View File

@ -7,11 +7,11 @@ import com.intellectualcrafters.plot.database.DBFunc;
import com.intellectualcrafters.plot.flag.Flags; import com.intellectualcrafters.plot.flag.Flags;
import com.intellectualcrafters.plot.util.EconHandler; import com.intellectualcrafters.plot.util.EconHandler;
import com.intellectualcrafters.plot.util.EventUtil; import com.intellectualcrafters.plot.util.EventUtil;
import com.intellectualcrafters.plot.util.expiry.ExpireManager;
import com.intellectualcrafters.plot.util.Permissions; import com.intellectualcrafters.plot.util.Permissions;
import com.intellectualcrafters.plot.util.PlotGameMode; import com.intellectualcrafters.plot.util.PlotGameMode;
import com.intellectualcrafters.plot.util.PlotWeather; import com.intellectualcrafters.plot.util.PlotWeather;
import com.intellectualcrafters.plot.util.UUIDHandler; import com.intellectualcrafters.plot.util.UUIDHandler;
import com.intellectualcrafters.plot.util.expiry.ExpireManager;
import com.plotsquared.general.commands.CommandCaller; import com.plotsquared.general.commands.CommandCaller;
import java.util.HashMap; import java.util.HashMap;
@ -113,7 +113,7 @@ public abstract class PlotPlayer implements CommandCaller, OfflinePlotPlayer {
*/ */
public Plot getCurrentPlot() { public Plot getCurrentPlot() {
Plot value = (Plot) getMeta("lastplot"); Plot value = (Plot) getMeta("lastplot");
if (value == null && !Settings.ENABLED_COMPONENTS.EVENTS) { if (value == null && !Settings.Enabled_Components.EVENTS) {
return getLocation().getPlot(); return getLocation().getPlot();
} }
return value; return value;
@ -125,7 +125,7 @@ public abstract class PlotPlayer implements CommandCaller, OfflinePlotPlayer {
* @return number of allowed plots within the scope (globally, or in the player's current world as defined in the settings.yml) * @return number of allowed plots within the scope (globally, or in the player's current world as defined in the settings.yml)
*/ */
public int getAllowedPlots() { public int getAllowedPlots() {
return Permissions.hasPermissionRange(this, "plots.plot", Settings.LIMIT.MAX_PLOTS); return Permissions.hasPermissionRange(this, "plots.plot", Settings.Limit.MAX_PLOTS);
} }
/** /**
@ -137,7 +137,7 @@ public abstract class PlotPlayer implements CommandCaller, OfflinePlotPlayer {
* @return number of plots within the scope (globally, or in the player's current world as defined in the settings.yml) * @return number of plots within the scope (globally, or in the player's current world as defined in the settings.yml)
*/ */
public int getPlotCount() { public int getPlotCount() {
if (!Settings.LIMIT.GLOBAL) { if (!Settings.Limit.GLOBAL) {
return getPlotCount(getLocation().getWorld()); return getPlotCount(getLocation().getWorld());
} }
final AtomicInteger count = new AtomicInteger(0); final AtomicInteger count = new AtomicInteger(0);
@ -145,7 +145,7 @@ public abstract class PlotPlayer implements CommandCaller, OfflinePlotPlayer {
PS.get().foreachPlotArea(new RunnableVal<PlotArea>() { PS.get().foreachPlotArea(new RunnableVal<PlotArea>() {
@Override @Override
public void run(PlotArea value) { public void run(PlotArea value) {
if (!Settings.DONE.COUNTS_TOWARDS_LIMIT) { if (!Settings.Done.COUNTS_TOWARDS_LIMIT) {
for (Plot plot : value.getPlotsAbs(uuid)) { for (Plot plot : value.getPlotsAbs(uuid)) {
if (!plot.hasFlag(Flags.DONE)) { if (!plot.hasFlag(Flags.DONE)) {
count.incrementAndGet(); count.incrementAndGet();
@ -168,7 +168,7 @@ public abstract class PlotPlayer implements CommandCaller, OfflinePlotPlayer {
UUID uuid = getUUID(); UUID uuid = getUUID();
int count = 0; int count = 0;
for (PlotArea area : PS.get().getPlotAreas(world)) { for (PlotArea area : PS.get().getPlotAreas(world)) {
if (!Settings.DONE.COUNTS_TOWARDS_LIMIT) { if (!Settings.Done.COUNTS_TOWARDS_LIMIT) {
for (Plot plot : area.getPlotsAbs(uuid)) { for (Plot plot : area.getPlotsAbs(uuid)) {
if (!plot.getFlag(Flags.DONE).isPresent()) { if (!plot.getFlag(Flags.DONE).isPresent()) {
count++; count++;
@ -347,7 +347,7 @@ public abstract class PlotPlayer implements CommandCaller, OfflinePlotPlayer {
if (plot != null) { if (plot != null) {
EventUtil.manager.callLeave(this, plot); EventUtil.manager.callLeave(this, plot);
} }
if (Settings.ENABLED_COMPONENTS.BAN_DELETER && isBanned()) { if (Settings.Enabled_Components.BAN_DELETER && isBanned()) {
for (Plot owned : getPlots()) { for (Plot owned : getPlots()) {
owned.deletePlot(null); owned.deletePlot(null);
PS.debug(String.format("&cPlot &6%s &cwas deleted + cleared due to &6%s&c getting banned", plot.getId(), getName())); PS.debug(String.format("&cPlot &6%s &cwas deleted + cleared due to &6%s&c getting banned", plot.getId(), getName()));

View File

@ -18,15 +18,15 @@ public class Rating {
public Rating(int value) { public Rating(int value) {
this.initial = value; this.initial = value;
this.ratingMap = new HashMap<>(); this.ratingMap = new HashMap<>();
if (Settings.RATINGS.CATEGORIES != null && Settings.RATINGS.CATEGORIES.size() > 1) { if (Settings.Ratings.CATEGORIES != null && Settings.Ratings.CATEGORIES.size() > 1) {
if (value < 10) { if (value < 10) {
for (String ratingCategory : Settings.RATINGS.CATEGORIES) { for (String ratingCategory : Settings.Ratings.CATEGORIES) {
this.ratingMap.put(ratingCategory, value); this.ratingMap.put(ratingCategory, value);
} }
this.changed = true; this.changed = true;
return; return;
} }
for (String ratingCategory : Settings.RATINGS.CATEGORIES) { for (String ratingCategory : Settings.Ratings.CATEGORIES) {
this.ratingMap.put(ratingCategory, value % 10 - 1); this.ratingMap.put(ratingCategory, value % 10 - 1);
value = value / 10; value = value / 10;
} }
@ -66,10 +66,10 @@ public class Rating {
if (!this.changed) { if (!this.changed) {
return this.initial; return this.initial;
} }
if (Settings.RATINGS.CATEGORIES != null && Settings.RATINGS.CATEGORIES.size() > 1) { if (Settings.Ratings.CATEGORIES != null && Settings.Ratings.CATEGORIES.size() > 1) {
int val = 0; int val = 0;
for (int i = 0; i < Settings.RATINGS.CATEGORIES.size(); i++) { for (int i = 0; i < Settings.Ratings.CATEGORIES.size(); i++) {
val += (i + 1) * Math.pow(10, this.ratingMap.get(Settings.RATINGS.CATEGORIES.get(i))); val += (i + 1) * Math.pow(10, this.ratingMap.get(Settings.Ratings.CATEGORIES.get(i)));
} }
return val; return val;
} else { } else {

View File

@ -289,9 +289,9 @@ public class BO3Handler {
} }
public static File getBaseFile(String category) { public static File getBaseFile(String category) {
File base = MainUtil.getFile(PS.get().IMP.getDirectory(), Settings.PATHS.BO3 + File.separator + category + File.separator + "base.yml"); File base = MainUtil.getFile(PS.get().IMP.getDirectory(), Settings.Paths.BO3 + File.separator + category + File.separator + "base.yml");
if (!base.exists()) { if (!base.exists()) {
PS.get().copyFile("base.yml", Settings.PATHS.BO3 + File.separator + category); PS.get().copyFile("base.yml", Settings.Paths.BO3 + File.separator + category);
} }
return base; return base;
} }

View File

@ -21,7 +21,7 @@ public class CommentManager {
public static final HashMap<String, CommentInbox> inboxes = new HashMap<>(); public static final HashMap<String, CommentInbox> inboxes = new HashMap<>();
public static void sendTitle(final PlotPlayer player, final Plot plot) { public static void sendTitle(final PlotPlayer player, final Plot plot) {
if (!Settings.ENABLED_COMPONENTS.COMMENT_NOTIFIER || !plot.isOwner(player.getUUID())) { if (!Settings.Enabled_Components.COMMENT_NOTIFIER || !plot.isOwner(player.getUUID())) {
return; return;
} }
TaskManager.runTaskLaterAsync(new Runnable() { TaskManager.runTaskLaterAsync(new Runnable() {

View File

@ -67,11 +67,11 @@ public abstract class EventUtil {
MainUtil.sendMessage(player, C.WORLDEDIT_BYPASSED); MainUtil.sendMessage(player, C.WORLDEDIT_BYPASSED);
} }
} }
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, "&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();
if (Settings.TELEPORT.ON_LOGIN && plot != null) { if (Settings.Teleport.ON_LOGIN && plot != null) {
TaskManager.runTask(new Runnable() { TaskManager.runTask(new Runnable() {
@Override @Override
public void run() { public void run() {
@ -84,7 +84,7 @@ public abstract class EventUtil {
public void doRespawnTask(final PlotPlayer player) { public void doRespawnTask(final PlotPlayer player) {
final Plot plot = player.getCurrentPlot(); final Plot plot = player.getCurrentPlot();
if (Settings.TELEPORT.ON_DEATH && plot != null) { if (Settings.Teleport.ON_DEATH && plot != null) {
TaskManager.runTask(new Runnable() { TaskManager.runTask(new Runnable() {
@Override @Override
public void run() { public void run() {

View File

@ -10,7 +10,7 @@ import java.net.URL;
public class HttpUtil { public class HttpUtil {
public static String readUrl(String urlString) { public static String readUrl(String urlString) {
try (BufferedReader reader = new BufferedReader(new InputStreamReader(new URL(urlString).openStream()))){ try (BufferedReader reader = new BufferedReader(new InputStreamReader(new URL(urlString).openStream()))) {
StringBuilder buffer = new StringBuilder(); StringBuilder buffer = new StringBuilder();
int read; int read;
char[] chars = new char[1024]; char[] chars = new char[1024];

View File

@ -19,6 +19,7 @@ import com.intellectualcrafters.plot.object.PlotPlayer;
import com.intellectualcrafters.plot.object.PseudoRandom; import com.intellectualcrafters.plot.object.PseudoRandom;
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 java.io.File; import java.io.File;
import java.io.IOException; import java.io.IOException;
import java.io.OutputStream; import java.io.OutputStream;
@ -123,15 +124,15 @@ public class MainUtil {
final String website; final String website;
if (uuid == null) { if (uuid == null) {
uuid = UUID.randomUUID(); uuid = UUID.randomUUID();
website = Settings.WEB.URL + "upload.php?" + uuid; website = Settings.Web.URL + "upload.php?" + uuid;
filename = "plot." + extension; filename = "plot." + extension;
} else { } else {
website = Settings.WEB.URL + "save.php?" + uuid; website = Settings.Web.URL + "save.php?" + uuid;
filename = file + '.' + extension; filename = file + '.' + extension;
} }
final URL url; final URL url;
try { try {
url = new URL(Settings.WEB.URL + "?key=" + uuid + "&ip=" + Settings.WEB.SERVER_IP + "&type=" + extension); url = new URL(Settings.Web.URL + "?key=" + uuid + "&ip=" + Settings.Web.SERVER_IP + "&type=" + extension);
} catch (MalformedURLException e) { } catch (MalformedURLException e) {
e.printStackTrace(); e.printStackTrace();
whenDone.run(); whenDone.run();
@ -663,14 +664,14 @@ public class MainUtil {
HashMap<UUID, Integer> rating; HashMap<UUID, Integer> rating;
if (plot.getSettings().ratings != null) { if (plot.getSettings().ratings != null) {
rating = plot.getSettings().ratings; rating = plot.getSettings().ratings;
} else if (Settings.ENABLED_COMPONENTS.RATING_CACHE) { } else if (Settings.Enabled_Components.RATING_CACHE) {
rating = new HashMap<>(); rating = new HashMap<>();
} else { } else {
rating = DBFunc.getRatings(plot); rating = DBFunc.getRatings(plot);
} }
int size = 1; int size = 1;
if (!Settings.RATINGS.CATEGORIES.isEmpty()) { if (!Settings.Ratings.CATEGORIES.isEmpty()) {
size = Math.max(1, Settings.RATINGS.CATEGORIES.size()); size = Math.max(1, Settings.Ratings.CATEGORIES.size());
} }
double[] ratings = new double[size]; double[] ratings = new double[size];
if (rating == null || rating.isEmpty()) { if (rating == null || rating.isEmpty()) {
@ -678,10 +679,10 @@ public class MainUtil {
} }
for (Entry<UUID, Integer> entry : rating.entrySet()) { for (Entry<UUID, Integer> entry : rating.entrySet()) {
int current = entry.getValue(); int current = entry.getValue();
if (Settings.RATINGS.CATEGORIES.isEmpty()) { if (Settings.Ratings.CATEGORIES.isEmpty()) {
ratings[0] += current; ratings[0] += current;
} else { } else {
for (int i = 0; i < Settings.RATINGS.CATEGORIES.size(); i++) { for (int i = 0; i < Settings.Ratings.CATEGORIES.size(); i++) {
ratings[i] += current % 10 - 1; ratings[i] += current % 10 - 1;
current /= 10; current /= 10;
} }
@ -739,7 +740,7 @@ public class MainUtil {
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 expires = C.UNKNOWN.s();
if (Settings.ENABLED_COMPONENTS.PLOT_EXPIRY) { if (Settings.Enabled_Components.PLOT_EXPIRY) {
if (plot.hasOwner()) { if (plot.hasOwner()) {
Optional<?> keep = plot.getFlag(Flags.KEEP); Optional<?> keep = plot.getFlag(Flags.KEEP);
if (keep.isPresent()) { if (keep.isPresent()) {
@ -803,11 +804,11 @@ public class MainUtil {
@Override @Override
public void run() { public void run() {
int max = 10; int max = 10;
if (Settings.RATINGS.CATEGORIES != null && !Settings.RATINGS.CATEGORIES.isEmpty()) { if (Settings.Ratings.CATEGORIES != null && !Settings.Ratings.CATEGORIES.isEmpty()) {
max = 8; max = 8;
} }
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) { for (double v : ratings) {
@ -816,7 +817,7 @@ public class MainUtil {
String rating = ""; String rating = "";
String prefix = ""; String prefix = "";
for (int i = 0; i < ratings.length; i++) { for (int i = 0; i < ratings.length; i++) {
rating += prefix + Settings.RATINGS.CATEGORIES.get(i) + '=' + String.format("%.1f", ratings[i]); rating += prefix + Settings.Ratings.CATEGORIES.get(i) + '=' + String.format("%.1f", ratings[i]);
prefix = ","; prefix = ",";
} }
info = newInfo.replaceAll("%rating%", rating); info = newInfo.replaceAll("%rating%", rating);

View File

@ -31,7 +31,7 @@ public class Permissions {
* @return * @return
*/ */
public static boolean hasPermission(PlotPlayer player, String permission) { public static boolean hasPermission(PlotPlayer player, String permission) {
if (!Settings.ENABLED_COMPONENTS.PERMISSION_CACHE) { if (!Settings.Enabled_Components.PERMISSION_CACHE) {
return hasPermission((CommandCaller) player, permission); return hasPermission((CommandCaller) player, permission);
} }
HashMap<String, Boolean> map = player.getMeta("perm"); HashMap<String, Boolean> map = player.getMeta("perm");
@ -93,7 +93,7 @@ public class Permissions {
/** /**
* Check the the highest permission a PlotPlayer has within a specified range.<br> * Check the the highest permission a PlotPlayer has within a specified range.<br>
* - Excessively high values will lag<br> * - Excessively high values will lag<br>
* - The default range that is checked is {@link Settings#LIMIT#MAX_PLOTS}<br> * - The default range that is checked is {@link Settings.Limit#MAX_PLOTS}<br>
* @param player * @param player
* @param stub The permission stub to check e.g. for `plots.plot.#` the stub is `plots.plot` * @param stub The permission stub to check e.g. for `plots.plot.#` the stub is `plots.plot`
* @param range The range to check * @param range The range to check

View File

@ -87,7 +87,7 @@ public abstract class SchematicHandler {
} }
final String directory; final String directory;
if (outputDir == null) { if (outputDir == null) {
directory = Settings.PATHS.SCHEMATICS; directory = Settings.Paths.SCHEMATICS;
} else { } else {
directory = outputDir.getAbsolutePath(); directory = outputDir.getAbsolutePath();
} }
@ -451,14 +451,14 @@ public abstract class SchematicHandler {
* @return schematic if found, else null * @return schematic if found, else null
*/ */
public Schematic getSchematic(String name) { public Schematic getSchematic(String name) {
File parent = MainUtil.getFile(PS.get().IMP.getDirectory(), Settings.PATHS.SCHEMATICS); File parent = MainUtil.getFile(PS.get().IMP.getDirectory(), Settings.Paths.SCHEMATICS);
if (!parent.exists()) { if (!parent.exists()) {
if (!parent.mkdir()) { if (!parent.mkdir()) {
throw new RuntimeException("Could not create schematic parent directory"); throw new RuntimeException("Could not create schematic parent directory");
} }
} }
File file = MainUtil.getFile(PS.get().IMP.getDirectory(), File file = MainUtil.getFile(PS.get().IMP.getDirectory(),
Settings.PATHS.SCHEMATICS + File.separator + name + (name.endsWith(".schematic") ? "" : ".schematic")); Settings.Paths.SCHEMATICS + File.separator + name + (name.endsWith(".schematic") ? "" : ".schematic"));
return getSchematic(file); return getSchematic(file);
} }
@ -512,7 +512,7 @@ public abstract class SchematicHandler {
public List<String> getSaves(UUID uuid) { public List<String> getSaves(UUID uuid) {
StringBuilder rawJSON = new StringBuilder(); StringBuilder rawJSON = new StringBuilder();
try { try {
String website = Settings.WEB.URL + "list.php?" + uuid.toString(); String website = Settings.Web.URL + "list.php?" + uuid.toString();
URL url = new URL(website); URL url = new URL(website);
URLConnection connection = new URL(url.toString()).openConnection(); URLConnection connection = new URL(url.toString()).openConnection();
connection.setRequestProperty("User-Agent", "Mozilla/5.0"); connection.setRequestProperty("User-Agent", "Mozilla/5.0");

View File

@ -2,12 +2,13 @@ package com.intellectualcrafters.plot.util.expiry;
import com.intellectualcrafters.plot.config.Settings; import com.intellectualcrafters.plot.config.Settings;
import com.intellectualcrafters.plot.object.PlotArea; import com.intellectualcrafters.plot.object.PlotArea;
import java.util.concurrent.TimeUnit; import java.util.concurrent.TimeUnit;
public class ExpiryTask { public class ExpiryTask {
private final Settings.AUTO_CLEAR settings; private final Settings.Auto_Clear settings;
public ExpiryTask(Settings.AUTO_CLEAR settings) { public ExpiryTask(Settings.Auto_Clear settings) {
this.settings = settings; this.settings = settings;
} }

View File

@ -32,7 +32,7 @@ public class PlotAnalysis {
public int variety_sd; public int variety_sd;
private int complexity; private int complexity;
public static PlotAnalysis getAnalysis(Plot plot, Settings.AUTO_CLEAR settings) { public static PlotAnalysis getAnalysis(Plot plot, Settings.Auto_Clear settings) {
Optional<List<Integer>> flag = plot.getFlag(Flags.ANALYSIS); Optional<List<Integer>> flag = plot.getFlag(Flags.ANALYSIS);
if (flag.isPresent()) { if (flag.isPresent()) {
PlotAnalysis analysis = new PlotAnalysis(); PlotAnalysis analysis = new PlotAnalysis();
@ -207,7 +207,7 @@ public class PlotAnalysis {
PS.debug(" - The analyzed plots which were processed and put into bulk data will be compared and correlated to the plot ranking"); PS.debug(" - The analyzed plots which were processed and put into bulk data will be compared and correlated to the plot ranking");
PS.debug(" - The calculated correlation constant will then be used to calibrate the threshold for auto plot clearing"); PS.debug(" - The calculated correlation constant will then be used to calibrate the threshold for auto plot clearing");
Settings.AUTO_CLEAR settings = new Settings.AUTO_CLEAR(); Settings.Auto_Clear settings = new Settings.Auto_Clear();
int[] rankChanges = rank(changes); int[] rankChanges = rank(changes);
int[] sdChanges = getSD(rankChanges, rankRatings); int[] sdChanges = getSD(rankChanges, rankRatings);
@ -527,8 +527,8 @@ public class PlotAnalysis {
this.variety_sd); this.variety_sd);
} }
public int getComplexity(Settings.AUTO_CLEAR settings) { public int getComplexity(Settings.Auto_Clear settings) {
Settings.AUTO_CLEAR.CALIBRATION modifiers = settings.CALIBRATION; Settings.Auto_Clear.CALIBRATION modifiers = settings.CALIBRATION;
if (this.complexity != 0) { if (this.complexity != 0) {
return this.complexity; return this.complexity;
} }

View File

@ -14,7 +14,6 @@ import com.intellectualcrafters.plot.object.RunnableVal;
import com.intellectualcrafters.plot.util.AbstractTitle; import com.intellectualcrafters.plot.util.AbstractTitle;
import com.intellectualcrafters.plot.util.CommentManager; import com.intellectualcrafters.plot.util.CommentManager;
import com.intellectualcrafters.plot.util.EventUtil; import com.intellectualcrafters.plot.util.EventUtil;
import com.intellectualcrafters.plot.util.expiry.ExpireManager;
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.PlotGameMode; import com.intellectualcrafters.plot.util.PlotGameMode;
@ -22,6 +21,7 @@ import com.intellectualcrafters.plot.util.PlotWeather;
import com.intellectualcrafters.plot.util.StringMan; import com.intellectualcrafters.plot.util.StringMan;
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 com.intellectualcrafters.plot.util.expiry.ExpireManager;
import java.util.HashMap; import java.util.HashMap;
import java.util.Map; import java.util.Map;

View File

@ -14,6 +14,7 @@ import com.sk89q.worldedit.extent.Extent;
import com.sk89q.worldedit.extent.NullExtent; import com.sk89q.worldedit.extent.NullExtent;
import com.sk89q.worldedit.util.Location; import com.sk89q.worldedit.util.Location;
import com.sk89q.worldedit.world.biome.BaseBiome; import com.sk89q.worldedit.world.biome.BaseBiome;
import java.lang.reflect.Field; import java.lang.reflect.Field;
import java.util.HashSet; import java.util.HashSet;
@ -92,7 +93,7 @@ public class ProcessedWEExtent extends AbstractDelegateExtent {
return false; return false;
} }
this.BScount++; this.BScount++;
if (this.BScount > Settings.CHUNK_PROCESSOR.MAX_TILES) { if (this.BScount > Settings.Chunk_Processor.MAX_TILES) {
this.BSblocked = true; this.BSblocked = true;
PS.debug("&cPlotSquared detected unsafe WorldEdit: " + location.getBlockX() + "," + location.getBlockZ()); PS.debug("&cPlotSquared detected unsafe WorldEdit: " + location.getBlockX() + "," + location.getBlockZ());
} }
@ -243,7 +244,7 @@ public class ProcessedWEExtent extends AbstractDelegateExtent {
return null; return null;
} }
this.Ecount++; this.Ecount++;
if (this.Ecount > Settings.CHUNK_PROCESSOR.MAX_ENTITIES) { if (this.Ecount > Settings.Chunk_Processor.MAX_ENTITIES) {
this.Eblocked = true; this.Eblocked = true;
PS.debug("&cPlotSquared detected unsafe WorldEdit: " + location.getBlockX() + "," + location.getBlockZ()); PS.debug("&cPlotSquared detected unsafe WorldEdit: " + location.getBlockX() + "," + location.getBlockZ());
} }

View File

@ -9,6 +9,7 @@ import com.intellectualcrafters.plot.object.PlotArea;
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.sk89q.worldedit.blocks.BaseBlock; import com.sk89q.worldedit.blocks.BaseBlock;
import java.util.HashSet; import java.util.HashSet;
import java.util.UUID; import java.util.UUID;
@ -48,7 +49,7 @@ public class WEManager {
return regions; return regions;
} }
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"); boolean allowMember = player.hasPermission("plots.worldedit.member");

View File

@ -17,6 +17,7 @@ import com.sk89q.worldedit.util.Location;
import com.sk89q.worldedit.util.eventbus.EventHandler.Priority; import com.sk89q.worldedit.util.eventbus.EventHandler.Priority;
import com.sk89q.worldedit.util.eventbus.Subscribe; import com.sk89q.worldedit.util.eventbus.Subscribe;
import com.sk89q.worldedit.world.World; import com.sk89q.worldedit.world.World;
import java.util.HashSet; import java.util.HashSet;
public class WESubscriber { public class WESubscriber {
@ -61,7 +62,7 @@ public class WESubscriber {
return; return;
} }
} }
if (Settings.ENABLED_COMPONENTS.CHUNK_PROCESSOR) { if (Settings.Enabled_Components.CHUNK_PROCESSOR) {
if (PS.get().hasPlotArea(world)) { if (PS.get().hasPlotArea(world)) {
event.setExtent(new ProcessedWEExtent(world, mask, event.getMaxBlocks(), event.getExtent(), event.getExtent())); event.setExtent(new ProcessedWEExtent(world, mask, event.getMaxBlocks(), event.getExtent(), event.getExtent()));
} }

View File

@ -52,12 +52,6 @@ import com.plotsquared.sponge.util.block.SlowQueue;
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 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;
@ -74,7 +68,14 @@ import org.spongepowered.api.world.World;
import org.spongepowered.api.world.gen.GenerationPopulator; 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.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.3.3")
@ -134,7 +135,7 @@ public class SpongeMain implements IPlotMain {
@Override @Override
public void log(String message) { public void log(String message) {
message = C.format(message, C.replacements); message = C.format(message, C.replacements);
if (!Settings.CHAT.CONSOLE_COLOR) { if (!Settings.Chat.CONSOLE_COLOR) {
message = message.replaceAll('\u00a7' + "[a-z|0-9]", ""); message = message.replaceAll('\u00a7' + "[a-z|0-9]", "");
} }
if (this.server == null) { if (this.server == null) {

View File

@ -95,7 +95,7 @@ public class MainListener {
if (source == null) { if (source == null) {
return; return;
} }
if (Settings.PLOTME.ALIAS) { if (Settings.PlotMe.ALIAS) {
SpongeMain.THIS.getGame().getCommandManager().process(source, ("plots " + event.getArguments()).trim()); SpongeMain.THIS.getGame().getCommandManager().process(source, ("plots " + event.getArguments()).trim());
} else { } else {
source.sendMessage(SpongeUtil.getText(C.NOT_USING_PLOTME.s())); source.sendMessage(SpongeUtil.getText(C.NOT_USING_PLOTME.s()));