what?
This commit is contained in:
39
src/com/bukkit/mcteam/factions/util/Log.java
Normal file
39
src/com/bukkit/mcteam/factions/util/Log.java
Normal file
@@ -0,0 +1,39 @@
|
||||
package com.bukkit.mcteam.factions.util;
|
||||
|
||||
import java.util.*;
|
||||
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
import com.bukkit.mcteam.factions.Factions;
|
||||
|
||||
public class Log {
|
||||
public static String prefix = Factions.desc.getName();
|
||||
public static ArrayList<Player> debuggers = new ArrayList<Player>();
|
||||
public static int threshold = 10;
|
||||
|
||||
public static void log(int level, String prefix, String msg) {
|
||||
if (threshold <= level) {
|
||||
msg = Log.prefix+prefix+msg;
|
||||
System.out.println(msg);
|
||||
for(Player debugger : debuggers) {
|
||||
debugger.sendMessage(msg);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public static void debug (String msg) {
|
||||
log(10, " debug: ", msg);
|
||||
}
|
||||
|
||||
public static void info (String msg) {
|
||||
log(20, " info: ", msg);
|
||||
}
|
||||
|
||||
public static void warn (String msg) {
|
||||
log(30, " warn: ", msg);
|
||||
}
|
||||
|
||||
public static void severe (String msg) {
|
||||
log(40, " severe: ", msg);
|
||||
}
|
||||
}
|
63
src/com/bukkit/mcteam/factions/util/TextUtil.java
Normal file
63
src/com/bukkit/mcteam/factions/util/TextUtil.java
Normal file
@@ -0,0 +1,63 @@
|
||||
package com.bukkit.mcteam.factions.util;
|
||||
import java.util.*;
|
||||
|
||||
import org.bukkit.Material;
|
||||
|
||||
import com.bukkit.mcteam.factions.entities.*;
|
||||
|
||||
public class TextUtil {
|
||||
public static String titleize(String str) {
|
||||
String line = Conf.colorChrome+repeat("_", 60);
|
||||
String center = ".[ " + Conf.colorSystem + str + Conf.colorChrome + " ].";
|
||||
int pivot = line.length() / 2;
|
||||
int eatLeft = center.length() / 2;
|
||||
int eatRight = center.length() - eatLeft;
|
||||
return line.substring(0, pivot - eatLeft) + center + line.substring(pivot + eatRight);
|
||||
}
|
||||
|
||||
public static String repeat(String s, int times) {
|
||||
if (times <= 0) return "";
|
||||
else return s + repeat(s, times-1);
|
||||
}
|
||||
|
||||
public static ArrayList<String> split(String str) {
|
||||
return new ArrayList<String>(Arrays.asList(str.trim().split("\\s+")));
|
||||
}
|
||||
|
||||
public static String implode(List<String> list, String glue) {
|
||||
String ret = "";
|
||||
for (int i=0; i<list.size(); i++) {
|
||||
if (i!=0) {
|
||||
ret += glue;
|
||||
}
|
||||
ret += list.get(i);
|
||||
}
|
||||
return ret;
|
||||
}
|
||||
public static String implode(List<String> list) {
|
||||
return implode(list, " ");
|
||||
}
|
||||
|
||||
public static String commandHelp(List<String> aliases, String param, String desc) {
|
||||
ArrayList<String> parts = new ArrayList<String>();
|
||||
parts.add(Conf.colorCommand+Conf.aliasBase.get(0));
|
||||
parts.add(TextUtil.implode(aliases, ", "));
|
||||
if (param.length() > 0) {
|
||||
parts.add(Conf.colorParameter+param);
|
||||
}
|
||||
if (desc.length() > 0) {
|
||||
parts.add(Conf.colorSystem+desc);
|
||||
}
|
||||
//Log.debug(TextUtil.implode(parts, " "));
|
||||
return TextUtil.implode(parts, " ");
|
||||
}
|
||||
|
||||
public static String getMaterialName(Material material) {
|
||||
String ret = material.toString();
|
||||
ret = ret.replace('_', ' ');
|
||||
ret = ret.toLowerCase();
|
||||
return ret.substring(0, 1).toUpperCase()+ret.substring(1);
|
||||
}
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user