diff --git a/pom.xml b/pom.xml index 24b9d04..a47928f 100644 --- a/pom.xml +++ b/pom.xml @@ -11,6 +11,8 @@ UTF-8 + 1.7 + 1.7 diff --git a/src/de/craftinc/gates/Gate.java b/src/de/craftinc/gates/Gate.java index 9089306..3c8f1fd 100644 --- a/src/de/craftinc/gates/Gate.java +++ b/src/de/craftinc/gates/Gate.java @@ -29,18 +29,23 @@ import java.util.*; public class Gate implements ConfigurationSerializable { protected Location location; /* saving both location and gateBlockLocations is redundant but makes it easy to allow players to reshape gates */ - protected Set gateBlockLocations = new HashSet(); /* Locations of the blocks inside the gate */ - protected Set gateFrameBlocks = new HashSet(); + private Set gateBlockLocations = new HashSet<>(); /* Locations of the blocks inside the gate */ + + private Set gateFrameBlocks = new HashSet<>(); protected Location exit; - protected boolean isHidden = false; - protected boolean isOpen = false; + private boolean isHidden = false; + private boolean isOpen = false; - protected boolean allowsVehicles = true; + private boolean allowsVehicles = true; protected String id; + public static String getGateBlocksKey() { + return gateBlocksKey; + } + /** * You should never create two gates with the same 'id'. Also see 'setId(String id)'. * @@ -77,12 +82,11 @@ public class Gate implements ConfigurationSerializable { findPortalBlocks(); validate(); } else { - this.gateBlockLocations = new HashSet(); - this.gateFrameBlocks = new HashSet(); + this.gateBlockLocations = new HashSet<>(); + this.gateFrameBlocks = new HashSet<>(); } } - /** * @return This method might return a 'null' value. */ @@ -90,7 +94,6 @@ public class Gate implements ConfigurationSerializable { return exit; } - /** * @param exit Supplying 'null' is permitted. * @throws Exception An exception will be thrown if 'null' data is supplied and this gate is open. Note that the @@ -102,7 +105,6 @@ public class Gate implements ConfigurationSerializable { validate(); } - /** * @return This method will never return 'null'. */ @@ -110,7 +112,6 @@ public class Gate implements ConfigurationSerializable { return id; } - /** * Every gate should have an unique 'id'. You should therefore check if another gate with the same 'id' exists. * Note that this method will not check if another gate with the same 'id' exists! @@ -125,23 +126,19 @@ public class Gate implements ConfigurationSerializable { this.id = id.toLowerCase(); } - public boolean isHidden() { return isHidden; } - public void setHidden(boolean isHidden) throws Exception { this.isHidden = isHidden; this.validate(); } - public boolean isOpen() { return isOpen; } - public void setOpen(boolean isOpen) throws Exception { if (isOpen && !this.isOpen) { findPortalBlocks(); @@ -151,17 +148,14 @@ public class Gate implements ConfigurationSerializable { validate(); } - public void setAllowsVehicles(boolean allowsVehicles) { this.allowsVehicles = allowsVehicles; } - public boolean getAllowsVehicles() { return this.allowsVehicles; } - /** * @return Will never return 'null' but might return an empty Set. */ @@ -169,7 +163,6 @@ public class Gate implements ConfigurationSerializable { return gateBlockLocations; } - /** * @return Will never return 'null' but might return an empty Set. */ @@ -177,9 +170,8 @@ public class Gate implements ConfigurationSerializable { return gateFrameBlocks; } - - protected void findPortalBlocks() { - gateBlockLocations = new HashSet(); + private void findPortalBlocks() { + gateBlockLocations = new HashSet<>(); Set gateBlocks = FloodUtil.getGatePortalBlocks(location.getBlock()); if (gateBlocks != null) { @@ -191,35 +183,34 @@ public class Gate implements ConfigurationSerializable { gateFrameBlocks = FloodUtil.getFrame(gateBlocks); } - /** * Checks if values attributes do add up; will close gate on wrong values. */ - public void validate() throws Exception { + void validate() throws Exception { if (!isOpen) { return; } if (location == null) { isOpen = false; - this.gateBlockLocations = new HashSet(); - this.gateFrameBlocks = new HashSet(); + this.gateBlockLocations = new HashSet<>(); + this.gateFrameBlocks = new HashSet<>(); throw new Exception("Gate got closed. It has no location."); } if (exit == null) { isOpen = false; - this.gateBlockLocations = new HashSet(); - this.gateFrameBlocks = new HashSet(); + this.gateBlockLocations = new HashSet<>(); + this.gateFrameBlocks = new HashSet<>(); throw new Exception("Gate got closed. It has no exit."); } if (gateBlockLocations.size() == 0) { isOpen = false; - this.gateBlockLocations = new HashSet(); - this.gateFrameBlocks = new HashSet(); + this.gateBlockLocations = new HashSet<>(); + this.gateFrameBlocks = new HashSet<>(); throw new Exception("Gate got closed. The frame is missing or broken. (no gate blocks)"); } @@ -230,8 +221,8 @@ public class Gate implements ConfigurationSerializable { if (b.getType() == Material.AIR) { isOpen = false; - this.gateBlockLocations = new HashSet(); - this.gateFrameBlocks = new HashSet(); + this.gateBlockLocations = new HashSet<>(); + this.gateFrameBlocks = new HashSet<>(); throw new Exception("Gate got closed. The frame is missing or broken. (missing frame block(s))"); } @@ -243,17 +234,17 @@ public class Gate implements ConfigurationSerializable { /* * INTERFACE: ConfigurationSerializable */ - static protected String idKey = "id"; - static protected String locationKey = "location"; - static protected String gateBlocksKey = "gateBlocks"; - static protected String exitKey = "exit"; - static protected String isHiddenKey = "hidden"; - static protected String isOpenKey = "open"; - static protected String locationYawKey = "locationYaw"; - static protected String locationPitchKey = "locationPitch"; - static protected String exitYawKey = "exitYaw"; - static protected String exitPitchKey = "exitPitch"; - static protected String allowsVehiclesKey = "allowsVehiclesKey"; + static private String idKey = "id"; + static private String locationKey = "location"; + static private String gateBlocksKey = "gateBlocks"; + static private String exitKey = "exit"; + static private String isHiddenKey = "hidden"; + static private String isOpenKey = "open"; + static private String locationYawKey = "locationYaw"; + static private String locationPitchKey = "locationPitch"; + static private String exitYawKey = "exitYaw"; + static private String exitPitchKey = "exitPitch"; + static private String allowsVehiclesKey = "allowsVehiclesKey"; @SuppressWarnings("unchecked") @@ -281,7 +272,7 @@ public class Gate implements ConfigurationSerializable { allowsVehicles = (Boolean) map.get(allowsVehiclesKey); } - gateBlockLocations = new HashSet(); + gateBlockLocations = new HashSet<>(); List> serializedGateBlocks = (List>) map.get(gateBlocksKey); for (Map sgb : serializedGateBlocks) { @@ -305,7 +296,7 @@ public class Gate implements ConfigurationSerializable { public Map serialize() { - Map retVal = new HashMap(); + Map retVal = new HashMap<>(); retVal.put(idKey, id); retVal.put(locationKey, LocationUtil.serializeLocation(location)); @@ -324,7 +315,7 @@ public class Gate implements ConfigurationSerializable { retVal.put(locationYawKey, location.getYaw()); } - List> serializedGateBlocks = new ArrayList>(); + List> serializedGateBlocks = new ArrayList<>(); for (Location l : gateBlockLocations) { serializedGateBlocks.add(LocationUtil.serializeLocation(l)); diff --git a/src/de/craftinc/gates/GateChangeListener.java b/src/de/craftinc/gates/GateChangeListener.java index fb41bca..7e0eae9 100644 --- a/src/de/craftinc/gates/GateChangeListener.java +++ b/src/de/craftinc/gates/GateChangeListener.java @@ -20,11 +20,11 @@ package de.craftinc.gates; import java.util.Map; public interface GateChangeListener { - public static final String newGate = "GateChangeListener-newGate"; // value will be null - public static final String removedGate = "GateChangeListener-removedGate"; // value will be null - public static final String changedID = "GateChangeListener-changedID"; // value will be the old ID - public static final String changedLocation = "GateChangeListener-changedLocation"; // value will the old location - public static final String changedExit = "GateChangeListener-changedExit"; // value will be the old exit + String newGate = "GateChangeListener-newGate"; // value will be null + String removedGate = "GateChangeListener-removedGate"; // value will be null + String changedID = "GateChangeListener-changedID"; // value will be the old ID + String changedLocation = "GateChangeListener-changedLocation"; // value will the old location + String changedExit = "GateChangeListener-changedExit"; // value will be the old exit - public void gateChangedHandler(final Gate g, final Map changeSet); + void gateChangedHandler(final Gate g, final Map changeSet); } diff --git a/src/de/craftinc/gates/GatesManager.java b/src/de/craftinc/gates/GatesManager.java index bcc7fbb..365a2f4 100644 --- a/src/de/craftinc/gates/GatesManager.java +++ b/src/de/craftinc/gates/GatesManager.java @@ -36,47 +36,30 @@ import de.craftinc.gates.util.SimpleLocation; public class GatesManager { - protected File gatesConfigFile; - protected FileConfiguration gatesConfig; - protected static final String gatesPath = "gates"; // path to gates inside the yaml file - protected static final String storageVersionPath = "version"; - protected static final int storageVersion = 2; - - protected int chunkRadius; - - protected Map gatesById; - protected Map> gatesByChunk; - protected Map gatesByLocation; - protected Map gatesByFrameLocation; - protected List gates; - protected boolean storageFileIsInvalid = false; - - protected Set changeListeners = new HashSet(); - - - public void addGateChangeListener(GateChangeListener listener) { - this.changeListeners.add(listener); - } - - - public void removeGateChangeListener(GateChangeListener listener) { - this.changeListeners.remove(listener); - } + private static final String gatesPath = "gates"; // path to gates inside the yaml file + private static final String storageVersionPath = "version"; + private static final int storageVersion = 2; + private File gatesConfigFile; + private FileConfiguration gatesConfig; + private int chunkRadius; + private Map gatesById; + private Map> gatesByChunk; + private Map gatesByLocation; + private Map gatesByFrameLocation; + private boolean storageFileIsInvalid = false; public Gate getGateWithId(final String id) { return gatesById.get(id.toLowerCase()); } - public Set getNearbyGates(final Chunk chunk) { SimpleChunk simpleChunk = new SimpleChunk(chunk); return gatesByChunk.get(simpleChunk); } - /** * Returns the closest gate. * @@ -138,7 +121,7 @@ public class GatesManager { @SuppressWarnings("unchecked") - public boolean loadGatesFromDisk() { + boolean loadGatesFromDisk() { this.gatesConfigFile = new File(Plugin.getPlugin().getDataFolder(), "gates.yml"); if (!this.gatesConfigFile.exists()) { @@ -168,7 +151,7 @@ public class GatesManager { this.gates = (List) gatesConfig.getList(gatesPath); if (this.gates == null) { - this.gates = new ArrayList(); + this.gates = new ArrayList<>(); } for (Object o : this.gates) { @@ -220,8 +203,7 @@ public class GatesManager { return true; } - - protected int getChunkRadius() { + private int getChunkRadius() { if (this.chunkRadius == 0) { this.chunkRadius = Plugin.getPlugin().getConfig().getInt(ConfigurationUtil.confPlayerGateBlockUpdateRadiusKey); this.chunkRadius = this.chunkRadius >> 4; @@ -230,97 +212,80 @@ public class GatesManager { return this.chunkRadius; } - - protected void fillGatesById() { - gatesById = new HashMap((int) (gates.size() * 1.25)); + private void fillGatesById() { + gatesById = new HashMap<>((int) (gates.size() * 1.25)); for (Gate g : gates) { this.addGateWithId(g); } } - - protected void fillGatesByChunk() { - HashSet chunksUsedByGates = new HashSet(); + private void fillGatesByChunk() { + HashSet chunksUsedByGates = new HashSet<>(); for (Gate g : gates) { - if (g.getLocation() != null) { - Chunk c = g.getLocation().getChunk(); int x = c.getX(); int z = c.getZ(); for (int i = x - getChunkRadius(); i < x + getChunkRadius(); i++) { - for (int j = z - getChunkRadius(); j < z + getChunkRadius(); j++) { - chunksUsedByGates.add(new SimpleChunk(i, j, c.getWorld())); } } } } - gatesByChunk = new HashMap>((int) (chunksUsedByGates.size() * 1.25)); + gatesByChunk = new HashMap<>((int) (chunksUsedByGates.size() * 1.25)); for (Gate g : gates) { this.addGateByChunk(g); } } - - protected void fillGatesByLocation() { - Set gateBlocks = new HashSet(); + private void fillGatesByLocation() { + Set gateBlocks = new HashSet<>(); for (Gate g : gates) { - for (Location l : g.getGateBlockLocations()) { gateBlocks.add(l); - - Location headLocation = new Location(l.getWorld(), - l.getX(), - l.getY() + 1, - l.getZ()); - + Location headLocation = l.clone().add(0, 1, 0); gateBlocks.add(headLocation); } } - gatesByLocation = new HashMap((int) (gateBlocks.size() * 1.25)); + gatesByLocation = new HashMap<>((int) (gateBlocks.size() * 1.25)); for (Gate g : gates) { this.addGateByLocations(g); } } - - protected void fillGatesByFrameLocation() { + private void fillGatesByFrameLocation() { int numFrameBlocks = 0; for (Gate g : gates) { - numFrameBlocks += g.gateFrameBlocks.size(); + numFrameBlocks += g.getGateFrameBlocks().size(); } - gatesByFrameLocation = new HashMap((int) (numFrameBlocks * 1.25)); + gatesByFrameLocation = new HashMap<>((int) (numFrameBlocks * 1.25)); for (Gate g : gates) { this.addGateByFrameLocations(g); } } - - protected void removeGateById(final String id) { + private void removeGateById(final String id) { gatesById.remove(id); } - - protected void addGateWithId(final Gate g) { + private void addGateWithId(final Gate g) { gatesById.put(g.getId(), g); } - - protected void removeGateByLocation(final Set gateBlocks) { + private void removeGateByLocation(final Set gateBlocks) { if (gateBlocks != null) { for (Location l : gateBlocks) { @@ -334,8 +299,7 @@ public class GatesManager { } } - - protected void removeGateByFrameLocation(final Set gateFrameBlocks) { + private void removeGateByFrameLocation(final Set gateFrameBlocks) { if (gateFrameBlocks != null) { for (Block block : gateFrameBlocks) { @@ -345,8 +309,7 @@ public class GatesManager { } } - - protected void addGateByLocations(final Gate g) { + private void addGateByLocations(final Gate g) { for (Location l : g.getGateBlockLocations()) { SimpleLocation sl = new SimpleLocation(l); @@ -357,16 +320,14 @@ public class GatesManager { } } - - protected void addGateByFrameLocations(final Gate g) { + private void addGateByFrameLocations(final Gate g) { for (Block block : g.getGateFrameBlocks()) { SimpleLocation sl = new SimpleLocation(block.getLocation()); gatesByFrameLocation.put(sl, g); } } - - protected void removeGateFromChunk(final Gate g, final Location l) { + private void removeGateFromChunk(final Gate g, final Location l) { if (l != null) { Chunk c = l.getChunk(); @@ -389,8 +350,7 @@ public class GatesManager { } } - - protected void addGateByChunk(final Gate g) { + private void addGateByChunk(final Gate g) { Location gateLocation = g.getLocation(); if (gateLocation != null) { @@ -418,8 +378,7 @@ public class GatesManager { } } - - public void storeInvalidGate(Map map) { + void storeInvalidGate(Map map) { File invalidGatesFile = new File(Plugin.getPlugin().getDataFolder(), "invalid_gates.yml"); Boolean invalidGatesFileExists = invalidGatesFile.exists(); @@ -473,13 +432,6 @@ public class GatesManager { public void handleGateIdChange(final Gate g, final String oldId) { this.removeGateById(oldId); this.addGateWithId(g); - - Map changeSet = new HashMap(); - changeSet.put(GateChangeListener.changedID, oldId); - - for (GateChangeListener l : this.changeListeners) { - l.gateChangedHandler(g, changeSet); - } } @@ -495,25 +447,11 @@ public class GatesManager { this.removeGateByFrameLocation(oldGateFrameBlocks); this.addGateByFrameLocations(g); - - Map changeSet = new HashMap(); - changeSet.put(GateChangeListener.changedLocation, oldLocation); - - for (GateChangeListener l : this.changeListeners) { - l.gateChangedHandler(g, changeSet); - } } public void handleGateExitChange(final Gate g, final Location oldExit) { // nothing to do - - Map changeSet = new HashMap(); - changeSet.put(GateChangeListener.changedExit, oldExit); - - for (GateChangeListener l : this.changeListeners) { - l.gateChangedHandler(g, changeSet); - } } @@ -524,14 +462,6 @@ public class GatesManager { this.addGateByLocations(g); this.addGateWithId(g); this.addGateByFrameLocations(g); - - - Map changeSet = new HashMap(); - changeSet.put(GateChangeListener.newGate, null); - - for (GateChangeListener l : this.changeListeners) { - l.gateChangedHandler(g, changeSet); - } } @@ -542,13 +472,6 @@ public class GatesManager { this.removeGateFromChunk(g, g.getLocation()); this.removeGateByLocation(g.getGateBlockLocations()); this.removeGateByFrameLocation(g.getGateFrameBlocks()); - - Map changeSet = new HashMap(); - changeSet.put(GateChangeListener.removedGate, null); - - for (GateChangeListener l : this.changeListeners) { - l.gateChangedHandler(g, changeSet); - } } diff --git a/src/de/craftinc/gates/Plugin.java b/src/de/craftinc/gates/Plugin.java index ef86dfa..d14e7d5 100644 --- a/src/de/craftinc/gates/Plugin.java +++ b/src/de/craftinc/gates/Plugin.java @@ -46,16 +46,16 @@ public class Plugin extends JavaPlugin { private static Plugin instance; private static Permission permission; - protected String baseCommand; - protected List commands = new ArrayList(); - protected GatesManager gatesManager = new GatesManager(); + private String baseCommand; + protected List commands = new ArrayList<>(); + private GatesManager gatesManager = new GatesManager(); - protected PlayerMoveListener moveListener = new PlayerMoveListener(); - protected PlayerTeleportListener teleportListener = new PlayerTeleportListener(); - protected PlayerRespawnListener respawnListener = new PlayerRespawnListener(); - protected PlayerChangedWorldListener worldChangeListener = new PlayerChangedWorldListener(); - protected PlayerJoinListener joinListener = new PlayerJoinListener(); - protected BlockBreakListener blockBreakListener = new BlockBreakListener(); + private PlayerMoveListener moveListener = new PlayerMoveListener(); + private PlayerTeleportListener teleportListener = new PlayerTeleportListener(); + private PlayerRespawnListener respawnListener = new PlayerRespawnListener(); + private PlayerChangedWorldListener worldChangeListener = new PlayerChangedWorldListener(); + private PlayerJoinListener joinListener = new PlayerJoinListener(); + private BlockBreakListener blockBreakListener = new BlockBreakListener(); public Plugin() { @@ -79,7 +79,7 @@ public class Plugin extends JavaPlugin { } - protected void setupPermissions() { + private void setupPermissions() { if (getServer().getPluginManager().getPlugin("Vault") == null) { return; } @@ -154,7 +154,7 @@ public class Plugin extends JavaPlugin { } - protected void registerEventListeners() { + private void registerEventListeners() { PluginManager pm = this.getServer().getPluginManager(); pm.registerEvents(this.moveListener, this); @@ -187,13 +187,13 @@ public class Plugin extends JavaPlugin { @Override public boolean onCommand(CommandSender sender, Command cmd, String commandLabel, String[] args) { - List parameters = new ArrayList(Arrays.asList(args)); + List parameters = new ArrayList<>(Arrays.asList(args)); this.handleCommand(sender, parameters); return true; } - public void handleCommand(CommandSender sender, List parameters) { + private void handleCommand(CommandSender sender, List parameters) { if (parameters.size() == 0) { this.commands.get(0).execute(sender, parameters); return; @@ -202,9 +202,9 @@ public class Plugin extends JavaPlugin { String commandName = parameters.get(0).toLowerCase(); parameters.remove(0); - for (BaseCommand fcommand : this.commands) { - if (fcommand.getAliases().contains(commandName)) { - fcommand.execute(sender, parameters); + for (BaseCommand command : this.commands) { + if (command.getAliases().contains(commandName)) { + command.execute(sender, parameters); return; } } @@ -213,7 +213,6 @@ public class Plugin extends JavaPlugin { ChatColor.GREEN + " Try " + "/" + getBaseCommand() + " help"); } - /* * Logging */ diff --git a/src/de/craftinc/gates/commands/BaseCommand.java b/src/de/craftinc/gates/commands/BaseCommand.java index b9da0ec..e3af472 100644 --- a/src/de/craftinc/gates/commands/BaseCommand.java +++ b/src/de/craftinc/gates/commands/BaseCommand.java @@ -32,31 +32,29 @@ import de.craftinc.gates.util.TextUtil; public abstract class BaseCommand { - protected List aliases = new ArrayList(); - protected List requiredParameters = new ArrayList(); - protected List optionalParameters = new ArrayList(); + protected List aliases = new ArrayList<>(); + protected List requiredParameters = new ArrayList<>(); + List optionalParameters = new ArrayList<>(); protected String helpDescription = "no description"; - protected List parameters; - protected CommandSender sender; + List parameters; + CommandSender sender; protected Player player; protected Gate gate; protected boolean senderMustBePlayer = true; - protected boolean hasGateParam = true; + boolean hasGateParam = true; protected String requiredPermission; protected boolean needsPermissionAtCurrentLocation; protected boolean shouldPersistToDisk; - public List getAliases() { return aliases; } - public void execute(CommandSender sender, List parameters) { this.sender = sender; this.parameters = parameters; @@ -66,7 +64,7 @@ public abstract class BaseCommand { } if (this.senderMustBePlayer) { - this.player = (Player) sender; + this.player = (Player)sender; } this.perform(); @@ -81,23 +79,19 @@ public abstract class BaseCommand { return config.getBoolean(ConfigurationUtil.confSaveOnChangesKey); } - abstract protected void perform(); - protected void sendMessage(String message) { sender.sendMessage(message); } - protected void sendMessage(List messages) { for (String message : messages) { this.sendMessage(message); } } - - protected boolean validateCall() { + private boolean validateCall() { boolean allParametersThere = parameters.size() >= requiredParameters.size(); boolean senderIsPlayer = this.sender instanceof Player; boolean hasGateParameter = false; @@ -110,17 +104,23 @@ public abstract class BaseCommand { boolean valid; if (this.senderMustBePlayer && !senderIsPlayer) { - sendMessage(ChatColor.RED + "This command can only be used by ingame players."); + sendMessage(ChatColor.RED + "This command can only be used by in-game players."); valid = false; } else { if (!allParametersThere) { - sendMessage(ChatColor.RED + "Some parameters are missing! " + ChatColor.AQUA + "Usage: " + this.getUsageTemplate(true)); + sendMessage(ChatColor.RED + "Some parameters are missing! " + + ChatColor.AQUA + "Usage: " + + this.getUsageTemplate() + ); valid = false; } else if ((!senderHasPermission && this.hasGateParam) || (!senderHasPermission) || (this.hasGateParam && !hasGateParameter)) { - sendMessage(ChatColor.RED + "You either provided a invalid gate or do not have permission to " + this.helpDescription.toLowerCase()); + sendMessage(ChatColor.RED + + "You either provided a invalid gate or do not have permission to " + + this.helpDescription.toLowerCase() + ); valid = false; } else { valid = true; @@ -130,8 +130,7 @@ public abstract class BaseCommand { return valid; } - - protected boolean setGateUsingParameter(String param) { + boolean setGateUsingParameter(String param) { GatesManager gateManager = Plugin.getPlugin().getGatesManager(); if (!gateManager.gateExists(param)) { @@ -142,11 +141,10 @@ public abstract class BaseCommand { } } - /** * This will return false if a gate is required for this command but this.gate == null. */ - protected boolean hasPermission() { + boolean hasPermission() { if (Plugin.getPermission() == null) { // fallback - use the standard bukkit permission system return this.sender.hasPermission(this.requiredPermission); } @@ -160,32 +158,35 @@ public abstract class BaseCommand { Player p = (Player) this.sender; boolean hasPermission = false; - if (this.requiredPermission.equals(Plugin.permissionInfo)) { + switch (this.requiredPermission) { + case Plugin.permissionInfo: - if (this.hasGateParam) { + if (this.hasGateParam) { + hasPermission = this.hasPermissionAtGateLocationAndExit(p); + } else { + hasPermission = hasPermissionAtPlayerLocation(p); + } + break; + case Plugin.permissionUse: hasPermission = this.hasPermissionAtGateLocationAndExit(p); - } else { - hasPermission = Plugin.getPermission().has(p.getWorld(), p.getName(), this.requiredPermission); - } - } else if (this.requiredPermission.equals(Plugin.permissionUse)) { - hasPermission = this.hasPermissionAtGateLocationAndExit(p); - } else if (this.requiredPermission.equals(Plugin.permissionManage)) { + break; + case Plugin.permissionManage: - if (this.needsPermissionAtCurrentLocation && this.hasGateParam) { - boolean hasPersmissionAtCurrentLocation = Plugin.getPermission().has(p.getWorld(), p.getName(), this.requiredPermission); - hasPermission = hasPersmissionAtCurrentLocation && this.hasPermissionAtGateLocationAndExit(p); - } else if (this.needsPermissionAtCurrentLocation) { - hasPermission = Plugin.getPermission().has(p.getWorld(), p.getName(), this.requiredPermission); - } else { - hasPermission = this.hasPermissionAtGateLocationAndExit(p); - } + if (this.needsPermissionAtCurrentLocation && this.hasGateParam) { + boolean hasPermissionAtCurrentLocation = hasPermissionAtPlayerLocation(p); + hasPermission = hasPermissionAtCurrentLocation && this.hasPermissionAtGateLocationAndExit(p); + } else if (this.needsPermissionAtCurrentLocation) { + hasPermission = hasPermissionAtPlayerLocation(p); + } else { + hasPermission = this.hasPermissionAtGateLocationAndExit(p); + } + break; } return hasPermission; } - - protected boolean hasPermissionAtGateLocationAndExit(Player p) { + private boolean hasPermissionAtGateLocationAndExit(Player p) { if (this.gate == null || p == null) { return false; } @@ -196,20 +197,21 @@ public abstract class BaseCommand { return permAtLocation & permAtExit; } + private boolean hasPermissionAtPlayerLocation(Player p) { + return Plugin.getPermission().has(p.getWorld(), p.getName(), this.requiredPermission); + } - // -------------------------------------------- // - // Help and usage description - // -------------------------------------------- // - protected String getUsageTemplate(boolean withColor, boolean withDescription) { + /* + Help and usage description + */ + + String getUsageTemplate(boolean withDescription) { String ret = ""; - if (withColor) { - ret += ChatColor.AQUA; - } - + ret += ChatColor.AQUA; ret += "/" + Plugin.getPlugin().getBaseCommand() + " " + TextUtil.implode(this.getAliases(), ",") + " "; - List parts = new ArrayList(); + List parts = new ArrayList<>(); for (String requiredParameter : this.requiredParameters) { parts.add("[" + requiredParameter + "]"); @@ -219,24 +221,19 @@ public abstract class BaseCommand { parts.add("*[" + optionalParameter + "]"); } - if (withColor) { - ret += ChatColor.DARK_AQUA; - } + ret += ChatColor.DARK_AQUA; ret += TextUtil.implode(parts, " "); if (withDescription) { ret += " "; - - if (withColor) { - ret += ChatColor.YELLOW; - } + ret += ChatColor.YELLOW; ret += this.helpDescription; } return ret; } - protected String getUsageTemplate(boolean withColor) { - return getUsageTemplate(withColor, false); + private String getUsageTemplate() { + return getUsageTemplate(false); } } diff --git a/src/de/craftinc/gates/commands/BaseLocationCommand.java b/src/de/craftinc/gates/commands/BaseLocationCommand.java index d7568e0..906371d 100644 --- a/src/de/craftinc/gates/commands/BaseLocationCommand.java +++ b/src/de/craftinc/gates/commands/BaseLocationCommand.java @@ -21,25 +21,21 @@ import org.bukkit.Material; import org.bukkit.block.Block; import org.bukkit.block.BlockFace; -public abstract class BaseLocationCommand extends BaseCommand { +abstract class BaseLocationCommand extends BaseCommand { - protected Location getValidPlayerLocation() { + Location getValidPlayerLocation() { // The player might stand in a half block or a sign or whatever // Therefore we load some extra locations and blocks - Block playerBlock = player.getLocation().getBlock(); + Location location = player.getLocation().clone(); + Block playerBlock = location.getBlock(); Block upBlock = playerBlock.getRelative(BlockFace.UP); if (playerBlock.getType() == Material.AIR) { - return player.getLocation(); + return location; } else if (upBlock.getType() == Material.AIR) { - return new Location(player.getLocation().getWorld(), - player.getLocation().getX(), - player.getLocation().getY() + 1, - player.getLocation().getZ(), - player.getLocation().getYaw(), - player.getLocation().getPitch()); + return location.add(0, 1, 0); + } else { + return null; } - - return null; } } diff --git a/src/de/craftinc/gates/commands/CommandHelp.java b/src/de/craftinc/gates/commands/CommandHelp.java index 1adb7b3..f774d63 100644 --- a/src/de/craftinc/gates/commands/CommandHelp.java +++ b/src/de/craftinc/gates/commands/CommandHelp.java @@ -25,36 +25,36 @@ import java.util.List; public class CommandHelp extends BaseCommand { - public static List> helpPages; + private static List> helpPages; static { // sort the usage strings - List allUsageStrings = new ArrayList(); + List allUsageStrings = new ArrayList<>(); - allUsageStrings.add(new CommandHelp().getUsageTemplate(true, true)); - allUsageStrings.add(new CommandNew().getUsageTemplate(true, true)); - allUsageStrings.add(new CommandRemove().getUsageTemplate(true, true)); - allUsageStrings.add(new CommandLocation().getUsageTemplate(true, true)); - allUsageStrings.add(new CommandExit().getUsageTemplate(true, true)); - allUsageStrings.add(new CommandOpen().getUsageTemplate(true, true)); - allUsageStrings.add(new CommandRename().getUsageTemplate(true, true)); - allUsageStrings.add(new CommandClose().getUsageTemplate(true, true)); - allUsageStrings.add(new CommandList().getUsageTemplate(true, true)); - allUsageStrings.add(new CommandInfo().getUsageTemplate(true, true)); - allUsageStrings.add(new CommandHide().getUsageTemplate(true, true)); - allUsageStrings.add(new CommandUnhide().getUsageTemplate(true, true)); - allUsageStrings.add(new CommandExitOpen().getUsageTemplate(true, true)); - allUsageStrings.add(new CommandNearby().getUsageTemplate(true, true)); + allUsageStrings.add(new CommandHelp().getUsageTemplate(true)); + allUsageStrings.add(new CommandNew().getUsageTemplate(true)); + allUsageStrings.add(new CommandRemove().getUsageTemplate(true)); + allUsageStrings.add(new CommandLocation().getUsageTemplate(true)); + allUsageStrings.add(new CommandExit().getUsageTemplate(true)); + allUsageStrings.add(new CommandOpen().getUsageTemplate(true)); + allUsageStrings.add(new CommandRename().getUsageTemplate(true)); + allUsageStrings.add(new CommandClose().getUsageTemplate(true)); + allUsageStrings.add(new CommandList().getUsageTemplate(true)); + allUsageStrings.add(new CommandInfo().getUsageTemplate(true)); + allUsageStrings.add(new CommandHide().getUsageTemplate(true)); + allUsageStrings.add(new CommandUnhide().getUsageTemplate(true)); + allUsageStrings.add(new CommandExitOpen().getUsageTemplate(true)); + allUsageStrings.add(new CommandNearby().getUsageTemplate(true)); Collections.sort(allUsageStrings); // put 5 commands on one page - helpPages = new ArrayList>(); + helpPages = new ArrayList<>(); while (!allUsageStrings.isEmpty()) { int toIndex = allUsageStrings.size() >= 6 ? 5 : allUsageStrings.size(); - List currentHelpPage = new ArrayList(allUsageStrings.subList(0, toIndex)); + List currentHelpPage = new ArrayList<>(allUsageStrings.subList(0, toIndex)); helpPages.add(currentHelpPage); allUsageStrings.removeAll(currentHelpPage); @@ -92,7 +92,7 @@ public class CommandHelp extends BaseCommand { page = 1; } - sendMessage(TextUtil.titleize("Craft Inc. Gates Help (" + page + "/" + helpPages.size() + ")")); + sendMessage(TextUtil.titleSize("Craft Inc. Gates Help (" + page + "/" + helpPages.size() + ")")); page -= 1; if (page < 0 || page >= helpPages.size()) { diff --git a/src/de/craftinc/gates/commands/CommandInfo.java b/src/de/craftinc/gates/commands/CommandInfo.java index 0c6c1d1..0dd1833 100644 --- a/src/de/craftinc/gates/commands/CommandInfo.java +++ b/src/de/craftinc/gates/commands/CommandInfo.java @@ -50,7 +50,7 @@ public class CommandInfo extends BaseCommand { return; } - sendMessage(TextUtil.titleize("Information about: '" + ChatColor.WHITE + gate.getId() + ChatColor.YELLOW + "'")); + sendMessage(TextUtil.titleSize("Information about: '" + ChatColor.WHITE + gate.getId() + ChatColor.YELLOW + "'")); } else { boolean senderIsPlayer = this.sender instanceof Player; @@ -69,7 +69,7 @@ public class CommandInfo extends BaseCommand { Plugin.log(this.gate.toString()); - sendMessage(TextUtil.titleize("Information about closest gate: '" + ChatColor.WHITE + gate.getId() + ChatColor.YELLOW + "'")); + sendMessage(TextUtil.titleSize("Information about closest gate: '" + ChatColor.WHITE + gate.getId() + ChatColor.YELLOW + "'")); } String openHiddenMessage = ChatColor.DARK_AQUA + "This gate is"; diff --git a/src/de/craftinc/gates/commands/CommandList.java b/src/de/craftinc/gates/commands/CommandList.java index 6d234b9..c870156 100644 --- a/src/de/craftinc/gates/commands/CommandList.java +++ b/src/de/craftinc/gates/commands/CommandList.java @@ -68,17 +68,17 @@ public class CommandList extends BaseCommand { return; } - String message = TextUtil.titleize("List of all gates (" + page + "/" + allPages.size() + ")") + "\n"; + String message = TextUtil.titleSize("List of all gates (" + page + "/" + allPages.size() + ")") + "\n"; message += allPages.get(page - 1); sendMessage(message); } private static List linesOfGateIds(List gates) { - List lines = new ArrayList(); + List lines = new ArrayList<>(); int index = 0; - List gateIdsForCurrentLine = new ArrayList(); + List gateIdsForCurrentLine = new ArrayList<>(); int numCharactersInCurrentLine = 0; while (index < gates.size()) { @@ -86,7 +86,7 @@ public class CommandList extends BaseCommand { int gateIdLength = gateId.length() + 2; // actual length + comma + whitespace if (gateIdLength > charactersPerLine && numCharactersInCurrentLine == 0) { // special case: very long gate id - gateIdsForCurrentLine = new ArrayList(); + gateIdsForCurrentLine = new ArrayList<>(); numCharactersInCurrentLine = 0; while ((gateId.length() + 2) > charactersPerLine) { @@ -113,7 +113,7 @@ public class CommandList extends BaseCommand { } else { // the current gate does not fit on the lines.add(TextUtil.implode(gateIdsForCurrentLine, ", ") + ", "); - gateIdsForCurrentLine = new ArrayList(); + gateIdsForCurrentLine = new ArrayList<>(); numCharactersInCurrentLine = 0; } } @@ -154,7 +154,7 @@ public class CommandList extends BaseCommand { Player p = (Player) this.sender; // create a copy since we cannot iterate over a collection while modifying it! - Collection gatesCopy = new ArrayList(gates); + Collection gatesCopy = new ArrayList<>(gates); for (Gate gate : gatesCopy) { if (gate.getLocation() != null) { @@ -186,7 +186,7 @@ public class CommandList extends BaseCommand { */ private static List> gatesSortedByName(Collection allGates) { // create the lists - List> ids = new ArrayList>(); + List> ids = new ArrayList<>(); for (int i = 0; i < 28; i++) { ids.add(new ArrayList()); @@ -232,7 +232,7 @@ public class CommandList extends BaseCommand { } List> gatesSortedByName = gatesSortedByName(gates); - List allPages = new ArrayList(); + List allPages = new ArrayList<>(); int linesLeftOnPage = linesPerPage - 1; String currentPageString = ""; diff --git a/src/de/craftinc/gates/commands/CommandLocation.java b/src/de/craftinc/gates/commands/CommandLocation.java index 4737872..f0cd22a 100644 --- a/src/de/craftinc/gates/commands/CommandLocation.java +++ b/src/de/craftinc/gates/commands/CommandLocation.java @@ -61,7 +61,7 @@ public class CommandLocation extends BaseLocationCommand { sendMessage(ChatColor.GREEN + "The location of '" + gate.getId() + "' is now at your current location."); } catch (Exception e) { sendMessage(ChatColor.RED + "There seems to be no frame at your new location! The gate got closed!" + ChatColor.AQUA + " You should build a frame now and execute:"); - sendMessage(new CommandOpen().getUsageTemplate(true, true)); + sendMessage(new CommandOpen().getUsageTemplate(true)); } finally { Plugin.getPlugin().getGatesManager().handleGateLocationChange(gate, oldLocation, oldGateBlockLocations, oldFrameBlocks); GateBlockChangeSender.updateGateBlocks(gate); diff --git a/src/de/craftinc/gates/commands/CommandNearby.java b/src/de/craftinc/gates/commands/CommandNearby.java index 1ce2708..349a804 100644 --- a/src/de/craftinc/gates/commands/CommandNearby.java +++ b/src/de/craftinc/gates/commands/CommandNearby.java @@ -32,7 +32,7 @@ public class CommandNearby extends BaseLocationCommand { } else { GateBlockChangeSender.temporaryHighlightGatesFrames(player, nearbyGates); - ArrayList gateNames = new ArrayList(); + ArrayList gateNames = new ArrayList<>(); for (Gate g : nearbyGates) { gateNames.add(g.getId()); diff --git a/src/de/craftinc/gates/commands/CommandNew.java b/src/de/craftinc/gates/commands/CommandNew.java index 4f9a090..f304318 100644 --- a/src/de/craftinc/gates/commands/CommandNew.java +++ b/src/de/craftinc/gates/commands/CommandNew.java @@ -62,7 +62,7 @@ public class CommandNew extends BaseLocationCommand { } } else { sendMessage(ChatColor.RED + "Your location is invalid!" + ChatColor.AQUA + "Go somewhere else and execute:"); - sendMessage(new CommandLocation().getUsageTemplate(true, true)); + sendMessage(new CommandLocation().getUsageTemplate(true)); } gatesManager.handleNewGate(gate); diff --git a/src/de/craftinc/gates/listeners/PlayerMoveListener.java b/src/de/craftinc/gates/listeners/PlayerMoveListener.java index 52bd70a..0bf3fd2 100644 --- a/src/de/craftinc/gates/listeners/PlayerMoveListener.java +++ b/src/de/craftinc/gates/listeners/PlayerMoveListener.java @@ -39,7 +39,7 @@ import org.bukkit.scheduler.BukkitScheduler; public class PlayerMoveListener implements Listener { - protected HashMap lastNoPermissionMessages = new HashMap(); + private HashMap lastNoPermissionMessages = new HashMap<>(); @EventHandler(priority = EventPriority.NORMAL) public void onPlayerMove(PlayerMoveEvent event) { @@ -150,7 +150,7 @@ public class PlayerMoveListener implements Listener { } - protected boolean hasPermission(final Player player, final Gate gate) { + private boolean hasPermission(final Player player, final Gate gate) { if (Plugin.getPermission() == null) { // fallback: use the standard bukkit permission system return player.hasPermission(Plugin.permissionUse); } else { diff --git a/src/de/craftinc/gates/persistence/LocationUtil.java b/src/de/craftinc/gates/persistence/LocationUtil.java index 58b7cd4..05eb369 100644 --- a/src/de/craftinc/gates/persistence/LocationUtil.java +++ b/src/de/craftinc/gates/persistence/LocationUtil.java @@ -26,11 +26,11 @@ import de.craftinc.gates.Plugin; public class LocationUtil { - protected final static String worldKey = "world"; - protected final static String xKey = "x"; - protected final static String yKey = "y"; - protected final static String zKey = "z"; + private final static String worldKey = "world"; + private final static String xKey = "x"; + private final static String yKey = "y"; + private final static String zKey = "z"; protected static World getWorld(final String name) throws Exception { if (name == null) { @@ -46,7 +46,6 @@ public class LocationUtil { return world; } - /** * Serializes a location. Helps storing locations inside yaml files. NOTE: We do not care about yaw * and pitch for gate locations. So we won't serialize them. @@ -59,7 +58,7 @@ public class LocationUtil { return null; } - Map serializedLocation = new HashMap(); + Map serializedLocation = new HashMap<>(); serializedLocation.put(worldKey, l.getWorld().getName()); serializedLocation.put(xKey, l.getX()); @@ -69,7 +68,6 @@ public class LocationUtil { return serializedLocation; } - /** * @param map A map generated with the 'serializeLocation' method. Supplying 'null' is ok. * @return A deserialized location. This method will return 'null' if 'map' is null! diff --git a/src/de/craftinc/gates/persistence/MigrationUtil.java b/src/de/craftinc/gates/persistence/MigrationUtil.java index 314f38b..83e2028 100644 --- a/src/de/craftinc/gates/persistence/MigrationUtil.java +++ b/src/de/craftinc/gates/persistence/MigrationUtil.java @@ -28,6 +28,7 @@ import java.util.logging.Level; public class MigrationUtil { + public static boolean performMigration(int storageVersion, int currentVersion, List gates) { if (storageVersion == 0 && currentVersion >= 2) { removePortalBlocks(gates); @@ -44,8 +45,7 @@ public class MigrationUtil { } } - - protected static void removePortalBlocks(List gates) { + private static void removePortalBlocks(List gates) { for (Gate g : gates) { for (Location l : g.getGateBlockLocations()) { @@ -58,10 +58,8 @@ public class MigrationUtil { } } - - protected static void updateAllowVehicles(List gates) { + private static void updateAllowVehicles(List gates) { for (Gate g : gates) { - g.setAllowsVehicles(true); } } diff --git a/src/de/craftinc/gates/util/ConfigurationUtil.java b/src/de/craftinc/gates/util/ConfigurationUtil.java index 253e1bc..74f5362 100644 --- a/src/de/craftinc/gates/util/ConfigurationUtil.java +++ b/src/de/craftinc/gates/util/ConfigurationUtil.java @@ -37,58 +37,82 @@ public class ConfigurationUtil { public static final String confGateMaterialKey = "gateMaterial"; - public static GateMaterial getPortalMaterial() { + static GateMaterial getPortalMaterial() { String materialString = Plugin.getPlugin().getConfig().getString(confGateMaterialKey); GateMaterial material = new GateMaterial(); - if (materialString.equals("sapling")) { - material.material = Material.SAPLING; - } else if (materialString.equals("water")) { - material.material = Material.STATIONARY_WATER; - } else if (materialString.equals("lava")) { - material.material = Material.STATIONARY_LAVA; - } else if (materialString.equals("cobweb")) { - material.material = Material.WEB; - } else if (materialString.equals("grass")) { - material.material = Material.LONG_GRASS; - material.data = 1; - } else if (materialString.equals("dead bush")) { - material.material = Material.DEAD_BUSH; - } else if (materialString.equals("dandelion")) { - material.material = Material.YELLOW_FLOWER; - } else if (materialString.equals("poppy")) { - material.material = Material.RED_ROSE; - } else if (materialString.equals("brown mushroom")) { - material.material = Material.BROWN_MUSHROOM; - } else if (materialString.equals("red mushroom")) { - material.material = Material.RED_MUSHROOM; - } else if (materialString.equals("torch")) { - material.material = Material.TORCH; - } else if (materialString.equals("redstone torch (off)")) { - material.material = Material.REDSTONE_TORCH_OFF; - } else if (materialString.equals("redstone torch (on)")) { - material.material = Material.REDSTONE_TORCH_ON; - } else if (materialString.equals("fence")) { - material.material = Material.FENCE; - } else if (materialString.equals("nether portal")) { - material.material = Material.PORTAL; - } else if (materialString.equals("iron bars")) { - material.material = Material.IRON_FENCE; - } else if (materialString.equals("glass pane")) { - material.material = Material.THIN_GLASS; - } else if (materialString.equals("fence gate")) { - material.material = Material.FENCE_GATE; - } else if (materialString.equals("nether brick fence")) { - material.material = Material.NETHER_FENCE; - } else if (materialString.equals("nether wart")) { - material.material = Material.NETHER_WARTS; - } else if (materialString.equals("end portal")) { - material.material = Material.ENDER_PORTAL; - } else if (materialString.equals("cobblestone wall")) { - material.material = Material.COBBLE_WALL; - } else { // fallback! - material.material = Material.PORTAL; - Plugin.log(Level.WARNING, "Gate material invalid! Please check and correct your configuration file!"); + switch (materialString) { + case "sapling": + material.material = Material.SAPLING; + break; + case "water": + material.material = Material.STATIONARY_WATER; + break; + case "lava": + material.material = Material.STATIONARY_LAVA; + break; + case "cobweb": + material.material = Material.WEB; + break; + case "grass": + material.material = Material.LONG_GRASS; + material.data = 1; + break; + case "dead bush": + material.material = Material.DEAD_BUSH; + break; + case "dandelion": + material.material = Material.YELLOW_FLOWER; + break; + case "poppy": + material.material = Material.RED_ROSE; + break; + case "brown mushroom": + material.material = Material.BROWN_MUSHROOM; + break; + case "red mushroom": + material.material = Material.RED_MUSHROOM; + break; + case "torch": + material.material = Material.TORCH; + break; + case "redstone torch (off)": + material.material = Material.REDSTONE_TORCH_OFF; + break; + case "redstone torch (on)": + material.material = Material.REDSTONE_TORCH_ON; + break; + case "fence": + material.material = Material.FENCE; + break; + case "nether portal": + material.material = Material.PORTAL; + break; + case "iron bars": + material.material = Material.IRON_FENCE; + break; + case "glass pane": + material.material = Material.THIN_GLASS; + break; + case "fence gate": + material.material = Material.FENCE_GATE; + break; + case "nether brick fence": + material.material = Material.NETHER_FENCE; + break; + case "nether wart": + material.material = Material.NETHER_WARTS; + break; + case "end portal": + material.material = Material.ENDER_PORTAL; + break; + case "cobblestone wall": + material.material = Material.COBBLE_WALL; + break; + default: // fallback! + material.material = Material.PORTAL; + Plugin.log(Level.WARNING, "Gate material invalid! Please check and correct your configuration file!"); + break; } return material; diff --git a/src/de/craftinc/gates/util/FloodUtil.java b/src/de/craftinc/gates/util/FloodUtil.java index 28e4cbf..7c14265 100644 --- a/src/de/craftinc/gates/util/FloodUtil.java +++ b/src/de/craftinc/gates/util/FloodUtil.java @@ -29,8 +29,8 @@ import de.craftinc.gates.Plugin; public class FloodUtil { - protected static final Set exp1 = new HashSet(); - protected static final Set exp2 = new HashSet(); + private static final Set exp1 = new HashSet<>(); + private static final Set exp2 = new HashSet<>(); static { exp1.add(BlockFace.UP); @@ -53,7 +53,7 @@ public class FloodUtil { */ public static Set getFrame(final Set blocks) { if (blocks == null || blocks.isEmpty()) { - return new HashSet(); + return new HashSet<>(); } // try to find gate's direction (north-south or east-west) @@ -97,8 +97,8 @@ public class FloodUtil { } - protected static Set _getFrame(final Set blocks, final Set searchDirections) { - Set frameBlocks = new HashSet(); + private static Set _getFrame(final Set blocks, final Set searchDirections) { + Set frameBlocks = new HashSet<>(); for (Block b : blocks) { @@ -126,7 +126,7 @@ public class FloodUtil { throw new IllegalArgumentException("'locations' must not be 'null'"); } - Set blocks = new HashSet(); + Set blocks = new HashSet<>(); for (Location l : locations) { blocks.add(l.getBlock()); @@ -167,7 +167,7 @@ public class FloodUtil { } - protected static Set getAirFloodBlocks(final Block startBlock, + private static Set getAirFloodBlocks(final Block startBlock, Set foundBlocks, final Set expandFaces, int limit) { @@ -185,10 +185,8 @@ public class FloodUtil { } if (startBlock.getType() == Material.AIR) { - // ... We found a block :D ... foundBlocks.add(startBlock); - // ... And flood away ! for (BlockFace face : expandFaces) { Block potentialBlock = startBlock.getRelative(face); foundBlocks = getAirFloodBlocks(potentialBlock, foundBlocks, expandFaces, limit); diff --git a/src/de/craftinc/gates/util/GateBlockChangeSender.java b/src/de/craftinc/gates/util/GateBlockChangeSender.java index e685d70..d85d7c5 100644 --- a/src/de/craftinc/gates/util/GateBlockChangeSender.java +++ b/src/de/craftinc/gates/util/GateBlockChangeSender.java @@ -97,7 +97,7 @@ public class GateBlockChangeSender { } - protected static void dehighlightGatesFrames(final Player player, final Set gates) { + private static void dehighlightGatesFrames(final Player player, final Set gates) { for (Gate g : gates) { Set frameBlocks = g.getGateFrameBlocks(); @@ -108,7 +108,7 @@ public class GateBlockChangeSender { } - protected static void dehighlightGateFrame(final Player player, final Gate gate) { + private static void dehighlightGateFrame(final Player player, final Gate gate) { Set frameBlocks = gate.getGateFrameBlocks(); for (Block b : frameBlocks) { @@ -207,7 +207,7 @@ public class GateBlockChangeSender { return; } - ArrayList playersNearby = new ArrayList(); + ArrayList playersNearby = new ArrayList<>(); int searchRadius = Plugin.getPlugin().getConfig().getInt(confPlayerGateBlockUpdateRadiusKey); diff --git a/src/de/craftinc/gates/util/TextUtil.java b/src/de/craftinc/gates/util/TextUtil.java index 4fbcd20..a4df65d 100644 --- a/src/de/craftinc/gates/util/TextUtil.java +++ b/src/de/craftinc/gates/util/TextUtil.java @@ -21,7 +21,8 @@ import org.bukkit.ChatColor; import java.util.List; public class TextUtil { - public static String titleize(String str) { + + public static String titleSize(String str) { String center = ".[ " + ChatColor.YELLOW + str + ChatColor.GOLD + " ]."; if (center.length() >= 60) { @@ -38,7 +39,7 @@ public class TextUtil { } - public static String repeat(String s, int times) { + private static String repeat(String s, int times) { if (times <= 0) return ""; diff --git a/src/de/craftinc/gates/util/VehicleCloner.java b/src/de/craftinc/gates/util/VehicleCloner.java index 3aba655..069555e 100644 --- a/src/de/craftinc/gates/util/VehicleCloner.java +++ b/src/de/craftinc/gates/util/VehicleCloner.java @@ -21,6 +21,7 @@ import org.bukkit.entity.*; public class VehicleCloner { + public static Vehicle clone(Vehicle parent, Location cloneLocation) { Vehicle clone = cloneLocation.getWorld().spawn(cloneLocation, parent.getClass());