mirror of
https://github.com/BentoBoxWorld/BentoBox.git
synced 2025-01-01 05:57:54 +01:00
Code clean up.
This commit is contained in:
parent
045855f6ad
commit
0e1ee335ea
@ -1490,7 +1490,7 @@ public class Settings implements DataObject, WorldSettings {
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* Set panel close on click outside
|
* Set panel close on click outside
|
||||||
* @param closePanelOnClickOutside
|
* @param closePanelOnClickOutside - true means close panel when click is outside panel
|
||||||
*/
|
*/
|
||||||
public void setClosePanelOnClickOutside(boolean closePanelOnClickOutside) {
|
public void setClosePanelOnClickOutside(boolean closePanelOnClickOutside) {
|
||||||
this.closePanelOnClickOutside = closePanelOnClickOutside;
|
this.closePanelOnClickOutside = closePanelOnClickOutside;
|
||||||
|
@ -92,7 +92,7 @@ public class AdminRegisterCommand extends CompositeCommand {
|
|||||||
/**
|
/**
|
||||||
* This returns the coordinate of where an island should be on the grid.
|
* This returns the coordinate of where an island should be on the grid.
|
||||||
*
|
*
|
||||||
* @param location
|
* @param location - location to check
|
||||||
* @return Location of where an island should be on a grid in this world
|
* @return Location of where an island should be on a grid in this world
|
||||||
*/
|
*/
|
||||||
public Location getClosestIsland(Location location) {
|
public Location getClosestIsland(Location location) {
|
||||||
|
@ -648,7 +648,7 @@ public class Island implements DataObject {
|
|||||||
* Show info on the island
|
* Show info on the island
|
||||||
* @param plugin - plugin
|
* @param plugin - plugin
|
||||||
* @param user - the user who is receiving the info
|
* @param user - the user who is receiving the info
|
||||||
* @param world
|
* @param world - world to check
|
||||||
* @return true always
|
* @return true always
|
||||||
*/
|
*/
|
||||||
public boolean showInfo(BSkyBlock plugin, User user, World world) {
|
public boolean showInfo(BSkyBlock plugin, User user, World world) {
|
||||||
@ -691,7 +691,7 @@ public class Island implements DataObject {
|
|||||||
* Shows the members of this island
|
* Shows the members of this island
|
||||||
* @param plugin - plugin
|
* @param plugin - plugin
|
||||||
* @param user - user who is requesting
|
* @param user - user who is requesting
|
||||||
* @param world
|
* @param world - world to check
|
||||||
*/
|
*/
|
||||||
public void showMembers(BSkyBlock plugin, User user, World world) {
|
public void showMembers(BSkyBlock plugin, User user, World world) {
|
||||||
if (plugin.getIslands().inTeam(world, user.getUniqueId())) {
|
if (plugin.getIslands().inTeam(world, user.getUniqueId())) {
|
||||||
|
@ -411,10 +411,9 @@ public class Clipboard {
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* Load a file to clipboard
|
* Load a file to clipboard
|
||||||
* @param filename - filename in schems folder
|
* @param fileName - filename in schems folder
|
||||||
* @return
|
* @throws IOException - if there's a load error with unziping or name
|
||||||
* @throws IOException
|
* @throws InvalidConfigurationException - the YAML of the schem is at fault
|
||||||
* @throws InvalidConfigurationException
|
|
||||||
*/
|
*/
|
||||||
public void load(String fileName) throws IOException, InvalidConfigurationException {
|
public void load(String fileName) throws IOException, InvalidConfigurationException {
|
||||||
File zipFile = new File(schemFolder, fileName + ".schem");
|
File zipFile = new File(schemFolder, fileName + ".schem");
|
||||||
@ -434,13 +433,13 @@ public class Clipboard {
|
|||||||
Files.delete(file.toPath());
|
Files.delete(file.toPath());
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/*
|
||||||
* Load a file to clipboard
|
Load a file to clipboard
|
||||||
*/
|
*/
|
||||||
/**
|
/**
|
||||||
* @param user - use trying to load
|
* @param user - use trying to load
|
||||||
* @param fileName - filename
|
* @param fileName - filename
|
||||||
* @return
|
* @return - ture if load is successful, false if not
|
||||||
*/
|
*/
|
||||||
public boolean load(User user, String fileName) {
|
public boolean load(User user, String fileName) {
|
||||||
try {
|
try {
|
||||||
|
@ -98,7 +98,7 @@ public class IslandBuilderNew {
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* Copies schems from the jar file
|
* Copies schems from the jar file
|
||||||
* @param schems2
|
* @param schems2 - file containing schem
|
||||||
*/
|
*/
|
||||||
private void copySchems(File schems2) {
|
private void copySchems(File schems2) {
|
||||||
plugin.saveResource("schems/island.schem", false);
|
plugin.saveResource("schems/island.schem", false);
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
/**
|
/*
|
||||||
*
|
|
||||||
*/
|
*/
|
||||||
package us.tastybento.bskyblock.listeners.flags;
|
package us.tastybento.bskyblock.listeners.flags;
|
||||||
|
|
||||||
@ -24,7 +24,7 @@ public class EnderChestListener extends AbstractFlagListener {
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* Prevents opening ender chest unless player has permission
|
* Prevents opening ender chest unless player has permission
|
||||||
* @param e
|
* @param e - event
|
||||||
*/
|
*/
|
||||||
@EventHandler(priority = EventPriority.LOW, ignoreCancelled = true)
|
@EventHandler(priority = EventPriority.LOW, ignoreCancelled = true)
|
||||||
public void onEnderChestOpen(PlayerInteractEvent e) {
|
public void onEnderChestOpen(PlayerInteractEvent e) {
|
||||||
@ -36,7 +36,7 @@ public class EnderChestListener extends AbstractFlagListener {
|
|||||||
/**
|
/**
|
||||||
* Prevents crafting of EnderChest unless the player has permission
|
* Prevents crafting of EnderChest unless the player has permission
|
||||||
*
|
*
|
||||||
* @param event
|
* @param e - event
|
||||||
*/
|
*/
|
||||||
@EventHandler(priority = EventPriority.LOW, ignoreCancelled = true)
|
@EventHandler(priority = EventPriority.LOW, ignoreCancelled = true)
|
||||||
public void onCraft(CraftItemEvent e) {
|
public void onCraft(CraftItemEvent e) {
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
/**
|
/*
|
||||||
*
|
|
||||||
*/
|
*/
|
||||||
package us.tastybento.bskyblock.listeners.flags;
|
package us.tastybento.bskyblock.listeners.flags;
|
||||||
|
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
/**
|
/*
|
||||||
*
|
|
||||||
*/
|
*/
|
||||||
package us.tastybento.bskyblock.listeners.flags;
|
package us.tastybento.bskyblock.listeners.flags;
|
||||||
|
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
/**
|
/*
|
||||||
*
|
|
||||||
*/
|
*/
|
||||||
package us.tastybento.bskyblock.listeners.flags;
|
package us.tastybento.bskyblock.listeners.flags;
|
||||||
|
|
||||||
@ -28,7 +28,7 @@ public class IslandRespawnListener extends AbstractFlagListener {
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* Tag players who die in island space and have an island
|
* Tag players who die in island space and have an island
|
||||||
* @param e
|
* @param e - event
|
||||||
*/
|
*/
|
||||||
@EventHandler(priority = EventPriority.LOW, ignoreCancelled = true)
|
@EventHandler(priority = EventPriority.LOW, ignoreCancelled = true)
|
||||||
public void onPlayerDeath(PlayerDeathEvent e) {
|
public void onPlayerDeath(PlayerDeathEvent e) {
|
||||||
@ -40,7 +40,7 @@ public class IslandRespawnListener extends AbstractFlagListener {
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* Place players back on their island if respawn on island is true and active
|
* Place players back on their island if respawn on island is true and active
|
||||||
* @param e
|
* @param e - event
|
||||||
*/
|
*/
|
||||||
@EventHandler(priority = EventPriority.HIGHEST, ignoreCancelled = true)
|
@EventHandler(priority = EventPriority.HIGHEST, ignoreCancelled = true)
|
||||||
public void onPlayerRespawn(PlayerRespawnEvent e) {
|
public void onPlayerRespawn(PlayerRespawnEvent e) {
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
/**
|
/*
|
||||||
*
|
|
||||||
*/
|
*/
|
||||||
package us.tastybento.bskyblock.listeners.flags;
|
package us.tastybento.bskyblock.listeners.flags;
|
||||||
|
|
||||||
|
@ -83,11 +83,9 @@ public class PlaceBlocksListener extends AbstractFlagListener {
|
|||||||
*/
|
*/
|
||||||
@EventHandler(priority = EventPriority.LOW, ignoreCancelled=true)
|
@EventHandler(priority = EventPriority.LOW, ignoreCancelled=true)
|
||||||
public void onBlockForm(EntityBlockFormEvent e) {
|
public void onBlockForm(EntityBlockFormEvent e) {
|
||||||
if (e.getNewState().getType().equals(Material.FROSTED_ICE)) {
|
if (e.getNewState().getType().equals(Material.FROSTED_ICE) && e.getEntity() instanceof Player) {
|
||||||
if (e.getEntity() instanceof Player) {
|
setUser(User.getInstance((Player)e.getEntity()));
|
||||||
this.setUser(User.getInstance((Player)e.getEntity()));
|
checkIsland(e, e.getBlock().getLocation(), Flags.PLACE_BLOCKS);
|
||||||
checkIsland(e, e.getBlock().getLocation(), Flags.PLACE_BLOCKS);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
/**
|
/*
|
||||||
*
|
|
||||||
*/
|
*/
|
||||||
package us.tastybento.bskyblock.listeners.flags;
|
package us.tastybento.bskyblock.listeners.flags;
|
||||||
|
|
||||||
@ -22,9 +22,11 @@ import us.tastybento.bskyblock.lists.Flags;
|
|||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
public class RemoveMobsListener extends AbstractFlagListener {
|
public class RemoveMobsListener extends AbstractFlagListener {
|
||||||
|
|
||||||
private static Set<EntityType> keepers = new HashSet<>();
|
private static Set<EntityType> keepers;
|
||||||
{
|
|
||||||
|
public RemoveMobsListener() {
|
||||||
|
keepers = new HashSet<>();
|
||||||
keepers.add(EntityType.ZOMBIE_VILLAGER);
|
keepers.add(EntityType.ZOMBIE_VILLAGER);
|
||||||
keepers.add(EntityType.PIG_ZOMBIE);
|
keepers.add(EntityType.PIG_ZOMBIE);
|
||||||
keepers.add(EntityType.WITHER);
|
keepers.add(EntityType.WITHER);
|
||||||
@ -39,11 +41,11 @@ public class RemoveMobsListener extends AbstractFlagListener {
|
|||||||
clearArea(e.getTo());
|
clearArea(e.getTo());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void clearArea(Location loc) {
|
public static void clearArea(Location loc) {
|
||||||
loc.getWorld().getNearbyEntities(loc, 5D, 5D, 5D).stream()
|
loc.getWorld().getNearbyEntities(loc, 5D, 5D, 5D).stream()
|
||||||
.filter(en -> (en instanceof Monster))
|
.filter(en -> (en instanceof Monster))
|
||||||
.filter(en -> !keepers.contains(en.getType()))
|
.filter(en -> !keepers.contains(en.getType()))
|
||||||
.forEach(Entity::remove);
|
.forEach(Entity::remove);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
/**
|
/*
|
||||||
*
|
|
||||||
*/
|
*/
|
||||||
package us.tastybento.bskyblock.listeners.flags.clicklisteners;
|
package us.tastybento.bskyblock.listeners.flags.clicklisteners;
|
||||||
|
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
/**
|
/*
|
||||||
*
|
|
||||||
*/
|
*/
|
||||||
package us.tastybento.bskyblock.listeners.flags.clicklisteners;
|
package us.tastybento.bskyblock.listeners.flags.clicklisteners;
|
||||||
|
|
||||||
|
@ -38,7 +38,7 @@ public class IslandCache {
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
islandsByLocation.put(island.getCenter(), island);
|
islandsByLocation.put(island.getCenter(), island);
|
||||||
// Make world
|
// Make world
|
||||||
islandsByUUID.putIfAbsent(island.getWorld(), new HashMap<>());
|
islandsByUUID.putIfAbsent(island.getWorld(), new HashMap<>());
|
||||||
// Only add islands to this map if they are owned
|
// Only add islands to this map if they are owned
|
||||||
if (island.getOwner() != null) {
|
if (island.getOwner() != null) {
|
||||||
@ -79,7 +79,7 @@ public class IslandCache {
|
|||||||
* @return true if successful, false if not
|
* @return true if successful, false if not
|
||||||
*/
|
*/
|
||||||
public boolean deleteIslandFromCache(Island island) {
|
public boolean deleteIslandFromCache(Island island) {
|
||||||
if (!islandsByLocation.remove(island.getCenter(), island) || !islandsByUUID.containsKey(island.getWorld())) {
|
if (!islandsByLocation.remove(island.getCenter(), island) || !islandsByUUID.containsKey(island.getWorld())) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
islandsByUUID.get(island.getWorld()).entrySet().removeIf(en -> en.getValue().equals(island));
|
islandsByUUID.get(island.getWorld()).entrySet().removeIf(en -> en.getValue().equals(island));
|
||||||
@ -179,7 +179,6 @@ public class IslandCache {
|
|||||||
// Clear ownership and members
|
// Clear ownership and members
|
||||||
island.getMembers().clear();
|
island.getMembers().clear();
|
||||||
island.setOwner(null);
|
island.setOwner(null);
|
||||||
//islandsByLocation.put(island.getCenter(), island);
|
|
||||||
} else {
|
} else {
|
||||||
// Remove player from the island membership
|
// Remove player from the island membership
|
||||||
island.removeMember(uuid);
|
island.removeMember(uuid);
|
||||||
@ -190,7 +189,7 @@ public class IslandCache {
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* Get the number of islands in the cache
|
* Get the number of islands in the cache
|
||||||
* @return the number of islands
|
* @return the number of islands
|
||||||
*/
|
*/
|
||||||
public int size() {
|
public int size() {
|
||||||
return islandsByLocation.size();
|
return islandsByLocation.size();
|
||||||
@ -205,7 +204,7 @@ public class IslandCache {
|
|||||||
island.setOwner(newOwnerUUID);
|
island.setOwner(newOwnerUUID);
|
||||||
islandsByUUID.putIfAbsent(Util.getWorld(island.getWorld()), new HashMap<>());
|
islandsByUUID.putIfAbsent(Util.getWorld(island.getWorld()), new HashMap<>());
|
||||||
islandsByUUID.get(Util.getWorld(island.getWorld())).put(newOwnerUUID, island);
|
islandsByUUID.get(Util.getWorld(island.getWorld())).put(newOwnerUUID, island);
|
||||||
islandsByLocation.put(island.getCenter(), island);
|
islandsByLocation.put(island.getCenter(), island);
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -10,12 +10,16 @@ import us.tastybento.bskyblock.api.panels.builders.PanelBuilder;
|
|||||||
import us.tastybento.bskyblock.api.panels.builders.PanelItemBuilder;
|
import us.tastybento.bskyblock.api.panels.builders.PanelItemBuilder;
|
||||||
import us.tastybento.bskyblock.api.user.User;
|
import us.tastybento.bskyblock.api.user.User;
|
||||||
|
|
||||||
|
import java.util.Comparator;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Creates settings panels
|
* Creates settings panels
|
||||||
* @author Poslovitch, tastybento
|
* @author Poslovitch, tastybento
|
||||||
*/
|
*/
|
||||||
public class SettingsPanel {
|
public class SettingsPanel {
|
||||||
|
|
||||||
|
private static final String PROTECTION_PANEL = "protection.panel.";
|
||||||
|
|
||||||
private SettingsPanel() {}
|
private SettingsPanel() {}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -26,13 +30,13 @@ public class SettingsPanel {
|
|||||||
public static void openPanel(BSkyBlock plugin, User user, Flag.Type flagType) {
|
public static void openPanel(BSkyBlock plugin, User user, Flag.Type flagType) {
|
||||||
// Create the panel
|
// Create the panel
|
||||||
PanelBuilder panelBuilder = new PanelBuilder()
|
PanelBuilder panelBuilder = new PanelBuilder()
|
||||||
.name(user.getTranslation("protection.panel." + flagType.toString() + ".title"))
|
.name(user.getTranslation(PROTECTION_PANEL + flagType.toString() + ".title"))
|
||||||
.size(54);
|
.size(54);
|
||||||
|
|
||||||
setupHeader(user, panelBuilder, flagType);
|
setupHeader(user, panelBuilder, flagType);
|
||||||
|
|
||||||
plugin.getFlagsManager().getFlags().stream().filter(f -> f.getType().equals(flagType))
|
plugin.getFlagsManager().getFlags().stream().filter(f -> f.getType().equals(flagType))
|
||||||
.sorted((e1, e2) -> e1.getID().compareTo(e2.getID())).forEach((f -> panelBuilder.item(f.toPanelItem(plugin, user))));
|
.sorted(Comparator.comparing(Flag::getID)).forEach((f -> panelBuilder.item(f.toPanelItem(plugin, user))));
|
||||||
|
|
||||||
// Show it to the player
|
// Show it to the player
|
||||||
panelBuilder.build().open(user);
|
panelBuilder.build().open(user);
|
||||||
@ -43,8 +47,8 @@ public class SettingsPanel {
|
|||||||
for (Flag.Type flagType : Flag.Type.values()) {
|
for (Flag.Type flagType : Flag.Type.values()) {
|
||||||
PanelItem panelItem = new PanelItemBuilder()
|
PanelItem panelItem = new PanelItemBuilder()
|
||||||
.icon(flagType.getIcon())
|
.icon(flagType.getIcon())
|
||||||
.name(user.getTranslation("protection.panel." + flagType.toString() + ".title"))
|
.name(user.getTranslation(PROTECTION_PANEL + flagType.toString() + ".title"))
|
||||||
.description(user.getTranslation("protection.panel." + flagType.toString() + ".description"))
|
.description(user.getTranslation(PROTECTION_PANEL + flagType.toString() + ".description"))
|
||||||
.glow(flagType.equals(currentFlagType))
|
.glow(flagType.equals(currentFlagType))
|
||||||
.clickHandler((panel, user1, clickType, slot1) -> {
|
.clickHandler((panel, user1, clickType, slot1) -> {
|
||||||
if (!flagType.equals(currentFlagType)) {
|
if (!flagType.equals(currentFlagType)) {
|
||||||
|
@ -6,7 +6,6 @@ import java.lang.reflect.Type;
|
|||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.Arrays;
|
import java.util.Arrays;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Optional;
|
|
||||||
import java.util.stream.Collectors;
|
import java.util.stream.Collectors;
|
||||||
|
|
||||||
import org.apache.commons.lang.math.NumberUtils;
|
import org.apache.commons.lang.math.NumberUtils;
|
||||||
|
Loading…
Reference in New Issue
Block a user