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");
}
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");
}
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");
}
}
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;
}
}
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();
}
}
Aggregations