Codestyle

This commit is contained in:
Auxilor
2021-11-11 12:59:22 +00:00
parent ac7a47a0f7
commit 55d316cb9d
13 changed files with 46 additions and 74 deletions

View File

@@ -13,7 +13,7 @@ public final class EconomyManager {
/**
* A set of all registered integrations.
*/
private static final Set<EconomyWrapper> registered = new HashSet<>();
private static final Set<EconomyWrapper> REGISTERED = new HashSet<>();
/**
* Register a new integration.
@@ -21,7 +21,7 @@ public final class EconomyManager {
* @param integration The integration to register.
*/
public static void register(@NotNull final EconomyWrapper integration) {
registered.add(integration);
REGISTERED.add(integration);
}
/**
@@ -30,7 +30,7 @@ public final class EconomyManager {
* @return If any economy.
*/
public static boolean hasRegistrations() {
return !registered.isEmpty();
return !REGISTERED.isEmpty();
}
/**
@@ -42,7 +42,7 @@ public final class EconomyManager {
*/
public static boolean hasAmount(@NotNull final OfflinePlayer player,
final double amount) {
for (EconomyWrapper wrapper : registered) {
for (EconomyWrapper wrapper : REGISTERED) {
return wrapper.hasAmount(player, amount);
}
@@ -58,7 +58,7 @@ public final class EconomyManager {
*/
public static boolean giveMoney(@NotNull final OfflinePlayer player,
final double amount) {
for (EconomyWrapper wrapper : registered) {
for (EconomyWrapper wrapper : REGISTERED) {
return wrapper.giveMoney(player, amount);
}
@@ -74,7 +74,7 @@ public final class EconomyManager {
*/
public static boolean removeMoney(@NotNull final OfflinePlayer player,
final double amount) {
for (EconomyWrapper wrapper : registered) {
for (EconomyWrapper wrapper : REGISTERED) {
return wrapper.removeMoney(player, amount);
}
@@ -88,7 +88,7 @@ public final class EconomyManager {
* @return The balance.
*/
public static double getBalance(@NotNull final OfflinePlayer player) {
for (EconomyWrapper wrapper : registered) {
for (EconomyWrapper wrapper : REGISTERED) {
return wrapper.getBalance(player);
}

View File

@@ -14,7 +14,7 @@ public final class HologramManager {
/**
* A set of all registered integrations.
*/
private static final Set<HologramWrapper> registered = new HashSet<>();
private static final Set<HologramWrapper> REGISTERED = new HashSet<>();
/**
* Register a new integration.
@@ -22,7 +22,7 @@ public final class HologramManager {
* @param integration The integration to register.
*/
public static void register(@NotNull final HologramWrapper integration) {
registered.add(integration);
REGISTERED.add(integration);
}
/**
@@ -34,7 +34,7 @@ public final class HologramManager {
*/
public static Hologram createHologram(@NotNull final Location location,
@NotNull final List<String> contents) {
for (HologramWrapper wrapper : registered) {
for (HologramWrapper wrapper : REGISTERED) {
return wrapper.createHologram(location, contents);
}

View File

@@ -14,7 +14,7 @@ public final class McmmoManager {
/**
* A set of all registered integrations.
*/
private static final Set<McmmoWrapper> registered = new HashSet<>();
private static final Set<McmmoWrapper> REGISTERED = new HashSet<>();
/**
* Register a new integration.
@@ -22,7 +22,7 @@ public final class McmmoManager {
* @param integration The integration to register.
*/
public static void register(@NotNull final McmmoWrapper integration) {
registered.add(integration);
REGISTERED.add(integration);
}
/**
@@ -32,7 +32,7 @@ public final class McmmoManager {
* @return The bonus drop count.
*/
public static int getBonusDropCount(@NotNull final Block block) {
for (McmmoWrapper mcmmoWrapper : registered) {
for (McmmoWrapper mcmmoWrapper : REGISTERED) {
return mcmmoWrapper.getBonusDropCount(block);
}
return 0;
@@ -45,7 +45,7 @@ public final class McmmoManager {
* @return If the event is fake.
*/
public static boolean isFake(@NotNull final Event event) {
for (McmmoWrapper mcmmoWrapper : registered) {
for (McmmoWrapper mcmmoWrapper : REGISTERED) {
return mcmmoWrapper.isFake(event);
}
return false;

View File

@@ -12,7 +12,7 @@ public final class ShopManager {
/**
* A set of all registered integrations.
*/
private static final Set<ShopWrapper> registered = new HashSet<>();
private static final Set<ShopWrapper> REGISTERED = new HashSet<>();
/**
* Register a new integration.
@@ -20,14 +20,14 @@ public final class ShopManager {
* @param integration The integration to register.
*/
public static void register(@NotNull final ShopWrapper integration) {
registered.add(integration);
REGISTERED.add(integration);
}
/**
* Register eco item provider for shop plugins.
*/
public static void registerEcoProvider() {
for (ShopWrapper shopWrapper : registered) {
for (ShopWrapper shopWrapper : REGISTERED) {
shopWrapper.registerEcoProvider();
}
}

View File

@@ -91,7 +91,7 @@ public class Paste {
conn.setRequestMethod("GET");
try (var reader = new BufferedReader(
new InputStreamReader(conn.getInputStream()))) {
for (String line; (line = reader.readLine()) != null; ) {
for (String line; (line = reader.readLine()) != null;) {
result.append(line);
}
}

View File

@@ -15,7 +15,7 @@ import org.bukkit.entity.Player;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
import java.awt.*;
import java.awt.Color;
import java.util.ArrayList;
import java.util.Collection;
import java.util.List;
@@ -24,8 +24,6 @@ import java.util.regex.Matcher;
import java.util.regex.Pattern;
import java.util.stream.Collectors;
import static net.md_5.bungee.api.ChatColor.*;
/**
* Utilities / API methods for strings.
*/
@@ -65,16 +63,16 @@ public final class StringUtils {
* Color map.
*/
private static final Map<String, ChatColor> COLOR_MAP = new ImmutableMap.Builder<String, ChatColor>()
.put("&l", BOLD)
.put("&o", ITALIC)
.put("&n", UNDERLINE)
.put("&m", STRIKETHROUGH)
.put("&k", MAGIC)
.put("§l", BOLD)
.put("§o", ITALIC)
.put("§n", UNDERLINE)
.put("§m", STRIKETHROUGH)
.put("§k", MAGIC)
.put("&l", ChatColor.BOLD)
.put("&o", ChatColor.ITALIC)
.put("&n", ChatColor.UNDERLINE)
.put("&m", ChatColor.STRIKETHROUGH)
.put("&k", ChatColor.MAGIC)
.put("§l", ChatColor.BOLD)
.put("§o", ChatColor.ITALIC)
.put("§n", ChatColor.UNDERLINE)
.put("§m", ChatColor.STRIKETHROUGH)
.put("§k", ChatColor.MAGIC)
.build();
/**
@@ -295,10 +293,10 @@ public final class StringUtils {
StringBuilder builder = new StringBuilder(message.length() + 4 * 8);
while (matcher.find()) {
String group = matcher.group(1);
matcher.appendReplacement(builder, COLOR_CHAR + "x"
+ COLOR_CHAR + group.charAt(0) + COLOR_CHAR + group.charAt(1)
+ COLOR_CHAR + group.charAt(2) + COLOR_CHAR + group.charAt(3)
+ COLOR_CHAR + group.charAt(4) + COLOR_CHAR + group.charAt(5));
matcher.appendReplacement(builder, ChatColor.COLOR_CHAR + "x"
+ ChatColor.COLOR_CHAR + group.charAt(0) + ChatColor.COLOR_CHAR + group.charAt(1)
+ ChatColor.COLOR_CHAR + group.charAt(2) + ChatColor.COLOR_CHAR + group.charAt(3)
+ ChatColor.COLOR_CHAR + group.charAt(4) + ChatColor.COLOR_CHAR + group.charAt(5));
}
return matcher.appendTail(builder).toString();

View File

@@ -12,6 +12,7 @@ import org.jetbrains.annotations.NotNull;
import java.util.HashMap;
import java.util.Map;
import java.util.Objects;
import java.util.stream.Collectors;
/**
@@ -31,7 +32,7 @@ public final class TeamUtils {
/**
* The server scoreboard.
*/
private static final Scoreboard SCOREBOARD = Bukkit.getScoreboardManager().getMainScoreboard();
private static final Scoreboard SCOREBOARD = Objects.requireNonNull(Bukkit.getScoreboardManager()).getMainScoreboard();
/**
* Get team from {@link ChatColor}.