當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。