Added private constructors to utility classes

This commit is contained in:
Intelli 2021-07-26 17:20:33 -06:00
parent a7eb6a48c9
commit f6f9c27f08
33 changed files with 130 additions and 7 deletions

View file

@ -18,8 +18,8 @@ public final class Chat {
public static final String COMPONENT_COMMAND = "COMMAND";
public static final String COMPONENT_POPUP = "POPUP";
private Chat() throws RuntimeException {
throw new RuntimeException();
private Chat() {
throw new IllegalStateException("Utility class");
}
public static void sendComponent(CommandSender sender, String string, String bypass) {

View file

@ -7,17 +7,17 @@ public class ChatMessage {
/**
* Returns the plugin name with the DARK_AQUA chat color.
*/
final String COREPROTECT = Color.DARK_AQUA + "CoreProtect";
String pluginName = Color.DARK_AQUA + "CoreProtect";
String message;
String textColor = Color.WHITE;
String textStyle = new String();
String textStyle = "";
String separator = "-";
boolean useTag = true;
boolean useSpaces = true;
public ChatMessage() {
this.message = new String();
this.message = "";
}
public ChatMessage setSeparator(String separator) {
@ -129,7 +129,7 @@ public class ChatMessage {
}
public String build() {
return (this.useTag ? COREPROTECT : createSpaces(COREPROTECT, true, this.useSpaces)) + this.textColor + " " + this.separator + " " + this.textStyle + this.message;
return (this.useTag ? pluginName : createSpaces(pluginName, true, this.useSpaces)) + this.textColor + " " + this.separator + " " + this.textStyle + this.message;
}
@Override

View file

@ -5,7 +5,6 @@ import org.bukkit.ChatColor;
public final class Color {
// we define our own constants here to eliminate string concatenation
// javadoc taken from org.bukkit.ChatColor
/**
@ -118,4 +117,8 @@ public final class Color {
*/
public static final String RESET = ChatColor.COLOR_CHAR + "r";
private Color() {
throw new IllegalStateException("Utility class");
}
}

View file

@ -110,6 +110,10 @@ public class Util extends Queue {
public static final java.util.regex.Pattern tagParser = java.util.regex.Pattern.compile(Chat.COMPONENT_TAG_OPEN + "(.+?)" + Chat.COMPONENT_TAG_CLOSE + "|(.+?)", java.util.regex.Pattern.DOTALL);
private static final String NAMESPACE = "minecraft:";
private Util() {
throw new IllegalStateException("Utility class");
}
public static String getPluginVersion() {
String version = CoreProtect.getInstance().getDescription().getVersion();
if (version.contains("-")) {

View file

@ -8,6 +8,10 @@ import org.bukkit.inventory.InventoryHolder;
public class Validate {
private Validate() {
throw new IllegalStateException("Utility class");
}
public static boolean isHopper(InventoryHolder inventoryHolder) {
return (inventoryHolder instanceof Hopper || inventoryHolder instanceof HopperMinecart);
}