use of com.solinia.solinia.Models.SoliniaAccountClaim in project solinia3-core by mixxit.
the class JsonAccountClaimRepository method reload.
@Override
public void reload() {
List<SoliniaAccountClaim> file = new ArrayList<SoliniaAccountClaim>();
try {
Gson gson = new Gson();
BufferedReader br = new BufferedReader(new FileReader(filePath));
file = gson.fromJson(br, new TypeToken<List<SoliniaAccountClaim>>() {
}.getType());
} catch (FileNotFoundException e) {
e.printStackTrace();
}
AccountClaims.clear();
for (SoliniaAccountClaim i : file) {
AccountClaims.put(i.getId(), i);
}
System.out.println("Reloaded " + AccountClaims.size() + " AccountClaims");
}
use of com.solinia.solinia.Models.SoliniaAccountClaim in project solinia3-core by mixxit.
the class JsonAccountClaimRepository method commit.
@Override
public void commit() {
// TODO Auto-generated method stub
GsonBuilder gsonbuilder = new GsonBuilder();
// gsonbuilder.setPrettyPrinting();
Gson gson = gsonbuilder.create();
String jsonOutput = gson.toJson(AccountClaims.values(), new TypeToken<List<SoliniaAccountClaim>>() {
}.getType());
try {
File file = new File(filePath);
if (!file.exists())
file.createNewFile();
FileOutputStream fileOut = new FileOutputStream(file);
OutputStreamWriter outWriter = new OutputStreamWriter(fileOut);
outWriter.append(jsonOutput);
outWriter.close();
fileOut.close();
System.out.println("Commited " + AccountClaims.size() + " AccountClaims");
} catch (FileNotFoundException e) {
// TODO Auto-generated catch block
e.printStackTrace();
} catch (IOException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
}
use of com.solinia.solinia.Models.SoliniaAccountClaim 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.Models.SoliniaAccountClaim in project solinia3-core by mixxit.
the class CommandClaim method onCommand.
@Override
public boolean onCommand(CommandSender sender, Command cmd, String label, String[] args) {
try {
if (args.length < 1) {
sender.sendMessage(ChatColor.GRAY + "Insufficient arguments (list,claim)");
return true;
}
switch(args[0]) {
case "list":
if (!(sender instanceof Player))
return false;
Player player = (Player) sender;
ISoliniaPlayer solplayer = SoliniaPlayerAdapter.Adapt(player);
sender.sendMessage("Current Claims: " + solplayer.getAccountClaims().size());
for (SoliniaAccountClaim claim : solplayer.getAccountClaims()) {
ISoliniaItem item = StateManager.getInstance().getConfigurationManager().getItem(claim.getItemid());
if (item == null)
continue;
TextComponent tc = new TextComponent();
tc.setText(ChatColor.LIGHT_PURPLE + item.getDisplayname() + " /claim claim " + claim.getId());
tc.setHoverEvent(new HoverEvent(HoverEvent.Action.SHOW_ITEM, new ComponentBuilder(item.asJsonString()).create()));
sender.spigot().sendMessage(tc);
}
return true;
case "give":
if (!sender.isOp())
return false;
if (args.length < 3) {
sender.sendMessage("That is not a claim id - /claim give mcaccountname itemid");
return true;
}
String mcaccountname = args[1];
int itemId = Integer.parseInt(args[2].toUpperCase());
SoliniaAccountClaim newclaim = new SoliniaAccountClaim();
newclaim.setId(StateManager.getInstance().getConfigurationManager().getNextAccountClaimId());
newclaim.setMcname(mcaccountname);
newclaim.setItemid(itemId);
newclaim.setClaimed(false);
StateManager.getInstance().getConfigurationManager().addAccountClaim(newclaim);
sender.sendMessage("Account claim added!");
return true;
case "claim":
if (!(sender instanceof Player))
return false;
Player claimPlayer = (Player) sender;
ISoliniaPlayer solClaimPlayer = SoliniaPlayerAdapter.Adapt(claimPlayer);
sender.sendMessage("Current Claims: " + solClaimPlayer.getAccountClaims().size());
if (args.length < 2) {
sender.sendMessage("That is not a claim id - /claim claim claimid (see /claim list)");
return true;
}
int seekClaimId = Integer.parseInt(args[1].toUpperCase());
System.out.println("Looking up claims for player name: " + claimPlayer.getName() + " for claim ID: " + seekClaimId);
SoliniaAccountClaim claim = StateManager.getInstance().getConfigurationManager().getAccountClaim(claimPlayer.getName().toUpperCase(), seekClaimId);
if (claim == null) {
sender.sendMessage("That is not a valid claim - /claim claim claimid (see /claim list)");
return true;
}
ISoliniaItem item = StateManager.getInstance().getConfigurationManager().getItem(claim.getItemid());
if (item == null) {
sender.sendMessage("That is not a valid claim item - /claim claim claimid (see /claim list)");
return true;
}
claimPlayer.getWorld().dropItemNaturally(claimPlayer.getLocation(), item.asItemStack());
sender.sendMessage("Claim item dropped at your feet - ID: " + claim.getId());
StateManager.getInstance().getConfigurationManager().removeClaim(claim.getId());
return true;
default:
sender.sendMessage(ChatColor.GRAY + "Invalid arguments (list,claim)");
return true;
}
} catch (CoreStateInitException e) {
}
return true;
}
Aggregations