diff --git a/Bukkit/src/main/java/com/plotsquared/bukkit/BukkitMain.java b/Bukkit/src/main/java/com/plotsquared/bukkit/BukkitMain.java index c42c1bba7..c5ad9cd46 100644 --- a/Bukkit/src/main/java/com/plotsquared/bukkit/BukkitMain.java +++ b/Bukkit/src/main/java/com/plotsquared/bukkit/BukkitMain.java @@ -33,7 +33,6 @@ import com.intellectualcrafters.plot.util.UUIDHandler; import com.intellectualcrafters.plot.util.UUIDHandlerImplementation; import com.intellectualcrafters.plot.util.WorldUtil; import com.intellectualcrafters.plot.uuid.UUIDWrapper; -import com.plotsquared.bukkit.commands.DebugUUID; import com.plotsquared.bukkit.database.plotme.ClassicPlotMeConnector; import com.plotsquared.bukkit.database.plotme.LikePlotMeConverter; import com.plotsquared.bukkit.database.plotme.PlotMeConnector_017; @@ -73,12 +72,6 @@ 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.Location; @@ -93,6 +86,13 @@ 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; @@ -171,7 +171,6 @@ public class BukkitMain extends JavaPlugin implements Listener, IPlotMain { plotCommand.setExecutor(bcmd); plotCommand.setAliases(Arrays.asList("p", "ps", "plotme", "plot")); plotCommand.setTabCompleter(bcmd); - new DebugUUID(); } @Override diff --git a/Bukkit/src/main/java/com/plotsquared/bukkit/util/Metrics.java b/Bukkit/src/main/java/com/plotsquared/bukkit/util/Metrics.java index 334127b15..d9d304404 100644 --- a/Bukkit/src/main/java/com/plotsquared/bukkit/util/Metrics.java +++ b/Bukkit/src/main/java/com/plotsquared/bukkit/util/Metrics.java @@ -53,7 +53,7 @@ public class Metrics { /** * The current revision number */ - private final static int REVISION = 7; + private static final int REVISION = 7; /** * The base url of the metrics domain */ diff --git a/Core/src/main/java/com/intellectualcrafters/plot/commands/Add.java b/Core/src/main/java/com/intellectualcrafters/plot/commands/Add.java index fd7e2baef..6bc8ef25a 100644 --- a/Core/src/main/java/com/intellectualcrafters/plot/commands/Add.java +++ b/Core/src/main/java/com/intellectualcrafters/plot/commands/Add.java @@ -41,7 +41,7 @@ import java.util.UUID; usage = "/plot add ", category = CommandCategory.SETTINGS, permission = "plots.add", - requiredType = RequiredType.NONE) + requiredType = RequiredType.PLAYER) public class Add extends SubCommand { public Add() { diff --git a/Core/src/main/java/com/intellectualcrafters/plot/commands/Area.java b/Core/src/main/java/com/intellectualcrafters/plot/commands/Area.java index ef5a783fc..f5267a008 100644 --- a/Core/src/main/java/com/intellectualcrafters/plot/commands/Area.java +++ b/Core/src/main/java/com/intellectualcrafters/plot/commands/Area.java @@ -39,7 +39,7 @@ import java.util.Set; description = "Create a new PlotArea", aliases = "world", usage = "/plot area ", - confirmation=true) + confirmation = true) public class Area extends SubCommand { @Override diff --git a/Core/src/main/java/com/intellectualcrafters/plot/commands/Deny.java b/Core/src/main/java/com/intellectualcrafters/plot/commands/Deny.java index 1fa1426cc..7021332c2 100644 --- a/Core/src/main/java/com/intellectualcrafters/plot/commands/Deny.java +++ b/Core/src/main/java/com/intellectualcrafters/plot/commands/Deny.java @@ -41,7 +41,7 @@ import java.util.UUID; description = "Deny a user from a plot", usage = "/plot deny ", category = CommandCategory.SETTINGS, - requiredType = RequiredType.NONE) + requiredType = RequiredType.PLAYER) public class Deny extends SubCommand { public Deny() { diff --git a/Core/src/main/java/com/intellectualcrafters/plot/commands/Kick.java b/Core/src/main/java/com/intellectualcrafters/plot/commands/Kick.java index 5636d9111..bfb9f91d0 100644 --- a/Core/src/main/java/com/intellectualcrafters/plot/commands/Kick.java +++ b/Core/src/main/java/com/intellectualcrafters/plot/commands/Kick.java @@ -28,6 +28,7 @@ import com.intellectualcrafters.plot.util.MainUtil; import com.intellectualcrafters.plot.util.Permissions; import com.intellectualcrafters.plot.util.UUIDHandler; import com.intellectualcrafters.plot.util.WorldUtil; +import com.plotsquared.general.commands.Argument; import com.plotsquared.general.commands.CommandDeclaration; @CommandDeclaration(command = "kick", @@ -35,9 +36,13 @@ import com.plotsquared.general.commands.CommandDeclaration; description = "Kick a player from your plot", permission = "plots.kick", category = CommandCategory.TELEPORT, - requiredType = RequiredType.NONE) + requiredType = RequiredType.PLAYER) public class Kick extends SubCommand { + public Kick() { + super(Argument.PlayerName); + } + @Override public boolean onCommand(PlotPlayer plr, String[] args) { Location loc = plr.getLocation(); diff --git a/Core/src/main/java/com/intellectualcrafters/plot/commands/Merge.java b/Core/src/main/java/com/intellectualcrafters/plot/commands/Merge.java index 7a3dd3ef0..c579ebdd8 100644 --- a/Core/src/main/java/com/intellectualcrafters/plot/commands/Merge.java +++ b/Core/src/main/java/com/intellectualcrafters/plot/commands/Merge.java @@ -46,8 +46,8 @@ import java.util.UUID; confirmation=true) public class Merge extends SubCommand { - public final static String[] values = new String[]{"north", "east", "south", "west", "auto"}; - public final static String[] aliases = new String[]{"n", "e", "s", "w", "all"}; + public static final String[] values = new String[]{"north", "east", "south", "west", "auto"}; + public static final String[] aliases = new String[]{"n", "e", "s", "w", "all"}; public static String direction(float yaw) { yaw = yaw / 90; diff --git a/Core/src/main/java/com/intellectualcrafters/plot/commands/Remove.java b/Core/src/main/java/com/intellectualcrafters/plot/commands/Remove.java index dfb39a87c..d9706d90a 100644 --- a/Core/src/main/java/com/intellectualcrafters/plot/commands/Remove.java +++ b/Core/src/main/java/com/intellectualcrafters/plot/commands/Remove.java @@ -40,7 +40,7 @@ import java.util.UUID; description = "Remove a player from a plot", usage = "/plot remove ", category = CommandCategory.SETTINGS, - requiredType = RequiredType.NONE, + requiredType = RequiredType.PLAYER, permission = "plots.remove") public class Remove extends SubCommand { diff --git a/Core/src/main/java/com/intellectualcrafters/plot/commands/Set.java b/Core/src/main/java/com/intellectualcrafters/plot/commands/Set.java index ce7611968..0bb43c328 100644 --- a/Core/src/main/java/com/intellectualcrafters/plot/commands/Set.java +++ b/Core/src/main/java/com/intellectualcrafters/plot/commands/Set.java @@ -52,8 +52,8 @@ import java.util.HashSet; requiredType = RequiredType.NONE) public class Set extends SubCommand { - public final static String[] values = new String[]{"biome", "alias", "home", "flag"}; - public final static String[] aliases = new String[]{"b", "w", "wf", "f", "a", "h", "fl"}; + public static final String[] values = new String[]{"biome", "alias", "home", "flag"}; + public static final String[] aliases = new String[]{"b", "w", "wf", "f", "a", "h", "fl"}; private final SetCommand component; diff --git a/Core/src/main/java/com/intellectualcrafters/plot/commands/Trust.java b/Core/src/main/java/com/intellectualcrafters/plot/commands/Trust.java index f16ff0223..4df59fce9 100644 --- a/Core/src/main/java/com/intellectualcrafters/plot/commands/Trust.java +++ b/Core/src/main/java/com/intellectualcrafters/plot/commands/Trust.java @@ -37,7 +37,7 @@ import java.util.UUID; @CommandDeclaration( command = "trust", aliases = {"t"}, - requiredType = RequiredType.NONE, + requiredType = RequiredType.PLAYER, usage = "/plot trust ", description = "Allow a player to build in a plot", category = CommandCategory.SETTINGS) diff --git a/Core/src/main/java/com/intellectualcrafters/plot/flag/FlagManager.java b/Core/src/main/java/com/intellectualcrafters/plot/flag/FlagManager.java index 04ea0ae59..52a09e453 100644 --- a/Core/src/main/java/com/intellectualcrafters/plot/flag/FlagManager.java +++ b/Core/src/main/java/com/intellectualcrafters/plot/flag/FlagManager.java @@ -46,9 +46,9 @@ import java.util.Set; */ public class FlagManager { - private final static HashSet reserved = new HashSet<>(); + private static final HashSet reserved = new HashSet<>(); - private final static HashSet flags = new HashSet<>(); + private static final HashSet flags = new HashSet<>(); /** * Reserve a flag so that it cannot be set by players diff --git a/Core/src/main/java/com/intellectualcrafters/plot/object/BlockLoc.java b/Core/src/main/java/com/intellectualcrafters/plot/object/BlockLoc.java index acecd07be..e3e310609 100644 --- a/Core/src/main/java/com/intellectualcrafters/plot/object/BlockLoc.java +++ b/Core/src/main/java/com/intellectualcrafters/plot/object/BlockLoc.java @@ -25,7 +25,8 @@ public class BlockLoc { public static BlockLoc fromString(String string) { String[] parts = string.split(","); - float yaw, pitch; + float yaw; + float pitch; if (parts.length == 3) { yaw = 0f; pitch = 0f; diff --git a/Core/src/main/java/com/intellectualcrafters/plot/object/PlotBlock.java b/Core/src/main/java/com/intellectualcrafters/plot/object/PlotBlock.java index ee7128fe8..d58315ab2 100644 --- a/Core/src/main/java/com/intellectualcrafters/plot/object/PlotBlock.java +++ b/Core/src/main/java/com/intellectualcrafters/plot/object/PlotBlock.java @@ -20,23 +20,20 @@ //////////////////////////////////////////////////////////////////////////////////////////////////// package com.intellectualcrafters.plot.object; -/** - - */ public class PlotBlock { - public final static PlotBlock EVERYTHING = new PlotBlock((short) 0, (byte) 0); - + public static final PlotBlock EVERYTHING = new PlotBlock((short) 0, (byte) 0); + public final short id; public final byte data; - - public PlotBlock(final short id, final byte data) { + + public PlotBlock(short id, byte data) { this.id = id; this.data = data; } - + @Override - public boolean equals(final Object obj) { + public boolean equals(Object obj) { if (this == obj) { return true; } @@ -46,20 +43,20 @@ public class PlotBlock { if (getClass() != obj.getClass()) { return false; } - final PlotBlock other = (PlotBlock) obj; - return ((id == other.id) && ((data == other.data) || (data == -1) || (other.data == -1))); + PlotBlock other = (PlotBlock) obj; + return (this.id == other.id) && ((this.data == other.data) || (this.data == -1) || (other.data == -1)); } - + @Override public int hashCode() { - return id; + return this.id; } - + @Override public String toString() { - if (data == -1) { - return id + ""; + if (this.data == -1) { + return this.id + ""; } - return id + ":" + data; + return this.id + ":" + this.data; } } diff --git a/Core/src/main/java/com/intellectualcrafters/plot/util/BO3Handler.java b/Core/src/main/java/com/intellectualcrafters/plot/util/BO3Handler.java index a9e822608..14c8318f6 100644 --- a/Core/src/main/java/com/intellectualcrafters/plot/util/BO3Handler.java +++ b/Core/src/main/java/com/intellectualcrafters/plot/util/BO3Handler.java @@ -62,19 +62,19 @@ public class BO3Handler { } /** - * Save a plot as a BO3 file
+ * Save a plot as a BO3 file. * - Use null for the player object if no player is applicable - * @param plr + * @param player * @param plot * @return */ - public static boolean saveBO3(PlotPlayer plr, Plot plot, RunnableVal saveTask) { + public static boolean saveBO3(PlotPlayer player, Plot plot, RunnableVal saveTask) { if (saveTask == null) { throw new IllegalArgumentException("Save task cannot be null!"); } PlotArea plotworld = plot.getArea(); if (!(plotworld instanceof ClassicPlotWorld) || plotworld.TYPE != 0) { - MainUtil.sendMessage(plr, "BO3 exporting only supports type 0 classic generation."); + MainUtil.sendMessage(player, "BO3 exporting only supports type 0 classic generation."); return false; } String alias = plot.toString(); @@ -150,7 +150,7 @@ public class BO3Handler { } if (!content) { - MainUtil.sendMessage(plr, "No content found!"); + MainUtil.sendMessage(player, "No content found!"); return false; } @@ -177,7 +177,7 @@ public class BO3Handler { } } if (parentLoc == null) { - MainUtil.sendMessage(plr, + MainUtil.sendMessage(player, "Exporting BO3 cancelled due to detached chunk: " + chunk + " - Make sure you only have one object per plot"); return false; } @@ -189,7 +189,7 @@ public class BO3Handler { saveTask.run(entry.getValue()); } - MainUtil.sendMessage(plr, "BO3 exporting was successful!"); + MainUtil.sendMessage(player, "BO3 exporting was successful!"); return true; } 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 e5f7d6a5b..dcb3e904c 100644 --- a/Core/src/main/java/com/plotsquared/general/commands/Command.java +++ b/Core/src/main/java/com/plotsquared/general/commands/Command.java @@ -473,7 +473,11 @@ public abstract class Command { String arg = args[0].toLowerCase(); if (space) { Command cmd = getCommand(arg); - return (cmd != null && cmd.canExecute(player, false)) ? cmd.tab(player, Arrays.copyOfRange(args, 1, args.length), space) : null; + if (cmd != null && cmd.canExecute(player, false)) { + return cmd.tab(player, Arrays.copyOfRange(args, 1, args.length), space); + } else { + return null; + } } else { Set commands = new HashSet(); for (Map.Entry entry : this.staticCommands.entrySet()) { @@ -485,7 +489,11 @@ public abstract class Command { } default: Command cmd = getCommand(args[0]); - return cmd != null ? cmd.tab(player, Arrays.copyOfRange(args, 1, args.length), space) : null; + if (cmd != null) { + return cmd.tab(player, Arrays.copyOfRange(args, 1, args.length), space); + } else { + return null; + } } } diff --git a/Sponge/src/main/java/com/plotsquared/sponge/object/SpongePlayer.java b/Sponge/src/main/java/com/plotsquared/sponge/object/SpongePlayer.java index c9f856686..ed7b7846d 100644 --- a/Sponge/src/main/java/com/plotsquared/sponge/object/SpongePlayer.java +++ b/Sponge/src/main/java/com/plotsquared/sponge/object/SpongePlayer.java @@ -130,17 +130,13 @@ public class SpongePlayer extends PlotPlayer { GameMode gamemode = this.player.getGameModeData().type().get(); if (gamemode == GameModes.ADVENTURE) { return PlotGameMode.ADVENTURE; - } - if (gamemode == GameModes.CREATIVE) { + } else if (gamemode == GameModes.CREATIVE) { return PlotGameMode.CREATIVE; - } - if (gamemode == GameModes.SPECTATOR) { + } else if (gamemode == GameModes.SPECTATOR) { return PlotGameMode.SPECTATOR; - } - if (gamemode == GameModes.SURVIVAL) { + } else if (gamemode == GameModes.SURVIVAL) { return PlotGameMode.SURVIVAL; - } - if (gamemode == GameModes.NOT_SET) { + } else { return PlotGameMode.NOT_SET; } } diff --git a/Sponge/src/main/java/com/plotsquared/sponge/util/SpongeChunkManager.java b/Sponge/src/main/java/com/plotsquared/sponge/util/SpongeChunkManager.java index 29a6d7e94..e874dd0fb 100644 --- a/Sponge/src/main/java/com/plotsquared/sponge/util/SpongeChunkManager.java +++ b/Sponge/src/main/java/com/plotsquared/sponge/util/SpongeChunkManager.java @@ -5,10 +5,7 @@ import com.intellectualcrafters.plot.object.ChunkLoc; import com.intellectualcrafters.plot.object.Location; import com.intellectualcrafters.plot.object.Plot; import com.intellectualcrafters.plot.util.ChunkManager; -import com.intellectualcrafters.plot.util.ReflectionUtils; -import com.intellectualcrafters.plot.util.SetQueue; import com.intellectualcrafters.plot.util.TaskManager; -import net.minecraft.world.ChunkCoordIntPair; import net.minecraft.world.chunk.IChunkProvider; import net.minecraft.world.gen.ChunkProviderServer; import org.spongepowered.api.entity.Entity; @@ -18,8 +15,6 @@ import org.spongepowered.api.entity.living.monster.Monster; import org.spongepowered.api.world.Chunk; import org.spongepowered.api.world.World; -import java.lang.reflect.Field; -import java.util.Arrays; import java.util.Optional; import java.util.Set; import java.util.function.Predicate; @@ -27,20 +22,20 @@ import java.util.function.Predicate; public class SpongeChunkManager extends ChunkManager { @Override - public int[] countEntities(final Plot plot) { - final Location pos1 = plot.getBottomAbs(); - final Location pos2 = plot.getTopAbs(); - final World world = SpongeUtil.getWorld(pos1.getWorld()); - final int bx = pos1.getX(); - final int bz = pos1.getZ(); - final int tx = pos2.getX(); - final int tz = pos2.getZ(); - final int[] count = new int[6]; + public int[] countEntities(Plot plot) { + Location pos1 = plot.getBottomAbs(); + Location pos2 = plot.getTopAbs(); + World world = SpongeUtil.getWorld(pos1.getWorld()); + int bx = pos1.getX(); + int bz = pos1.getZ(); + int tx = pos2.getX(); + int tz = pos2.getZ(); + int[] count = new int[6]; world.getEntities(entity -> { - final org.spongepowered.api.world.Location loc = entity.getLocation(); - final int x = loc.getBlockX(); + org.spongepowered.api.world.Location loc = entity.getLocation(); + int x = loc.getBlockX(); if ((x >= bx) && (x <= tx)) { - final int z = loc.getBlockZ(); + int z = loc.getBlockZ(); if ((z >= bz) && (z <= tz)) { count[0]++; if (entity instanceof Living) { @@ -62,22 +57,22 @@ public class SpongeChunkManager extends ChunkManager { } @Override - public boolean loadChunk(final String world, final ChunkLoc loc, final boolean force) { - final World worldObj = SpongeUtil.getWorld(world); + public boolean loadChunk(String world, ChunkLoc loc, boolean force) { + World worldObj = SpongeUtil.getWorld(world); return worldObj.loadChunk(loc.x << 4, 0, loc.z << 4, force).isPresent(); } @Override - public Set getChunkChunks(final String world) { + public Set getChunkChunks(String world) { // TODO save world; return super.getChunkChunks(world); } @Override - public void regenerateChunk(final String world, final ChunkLoc loc) { - final World spongeWorld = SpongeUtil.getWorld(world); - final net.minecraft.world.World nmsWorld = (net.minecraft.world.World) spongeWorld; - final Optional chunkOpt = spongeWorld.getChunk(loc.x, 0, loc.z); + public void regenerateChunk(String world, ChunkLoc loc) { + World spongeWorld = SpongeUtil.getWorld(world); + net.minecraft.world.World nmsWorld = (net.minecraft.world.World) spongeWorld; + Optional chunkOpt = spongeWorld.getChunk(loc.x, 0, loc.z); if (chunkOpt.isPresent()) { try { Chunk spongeChunk = chunkOpt.get(); @@ -86,7 +81,7 @@ public class SpongeChunkManager extends ChunkManager { PS.debug("Not valid world generator for: " + world); return; } - ChunkProviderServer chunkServer = (ChunkProviderServer) provider; +/* ChunkProviderServer chunkServer = (ChunkProviderServer) provider; IChunkProvider chunkProvider = chunkServer.serverChunkGenerator; long pos = ChunkCoordIntPair.chunkXZ2Int(loc.x, loc.z); @@ -103,6 +98,7 @@ public class SpongeChunkManager extends ChunkManager { } Set set = (Set) fieldDroppedChunksSet.get(chunkServer); set.remove(pos); + ReflectionUtils.findField(chunkServer.getClass(),) chunkServer.id2ChunkMap.remove(pos); mcChunk = chunkProvider.provideChunk(loc.x, loc.z); chunkServer.id2ChunkMap.add(pos, mcChunk); @@ -114,7 +110,7 @@ public class SpongeChunkManager extends ChunkManager { } else { PS.debug("CHUNK IS NULL!?"); - } + }*/ } catch (Throwable e){ e.printStackTrace(); } @@ -122,27 +118,27 @@ public class SpongeChunkManager extends ChunkManager { } @Override - public boolean copyRegion(final Location pos1, final Location pos2, final Location newPos, final Runnable whenDone) { + public boolean copyRegion(Location pos1, Location pos2, Location newPos, Runnable whenDone) { // TODO copy a region TaskManager.runTask(whenDone); return false; } @Override - public void clearAllEntities(final Location pos1, final Location pos2) { - final String worldname = pos1.getWorld(); - final World world = SpongeUtil.getWorld(worldname); - final int bx = pos1.getX(); - final int bz = pos1.getZ(); - final int tx = pos2.getX(); - final int tz = pos2.getZ(); + public void clearAllEntities(Location pos1, Location pos2) { + String worldname = pos1.getWorld(); + World world = SpongeUtil.getWorld(worldname); + int bx = pos1.getX(); + int bz = pos1.getZ(); + int tx = pos2.getX(); + int tz = pos2.getZ(); world.getEntities(new Predicate() { @Override - public boolean test(final Entity entity) { - final org.spongepowered.api.world.Location loc = entity.getLocation(); - final int x = loc.getBlockX(); + public boolean test(Entity entity) { + org.spongepowered.api.world.Location loc = entity.getLocation(); + int x = loc.getBlockX(); if ((x >= bx) && (x <= tx)) { - final int z = loc.getBlockZ(); + int z = loc.getBlockZ(); if ((z >= bz) && (z <= tz)) { entity.remove(); } @@ -160,8 +156,8 @@ public class SpongeChunkManager extends ChunkManager { @Override public void unloadChunk(String world, ChunkLoc loc, boolean save, boolean safe) { - final World worldObj = SpongeUtil.getWorld(world); - final Optional chunk = worldObj.getChunk(loc.x << 4, 0, loc.z << 4); + World worldObj = SpongeUtil.getWorld(world); + Optional chunk = worldObj.getChunk(loc.x << 4, 0, loc.z << 4); if (chunk.isPresent()) { worldObj.unloadChunk(chunk.get()); } diff --git a/build.gradle b/build.gradle index 8ac813bc5..8bd7a2b13 100644 --- a/build.gradle +++ b/build.gradle @@ -10,7 +10,7 @@ buildscript { } group = 'com.intellectualcrafters' -version = '3.3.3-SNAPSHOT' +version = '3.3.3' description = """PlotSquared""" subprojects {