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;
}
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;
}
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;
}
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;
}
}
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
}
}
}
}
Aggregations