use of com.solinia.solinia.Exceptions.CoreStateInitException 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.Exceptions.CoreStateInitException in project solinia3-core by mixxit.
the class CommandListItems 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.hasPermission("solinia.listitems")) {
player.sendMessage("You do not have permission to access this command");
return false;
}
}
if (args.length == 0) {
sender.sendMessage("You must provide some text to filter the item name by");
return true;
}
// Filter for name
int found = 0;
try {
for (ISoliniaItem item : StateManager.getInstance().getConfigurationManager().getItems()) {
found++;
if (item.getDisplayname().toUpperCase().contains(args[0].toUpperCase())) {
String itemmessage = item.getId() + " - " + item.getDisplayname();
sender.sendMessage(itemmessage);
}
}
if (found == 0) {
sender.sendMessage("Item could not be located by search string");
}
} catch (CoreStateInitException e) {
// TODO Auto-generated catch block
sender.sendMessage(e.getMessage());
e.printStackTrace();
}
return true;
}
use of com.solinia.solinia.Exceptions.CoreStateInitException 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
}
}
}
}
use of com.solinia.solinia.Exceptions.CoreStateInitException in project solinia3-core by mixxit.
the class SoliniaActiveSpell method applyRevive.
private void applyRevive(SpellEffect spellEffect, ISoliniaSpell soliniaSpell, int casterLevel) {
if (!(getLivingEntity() instanceof Player)) {
return;
}
Entity source = Bukkit.getEntity(getSourceUuid());
if (!(source instanceof Player))
return;
Player sourcePlayer = (Player) source;
if (!sourcePlayer.getInventory().getItemInOffHand().getType().equals(Material.NAME_TAG)) {
sourcePlayer.sendMessage("You are not holding a Signaculum in your offhand (MC): " + sourcePlayer.getInventory().getItemInOffHand().getType().name());
return;
}
ItemStack item = sourcePlayer.getInventory().getItemInOffHand();
if (item.getEnchantmentLevel(Enchantment.DURABILITY) != 1) {
sourcePlayer.sendMessage("You are not holding a Signaculum in your offhand (EC)");
return;
}
if (!item.getItemMeta().getDisplayName().equals("Signaculum")) {
sourcePlayer.sendMessage("You are not holding a Signaculum in your offhand (NC)");
return;
}
if (item.getItemMeta().getLore().size() < 5) {
sourcePlayer.sendMessage("You are not holding a Signaculum in your offhand (LC)");
return;
}
String sigdataholder = item.getItemMeta().getLore().get(3);
String[] sigdata = sigdataholder.split("\\|");
if (sigdata.length != 2) {
sourcePlayer.sendMessage("You are not holding a Signaculum in your offhand (SD)");
return;
}
String str_experience = sigdata[0];
String str_stimetsamp = sigdata[1];
int experience = Integer.parseInt(str_experience);
Timestamp timestamp = Timestamp.valueOf(str_stimetsamp);
LocalDateTime datetime = LocalDateTime.now();
Timestamp currenttimestamp = Timestamp.valueOf(datetime);
long maxminutes = 60 * 7;
if ((currenttimestamp.getTime() - timestamp.getTime()) >= maxminutes * 60 * 1000) {
sourcePlayer.sendMessage("This Signaculum has lost its binding to the soul");
return;
}
String playeruuidb64 = item.getItemMeta().getLore().get(4);
String uuid = Utils.uuidFromBase64(playeruuidb64);
Player targetplayer = Bukkit.getPlayer(UUID.fromString(uuid));
if (targetplayer == null || !targetplayer.isOnline()) {
sourcePlayer.sendMessage("You cannot resurrect that player as they are offline");
return;
}
int multiplier = 1;
if (spellEffect.getBase() > 0 && spellEffect.getBase() < 100)
multiplier = spellEffect.getBase();
try {
double finalexperience = (experience / 100) * multiplier;
SoliniaPlayerAdapter.Adapt(targetplayer).increasePlayerNormalExperience(finalexperience);
targetplayer.sendMessage("You have been resurrected by " + sourcePlayer.getCustomName() + "!");
targetplayer.teleport(sourcePlayer.getLocation());
sourcePlayer.getInventory().setItemInOffHand(new ItemStack(Material.AIR));
} catch (CoreStateInitException e) {
return;
}
return;
}
use of com.solinia.solinia.Exceptions.CoreStateInitException in project solinia3-core by mixxit.
the class SoliniaActiveSpell method applySenseSummoned.
private void applySenseSummoned(SpellEffect spellEffect, ISoliniaSpell soliniaSpell, int casterLevel) {
try {
for (Entity e : this.getLivingEntity().getNearbyEntities(100, 100, 100)) {
if (!(e instanceof LivingEntity))
continue;
if (!(e instanceof Creature))
continue;
ISoliniaLivingEntity solEntity = SoliniaLivingEntityAdapter.Adapt((LivingEntity) e);
if (!solEntity.isPet())
continue;
Vector dir = ((LivingEntity) e).getLocation().clone().subtract(getLivingEntity().getEyeLocation()).toVector();
Location loc = getLivingEntity().getLocation().setDirection(dir);
getLivingEntity().teleport(loc);
}
} catch (CoreStateInitException e) {
}
}
Aggregations