Added private constructors to utility classes
This commit is contained in:
parent
a7eb6a48c9
commit
f6f9c27f08
33 changed files with 130 additions and 7 deletions
|
|
@ -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) {
|
||||
|
|
|
|||
|
|
@ -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
|
||||
|
|
|
|||
|
|
@ -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");
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
|||
|
|
@ -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("-")) {
|
||||
|
|
|
|||
|
|
@ -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);
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue