forked from LogBlock/LogBlock
Made LogBlock's messages far more visual appealing
This commit is contained in:
committed by
Wyatt Childers
parent
f6522b73f4
commit
8f429afbeb
@ -1,7 +1,6 @@
|
||||
package de.diddiz.LogBlock;
|
||||
|
||||
import de.diddiz.LogBlock.blockstate.BlockStateCodecs;
|
||||
import de.diddiz.LogBlock.config.Config;
|
||||
import de.diddiz.util.BukkitUtils;
|
||||
import de.diddiz.util.Utils;
|
||||
|
||||
@ -11,19 +10,16 @@ import org.bukkit.Note;
|
||||
import org.bukkit.block.data.BlockData;
|
||||
import org.bukkit.block.data.Openable;
|
||||
import org.bukkit.block.data.Powerable;
|
||||
import org.bukkit.block.data.type.Comparator;
|
||||
import org.bukkit.block.data.type.DaylightDetector;
|
||||
import org.bukkit.block.data.type.NoteBlock;
|
||||
import org.bukkit.block.data.type.Repeater;
|
||||
import org.bukkit.block.data.type.Sign;
|
||||
import org.bukkit.block.data.type.Switch;
|
||||
import org.bukkit.block.data.type.WallSign;
|
||||
import org.bukkit.block.data.type.*;
|
||||
import org.bukkit.inventory.ItemStack;
|
||||
|
||||
import java.sql.ResultSet;
|
||||
import java.sql.SQLException;
|
||||
import java.util.logging.Level;
|
||||
|
||||
import static de.diddiz.util.ActionColor.*;
|
||||
import static de.diddiz.util.MessagingUtil.*;
|
||||
|
||||
public class BlockChange implements LookupCacheElement {
|
||||
public final long id, date;
|
||||
public final Location loc;
|
||||
@ -70,14 +66,9 @@ public class BlockChange implements LookupCacheElement {
|
||||
ca = catemp;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
BlockData type = getBlockSet();
|
||||
BlockData replaced = getBlockReplaced();
|
||||
if (type == null || replaced == null) {
|
||||
return "Unknown block modification";
|
||||
}
|
||||
private String getTypeDetails(BlockData type, byte[] typeState) {
|
||||
String typeDetails = null;
|
||||
|
||||
if (BlockStateCodecs.hasCodec(type.getMaterial())) {
|
||||
try {
|
||||
typeDetails = BlockStateCodecs.toString(type.getMaterial(), Utils.deserializeYamlConfiguration(typeState));
|
||||
@ -85,80 +76,85 @@ public class BlockChange implements LookupCacheElement {
|
||||
LogBlock.getInstance().getLogger().log(Level.SEVERE, "Could not parse BlockState for " + type.getMaterial(), e);
|
||||
}
|
||||
}
|
||||
|
||||
if (typeDetails == null) {
|
||||
typeDetails = "";
|
||||
return "";
|
||||
} else {
|
||||
typeDetails = " " + typeDetails;
|
||||
return " " + typeDetails;
|
||||
}
|
||||
String replacedDetails = null;
|
||||
if (BlockStateCodecs.hasCodec(replaced.getMaterial())) {
|
||||
try {
|
||||
replacedDetails = BlockStateCodecs.toString(replaced.getMaterial(), Utils.deserializeYamlConfiguration(replacedState));
|
||||
} catch (Exception e) {
|
||||
LogBlock.getInstance().getLogger().log(Level.SEVERE, "Could not parse BlockState for " + replaced.getMaterial(), e);
|
||||
}
|
||||
}
|
||||
if (replacedDetails == null) {
|
||||
replacedDetails = "";
|
||||
} else {
|
||||
replacedDetails = " " + replacedDetails;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
BlockData type = getBlockSet();
|
||||
BlockData replaced = getBlockReplaced();
|
||||
if (type == null || replaced == null) {
|
||||
return "Unknown block modification";
|
||||
}
|
||||
|
||||
// Process type details once for later use.
|
||||
String typeDetails = getTypeDetails(type, typeState);
|
||||
String replacedDetails = getTypeDetails(replaced, replacedState);
|
||||
|
||||
final StringBuilder msg = new StringBuilder();
|
||||
|
||||
if (date > 0) {
|
||||
msg.append(Config.formatter.format(date)).append(" ");
|
||||
msg.append(brackets(prettyDate(date), BracketType.STANDARD)).append(' ');
|
||||
}
|
||||
|
||||
if (actor != null) {
|
||||
msg.append(actor.getName()).append(" ");
|
||||
}
|
||||
|
||||
if (type.getMaterial().equals(replaced.getMaterial())) {
|
||||
if (BukkitUtils.isEmpty(type.getMaterial())) {
|
||||
msg.append("did an unspecified action");
|
||||
msg.append(INTERACT).append("did an unspecified action");
|
||||
} else if (ca != null) {
|
||||
if (ca.itemStack == null) {
|
||||
msg.append("looked inside ").append(type.getMaterial().name());
|
||||
msg.append(INTERACT).append("looked inside ").append(prettyMaterial(type.getMaterial()));
|
||||
} else if (ca.remove) {
|
||||
msg.append("took ").append(BukkitUtils.toString(ca.itemStack)).append(" from ").append(type.getMaterial().name());
|
||||
msg.append(DESTROY).append("took ").append(BukkitUtils.toString(ca.itemStack)).append(" from ").append(prettyMaterial(type.getMaterial()));
|
||||
} else {
|
||||
msg.append("put ").append(BukkitUtils.toString(ca.itemStack)).append(" into ").append(type.getMaterial().name());
|
||||
msg.append(CREATE).append("put ").append(BukkitUtils.toString(ca.itemStack)).append(" into ").append(prettyMaterial(type.getMaterial()));
|
||||
}
|
||||
} else if (BukkitUtils.getContainerBlocks().contains(type.getMaterial())) {
|
||||
msg.append("opened ").append(type.getMaterial().name());
|
||||
msg.append(INTERACT).append("opened ").append(prettyMaterial(type.getMaterial()));
|
||||
} else if (type instanceof Openable) {
|
||||
// Door, Trapdoor, Fence gate
|
||||
msg.append(((Openable)type).isOpen() ? "opened" : "closed").append(" ").append(type.getMaterial().name());
|
||||
msg.append(INTERACT).append(((Openable)type).isOpen() ? "opened" : "closed").append(" ").append(prettyMaterial(type.getMaterial()));
|
||||
} else if (type.getMaterial() == Material.LEVER) {
|
||||
msg.append("switched ").append(type.getMaterial().name()).append(" ").append(((Switch) type).isPowered() ? "on" : "off");
|
||||
msg.append(INTERACT).append("switched ").append(prettyMaterial(type.getMaterial())).append(" ").append(prettyState(((Switch) type).isPowered() ? "on" : "off"));
|
||||
} else if (type instanceof Switch) {
|
||||
msg.append("pressed ").append(type.getMaterial().name());
|
||||
msg.append(INTERACT).append("pressed ").append(prettyMaterial(type.getMaterial()));
|
||||
} else if (type.getMaterial() == Material.CAKE) {
|
||||
msg.append("ate a piece of ").append(type.getMaterial().name());
|
||||
msg.append(DESTROY).append("ate a piece of ").append(prettyMaterial(type.getMaterial()));
|
||||
} else if (type.getMaterial() == Material.NOTE_BLOCK) {
|
||||
Note note = ((NoteBlock) type).getNote();
|
||||
msg.append("set ").append(type.getMaterial().name()).append(" to ").append(note.getTone().name()).append(note.isSharped() ? "#" : "");
|
||||
msg.append(INTERACT).append("set ").append(prettyMaterial(type.getMaterial())).append(" to ").append(prettyState(note.getTone().name() + (note.isSharped() ? "#" : "")));
|
||||
} else if (type.getMaterial() == Material.REPEATER) {
|
||||
msg.append("set ").append(type.getMaterial().name()).append(" to ").append(((Repeater) type).getDelay()).append(" ticks delay");
|
||||
msg.append(INTERACT).append("set ").append(prettyMaterial(type.getMaterial())).append(" to ").append(prettyState(((Repeater) type).getDelay())).append(" ticks delay");
|
||||
} else if (type.getMaterial() == Material.COMPARATOR) {
|
||||
msg.append("set ").append(type.getMaterial().name()).append(" to ").append(((Comparator) type).getMode());
|
||||
msg.append(INTERACT).append("set ").append(prettyMaterial(type.getMaterial())).append(" to ").append(prettyState(((Comparator) type).getMode()));
|
||||
} else if (type.getMaterial() == Material.DAYLIGHT_DETECTOR) {
|
||||
msg.append("set ").append(type.getMaterial().name()).append(" to ").append(((DaylightDetector) type).isInverted() ? "inverted" : "normal");
|
||||
msg.append(INTERACT).append("set ").append(prettyMaterial(type.getMaterial())).append(" to ").append(prettyState(((DaylightDetector) type).isInverted() ? "inverted" : "normal"));
|
||||
} else if (type instanceof Powerable) {
|
||||
msg.append("stepped on ").append(type.getMaterial().name());
|
||||
msg.append(INTERACT).append("stepped on ").append(prettyMaterial(type.getMaterial()));
|
||||
} else if (type.getMaterial() == Material.TRIPWIRE) {
|
||||
msg.append("ran into ").append(type.getMaterial().name());
|
||||
msg.append(INTERACT).append("ran into ").append(prettyMaterial(type.getMaterial()));
|
||||
} else if (type instanceof Sign || type instanceof WallSign) {
|
||||
msg.append("edited a ").append(type.getMaterial().name()).append(" to ").append(typeDetails);
|
||||
msg.append(DESTROY).append("edited a ").append(prettyMaterial(type.getMaterial())).append(CREATE).append(" to ").append(prettyState(typeDetails));
|
||||
} else {
|
||||
msg.append("replaced ").append(replaced.getMaterial().name()).append(replacedDetails).append(" with ").append(type.getMaterial().name()).append(typeDetails);
|
||||
msg.append(DESTROY).append("replaced ").append(prettyMaterial(replaced.getMaterial())).append(prettyState(replacedDetails)).append(CREATE).append(" with ").append(prettyMaterial(type.getMaterial())).append(prettyState(typeDetails));
|
||||
}
|
||||
} else if (BukkitUtils.isEmpty(type.getMaterial())) {
|
||||
msg.append("destroyed ").append(replaced.getMaterial().name()).append(replacedDetails);
|
||||
msg.append(DESTROY).append("destroyed ").append(prettyMaterial(replaced.getMaterial())).append(prettyState(replacedDetails));
|
||||
} else if (BukkitUtils.isEmpty(replaced.getMaterial())) {
|
||||
msg.append("created ").append(type.getMaterial().name()).append(typeDetails);
|
||||
msg.append(CREATE).append("created ").append(prettyMaterial(type.getMaterial())).append(prettyState(typeDetails));
|
||||
} else {
|
||||
msg.append("replaced ").append(replaced.getMaterial().name()).append(replacedDetails).append(" with ").append(type.getMaterial().name()).append(typeDetails);
|
||||
msg.append(DESTROY).append("replaced ").append(prettyMaterial(replaced.getMaterial())).append(prettyState(replacedDetails)).append(CREATE).append(" with ").append(type.getMaterial().name()).append(typeDetails);
|
||||
}
|
||||
if (loc != null) {
|
||||
msg.append(" at ").append(loc.getBlockX()).append(":").append(loc.getBlockY()).append(":").append(loc.getBlockZ());
|
||||
msg.append(" at: ").append(prettyLocation(loc));
|
||||
}
|
||||
return msg.toString();
|
||||
}
|
||||
|
@ -1,10 +1,13 @@
|
||||
package de.diddiz.LogBlock;
|
||||
|
||||
import org.bukkit.ChatColor;
|
||||
import org.bukkit.Location;
|
||||
|
||||
import java.sql.ResultSet;
|
||||
import java.sql.SQLException;
|
||||
|
||||
import static de.diddiz.util.ActionColor.CREATE;
|
||||
import static de.diddiz.util.MessagingUtil.*;
|
||||
import static de.diddiz.util.LoggingUtil.checkText;
|
||||
|
||||
public class ChatMessage implements LookupCacheElement {
|
||||
@ -35,6 +38,6 @@ public class ChatMessage implements LookupCacheElement {
|
||||
|
||||
@Override
|
||||
public String getMessage() {
|
||||
return (player != null ? "<" + player.getName() + "> " : "") + (message != null ? message : "");
|
||||
return (playerName != null ? brackets(ChatColor.WHITE + playerName, BracketType.ANGLE) + ' ' : "") + (message != null ? CREATE + message : "");
|
||||
}
|
||||
}
|
||||
|
@ -37,6 +37,9 @@ import static de.diddiz.LogBlock.Session.getSession;
|
||||
import static de.diddiz.LogBlock.config.Config.*;
|
||||
import static de.diddiz.util.BukkitUtils.giveTool;
|
||||
import static de.diddiz.util.BukkitUtils.saveSpawnHeight;
|
||||
import static de.diddiz.util.TypeColor.DEFAULT;
|
||||
import static de.diddiz.util.TypeColor.ERROR;
|
||||
import static de.diddiz.util.TypeColor.HEADER;
|
||||
import static de.diddiz.util.Utils.isInt;
|
||||
import static de.diddiz.util.Utils.listing;
|
||||
|
||||
@ -382,19 +385,19 @@ public class CommandsHandler implements CommandExecutor {
|
||||
final int stoppos = startpos + linesPerPage >= lookupElements.length ? lookupElements.length - 1 : startpos + linesPerPage - 1;
|
||||
final int numberOfPages = (int) Math.ceil(lookupElements.length / (double) linesPerPage);
|
||||
if (numberOfPages != 1) {
|
||||
sender.sendMessage(ChatColor.DARK_AQUA + "Page " + page + "/" + numberOfPages);
|
||||
sender.sendMessage(HEADER + "Page " + page + "/" + numberOfPages);
|
||||
}
|
||||
for (int i = startpos; i <= stoppos; i++) {
|
||||
sender.sendMessage(ChatColor.GOLD + (lookupElements[i].getLocation() != null ? "(" + (i + 1) + ") " : "") + lookupElements[i].getMessage());
|
||||
sender.sendMessage(DEFAULT + (lookupElements[i].getLocation() != null ? "(" + (i + 1) + ") " : "") + lookupElements[i].getMessage());
|
||||
}
|
||||
if (setSessionPage) {
|
||||
getSession(sender).page = page;
|
||||
}
|
||||
} else {
|
||||
sender.sendMessage(ChatColor.RED + "There isn't a page '" + page + "'");
|
||||
sender.sendMessage(ERROR + "There isn't a page '" + page + "'");
|
||||
}
|
||||
} else {
|
||||
sender.sendMessage(ChatColor.RED + "No blocks in lookup cache");
|
||||
sender.sendMessage(ERROR + "No blocks in lookup cache");
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -1,14 +1,18 @@
|
||||
package de.diddiz.LogBlock;
|
||||
|
||||
import de.diddiz.LogBlock.config.Config;
|
||||
import de.diddiz.util.BukkitUtils;
|
||||
|
||||
import de.diddiz.util.TypeColor;
|
||||
import org.bukkit.Location;
|
||||
import org.bukkit.Material;
|
||||
|
||||
import java.sql.ResultSet;
|
||||
import java.sql.SQLException;
|
||||
|
||||
import static de.diddiz.util.ActionColor.DESTROY;
|
||||
import static de.diddiz.util.MessagingUtil.*;
|
||||
import static de.diddiz.util.TypeColor.DEFAULT;
|
||||
|
||||
public class Kill implements LookupCacheElement {
|
||||
final long id, date;
|
||||
public final Location loc;
|
||||
@ -37,15 +41,15 @@ public class Kill implements LookupCacheElement {
|
||||
public String toString() {
|
||||
final StringBuilder msg = new StringBuilder();
|
||||
if (date > 0) {
|
||||
msg.append(Config.formatter.format(date)).append(" ");
|
||||
msg.append(brackets(prettyDate(date), BracketType.STANDARD)).append(' ');
|
||||
}
|
||||
msg.append(killerName).append(" killed ").append(victimName);
|
||||
msg.append(killerName).append(DESTROY).append(" killed ").append(DEFAULT).append(victimName);
|
||||
if (loc != null) {
|
||||
msg.append(" at ").append(loc.getBlockX()).append(":").append(loc.getBlockY()).append(":").append(loc.getBlockZ());
|
||||
msg.append(" at ").append(prettyLocation(loc));
|
||||
}
|
||||
if (weapon != 0) {
|
||||
String weaponName = prettyItemName(MaterialConverter.getMaterial(weapon));
|
||||
msg.append(" with " + weaponName); // + ("aeiou".contains(weaponName.substring(0, 1)) ? "an " : "a " )
|
||||
msg.append(" with ").append(weaponName); // + ("aeiou".contains(weaponName.substring(0, 1)) ? "an " : "a " )
|
||||
}
|
||||
return msg.toString();
|
||||
}
|
||||
@ -62,8 +66,8 @@ public class Kill implements LookupCacheElement {
|
||||
|
||||
public String prettyItemName(Material t) {
|
||||
if (t == null || BukkitUtils.isEmpty(t)) {
|
||||
return "fist";
|
||||
return prettyMaterial("fist");
|
||||
}
|
||||
return t.toString().replace('_', ' ').toLowerCase();
|
||||
return prettyMaterial(t.toString().replace('_', ' '));
|
||||
}
|
||||
}
|
||||
|
@ -7,6 +7,10 @@ import java.sql.ResultSet;
|
||||
import java.sql.SQLException;
|
||||
import java.util.Objects;
|
||||
|
||||
import static de.diddiz.util.ActionColor.CREATE;
|
||||
import static de.diddiz.util.ActionColor.DESTROY;
|
||||
import static de.diddiz.util.MessagingUtil.prettyMaterial;
|
||||
import static de.diddiz.util.TypeColor.DEFAULT;
|
||||
import static de.diddiz.util.Utils.spaces;
|
||||
|
||||
public class SummedBlockChanges implements LookupCacheElement {
|
||||
@ -31,6 +35,10 @@ public class SummedBlockChanges implements LookupCacheElement {
|
||||
|
||||
@Override
|
||||
public String getMessage() {
|
||||
return created + spaces((int) ((10 - String.valueOf(created).length()) / spaceFactor)) + destroyed + spaces((int) ((10 - String.valueOf(destroyed).length()) / spaceFactor)) + (actor != null ? actor.getName() : Objects.toString(MaterialConverter.getMaterial(type)));
|
||||
StringBuilder builder = new StringBuilder();
|
||||
builder.append(CREATE).append(created).append(spaces((int) ((10 - String.valueOf(created).length()) / spaceFactor)));
|
||||
builder.append(DESTROY).append(destroyed).append(spaces((int)((10 - String.valueOf(destroyed).length()) / spaceFactor)));
|
||||
builder.append(actor != null ? DEFAULT + actor.getName() : prettyMaterial(Objects.toString(MaterialConverter.getMaterial(type))));
|
||||
return builder.toString();
|
||||
}
|
||||
}
|
||||
|
@ -5,6 +5,9 @@ import org.bukkit.Location;
|
||||
import java.sql.ResultSet;
|
||||
import java.sql.SQLException;
|
||||
|
||||
import static de.diddiz.util.ActionColor.CREATE;
|
||||
import static de.diddiz.util.ActionColor.DESTROY;
|
||||
import static de.diddiz.util.TypeColor.DEFAULT;
|
||||
import static de.diddiz.util.Utils.spaces;
|
||||
|
||||
public class SummedKills implements LookupCacheElement {
|
||||
@ -26,6 +29,11 @@ public class SummedKills implements LookupCacheElement {
|
||||
|
||||
@Override
|
||||
public String getMessage() {
|
||||
return kills + spaces((int) ((6 - String.valueOf(kills).length()) / spaceFactor)) + killed + spaces((int) ((7 - String.valueOf(killed).length()) / spaceFactor)) + player.getName();
|
||||
StringBuilder builder = new StringBuilder();
|
||||
builder.append(CREATE).append(kills).append(spaces((int)((6 - String.valueOf(kills).length()) / spaceFactor)));
|
||||
builder.append(DESTROY).append(killed).append(spaces((int)((7 - String.valueOf(killed).length()) / spaceFactor)));
|
||||
builder.append(DEFAULT).append(player.getName());
|
||||
return builder.toString();
|
||||
|
||||
}
|
||||
}
|
||||
|
24
src/main/java/de/diddiz/util/ActionColor.java
Normal file
24
src/main/java/de/diddiz/util/ActionColor.java
Normal file
@ -0,0 +1,24 @@
|
||||
package de.diddiz.util;
|
||||
|
||||
import org.bukkit.ChatColor;
|
||||
|
||||
public enum ActionColor {
|
||||
DESTROY(ChatColor.RED),
|
||||
CREATE(ChatColor.DARK_GREEN),
|
||||
INTERACT(ChatColor.GRAY);
|
||||
|
||||
private final ChatColor color;
|
||||
|
||||
ActionColor(ChatColor color) {
|
||||
this.color = color;
|
||||
}
|
||||
|
||||
public ChatColor getColor() {
|
||||
return color;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return color.toString();
|
||||
}
|
||||
}
|
@ -28,6 +28,9 @@ import java.io.File;
|
||||
import java.util.*;
|
||||
import java.util.Map.Entry;
|
||||
|
||||
import static de.diddiz.util.MessagingUtil.prettyMaterial;
|
||||
import static de.diddiz.util.TypeColor.DEFAULT;
|
||||
|
||||
public class BukkitUtils {
|
||||
private static final Set<Set<Integer>> blockEquivalents;
|
||||
private static final Set<Material> relativeBreakable;
|
||||
@ -642,10 +645,11 @@ public class BukkitUtils {
|
||||
|
||||
public static String toString(ItemStack stack) {
|
||||
if (stack == null || stack.getAmount() == 0 || isEmpty(stack.getType())) {
|
||||
return "nothing";
|
||||
return prettyMaterial("nothing");
|
||||
}
|
||||
StringBuilder sb = new StringBuilder();
|
||||
sb.append(stack.getAmount()).append("x ").append(stack.getType().name());
|
||||
sb.append(stack.getAmount()).append("x ").append(prettyMaterial(stack.getType()));
|
||||
sb.append(TypeColor.STATE);
|
||||
ItemMeta meta = stack.getItemMeta();
|
||||
boolean metaStarted = false;
|
||||
if (meta.hasEnchants()) {
|
||||
@ -659,8 +663,8 @@ public class BukkitUtils {
|
||||
sb.append(", ");
|
||||
}
|
||||
sb.append(formatMinecraftKey(e.getKey().getKey().getKey()));
|
||||
if (e.getValue().intValue() > 1) {
|
||||
sb.append(" ").append(maybeToRoman(e.getValue().intValue() - 1));
|
||||
if (e.getValue() > 1) {
|
||||
sb.append(" ").append(maybeToRoman(e.getValue() - 1));
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -678,8 +682,8 @@ public class BukkitUtils {
|
||||
sb.append(", ");
|
||||
}
|
||||
sb.append(formatMinecraftKey(e.getKey().getKey().getKey()));
|
||||
if (e.getValue().intValue() > 1) {
|
||||
sb.append(" ").append(maybeToRoman(e.getValue().intValue() - 1));
|
||||
if (e.getValue() > 1) {
|
||||
sb.append(" ").append(maybeToRoman(e.getValue() - 1));
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -688,6 +692,7 @@ public class BukkitUtils {
|
||||
if (metaStarted) {
|
||||
sb.append("]");
|
||||
}
|
||||
sb.append(DEFAULT);
|
||||
return sb.toString();
|
||||
}
|
||||
|
||||
|
66
src/main/java/de/diddiz/util/MessagingUtil.java
Normal file
66
src/main/java/de/diddiz/util/MessagingUtil.java
Normal file
@ -0,0 +1,66 @@
|
||||
package de.diddiz.util;
|
||||
|
||||
import de.diddiz.LogBlock.config.Config;
|
||||
import org.bukkit.ChatColor;
|
||||
import org.bukkit.Location;
|
||||
import org.bukkit.Material;
|
||||
|
||||
import static de.diddiz.util.TypeColor.DEFAULT;
|
||||
|
||||
public class MessagingUtil {
|
||||
public static String brackets(String string, BracketType type) {
|
||||
return TypeColor.BRACKETS + String.valueOf(type.getStarting()) + string + TypeColor.BRACKETS + type.getEnding() + DEFAULT;
|
||||
}
|
||||
|
||||
public static String prettyDate(long date) {
|
||||
return TypeColor.DATE + Config.formatter.format(date) + DEFAULT;
|
||||
}
|
||||
|
||||
public static String prettyState(String stateName) {
|
||||
return TypeColor.STATE + stateName.toUpperCase() + DEFAULT;
|
||||
}
|
||||
|
||||
public static String prettyState(int stateValue) {
|
||||
return prettyState(Integer.toString(stateValue));
|
||||
}
|
||||
|
||||
public static <E extends Enum<E>> String prettyState(E enumerator) {
|
||||
return prettyState(enumerator.toString());
|
||||
}
|
||||
|
||||
public static String prettyMaterial(String materialName) {
|
||||
return TypeColor.MATERIAL + materialName.toUpperCase() + DEFAULT;
|
||||
}
|
||||
|
||||
public static String prettyMaterial(Material material) {
|
||||
return prettyMaterial(material.name());
|
||||
}
|
||||
|
||||
public static String prettyLocation(Location loc) {
|
||||
return prettyLocation(loc.getBlockX(), loc.getBlockY(), loc.getBlockZ());
|
||||
}
|
||||
|
||||
public static String prettyLocation(Number x, Number y, Number z) {
|
||||
return DEFAULT + "X: " + TypeColor.COORDINATE + x.intValue() + DEFAULT + ", Y: " + TypeColor.COORDINATE + y.intValue() + DEFAULT + ", Z: " + TypeColor.COORDINATE + z.intValue() + DEFAULT;
|
||||
}
|
||||
|
||||
public enum BracketType {
|
||||
STANDARD('[', ']'),
|
||||
ANGLE('<', '>');
|
||||
|
||||
private char starting, ending;
|
||||
|
||||
BracketType(char starting, char ending) {
|
||||
this.starting = starting;
|
||||
this.ending = ending;
|
||||
}
|
||||
|
||||
public char getStarting() {
|
||||
return starting;
|
||||
}
|
||||
|
||||
public char getEnding() {
|
||||
return ending;
|
||||
}
|
||||
}
|
||||
}
|
29
src/main/java/de/diddiz/util/TypeColor.java
Normal file
29
src/main/java/de/diddiz/util/TypeColor.java
Normal file
@ -0,0 +1,29 @@
|
||||
package de.diddiz.util;
|
||||
|
||||
import org.bukkit.ChatColor;
|
||||
|
||||
public enum TypeColor {
|
||||
DEFAULT(ChatColor.YELLOW),
|
||||
MATERIAL(ChatColor.BLUE),
|
||||
STATE(ChatColor.BLUE),
|
||||
DATE(ChatColor.DARK_AQUA),
|
||||
BRACKETS(ChatColor.DARK_GRAY),
|
||||
COORDINATE(ChatColor.WHITE),
|
||||
HEADER(ChatColor.GOLD),
|
||||
ERROR(ChatColor.RED);
|
||||
|
||||
private final ChatColor color;
|
||||
|
||||
TypeColor(ChatColor color) {
|
||||
this.color = color;
|
||||
}
|
||||
|
||||
public ChatColor getColor() {
|
||||
return color;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return color.toString();
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user