mirror of
https://github.com/BentoBoxWorld/BentoBox.git
synced 2025-02-02 13:31:47 +01:00
Fixed some code smells (Sonarcloud)
This commit is contained in:
parent
eeeccf6781
commit
704c249b49
@ -30,12 +30,6 @@ public class IslandTeamCommand extends CompositeCommand {
|
||||
*/
|
||||
private Map<UUID, Invite> inviteMap;
|
||||
|
||||
/**
|
||||
* Contains the text variable for units.
|
||||
* @since 1.9.0
|
||||
*/
|
||||
private final String UNIT = "[unit]";
|
||||
|
||||
private IslandTeamInviteCommand inviteCommand;
|
||||
|
||||
public IslandTeamCommand(CompositeCommand parent) {
|
||||
@ -143,15 +137,15 @@ public class IslandTeamCommand extends CompositeCommand {
|
||||
if (duration.toMinutes() < 60L) {
|
||||
lastSeen = user.getTranslation(reference,
|
||||
TextVariables.NUMBER, String.valueOf(duration.toMinutes()),
|
||||
UNIT, user.getTranslation("commands.island.team.info.last-seen.minutes"));
|
||||
TextVariables.UNIT, user.getTranslation("commands.island.team.info.last-seen.minutes"));
|
||||
} else if (duration.toHours() < 24L) {
|
||||
lastSeen = user.getTranslation(reference,
|
||||
TextVariables.NUMBER, String.valueOf(duration.toHours()),
|
||||
UNIT, user.getTranslation("commands.island.team.info.last-seen.hours"));
|
||||
TextVariables.UNIT, user.getTranslation("commands.island.team.info.last-seen.hours"));
|
||||
} else {
|
||||
lastSeen = user.getTranslation(reference,
|
||||
TextVariables.NUMBER, String.valueOf(duration.toDays()),
|
||||
UNIT, user.getTranslation("commands.island.team.info.last-seen.days"));
|
||||
TextVariables.UNIT, user.getTranslation("commands.island.team.info.last-seen.days"));
|
||||
}
|
||||
|
||||
user.sendMessage("commands.island.team.info.member-layout.offline",
|
||||
|
@ -21,4 +21,8 @@ public class TextVariables {
|
||||
* @since 1.6.0
|
||||
*/
|
||||
public static final String NEXT = "[next]";
|
||||
/**
|
||||
* @since 1.10.0
|
||||
*/
|
||||
public static final String UNIT = "[unit]";
|
||||
}
|
||||
|
@ -42,10 +42,10 @@ public class ItemStackTypeAdapter extends TypeAdapter<ItemStack> {
|
||||
}
|
||||
YamlConfiguration c = new YamlConfiguration();
|
||||
String n = reader.nextString();
|
||||
// Verify material type because yaml loading errors of unknown materials cannot be trapped bu try clause.
|
||||
// Verify material type because yaml loading errors of unknown materials cannot be trapped by try clause.
|
||||
if (n.contains("type:")) {
|
||||
String type = n.substring(n.indexOf("type:") + 6, n.length());
|
||||
type = type.substring(0, type.indexOf("\n"));
|
||||
String type = n.substring(n.indexOf("type:") + 6);
|
||||
type = type.substring(0, type.indexOf('\n'));
|
||||
Material m = Material.matchMaterial(type);
|
||||
if (m == null) {
|
||||
BentoBox.getInstance().logWarning("Unknown material: " + type);
|
||||
|
@ -302,7 +302,7 @@ public class LocalesManager {
|
||||
user.sendRawMessage(ChatColor.AQUA + SPACER);
|
||||
loadLocalesFromFile(BENTOBOX);
|
||||
if (languages.containsKey(Locale.US)) {
|
||||
analyze(user, fix);
|
||||
analyze(user);
|
||||
} else {
|
||||
user.sendRawMessage(ChatColor.RED + "No US English in BentoBox to use for analysis!");
|
||||
}
|
||||
@ -314,7 +314,7 @@ public class LocalesManager {
|
||||
languages.clear();
|
||||
loadLocalesFromFile(addon.getDescription().getName());
|
||||
if (languages.containsKey(Locale.US)) {
|
||||
analyze(user, fix);
|
||||
analyze(user);
|
||||
} else {
|
||||
user.sendRawMessage(ChatColor.RED + "No US English to use for analysis!");
|
||||
}
|
||||
@ -325,11 +325,9 @@ public class LocalesManager {
|
||||
/**
|
||||
*
|
||||
* @param user - user
|
||||
* @param fix whether or not locale files with missing translations should be fixed.
|
||||
* Not currently supported.
|
||||
* @since 1.5.0
|
||||
*/
|
||||
private void analyze(User user, boolean fix) {
|
||||
private void analyze(User user) {
|
||||
|
||||
user.sendRawMessage(ChatColor.GREEN + "The following locales are supported:");
|
||||
languages.forEach((k,v) -> user.sendRawMessage(ChatColor.GOLD + k.toLanguageTag() + " " + k.getDisplayLanguage() + " " + k.getDisplayCountry()));
|
||||
|
@ -32,7 +32,6 @@ public class PlayersManager {
|
||||
private Map<UUID, Players> playerCache;
|
||||
private Set<UUID> inTeleport;
|
||||
private Set<UUID> toSave = new HashSet<>();
|
||||
private Iterator<UUID> it;
|
||||
private BukkitTask task;
|
||||
|
||||
/**
|
||||
@ -84,7 +83,7 @@ public class PlayersManager {
|
||||
if (!toSave.isEmpty()) return;
|
||||
// Get a list of ID's to save
|
||||
toSave = new HashSet<>(playerCache.keySet());
|
||||
it = toSave.iterator();
|
||||
Iterator<UUID> it = toSave.iterator();
|
||||
task = Bukkit.getScheduler().runTaskTimer(plugin, () -> {
|
||||
if (plugin.isEnabled() && it.hasNext()) {
|
||||
this.save(it.next());
|
||||
|
@ -35,7 +35,6 @@ class IslandGrid {
|
||||
Island clone = new Island(firstLoaded);
|
||||
firstLoaded = new Island(island);
|
||||
zEntry.put(island.getMinZ(), firstLoaded);
|
||||
island = new Island(clone);
|
||||
} else if (firstLoaded.getOwner() != null && island.getOwner() != null) {
|
||||
// Check if the owners are the same - this is a true duplicate
|
||||
if (firstLoaded.getOwner().equals(island.getOwner())) {
|
||||
@ -46,7 +45,6 @@ class IslandGrid {
|
||||
Island clone = new Island(firstLoaded);
|
||||
firstLoaded = new Island(island);
|
||||
zEntry.put(island.getMinZ(), firstLoaded);
|
||||
island = new Island(clone);
|
||||
} else {
|
||||
plugin.logError("Same owner duplicate.");
|
||||
}
|
||||
|
@ -11,8 +11,6 @@ import java.util.jar.JarEntry;
|
||||
import java.util.jar.JarFile;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
import javax.annotation.Nonnull;
|
||||
|
||||
import org.apache.commons.lang.Validate;
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.ChatColor;
|
||||
@ -372,8 +370,8 @@ public class Util {
|
||||
* @param location The Location to Teleport to
|
||||
* @return Future that completes with the result of the teleport
|
||||
*/
|
||||
@Nonnull
|
||||
public static CompletableFuture<Boolean> teleportAsync(@Nonnull Entity entity, @Nonnull Location location) {
|
||||
@NonNull
|
||||
public static CompletableFuture<Boolean> teleportAsync(@NonNull Entity entity, @NonNull Location location) {
|
||||
return PaperLib.teleportAsync(entity, location);
|
||||
}
|
||||
|
||||
@ -384,8 +382,8 @@ public class Util {
|
||||
* @param cause The cause for the teleportation
|
||||
* @return Future that completes with the result of the teleport
|
||||
*/
|
||||
@Nonnull
|
||||
public static CompletableFuture<Boolean> teleportAsync(@Nonnull Entity entity, @Nonnull Location location, TeleportCause cause) {
|
||||
@NonNull
|
||||
public static CompletableFuture<Boolean> teleportAsync(@NonNull Entity entity, @NonNull Location location, TeleportCause cause) {
|
||||
return PaperLib.teleportAsync(entity, location, cause);
|
||||
}
|
||||
|
||||
@ -394,8 +392,8 @@ public class Util {
|
||||
* @param loc Location to get chunk for
|
||||
* @return Future that completes with the chunk
|
||||
*/
|
||||
@Nonnull
|
||||
public static CompletableFuture<Chunk> getChunkAtAsync(@Nonnull Location loc) {
|
||||
@NonNull
|
||||
public static CompletableFuture<Chunk> getChunkAtAsync(@NonNull Location loc) {
|
||||
return getChunkAtAsync(loc.getWorld(), loc.getBlockX() >> 4, loc.getBlockZ() >> 4, true);
|
||||
}
|
||||
|
||||
@ -405,8 +403,8 @@ public class Util {
|
||||
* @param gen Should the chunk generate or not. Only respected on some MC versions, 1.13 for CB, 1.12 for Paper
|
||||
* @return Future that completes with the chunk, or null if the chunk did not exists and generation was not requested.
|
||||
*/
|
||||
@Nonnull
|
||||
public static CompletableFuture<Chunk> getChunkAtAsync(@Nonnull Location loc, boolean gen) {
|
||||
@NonNull
|
||||
public static CompletableFuture<Chunk> getChunkAtAsync(@NonNull Location loc, boolean gen) {
|
||||
return getChunkAtAsync(loc.getWorld(), loc.getBlockX() >> 4, loc.getBlockZ() >> 4, gen);
|
||||
}
|
||||
|
||||
@ -417,8 +415,8 @@ public class Util {
|
||||
* @param z Z coordinate of the chunk to load
|
||||
* @return Future that completes with the chunk
|
||||
*/
|
||||
@Nonnull
|
||||
public static CompletableFuture<Chunk> getChunkAtAsync(@Nonnull World world, int x, int z) {
|
||||
@NonNull
|
||||
public static CompletableFuture<Chunk> getChunkAtAsync(@NonNull World world, int x, int z) {
|
||||
return getChunkAtAsync(world, x, z, true);
|
||||
}
|
||||
|
||||
@ -430,8 +428,8 @@ public class Util {
|
||||
* @param gen Should the chunk generate or not. Only respected on some MC versions, 1.13 for CB, 1.12 for Paper
|
||||
* @return Future that completes with the chunk, or null if the chunk did not exists and generation was not requested.
|
||||
*/
|
||||
@Nonnull
|
||||
public static CompletableFuture<Chunk> getChunkAtAsync(@Nonnull World world, int x, int z, boolean gen) {
|
||||
@NonNull
|
||||
public static CompletableFuture<Chunk> getChunkAtAsync(@NonNull World world, int x, int z, boolean gen) {
|
||||
return PaperLib.getChunkAtAsync(world, x, z, gen);
|
||||
}
|
||||
|
||||
@ -440,7 +438,7 @@ public class Util {
|
||||
* @param loc Location to check if the chunk is generated
|
||||
* @return If the chunk is generated or not
|
||||
*/
|
||||
public static boolean isChunkGenerated(@Nonnull Location loc) {
|
||||
public static boolean isChunkGenerated(@NonNull Location loc) {
|
||||
return isChunkGenerated(loc.getWorld(), loc.getBlockX() >> 4, loc.getBlockZ() >> 4);
|
||||
}
|
||||
|
||||
@ -451,7 +449,7 @@ public class Util {
|
||||
* @param z Z coordinate of the chunk to checl
|
||||
* @return If the chunk is generated or not
|
||||
*/
|
||||
public static boolean isChunkGenerated(@Nonnull World world, int x, int z) {
|
||||
public static boolean isChunkGenerated(@NonNull World world, int x, int z) {
|
||||
return PaperLib.isChunkGenerated(world, x, z);
|
||||
}
|
||||
|
||||
@ -461,8 +459,8 @@ public class Util {
|
||||
* @param useSnapshot Whether or not to use a snapshot when supported
|
||||
* @return The BlockState
|
||||
*/
|
||||
@Nonnull
|
||||
public static BlockStateSnapshotResult getBlockState(@Nonnull Block block, boolean useSnapshot) {
|
||||
@NonNull
|
||||
public static BlockStateSnapshotResult getBlockState(@NonNull Block block, boolean useSnapshot) {
|
||||
return PaperLib.getBlockState(block, useSnapshot);
|
||||
}
|
||||
|
||||
@ -544,9 +542,6 @@ public class Util {
|
||||
// Original code from Jonas Klemming on StackOverflow (https://stackoverflow.com/q/237159).
|
||||
// I slightly refined it to catch more edge cases.
|
||||
// It is a faster alternative to catch malformed strings than the NumberFormatException.
|
||||
if (nbr == null) {
|
||||
return false;
|
||||
}
|
||||
int length = nbr.length();
|
||||
if (length == 0) {
|
||||
return false;
|
||||
@ -572,7 +567,6 @@ public class Util {
|
||||
} else {
|
||||
// we will need to make sure there is nothing else but 0's after the dot.
|
||||
trailingDot = true;
|
||||
continue;
|
||||
}
|
||||
} else if (!trailingDot && (c < '0' || c > '9')) {
|
||||
return false;
|
||||
|
Loading…
Reference in New Issue
Block a user