Java Code Examples for org.bukkit.Bukkit#getServer()
The following examples show how to use
org.bukkit.Bukkit#getServer() .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: AdminRebuild.java From Modern-LWC with MIT License | 6 votes |
/** * Look for a protectable block in each world. Return the first one found. Starts in the main world. * * @param x * @param y * @param z * @return */ private Block findProtectableBlock(int x, int y, int z) { LWC lwc = LWC.getInstance(); Server server = Bukkit.getServer(); for (World world : server.getWorlds()) { Block block = world.getBlockAt(x, y, z); if (lwc.isProtectable(block)) { // Woo! return block; } } // Bad news... return null; }
Example 2
Source File: NMS_1_13_1.java From 1.13-Command-API with Apache License 2.0 | 5 votes |
@Override public void resendPackets(Player player) { CraftPlayer craftPlayer = (CraftPlayer) player; CraftServer craftServer = (CraftServer) Bukkit.getServer(); net.minecraft.server.v1_13_R2.CommandDispatcher nmsDispatcher = craftServer.getServer().commandDispatcher; nmsDispatcher.a(craftPlayer.getHandle()); }
Example 3
Source File: PingInjector.java From PingAPI with MIT License | 5 votes |
/** * Constructs a new PingInjector and gets the list of open NetworkManager instances */ public PingInjector() { try { CraftServer craftserver = (CraftServer) Bukkit.getServer(); Field console = craftserver.getClass().getDeclaredField("console"); console.setAccessible(true); this.server = (MinecraftServer) console.get(craftserver); ServerConnection conn = this.server.getServerConnection(); networkManagers = Collections.synchronizedList((List<?>) this.getNetworkManagerList(conn)); } catch(IllegalAccessException | NoSuchFieldException e) { e.printStackTrace(); } }
Example 4
Source File: PingInjector.java From PingAPI with MIT License | 5 votes |
/** * Constructs a new PingInjector and gets the list of open NetworkManager instances */ public PingInjector() { try { CraftServer craftserver = (CraftServer) Bukkit.getServer(); Field console = craftserver.getClass().getDeclaredField("console"); console.setAccessible(true); this.server = (MinecraftServer) console.get(craftserver); ServerConnection conn = this.server.an(); networkManagers = Collections.synchronizedList((List<?>) this.getNetworkManagerList(conn)); } catch(IllegalAccessException | NoSuchFieldException e) { e.printStackTrace(); } }
Example 5
Source File: PingInjector.java From PingAPI with MIT License | 5 votes |
/** * Constructs a new PingInjector and gets the list of open NetworkManager instances */ public PingInjector() { try { CraftServer craftserver = (CraftServer) Bukkit.getServer(); Field console = craftserver.getClass().getDeclaredField("console"); console.setAccessible(true); this.server = (MinecraftServer) console.get(craftserver); ServerConnection conn = this.server.ap(); networkManagers = Collections.synchronizedList((List<?>) this.getNetworkManagerList(conn)); } catch(IllegalAccessException | NoSuchFieldException e) { e.printStackTrace(); } }
Example 6
Source File: NbtFactory.java From AdditionsAPI with MIT License | 5 votes |
private String getPackageName() { Server server = Bukkit.getServer(); String name = server != null ? server.getClass().getPackage().getName() : null; if (name != null && name.contains("craftbukkit")) { return name; } else { // Fallback return "org.bukkit.craftbukkit.v1_13_R1"; } }
Example 7
Source File: PingInjector.java From PingAPI with MIT License | 5 votes |
/** * Constructs a new PingInjector and gets the list of open NetworkManager instances */ public PingInjector() { try { CraftServer craftserver = (CraftServer) Bukkit.getServer(); Field console = craftserver.getClass().getDeclaredField("console"); console.setAccessible(true); this.server = (MinecraftServer) console.get(craftserver); ServerConnection conn = this.server.ah(); networkManagers = Collections.synchronizedList((List<?>) this.getNetworkManagerList(conn)); } catch(IllegalAccessException | NoSuchFieldException e) { e.printStackTrace(); } }
Example 8
Source File: PingInjector.java From PingAPI with MIT License | 5 votes |
/** * Constructs a new PingInjector and gets the list of open NetworkManager instances */ public PingInjector() { try { CraftServer craftserver = (CraftServer) Bukkit.getServer(); Field console = craftserver.getClass().getDeclaredField("console"); console.setAccessible(true); this.server = (MinecraftServer) console.get(craftserver); ServerConnection conn = this.server.ai(); networkManagers = Collections.synchronizedList((List<?>) this.getNetworkManagerList(conn)); } catch(IllegalAccessException | NoSuchFieldException e) { e.printStackTrace(); } }
Example 9
Source File: NMS_1_14_4.java From 1.13-Command-API with Apache License 2.0 | 5 votes |
@Override public void resendPackets(Player player) { CraftPlayer craftPlayer = (CraftPlayer) player; CraftServer craftServer = (CraftServer) Bukkit.getServer(); @SuppressWarnings("resource") net.minecraft.server.v1_14_R1.CommandDispatcher nmsDispatcher = craftServer.getServer().commandDispatcher; nmsDispatcher.a(craftPlayer.getHandle()); }
Example 10
Source File: MineCloudPlugin.java From MineCloud with ISC License | 5 votes |
public double fetchTps() { try { org.bukkit.Server server = Bukkit.getServer(); Object minecraftServer = server.getClass().getDeclaredMethod("getServer").invoke(server); Field tps = minecraftServer.getClass().getField("recentTps"); return ((double[]) tps.get(minecraftServer))[0]; } catch (Exception ex) { getLogger().log(Level.SEVERE, "Could not fetch TPS", ex); return 21; } }
Example 11
Source File: NMS_1_15.java From 1.13-Command-API with Apache License 2.0 | 5 votes |
@Override public void resendPackets(Player player) { CraftPlayer craftPlayer = (CraftPlayer) player; CraftServer craftServer = (CraftServer) Bukkit.getServer(); @SuppressWarnings("resource") net.minecraft.server.v1_15_R1.CommandDispatcher nmsDispatcher = craftServer.getServer().commandDispatcher; nmsDispatcher.a(craftPlayer.getHandle()); }
Example 12
Source File: NMS_1_13.java From 1.13-Command-API with Apache License 2.0 | 5 votes |
@Override public void resendPackets(Player player) { CraftPlayer craftPlayer = (CraftPlayer) player; CraftServer craftServer = (CraftServer) Bukkit.getServer(); net.minecraft.server.v1_13_R1.CommandDispatcher nmsDispatcher = craftServer.getServer().commandDispatcher; nmsDispatcher.a(craftPlayer.getHandle()); }
Example 13
Source File: Reflection.java From FastAsyncWorldedit with GNU General Public License v3.0 | 5 votes |
/** * Gets the version string from the package name of the CraftBukkit server implementation. * This is needed to bypass the JAR package name changing on each update. * * @return The version string of the OBC and NMS packages, <em>including the trailing dot</em>. */ public synchronized static String getVersion() { if (_versionString == null) { if (Bukkit.getServer() == null) { // The server hasn't started, static initializer call? return null; } String name = Bukkit.getServer().getClass().getPackage().getName(); _versionString = name.substring(name.lastIndexOf('.') + 1) + "."; } return _versionString; }
Example 14
Source File: NMS_1_16_R1.java From 1.13-Command-API with Apache License 2.0 | 5 votes |
@Override public void resendPackets(Player player) { CraftPlayer craftPlayer = (CraftPlayer) player; CraftServer craftServer = (CraftServer) Bukkit.getServer(); net.minecraft.server.v1_16_R1.CommandDispatcher nmsDispatcher = craftServer.getServer().getCommandDispatcher(); nmsDispatcher.a(craftPlayer.getHandle()); }
Example 15
Source File: PingInjector.java From PingAPI with MIT License | 5 votes |
/** * Constructs a new PingInjector and gets the list of open NetworkManager instances */ public PingInjector() { try { CraftServer craftserver = (CraftServer) Bukkit.getServer(); Field console = craftserver.getClass().getDeclaredField("console"); console.setAccessible(true); this.server = (MinecraftServer) console.get(craftserver); ServerConnection conn = this.server.aq(); networkManagers = Collections.synchronizedList((List<?>) this.getNetworkManagerList(conn)); } catch(IllegalAccessException | NoSuchFieldException e) { e.printStackTrace(); } }
Example 16
Source File: CraftMinecartCommand.java From Kettle with GNU General Public License v3.0 | 4 votes |
@Override public Server getServer() { return Bukkit.getServer(); }
Example 17
Source File: Helper.java From helper with MIT License | 4 votes |
public static Server server() { return Bukkit.getServer(); }
Example 18
Source File: ServerCommandSender.java From Thermos with GNU General Public License v3.0 | 4 votes |
public Server getServer() { return Bukkit.getServer(); }
Example 19
Source File: CommonReflection.java From EchoPet with GNU General Public License v3.0 | 4 votes |
/** * 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!"); } }
Example 20
Source File: ServerCommandSender.java From Kettle with GNU General Public License v3.0 | 4 votes |
public Server getServer() { return Bukkit.getServer(); }