当前位置: 首页>>代码示例>>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;未经允许,请勿转载。