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


Java Bukkit.setServer方法代碼示例

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


在下文中一共展示了Bukkit.setServer方法的9個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的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: 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,代碼來源:StatsSQLiteControllerTest.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,代碼來源:PetMetaSQLiteControllerIT.java

示例7: mock

import org.bukkit.Bukkit; //導入方法依賴的package包/類
/**
 * Start mocking the <code>Bukkit</code> singleton. Also returns the
 * {@link ServerMock} that was created for ease of use.
 * 
 * @return The created {@link ServerMock}.
 */
public static ServerMock mock()
{
	if (mock != null)
	{
		throw new IllegalStateException("Already mocking");
	}

	mock = new ServerMock();
	Bukkit.setServer(mock);
	return mock;
}
 
開發者ID:seeseemelk,項目名稱:MockBukkit,代碼行數:18,代碼來源:MockBukkit.java

示例8: setServerInstanceToNull

import org.bukkit.Bukkit; //導入方法依賴的package包/類
@Test
public void setServerInstanceToNull()
{
	ServerMock server = new ServerMock();
	Bukkit.setServer(server);
	assumeNotNull(Bukkit.getServer());
	MockBukkit.setServerInstanceToNull();
	assertNull(Bukkit.getServer());
}
 
開發者ID:seeseemelk,項目名稱:MockBukkit,代碼行數:10,代碼來源:MockBukkitTest.java

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