diff --git a/Bukkit/build.gradle b/Bukkit/build.gradle index e9aadce6a..67ec86e4d 100644 --- a/Bukkit/build.gradle +++ b/Bukkit/build.gradle @@ -1,6 +1,6 @@ dependencies { compile project(':Core') - compile 'org.spigotmc:spigot-api:1.10.2-R0.1-SNAPSHOT' + compile 'org.bukkit:Spigot:1.10' compile 'org.mcstats.bukkit:metrics:R7' compile 'net.milkbowl.vault:VaultAPI:1.6' } diff --git a/Bukkit/src/main/java/com/plotsquared/bukkit/listeners/ChunkListener.java b/Bukkit/src/main/java/com/plotsquared/bukkit/listeners/ChunkListener.java index f6355eeec..4e5ab09da 100644 --- a/Bukkit/src/main/java/com/plotsquared/bukkit/listeners/ChunkListener.java +++ b/Bukkit/src/main/java/com/plotsquared/bukkit/listeners/ChunkListener.java @@ -1,7 +1,5 @@ package com.plotsquared.bukkit.listeners; -import static com.intellectualcrafters.plot.util.ReflectionUtils.getRefClass; - import com.intellectualcrafters.plot.PS; import com.intellectualcrafters.plot.config.Settings; import com.intellectualcrafters.plot.object.Location; @@ -10,6 +8,8 @@ import com.intellectualcrafters.plot.util.ReflectionUtils.RefClass; import com.intellectualcrafters.plot.util.ReflectionUtils.RefField; import com.intellectualcrafters.plot.util.ReflectionUtils.RefMethod; import com.intellectualcrafters.plot.util.TaskManager; +import java.lang.reflect.Method; +import java.util.HashSet; import org.bukkit.Bukkit; import org.bukkit.Chunk; import org.bukkit.Material; @@ -28,8 +28,8 @@ import org.bukkit.event.entity.ItemSpawnEvent; import org.bukkit.event.world.ChunkLoadEvent; import org.bukkit.event.world.ChunkUnloadEvent; -import java.lang.reflect.Method; -import java.util.HashSet; + +import static com.intellectualcrafters.plot.util.ReflectionUtils.getRefClass; public class ChunkListener implements Listener { @@ -100,14 +100,21 @@ public class ChunkListener implements Listener { }, 1); } + private boolean ignoreUnload = false; + public boolean unloadChunk(String world, Chunk chunk, boolean safe) { if (safe && shouldSave(world, chunk.getX(), chunk.getZ())) { return false; } Object c = this.methodGetHandleChunk.of(chunk).call(); - this.mustSave.of(c).set(false); - if (chunk.isLoaded()) { - chunk.unload(false, false); + RefField.RefExecutor field = this.mustSave.of(c); + if (field.get() == true) { + field.set(false); + if (chunk.isLoaded()) { + ignoreUnload = true; + chunk.unload(false, false); + ignoreUnload = false; + } } return true; } @@ -139,6 +146,9 @@ public class ChunkListener implements Listener { @EventHandler public void onChunkUnload(ChunkUnloadEvent event) { + if (ignoreUnload) { + return; + } if (Settings.Chunk_Processor.AUTO_TRIM) { Chunk chunk = event.getChunk(); String world = chunk.getWorld().getName(); diff --git a/Bukkit/src/main/java/com/plotsquared/bukkit/listeners/PlayerEvents.java b/Bukkit/src/main/java/com/plotsquared/bukkit/listeners/PlayerEvents.java index ab00d14a6..2ff26fcfd 100644 --- a/Bukkit/src/main/java/com/plotsquared/bukkit/listeners/PlayerEvents.java +++ b/Bukkit/src/main/java/com/plotsquared/bukkit/listeners/PlayerEvents.java @@ -1374,7 +1374,7 @@ public class PlayerEvents extends PlotListener implements Listener { this.lastRadius = event.getRadius() + 1; } - public boolean checkEntity(Plot plot, IntegerFlag... flags) { + public static boolean checkEntity(Plot plot, IntegerFlag... flags) { int[] mobs = null; for (IntegerFlag flag : flags) { int i; diff --git a/Core/src/main/java/com/intellectualcrafters/plot/commands/MainCommand.java b/Core/src/main/java/com/intellectualcrafters/plot/commands/MainCommand.java index 40751412b..20b897f0d 100644 --- a/Core/src/main/java/com/intellectualcrafters/plot/commands/MainCommand.java +++ b/Core/src/main/java/com/intellectualcrafters/plot/commands/MainCommand.java @@ -223,7 +223,12 @@ public class MainCommand extends Command { args = Arrays.copyOfRange(args, 1, args.length); } } - super.execute(player, args, confirm, whenDone); + try { + super.execute(player, args, confirm, whenDone); + } catch (Throwable e) { + e.printStackTrace(); + C.ERROR.send(player, e.getLocalizedMessage()); + } // Reset command scope // if (tp && !(player instanceof ConsolePlayer)) { if (loc == null) { diff --git a/Core/src/main/java/com/intellectualcrafters/plot/commands/Visit.java b/Core/src/main/java/com/intellectualcrafters/plot/commands/Visit.java index 319407f4f..b09662e77 100644 --- a/Core/src/main/java/com/intellectualcrafters/plot/commands/Visit.java +++ b/Core/src/main/java/com/intellectualcrafters/plot/commands/Visit.java @@ -4,10 +4,13 @@ import com.intellectualcrafters.plot.PS; import com.intellectualcrafters.plot.config.C; import com.intellectualcrafters.plot.object.Plot; import com.intellectualcrafters.plot.object.PlotPlayer; +import com.intellectualcrafters.plot.object.RunnableVal2; +import com.intellectualcrafters.plot.object.RunnableVal3; import com.intellectualcrafters.plot.util.MainUtil; import com.intellectualcrafters.plot.util.MathMan; import com.intellectualcrafters.plot.util.Permissions; import com.intellectualcrafters.plot.util.UUIDHandler; +import com.plotsquared.general.commands.Command; import com.plotsquared.general.commands.CommandDeclaration; import java.util.Collection; @@ -20,14 +23,23 @@ import java.util.UUID; command = "visit", permission = "plots.visit", description = "Visit someones plot", - usage = "/plot visit [player|alias|world|id] [#]", + usage = "/plot visit [|||] [#]", aliases = {"v", "tp", "teleport", "goto", "home", "h"}, requiredType = RequiredType.NONE, category = CommandCategory.TELEPORT) -public class Visit extends SubCommand { +public class Visit extends Command { + + public Visit() { + super(MainCommand.getInstance(), true); + } @Override - public boolean onCommand(PlotPlayer player, String[] args) { + public Collection tab(PlotPlayer player, String[] args, boolean space) { + return tabOf(player, args, space, getUsage()); + } + + @Override + public void execute(final PlotPlayer player, String[] args, RunnableVal3 confirm, final RunnableVal2 whenDone) throws CommandException { if (args.length == 1 && args[0].contains(":")) { args = args[0].split(":"); } @@ -36,9 +48,9 @@ public class Visit extends SubCommand { switch (args.length) { case 2: if (!MathMan.isInteger(args[1])) { - sendMessage(player, C.NOT_VALID_NUMBER, "(1, ∞)"); - sendMessage(player, C.COMMAND_SYNTAX, "/plot visit " + args[0] + " [#]"); - return false; + C.NOT_VALID_NUMBER.send(player, "(1, ∞)"); + C.COMMAND_SYNTAX.send(player, getUsage());; + return; } page = Integer.parseInt(args[1]); case 1: @@ -68,8 +80,8 @@ public class Visit extends SubCommand { page = 1; } if (unsorted == null || unsorted.isEmpty()) { - sendMessage(player, C.FOUND_NO_PLOTS); - return false; + C.FOUND_NO_PLOTS.send(player); + return; } Iterator iterator = unsorted.iterator(); while (iterator.hasNext()) { @@ -78,34 +90,47 @@ public class Visit extends SubCommand { } } if (page < 1 || page > unsorted.size()) { - sendMessage(player, C.NOT_VALID_NUMBER, "(1, " + unsorted.size() + ')'); - return false; + C.NOT_VALID_NUMBER.send(player, "(1, " + unsorted.size() + ")"); + return; } List plots = PS.get().sortPlotsByTemp(unsorted); - Plot plot = plots.get(page - 1); + final Plot plot = plots.get(page - 1); if (!plot.hasOwner()) { if (!Permissions.hasPermission(player, "plots.visit.unowned")) { - sendMessage(player, C.NO_PERMISSION, "plots.visit.unowned"); - return false; + C.NO_PERMISSION.send(player, "plots.visit.unowned"); + return; } } else if (plot.isOwner(player.getUUID())) { if (!Permissions.hasPermission(player, "plots.visit.owned") && !Permissions.hasPermission(player, "plots.home")) { - sendMessage(player, C.NO_PERMISSION, "plots.visit.owned, plots.home"); - return false; + C.NO_PERMISSION.send(player, "plots.visit.owned, plots.home"); + return; } } else if (plot.isAdded(player.getUUID())) { if (!Permissions.hasPermission(player, "plots.visit.shared")) { - sendMessage(player, C.NO_PERMISSION, "plots.visit.shared"); - return false; + C.NO_PERMISSION.send(player, "plots.visit.shared"); + return; } } else { if (!Permissions.hasPermission(player, "plots.visit.other")) { - sendMessage(player, C.NO_PERMISSION, "plots.visit.other"); - return false; + C.NO_PERMISSION.send(player, "plots.visit.other"); + return; } } - plot.teleportPlayer(player); - return true; + confirm.run(this, new Runnable() { + @Override + public void run() { + if (plot.teleportPlayer(player)) { + whenDone.run(Visit.this, CommandResult.SUCCESS); + } else { + whenDone.run(Visit.this, CommandResult.SUCCESS); + } + } + }, new Runnable() { + @Override + public void run() { + whenDone.run(Visit.this, CommandResult.FAILURE); + } + }); } } diff --git a/Core/src/main/java/com/intellectualcrafters/plot/config/C.java b/Core/src/main/java/com/intellectualcrafters/plot/config/C.java index 9116f88b7..978950114 100644 --- a/Core/src/main/java/com/intellectualcrafters/plot/config/C.java +++ b/Core/src/main/java/com/intellectualcrafters/plot/config/C.java @@ -365,6 +365,10 @@ public enum C { INVALID_PLAYER_WAIT("$2Player not found: $1%s$2, fetching it. Try again soon.", "Errors"), INVALID_PLAYER("$2Player not found: $1%s$2.", "Errors"), INVALID_PLAYER_OFFLINE("$2The player must be online: $1%s.", "Errors"), + /* + * Unknown Error + */ + ERROR("$2An error occured: %s", "Errors"), // SETTINGS_PASTE_UPLOADED("$2settings.yml was uploaded to: $1%url%", "Paste"), // LATEST_LOG_UPLOADED("$2latest.log was uploaded to: $1%url%", "Paste"), DEBUG_REPORT_CREATED("$1Uploaded a full debug to: $1%url%", "Paste"), diff --git a/Core/src/main/java/com/plotsquared/general/commands/Command.java b/Core/src/main/java/com/plotsquared/general/commands/Command.java index 3f750287f..731f4102b 100644 --- a/Core/src/main/java/com/plotsquared/general/commands/Command.java +++ b/Core/src/main/java/com/plotsquared/general/commands/Command.java @@ -484,6 +484,23 @@ public abstract class Command { return getCommandString() + " " + args + "]"; } + public Collection tabOf(PlotPlayer player, String[] input, boolean space, String... args) { + /* + + + + + <#> + */ +// int index = input.length - (space ? 0 : 1); +// List result = new ArrayList<>(); +// for (String arg : args) { +// String[] split = arg.split(" "); +// } + // TODO + return new ArrayList<>(); + } + public Collection tab(PlotPlayer player, String[] args, boolean space) { switch (args.length) { case 0: diff --git a/Core/src/main/java/com/plotsquared/listener/PlotListener.java b/Core/src/main/java/com/plotsquared/listener/PlotListener.java index 65778c9c1..5889d8a8d 100644 --- a/Core/src/main/java/com/plotsquared/listener/PlotListener.java +++ b/Core/src/main/java/com/plotsquared/listener/PlotListener.java @@ -75,11 +75,11 @@ public class PlotListener { Optional flyFlag = plot.getFlag(Flags.FLY); if (flyFlag.isPresent()) { boolean flight = player.getFlight(); + PlotGameMode gamemode = player.getGameMode(); + if (flight != (gamemode == PlotGameMode.CREATIVE || gamemode == PlotGameMode.SPECTATOR)) { + player.setPersistentMeta("flight", ByteArrayUtilities.booleanToBytes(player.getFlight())); + } if (flyFlag.get() != player.getFlight()) { - PlotGameMode gamemode = player.getGameMode(); - if (flight != (gamemode == PlotGameMode.CREATIVE || gamemode == PlotGameMode.SPECTATOR)) { - player.setPersistentMeta("flight", ByteArrayUtilities.booleanToBytes(player.getFlight())); - } player.setFlight(flyFlag.get()); } } @@ -209,6 +209,8 @@ public class PlotListener { PlotGameMode gameMode = player.getGameMode(); if (gameMode == PlotGameMode.SURVIVAL || gameMode == PlotGameMode.ADVENTURE) { player.setFlight(false); + } else if (player.getFlight() != true) { + player.setFlight(true); } } } diff --git a/gradle/wrapper/gradle-wrapper.properties b/gradle/wrapper/gradle-wrapper.properties index fe8ac27af..44a4bea14 100644 --- a/gradle/wrapper/gradle-wrapper.properties +++ b/gradle/wrapper/gradle-wrapper.properties @@ -1,6 +1,6 @@ -#Wed Jun 22 12:28:48 EDT 2016 +#Tue Jun 28 19:14:40 AEST 2016 distributionBase=GRADLE_USER_HOME distributionPath=wrapper/dists zipStoreBase=GRADLE_USER_HOME zipStorePath=wrapper/dists -distributionUrl=https\://services.gradle.org/distributions/gradle-2.14-bin.zip +distributionUrl=https\://services.gradle.org/distributions/gradle-2.14-all.zip diff --git a/pom.xml b/pom.xml index fe2da4f4a..a043d4ad1 100644 --- a/pom.xml +++ b/pom.xml @@ -73,12 +73,16 @@ vault-repo http://nexus.theyeticave.net/content/repositories/pub_releases + + empcraft-repo + http://empcraft.com/maven2 + org.bukkit - bukkit - 1.10-R0.1-SNAPSHOT + Spigot + 1.10 com.sk89q