mirror of
https://github.com/IntellectualSites/PlotSquared.git
synced 2024-11-29 16:46:45 +01:00
Some minor stuff
This commit is contained in:
parent
5140d472ff
commit
555e8aaa6e
@ -21,38 +21,31 @@
|
|||||||
|
|
||||||
package com.intellectualcrafters.plot;
|
package com.intellectualcrafters.plot;
|
||||||
|
|
||||||
import java.io.File;
|
import com.intellectualcrafters.plot.commands.Auto;
|
||||||
import java.io.FileWriter;
|
import com.intellectualcrafters.plot.commands.MainCommand;
|
||||||
import java.io.IOException;
|
import com.intellectualcrafters.plot.config.C;
|
||||||
import java.sql.Connection;
|
import com.intellectualcrafters.plot.config.ConfigurationNode;
|
||||||
import java.sql.DatabaseMetaData;
|
import com.intellectualcrafters.plot.config.Settings;
|
||||||
import java.sql.ResultSet;
|
import com.intellectualcrafters.plot.database.*;
|
||||||
import java.sql.SQLException;
|
import com.intellectualcrafters.plot.events.PlayerTeleportToPlotEvent;
|
||||||
import java.util.ArrayList;
|
import com.intellectualcrafters.plot.events.PlotDeleteEvent;
|
||||||
import java.util.Arrays;
|
import com.intellectualcrafters.plot.flag.AbstractFlag;
|
||||||
import java.util.Collection;
|
import com.intellectualcrafters.plot.flag.FlagManager;
|
||||||
import java.util.Date;
|
import com.intellectualcrafters.plot.generator.DefaultPlotManager;
|
||||||
import java.util.HashMap;
|
import com.intellectualcrafters.plot.generator.DefaultPlotWorld;
|
||||||
import java.util.HashSet;
|
import com.intellectualcrafters.plot.generator.WorldGenerator;
|
||||||
import java.util.LinkedHashMap;
|
import com.intellectualcrafters.plot.listeners.*;
|
||||||
import java.util.LinkedHashSet;
|
import com.intellectualcrafters.plot.object.*;
|
||||||
import java.util.List;
|
import com.intellectualcrafters.plot.util.*;
|
||||||
import java.util.Map;
|
import com.intellectualcrafters.plot.util.Logger.LogLevel;
|
||||||
import java.util.Map.Entry;
|
import com.intellectualcrafters.plot.uuid.OfflineUUIDWrapper;
|
||||||
import java.util.Set;
|
import com.intellectualcrafters.plot.uuid.PlotUUIDSaver;
|
||||||
import java.util.UUID;
|
import com.intellectualcrafters.plot.uuid.UUIDSaver;
|
||||||
import java.util.concurrent.TimeUnit;
|
import com.sk89q.worldedit.bukkit.WorldEditPlugin;
|
||||||
|
import com.sk89q.worldguard.bukkit.WorldGuardPlugin;
|
||||||
import me.confuser.barapi.BarAPI;
|
import me.confuser.barapi.BarAPI;
|
||||||
import net.milkbowl.vault.economy.Economy;
|
import net.milkbowl.vault.economy.Economy;
|
||||||
|
import org.bukkit.*;
|
||||||
import org.bukkit.Bukkit;
|
|
||||||
import org.bukkit.ChatColor;
|
|
||||||
import org.bukkit.Chunk;
|
|
||||||
import org.bukkit.Location;
|
|
||||||
import org.bukkit.Material;
|
|
||||||
import org.bukkit.OfflinePlayer;
|
|
||||||
import org.bukkit.World;
|
|
||||||
import org.bukkit.command.PluginCommand;
|
import org.bukkit.command.PluginCommand;
|
||||||
import org.bukkit.configuration.file.YamlConfiguration;
|
import org.bukkit.configuration.file.YamlConfiguration;
|
||||||
import org.bukkit.entity.Entity;
|
import org.bukkit.entity.Entity;
|
||||||
@ -61,51 +54,16 @@ import org.bukkit.generator.ChunkGenerator;
|
|||||||
import org.bukkit.plugin.RegisteredServiceProvider;
|
import org.bukkit.plugin.RegisteredServiceProvider;
|
||||||
import org.bukkit.plugin.java.JavaPlugin;
|
import org.bukkit.plugin.java.JavaPlugin;
|
||||||
|
|
||||||
import com.intellectualcrafters.plot.commands.Auto;
|
import java.io.File;
|
||||||
import com.intellectualcrafters.plot.commands.MainCommand;
|
import java.io.FileWriter;
|
||||||
import com.intellectualcrafters.plot.config.C;
|
import java.io.IOException;
|
||||||
import com.intellectualcrafters.plot.config.ConfigurationNode;
|
import java.sql.Connection;
|
||||||
import com.intellectualcrafters.plot.config.Settings;
|
import java.sql.DatabaseMetaData;
|
||||||
import com.intellectualcrafters.plot.database.DBFunc;
|
import java.sql.ResultSet;
|
||||||
import com.intellectualcrafters.plot.database.MySQL;
|
import java.sql.SQLException;
|
||||||
import com.intellectualcrafters.plot.database.PlotMeConverter;
|
import java.util.*;
|
||||||
import com.intellectualcrafters.plot.database.SQLManager;
|
import java.util.Map.Entry;
|
||||||
import com.intellectualcrafters.plot.database.SQLite;
|
import java.util.concurrent.TimeUnit;
|
||||||
import com.intellectualcrafters.plot.events.PlayerTeleportToPlotEvent;
|
|
||||||
import com.intellectualcrafters.plot.events.PlotDeleteEvent;
|
|
||||||
import com.intellectualcrafters.plot.flag.AbstractFlag;
|
|
||||||
import com.intellectualcrafters.plot.flag.FlagManager;
|
|
||||||
import com.intellectualcrafters.plot.generator.DefaultPlotManager;
|
|
||||||
import com.intellectualcrafters.plot.generator.DefaultPlotWorld;
|
|
||||||
import com.intellectualcrafters.plot.generator.WorldGenerator;
|
|
||||||
import com.intellectualcrafters.plot.listeners.EntityListener;
|
|
||||||
import com.intellectualcrafters.plot.listeners.ForceFieldListener;
|
|
||||||
import com.intellectualcrafters.plot.listeners.InventoryListener;
|
|
||||||
import com.intellectualcrafters.plot.listeners.PlayerEvents;
|
|
||||||
import com.intellectualcrafters.plot.listeners.PlotListener;
|
|
||||||
import com.intellectualcrafters.plot.listeners.PlotPlusListener;
|
|
||||||
import com.intellectualcrafters.plot.listeners.WorldEditListener;
|
|
||||||
import com.intellectualcrafters.plot.listeners.WorldGuardListener;
|
|
||||||
import com.intellectualcrafters.plot.object.Plot;
|
|
||||||
import com.intellectualcrafters.plot.object.PlotGenerator;
|
|
||||||
import com.intellectualcrafters.plot.object.PlotId;
|
|
||||||
import com.intellectualcrafters.plot.object.PlotManager;
|
|
||||||
import com.intellectualcrafters.plot.object.PlotWorld;
|
|
||||||
import com.intellectualcrafters.plot.util.ConsoleColors;
|
|
||||||
import com.intellectualcrafters.plot.util.Lag;
|
|
||||||
import com.intellectualcrafters.plot.util.Logger;
|
|
||||||
import com.intellectualcrafters.plot.util.Logger.LogLevel;
|
|
||||||
import com.intellectualcrafters.plot.util.Metrics;
|
|
||||||
import com.intellectualcrafters.plot.util.PlayerFunctions;
|
|
||||||
import com.intellectualcrafters.plot.util.PlotHelper;
|
|
||||||
import com.intellectualcrafters.plot.util.SendChunk;
|
|
||||||
import com.intellectualcrafters.plot.util.SetBlockFast;
|
|
||||||
import com.intellectualcrafters.plot.util.UUIDHandler;
|
|
||||||
import com.intellectualcrafters.plot.uuid.OfflineUUIDWrapper;
|
|
||||||
import com.intellectualcrafters.plot.uuid.PlotUUIDSaver;
|
|
||||||
import com.intellectualcrafters.plot.uuid.UUIDSaver;
|
|
||||||
import com.sk89q.worldedit.bukkit.WorldEditPlugin;
|
|
||||||
import com.sk89q.worldguard.bukkit.WorldGuardPlugin;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* PlotMain class.
|
* PlotMain class.
|
||||||
@ -115,7 +73,7 @@ import com.sk89q.worldguard.bukkit.WorldGuardPlugin;
|
|||||||
*/
|
*/
|
||||||
@SuppressWarnings("unused")
|
@SuppressWarnings("unused")
|
||||||
public class PlotMain extends JavaPlugin {
|
public class PlotMain extends JavaPlugin {
|
||||||
private static PlotMain main = null;
|
|
||||||
/**
|
/**
|
||||||
* Permission that allows for "everything"
|
* Permission that allows for "everything"
|
||||||
*/
|
*/
|
||||||
@ -128,7 +86,6 @@ public class PlotMain extends JavaPlugin {
|
|||||||
* Boolean Flags (material)
|
* Boolean Flags (material)
|
||||||
*/
|
*/
|
||||||
public final static HashMap<Material, String> booleanFlags = new HashMap<>();
|
public final static HashMap<Material, String> booleanFlags = new HashMap<>();
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Initialize the material flags
|
* Initialize the material flags
|
||||||
*/
|
*/
|
||||||
@ -146,7 +103,6 @@ public class PlotMain extends JavaPlugin {
|
|||||||
booleanFlags.put(Material.DISPENSER, "dispenser");
|
booleanFlags.put(Material.DISPENSER, "dispenser");
|
||||||
booleanFlags.put(Material.DROPPER, "dropper");
|
booleanFlags.put(Material.DROPPER, "dropper");
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* All loaded plot worlds
|
* All loaded plot worlds
|
||||||
*/
|
*/
|
||||||
@ -199,6 +155,10 @@ public class PlotMain extends JavaPlugin {
|
|||||||
* Use Economy?
|
* Use Economy?
|
||||||
*/
|
*/
|
||||||
public static boolean useEconomy = false;
|
public static boolean useEconomy = false;
|
||||||
|
/**
|
||||||
|
* The instance
|
||||||
|
*/
|
||||||
|
private static PlotMain main = null;
|
||||||
/**
|
/**
|
||||||
* The UUID Saver
|
* The UUID Saver
|
||||||
*/
|
*/
|
||||||
@ -251,10 +211,7 @@ public class PlotMain extends JavaPlugin {
|
|||||||
* @return permitted range
|
* @return permitted range
|
||||||
*/
|
*/
|
||||||
public static int hasPermissionRange(final Player player, final String stub, final int range) {
|
public static int hasPermissionRange(final Player player, final String stub, final int range) {
|
||||||
if ((player == null) || player.isOp() || player.hasPermission(ADMIN_PERMISSION)) {
|
if (player == null || player.isOp() || player.hasPermission(ADMIN_PERMISSION) || player.hasPermission(stub + ".*")) {
|
||||||
return Byte.MAX_VALUE;
|
|
||||||
}
|
|
||||||
if (player.hasPermission(stub + ".*")) {
|
|
||||||
return Byte.MAX_VALUE;
|
return Byte.MAX_VALUE;
|
||||||
}
|
}
|
||||||
for (int i = range; i > 0; i--) {
|
for (int i = range; i > 0; i--) {
|
||||||
@ -411,7 +368,7 @@ public class PlotMain extends JavaPlugin {
|
|||||||
*/
|
*/
|
||||||
public static Set<Plot> getPlots(final World world, final Player player) {
|
public static Set<Plot> getPlots(final World world, final Player player) {
|
||||||
final UUID uuid = UUIDHandler.getUUID(player);
|
final UUID uuid = UUIDHandler.getUUID(player);
|
||||||
final ArrayList<Plot> myplots = new ArrayList<>();
|
final List<Plot> myplots = new ArrayList<>();
|
||||||
for (final Plot plot : getPlots(world).values()) {
|
for (final Plot plot : getPlots(world).values()) {
|
||||||
if (plot.hasOwner()) {
|
if (plot.hasOwner()) {
|
||||||
if (plot.getOwner().equals(uuid)) {
|
if (plot.getOwner().equals(uuid)) {
|
||||||
@ -703,6 +660,21 @@ public class PlotMain extends JavaPlugin {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Send a formatted message
|
||||||
|
* <p/>
|
||||||
|
* Replaced {0}, {1}...
|
||||||
|
*
|
||||||
|
* @param string To be formatted
|
||||||
|
* @param objs To replace with (using #toString())
|
||||||
|
*/
|
||||||
|
public static void sendConsoleSenderMessagef(String string, final Object... objs) {
|
||||||
|
for (int i = 0; i < objs.length; i++) {
|
||||||
|
string = string.replace("{" + i + "}", objs[i].toString());
|
||||||
|
}
|
||||||
|
sendConsoleSenderMessage(string);
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Teleport a player to a plot
|
* Teleport a player to a plot
|
||||||
*
|
*
|
||||||
@ -876,11 +848,22 @@ public class PlotMain extends JavaPlugin {
|
|||||||
settings.put("Schematics Save Path", "" + Settings.SCHEMATIC_SAVE_PATH);
|
settings.put("Schematics Save Path", "" + Settings.SCHEMATIC_SAVE_PATH);
|
||||||
settings.put("API Location", "" + Settings.API_URL);
|
settings.put("API Location", "" + Settings.API_URL);
|
||||||
for (final Entry<String, String> setting : settings.entrySet()) {
|
for (final Entry<String, String> setting : settings.entrySet()) {
|
||||||
sendConsoleSenderMessage(C.PREFIX.s() + String.format("&cKey: &6%s&c, Value: &6%s", setting.getKey(), setting.getValue()));
|
sendConsoleSenderMessagef("{0} &cKey: &6{1}&c, Value: &c{2}", C.PREFIX, setting.getKey(), setting.getValue());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get the instance
|
||||||
|
*
|
||||||
|
* @return instance
|
||||||
|
*/
|
||||||
|
public static PlotMain getInstance() {
|
||||||
|
if (main == null)
|
||||||
|
throw new UnsupportedOperationException("Cannot retrieve the PlotMain instance before it's created");
|
||||||
|
return main;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Kill all entities on roads
|
* Kill all entities on roads
|
||||||
*/
|
*/
|
||||||
@ -898,7 +881,7 @@ public class PlotMain extends JavaPlugin {
|
|||||||
public void run() {
|
public void run() {
|
||||||
if (this.ticked > 36_000L) {
|
if (this.ticked > 36_000L) {
|
||||||
this.ticked = 0l;
|
this.ticked = 0l;
|
||||||
sendConsoleSenderMessage(C.PREFIX.s() + "KillAllEntities has been running for 60 minutes. Errors: " + this.error);
|
sendConsoleSenderMessagef("{0} KillAllEntities has been running for 60 minutes. Errors: {1}", C.PREFIX, this.error);
|
||||||
this.error = 0l;
|
this.error = 0l;
|
||||||
}
|
}
|
||||||
for (final String w : getPlotWorlds()) {
|
for (final String w : getPlotWorlds()) {
|
||||||
@ -1423,21 +1406,21 @@ public class PlotMain extends JavaPlugin {
|
|||||||
* Set all plots
|
* Set all plots
|
||||||
*
|
*
|
||||||
* @param plots
|
* @param plots
|
||||||
* New Plot LinkedHashMap
|
* New Plot HashMap
|
||||||
*/
|
*/
|
||||||
public static void setAllPlotsRaw(final LinkedHashMap<String, HashMap<PlotId, Plot>> plots) {
|
public static void setAllPlotsRaw(final HashMap<String, HashMap<PlotId, Plot>> plots) {
|
||||||
PlotMain.plots = plots;
|
PlotMain.plots = new LinkedHashMap<>(plots);
|
||||||
|
// PlotMain.plots.putAll(plots);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Set all plots
|
* Set all plots
|
||||||
*
|
*
|
||||||
* @param plots
|
* @param plots
|
||||||
* New Plot HashMap
|
* New Plot LinkedHashMap
|
||||||
*/
|
*/
|
||||||
public static void setAllPlotsRaw(final HashMap<String, HashMap<PlotId, Plot>> plots) {
|
public static void setAllPlotsRaw(final LinkedHashMap<String, HashMap<PlotId, Plot>> plots) {
|
||||||
PlotMain.plots = new LinkedHashMap<>(plots);
|
PlotMain.plots = plots;
|
||||||
// PlotMain.plots.putAll(plots);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -1711,7 +1694,6 @@ public class PlotMain extends JavaPlugin {
|
|||||||
UUIDHandler.uuidWrapper = new OfflineUUIDWrapper();
|
UUIDHandler.uuidWrapper = new OfflineUUIDWrapper();
|
||||||
}
|
}
|
||||||
setUUIDSaver(new PlotUUIDSaver());
|
setUUIDSaver(new PlotUUIDSaver());
|
||||||
// Looks really cool xD
|
|
||||||
getUUIDSaver().globalPopulate();
|
getUUIDSaver().globalPopulate();
|
||||||
}
|
}
|
||||||
// Now we're finished :D
|
// Now we're finished :D
|
||||||
|
@ -21,15 +21,10 @@
|
|||||||
|
|
||||||
package com.intellectualcrafters.plot.config;
|
package com.intellectualcrafters.plot.config;
|
||||||
|
|
||||||
import org.bukkit.ChatColor;
|
|
||||||
|
|
||||||
import com.intellectualcrafters.plot.PlotMain;
|
import com.intellectualcrafters.plot.PlotMain;
|
||||||
import com.intellectualsites.translation.TranslationFile;
|
import com.intellectualsites.translation.*;
|
||||||
import com.intellectualsites.translation.TranslationLanguage;
|
|
||||||
import com.intellectualsites.translation.TranslationManager;
|
|
||||||
import com.intellectualsites.translation.TranslationObject;
|
|
||||||
import com.intellectualsites.translation.YamlTranslationFile;
|
|
||||||
import com.intellectualsites.translation.bukkit.BukkitTranslation;
|
import com.intellectualsites.translation.bukkit.BukkitTranslation;
|
||||||
|
import org.bukkit.ChatColor;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Captions class.
|
* Captions class.
|
||||||
@ -491,4 +486,9 @@ public enum C {
|
|||||||
public String translated() {
|
public String translated() {
|
||||||
return ChatColor.translateAlternateColorCodes('&', this.s());
|
return ChatColor.translateAlternateColorCodes('&', this.s());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String toString() {
|
||||||
|
return this.s();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user