closes #679
closes #676
This commit is contained in:
Jesse Boyd 2015-10-19 17:27:51 +11:00
parent f509252646
commit fa442f5903
23 changed files with 127 additions and 83 deletions

View File

@ -8,7 +8,7 @@
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
</properties>
<artifactId>PlotSquared</artifactId>
<version>3.2.12</version>
<version>3.2.13</version>
<name>PlotSquared</name>
<packaging>jar</packaging>
<build>

View File

@ -1371,7 +1371,9 @@ public class PS {
}
}
try {
plotworld.loadConfiguration(config.getConfigurationSection("worlds." + world));
ConfigurationSection section = config.getConfigurationSection("worlds." + world);
plotworld.saveConfiguration(section);
plotworld.loadConfiguration(section);
config.save(configFile);
} catch (final Exception e) {
e.printStackTrace();

View File

@ -21,6 +21,7 @@
package com.intellectualcrafters.plot.commands;
import java.util.Arrays;
import java.util.Map.Entry;
import com.intellectualcrafters.plot.config.C;
import com.intellectualcrafters.plot.object.Location;
@ -76,7 +77,8 @@ public class Comment extends SubCommand {
sendMessage(player, C.COMMENT_SYNTAX, StringMan.join(CommentManager.inboxes.keySet(), "|"));
return false;
}
for (final PlotPlayer pp : UUIDHandler.getPlayers().values()) {
for (Entry<String, PlotPlayer> entry : UUIDHandler.getPlayers().entrySet()) {
PlotPlayer pp = entry.getValue();
if (pp.getAttribute("chatspy")) {
MainUtil.sendMessage(pp, "/plot comment " + StringMan.join(args, " "));
}

View File

@ -77,7 +77,7 @@ public class DebugClaimTest extends SubCommand {
}
final String world = args[0];
if (!BlockManager.manager.isWorld(world) || !PS.get().isPlotWorld(world)) {
return !MainUtil.sendMessage(null, "&cInvalid plot world!");
return !MainUtil.sendMessage(plr, "&cInvalid plot world!");
}
PlotId min, max;
try {
@ -86,18 +86,18 @@ public class DebugClaimTest extends SubCommand {
min = PlotId.fromString(args[1]);
max = PlotId.fromString(args[2]);
} catch (final Exception e) {
return !MainUtil.sendMessage(null,
return !MainUtil.sendMessage(plr,
"&cInvalid min/max values. &7The values are to Plot IDs in the format &cX;Y &7where X;Y are the plot coords\nThe conversion will only check the plots in the selected area.");
}
MainUtil.sendMessage(null, "&3Sign Block&8->&3PlotSquared&8: &7Beginning sign to plot conversion. This may take a while...");
MainUtil.sendMessage(null, "&3Sign Block&8->&3PlotSquared&8: Found an excess of 250,000 chunks. Limiting search radius... (~3.8 min)");
MainUtil.sendMessage(plr, "&3Sign Block&8->&3PlotSquared&8: &7Beginning sign to plot conversion. This may take a while...");
MainUtil.sendMessage(plr, "&3Sign Block&8->&3PlotSquared&8: Found an excess of 250,000 chunks. Limiting search radius... (~3.8 min)");
final PlotManager manager = PS.get().getPlotManager(world);
final PlotWorld plotworld = PS.get().getPlotWorld(world);
final ArrayList<Plot> plots = new ArrayList<>();
for (final PlotId id : MainUtil.getPlotSelectionIds(min, max)) {
final Plot plot = MainUtil.getPlotAbs(world, id);
if (PS.get().getPlot(world, plot.id) != null) {
MainUtil.sendMessage(null, " - &cDB Already contains: " + plot.id);
MainUtil.sendMessage(plr, " - &cDB Already contains: " + plot.id);
continue;
}
final Location loc = manager.getSignLoc(plotworld, plot);
@ -125,29 +125,29 @@ public class DebugClaimTest extends SubCommand {
uuid = UUIDHandler.getUUID(line, null);
}
if (uuid != null) {
MainUtil.sendMessage(null, " - &aFound plot: " + plot.id + " : " + line);
MainUtil.sendMessage(plr, " - &aFound plot: " + plot.id + " : " + line);
plot.owner = uuid;
plots.add(plot);
} else {
MainUtil.sendMessage(null, " - &cInvalid playername: " + plot.id + " : " + line);
MainUtil.sendMessage(plr, " - &cInvalid playername: " + plot.id + " : " + line);
}
}
}
}
if (plots.size() > 0) {
MainUtil.sendMessage(null, "&3Sign Block&8->&3PlotSquared&8: &7Updating '" + plots.size() + "' plots!");
MainUtil.sendMessage(plr, "&3Sign Block&8->&3PlotSquared&8: &7Updating '" + plots.size() + "' plots!");
DBFunc.createPlotsAndData(plots, new Runnable() {
@Override
public void run() {
MainUtil.sendMessage(null, "&6Database update finished!");
MainUtil.sendMessage(plr, "&6Database update finished!");
}
});
for (final Plot plot : plots) {
PS.get().updatePlot(plot);
}
MainUtil.sendMessage(null, "&3Sign Block&8->&3PlotSquared&8: &7Complete!");
MainUtil.sendMessage(plr, "&3Sign Block&8->&3PlotSquared&8: &7Complete!");
} else {
MainUtil.sendMessage(null, "No plots were found for the given search.");
MainUtil.sendMessage(plr, "No plots were found for the given search.");
}
return true;
}

View File

@ -433,13 +433,13 @@ public class DebugExec extends SubCommand {
} catch (final ScriptException e) {
e.printStackTrace();
}
PS.log("> " + (System.currentTimeMillis() - start) + "ms -> " + result);
ConsolePlayer.getConsole().sendMessage("> " + (System.currentTimeMillis() - start) + "ms -> " + result);
}
});
} else {
final long start = System.currentTimeMillis();
Object result = engine.eval(script, scope);
PS.log("> " + (System.currentTimeMillis() - start) + "ms -> " + result);
ConsolePlayer.getConsole().sendMessage("> " + (System.currentTimeMillis() - start) + "ms -> " + result);
}
return true;
} catch (final ScriptException e) {

View File

@ -42,11 +42,11 @@ public class DebugSaveTest extends SubCommand {
public boolean onCommand(final PlotPlayer plr, final String[] args) {
final ArrayList<Plot> plots = new ArrayList<Plot>();
plots.addAll(PS.get().getPlots());
MainUtil.sendMessage(null, "&6Starting `DEBUGSAVETEST`");
MainUtil.sendMessage(plr, "&6Starting `DEBUGSAVETEST`");
DBFunc.createPlotsAndData(plots, new Runnable() {
@Override
public void run() {
MainUtil.sendMessage(null, "&6Database sync finished!");
MainUtil.sendMessage(plr, "&6Database sync finished!");
}
});
return true;

View File

@ -67,9 +67,7 @@ public class DebugUUID extends SubCommand {
}
@Override
public boolean onCommand(final PlotPlayer plr, final String[] args) {
final PlotPlayer player = null;
public boolean onCommand(final PlotPlayer player, final String[] args) {
final UUIDWrapper currentUUIDWrapper = UUIDHandler.getUUIDWrapper();
final UUIDWrapper newWrapper;
@ -113,18 +111,18 @@ public class DebugUUID extends SubCommand {
MainUtil.sendMessage(player, "&cUUID mode already in use!");
return false;
}
MainUtil.sendConsoleMessage("&6Beginning UUID mode conversion");
MainUtil.sendConsoleMessage("&7 - Disconnecting players");
for (final PlotPlayer pp : UUIDHandler.getPlayers().values()) {
pp.kick("PlotSquared UUID conversion has been initiated. You may reconnect when finished.");
MainUtil.sendMessage(player, "&6Beginning UUID mode conversion");
MainUtil.sendMessage(player, "&7 - Disconnecting players");
for (Entry<String, PlotPlayer> entry : UUIDHandler.getPlayers().entrySet()) {
entry.getValue().kick("PlotSquared UUID conversion has been initiated. You may reconnect when finished.");
}
MainUtil.sendConsoleMessage("&7 - Initializing map");
MainUtil.sendMessage(player, "&7 - Initializing map");
final HashMap<UUID, UUID> uCMap = new HashMap<UUID, UUID>();
final HashMap<UUID, UUID> uCReverse = new HashMap<UUID, UUID>();
MainUtil.sendConsoleMessage("&7 - Collecting playerdata");
MainUtil.sendMessage(player, "&7 - Collecting playerdata");
final HashSet<String> worlds = new HashSet<>();
worlds.add(Bukkit.getWorlds().get(0).getName());
@ -146,7 +144,7 @@ public class DebugUUID extends SubCommand {
final UUID uuid = UUID.fromString(s);
uuids.add(uuid);
} catch (final Exception e) {
MainUtil.sendMessage(plr, C.PREFIX.s() + "Invalid playerdata: " + current);
MainUtil.sendMessage(player, C.PREFIX.s() + "Invalid playerdata: " + current);
}
}
}
@ -164,7 +162,7 @@ public class DebugUUID extends SubCommand {
}
}
MainUtil.sendConsoleMessage("&7 - Populating map");
MainUtil.sendMessage(player, "&7 - Populating map");
UUID uuid2;
final UUIDWrapper wrapper = new DefaultUUIDWrapper();
for (UUID uuid : uuids) {
@ -177,7 +175,7 @@ public class DebugUUID extends SubCommand {
uCReverse.put(uuid2, uuid);
}
} catch (final Throwable e) {
MainUtil.sendMessage(plr, C.PREFIX.s() + "&6Invalid playerdata: " + uuid.toString() + ".dat");
MainUtil.sendMessage(player, C.PREFIX.s() + "&6Invalid playerdata: " + uuid.toString() + ".dat");
}
}
for (final String name : names) {
@ -189,7 +187,7 @@ public class DebugUUID extends SubCommand {
}
}
if (uCMap.size() == 0) {
MainUtil.sendConsoleMessage("&c - Error! Attempting to repopulate");
MainUtil.sendMessage(player, "&c - Error! Attempting to repopulate");
for (final OfflinePlotPlayer op : currentUUIDWrapper.getOfflinePlayers()) {
if (op.getLastPlayed() != 0) {
// String name = op.getName();
@ -203,14 +201,14 @@ public class DebugUUID extends SubCommand {
}
}
if (uCMap.size() == 0) {
MainUtil.sendConsoleMessage("&cError. Failed to collect UUIDs!");
MainUtil.sendMessage(player, "&cError. Failed to collect UUIDs!");
return false;
} else {
MainUtil.sendConsoleMessage("&a - Successfully repopulated");
MainUtil.sendMessage(player, "&a - Successfully repopulated");
}
}
MainUtil.sendConsoleMessage("&7 - Replacing cache");
MainUtil.sendMessage(player, "&7 - Replacing cache");
TaskManager.runTaskAsync(new Runnable() {
@Override
public void run() {
@ -221,7 +219,7 @@ public class DebugUUID extends SubCommand {
}
}
MainUtil.sendConsoleMessage("&7 - Scanning for applicable files (uuids.txt)");
MainUtil.sendMessage(player, "&7 - Scanning for applicable files (uuids.txt)");
final File file = new File(PS.get().IMP.getDirectory(), "uuids.txt");
if (file.exists()) {
@ -256,10 +254,10 @@ public class DebugUUID extends SubCommand {
}
}
MainUtil.sendConsoleMessage("&7 - Replacing wrapper");
MainUtil.sendMessage(player, "&7 - Replacing wrapper");
UUIDHandler.setUUIDWrapper(newWrapper);
MainUtil.sendConsoleMessage("&7 - Updating plot objects");
MainUtil.sendMessage(player, "&7 - Updating plot objects");
for (final Plot plot : PS.get().getPlotsRaw()) {
final UUID value = uCMap.get(plot.owner);
@ -271,16 +269,16 @@ public class DebugUUID extends SubCommand {
plot.getDenied().clear();
}
MainUtil.sendConsoleMessage("&7 - Deleting database");
MainUtil.sendMessage(player, "&7 - Deleting database");
final AbstractDB database = DBFunc.dbManager;
final boolean result = database.deleteTables();
MainUtil.sendConsoleMessage("&7 - Creating tables");
MainUtil.sendMessage(player, "&7 - Creating tables");
try {
database.createTables();
if (!result) {
MainUtil.sendConsoleMessage("&cConversion failed! Attempting recovery");
MainUtil.sendMessage(player, "&cConversion failed! Attempting recovery");
for (final Plot plot : PS.get().getPlots()) {
final UUID value = uCReverse.get(plot.owner);
if (value != null) {
@ -290,7 +288,7 @@ public class DebugUUID extends SubCommand {
database.createPlotsAndData(new ArrayList<>(PS.get().getPlots()), new Runnable() {
@Override
public void run() {
MainUtil.sendMessage(null, "&6Recovery was successful!");
MainUtil.sendMessage(player, "&6Recovery was successful!");
}
});
return;
@ -313,10 +311,10 @@ public class DebugUUID extends SubCommand {
try {
PS.get().config.save(PS.get().configFile);
} catch (final Exception e) {
MainUtil.sendConsoleMessage("Could not save configuration. It will need to be manuall set!");
MainUtil.sendMessage(player, "Could not save configuration. It will need to be manuall set!");
}
MainUtil.sendConsoleMessage("&7 - Populating tables");
MainUtil.sendMessage(player, "&7 - Populating tables");
TaskManager.runTaskAsync(new Runnable() {
@Override
@ -325,14 +323,14 @@ public class DebugUUID extends SubCommand {
database.createPlotsAndData(plots, new Runnable() {
@Override
public void run() {
MainUtil.sendConsoleMessage("&aConversion complete!");
MainUtil.sendMessage(player, "&aConversion complete!");
}
});
}
});
MainUtil.sendConsoleMessage("&aIt is now safe for players to join");
MainUtil.sendConsoleMessage("&cConversion is still in progress, you will be notified when it is complete");
MainUtil.sendMessage(player, "&aIt is now safe for players to join");
MainUtil.sendMessage(player, "&cConversion is still in progress, you will be notified when it is complete");
}
});
return true;

View File

@ -104,7 +104,7 @@ public class Purge extends SubCommand {
final Set<PlotId> ids = PS.get().getPlots(worldname).keySet();
final int length = ids.size();
if (length == 0) {
return MainUtil.sendMessage(null, "&cNo plots found");
return MainUtil.sendMessage(plr, "&cNo plots found");
}
DBFunc.purge(worldname, ids);
return finishPurge(length);
@ -122,7 +122,7 @@ public class Purge extends SubCommand {
}
final int length = ids.size();
if (length == 0) {
return MainUtil.sendMessage(null, "&cNo plots found");
return MainUtil.sendMessage(plr, "&cNo plots found");
}
DBFunc.purge(worldname, ids);
return finishPurge(length);
@ -137,7 +137,7 @@ public class Purge extends SubCommand {
}
final int length = ids.size();
if (length == 0) {
return MainUtil.sendMessage(null, "&cNo plots found");
return MainUtil.sendMessage(plr, "&cNo plots found");
}
DBFunc.purge(worldname, ids);
return finishPurge(length);

View File

@ -167,7 +167,7 @@ public class SchematicCmd extends SubCommand {
return false;
}
if (args.length != 2) {
MainUtil.sendMessage(null, "&cNeed world arg. Use &7/plots sch exportall <world>");
MainUtil.sendMessage(plr, "&cNeed world arg. Use &7/plots sch exportall <world>");
return false;
}
final Collection<Plot> plots = PS.get().getPlotsInWorld(args[1]);

View File

@ -31,6 +31,7 @@ import java.util.HashSet;
import com.intellectualcrafters.plot.PS;
import com.intellectualcrafters.plot.config.C;
import com.intellectualcrafters.plot.object.ChunkLoc;
import com.intellectualcrafters.plot.object.ConsolePlayer;
import com.intellectualcrafters.plot.object.Location;
import com.intellectualcrafters.plot.object.Plot;
import com.intellectualcrafters.plot.object.PlotId;
@ -158,7 +159,7 @@ public class Trim extends SubCommand {
}
public static void sendMessage(final String message) {
PS.log("&3PlotSquared -> World trim&8: &7" + message);
ConsolePlayer.getConsole().sendMessage("&3PlotSquared -> World trim&8: &7" + message);
}
public PlotId getId(final String id) {
@ -207,11 +208,12 @@ public class Trim extends SubCommand {
sendMessage(C.TASK_START.s());
final ArrayList<ChunkLoc> empty = new ArrayList<>();
getTrimRegions(empty, world, new Runnable() {
@Override
public void run() {
deleteChunks(world, empty, new Runnable() {
@Override
public void run() {
PS.log("$1Trim task complete!");
ConsolePlayer.getConsole().sendMessage("$1Trim task complete!");
}
});
}

View File

@ -50,8 +50,8 @@ public class Update extends SubCommand {
try {
url = new URL(args[0]);
} catch (final MalformedURLException e) {
MainUtil.sendConsoleMessage("&cInvalid url: " + args[0]);
MainUtil.sendConsoleMessage(C.COMMAND_SYNTAX, "/plot update [url]");
MainUtil.sendMessage(plr, "&cInvalid url: " + args[0]);
MainUtil.sendMessage(plr, C.COMMAND_SYNTAX, "/plot update [url]");
return false;
}
} else {

View File

@ -26,7 +26,11 @@ public class ConsolePlayer extends PlotPlayer {
return instance;
}
private ConsolePlayer() {
/**
* Direct access is deprecated
*/
@Deprecated
public ConsolePlayer() {
String world;
final Set<String> plotworlds = PS.get().getPlotWorlds();
if (plotworlds.size() > 0) {
@ -39,7 +43,7 @@ public class ConsolePlayer extends PlotPlayer {
}
public static boolean isConsole(final PlotPlayer plr) {
return instance == plr;
return plr instanceof ConsolePlayer;
}
@Override

View File

@ -9,6 +9,7 @@ import java.util.Set;
import com.intellectualcrafters.plot.PS;
import com.intellectualcrafters.plot.object.ChunkLoc;
import com.intellectualcrafters.plot.object.ConsolePlayer;
import com.intellectualcrafters.plot.object.Location;
import com.intellectualcrafters.plot.object.Plot;
import com.intellectualcrafters.plot.object.PlotBlock;
@ -141,7 +142,7 @@ public abstract class ChunkManager {
for (final ChunkLoc loc : chunks) {
final String directory = world + File.separator + "region" + File.separator + "r." + loc.x + "." + loc.z + ".mca";
final File file = new File(PS.get().IMP.getWorldContainer(), directory);
PS.log("&6 - Deleting file: " + file.getName() + " (max 1024 chunks)");
ConsolePlayer.getConsole().sendMessage("&6 - Deleting file: " + file.getName() + " (max 1024 chunks)");
if (file.exists()) {
file.delete();
}

View File

@ -44,6 +44,7 @@ import com.intellectualcrafters.plot.flag.Flag;
import com.intellectualcrafters.plot.flag.FlagManager;
import com.intellectualcrafters.plot.object.BlockLoc;
import com.intellectualcrafters.plot.object.ChunkLoc;
import com.intellectualcrafters.plot.object.ConsolePlayer;
import com.intellectualcrafters.plot.object.Location;
import com.intellectualcrafters.plot.object.Plot;
import com.intellectualcrafters.plot.object.PlotBlock;
@ -283,7 +284,8 @@ public class MainUtil {
public static List<PlotPlayer> getPlayersInPlot(final Plot plot) {
final ArrayList<PlotPlayer> players = new ArrayList<>();
for (final PlotPlayer pp : UUIDHandler.getPlayers().values()) {
for (Entry<String, PlotPlayer> entry : UUIDHandler.getPlayers().entrySet()) {
PlotPlayer pp = entry.getValue();
if (plot.equals(pp.getCurrentPlot())) {
players.add(pp);
}
@ -2013,7 +2015,7 @@ public class MainUtil {
public static boolean sendMessage(final PlotPlayer plr, final String msg, final boolean prefix) {
if ((msg.length() > 0) && !msg.equals("")) {
if (plr == null) {
PS.log((prefix ? C.PREFIX.s() : "") + msg);
ConsolePlayer.getConsole().sendMessage((prefix ? C.PREFIX.s() : "") + msg);
} else {
plr.sendMessage((prefix ? C.PREFIX.s() : "") + C.color(msg));
}
@ -2103,7 +2105,7 @@ public class MainUtil {
msg = C.format(c, args);
}
if (plr == null) {
PS.log(msg);
ConsolePlayer.getConsole().sendMessage(msg);
} else {
sendMessage(plr, msg, c.usePrefix());
}
@ -2126,7 +2128,7 @@ public class MainUtil {
msg = C.format(c, args);
}
if (plr == null) {
PS.log(msg);
ConsolePlayer.getConsole().sendMessage(msg);
} else {
sendMessage(plr, msg, c.usePrefix());
}

View File

@ -5,6 +5,7 @@ import java.util.HashSet;
import java.util.Map;
import java.util.Set;
import java.util.UUID;
import java.util.concurrent.ConcurrentHashMap;
import com.google.common.base.Charsets;
import com.google.common.collect.BiMap;
@ -13,6 +14,7 @@ import com.intellectualcrafters.plot.PS;
import com.intellectualcrafters.plot.config.C;
import com.intellectualcrafters.plot.config.Settings;
import com.intellectualcrafters.plot.database.DBFunc;
import com.intellectualcrafters.plot.object.ConsolePlayer;
import com.intellectualcrafters.plot.object.OfflinePlotPlayer;
import com.intellectualcrafters.plot.object.Plot;
import com.intellectualcrafters.plot.object.PlotPlayer;
@ -25,11 +27,11 @@ public abstract class UUIDHandlerImplementation {
private BiMap<StringWrapper, UUID> uuidMap = HashBiMap.create(new HashMap<StringWrapper, UUID>());
public boolean CACHED = false;
public UUIDWrapper uuidWrapper = null;
public final HashMap<String, PlotPlayer> players;
public final ConcurrentHashMap<String, PlotPlayer> players;
public UUIDHandlerImplementation(final UUIDWrapper wrapper) {
uuidWrapper = wrapper;
players = new HashMap<>();
players = new ConcurrentHashMap<>();
}
/**
@ -96,7 +98,7 @@ public abstract class UUIDHandlerImplementation {
try {
unknown.add(uuid);
} catch (final Exception e) {
PS.log("&c(minor) Invalid UUID mapping: " + uuid);
ConsolePlayer.getConsole().sendMessage("&c(minor) Invalid UUID mapping: " + uuid);
e.printStackTrace();
}
return false;
@ -178,11 +180,11 @@ public abstract class UUIDHandlerImplementation {
if (uuid == null) {
return null;
}
// check online
final PlotPlayer player = getPlayer(uuid);
if (player != null) {
return player.getName();
}
// // check online
// final PlotPlayer player = getPlayer(uuid);
// if (player != null) {
// return player.getName();
// }
// check cache
final StringWrapper name = uuidMap.inverse().get(uuid);
if (name != null) {
@ -228,10 +230,9 @@ public abstract class UUIDHandlerImplementation {
}
public PlotPlayer getPlayer(final UUID uuid) {
for (final PlotPlayer player : players.values()) {
if (player.getUUID().equals(uuid)) {
return player;
}
String name = getName(uuid);
if (name != null) {
return getPlayer(name);
}
return null;
}

View File

@ -41,7 +41,6 @@ public class AugmentedPopulator extends BlockPopulator {
public AugmentedPopulator(final String world, final BukkitPlotGenerator generator, final PlotCluster cluster, final boolean p, final boolean b) {
MainUtil.initCache();
PS.log("== NEW AUGMENTED POPULATOR FOR: " + world);
this.cluster = cluster;
this.generator = generator;
plotworld = PS.get().getPlotWorld(world);

View File

@ -5,6 +5,7 @@ import java.util.Arrays;
import java.util.HashSet;
import java.util.Iterator;
import java.util.List;
import java.util.Map.Entry;
import java.util.Objects;
import java.util.Set;
import java.util.UUID;
@ -140,7 +141,8 @@ public class PlayerEvents extends com.plotsquared.listener.PlotListener implemen
final int x = bloc.getBlockX();
final int z = bloc.getBlockZ();
final int distance = Bukkit.getViewDistance() * 16;
for (final PlotPlayer player : UUIDHandler.getPlayers().values()) {
for (Entry<String, PlotPlayer> entry : UUIDHandler.getPlayers().entrySet()) {
PlotPlayer player = entry.getValue();
final Location loc = player.getLocation();
if (loc.getWorld().equals(world)) {
if ((16 * (Math.abs(loc.getX() - x) / 16)) > distance) {
@ -223,8 +225,8 @@ public class PlayerEvents extends com.plotsquared.listener.PlotListener implemen
}
}
if (Settings.REDSTONE_DISABLER_UNOCCUPIED) {
for (final PlotPlayer pp : UUIDHandler.getPlayers().values()) {
if (plot.equals(pp.getCurrentPlot())) {
for (Entry<String, PlotPlayer> entry : UUIDHandler.getPlayers().entrySet()) {
if (plot.equals(entry.getValue().getCurrentPlot())) {
return;
}
}

View File

@ -6,6 +6,7 @@ import java.util.HashSet;
import java.util.List;
import java.util.Set;
import org.bukkit.Bukkit;
import org.bukkit.command.CommandExecutor;
import org.bukkit.command.CommandSender;
import org.bukkit.command.TabCompleter;
@ -34,7 +35,33 @@ public class BukkitCommand implements CommandExecutor, TabCompleter {
if (commandSender instanceof Player) {
return MainCommand.onCommand(BukkitUtil.getPlayer((Player) commandSender), commandLabel, args);
}
return MainCommand.onCommand(ConsolePlayer.getConsole(), commandLabel, args);
if (commandSender == null || commandSender.getClass() == Bukkit.getConsoleSender().getClass()) {
return MainCommand.onCommand(ConsolePlayer.getConsole(), commandLabel, args);
}
@SuppressWarnings("deprecation")
ConsolePlayer sender = new ConsolePlayer() {
@Override
public void sendMessage(String message) {
commandSender.sendMessage(commandLabel);
}
@Override
public boolean hasPermission(String perm) {
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, commandLabel, args);
ConsolePlayer.getConsole().teleport(sender.getLocationFull());
return result;
}
@Override

View File

@ -125,7 +125,7 @@ public class BukkitUtil extends BlockManager {
return lastPlotPlayer;
}
final String name = player.getName();
final PlotPlayer pp = UUIDHandler.getPlayers().get(name);
final PlotPlayer pp = UUIDHandler.getPlayer(name);
if (pp != null) {
return pp;
}

View File

@ -7,6 +7,7 @@ import java.util.Collection;
import java.util.HashMap;
import java.util.HashSet;
import java.util.List;
import java.util.Map.Entry;
import org.bukkit.Bukkit;
import org.bukkit.Chunk;
@ -76,7 +77,8 @@ public class SendChunk {
final Object c = methodGetHandleChunk.of(chunk).call();
methodInitLighting.of(c).call();
}
for (final PlotPlayer pp : UUIDHandler.getPlayers().values()) {
for (Entry<String, PlotPlayer> entry : UUIDHandler.getPlayers().entrySet()) {
PlotPlayer pp = entry.getValue();
final Plot plot = pp.getCurrentPlot();
Location loc = null;
String world;

View File

@ -3,6 +3,7 @@ package com.plotsquared.sponge.listener;
import java.util.ArrayList;
import java.util.HashSet;
import java.util.List;
import java.util.Map.Entry;
import java.util.Objects;
import java.util.Optional;
import java.util.UUID;
@ -408,7 +409,8 @@ public class MainListener {
final String newMessage = StringMan.replaceAll(C.PLOT_CHAT_FORMAT.s(), "%plot_id%", id.x + ";" + id.y, "%sender%", sender);
final Text forcedMessage = event.getMessage();
// String forcedMessage = StringMan.replaceAll(C.PLOT_CHAT_FORCED.s(), "%plot_id%", id.x + ";" + id.y, "%sender%", sender);
for (final PlotPlayer user : UUIDHandler.getPlayers().values()) {
for (Entry<String, PlotPlayer> entry : UUIDHandler.getPlayers().entrySet()) {
PlotPlayer user = entry.getValue();
String toSend;
if (plot.equals(MainUtil.getPlot(user.getLocation()))) {
toSend = newMessage;

View File

@ -46,7 +46,7 @@ public class SpongeUtil {
return lastPlotPlayer;
}
final String name = player.getName();
final PlotPlayer pp = UUIDHandler.getPlayers().get(name);
final PlotPlayer pp = UUIDHandler.getPlayer(name);
if (pp != null) {
return pp;
}

Binary file not shown.