use of com.solinia.solinia.Exceptions.SoliniaItemException in project solinia3-core by mixxit.
the class Solinia3CoreEntityListener method onEntityDamage.
@EventHandler
public void onEntityDamage(EntityDamageEvent event) {
if (event.isCancelled())
return;
if (!(event instanceof EntityDamageByEntityEvent)) {
return;
}
EntityDamageByEntityEvent damagecause = (EntityDamageByEntityEvent) event;
// If the event is being blocked by a shield negate 85% of it unless its thorns then always allow it through
if (damagecause.getDamage(DamageModifier.BLOCKING) < 0) {
if (event.getCause().equals(DamageCause.THORNS)) {
damagecause.setDamage(DamageModifier.BLOCKING, 0);
} else {
// Only give them 15% blocking
double newarmour = (damagecause.getDamage(DamageModifier.BLOCKING) / 100) * 15;
damagecause.setDamage(DamageModifier.BLOCKING, newarmour);
}
}
// and check they are not mezzed
try {
if (damagecause.getDamager() instanceof LivingEntity) {
LivingEntity attacker = (LivingEntity) damagecause.getDamager();
// Change attacker to archer
if (damagecause.getDamager() instanceof Arrow) {
Arrow arr = (Arrow) attacker;
if (arr.getShooter() instanceof LivingEntity) {
attacker = (LivingEntity) arr.getShooter();
} else {
}
}
// cancel attacks on mobs mezzed
if (attacker instanceof Creature && attacker instanceof LivingEntity && event.getEntity() instanceof LivingEntity) {
ISoliniaLivingEntity solCreatureEntity = SoliniaLivingEntityAdapter.Adapt(attacker);
if (solCreatureEntity.isPet() || !solCreatureEntity.isPlayer()) {
Timestamp mezExpiry = StateManager.getInstance().getEntityManager().getMezzed((LivingEntity) event.getEntity());
if (mezExpiry != null) {
((Creature) attacker).setTarget(null);
if (solCreatureEntity.isPet()) {
Wolf wolf = (Wolf) attacker;
wolf.setTarget(null);
solCreatureEntity.say("Stopping attacking master, the target is mesmerized");
}
event.setCancelled(true);
return;
}
}
}
try {
Timestamp mzExpiry = StateManager.getInstance().getEntityManager().getMezzed((LivingEntity) attacker);
if (mzExpiry != null) {
if (attacker instanceof Player) {
attacker.sendMessage("* You are mezzed!");
}
Utils.CancelEvent(event);
;
return;
}
} catch (CoreStateInitException e) {
}
List<Integer> removeSpells = new ArrayList<Integer>();
for (SoliniaActiveSpell spell : StateManager.getInstance().getEntityManager().getActiveEntitySpells((LivingEntity) attacker).getActiveSpells()) {
if (spell.getSpell().getSpellEffectTypes().contains(SpellEffectType.InvisVsUndead) || spell.getSpell().getSpellEffectTypes().contains(SpellEffectType.Mez) || spell.getSpell().getSpellEffectTypes().contains(SpellEffectType.InvisVsUndead2) || spell.getSpell().getSpellEffectTypes().contains(SpellEffectType.Invisibility) || spell.getSpell().getSpellEffectTypes().contains(SpellEffectType.Invisibility2) || spell.getSpell().getSpellEffectTypes().contains(SpellEffectType.InvisVsAnimals) || spell.getSpell().getSpellEffectTypes().contains(SpellEffectType.ImprovedInvisAnimals)) {
if (!removeSpells.contains(spell.getSpell().getId()))
removeSpells.add(spell.getSpell().getId());
}
}
for (Integer spellId : removeSpells) {
StateManager.getInstance().getEntityManager().removeSpellEffectsOfSpellId(plugin, ((LivingEntity) attacker).getUniqueId(), spellId);
}
}
} catch (CoreStateInitException e) {
// skip
}
// Remove buffs on recipient (invis should drop)
try {
if (event.getEntity() instanceof LivingEntity) {
List<Integer> removeSpells = new ArrayList<Integer>();
for (SoliniaActiveSpell spell : StateManager.getInstance().getEntityManager().getActiveEntitySpells((LivingEntity) event.getEntity()).getActiveSpells()) {
if (spell.getSpell().getSpellEffectTypes().contains(SpellEffectType.Mez) || spell.getSpell().getSpellEffectTypes().contains(SpellEffectType.InvisVsUndead) || spell.getSpell().getSpellEffectTypes().contains(SpellEffectType.InvisVsUndead) || spell.getSpell().getSpellEffectTypes().contains(SpellEffectType.InvisVsUndead2) || spell.getSpell().getSpellEffectTypes().contains(SpellEffectType.Invisibility) || spell.getSpell().getSpellEffectTypes().contains(SpellEffectType.Invisibility2) || spell.getSpell().getSpellEffectTypes().contains(SpellEffectType.InvisVsAnimals) || spell.getSpell().getSpellEffectTypes().contains(SpellEffectType.ImprovedInvisAnimals)) {
if (!removeSpells.contains(spell.getSpell().getId()))
removeSpells.add(spell.getSpell().getId());
}
}
for (Integer spellId : removeSpells) {
StateManager.getInstance().getEntityManager().removeSpellEffectsOfSpellId(plugin, ((LivingEntity) event.getEntity()).getUniqueId(), spellId);
}
}
// Check for rune damage
if (event.getEntity() instanceof LivingEntity) {
ISoliniaLivingEntity soldefender = SoliniaLivingEntityAdapter.Adapt((LivingEntity) event.getEntity());
if (soldefender.isInvulnerable()) {
event.setDamage(0);
Utils.CancelEvent(event);
;
if (damagecause.getDamager() instanceof Player) {
((Player) damagecause.getDamager()).sendMessage("* Your attack was prevented as the target is Invulnerable!");
}
if (event.getEntity() instanceof Player) {
((Player) event.getEntity()).sendMessage("* Your invulnerability prevented the targets attack!");
}
}
}
// see if any runes want to reduce this damage
if (event.getEntity() instanceof LivingEntity) {
if (!event.getCause().equals(DamageCause.THORNS)) {
ISoliniaLivingEntity soldefender = SoliniaLivingEntityAdapter.Adapt((LivingEntity) event.getEntity());
event.setDamage(Utils.reduceDamage(soldefender, event.getDamage()));
}
}
// Check for rune damage
if (event.getEntity() instanceof LivingEntity) {
ISoliniaLivingEntity soldefender = SoliniaLivingEntityAdapter.Adapt((LivingEntity) event.getEntity());
if (soldefender.getRune() > 0) {
event.setDamage(soldefender.reduceAndRemoveRunesAndReturnLeftover(plugin, (int) event.getDamage()));
if (event.getDamage() <= 0) {
Utils.CancelEvent(event);
;
if (damagecause.getDamager() instanceof Player) {
((Player) damagecause.getDamager()).sendMessage("* Your attack was absorbed by the targets Rune");
}
if (event.getEntity() instanceof Player) {
((Player) event.getEntity()).sendMessage("* Your rune spell absorbed the targets attack!");
}
return;
}
}
}
} catch (CoreStateInitException e) {
// skip
}
if ((damagecause.getDamager() instanceof LivingEntity || damagecause.getDamager() instanceof Arrow) && event.getEntity() instanceof LivingEntity) {
// code
if (event.getCause().equals(DamageCause.THORNS)) {
if (damagecause.getDamager() instanceof Player) {
LivingEntity recipient = (LivingEntity) event.getEntity();
DecimalFormat df = new DecimalFormat();
df.setMaximumFractionDigits(2);
String name = recipient.getName();
if (recipient.getCustomName() != null)
name = recipient.getCustomName();
((Player) damagecause.getDamager()).spigot().sendMessage(ChatMessageType.ACTION_BAR, new TextComponent("You SPELLDMG'd " + name + " for " + df.format(event.getDamage()) + " [" + df.format(recipient.getHealth() - event.getDamage()) + "/" + df.format(recipient.getMaxHealth()) + "]"));
}
if (event.getEntity() instanceof LivingEntity) {
ISoliniaLivingEntity solentity;
try {
solentity = SoliniaLivingEntityAdapter.Adapt((LivingEntity) event.getEntity());
if (event.getDamage() > solentity.getBukkitLivingEntity().getHealth() && solentity.hasDeathSave() > 0) {
Utils.CancelEvent(event);
solentity.removeDeathSaves(plugin);
solentity.getBukkitLivingEntity().sendMessage("* Your death/divine save boon has saved you from death!");
return;
}
solentity.damageHook(event.getDamage(), damagecause.getDamager());
} catch (CoreStateInitException e) {
// skip
}
}
return;
}
try {
Entity damager = damagecause.getDamager();
// Change attacker to archer
if (damagecause.getDamager() instanceof Arrow) {
Arrow arr = (Arrow) damagecause.getDamager();
if (arr.getShooter() instanceof LivingEntity) {
damager = (LivingEntity) arr.getShooter();
// Modify Player Bow Damage
if (arr.getShooter() instanceof Player) {
Player shooter = (Player) arr.getShooter();
ItemStack mainitem = shooter.getInventory().getItemInMainHand();
if (mainitem != null) {
if (mainitem.getType() == Material.BOW) {
int dmgmodifier = 0;
if (Utils.IsSoliniaItem(mainitem)) {
try {
ISoliniaItem item = SoliniaItemAdapter.Adapt(mainitem);
if (item.getDamage() > 0 && item.getBasename().equals("BOW")) {
dmgmodifier = item.getDamage();
}
} catch (SoliniaItemException e) {
// sok just skip
}
}
event.setDamage(event.getDamage() + dmgmodifier);
}
}
}
} else {
}
}
if (!(damager instanceof LivingEntity))
return;
LivingEntity attacker = (LivingEntity) damager;
// Change attacker to archer
if (damagecause.getDamager() instanceof Arrow) {
Arrow arr = (Arrow) damagecause.getDamager();
if (arr.getShooter() instanceof LivingEntity) {
attacker = (LivingEntity) arr.getShooter();
} else {
}
}
if (attacker == null)
return;
ISoliniaLivingEntity soldefender = SoliniaLivingEntityAdapter.Adapt((LivingEntity) event.getEntity());
ISoliniaLivingEntity solattacker = SoliniaLivingEntityAdapter.Adapt((LivingEntity) attacker);
if (attacker instanceof Player && event.getEntity() instanceof Wolf) {
if (soldefender.isPet()) {
Wolf wolf = (Wolf) event.getEntity();
if (wolf != null) {
if (wolf.getTarget() == null || !wolf.getTarget().equals(attacker)) {
Utils.CancelEvent(event);
;
return;
}
} else {
Utils.CancelEvent(event);
;
return;
}
}
}
if (!(event instanceof EntityDamageByEntityEvent)) {
soldefender.damageHook(event.getDamage(), damagecause.getDamager());
return;
}
solattacker.Attack(soldefender, event, damagecause.getDamager() instanceof Arrow, plugin);
} catch (CoreStateInitException e) {
}
}
}
use of com.solinia.solinia.Exceptions.SoliniaItemException in project solinia3-core by mixxit.
the class Solinia3CoreItemPickupListener method PickupItem.
@EventHandler
public void PickupItem(PlayerPickupItemEvent e) {
ItemStack pickedUpItemStack = e.getItem().getItemStack();
// Replace oxygen items with durability items
if (pickedUpItemStack.getEnchantmentLevel(Enchantment.OXYGEN) > 999) {
e.getPlayer().sendMessage("Detected an item in the old format, converting to the new format. Please drop all your old items and pick them up if you are having problems with them");
try {
ISoliniaItem latestitem = StateManager.getInstance().getConfigurationManager().getItemByOxygen(pickedUpItemStack);
if (pickedUpItemStack != null) {
if (latestitem != null) {
ItemStack latestitemstack = latestitem.asItemStack();
pickedUpItemStack.setItemMeta(latestitemstack.getItemMeta());
} else {
// this is an item that is broken
e.getPlayer().sendMessage("This item is no longer implemented");
Utils.CancelEvent(e);
e.getItem().remove();
}
}
} catch (CoreStateInitException eOxy) {
}
}
String temporaryGuid = null;
Integer augmentationItemId = null;
try {
if (Utils.IsSoliniaItem(pickedUpItemStack) && pickedUpItemStack.getType().equals(Material.ENCHANTED_BOOK)) {
e.getPlayer().sendMessage(ChatColor.GRAY + "You have picked up an ability! To use it, hold it in your hand and right click!");
ISoliniaItem latestitem = StateManager.getInstance().getConfigurationManager().getItem(pickedUpItemStack);
if (pickedUpItemStack != null) {
if (latestitem != null) {
ItemStack latestitemstack = latestitem.asItemStack();
pickedUpItemStack.setItemMeta(latestitemstack.getItemMeta());
} else {
// this is an item that is broken
e.getPlayer().sendMessage("This item is no longer implemented");
Utils.CancelEvent(e);
e.getItem().remove();
}
}
if (latestitem.getDiscoverer() == null || latestitem.getDiscoverer().equals("")) {
latestitem.setDiscoverer(e.getPlayer().getCustomName());
e.getPlayer().getServer().broadcastMessage(ChatColor.YELLOW + "* " + latestitem.getDisplayname() + " was discovered by " + e.getPlayer().getCustomName() + "!");
StateManager.getInstance().getChannelManager().sendToDiscordMC(null, StateManager.getInstance().getChannelManager().getDefaultDiscordChannel(), latestitem.getDisplayname() + " was discovered by " + e.getPlayer().getCustomName() + "!");
}
}
if (Utils.IsSoliniaItem(pickedUpItemStack) && !(pickedUpItemStack.getType().equals(Material.ENCHANTED_BOOK))) {
Map<Enchantment, Integer> oldenchantments = pickedUpItemStack.getEnchantments();
ISoliniaItem latestitem = StateManager.getInstance().getConfigurationManager().getItem(pickedUpItemStack);
if (latestitem.getDiscoverer() == null || latestitem.getDiscoverer().equals("")) {
latestitem.setDiscoverer(e.getPlayer().getCustomName());
e.getPlayer().getServer().broadcastMessage(ChatColor.YELLOW + "* " + latestitem.getDisplayname() + " was discovered by " + e.getPlayer().getCustomName() + "!");
StateManager.getInstance().getChannelManager().sendToDiscordMC(null, StateManager.getInstance().getChannelManager().getDefaultDiscordChannel(), latestitem.getDisplayname() + " was discovered by " + e.getPlayer().getCustomName() + "!");
}
if (pickedUpItemStack != null) {
ItemStack latestitemstack = latestitem.asItemStack();
// We need to store this information before we change the itemmeta, so we can update it afterwards
if (latestitem.isTemporary()) {
temporaryGuid = ItemStackUtils.getTemporaryItemGuid(pickedUpItemStack);
}
augmentationItemId = ItemStackUtils.getAugmentationItemId(pickedUpItemStack);
// Now go and replace the itemmeta
pickedUpItemStack.setItemMeta(latestitemstack.getItemMeta());
// Now re-apply enchantments that it had before
for (Map.Entry<Enchantment, Integer> entry : oldenchantments.entrySet()) {
Enchantment key = entry.getKey();
Integer value = entry.getValue();
if (value < 1000) {
pickedUpItemStack.addUnsafeEnchantment(key, value);
}
}
// Since the item is temporary, attempt to apply the temporary timestamp it had prior to this
if (latestitem.isTemporary()) {
pickedUpItemStack.setItemMeta(ItemStackUtils.applyTemporaryStamp(pickedUpItemStack, temporaryGuid));
}
if (augmentationItemId != null && augmentationItemId != 0) {
pickedUpItemStack.setItemMeta(ItemStackUtils.applyAugmentationToItemStack(pickedUpItemStack, augmentationItemId));
}
}
}
// group messages
if (Utils.IsSoliniaItem(pickedUpItemStack)) {
ISoliniaItem item;
try {
item = SoliniaItemAdapter.Adapt(pickedUpItemStack);
if (item.getAllowedClassNames().size() > 0) {
ISoliniaPlayer solPlayer = SoliniaPlayerAdapter.Adapt(e.getPlayer());
if (solPlayer.getGroup() != null && solPlayer.getGroup().getMembers() != null)
for (UUID playerUuid : solPlayer.getGroup().getMembers()) {
if (playerUuid.equals(e.getPlayer().getUniqueId()))
continue;
Player groupMember = Bukkit.getPlayer(playerUuid);
ISoliniaPlayer groupSolPlayer = SoliniaPlayerAdapter.Adapt(groupMember);
if (groupSolPlayer != null) {
if (groupSolPlayer.getClassObj() != null)
if (item.getAllowedClassNames().contains(groupSolPlayer.getClassObj().getName().toUpperCase())) {
TextComponent tc = new TextComponent();
tc.setText("* " + groupSolPlayer.getFullName() + " picked up an item of interest to your class: [" + ChatColor.AQUA + item.getDisplayname() + ChatColor.RESET + "]");
tc.setHoverEvent(new HoverEvent(HoverEvent.Action.SHOW_ITEM, new ComponentBuilder(item.asJsonString()).create()));
groupSolPlayer.getBukkitPlayer().spigot().sendMessage(tc);
}
}
}
}
} catch (SoliniaItemException e1) {
}
}
} catch (CoreStateInitException coreException) {
// do nothing
}
}
use of com.solinia.solinia.Exceptions.SoliniaItemException in project solinia3-core by mixxit.
the class SoliniaItemFactory method CreateItem.
public static ISoliniaItem CreateItem(ItemStack itemStack, boolean operatorCreated) throws SoliniaItemException, CoreStateInitException {
SoliniaItem item = new SoliniaItem();
item.setOperatorCreated(operatorCreated);
item.setId(StateManager.getInstance().getConfigurationManager().getNextItemId());
item.setBasename(itemStack.getType().name());
item.setDisplayname(itemStack.getType().name());
if (itemStack.getData() != null) {
try {
item.setColor(itemStack.getData().getData());
} catch (Exception e) {
e.printStackTrace();
}
}
if (itemStack.getType().name().equals("SKULL_ITEM")) {
net.minecraft.server.v1_12_R1.ItemStack stack = CraftItemStack.asNMSCopy(itemStack);
NBTTagCompound tag = stack.hasTag() ? stack.getTag() : new NBTTagCompound();
tag.getCompound("SkullOwner").getString("Id");
String texturevalue = tag.getCompound("SkullOwner").getCompound("Properties").getList("textures", 10).get(0).getString("Value");
item.setTexturebase64(texturevalue);
}
StateManager.getInstance().getConfigurationManager().addItem(item);
System.out.println("New Item Added: " + item.getId() + " - " + item.getDisplayname());
return item;
}
use of com.solinia.solinia.Exceptions.SoliniaItemException in project solinia3-core by mixxit.
the class Solinia3CorePlayerListener method onPlayerConsumeEvent.
@EventHandler
public void onPlayerConsumeEvent(PlayerItemConsumeEvent event) {
if (event.isCancelled())
return;
try {
ISoliniaItem item = SoliniaItemAdapter.Adapt(event.getItem());
item.consume(plugin, event.getPlayer());
} catch (SoliniaItemException | CoreStateInitException e) {
}
}
use of com.solinia.solinia.Exceptions.SoliniaItemException in project solinia3-core by mixxit.
the class CommandInspiration method onCommand.
@Override
public boolean onCommand(CommandSender sender, Command cmd, String label, String[] args) {
try {
if (args.length == 0) {
sender.sendMessage(ChatColor.LIGHT_PURPLE + "Inspiration Shop");
sender.sendMessage("-----------------");
sender.sendMessage(ChatColor.LIGHT_PURPLE + "Buy 1 AA Point " + ChatColor.RESET + " - Cost: 5 inspiration : /inspiration buy aa");
sender.sendMessage(ChatColor.LIGHT_PURPLE + "Buy Mana Regen Aug (Head) " + ChatColor.RESET + " - Cost: 2 inspiration : /inspiration buy manahead");
sender.sendMessage(ChatColor.LIGHT_PURPLE + "Buy Mana Regen Aug (Chest) " + ChatColor.RESET + " - Cost: 2 inspiration : /inspiration buy manachest");
sender.sendMessage(ChatColor.LIGHT_PURPLE + "Buy Mana Regen Aug (Legs) " + ChatColor.RESET + " - Cost: 2 inspiration : /inspiration buy manalegs");
sender.sendMessage(ChatColor.LIGHT_PURPLE + "Buy Mana Regen Aug (Feet) " + ChatColor.RESET + " - Cost: 2 inspiration : /inspiration buy manafeet");
sender.sendMessage(ChatColor.LIGHT_PURPLE + "Buy 1x 100% Experience Potion " + ChatColor.RESET + " - Cost: 2 inspiration : /inspiration buy xpbottle");
sender.sendMessage(ChatColor.LIGHT_PURPLE + "Buy 1x next tier gear set" + ChatColor.RESET + " - Cost: 35 inspiration : /inspiration buy gear");
sender.sendMessage("-----------------");
sender.sendMessage("Sub Commands: " + ChatColor.LIGHT_PURPLE + "sites, buy, send");
if (sender instanceof Player) {
ISoliniaPlayer solPlayer = SoliniaPlayerAdapter.Adapt((Player) sender);
sender.sendMessage("Points Available: " + ChatColor.LIGHT_PURPLE + solPlayer.getInspiration());
}
return true;
}
switch(args[0].toLowerCase()) {
case "buy":
if (args.length > 1) {
int cost = 0;
switch(args[1].toLowerCase()) {
case "gear":
if (sender instanceof Player) {
ISoliniaPlayer player = SoliniaPlayerAdapter.Adapt((Player) sender);
cost = 35;
if (player.getInspiration() >= cost) {
String suffix = "of Inspiration";
int playertier = 1;
if (player.getLevel() >= 1 && player.getLevel() < 11)
playertier = 1;
if (player.getLevel() >= 11 && player.getLevel() < 21)
playertier = 2;
if (player.getLevel() >= 21 && player.getLevel() < 31)
playertier = 3;
if (player.getLevel() >= 31 && player.getLevel() < 41)
playertier = 4;
if (player.getLevel() >= 41 && player.getLevel() < 51)
playertier = 5;
if (player.getLevel() >= 51 && player.getLevel() < 61)
playertier = 6;
try {
// always give the next tier up
// this ability is for special seasonal rewards only
playertier += 1;
List<Integer> items = SoliniaItemFactory.CreateClassItemSet(player.getClassObj(), playertier, suffix, false, true);
for (int itemid : items) {
ISoliniaItem item = StateManager.getInstance().getConfigurationManager().getItem(itemid);
final String playerName = player.getBukkitPlayer().getName();
final int minLevel = player.getLevel();
final int finalitemid = itemid;
if (item != null) {
Bukkit.getServer().getScheduler().scheduleSyncDelayedTask(Bukkit.getPluginManager().getPlugin("Solinia3Core"), new Runnable() {
public void run() {
try {
ISoliniaItem item = StateManager.getInstance().getConfigurationManager().getItem(finalitemid);
item.setMinLevel(minLevel);
SoliniaAccountClaim claim = new SoliniaAccountClaim();
claim.setId(StateManager.getInstance().getConfigurationManager().getNextAccountClaimId());
claim.setMcname(playerName);
claim.setItemid(finalitemid);
claim.setClaimed(false);
Player claimPlayer = Bukkit.getPlayer(playerName);
if (claimPlayer != null) {
claimPlayer.sendMessage(ChatColor.GOLD + "You have been awarded with a claim item! See /claim");
}
StateManager.getInstance().getConfigurationManager().addAccountClaim(claim);
System.out.println("Awarded Claim: " + item.getDisplayname() + " to " + playerName);
} catch (CoreStateInitException e) {
// skip
}
}
});
}
}
player.setInspiration(player.getInspiration() - cost);
sender.sendMessage("You have purchased a full set of gear!");
} catch (CoreStateInitException e) {
sender.sendMessage("There was a problem generating your gear (Core), please report this to a developer");
} catch (SoliniaItemException e) {
sender.sendMessage("There was a problem generating your gear (Item), please report this to a developer");
}
return true;
} else {
sender.sendMessage("You require more inspiration points to purchase this");
return true;
}
} else {
sender.sendMessage("This is a player only subcommand");
}
case "aa":
if (sender instanceof Player) {
ISoliniaPlayer solPlayer = SoliniaPlayerAdapter.Adapt((Player) sender);
if (solPlayer.getLevel() < 20) {
sender.sendMessage("Only players level 20 and above can have AA points any lower and it would be useless");
return true;
} else {
cost = 5;
if (solPlayer.getInspiration() >= cost) {
solPlayer.setInspiration(solPlayer.getInspiration() - cost);
solPlayer.setAAPoints(solPlayer.getAAPoints() + 1);
sender.sendMessage("You have purchased an AA point!");
return true;
} else {
sender.sendMessage("You require more inspiration points to purchase this");
return true;
}
}
} else {
sender.sendMessage("This is a player only subcommand");
}
case "manahead":
if (sender instanceof Player) {
ISoliniaPlayer solPlayer = SoliniaPlayerAdapter.Adapt((Player) sender);
cost = 2;
if (solPlayer.getInspiration() >= cost) {
solPlayer.setInspiration(solPlayer.getInspiration() - cost);
ISoliniaItem item = StateManager.getInstance().getConfigurationManager().getItem(18019);
((Player) sender).getLocation().getWorld().dropItemNaturally(((Player) sender).getLocation(), item.asItemStack());
sender.sendMessage("You have purchased an item!");
return true;
} else {
sender.sendMessage("You require more inspiration points to purchase this");
return true;
}
} else {
sender.sendMessage("This is a player only subcommand");
}
case "manachest":
if (sender instanceof Player) {
ISoliniaPlayer solPlayer = SoliniaPlayerAdapter.Adapt((Player) sender);
cost = 2;
if (solPlayer.getInspiration() >= cost) {
solPlayer.setInspiration(solPlayer.getInspiration() - cost);
ISoliniaItem item = StateManager.getInstance().getConfigurationManager().getItem(18020);
((Player) sender).getLocation().getWorld().dropItemNaturally(((Player) sender).getLocation(), item.asItemStack());
sender.sendMessage("You have purchased an item!");
return true;
} else {
sender.sendMessage("You require more inspiration points to purchase this");
return true;
}
} else {
sender.sendMessage("This is a player only subcommand");
}
case "manalegs":
if (sender instanceof Player) {
ISoliniaPlayer solPlayer = SoliniaPlayerAdapter.Adapt((Player) sender);
cost = 2;
if (solPlayer.getInspiration() >= cost) {
solPlayer.setInspiration(solPlayer.getInspiration() - cost);
ISoliniaItem item = StateManager.getInstance().getConfigurationManager().getItem(18021);
((Player) sender).getLocation().getWorld().dropItemNaturally(((Player) sender).getLocation(), item.asItemStack());
sender.sendMessage("You have purchased an item!");
return true;
} else {
sender.sendMessage("You require more inspiration points to purchase this");
return true;
}
} else {
sender.sendMessage("This is a player only subcommand");
}
case "manafeet":
if (sender instanceof Player) {
ISoliniaPlayer solPlayer = SoliniaPlayerAdapter.Adapt((Player) sender);
cost = 2;
if (solPlayer.getInspiration() >= cost) {
solPlayer.setInspiration(solPlayer.getInspiration() - cost);
ISoliniaItem item = StateManager.getInstance().getConfigurationManager().getItem(18022);
((Player) sender).getLocation().getWorld().dropItemNaturally(((Player) sender).getLocation(), item.asItemStack());
sender.sendMessage("You have purchased an item!");
return true;
} else {
sender.sendMessage("You require more inspiration points to purchase this");
return true;
}
} else {
sender.sendMessage("This is a player only subcommand");
}
case "xpbottle":
if (sender instanceof Player) {
ISoliniaPlayer solPlayer = SoliniaPlayerAdapter.Adapt((Player) sender);
cost = 2;
if (solPlayer.getInspiration() >= cost) {
solPlayer.setInspiration(solPlayer.getInspiration() - cost);
ISoliniaItem item = StateManager.getInstance().getConfigurationManager().getItem(18024);
((Player) sender).getLocation().getWorld().dropItemNaturally(((Player) sender).getLocation(), item.asItemStack());
sender.sendMessage("You have purchased an item!");
return true;
} else {
sender.sendMessage("You require more inspiration points to purchase this");
return true;
}
} else {
sender.sendMessage("This is a player only subcommand");
}
default:
sender.sendMessage("This is not a known shop item to buy. See /inspiration for valid commands");
return true;
}
} else {
sender.sendMessage("You must specify the shop item you want to buy. Ie: /inspiration buy aa");
return true;
}
case "sites":
sender.sendMessage(ChatColor.YELLOW + "Sites you can vote on:");
sender.sendMessage("https://www.planetminecraft.com/server/fall-of-an-empire-heavyrp/vote/");
sender.sendMessage("http://www.minecraftforum.net/servers/6305-fall-of-an-empire-heavy-rp/vote:");
sender.sendMessage("https://minecraftlist.org/vote/5962");
sender.sendMessage("https://minecraft-server.net/vote/fallofanempire");
sender.sendMessage("http://minecraft-server-list.com/server/345651/vote/");
sender.sendMessage(ChatColor.YELLOW + "You will earn 1 inspiration point for each vote");
break;
case "send":
if (args.length > 2) {
if (sender instanceof Player) {
ISoliniaPlayer solPlayer = SoliniaPlayerAdapter.Adapt((Player) sender);
String mcAccount = args[1];
int amount = Integer.parseInt(args[2]);
Player player = Bukkit.getPlayer(mcAccount);
if (player == null) {
sender.sendMessage("Cannot find that player to forward to. It must be their minecraft account name and they must be online (ie /inspiration send mixxit 1)");
return true;
}
if (solPlayer.getInspiration() >= amount) {
ISoliniaPlayer targetPlayer = SoliniaPlayerAdapter.Adapt(player);
solPlayer.setInspiration(solPlayer.getInspiration() - amount);
targetPlayer.setInspiration(targetPlayer.getInspiration() + amount);
sender.sendMessage("You have sent " + amount + " inspiration to " + player.getName());
player.sendMessage("You have received " + amount + " inspiration from " + sender.getName());
return true;
} else {
sender.sendMessage("You do not have that amount of inspiration to send");
return true;
}
} else {
sender.sendMessage("This is a player only subcommand");
}
} else {
sender.sendMessage("You must specify how many you wish to transfer and the mc account name of the person you want to send it to (ie /inspiration send mixxit 1)");
return true;
}
case "grant":
if (args.length > 2) {
String mcAccount = args[1];
int amount = Integer.parseInt(args[2]);
Player player = Bukkit.getPlayer(mcAccount);
if (player == null) {
sender.sendMessage("Cannot find that player to grant to. It must be their minecraft account name and they must be online (ie /inspiration grant mixxit 1)");
return true;
}
if (sender.isOp()) {
ISoliniaPlayer targetPlayer = SoliniaPlayerAdapter.Adapt(player);
targetPlayer.setInspiration(targetPlayer.getInspiration() + amount);
sender.sendMessage("You have granted " + amount + " inspiration to " + player.getName());
player.sendMessage("You have received " + amount + " inspiration from " + sender.getName());
return true;
} else {
sender.sendMessage("This is an operator only command");
}
} else {
sender.sendMessage("You must specify how many you wish to grant and the mc account name of the person you want to send it to (ie /inspiration grant mixxit 1)");
return true;
}
default:
sender.sendMessage("Unknown subcommand - Valid are: sites, buy, send");
break;
}
return true;
} catch (CoreStateInitException e) {
// TODO Auto-generated catch block
e.printStackTrace();
sender.sendMessage(e.getMessage());
return true;
}
}
Aggregations