mirror of
https://github.com/BentoBoxWorld/BentoBox.git
synced 2024-11-24 11:45:31 +01:00
Removed code smells.
This commit is contained in:
parent
de85f85bbe
commit
cccbf2d270
@ -19,6 +19,7 @@ import us.tastybento.bskyblock.managers.island.NewIsland;
|
|||||||
|
|
||||||
public class IslandResetCommand extends CompositeCommand {
|
public class IslandResetCommand extends CompositeCommand {
|
||||||
|
|
||||||
|
private static final String SECONDS_PLACEHOLDER = "[seconds]";
|
||||||
private Map<UUID, Long> cooldown;
|
private Map<UUID, Long> cooldown;
|
||||||
private Map<UUID, Long> confirm;
|
private Map<UUID, Long> confirm;
|
||||||
|
|
||||||
@ -39,7 +40,7 @@ public class IslandResetCommand extends CompositeCommand {
|
|||||||
public boolean execute(User user, List<String> args) {
|
public boolean execute(User user, List<String> args) {
|
||||||
// Check cooldown
|
// Check cooldown
|
||||||
if (getSettings().getResetWait() > 0 && onRestartWaitTime(user) > 0 && !user.isOp()) {
|
if (getSettings().getResetWait() > 0 && onRestartWaitTime(user) > 0 && !user.isOp()) {
|
||||||
user.sendMessage("general.errors.you-must-wait", "[seconds]", String.valueOf(onRestartWaitTime(user)));
|
user.sendMessage("general.errors.you-must-wait", SECONDS_PLACEHOLDER, String.valueOf(onRestartWaitTime(user)));
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
if (!getIslands().hasIsland(user.getUniqueId())) {
|
if (!getIslands().hasIsland(user.getUniqueId())) {
|
||||||
@ -80,13 +81,13 @@ public class IslandResetCommand extends CompositeCommand {
|
|||||||
} else {
|
} else {
|
||||||
// Show how many seconds left to confirm
|
// Show how many seconds left to confirm
|
||||||
int time = (int)((confirm.get(user.getUniqueId()) - System.currentTimeMillis()) / 1000D);
|
int time = (int)((confirm.get(user.getUniqueId()) - System.currentTimeMillis()) / 1000D);
|
||||||
user.sendMessage("commands.island.reset.confirm", "[label]", Constants.ISLANDCOMMAND, "[seconds]", String.valueOf(time));
|
user.sendMessage("commands.island.reset.confirm", "[label]", Constants.ISLANDCOMMAND, "SECONDS_PLACEHOLDER", String.valueOf(time));
|
||||||
}
|
}
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
private void requestConfirmation(User user) {
|
private void requestConfirmation(User user) {
|
||||||
user.sendMessage("commands.island.reset.confirm", "[label]", Constants.ISLANDCOMMAND, "[seconds]", String.valueOf(getSettings().getConfirmationTime()));
|
user.sendMessage("commands.island.reset.confirm", "[label]", Constants.ISLANDCOMMAND, "SECONDS_PLACEHOLDER", String.valueOf(getSettings().getConfirmationTime()));
|
||||||
// Require confirmation
|
// Require confirmation
|
||||||
confirm.put(user.getUniqueId(), System.currentTimeMillis() + getSettings().getConfirmationTime() * 1000L);
|
confirm.put(user.getUniqueId(), System.currentTimeMillis() + getSettings().getConfirmationTime() * 1000L);
|
||||||
Bukkit.getScheduler().runTaskLater(getPlugin(), () -> {
|
Bukkit.getScheduler().runTaskLater(getPlugin(), () -> {
|
||||||
|
@ -37,6 +37,8 @@ public class IslandBuilder {
|
|||||||
END
|
END
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private static final String PLAYER_PLACEHOLDER = "[player]";
|
||||||
|
|
||||||
private Island island;
|
private Island island;
|
||||||
private World world;
|
private World world;
|
||||||
private IslandType type = IslandType.ISLAND;
|
private IslandType type = IslandType.ISLAND;
|
||||||
@ -460,10 +462,10 @@ public class IslandBuilder {
|
|||||||
User user = User.getInstance(playerUUID);
|
User user = User.getInstance(playerUUID);
|
||||||
|
|
||||||
// Sets the lines of the sign
|
// Sets the lines of the sign
|
||||||
sign.setLine(0, user.getTranslation("new-island.sign.line0", "[player]", playerName));
|
sign.setLine(0, user.getTranslation("new-island.sign.line0", PLAYER_PLACEHOLDER, playerName));
|
||||||
sign.setLine(1, user.getTranslation("new-island.sign.line1", "[player]", playerName));
|
sign.setLine(1, user.getTranslation("new-island.sign.line1", PLAYER_PLACEHOLDER, playerName));
|
||||||
sign.setLine(2, user.getTranslation("new-island.sign.line2", "[player]", playerName));
|
sign.setLine(2, user.getTranslation("new-island.sign.line2", PLAYER_PLACEHOLDER, playerName));
|
||||||
sign.setLine(3, user.getTranslation("new-island.sign.line3", "[player]", playerName));
|
sign.setLine(3, user.getTranslation("new-island.sign.line3", PLAYER_PLACEHOLDER, playerName));
|
||||||
|
|
||||||
((org.bukkit.material.Sign) sign.getData()).setFacingDirection(BlockFace.NORTH);
|
((org.bukkit.material.Sign) sign.getData()).setFacingDirection(BlockFace.NORTH);
|
||||||
sign.update();
|
sign.update();
|
||||||
|
@ -105,13 +105,18 @@ public class LockAndBanListener implements Listener {
|
|||||||
* @return CheckResult LOCKED, BANNED or OPEN. If an island is locked, that will take priority over banned
|
* @return CheckResult LOCKED, BANNED or OPEN. If an island is locked, that will take priority over banned
|
||||||
*/
|
*/
|
||||||
private CheckResult check(Player player, Location loc) {
|
private CheckResult check(Player player, Location loc) {
|
||||||
|
|
||||||
// See if the island is locked to non-members or player is banned
|
// See if the island is locked to non-members or player is banned
|
||||||
return im.getProtectedIslandAt(loc)
|
return im.getProtectedIslandAt(loc)
|
||||||
.map(is -> !is.isAllowed(User.getInstance(player), Flags.LOCK) ? CheckResult.LOCKED
|
.map(is -> {
|
||||||
: is.isBanned(player.getUniqueId()) ? CheckResult.BANNED
|
if (is.isBanned(player.getUniqueId())) {
|
||||||
: CheckResult.OPEN)
|
return CheckResult.BANNED;
|
||||||
.orElse(CheckResult.OPEN);
|
}
|
||||||
|
if (!is.isAllowed(User.getInstance(player), Flags.LOCK)) {
|
||||||
|
return CheckResult.LOCKED;
|
||||||
|
}
|
||||||
|
return CheckResult.OPEN;
|
||||||
|
}).orElse(CheckResult.OPEN);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -53,14 +53,12 @@ public class LocalesManager {
|
|||||||
/**
|
/**
|
||||||
* Loads all the locales available. If the locale folder does not exist, one will be created and
|
* Loads all the locales available. If the locale folder does not exist, one will be created and
|
||||||
* filled with locale files from the jar.
|
* filled with locale files from the jar.
|
||||||
* TODO: Make more robust. The file filter is fragile.
|
|
||||||
*/
|
*/
|
||||||
public void loadLocales(String parent) {
|
public void loadLocales(String parent) {
|
||||||
// Describe the filter - we only want files that are correctly named
|
// Describe the filter - we only want files that are correctly named
|
||||||
FilenameFilter ymlFilter = (dir, name) -> {
|
// Files must be 9 chars long
|
||||||
// Files must be 9 chars long
|
FilenameFilter ymlFilter = (dir, name) -> name.toLowerCase().endsWith(".yml") && name.length() == 9;
|
||||||
return name.toLowerCase().endsWith(".yml") && name.length() == 9;
|
|
||||||
};
|
|
||||||
|
|
||||||
// Run through the files and store the locales
|
// Run through the files and store the locales
|
||||||
File localeDir = new File(plugin.getDataFolder(), LOCALE_FOLDER + File.separator + parent);
|
File localeDir = new File(plugin.getDataFolder(), LOCALE_FOLDER + File.separator + parent);
|
||||||
|
@ -11,6 +11,8 @@ import us.tastybento.bskyblock.api.user.User;
|
|||||||
* @author Poslovitch
|
* @author Poslovitch
|
||||||
*/
|
*/
|
||||||
public class LanguagePanel {
|
public class LanguagePanel {
|
||||||
|
|
||||||
|
private LanguagePanel() {}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Dynamically creates the panel.
|
* Dynamically creates the panel.
|
||||||
|
Loading…
Reference in New Issue
Block a user