當前位置: 首頁>>代碼示例>>Java>>正文


Java Bukkit.getServer方法代碼示例

本文整理匯總了Java中org.bukkit.Bukkit.getServer方法的典型用法代碼示例。如果您正苦於以下問題:Java Bukkit.getServer方法的具體用法?Java Bukkit.getServer怎麽用?Java Bukkit.getServer使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在org.bukkit.Bukkit的用法示例。


在下文中一共展示了Bukkit.getServer方法的14個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: mockPlugin

import org.bukkit.Bukkit; //導入方法依賴的package包/類
private static Plugin mockPlugin() {
    final YamlConfiguration configuration = new YamlConfiguration();
    configuration.set("sql.enabled", false);
    configuration.set("sql.host", "localhost");
    configuration.set("sql.port", 3306);
    configuration.set("sql.database", "db");
    configuration.set("sql.username", "root");
    configuration.set("sql.password", "");
    final Plugin plugin = mock(Plugin.class);
    if (Bukkit.getServer() == null) {
        final Server server = mock(Server.class);
        when(server.getLogger()).thenReturn(Logger.getGlobal());
        Bukkit.setServer(server);
    }
    new File("PetBlocks.db").delete();
    when(plugin.getDataFolder()).thenReturn(new File("PetBlocks"));
    when(plugin.getConfig()).thenReturn(configuration);
    when(plugin.getResource(any(String.class))).thenAnswer(invocationOnMock -> {
        final String file = invocationOnMock.getArgument(0);
        return Thread.currentThread().getContextClassLoader().getResourceAsStream(file);
    });
    return plugin;
}
 
開發者ID:Shynixn,項目名稱:PetBlocks,代碼行數:24,代碼來源:PlayerMetaSQLiteControllerIT.java

示例2: mockPlugin

import org.bukkit.Bukkit; //導入方法依賴的package包/類
private static Plugin mockPlugin() {
    final YamlConfiguration configuration = new YamlConfiguration();
    configuration.set("sql.enabled", false);
    configuration.set("sql.host", "localhost");
    configuration.set("sql.port", 3306);
    configuration.set("sql.database", "db");
    configuration.set("sql.username", "root");
    configuration.set("sql.password", "");
    final Plugin plugin = mock(Plugin.class);
    final Server server = mock(Server.class);
    when(server.getLogger()).thenReturn(Logger.getGlobal());
    if (Bukkit.getServer() == null)
        Bukkit.setServer(server);
    new File("BlockBall/BlockBall.db").delete();
    when(plugin.getDataFolder()).thenReturn(new File("BlockBall"));
    when(plugin.getConfig()).thenReturn(configuration);
    when(plugin.getResource(any(String.class))).thenAnswer(invocationOnMock -> {
        final String file = invocationOnMock.getArgument(0);
        return Thread.currentThread().getContextClassLoader().getResourceAsStream(file);
    });
    return plugin;
}
 
開發者ID:Shynixn,項目名稱:BlockBall,代碼行數:23,代碼來源:StatsMySQLControllerTest.java

示例3: mockPlugin

import org.bukkit.Bukkit; //導入方法依賴的package包/類
private static Plugin mockPlugin() {
    final YamlConfiguration configuration = new YamlConfiguration();
    configuration.set("sql.enabled", false);
    configuration.set("sql.host", "localhost");
    configuration.set("sql.port", 3306);
    configuration.set("sql.database", "db");
    configuration.set("sql.username", "root");
    configuration.set("sql.password", "");
    final Plugin plugin = mock(Plugin.class);
    final Server server = mock(Server.class);
    when(server.getLogger()).thenReturn(Logger.getGlobal());
    if(Bukkit.getServer() == null)
        Bukkit.setServer(server);
    new File("BlockBall/BlockBall.db").delete();
    when(plugin.getDataFolder()).thenReturn(new File("BlockBall"));
    when(plugin.getConfig()).thenReturn(configuration);
    when(plugin.getResource(any(String.class))).thenAnswer(invocationOnMock -> {
        final String file = invocationOnMock.getArgument(0);
        return Thread.currentThread().getContextClassLoader().getResourceAsStream(file);
    });
    return plugin;
}
 
開發者ID:Shynixn,項目名稱:BlockBall,代碼行數:23,代碼來源:PlayerMetaMySQLControllerTest.java

示例4: mockPlugin

import org.bukkit.Bukkit; //導入方法依賴的package包/類
private static Plugin mockPlugin() {
    final YamlConfiguration configuration = new YamlConfiguration();
    configuration.set("sql.enabled", false);
    configuration.set("sql.host", "localhost");
    configuration.set("sql.port", 3306);
    configuration.set("sql.database", "db");
    configuration.set("sql.username", "root");
    configuration.set("sql.password", "");
    final Plugin plugin = mock(Plugin.class);
    final Server server = mock(Server.class);
    when(server.getLogger()).thenReturn(Logger.getGlobal());
    if(Bukkit.getServer() == null)
        Bukkit.setServer(server);
    Factory.disable();
    new File("BlockBall/BlockBall.db").delete();
    when(plugin.getDataFolder()).thenReturn(new File("BlockBall"));
    when(plugin.getConfig()).thenReturn(configuration);
    when(plugin.getResource(any(String.class))).thenAnswer(invocationOnMock -> {
        final String file = invocationOnMock.getArgument(0);
        return Thread.currentThread().getContextClassLoader().getResourceAsStream(file);
    });
    return plugin;
}
 
開發者ID:Shynixn,項目名稱:BlockBall,代碼行數:24,代碼來源:PlayerMetaSQLiteControllerTest.java

示例5: exec

import org.bukkit.Bukkit; //導入方法依賴的package包/類
@Override
protected void exec(CommandSender sender) {
	/*
	 * ======== Zabbigot (Player: 0/20) ========
	 * TPS: [####################] 20.00 (100.0%)
	 * MEM: [###################_] 7832.4MB/8192.0MB (95.6%)
	 */

	Server server = Bukkit.getServer();
	sender.sendMessage(ChatColor.GREEN + "========" + ChatColor.RESET
			+ " Zabbigot (Player: "
			+ server.getOnlinePlayers().size()
			+ "/"
			+ server.getMaxPlayers()
			+ ") " + ChatColor.GREEN + "========");

	sender.sendMessage(formatTps(watcher.getTPS()));
	sender.sendMessage(formatMem());
}
 
開發者ID:HimaJyun,項目名稱:Zabbigot,代碼行數:20,代碼來源:Show.java

示例6: mockPlugin

import org.bukkit.Bukkit; //導入方法依賴的package包/類
private static Plugin mockPlugin() {
    final Server server = mock(Server.class);
    when(server.getLogger()).thenReturn(Logger.getGlobal());
    if(Bukkit.getServer() == null)
        Bukkit.setServer(server);
    try {
        final Field field = PetBlocksPlugin.class.getDeclaredField("logger");
        field.setAccessible(true);
        field.set(null, Logger.getGlobal());
    } catch (IllegalAccessException | NoSuchFieldException e) {
        Assert.fail();
    }
    final YamlConfiguration configuration = new YamlConfiguration();
    configuration.set("sql.enabled",false);
    configuration.set("sql.host", "localhost");
    configuration.set("sql.port", 3306);
    configuration.set("sql.database", "db");
    configuration.set("sql.username", "root");
    configuration.set("sql.password", "");
    final Plugin plugin = mock(Plugin.class);
    new File("PetBlocks.db").delete();
    when(plugin.getDataFolder()).thenReturn(new File("PetBlocks"));
    when(plugin.getConfig()).thenReturn(configuration);
    when(plugin.getResource(any(String.class))).thenAnswer(invocationOnMock -> {
        final String file = invocationOnMock.getArgument(0);
        return Thread.currentThread().getContextClassLoader().getResourceAsStream(file);
    });
    return plugin;
}
 
開發者ID:Shynixn,項目名稱:PetBlocks,代碼行數:30,代碼來源:ParticleEffectMetaSQLiteControllerIT.java

示例7: getVersion

import org.bukkit.Bukkit; //導入方法依賴的package包/類
/**
 * 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;
}
 
開發者ID:SamaGames,項目名稱:SamaGamesAPI,代碼行數:18,代碼來源:Reflection.java

示例8: getVersion

import org.bukkit.Bukkit; //導入方法依賴的package包/類
/**
 * 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;
}
 
開發者ID:edasaki,項目名稱:ZentrelaCore,代碼行數:18,代碼來源:Reflection.java

示例9: getPackageName

import org.bukkit.Bukkit; //導入方法依賴的package包/類
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_7_R3";
    }
}
 
開發者ID:SamaGames,項目名稱:SurvivalAPI,代碼行數:12,代碼來源:NbtFactory.java

示例10: initialize

import org.bukkit.Bukkit; //導入方法依賴的package包/類
protected RemappedClassHandler initialize() throws UnsupportedOperationException, IllegalStateException {
    if (Bukkit.getServer() == null || !Bukkit.getServer().getVersion().contains("MCPC-Plus")) {
        throw new UnsupportedOperationException("Remapper not available!");
    }

    this.remapper = ClassTemplate.create(this.classLoader.getClass()).getField("remapper").get(getClass().getClassLoader());

    if (this.remapper == null) {
        throw new IllegalStateException("Remapper is NULL!");
    }

    Class<?> remapperClass = this.remapper.getClass();
    this.map = ClassTemplate.create(remapperClass).getMethod("map", String.class);
    return this;
}
 
開發者ID:Borlea,項目名稱:EchoPet,代碼行數:16,代碼來源:RemappedClassHandler.java

示例11: getServer

import org.bukkit.Bukkit; //導入方法依賴的package包/類
@Override
public Server getServer() {
    return Bukkit.getServer();
}
 
開發者ID:UraniumMC,項目名稱:Uranium,代碼行數:5,代碼來源:CraftMinecartCommand.java

示例12: server

import org.bukkit.Bukkit; //導入方法依賴的package包/類
public static Server server() {
    return Bukkit.getServer();
}
 
開發者ID:lucko,項目名稱:helper,代碼行數:4,代碼來源:Helper.java

示例13: getServer

import org.bukkit.Bukkit; //導入方法依賴的package包/類
public Server getServer() {
	return Bukkit.getServer();
}
 
開發者ID:GigaGamma,項目名稱:SuperiorCraft,代碼行數:4,代碼來源:SuperiorCraftPackage.java

示例14: injectServer

import org.bukkit.Bukkit; //導入方法依賴的package包/類
public static void injectServer(Server server) {
    if (Bukkit.getServer() == null) {
        Bukkit.setServer(server);
    }
}
 
開發者ID:EntryPointKR,項目名稱:MCLibrary,代碼行數:6,代碼來源:Injector.java


注:本文中的org.bukkit.Bukkit.getServer方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。