Search in sources :

Example 51 with CoreStateInitException

use of com.solinia.solinia.Exceptions.CoreStateInitException in project solinia3-core by mixxit.

the class Solinia3CorePlayerListener method onPlayerConsumeEvent.

@EventHandler
public void onPlayerConsumeEvent(PlayerItemConsumeEvent event) {
    if (event.isCancelled())
        return;
    try {
        ISoliniaItem item = SoliniaItemAdapter.Adapt(event.getItem());
        item.consume(plugin, event.getPlayer());
    } catch (SoliniaItemException | CoreStateInitException e) {
    }
}
Also used : ISoliniaItem(com.solinia.solinia.Interfaces.ISoliniaItem) CoreStateInitException(com.solinia.solinia.Exceptions.CoreStateInitException) SoliniaItemException(com.solinia.solinia.Exceptions.SoliniaItemException) EventHandler(org.bukkit.event.EventHandler)

Example 52 with CoreStateInitException

use of com.solinia.solinia.Exceptions.CoreStateInitException in project solinia3-core by mixxit.

the class Solinia3CorePlayerListener method onChat.

@EventHandler
public void onChat(AsyncPlayerChatEvent event) {
    if (event.isCancelled())
        return;
    SoliniaAsyncPlayerChatEvent soliniaevent;
    try {
        ISoliniaPlayer solplayer = SoliniaPlayerAdapter.Adapt(event.getPlayer());
        if (solplayer.getLanguage() == null || solplayer.getLanguage().equals("UNKNOWN")) {
            if (solplayer.getRace() == null) {
                event.getPlayer().sendMessage("You cannot speak until you set a race /setrace");
                Utils.CancelEvent(event);
                ;
                return;
            } else {
                solplayer.setLanguage(solplayer.getRace().getName().toUpperCase());
            }
        }
        soliniaevent = new SoliniaAsyncPlayerChatEvent(event, solplayer, event.getMessage());
        Bukkit.getPluginManager().callEvent(soliniaevent);
    } catch (CoreStateInitException e) {
        // TODO Auto-generated catch block
        e.printStackTrace();
    }
}
Also used : SoliniaAsyncPlayerChatEvent(com.solinia.solinia.Events.SoliniaAsyncPlayerChatEvent) CoreStateInitException(com.solinia.solinia.Exceptions.CoreStateInitException) ISoliniaPlayer(com.solinia.solinia.Interfaces.ISoliniaPlayer) EventHandler(org.bukkit.event.EventHandler)

Example 53 with CoreStateInitException

use of com.solinia.solinia.Exceptions.CoreStateInitException in project solinia3-core by mixxit.

the class Solinia3CorePlayerListener method onPlayerJoin.

@EventHandler
public void onPlayerJoin(PlayerJoinEvent event) {
    SoliniaPlayerJoinEvent soliniaevent;
    try {
        ISoliniaPlayer solplayer = SoliniaPlayerAdapter.Adapt(event.getPlayer());
        soliniaevent = new SoliniaPlayerJoinEvent(event, solplayer);
        solplayer.updateDisplayName();
        solplayer.updateMaxHp();
        Bukkit.getPluginManager().callEvent(soliniaevent);
        // patch
        if (solplayer.getClassObj() != null)
            solplayer.setChosenClass(true);
        else
            solplayer.setChosenClass(false);
        // patch
        if (solplayer.getRace() != null)
            solplayer.setChosenRace(true);
        else
            solplayer.setChosenRace(false);
        StateManager.getInstance().getChannelManager().sendToDiscordMC(solplayer, StateManager.getInstance().getChannelManager().getDefaultDiscordChannel(), event.getPlayer().getName() + "(" + solplayer.getFullName() + ") has joined the game");
    } catch (CoreStateInitException e) {
        event.getPlayer().kickPlayer("Server initialising");
    }
}
Also used : CoreStateInitException(com.solinia.solinia.Exceptions.CoreStateInitException) SoliniaPlayerJoinEvent(com.solinia.solinia.Events.SoliniaPlayerJoinEvent) ISoliniaPlayer(com.solinia.solinia.Interfaces.ISoliniaPlayer) EventHandler(org.bukkit.event.EventHandler)

Example 54 with CoreStateInitException

use of com.solinia.solinia.Exceptions.CoreStateInitException in project solinia3-core by mixxit.

the class ConfigurationManager method commitPlayersToCharacterLists.

private void commitPlayersToCharacterLists() {
    try {
        int count = 0;
        for (ISoliniaPlayer player : StateManager.getInstance().getPlayerManager().getPlayers()) {
            commitPlayerToCharacterLists(player);
            count++;
        }
        System.out.println("Commited " + count + " characters to the CharacterList repository");
    } catch (CoreStateInitException e) {
        // TODO Auto-generated catch block
        e.printStackTrace();
    }
}
Also used : CoreStateInitException(com.solinia.solinia.Exceptions.CoreStateInitException) ISoliniaPlayer(com.solinia.solinia.Interfaces.ISoliniaPlayer)

Example 55 with CoreStateInitException

use of com.solinia.solinia.Exceptions.CoreStateInitException in project solinia3-core by mixxit.

the class ChannelManager method sendItemListToDiscordChannel.

private void sendItemListToDiscordChannel(DiscordChannel discordChannel, String itemMatch) {
    try {
        String targetChannelId = getDefaultDiscordChannel();
        if (discordChannel.equals(DiscordChannel.ADMIN))
            targetChannelId = getAdminDiscordChannel();
        int itemId = 0;
        try {
            itemId = StateManager.getInstance().getConfigurationManager().getItem(Integer.parseInt(itemMatch)).getId();
        } catch (Exception e) {
        }
        if (itemId > 0) {
            ISoliniaItem item = StateManager.getInstance().getConfigurationManager().getItem(itemId);
            sendItemToDiscordChannel(discordChannel, item);
            return;
        }
        if (itemMatch.length() < 3) {
            sendToDiscordMC(null, targetChannelId, "Item search must be at least 3 characters: " + itemMatch);
            return;
        }
        List<ISoliniaItem> items = StateManager.getInstance().getConfigurationManager().getItemsByPartialName(itemMatch);
        if (items.size() > 20) {
            sendToDiscordMC(null, targetChannelId, "Item matched more than 20 items, please be more specific than " + itemMatch);
            return;
        }
        if (items.size() != 1) {
            List<String> matchingItemList = new ArrayList<String>();
            String currentLine = "";
            for (ISoliniaItem item : items) {
                if ((currentLine + "[" + item.getId() + "] " + item.getDisplayname() + " ").length() > 2000) {
                    matchingItemList.add(currentLine);
                    currentLine = "";
                }
                currentLine += "[" + item.getId() + "] " + item.getDisplayname() + " ";
            }
            if (!currentLine.equals("")) {
                matchingItemList.add(currentLine);
            }
            for (String line : matchingItemList) {
                sendToDiscordMC(null, targetChannelId, "Item [" + itemMatch + "] matched with: " + line);
            }
        } else {
            for (ISoliniaItem item : items) {
                sendItemToDiscordChannel(discordChannel, item);
            }
        }
    } catch (CoreStateInitException e) {
    // ignore it
    }
}
Also used : ISoliniaItem(com.solinia.solinia.Interfaces.ISoliniaItem) CoreStateInitException(com.solinia.solinia.Exceptions.CoreStateInitException) ArrayList(java.util.ArrayList) EventException(org.bukkit.event.EventException) CoreStateInitException(com.solinia.solinia.Exceptions.CoreStateInitException)

Aggregations

CoreStateInitException (com.solinia.solinia.Exceptions.CoreStateInitException)216 Player (org.bukkit.entity.Player)114 ISoliniaPlayer (com.solinia.solinia.Interfaces.ISoliniaPlayer)99 ISoliniaNPC (com.solinia.solinia.Interfaces.ISoliniaNPC)43 CommandSender (org.bukkit.command.CommandSender)42 ISoliniaLivingEntity (com.solinia.solinia.Interfaces.ISoliniaLivingEntity)41 ISoliniaItem (com.solinia.solinia.Interfaces.ISoliniaItem)36 ConsoleCommandSender (org.bukkit.command.ConsoleCommandSender)36 LivingEntity (org.bukkit.entity.LivingEntity)32 ArrayList (java.util.ArrayList)31 Entity (org.bukkit.entity.Entity)21 ItemStack (org.bukkit.inventory.ItemStack)20 SoliniaItemException (com.solinia.solinia.Exceptions.SoliniaItemException)17 ISoliniaSpell (com.solinia.solinia.Interfaces.ISoliniaSpell)16 EventHandler (org.bukkit.event.EventHandler)16 Timestamp (java.sql.Timestamp)13 TextComponent (net.md_5.bungee.api.chat.TextComponent)12 CraftEntity (org.bukkit.craftbukkit.v1_12_R1.entity.CraftEntity)11 CraftLivingEntity (org.bukkit.craftbukkit.v1_12_R1.entity.CraftLivingEntity)11 PathEntity (net.minecraft.server.v1_12_R1.PathEntity)10