Search in sources :

Example 6 with ISoliniaGroup

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

the class CoreState method invitePlayerToGroup.

public void invitePlayerToGroup(Player leader, Player member) {
    if (getPlayerInviteGroupID(member) != null) {
        leader.sendMessage("You cannot invite that player, they are already pending a group invite");
        return;
    }
    ISoliniaGroup inviteegroup = getGroupByMember(member.getUniqueId());
    ISoliniaGroup invitergroup = getGroupByMember(leader.getUniqueId());
    if (inviteegroup != null) {
        leader.sendMessage("You cannot invite that player, they are already in a group");
        return;
    }
    if (invitergroup == null) {
        // No group exists, create it
        invitergroup = createNewGroup(leader);
        leader.sendMessage("You have joined a new group");
    }
    if (invitergroup == null) {
        leader.sendMessage("Your group does not exist");
        return;
    }
    if (!invitergroup.getOwner().equals(leader.getUniqueId())) {
        leader.sendMessage("You cannot invite that player, you are not the group leader");
        return;
    }
    if (invitergroup.getMembers().size() > 5) {
        leader.sendMessage("You cannot invite that player, your group is already full");
        return;
    }
    groupinvites.put(member.getUniqueId(), invitergroup.getId());
    leader.sendMessage("Invited " + member.getDisplayName() + " to join your group");
    member.sendMessage("You have been invited to join " + leader.getName() + "'s group - /group accept | /group decline");
}
Also used : ISoliniaGroup(com.solinia.solinia.Interfaces.ISoliniaGroup)

Example 7 with ISoliniaGroup

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

the class Solinia3CorePlayerListener method onPlayerQuit.

@EventHandler
public void onPlayerQuit(PlayerQuitEvent event) {
    ISoliniaGroup group = StateManager.getInstance().getGroupByMember(event.getPlayer().getUniqueId());
    if (group != null) {
        StateManager.getInstance().removePlayerFromGroup(event.getPlayer());
    }
    StateManager.getInstance().getChannelManager().sendToDiscordMC(null, StateManager.getInstance().getChannelManager().getDefaultDiscordChannel(), event.getPlayer().getName() + " has quit the game");
}
Also used : ISoliniaGroup(com.solinia.solinia.Interfaces.ISoliniaGroup) EventHandler(org.bukkit.event.EventHandler)

Example 8 with ISoliniaGroup

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

the class SoliniaGroup method sendGroupList.

@Override
public void sendGroupList(Player player) {
    ISoliniaGroup group = StateManager.getInstance().getGroupByMember(player.getUniqueId());
    if (group == null) {
        player.sendMessage("Your group doesn't exist");
        return;
    }
    if (group.getMembers().size() > 0) {
        for (UUID memberid : group.getMembers()) {
            Player member = Bukkit.getPlayer(memberid);
            if (member != null) {
                String leader = "";
                if (member.getUniqueId().equals(group.getId())) {
                    leader = " - Leader";
                }
                player.sendMessage(member.getDisplayName() + leader);
            }
        }
    } else {
        player.sendMessage("Your group has no members");
    }
}
Also used : Player(org.bukkit.entity.Player) ISoliniaGroup(com.solinia.solinia.Interfaces.ISoliniaGroup) UUID(java.util.UUID)

Example 9 with ISoliniaGroup

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

the class SoliniaSpell method tryApplyOnEntity.

@Override
public boolean tryApplyOnEntity(Plugin plugin, LivingEntity sourceEntity, LivingEntity targetentity) {
    // Entity was targeted for this spell but is that the final location?
    try {
        switch(Utils.getSpellTargetType(getTargettype())) {
            case Self:
                return StateManager.getInstance().getEntityManager().addActiveEntitySpell(plugin, sourceEntity, this, sourceEntity);
            // Casts on self as holding signaculum
            case Corpse:
                return StateManager.getInstance().getEntityManager().addActiveEntitySpell(plugin, sourceEntity, this, sourceEntity);
            case Pet:
                if (sourceEntity instanceof Player) {
                    Player player = (Player) sourceEntity;
                    try {
                        LivingEntity pet = StateManager.getInstance().getEntityManager().getPet(player);
                        if (pet != null) {
                            return StateManager.getInstance().getEntityManager().addActiveEntitySpell(plugin, pet, this, sourceEntity);
                        }
                    } catch (CoreStateInitException e) {
                        e.printStackTrace();
                    }
                }
                return false;
            case TargetOptional:
                return StateManager.getInstance().getEntityManager().addActiveEntitySpell(plugin, targetentity, this, sourceEntity);
            case Target:
                return StateManager.getInstance().getEntityManager().addActiveEntitySpell(plugin, targetentity, this, sourceEntity);
            case Tap:
                return StateManager.getInstance().getEntityManager().addActiveEntitySpell(plugin, targetentity, this, sourceEntity);
            case TargetAETap:
                // Get entities around entity and attempt to apply, if any are successful, return true
                boolean tapsuccess = false;
                // TODO - should the ae range be read from a field of the spell?
                for (Entity e : targetentity.getNearbyEntities(10, 10, 10)) {
                    if (!(e instanceof LivingEntity))
                        continue;
                    boolean loopSuccess = StateManager.getInstance().getEntityManager().addActiveEntitySpell(plugin, (LivingEntity) e, this, sourceEntity);
                    if (loopSuccess == true)
                        tapsuccess = true;
                }
                boolean loopSuccess = StateManager.getInstance().getEntityManager().addActiveEntitySpell(plugin, (LivingEntity) targetentity, this, sourceEntity);
                if (loopSuccess == true)
                    tapsuccess = true;
                return tapsuccess;
            case AETarget:
                // Get entities around entity and attempt to apply, if any are successful, return true
                boolean success = false;
                // TODO - should the ae range be read from a field of the spell?
                for (Entity e : targetentity.getNearbyEntities(10, 10, 10)) {
                    if (!(e instanceof LivingEntity))
                        continue;
                    boolean loopSuccess2 = StateManager.getInstance().getEntityManager().addActiveEntitySpell(plugin, (LivingEntity) e, this, sourceEntity);
                    if (loopSuccess2 == true)
                        success = true;
                }
                boolean loopSuccess2 = StateManager.getInstance().getEntityManager().addActiveEntitySpell(plugin, (LivingEntity) targetentity, this, sourceEntity);
                if (loopSuccess2 == true)
                    success = true;
                return success;
            case GroupTeleport:
                boolean successGroupTeleport = false;
                if (!(sourceEntity instanceof Player))
                    return false;
                ISoliniaPlayer player = SoliniaPlayerAdapter.Adapt((Player) sourceEntity);
                ISoliniaGroup group = player.getGroup();
                if (group != null) {
                    for (Entity e : sourceEntity.getNearbyEntities(10, 10, 10)) {
                        if (!(e instanceof Player))
                            continue;
                        if (group.getMembers().contains(e.getUniqueId())) {
                            boolean loopSuccess3 = StateManager.getInstance().getEntityManager().addActiveEntitySpell(plugin, (LivingEntity) e, this, sourceEntity);
                            if (loopSuccess3 == true)
                                successGroupTeleport = true;
                        }
                    }
                }
                boolean selfSuccessTeleport = StateManager.getInstance().getEntityManager().addActiveEntitySpell(plugin, sourceEntity, this, sourceEntity);
                if (selfSuccessTeleport == true)
                    successGroupTeleport = true;
                return successGroupTeleport;
            // this might need to be target only
            case GroupClientAndPet:
                boolean successGroupClient = false;
                if (!(sourceEntity instanceof Player))
                    return false;
                ISoliniaPlayer playerGroupClient = SoliniaPlayerAdapter.Adapt((Player) sourceEntity);
                ISoliniaGroup groupClient = playerGroupClient.getGroup();
                if (groupClient != null) {
                    for (UUID uuidClient : playerGroupClient.getGroup().getMembers()) {
                        Entity e = Bukkit.getEntity(uuidClient);
                        if (!(e instanceof Player))
                            continue;
                        if (groupClient.getMembers().contains(e.getUniqueId())) {
                            boolean loopSuccess3 = StateManager.getInstance().getEntityManager().addActiveEntitySpell(plugin, (LivingEntity) e, this, sourceEntity);
                            if (loopSuccess3 == true)
                                successGroupClient = true;
                        }
                    }
                }
                boolean selfSuccessClient = StateManager.getInstance().getEntityManager().addActiveEntitySpell(plugin, sourceEntity, this, sourceEntity);
                if (selfSuccessClient == true)
                    successGroupClient = true;
                return successGroupClient;
            case Group:
                boolean successGroup = false;
                if (!(sourceEntity instanceof Player))
                    return false;
                ISoliniaPlayer playerGroupTeleport = SoliniaPlayerAdapter.Adapt((Player) sourceEntity);
                ISoliniaGroup groupTeleport = playerGroupTeleport.getGroup();
                if (groupTeleport != null) {
                    for (Entity e : sourceEntity.getNearbyEntities(10, 10, 10)) {
                        if (!(e instanceof Player))
                            continue;
                        if (groupTeleport.getMembers().contains(e.getUniqueId())) {
                            boolean loopSuccess3 = StateManager.getInstance().getEntityManager().addActiveEntitySpell(plugin, (LivingEntity) e, this, sourceEntity);
                            if (loopSuccess3 == true)
                                successGroup = true;
                        }
                    }
                }
                boolean selfSuccess = StateManager.getInstance().getEntityManager().addActiveEntitySpell(plugin, sourceEntity, this, sourceEntity);
                if (selfSuccess == true)
                    successGroup = true;
                return successGroup;
            case AECaster:
                // Get entities around caster and attempt to apply, if any are successful, return true
                boolean successCaster = false;
                // TODO - should the ae range be read from a field of the spell?
                for (Entity e : sourceEntity.getNearbyEntities(10, 10, 10)) {
                    if (!(e instanceof LivingEntity))
                        continue;
                    boolean loopSuccess4 = StateManager.getInstance().getEntityManager().addActiveEntitySpell(plugin, (LivingEntity) e, this, sourceEntity);
                    if (loopSuccess4 == true)
                        successCaster = true;
                }
                return successCaster;
            default:
                return false;
        }
    } catch (CoreStateInitException e) {
        // TODO Auto-generated catch block
        e.printStackTrace();
        return false;
    }
}
Also used : ISoliniaLivingEntity(com.solinia.solinia.Interfaces.ISoliniaLivingEntity) LivingEntity(org.bukkit.entity.LivingEntity) ISoliniaLivingEntity(com.solinia.solinia.Interfaces.ISoliniaLivingEntity) Entity(org.bukkit.entity.Entity) LivingEntity(org.bukkit.entity.LivingEntity) Player(org.bukkit.entity.Player) ISoliniaPlayer(com.solinia.solinia.Interfaces.ISoliniaPlayer) ISoliniaGroup(com.solinia.solinia.Interfaces.ISoliniaGroup) CoreStateInitException(com.solinia.solinia.Exceptions.CoreStateInitException) ISoliniaPlayer(com.solinia.solinia.Interfaces.ISoliniaPlayer) UUID(java.util.UUID)

Example 10 with ISoliniaGroup

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

the class CoreState method sendGroupMessage.

public void sendGroupMessage(Player player, String message) {
    if (message == null || message.equals("")) {
        player.sendMessage("You cannot send an empty message");
        return;
    }
    try {
        ISoliniaPlayer solplayer = SoliniaPlayerAdapter.Adapt(player);
        ISoliniaGroup group = getGroupByMember(player.getUniqueId());
        if (group == null) {
            player.sendMessage("You are not in a group");
            return;
        }
        String type = "";
        if (group.getOwner().equals(player.getUniqueId())) {
            type = "[" + ChatColor.LIGHT_PURPLE + "L" + ChatColor.RESET + "]";
        } else {
            type = "[" + ChatColor.LIGHT_PURPLE + "M" + ChatColor.RESET + "]";
        }
        if (group.getMembers().size() > 0) {
            for (UUID memberid : group.getMembers()) {
                Player groupplayer = Bukkit.getPlayer(memberid);
                if (groupplayer != null) {
                    System.out.println("group: " + group.getId() + ":" + player.getDisplayName() + ": " + ChatColor.AQUA + message);
                    groupplayer.sendMessage(type + " " + ChatColor.WHITE + solplayer.getFullName() + ChatColor.RESET + " [" + ChatColor.RED + (int) player.getHealth() + ChatColor.RESET + "/" + ChatColor.BLUE + solplayer.getMana() + ChatColor.RESET + "]: " + ChatColor.AQUA + message);
                }
            }
        } else {
            player.sendMessage("There were no members of that group");
            return;
        }
    } catch (CoreStateInitException e) {
        e.printStackTrace();
    }
}
Also used : Player(org.bukkit.entity.Player) ISoliniaPlayer(com.solinia.solinia.Interfaces.ISoliniaPlayer) ISoliniaGroup(com.solinia.solinia.Interfaces.ISoliniaGroup) CoreStateInitException(com.solinia.solinia.Exceptions.CoreStateInitException) ISoliniaPlayer(com.solinia.solinia.Interfaces.ISoliniaPlayer) UUID(java.util.UUID)

Aggregations

ISoliniaGroup (com.solinia.solinia.Interfaces.ISoliniaGroup)10 UUID (java.util.UUID)8 Player (org.bukkit.entity.Player)6 ISoliniaPlayer (com.solinia.solinia.Interfaces.ISoliniaPlayer)5 CoreStateInitException (com.solinia.solinia.Exceptions.CoreStateInitException)3 ISoliniaLivingEntity (com.solinia.solinia.Interfaces.ISoliniaLivingEntity)2 Entity (org.bukkit.entity.Entity)2 LivingEntity (org.bukkit.entity.LivingEntity)2 EventHandler (org.bukkit.event.EventHandler)2 ISoliniaFaction (com.solinia.solinia.Interfaces.ISoliniaFaction)1 ISoliniaNPC (com.solinia.solinia.Interfaces.ISoliniaNPC)1 FactionStandingEntry (com.solinia.solinia.Models.FactionStandingEntry)1 SoliniaGroup (com.solinia.solinia.Models.SoliniaGroup)1 ArrayList (java.util.ArrayList)1 Animals (org.bukkit.entity.Animals)1 ArmorStand (org.bukkit.entity.ArmorStand)1 Projectile (org.bukkit.entity.Projectile)1 Wolf (org.bukkit.entity.Wolf)1 EntityDamageByEntityEvent (org.bukkit.event.entity.EntityDamageByEntityEvent)1