mirror of
https://github.com/IntellectualSites/PlotSquared.git
synced 2024-11-22 13:16:45 +01:00
Code cleanup
maybe a bug fix or two
This commit is contained in:
parent
8d4f042abc
commit
76e2b1f416
@ -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
|
||||
|
@ -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
|
||||
*/
|
||||
|
@ -41,7 +41,7 @@ import java.util.UUID;
|
||||
usage = "/plot add <player>",
|
||||
category = CommandCategory.SETTINGS,
|
||||
permission = "plots.add",
|
||||
requiredType = RequiredType.NONE)
|
||||
requiredType = RequiredType.PLAYER)
|
||||
public class Add extends SubCommand {
|
||||
|
||||
public Add() {
|
||||
|
@ -39,7 +39,7 @@ import java.util.Set;
|
||||
description = "Create a new PlotArea",
|
||||
aliases = "world",
|
||||
usage = "/plot area <create|info|list|tp|regen>",
|
||||
confirmation=true)
|
||||
confirmation = true)
|
||||
public class Area extends SubCommand {
|
||||
|
||||
@Override
|
||||
|
@ -41,7 +41,7 @@ import java.util.UUID;
|
||||
description = "Deny a user from a plot",
|
||||
usage = "/plot deny <player>",
|
||||
category = CommandCategory.SETTINGS,
|
||||
requiredType = RequiredType.NONE)
|
||||
requiredType = RequiredType.PLAYER)
|
||||
public class Deny extends SubCommand {
|
||||
|
||||
public Deny() {
|
||||
|
@ -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();
|
||||
|
@ -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;
|
||||
|
@ -40,7 +40,7 @@ import java.util.UUID;
|
||||
description = "Remove a player from a plot",
|
||||
usage = "/plot remove <player>",
|
||||
category = CommandCategory.SETTINGS,
|
||||
requiredType = RequiredType.NONE,
|
||||
requiredType = RequiredType.PLAYER,
|
||||
permission = "plots.remove")
|
||||
public class Remove extends SubCommand {
|
||||
|
||||
|
@ -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;
|
||||
|
||||
|
@ -37,7 +37,7 @@ import java.util.UUID;
|
||||
@CommandDeclaration(
|
||||
command = "trust",
|
||||
aliases = {"t"},
|
||||
requiredType = RequiredType.NONE,
|
||||
requiredType = RequiredType.PLAYER,
|
||||
usage = "/plot trust <player>",
|
||||
description = "Allow a player to build in a plot",
|
||||
category = CommandCategory.SETTINGS)
|
||||
|
@ -46,9 +46,9 @@ import java.util.Set;
|
||||
*/
|
||||
public class FlagManager {
|
||||
|
||||
private final static HashSet<String> reserved = new HashSet<>();
|
||||
private static final HashSet<String> reserved = new HashSet<>();
|
||||
|
||||
private final static HashSet<AbstractFlag> flags = new HashSet<>();
|
||||
private static final HashSet<AbstractFlag> flags = new HashSet<>();
|
||||
|
||||
/**
|
||||
* Reserve a flag so that it cannot be set by players
|
||||
|
@ -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;
|
||||
|
@ -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;
|
||||
}
|
||||
}
|
||||
|
@ -62,19 +62,19 @@ public class BO3Handler {
|
||||
}
|
||||
|
||||
/**
|
||||
* Save a plot as a BO3 file<br>
|
||||
* 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<BO3> saveTask) {
|
||||
public static boolean saveBO3(PlotPlayer player, Plot plot, RunnableVal<BO3> 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;
|
||||
}
|
||||
|
||||
|
@ -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<Command> commands = new HashSet<Command>();
|
||||
for (Map.Entry<String, Command> 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;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -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;
|
||||
}
|
||||
}
|
||||
|
@ -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<ChunkLoc> getChunkChunks(final String world) {
|
||||
public Set<ChunkLoc> 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<Chunk> 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<Chunk> 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<Long> set = (Set<Long>) 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<Entity>() {
|
||||
@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> chunk = worldObj.getChunk(loc.x << 4, 0, loc.z << 4);
|
||||
World worldObj = SpongeUtil.getWorld(world);
|
||||
Optional<Chunk> chunk = worldObj.getChunk(loc.x << 4, 0, loc.z << 4);
|
||||
if (chunk.isPresent()) {
|
||||
worldObj.unloadChunk(chunk.get());
|
||||
}
|
||||
|
@ -10,7 +10,7 @@ buildscript {
|
||||
}
|
||||
|
||||
group = 'com.intellectualcrafters'
|
||||
version = '3.3.3-SNAPSHOT'
|
||||
version = '3.3.3'
|
||||
description = """PlotSquared"""
|
||||
|
||||
subprojects {
|
||||
|
Loading…
Reference in New Issue
Block a user