当前位置: 首页>>代码示例>>Java>>正文


Java Server类代码示例

本文整理汇总了Java中org.bukkit.Server的典型用法代码示例。如果您正苦于以下问题:Java Server类的具体用法?Java Server怎么用?Java Server使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


Server类属于org.bukkit包,在下文中一共展示了Server类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: mockPlugin

import org.bukkit.Server; //导入依赖的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.Server; //导入依赖的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.Server; //导入依赖的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.Server; //导入依赖的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.Server; //导入依赖的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: SurvivalGameLoop

import org.bukkit.Server; //导入依赖的package包/类
/**
 * Constructor
 *
 * @param plugin Parent plugin
 * @param server Server instance
 * @param game Game instance
 */
public SurvivalGameLoop(JavaPlugin plugin, Server server, SurvivalGame game)
{
    this.game = game;
    this.plugin = plugin;
    this.server = server;
    this.world = server.getWorlds().get(0);
    this.objectives = new ConcurrentHashMap<>();

    this.seconds = 0;
    this.minutes = 0;
    this.episode = 1;

    this.episodeEnabled = false;
    this.blocksProtected = true;
    this.netherClosed = false;

    this.createWaitingBlockRemovingEvent();
}
 
开发者ID:SamaGames,项目名称:SurvivalAPI,代码行数:26,代码来源:SurvivalGameLoop.java

示例7: ReplaceCharBroadcastPlayerMoreGeneral

import org.bukkit.Server; //导入依赖的package包/类
public static void ReplaceCharBroadcastPlayerMoreGeneral(String str, Server server, Player player) {
	if (ConfigGlobal.getConfig().getBoolean("Plugin.Use.PlaceholderAPI")) {
		Bukkit.broadcastMessage(ChatColor.translateAlternateColorCodes('&', PlaceholderAPI.setPlaceholders(player, str)
				.replaceAll("%player%", player.getName())
				.replaceAll("%DELAY%", String.valueOf(DelaychatCommand.delay))
				.replaceAll("%ping%", String.valueOf(PingCommand.getPing(player)))
				.replaceAll("%tps%", String.valueOf(Tps.getTPS()))
				.replaceAll("%timedelaypvcji%", String.valueOf(ConfigGPlayerVisibility.getConfig().getInt("PV.Option.Item-Delay.Delay")))
				.replaceAll("%timedelaypvcommands%", String.valueOf(ConfigCPlayerOption.getConfig().getInt("PlayerOption.PlayerVisivility.Delay.Delay")))
				));
	} else {
		Bukkit.broadcastMessage(ChatColor.translateAlternateColorCodes('&', str)
				.replaceAll("%player%", player.getName())
				.replaceAll("%DELAY%", String.valueOf(DelaychatCommand.delay))
				.replaceAll("%ping%", String.valueOf(PingCommand.getPing(player)))
				.replaceAll("%tps%", String.valueOf(Tps.getTPS()))
				.replaceAll("%timedelaypvcji%", String.valueOf(ConfigGPlayerVisibility.getConfig().getInt("PV.Option.Item-Delay.Delay")))
				.replaceAll("%timedelaypvcommands%", String.valueOf(ConfigCPlayerOption.getConfig().getInt("PlayerOption.PlayerVisivility.Delay.Delay")))
				);
	}
}
 
开发者ID:DianoxDragon,项目名称:UltimateSpawn,代码行数:22,代码来源:PlaceHolderMessageUtils.java

示例8: getOnlinePlayers

import org.bukkit.Server; //导入依赖的package包/类
/**
 * Gets the online player (backwards compatibility)
 *
 * @return online player amount
 */
private int getOnlinePlayers() {
    try {
        Method onlinePlayerMethod = Server.class.getMethod("getOnlinePlayers");
        if (onlinePlayerMethod.getReturnType().equals(Collection.class)) {
            return ((Collection<?>) onlinePlayerMethod.invoke(Bukkit.getServer())).size();
        } else {
            return ((Player[]) onlinePlayerMethod.invoke(Bukkit.getServer())).length;
        }
    } catch (Exception ex) {
        if (debug) {
            Bukkit.getLogger().log(Level.INFO, "[Metrics] " + ex.getMessage());
        }
    }

    return 0;
}
 
开发者ID:EndlessCodeGroup,项目名称:RPGInventory,代码行数:22,代码来源:Metrics.java

示例9: createMockServer

import org.bukkit.Server; //导入依赖的package包/类
public static Server createMockServer() {
    ConsoleCommandSender commandSender = (ConsoleCommandSender) createCommandSender();
    Server server = mock(Server.class);
    when(server.getLogger()).thenReturn(Logger.getGlobal());
    when(server.getPluginManager()).thenReturn(
            new SimplePluginManager(server, new SimpleCommandMap(server)));
    when(server.getItemFactory()).thenReturn(new MockItemFactory());
    doAnswer(invocation -> new MockInventory(InventoryType.CHEST, invocation.getArgument(1), invocation.getArgument(2)))
            .when(server).createInventory(any(), anyInt(), anyString());
    when(server.getBukkitVersion()).thenReturn("1.0");
    when(server.getConsoleSender()).thenReturn(commandSender);
    doAnswer(invocation -> createMockWorld())
            .when(server).getWorld(anyString());

    return server;
}
 
开发者ID:EntryPointKR,项目名称:MCLibrary,代码行数:17,代码来源:MockFactory.java

示例10: exec

import org.bukkit.Server; //导入依赖的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

示例11: onCommand

import org.bukkit.Server; //导入依赖的package包/类
public boolean onCommand(CommandSender sender, String label, String[] args) {
    JavaPlugin plugin = CommandManager.plugin;
    Server server = plugin.getServer();

    if (args.length > 0) {
        if (!sender.hasPermission("exprate.change")) {
            sender.sendMessage("仅管理员可改变当前服务器经验倍率");
            return true;
        }
        plugin.getConfig().set("EXP_RATE", Integer.valueOf(args[0]));
        server.broadcastMessage(ChatColor.BLUE + "服务器经验倍率调整为" + ChatColor.GREEN + plugin.getConfig().getInt("EXP_RATE"));
        plugin.saveConfig();
    } else {
        sender.sendMessage(ChatColor.BLUE + "当前服务器经验倍率为" + ChatColor.GREEN + plugin.getConfig().getInt("EXP_RATE"));
    }
    return true;
}
 
开发者ID:kncxstudio,项目名称:BasicSurvivalPlus,代码行数:18,代码来源:ExpRateChangeCommand.java

示例12: setUp

import org.bukkit.Server; //导入依赖的package包/类
@Before
public void setUp() throws Exception {
    Configuration config = new Configuration(File.createTempFile("SignEdit-", "-config.yml"));
    spyConfig = spy(config);
    listener = new Interact();
    doReturn(false).when(spyConfig).writeFullConfig(new YamlConfiguration());

    uiSignSubcommand = mock(UiSignSubcommand.class);
    whenNew(UiSignSubcommand.class).withAnyArguments().thenReturn(uiSignSubcommand);

    signCommand = new SignCommand(spyConfig, listener);

    player = mock(Player.class);
    command = mock(Command.class);
    sign = mock(Sign.class);
    block = mock(Block.class);
    when(player.hasPermission("SignEdit.use")).thenReturn(true);
    when(block.getState()).thenReturn(sign);

    server = mock(Server.class);
    pluginManager = mock(PluginManager.class);
    mockStatic(Bukkit.class);
    when(Bukkit.getServer()).thenReturn(server);
    when(server.getPluginManager()).thenReturn(pluginManager);
}
 
开发者ID:Deltik,项目名称:SignEdit,代码行数:26,代码来源:SignEditTest.java

示例13: getOnlinePlayers

import org.bukkit.Server; //导入依赖的package包/类
/**
 * Gets the online player (backwards compatibility)
 * 
 * @return online player amount
 */
private int getOnlinePlayers() {
    try {
        Method onlinePlayerMethod = Server.class.getMethod("getOnlinePlayers");
        if(onlinePlayerMethod.getReturnType().equals(Collection.class)) {
            return ((Collection<?>)onlinePlayerMethod.invoke(Bukkit.getServer())).size();
        } else {
            return ((Player[])onlinePlayerMethod.invoke(Bukkit.getServer())).length;
        }
    } catch (Exception ex) {
        if (debug) {
            Bukkit.getLogger().log(Level.INFO, "[Metrics] " + ex.getMessage());
        }
    }
    
    return 0;
}
 
开发者ID:JoelGodOfwar,项目名称:SinglePlayerSleep,代码行数:22,代码来源:MetricsLite.java

示例14: onPlayerJoin

import org.bukkit.Server; //导入依赖的package包/类
@EventHandler(ignoreCancelled = true)
void onPlayerJoin(PlayerJoinEvent event) {
    Player player = event.getPlayer();
    String playerName = player.getName();
    if (!status.contains(playerName)) status.add(player.getName());

    // Schedule a command executor task
    this.plugin.getServer().getScheduler().scheduleSyncDelayedTask(plugin, () -> {
        Server server = Bukkit.getServer();
        if (plugin.messages.containsKey(playerName)) {
            // Finally let's execute command!
            String command = plugin.messages.get(playerName);
            if (command.charAt(command.length() - 2) == '@') {
                command = command.substring(0, command.length() - 2);
                player.performCommand(command);
            } else {
                server.dispatchCommand(server.getConsoleSender(), command);
            }
            plugin.messages.remove(playerName);
        }
    }, 10L);

    // Schedule a slight delay (this prevents a player for reusing portal on target server)
    this.plugin.getServer().getScheduler().scheduleSyncDelayedTask(plugin, () -> status.remove(playerName), 40L);
}
 
开发者ID:worldbeater,项目名称:CutePortals,代码行数:26,代码来源:EventListener.java

示例15: getOnlinePlayers

import org.bukkit.Server; //导入依赖的package包/类
/**
 * Gets the online player (backwards compatibility)
 *
 * @return online player amount
 */
private int getOnlinePlayers() {
    try {
        Method onlinePlayerMethod = Server.class.getMethod("getOnlinePlayers");
        if(onlinePlayerMethod.getReturnType().equals(Collection.class)) {
            return ((Collection<?>)onlinePlayerMethod.invoke(Bukkit.getServer())).size();
        } else {
            return ((Player[])onlinePlayerMethod.invoke(Bukkit.getServer())).length;
        }
    } catch (Exception ex) {
        if (debug) {
            Bukkit.getLogger().log(Level.INFO, "[Metrics] " + ex.getMessage());
        }
    }

    return 0;
}
 
开发者ID:worldbeater,项目名称:CutePortals,代码行数:22,代码来源:Metrics.java


注:本文中的org.bukkit.Server类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。