use of com.solinia.solinia.Interfaces.ISoliniaItem 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;
}
}
use of com.solinia.solinia.Interfaces.ISoliniaItem in project solinia3-core by mixxit.
the class CommandEquip method showCurrentEquippedItems.
private void showCurrentEquippedItems(ISoliniaPlayer solPlayer) {
try {
if (solPlayer.getNeckItem() > 0) {
ISoliniaItem item = StateManager.getInstance().getConfigurationManager().getItem(solPlayer.getNeckItem());
solPlayer.getBukkitPlayer().sendMessage("Neck Item: " + item.getDisplayname());
} else {
solPlayer.getBukkitPlayer().sendMessage("Neck Item: EMPTY");
}
if (solPlayer.getFingersItem() > 0) {
ISoliniaItem item = StateManager.getInstance().getConfigurationManager().getItem(solPlayer.getNeckItem());
solPlayer.getBukkitPlayer().sendMessage("Fingers Item: " + item.getDisplayname());
} else {
solPlayer.getBukkitPlayer().sendMessage("Fingers Item: EMPTY");
}
if (solPlayer.getShouldersItem() > 0) {
ISoliniaItem item = StateManager.getInstance().getConfigurationManager().getItem(solPlayer.getNeckItem());
solPlayer.getBukkitPlayer().sendMessage("Shoulders Item: " + item.getDisplayname());
} else {
solPlayer.getBukkitPlayer().sendMessage("Shoulders Item: EMPTY");
}
} catch (CoreStateInitException e) {
}
}
use of com.solinia.solinia.Interfaces.ISoliniaItem in project solinia3-core by mixxit.
the class CommandEquip method onCommand.
@Override
public boolean onCommand(CommandSender sender, Command cmd, String label, String[] args) {
if (!(sender instanceof Player) && !(sender instanceof CommandSender))
return false;
Player player = (Player) sender;
try {
ISoliniaPlayer solPlayer = SoliniaPlayerAdapter.Adapt(player);
showCurrentEquippedItems(solPlayer);
ItemStack primaryItem = player.getInventory().getItemInMainHand();
if (primaryItem.getType().equals(Material.AIR)) {
player.sendMessage(ChatColor.GRAY + "Empty item in primary hand. You must hold the item you want to equip in your main hand");
return false;
}
if (!Utils.IsSoliniaItem(primaryItem)) {
player.sendMessage("You can only equip solinia items this way");
return true;
}
ISoliniaItem item = SoliniaItemAdapter.Adapt(primaryItem);
if (item == null) {
player.sendMessage("You cannot equip this item this way");
return true;
}
if (item.getMinLevel() > solPlayer.getLevel()) {
player.sendMessage("You cannot equip this item (minlevel: " + item.getMinLevel() + ")");
return true;
}
if (solPlayer.getClassObj() == null) {
player.sendMessage(ChatColor.GRAY + "Your class cannot wear this equipment");
return true;
}
if (item.isSpellscroll()) {
player.sendMessage("You cannot equip this item");
return true;
}
if (!item.getAllowedClassNames().contains(solPlayer.getClassObj().getName().toUpperCase())) {
player.sendMessage(ChatColor.GRAY + "Your class cannot wear this equipment");
return true;
}
if (item.getMinLevel() > solPlayer.getLevel()) {
player.sendMessage(ChatColor.GRAY + "Your are not sufficient level to wear this equipment");
return true;
}
if (item.isFingersItem())
if (solPlayer.getFingersItem() > 0) {
player.sendMessage("You have already equipped an item in that slot");
return true;
} else {
solPlayer.setFingersItem(item.getId());
player.getInventory().setItemInMainHand(null);
player.updateInventory();
player.sendMessage("You have equipped this item");
return true;
}
if (item.isShouldersItem())
if (solPlayer.getShouldersItem() > 0) {
player.sendMessage("You have already equipped an item in that slot");
return true;
} else {
solPlayer.setShouldersItem(item.getId());
player.getInventory().setItemInMainHand(null);
player.updateInventory();
player.sendMessage("You have equipped this item");
return true;
}
if (item.isNeckItem())
if (solPlayer.getNeckItem() > 0) {
player.sendMessage("You have already equipped an item in that slot");
return true;
} else {
solPlayer.setNeckItem(item.getId());
player.getInventory().setItemInMainHand(null);
player.updateInventory();
player.sendMessage("You have equipped this item");
return true;
}
return false;
} catch (CoreStateInitException e) {
return false;
} catch (SoliniaItemException e) {
player.sendMessage("You cannot equip this item");
return true;
}
}
use of com.solinia.solinia.Interfaces.ISoliniaItem in project solinia3-core by mixxit.
the class CommandLoot method sendLootListToSender.
private void sendLootListToSender(CommandSender sender, String itemMatch) {
try {
if (itemMatch.length() < 3) {
sender.sendMessage("Item search must be at least 3 characters: " + itemMatch);
return;
}
List<ISoliniaItem> items = StateManager.getInstance().getConfigurationManager().getItemsByPartialName(itemMatch);
int itemIdLookup = 0;
try {
itemIdLookup = Integer.parseInt(itemMatch);
ISoliniaItem item = StateManager.getInstance().getConfigurationManager().getItem(itemIdLookup);
items.add(item);
} catch (Exception e) {
}
if (items.size() < 1) {
sender.sendMessage("Could not find item: " + itemMatch);
return;
}
if (items.size() > 1) {
sender.sendMessage("More than one item found with this string, please be more specific: " + itemMatch);
return;
}
String itemname = "";
for (ISoliniaItem item : items) {
itemname = item.getDisplayname();
List<Integer> lootDropIds = StateManager.getInstance().getConfigurationManager().getLootDropIdsWithItemId(item.getId());
if (lootDropIds.size() < 1) {
sender.sendMessage("Item [" + itemname + "] not found in any loot drops");
return;
}
List<Integer> lootTableIds = StateManager.getInstance().getConfigurationManager().getLootTablesWithLootDrops(lootDropIds);
if (lootTableIds.size() < 1) {
sender.sendMessage("Item [" + itemname + "] not found in any loot tables");
return;
}
List<String> matchingNpcList = new ArrayList<String>();
String currentLine = "";
for (ISoliniaNPC npc : StateManager.getInstance().getConfigurationManager().getNPCs()) {
if (!lootTableIds.contains(npc.getLoottableid()))
continue;
if ((currentLine + npc.getName() + " ").length() > 2000) {
matchingNpcList.add(currentLine);
currentLine = "";
}
currentLine += npc.getName() + " ";
}
if (!currentLine.equals("")) {
matchingNpcList.add(currentLine);
}
for (String line : matchingNpcList) {
sender.sendMessage("Item [" + itemname + "] found on: " + line);
}
}
} catch (CoreStateInitException e) {
// ignore it
}
}
use of com.solinia.solinia.Interfaces.ISoliniaItem 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;
}
Aggregations