本文整理匯總了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!");
}
}