Search in sources :

Example 36 with ISoliniaPlayer

use of com.solinia.solinia.Interfaces.ISoliniaPlayer in project solinia3-core by mixxit.

the class CommandForceLevel method onCommand.

@Override
public boolean onCommand(CommandSender sender, Command cmd, String label, String[] args) {
    if (!(sender instanceof Player) && !(sender instanceof CommandSender))
        return false;
    if (sender instanceof Player) {
        Player player = (Player) sender;
        if (!player.isOp()) {
            player.sendMessage("This is an operator only command");
            return false;
        }
    }
    if (args.length < 2) {
        sender.sendMessage("Insufficient arguments (<mcname> <level>)");
        return false;
    }
    String name = args[0];
    int level = Integer.parseInt(args[1]);
    if (level < 1) {
        sender.sendMessage("Level must be greater than 0");
    }
    boolean found = false;
    Double experience = Utils.getExperienceRequirementForLevel(level);
    for (Player currentplayer : Bukkit.getServer().getOnlinePlayers()) {
        if (!currentplayer.getName().toUpperCase().equals(name.toUpperCase()))
            continue;
        try {
            ISoliniaPlayer solplayer = SoliniaPlayerAdapter.Adapt(currentplayer);
            found = true;
            if (found) {
                solplayer.setExperience(experience);
                sender.sendMessage("* Player " + name + " set to " + level);
                solplayer.updateMaxHp();
                return true;
            } else {
                sender.sendMessage("Force level command failed. Is that a valid level and a valid online mcaccount?");
                return false;
            }
        } catch (CoreStateInitException e) {
            e.printStackTrace();
            sender.sendMessage(e.getMessage());
        }
    }
    if (found == false) {
        sender.sendMessage("Failed to find player by that minecraft username");
        return false;
    }
    return true;
}
Also used : ISoliniaPlayer(com.solinia.solinia.Interfaces.ISoliniaPlayer) Player(org.bukkit.entity.Player) CoreStateInitException(com.solinia.solinia.Exceptions.CoreStateInitException) CommandSender(org.bukkit.command.CommandSender) ConsoleCommandSender(org.bukkit.command.ConsoleCommandSender) ISoliniaPlayer(com.solinia.solinia.Interfaces.ISoliniaPlayer)

Example 37 with ISoliniaPlayer

use of com.solinia.solinia.Interfaces.ISoliniaPlayer in project solinia3-core by mixxit.

the class CommandGroup method onCommand.

@Override
public boolean onCommand(CommandSender sender, Command cmd, String label, String[] args) {
    // TODO Auto-generated method stub
    if (!(sender instanceof Player)) {
        return false;
    }
    Player player = (Player) sender;
    try {
        ISoliniaPlayer solplayer = SoliniaPlayerAdapter.Adapt(player);
        String groupname = "You have no group";
        if (solplayer.getGroup() != null) {
            UUID ownerid = solplayer.getGroup().getOwner();
            Player owner = Bukkit.getPlayer(ownerid);
            if (owner != null) {
                groupname = owner.getDisplayName() + "'s group";
            }
        }
        if (args.length == 0) {
            player.sendMessage("Your group: " + groupname);
            player.sendMessage("Valid commands are: /group invite <name>, /group list, /group accept, /group decline, /group leave,/g <msg>");
            return true;
        }
        if (args[0].equals("invite")) {
            if (args.length == 2) {
                Player target = Bukkit.getPlayer(args[1]);
                if (target != null) {
                    if (!target.equals(player)) {
                        StateManager.getInstance().invitePlayerToGroup(player, target);
                    } else {
                        player.sendMessage("You cannot invite yourself to a group");
                    }
                } else {
                    player.sendMessage(args[1] + " is not online");
                }
                return true;
            } else {
                player.sendMessage("Incorrect arguments [" + args.length + "] for group invite - see /group");
                return true;
            }
        }
        if (args[0].equals("leave")) {
            if (solplayer.getGroup() == null)
                return true;
            solplayer.getGroup().removePlayer(player);
            return true;
        }
        if (args[0].equals("list")) {
            if (solplayer.getGroup() == null)
                return true;
            solplayer.getGroup().sendGroupList(player);
            return true;
        }
        if (args[0].equals("accept")) {
            StateManager.getInstance().acceptGroupInvite(player);
            return true;
        }
        if (args[0].equals("decline")) {
            StateManager.getInstance().declineGroupInvite(player);
            return true;
        }
    } catch (CoreStateInitException e) {
        sender.sendMessage(e.getMessage());
    }
    return true;
}
Also used : ISoliniaPlayer(com.solinia.solinia.Interfaces.ISoliniaPlayer) Player(org.bukkit.entity.Player) CoreStateInitException(com.solinia.solinia.Exceptions.CoreStateInitException) ISoliniaPlayer(com.solinia.solinia.Interfaces.ISoliniaPlayer) UUID(java.util.UUID)

Example 38 with ISoliniaPlayer

use of com.solinia.solinia.Interfaces.ISoliniaPlayer in project solinia3-core by mixxit.

the class CommandHideOoc method onCommand.

@Override
public boolean onCommand(CommandSender sender, Command cmd, String label, String[] args) {
    if (sender instanceof Player) {
        try {
            ISoliniaPlayer solPlayer = SoliniaPlayerAdapter.Adapt((Player) sender);
            if (solPlayer.isOocEnabled() == false) {
                solPlayer.setOocEnabled(true);
                sender.sendMessage("Ooc enabled");
            } else {
                solPlayer.setOocEnabled(false);
                sender.sendMessage("Ooc disabled");
            }
        } catch (CoreStateInitException e) {
            return false;
        }
        return true;
    }
    return false;
}
Also used : ISoliniaPlayer(com.solinia.solinia.Interfaces.ISoliniaPlayer) Player(org.bukkit.entity.Player) CoreStateInitException(com.solinia.solinia.Exceptions.CoreStateInitException) ISoliniaPlayer(com.solinia.solinia.Interfaces.ISoliniaPlayer)

Example 39 with ISoliniaPlayer

use of com.solinia.solinia.Interfaces.ISoliniaPlayer in project solinia3-core by mixxit.

the class CommandGrantTitle method onCommand.

@Override
public boolean onCommand(CommandSender sender, Command cmd, String label, String[] args) {
    if (!(sender instanceof Player) && !(sender instanceof CommandSender)) {
        sender.sendMessage("This is a Player/Console only command");
        return false;
    }
    if (sender instanceof Player) {
        Player player = (Player) sender;
        if (!player.isOp()) {
            player.sendMessage("This is an operator only command");
            return true;
        }
    }
    if (args.length < 2)
        return false;
    if (Bukkit.getPlayer(args[0]) == null) {
        sender.sendMessage("Cannot find player");
        return true;
    }
    String targetTitle = "";
    int current = 0;
    for (String entry : args) {
        current++;
        if (current < 2)
            continue;
        targetTitle = targetTitle + entry + " ";
    }
    targetTitle = targetTitle.trim();
    try {
        ISoliniaPlayer solplayer = SoliniaPlayerAdapter.Adapt(Bukkit.getPlayer(args[0]));
        boolean success = solplayer.grantTitle(targetTitle);
        if (success)
            sender.sendMessage("Player title granted: " + targetTitle);
        else
            sender.sendMessage("Player already has title: " + targetTitle);
        return true;
    } catch (CoreStateInitException e) {
        // TODO Auto-generated catch block
        e.printStackTrace();
        sender.sendMessage(e.getMessage());
        return true;
    }
}
Also used : ISoliniaPlayer(com.solinia.solinia.Interfaces.ISoliniaPlayer) Player(org.bukkit.entity.Player) CoreStateInitException(com.solinia.solinia.Exceptions.CoreStateInitException) CommandSender(org.bukkit.command.CommandSender) ConsoleCommandSender(org.bukkit.command.ConsoleCommandSender) ISoliniaPlayer(com.solinia.solinia.Interfaces.ISoliniaPlayer)

Example 40 with ISoliniaPlayer

use of com.solinia.solinia.Interfaces.ISoliniaPlayer in project solinia3-core by mixxit.

the class SoliniaEntitySpells method removeSpell.

public void removeSpell(Plugin plugin, Integer spellId) {
    // Effect has worn off
    SoliniaActiveSpell activeSpell = activeSpells.get(spellId);
    if (activeSpell == null)
        return;
    boolean updateMaxHp = false;
    boolean updateDisguise = false;
    // Handle any effect removals needed
    for (ActiveSpellEffect effect : activeSpell.getActiveSpellEffects()) {
        switch(effect.getSpellEffectType()) {
            case TotalHP:
                updateMaxHp = true;
                break;
            case STA:
                updateMaxHp = true;
                break;
            case Illusion:
            case IllusionCopy:
            case IllusionOther:
            case IllusionPersistence:
            case IllusionaryTarget:
                updateDisguise = true;
                break;
        }
    }
    activeSpells.remove(spellId);
    if (updateMaxHp == true) {
        if (getLivingEntity() != null && getLivingEntity() instanceof Player) {
            try {
                ISoliniaPlayer solplayer = SoliniaPlayerAdapter.Adapt((Player) getLivingEntity());
                if (solplayer != null)
                    solplayer.updateMaxHp();
            } catch (CoreStateInitException e) {
            }
        }
    }
    if (updateDisguise == true) {
        if (getLivingEntity() != null)
            DisguiseAPI.undisguiseToAll(getLivingEntity());
    }
    // Check if bard song, may need to keep singing
    if (activeSpell.getSpell().isBardSong()) {
        if (getLivingEntityUUID().equals(activeSpell.getSourceUuid())) {
            try {
                if (getLivingEntity() != null) {
                    if (StateManager.getInstance().getEntityManager().getEntitySinging(getLivingEntity().getUniqueId()) != null) {
                        Integer singingId = StateManager.getInstance().getEntityManager().getEntitySinging(getLivingEntity().getUniqueId());
                        if (singingId != activeSpell.getSpellId()) {
                            ISoliniaLivingEntity solEntity = SoliniaLivingEntityAdapter.Adapt(getLivingEntity());
                            solEntity.emote(getLivingEntity().getCustomName() + "'s song comes to a close [" + activeSpell.getSpell().getName() + "]");
                        } else {
                            // Continue singing!
                            if (Bukkit.getEntity(activeSpell.getOwnerUuid()) instanceof LivingEntity && Bukkit.getEntity(activeSpell.getSourceUuid()) instanceof LivingEntity) {
                                boolean itemUseSuccess = activeSpell.getSpell().tryApplyOnEntity(plugin, (LivingEntity) Bukkit.getEntity(activeSpell.getSourceUuid()), (LivingEntity) Bukkit.getEntity(activeSpell.getOwnerUuid()));
                                return;
                            }
                        }
                    } else {
                    // skip
                    }
                }
            } catch (CoreStateInitException e) {
            // ignore
            }
        }
    }
}
Also used : ISoliniaLivingEntity(com.solinia.solinia.Interfaces.ISoliniaLivingEntity) LivingEntity(org.bukkit.entity.LivingEntity) Player(org.bukkit.entity.Player) ISoliniaPlayer(com.solinia.solinia.Interfaces.ISoliniaPlayer) ISoliniaLivingEntity(com.solinia.solinia.Interfaces.ISoliniaLivingEntity) CoreStateInitException(com.solinia.solinia.Exceptions.CoreStateInitException) ISoliniaPlayer(com.solinia.solinia.Interfaces.ISoliniaPlayer)

Aggregations

ISoliniaPlayer (com.solinia.solinia.Interfaces.ISoliniaPlayer)89 CoreStateInitException (com.solinia.solinia.Exceptions.CoreStateInitException)85 Player (org.bukkit.entity.Player)57 ISoliniaNPC (com.solinia.solinia.Interfaces.ISoliniaNPC)16 ISoliniaLivingEntity (com.solinia.solinia.Interfaces.ISoliniaLivingEntity)13 ISoliniaItem (com.solinia.solinia.Interfaces.ISoliniaItem)12 EventHandler (org.bukkit.event.EventHandler)11 LivingEntity (org.bukkit.entity.LivingEntity)10 ArrayList (java.util.ArrayList)9 UUID (java.util.UUID)9 SoliniaItemException (com.solinia.solinia.Exceptions.SoliniaItemException)8 TextComponent (net.md_5.bungee.api.chat.TextComponent)8 ItemStack (org.bukkit.inventory.ItemStack)8 CommandSender (org.bukkit.command.CommandSender)5 ConsoleCommandSender (org.bukkit.command.ConsoleCommandSender)5 Entity (org.bukkit.entity.Entity)5 Timestamp (java.sql.Timestamp)4 LocalDateTime (java.time.LocalDateTime)4 ComponentBuilder (net.md_5.bungee.api.chat.ComponentBuilder)4 HoverEvent (net.md_5.bungee.api.chat.HoverEvent)4