Search in sources :

Example 1 with WorldClientLocal

use of io.xol.chunkstories.world.WorldClientLocal in project chunkstories by Hugobros3.

the class ChatManager method processTextInput.

private void processTextInput(String input) {
    String username = ingame.getGameWindow().getClient().username();
    if (input.startsWith("/")) {
        String chatMsg = input;
        chatMsg = chatMsg.substring(1, chatMsg.length());
        String cmdName = chatMsg.toLowerCase();
        String[] args = {};
        if (chatMsg.contains(" ")) {
            cmdName = chatMsg.substring(0, chatMsg.indexOf(" "));
            args = chatMsg.substring(chatMsg.indexOf(" ") + 1, chatMsg.length()).split(" ");
        }
        if (ingame.getGameWindow().getClient().getPluginManager().dispatchCommand(Client.getInstance().getPlayer(), cmdName, args)) {
            if (sent.size() == 0 || !sent.get(0).equals(input)) {
                sent.add(0, input);
                sentMessages++;
            }
            return;
        } else if (cmdName.equals("plugins")) {
            String list = "";
            Iterator<ChunkStoriesPlugin> i = ingame.getGameWindow().getClient().getPluginManager().activePlugins();
            while (i.hasNext()) {
                ChunkStoriesPlugin plugin = i.next();
                list += plugin.getName() + (i.hasNext() ? ", " : "");
            }
            if (Client.getInstance().getWorld() instanceof WorldClientLocal)
                insert("#00FFD0" + i + " active client [master] plugins : " + list);
            else
                insert("#74FFD0" + i + " active client [remote] plugins : " + list);
            if (sent.size() == 0 || !sent.get(0).equals(input)) {
                sent.add(0, input);
                sentMessages++;
            }
        } else if (cmdName.equals("mods")) {
            String list = "";
            int i = 0;
            for (Mod mod : Client.getInstance().getContent().modsManager().getCurrentlyLoadedMods()) {
                i++;
                list += mod.getModInfo().getName() + (i == Client.getInstance().getContent().modsManager().getCurrentlyLoadedMods().size() ? "" : ", ");
            }
            if (Client.getInstance().getWorld() instanceof WorldClientLocal)
                insert("#FF0000" + i + " active client [master] mods : " + list);
            else
                insert("#FF7070" + i + " active client [remote] mods : " + list);
            if (sent.size() == 0 || !sent.get(0).equals(input)) {
                sent.add(0, input);
                sentMessages++;
            }
        }
    }
    if (input.equals("/locclear")) {
        chat.clear();
    } else if (input.equals("I am Mr Debug")) {
        // it was you this whole time
        ClientLimitations.isDebugAllowed = true;
    }
    if (ingame.getGameWindow().getClient().getWorld() instanceof WorldClientRemote)
        ((WorldClientRemote) ingame.getGameWindow().getClient().getWorld()).getConnection().sendTextMessage("chat/" + input);
    else
        insert(ColorsTools.getUniqueColorPrefix(username) + username + "#FFFFFF > " + input);
    System.out.println(username + " > " + input);
    if (sent.size() == 0 || !sent.get(0).equals(input)) {
        sent.add(0, input);
        sentMessages++;
    }
}
Also used : Mod(io.xol.chunkstories.api.content.mods.Mod) ChunkStoriesPlugin(io.xol.chunkstories.api.plugin.ChunkStoriesPlugin) Iterator(java.util.Iterator) WorldClientRemote(io.xol.chunkstories.world.WorldClientRemote) WorldClientLocal(io.xol.chunkstories.world.WorldClientLocal)

Aggregations

Mod (io.xol.chunkstories.api.content.mods.Mod)1 ChunkStoriesPlugin (io.xol.chunkstories.api.plugin.ChunkStoriesPlugin)1 WorldClientLocal (io.xol.chunkstories.world.WorldClientLocal)1 WorldClientRemote (io.xol.chunkstories.world.WorldClientRemote)1 Iterator (java.util.Iterator)1