mirror of
https://github.com/IntellectualSites/PlotSquared.git
synced 2024-11-26 07:06:44 +01:00
parent
c72edc40f0
commit
35589dcc5f
2
pom.xml
2
pom.xml
@ -8,7 +8,7 @@
|
|||||||
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
|
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
|
||||||
</properties>
|
</properties>
|
||||||
<artifactId>PlotSquared</artifactId>
|
<artifactId>PlotSquared</artifactId>
|
||||||
<version>3.2.22</version>
|
<version>3.2.23</version>
|
||||||
<name>PlotSquared</name>
|
<name>PlotSquared</name>
|
||||||
<packaging>jar</packaging>
|
<packaging>jar</packaging>
|
||||||
<build>
|
<build>
|
||||||
|
@ -1336,17 +1336,17 @@ public class PS {
|
|||||||
}
|
}
|
||||||
case "f":
|
case "f":
|
||||||
case "floor": {
|
case "floor": {
|
||||||
config.set(base + "plot.floor", Arrays.asList(StringMan.join(Configuration.BLOCKLIST.parseString(value), ",").split(",")));
|
config.set(base + "plot.floor", new ArrayList<String>(Arrays.asList(StringMan.join(Configuration.BLOCKLIST.parseString(value), ",").split(","))));
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
case "m":
|
case "m":
|
||||||
case "main": {
|
case "main": {
|
||||||
config.set(base + "plot.filling", Arrays.asList(StringMan.join(Configuration.BLOCKLIST.parseString(value), ",").split(",")));
|
config.set(base + "plot.filling", new ArrayList<String>(Arrays.asList(StringMan.join(Configuration.BLOCKLIST.parseString(value), ",").split(","))));
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
case "w":
|
case "w":
|
||||||
case "wall": {
|
case "wall": {
|
||||||
config.set(base + "wall.filling", Arrays.asList(StringMan.join(Configuration.BLOCKLIST.parseString(value), ",").split(",")));
|
config.set(base + "wall.filling", Configuration.BLOCK.parseString(value).toString());
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
case "b":
|
case "b":
|
||||||
|
@ -218,7 +218,7 @@ public class DebugExec extends SubCommand {
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
final String flag = args[1];
|
final String flag = args[1];
|
||||||
for (final Plot plot : PS.get().getPlots()) {
|
for (final Plot plot : PS.get().getBasePlots()) {
|
||||||
if (FlagManager.getPlotFlagRaw(plot, flag) != null) {
|
if (FlagManager.getPlotFlagRaw(plot, flag) != null) {
|
||||||
FlagManager.removePlotFlag(plot, flag);
|
FlagManager.removePlotFlag(plot, flag);
|
||||||
}
|
}
|
||||||
@ -409,6 +409,49 @@ public class DebugExec extends SubCommand {
|
|||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
case "allcmd": {
|
||||||
|
if (args.length < 3) {
|
||||||
|
C.COMMAND_SYNTAX.send(player, "/plot debugexec allcmd <condition> <command>");
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
long start = System.currentTimeMillis();
|
||||||
|
Command<PlotPlayer> cmd = MainCommand.getInstance().getCommand(args[3]);
|
||||||
|
String[] params = Arrays.copyOfRange(args, 4, args.length);
|
||||||
|
if (args[1].equals("true")) {
|
||||||
|
Location loc = (Location) player.getMeta("location");
|
||||||
|
Plot plot = (Plot) player.getMeta("lastplot");
|
||||||
|
for (Plot current : PS.get().getBasePlots()) {
|
||||||
|
player.setMeta("location", current.getBottomAbs());
|
||||||
|
player.setMeta("lastplot", current);
|
||||||
|
cmd.onCommand(player, params);
|
||||||
|
}
|
||||||
|
if (loc == null) {
|
||||||
|
player.deleteMeta("location");
|
||||||
|
} else {
|
||||||
|
player.setMeta("location", loc);
|
||||||
|
}
|
||||||
|
if (plot == null) {
|
||||||
|
player.deleteMeta("lastplot");
|
||||||
|
} else {
|
||||||
|
player.setMeta("lastplot", plot);
|
||||||
|
}
|
||||||
|
player.sendMessage("&c> " + (System.currentTimeMillis() - start));
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
init();
|
||||||
|
scope.put("_2", params);
|
||||||
|
scope.put("_3", cmd);
|
||||||
|
script = "_1=PS.getBasePlots().iterator();while(_1.hasNext()){plot=_1.next();if(" + args[1] + "){PlotPlayer.setMeta(\"location\",plot.getBottomAbs());PlotPlayer.setMeta(\"lastplot\",plot);_3.onCommand(PlotPlayer,_2)}}";
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
case "all": {
|
||||||
|
if (args.length < 3) {
|
||||||
|
C.COMMAND_SYNTAX.send(player, "/plot debugexec all <condition> <code>");
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
script = "_1=PS.getBasePlots().iterator();while(_1.hasNext()){plot=_1.next();if(" + args[1] + "){" + StringMan.join(Arrays.copyOfRange(args, 2, args.length), " ") + "}}";
|
||||||
|
break;
|
||||||
|
}
|
||||||
default: {
|
default: {
|
||||||
script = StringMan.join(args, " ");
|
script = StringMan.join(args, " ");
|
||||||
}
|
}
|
||||||
|
@ -210,6 +210,8 @@ public class MainCommand extends CommandManager<PlotPlayer> {
|
|||||||
int help_index = -1;
|
int help_index = -1;
|
||||||
String category = null;
|
String category = null;
|
||||||
Location loc = null;
|
Location loc = null;
|
||||||
|
Plot plot = null;
|
||||||
|
boolean tp = false;
|
||||||
switch (args.length) {
|
switch (args.length) {
|
||||||
case 0: {
|
case 0: {
|
||||||
help_index = 0;
|
help_index = 0;
|
||||||
@ -268,15 +270,21 @@ public class MainCommand extends CommandManager<PlotPlayer> {
|
|||||||
default: {
|
default: {
|
||||||
if (args.length >= 2) {
|
if (args.length >= 2) {
|
||||||
String world = player.getLocation().getWorld();
|
String world = player.getLocation().getWorld();
|
||||||
Plot plot = Plot.fromString(world, args[0]);
|
Plot newPlot = Plot.fromString(world, args[0]);
|
||||||
if (plot == null) {
|
if (newPlot == null) {
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
if (!ConsolePlayer.isConsole(player) && (!plot.world.equals(world) || plot.isDenied(player.getUUID())) && !Permissions.hasPermission(player, C.PERMISSION_ADMIN)) {
|
if (!ConsolePlayer.isConsole(player) && (!newPlot.world.equals(world) || newPlot.isDenied(player.getUUID())) && !Permissions.hasPermission(player, C.PERMISSION_ADMIN)) {
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
// Save meta
|
||||||
loc = (Location) player.getMeta("location");
|
loc = (Location) player.getMeta("location");
|
||||||
player.setMeta("location", plot.getBottomAbs());
|
plot = (Plot) player.getMeta("lastplot");
|
||||||
|
tp = true;
|
||||||
|
// Set loc
|
||||||
|
player.setMeta("location", newPlot.getBottomAbs());
|
||||||
|
player.setMeta("lastplot", newPlot);
|
||||||
|
// Trim command
|
||||||
args = Arrays.copyOfRange(args, 1, args.length);
|
args = Arrays.copyOfRange(args, 1, args.length);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -292,8 +300,18 @@ public class MainCommand extends CommandManager<PlotPlayer> {
|
|||||||
}
|
}
|
||||||
String fullCmd = StringMan.join(args, " ");
|
String fullCmd = StringMan.join(args, " ");
|
||||||
getInstance().handle(player, cmd + " " + fullCmd);
|
getInstance().handle(player, cmd + " " + fullCmd);
|
||||||
if (loc != null) {
|
// Restore location
|
||||||
player.setMeta("location", loc);
|
if (tp) {
|
||||||
|
if (loc == null) {
|
||||||
|
player.deleteMeta("location");
|
||||||
|
} else {
|
||||||
|
player.setMeta("location", loc);
|
||||||
|
}
|
||||||
|
if (plot == null) {
|
||||||
|
player.deleteMeta("lastplot");
|
||||||
|
} else {
|
||||||
|
player.setMeta("lastplot", plot);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
@ -15,7 +15,6 @@ import com.intellectualcrafters.plot.util.PlotWeather;
|
|||||||
public class ConsolePlayer extends PlotPlayer {
|
public class ConsolePlayer extends PlotPlayer {
|
||||||
|
|
||||||
private static ConsolePlayer instance;
|
private static ConsolePlayer instance;
|
||||||
private Location loc;
|
|
||||||
private final HashMap<String, Object> meta;
|
private final HashMap<String, Object> meta;
|
||||||
|
|
||||||
public static ConsolePlayer getConsole() {
|
public static ConsolePlayer getConsole() {
|
||||||
@ -38,8 +37,9 @@ public class ConsolePlayer extends PlotPlayer {
|
|||||||
} else {
|
} else {
|
||||||
world = "world";
|
world = "world";
|
||||||
}
|
}
|
||||||
loc = new Location(world, 0, 0, 0);
|
|
||||||
meta = new HashMap<>();
|
meta = new HashMap<>();
|
||||||
|
Location loc = new Location(world, 0, 0, 0);
|
||||||
|
setMeta("location", loc);
|
||||||
}
|
}
|
||||||
|
|
||||||
public static boolean isConsole(final PlotPlayer plr) {
|
public static boolean isConsole(final PlotPlayer plr) {
|
||||||
@ -53,12 +53,12 @@ public class ConsolePlayer extends PlotPlayer {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Location getLocation() {
|
public Location getLocation() {
|
||||||
return loc;
|
return (Location) getMeta("location");
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Location getLocationFull() {
|
public Location getLocationFull() {
|
||||||
return loc;
|
return (Location) getMeta("location");
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@ -85,7 +85,7 @@ public class ConsolePlayer extends PlotPlayer {
|
|||||||
public void teleport(final Location loc) {
|
public void teleport(final Location loc) {
|
||||||
final Plot plot = MainUtil.getPlot(loc);
|
final Plot plot = MainUtil.getPlot(loc);
|
||||||
setMeta("lastplot", plot);
|
setMeta("lastplot", plot);
|
||||||
this.loc = loc;
|
setMeta("location", loc);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -7,14 +7,15 @@ import java.util.concurrent.ConcurrentHashMap;
|
|||||||
import com.intellectualcrafters.plot.PS;
|
import com.intellectualcrafters.plot.PS;
|
||||||
import com.intellectualcrafters.plot.commands.RequiredType;
|
import com.intellectualcrafters.plot.commands.RequiredType;
|
||||||
import com.intellectualcrafters.plot.config.Settings;
|
import com.intellectualcrafters.plot.config.Settings;
|
||||||
|
import com.intellectualcrafters.plot.util.CmdConfirm;
|
||||||
import com.intellectualcrafters.plot.util.EventUtil;
|
import com.intellectualcrafters.plot.util.EventUtil;
|
||||||
import com.intellectualcrafters.plot.util.ExpireManager;
|
import com.intellectualcrafters.plot.util.ExpireManager;
|
||||||
import com.intellectualcrafters.plot.util.MainUtil;
|
import com.intellectualcrafters.plot.util.MainUtil;
|
||||||
import com.intellectualcrafters.plot.util.PlotGamemode;
|
import com.intellectualcrafters.plot.util.PlotGamemode;
|
||||||
import com.intellectualcrafters.plot.util.PlotWeather;
|
import com.intellectualcrafters.plot.util.PlotWeather;
|
||||||
|
import com.intellectualcrafters.plot.util.SetupUtils;
|
||||||
import com.intellectualcrafters.plot.util.UUIDHandler;
|
import com.intellectualcrafters.plot.util.UUIDHandler;
|
||||||
import com.plotsquared.general.commands.CommandCaller;
|
import com.plotsquared.general.commands.CommandCaller;
|
||||||
import com.plotsquared.listener.PlotListener;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The PlotPlayer class<br>
|
* The PlotPlayer class<br>
|
||||||
@ -321,17 +322,19 @@ public abstract class PlotPlayer implements CommandCaller {
|
|||||||
public void unregister() {
|
public void unregister() {
|
||||||
final Plot plot = getCurrentPlot();
|
final Plot plot = getCurrentPlot();
|
||||||
if (plot != null) {
|
if (plot != null) {
|
||||||
PlotListener.plotExit(this, plot);
|
EventUtil.manager.callLeave(this, plot);
|
||||||
}
|
}
|
||||||
ExpireManager.dates.put(getUUID(), System.currentTimeMillis());
|
|
||||||
EventUtil.unregisterPlayer(this);
|
|
||||||
if (Settings.DELETE_PLOTS_ON_BAN && isBanned()) {
|
if (Settings.DELETE_PLOTS_ON_BAN && isBanned()) {
|
||||||
for (final Plot owned : PS.get().getPlotsInWorld(getName())) {
|
for (final Plot owned : PS.get().getPlotsInWorld(getName())) {
|
||||||
owned.deletePlot(null);
|
owned.deletePlot(null);
|
||||||
PS.debug(String.format("&cPlot &6%s &cwas deleted + cleared due to &6%s&c getting banned", plot.getId(), getName()));
|
PS.debug(String.format("&cPlot &6%s &cwas deleted + cleared due to &6%s&c getting banned", plot.getId(), getName()));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
UUIDHandler.getPlayers().remove(getName());
|
String name = getName();
|
||||||
|
ExpireManager.dates.put(getUUID(), System.currentTimeMillis());
|
||||||
|
SetupUtils.setupMap.remove(name);
|
||||||
|
CmdConfirm.removePending(name);
|
||||||
|
UUIDHandler.getPlayers().remove(name);
|
||||||
PS.get().IMP.unregister(this);
|
PS.get().IMP.unregister(this);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -284,6 +284,11 @@ public abstract class PlotWorld {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String toString() {
|
||||||
|
return worldname;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Used for the <b>/plot setup</b> command Return null if you do not want to support this feature
|
* Used for the <b>/plot setup</b> command Return null if you do not want to support this feature
|
||||||
*
|
*
|
||||||
|
@ -4,7 +4,6 @@ import java.util.ArrayList;
|
|||||||
import java.util.HashSet;
|
import java.util.HashSet;
|
||||||
import java.util.UUID;
|
import java.util.UUID;
|
||||||
|
|
||||||
import com.intellectualcrafters.plot.PS;
|
|
||||||
import com.intellectualcrafters.plot.config.C;
|
import com.intellectualcrafters.plot.config.C;
|
||||||
import com.intellectualcrafters.plot.flag.Flag;
|
import com.intellectualcrafters.plot.flag.Flag;
|
||||||
import com.intellectualcrafters.plot.flag.FlagManager;
|
import com.intellectualcrafters.plot.flag.FlagManager;
|
||||||
@ -22,15 +21,6 @@ public abstract class EventUtil {
|
|||||||
|
|
||||||
public static EventUtil manager = null;
|
public static EventUtil manager = null;
|
||||||
|
|
||||||
public static void unregisterPlayer(final PlotPlayer player) {
|
|
||||||
final String name = player.getName();
|
|
||||||
if (SetupUtils.setupMap.containsKey(name)) {
|
|
||||||
SetupUtils.setupMap.remove(name);
|
|
||||||
}
|
|
||||||
CmdConfirm.removePending(name);
|
|
||||||
PS.get().IMP.unregister(player);
|
|
||||||
}
|
|
||||||
|
|
||||||
public abstract Rating callRating(final PlotPlayer player, final Plot plot, final Rating rating);
|
public abstract Rating callRating(final PlotPlayer player, final Plot plot, final Rating rating);
|
||||||
|
|
||||||
public abstract boolean callClaim(final PlotPlayer player, final Plot plot, final boolean auto);
|
public abstract boolean callClaim(final PlotPlayer player, final Plot plot, final boolean auto);
|
||||||
|
@ -108,27 +108,32 @@ public abstract class UUIDHandlerImplementation {
|
|||||||
* lazy UUID conversion:
|
* lazy UUID conversion:
|
||||||
* - Useful if the person misconfigured the database, or settings before PlotMe conversion
|
* - Useful if the person misconfigured the database, or settings before PlotMe conversion
|
||||||
*/
|
*/
|
||||||
if (!Settings.OFFLINE_MODE) {
|
if (!Settings.OFFLINE_MODE && unknown.size() > 0) {
|
||||||
UUID offline = UUID.nameUUIDFromBytes(("OfflinePlayer:" + name.value).getBytes(Charsets.UTF_8));
|
TaskManager.runTaskAsync(new Runnable() {
|
||||||
if (!unknown.contains(offline) && !name.value.equals(name.value.toLowerCase())) {
|
@Override
|
||||||
offline = UUID.nameUUIDFromBytes(("OfflinePlayer:" + name.value).getBytes(Charsets.UTF_8));
|
public void run() {
|
||||||
if (!unknown.contains(offline)) {
|
UUID offline = UUID.nameUUIDFromBytes(("OfflinePlayer:" + name.value).getBytes(Charsets.UTF_8));
|
||||||
offline = null;
|
if (!unknown.contains(offline) && !name.value.equals(name.value.toLowerCase())) {
|
||||||
}
|
offline = UUID.nameUUIDFromBytes(("OfflinePlayer:" + name.value.toLowerCase()).getBytes(Charsets.UTF_8));
|
||||||
}
|
if (!unknown.contains(offline)) {
|
||||||
if (offline != null && !offline.equals(uuid)) {
|
offline = null;
|
||||||
unknown.remove(offline);
|
}
|
||||||
final Set<Plot> plots = PS.get().getPlots(offline);
|
}
|
||||||
if (plots.size() > 0) {
|
if (offline != null && !offline.equals(uuid)) {
|
||||||
for (final Plot plot : plots) {
|
unknown.remove(offline);
|
||||||
plot.owner = uuid;
|
final Set<Plot> plots = PS.get().getPlots(offline);
|
||||||
|
if (plots.size() > 0) {
|
||||||
|
for (final Plot plot : plots) {
|
||||||
|
plot.owner = uuid;
|
||||||
|
}
|
||||||
|
DBFunc.replaceUUID(offline, uuid);
|
||||||
|
PS.debug("&cDetected invalid UUID stored for: " + name.value);
|
||||||
|
PS.debug("&7 - Did you recently switch to online-mode storage without running `uuidconvert`?");
|
||||||
|
PS.debug("&6PlotSquared will update incorrect entries when the user logs in, or you can reconstruct your database.");
|
||||||
|
}
|
||||||
}
|
}
|
||||||
DBFunc.replaceUUID(offline, uuid);
|
|
||||||
PS.debug("&cDetected invalid UUID stored for: " + name.value);
|
|
||||||
PS.debug("&7 - Did you recently switch to online-mode storage without running `uuidconvert`?");
|
|
||||||
PS.debug("&6PlotSquared will update incorrect entries when the user logs in, or you can reconstruct your database.");
|
|
||||||
}
|
}
|
||||||
}
|
});
|
||||||
}
|
}
|
||||||
try {
|
try {
|
||||||
final UUID offline = uuidMap.put(name, uuid);
|
final UUID offline = uuidMap.put(name, uuid);
|
||||||
|
@ -74,9 +74,7 @@ import org.bukkit.event.player.PlayerCommandPreprocessEvent;
|
|||||||
import org.bukkit.event.player.PlayerEggThrowEvent;
|
import org.bukkit.event.player.PlayerEggThrowEvent;
|
||||||
import org.bukkit.event.player.PlayerInteractEntityEvent;
|
import org.bukkit.event.player.PlayerInteractEntityEvent;
|
||||||
import org.bukkit.event.player.PlayerInteractEvent;
|
import org.bukkit.event.player.PlayerInteractEvent;
|
||||||
import org.bukkit.event.player.PlayerJoinEvent;
|
|
||||||
import org.bukkit.event.player.PlayerLoginEvent;
|
import org.bukkit.event.player.PlayerLoginEvent;
|
||||||
import org.bukkit.event.player.PlayerLoginEvent.Result;
|
|
||||||
import org.bukkit.event.player.PlayerMoveEvent;
|
import org.bukkit.event.player.PlayerMoveEvent;
|
||||||
import org.bukkit.event.player.PlayerQuitEvent;
|
import org.bukkit.event.player.PlayerQuitEvent;
|
||||||
import org.bukkit.event.player.PlayerTeleportEvent;
|
import org.bukkit.event.player.PlayerTeleportEvent;
|
||||||
@ -96,7 +94,6 @@ import org.bukkit.util.Vector;
|
|||||||
import com.intellectualcrafters.plot.PS;
|
import com.intellectualcrafters.plot.PS;
|
||||||
import com.intellectualcrafters.plot.config.C;
|
import com.intellectualcrafters.plot.config.C;
|
||||||
import com.intellectualcrafters.plot.config.Settings;
|
import com.intellectualcrafters.plot.config.Settings;
|
||||||
import com.intellectualcrafters.plot.database.DBFunc;
|
|
||||||
import com.intellectualcrafters.plot.flag.Flag;
|
import com.intellectualcrafters.plot.flag.Flag;
|
||||||
import com.intellectualcrafters.plot.flag.FlagManager;
|
import com.intellectualcrafters.plot.flag.FlagManager;
|
||||||
import com.intellectualcrafters.plot.object.Location;
|
import com.intellectualcrafters.plot.object.Location;
|
||||||
@ -407,57 +404,48 @@ public class PlayerEvents extends com.plotsquared.listener.PlotListener implemen
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@EventHandler(priority = EventPriority.HIGHEST, ignoreCancelled = true)
|
@EventHandler(priority = EventPriority.MONITOR, ignoreCancelled = true)
|
||||||
public void onConnect(final PlayerLoginEvent event) {
|
public void onConnect(final PlayerLoginEvent event) {
|
||||||
final Player player = event.getPlayer();
|
final Player player = event.getPlayer();
|
||||||
final String name = player.getName();
|
BukkitUtil.getPlayer(event.getPlayer()).unregister();
|
||||||
final PlotPlayer pp = BukkitUtil.getPlayer(player);
|
final PlotPlayer pp = BukkitUtil.getPlayer(player);
|
||||||
if (name.equals("PlotSquared") || pp.getUUID().equals(DBFunc.everyone)) {
|
// Now
|
||||||
event.disallow(Result.KICK_WHITELIST, "This account is reserved");
|
String name = pp.getName();
|
||||||
BukkitUtil.removePlayer(pp.getName());
|
StringWrapper sw = new StringWrapper(name);
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
@EventHandler(priority = EventPriority.HIGHEST, ignoreCancelled = true)
|
|
||||||
public void onJoin(final PlayerJoinEvent event) {
|
|
||||||
final Player player = event.getPlayer();
|
|
||||||
if (!player.hasPlayedBefore()) {
|
|
||||||
player.saveData();
|
|
||||||
}
|
|
||||||
BukkitUtil.getPlayer(event.getPlayer()).unregister();;
|
|
||||||
final PlotPlayer pp = BukkitUtil.getPlayer(player);
|
|
||||||
|
|
||||||
// Set last location
|
|
||||||
pp.setMeta("location", BukkitUtil.getLocation(player.getLocation()));
|
|
||||||
|
|
||||||
final String username = pp.getName();
|
|
||||||
final StringWrapper name = new StringWrapper(username);
|
|
||||||
final UUID uuid = pp.getUUID();
|
final UUID uuid = pp.getUUID();
|
||||||
UUIDHandler.add(name, uuid);
|
UUIDHandler.add(sw, uuid);
|
||||||
ExpireManager.dates.put(uuid, System.currentTimeMillis());
|
|
||||||
if (BukkitMain.worldEdit != null) {
|
Location loc = pp.getLocation();
|
||||||
if (pp.getAttribute("worldedit")) {
|
final Plot plot = MainUtil.getPlotAbs(loc);
|
||||||
MainUtil.sendMessage(pp, C.WORLDEDIT_BYPASSED);
|
if (plot != null) {
|
||||||
}
|
plotEntry(pp, plot);
|
||||||
}
|
}
|
||||||
if ((PS.get().update != null) && Permissions.hasPermission(pp, C.PERMISSION_ADMIN_UPDATE) && Settings.UPDATE_NOTIFICATIONS) {
|
// Delayed
|
||||||
TaskManager.runTaskLater(new Runnable() {
|
{
|
||||||
@Override
|
|
||||||
public void run() {
|
}
|
||||||
|
// Async
|
||||||
|
TaskManager.runTaskLaterAsync(new Runnable() {
|
||||||
|
@Override
|
||||||
|
public void run() {
|
||||||
|
if (!player.hasPlayedBefore()) {
|
||||||
|
player.saveData();
|
||||||
|
}
|
||||||
|
ExpireManager.dates.put(uuid, System.currentTimeMillis());
|
||||||
|
if (BukkitMain.worldEdit != null) {
|
||||||
|
if (pp.getAttribute("worldedit")) {
|
||||||
|
MainUtil.sendMessage(pp, C.WORLDEDIT_BYPASSED);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if ((PS.get().update != null) && Permissions.hasPermission(pp, C.PERMISSION_ADMIN_UPDATE) && Settings.UPDATE_NOTIFICATIONS) {
|
||||||
MainUtil.sendMessage(pp, "&6An update for PlotSquared is available: &7/plot update");
|
MainUtil.sendMessage(pp, "&6An update for PlotSquared is available: &7/plot update");
|
||||||
}
|
}
|
||||||
}, 20);
|
if (Settings.TELEPORT_ON_LOGIN && plot != null) {
|
||||||
}
|
MainUtil.teleportPlayer(pp, pp.getLocation(), plot);
|
||||||
final Location loc = BukkitUtil.getLocation(player.getLocation());
|
MainUtil.sendMessage(pp, C.TELEPORTED_TO_ROAD);
|
||||||
final Plot plot = MainUtil.getPlot(loc);
|
}
|
||||||
if (plot == null) {
|
}
|
||||||
return;
|
}, 20);
|
||||||
}
|
|
||||||
if (Settings.TELEPORT_ON_LOGIN) {
|
|
||||||
MainUtil.teleportPlayer(pp, pp.getLocation(), plot);
|
|
||||||
MainUtil.sendMessage(pp, C.TELEPORTED_TO_ROAD);
|
|
||||||
}
|
|
||||||
plotEntry(pp, plot);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@EventHandler(priority = EventPriority.HIGHEST, ignoreCancelled = true)
|
@EventHandler(priority = EventPriority.HIGHEST, ignoreCancelled = true)
|
||||||
@ -740,8 +728,7 @@ public class PlayerEvents extends com.plotsquared.listener.PlotListener implemen
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (Settings.PERMISSION_CACHING) {
|
if (Settings.PERMISSION_CACHING) {
|
||||||
((BukkitPlayer) pp).hasPerm = new HashSet<>();
|
pp.deleteMeta("perm");
|
||||||
((BukkitPlayer) pp).noPerm = new HashSet<>();
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1225,9 +1212,8 @@ public class PlayerEvents extends com.plotsquared.listener.PlotListener implemen
|
|||||||
if (entity instanceof Player) {
|
if (entity instanceof Player) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
final Location loc = BukkitUtil.getLocation(event.getLocation());
|
final Location loc = BukkitUtil.getLocation(entity.getLocation());
|
||||||
final String world = loc.getWorld();
|
final PlotWorld plotworld = loc.getPlotWorld();
|
||||||
final PlotWorld plotworld = PS.get().getPlotWorld(world);
|
|
||||||
if (plotworld == null) {
|
if (plotworld == null) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@ -1235,18 +1221,28 @@ public class PlayerEvents extends com.plotsquared.listener.PlotListener implemen
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
final CreatureSpawnEvent.SpawnReason reason = event.getSpawnReason();
|
final CreatureSpawnEvent.SpawnReason reason = event.getSpawnReason();
|
||||||
if (((reason == CreatureSpawnEvent.SpawnReason.SPAWNER_EGG) || (reason == CreatureSpawnEvent.SpawnReason.DISPENSE_EGG)) && !plotworld.SPAWN_EGGS) {
|
switch (reason) {
|
||||||
event.setCancelled(true);
|
case SPAWNER_EGG:
|
||||||
return;
|
case DISPENSE_EGG:
|
||||||
} else if ((reason == CreatureSpawnEvent.SpawnReason.BREEDING) && !plotworld.SPAWN_BREEDING) {
|
if (!plotworld.SPAWN_EGGS) {
|
||||||
event.setCancelled(true);
|
event.setCancelled(true);
|
||||||
return;
|
return;
|
||||||
} else if ((reason == CreatureSpawnEvent.SpawnReason.CUSTOM) && !plotworld.SPAWN_CUSTOM && !(event.getEntityType().getTypeId() == 30)) {
|
}
|
||||||
event.setCancelled(true);
|
break;
|
||||||
return;
|
case BREEDING:
|
||||||
|
if (!plotworld.SPAWN_BREEDING) {
|
||||||
|
event.setCancelled(true);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
case CUSTOM:
|
||||||
|
if (!plotworld.SPAWN_CUSTOM && entity.getType().getTypeId() != 30) {
|
||||||
|
event.setCancelled(true);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
break;
|
||||||
}
|
}
|
||||||
|
final Plot plot = MainUtil.getPlotAbs(loc);
|
||||||
final Plot plot = MainUtil.getPlot(loc);
|
|
||||||
if (checkEntity(entity, plot)) {
|
if (checkEntity(entity, plot)) {
|
||||||
event.setCancelled(true);
|
event.setCancelled(true);
|
||||||
return;
|
return;
|
||||||
@ -1342,116 +1338,116 @@ public class PlayerEvents extends com.plotsquared.listener.PlotListener implemen
|
|||||||
}
|
}
|
||||||
|
|
||||||
public boolean checkEntity(final Entity entity, final Plot plot) {
|
public boolean checkEntity(final Entity entity, final Plot plot) {
|
||||||
if ((plot != null) && (plot.owner != null)) {
|
if (plot == null || plot.owner == null || plot.settings == null || (plot.settings.flags.size() == 0 && plot.getWorld().DEFAULT_FLAGS.size() == 0)) {
|
||||||
switch (entity.getType()) {
|
return false;
|
||||||
case PLAYER: {
|
}
|
||||||
return false;
|
switch (entity.getType()) {
|
||||||
}
|
case PLAYER: {
|
||||||
case SMALL_FIREBALL:
|
return false;
|
||||||
case FIREBALL:
|
}
|
||||||
case DROPPED_ITEM:
|
case SMALL_FIREBALL:
|
||||||
case EGG:
|
case FIREBALL:
|
||||||
case THROWN_EXP_BOTTLE:
|
case DROPPED_ITEM:
|
||||||
case SPLASH_POTION:
|
case EGG:
|
||||||
case SNOWBALL:
|
case THROWN_EXP_BOTTLE:
|
||||||
case ENDER_PEARL:
|
case SPLASH_POTION:
|
||||||
case ARROW: {
|
case SNOWBALL:
|
||||||
// projectile
|
case ENDER_PEARL:
|
||||||
}
|
case ARROW: {
|
||||||
case PRIMED_TNT:
|
// projectile
|
||||||
case FALLING_BLOCK: {
|
}
|
||||||
// Block entities
|
case PRIMED_TNT:
|
||||||
}
|
case FALLING_BLOCK: {
|
||||||
case ENDER_CRYSTAL:
|
// Block entities
|
||||||
case COMPLEX_PART:
|
}
|
||||||
case FISHING_HOOK:
|
case ENDER_CRYSTAL:
|
||||||
case ENDER_SIGNAL:
|
case COMPLEX_PART:
|
||||||
case EXPERIENCE_ORB:
|
case FISHING_HOOK:
|
||||||
case LEASH_HITCH:
|
case ENDER_SIGNAL:
|
||||||
case FIREWORK:
|
case EXPERIENCE_ORB:
|
||||||
case WEATHER:
|
case LEASH_HITCH:
|
||||||
case LIGHTNING:
|
case FIREWORK:
|
||||||
case WITHER_SKULL:
|
case WEATHER:
|
||||||
case UNKNOWN: {
|
case LIGHTNING:
|
||||||
// non moving / unremovable
|
case WITHER_SKULL:
|
||||||
return checkEntity(plot, "entity-cap");
|
case UNKNOWN: {
|
||||||
}
|
// non moving / unremovable
|
||||||
case ITEM_FRAME:
|
return checkEntity(plot, "entity-cap");
|
||||||
case PAINTING:
|
}
|
||||||
case ARMOR_STAND: {
|
case ITEM_FRAME:
|
||||||
return checkEntity(plot, "entity-cap", "misc-cap");
|
case PAINTING:
|
||||||
// misc
|
case ARMOR_STAND: {
|
||||||
}
|
return checkEntity(plot, "entity-cap", "misc-cap");
|
||||||
case MINECART:
|
// misc
|
||||||
case MINECART_CHEST:
|
}
|
||||||
case MINECART_COMMAND:
|
case MINECART:
|
||||||
case MINECART_FURNACE:
|
case MINECART_CHEST:
|
||||||
case MINECART_HOPPER:
|
case MINECART_COMMAND:
|
||||||
case MINECART_MOB_SPAWNER:
|
case MINECART_FURNACE:
|
||||||
case MINECART_TNT:
|
case MINECART_HOPPER:
|
||||||
case BOAT: {
|
case MINECART_MOB_SPAWNER:
|
||||||
return checkEntity(plot, "entity-cap", "vehicle-cap");
|
case MINECART_TNT:
|
||||||
}
|
case BOAT: {
|
||||||
case RABBIT:
|
return checkEntity(plot, "entity-cap", "vehicle-cap");
|
||||||
case SHEEP:
|
}
|
||||||
case MUSHROOM_COW:
|
case RABBIT:
|
||||||
case OCELOT:
|
case SHEEP:
|
||||||
case PIG:
|
case MUSHROOM_COW:
|
||||||
case HORSE:
|
case OCELOT:
|
||||||
case SQUID:
|
case PIG:
|
||||||
case VILLAGER:
|
case HORSE:
|
||||||
case IRON_GOLEM:
|
case SQUID:
|
||||||
case WOLF:
|
case VILLAGER:
|
||||||
case CHICKEN:
|
case IRON_GOLEM:
|
||||||
case COW:
|
case WOLF:
|
||||||
case SNOWMAN:
|
case CHICKEN:
|
||||||
case BAT: {
|
case COW:
|
||||||
// animal
|
case SNOWMAN:
|
||||||
return checkEntity(plot, "entity-cap", "mob-cap", "animal-cap");
|
case BAT: {
|
||||||
}
|
// animal
|
||||||
case BLAZE:
|
return checkEntity(plot, "entity-cap", "mob-cap", "animal-cap");
|
||||||
case CAVE_SPIDER:
|
}
|
||||||
case CREEPER:
|
case BLAZE:
|
||||||
case ENDERMAN:
|
case CAVE_SPIDER:
|
||||||
case ENDERMITE:
|
case CREEPER:
|
||||||
case ENDER_DRAGON:
|
case ENDERMAN:
|
||||||
case GHAST:
|
case ENDERMITE:
|
||||||
case GIANT:
|
case ENDER_DRAGON:
|
||||||
case GUARDIAN:
|
case GHAST:
|
||||||
case MAGMA_CUBE:
|
case GIANT:
|
||||||
case PIG_ZOMBIE:
|
case GUARDIAN:
|
||||||
case SILVERFISH:
|
case MAGMA_CUBE:
|
||||||
case SKELETON:
|
case PIG_ZOMBIE:
|
||||||
case SLIME:
|
case SILVERFISH:
|
||||||
case SPIDER:
|
case SKELETON:
|
||||||
case WITCH:
|
case SLIME:
|
||||||
case WITHER:
|
case SPIDER:
|
||||||
case ZOMBIE: {
|
case WITCH:
|
||||||
// monster
|
case WITHER:
|
||||||
return checkEntity(plot, "entity-cap", "mob-cap", "hostile-cap");
|
case ZOMBIE: {
|
||||||
}
|
// monster
|
||||||
default: {
|
return checkEntity(plot, "entity-cap", "mob-cap", "hostile-cap");
|
||||||
String[] types;
|
}
|
||||||
if (entity instanceof LivingEntity) {
|
default: {
|
||||||
if (entity instanceof Animals) {
|
String[] types;
|
||||||
types = new String[] { "entity-cap", "mob-cap", "animal-cap" };
|
if (entity instanceof LivingEntity) {
|
||||||
} else if (entity instanceof Monster) {
|
if (entity instanceof Animals) {
|
||||||
types = new String[] { "entity-cap", "mob-cap", "hostile-cap" };
|
types = new String[] { "entity-cap", "mob-cap", "animal-cap" };
|
||||||
} else {
|
} else if (entity instanceof Monster) {
|
||||||
types = new String[] { "entity-cap", "mob-cap" };
|
types = new String[] { "entity-cap", "mob-cap", "hostile-cap" };
|
||||||
}
|
|
||||||
} else if (entity instanceof Vehicle) {
|
|
||||||
types = new String[] { "entity-cap", "vehicle-cap" };
|
|
||||||
} else if (entity instanceof Hanging) {
|
|
||||||
types = new String[] { "entity-cap", "misc-cap" };
|
|
||||||
} else {
|
} else {
|
||||||
types = new String[] { "entity-cap" };
|
types = new String[] { "entity-cap", "mob-cap" };
|
||||||
}
|
}
|
||||||
return checkEntity(plot, types);
|
} else if (entity instanceof Vehicle) {
|
||||||
|
types = new String[] { "entity-cap", "vehicle-cap" };
|
||||||
|
} else if (entity instanceof Hanging) {
|
||||||
|
types = new String[] { "entity-cap", "misc-cap" };
|
||||||
|
} else {
|
||||||
|
types = new String[] { "entity-cap" };
|
||||||
}
|
}
|
||||||
|
return checkEntity(plot, types);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return false;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@EventHandler(priority = EventPriority.HIGHEST, ignoreCancelled = true)
|
@EventHandler(priority = EventPriority.HIGHEST, ignoreCancelled = true)
|
||||||
|
@ -65,37 +65,41 @@ public class PlotPlusListener extends PlotListener implements Listener {
|
|||||||
plugin.getServer().getScheduler().scheduleSyncRepeatingTask(plugin, new Runnable() {
|
plugin.getServer().getScheduler().scheduleSyncRepeatingTask(plugin, new Runnable() {
|
||||||
@Override
|
@Override
|
||||||
public void run() {
|
public void run() {
|
||||||
for (final Iterator<Entry<String, Interval>> iter = healRunnable.entrySet().iterator(); iter.hasNext();) {
|
if (healRunnable.size() > 0) {
|
||||||
final Entry<String, Interval> entry = iter.next();
|
for (final Iterator<Entry<String, Interval>> iter = healRunnable.entrySet().iterator(); iter.hasNext();) {
|
||||||
final Interval value = entry.getValue();
|
final Entry<String, Interval> entry = iter.next();
|
||||||
++value.count;
|
final Interval value = entry.getValue();
|
||||||
if (value.count == value.interval) {
|
++value.count;
|
||||||
value.count = 0;
|
if (value.count == value.interval) {
|
||||||
final Player player = Bukkit.getPlayer(entry.getKey());
|
value.count = 0;
|
||||||
if (player == null) {
|
final Player player = Bukkit.getPlayer(entry.getKey());
|
||||||
iter.remove();
|
if (player == null) {
|
||||||
continue;
|
iter.remove();
|
||||||
}
|
continue;
|
||||||
final double level = player.getHealth();
|
}
|
||||||
if (level != value.max) {
|
final double level = player.getHealth();
|
||||||
player.setHealth(Math.min(level + value.amount, value.max));
|
if (level != value.max) {
|
||||||
|
player.setHealth(Math.min(level + value.amount, value.max));
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
for (final Iterator<Entry<String, Interval>> iter = feedRunnable.entrySet().iterator(); iter.hasNext();) {
|
if (feedRunnable.size() > 0) {
|
||||||
final Entry<String, Interval> entry = iter.next();
|
for (final Iterator<Entry<String, Interval>> iter = feedRunnable.entrySet().iterator(); iter.hasNext();) {
|
||||||
final Interval value = entry.getValue();
|
final Entry<String, Interval> entry = iter.next();
|
||||||
++value.count;
|
final Interval value = entry.getValue();
|
||||||
if (value.count == value.interval) {
|
++value.count;
|
||||||
value.count = 0;
|
if (value.count == value.interval) {
|
||||||
final Player player = Bukkit.getPlayer(entry.getKey());
|
value.count = 0;
|
||||||
if (player == null) {
|
final Player player = Bukkit.getPlayer(entry.getKey());
|
||||||
iter.remove();
|
if (player == null) {
|
||||||
continue;
|
iter.remove();
|
||||||
}
|
continue;
|
||||||
final int level = player.getFoodLevel();
|
}
|
||||||
if (level != value.max) {
|
final int level = player.getFoodLevel();
|
||||||
player.setFoodLevel(Math.min(level + value.amount, value.max));
|
if (level != value.max) {
|
||||||
|
player.setFoodLevel(Math.min(level + value.amount, value.max));
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1,6 +1,5 @@
|
|||||||
package com.plotsquared.bukkit.object;
|
package com.plotsquared.bukkit.object;
|
||||||
|
|
||||||
import java.util.HashSet;
|
|
||||||
import java.util.UUID;
|
import java.util.UUID;
|
||||||
|
|
||||||
import org.bukkit.Bukkit;
|
import org.bukkit.Bukkit;
|
||||||
@ -29,8 +28,6 @@ public class BukkitPlayer extends PlotPlayer {
|
|||||||
private UUID uuid;
|
private UUID uuid;
|
||||||
private String name;
|
private String name;
|
||||||
private long last = 0;
|
private long last = 0;
|
||||||
public HashSet<String> hasPerm = new HashSet<>();
|
|
||||||
public HashSet<String> noPerm = new HashSet<>();
|
|
||||||
public boolean offline;
|
public boolean offline;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
Binary file not shown.
Loading…
Reference in New Issue
Block a user