mirror of
https://github.com/IntellectualSites/PlotSquared.git
synced 2024-11-26 07:06:44 +01:00
Nothing is implemented, but it can compile and "run" on sponge now.
This commit is contained in:
parent
904b75a7cd
commit
89e3bd97f0
@ -5,8 +5,7 @@ import com.intellectualcrafters.plot.generator.HybridUtils;
|
|||||||
import com.intellectualcrafters.plot.generator.PlotGenerator;
|
import com.intellectualcrafters.plot.generator.PlotGenerator;
|
||||||
import com.intellectualcrafters.plot.object.PlotPlayer;
|
import com.intellectualcrafters.plot.object.PlotPlayer;
|
||||||
import com.intellectualcrafters.plot.util.*;
|
import com.intellectualcrafters.plot.util.*;
|
||||||
import com.plotsquared.bukkit.listeners.APlotListener;
|
import com.plotsquared.listener.APlotListener;
|
||||||
import com.plotsquared.bukkit.util.SetupUtils;
|
|
||||||
|
|
||||||
import java.io.File;
|
import java.io.File;
|
||||||
import java.util.UUID;
|
import java.util.UUID;
|
||||||
|
@ -12,9 +12,7 @@ import com.intellectualcrafters.plot.flag.FlagValue;
|
|||||||
import com.intellectualcrafters.plot.generator.*;
|
import com.intellectualcrafters.plot.generator.*;
|
||||||
import com.intellectualcrafters.plot.object.*;
|
import com.intellectualcrafters.plot.object.*;
|
||||||
import com.intellectualcrafters.plot.util.*;
|
import com.intellectualcrafters.plot.util.*;
|
||||||
import com.plotsquared.bukkit.listeners.APlotListener;
|
import com.plotsquared.listener.APlotListener;
|
||||||
import com.plotsquared.bukkit.object.comment.CommentManager;
|
|
||||||
import com.plotsquared.bukkit.util.SetupUtils;
|
|
||||||
import com.sk89q.worldedit.bukkit.WorldEditPlugin;
|
import com.sk89q.worldedit.bukkit.WorldEditPlugin;
|
||||||
|
|
||||||
import java.io.*;
|
import java.io.*;
|
||||||
@ -73,12 +71,15 @@ public class PS {
|
|||||||
* @param imp_class
|
* @param imp_class
|
||||||
*/
|
*/
|
||||||
public PS(final IPlotMain imp_class) {
|
public PS(final IPlotMain imp_class) {
|
||||||
|
try {
|
||||||
instance = this;
|
instance = this;
|
||||||
SetupUtils.generators = new HashMap<>();
|
SetupUtils.generators = new HashMap<>();
|
||||||
IMP = imp_class;
|
IMP = imp_class;
|
||||||
try {
|
try {
|
||||||
FILE = new File(PS.class.getProtectionDomain().getCodeSource().getLocation().toURI().getPath());
|
FILE = new File(PS.class.getProtectionDomain().getCodeSource().getLocation().toURI().getPath());
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
|
FILE = new File(IMP.getDirectory().getParentFile(), "PlotSquared.jar");
|
||||||
|
e.printStackTrace();
|
||||||
log("Could not determine file path");
|
log("Could not determine file path");
|
||||||
}
|
}
|
||||||
VERSION = IMP.getPluginVersion();
|
VERSION = IMP.getPluginVersion();
|
||||||
@ -129,7 +130,7 @@ public class PS {
|
|||||||
}
|
}
|
||||||
// create UUIDWrapper
|
// create UUIDWrapper
|
||||||
UUIDHandler.implementation = IMP.initUUIDHandler();
|
UUIDHandler.implementation = IMP.initUUIDHandler();
|
||||||
UUIDHandler.implementation.startCaching(null); // TODO maybe a notification when this is done?
|
UUIDHandler.startCaching(null); // TODO maybe a notification when this is done?
|
||||||
// create event util class
|
// create event util class
|
||||||
EventUtil.manager = IMP.initEventUtil();
|
EventUtil.manager = IMP.initEventUtil();
|
||||||
// create Hybrid utility class
|
// create Hybrid utility class
|
||||||
@ -158,7 +159,7 @@ public class PS {
|
|||||||
log("&8 - &3Use: &7/plot update");
|
log("&8 - &3Use: &7/plot update");
|
||||||
log("&8 - &3Or: &7" + url);
|
log("&8 - &3Or: &7" + url);
|
||||||
}
|
}
|
||||||
else if (LAST_VERSION != null && !VERSION.equals(LAST_VERSION)) {
|
else if (LAST_VERSION != null && !StringMan.join(VERSION,".").equals(LAST_VERSION)) {
|
||||||
log("&aThanks for updating from: " + LAST_VERSION + " to " + StringMan.join(VERSION, "."));
|
log("&aThanks for updating from: " + LAST_VERSION + " to " + StringMan.join(VERSION, "."));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -204,6 +205,10 @@ public class PS {
|
|||||||
copyFile("italian.yml", "translations");
|
copyFile("italian.yml", "translations");
|
||||||
showDebug();
|
showDebug();
|
||||||
}
|
}
|
||||||
|
catch (Throwable e) {
|
||||||
|
e.printStackTrace();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
public boolean checkVersion(int[] version, int major, int minor, int minor2) {
|
public boolean checkVersion(int[] version, int major, int minor, int minor2) {
|
||||||
return (version[0] > major) || ((version[0] == major) && (version[1] > minor)) || ((version[0] == major) && (version[1] == minor) && (version[2] >= minor2));
|
return (version[0] > major) || ((version[0] == major) && (version[1] > minor)) || ((version[0] == major) && (version[1] == minor) && (version[2] >= minor2));
|
||||||
@ -1260,7 +1265,7 @@ public class PS {
|
|||||||
*/
|
*/
|
||||||
public void setupConfig() {
|
public void setupConfig() {
|
||||||
LAST_VERSION = config.getString("version");
|
LAST_VERSION = config.getString("version");
|
||||||
config.set("version", VERSION);
|
config.set("version", StringMan.join(VERSION,"."));
|
||||||
|
|
||||||
final Map<String, Object> options = new HashMap<>();
|
final Map<String, Object> options = new HashMap<>();
|
||||||
// Command confirmation
|
// Command confirmation
|
||||||
@ -1553,7 +1558,7 @@ public class PS {
|
|||||||
* Setup the storage file (load + save missing nodes)
|
* Setup the storage file (load + save missing nodes)
|
||||||
*/
|
*/
|
||||||
private void setupStorage() {
|
private void setupStorage() {
|
||||||
storage.set("version", VERSION);
|
storage.set("version", StringMan.join(VERSION,"."));
|
||||||
final Map<String, Object> options = new HashMap<>();
|
final Map<String, Object> options = new HashMap<>();
|
||||||
options.put("mysql.use", false);
|
options.put("mysql.use", false);
|
||||||
options.put("sqlite.use", true);
|
options.put("sqlite.use", true);
|
||||||
@ -1611,7 +1616,7 @@ public class PS {
|
|||||||
* Setup the style.yml file
|
* Setup the style.yml file
|
||||||
*/
|
*/
|
||||||
private void setupStyle() {
|
private void setupStyle() {
|
||||||
style.set("version", VERSION);
|
style.set("version", StringMan.join(VERSION,"."));
|
||||||
final Map<String, Object> o = new HashMap<>();
|
final Map<String, Object> o = new HashMap<>();
|
||||||
o.put("color.1", "6");
|
o.put("color.1", "6");
|
||||||
o.put("color.2", "7");
|
o.put("color.2", "7");
|
||||||
|
@ -28,8 +28,8 @@ import com.intellectualcrafters.plot.util.*;
|
|||||||
import com.plotsquared.bukkit.generator.AugmentedPopulator;
|
import com.plotsquared.bukkit.generator.AugmentedPopulator;
|
||||||
import com.plotsquared.bukkit.generator.BukkitPlotGenerator;
|
import com.plotsquared.bukkit.generator.BukkitPlotGenerator;
|
||||||
import com.plotsquared.bukkit.generator.HybridGen;
|
import com.plotsquared.bukkit.generator.HybridGen;
|
||||||
import com.plotsquared.bukkit.util.SetupUtils;
|
|
||||||
import com.plotsquared.general.commands.CommandDeclaration;
|
import com.plotsquared.general.commands.CommandDeclaration;
|
||||||
|
|
||||||
import org.bukkit.generator.ChunkGenerator;
|
import org.bukkit.generator.ChunkGenerator;
|
||||||
|
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
|
@ -27,9 +27,10 @@ import com.intellectualcrafters.plot.object.PlotId;
|
|||||||
import com.intellectualcrafters.plot.object.PlotPlayer;
|
import com.intellectualcrafters.plot.object.PlotPlayer;
|
||||||
import com.intellectualcrafters.plot.object.comment.CommentInbox;
|
import com.intellectualcrafters.plot.object.comment.CommentInbox;
|
||||||
import com.intellectualcrafters.plot.object.comment.PlotComment;
|
import com.intellectualcrafters.plot.object.comment.PlotComment;
|
||||||
|
import com.intellectualcrafters.plot.util.CommentManager;
|
||||||
import com.intellectualcrafters.plot.util.MainUtil;
|
import com.intellectualcrafters.plot.util.MainUtil;
|
||||||
import com.plotsquared.bukkit.object.comment.CommentManager;
|
|
||||||
import com.plotsquared.general.commands.CommandDeclaration;
|
import com.plotsquared.general.commands.CommandDeclaration;
|
||||||
|
|
||||||
import org.apache.commons.lang.StringUtils;
|
import org.apache.commons.lang.StringUtils;
|
||||||
|
|
||||||
import java.util.Arrays;
|
import java.util.Arrays;
|
||||||
|
@ -51,7 +51,7 @@ public class Delete extends SubCommand {
|
|||||||
if (!MainUtil.getTopPlot(plot).equals(MainUtil.getBottomPlot(plot))) {
|
if (!MainUtil.getTopPlot(plot).equals(MainUtil.getBottomPlot(plot))) {
|
||||||
return !sendMessage(plr, C.UNLINK_REQUIRED);
|
return !sendMessage(plr, C.UNLINK_REQUIRED);
|
||||||
}
|
}
|
||||||
if (((!plot.hasOwner() || !plot.isOwner(UUIDHandler.getUUIDWrapper().getUUID(plr)))) && !Permissions.hasPermission(plr, "plots.admin.command.delete")) {
|
if (((!plot.hasOwner() || !plot.isOwner(plr.getUUID()))) && !Permissions.hasPermission(plr, "plots.admin.command.delete")) {
|
||||||
return !sendMessage(plr, C.NO_PLOT_PERMS);
|
return !sendMessage(plr, C.NO_PLOT_PERMS);
|
||||||
}
|
}
|
||||||
final PlotWorld pWorld = PS.get().getPlotWorld(plot.world);
|
final PlotWorld pWorld = PS.get().getPlotWorld(plot.world);
|
||||||
|
@ -26,10 +26,11 @@ import com.intellectualcrafters.plot.object.PlotPlayer;
|
|||||||
import com.intellectualcrafters.plot.object.RunnableVal;
|
import com.intellectualcrafters.plot.object.RunnableVal;
|
||||||
import com.intellectualcrafters.plot.object.comment.CommentInbox;
|
import com.intellectualcrafters.plot.object.comment.CommentInbox;
|
||||||
import com.intellectualcrafters.plot.object.comment.PlotComment;
|
import com.intellectualcrafters.plot.object.comment.PlotComment;
|
||||||
|
import com.intellectualcrafters.plot.util.CommentManager;
|
||||||
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.plotsquared.bukkit.object.comment.CommentManager;
|
|
||||||
import com.plotsquared.general.commands.CommandDeclaration;
|
import com.plotsquared.general.commands.CommandDeclaration;
|
||||||
|
|
||||||
import org.apache.commons.lang.StringUtils;
|
import org.apache.commons.lang.StringUtils;
|
||||||
|
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
|
@ -28,8 +28,9 @@ import com.intellectualcrafters.plot.flag.Flag;
|
|||||||
import com.intellectualcrafters.plot.flag.FlagManager;
|
import com.intellectualcrafters.plot.flag.FlagManager;
|
||||||
import com.intellectualcrafters.plot.object.*;
|
import com.intellectualcrafters.plot.object.*;
|
||||||
import com.intellectualcrafters.plot.util.*;
|
import com.intellectualcrafters.plot.util.*;
|
||||||
import com.plotsquared.bukkit.listeners.APlotListener;
|
|
||||||
import com.plotsquared.general.commands.CommandDeclaration;
|
import com.plotsquared.general.commands.CommandDeclaration;
|
||||||
|
import com.plotsquared.listener.APlotListener;
|
||||||
|
|
||||||
import org.apache.commons.lang.StringUtils;
|
import org.apache.commons.lang.StringUtils;
|
||||||
|
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
|
@ -23,14 +23,16 @@ package com.intellectualcrafters.plot.commands;
|
|||||||
import com.intellectualcrafters.plot.config.C;
|
import com.intellectualcrafters.plot.config.C;
|
||||||
import com.intellectualcrafters.plot.config.ConfigurationNode;
|
import com.intellectualcrafters.plot.config.ConfigurationNode;
|
||||||
import com.intellectualcrafters.plot.config.Settings;
|
import com.intellectualcrafters.plot.config.Settings;
|
||||||
|
import com.intellectualcrafters.plot.generator.PlotGenerator;
|
||||||
import com.intellectualcrafters.plot.object.PlotPlayer;
|
import com.intellectualcrafters.plot.object.PlotPlayer;
|
||||||
import com.intellectualcrafters.plot.object.SetupObject;
|
import com.intellectualcrafters.plot.object.SetupObject;
|
||||||
import com.intellectualcrafters.plot.util.BlockManager;
|
import com.intellectualcrafters.plot.util.BlockManager;
|
||||||
import com.intellectualcrafters.plot.util.MainUtil;
|
import com.intellectualcrafters.plot.util.MainUtil;
|
||||||
|
import com.intellectualcrafters.plot.util.SetupUtils;
|
||||||
import com.plotsquared.bukkit.generator.BukkitPlotGenerator;
|
import com.plotsquared.bukkit.generator.BukkitPlotGenerator;
|
||||||
import com.plotsquared.bukkit.generator.HybridGen;
|
import com.plotsquared.bukkit.generator.HybridGen;
|
||||||
import com.plotsquared.bukkit.util.SetupUtils;
|
|
||||||
import com.plotsquared.general.commands.CommandDeclaration;
|
import com.plotsquared.general.commands.CommandDeclaration;
|
||||||
|
|
||||||
import org.apache.commons.lang.StringUtils;
|
import org.apache.commons.lang.StringUtils;
|
||||||
import org.bukkit.generator.ChunkGenerator;
|
import org.bukkit.generator.ChunkGenerator;
|
||||||
|
|
||||||
@ -52,14 +54,11 @@ public class Setup extends SubCommand {
|
|||||||
public void displayGenerators(PlotPlayer plr) {
|
public void displayGenerators(PlotPlayer plr) {
|
||||||
StringBuffer message = new StringBuffer();
|
StringBuffer message = new StringBuffer();
|
||||||
message.append("&6What generator do you want?");
|
message.append("&6What generator do you want?");
|
||||||
for (Entry<String, ChunkGenerator> entry : SetupUtils.generators.entrySet()) {
|
for (Entry<String, PlotGenerator<?>> entry : SetupUtils.generators.entrySet()) {
|
||||||
if (entry.getKey().equals("PlotSquared")) {
|
if (entry.getKey().equals("PlotSquared")) {
|
||||||
message.append("\n&8 - &2" + entry.getKey() + " (Default Generator)");
|
message.append("\n&8 - &2" + entry.getKey() + " (Default Generator)");
|
||||||
}
|
}
|
||||||
else if (entry.getValue() instanceof HybridGen) {
|
else if (entry.getValue().isFull()) {
|
||||||
message.append("\n&8 - &7" + entry.getKey() + " (Hybrid Generator)");
|
|
||||||
}
|
|
||||||
else if (entry.getValue() instanceof BukkitPlotGenerator) {
|
|
||||||
message.append("\n&8 - &7" + entry.getKey() + " (Plot Generator)");
|
message.append("\n&8 - &7" + entry.getKey() + " (Plot Generator)");
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
@ -119,7 +118,7 @@ public class Setup extends SubCommand {
|
|||||||
List<String> allTypes = Arrays.asList(new String[] { "default", "augmented", "partial"});
|
List<String> allTypes = Arrays.asList(new String[] { "default", "augmented", "partial"});
|
||||||
List<String> allDesc = Arrays.asList(new String[] { "Standard plot generation", "Plot generation with vanilla terrain", "Vanilla with clusters of plots"});
|
List<String> allDesc = Arrays.asList(new String[] { "Standard plot generation", "Plot generation with vanilla terrain", "Vanilla with clusters of plots"});
|
||||||
ArrayList<String> types = new ArrayList<>();
|
ArrayList<String> types = new ArrayList<>();
|
||||||
if (SetupUtils.generators.get(object.setupGenerator) instanceof BukkitPlotGenerator) {
|
if (SetupUtils.generators.get(object.setupGenerator).isFull()) {
|
||||||
types.add("default");
|
types.add("default");
|
||||||
}
|
}
|
||||||
types.add("augmented");
|
types.add("augmented");
|
||||||
@ -140,13 +139,13 @@ public class Setup extends SubCommand {
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
object.type = allTypes.indexOf(args[0].toLowerCase());
|
object.type = allTypes.indexOf(args[0].toLowerCase());
|
||||||
ChunkGenerator gen = SetupUtils.generators.get(object.setupGenerator);
|
PlotGenerator<?> gen = SetupUtils.generators.get(object.setupGenerator);
|
||||||
if (object.type == 0) {
|
if (object.type == 0) {
|
||||||
object.current++;
|
object.current++;
|
||||||
if (object.step == null) {
|
if (object.step == null) {
|
||||||
object.plotManager = object.setupGenerator;
|
object.plotManager = object.setupGenerator;
|
||||||
object.step = ((BukkitPlotGenerator) SetupUtils.generators.get(object.plotManager)).getNewPlotWorld(null).getSettingNodes();
|
object.step = SetupUtils.generators.get(object.plotManager).getNewPlotWorld(null).getSettingNodes();
|
||||||
((BukkitPlotGenerator) SetupUtils.generators.get(object.plotManager)).processSetup(object);
|
SetupUtils.generators.get(object.plotManager).processSetup(object);
|
||||||
}
|
}
|
||||||
if (object.step.length == 0) {
|
if (object.step.length == 0) {
|
||||||
object.current = 4;
|
object.current = 4;
|
||||||
@ -157,17 +156,17 @@ public class Setup extends SubCommand {
|
|||||||
final ConfigurationNode step = object.step[object.setup_index];
|
final ConfigurationNode step = object.step[object.setup_index];
|
||||||
sendMessage(plr, C.SETUP_STEP, object.setup_index + 1 + "", step.getDescription(), step.getType().getType(), step.getDefaultValue() + "");
|
sendMessage(plr, C.SETUP_STEP, object.setup_index + 1 + "", step.getDescription(), step.getType().getType(), step.getDefaultValue() + "");
|
||||||
} else {
|
} else {
|
||||||
if (gen instanceof BukkitPlotGenerator) {
|
if (gen.isFull()) {
|
||||||
object.plotManager = object.setupGenerator;
|
object.plotManager = object.setupGenerator;
|
||||||
object.setupGenerator = null;
|
object.setupGenerator = null;
|
||||||
object.step = ((BukkitPlotGenerator) SetupUtils.generators.get(object.plotManager)).getNewPlotWorld(null).getSettingNodes();
|
object.step = SetupUtils.generators.get(object.plotManager).getNewPlotWorld(null).getSettingNodes();
|
||||||
((BukkitPlotGenerator) SetupUtils.generators.get(object.plotManager)).processSetup(object);
|
SetupUtils.generators.get(object.plotManager).processSetup(object);
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
object.plotManager = "PlotSquared";
|
object.plotManager = "PlotSquared";
|
||||||
MainUtil.sendMessage(plr, "&c[WARNING] The specified generator does not identify as BukkitPlotGenerator");
|
MainUtil.sendMessage(plr, "&c[WARNING] The specified generator does not identify as BukkitPlotGenerator");
|
||||||
MainUtil.sendMessage(plr, "&7 - You may need to manually configure the other plugin");
|
MainUtil.sendMessage(plr, "&7 - You may need to manually configure the other plugin");
|
||||||
object.step = ((BukkitPlotGenerator) SetupUtils.generators.get(object.plotManager)).getNewPlotWorld(null).getSettingNodes();
|
object.step = SetupUtils.generators.get(object.plotManager).getNewPlotWorld(null).getSettingNodes();
|
||||||
}
|
}
|
||||||
MainUtil.sendMessage(plr, "&6What terrain would you like in plots?" + "\n&8 - &2NONE&8 - &7No terrain at all" + "\n&8 - &7ORE&8 - &7Just some ore veins and trees" + "\n&8 - &7ROAD&8 - &7Terrain seperated by roads" + "\n&8 - &7ALL&8 - &7Entirely vanilla generation");
|
MainUtil.sendMessage(plr, "&6What terrain would you like in plots?" + "\n&8 - &2NONE&8 - &7No terrain at all" + "\n&8 - &7ORE&8 - &7Just some ore veins and trees" + "\n&8 - &7ROAD&8 - &7Terrain seperated by roads" + "\n&8 - &7ALL&8 - &7Entirely vanilla generation");
|
||||||
}
|
}
|
||||||
@ -183,7 +182,7 @@ public class Setup extends SubCommand {
|
|||||||
object.terrain = terrain.indexOf(args[0].toLowerCase());
|
object.terrain = terrain.indexOf(args[0].toLowerCase());
|
||||||
object.current++;
|
object.current++;
|
||||||
if (object.step == null) {
|
if (object.step == null) {
|
||||||
object.step = ((BukkitPlotGenerator) SetupUtils.generators.get(object.plotManager)).getNewPlotWorld(null).getSettingNodes();
|
object.step = SetupUtils.generators.get(object.plotManager).getNewPlotWorld(null).getSettingNodes();
|
||||||
}
|
}
|
||||||
final ConfigurationNode step = object.step[object.setup_index];
|
final ConfigurationNode step = object.step[object.setup_index];
|
||||||
sendMessage(plr, C.SETUP_STEP, object.setup_index + 1 + "", step.getDescription(), step.getType().getType(), step.getDefaultValue() + "");
|
sendMessage(plr, C.SETUP_STEP, object.setup_index + 1 + "", step.getDescription(), step.getType().getType(), step.getDefaultValue() + "");
|
||||||
|
@ -28,8 +28,8 @@ import com.intellectualcrafters.plot.config.ConfigurationNode;
|
|||||||
import com.intellectualcrafters.plot.object.*;
|
import com.intellectualcrafters.plot.object.*;
|
||||||
import com.intellectualcrafters.plot.util.BlockManager;
|
import com.intellectualcrafters.plot.util.BlockManager;
|
||||||
import com.intellectualcrafters.plot.util.MainUtil;
|
import com.intellectualcrafters.plot.util.MainUtil;
|
||||||
|
import com.intellectualcrafters.plot.util.SetupUtils;
|
||||||
import com.intellectualcrafters.plot.util.TaskManager;
|
import com.intellectualcrafters.plot.util.TaskManager;
|
||||||
import com.plotsquared.bukkit.util.SetupUtils;
|
|
||||||
import com.plotsquared.general.commands.CommandDeclaration;
|
import com.plotsquared.general.commands.CommandDeclaration;
|
||||||
|
|
||||||
import java.io.File;
|
import java.io.File;
|
||||||
|
@ -209,10 +209,8 @@ public enum C {
|
|||||||
/*
|
/*
|
||||||
* Title Stuff
|
* Title Stuff
|
||||||
*/
|
*/
|
||||||
TITLE_ENTERED_PLOT("Plot: %world%;%x%;%z%", "Titles"),
|
TITLE_ENTERED_PLOT("$1Plot: %world%;%x%;%z%", "Titles"),
|
||||||
TITLE_ENTERED_PLOT_COLOR("GOLD", "Titles"),
|
TITLE_ENTERED_PLOT_SUB("$4Owned by %s", "Titles"),
|
||||||
TITLE_ENTERED_PLOT_SUB("Owned by %s", "Titles"),
|
|
||||||
TITLE_ENTERED_PLOT_SUB_COLOR("RED", "Titles"),
|
|
||||||
PREFIX_GREETING("$1%id%$2> ", "Titles"),
|
PREFIX_GREETING("$1%id%$2> ", "Titles"),
|
||||||
PREFIX_FAREWELL("$1%id%$2> ", "Titles"),
|
PREFIX_FAREWELL("$1%id%$2> ", "Titles"),
|
||||||
/*
|
/*
|
||||||
|
@ -3,6 +3,7 @@ package com.intellectualcrafters.plot.generator;
|
|||||||
import com.intellectualcrafters.plot.object.PlotCluster;
|
import com.intellectualcrafters.plot.object.PlotCluster;
|
||||||
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 com.intellectualcrafters.plot.object.SetupObject;
|
||||||
|
|
||||||
public abstract class PlotGenerator<T> {
|
public abstract class PlotGenerator<T> {
|
||||||
public final String world;
|
public final String world;
|
||||||
@ -46,4 +47,6 @@ public abstract class PlotGenerator<T> {
|
|||||||
public abstract boolean isFull();
|
public abstract boolean isFull();
|
||||||
|
|
||||||
public abstract String getName();
|
public abstract String getName();
|
||||||
|
|
||||||
|
public abstract void processSetup(SetupObject object);
|
||||||
}
|
}
|
||||||
|
@ -1,7 +1,7 @@
|
|||||||
package com.intellectualcrafters.plot.object;
|
package com.intellectualcrafters.plot.object;
|
||||||
|
|
||||||
import com.intellectualcrafters.plot.config.ConfigurationNode;
|
import com.intellectualcrafters.plot.config.ConfigurationNode;
|
||||||
import com.plotsquared.bukkit.util.SetupUtils;
|
import com.intellectualcrafters.plot.util.SetupUtils;
|
||||||
|
|
||||||
public class SetupObject {
|
public class SetupObject {
|
||||||
|
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
package com.plotsquared.bukkit.object.comment;
|
package com.intellectualcrafters.plot.util;
|
||||||
|
|
||||||
import com.intellectualcrafters.plot.config.C;
|
import com.intellectualcrafters.plot.config.C;
|
||||||
import com.intellectualcrafters.plot.config.Settings;
|
import com.intellectualcrafters.plot.config.Settings;
|
||||||
@ -6,9 +6,7 @@ import com.intellectualcrafters.plot.object.Plot;
|
|||||||
import com.intellectualcrafters.plot.object.PlotPlayer;
|
import com.intellectualcrafters.plot.object.PlotPlayer;
|
||||||
import com.intellectualcrafters.plot.object.RunnableVal;
|
import com.intellectualcrafters.plot.object.RunnableVal;
|
||||||
import com.intellectualcrafters.plot.object.comment.*;
|
import com.intellectualcrafters.plot.object.comment.*;
|
||||||
import com.intellectualcrafters.plot.util.TaskManager;
|
|
||||||
import com.plotsquared.bukkit.titles.AbstractTitle;
|
import com.plotsquared.bukkit.titles.AbstractTitle;
|
||||||
import org.bukkit.ChatColor;
|
|
||||||
|
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.Collection;
|
import java.util.Collection;
|
||||||
@ -50,7 +48,7 @@ public class CommentManager {
|
|||||||
total = count.get();
|
total = count.get();
|
||||||
}
|
}
|
||||||
if (size.decrementAndGet() == 0 && total > 0) {
|
if (size.decrementAndGet() == 0 && total > 0) {
|
||||||
AbstractTitle.sendTitle(player, "", C.INBOX_NOTIFICATION.s().replaceAll("%s", "" + total), ChatColor.GOLD, ChatColor.valueOf(C.TITLE_ENTERED_PLOT_SUB_COLOR.s()));
|
AbstractTitle.sendTitle(player, "", C.INBOX_NOTIFICATION.s().replaceAll("%s", "" + total));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
});
|
});
|
@ -15,7 +15,6 @@ import com.intellectualcrafters.plot.object.PlotBlock;
|
|||||||
import com.intellectualcrafters.plot.object.PlotCluster;
|
import com.intellectualcrafters.plot.object.PlotCluster;
|
||||||
import com.intellectualcrafters.plot.object.PlotId;
|
import com.intellectualcrafters.plot.object.PlotId;
|
||||||
import com.intellectualcrafters.plot.object.PlotPlayer;
|
import com.intellectualcrafters.plot.object.PlotPlayer;
|
||||||
import com.plotsquared.bukkit.util.SetupUtils;
|
|
||||||
|
|
||||||
public abstract class EventUtil {
|
public abstract class EventUtil {
|
||||||
|
|
||||||
|
@ -17,6 +17,106 @@ public class MathMan {
|
|||||||
return count / array.length;
|
return count / array.length;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Returns [x, y, z]
|
||||||
|
* @param yaw
|
||||||
|
* @param pitch
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
|
public static float[] getDirection(float yaw, float pitch) {
|
||||||
|
double pitch_sin = Math.sin(pitch);
|
||||||
|
return new float[] {
|
||||||
|
(float) (pitch_sin * Math.cos(yaw)),
|
||||||
|
(float) (pitch_sin * Math.sin(yaw)),
|
||||||
|
(float) Math.cos(pitch)
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Returns [ pitch, yaw ]
|
||||||
|
* @param x
|
||||||
|
* @param y
|
||||||
|
* @param z
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
|
public static float[] getPitchAndYaw(float x, float y, float z) {
|
||||||
|
float distance = sqrtApprox(z * z + x * x);
|
||||||
|
return new float[] { atan2(y, distance), atan2(x, z) };
|
||||||
|
}
|
||||||
|
|
||||||
|
private static final int ATAN2_BITS = 7;
|
||||||
|
|
||||||
|
private static final int ATAN2_BITS2 = ATAN2_BITS << 1;
|
||||||
|
private static final int ATAN2_MASK = ~(-1 << ATAN2_BITS2);
|
||||||
|
private static final int ATAN2_COUNT = ATAN2_MASK + 1;
|
||||||
|
private static final int ATAN2_DIM = (int) Math.sqrt(ATAN2_COUNT);
|
||||||
|
|
||||||
|
private static final float INV_ATAN2_DIM_MINUS_1 = 1.0f / (ATAN2_DIM - 1);
|
||||||
|
|
||||||
|
private static final float[] atan2 = new float[ATAN2_COUNT];
|
||||||
|
|
||||||
|
static {
|
||||||
|
for (int i = 0; i < ATAN2_DIM; i++) {
|
||||||
|
for (int j = 0; j < ATAN2_DIM; j++) {
|
||||||
|
float x0 = (float) i / ATAN2_DIM;
|
||||||
|
float y0 = (float) j / ATAN2_DIM;
|
||||||
|
|
||||||
|
atan2[j * ATAN2_DIM + i] = (float) Math.atan2(y0, x0);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public static final float atan2(float y, float x) {
|
||||||
|
float add, mul;
|
||||||
|
|
||||||
|
if (x < 0.0f) {
|
||||||
|
if (y < 0.0f) {
|
||||||
|
x = -x;
|
||||||
|
y = -y;
|
||||||
|
|
||||||
|
mul = 1.0f;
|
||||||
|
} else {
|
||||||
|
x = -x;
|
||||||
|
mul = -1.0f;
|
||||||
|
}
|
||||||
|
|
||||||
|
add = -3.141592653f;
|
||||||
|
} else {
|
||||||
|
if (y < 0.0f) {
|
||||||
|
y = -y;
|
||||||
|
mul = -1.0f;
|
||||||
|
} else {
|
||||||
|
mul = 1.0f;
|
||||||
|
}
|
||||||
|
|
||||||
|
add = 0.0f;
|
||||||
|
}
|
||||||
|
|
||||||
|
float invDiv = 1.0f / (((x < y) ? y : x) * INV_ATAN2_DIM_MINUS_1);
|
||||||
|
|
||||||
|
int xi = (int) (x * invDiv);
|
||||||
|
int yi = (int) (y * invDiv);
|
||||||
|
|
||||||
|
return (atan2[yi * ATAN2_DIM + xi] + add) * mul;
|
||||||
|
}
|
||||||
|
|
||||||
|
public static float sqrtApprox(float f) {
|
||||||
|
return f * Float.intBitsToFloat(0x5f375a86 - (Float.floatToIntBits(f) >> 1));
|
||||||
|
}
|
||||||
|
|
||||||
|
public static double sqrtApprox(double d) {
|
||||||
|
return Double.longBitsToDouble( ( ( Double.doubleToLongBits( d )-(1l<<52) )>>1 ) + ( 1l<<61 ) );
|
||||||
|
}
|
||||||
|
|
||||||
|
public static float invSqrt(float x) {
|
||||||
|
float xhalf = 0.5f*x;
|
||||||
|
int i = Float.floatToIntBits(x);
|
||||||
|
i = 0x5f3759df - (i>>1);
|
||||||
|
x = Float.intBitsToFloat(i);
|
||||||
|
x = x*(1.5f - xhalf*x*x);
|
||||||
|
return x;
|
||||||
|
}
|
||||||
|
|
||||||
public static int getPositiveId(int i) {
|
public static int getPositiveId(int i) {
|
||||||
if (i < 0) {
|
if (i < 0) {
|
||||||
return -i*2 - 1;
|
return -i*2 - 1;
|
||||||
|
@ -1,7 +1,9 @@
|
|||||||
package com.plotsquared.bukkit.util;
|
package com.intellectualcrafters.plot.util;
|
||||||
|
|
||||||
|
import com.intellectualcrafters.plot.generator.PlotGenerator;
|
||||||
import com.intellectualcrafters.plot.object.PlotWorld;
|
import com.intellectualcrafters.plot.object.PlotWorld;
|
||||||
import com.intellectualcrafters.plot.object.SetupObject;
|
import com.intellectualcrafters.plot.object.SetupObject;
|
||||||
|
|
||||||
import org.bukkit.generator.ChunkGenerator;
|
import org.bukkit.generator.ChunkGenerator;
|
||||||
|
|
||||||
import java.util.HashMap;
|
import java.util.HashMap;
|
||||||
@ -12,7 +14,7 @@ public abstract class SetupUtils {
|
|||||||
public static SetupUtils manager;
|
public static SetupUtils manager;
|
||||||
|
|
||||||
public final static Map<String, SetupObject> setupMap = new HashMap<>();
|
public final static Map<String, SetupObject> setupMap = new HashMap<>();
|
||||||
public static HashMap<String, ChunkGenerator> generators = new HashMap<>();
|
public static HashMap<String, PlotGenerator<?>> generators = new HashMap<>();
|
||||||
|
|
||||||
public abstract void updateGenerators();
|
public abstract void updateGenerators();
|
||||||
|
|
@ -33,6 +33,7 @@ import com.intellectualcrafters.plot.util.EventUtil;
|
|||||||
import com.intellectualcrafters.plot.util.InventoryUtil;
|
import com.intellectualcrafters.plot.util.InventoryUtil;
|
||||||
import com.intellectualcrafters.plot.util.MainUtil;
|
import com.intellectualcrafters.plot.util.MainUtil;
|
||||||
import com.intellectualcrafters.plot.util.PlayerManager;
|
import com.intellectualcrafters.plot.util.PlayerManager;
|
||||||
|
import com.intellectualcrafters.plot.util.SetupUtils;
|
||||||
import com.intellectualcrafters.plot.util.TaskManager;
|
import com.intellectualcrafters.plot.util.TaskManager;
|
||||||
import com.intellectualcrafters.plot.util.UUIDHandlerImplementation;
|
import com.intellectualcrafters.plot.util.UUIDHandlerImplementation;
|
||||||
import com.intellectualcrafters.plot.uuid.UUIDWrapper;
|
import com.intellectualcrafters.plot.uuid.UUIDWrapper;
|
||||||
@ -42,7 +43,6 @@ import com.plotsquared.bukkit.database.plotme.LikePlotMeConverter;
|
|||||||
import com.plotsquared.bukkit.database.plotme.PlotMeConnector_017;
|
import com.plotsquared.bukkit.database.plotme.PlotMeConnector_017;
|
||||||
import com.plotsquared.bukkit.generator.BukkitGeneratorWrapper;
|
import com.plotsquared.bukkit.generator.BukkitGeneratorWrapper;
|
||||||
import com.plotsquared.bukkit.generator.HybridGen;
|
import com.plotsquared.bukkit.generator.HybridGen;
|
||||||
import com.plotsquared.bukkit.listeners.APlotListener;
|
|
||||||
import com.plotsquared.bukkit.listeners.ChunkListener;
|
import com.plotsquared.bukkit.listeners.ChunkListener;
|
||||||
import com.plotsquared.bukkit.listeners.ForceFieldListener;
|
import com.plotsquared.bukkit.listeners.ForceFieldListener;
|
||||||
import com.plotsquared.bukkit.listeners.PlayerEvents;
|
import com.plotsquared.bukkit.listeners.PlayerEvents;
|
||||||
@ -57,7 +57,6 @@ import com.plotsquared.bukkit.listeners.worldedit.WESubscriber;
|
|||||||
import com.plotsquared.bukkit.titles.AbstractTitle;
|
import com.plotsquared.bukkit.titles.AbstractTitle;
|
||||||
import com.plotsquared.bukkit.titles.DefaultTitle;
|
import com.plotsquared.bukkit.titles.DefaultTitle;
|
||||||
import com.plotsquared.bukkit.util.BukkitHybridUtils;
|
import com.plotsquared.bukkit.util.BukkitHybridUtils;
|
||||||
import com.plotsquared.bukkit.util.SetupUtils;
|
|
||||||
import com.plotsquared.bukkit.util.bukkit.BukkitChunkManager;
|
import com.plotsquared.bukkit.util.bukkit.BukkitChunkManager;
|
||||||
import com.plotsquared.bukkit.util.bukkit.BukkitEconHandler;
|
import com.plotsquared.bukkit.util.bukkit.BukkitEconHandler;
|
||||||
import com.plotsquared.bukkit.util.bukkit.BukkitEventUtil;
|
import com.plotsquared.bukkit.util.bukkit.BukkitEventUtil;
|
||||||
@ -78,6 +77,7 @@ import com.plotsquared.bukkit.util.bukkit.uuid.SQLUUIDHandler;
|
|||||||
import com.plotsquared.bukkit.uuid.DefaultUUIDWrapper;
|
import com.plotsquared.bukkit.uuid.DefaultUUIDWrapper;
|
||||||
import com.plotsquared.bukkit.uuid.LowerOfflineUUIDWrapper;
|
import com.plotsquared.bukkit.uuid.LowerOfflineUUIDWrapper;
|
||||||
import com.plotsquared.bukkit.uuid.OfflineUUIDWrapper;
|
import com.plotsquared.bukkit.uuid.OfflineUUIDWrapper;
|
||||||
|
import com.plotsquared.listener.APlotListener;
|
||||||
import com.sk89q.worldedit.WorldEdit;
|
import com.sk89q.worldedit.WorldEdit;
|
||||||
import com.sk89q.worldedit.bukkit.WorldEditPlugin;
|
import com.sk89q.worldedit.bukkit.WorldEditPlugin;
|
||||||
|
|
||||||
|
@ -5,6 +5,8 @@ import com.intellectualcrafters.plot.generator.PlotGenerator;
|
|||||||
import com.intellectualcrafters.plot.object.PlotCluster;
|
import com.intellectualcrafters.plot.object.PlotCluster;
|
||||||
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 com.intellectualcrafters.plot.object.SetupObject;
|
||||||
|
|
||||||
import org.bukkit.generator.ChunkGenerator;
|
import org.bukkit.generator.ChunkGenerator;
|
||||||
|
|
||||||
public class BukkitGeneratorWrapper extends PlotGenerator<ChunkGenerator> {
|
public class BukkitGeneratorWrapper extends PlotGenerator<ChunkGenerator> {
|
||||||
@ -13,7 +15,7 @@ public class BukkitGeneratorWrapper extends PlotGenerator<ChunkGenerator> {
|
|||||||
|
|
||||||
public BukkitGeneratorWrapper(String world, ChunkGenerator generator) {
|
public BukkitGeneratorWrapper(String world, ChunkGenerator generator) {
|
||||||
super(world, generator);
|
super(world, generator);
|
||||||
full = generator != null;
|
full = (generator instanceof BukkitPlotGenerator);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@ -77,4 +79,11 @@ public class BukkitGeneratorWrapper extends PlotGenerator<ChunkGenerator> {
|
|||||||
return generator.getClass().getName();
|
return generator.getClass().getName();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void processSetup(SetupObject object) {
|
||||||
|
if (generator instanceof BukkitPlotGenerator) {
|
||||||
|
((BukkitPlotGenerator) generator).processSetup(object);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -31,8 +31,9 @@ import com.intellectualcrafters.plot.util.*;
|
|||||||
import com.plotsquared.bukkit.events.PlayerEnterPlotEvent;
|
import com.plotsquared.bukkit.events.PlayerEnterPlotEvent;
|
||||||
import com.plotsquared.bukkit.events.PlayerLeavePlotEvent;
|
import com.plotsquared.bukkit.events.PlayerLeavePlotEvent;
|
||||||
import com.plotsquared.bukkit.object.BukkitPlayer;
|
import com.plotsquared.bukkit.object.BukkitPlayer;
|
||||||
import com.plotsquared.bukkit.object.comment.CommentManager;
|
|
||||||
import com.plotsquared.bukkit.titles.AbstractTitle;
|
import com.plotsquared.bukkit.titles.AbstractTitle;
|
||||||
|
import com.plotsquared.listener.APlotListener;
|
||||||
|
|
||||||
import org.bukkit.*;
|
import org.bukkit.*;
|
||||||
import org.bukkit.entity.Player;
|
import org.bukkit.entity.Player;
|
||||||
|
|
||||||
@ -205,7 +206,7 @@ public class PlotListener extends APlotListener {
|
|||||||
replacements.put("%s", getName(plot.owner));
|
replacements.put("%s", getName(plot.owner));
|
||||||
String main = StringMan.replaceFromMap(C.TITLE_ENTERED_PLOT.s(), replacements);
|
String main = StringMan.replaceFromMap(C.TITLE_ENTERED_PLOT.s(), replacements);
|
||||||
String sub = StringMan.replaceFromMap(C.TITLE_ENTERED_PLOT_SUB.s(), replacements);
|
String sub = StringMan.replaceFromMap(C.TITLE_ENTERED_PLOT_SUB.s(), replacements);
|
||||||
AbstractTitle.sendTitle(pp, main, sub, ChatColor.valueOf(C.TITLE_ENTERED_PLOT_COLOR.s()), ChatColor.valueOf(C.TITLE_ENTERED_PLOT_SUB_COLOR.s()));
|
AbstractTitle.sendTitle(pp, main, sub);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}, 20);
|
}, 20);
|
||||||
|
@ -21,12 +21,12 @@ import java.util.UUID;
|
|||||||
public class BukkitPlayer implements PlotPlayer {
|
public class BukkitPlayer implements PlotPlayer {
|
||||||
|
|
||||||
public final Player player;
|
public final Player player;
|
||||||
UUID uuid;
|
private UUID uuid;
|
||||||
String name;
|
private String name;
|
||||||
private int op = 0;
|
private int op = 0;
|
||||||
private long last = 0;
|
private long last = 0;
|
||||||
public HashSet<String> hasPerm = new HashSet<>();
|
private HashSet<String> hasPerm = new HashSet<>();
|
||||||
public HashSet<String> noPerm = new HashSet<>();
|
private HashSet<String> noPerm = new HashSet<>();
|
||||||
|
|
||||||
private HashMap<String, Object> meta;
|
private HashMap<String, Object> meta;
|
||||||
|
|
||||||
|
@ -6,11 +6,11 @@ import org.bukkit.ChatColor;
|
|||||||
public abstract class AbstractTitle {
|
public abstract class AbstractTitle {
|
||||||
public static AbstractTitle TITLE_CLASS;
|
public static AbstractTitle TITLE_CLASS;
|
||||||
|
|
||||||
public static void sendTitle(PlotPlayer player, String head, String sub, ChatColor head_color, ChatColor sub_color) {
|
public static void sendTitle(PlotPlayer player, String head, String sub) {
|
||||||
if (TITLE_CLASS != null && !player.getAttribute("disabletitles")) {
|
if (TITLE_CLASS != null && !player.getAttribute("disabletitles")) {
|
||||||
TITLE_CLASS.sendTitle(player, head, sub, head_color, sub_color, 1, 2, 1);
|
TITLE_CLASS.sendTitle(player, head, sub, 1, 2, 1);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public abstract void sendTitle(PlotPlayer player, String head, String sub, ChatColor head_color, ChatColor sub_color, int in, int delay, int out);
|
public abstract void sendTitle(PlotPlayer player, String head, String sub, int in, int delay, int out);
|
||||||
}
|
}
|
||||||
|
@ -6,15 +6,13 @@ import org.bukkit.ChatColor;
|
|||||||
|
|
||||||
public class DefaultTitle extends AbstractTitle {
|
public class DefaultTitle extends AbstractTitle {
|
||||||
@Override
|
@Override
|
||||||
public void sendTitle(final PlotPlayer player, final String head, final String sub, final ChatColor head_color, final ChatColor sub_color, int in, int delay, int out) {
|
public void sendTitle(final PlotPlayer player, final String head, final String sub, int in, int delay, int out) {
|
||||||
try {
|
try {
|
||||||
final DefaultTitleManager title = new DefaultTitleManager(head, sub, in, delay, out);
|
final DefaultTitleManager title = new DefaultTitleManager(head, sub, in, delay, out);
|
||||||
title.setTitleColor(head_color);
|
|
||||||
title.setSubtitleColor(sub_color);
|
|
||||||
title.send(((BukkitPlayer) player).player);
|
title.send(((BukkitPlayer) player).player);
|
||||||
} catch (final Throwable e) {
|
} catch (final Throwable e) {
|
||||||
AbstractTitle.TITLE_CLASS = new DefaultTitle_183();
|
AbstractTitle.TITLE_CLASS = new DefaultTitle_183();
|
||||||
AbstractTitle.TITLE_CLASS.sendTitle(player, head, sub, head_color, sub_color, in, delay, out);
|
AbstractTitle.TITLE_CLASS.sendTitle(player, head, sub, in, delay, out);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -6,15 +6,13 @@ import org.bukkit.ChatColor;
|
|||||||
|
|
||||||
public class DefaultTitle_183 extends AbstractTitle {
|
public class DefaultTitle_183 extends AbstractTitle {
|
||||||
@Override
|
@Override
|
||||||
public void sendTitle(final PlotPlayer player, final String head, final String sub, final ChatColor head_color, final ChatColor sub_color, int in, int delay, int out) {
|
public void sendTitle(final PlotPlayer player, final String head, final String sub, int in, int delay, int out) {
|
||||||
try {
|
try {
|
||||||
final DefaultTitleManager_183 title = new DefaultTitleManager_183(head, sub, in, delay, out);
|
final DefaultTitleManager_183 title = new DefaultTitleManager_183(head, sub, in, delay, out);
|
||||||
title.setTitleColor(head_color);
|
|
||||||
title.setSubtitleColor(sub_color);
|
|
||||||
title.send(((BukkitPlayer) player).player);
|
title.send(((BukkitPlayer) player).player);
|
||||||
} catch (final Throwable e) {
|
} catch (final Throwable e) {
|
||||||
AbstractTitle.TITLE_CLASS = new HackTitle();
|
AbstractTitle.TITLE_CLASS = new HackTitle();
|
||||||
AbstractTitle.TITLE_CLASS.sendTitle(player, head, sub, head_color, sub_color, in, delay, out);
|
AbstractTitle.TITLE_CLASS.sendTitle(player, head, sub, in, delay, out);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -8,11 +8,9 @@ import org.bukkit.ChatColor;
|
|||||||
|
|
||||||
public class HackTitle extends AbstractTitle {
|
public class HackTitle extends AbstractTitle {
|
||||||
@Override
|
@Override
|
||||||
public void sendTitle(final PlotPlayer player, final String head, final String sub, final ChatColor head_color, final ChatColor sub_color, int in, int delay, int out) {
|
public void sendTitle(final PlotPlayer player, final String head, final String sub, int in, int delay, int out) {
|
||||||
try {
|
try {
|
||||||
final HackTitleManager title = new HackTitleManager(head, sub, in, delay, out);
|
final HackTitleManager title = new HackTitleManager(head, sub, in, delay, out);
|
||||||
title.setTitleColor(head_color);
|
|
||||||
title.setSubtitleColor(sub_color);
|
|
||||||
title.send(((BukkitPlayer) player).player);
|
title.send(((BukkitPlayer) player).player);
|
||||||
} catch (final Throwable e) {
|
} catch (final Throwable e) {
|
||||||
PS.log("&cYour server version does not support titles!");
|
PS.log("&cYour server version does not support titles!");
|
||||||
|
@ -2,10 +2,13 @@ package com.plotsquared.bukkit.util.bukkit;
|
|||||||
|
|
||||||
import com.intellectualcrafters.plot.PS;
|
import com.intellectualcrafters.plot.PS;
|
||||||
import com.intellectualcrafters.plot.config.ConfigurationNode;
|
import com.intellectualcrafters.plot.config.ConfigurationNode;
|
||||||
|
import com.intellectualcrafters.plot.generator.PlotGenerator;
|
||||||
import com.intellectualcrafters.plot.object.PlotWorld;
|
import com.intellectualcrafters.plot.object.PlotWorld;
|
||||||
import com.intellectualcrafters.plot.object.SetupObject;
|
import com.intellectualcrafters.plot.object.SetupObject;
|
||||||
|
import com.intellectualcrafters.plot.util.SetupUtils;
|
||||||
|
import com.plotsquared.bukkit.generator.BukkitGeneratorWrapper;
|
||||||
import com.plotsquared.bukkit.generator.BukkitPlotGenerator;
|
import com.plotsquared.bukkit.generator.BukkitPlotGenerator;
|
||||||
import com.plotsquared.bukkit.util.SetupUtils;
|
|
||||||
import org.bukkit.Bukkit;
|
import org.bukkit.Bukkit;
|
||||||
import org.bukkit.World;
|
import org.bukkit.World;
|
||||||
import org.bukkit.World.Environment;
|
import org.bukkit.World.Environment;
|
||||||
@ -32,7 +35,7 @@ public class BukkitSetupUtils extends SetupUtils {
|
|||||||
final String name = plugin.getDescription().getName();
|
final String name = plugin.getDescription().getName();
|
||||||
// final PlotGenerator pgen = (PlotGenerator) generator;
|
// final PlotGenerator pgen = (PlotGenerator) generator;
|
||||||
// if (pgen.getPlotManager() instanceof SquarePlotManager) {
|
// if (pgen.getPlotManager() instanceof SquarePlotManager) {
|
||||||
SetupUtils.generators.put(name, generator);
|
SetupUtils.generators.put(name, new BukkitGeneratorWrapper("CheckingPlotSquaredGenerator", generator));
|
||||||
// }
|
// }
|
||||||
// }
|
// }
|
||||||
}
|
}
|
||||||
@ -55,8 +58,8 @@ public class BukkitSetupUtils extends SetupUtils {
|
|||||||
if (object.setupGenerator != null && !object.setupGenerator.equals(object.plotManager)) {
|
if (object.setupGenerator != null && !object.setupGenerator.equals(object.plotManager)) {
|
||||||
PS.get().config.set("worlds." + world + "." + "generator.init", object.setupGenerator);
|
PS.get().config.set("worlds." + world + "." + "generator.init", object.setupGenerator);
|
||||||
}
|
}
|
||||||
ChunkGenerator gen = generators.get(object.setupGenerator);
|
PlotGenerator<ChunkGenerator> gen = (PlotGenerator<ChunkGenerator>) generators.get(object.setupGenerator);
|
||||||
if (gen instanceof BukkitPlotGenerator) {
|
if (gen.generator instanceof BukkitPlotGenerator) {
|
||||||
object.setupGenerator = null;
|
object.setupGenerator = null;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -105,8 +108,8 @@ public class BukkitSetupUtils extends SetupUtils {
|
|||||||
if (!(generator instanceof BukkitPlotGenerator)) {
|
if (!(generator instanceof BukkitPlotGenerator)) {
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
for (Entry<String, ChunkGenerator> entry : generators.entrySet()) {
|
for (Entry<String, PlotGenerator<?>> entry : generators.entrySet()) {
|
||||||
if (entry.getValue().getClass().getName().equals(generator.getClass().getName())) {
|
if (entry.getValue().generator.getClass().getName().equals(generator.getClass().getName())) {
|
||||||
return entry.getKey();
|
return entry.getKey();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1,8 +1,10 @@
|
|||||||
package com.plotsquared.bukkit.util.bukkit;
|
package com.plotsquared.bukkit.util.bukkit;
|
||||||
|
|
||||||
import com.intellectualcrafters.plot.PS;
|
import com.intellectualcrafters.plot.PS;
|
||||||
|
import com.intellectualcrafters.plot.generator.PlotGenerator;
|
||||||
|
import com.intellectualcrafters.plot.util.SetupUtils;
|
||||||
import com.plotsquared.bukkit.generator.AugmentedPopulator;
|
import com.plotsquared.bukkit.generator.AugmentedPopulator;
|
||||||
import com.plotsquared.bukkit.util.SetupUtils;
|
|
||||||
import org.bukkit.World;
|
import org.bukkit.World;
|
||||||
import org.bukkit.generator.BlockPopulator;
|
import org.bukkit.generator.BlockPopulator;
|
||||||
import org.bukkit.generator.ChunkGenerator;
|
import org.bukkit.generator.ChunkGenerator;
|
||||||
@ -22,7 +24,8 @@ public class SetGenCB {
|
|||||||
}
|
}
|
||||||
String name = gen.getClass().getCanonicalName();
|
String name = gen.getClass().getCanonicalName();
|
||||||
boolean set = false;
|
boolean set = false;
|
||||||
for (ChunkGenerator newGen : SetupUtils.generators.values()) {
|
for (PlotGenerator<?> wrapper : SetupUtils.generators.values()) {
|
||||||
|
ChunkGenerator newGen = (ChunkGenerator) wrapper.generator;
|
||||||
if (newGen.getClass().getCanonicalName().equals(name)) {
|
if (newGen.getClass().getCanonicalName().equals(name)) {
|
||||||
// set generator
|
// set generator
|
||||||
Field generator = world.getClass().getDeclaredField("generator");
|
Field generator = world.getClass().getDeclaredField("generator");
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
package com.plotsquared.bukkit.listeners;
|
package com.plotsquared.listener;
|
||||||
|
|
||||||
import com.intellectualcrafters.plot.object.Plot;
|
import com.intellectualcrafters.plot.object.Plot;
|
||||||
import com.intellectualcrafters.plot.object.PlotPlayer;
|
import com.intellectualcrafters.plot.object.PlotPlayer;
|
@ -4,6 +4,8 @@ import com.intellectualcrafters.plot.generator.PlotGenerator;
|
|||||||
import com.intellectualcrafters.plot.object.PlotCluster;
|
import com.intellectualcrafters.plot.object.PlotCluster;
|
||||||
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 com.intellectualcrafters.plot.object.SetupObject;
|
||||||
|
|
||||||
import org.spongepowered.api.world.gen.WorldGenerator;
|
import org.spongepowered.api.world.gen.WorldGenerator;
|
||||||
|
|
||||||
public class SpongeGeneratorWrapper extends PlotGenerator<WorldGenerator>{
|
public class SpongeGeneratorWrapper extends PlotGenerator<WorldGenerator>{
|
||||||
@ -55,4 +57,9 @@ public class SpongeGeneratorWrapper extends PlotGenerator<WorldGenerator>{
|
|||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void processSetup(SetupObject object) {
|
||||||
|
// TODO Auto-generated method stub
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -0,0 +1,93 @@
|
|||||||
|
package com.plotsquared.sponge;
|
||||||
|
|
||||||
|
import java.util.UUID;
|
||||||
|
import java.util.concurrent.ExecutionException;
|
||||||
|
|
||||||
|
import org.spongepowered.api.GameProfile;
|
||||||
|
import org.spongepowered.api.entity.player.Player;
|
||||||
|
import org.spongepowered.api.service.profile.GameProfileResolver;
|
||||||
|
|
||||||
|
import com.google.common.base.Charsets;
|
||||||
|
import com.google.inject.Inject;
|
||||||
|
import com.intellectualcrafters.plot.object.OfflinePlotPlayer;
|
||||||
|
import com.intellectualcrafters.plot.object.PlotPlayer;
|
||||||
|
import com.intellectualcrafters.plot.util.UUIDHandler;
|
||||||
|
import com.intellectualcrafters.plot.uuid.UUIDWrapper;
|
||||||
|
|
||||||
|
public class SpongeLowerOfflineUUIDWrapper extends UUIDWrapper {
|
||||||
|
|
||||||
|
public SpongeLowerOfflineUUIDWrapper() {
|
||||||
|
// Anything?
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public UUID getUUID(final PlotPlayer player) {
|
||||||
|
return getUUID(player.getName());
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public UUID getUUID(final OfflinePlotPlayer player) {
|
||||||
|
return getUUID(player.getName());
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public OfflinePlotPlayer getOfflinePlayer(final UUID uuid) {
|
||||||
|
String name = UUIDHandler.getName(uuid);
|
||||||
|
if (name == null) {
|
||||||
|
try {
|
||||||
|
GameProfile profile = SpongeMain.THIS.getResolver().get(uuid).get();
|
||||||
|
if (profile != null) {
|
||||||
|
name = profile.getName();
|
||||||
|
}
|
||||||
|
} catch (Exception e) {
|
||||||
|
e.printStackTrace();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (name == null) {
|
||||||
|
for (GameProfile profile : SpongeMain.THIS.getResolver().getCachedProfiles()) {
|
||||||
|
if (getUUID(profile.getName()).equals(uuid)) {
|
||||||
|
name = profile.getName();
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
final String username = name;
|
||||||
|
return new OfflinePlotPlayer() {
|
||||||
|
@Override
|
||||||
|
public boolean isOnline() {
|
||||||
|
return UUIDHandler.getPlayer(uuid) != null;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public UUID getUUID() {
|
||||||
|
return uuid;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String getName() {
|
||||||
|
return username;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public long getLastPlayed() {
|
||||||
|
// TODO FIXME
|
||||||
|
throw new UnsupportedOperationException("NOT IMPLEMENTED YET");
|
||||||
|
}
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
public Player[] getOnlinePlayers() {
|
||||||
|
return SpongeMain.THIS.getServer().getOnlinePlayers().toArray(new Player[0]);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public UUID getUUID(final String name) {
|
||||||
|
return UUID.nameUUIDFromBytes(("OfflinePlayer:" + name.toLowerCase()).getBytes(Charsets.UTF_8));
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public OfflinePlotPlayer[] getOfflinePlayers() {
|
||||||
|
// TODO FIXME
|
||||||
|
throw new UnsupportedOperationException("NOT IMPLEMENTED YET");
|
||||||
|
}
|
||||||
|
}
|
@ -9,11 +9,13 @@ import com.intellectualcrafters.plot.config.Settings;
|
|||||||
import com.intellectualcrafters.plot.generator.HybridUtils;
|
import com.intellectualcrafters.plot.generator.HybridUtils;
|
||||||
import com.intellectualcrafters.plot.object.PlotPlayer;
|
import com.intellectualcrafters.plot.object.PlotPlayer;
|
||||||
import com.intellectualcrafters.plot.util.*;
|
import com.intellectualcrafters.plot.util.*;
|
||||||
import com.plotsquared.bukkit.listeners.APlotListener;
|
import com.intellectualcrafters.plot.uuid.UUIDWrapper;
|
||||||
import com.plotsquared.bukkit.util.SetupUtils;
|
import com.plotsquared.listener.APlotListener;
|
||||||
|
|
||||||
import org.slf4j.Logger;
|
import org.slf4j.Logger;
|
||||||
import org.spongepowered.api.Game;
|
import org.spongepowered.api.Game;
|
||||||
|
import org.spongepowered.api.GameRegistry;
|
||||||
|
import org.spongepowered.api.MinecraftVersion;
|
||||||
import org.spongepowered.api.Server;
|
import org.spongepowered.api.Server;
|
||||||
import org.spongepowered.api.entity.player.Player;
|
import org.spongepowered.api.entity.player.Player;
|
||||||
import org.spongepowered.api.entity.player.gamemode.GameModes;
|
import org.spongepowered.api.entity.player.gamemode.GameModes;
|
||||||
@ -23,6 +25,7 @@ import org.spongepowered.api.event.state.PreInitializationEvent;
|
|||||||
import org.spongepowered.api.event.state.ServerAboutToStartEvent;
|
import org.spongepowered.api.event.state.ServerAboutToStartEvent;
|
||||||
import org.spongepowered.api.plugin.Plugin;
|
import org.spongepowered.api.plugin.Plugin;
|
||||||
import org.spongepowered.api.plugin.PluginContainer;
|
import org.spongepowered.api.plugin.PluginContainer;
|
||||||
|
import org.spongepowered.api.service.profile.GameProfileResolver;
|
||||||
import org.spongepowered.api.world.DimensionTypes;
|
import org.spongepowered.api.world.DimensionTypes;
|
||||||
import org.spongepowered.api.world.GeneratorTypes;
|
import org.spongepowered.api.world.GeneratorTypes;
|
||||||
import org.spongepowered.api.world.World;
|
import org.spongepowered.api.world.World;
|
||||||
@ -43,8 +46,34 @@ public class SpongeMain implements IPlotMain, PluginContainer {
|
|||||||
@Inject private Game game;
|
@Inject private Game game;
|
||||||
private Server server;
|
private Server server;
|
||||||
|
|
||||||
|
private GameProfileResolver resolver;
|
||||||
|
|
||||||
private WorldModify modify;
|
private WorldModify modify;
|
||||||
|
|
||||||
|
private Object plugin;
|
||||||
|
|
||||||
|
// stuff //
|
||||||
|
public Logger getLogger() {
|
||||||
|
return logger;
|
||||||
|
}
|
||||||
|
|
||||||
|
public Game getGame() {
|
||||||
|
return game;
|
||||||
|
}
|
||||||
|
|
||||||
|
public Server getServer() {
|
||||||
|
return server;
|
||||||
|
}
|
||||||
|
|
||||||
|
public GameProfileResolver getResolver() {
|
||||||
|
return resolver;
|
||||||
|
}
|
||||||
|
|
||||||
|
public Object getPlugin() {
|
||||||
|
return this.plugin;
|
||||||
|
}
|
||||||
|
/////////
|
||||||
|
|
||||||
////////////////////// SPONGE PLUGIN REGISTRATION ////////////////////
|
////////////////////// SPONGE PLUGIN REGISTRATION ////////////////////
|
||||||
@Override
|
@Override
|
||||||
public String getId() {
|
public String getId() {
|
||||||
@ -84,27 +113,18 @@ public class SpongeMain implements IPlotMain, PluginContainer {
|
|||||||
public void onServerAboutToStart(ServerAboutToStartEvent event) {
|
public void onServerAboutToStart(ServerAboutToStartEvent event) {
|
||||||
log("INIT");
|
log("INIT");
|
||||||
THIS = this;
|
THIS = this;
|
||||||
PS.instance = new PS(this);
|
|
||||||
|
|
||||||
// Setup metrics
|
// resolver
|
||||||
if (Settings.METRICS) {
|
resolver = game.getServiceManager().provide(GameProfileResolver.class).get();
|
||||||
try {
|
plugin = game.getPluginManager().getPlugin("PlotSquared").get().getInstance();
|
||||||
final SpongeMetrics metrics = new SpongeMetrics(game, this);
|
|
||||||
metrics.start();
|
PS.instance = new PS(this);
|
||||||
log(C.PREFIX.s() + "&6Metrics enabled.");
|
|
||||||
} catch (final Exception e) {
|
|
||||||
log(C.PREFIX.s() + "&cFailed to load up metrics.");
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
log("&dUsing metrics will allow us to improve the plugin, please consider it :)");
|
|
||||||
}
|
|
||||||
|
|
||||||
// Set the generators for each world...
|
// Set the generators for each world...
|
||||||
server = game.getServer();
|
server = game.getServer();
|
||||||
Collection<World> worlds = server.getWorlds();
|
Collection<World> worlds = server.getWorlds();
|
||||||
if (worlds.size() > 0) {
|
if (worlds.size() > 0) {
|
||||||
log("INJECTING WORLDS!!!!!!!");
|
log("INJECTING WORLDS!!!!!!!");
|
||||||
UUIDHandler.startCaching(null);
|
|
||||||
for (World world : server.getWorlds()) {
|
for (World world : server.getWorlds()) {
|
||||||
log("INJECTING WORLD: " + world.getName());
|
log("INJECTING WORLD: " + world.getName());
|
||||||
world.setWorldGenerator(new SpongePlotGenerator(world.getName()));
|
world.setWorldGenerator(new SpongePlotGenerator(world.getName()));
|
||||||
@ -112,6 +132,7 @@ public class SpongeMain implements IPlotMain, PluginContainer {
|
|||||||
}
|
}
|
||||||
|
|
||||||
ConfigurationSection worldSection = PS.get().config.getConfigurationSection("worlds");
|
ConfigurationSection worldSection = PS.get().config.getConfigurationSection("worlds");
|
||||||
|
if (worldSection != null) {
|
||||||
for (String world : worldSection.getKeys(false)) {
|
for (String world : worldSection.getKeys(false)) {
|
||||||
this.modify = new WorldModify(this);
|
this.modify = new WorldModify(this);
|
||||||
Game game = event.getGame();
|
Game game = event.getGame();
|
||||||
@ -128,13 +149,6 @@ public class SpongeMain implements IPlotMain, PluginContainer {
|
|||||||
.build();
|
.build();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public Logger getLogger() {
|
|
||||||
return logger;
|
|
||||||
}
|
|
||||||
|
|
||||||
public Game getGame() {
|
|
||||||
return game;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Subscribe
|
@Subscribe
|
||||||
@ -163,68 +177,72 @@ public class SpongeMain implements IPlotMain, PluginContainer {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public int[] getPluginVersion() {
|
public int[] getPluginVersion() {
|
||||||
// TODO Auto-generated method stub
|
PluginContainer plugin = game.getPluginManager().getPlugin("PlotSquared").get();
|
||||||
return null;
|
String version = plugin.getVersion();
|
||||||
|
log("Checking plugin version: PlotSquared: ");
|
||||||
|
String[] split = version.split("\\.");
|
||||||
|
return new int[] { Integer.parseInt(split[0]), Integer.parseInt(split[1]), (split.length == 3) ? Integer.parseInt(split[2]) : 0 };
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public int[] getServerVersion() {
|
public int[] getServerVersion() {
|
||||||
// TODO Auto-generated method stub
|
log("Checking minecraft version: Sponge: ");
|
||||||
return null;
|
String version = game.getPlatform().getMinecraftVersion().getName();
|
||||||
|
String[] split = version.split("\\.");
|
||||||
|
return new int[] { Integer.parseInt(split[0]), Integer.parseInt(split[1]), (split.length == 3) ? Integer.parseInt(split[2]) : 0 };
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public TaskManager getTaskManager() {
|
public TaskManager getTaskManager() {
|
||||||
// TODO Auto-generated method stub
|
return new SpongeTaskManager();
|
||||||
return null;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void runEntityTask() {
|
public void runEntityTask() {
|
||||||
// TODO Auto-generated method stub
|
// TODO Auto-generated method stub
|
||||||
|
log("runEntityTask is not implemented!");
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void registerCommands() {
|
public void registerCommands() {
|
||||||
// TODO Auto-generated method stub
|
// TODO Auto-generated method stub
|
||||||
|
log("registerCommands is not implemented!");
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void registerPlayerEvents() {
|
public void registerPlayerEvents() {
|
||||||
// TODO Auto-generated method stub
|
// TODO Auto-generated method stub
|
||||||
|
log("registerPlayerEvents is not implemented!");
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void registerInventoryEvents() {
|
public void registerInventoryEvents() {
|
||||||
// TODO Auto-generated method stub
|
// TODO Auto-generated method stub
|
||||||
|
log("registerInventoryEvents is not implemented!");
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void registerPlotPlusEvents() {
|
public void registerPlotPlusEvents() {
|
||||||
// TODO Auto-generated method stub
|
// TODO Auto-generated method stub
|
||||||
|
log("registerPlotPlusEvents is not implemented!");
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void registerForceFieldEvents() {
|
public void registerForceFieldEvents() {
|
||||||
// TODO Auto-generated method stub
|
// TODO Auto-generated method stub
|
||||||
|
log("registerForceFieldEvents is not implemented!");
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void registerWorldEditEvents() {
|
public void registerWorldEditEvents() {
|
||||||
// TODO Auto-generated method stub
|
// TODO Auto-generated method stub
|
||||||
|
log("registerWorldEditEvents is not implemented!");
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void registerTNTListener() {
|
public void registerTNTListener() {
|
||||||
// TODO Auto-generated method stub
|
// TODO Auto-generated method stub
|
||||||
|
log("registerTNTListener is not implemented!");
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@ -265,8 +283,14 @@ public class SpongeMain implements IPlotMain, PluginContainer {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public UUIDHandlerImplementation initUUIDHandler() {
|
public UUIDHandlerImplementation initUUIDHandler() {
|
||||||
// TODO Auto-generated method stub
|
UUIDWrapper wrapper;
|
||||||
return null;
|
if (Settings.OFFLINE_MODE || !PS.get().checkVersion(this.getServerVersion(), 1, 7, 6)) {
|
||||||
|
wrapper = new SpongeLowerOfflineUUIDWrapper();
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
wrapper = new SpongeOnlineUUIDWrapper();
|
||||||
|
}
|
||||||
|
return new SpongeUUIDHandler(wrapper);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@ -319,14 +343,19 @@ public class SpongeMain implements IPlotMain, PluginContainer {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String getServerName() {
|
public String getServerName() {
|
||||||
// TODO Auto-generated method stub
|
// TODO FIXME
|
||||||
return null;
|
throw new UnsupportedOperationException("NOT IMPLEMENTED YET");
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void startMetrics() {
|
public void startMetrics() {
|
||||||
// TODO Auto-generated method stub
|
try {
|
||||||
|
final SpongeMetrics metrics = new SpongeMetrics(game, this);
|
||||||
|
metrics.start();
|
||||||
|
log(C.PREFIX.s() + "&6Metrics enabled.");
|
||||||
|
} catch (final Exception e) {
|
||||||
|
log(C.PREFIX.s() + "&cFailed to load up metrics.");
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -0,0 +1,72 @@
|
|||||||
|
package com.plotsquared.sponge;
|
||||||
|
|
||||||
|
import java.util.UUID;
|
||||||
|
import java.util.concurrent.ExecutionException;
|
||||||
|
|
||||||
|
import com.intellectualcrafters.plot.object.OfflinePlotPlayer;
|
||||||
|
import com.intellectualcrafters.plot.object.PlotPlayer;
|
||||||
|
import com.intellectualcrafters.plot.util.UUIDHandler;
|
||||||
|
import com.intellectualcrafters.plot.uuid.UUIDWrapper;
|
||||||
|
|
||||||
|
public class SpongeOnlineUUIDWrapper extends UUIDWrapper {
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public UUID getUUID(PlotPlayer player) {
|
||||||
|
return ((SpongePlayer) player).player.getUniqueId();
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public UUID getUUID(OfflinePlotPlayer player) {
|
||||||
|
return player.getUUID();
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public UUID getUUID(String name) {
|
||||||
|
try {
|
||||||
|
return SpongeMain.THIS.getResolver().get(name, true).get().getUniqueId();
|
||||||
|
} catch (Exception e) {
|
||||||
|
e.printStackTrace();
|
||||||
|
}
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public OfflinePlotPlayer getOfflinePlayer(final UUID uuid) {
|
||||||
|
String name;
|
||||||
|
try {
|
||||||
|
name = SpongeMain.THIS.getResolver().get(uuid, true).get().getName();
|
||||||
|
}
|
||||||
|
catch (Exception e) {
|
||||||
|
name = null;
|
||||||
|
}
|
||||||
|
final String username = name;
|
||||||
|
return new OfflinePlotPlayer() {
|
||||||
|
@Override
|
||||||
|
public boolean isOnline() {
|
||||||
|
return UUIDHandler.getPlayer(uuid) != null;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public UUID getUUID() {
|
||||||
|
return uuid;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String getName() {
|
||||||
|
return username;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public long getLastPlayed() {
|
||||||
|
// TODO FIXME
|
||||||
|
throw new UnsupportedOperationException("NOT IMPLEMENTED YET");
|
||||||
|
}
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public OfflinePlotPlayer[] getOfflinePlayers() {
|
||||||
|
throw new UnsupportedOperationException("NOT IMPLEMENTED YET");
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
205
src/main/java/com/plotsquared/sponge/SpongePlayer.java
Normal file
205
src/main/java/com/plotsquared/sponge/SpongePlayer.java
Normal file
@ -0,0 +1,205 @@
|
|||||||
|
package com.plotsquared.sponge;
|
||||||
|
|
||||||
|
import java.util.HashMap;
|
||||||
|
import java.util.HashSet;
|
||||||
|
import java.util.UUID;
|
||||||
|
|
||||||
|
import org.bukkit.Bukkit;
|
||||||
|
import org.bukkit.permissions.Permission;
|
||||||
|
import org.bukkit.permissions.PermissionDefault;
|
||||||
|
import org.spongepowered.api.entity.player.Player;
|
||||||
|
import org.spongepowered.api.text.chat.ChatTypes;
|
||||||
|
|
||||||
|
import com.flowpowered.math.vector.Vector3d;
|
||||||
|
import com.intellectualcrafters.plot.commands.RequiredType;
|
||||||
|
import com.intellectualcrafters.plot.config.C;
|
||||||
|
import com.intellectualcrafters.plot.config.Settings;
|
||||||
|
import com.intellectualcrafters.plot.object.Location;
|
||||||
|
import com.intellectualcrafters.plot.object.PlotPlayer;
|
||||||
|
import com.intellectualcrafters.plot.util.EconHandler;
|
||||||
|
import com.intellectualcrafters.plot.util.MainUtil;
|
||||||
|
import com.intellectualcrafters.plot.util.UUIDHandler;
|
||||||
|
|
||||||
|
public class SpongePlayer implements PlotPlayer {
|
||||||
|
|
||||||
|
public final Player player;
|
||||||
|
private UUID uuid;
|
||||||
|
private String name;
|
||||||
|
private int op = 0;
|
||||||
|
private long last = 0;
|
||||||
|
private HashSet<String> hasPerm = new HashSet<>();
|
||||||
|
private HashSet<String> noPerm = new HashSet<>();
|
||||||
|
|
||||||
|
private HashMap<String, Object> meta;
|
||||||
|
|
||||||
|
public SpongePlayer(Player player) {
|
||||||
|
this.player = player;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void sendMessage(C c, String... args) {
|
||||||
|
MainUtil.sendMessage(this, c, args);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public RequiredType getSuperCaller() {
|
||||||
|
return RequiredType.PLAYER;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public long getPreviousLogin() {
|
||||||
|
return (long) (player.getJoinData().getLastPlayed().getSeconds()) * 1000;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public Location getLocation() {
|
||||||
|
return SpongeUtil.getLocation(player);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public Location getLocationFull() {
|
||||||
|
return SpongeUtil.getLocationFull(player);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public UUID getUUID() {
|
||||||
|
if (this.uuid == null) {
|
||||||
|
this.uuid = UUIDHandler.getUUID(this);
|
||||||
|
}
|
||||||
|
return uuid;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean hasPermission(String perm) {
|
||||||
|
if (Settings.PERMISSION_CACHING) {
|
||||||
|
if (this.noPerm.contains(perm)) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
if (this.hasPerm.contains(perm)) {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
final boolean result = this.player.hasPermission(perm);
|
||||||
|
if (!result) {
|
||||||
|
this.noPerm.add(perm);
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
this.hasPerm.add(perm);
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
return this.player.hasPermission(perm);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void sendMessage(String message) {
|
||||||
|
player.sendMessage(ChatTypes.CHAT, message);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void teleport(Location loc) {
|
||||||
|
String world = player.getWorld().getName();
|
||||||
|
if (world != loc.getWorld()) {
|
||||||
|
player.transferToWorld(world, new Vector3d(loc.getX(), loc.getY(), loc.getZ()));
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
org.spongepowered.api.world.Location current = player.getLocation();
|
||||||
|
player.setLocationSafely(current.setPosition(new Vector3d(loc.getX(), loc.getY(), loc.getZ())));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean isOp() {
|
||||||
|
if (this.op != 0) {
|
||||||
|
return this.op != 1;
|
||||||
|
}
|
||||||
|
final boolean result = this.player.hasPermission("*");
|
||||||
|
if (!result) {
|
||||||
|
this.op = 1;
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
this.op = 2;
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean isOnline() {
|
||||||
|
return player.isOnline();
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String getName() {
|
||||||
|
if (this.name == null) {
|
||||||
|
this.name = this.player.getName();
|
||||||
|
}
|
||||||
|
return this.name;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void setCompassTarget(Location loc) {
|
||||||
|
// TODO set compass target
|
||||||
|
throw new UnsupportedOperationException("NOT IMPLEMENTED YET");
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void loadData() {
|
||||||
|
// TODO Auto-generated method stub
|
||||||
|
throw new UnsupportedOperationException("NOT IMPLEMENTED YET");
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void saveData() {
|
||||||
|
// TODO Auto-generated method stub
|
||||||
|
throw new UnsupportedOperationException("NOT IMPLEMENTED YET");
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void setMeta(String key, Object value) {
|
||||||
|
if (this.meta == null) {
|
||||||
|
this.meta = new HashMap<String, Object>();
|
||||||
|
}
|
||||||
|
this.meta.put(key, value);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public Object getMeta(String key) {
|
||||||
|
if (this.meta != null) {
|
||||||
|
return this.meta.get(key);
|
||||||
|
}
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void deleteMeta(String key) {
|
||||||
|
if (this.meta != null) {
|
||||||
|
this.meta.remove(key);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String toString() {
|
||||||
|
return getName();
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void setAttribute(String key) {
|
||||||
|
key = "plotsquared_user_attributes." + key;
|
||||||
|
EconHandler.manager.setPermission(this, key, true);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean getAttribute(String key) {
|
||||||
|
key = "plotsquared_user_attributes." + key;
|
||||||
|
Permission perm = Bukkit.getServer().getPluginManager().getPermission(key);
|
||||||
|
if (perm == null) {
|
||||||
|
perm = new Permission(key, PermissionDefault.FALSE);
|
||||||
|
Bukkit.getServer().getPluginManager().addPermission(perm);
|
||||||
|
Bukkit.getServer().getPluginManager().recalculatePermissionDefaults(perm);
|
||||||
|
}
|
||||||
|
return player.hasPermission(key);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void removeAttribute(String key) {
|
||||||
|
key = "plotsquared_user_attributes." + key;
|
||||||
|
EconHandler.manager.setPermission(this, key, false);
|
||||||
|
}
|
||||||
|
}
|
59
src/main/java/com/plotsquared/sponge/SpongeTaskManager.java
Normal file
59
src/main/java/com/plotsquared/sponge/SpongeTaskManager.java
Normal file
@ -0,0 +1,59 @@
|
|||||||
|
package com.plotsquared.sponge;
|
||||||
|
|
||||||
|
import java.util.HashMap;
|
||||||
|
import java.util.concurrent.atomic.AtomicInteger;
|
||||||
|
|
||||||
|
import org.spongepowered.api.service.scheduler.Task;
|
||||||
|
import org.spongepowered.api.service.scheduler.TaskBuilder;
|
||||||
|
|
||||||
|
import com.intellectualcrafters.plot.util.TaskManager;
|
||||||
|
|
||||||
|
public class SpongeTaskManager extends TaskManager {
|
||||||
|
|
||||||
|
private AtomicInteger i = new AtomicInteger();
|
||||||
|
|
||||||
|
private HashMap<Integer, Task> tasks = new HashMap<>();
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public int taskRepeat(Runnable r, int interval) {
|
||||||
|
int val = i.incrementAndGet();
|
||||||
|
TaskBuilder builder = SpongeMain.THIS.getGame().getScheduler().getTaskBuilder();
|
||||||
|
TaskBuilder built = builder.delay(interval).interval(interval).execute(r);
|
||||||
|
Task task = built.submit(SpongeMain.THIS.getPlugin());
|
||||||
|
tasks.put(val, task);
|
||||||
|
return val;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void taskAsync(Runnable r) {
|
||||||
|
TaskBuilder builder = SpongeMain.THIS.getGame().getScheduler().getTaskBuilder();
|
||||||
|
builder.async().execute(r);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void task(Runnable r) {
|
||||||
|
TaskBuilder builder = SpongeMain.THIS.getGame().getScheduler().getTaskBuilder();
|
||||||
|
builder.execute(r);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void taskLater(Runnable r, int delay) {
|
||||||
|
TaskBuilder builder = SpongeMain.THIS.getGame().getScheduler().getTaskBuilder();
|
||||||
|
builder.delay(delay).execute(r);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void taskLaterAsync(Runnable r, int delay) {
|
||||||
|
TaskBuilder builder = SpongeMain.THIS.getGame().getScheduler().getTaskBuilder();
|
||||||
|
builder.async().delay(delay).execute(r);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void cancelTask(int i) {
|
||||||
|
Task task = tasks.remove(i);
|
||||||
|
if (task != null) {
|
||||||
|
task.cancel();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
53
src/main/java/com/plotsquared/sponge/SpongeUUIDHandler.java
Normal file
53
src/main/java/com/plotsquared/sponge/SpongeUUIDHandler.java
Normal file
@ -0,0 +1,53 @@
|
|||||||
|
package com.plotsquared.sponge;
|
||||||
|
|
||||||
|
import java.util.Collection;
|
||||||
|
import java.util.UUID;
|
||||||
|
|
||||||
|
import org.spongepowered.api.GameProfile;
|
||||||
|
import org.spongepowered.api.service.profile.GameProfileResolver;
|
||||||
|
|
||||||
|
import com.google.inject.Inject;
|
||||||
|
import com.intellectualcrafters.plot.database.DBFunc;
|
||||||
|
import com.intellectualcrafters.plot.object.RunnableVal;
|
||||||
|
import com.intellectualcrafters.plot.object.StringWrapper;
|
||||||
|
import com.intellectualcrafters.plot.util.TaskManager;
|
||||||
|
import com.intellectualcrafters.plot.util.UUIDHandlerImplementation;
|
||||||
|
import com.intellectualcrafters.plot.uuid.UUIDWrapper;
|
||||||
|
|
||||||
|
public class SpongeUUIDHandler extends UUIDHandlerImplementation {
|
||||||
|
|
||||||
|
public SpongeUUIDHandler(UUIDWrapper wrapper) {
|
||||||
|
super(wrapper);
|
||||||
|
// TODO Auto-generated constructor stub
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean startCaching(Runnable whenDone) {
|
||||||
|
if (!super.startCaching(whenDone)) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
return cache(whenDone);
|
||||||
|
}
|
||||||
|
|
||||||
|
public boolean cache(Runnable whenDone) {
|
||||||
|
// TODO cache UUIDS
|
||||||
|
// SpongeMain.THIS.getRegistry().get
|
||||||
|
add(new StringWrapper("*"), DBFunc.everyone);
|
||||||
|
for (GameProfile profile : SpongeMain.THIS.getResolver().getCachedProfiles()) {
|
||||||
|
add(new StringWrapper(profile.getName()), profile.getUniqueId());
|
||||||
|
}
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void fetchUUID(final String name, final RunnableVal<UUID> ifFetch) {
|
||||||
|
TaskManager.runTaskAsync(new Runnable() {
|
||||||
|
@Override
|
||||||
|
public void run() {
|
||||||
|
ifFetch.value = uuidWrapper.getUUID(name);
|
||||||
|
TaskManager.runTask(ifFetch);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
28
src/main/java/com/plotsquared/sponge/SpongeUtil.java
Normal file
28
src/main/java/com/plotsquared/sponge/SpongeUtil.java
Normal file
@ -0,0 +1,28 @@
|
|||||||
|
package com.plotsquared.sponge;
|
||||||
|
|
||||||
|
import org.spongepowered.api.entity.Entity;
|
||||||
|
|
||||||
|
import com.flowpowered.math.vector.Vector3d;
|
||||||
|
import com.flowpowered.math.vector.Vector3i;
|
||||||
|
import com.intellectualcrafters.plot.object.Location;
|
||||||
|
import com.intellectualcrafters.plot.util.MathMan;
|
||||||
|
|
||||||
|
public class SpongeUtil {
|
||||||
|
|
||||||
|
public static Location getLocation(Entity player) {
|
||||||
|
String world = player.getWorld().getName();
|
||||||
|
org.spongepowered.api.world.Location loc = player.getLocation();
|
||||||
|
Vector3i pos = loc.getBlockPosition();
|
||||||
|
return new Location(world, pos.getX(), pos.getY(), pos.getZ());
|
||||||
|
}
|
||||||
|
|
||||||
|
public static Location getLocationFull(Entity player) {
|
||||||
|
String world = player.getWorld().getName();
|
||||||
|
Vector3d rot = player.getRotation();
|
||||||
|
float[] pitchYaw = MathMan.getPitchAndYaw((float) rot.getX(), (float) rot.getY(), (float) rot.getZ());
|
||||||
|
org.spongepowered.api.world.Location loc = player.getLocation();
|
||||||
|
Vector3i pos = loc.getBlockPosition();
|
||||||
|
return new Location(world, pos.getX(), pos.getY(), pos.getZ(), pitchYaw[1], pitchYaw[0]);
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
Loading…
Reference in New Issue
Block a user