mirror of
https://github.com/IntellectualSites/PlotSquared.git
synced 2025-06-25 10:14:42 +02:00
Merge remote-tracking branch 'origin/master'
# Conflicts: # Bukkit/src/main/java/com/plotsquared/bukkit/util/block/FastQueue_1_8_3.java # Bukkit/src/main/java/com/plotsquared/bukkit/util/block/FastQueue_1_9.java
This commit is contained in:
@ -13,6 +13,7 @@ import com.intellectualcrafters.plot.object.PlotManager;
|
||||
import com.intellectualcrafters.plot.object.PlotPlayer;
|
||||
import com.intellectualcrafters.plot.util.ChunkManager;
|
||||
import com.intellectualcrafters.plot.util.MainUtil;
|
||||
import com.intellectualcrafters.plot.util.Permissions;
|
||||
import com.intellectualcrafters.plot.util.SchematicHandler;
|
||||
import com.intellectualcrafters.plot.util.SetQueue;
|
||||
import com.intellectualcrafters.plot.util.UUIDHandler;
|
||||
@ -32,28 +33,20 @@ import java.util.UUID;
|
||||
|
||||
/**
|
||||
* PlotSquared API.
|
||||
* <br>
|
||||
* <br>
|
||||
* Useful classes:<br>
|
||||
* @see BukkitUtil
|
||||
* @see PlotPlayer
|
||||
* @see Plot
|
||||
* @see com.intellectualcrafters.plot.object.Location
|
||||
* @see PlotArea
|
||||
* @see PS
|
||||
*
|
||||
* <p>Useful classes:</p>
|
||||
* <ul>
|
||||
* <li>{@link BukkitUtil}</li>
|
||||
* <li>{@link PlotPlayer}</li>
|
||||
* <li>{@link Plot}</li>
|
||||
* <li>{@link com.intellectualcrafters.plot.object.Location}</li>
|
||||
* <li>{@link PlotArea}</li>
|
||||
* <li>{@link PS}</li>
|
||||
* </ul>
|
||||
* @version 3.3.3
|
||||
>>>>>>> origin/master
|
||||
*/
|
||||
public class PlotAPI {
|
||||
|
||||
/**
|
||||
* Permission that allows for admin access, this permission node will allow
|
||||
* the player to use any part of the plugin, without limitations.
|
||||
* @deprecated Use C.PERMISSION_ADMIN instead
|
||||
*/
|
||||
@Deprecated
|
||||
public static final String ADMIN_PERMISSION = C.PERMISSION_ADMIN.s();
|
||||
|
||||
/**
|
||||
* Deprecated, does nothing.
|
||||
* @param plugin not needed
|
||||
@ -63,24 +56,6 @@ public class PlotAPI {
|
||||
public PlotAPI(JavaPlugin plugin) {
|
||||
}
|
||||
|
||||
/**
|
||||
* Default Constructor that does nothing.
|
||||
*
|
||||
* @deprecated Use this class if you just want to do a few simple things
|
||||
* <ul>
|
||||
* <li>It will remain stable for future versions
|
||||
* of the plugin</li>
|
||||
* <li>The PlotPlayer and Plot class should be considered
|
||||
* relatively safe</li>
|
||||
* <li>For more advanced/intensive tasks you should consider
|
||||
* using other classes</li>
|
||||
* </ul>
|
||||
*
|
||||
*/
|
||||
@Deprecated
|
||||
public PlotAPI() {
|
||||
}
|
||||
|
||||
/**
|
||||
* Get all plots.
|
||||
*
|
||||
@ -156,7 +131,7 @@ public class PlotAPI {
|
||||
*
|
||||
* @return ChunkManager
|
||||
*
|
||||
* @see com.intellectualcrafters.plot.util.ChunkManager
|
||||
* @see ChunkManager
|
||||
*/
|
||||
public ChunkManager getChunkManager() {
|
||||
return ChunkManager.manager;
|
||||
@ -176,7 +151,7 @@ public class PlotAPI {
|
||||
*
|
||||
* @return UUIDWrapper
|
||||
*
|
||||
* @see com.intellectualcrafters.plot.uuid.UUIDWrapper
|
||||
* @see UUIDWrapper
|
||||
*/
|
||||
public UUIDWrapper getUUIDWrapper() {
|
||||
return UUIDHandler.getUUIDWrapper();
|
||||
@ -211,7 +186,7 @@ public class PlotAPI {
|
||||
*
|
||||
* @return Array of strings
|
||||
*
|
||||
* @see com.intellectualcrafters.plot.util.Permissions
|
||||
* @see Permissions
|
||||
* @deprecated Use {@link C} to list all the permissions
|
||||
*/
|
||||
@Deprecated
|
||||
@ -231,7 +206,7 @@ public class PlotAPI {
|
||||
*
|
||||
* @return SchematicHandler
|
||||
*
|
||||
* @see com.intellectualcrafters.plot.util.SchematicHandler
|
||||
* @see SchematicHandler
|
||||
*/
|
||||
public SchematicHandler getSchematicHandler() {
|
||||
return SchematicHandler.manager;
|
||||
@ -256,7 +231,7 @@ public class PlotAPI {
|
||||
*
|
||||
* @return PlotManager
|
||||
*
|
||||
* @see com.intellectualcrafters.plot.object.PlotManager
|
||||
* @see PlotManager
|
||||
* @see PS#getPlotManager(Plot)
|
||||
*/
|
||||
@Deprecated
|
||||
@ -288,7 +263,7 @@ public class PlotAPI {
|
||||
* @return PlotManager
|
||||
*
|
||||
* @see PS#getPlotManager(Plot)
|
||||
* @see com.intellectualcrafters.plot.object.PlotManager
|
||||
* @see PlotManager
|
||||
*/
|
||||
@Deprecated
|
||||
public PlotManager getPlotManager(String world) {
|
||||
@ -314,7 +289,7 @@ public class PlotAPI {
|
||||
* @return The {@link PlotArea} for the world or null if not in plotworld
|
||||
*
|
||||
* @see #getPlotAreas(World)
|
||||
* @see com.intellectualcrafters.plot.object.PlotArea
|
||||
* @see PlotArea
|
||||
*/
|
||||
@Deprecated
|
||||
public PlotArea getWorldSettings(World world) {
|
||||
@ -332,7 +307,7 @@ public class PlotAPI {
|
||||
* @return The {@link PlotArea} for the world or null if not in plotworld
|
||||
*
|
||||
* @see PS#getPlotArea(String, String)
|
||||
* @see com.intellectualcrafters.plot.object.PlotArea
|
||||
* @see PlotArea
|
||||
*/
|
||||
@Deprecated
|
||||
public PlotArea getWorldSettings(String world) {
|
||||
@ -392,7 +367,7 @@ public class PlotAPI {
|
||||
* @param caption The caption
|
||||
*
|
||||
* @see #sendConsoleMessage(String)
|
||||
* @see com.intellectualcrafters.plot.config.C
|
||||
* @see C
|
||||
*/
|
||||
public void sendConsoleMessage(C caption) {
|
||||
sendConsoleMessage(caption.s());
|
||||
@ -403,8 +378,8 @@ public class PlotAPI {
|
||||
*
|
||||
* @param flag Flag that should be registered
|
||||
*
|
||||
* @see com.intellectualcrafters.plot.flag.FlagManager#addFlag(com.intellectualcrafters.plot.flag.AbstractFlag)
|
||||
* @see com.intellectualcrafters.plot.flag.AbstractFlag
|
||||
* @see FlagManager#addFlag(AbstractFlag)
|
||||
* @see AbstractFlag
|
||||
*/
|
||||
public void addFlag(AbstractFlag flag) {
|
||||
FlagManager.addFlag(flag);
|
||||
@ -415,8 +390,8 @@ public class PlotAPI {
|
||||
*
|
||||
* @return array of Flag[]
|
||||
*
|
||||
* @see com.intellectualcrafters.plot.flag.FlagManager#getFlags()
|
||||
* @see com.intellectualcrafters.plot.flag.AbstractFlag
|
||||
* @see FlagManager#getFlags()
|
||||
* @see AbstractFlag
|
||||
*/
|
||||
public AbstractFlag[] getFlags() {
|
||||
return FlagManager.getFlags().toArray(new AbstractFlag[FlagManager.getFlags().size()]);
|
||||
@ -468,7 +443,7 @@ public class PlotAPI {
|
||||
*
|
||||
* @return plot if found, otherwise it creates a temporary plot
|
||||
*
|
||||
* @see #getPlot(org.bukkit.Location)
|
||||
* @see #getPlot(Location)
|
||||
* @see Plot
|
||||
*/
|
||||
public Plot getPlot(Player player) {
|
||||
@ -638,7 +613,7 @@ public class PlotAPI {
|
||||
* Register a subcommand.
|
||||
* @deprecated Command registration is done on object creation
|
||||
* @param c SubCommand, that we want to register
|
||||
* @see com.intellectualcrafters.plot.commands.SubCommand
|
||||
* @see SubCommand
|
||||
*/
|
||||
@Deprecated
|
||||
public void registerCommand(SubCommand c) {
|
||||
|
@ -73,14 +73,9 @@ import com.plotsquared.bukkit.uuid.LowerOfflineUUIDWrapper;
|
||||
import com.plotsquared.bukkit.uuid.OfflineUUIDWrapper;
|
||||
import com.plotsquared.bukkit.uuid.SQLUUIDHandler;
|
||||
import com.sk89q.worldedit.bukkit.WorldEditPlugin;
|
||||
import java.io.File;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
import java.util.Iterator;
|
||||
import java.util.List;
|
||||
import java.util.UUID;
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.ChatColor;
|
||||
import org.bukkit.Chunk;
|
||||
import org.bukkit.Location;
|
||||
import org.bukkit.OfflinePlayer;
|
||||
import org.bukkit.World;
|
||||
@ -93,9 +88,15 @@ import org.bukkit.metadata.MetadataValue;
|
||||
import org.bukkit.plugin.Plugin;
|
||||
import org.bukkit.plugin.java.JavaPlugin;
|
||||
|
||||
import java.io.File;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
import java.util.Iterator;
|
||||
import java.util.List;
|
||||
import java.util.UUID;
|
||||
|
||||
public class BukkitMain extends JavaPlugin implements Listener, IPlotMain {
|
||||
|
||||
public static BukkitMain THIS;
|
||||
public static WorldEditPlugin worldEdit;
|
||||
|
||||
private int[] version;
|
||||
@ -123,7 +124,6 @@ public class BukkitMain extends JavaPlugin implements Listener, IPlotMain {
|
||||
|
||||
@Override
|
||||
public void onEnable() {
|
||||
BukkitMain.THIS = this;
|
||||
new PS(this, "Bukkit");
|
||||
}
|
||||
|
||||
@ -131,40 +131,35 @@ public class BukkitMain extends JavaPlugin implements Listener, IPlotMain {
|
||||
public void onDisable() {
|
||||
PS.get().disable();
|
||||
Bukkit.getScheduler().cancelTasks(this);
|
||||
BukkitMain.THIS = null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void log(String message) {
|
||||
if (BukkitMain.THIS != null) {
|
||||
try {
|
||||
message = C.color(message);
|
||||
if (!Settings.CONSOLE_COLOR) {
|
||||
message = ChatColor.stripColor(message);
|
||||
}
|
||||
this.getServer().getConsoleSender().sendMessage(message);
|
||||
return;
|
||||
} catch (Throwable ignored) {
|
||||
//ignored
|
||||
try {
|
||||
message = C.color(message);
|
||||
if (!Settings.CONSOLE_COLOR) {
|
||||
message = ChatColor.stripColor(message);
|
||||
}
|
||||
this.getServer().getConsoleSender().sendMessage(message);
|
||||
return;
|
||||
} catch (Throwable ignored) {
|
||||
//ignored
|
||||
}
|
||||
System.out.println(ConsoleColors.fromString(message));
|
||||
}
|
||||
|
||||
@Override
|
||||
public void disable() {
|
||||
if (BukkitMain.THIS != null) {
|
||||
onDisable();
|
||||
}
|
||||
onDisable();
|
||||
}
|
||||
|
||||
@Override
|
||||
public int[] getPluginVersion() {
|
||||
String version = getDescription().getVersion();
|
||||
if (version.contains("-SNAPSHOT")) {
|
||||
version = version.split("-SNAPSHOT")[0];
|
||||
String ver = getDescription().getVersion();
|
||||
if (ver.contains("-SNAPSHOT")) {
|
||||
ver = ver.split("-SNAPSHOT")[0];
|
||||
}
|
||||
String[] split = version.split("\\.");
|
||||
String[] split = ver.split("\\.");
|
||||
return new int[]{Integer.parseInt(split[0]), Integer.parseInt(split[1]), Integer.parseInt(split[2])};
|
||||
}
|
||||
|
||||
@ -189,7 +184,7 @@ public class BukkitMain extends JavaPlugin implements Listener, IPlotMain {
|
||||
|
||||
@Override
|
||||
public TaskManager getTaskManager() {
|
||||
return new BukkitTaskManager();
|
||||
return new BukkitTaskManager(this);
|
||||
}
|
||||
|
||||
@Override
|
||||
@ -402,7 +397,7 @@ public class BukkitMain extends JavaPlugin implements Listener, IPlotMain {
|
||||
}
|
||||
|
||||
@Override
|
||||
public PlotQueue initPlotQueue() {
|
||||
public PlotQueue<Chunk> initPlotQueue() {
|
||||
try {
|
||||
new SendChunk();
|
||||
MainUtil.canSendChunk = true;
|
||||
@ -449,18 +444,15 @@ public class BukkitMain extends JavaPlugin implements Listener, IPlotMain {
|
||||
TaskManager.runTaskLaterAsync(new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
if (new LikePlotMeConverter("PlotMe").run(new ClassicPlotMeConnector())) {
|
||||
if (new LikePlotMeConverter().run(new ClassicPlotMeConnector())) {
|
||||
return;
|
||||
}
|
||||
if (new LikePlotMeConverter("PlotMe").run(new PlotMeConnector_017())) {
|
||||
return;
|
||||
}
|
||||
if (new LikePlotMeConverter("AthionPlots").run(new ClassicPlotMeConnector())) {
|
||||
if (new LikePlotMeConverter().run(new PlotMeConnector_017())) {
|
||||
return;
|
||||
}
|
||||
}
|
||||
}, 20);
|
||||
return Bukkit.getPluginManager().getPlugin("PlotMe") != null || Bukkit.getPluginManager().getPlugin("AthionPlots") != null;
|
||||
return Bukkit.getPluginManager().getPlugin("PlotMe") != null;
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -15,7 +15,7 @@ import java.util.HashMap;
|
||||
|
||||
abstract class APlotMeConnector {
|
||||
|
||||
public abstract Connection getPlotMeConnection(String plugin, FileConfiguration plotConfig, String dataFolder);
|
||||
public abstract Connection getPlotMeConnection(FileConfiguration plotConfig, String dataFolder);
|
||||
|
||||
public abstract HashMap<String, HashMap<PlotId, Plot>> getPlotMePlots(Connection connection) throws SQLException;
|
||||
|
||||
|
@ -30,16 +30,15 @@ public class ClassicPlotMeConnector extends APlotMeConnector {
|
||||
private String prefix;
|
||||
|
||||
@Override
|
||||
public Connection getPlotMeConnection(String plugin, FileConfiguration plotConfig, String dataFolder) {
|
||||
this.plugin = plugin.toLowerCase();
|
||||
this.prefix = plotConfig.getString("mySQLprefix", plugin.toLowerCase());
|
||||
public Connection getPlotMeConnection(FileConfiguration plotConfig, String dataFolder) {
|
||||
this.plugin = this.plugin.toLowerCase();
|
||||
this.prefix = plotConfig.getString("mySQLprefix", this.plugin.toLowerCase());
|
||||
try {
|
||||
if (plotConfig.getBoolean("usemySQL")) {
|
||||
String user = plotConfig.getString("mySQLuname");
|
||||
String password = plotConfig.getString("mySQLpass");
|
||||
String con = plotConfig.getString("mySQLconn");
|
||||
return DriverManager.getConnection(con, user, password);
|
||||
// return new MySQL(plotsquared, hostname, port, database, username, password)
|
||||
} else {
|
||||
return new SQLite(dataFolder + File.separator + "plots.db").openConnection();
|
||||
}
|
||||
@ -110,32 +109,21 @@ public class ClassicPlotMeConnector extends APlotMeConnector {
|
||||
owner = DBFunc.everyone;
|
||||
} else {
|
||||
if (checkUUID || checkUUID2) {
|
||||
try {
|
||||
byte[] bytes = resultSet.getBytes(column);
|
||||
if (bytes != null) {
|
||||
try {
|
||||
ByteBuffer bb = ByteBuffer.wrap(bytes);
|
||||
long high = bb.getLong();
|
||||
long low = bb.getLong();
|
||||
owner = new UUID(high, low);
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
owner = UUID.nameUUIDFromBytes(bytes);
|
||||
}
|
||||
UUIDHandler.add(new StringWrapper(name), owner);
|
||||
}
|
||||
} catch (SQLException e) {
|
||||
e.printStackTrace();
|
||||
byte[] bytes = resultSet.getBytes(column);
|
||||
if (bytes != null) {
|
||||
ByteBuffer bb = ByteBuffer.wrap(bytes);
|
||||
long high = bb.getLong();
|
||||
long low = bb.getLong();
|
||||
owner = new UUID(high, low);
|
||||
UUIDHandler.add(new StringWrapper(name), owner);
|
||||
}
|
||||
}
|
||||
if (owner == null) {
|
||||
if (name.isEmpty()) {
|
||||
PS.log("&cCould not identify owner for plot: " + id + " -> '" + name + "'");
|
||||
missing++;
|
||||
continue;
|
||||
}
|
||||
owner = UUID.nameUUIDFromBytes(("OfflinePlayer:" + name.toLowerCase()).getBytes(Charsets.UTF_8));
|
||||
if (name.isEmpty()) {
|
||||
PS.log("&cCould not identify owner for plot: " + id + " -> '" + name + "'");
|
||||
missing++;
|
||||
continue;
|
||||
}
|
||||
owner = UUID.nameUUIDFromBytes(("OfflinePlayer:" + name.toLowerCase()).getBytes(Charsets.UTF_8));
|
||||
}
|
||||
} else {
|
||||
UUIDHandler.add(new StringWrapper(name), owner);
|
||||
@ -180,22 +168,13 @@ public class ClassicPlotMeConnector extends APlotMeConnector {
|
||||
if ("*".equals(name)) {
|
||||
denied = DBFunc.everyone;
|
||||
} else if (DBFunc.hasColumn(resultSet, "playerid")) {
|
||||
try {
|
||||
byte[] bytes = resultSet.getBytes("playerid");
|
||||
if (bytes != null) {
|
||||
try {
|
||||
ByteBuffer bb = ByteBuffer.wrap(bytes);
|
||||
long high = bb.getLong();
|
||||
long low = bb.getLong();
|
||||
denied = new UUID(high, low);
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
denied = UUID.nameUUIDFromBytes(bytes);
|
||||
}
|
||||
UUIDHandler.add(new StringWrapper(name), denied);
|
||||
}
|
||||
} catch (SQLException e) {
|
||||
e.printStackTrace();
|
||||
byte[] bytes = resultSet.getBytes("playerid");
|
||||
if (bytes != null) {
|
||||
ByteBuffer bb = ByteBuffer.wrap(bytes);
|
||||
long mostSigBits = bb.getLong();
|
||||
long leastSigBits = bb.getLong();
|
||||
denied = new UUID(mostSigBits, leastSigBits);
|
||||
UUIDHandler.add(new StringWrapper(name), denied);
|
||||
}
|
||||
}
|
||||
if (denied == null) {
|
||||
@ -224,22 +203,13 @@ public class ClassicPlotMeConnector extends APlotMeConnector {
|
||||
if ("*".equals(name)) {
|
||||
helper = DBFunc.everyone;
|
||||
} else if (DBFunc.hasColumn(resultSet, "playerid")) {
|
||||
try {
|
||||
byte[] bytes = resultSet.getBytes("playerid");
|
||||
if (bytes != null) {
|
||||
try {
|
||||
ByteBuffer bb = ByteBuffer.wrap(bytes);
|
||||
long high = bb.getLong();
|
||||
long low = bb.getLong();
|
||||
helper = new UUID(high, low);
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
helper = UUID.nameUUIDFromBytes(bytes);
|
||||
}
|
||||
UUIDHandler.add(new StringWrapper(name), helper);
|
||||
}
|
||||
} catch (SQLException e) {
|
||||
e.printStackTrace();
|
||||
byte[] bytes = resultSet.getBytes("playerid");
|
||||
if (bytes != null) {
|
||||
ByteBuffer bb = ByteBuffer.wrap(bytes);
|
||||
long mostSigBits = bb.getLong();
|
||||
long leastSigBits = bb.getLong();
|
||||
helper = new UUID(mostSigBits, leastSigBits);
|
||||
UUIDHandler.add(new StringWrapper(name), helper);
|
||||
}
|
||||
}
|
||||
if (helper == null) {
|
||||
|
@ -24,6 +24,7 @@ import java.nio.file.Files;
|
||||
import java.nio.file.Path;
|
||||
import java.nio.file.Paths;
|
||||
import java.sql.Connection;
|
||||
import java.sql.SQLException;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collections;
|
||||
import java.util.HashMap;
|
||||
@ -33,17 +34,6 @@ import java.util.concurrent.atomic.AtomicBoolean;
|
||||
|
||||
public class LikePlotMeConverter {
|
||||
|
||||
private final String plugin;
|
||||
|
||||
/**
|
||||
* Constructor.
|
||||
*
|
||||
* @param plugin Plugin Used to run the converter
|
||||
*/
|
||||
public LikePlotMeConverter(String plugin) {
|
||||
this.plugin = plugin;
|
||||
}
|
||||
|
||||
public static String getWorld(String world) {
|
||||
for (World newWorld : Bukkit.getWorlds()) {
|
||||
if (newWorld.getName().equalsIgnoreCase(world)) {
|
||||
@ -58,11 +48,7 @@ public class LikePlotMeConverter {
|
||||
}
|
||||
|
||||
public String getPlotMePath() {
|
||||
return new File(".").getAbsolutePath() + File.separator + "plugins" + File.separator + this.plugin + File.separator;
|
||||
}
|
||||
|
||||
public String getAthionPlotsPath() {
|
||||
return new File(".").getAbsolutePath() + File.separator + "plugins" + File.separator + this.plugin + File.separator;
|
||||
return new File(".").getAbsolutePath() + File.separator + "plugins" + File.separator + "PlotMe" + File.separator;
|
||||
}
|
||||
|
||||
public FileConfiguration getPlotMeConfig(String dataFolder) {
|
||||
@ -77,10 +63,10 @@ public class LikePlotMeConverter {
|
||||
return plotConfig.getConfigurationSection("worlds").getKeys(false);
|
||||
}
|
||||
|
||||
public void mergeWorldYml(String plugin, FileConfiguration plotConfig) {
|
||||
public void mergeWorldYml(FileConfiguration plotConfig) {
|
||||
try {
|
||||
File genConfig =
|
||||
new File("plugins" + File.separator + plugin + File.separator + "PlotMe-DefaultGenerator" + File.separator + "config.yml");
|
||||
new File("plugins" + File.separator + "PlotMe" + File.separator + "PlotMe-DefaultGenerator" + File.separator + "config.yml");
|
||||
if (genConfig.exists()) {
|
||||
YamlConfiguration yml = YamlConfiguration.loadConfiguration(genConfig);
|
||||
for (String key : yml.getKeys(true)) {
|
||||
@ -97,7 +83,7 @@ public class LikePlotMeConverter {
|
||||
}
|
||||
}
|
||||
|
||||
public void updateWorldYml(String plugin, String location) {
|
||||
public void updateWorldYml(String location) {
|
||||
try {
|
||||
Path path = Paths.get(location);
|
||||
File file = new File(location);
|
||||
@ -106,7 +92,7 @@ public class LikePlotMeConverter {
|
||||
}
|
||||
String content = new String(Files.readAllBytes(path), StandardCharsets.UTF_8);
|
||||
content = content.replaceAll("PlotMe-DefaultGenerator", "PlotSquared");
|
||||
content = content.replaceAll(plugin, "PlotSquared");
|
||||
content = content.replaceAll("PlotMe", "PlotSquared");
|
||||
Files.write(path, content.getBytes(StandardCharsets.UTF_8));
|
||||
} catch (IOException ignored) {
|
||||
//ignored
|
||||
@ -131,31 +117,31 @@ public class LikePlotMeConverter {
|
||||
|
||||
PS.debug("&3Using connector: " + connector.getClass().getCanonicalName());
|
||||
|
||||
Connection connection = connector.getPlotMeConnection(this.plugin, plotConfig, dataFolder);
|
||||
Connection connection = connector.getPlotMeConnection(plotConfig, dataFolder);
|
||||
|
||||
if (!connector.isValidConnection(connection)) {
|
||||
sendMessage("Cannot connect to PlotMe DB. Conversion process will not continue");
|
||||
return false;
|
||||
}
|
||||
|
||||
sendMessage(this.plugin + " conversion has started. To disable this, please set 'plotme-convert.enabled' to false in the 'settings.yml'");
|
||||
sendMessage("PlotMe conversion has started. To disable this, please set 'plotme-convert.enabled' to false in the 'settings.yml'");
|
||||
|
||||
mergeWorldYml(this.plugin, plotConfig);
|
||||
mergeWorldYml(plotConfig);
|
||||
|
||||
sendMessage("Connecting to " + this.plugin + " DB");
|
||||
sendMessage("Connecting to PlotMe DB");
|
||||
|
||||
ArrayList<Plot> createdPlots = new ArrayList<>();
|
||||
|
||||
sendMessage("Collecting plot data");
|
||||
|
||||
String dbPrefix = this.plugin.toLowerCase();
|
||||
String dbPrefix = "PlotMe".toLowerCase();
|
||||
sendMessage(" - " + dbPrefix + "Plots");
|
||||
final Set<String> worlds = getPlotMeWorlds(plotConfig);
|
||||
|
||||
if (Settings.CONVERT_PLOTME) {
|
||||
sendMessage("Updating bukkit.yml");
|
||||
updateWorldYml(this.plugin, "bukkit.yml");
|
||||
updateWorldYml(this.plugin, "plugins/Multiverse-Core/worlds.yml");
|
||||
updateWorldYml("bukkit.yml");
|
||||
updateWorldYml("plugins/Multiverse-Core/worlds.yml");
|
||||
for (String world : plotConfig.getConfigurationSection("worlds").getKeys(false)) {
|
||||
sendMessage("Copying config for: " + world);
|
||||
try {
|
||||
@ -188,24 +174,17 @@ public class LikePlotMeConverter {
|
||||
for (String world : plots.keySet()) {
|
||||
String actualWorldName = getWorld(world);
|
||||
String plotMeWorldName = world.toLowerCase();
|
||||
Integer pathwidth = plotmeDgYml.getInt("worlds." + plotMeWorldName + ".PathWidth"); //
|
||||
/*
|
||||
* TODO: dead code
|
||||
*
|
||||
if (pathwidth == null) {
|
||||
pathwidth = 7;
|
||||
}
|
||||
*/
|
||||
PS.get().config.set("worlds." + world + ".road.width", pathwidth);
|
||||
Integer pathWidth = plotmeDgYml.getInt("worlds." + plotMeWorldName + ".PathWidth"); //
|
||||
PS.get().config.set("worlds." + world + ".road.width", pathWidth);
|
||||
|
||||
Integer pathheight = plotmeDgYml.getInt("worlds." + plotMeWorldName + ".RoadHeight"); //
|
||||
if (pathheight == 0) {
|
||||
pathheight = 64;
|
||||
int pathHeight = plotmeDgYml.getInt("worlds." + plotMeWorldName + ".RoadHeight"); //
|
||||
if (pathHeight == 0) {
|
||||
pathHeight = 64;
|
||||
}
|
||||
PS.get().config.set("worlds." + world + ".road.height", pathheight);
|
||||
PS.get().config.set("worlds." + world + ".wall.height", pathheight);
|
||||
PS.get().config.set("worlds." + world + ".plot.height", pathheight);
|
||||
Integer plotSize = plotmeDgYml.getInt("worlds." + plotMeWorldName + ".PlotSize"); //
|
||||
PS.get().config.set("worlds." + world + ".road.height", pathHeight);
|
||||
PS.get().config.set("worlds." + world + ".wall.height", pathHeight);
|
||||
PS.get().config.set("worlds." + world + ".plot.height", pathHeight);
|
||||
int plotSize = plotmeDgYml.getInt("worlds." + plotMeWorldName + ".PlotSize", 32); //
|
||||
if (plotSize == 0) {
|
||||
plotSize = 32;
|
||||
}
|
||||
@ -218,7 +197,7 @@ public class LikePlotMeConverter {
|
||||
PS.get().config.set("worlds." + world + ".plot.filling", Collections.singletonList(filling));
|
||||
String road = plotmeDgYml.getString("worlds." + plotMeWorldName + ".RoadMainBlock", "5");
|
||||
PS.get().config.set("worlds." + world + ".road.block", road);
|
||||
Integer height = plotmeDgYml.getInt("worlds." + plotMeWorldName + ".RoadHeight"); //
|
||||
int height = plotmeDgYml.getInt("worlds." + plotMeWorldName + ".RoadHeight"); //
|
||||
if (height == 0) {
|
||||
height = plotmeDgYml.getInt("worlds." + plotMeWorldName + ".GroundHeight"); //
|
||||
if (height == 0) {
|
||||
@ -364,7 +343,7 @@ public class LikePlotMeConverter {
|
||||
}
|
||||
}
|
||||
});
|
||||
} catch (Exception e) {
|
||||
} catch (InterruptedException | SQLException e) {
|
||||
e.printStackTrace();
|
||||
PS.debug("&/end/");
|
||||
}
|
||||
|
@ -19,7 +19,6 @@ import java.sql.PreparedStatement;
|
||||
import java.sql.ResultSet;
|
||||
import java.sql.SQLException;
|
||||
import java.util.HashMap;
|
||||
import java.util.Map.Entry;
|
||||
import java.util.UUID;
|
||||
|
||||
public class PlotMeConnector_017 extends APlotMeConnector {
|
||||
@ -27,8 +26,8 @@ public class PlotMeConnector_017 extends APlotMeConnector {
|
||||
private String plugin;
|
||||
|
||||
@Override
|
||||
public Connection getPlotMeConnection(String plugin, FileConfiguration plotConfig, String dataFolder) {
|
||||
this.plugin = plugin.toLowerCase();
|
||||
public Connection getPlotMeConnection(FileConfiguration plotConfig, String dataFolder) {
|
||||
this.plugin = this.plugin.toLowerCase();
|
||||
try {
|
||||
if (plotConfig.getBoolean("usemySQL")) {
|
||||
String user = plotConfig.getString("mySQLuname");
|
||||
@ -110,14 +109,10 @@ public class PlotMeConnector_017 extends APlotMeConnector {
|
||||
owner = DBFunc.everyone;
|
||||
} else {
|
||||
if (checkUUID) {
|
||||
try {
|
||||
byte[] bytes = resultSet.getBytes("ownerid");
|
||||
if (bytes != null) {
|
||||
owner = UUID.nameUUIDFromBytes(bytes);
|
||||
UUIDHandler.add(new StringWrapper(name), owner);
|
||||
}
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
byte[] bytes = resultSet.getBytes("ownerid");
|
||||
if (bytes != null) {
|
||||
owner = UUID.nameUUIDFromBytes(bytes);
|
||||
UUIDHandler.add(new StringWrapper(name), owner);
|
||||
}
|
||||
}
|
||||
if (owner == null) {
|
||||
@ -131,8 +126,7 @@ public class PlotMeConnector_017 extends APlotMeConnector {
|
||||
Plot plot = new Plot(PlotArea.createGeneric(world), id, owner);
|
||||
plots.put(key, plot);
|
||||
}
|
||||
for (Entry<Integer, Plot> entry : plots.entrySet()) {
|
||||
Plot plot = entry.getValue();
|
||||
for (Plot plot : plots.values()) {
|
||||
HashMap<PlotId, boolean[]> mergeMap = merges.get(plot.getArea().worldname);
|
||||
if (mergeMap != null) {
|
||||
if (mergeMap.containsKey(plot.getId())) {
|
||||
@ -180,8 +174,7 @@ public class PlotMeConnector_017 extends APlotMeConnector {
|
||||
}
|
||||
HashMap<String, HashMap<PlotId, Plot>> processed = new HashMap<>();
|
||||
|
||||
for (Entry<Integer, Plot> entry : plots.entrySet()) {
|
||||
Plot plot = entry.getValue();
|
||||
for (Plot plot : plots.values()) {
|
||||
HashMap<PlotId, Plot> map = processed.get(plot.getArea().worldname);
|
||||
if (map == null) {
|
||||
map = new HashMap<>();
|
||||
|
@ -16,17 +16,18 @@ import com.intellectualcrafters.plot.util.PlotChunk;
|
||||
import com.intellectualcrafters.plot.util.SetQueue;
|
||||
import com.plotsquared.bukkit.util.BukkitUtil;
|
||||
import com.plotsquared.bukkit.util.block.GenChunk;
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Random;
|
||||
import java.util.Set;
|
||||
import org.bukkit.Chunk;
|
||||
import org.bukkit.World;
|
||||
import org.bukkit.block.Biome;
|
||||
import org.bukkit.generator.BlockPopulator;
|
||||
import org.bukkit.generator.ChunkGenerator;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Random;
|
||||
import java.util.Set;
|
||||
|
||||
public class BukkitPlotGenerator extends ChunkGenerator implements GeneratorWrapper<ChunkGenerator> {
|
||||
|
||||
private final PlotChunk<Chunk> chunkSetter;
|
||||
@ -35,10 +36,9 @@ public class BukkitPlotGenerator extends ChunkGenerator implements GeneratorWrap
|
||||
private final List<BlockPopulator> populators = new ArrayList<>();
|
||||
private final ChunkGenerator platformGenerator;
|
||||
private final boolean full;
|
||||
private final HashMap<ChunkLoc, byte[][]> dataMap = new HashMap<>();
|
||||
private boolean loaded = false;
|
||||
|
||||
HashMap<ChunkLoc, byte[][]> dataMap = new HashMap<>();
|
||||
|
||||
public BukkitPlotGenerator(IndependentPlotGenerator generator) {
|
||||
this.plotGenerator = generator;
|
||||
this.platformGenerator = this;
|
||||
@ -47,8 +47,8 @@ public class BukkitPlotGenerator extends ChunkGenerator implements GeneratorWrap
|
||||
public void populate(World world, Random r, Chunk c) {
|
||||
ChunkLoc loc = new ChunkLoc(c.getX(), c.getZ());
|
||||
byte[][] resultData;
|
||||
if (!dataMap.containsKey(loc)) {
|
||||
GenChunk result = (GenChunk) chunkSetter;
|
||||
if (!BukkitPlotGenerator.this.dataMap.containsKey(loc)) {
|
||||
GenChunk result = (GenChunk) BukkitPlotGenerator.this.chunkSetter;
|
||||
// Set the chunk location
|
||||
result.setChunkWrapper(SetQueue.IMP.new ChunkWrapper(world.getName(), loc.x, loc.z));
|
||||
// Set the result data
|
||||
@ -60,7 +60,7 @@ public class BukkitPlotGenerator extends ChunkGenerator implements GeneratorWrap
|
||||
generate(world, loc.x, loc.z, result);
|
||||
resultData = result.result_data;
|
||||
} else {
|
||||
resultData = dataMap.remove(loc);
|
||||
resultData = BukkitPlotGenerator.this.dataMap.remove(loc);
|
||||
}
|
||||
if (resultData != null) {
|
||||
for (int i = 0; i < resultData.length; i++) {
|
||||
@ -76,11 +76,11 @@ public class BukkitPlotGenerator extends ChunkGenerator implements GeneratorWrap
|
||||
}
|
||||
}
|
||||
}
|
||||
random.state = c.getX() << 16 | c.getZ() & 0xFFFF;
|
||||
BukkitPlotGenerator.this.random.state = c.getX() << 16 | c.getZ() & 0xFFFF;
|
||||
PlotArea area = PS.get().getPlotArea(world.getName(), null);
|
||||
SetQueue.ChunkWrapper wrap = SetQueue.IMP.new ChunkWrapper(area.worldname, c.getX(), c.getZ());
|
||||
PlotChunk<?> chunk = SetQueue.IMP.queue.getChunk(wrap);
|
||||
if (plotGenerator.populateChunk(chunk, area, random)) {
|
||||
if (BukkitPlotGenerator.this.plotGenerator.populateChunk(chunk, area, BukkitPlotGenerator.this.random)) {
|
||||
chunk.addToQueue();
|
||||
}
|
||||
}
|
||||
@ -232,12 +232,9 @@ public class BukkitPlotGenerator extends ChunkGenerator implements GeneratorWrap
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
if (world == null) {
|
||||
return populators;
|
||||
}
|
||||
ArrayList<BlockPopulator> toAdd = new ArrayList<BlockPopulator>();
|
||||
List<BlockPopulator> existing = world.getPopulators();
|
||||
for (BlockPopulator populator : populators) {
|
||||
for (BlockPopulator populator : this.populators) {
|
||||
if (!existing.contains(populator)) {
|
||||
toAdd.add(populator);
|
||||
}
|
||||
@ -269,7 +266,7 @@ public class BukkitPlotGenerator extends ChunkGenerator implements GeneratorWrap
|
||||
// Return the result data
|
||||
return result.cd;
|
||||
}
|
||||
|
||||
|
||||
public void generate(World world, int cx, int cz, PlotChunk<?> result) {
|
||||
// Load if improperly loaded
|
||||
if (!this.loaded) {
|
||||
@ -305,7 +302,7 @@ public class BukkitPlotGenerator extends ChunkGenerator implements GeneratorWrap
|
||||
return this.platformGenerator.generateExtBlockSections(world, r, cx, cz, grid);
|
||||
} else {
|
||||
generate(world, cx, cz, result);
|
||||
dataMap.put(new ChunkLoc(cx, cz), result.result_data);
|
||||
this.dataMap.put(new ChunkLoc(cx, cz), result.result_data);
|
||||
|
||||
}
|
||||
} catch (Throwable e) {
|
||||
@ -330,7 +327,7 @@ public class BukkitPlotGenerator extends ChunkGenerator implements GeneratorWrap
|
||||
@Override
|
||||
public String toString() {
|
||||
if (this.platformGenerator == this) {
|
||||
return "" + this.plotGenerator;
|
||||
return this.plotGenerator.getName();
|
||||
}
|
||||
if (this.platformGenerator == null) {
|
||||
return "null";
|
||||
|
@ -22,7 +22,6 @@ import com.intellectualcrafters.plot.util.RegExUtil;
|
||||
import com.intellectualcrafters.plot.util.StringMan;
|
||||
import com.intellectualcrafters.plot.util.TaskManager;
|
||||
import com.intellectualcrafters.plot.util.UUIDHandler;
|
||||
import com.plotsquared.bukkit.BukkitMain;
|
||||
import com.plotsquared.bukkit.object.BukkitLazyBlock;
|
||||
import com.plotsquared.bukkit.object.BukkitPlayer;
|
||||
import com.plotsquared.bukkit.util.BukkitUtil;
|
||||
@ -42,6 +41,7 @@ import org.bukkit.entity.Creature;
|
||||
import org.bukkit.entity.EnderDragon;
|
||||
import org.bukkit.entity.Entity;
|
||||
import org.bukkit.entity.EntityType;
|
||||
import org.bukkit.entity.FallingBlock;
|
||||
import org.bukkit.entity.Fireball;
|
||||
import org.bukkit.entity.Hanging;
|
||||
import org.bukkit.entity.HumanEntity;
|
||||
@ -109,6 +109,7 @@ import org.bukkit.plugin.Plugin;
|
||||
import org.bukkit.projectiles.BlockProjectileSource;
|
||||
import org.bukkit.projectiles.ProjectileSource;
|
||||
import org.bukkit.util.Vector;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
import java.util.HashSet;
|
||||
@ -362,7 +363,7 @@ public class PlayerEvents extends PlotListener implements Listener {
|
||||
}
|
||||
}
|
||||
Player player = event.getPlayer();
|
||||
BukkitPlayer pp = (BukkitPlayer) BukkitUtil.getPlayer(player);
|
||||
PlotPlayer pp = BukkitUtil.getPlayer(player);
|
||||
Plot plot = pp.getCurrentPlot();
|
||||
if (plot == null) {
|
||||
return;
|
||||
@ -464,8 +465,8 @@ public class PlayerEvents extends PlotListener implements Listener {
|
||||
|
||||
@EventHandler(priority = EventPriority.HIGHEST, ignoreCancelled = true)
|
||||
public void playerRespawn(PlayerRespawnEvent event) {
|
||||
final Player player = event.getPlayer();
|
||||
final PlotPlayer pp = BukkitUtil.getPlayer(player);
|
||||
Player player = event.getPlayer();
|
||||
PlotPlayer pp = BukkitUtil.getPlayer(player);
|
||||
EventUtil.manager.doDeathTask(pp);
|
||||
}
|
||||
|
||||
@ -572,14 +573,13 @@ public class PlayerEvents extends PlotListener implements Listener {
|
||||
|
||||
@EventHandler(priority = EventPriority.LOWEST, ignoreCancelled = true)
|
||||
public void onChat(AsyncPlayerChatEvent event) {
|
||||
Player player = event.getPlayer();
|
||||
PlotPlayer plr = BukkitUtil.getPlayer(player);
|
||||
Location loc = plr.getLocation();
|
||||
PlotArea area = loc.getPlotArea();
|
||||
if (area == null || (!area.PLOT_CHAT && !plr.getAttribute("chat"))) {
|
||||
PlotPlayer plotPlayer = BukkitUtil.getPlayer(event.getPlayer());
|
||||
Location location = plotPlayer.getLocation();
|
||||
PlotArea area = location.getPlotArea();
|
||||
if (area == null || (!area.PLOT_CHAT && !plotPlayer.getAttribute("chat"))) {
|
||||
return;
|
||||
}
|
||||
Plot plot = area.getPlot(loc);
|
||||
Plot plot = area.getPlot(location);
|
||||
if (plot == null) {
|
||||
return;
|
||||
}
|
||||
@ -614,7 +614,7 @@ public class PlayerEvents extends PlotListener implements Listener {
|
||||
}
|
||||
|
||||
@EventHandler(priority = EventPriority.LOWEST)
|
||||
public void BlockDestroy(BlockBreakEvent event) {
|
||||
public void blockDestroy(BlockBreakEvent event) {
|
||||
Player player = event.getPlayer();
|
||||
Location loc = BukkitUtil.getLocation(event.getBlock().getLocation());
|
||||
PlotArea area = loc.getPlotArea();
|
||||
@ -737,7 +737,7 @@ public class PlayerEvents extends PlotListener implements Listener {
|
||||
plotExit(pp, plot);
|
||||
}
|
||||
|
||||
if (BukkitMain.worldEdit != null && PS.get().worldedit != null) {
|
||||
if (true && PS.get().worldedit != null) {
|
||||
if (!Permissions.hasPermission(pp, C.PERMISSION_WORLDEDIT_BYPASS)) {
|
||||
if (pp.getAttribute("worldedit")) {
|
||||
pp.removeAttribute("worldedit");
|
||||
@ -756,7 +756,7 @@ public class PlayerEvents extends PlotListener implements Listener {
|
||||
return;
|
||||
}
|
||||
Entity e = event.getEntity();
|
||||
if (!(e instanceof org.bukkit.entity.FallingBlock)) {
|
||||
if (!(e instanceof FallingBlock)) {
|
||||
event.setCancelled(true);
|
||||
}
|
||||
}
|
||||
@ -773,20 +773,16 @@ public class PlayerEvents extends PlotListener implements Listener {
|
||||
}
|
||||
|
||||
@EventHandler(priority = EventPriority.HIGHEST, ignoreCancelled = true)
|
||||
public void onBS(BlockSpreadEvent e) {
|
||||
Block b = e.getBlock();
|
||||
Location loc = BukkitUtil.getLocation(b.getLocation());
|
||||
if (loc.isPlotRoad()) {
|
||||
e.setCancelled(true);
|
||||
}
|
||||
public void onBlockSpread(BlockSpreadEvent event) {
|
||||
onBlockForm(event); //send to super class.
|
||||
}
|
||||
|
||||
@EventHandler(priority = EventPriority.HIGHEST, ignoreCancelled = true)
|
||||
public void onBF(BlockFormEvent e) {
|
||||
Block b = e.getBlock();
|
||||
Location loc = BukkitUtil.getLocation(b.getLocation());
|
||||
public void onBlockForm(BlockFormEvent event) {
|
||||
Block block = event.getBlock();
|
||||
Location loc = BukkitUtil.getLocation(block.getLocation());
|
||||
if (loc.isPlotRoad()) {
|
||||
e.setCancelled(true);
|
||||
event.setCancelled(true);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -9,6 +9,8 @@ import org.bukkit.World;
|
||||
import org.bukkit.block.BlockFace;
|
||||
import org.bukkit.entity.Ageable;
|
||||
import org.bukkit.entity.ArmorStand;
|
||||
import org.bukkit.entity.Bat;
|
||||
import org.bukkit.entity.EnderDragon;
|
||||
import org.bukkit.entity.Entity;
|
||||
import org.bukkit.entity.EntityType;
|
||||
import org.bukkit.entity.Guardian;
|
||||
@ -16,6 +18,7 @@ import org.bukkit.entity.Horse;
|
||||
import org.bukkit.entity.Horse.Color;
|
||||
import org.bukkit.entity.Horse.Style;
|
||||
import org.bukkit.entity.Horse.Variant;
|
||||
import org.bukkit.entity.IronGolem;
|
||||
import org.bukkit.entity.Item;
|
||||
import org.bukkit.entity.ItemFrame;
|
||||
import org.bukkit.entity.LivingEntity;
|
||||
@ -25,6 +28,7 @@ import org.bukkit.entity.Rabbit.Type;
|
||||
import org.bukkit.entity.Sheep;
|
||||
import org.bukkit.entity.Skeleton;
|
||||
import org.bukkit.entity.Skeleton.SkeletonType;
|
||||
import org.bukkit.entity.Slime;
|
||||
import org.bukkit.entity.Tameable;
|
||||
import org.bukkit.inventory.EntityEquipment;
|
||||
import org.bukkit.inventory.InventoryHolder;
|
||||
@ -34,15 +38,15 @@ import org.bukkit.util.Vector;
|
||||
|
||||
public class EntityWrapper {
|
||||
|
||||
public final EntityType type;
|
||||
public final float yaw;
|
||||
public final float pitch;
|
||||
public final short depth;
|
||||
private final int hash;
|
||||
public EntityType type;
|
||||
public float yaw;
|
||||
public float pitch;
|
||||
private final EntityBaseStats base = new EntityBaseStats();
|
||||
public double x;
|
||||
public double y;
|
||||
public double z;
|
||||
public short depth;
|
||||
public EntityBaseStats base = null;
|
||||
// Extended
|
||||
public ItemStack stack;
|
||||
public ItemStack[] inventory;
|
||||
@ -52,10 +56,9 @@ public class EntityWrapper {
|
||||
public LivingEntityStats lived;
|
||||
public AgeableStats aged;
|
||||
public TameableStats tamed;
|
||||
ArmorStandStats stand;
|
||||
private HorseStats horse;
|
||||
private ArmorStandStats stand;
|
||||
|
||||
@SuppressWarnings("deprecation")
|
||||
|
||||
public EntityWrapper(Entity entity, short depth) {
|
||||
this.hash = entity.getEntityId();
|
||||
this.depth = depth;
|
||||
@ -69,10 +72,9 @@ public class EntityWrapper {
|
||||
if (depth == 0) {
|
||||
return;
|
||||
}
|
||||
this.base = new EntityBaseStats();
|
||||
Entity p = entity.getPassenger();
|
||||
if (p != null) {
|
||||
this.base.passenger = new EntityWrapper(p, depth);
|
||||
Entity passenger = entity.getPassenger();
|
||||
if (passenger != null) {
|
||||
this.base.passenger = new EntityWrapper(passenger, depth);
|
||||
}
|
||||
this.base.fall = entity.getFallDistance();
|
||||
this.base.fire = (short) entity.getFireTicks();
|
||||
@ -168,10 +170,10 @@ public class EntityWrapper {
|
||||
this.horse.variant = getOrdinal(Variant.values(), horse.getVariant());
|
||||
this.horse.style = getOrdinal(Style.values(), horse.getStyle());
|
||||
this.horse.color = getOrdinal(Color.values(), horse.getColor());
|
||||
storeTameable((Tameable) entity);
|
||||
storeAgeable((Ageable) entity);
|
||||
storeLiving((LivingEntity) entity);
|
||||
storeInventory((InventoryHolder) entity);
|
||||
storeTameable(horse);
|
||||
storeAgeable(horse);
|
||||
storeLiving(horse);
|
||||
storeInventory(horse);
|
||||
return;
|
||||
// END INVENTORY HOLDER //
|
||||
case WOLF:
|
||||
@ -185,8 +187,8 @@ public class EntityWrapper {
|
||||
Sheep sheep = (Sheep) entity;
|
||||
this.dataByte = (byte) (sheep.isSheared() ? 1 : 0);
|
||||
this.dataByte2 = sheep.getColor().getDyeData();
|
||||
storeAgeable((Ageable) entity);
|
||||
storeLiving((LivingEntity) entity);
|
||||
storeAgeable(sheep);
|
||||
storeLiving(sheep);
|
||||
return;
|
||||
case VILLAGER:
|
||||
case CHICKEN:
|
||||
@ -196,26 +198,25 @@ public class EntityWrapper {
|
||||
storeAgeable((Ageable) entity);
|
||||
storeLiving((LivingEntity) entity);
|
||||
return;
|
||||
case RABBIT: // NEW
|
||||
case RABBIT:
|
||||
this.dataByte = getOrdinal(Type.values(), ((Rabbit) entity).getRabbitType());
|
||||
storeAgeable((Ageable) entity);
|
||||
storeLiving((LivingEntity) entity);
|
||||
return;
|
||||
// END AGEABLE //
|
||||
case GUARDIAN: // NEW
|
||||
case GUARDIAN:
|
||||
this.dataByte = (byte) (((Guardian) entity).isElder() ? 1 : 0);
|
||||
storeLiving((LivingEntity) entity);
|
||||
return;
|
||||
case SKELETON: // NEW
|
||||
case SKELETON:
|
||||
this.dataByte = (byte) ((Skeleton) entity).getSkeletonType().getId();
|
||||
storeLiving((LivingEntity) entity);
|
||||
return;
|
||||
case ARMOR_STAND: // NEW
|
||||
// CHECK positions
|
||||
case ARMOR_STAND:
|
||||
ArmorStand stand = (ArmorStand) entity;
|
||||
this.inventory = new ItemStack[]{stand.getItemInHand().clone(), stand.getHelmet().clone(), stand.getChestplate().clone(),
|
||||
stand.getLeggings().clone(), stand.getBoots().clone()};
|
||||
storeLiving((LivingEntity) entity);
|
||||
storeLiving(stand);
|
||||
this.stand = new ArmorStandStats();
|
||||
|
||||
EulerAngle head = stand.getHeadPose();
|
||||
@ -264,9 +265,19 @@ public class EntityWrapper {
|
||||
this.stand.small = true;
|
||||
}
|
||||
return;
|
||||
case ENDERMITE: // NEW
|
||||
case ENDERMITE:
|
||||
return;
|
||||
case BAT:
|
||||
if (((Bat) entity).isAwake()) {
|
||||
this.dataByte = (byte) 1;
|
||||
} else {
|
||||
this.dataByte = (byte) 0;
|
||||
}
|
||||
return;
|
||||
case ENDER_DRAGON:
|
||||
EnderDragon entity1 = (EnderDragon) entity;
|
||||
this.dataByte = (byte) entity1.getPhase().ordinal();
|
||||
return;
|
||||
case GHAST:
|
||||
case MAGMA_CUBE:
|
||||
case SQUID:
|
||||
@ -283,8 +294,16 @@ public class EntityWrapper {
|
||||
case BLAZE:
|
||||
case SHULKER:
|
||||
case SNOWMAN:
|
||||
case IRON_GOLEM:
|
||||
storeLiving((LivingEntity) entity);
|
||||
return;
|
||||
case IRON_GOLEM:
|
||||
if (((IronGolem) entity).isPlayerCreated()) {
|
||||
this.dataByte = (byte) 1;
|
||||
} else {
|
||||
this.dataByte = (byte) 0;
|
||||
}
|
||||
storeLiving((LivingEntity) entity);
|
||||
return;
|
||||
// END LIVING //
|
||||
}
|
||||
}
|
||||
@ -303,7 +322,7 @@ public class EntityWrapper {
|
||||
this.inventory = held.getInventory().getContents().clone();
|
||||
}
|
||||
|
||||
private void restoreLiving(LivingEntity entity) {
|
||||
void restoreLiving(LivingEntity entity) {
|
||||
entity.setCanPickupItems(this.lived.loot);
|
||||
if (this.lived.name != null) {
|
||||
entity.setCustomName(this.lived.name);
|
||||
@ -315,12 +334,7 @@ public class EntityWrapper {
|
||||
entity.setRemainingAir(this.lived.air);
|
||||
entity.setRemoveWhenFarAway(this.lived.persistent);
|
||||
if (this.lived.equipped) {
|
||||
EntityEquipment equipment = entity.getEquipment();
|
||||
equipment.setItemInHand(this.lived.hands);
|
||||
equipment.setHelmet(this.lived.helmet);
|
||||
equipment.setChestplate(this.lived.chestplate);
|
||||
equipment.setLeggings(this.lived.leggings);
|
||||
equipment.setBoots(this.lived.boots);
|
||||
this.restoreEquipment(entity);
|
||||
}
|
||||
if (this.lived.leashed) {
|
||||
// TODO leashes
|
||||
@ -331,6 +345,20 @@ public class EntityWrapper {
|
||||
}
|
||||
}
|
||||
|
||||
void restoreEquipment(LivingEntity entity) {
|
||||
EntityEquipment equipment = entity.getEquipment();
|
||||
if (PS.get().checkVersion(PS.get().IMP.getServerVersion(), 1, 9, 0)) {
|
||||
equipment.setItemInMainHand(this.lived.mainHand);
|
||||
equipment.setItemInOffHand(this.lived.offHand);
|
||||
} else {
|
||||
equipment.setItemInHand(this.lived.mainHand);
|
||||
}
|
||||
equipment.setHelmet(this.lived.helmet);
|
||||
equipment.setChestplate(this.lived.chestplate);
|
||||
equipment.setLeggings(this.lived.leggings);
|
||||
equipment.setBoots(this.lived.boots);
|
||||
}
|
||||
|
||||
private void restoreInventory(InventoryHolder entity) {
|
||||
entity.getInventory().setContents(this.inventory);
|
||||
}
|
||||
@ -354,14 +382,24 @@ public class EntityWrapper {
|
||||
EntityEquipment equipment = lived.getEquipment();
|
||||
this.lived.equipped = equipment != null;
|
||||
if (this.lived.equipped) {
|
||||
this.lived.hands = equipment.getItemInHand().clone();
|
||||
this.lived.boots = equipment.getBoots().clone();
|
||||
this.lived.leggings = equipment.getLeggings().clone();
|
||||
this.lived.chestplate = equipment.getChestplate().clone();
|
||||
this.lived.helmet = equipment.getHelmet().clone();
|
||||
storeEquipment(equipment);
|
||||
}
|
||||
}
|
||||
|
||||
void storeEquipment(EntityEquipment equipment) {
|
||||
if (PS.get().checkVersion(PS.get().IMP.getServerVersion(), 1, 9, 0)) {
|
||||
this.lived.mainHand = equipment.getItemInMainHand().clone();
|
||||
this.lived.offHand = equipment.getItemInOffHand().clone();
|
||||
} else {
|
||||
this.lived.mainHand = equipment.getItemInHand().clone();
|
||||
this.lived.offHand = null;
|
||||
}
|
||||
this.lived.boots = equipment.getBoots().clone();
|
||||
this.lived.leggings = equipment.getLeggings().clone();
|
||||
this.lived.chestplate = equipment.getChestplate().clone();
|
||||
this.lived.helmet = equipment.getHelmet().clone();
|
||||
}
|
||||
|
||||
private void restoreTameable(Tameable entity) {
|
||||
if (this.tamed.tamed) {
|
||||
if (this.tamed.owner != null) {
|
||||
@ -394,7 +432,6 @@ public class EntityWrapper {
|
||||
this.tamed.tamed = tamed.isTamed();
|
||||
}
|
||||
|
||||
@SuppressWarnings("deprecation")
|
||||
public Entity spawn(World world, int x_offset, int z_offset) {
|
||||
Location loc = new Location(world, this.x + x_offset, this.y, this.z + z_offset);
|
||||
loc.setYaw(this.yaw);
|
||||
@ -449,6 +486,7 @@ public class EntityWrapper {
|
||||
case ENDER_CRYSTAL:
|
||||
case ENDER_PEARL:
|
||||
case ENDER_SIGNAL:
|
||||
case DROPPED_ITEM:
|
||||
case EXPERIENCE_ORB:
|
||||
case FALLING_BLOCK:
|
||||
case FIREBALL:
|
||||
@ -463,11 +501,19 @@ public class EntityWrapper {
|
||||
case PLAYER:
|
||||
case PRIMED_TNT:
|
||||
case SLIME:
|
||||
((Slime) entity).setSize(this.dataByte);
|
||||
return entity;
|
||||
case SMALL_FIREBALL:
|
||||
case SNOWBALL:
|
||||
case SPLASH_POTION:
|
||||
case THROWN_EXP_BOTTLE:
|
||||
case WEATHER:
|
||||
case TIPPED_ARROW:
|
||||
case SPECTRAL_ARROW:
|
||||
case SHULKER_BULLET:
|
||||
case LINGERING_POTION:
|
||||
case AREA_EFFECT_CLOUD:
|
||||
case DRAGON_FIREBALL:
|
||||
case WITHER_SKULL:
|
||||
case MINECART_FURNACE:
|
||||
case UNKNOWN:
|
||||
@ -503,10 +549,10 @@ public class EntityWrapper {
|
||||
horse.setVariant(Variant.values()[this.horse.variant]);
|
||||
horse.setStyle(Style.values()[this.horse.style]);
|
||||
horse.setColor(Color.values()[this.horse.color]);
|
||||
restoreTameable((Tameable) entity);
|
||||
restoreAgeable((Ageable) entity);
|
||||
restoreLiving((LivingEntity) entity);
|
||||
restoreInventory((InventoryHolder) entity);
|
||||
restoreTameable(horse);
|
||||
restoreAgeable(horse);
|
||||
restoreLiving(horse);
|
||||
restoreInventory(horse);
|
||||
return entity;
|
||||
// END INVENTORY HOLDER //
|
||||
case WOLF:
|
||||
@ -524,9 +570,9 @@ public class EntityWrapper {
|
||||
if (this.dataByte2 != 0) {
|
||||
sheep.setColor(DyeColor.getByDyeData(this.dataByte2));
|
||||
}
|
||||
restoreAgeable((Ageable) entity);
|
||||
restoreLiving((LivingEntity) entity);
|
||||
return entity;
|
||||
restoreAgeable(sheep);
|
||||
restoreLiving(sheep);
|
||||
return sheep;
|
||||
case VILLAGER:
|
||||
case CHICKEN:
|
||||
case COW:
|
||||
@ -536,26 +582,26 @@ public class EntityWrapper {
|
||||
restoreLiving((LivingEntity) entity);
|
||||
return entity;
|
||||
// END AGEABLE //
|
||||
case RABBIT: // NEW
|
||||
case RABBIT:
|
||||
if (this.dataByte != 0) {
|
||||
((Rabbit) entity).setRabbitType(Type.values()[this.dataByte]);
|
||||
}
|
||||
restoreAgeable((Ageable) entity);
|
||||
restoreLiving((LivingEntity) entity);
|
||||
return entity;
|
||||
case GUARDIAN: // NEW
|
||||
case GUARDIAN:
|
||||
if (this.dataByte != 0) {
|
||||
((Guardian) entity).setElder(true);
|
||||
}
|
||||
restoreLiving((LivingEntity) entity);
|
||||
return entity;
|
||||
case SKELETON: // NEW
|
||||
case SKELETON:
|
||||
if (this.dataByte != 0) {
|
||||
((Skeleton) entity).setSkeletonType(SkeletonType.values()[this.dataByte]);
|
||||
}
|
||||
storeLiving((LivingEntity) entity);
|
||||
return entity;
|
||||
case ARMOR_STAND: // NEW
|
||||
case ARMOR_STAND:
|
||||
// CHECK positions
|
||||
ArmorStand stand = (ArmorStand) entity;
|
||||
if (this.inventory[0] != null) {
|
||||
@ -612,11 +658,21 @@ public class EntityWrapper {
|
||||
if (this.stand.small) {
|
||||
stand.setSmall(true);
|
||||
}
|
||||
restoreLiving(stand);
|
||||
return stand;
|
||||
case BAT:
|
||||
if (this.dataByte != 0) {
|
||||
((Bat) entity).setAwake(true);
|
||||
}
|
||||
restoreLiving((LivingEntity) entity);
|
||||
return entity;
|
||||
case ENDERMITE: // NEW
|
||||
case BAT:
|
||||
case ENDER_DRAGON:
|
||||
if (this.dataByte != 0) {
|
||||
((EnderDragon) entity).setPhase(EnderDragon.Phase.values()[this.dataByte]);
|
||||
}
|
||||
restoreLiving((LivingEntity) entity);
|
||||
return entity;
|
||||
case ENDERMITE:
|
||||
case GHAST:
|
||||
case MAGMA_CUBE:
|
||||
case SQUID:
|
||||
@ -632,7 +688,13 @@ public class EntityWrapper {
|
||||
case CREEPER:
|
||||
case BLAZE:
|
||||
case SNOWMAN:
|
||||
case SHULKER:
|
||||
restoreLiving((LivingEntity) entity);
|
||||
return entity;
|
||||
case IRON_GOLEM:
|
||||
if (this.dataByte != 0) {
|
||||
((IronGolem) entity).setPlayerCreated(true);
|
||||
}
|
||||
restoreLiving((LivingEntity) entity);
|
||||
return entity;
|
||||
// END LIVING //
|
||||
|
@ -1,10 +1,10 @@
|
||||
package com.plotsquared.bukkit.object.entity;
|
||||
|
||||
import java.util.Collection;
|
||||
|
||||
import org.bukkit.inventory.ItemStack;
|
||||
import org.bukkit.potion.PotionEffect;
|
||||
|
||||
import java.util.Collection;
|
||||
|
||||
public class LivingEntityStats {
|
||||
public boolean loot;
|
||||
public String name;
|
||||
@ -17,10 +17,11 @@ public class LivingEntityStats {
|
||||
public short leash_y;
|
||||
public short leash_z;
|
||||
public boolean equipped;
|
||||
public ItemStack hands;
|
||||
public ItemStack mainHand;
|
||||
public ItemStack helmet;
|
||||
public ItemStack boots;
|
||||
public ItemStack leggings;
|
||||
public ItemStack chestplate;
|
||||
public Collection<PotionEffect> potions;
|
||||
public ItemStack offHand;
|
||||
}
|
||||
|
@ -8,11 +8,6 @@ import com.intellectualcrafters.jnbt.Tag;
|
||||
import com.intellectualcrafters.plot.object.schematic.ItemType;
|
||||
import com.intellectualcrafters.plot.util.MathMan;
|
||||
import com.plotsquared.bukkit.util.BukkitUtil;
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Map.Entry;
|
||||
import org.bukkit.World;
|
||||
import org.bukkit.block.Block;
|
||||
import org.bukkit.block.BlockState;
|
||||
@ -21,6 +16,12 @@ import org.bukkit.inventory.Inventory;
|
||||
import org.bukkit.inventory.InventoryHolder;
|
||||
import org.bukkit.inventory.ItemStack;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Map.Entry;
|
||||
|
||||
public class StateWrapper {
|
||||
|
||||
public BlockState state = null;
|
||||
@ -38,8 +39,8 @@ public class StateWrapper {
|
||||
if (this.tag == null) {
|
||||
return false;
|
||||
}
|
||||
switch (tag.getString("id").toLowerCase()) {
|
||||
case "chest": {
|
||||
switch (this.tag.getString("id").toLowerCase()) {
|
||||
case "chest":
|
||||
List<Tag> itemsTag = this.tag.getListTag("Items").getValue();
|
||||
int length = itemsTag.size();
|
||||
short[] ids = new short[length];
|
||||
@ -75,9 +76,7 @@ public class StateWrapper {
|
||||
}
|
||||
state.update(true);
|
||||
return true;
|
||||
} else {
|
||||
}
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
@ -1,86 +1,14 @@
|
||||
package com.plotsquared.bukkit.titles;
|
||||
|
||||
import com.plotsquared.bukkit.chat.Reflection;
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.ChatColor;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
import java.lang.reflect.Field;
|
||||
import java.lang.reflect.InvocationTargetException;
|
||||
import java.lang.reflect.Method;
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
|
||||
/**
|
||||
* [ PlotSquared DefaultTitleManager by Maxim Van de Wynckel ]
|
||||
*
|
||||
* @author Maxim Van de Wynckel
|
||||
*
|
||||
*/
|
||||
public class DefaultTitleManager {
|
||||
|
||||
private static final Map<Class<?>, Class<?>> CORRESPONDING_TYPES = new HashMap<>();
|
||||
/* Title packet */
|
||||
private Class<?> packetTitle;
|
||||
/* Title packet actions ENUM */
|
||||
private Class<?> packetActions;
|
||||
/* Chat serializer */
|
||||
private Class<?> nmsChatSerializer;
|
||||
private Class<?> chatBaseComponent;
|
||||
/* Title text and color */
|
||||
private String title = "";
|
||||
private ChatColor titleColor = ChatColor.WHITE;
|
||||
/* Subtitle text and color */
|
||||
private String subtitle = "";
|
||||
private ChatColor subtitleColor = ChatColor.WHITE;
|
||||
/* Title timings */
|
||||
private int fadeInTime = -1;
|
||||
private int stayTime = -1;
|
||||
private int fadeOutTime = -1;
|
||||
private boolean ticks = false;
|
||||
|
||||
/**
|
||||
* Create a new 1.8 title.
|
||||
*
|
||||
* @param title Title
|
||||
* @throws ClassNotFoundException
|
||||
*/
|
||||
public DefaultTitleManager(String title) throws ClassNotFoundException {
|
||||
this.title = title;
|
||||
loadClasses();
|
||||
}
|
||||
|
||||
/**
|
||||
* Create a new 1.8 title.
|
||||
*
|
||||
* @param title Title text
|
||||
* @param subtitle Subtitle text
|
||||
* @throws ClassNotFoundException
|
||||
*/
|
||||
public DefaultTitleManager(String title, String subtitle) throws ClassNotFoundException {
|
||||
this.title = title;
|
||||
this.subtitle = subtitle;
|
||||
loadClasses();
|
||||
}
|
||||
|
||||
/**
|
||||
* Copy 1.8 title.
|
||||
*
|
||||
* @param title Title
|
||||
* @throws ClassNotFoundException
|
||||
*/
|
||||
public DefaultTitleManager(DefaultTitleManager title) throws ClassNotFoundException {
|
||||
// Copy title
|
||||
this.title = title.title;
|
||||
this.subtitle = title.subtitle;
|
||||
this.titleColor = title.titleColor;
|
||||
this.subtitleColor = title.subtitleColor;
|
||||
this.fadeInTime = title.fadeInTime;
|
||||
this.fadeOutTime = title.fadeOutTime;
|
||||
this.stayTime = title.stayTime;
|
||||
this.ticks = title.ticks;
|
||||
loadClasses();
|
||||
}
|
||||
public class DefaultTitleManager extends TitleManager {
|
||||
|
||||
/**
|
||||
* Create a new 1.8 title.
|
||||
@ -90,16 +18,9 @@ public class DefaultTitleManager {
|
||||
* @param fadeInTime Fade in time
|
||||
* @param stayTime Stay on screen time
|
||||
* @param fadeOutTime Fade out time
|
||||
* @throws ClassNotFoundException
|
||||
*/
|
||||
public DefaultTitleManager(String title, String subtitle, int fadeInTime, int stayTime, int fadeOutTime)
|
||||
throws ClassNotFoundException {
|
||||
this.title = title;
|
||||
this.subtitle = subtitle;
|
||||
this.fadeInTime = fadeInTime;
|
||||
this.stayTime = stayTime;
|
||||
this.fadeOutTime = fadeOutTime;
|
||||
loadClasses();
|
||||
public DefaultTitleManager(String title, String subtitle, int fadeInTime, int stayTime, int fadeOutTime) {
|
||||
super(title, subtitle, fadeInTime, stayTime, fadeOutTime);
|
||||
}
|
||||
|
||||
private static boolean equalsTypeArray(Class<?>[] a, Class<?>[] o) {
|
||||
@ -117,115 +38,20 @@ public class DefaultTitleManager {
|
||||
/**
|
||||
* Load spigot and NMS classes.
|
||||
*/
|
||||
private void loadClasses() {
|
||||
@Override void loadClasses() {
|
||||
this.packetTitle = Reflection.getNMSClass("PacketPlayOutTitle");
|
||||
this.packetActions = Reflection.getNMSClass("EnumTitleAction");
|
||||
this.chatBaseComponent = Reflection.getNMSClass("IChatBaseComponent");
|
||||
this.nmsChatSerializer = Reflection.getNMSClass("ChatSerializer");
|
||||
}
|
||||
|
||||
/**
|
||||
* Get title text.
|
||||
*
|
||||
* @return Title text
|
||||
*/
|
||||
public String getTitle() {
|
||||
return this.title;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set title text.
|
||||
*
|
||||
* @param title Title
|
||||
*/
|
||||
public void setTitle(String title) {
|
||||
this.title = title;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get subtitle text.
|
||||
*
|
||||
* @return Subtitle text
|
||||
*/
|
||||
public String getSubtitle() {
|
||||
return this.subtitle;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set subtitle text.
|
||||
*
|
||||
* @param subtitle Subtitle text
|
||||
*/
|
||||
public void setSubtitle(String subtitle) {
|
||||
this.subtitle = subtitle;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set the title color.
|
||||
*
|
||||
* @param color Chat color
|
||||
*/
|
||||
public void setTitleColor(ChatColor color) {
|
||||
this.titleColor = color;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set the subtitle color.
|
||||
*
|
||||
* @param color Chat color
|
||||
*/
|
||||
public void setSubtitleColor(ChatColor color) {
|
||||
this.subtitleColor = color;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set title fade in time.
|
||||
*
|
||||
* @param time Time
|
||||
*/
|
||||
public void setFadeInTime(int time) {
|
||||
this.fadeInTime = time;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set title fade out time.
|
||||
*
|
||||
* @param time Time
|
||||
*/
|
||||
public void setFadeOutTime(int time) {
|
||||
this.fadeOutTime = time;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set title stay time.
|
||||
*
|
||||
* @param time Time
|
||||
*/
|
||||
public void setStayTime(int time) {
|
||||
this.stayTime = time;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set timings to ticks.
|
||||
*/
|
||||
public void setTimingsToTicks() {
|
||||
this.ticks = true;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set timings to seconds.
|
||||
*/
|
||||
public void setTimingsToSeconds() {
|
||||
this.ticks = false;
|
||||
}
|
||||
|
||||
/**
|
||||
* Send the title to a player.
|
||||
*
|
||||
* @param player Player
|
||||
* @throws Exception
|
||||
*/
|
||||
public void send(Player player) throws Exception {
|
||||
@Override public void send(Player player) throws Exception {
|
||||
if (this.packetTitle != null) {
|
||||
// First reset previous settings
|
||||
resetTitle(player);
|
||||
@ -243,13 +69,14 @@ public class DefaultTitleManager {
|
||||
}
|
||||
// Send title
|
||||
Object serialized = getMethod(this.nmsChatSerializer, "a", String.class).invoke(null,
|
||||
"{text:\"" + ChatColor.translateAlternateColorCodes('&', this.title) + "\",color:" + this.titleColor.name().toLowerCase() + "}");
|
||||
"{text:\"" + ChatColor.translateAlternateColorCodes('&', this.getTitle()) + "\",color:" + this.titleColor.name().toLowerCase()
|
||||
+ "}");
|
||||
packet = this.packetTitle.getConstructor(this.packetActions, this.chatBaseComponent).newInstance(actions[0], serialized);
|
||||
sendPacket.invoke(connection, packet);
|
||||
if (!this.subtitle.isEmpty()) {
|
||||
if (!this.getSubtitle().isEmpty()) {
|
||||
// Send subtitle if present
|
||||
serialized = getMethod(this.nmsChatSerializer, "a", String.class).invoke(null,
|
||||
"{text:\"" + ChatColor.translateAlternateColorCodes('&', this.subtitle) + "\",color:" + this.subtitleColor.name()
|
||||
"{text:\"" + ChatColor.translateAlternateColorCodes('&', this.getSubtitle()) + "\",color:" + this.subtitleColor.name()
|
||||
.toLowerCase() + "}");
|
||||
packet = this.packetTitle.getConstructor(this.packetActions, this.chatBaseComponent).newInstance(actions[1], serialized);
|
||||
sendPacket.invoke(connection, packet);
|
||||
@ -257,24 +84,13 @@ public class DefaultTitleManager {
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Broadcast the title to all players.
|
||||
*
|
||||
* @throws Exception
|
||||
*/
|
||||
public void broadcast() throws Exception {
|
||||
for (Player p : Bukkit.getOnlinePlayers()) {
|
||||
send(p);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Clear the title.
|
||||
*
|
||||
* @param player Player
|
||||
* @throws Exception
|
||||
*/
|
||||
public void clearTitle(Player player) throws Exception {
|
||||
@Override public void clearTitle(Player player) throws Exception {
|
||||
// Send timings first
|
||||
Object handle = getHandle(player);
|
||||
Object connection = getField(handle.getClass(), "playerConnection").get(handle);
|
||||
@ -290,7 +106,7 @@ public class DefaultTitleManager {
|
||||
* @param player Player
|
||||
* @throws Exception
|
||||
*/
|
||||
public void resetTitle(Player player) throws Exception {
|
||||
@Override public void resetTitle(Player player) throws Exception {
|
||||
// Send timings first
|
||||
Object handle = getHandle(player);
|
||||
Object connection = getField(handle.getClass(), "playerConnection").get(handle);
|
||||
@ -300,29 +116,10 @@ public class DefaultTitleManager {
|
||||
sendPacket.invoke(connection, packet);
|
||||
}
|
||||
|
||||
private Class<?> getPrimitiveType(Class<?> clazz) {
|
||||
return CORRESPONDING_TYPES.containsKey(clazz) ? CORRESPONDING_TYPES.get(clazz) : clazz;
|
||||
}
|
||||
|
||||
private Class<?>[] toPrimitiveTypeArray(Class<?>[] classes) {
|
||||
int a = classes != null ? classes.length : 0;
|
||||
Class<?>[] types = new Class<?>[a];
|
||||
for (int i = 0; i < a; i++) {
|
||||
types[i] = getPrimitiveType(classes[i]);
|
||||
}
|
||||
return types;
|
||||
}
|
||||
|
||||
private Object getHandle(Object obj) {
|
||||
try {
|
||||
return getMethod("getHandle", obj.getClass()).invoke(obj);
|
||||
} catch (IllegalAccessException e) {
|
||||
e.printStackTrace();
|
||||
return null;
|
||||
} catch (IllegalArgumentException e) {
|
||||
e.printStackTrace();
|
||||
return null;
|
||||
} catch (InvocationTargetException e) {
|
||||
} catch (IllegalAccessException | IllegalArgumentException | InvocationTargetException e) {
|
||||
e.printStackTrace();
|
||||
return null;
|
||||
}
|
||||
@ -344,10 +141,7 @@ public class DefaultTitleManager {
|
||||
Field field = clazz.getDeclaredField(name);
|
||||
field.setAccessible(true);
|
||||
return field;
|
||||
} catch (NoSuchFieldException e) {
|
||||
e.printStackTrace();
|
||||
return null;
|
||||
} catch (SecurityException e) {
|
||||
} catch (NoSuchFieldException | SecurityException e) {
|
||||
e.printStackTrace();
|
||||
return null;
|
||||
}
|
||||
|
@ -1,87 +1,13 @@
|
||||
package com.plotsquared.bukkit.titles;
|
||||
|
||||
import com.plotsquared.bukkit.chat.Reflection;
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.ChatColor;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
import java.lang.reflect.Field;
|
||||
import java.lang.reflect.Method;
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
|
||||
/**
|
||||
* [ PlotSquared DefaultTitleManager by Maxim Van de Wynckel ]
|
||||
*
|
||||
* @version 1.1.0
|
||||
* @author Maxim Van de Wynckel
|
||||
*
|
||||
*/
|
||||
public class DefaultTitleManager_183 {
|
||||
|
||||
private static final Map<Class<?>, Class<?>> CORRESPONDING_TYPES = new HashMap<>();
|
||||
/* Title packet */
|
||||
private Class<?> packetTitle;
|
||||
/* Title packet actions ENUM */
|
||||
private Class<?> packetActions;
|
||||
/* Chat serializer */
|
||||
private Class<?> nmsChatSerializer;
|
||||
private Class<?> chatBaseComponent;
|
||||
/* Title text and color */
|
||||
private String title = "";
|
||||
private ChatColor titleColor = ChatColor.WHITE;
|
||||
/* Subtitle text and color */
|
||||
private String subtitle = "";
|
||||
private ChatColor subtitleColor = ChatColor.WHITE;
|
||||
/* Title timings */
|
||||
private int fadeInTime = -1;
|
||||
private int stayTime = -1;
|
||||
private int fadeOutTime = -1;
|
||||
private boolean ticks = false;
|
||||
|
||||
/**
|
||||
* Create a new 1.8 title
|
||||
*
|
||||
* @param title
|
||||
* Title
|
||||
* @throws ClassNotFoundException
|
||||
*/
|
||||
public DefaultTitleManager_183(String title) throws ClassNotFoundException {
|
||||
this.title = title;
|
||||
loadClasses();
|
||||
}
|
||||
|
||||
/**
|
||||
* Create a new 1.8 title.
|
||||
*
|
||||
* @param title Title text
|
||||
* @param subtitle Subtitle text
|
||||
* @throws ClassNotFoundException
|
||||
*/
|
||||
public DefaultTitleManager_183(String title, String subtitle) throws ClassNotFoundException {
|
||||
this.title = title;
|
||||
this.subtitle = subtitle;
|
||||
loadClasses();
|
||||
}
|
||||
|
||||
/**
|
||||
* Copy 1.8 title.
|
||||
*
|
||||
* @param title Title
|
||||
* @throws ClassNotFoundException
|
||||
*/
|
||||
public DefaultTitleManager_183(DefaultTitleManager_183 title) throws ClassNotFoundException {
|
||||
// Copy title
|
||||
this.title = title.title;
|
||||
this.subtitle = title.subtitle;
|
||||
this.titleColor = title.titleColor;
|
||||
this.subtitleColor = title.subtitleColor;
|
||||
this.fadeInTime = title.fadeInTime;
|
||||
this.fadeOutTime = title.fadeOutTime;
|
||||
this.stayTime = title.stayTime;
|
||||
this.ticks = title.ticks;
|
||||
loadClasses();
|
||||
}
|
||||
public class DefaultTitleManager_183 extends TitleManager {
|
||||
|
||||
/**
|
||||
* Create a new 1.8 title.
|
||||
@ -91,15 +17,9 @@ public class DefaultTitleManager_183 {
|
||||
* @param fadeInTime Fade in time
|
||||
* @param stayTime Stay on screen time
|
||||
* @param fadeOutTime Fade out time
|
||||
* @throws ClassNotFoundException
|
||||
*/
|
||||
public DefaultTitleManager_183(String title, String subtitle, int fadeInTime, int stayTime, int fadeOutTime) throws ClassNotFoundException {
|
||||
this.title = title;
|
||||
this.subtitle = subtitle;
|
||||
this.fadeInTime = fadeInTime;
|
||||
this.stayTime = stayTime;
|
||||
this.fadeOutTime = fadeOutTime;
|
||||
loadClasses();
|
||||
public DefaultTitleManager_183(String title, String subtitle, int fadeInTime, int stayTime, int fadeOutTime) {
|
||||
super(title, subtitle, fadeInTime, stayTime, fadeOutTime);
|
||||
}
|
||||
|
||||
private static boolean equalsTypeArray(Class<?>[] a, Class<?>[] o) {
|
||||
@ -117,7 +37,8 @@ public class DefaultTitleManager_183 {
|
||||
/**
|
||||
* Load spigot and NMS classes.
|
||||
*/
|
||||
private void loadClasses() {
|
||||
@Override
|
||||
void loadClasses() {
|
||||
this.packetTitle = Reflection.getNMSClass("PacketPlayOutTitle");
|
||||
this.chatBaseComponent = Reflection.getNMSClass("IChatBaseComponent");
|
||||
this.packetActions = Reflection.getNMSClass("PacketPlayOutTitle$EnumTitleAction");
|
||||
@ -125,108 +46,7 @@ public class DefaultTitleManager_183 {
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Get title text.
|
||||
*
|
||||
* @return Title text
|
||||
*/
|
||||
public String getTitle() {
|
||||
return this.title;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set title text.
|
||||
*
|
||||
* @param title Title
|
||||
*/
|
||||
public void setTitle(String title) {
|
||||
this.title = title;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get subtitle text.
|
||||
*
|
||||
* @return Subtitle text
|
||||
*/
|
||||
public String getSubtitle() {
|
||||
return this.subtitle;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set subtitle text.
|
||||
*
|
||||
* @param subtitle Subtitle text
|
||||
*/
|
||||
public void setSubtitle(String subtitle) {
|
||||
this.subtitle = subtitle;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set the title color.
|
||||
*
|
||||
* @param color Chat color
|
||||
*/
|
||||
public void setTitleColor(ChatColor color) {
|
||||
this.titleColor = color;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set the subtitle color.
|
||||
*
|
||||
* @param color Chat color
|
||||
*/
|
||||
public void setSubtitleColor(ChatColor color) {
|
||||
this.subtitleColor = color;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set title fade in time.
|
||||
*
|
||||
* @param time
|
||||
* Time
|
||||
*/
|
||||
public void setFadeInTime(int time) {
|
||||
this.fadeInTime = time;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set title fade out time.
|
||||
*
|
||||
* @param time Time
|
||||
*/
|
||||
public void setFadeOutTime(int time) {
|
||||
this.fadeOutTime = time;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set title stay time.
|
||||
*
|
||||
* @param time Time
|
||||
*/
|
||||
public void setStayTime(int time) {
|
||||
this.stayTime = time;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set timings to ticks.
|
||||
*/
|
||||
public void setTimingsToTicks() {
|
||||
this.ticks = true;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set timings to seconds.
|
||||
*/
|
||||
public void setTimingsToSeconds() {
|
||||
this.ticks = false;
|
||||
}
|
||||
|
||||
/**
|
||||
* Send the title to a player.
|
||||
*
|
||||
* @param player Player
|
||||
* @throws Exception
|
||||
*/
|
||||
@Override
|
||||
public void send(Player player) throws Exception {
|
||||
if (this.packetTitle != null) {
|
||||
// First reset previous settings
|
||||
@ -247,13 +67,14 @@ public class DefaultTitleManager_183 {
|
||||
}
|
||||
// Send title
|
||||
Object serialized = getMethod(this.nmsChatSerializer, "a", String.class).invoke(null,
|
||||
"{text:\"" + ChatColor.translateAlternateColorCodes('&', this.title) + "\",color:" + this.titleColor.name().toLowerCase() + "}");
|
||||
"{text:\"" + ChatColor.translateAlternateColorCodes('&', this.getTitle()) + "\",color:" + this.titleColor.name().toLowerCase()
|
||||
+ "}");
|
||||
packet = this.packetTitle.getConstructor(this.packetActions, this.chatBaseComponent).newInstance(actions[0], serialized);
|
||||
sendPacket.invoke(connection, packet);
|
||||
if (!this.subtitle.isEmpty()) {
|
||||
if (!this.getSubtitle().isEmpty()) {
|
||||
// Send subtitle if present
|
||||
serialized = getMethod(this.nmsChatSerializer, "a", String.class).invoke(null,
|
||||
"{text:\"" + ChatColor.translateAlternateColorCodes('&', this.subtitle) + "\",color:" + this.subtitleColor.name()
|
||||
"{text:\"" + ChatColor.translateAlternateColorCodes('&', this.getSubtitle()) + "\",color:" + this.subtitleColor.name()
|
||||
.toLowerCase() + "}");
|
||||
packet = this.packetTitle.getConstructor(this.packetActions, this.chatBaseComponent).newInstance(actions[1], serialized);
|
||||
sendPacket.invoke(connection, packet);
|
||||
@ -261,22 +82,13 @@ public class DefaultTitleManager_183 {
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Broadcast the title to all players.
|
||||
* @throws Exception
|
||||
*/
|
||||
public void broadcast() throws Exception {
|
||||
for (Player p : Bukkit.getOnlinePlayers()) {
|
||||
send(p);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Clear the title.
|
||||
*
|
||||
* @param player Player
|
||||
* @throws Exception
|
||||
*/
|
||||
@Override
|
||||
public void clearTitle(Player player) throws Exception {
|
||||
// Send timings first
|
||||
Object handle = getHandle(player);
|
||||
@ -293,6 +105,7 @@ public class DefaultTitleManager_183 {
|
||||
* @param player Player
|
||||
* @throws Exception
|
||||
*/
|
||||
@Override
|
||||
public void resetTitle(Player player) throws Exception {
|
||||
// Send timings first
|
||||
Object handle = getHandle(player);
|
||||
@ -303,19 +116,6 @@ public class DefaultTitleManager_183 {
|
||||
sendPacket.invoke(connection, packet);
|
||||
}
|
||||
|
||||
private Class<?> getPrimitiveType(Class<?> clazz) {
|
||||
return CORRESPONDING_TYPES.containsKey(clazz) ? CORRESPONDING_TYPES.get(clazz) : clazz;
|
||||
}
|
||||
|
||||
private Class<?>[] toPrimitiveTypeArray(Class<?>[] classes) {
|
||||
int a = classes != null ? classes.length : 0;
|
||||
Class<?>[] types = new Class<?>[a];
|
||||
for (int i = 0; i < a; i++) {
|
||||
types[i] = getPrimitiveType(classes[i]);
|
||||
}
|
||||
return types;
|
||||
}
|
||||
|
||||
private Object getHandle(Object obj) {
|
||||
try {
|
||||
return getMethod("getHandle", obj.getClass()).invoke(obj);
|
||||
|
@ -11,7 +11,7 @@ public class DefaultTitle_183 extends AbstractTitle {
|
||||
try {
|
||||
DefaultTitleManager_183 title = new DefaultTitleManager_183(head, sub, in, delay, out);
|
||||
title.send(((BukkitPlayer) player).player);
|
||||
} catch (Throwable e) {
|
||||
} catch (Exception e) {
|
||||
AbstractTitle.TITLE_CLASS = new HackTitle();
|
||||
AbstractTitle.TITLE_CLASS.sendTitle(player, head, sub, in, delay, out);
|
||||
}
|
||||
|
@ -13,7 +13,7 @@ public class HackTitle extends AbstractTitle {
|
||||
try {
|
||||
HackTitleManager title = new HackTitleManager(head, sub, in, delay, out);
|
||||
title.send(((BukkitPlayer) player).player);
|
||||
} catch (Throwable e) {
|
||||
} catch (Exception e) {
|
||||
PS.debug("&cYour server version does not support titles!");
|
||||
Settings.TITLES = false;
|
||||
AbstractTitle.TITLE_CLASS = null;
|
||||
|
@ -8,78 +8,8 @@ import org.bukkit.entity.Player;
|
||||
import java.lang.reflect.Field;
|
||||
import java.lang.reflect.InvocationTargetException;
|
||||
import java.lang.reflect.Method;
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
|
||||
/**
|
||||
* Minecraft 1.8 Title.
|
||||
*
|
||||
* @version 1.0.4
|
||||
* @author Maxim Van de Wynckel
|
||||
*/
|
||||
public class HackTitleManager {
|
||||
|
||||
private static final Map<Class<?>, Class<?>> CORRESPONDING_TYPES = new HashMap<>();
|
||||
/* Title packet */
|
||||
private Class<?> packetTitle;
|
||||
/* Title packet actions ENUM */
|
||||
private Class<?> packetActions;
|
||||
/* Chat serializer */
|
||||
private Class<?> nmsChatSerializer;
|
||||
/* Title text and color */
|
||||
private String title = "";
|
||||
private ChatColor titleColor = ChatColor.WHITE;
|
||||
/* Subtitle text and color */
|
||||
private String subtitle = "";
|
||||
private ChatColor subtitleColor = ChatColor.WHITE;
|
||||
/* Title timings. */
|
||||
private int fadeInTime = -1;
|
||||
private int stayTime = -1;
|
||||
private int fadeOutTime = -1;
|
||||
private boolean ticks = false;
|
||||
|
||||
/**
|
||||
* Create a new 1.8 title.
|
||||
*
|
||||
* @param title Title
|
||||
* @throws ClassNotFoundException NMS Error.
|
||||
*/
|
||||
public HackTitleManager(String title) throws ClassNotFoundException {
|
||||
this.title = title;
|
||||
loadClasses();
|
||||
}
|
||||
|
||||
/**
|
||||
* Create a new 1.8 title.
|
||||
*
|
||||
* @param title Title text
|
||||
* @param subtitle Subtitle text
|
||||
* @throws ClassNotFoundException NMS Error
|
||||
*/
|
||||
public HackTitleManager(String title, String subtitle) throws ClassNotFoundException {
|
||||
this.title = title;
|
||||
this.subtitle = subtitle;
|
||||
loadClasses();
|
||||
}
|
||||
|
||||
/**
|
||||
* Copy 1.8 title.
|
||||
*
|
||||
* @param title Title
|
||||
* @throws ClassNotFoundException NMS Error
|
||||
*/
|
||||
public HackTitleManager(HackTitleManager title) throws ClassNotFoundException {
|
||||
// Copy title
|
||||
this.title = title.title;
|
||||
this.subtitle = title.subtitle;
|
||||
this.titleColor = title.titleColor;
|
||||
this.subtitleColor = title.subtitleColor;
|
||||
this.fadeInTime = title.fadeInTime;
|
||||
this.fadeOutTime = title.fadeOutTime;
|
||||
this.stayTime = title.stayTime;
|
||||
this.ticks = title.ticks;
|
||||
loadClasses();
|
||||
}
|
||||
public class HackTitleManager extends TitleManager {
|
||||
|
||||
/**
|
||||
* Create a new 1.8 title.
|
||||
@ -89,15 +19,9 @@ public class HackTitleManager {
|
||||
* @param fadeInTime Fade in time
|
||||
* @param stayTime Stay on screen time
|
||||
* @param fadeOutTime Fade out time
|
||||
* @throws ClassNotFoundException NMS error
|
||||
*/
|
||||
public HackTitleManager(String title, String subtitle, int fadeInTime, int stayTime, int fadeOutTime) throws ClassNotFoundException {
|
||||
this.title = title;
|
||||
this.subtitle = subtitle;
|
||||
this.fadeInTime = fadeInTime;
|
||||
this.stayTime = stayTime;
|
||||
this.fadeOutTime = fadeOutTime;
|
||||
loadClasses();
|
||||
public HackTitleManager(String title, String subtitle, int fadeInTime, int stayTime, int fadeOutTime) {
|
||||
super(title, subtitle, fadeInTime, stayTime, fadeOutTime);
|
||||
}
|
||||
|
||||
private static boolean equalsTypeArray(Class<?>[] a, Class<?>[] o) {
|
||||
@ -115,114 +39,20 @@ public class HackTitleManager {
|
||||
/**
|
||||
* Load spigot and NMS classes.
|
||||
*/
|
||||
private void loadClasses() {
|
||||
@Override
|
||||
void loadClasses() {
|
||||
this.packetTitle = getClass("org.spigotmc.ProtocolInjector$PacketTitle");
|
||||
this.packetActions = getClass("org.spigotmc.ProtocolInjector$PacketTitle$Action");
|
||||
this.nmsChatSerializer = Reflection.getNMSClass("ChatSerializer");
|
||||
}
|
||||
|
||||
/**
|
||||
* Get title text.
|
||||
*
|
||||
* @return Title text
|
||||
*/
|
||||
public String getTitle() {
|
||||
return this.title;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set title text.
|
||||
*
|
||||
* @param title Title
|
||||
*/
|
||||
public void setTitle(String title) {
|
||||
this.title = title;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get subtitle text.
|
||||
*
|
||||
* @return Subtitle text
|
||||
*/
|
||||
public String getSubtitle() {
|
||||
return this.subtitle;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set subtitle text.
|
||||
*
|
||||
* @param subtitle Subtitle text
|
||||
*/
|
||||
public void setSubtitle(String subtitle) {
|
||||
this.subtitle = subtitle;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set the title color.
|
||||
*
|
||||
* @param color Chat color
|
||||
*/
|
||||
public void setTitleColor(ChatColor color) {
|
||||
this.titleColor = color;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set the subtitle color.
|
||||
*
|
||||
* @param color Chat color
|
||||
*/
|
||||
public void setSubtitleColor(ChatColor color) {
|
||||
this.subtitleColor = color;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set title fade in time.
|
||||
*
|
||||
* @param time Time
|
||||
*/
|
||||
public void setFadeInTime(int time) {
|
||||
this.fadeInTime = time;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set title fade out time.
|
||||
*
|
||||
* @param time Time
|
||||
*/
|
||||
public void setFadeOutTime(int time) {
|
||||
this.fadeOutTime = time;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set title stay time.
|
||||
*
|
||||
* @param time Time
|
||||
*/
|
||||
public void setStayTime(int time) {
|
||||
this.stayTime = time;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set timings to ticks.
|
||||
*/
|
||||
public void setTimingsToTicks() {
|
||||
this.ticks = true;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set timings to seconds.
|
||||
*/
|
||||
public void setTimingsToSeconds() {
|
||||
this.ticks = false;
|
||||
}
|
||||
|
||||
/**
|
||||
* Send the title to a player.
|
||||
*
|
||||
* @param player Player
|
||||
* @throws Exception on NMS error
|
||||
*/
|
||||
public void send(Player player) throws Exception {
|
||||
@Override public void send(Player player) throws Exception {
|
||||
if ((getProtocolVersion(player) >= 47) && isSpigot() && (this.packetTitle != null)) {
|
||||
// First reset previous settings
|
||||
resetTitle(player);
|
||||
@ -241,14 +71,15 @@ public class HackTitleManager {
|
||||
}
|
||||
// Send title
|
||||
Object serialized = getMethod(this.nmsChatSerializer, "a", String.class).invoke(null,
|
||||
"{text:\"" + ChatColor.translateAlternateColorCodes('&', this.title) + "\",color:" + this.titleColor.name().toLowerCase() + "}");
|
||||
"{text:\"" + ChatColor.translateAlternateColorCodes('&', this.getTitle()) + "\",color:" + this.titleColor.name().toLowerCase()
|
||||
+ "}");
|
||||
packet = this.packetTitle.getConstructor(this.packetActions, Reflection.getNMSClass("IChatBaseComponent"))
|
||||
.newInstance(actions[0], serialized);
|
||||
sendPacket.invoke(connection, packet);
|
||||
if (!this.subtitle.isEmpty()) {
|
||||
if (!this.getSubtitle().isEmpty()) {
|
||||
// Send subtitle if present
|
||||
serialized = getMethod(this.nmsChatSerializer, "a", String.class).invoke(null,
|
||||
"{text:\"" + ChatColor.translateAlternateColorCodes('&', this.subtitle) + "\",color:" + this.subtitleColor.name()
|
||||
"{text:\"" + ChatColor.translateAlternateColorCodes('&', this.getSubtitle()) + "\",color:" + this.subtitleColor.name()
|
||||
.toLowerCase() + "}");
|
||||
packet = this.packetTitle.getConstructor(this.packetActions, Reflection.getNMSClass("IChatBaseComponent"))
|
||||
.newInstance(actions[1], serialized);
|
||||
@ -257,23 +88,13 @@ public class HackTitleManager {
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Broadcast the title to all players.
|
||||
* @throws Exception on NMS Error
|
||||
*/
|
||||
public void broadcast() throws Exception {
|
||||
for (Player p : Bukkit.getOnlinePlayers()) {
|
||||
send(p);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Clear the title.
|
||||
*
|
||||
* @param player Player
|
||||
* @throws Exception on NMS Error
|
||||
*/
|
||||
public void clearTitle(Player player) throws Exception {
|
||||
@Override public void clearTitle(Player player) throws Exception {
|
||||
if ((getProtocolVersion(player) >= 47) && isSpigot()) {
|
||||
// Send timings first
|
||||
Object handle = getHandle(player);
|
||||
@ -291,7 +112,7 @@ public class HackTitleManager {
|
||||
* @param player Player
|
||||
* @throws Exception on NMS error.
|
||||
*/
|
||||
public void resetTitle(Player player) throws Exception {
|
||||
@Override public void resetTitle(Player player) throws Exception {
|
||||
if ((getProtocolVersion(player) >= 47) && isSpigot()) {
|
||||
// Send timings first
|
||||
Object handle = getHandle(player);
|
||||
@ -350,19 +171,6 @@ public class HackTitleManager {
|
||||
return f.get(obj);
|
||||
}
|
||||
|
||||
private Class<?> getPrimitiveType(Class<?> clazz) {
|
||||
return CORRESPONDING_TYPES.containsKey(clazz) ? CORRESPONDING_TYPES.get(clazz) : clazz;
|
||||
}
|
||||
|
||||
private Class<?>[] toPrimitiveTypeArray(Class<?>[] classes) {
|
||||
int a = classes != null ? classes.length : 0;
|
||||
Class<?>[] types = new Class<?>[a];
|
||||
for (int i = 0; i < a; i++) {
|
||||
types[i] = getPrimitiveType(classes[i]);
|
||||
}
|
||||
return types;
|
||||
}
|
||||
|
||||
private Object getHandle(Object obj) {
|
||||
try {
|
||||
return getMethod("getHandle", obj.getClass()).invoke(obj);
|
||||
|
@ -0,0 +1,204 @@
|
||||
package com.plotsquared.bukkit.titles;
|
||||
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.ChatColor;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
|
||||
public abstract class TitleManager {
|
||||
|
||||
private static final Map<Class<?>, Class<?>> CORRESPONDING_TYPES = new HashMap<>();
|
||||
/* Title packet */
|
||||
Class<?> packetTitle;
|
||||
/* Title packet actions ENUM */
|
||||
Class<?> packetActions;
|
||||
/* Chat serializer */
|
||||
Class<?> nmsChatSerializer;
|
||||
Class<?> chatBaseComponent;
|
||||
ChatColor titleColor = ChatColor.WHITE;
|
||||
ChatColor subtitleColor = ChatColor.WHITE;
|
||||
/* Title timings */
|
||||
int fadeInTime = -1;
|
||||
int stayTime = -1;
|
||||
int fadeOutTime = -1;
|
||||
boolean ticks = false;
|
||||
/* Title text and color */
|
||||
private String title = "";
|
||||
/* Subtitle text and color */
|
||||
private String subtitle = "";
|
||||
|
||||
/**
|
||||
* Create a new 1.8 title.
|
||||
*
|
||||
* @param title Title text
|
||||
* @param subtitle Subtitle text
|
||||
* @param fadeInTime Fade in time
|
||||
* @param stayTime Stay on screen time
|
||||
* @param fadeOutTime Fade out time
|
||||
*/
|
||||
TitleManager(String title, String subtitle, int fadeInTime, int stayTime, int fadeOutTime) {
|
||||
this.title = title;
|
||||
this.subtitle = subtitle;
|
||||
this.fadeInTime = fadeInTime;
|
||||
this.stayTime = stayTime;
|
||||
this.fadeOutTime = fadeOutTime;
|
||||
loadClasses();
|
||||
}
|
||||
|
||||
abstract void loadClasses();
|
||||
|
||||
/**
|
||||
* Get title text.
|
||||
*
|
||||
* @return Title text
|
||||
*/
|
||||
public final String getTitle() {
|
||||
return this.title;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set title text.
|
||||
*
|
||||
* @param title Title
|
||||
*/
|
||||
public final void setTitle(String title) {
|
||||
this.title = title;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get subtitle text.
|
||||
*
|
||||
* @return Subtitle text
|
||||
*/
|
||||
public final String getSubtitle() {
|
||||
return this.subtitle;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set subtitle text.
|
||||
*
|
||||
* @param subtitle Subtitle text
|
||||
*/
|
||||
public final void setSubtitle(String subtitle) {
|
||||
this.subtitle = subtitle;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set the title color.
|
||||
*
|
||||
* @param color Chat color
|
||||
*/
|
||||
public final void setTitleColor(ChatColor color) {
|
||||
this.titleColor = color;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set the subtitle color.
|
||||
*
|
||||
* @param color Chat color
|
||||
*/
|
||||
public final void setSubtitleColor(ChatColor color) {
|
||||
this.subtitleColor = color;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set title fade in time.
|
||||
*
|
||||
* @param time Time
|
||||
*/
|
||||
public final void setFadeInTime(int time) {
|
||||
this.fadeInTime = time;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set title fade out time.
|
||||
*
|
||||
* @param time Time
|
||||
*/
|
||||
public final void setFadeOutTime(int time) {
|
||||
this.fadeOutTime = time;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set title stay time.
|
||||
*
|
||||
* @param time Time
|
||||
*/
|
||||
public final void setStayTime(int time) {
|
||||
this.stayTime = time;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set timings to ticks.
|
||||
*/
|
||||
public final void setTimingsToTicks() {
|
||||
this.ticks = true;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set timings to seconds.
|
||||
*/
|
||||
public final void setTimingsToSeconds() {
|
||||
this.ticks = false;
|
||||
}
|
||||
|
||||
/**
|
||||
* Send the title to a player.
|
||||
*
|
||||
* @param player Player
|
||||
* @throws Exception
|
||||
*/
|
||||
public abstract void send(Player player) throws Exception;
|
||||
|
||||
/**
|
||||
* Broadcast the title to all players.
|
||||
*
|
||||
* @throws Exception
|
||||
*/
|
||||
public final void broadcast() throws Exception {
|
||||
for (Player p : Bukkit.getOnlinePlayers()) {
|
||||
send(p);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Clear the title.
|
||||
*
|
||||
* @param player Player
|
||||
* @throws Exception
|
||||
*/
|
||||
public abstract void clearTitle(Player player) throws Exception;
|
||||
|
||||
/**
|
||||
* Reset the title settings.
|
||||
*
|
||||
* @param player Player
|
||||
* @throws Exception
|
||||
*/
|
||||
public abstract void resetTitle(Player player) throws Exception;
|
||||
|
||||
private Class<?> getPrimitiveType(Class<?> clazz) {
|
||||
if (CORRESPONDING_TYPES.containsKey(clazz)) {
|
||||
return CORRESPONDING_TYPES.get(clazz);
|
||||
} else {
|
||||
return clazz;
|
||||
}
|
||||
}
|
||||
|
||||
final Class<?>[] toPrimitiveTypeArray(Class<?>[] classes) {
|
||||
int a;
|
||||
if (classes != null) {
|
||||
a = classes.length;
|
||||
} else {
|
||||
a = 0;
|
||||
}
|
||||
Class<?>[] types = new Class<?>[a];
|
||||
for (int i = 0; i < a; i++) {
|
||||
types[i] = getPrimitiveType(classes[i]);
|
||||
}
|
||||
return types;
|
||||
}
|
||||
|
||||
}
|
@ -45,7 +45,7 @@ public class BukkitChatManager extends ChatManager<FancyMessage> {
|
||||
|
||||
@Override
|
||||
public void send(PlotMessage m, PlotPlayer player) {
|
||||
if (ConsolePlayer.isConsole(player)) {
|
||||
if (player instanceof ConsolePlayer) {
|
||||
player.sendMessage(m.$(this).toOldMessageFormat());
|
||||
} else {
|
||||
m.$(this).send(((BukkitPlayer) player).player);
|
||||
|
File diff suppressed because it is too large
Load Diff
@ -4,9 +4,12 @@ import com.intellectualcrafters.plot.commands.MainCommand;
|
||||
import com.intellectualcrafters.plot.object.ConsolePlayer;
|
||||
import com.intellectualcrafters.plot.object.PlotPlayer;
|
||||
import com.plotsquared.bukkit.commands.DebugUUID;
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.command.Command;
|
||||
import org.bukkit.command.CommandExecutor;
|
||||
import org.bukkit.command.CommandSender;
|
||||
import org.bukkit.command.ConsoleCommandSender;
|
||||
import org.bukkit.command.ProxiedCommandSender;
|
||||
import org.bukkit.command.RemoteConsoleCommandSender;
|
||||
import org.bukkit.command.TabCompleter;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
@ -22,41 +25,19 @@ public class BukkitCommand implements CommandExecutor, TabCompleter {
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean onCommand(final CommandSender commandSender, org.bukkit.command.Command command, final String commandLabel, String[] args) {
|
||||
public boolean onCommand(CommandSender commandSender, Command command, String commandLabel, String[] args) {
|
||||
if (commandSender instanceof Player) {
|
||||
return MainCommand.onCommand(BukkitUtil.getPlayer((Player) commandSender), args);
|
||||
}
|
||||
if (commandSender.getClass() == Bukkit.getConsoleSender().getClass()) {
|
||||
if (commandSender instanceof ConsoleCommandSender || commandSender instanceof ProxiedCommandSender
|
||||
|| commandSender instanceof RemoteConsoleCommandSender) {
|
||||
return MainCommand.onCommand(ConsolePlayer.getConsole(), args);
|
||||
}
|
||||
@SuppressWarnings("deprecation")
|
||||
ConsolePlayer sender = new ConsolePlayer() {
|
||||
@Override
|
||||
public void sendMessage(String message) {
|
||||
commandSender.sendMessage(commandLabel);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean hasPermission(String permission) {
|
||||
return commandSender.hasPermission(commandLabel);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getName() {
|
||||
if (commandSender.getName().equals("CONSOLE")) {
|
||||
return "*";
|
||||
}
|
||||
return commandSender.getName();
|
||||
}
|
||||
};
|
||||
sender.teleport(ConsolePlayer.getConsole().getLocationFull());
|
||||
boolean result = MainCommand.onCommand(sender, args);
|
||||
ConsolePlayer.getConsole().teleport(sender.getLocationFull());
|
||||
return result;
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<String> onTabComplete(CommandSender commandSender, org.bukkit.command.Command command, String s, String[] args) {
|
||||
public List<String> onTabComplete(CommandSender commandSender, Command command, String s, String[] args) {
|
||||
if (!(commandSender instanceof Player)) {
|
||||
return null;
|
||||
}
|
||||
@ -72,6 +53,6 @@ public class BukkitCommand implements CommandExecutor, TabCompleter {
|
||||
for (Object o : objects) {
|
||||
result.add(o.toString());
|
||||
}
|
||||
return result.size() == 0 ? null : result;
|
||||
return result.isEmpty() ? null : result;
|
||||
}
|
||||
}
|
||||
|
@ -15,16 +15,6 @@ public class BukkitEconHandler extends EconHandler {
|
||||
private Economy econ;
|
||||
private Permission perms;
|
||||
|
||||
public Economy getEconomy() {
|
||||
init();
|
||||
return this.econ;
|
||||
}
|
||||
|
||||
public Permission getPermissions() {
|
||||
init();
|
||||
return this.perms;
|
||||
}
|
||||
|
||||
public boolean init() {
|
||||
if (this.econ == null || this.perms == null) {
|
||||
setupPermissions();
|
||||
|
@ -6,35 +6,41 @@ import org.bukkit.Bukkit;
|
||||
|
||||
public class BukkitTaskManager extends TaskManager {
|
||||
|
||||
private final BukkitMain bukkitMain;
|
||||
|
||||
public BukkitTaskManager(BukkitMain bukkitMain) {
|
||||
this.bukkitMain = bukkitMain;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int taskRepeat(Runnable runnable, int interval) {
|
||||
return BukkitMain.THIS.getServer().getScheduler().scheduleSyncRepeatingTask(BukkitMain.THIS, runnable, interval, interval);
|
||||
return this.bukkitMain.getServer().getScheduler().scheduleSyncRepeatingTask(this.bukkitMain, runnable, interval, interval);
|
||||
}
|
||||
|
||||
@SuppressWarnings("deprecation")
|
||||
@Override
|
||||
public int taskRepeatAsync(Runnable runnable, int interval) {
|
||||
return BukkitMain.THIS.getServer().getScheduler().scheduleAsyncRepeatingTask(BukkitMain.THIS, runnable, interval, interval);
|
||||
return this.bukkitMain.getServer().getScheduler().scheduleAsyncRepeatingTask(this.bukkitMain, runnable, interval, interval);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void taskAsync(Runnable runnable) {
|
||||
BukkitMain.THIS.getServer().getScheduler().runTaskAsynchronously(BukkitMain.THIS, runnable).getTaskId();
|
||||
this.bukkitMain.getServer().getScheduler().runTaskAsynchronously(this.bukkitMain, runnable).getTaskId();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void task(Runnable runnable) {
|
||||
BukkitMain.THIS.getServer().getScheduler().runTask(BukkitMain.THIS, runnable).getTaskId();
|
||||
this.bukkitMain.getServer().getScheduler().runTask(this.bukkitMain, runnable).getTaskId();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void taskLater(Runnable runnable, int delay) {
|
||||
BukkitMain.THIS.getServer().getScheduler().runTaskLater(BukkitMain.THIS, runnable, delay).getTaskId();
|
||||
this.bukkitMain.getServer().getScheduler().runTaskLater(this.bukkitMain, runnable, delay).getTaskId();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void taskLaterAsync(Runnable runnable, int delay) {
|
||||
BukkitMain.THIS.getServer().getScheduler().runTaskLaterAsynchronously(BukkitMain.THIS, runnable, delay);
|
||||
this.bukkitMain.getServer().getScheduler().runTaskLaterAsynchronously(this.bukkitMain, runnable, delay);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -50,6 +50,7 @@ public class SendChunk {
|
||||
RefClass classChunk = getRefClass("{nms}.Chunk");
|
||||
this.methodInitLighting = classChunk.getMethod("initLighting");
|
||||
RefClass classMapChunk = getRefClass("{nms}.PacketPlayOutMapChunk");
|
||||
//TODO in 1.7.10 this is PacketPlayOutMapChunk(Chunk chunk, boolean flag, int i, int version)
|
||||
this.mapChunk = classMapChunk.getConstructor(classChunk.getRealClass(), boolean.class, int.class);
|
||||
RefClass classEntityPlayer = getRefClass("{nms}.EntityPlayer");
|
||||
this.connection = classEntityPlayer.getField("playerConnection");
|
||||
|
@ -12,7 +12,6 @@ import com.intellectualcrafters.plot.util.ReflectionUtils.RefMethod;
|
||||
import com.intellectualcrafters.plot.util.SetQueue;
|
||||
import com.intellectualcrafters.plot.util.SetQueue.ChunkWrapper;
|
||||
import com.intellectualcrafters.plot.util.TaskManager;
|
||||
import com.plotsquared.bukkit.util.BukkitUtil;
|
||||
import com.plotsquared.bukkit.util.SendChunk;
|
||||
import org.bukkit.Chunk;
|
||||
import org.bukkit.World;
|
||||
@ -370,7 +369,6 @@ public class FastQueue_1_8 extends SlowQueue {
|
||||
*/
|
||||
@Override
|
||||
public void sendChunk(String world, Collection<ChunkLoc> locations) {
|
||||
World worldObj = BukkitUtil.getWorld(world);
|
||||
for (ChunkLoc loc : locations) {
|
||||
ChunkWrapper wrapper = SetQueue.IMP.new ChunkWrapper(world, loc.x, loc.z);
|
||||
this.toUpdate.remove(wrapper);
|
||||
|
@ -1,5 +1,7 @@
|
||||
package com.plotsquared.bukkit.util.block;
|
||||
|
||||
import static com.intellectualcrafters.plot.util.ReflectionUtils.getRefClass;
|
||||
|
||||
import com.intellectualcrafters.plot.object.ChunkLoc;
|
||||
import com.intellectualcrafters.plot.object.PseudoRandom;
|
||||
import com.intellectualcrafters.plot.util.ChunkManager;
|
||||
@ -14,6 +16,12 @@ import com.intellectualcrafters.plot.util.SetQueue;
|
||||
import com.intellectualcrafters.plot.util.SetQueue.ChunkWrapper;
|
||||
import com.intellectualcrafters.plot.util.TaskManager;
|
||||
import com.plotsquared.bukkit.util.SendChunk;
|
||||
import org.bukkit.Chunk;
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.World;
|
||||
import org.bukkit.World.Environment;
|
||||
import org.bukkit.block.Biome;
|
||||
|
||||
import java.lang.reflect.Field;
|
||||
import java.lang.reflect.InvocationTargetException;
|
||||
import java.lang.reflect.Method;
|
||||
@ -23,14 +31,6 @@ import java.util.HashMap;
|
||||
import java.util.Iterator;
|
||||
import java.util.Map.Entry;
|
||||
import java.util.Set;
|
||||
import org.bukkit.Chunk;
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.World;
|
||||
import org.bukkit.World.Environment;
|
||||
import org.bukkit.block.Biome;
|
||||
|
||||
|
||||
import static com.intellectualcrafters.plot.util.ReflectionUtils.getRefClass;
|
||||
|
||||
public class FastQueue_1_8_3 extends SlowQueue {
|
||||
|
||||
|
@ -85,7 +85,7 @@ public class FastQueue_1_9 extends SlowQueue {
|
||||
* @param plotChunk
|
||||
*/
|
||||
@Override
|
||||
public void execute(final PlotChunk<Chunk> plotChunk) {
|
||||
public void execute(PlotChunk<Chunk> plotChunk) {
|
||||
final FastChunk_1_9 fs = (FastChunk_1_9) plotChunk;
|
||||
Chunk chunk = plotChunk.getChunk();
|
||||
World world = chunk.getWorld();
|
||||
@ -413,7 +413,7 @@ public class FastQueue_1_9 extends SlowQueue {
|
||||
* @param locations
|
||||
*/
|
||||
@Override
|
||||
public void sendChunk(final String world, final Collection<ChunkLoc> locations) {
|
||||
public void sendChunk(String world, Collection<ChunkLoc> locations) {
|
||||
World worldObj = BukkitUtil.getWorld(world);
|
||||
for (ChunkLoc loc : locations) {
|
||||
worldObj.refreshChunk(loc.x, loc.z);
|
||||
|
@ -9,13 +9,14 @@ import com.intellectualcrafters.plot.util.PlotQueue;
|
||||
import com.intellectualcrafters.plot.util.SetQueue;
|
||||
import com.intellectualcrafters.plot.util.SetQueue.ChunkWrapper;
|
||||
import com.plotsquared.bukkit.util.BukkitUtil;
|
||||
import org.bukkit.Chunk;
|
||||
import org.bukkit.block.Biome;
|
||||
import org.bukkit.block.Block;
|
||||
|
||||
import java.util.Collection;
|
||||
import java.util.Iterator;
|
||||
import java.util.Map.Entry;
|
||||
import java.util.concurrent.ConcurrentHashMap;
|
||||
import org.bukkit.Chunk;
|
||||
import org.bukkit.block.Biome;
|
||||
import org.bukkit.block.Block;
|
||||
|
||||
public class SlowQueue implements PlotQueue<Chunk> {
|
||||
|
||||
|
@ -74,14 +74,14 @@ public class SQLUUIDHandler extends UUIDHandlerImplementation {
|
||||
public void run() {
|
||||
try {
|
||||
HashBiMap<StringWrapper, UUID> toAdd = HashBiMap.create(new HashMap<StringWrapper, UUID>());
|
||||
PreparedStatement statement = getConnection().prepareStatement("SELECT `uuid`, `username` FROM `usercache`");
|
||||
ResultSet resultSet = statement.executeQuery();
|
||||
while (resultSet.next()) {
|
||||
StringWrapper username = new StringWrapper(resultSet.getString("username"));
|
||||
UUID uuid = UUID.fromString(resultSet.getString("uuid"));
|
||||
toAdd.put(new StringWrapper(username.value), uuid);
|
||||
try (PreparedStatement statement = getConnection().prepareStatement("SELECT `uuid`, `username` FROM `usercache`");
|
||||
ResultSet resultSet = statement.executeQuery()) {
|
||||
while (resultSet.next()) {
|
||||
StringWrapper username = new StringWrapper(resultSet.getString("username"));
|
||||
UUID uuid = UUID.fromString(resultSet.getString("uuid"));
|
||||
toAdd.put(new StringWrapper(username.value), uuid);
|
||||
}
|
||||
}
|
||||
statement.close();
|
||||
add(toAdd);
|
||||
add(new StringWrapper("*"), DBFunc.everyone);
|
||||
|
||||
|
Reference in New Issue
Block a user