1
0
mirror of https://e.coding.net/circlecloud/YumCore.git synced 2024-11-24 02:08:48 +00:00

feat: 添加代理方法

Signed-off-by: 502647092 <admin@yumc.pw>
This commit is contained in:
502647092 2016-07-25 13:53:57 +08:00
parent 73eeac2484
commit 1a7e967826
2 changed files with 107 additions and 77 deletions

View File

@ -1,48 +1,59 @@
package pw.yumc.YumCore.bukkit; package pw.yumc.YumCore.bukkit;
import java.util.logging.Handler; import java.util.logging.Handler;
import java.util.logging.Level; import java.util.logging.Level;
import java.util.logging.Logger; import java.util.logging.Logger;
/** import org.bukkit.Bukkit;
* 插件日志输出类 import org.bukkit.command.CommandSender;
*
* @since 2016年7月23日 上午9:11:01 /**
* @author * 插件日志输出类
*/ *
public class Log { * @since 2016年7月23日 上午9:11:01
private static Logger logger = P.instance.getLogger(); * @author
*/
public static void addHandler(final Handler handler) throws SecurityException { public class Log {
logger.addHandler(handler); private static Logger logger = P.instance.getLogger();
} private static String prefix = String.format("§6[§b%s§6]§r ", P.instance.getName());
private static CommandSender console = Bukkit.getConsoleSender();
public static void info(final String msg) {
logger.info(msg); public static void addHandler(final Handler handler) throws SecurityException {
} logger.addHandler(handler);
}
public static void log(final Level level, final String msg) {
logger.log(level, msg); public static void console(final String... msg) {
} for (final String str : msg) {
console.sendMessage(prefix + str);
public static void log(final Level level, final String msg, final Object param1) { }
logger.log(level, msg, param1); }
}
public static void info(final String msg) {
public static void log(final Level level, final String msg, final Object[] params) { logger.info(msg);
logger.log(level, msg, params); }
}
public static void log(final Level level, final String msg) {
public static void log(final Level level, final String msg, final Throwable thrown) { logger.log(level, msg);
logger.log(level, msg, thrown); }
}
public static void log(final Level level, final String msg, final Object param1) {
public static void severe(final String msg) { logger.log(level, msg, param1);
logger.severe(msg); }
}
public static void log(final Level level, final String msg, final Object[] params) {
public static void warning(final String msg) { logger.log(level, msg, params);
logger.warning(msg); }
}
public static void log(final Level level, final String msg, final Throwable thrown) {
} logger.log(level, msg, thrown);
}
public static void severe(final String msg) {
logger.severe(msg);
}
public static void warning(final String msg) {
logger.warning(msg);
}
}

View File

@ -1,29 +1,48 @@
package pw.yumc.YumCore.bukkit; package pw.yumc.YumCore.bukkit;
import java.lang.reflect.Field; import java.lang.reflect.Field;
import java.util.logging.Logger;
import org.bukkit.plugin.java.JavaPlugin;
import org.bukkit.command.PluginCommand;
/** import org.bukkit.configuration.file.FileConfiguration;
* 插件Instance获取类 import org.bukkit.plugin.java.JavaPlugin;
*
* @since 2016年7月23日 上午9:09:57 /**
* @author * 插件Instance获取类
*/ *
public class P { * @since 2016年7月23日 上午9:09:57
/** * @author
* 插件实例 */
*/ public class P {
public static JavaPlugin instance; /**
* 插件实例
static { */
final Object pluginClassLoader = P.class.getClassLoader(); public static JavaPlugin instance;
try {
final Field field = pluginClassLoader.getClass().getDeclaredField("plugin"); static {
field.setAccessible(true); final Object pluginClassLoader = P.class.getClassLoader();
instance = (JavaPlugin) field.get(pluginClassLoader); try {
} catch (final Exception e) { final Field field = pluginClassLoader.getClass().getDeclaredField("plugin");
e.printStackTrace(); field.setAccessible(true);
} instance = (JavaPlugin) field.get(pluginClassLoader);
} } catch (final Exception e) {
} e.printStackTrace();
}
}
public PluginCommand getCommand(final String name) {
return instance.getCommand(name);
}
public FileConfiguration getConfig() {
return instance.getConfig();
}
public final Logger getLogger() {
return instance.getLogger();
}
public final String getName() {
return instance.getName();
}
}