本文整理汇总了Java中org.bukkit.Server.getClass方法的典型用法代码示例。如果您正苦于以下问题:Java Server.getClass方法的具体用法?Java Server.getClass怎么用?Java Server.getClass使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.bukkit.Server
的用法示例。
在下文中一共展示了Server.getClass方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: initializePackageNames
import org.bukkit.Server; //导入方法依赖的package包/类
/**
* Initializes the package names.
*
* @return
*/
protected static void initializePackageNames() {
Server bukkitServer = Bukkit.getServer();
if (bukkitServer != null) {
// Handle CraftBukkit package
Class<?> craftServerClass = bukkitServer.getClass();
CRAFTBUKKIT_PACKAGE = trimPackageName(craftServerClass.getCanonicalName());
Matcher matcher = PACKAGE_VERSION_MATCHER.matcher(CRAFTBUKKIT_PACKAGE);
if (matcher.matches()) {
VERSION_TAG = matcher.group(1);
}
// Handle NMS-Package
Class<?> craftEntityClass = getCraftEntityClass();
MethodAccessor<Object> getHandle = ClassTemplate.create(craftEntityClass).getMethod("getHandle");
MINECARFT_PACKAGE = trimPackageName(getHandle.getReturnType().getCanonicalName());
if (!MINECARFT_PACKAGE.startsWith(MINECARFT_PACKAGE_PREFIX)) {
// We're dealing with a Forge server.
// Credits to ProtocolLib for this method
if (MINECARFT_PACKAGE.equals(FORGE_ENTITY_PACKAGE)) {
// Hack for MCPC+ for 1.7.x
try {
if (VERSION_TAG == null || VERSION_TAG == "") {
if (getClass("org.bukkit.plugin.java.PluginClassLoader") != null) {
ClassTemplate<?> pluginClassLoader = ClassTemplate.create(getClass("org.bukkit.plugin.java.PluginClassLoader"));
MethodAccessor<String> getNativeVersion = pluginClassLoader.getMethod("getNativeVersion");
if (getNativeVersion != null) {
VERSION_TAG = getNativeVersion.invoke(null);
}
}
}
} catch (Exception e) {
if (VERSION_TAG == null) {
EchoPet.LOG.warning("Version tag is null and it appears the server is modded but does not contain the expected method(s)! HoloAPI may not work correctly!");
}
}
MINECARFT_PACKAGE = combine(MINECARFT_PACKAGE_PREFIX, VERSION_TAG);
} else {
MINECARFT_PACKAGE_PREFIX = MINECARFT_PACKAGE;
}
}
} else {
throw new IllegalStateException("Failed to find Bukkit!");
}
}
示例2: initializePackageNames
import org.bukkit.Server; //导入方法依赖的package包/类
/**
* Initializes the package names.
*
* @return
*/
protected static void initializePackageNames() {
Server bukkitServer = Bukkit.getServer();
if (bukkitServer != null) {
// Handle CraftBukkit package
Class<?> craftServerClass = bukkitServer.getClass();
CRAFTBUKKIT_PACKAGE = trimPackageName(craftServerClass.getCanonicalName());
Matcher matcher = PACKAGE_VERSION_MATCHER.matcher(CRAFTBUKKIT_PACKAGE);
if (matcher.matches()) {
VERSION_TAG = matcher.group(1);
}
// Handle NMS-Package
Class<?> craftEntityClass = getCraftEntityClass();
MethodAccessor<Object> getHandle = ClassTemplate.create(craftEntityClass).getMethod("getHandle");
MINECARFT_PACKAGE = trimPackageName(getHandle.getReturnType().getCanonicalName());
if (!MINECARFT_PACKAGE.startsWith(MINECARFT_PACKAGE_PREFIX)) {
// We're dealing with a Forge server.
// Credits to ProtocolLib for this method
if (MINECARFT_PACKAGE.equals(FORGE_ENTITY_PACKAGE)) {
// Hack for MCPC+ for 1.7.x
try {
if (VERSION_TAG == null || VERSION_TAG == "") {
if (getClass("org.bukkit.plugin.java.PluginClassLoader") != null) {
ClassTemplate pluginClassLoader = ClassTemplate.create(getClass("org.bukkit.plugin.java.PluginClassLoader"));
MethodAccessor<String> getNativeVersion = pluginClassLoader.getMethod("getNativeVersion");
if (getNativeVersion != null) {
VERSION_TAG = getNativeVersion.invoke(null);
}
}
}
} catch (Exception e) {
if (VERSION_TAG == null) {
EchoPet.LOG.warning("Version tag is null and it appears the server is modded but does not contain the expected method(s)! HoloAPI may not work correctly!");
}
}
MINECARFT_PACKAGE = combine(MINECARFT_PACKAGE_PREFIX, VERSION_TAG);
} else {
MINECARFT_PACKAGE_PREFIX = MINECARFT_PACKAGE;
}
}
} else {
throw new IllegalStateException("Failed to find Bukkit!");
}
}