mirror of
https://github.com/IntellectualSites/PlotSquared.git
synced 2024-11-12 10:24:07 +01:00
Starting to improve the translation system
This commit is contained in:
parent
82706e399c
commit
22caf11ab7
@ -21,36 +21,37 @@
|
|||||||
|
|
||||||
package com.intellectualcrafters.plot;
|
package com.intellectualcrafters.plot;
|
||||||
|
|
||||||
import java.io.File;
|
import com.intellectualcrafters.plot.commands.Buy;
|
||||||
import java.io.FileWriter;
|
import com.intellectualcrafters.plot.commands.Cluster;
|
||||||
import java.io.IOException;
|
import com.intellectualcrafters.plot.commands.MainCommand;
|
||||||
import java.sql.Connection;
|
import com.intellectualcrafters.plot.commands.WE_Anywhere;
|
||||||
import java.sql.DatabaseMetaData;
|
import com.intellectualcrafters.plot.config.C;
|
||||||
import java.sql.ResultSet;
|
import com.intellectualcrafters.plot.config.Configuration;
|
||||||
import java.sql.SQLException;
|
import com.intellectualcrafters.plot.config.ConfigurationNode;
|
||||||
import java.util.ArrayList;
|
import com.intellectualcrafters.plot.config.Settings;
|
||||||
import java.util.Arrays;
|
import com.intellectualcrafters.plot.database.*;
|
||||||
import java.util.Collection;
|
import com.intellectualcrafters.plot.events.PlayerTeleportToPlotEvent;
|
||||||
import java.util.Date;
|
import com.intellectualcrafters.plot.events.PlotDeleteEvent;
|
||||||
import java.util.HashMap;
|
import com.intellectualcrafters.plot.flag.AbstractFlag;
|
||||||
import java.util.HashSet;
|
import com.intellectualcrafters.plot.flag.FlagManager;
|
||||||
import java.util.LinkedHashMap;
|
import com.intellectualcrafters.plot.flag.FlagValue;
|
||||||
import java.util.LinkedHashSet;
|
import com.intellectualcrafters.plot.generator.AugmentedPopulator;
|
||||||
import java.util.List;
|
import com.intellectualcrafters.plot.generator.HybridGen;
|
||||||
import java.util.Map;
|
import com.intellectualcrafters.plot.generator.HybridPlotWorld;
|
||||||
import java.util.Map.Entry;
|
import com.intellectualcrafters.plot.listeners.*;
|
||||||
import java.util.Set;
|
import com.intellectualcrafters.plot.object.*;
|
||||||
import java.util.UUID;
|
import com.intellectualcrafters.plot.titles.AbstractTitle;
|
||||||
|
import com.intellectualcrafters.plot.titles.DefaultTitle;
|
||||||
|
import com.intellectualcrafters.plot.util.*;
|
||||||
|
import com.intellectualcrafters.plot.util.Logger.LogLevel;
|
||||||
|
import com.intellectualcrafters.plot.uuid.DefaultUUIDWrapper;
|
||||||
|
import com.intellectualcrafters.plot.uuid.OfflineUUIDWrapper;
|
||||||
|
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.Location;
|
||||||
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;
|
||||||
@ -64,64 +65,15 @@ import org.bukkit.plugin.Plugin;
|
|||||||
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.Buy;
|
import java.io.File;
|
||||||
import com.intellectualcrafters.plot.commands.Cluster;
|
import java.io.FileWriter;
|
||||||
import com.intellectualcrafters.plot.commands.MainCommand;
|
import java.io.IOException;
|
||||||
import com.intellectualcrafters.plot.commands.WE_Anywhere;
|
import java.sql.Connection;
|
||||||
import com.intellectualcrafters.plot.config.C;
|
import java.sql.DatabaseMetaData;
|
||||||
import com.intellectualcrafters.plot.config.Configuration;
|
import java.sql.ResultSet;
|
||||||
import com.intellectualcrafters.plot.config.ConfigurationNode;
|
import java.sql.SQLException;
|
||||||
import com.intellectualcrafters.plot.config.Settings;
|
import java.util.*;
|
||||||
import com.intellectualcrafters.plot.database.DBFunc;
|
import java.util.Map.Entry;
|
||||||
import com.intellectualcrafters.plot.database.MySQL;
|
|
||||||
import com.intellectualcrafters.plot.database.PlotMeConverter;
|
|
||||||
import com.intellectualcrafters.plot.database.SQLManager;
|
|
||||||
import com.intellectualcrafters.plot.database.SQLite;
|
|
||||||
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.flag.FlagValue;
|
|
||||||
import com.intellectualcrafters.plot.generator.AugmentedPopulator;
|
|
||||||
import com.intellectualcrafters.plot.generator.HybridGen;
|
|
||||||
import com.intellectualcrafters.plot.generator.HybridPlotWorld;
|
|
||||||
import com.intellectualcrafters.plot.listeners.ForceFieldListener;
|
|
||||||
import com.intellectualcrafters.plot.listeners.InventoryListener;
|
|
||||||
import com.intellectualcrafters.plot.listeners.PlayerEvents;
|
|
||||||
import com.intellectualcrafters.plot.listeners.PlayerEvents_1_8;
|
|
||||||
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.PlotBlock;
|
|
||||||
import com.intellectualcrafters.plot.object.PlotCluster;
|
|
||||||
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.titles.AbstractTitle;
|
|
||||||
import com.intellectualcrafters.plot.titles.DefaultTitle;
|
|
||||||
import com.intellectualcrafters.plot.util.AbstractSetBlock;
|
|
||||||
import com.intellectualcrafters.plot.util.ClusterManager;
|
|
||||||
import com.intellectualcrafters.plot.util.ConsoleColors;
|
|
||||||
import com.intellectualcrafters.plot.util.ExpireManager;
|
|
||||||
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.SetBlockFast_1_8;
|
|
||||||
import com.intellectualcrafters.plot.util.SetBlockSlow;
|
|
||||||
import com.intellectualcrafters.plot.util.TaskManager;
|
|
||||||
import com.intellectualcrafters.plot.util.UUIDHandler;
|
|
||||||
import com.intellectualcrafters.plot.uuid.DefaultUUIDWrapper;
|
|
||||||
import com.intellectualcrafters.plot.uuid.OfflineUUIDWrapper;
|
|
||||||
import com.sk89q.worldedit.bukkit.WorldEditPlugin;
|
|
||||||
import com.sk89q.worldguard.bukkit.WorldGuardPlugin;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* PlotMain class.
|
* PlotMain class.
|
||||||
@ -146,6 +98,11 @@ public class PlotMain extends JavaPlugin implements Listener {
|
|||||||
* All world managers
|
* All world managers
|
||||||
*/
|
*/
|
||||||
private final static HashMap<String, PlotManager> managers = new HashMap<>();
|
private final static HashMap<String, PlotManager> managers = new HashMap<>();
|
||||||
|
/**
|
||||||
|
* style
|
||||||
|
*/
|
||||||
|
public static File styleFile;
|
||||||
|
public static YamlConfiguration styleConfig;
|
||||||
/**
|
/**
|
||||||
* settings.properties
|
* settings.properties
|
||||||
*/
|
*/
|
||||||
@ -710,6 +667,19 @@ public class PlotMain extends JavaPlugin implements Listener {
|
|||||||
if (!folder.exists() && !folder.mkdirs()) {
|
if (!folder.exists() && !folder.mkdirs()) {
|
||||||
sendConsoleSenderMessage(C.PREFIX.s() + "&cFailed to create the /plugins/config folder. Please create it manually.");
|
sendConsoleSenderMessage(C.PREFIX.s() + "&cFailed to create the /plugins/config folder. Please create it manually.");
|
||||||
}
|
}
|
||||||
|
try {
|
||||||
|
styleFile = new File(getMain().getDataFolder() + File.separator + "translations" + File.separator + "style.yml");
|
||||||
|
if (!styleFile.exists()) {
|
||||||
|
if (!styleFile.createNewFile()) {
|
||||||
|
sendConsoleSenderMessage("Could not create the style file, please create \"translations/style.yml\" manually");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
styleConfig = YamlConfiguration.loadConfiguration(styleFile);
|
||||||
|
setupStyle();
|
||||||
|
} catch (final Exception err) {
|
||||||
|
Logger.add(LogLevel.DANGER, "Failed to save style.yml");
|
||||||
|
System.out.println("failed to save style.yml");
|
||||||
|
}
|
||||||
try {
|
try {
|
||||||
configFile = new File(getMain().getDataFolder() + File.separator + "config" + File.separator + "settings.yml");
|
configFile = new File(getMain().getDataFolder() + File.separator + "config" + File.separator + "settings.yml");
|
||||||
if (!configFile.exists()) {
|
if (!configFile.exists()) {
|
||||||
@ -737,6 +707,7 @@ public class PlotMain extends JavaPlugin implements Listener {
|
|||||||
System.out.println("Failed to save storage.yml");
|
System.out.println("Failed to save storage.yml");
|
||||||
}
|
}
|
||||||
try {
|
try {
|
||||||
|
styleConfig.save(styleFile);
|
||||||
config.save(configFile);
|
config.save(configFile);
|
||||||
storage.save(storageFile);
|
storage.save(storageFile);
|
||||||
} catch (final IOException e) {
|
} catch (final IOException e) {
|
||||||
@ -760,6 +731,11 @@ public class PlotMain extends JavaPlugin implements Listener {
|
|||||||
Settings.API_URL = config.getString("uuid.api.location");
|
Settings.API_URL = config.getString("uuid.api.location");
|
||||||
Settings.CUSTOM_API = config.getBoolean("uuid.api.custom");
|
Settings.CUSTOM_API = config.getBoolean("uuid.api.custom");
|
||||||
Settings.UUID_FECTHING = config.getBoolean("uuid.fetching");
|
Settings.UUID_FECTHING = config.getBoolean("uuid.fetching");
|
||||||
|
|
||||||
|
C.COLOR_1 = ChatColor.getByChar(styleConfig.getString("color.1"));
|
||||||
|
C.COLOR_2 = ChatColor.getByChar(styleConfig.getString("color.2"));
|
||||||
|
C.COLOR_3 = ChatColor.getByChar(styleConfig.getString("color.3"));
|
||||||
|
C.COLOR_4 = ChatColor.getByChar(styleConfig.getString("color.4"));
|
||||||
}
|
}
|
||||||
if (Settings.DEBUG) {
|
if (Settings.DEBUG) {
|
||||||
final Map<String, String> settings = new HashMap<>();
|
final Map<String, String> settings = new HashMap<>();
|
||||||
@ -931,24 +907,6 @@ public class PlotMain extends JavaPlugin implements Listener {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@EventHandler
|
|
||||||
public void PlayerCommand(PlayerCommandPreprocessEvent event) {
|
|
||||||
String message = event.getMessage();
|
|
||||||
if (message.toLowerCase().startsWith("/plotme")) {
|
|
||||||
Plugin plotme = Bukkit.getPluginManager().getPlugin("PlotMe");
|
|
||||||
if (plotme == null) {
|
|
||||||
Player player = event.getPlayer();
|
|
||||||
if (Settings.USE_PLOTME_ALIAS) {
|
|
||||||
player.performCommand(message.replace("/plotme", "plots"));
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
PlayerFunctions.sendMessage(player, C.NOT_USING_PLOTME);
|
|
||||||
}
|
|
||||||
event.setCancelled(true);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
@EventHandler
|
@EventHandler
|
||||||
public static void worldLoad(WorldLoadEvent event) {
|
public static void worldLoad(WorldLoadEvent event) {
|
||||||
if (!UUIDHandler.CACHED) {
|
if (!UUIDHandler.CACHED) {
|
||||||
@ -968,7 +926,7 @@ public class PlotMain extends JavaPlugin implements Listener {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void loadWorld(final String world, final ChunkGenerator generator) {
|
public static void loadWorld(final String world, final ChunkGenerator generator) {
|
||||||
if (getWorldSettings(world) != null) {
|
if (getWorldSettings(world) != null) {
|
||||||
return;
|
return;
|
||||||
@ -1015,22 +973,18 @@ public class PlotMain extends JavaPlugin implements Listener {
|
|||||||
Plugin gen_plugin = gen_string == null ? null : Bukkit.getPluginManager().getPlugin(gen_string);
|
Plugin gen_plugin = gen_string == null ? null : Bukkit.getPluginManager().getPlugin(gen_string);
|
||||||
if (gen_plugin != null && gen_plugin.isEnabled()) {
|
if (gen_plugin != null && gen_plugin.isEnabled()) {
|
||||||
gen_plugin.getDefaultWorldGenerator(world, "");
|
gen_plugin.getDefaultWorldGenerator(world, "");
|
||||||
}
|
} else {
|
||||||
else {
|
|
||||||
new HybridGen(world);
|
new HybridGen(world);
|
||||||
}
|
}
|
||||||
}
|
} catch (Exception e) {
|
||||||
catch (Exception e) {
|
|
||||||
PlotMain.sendConsoleSenderMessage("&d=== Oh no! Please set the generator for the " + world + " ===");
|
PlotMain.sendConsoleSenderMessage("&d=== Oh no! Please set the generator for the " + world + " ===");
|
||||||
e.printStackTrace();
|
e.printStackTrace();
|
||||||
LOADING_WORLD = false;
|
LOADING_WORLD = false;
|
||||||
removePlotWorld(world);
|
removePlotWorld(world);
|
||||||
}
|
} finally {
|
||||||
finally {
|
|
||||||
LOADING_WORLD = false;
|
LOADING_WORLD = false;
|
||||||
}
|
}
|
||||||
}
|
} else {
|
||||||
else {
|
|
||||||
PlotGenerator gen_class = (PlotGenerator) generator;
|
PlotGenerator gen_class = (PlotGenerator) generator;
|
||||||
plotWorld = gen_class.getNewPlotWorld(world);
|
plotWorld = gen_class.getNewPlotWorld(world);
|
||||||
plotManager = gen_class.getPlotManager();
|
plotManager = gen_class.getPlotManager();
|
||||||
@ -1057,14 +1011,13 @@ public class PlotMain extends JavaPlugin implements Listener {
|
|||||||
new AugmentedPopulator(world, gen_class, cluster, plotWorld.TERRAIN == 2, plotWorld.TERRAIN != 2);
|
new AugmentedPopulator(world, gen_class, cluster, plotWorld.TERRAIN == 2, plotWorld.TERRAIN != 2);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
} else if (plotWorld.TYPE == 1) {
|
||||||
else if (plotWorld.TYPE == 1) {
|
|
||||||
new AugmentedPopulator(world, gen_class, null, plotWorld.TERRAIN == 2, plotWorld.TERRAIN != 2);
|
new AugmentedPopulator(world, gen_class, null, plotWorld.TERRAIN == 2, plotWorld.TERRAIN != 2);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Adds an external world as a recognized PlotSquared world - The PlotWorld class created is based off the
|
* Adds an external world as a recognized PlotSquared world - The PlotWorld class created is based off the
|
||||||
* configuration in the settings.yml - Do not use this method unless the required world is preconfigured in the
|
* configuration in the settings.yml - Do not use this method unless the required world is preconfigured in the
|
||||||
@ -1080,6 +1033,20 @@ public class PlotMain extends JavaPlugin implements Listener {
|
|||||||
loadWorld(world.getName(), generator);
|
loadWorld(world.getName(), generator);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static void setupStyle() {
|
||||||
|
styleConfig.set("version", 0);
|
||||||
|
final Map<String, Object> o = new HashMap<>();
|
||||||
|
o.put("color.1", C.COLOR_1.getChar());
|
||||||
|
o.put("color.2", C.COLOR_2.getChar());
|
||||||
|
o.put("color.3", C.COLOR_3.getChar());
|
||||||
|
o.put("color.4", C.COLOR_4.getChar());
|
||||||
|
for (final Entry<String, Object> node : o.entrySet()) {
|
||||||
|
if (!styleConfig.contains(node.getKey())) {
|
||||||
|
styleConfig.set(node.getKey(), node.getValue());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* SETUP: storage.properties
|
* SETUP: storage.properties
|
||||||
*/
|
*/
|
||||||
@ -1120,27 +1087,27 @@ public class PlotMain extends JavaPlugin implements Listener {
|
|||||||
private static void defaultFlags() {
|
private static void defaultFlags() {
|
||||||
addPlusFlags();
|
addPlusFlags();
|
||||||
FlagManager.addFlag(new AbstractFlag("fly", new FlagValue.BooleanValue()));
|
FlagManager.addFlag(new AbstractFlag("fly", new FlagValue.BooleanValue()));
|
||||||
|
|
||||||
FlagManager.addFlag(new AbstractFlag("explosion", new FlagValue.BooleanValue()));
|
FlagManager.addFlag(new AbstractFlag("explosion", new FlagValue.BooleanValue()));
|
||||||
|
|
||||||
FlagManager.addFlag(new AbstractFlag("hostile-interact", new FlagValue.BooleanValue()));
|
FlagManager.addFlag(new AbstractFlag("hostile-interact", new FlagValue.BooleanValue()));
|
||||||
FlagManager.addFlag(new AbstractFlag("hostile-attack", new FlagValue.BooleanValue()));
|
FlagManager.addFlag(new AbstractFlag("hostile-attack", new FlagValue.BooleanValue()));
|
||||||
|
|
||||||
FlagManager.addFlag(new AbstractFlag("animal-interact", new FlagValue.BooleanValue()));
|
FlagManager.addFlag(new AbstractFlag("animal-interact", new FlagValue.BooleanValue()));
|
||||||
FlagManager.addFlag(new AbstractFlag("animal-attack", new FlagValue.BooleanValue()));
|
FlagManager.addFlag(new AbstractFlag("animal-attack", new FlagValue.BooleanValue()));
|
||||||
|
|
||||||
FlagManager.addFlag(new AbstractFlag("tamed-interact", new FlagValue.BooleanValue()));
|
FlagManager.addFlag(new AbstractFlag("tamed-interact", new FlagValue.BooleanValue()));
|
||||||
FlagManager.addFlag(new AbstractFlag("tamed-attack", new FlagValue.BooleanValue()));
|
FlagManager.addFlag(new AbstractFlag("tamed-attack", new FlagValue.BooleanValue()));
|
||||||
|
|
||||||
FlagManager.addFlag(new AbstractFlag("misc-interact", new FlagValue.BooleanValue()));
|
FlagManager.addFlag(new AbstractFlag("misc-interact", new FlagValue.BooleanValue()));
|
||||||
|
|
||||||
FlagManager.addFlag(new AbstractFlag("hanging-place", new FlagValue.BooleanValue()));
|
FlagManager.addFlag(new AbstractFlag("hanging-place", new FlagValue.BooleanValue()));
|
||||||
FlagManager.addFlag(new AbstractFlag("hanging-break", new FlagValue.BooleanValue()));
|
FlagManager.addFlag(new AbstractFlag("hanging-break", new FlagValue.BooleanValue()));
|
||||||
|
|
||||||
FlagManager.addFlag(new AbstractFlag("vehicle-use", new FlagValue.BooleanValue()));
|
FlagManager.addFlag(new AbstractFlag("vehicle-use", new FlagValue.BooleanValue()));
|
||||||
FlagManager.addFlag(new AbstractFlag("vehicle-place", new FlagValue.BooleanValue()));
|
FlagManager.addFlag(new AbstractFlag("vehicle-place", new FlagValue.BooleanValue()));
|
||||||
FlagManager.addFlag(new AbstractFlag("vehicle-break", new FlagValue.BooleanValue()));
|
FlagManager.addFlag(new AbstractFlag("vehicle-break", new FlagValue.BooleanValue()));
|
||||||
|
|
||||||
FlagManager.addFlag(new AbstractFlag("place", new FlagValue.PlotBlockListValue()));
|
FlagManager.addFlag(new AbstractFlag("place", new FlagValue.PlotBlockListValue()));
|
||||||
FlagManager.addFlag(new AbstractFlag("break", new FlagValue.PlotBlockListValue()));
|
FlagManager.addFlag(new AbstractFlag("break", new FlagValue.PlotBlockListValue()));
|
||||||
FlagManager.addFlag(new AbstractFlag("use", new FlagValue.PlotBlockListValue()));
|
FlagManager.addFlag(new AbstractFlag("use", new FlagValue.PlotBlockListValue()));
|
||||||
@ -1171,7 +1138,7 @@ public class PlotMain extends JavaPlugin implements Listener {
|
|||||||
return "Flag value must be a gamemode: 'creative' , 'survival' or 'adventure'";
|
return "Flag value must be a gamemode: 'creative' , 'survival' or 'adventure'";
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
FlagManager.addFlag(new AbstractFlag("price", new FlagValue.UnsignedDoubleValue()));
|
FlagManager.addFlag(new AbstractFlag("price", new FlagValue.UnsignedDoubleValue()));
|
||||||
|
|
||||||
FlagManager.addFlag(new AbstractFlag("time", new FlagValue.LongValue()));
|
FlagManager.addFlag(new AbstractFlag("time", new FlagValue.LongValue()));
|
||||||
@ -1225,11 +1192,11 @@ public class PlotMain extends JavaPlugin implements Listener {
|
|||||||
managers.remove(world);
|
managers.remove(world);
|
||||||
worlds.remove(world);
|
worlds.remove(world);
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void removePlots(final String world) {
|
public static void removePlots(final String world) {
|
||||||
plots.put(world, new HashMap<PlotId, Plot>());
|
plots.put(world, new HashMap<PlotId, Plot>());
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Get all plots
|
* Get all plots
|
||||||
*
|
*
|
||||||
@ -1239,6 +1206,15 @@ public class PlotMain extends JavaPlugin implements Listener {
|
|||||||
return plots;
|
return plots;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Set all plots
|
||||||
|
*
|
||||||
|
* @param plots New Plot LinkedHashMap
|
||||||
|
*/
|
||||||
|
public static void setAllPlotsRaw(final LinkedHashMap<String, HashMap<PlotId, Plot>> plots) {
|
||||||
|
PlotMain.plots = plots;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Set all plots
|
* Set all plots
|
||||||
*
|
*
|
||||||
@ -1249,13 +1225,39 @@ public class PlotMain extends JavaPlugin implements Listener {
|
|||||||
// PlotMain.plots.putAll(plots);
|
// PlotMain.plots.putAll(plots);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
public static boolean checkVersion(int major, int minor, int minor2) {
|
||||||
* Set all plots
|
try {
|
||||||
*
|
String[] version = Bukkit.getBukkitVersion().split("-")[0].split("\\.");
|
||||||
* @param plots New Plot LinkedHashMap
|
int a = Integer.parseInt(version[0]);
|
||||||
*/
|
int b = Integer.parseInt(version[1]);
|
||||||
public static void setAllPlotsRaw(final LinkedHashMap<String, HashMap<PlotId, Plot>> plots) {
|
int c = 0;
|
||||||
PlotMain.plots = plots;
|
if (version.length == 3) {
|
||||||
|
c = Integer.parseInt(version[2]);
|
||||||
|
}
|
||||||
|
if (a > major || (a == major && b > minor) || (a == major && b == minor && c >= minor2)) {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
return false;
|
||||||
|
} catch (Exception e) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@EventHandler
|
||||||
|
public void PlayerCommand(PlayerCommandPreprocessEvent event) {
|
||||||
|
String message = event.getMessage();
|
||||||
|
if (message.toLowerCase().startsWith("/plotme")) {
|
||||||
|
Plugin plotme = Bukkit.getPluginManager().getPlugin("PlotMe");
|
||||||
|
if (plotme == null) {
|
||||||
|
Player player = event.getPlayer();
|
||||||
|
if (Settings.USE_PLOTME_ALIAS) {
|
||||||
|
player.performCommand(message.replace("/plotme", "plots"));
|
||||||
|
} else {
|
||||||
|
PlayerFunctions.sendMessage(player, C.NOT_USING_PLOTME);
|
||||||
|
}
|
||||||
|
event.setCancelled(true);
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -1269,7 +1271,7 @@ public class PlotMain extends JavaPlugin implements Listener {
|
|||||||
// save configuration
|
// save configuration
|
||||||
String[] split = id.split(",");
|
String[] split = id.split(",");
|
||||||
HybridPlotWorld plotworld = new HybridPlotWorld(world);
|
HybridPlotWorld plotworld = new HybridPlotWorld(world);
|
||||||
|
|
||||||
int width = HybridPlotWorld.PLOT_WIDTH_DEFAULT;
|
int width = HybridPlotWorld.PLOT_WIDTH_DEFAULT;
|
||||||
int gap = HybridPlotWorld.ROAD_WIDTH_DEFAULT;
|
int gap = HybridPlotWorld.ROAD_WIDTH_DEFAULT;
|
||||||
int height = HybridPlotWorld.PLOT_HEIGHT_DEFAULT;
|
int height = HybridPlotWorld.PLOT_HEIGHT_DEFAULT;
|
||||||
@ -1277,7 +1279,7 @@ public class PlotMain extends JavaPlugin implements Listener {
|
|||||||
PlotBlock[] main = HybridPlotWorld.MAIN_BLOCK_DEFAULT;
|
PlotBlock[] main = HybridPlotWorld.MAIN_BLOCK_DEFAULT;
|
||||||
PlotBlock wall = HybridPlotWorld.WALL_FILLING_DEFAULT;
|
PlotBlock wall = HybridPlotWorld.WALL_FILLING_DEFAULT;
|
||||||
PlotBlock border = HybridPlotWorld.WALL_BLOCK_DEFAULT;
|
PlotBlock border = HybridPlotWorld.WALL_BLOCK_DEFAULT;
|
||||||
|
|
||||||
for (String element : split) {
|
for (String element : split) {
|
||||||
String[] pair = element.split("=");
|
String[] pair = element.split("=");
|
||||||
if (pair.length != 2) {
|
if (pair.length != 2) {
|
||||||
@ -1308,7 +1310,7 @@ public class PlotMain extends JavaPlugin implements Listener {
|
|||||||
case "f":
|
case "f":
|
||||||
case "floor": {
|
case "floor": {
|
||||||
HybridPlotWorld.TOP_BLOCK_DEFAULT = (PlotBlock[]) Configuration.BLOCKLIST.parseString(value);
|
HybridPlotWorld.TOP_BLOCK_DEFAULT = (PlotBlock[]) Configuration.BLOCKLIST.parseString(value);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
case "m":
|
case "m":
|
||||||
case "main": {
|
case "main": {
|
||||||
@ -1438,8 +1440,7 @@ public class PlotMain extends JavaPlugin implements Listener {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Add tables to this one, if we create more :D
|
// Add tables to this one, if we create more :D
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
// Use mysql?
|
// Use mysql?
|
||||||
if (Settings.DB.USE_MYSQL) {
|
if (Settings.DB.USE_MYSQL) {
|
||||||
@ -1529,7 +1530,7 @@ public class PlotMain extends JavaPlugin implements Listener {
|
|||||||
plotCommand.setAliases(Arrays.asList("p", "ps", "plotme", "plot"));
|
plotCommand.setAliases(Arrays.asList("p", "ps", "plotme", "plot"));
|
||||||
plotCommand.setTabCompleter(command);
|
plotCommand.setTabCompleter(command);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Main event handler
|
// Main event handler
|
||||||
getServer().getPluginManager().registerEvents(new PlayerEvents(), this);
|
getServer().getPluginManager().registerEvents(new PlayerEvents(), this);
|
||||||
if (checkVersion(1, 8, 0)) {
|
if (checkVersion(1, 8, 0)) {
|
||||||
@ -1652,25 +1653,6 @@ public class PlotMain extends JavaPlugin implements Listener {
|
|||||||
Broadcast(C.ENABLED);
|
Broadcast(C.ENABLED);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public static boolean checkVersion(int major, int minor, int minor2) {
|
|
||||||
try {
|
|
||||||
String[] version = Bukkit.getBukkitVersion().split("-")[0].split("\\.");
|
|
||||||
int a = Integer.parseInt(version[0]);
|
|
||||||
int b = Integer.parseInt(version[1]);
|
|
||||||
int c = 0;
|
|
||||||
if (version.length == 3) {
|
|
||||||
c = Integer.parseInt(version[2]);
|
|
||||||
}
|
|
||||||
if (a > major || (a == major && b > minor) || (a == major && b == minor && c >= minor2)) {
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
catch (Exception e) {
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* On unload
|
* On unload
|
||||||
|
@ -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.
|
||||||
@ -452,30 +447,32 @@ public enum C {
|
|||||||
* @see com.intellectualsites.translation.TranslationLanguage
|
* @see com.intellectualsites.translation.TranslationLanguage
|
||||||
*/
|
*/
|
||||||
protected final static TranslationLanguage lang = new TranslationLanguage("PlotSquared", "this", "use");
|
protected final static TranslationLanguage lang = new TranslationLanguage("PlotSquared", "this", "use");
|
||||||
|
public static ChatColor COLOR_1 = ChatColor.RED, COLOR_2 = ChatColor.YELLOW, COLOR_3 = ChatColor.AQUA, COLOR_4 = ChatColor.GRAY;
|
||||||
/**
|
/**
|
||||||
* The TranslationManager
|
* The TranslationManager
|
||||||
*
|
*
|
||||||
* @see com.intellectualsites.translation.TranslationManager
|
* @see com.intellectualsites.translation.TranslationManager
|
||||||
*/
|
*/
|
||||||
private static TranslationManager manager;
|
private static TranslationManager manager;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The default file
|
* The default file
|
||||||
*
|
*
|
||||||
* @see com.intellectualsites.translation.TranslationFile
|
* @see com.intellectualsites.translation.TranslationFile
|
||||||
*/
|
*/
|
||||||
private static TranslationFile defaultFile;
|
private static TranslationFile defaultFile;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Default
|
* Default
|
||||||
*/
|
*/
|
||||||
private String d;
|
private String d;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Translated
|
* Translated
|
||||||
*/
|
*/
|
||||||
private String s;
|
private String s;
|
||||||
|
/**
|
||||||
|
* Should the string be prefixed?
|
||||||
|
*/
|
||||||
|
private boolean prefix;
|
||||||
|
private ChatColor[] sColors = null;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Constructor for custom strings.
|
* Constructor for custom strings.
|
||||||
@ -490,12 +487,23 @@ public enum C {
|
|||||||
* Constructor
|
* Constructor
|
||||||
*
|
*
|
||||||
* @param d default
|
* @param d default
|
||||||
|
* @param prefix use prefix
|
||||||
*/
|
*/
|
||||||
C(final String d) {
|
C(final String d, final boolean prefix) {
|
||||||
this.d = d;
|
this.d = d;
|
||||||
if (this.s == null) {
|
if (this.s == null) {
|
||||||
this.s = "";
|
this.s = "";
|
||||||
}
|
}
|
||||||
|
this.prefix = prefix;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Constructor
|
||||||
|
*
|
||||||
|
* @param d default
|
||||||
|
*/
|
||||||
|
C(final String d) {
|
||||||
|
this(d, true);
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void setupTranslations() {
|
public static void setupTranslations() {
|
||||||
@ -530,7 +538,8 @@ public enum C {
|
|||||||
* @return translated if exists else default
|
* @return translated if exists else default
|
||||||
*/
|
*/
|
||||||
public String s() {
|
public String s() {
|
||||||
return manager.getTranslated(toString(), lang).getTranslated().replaceAll("&-", "\n").replaceAll("\\n", "\n");
|
String s = manager.getTranslated(toString(), lang).getTranslated().replaceAll("&-", "\n").replaceAll("\\n", "\n");
|
||||||
|
return s.replace("$1", COLOR_1.toString()).replace("$2", COLOR_2.toString()).replace("$3", COLOR_3.toString()).replace("$4", COLOR_4.toString());
|
||||||
/*
|
/*
|
||||||
* if (PlotMain.translations != null) {
|
* if (PlotMain.translations != null) {
|
||||||
* final String t = PlotMain.translations.getString(this.toString());
|
* final String t = PlotMain.translations.getString(this.toString());
|
||||||
@ -545,6 +554,10 @@ public enum C {
|
|||||||
*/
|
*/
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public boolean usePrefix() {
|
||||||
|
return this.prefix;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @return translated and color decoded
|
* @return translated and color decoded
|
||||||
*
|
*
|
||||||
|
@ -21,17 +21,6 @@
|
|||||||
|
|
||||||
package com.intellectualcrafters.plot.util;
|
package com.intellectualcrafters.plot.util;
|
||||||
|
|
||||||
import java.util.ArrayList;
|
|
||||||
import java.util.HashSet;
|
|
||||||
import java.util.Set;
|
|
||||||
import java.util.UUID;
|
|
||||||
|
|
||||||
import org.bukkit.ChatColor;
|
|
||||||
import org.bukkit.Location;
|
|
||||||
import org.bukkit.World;
|
|
||||||
import org.bukkit.entity.Player;
|
|
||||||
import org.bukkit.util.ChatPaginator;
|
|
||||||
|
|
||||||
import com.intellectualcrafters.plot.PlotMain;
|
import com.intellectualcrafters.plot.PlotMain;
|
||||||
import com.intellectualcrafters.plot.config.C;
|
import com.intellectualcrafters.plot.config.C;
|
||||||
import com.intellectualcrafters.plot.config.Settings;
|
import com.intellectualcrafters.plot.config.Settings;
|
||||||
@ -39,6 +28,16 @@ import com.intellectualcrafters.plot.object.Plot;
|
|||||||
import com.intellectualcrafters.plot.object.PlotId;
|
import com.intellectualcrafters.plot.object.PlotId;
|
||||||
import com.intellectualcrafters.plot.object.PlotManager;
|
import com.intellectualcrafters.plot.object.PlotManager;
|
||||||
import com.intellectualcrafters.plot.object.PlotWorld;
|
import com.intellectualcrafters.plot.object.PlotWorld;
|
||||||
|
import org.bukkit.ChatColor;
|
||||||
|
import org.bukkit.Location;
|
||||||
|
import org.bukkit.World;
|
||||||
|
import org.bukkit.entity.Player;
|
||||||
|
import org.bukkit.util.ChatPaginator;
|
||||||
|
|
||||||
|
import java.util.ArrayList;
|
||||||
|
import java.util.HashSet;
|
||||||
|
import java.util.Set;
|
||||||
|
import java.util.UUID;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Functions involving players, plots and locations.
|
* Functions involving players, plots and locations.
|
||||||
@ -275,6 +274,10 @@ import com.intellectualcrafters.plot.object.PlotWorld;
|
|||||||
* @return true Can be used in things such as commands (return PlayerFunctions.sendMessage(...))
|
* @return true Can be used in things such as commands (return PlayerFunctions.sendMessage(...))
|
||||||
*/
|
*/
|
||||||
public static boolean sendMessage(final Player plr, final String msg) {
|
public static boolean sendMessage(final Player plr, final String msg) {
|
||||||
|
return sendMessage(plr, msg, true);
|
||||||
|
}
|
||||||
|
|
||||||
|
public static boolean sendMessage(final Player plr, final String msg, final boolean prefix) {
|
||||||
if ((msg.length() > 0) && !msg.equals("")) {
|
if ((msg.length() > 0) && !msg.equals("")) {
|
||||||
if (plr == null) {
|
if (plr == null) {
|
||||||
PlotMain.sendConsoleSenderMessage(C.PREFIX.s() + msg);
|
PlotMain.sendConsoleSenderMessage(C.PREFIX.s() + msg);
|
||||||
@ -283,17 +286,6 @@ import com.intellectualcrafters.plot.object.PlotWorld;
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
return true;
|
return true;
|
||||||
/*
|
|
||||||
* if ((msg.length() == 0) || msg.equalsIgnoreCase("")) {
|
|
||||||
* return ;
|
|
||||||
* }
|
|
||||||
* if (plr == null) {
|
|
||||||
* PlotMain.sendConsoleSenderMessage(C.PREFIX.s() + msg);
|
|
||||||
* return;
|
|
||||||
* }
|
|
||||||
* sendMessageWrapped(plr, ChatColor.translateAlternateColorCodes('&',
|
|
||||||
* C.PREFIX.s() + msg));
|
|
||||||
*/
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -318,30 +310,9 @@ import com.intellectualcrafters.plot.object.PlotWorld;
|
|||||||
PlotMain.sendConsoleSenderMessage(msg);
|
PlotMain.sendConsoleSenderMessage(msg);
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
sendMessage(plr, msg);
|
sendMessage(plr, msg, c.usePrefix());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return true;
|
return true;
|
||||||
/*
|
|
||||||
* if (plr == null) {
|
|
||||||
* PlotMain.sendConsoleSenderMessage(c);
|
|
||||||
* return;
|
|
||||||
* }
|
|
||||||
* >>>>>>> origin/master
|
|
||||||
* if (c.s().length() < 1) {
|
|
||||||
* return;
|
|
||||||
* }
|
|
||||||
* String msg = c.s();
|
|
||||||
* if ((args != null) && (args.length > 0)) {
|
|
||||||
* for (final String str : args) {
|
|
||||||
* msg = msg.replaceFirst("%s", str);
|
|
||||||
* }
|
|
||||||
* }
|
|
||||||
* if (plr == null) {
|
|
||||||
* PlotMain.sendConsoleSenderMessage(c);
|
|
||||||
* return;
|
|
||||||
* }
|
|
||||||
* sendMessage(plr, msg);
|
|
||||||
*/
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user