mirror of
https://github.com/BentoBoxWorld/BentoBox.git
synced 2024-11-28 13:45:14 +01:00
Fixed some code smells
This commit is contained in:
parent
28cf3ca278
commit
16e864f495
@ -96,7 +96,7 @@ public class Settings implements DataObject {
|
||||
|
||||
@ConfigComment("Allow FTB Autonomous Activator to work (will allow a pseudo player [CoFH] to place and break blocks and hang items)")
|
||||
@ConfigComment("Add other fake player names here if required")
|
||||
@ConfigEntry(path = "general.fakeplayers")
|
||||
@ConfigEntry(path = "general.fakeplayers", experimental = true)
|
||||
private Set<String> fakePlayers = new HashSet<>();
|
||||
|
||||
@ConfigComment("Allow obsidian to be scooped up with an empty bucket back into lava")
|
||||
|
@ -59,10 +59,11 @@ public class DefaultHelpCommand extends CompositeCommand {
|
||||
if (depth < MAX_DEPTH) {
|
||||
if (!parent.getLabel().equals(HELP)) {
|
||||
|
||||
|
||||
// Get elements
|
||||
String usage = parent.getUsage().isEmpty() ? "" : user.getTranslation(parent.getUsage());
|
||||
String params = getParameters().isEmpty() ? "" : user.getTranslation(getParameters());
|
||||
String desc = getDescription().isEmpty() ? "" : user.getTranslation(getDescription());
|
||||
String usage = user.getTranslationOrNothing(parent.getUsage());
|
||||
String params = user.getTranslationOrNothing(getParameters());
|
||||
String desc = user.getTranslationOrNothing(getDescription());
|
||||
|
||||
if (showPrettyHelp(user, usage, params, desc)) {
|
||||
// No more to show
|
||||
|
@ -34,7 +34,7 @@ public class AdminClearResetsAllCommand extends CompositeCommand {
|
||||
Bukkit.getOnlinePlayers().stream().map(Player::getUniqueId).filter(getPlayers()::isKnown).forEach(u -> getPlayers().setResets(getWorld(), u, 0));
|
||||
user.sendMessage("general.success");
|
||||
});
|
||||
return false;
|
||||
return true;
|
||||
}
|
||||
|
||||
}
|
@ -47,6 +47,9 @@ public class AdminRangeDisplayCommand extends CompositeCommand {
|
||||
case "hide":
|
||||
user.sendMessage("commands.admin.range.display.already-off");
|
||||
break;
|
||||
default:
|
||||
showHelp(this, user);
|
||||
break;
|
||||
}
|
||||
} else {
|
||||
switch (label) {
|
||||
@ -57,6 +60,9 @@ public class AdminRangeDisplayCommand extends CompositeCommand {
|
||||
case "show":
|
||||
user.sendMessage("commands.admin.range.display.already-on");
|
||||
break;
|
||||
default:
|
||||
showHelp(this, user);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -47,7 +47,7 @@ public class AdminRangeSetCommand extends CompositeCommand {
|
||||
user.sendMessage("commands.admin.range.set.invalid-value.not-numeric", TextVariables.NUMBER, args.get(1));
|
||||
return false;
|
||||
}
|
||||
int range = Integer.valueOf(args.get(1));
|
||||
int range = Integer.parseInt(args.get(1));
|
||||
|
||||
// Get island
|
||||
Island island = getIslands().getIsland(getWorld(), targetUUID);
|
||||
|
@ -33,7 +33,7 @@ public class IslandGoCommand extends CompositeCommand {
|
||||
return false;
|
||||
}
|
||||
if (!args.isEmpty() && NumberUtils.isDigits(args.get(0))) {
|
||||
int homeValue = Integer.valueOf(args.get(0));
|
||||
int homeValue = Integer.parseInt(args.get(0));
|
||||
int maxHomes = Util.getPermValue(user.getPlayer(), "island.maxhomes", getIWM().getMaxHomes(getWorld()));
|
||||
if (homeValue > 1 && homeValue <= maxHomes) {
|
||||
getIslands().homeTeleport(getWorld(), user.getPlayer(), homeValue);
|
||||
|
@ -74,13 +74,9 @@ public class IslandTeamKickCommand extends CompositeCommand {
|
||||
user.sendMessage("general.success");
|
||||
|
||||
// Add cooldown for this player and target
|
||||
if (getSettings().getInviteWait() > 0) {
|
||||
if (getSettings().getInviteWait() > 0 && getParent() != null) {
|
||||
// Get the invite class from the parent
|
||||
if (getParent() != null) {
|
||||
getParent().getSubCommand("invite").ifPresent(c -> c.setCooldown(user.getUniqueId(), targetUUID, getSettings().getInviteWait() * 60));
|
||||
}
|
||||
|
||||
getParent().getSubCommand("invite").ifPresent(c -> c.setCooldown(user.getUniqueId(), targetUUID, getSettings().getInviteWait() * 60));
|
||||
}
|
||||
}
|
||||
|
||||
}
|
@ -119,7 +119,9 @@ public class FlatFileDatabaseHandler<T> extends AbstractDatabaseHandler<T> {
|
||||
|
||||
// Information about the field
|
||||
String storageLocation = field.getName();
|
||||
boolean overrideOnChange, experimental, needsReset = false;
|
||||
boolean overrideOnChange = false;
|
||||
boolean experimental = false;
|
||||
boolean needsReset = false;
|
||||
|
||||
// Check if there is an annotation on the field
|
||||
ConfigEntry configEntry = field.getAnnotation(ConfigEntry.class);
|
||||
|
@ -21,6 +21,7 @@ import com.google.gson.annotations.Expose;
|
||||
import world.bentobox.bentobox.BentoBox;
|
||||
import world.bentobox.bentobox.api.configuration.WorldSettings;
|
||||
import world.bentobox.bentobox.api.flags.Flag;
|
||||
import world.bentobox.bentobox.api.localization.TextVariables;
|
||||
import world.bentobox.bentobox.api.user.User;
|
||||
import world.bentobox.bentobox.database.objects.adapters.Adapter;
|
||||
import world.bentobox.bentobox.database.objects.adapters.FlagSerializer;
|
||||
@ -623,7 +624,7 @@ public class Island implements DataObject {
|
||||
Set<UUID> banned = getBanned();
|
||||
if (!banned.isEmpty()) {
|
||||
user.sendMessage("commands.admin.info.banned-players");
|
||||
banned.forEach(u -> user.sendMessage("commands.admin.info.banned-format", "[name]", plugin.getPlayers().getName(u)));
|
||||
banned.forEach(u -> user.sendMessage("commands.admin.info.banned-format", TextVariables.NAME, plugin.getPlayers().getName(u)));
|
||||
}
|
||||
return true;
|
||||
}
|
||||
@ -639,10 +640,10 @@ public class Island implements DataObject {
|
||||
user.sendMessage("commands.admin.info.team-members-title");
|
||||
members.forEach((u, i) -> {
|
||||
if (owner.equals(u)) {
|
||||
user.sendMessage("commands.admin.info.team-owner-format", "[name]", plugin.getPlayers().getName(u)
|
||||
user.sendMessage("commands.admin.info.team-owner-format", TextVariables.NAME, plugin.getPlayers().getName(u)
|
||||
, "[rank]", user.getTranslation(plugin.getRanksManager().getRank(i)));
|
||||
} else if (i > RanksManager.VISITOR_RANK){
|
||||
user.sendMessage("commands.admin.info.team-member-format", "[name]", plugin.getPlayers().getName(u)
|
||||
user.sendMessage("commands.admin.info.team-member-format", TextVariables.NAME, plugin.getPlayers().getName(u)
|
||||
, "[rank]", user.getTranslation(plugin.getRanksManager().getRank(i)));
|
||||
}
|
||||
});
|
||||
|
@ -24,6 +24,7 @@ import org.bukkit.inventory.ItemStack;
|
||||
import org.bukkit.util.Vector;
|
||||
|
||||
import world.bentobox.bentobox.BentoBox;
|
||||
import world.bentobox.bentobox.api.localization.TextVariables;
|
||||
import world.bentobox.bentobox.api.user.User;
|
||||
import world.bentobox.bentobox.database.Database;
|
||||
import world.bentobox.bentobox.database.objects.Island;
|
||||
@ -550,7 +551,7 @@ public class IslandsManager {
|
||||
if (number == 1) {
|
||||
user.sendMessage("commands.island.go.teleport");
|
||||
} else {
|
||||
user.sendMessage("commands.island.go.teleported", "[number]", String.valueOf(number));
|
||||
user.sendMessage("commands.island.go.teleported", TextVariables.NUMBER, String.valueOf(number));
|
||||
}
|
||||
// Exit spectator mode if in it
|
||||
if (player.getGameMode().equals(GameMode.SPECTATOR)) {
|
||||
@ -769,7 +770,6 @@ public class IslandsManager {
|
||||
return getMembers(world, playerUUID).size() > 1;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Makes a new leader for an island
|
||||
* @param world - world
|
||||
@ -799,8 +799,8 @@ public class IslandsManager {
|
||||
int range = Util.getPermValue(target.getPlayer(), permPrefix + "island.range.", plugin.getIWM().getIslandProtectionRange(Util.getWorld(island.getWorld())));
|
||||
// Range can go up or down
|
||||
if (range != island.getProtectionRange()) {
|
||||
user.sendMessage("commands.admin.setrange.range-updated", "[number]", String.valueOf(range));
|
||||
target.sendMessage("commands.admin.setrange.range-updated", "[number]", String.valueOf(range));
|
||||
user.sendMessage("commands.admin.setrange.range-updated", TextVariables.NUMBER, String.valueOf(range));
|
||||
target.sendMessage("commands.admin.setrange.range-updated", TextVariables.NUMBER, String.valueOf(range));
|
||||
plugin.log("Makeleader: Island protection range changed from " + island.getProtectionRange() + " to "
|
||||
+ range + " for " + user.getName() + " due to permission.");
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user