+>Alustine 3 set bonus now resists Infection, Bleeding, Burn, and

Shrapnel DoT effects.
 >Fixed UUID issues with World Shops and Daily Challenge scoreboards.
 >Minibosses no longer spawn in player-built locations (Similar to Elite
spawning behavior.)
patch_branch
sigonasr2 8 years ago
parent 2dbb09c8e0
commit d5969900b0
  1. BIN
      TwosideKeeper.jar
  2. 2
      src/plugin.yml
  3. 10
      src/sig/plugin/TwosideKeeper/CustomDamage.java
  4. 4
      src/sig/plugin/TwosideKeeper/HelperStructures/Common/GenericFunctions.java
  5. 2
      src/sig/plugin/TwosideKeeper/HelperStructures/ItemSet.java
  6. 22
      src/sig/plugin/TwosideKeeper/HelperStructures/ShopPurchase.java
  7. 26
      src/sig/plugin/TwosideKeeper/HelperStructures/WorldShop.java
  8. 4
      src/sig/plugin/TwosideKeeper/Monster/GenericBoss.java
  9. 3
      src/sig/plugin/TwosideKeeper/Monster/Knight.java
  10. 3
      src/sig/plugin/TwosideKeeper/Monster/SniperSkeleton.java
  11. 183
      src/sig/plugin/TwosideKeeper/PVP.java
  12. 63
      src/sig/plugin/TwosideKeeper/RecordKeeping.java
  13. 165
      src/sig/plugin/TwosideKeeper/TwosideKeeper.java
  14. 29
      src/sig/plugin/TwosideKeeper/TwosideKeeperAPI.java
  15. 49
      src/sig/plugin/TwosideKeeper/WorldShopManager.java

Binary file not shown.

@ -1,6 +1,6 @@
name: TwosideKeeper name: TwosideKeeper
main: sig.plugin.TwosideKeeper.TwosideKeeper main: sig.plugin.TwosideKeeper.TwosideKeeper
version: 3.11.1d version: 3.11.1f
loadbefore: [aPlugin] loadbefore: [aPlugin]
commands: commands:
money: money:

@ -1072,7 +1072,7 @@ public class CustomDamage {
private static void addSweepupBonus(Player p, double damage, String reason) { private static void addSweepupBonus(Player p, double damage, String reason) {
if (reason!=null && reason.equalsIgnoreCase("sweep up")) { if (reason!=null && reason.equalsIgnoreCase("sweep up")) {
if (ItemSet.HasSetBonusBasedOnSetBonusCount(p, ItemSet.PRIDE, 5)) { if (ItemSet.HasSetBonusBasedOnSetBonusCount(p, ItemSet.PRIDE, 5)) {
TwosideKeeper.log("In here. Damage: "+damage, 0); //TwosideKeeper.log("In here. Damage: "+damage, 0);
GenericFunctions.HealEntity(p, damage/2); GenericFunctions.HealEntity(p, damage/2);
} }
} }
@ -2282,8 +2282,8 @@ public class CustomDamage {
//!damager.getWorld().getPVP() //!damager.getWorld().getPVP()
Player attacker = (Player)damager; Player attacker = (Player)damager;
Player defender = (Player)target; Player defender = (Player)target;
if (!attacker.getWorld().getPVP() || !defender.isOnline() || if (attacker.getWorld().getPVP() && (!defender.isOnline() ||
PVP.isFriendly(attacker,defender) || !PVP.isPvPing(defender)) { PVP.isFriendly(attacker,defender) || !PVP.isPvPing(defender))) {
if (PVP.isWaitingForPlayers(defender)) { if (PVP.isWaitingForPlayers(defender)) {
PVP session = PVP.getMatch(defender); PVP session = PVP.getMatch(defender);
session.joinMatch(attacker); session.joinMatch(attacker);
@ -2418,7 +2418,7 @@ public class CustomDamage {
public static boolean CanResistDotsWithExperienceSet(Entity damager, LivingEntity target, String reason) { public static boolean CanResistDotsWithExperienceSet(Entity damager, LivingEntity target, String reason) {
return target instanceof Player && ItemSet.HasSetBonusBasedOnSetBonusCount((Player)target, ItemSet.ALUSTINE, 3) && return target instanceof Player && ItemSet.HasSetBonusBasedOnSetBonusCount((Player)target, ItemSet.ALUSTINE, 3) &&
((reason!=null && (reason.equalsIgnoreCase("poison") || reason.equalsIgnoreCase("wither") || reason.equalsIgnoreCase("fire_tick") || reason.equalsIgnoreCase("lava") || reason.equalsIgnoreCase("fire")))) && ((reason!=null && (reason.equalsIgnoreCase("shrapnel") ||reason.equalsIgnoreCase("bleeding") ||reason.equalsIgnoreCase("infection") ||reason.equalsIgnoreCase("burn") || reason.equalsIgnoreCase("poison") || reason.equalsIgnoreCase("wither") || reason.equalsIgnoreCase("fire_tick") || reason.equalsIgnoreCase("lava") || reason.equalsIgnoreCase("fire")))) &&
aPlugin.API.getTotalExperience((Player)target)>=ItemSet.TotalBaseAmountBasedOnSetBonusCount((Player)target, ItemSet.ALUSTINE, 3, 3); aPlugin.API.getTotalExperience((Player)target)>=ItemSet.TotalBaseAmountBasedOnSetBonusCount((Player)target, ItemSet.ALUSTINE, 3, 3);
} }
@ -3642,7 +3642,7 @@ public class CustomDamage {
Player p = (Player)damager; Player p = (Player)damager;
if (target instanceof Player && if (target instanceof Player &&
PVP.isEnemy(p, (Player)target)) { PVP.isEnemy(p, (Player)target)) {
armorpenmult = 0.25; armorpenmult = 0.2;
} }
PlayerStructure pd = PlayerStructure.GetPlayerStructure(p); PlayerStructure pd = PlayerStructure.GetPlayerStructure(p);
if (GenericFunctions.isArtifactEquip(weapon) && if (GenericFunctions.isArtifactEquip(weapon) &&

@ -3241,7 +3241,7 @@ public class GenericFunctions {
public static boolean hasPermissionToBreakSign(Sign s, Player p) { public static boolean hasPermissionToBreakSign(Sign s, Player p) {
if (WorldShop.isWorldShopSign(s)) { if (WorldShop.isWorldShopSign(s)) {
WorldShop shop = TwosideKeeper.TwosideShops.LoadWorldShopData(s); WorldShop shop = TwosideKeeper.TwosideShops.LoadWorldShopData(s);
if (shop.GetOwner().equalsIgnoreCase(p.getName()) || p.isOp()) { if (shop.GetOwner().equals(p.getUniqueId()) || p.isOp()) {
return true; return true;
} else { } else {
return false; return false;
@ -4061,7 +4061,7 @@ public class GenericFunctions {
} }
if (allowed) { if (allowed) {
LivingEntity m = (LivingEntity)e; LivingEntity m = (LivingEntity)e;
TwosideKeeper.log("Allowed to hit entity "+GenericFunctions.GetEntityDisplayName(m)+" Damager: "+GenericFunctions.GetEntityDisplayName(damager), 0); //TwosideKeeper.log("Allowed to hit entity "+GenericFunctions.GetEntityDisplayName(m)+" Damager: "+GenericFunctions.GetEntityDisplayName(damager), 0);
affectedents.add(m); affectedents.add(m);
if (enoughTicksHavePassed(m,(Player)damager)) { if (enoughTicksHavePassed(m,(Player)damager)) {
basedmg=origdmg; basedmg=origdmg;

@ -711,7 +711,7 @@ public enum ItemSet {
lore.add(ChatColor.DARK_AQUA+" 2 - "+ChatColor.WHITE+" Gain immunity to Explosions."); lore.add(ChatColor.DARK_AQUA+" 2 - "+ChatColor.WHITE+" Gain immunity to Explosions.");
lore.add(ChatColor.DARK_AQUA+" "+ChatColor.WHITE+" Consumes "+ChatColor.YELLOW+ItemSet.GetBaseAmount(set, tier, 2)+" XP"+ChatColor.WHITE+" per absorbed hit."); lore.add(ChatColor.DARK_AQUA+" "+ChatColor.WHITE+" Consumes "+ChatColor.YELLOW+ItemSet.GetBaseAmount(set, tier, 2)+" XP"+ChatColor.WHITE+" per absorbed hit.");
lore.add(ChatColor.DARK_AQUA+" "+ChatColor.GRAY+ChatColor.ITALIC+"Must have at least "+ChatColor.YELLOW+ChatColor.ITALIC+ItemSet.GetBaseAmount(set, tier, 2)+" XP"+ChatColor.GRAY+ChatColor.ITALIC+" to trigger."); lore.add(ChatColor.DARK_AQUA+" "+ChatColor.GRAY+ChatColor.ITALIC+"Must have at least "+ChatColor.YELLOW+ChatColor.ITALIC+ItemSet.GetBaseAmount(set, tier, 2)+" XP"+ChatColor.GRAY+ChatColor.ITALIC+" to trigger.");
lore.add(ChatColor.DARK_AQUA+" 3 - "+ChatColor.WHITE+" Resists all fire, poison, and wither damage."); lore.add(ChatColor.DARK_AQUA+" 3 - "+ChatColor.WHITE+" Resists all fire, poison, bleeding, infection and wither damage.");
lore.add(ChatColor.DARK_AQUA+" "+ChatColor.WHITE+" Consumes "+ChatColor.YELLOW+ItemSet.GetBaseAmount(set, tier, 3)+" XP"+ChatColor.WHITE+" per absorbed hit."); lore.add(ChatColor.DARK_AQUA+" "+ChatColor.WHITE+" Consumes "+ChatColor.YELLOW+ItemSet.GetBaseAmount(set, tier, 3)+" XP"+ChatColor.WHITE+" per absorbed hit.");
lore.add(ChatColor.DARK_AQUA+" "+ChatColor.GRAY+ChatColor.ITALIC+"Must have at least "+ChatColor.YELLOW+ChatColor.ITALIC+ItemSet.GetBaseAmount(set, tier, 3)+" XP"+ChatColor.GRAY+ChatColor.ITALIC+" to trigger."); lore.add(ChatColor.DARK_AQUA+" "+ChatColor.GRAY+ChatColor.ITALIC+"Must have at least "+ChatColor.YELLOW+ChatColor.ITALIC+ItemSet.GetBaseAmount(set, tier, 3)+" XP"+ChatColor.GRAY+ChatColor.ITALIC+" to trigger.");
lore.add(ChatColor.DARK_AQUA+" 5 - "+ChatColor.WHITE+" Backstabs spill "+ChatColor.YELLOW+ItemSet.GetBaseAmount(set, tier, 4)+" XP"+ChatColor.WHITE+" out from the target hit."); lore.add(ChatColor.DARK_AQUA+" 5 - "+ChatColor.WHITE+" Backstabs spill "+ChatColor.YELLOW+ItemSet.GetBaseAmount(set, tier, 4)+" XP"+ChatColor.WHITE+" out from the target hit.");

@ -1,7 +1,9 @@
package sig.plugin.TwosideKeeper.HelperStructures; package sig.plugin.TwosideKeeper.HelperStructures;
import java.text.DecimalFormat; import java.text.DecimalFormat;
import java.util.UUID;
import org.bukkit.Bukkit;
import org.bukkit.ChatColor; import org.bukkit.ChatColor;
import org.bukkit.inventory.ItemStack; import org.bukkit.inventory.ItemStack;
@ -11,14 +13,14 @@ import net.md_5.bungee.api.chat.TextComponent;
import sig.plugin.TwosideKeeper.HelperStructures.Common.GenericFunctions; import sig.plugin.TwosideKeeper.HelperStructures.Common.GenericFunctions;
public class ShopPurchase { public class ShopPurchase {
String player; UUID player;
String customer; UUID customer;
ItemStack item; ItemStack item;
double money; double money;
int amt; int amt;
boolean sell; boolean sell;
public ShopPurchase(String p, String customer, ItemStack item, double money, int amt) { public ShopPurchase(UUID p, UUID customer, ItemStack item, double money, int amt) {
this.player = p; this.player = p;
this.customer=customer; this.customer=customer;
this.item=item; this.item=item;
@ -27,7 +29,7 @@ public class ShopPurchase {
this.sell=true; this.sell=true;
} }
public ShopPurchase(String p, String customer, ItemStack item, double money, int amt, boolean sell) { public ShopPurchase(UUID p, UUID customer, ItemStack item, double money, int amt, boolean sell) {
this.player = p; this.player = p;
this.customer=customer; this.customer=customer;
this.item=item; this.item=item;
@ -36,11 +38,11 @@ public class ShopPurchase {
this.sell=sell; this.sell=sell;
} }
public String getSeller() { public UUID getSeller() {
return player; return Bukkit.getOfflinePlayer(player).getUniqueId();
} }
public String getCustomer() { public UUID getCustomer() {
return customer; return Bukkit.getOfflinePlayer(customer).getUniqueId();
} }
public ItemStack getItem() { public ItemStack getItem() {
return item; return item;
@ -58,7 +60,7 @@ public class ShopPurchase {
public TextComponent announcementString() { public TextComponent announcementString() {
DecimalFormat df = new DecimalFormat("0.00"); DecimalFormat df = new DecimalFormat("0.00");
if (sell) { if (sell) {
TextComponent message1 = new TextComponent("Player "+ChatColor.BLUE+customer+ChatColor.WHITE+" has purchased "+ChatColor.YELLOW+amt+ChatColor.WHITE+" of your "); TextComponent message1 = new TextComponent("Player "+ChatColor.BLUE+WorldShop.getFriendlyOwnerName(customer)+ChatColor.WHITE+" has purchased "+ChatColor.YELLOW+amt+ChatColor.WHITE+" of your ");
TextComponent message2 = new TextComponent(ChatColor.GREEN+"["+GenericFunctions.GetItemName(this.item)+ChatColor.RESET+""+ChatColor.GREEN+"]"); TextComponent message2 = new TextComponent(ChatColor.GREEN+"["+GenericFunctions.GetItemName(this.item)+ChatColor.RESET+""+ChatColor.GREEN+"]");
message2.setHoverEvent(new HoverEvent( HoverEvent.Action.SHOW_TEXT, new ComponentBuilder(GenericFunctions.GetItemName(this.item)+WorldShop.GetItemInfo(this.item)).create())); message2.setHoverEvent(new HoverEvent( HoverEvent.Action.SHOW_TEXT, new ComponentBuilder(GenericFunctions.GetItemName(this.item)+WorldShop.GetItemInfo(this.item)).create()));
TextComponent message3 = new TextComponent(". You have earned $"+df.format(money)+". "+ChatColor.GRAY+""+ChatColor.ITALIC+"(See /money)"); TextComponent message3 = new TextComponent(". You have earned $"+df.format(money)+". "+ChatColor.GRAY+""+ChatColor.ITALIC+"(See /money)");
@ -67,7 +69,7 @@ public class ShopPurchase {
finalmsg.addExtra(message3); finalmsg.addExtra(message3);
return finalmsg; return finalmsg;
} else { } else {
TextComponent message1 = new TextComponent("Player "+ChatColor.BLUE+customer+ChatColor.WHITE+" has sold "+ChatColor.YELLOW+amt+ChatColor.WHITE+" "); TextComponent message1 = new TextComponent("Player "+ChatColor.BLUE+WorldShop.getFriendlyOwnerName(customer)+ChatColor.WHITE+" has sold "+ChatColor.YELLOW+amt+ChatColor.WHITE+" ");
TextComponent message2 = new TextComponent(ChatColor.GREEN+"["+GenericFunctions.GetItemName(this.item)+ChatColor.RESET+""+ChatColor.GREEN+"]"); TextComponent message2 = new TextComponent(ChatColor.GREEN+"["+GenericFunctions.GetItemName(this.item)+ChatColor.RESET+""+ChatColor.GREEN+"]");
message2.setHoverEvent(new HoverEvent( HoverEvent.Action.SHOW_TEXT, new ComponentBuilder(GenericFunctions.GetItemName(this.item)+WorldShop.GetItemInfo(this.item)).create())); message2.setHoverEvent(new HoverEvent( HoverEvent.Action.SHOW_TEXT, new ComponentBuilder(GenericFunctions.GetItemName(this.item)+WorldShop.GetItemInfo(this.item)).create()));
TextComponent message3 = new TextComponent(" to you. $"+df.format(money)+" has been deducted from your bank account. "+ChatColor.GRAY+""+ChatColor.ITALIC+"(Check your shop to collect your items.)"); TextComponent message3 = new TextComponent(" to you. $"+df.format(money)+" has been deducted from your bank account. "+ChatColor.GRAY+""+ChatColor.ITALIC+"(Check your shop to collect your items.)");

@ -16,6 +16,7 @@ import java.util.List;
import java.util.Map; import java.util.Map;
import java.util.Random; import java.util.Random;
import java.util.Set; import java.util.Set;
import java.util.UUID;
import org.bukkit.Bukkit; import org.bukkit.Bukkit;
import org.bukkit.ChatColor; import org.bukkit.ChatColor;
@ -24,6 +25,7 @@ import org.bukkit.DyeColor;
import org.bukkit.FireworkEffect; import org.bukkit.FireworkEffect;
import org.bukkit.Location; import org.bukkit.Location;
import org.bukkit.Material; import org.bukkit.Material;
import org.bukkit.OfflinePlayer;
import org.bukkit.block.Banner; import org.bukkit.block.Banner;
import org.bukkit.block.Block; import org.bukkit.block.Block;
import org.bukkit.block.BlockFace; import org.bukkit.block.BlockFace;
@ -63,7 +65,7 @@ import sig.plugin.TwosideKeeper.HelperStructures.Utils.ItemUtils;
public class WorldShop { public class WorldShop {
ItemStack item; ItemStack item;
String owner; UUID owner;
double price; double price;
int amt; int amt;
int storedamt = 0; int storedamt = 0;
@ -72,8 +74,9 @@ public class WorldShop {
public static final double DEFAULTPRICE = 99.99; public static final double DEFAULTPRICE = 99.99;
public static HashMap<String,Double> pricelist = new HashMap<String,Double>(); public static HashMap<String,Double> pricelist = new HashMap<String,Double>();
public static String price_file = TwosideKeeper.plugin.getDataFolder()+"/ShopPrices.data"; public static String price_file = TwosideKeeper.plugin.getDataFolder()+"/ShopPrices.data";
public static final UUID ADMIN_UUID = UUID.nameUUIDFromBytes(new byte[]{(byte)0});
public WorldShop (ItemStack i, int amt, int storedamt, double p, String player, int shopID, Location shopLoc) { public WorldShop (ItemStack i, int amt, int storedamt, double p, UUID player, int shopID, Location shopLoc) {
this.item=i; this.item=i;
this.price=p; this.price=p;
this.owner=player; this.owner=player;
@ -110,6 +113,15 @@ public class WorldShop {
this.loc=loc; this.loc=loc;
} }
public static String getFriendlyOwnerName(UUID id) {
OfflinePlayer op = Bukkit.getOfflinePlayer(id);
if (op!=null) {
return op.getName();
} else {
return "admin";
}
}
public Location getLoc() { public Location getLoc() {
return loc; return loc;
} }
@ -121,7 +133,7 @@ public class WorldShop {
return item; return item;
} }
public double GetUnitPrice() { public double GetUnitPrice() {
if (owner.equalsIgnoreCase("admin")) { if (owner.equals(ADMIN_UUID)) {
return GetWorldShopPrice(item); return GetWorldShopPrice(item);
} else { } else {
return price; return price;
@ -241,13 +253,13 @@ public class WorldShop {
return id; return id;
} }
public int GetAmount() { public int GetAmount() {
if (owner.equalsIgnoreCase("admin")) { if (owner.equals(ADMIN_UUID)) {
return 10000; return 10000;
} else { } else {
return amt; return amt;
} }
} }
public String GetOwner() { public UUID GetOwner() {
return owner; return owner;
} }
@ -1101,7 +1113,7 @@ public class WorldShop {
public static boolean hasPermissionToBreakWorldShopSign(Sign s, Player p) { public static boolean hasPermissionToBreakWorldShopSign(Sign s, Player p) {
if (WorldShop.isWorldShopSign(s)) { if (WorldShop.isWorldShopSign(s)) {
WorldShop shop = TwosideKeeper.TwosideShops.LoadWorldShopData(s); WorldShop shop = TwosideKeeper.TwosideShops.LoadWorldShopData(s);
if (shop.GetOwner().equalsIgnoreCase(p.getName()) || p.isOp()) { if (shop.GetOwner().equals(p.getUniqueId()) || p.isOp()) {
return true; return true;
} else { } else {
return false; return false;
@ -1240,7 +1252,7 @@ public class WorldShop {
wallsign.setData(sign.getData()); wallsign.setData(sign.getData());
Sign s = (Sign)wallsign.getState(); Sign s = (Sign)wallsign.getState();
s.setLine(0,"shop"); s.setLine(0,"shop");
WorldShop shop = TwosideKeeper.TwosideShops.CreateWorldShop(s, item, 10000, DEFAULTPRICE, "admin"); WorldShop shop = TwosideKeeper.TwosideShops.CreateWorldShop(s, item, 10000, DEFAULTPRICE, ADMIN_UUID);
/*s.setLine(0, ChatColor.BLUE+"-- SHOP --"); /*s.setLine(0, ChatColor.BLUE+"-- SHOP --");
s.setLine(1, GenericFunctions.UserFriendlyMaterialName(item)); s.setLine(1, GenericFunctions.UserFriendlyMaterialName(item));
s.setLine(2, "$"+df.format(GetWorldShopPrice(item))+ChatColor.DARK_BLUE+" [x10000]"); s.setLine(2, "$"+df.format(GetWorldShopPrice(item))+ChatColor.DARK_BLUE+" [x10000]");

@ -293,8 +293,8 @@ public class GenericBoss extends CustomMonster{
it.setPickupDelay(0);*/ it.setPickupDelay(0);*/
} }
} }
Bukkit.getServer().broadcastMessage(ChatColor.GREEN+participants_list.toString()+ChatColor.WHITE+" "+(participants_list.length()==1?"has single-handedly taken down the ":"have successfully slain ")+GenericFunctions.getDisplayName(m)+ChatColor.WHITE+"!"); Bukkit.getServer().broadcastMessage(ChatColor.GREEN+participants_list.toString()+ChatColor.WHITE+" "+(participants.size()==1?"has single-handedly taken down the ":"have successfully slain ")+GenericFunctions.getDisplayName(m)+ChatColor.WHITE+"!");
aPlugin.API.discordSendRaw(ChatColor.GREEN+participants_list.toString()+ChatColor.WHITE+" "+(participants_list.length()==1?"has single-handedly taken down the ":"have successfully slain ")+"**"+GenericFunctions.getDisplayName(m)+ChatColor.WHITE+"**!"); aPlugin.API.discordSendRaw(ChatColor.GREEN+participants_list.toString()+ChatColor.WHITE+" "+(participants.size()==1?"has single-handedly taken down the ":"have successfully slain ")+"**"+GenericFunctions.getDisplayName(m)+ChatColor.WHITE+"**!");
Bukkit.getScheduler().scheduleSyncDelayedTask(TwosideKeeper.plugin, new Runnable() { Bukkit.getScheduler().scheduleSyncDelayedTask(TwosideKeeper.plugin, new Runnable() {
public void run() { public void run() {

@ -941,7 +941,8 @@ public class Knight extends GenericBoss{
!m.getWorld().getName().contains("Instance") && !m.getWorld().getName().contains("Instance") &&
Math.random()<=0.015 && Math.random()<=0.015 &&
TwosideKeeper.elitemonsters.size()==0 && TwosideKeeper.elitemonsters.size()==0 &&
GenericBoss.bossCount()==0) || force) { //GenericBoss.bossCount()==0 &&
GenericFunctions.AllNaturalBlocks(m.getLocation().getBlock(),16,8,16)) || force) {
Skeleton s = (Skeleton)m; Skeleton s = (Skeleton)m;
s.setSkeletonType(SkeletonType.WITHER); s.setSkeletonType(SkeletonType.WITHER);
Spider ss = DarkSpider.InitializeDarkSpider(m); Spider ss = DarkSpider.InitializeDarkSpider(m);

@ -675,7 +675,8 @@ public class SniperSkeleton extends GenericBoss{
!m.getWorld().getName().contains("Instance") && !m.getWorld().getName().contains("Instance") &&
Math.random()<=0.015 && Math.random()<=0.015 &&
TwosideKeeper.elitemonsters.size()==0 && TwosideKeeper.elitemonsters.size()==0 &&
GenericBoss.bossCount()==0) || force) { //GenericBoss.bossCount()==0 &&
GenericFunctions.AllNaturalBlocks(m.getLocation().getBlock(),16,8,16)) || force) {
Skeleton s = (Skeleton)m; Skeleton s = (Skeleton)m;
s.setSkeletonType(SkeletonType.NORMAL); s.setSkeletonType(SkeletonType.NORMAL);
//Determine distance from Twoside for Difficulty. //Determine distance from Twoside for Difficulty.

@ -24,6 +24,10 @@ public class PVP {
PVPOption battlefield; PVPOption battlefield;
CHOICEENGINE state; CHOICEENGINE state;
long timer; long timer;
private long lastSelected=0;
int scorelimit;
long timelimit;
boolean scorematch = false; //If true, uses score limit. If false uses timer.
//NEUTRAL team //NEUTRAL team
//Team1 //Team1
@ -145,10 +149,17 @@ public class PVP {
p.sendMessage(ChatColor.YELLOW+style.getTitle()+ChatColor.GREEN+" has been voted as the style for this PVP match!"); p.sendMessage(ChatColor.YELLOW+style.getTitle()+ChatColor.GREEN+" has been voted as the style for this PVP match!");
} }
} }
if (players.size()>2 && style.name().contains("ROUNDS")) {
state = CHOICEENGINE.WAITFORTEAMCHOICES;
lastSelected=TwosideKeeper.getServerTickTime();
resetPlayerChoices();
DisplayTeamChoices();
} else {
state = CHOICEENGINE.WAITFORSTAGECHOICES; state = CHOICEENGINE.WAITFORSTAGECHOICES;
timer=TwosideKeeper.getServerTickTime();
resetPlayerChoices(); resetPlayerChoices();
DisplayStageChoices(); DisplayStageChoices();
}
timer=TwosideKeeper.getServerTickTime();
} else { } else {
for (String s : players.keySet()) { for (String s : players.keySet()) {
Player pl = Bukkit.getPlayer(s); Player pl = Bukkit.getPlayer(s);
@ -160,6 +171,26 @@ public class PVP {
} }
} }
}break; }break;
case WAITFORTEAMCHOICES:{
if (lastSelected+100<=TwosideKeeper.getServerTickTime()) {
if (allPlayersHaveChosenATeam() || lastSelected+4000<=TwosideKeeper.getServerTickTime()) {
randomlyPickTeams();
if (teamsAreInvalid()) {
for (String s : players.keySet()) {
Player p = Bukkit.getPlayer(s);
if (p!=null) {
p.sendMessage("Not enough players in both teams to begin a PvP Match! The match has been cancelled.");
}
}
return false;
}
SendTeamList();
resetPlayerChoices();
DisplayStageChoices();
state = CHOICEENGINE.WAITFORSTAGECHOICES;
}
}
}break;
case WAITFORSTAGECHOICES:{ case WAITFORSTAGECHOICES:{
if (timer+400<=TwosideKeeper.getServerTickTime() || allPlayersPicked()) { if (timer+400<=TwosideKeeper.getServerTickTime() || allPlayersPicked()) {
if (players.size()>=2) { if (players.size()>=2) {
@ -215,6 +246,38 @@ public class PVP {
return true; return true;
} }
private boolean teamsAreInvalid() {
if (getPlayersInTeam(1).size()==0 ||
getPlayersInTeam(2).size()==0) {
return true;
} else {
return false;
}
}
private void randomlyPickTeams() {
for (String s : players.keySet()) {
PVPPlayer pp = players.get(s);
if (pp.team==0) {
if (getPlayersInTeam(1).size()<getPlayersInTeam(2).size()) {
pp.team=1;
} else {
pp.team=2;
}
}
}
}
private boolean allPlayersHaveChosenATeam() {
for (String s : players.keySet()) {
PVPPlayer pp = players.get(s);
if (pp.team==0) {
return false;
}
}
return true;
}
private void TransferPlayersToArena() { private void TransferPlayersToArena() {
Location baseloc = null; Location baseloc = null;
for (String s : players.keySet()) { for (String s : players.keySet()) {
@ -227,7 +290,11 @@ public class PVP {
pp.startingLoc = baseloc; pp.startingLoc = baseloc;
} }
if (Bukkit.getPlayer(s)!=null) { if (Bukkit.getPlayer(s)!=null) {
if (pp.team!=0) {
PVP.setTeam(s+"_TEAM"+pp.team, Bukkit.getPlayer(s));
} else {
PVP.setTeam(s+"_PVP", Bukkit.getPlayer(s)); PVP.setTeam(s+"_PVP", Bukkit.getPlayer(s));
}
pp.lastLoc = Bukkit.getPlayer(s).getLocation().clone(); pp.lastLoc = Bukkit.getPlayer(s).getLocation().clone();
Bukkit.getPlayer(s).sendMessage(ChatColor.GREEN+"The PVP Match between "+getParticipants()+" has begun!"); Bukkit.getPlayer(s).sendMessage(ChatColor.GREEN+"The PVP Match between "+getParticipants()+" has begun!");
aPlugin.API.discordSendRawItalicized("The PVP Match between **"+getParticipants()+"** has begun!"); aPlugin.API.discordSendRawItalicized("The PVP Match between **"+getParticipants()+"** has begun!");
@ -251,6 +318,18 @@ public class PVP {
} }
} }
private void DisplayTeamChoices() {
for (String s : players.keySet()) {
Player p = Bukkit.getPlayer(s);
if (p!=null && p.isValid() && p.isOnline()) {
p.sendMessage(ChatColor.GREEN+"Please pick a team:");
TextComponent tc = PVPOption.TEAM1.getComponent();
tc.addExtra(" ");tc.addExtra(PVPOption.TEAM2.getComponent());
p.spigot().sendMessage(tc);
}
}
}
private void DisplayRoundChoices() { private void DisplayRoundChoices() {
for (String s : players.keySet()) { for (String s : players.keySet()) {
Player p = Bukkit.getPlayer(s); Player p = Bukkit.getPlayer(s);
@ -292,7 +371,22 @@ public class PVP {
PVPOption option = PVPOption.valueOf(choice); PVPOption option = PVPOption.valueOf(choice);
if (ValidateChoice(option)) { if (ValidateChoice(option)) {
pp.choice = option; pp.choice = option;
lastSelected=TwosideKeeper.getServerTickTime();
if (state!=CHOICEENGINE.WAITFORTEAMCHOICES) {
p.sendMessage(ChatColor.GRAY+""+ChatColor.ITALIC+"Your choice for "+ChatColor.GREEN+option.getTitle()+ChatColor.RESET+" has been entered."); p.sendMessage(ChatColor.GRAY+""+ChatColor.ITALIC+"Your choice for "+ChatColor.GREEN+option.getTitle()+ChatColor.RESET+" has been entered.");
} else {
pp.team=pp.choice.selection_numb;
SendTeamList();
for (String s : players.keySet()) {
Player pl = Bukkit.getPlayer(s);
if (pl!=null) {
pl.sendMessage(ChatColor.GREEN+"Please pick a team:");
TextComponent tc = PVPOption.TEAM1.getComponent();
tc.addExtra(" ");tc.addExtra(PVPOption.TEAM2.getComponent());
pl.spigot().sendMessage(tc);
}
}
}
timer=TwosideKeeper.getServerTickTime(); timer=TwosideKeeper.getServerTickTime();
} else { } else {
p.sendMessage(ChatColor.RED+"That is not a valid option!"); p.sendMessage(ChatColor.RED+"That is not a valid option!");
@ -300,11 +394,66 @@ public class PVP {
} }
} }
private void SendTeamList() {
List<String> team1 = getPlayersInTeam(1);
List<String> team2 = getPlayersInTeam(2);
StringBuilder sb = new StringBuilder();
sb.append(ChatColor.BLUE+"\n"+ChatColor.UNDERLINE+" Team 1 \n"+ChatColor.RESET+ChatColor.AQUA);
if (team1.size()>0) {
AppendTeam(team1, sb);
} else {
sb.append(ChatColor.ITALIC+"No One"+ChatColor.RESET);
}
sb.append("\n\n"+ChatColor.RED+""+ChatColor.UNDERLINE+" Team 2 \n"+ChatColor.RESET+ChatColor.GOLD);
if (team2.size()>0) {
AppendTeam(team2, sb);
} else {
sb.append(ChatColor.ITALIC+"No One"+ChatColor.RESET);
}
sb.append("\n");
for (String s : players.keySet()) {
Player p = Bukkit.getPlayer(s);
if (p!=null) {
p.sendMessage(sb.toString());
}
}
}
private void AppendTeam(List<String> team1, StringBuilder sb) {
for (int i=0;i<team1.size();i++) {
if (i==0) {
sb.append(team1.get(i));
} else {
if (team1.size()==2) {
sb.append(" and "+team1.get(i));
} else {
if (i==team1.size()-1) {
sb.append(", and "+team1.get(i));
} else {
sb.append(", "+team1.get(i));
}
}
}
}
}
private List<String> getPlayersInTeam(int i) {
List<String> teams = new ArrayList<String>();
for (String s : players.keySet()) {
PVPPlayer pp = players.get(s);
if (pp.team==i) {
teams.add(s);
}
}
return teams;
}
private boolean ValidateChoice(PVPOption option) { private boolean ValidateChoice(PVPOption option) {
List<PVPOption> options1 = ImmutableList.of(PVPOption.ROUNDS3,PVPOption.ROUNDS5,PVPOption.ROUNDS7, List<PVPOption> options1 = ImmutableList.of(PVPOption.ROUNDS3,PVPOption.ROUNDS5,PVPOption.ROUNDS7,
PVPOption.ROUNDS15,PVPOption.MIN3,PVPOption.MIN5,PVPOption.MIN10); PVPOption.ROUNDS15,PVPOption.MIN3,PVPOption.MIN5,PVPOption.MIN10);
List<PVPOption> options2 = ImmutableList.of(PVPOption.OPENWORLD,PVPOption.SMALLBATTLEFIELD,PVPOption.AQUATICFORT, List<PVPOption> options2 = ImmutableList.of(PVPOption.OPENWORLD,PVPOption.SMALLBATTLEFIELD,PVPOption.AQUATICFORT,
PVPOption.NETHERFORTRESS,PVPOption.THEEND); PVPOption.NETHERFORTRESS,PVPOption.THEEND);
List<PVPOption> options3 = ImmutableList.of(PVPOption.TEAM1,PVPOption.TEAM2);
switch (state) { switch (state) {
case WAITFORROUNDCHOICES:{ case WAITFORROUNDCHOICES:{
return options1.contains(option); return options1.contains(option);
@ -312,6 +461,9 @@ public class PVP {
case WAITFORSTAGECHOICES:{ case WAITFORSTAGECHOICES:{
return options2.contains(option); return options2.contains(option);
} }
case WAITFORTEAMCHOICES:{
return options3.contains(option);
}
} }
return true; return true;
} }
@ -437,18 +589,21 @@ class PVPPlayer {
Location startingLoc; Location startingLoc;
Location lastLoc; Location lastLoc;
PVPOption choice; PVPOption choice;
int team;
PVPPlayer() { PVPPlayer() {
score=0; score=0;
startingLoc=null; startingLoc=null;
choice=PVPOption.NONE; choice=PVPOption.NONE;
lastLoc=null; lastLoc=null;
team=0;
} }
} }
enum CHOICEENGINE { enum CHOICEENGINE {
WAITFORPLAYERS, //Waits 10 seconds for any additional players to join in. WAITFORPLAYERS, //Waits 10 seconds for any additional players to join in.
WAITFORROUNDCHOICES, //Asks all participants to submit a round choice. (10 seconds Max) WAITFORROUNDCHOICES, //Asks all participants to submit a round choice. (10 seconds Max)
WAITFORTEAMCHOICES, //Asks all participants to submit a team choice.
WAITFORSTAGECHOICES, //Asks all participants to submit a stage choice. (10 seconds Max) WAITFORSTAGECHOICES, //Asks all participants to submit a stage choice. (10 seconds Max)
PREPAREFORBATTLE, //Gives players 10 seconds before transferring them. PREPAREFORBATTLE, //Gives players 10 seconds before transferring them.
FIGHTING, //The actual fighting FIGHTING, //The actual fighting
@ -457,29 +612,39 @@ enum CHOICEENGINE {
enum PVPOption { enum PVPOption {
NONE(0,"No Choice","Hey look! It's my favorite streamer! The one and only >>Legendary<<, yes LEGENDARY Captain_Marrow aka Storm! We break ultimate plates, alchemize Artifacts, miss skillshots, break Master Swords, collect food because we cannot dodge the Ganon, deny our combat-buddies from keeping their legendary equipment, and jump off boats right before they leave ( cy@ VoHiYo )! Come join the fun! Kappa"), NONE(0,"No Choice","Hey look! It's my favorite streamer! The one and only >>Legendary<<, yes LEGENDARY Captain_Marrow aka Storm! We break ultimate plates, alchemize Artifacts, miss skillshots, break Master Swords, collect food because we cannot dodge the Ganon, deny our combat-buddies from keeping their legendary equipment, and jump off boats right before they leave ( cy@ VoHiYo )! Come join the fun! Kappa"),
ROUNDS3(1,ChatColor.WHITE+"Best of 3","The player that wins 2 of 3 total rounds wins the duel."), ROUNDS3(1,ChatColor.WHITE+"Best of 3","The team that wins 2 of 3 total rounds wins the duel."),
ROUNDS5(2,ChatColor.GRAY+"Best of 5","The player that wins 3 of 5 total rounds wins the duel."), ROUNDS5(2,ChatColor.GRAY+"Best of 5","The team that wins 3 of 5 total rounds wins the duel."),
ROUNDS7(3,ChatColor.WHITE+"Best of 7","The player that wins 4 of 7 total rounds wins the duel."), ROUNDS7(3,ChatColor.WHITE+"Best of 7","The team that wins 4 of 7 total rounds wins the duel."),
ROUNDS15(4,ChatColor.GRAY+"Best of 15","The player that wins 8 of 15 total rounds wins the duel."), ROUNDS15(4,ChatColor.GRAY+"Best of 15","The team that wins 8 of 15 total rounds wins the duel."),
MIN3(5,ChatColor.WHITE+"3 Min Deathmatch","The player that gets the highest score within 3 minutes wins the duel. "+ChatColor.GREEN+"+1 Point per Kill"+ChatColor.RESET+", "+ChatColor.RED+"-1 Point per Death"), MIN3(5,ChatColor.WHITE+"3 Min Deathmatch","The player that gets the highest score within 3 minutes wins the duel. "+ChatColor.GREEN+"+1 Point per Kill"+ChatColor.RESET+", "+ChatColor.RED+"-1 Point per Death",20*60*3),
MIN5(6,ChatColor.GRAY+"5 Min Deathmatch","The player that gets the highest score within 5 minutes wins the duel. "+ChatColor.GREEN+"+1 Point per Kill"+ChatColor.RESET+", "+ChatColor.RED+"-1 Point per Death"), MIN5(6,ChatColor.GRAY+"5 Min Deathmatch","The player that gets the highest score within 5 minutes wins the duel. "+ChatColor.GREEN+"+1 Point per Kill"+ChatColor.RESET+", "+ChatColor.RED+"-1 Point per Death",20*60*5),
MIN10(7,ChatColor.WHITE+"10 Min Deathmatch","The player that gets the highest score within 10 minutes wins the duel. "+ChatColor.GREEN+"+1 Point per Kill"+ChatColor.RESET+", "+ChatColor.RED+"-1 Point per Death"), MIN10(7,ChatColor.WHITE+"10 Min Deathmatch","The player that gets the highest score within 10 minutes wins the duel. "+ChatColor.GREEN+"+1 Point per Kill"+ChatColor.RESET+", "+ChatColor.RED+"-1 Point per Death",20*60*10),
OPENWORLD(1,ChatColor.WHITE+"Open World","Fight in the current location you are located at."+ChatColor.RED+"\n NOTE: "+ChatColor.WHITE+"You may not wander more than 32 blocks away from your starting battle location."), OPENWORLD(1,ChatColor.WHITE+"Open World","Fight in the current location you are located at."+ChatColor.RED+"\n NOTE: "+ChatColor.WHITE+"You may not wander more than 32 blocks away from your starting battle location."),
SMALLBATTLEFIELD(2,ChatColor.GRAY+"Small Battlefield","Fight in a small, instanced battlefield"), SMALLBATTLEFIELD(2,ChatColor.GRAY+"Small Battlefield","Fight in a small, instanced battlefield"),
AQUATICFORT(3,ChatColor.WHITE+"Aquatic Fort","Fight in a small, decorated fort with a moat surrounding the area."), AQUATICFORT(3,ChatColor.WHITE+"Aquatic Fort","Fight in a small, decorated fort with a moat surrounding the area."),
NETHERFORTRESS(4,ChatColor.GRAY+"Nether Fortress","Fight in a medium-sized fortress sitting upon the fiery flames of hell."), NETHERFORTRESS(4,ChatColor.GRAY+"Nether Fortress","Fight in a medium-sized fortress sitting upon the fiery flames of hell."),
THEEND(5,ChatColor.WHITE+"The End","This is where all battles come to a spectacular end. A medium platform suspended high into the void. Falling off is inevitable."); THEEND(5,ChatColor.WHITE+"The End","This is where all battles come to a spectacular end. A medium platform suspended high into the void. Falling off is inevitable."),
TEAM1(1,ChatColor.GRAY+"Team 1",""),
TEAM2(2,ChatColor.WHITE+"Team 2","");
int selection_numb; int selection_numb;
String short_desc; String short_desc;
String hover_desc; String hover_desc;
long time;
PVPOption(int numb, String desc, String hover) { PVPOption(int numb, String desc, String hover) {
this.selection_numb=numb; this.selection_numb=numb;
this.short_desc=desc; this.short_desc=desc;
this.hover_desc=hover; this.hover_desc=hover;
this.time=0;
} }
PVPOption(int numb, String desc, String hover, long time) {
this.selection_numb=numb;
this.short_desc=desc;
this.hover_desc=hover;
this.time=time;
}
int getSelectionNumber() { int getSelectionNumber() {
return selection_numb; return selection_numb;
} }

@ -9,12 +9,14 @@ import java.io.IOException;
import java.text.DecimalFormat; import java.text.DecimalFormat;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.List; import java.util.List;
import java.util.UUID;
import org.bukkit.Bukkit; import org.bukkit.Bukkit;
import org.bukkit.ChatColor; import org.bukkit.ChatColor;
import org.bukkit.entity.Player; import org.bukkit.entity.Player;
import sig.plugin.TwosideKeeper.HelperStructures.PlayerMode; import sig.plugin.TwosideKeeper.HelperStructures.PlayerMode;
import sig.plugin.TwosideKeeper.HelperStructures.WorldShop;
public class RecordKeeping { public class RecordKeeping {
String name; String name;
@ -50,7 +52,7 @@ public class RecordKeeping {
} }
public void saveRecordsToConfig() { public void saveRecordsToConfig() {
File file = new File(TwosideKeeper.plugin.getDataFolder()+"/records/"+ChatColor.stripColor(name)+".data"); File file = new File(TwosideKeeper.plugin.getDataFolder()+"/records/"+ChatColor.stripColor(name)+".data2");
if (!file.exists()) { if (!file.exists()) {
try { try {
file.createNewFile(); file.createNewFile();
@ -74,8 +76,32 @@ public class RecordKeeping {
public void loadRecordsFromConfig() { public void loadRecordsFromConfig() {
File file = new File(TwosideKeeper.plugin.getDataFolder()+"/records/"+ChatColor.stripColor(name)+".data"); File file = new File(TwosideKeeper.plugin.getDataFolder()+"/records/"+ChatColor.stripColor(name)+".data");
File file2 = new File(TwosideKeeper.plugin.getDataFolder()+"/records/"+ChatColor.stripColor(name)+".data2");
if (file2.exists()) {
try(
FileReader fw = new FileReader(file);
BufferedReader bw = new BufferedReader(fw);)
{
String readline = bw.readLine();
int lines = 0;
do {
if (readline!=null) {
lines++;
String[] split = readline.split(",");
UUID name = UUID.fromString(split[0]);
double score = Double.parseDouble(split[1]);
PlayerMode mode = PlayerMode.valueOf(split[2]);
recordlist.add(new Record(name,score,mode));
readline = bw.readLine();
}} while (readline!=null);
} catch (IOException e) {
e.printStackTrace();
}
} else
if (file.exists()) { if (file.exists()) {
//Using the old system. Convert temporarily.
TwosideKeeper.log("WARNING! Using the old file system for Records "+name+". Converting...", 1);
try( try(
FileReader fw = new FileReader(file); FileReader fw = new FileReader(file);
BufferedReader bw = new BufferedReader(fw);) BufferedReader bw = new BufferedReader(fw);)
@ -86,7 +112,7 @@ public class RecordKeeping {
if (readline!=null) { if (readline!=null) {
lines++; lines++;
String[] split = readline.split(","); String[] split = readline.split(",");
String name = split[0]; UUID name = Bukkit.getOfflinePlayer(split[0]).getUniqueId();
double score = Double.parseDouble(split[1]); double score = Double.parseDouble(split[1]);
PlayerMode mode = PlayerMode.valueOf(split[2]); PlayerMode mode = PlayerMode.valueOf(split[2]);
recordlist.add(new Record(name,score,mode)); recordlist.add(new Record(name,score,mode));
@ -95,6 +121,7 @@ public class RecordKeeping {
} catch (IOException e) { } catch (IOException e) {
e.printStackTrace(); e.printStackTrace();
} }
file.delete();
} }
sortRecords(); sortRecords();
@ -103,9 +130,9 @@ public class RecordKeeping {
} }
} }
public void addRecord(String name, double score, PlayerMode mostusedmode) { public void addRecord(UUID name, double score, PlayerMode mostusedmode) {
for (Record r : recordlist) { for (Record r : recordlist) {
if (r.getName().equalsIgnoreCase(name)) { if (r.getName().equals(name)) {
if ((reverse && r.getScore()>score) || (!reverse && r.getScore()<score)) { if ((reverse && r.getScore()>score) || (!reverse && r.getScore()<score)) {
DecimalFormat df = new DecimalFormat("0.00"); DecimalFormat df = new DecimalFormat("0.00");
Player p = Bukkit.getPlayer(name); Player p = Bukkit.getPlayer(name);
@ -118,8 +145,10 @@ public class RecordKeeping {
DetermineIfNewHighScoreAchieved(r); DetermineIfNewHighScoreAchieved(r);
} else { } else {
DecimalFormat df = new DecimalFormat("0.00"); DecimalFormat df = new DecimalFormat("0.00");
Bukkit.broadcastMessage(mostusedmode.getColor()+"("+mostusedmode.getAbbreviation()+")"+ChatColor.RESET+ChatColor.GREEN+r.getName()+ChatColor.RESET+" has completed "+ChatColor.AQUA+ChatColor.BOLD+this.name+ChatColor.RESET+" with a score of "+ChatColor.YELLOW+ChatColor.BOLD+df.format(score)); if (!this.name.contains("Hall of Fame")) {
aPlugin.API.discordSendRaw(mostusedmode.getColor()+"*("+mostusedmode.getAbbreviation()+")*"+r.getName()+" has completed **"+this.name+"** with a score of "+ChatColor.YELLOW+ChatColor.BOLD+df.format(score)); Bukkit.broadcastMessage(mostusedmode.getColor()+"("+mostusedmode.getAbbreviation()+")"+ChatColor.RESET+ChatColor.GREEN+WorldShop.getFriendlyOwnerName(r.getName())+ChatColor.RESET+" has completed "+ChatColor.AQUA+ChatColor.BOLD+this.name+ChatColor.RESET+" with a score of "+ChatColor.YELLOW+ChatColor.BOLD+df.format(score));
aPlugin.API.discordSendRaw(mostusedmode.getColor()+"*("+mostusedmode.getAbbreviation()+")*"+WorldShop.getFriendlyOwnerName(r.getName())+" has completed **"+this.name+"** with a score of "+ChatColor.YELLOW+ChatColor.BOLD+df.format(score));
}
} }
return; return;
} }
@ -132,7 +161,7 @@ public class RecordKeeping {
} }
public void addRecord(Player p, double score, PlayerMode mostusedmode) { public void addRecord(Player p, double score, PlayerMode mostusedmode) {
addRecord(p.getName(),score,mostusedmode); addRecord(p.getUniqueId(),score,mostusedmode);
} }
private void DetermineIfNewHighScoreAchieved(Record newRecordAdded) { private void DetermineIfNewHighScoreAchieved(Record newRecordAdded) {
@ -147,12 +176,12 @@ public class RecordKeeping {
if (currentRecord.equals(newRecordAdded) && recordlist.size()>1) { if (currentRecord.equals(newRecordAdded) && recordlist.size()>1) {
Record recordbeat = recordlist.get(1);//Get the record we beat. Record recordbeat = recordlist.get(1);//Get the record we beat.
//DecimalFormat df = new DecimalFormat("0.00"); //DecimalFormat df = new DecimalFormat("0.00");
Bukkit.broadcastMessage(newRecordAdded.getMode().getColor()+"("+newRecordAdded.getMode().getAbbreviation()+")"+ChatColor.RESET+ChatColor.GREEN+newRecordAdded.getName()+ChatColor.RESET+" has beat "+recordbeat.getMode().getColor()+"("+recordbeat.getMode().getAbbreviation()+")"+ChatColor.RESET+ChatColor.GREEN+recordbeat.getName()+ChatColor.RESET+" in "+ChatColor.AQUA+ChatColor.BOLD+name+ChatColor.RESET+" with a score of "+ChatColor.YELLOW+ChatColor.BOLD+df.format(newRecordAdded.getScore())+"!!"); Bukkit.broadcastMessage(newRecordAdded.getMode().getColor()+"("+newRecordAdded.getMode().getAbbreviation()+")"+ChatColor.RESET+ChatColor.GREEN+WorldShop.getFriendlyOwnerName(newRecordAdded.getName())+ChatColor.RESET+" has beat "+recordbeat.getMode().getColor()+"("+recordbeat.getMode().getAbbreviation()+")"+ChatColor.RESET+ChatColor.GREEN+WorldShop.getFriendlyOwnerName(recordbeat.getName())+ChatColor.RESET+" in "+ChatColor.AQUA+ChatColor.BOLD+name+ChatColor.RESET+" with a score of "+ChatColor.YELLOW+ChatColor.BOLD+df.format(newRecordAdded.getScore())+"!!");
aPlugin.API.discordSendRaw("*("+newRecordAdded.getMode().getAbbreviation()+")*"+newRecordAdded.getName()+" has beat *("+recordbeat.getMode().getAbbreviation()+")*"+recordbeat.getName()+" in **"+name+"** with a score of "+ChatColor.YELLOW+ChatColor.BOLD+df.format(newRecordAdded.getScore())+"!!"); aPlugin.API.discordSendRaw("*("+newRecordAdded.getMode().getAbbreviation()+")*"+WorldShop.getFriendlyOwnerName(newRecordAdded.getName())+" has beat *("+recordbeat.getMode().getAbbreviation()+")*"+WorldShop.getFriendlyOwnerName(recordbeat.getName())+" in **"+name+"** with a score of "+ChatColor.YELLOW+ChatColor.BOLD+df.format(newRecordAdded.getScore())+"!!");
leader = currentRecord; leader = currentRecord;
} else { } else {
Bukkit.broadcastMessage(newRecordAdded.getMode().getColor()+"("+newRecordAdded.getMode().getAbbreviation()+")"+ChatColor.RESET+ChatColor.GREEN+newRecordAdded.getName()+ChatColor.RESET+" has completed "+ChatColor.AQUA+ChatColor.BOLD+name+ChatColor.RESET+" with a score of "+ChatColor.YELLOW+ChatColor.BOLD+df.format(newRecordAdded.getScore())); Bukkit.broadcastMessage(newRecordAdded.getMode().getColor()+"("+newRecordAdded.getMode().getAbbreviation()+")"+ChatColor.RESET+ChatColor.GREEN+WorldShop.getFriendlyOwnerName(newRecordAdded.getName())+ChatColor.RESET+" has completed "+ChatColor.AQUA+ChatColor.BOLD+name+ChatColor.RESET+" with a new personal best score of "+ChatColor.YELLOW+ChatColor.BOLD+df.format(newRecordAdded.getScore()));
aPlugin.API.discordSendRaw(newRecordAdded.getMode().getColor()+"*("+newRecordAdded.getMode().getAbbreviation()+")*"+newRecordAdded.getName()+" has completed **"+name+"** with a score of "+ChatColor.YELLOW+ChatColor.BOLD+df.format(newRecordAdded.getScore())); aPlugin.API.discordSendRaw(newRecordAdded.getMode().getColor()+"*("+newRecordAdded.getMode().getAbbreviation()+")*"+WorldShop.getFriendlyOwnerName(newRecordAdded.getName())+" has completed **"+name+"** with a new personal best score of "+ChatColor.YELLOW+ChatColor.BOLD+df.format(newRecordAdded.getScore()));
} }
} }
@ -164,7 +193,7 @@ public class RecordKeeping {
if (recordlist.size()>0) { if (recordlist.size()>0) {
p.sendMessage(ChatColor.AQUA+"Records for "+ChatColor.BOLD+name); p.sendMessage(ChatColor.AQUA+"Records for "+ChatColor.BOLD+name);
for (int i=0;i<amtToShow;i++) { for (int i=0;i<amtToShow;i++) {
p.sendMessage(" "+ChatColor.GRAY+(i+1)+"."+ChatColor.YELLOW+" "+recordlist.get(i).getScore()+" - "+recordlist.get(i).getMode().getColor()+"("+recordlist.get(i).getMode().getAbbreviation()+")"+ChatColor.RESET+ChatColor.GREEN+recordlist.get(i).getName()); p.sendMessage(" "+ChatColor.GRAY+(i+1)+"."+ChatColor.YELLOW+" "+recordlist.get(i).getScore()+" - "+recordlist.get(i).getMode().getColor()+"("+recordlist.get(i).getMode().getAbbreviation()+")"+ChatColor.RESET+ChatColor.GREEN+WorldShop.getFriendlyOwnerName(recordlist.get(i).getName()));
} }
} else { } else {
p.sendMessage(ChatColor.WHITE+"No Records set for "+ChatColor.BOLD+name+ChatColor.RESET+" yet!"); p.sendMessage(ChatColor.WHITE+"No Records set for "+ChatColor.BOLD+name+ChatColor.RESET+" yet!");
@ -213,15 +242,15 @@ public class RecordKeeping {
} }
} }
class Record{ class Record{
String name; UUID name;
double score; double score;
PlayerMode mode; PlayerMode mode;
Record(String name,double score,PlayerMode mode) { Record(UUID name,double score,PlayerMode mode) {
this.name=name; this.name=name;
this.score=score; this.score=score;
this.mode=mode; this.mode=mode;
} }
String getName() { UUID getName() {
return name; return name;
} }
double getScore() { double getScore() {
@ -230,9 +259,9 @@ class Record{
PlayerMode getMode() { PlayerMode getMode() {
return mode; return mode;
} }
public void setName(String name) { /*public void setName(String name) {
this.name = name; this.name = name;
} }*/
public void setScore(double score) { public void setScore(double score) {
this.score = score; this.score = score;
} }

@ -260,6 +260,7 @@ import sig.plugin.TwosideKeeper.HelperStructures.Effects.WindSlash;
import sig.plugin.TwosideKeeper.HelperStructures.Utils.ArrayUtils; import sig.plugin.TwosideKeeper.HelperStructures.Utils.ArrayUtils;
import sig.plugin.TwosideKeeper.HelperStructures.Utils.ArtifactUtils; import sig.plugin.TwosideKeeper.HelperStructures.Utils.ArtifactUtils;
import sig.plugin.TwosideKeeper.HelperStructures.Utils.BlockUtils; import sig.plugin.TwosideKeeper.HelperStructures.Utils.BlockUtils;
import sig.plugin.TwosideKeeper.HelperStructures.Utils.DebugUtils;
import sig.plugin.TwosideKeeper.HelperStructures.Utils.EntityUtils; import sig.plugin.TwosideKeeper.HelperStructures.Utils.EntityUtils;
import sig.plugin.TwosideKeeper.HelperStructures.Utils.InventoryUtils; import sig.plugin.TwosideKeeper.HelperStructures.Utils.InventoryUtils;
import sig.plugin.TwosideKeeper.HelperStructures.Utils.ItemCubeUtils; import sig.plugin.TwosideKeeper.HelperStructures.Utils.ItemCubeUtils;
@ -664,7 +665,7 @@ public class TwosideKeeper extends JavaPlugin implements Listener {
@Override @Override
public void run() { public void run() {
WorldShop newshop = TwosideShops.CreateWorldShop(current_session.GetSign(), current_session.getItem(), current_session.getAmt(), Double.parseDouble(df.format(amt)), ev.getPlayer().getName(),true); WorldShop newshop = TwosideShops.CreateWorldShop(current_session.GetSign(), current_session.getItem(), current_session.getAmt(), Double.parseDouble(df.format(amt)), ev.getPlayer().getUniqueId(),true);
TwosideShops.SaveWorldShopData(newshop); TwosideShops.SaveWorldShopData(newshop);
WorldShop.spawnShopItem(current_session.GetSign().getLocation(), newshop); WorldShop.spawnShopItem(current_session.GetSign().getLocation(), newshop);
Chest c = (Chest)WorldShop.getBlockShopSignAttachedTo(current_session.GetSign()).getState(); Chest c = (Chest)WorldShop.getBlockShopSignAttachedTo(current_session.GetSign()).getState();
@ -689,7 +690,7 @@ public class TwosideKeeper extends JavaPlugin implements Listener {
@Override @Override
public void run() { public void run() {
WorldShop newshop = TwosideShops.CreateWorldShop(current_session.GetSign(), current_session.getItem(), current_session.getAmt(), Double.parseDouble(df.format(amt)), ev.getPlayer().getName()); WorldShop newshop = TwosideShops.CreateWorldShop(current_session.GetSign(), current_session.getItem(), current_session.getAmt(), Double.parseDouble(df.format(amt)), ev.getPlayer().getUniqueId());
WorldShop.spawnShopItem(current_session.GetSign().getLocation(), newshop); WorldShop.spawnShopItem(current_session.GetSign().getLocation(), newshop);
Chest c = (Chest)WorldShop.getBlockShopSignAttachedTo(current_session.GetSign()).getState(); Chest c = (Chest)WorldShop.getBlockShopSignAttachedTo(current_session.GetSign()).getState();
notWorldShop.remove(InventoryUtils.getInventoryHash(c.getInventory())); notWorldShop.remove(InventoryUtils.getInventoryHash(c.getInventory()));
@ -1581,6 +1582,13 @@ public class TwosideKeeper extends JavaPlugin implements Listener {
session.addChoice(p,args[1]); session.addChoice(p,args[1]);
} }
}break; }break;
case "_TEAM_":{
Player p = (Player)sender;
PVP session = PVP.getMatch(p);
if (session!=null) {
session.addChoice(p,args[1]);
}
}break;
} }
} }
return true; return true;
@ -2333,7 +2341,7 @@ public class TwosideKeeper extends JavaPlugin implements Listener {
LivingEntityStructure.setCustomLivingEntityName(z, ChatColor.RED+"Challenge Zombie"); LivingEntityStructure.setCustomLivingEntityName(z, ChatColor.RED+"Challenge Zombie");
}break; }break;
case "TESTRECORD":{ case "TESTRECORD":{
dpschallenge_records.addRecord(args[1], Integer.parseInt(args[2]), PlayerMode.values()[(int)(Math.random()*PlayerMode.values().length)]); //dpschallenge_records.addRecord(args[1], Integer.parseInt(args[2]), PlayerMode.values()[(int)(Math.random()*PlayerMode.values().length)]);
}break; }break;
case "DISPLAYSCORES":{ case "DISPLAYSCORES":{
dpschallenge_records.displayRecords(p); dpschallenge_records.displayRecords(p);
@ -3513,7 +3521,7 @@ public class TwosideKeeper extends JavaPlugin implements Listener {
} }
WorldShopManager.UpdateSign(shop, shop.getID(), current_session.GetSign(),false); WorldShopManager.UpdateSign(shop, shop.getID(), current_session.GetSign(),false);
TwosideShops.SaveWorldShopData(shop); TwosideShops.SaveWorldShopData(shop);
TwosideShops.AddNewPurchase(shop.GetOwner(), ev.getPlayer().getName(), shop.GetItem(), amt*shop.GetUnitPrice(), amt); TwosideShops.AddNewPurchase(shop.GetOwner(), ev.getPlayer().getUniqueId(), shop.GetItem(), amt*shop.GetUnitPrice(), amt);
final int ID = shopID; final int ID = shopID;
Bukkit.getScheduler().scheduleSyncDelayedTask(this, new Runnable() { Bukkit.getScheduler().scheduleSyncDelayedTask(this, new Runnable() {
@Override @Override
@ -3524,13 +3532,9 @@ public class TwosideKeeper extends JavaPlugin implements Listener {
}},1); }},1);
TwosideShops.RemoveSession(ev.getPlayer()); TwosideShops.RemoveSession(ev.getPlayer());
givePlayerMoney(ev.getPlayer(), -amt*shop.GetUnitPrice()); givePlayerMoney(ev.getPlayer(), -amt*shop.GetUnitPrice());
if (!shop.GetOwner().equalsIgnoreCase("admin")) { if (!shop.GetOwner().equals(WorldShop.ADMIN_UUID)) {
if (Bukkit.getPlayer(shop.GetOwner())!=null) {
givePlayerMoney(Bukkit.getPlayer(shop.GetOwner()), amt*shop.GetUnitPrice());
} else {
givePlayerMoney(shop.GetOwner(), amt*shop.GetUnitPrice()); givePlayerMoney(shop.GetOwner(), amt*shop.GetUnitPrice());
} }
}
} else { } else {
ev.getPlayer().sendMessage("You do not have enough money to buy that many (You can buy "+ChatColor.GREEN+(int)(getPlayerMoney(ev.getPlayer())/shop.GetUnitPrice())+ChatColor.WHITE+" of them)! Please try again."); ev.getPlayer().sendMessage("You do not have enough money to buy that many (You can buy "+ChatColor.GREEN+(int)(getPlayerMoney(ev.getPlayer())/shop.GetUnitPrice())+ChatColor.WHITE+" of them)! Please try again.");
} }
@ -3582,9 +3586,9 @@ public class TwosideKeeper extends JavaPlugin implements Listener {
TwosideShops.RemoveSession(ev.getPlayer()); TwosideShops.RemoveSession(ev.getPlayer());
givePlayerMoney(ev.getPlayer(), amt*shop.GetUnitPrice()); givePlayerMoney(ev.getPlayer(), amt*shop.GetUnitPrice());
givePlayerBankMoney(shop.GetOwner(), -amt*shop.GetUnitPrice()); givePlayerBankMoney(shop.GetOwner(), -amt*shop.GetUnitPrice());
TwosideShops.AddNewPurchase(shop.GetOwner(), ev.getPlayer().getName(), shop.GetItem(), amt*shop.GetUnitPrice(), amt, false); TwosideShops.AddNewPurchase(shop.GetOwner(), ev.getPlayer().getUniqueId(), shop.GetItem(), amt*shop.GetUnitPrice(), amt, false);
} else { } else {
ev.getPlayer().sendMessage(ChatColor.LIGHT_PURPLE+shop.GetOwner()+ChatColor.WHITE+" only has enough money in their bank to buy "+ChatColor.GREEN+(int)(getPlayerBankMoney(shop.GetOwner())/shop.GetUnitPrice())+ChatColor.WHITE+" of "+ChatColor.GREEN+shop.GetItemName()+ChatColor.WHITE+"! Please try again."); ev.getPlayer().sendMessage(ChatColor.LIGHT_PURPLE+WorldShop.getFriendlyOwnerName(shop.GetOwner())+ChatColor.WHITE+" only has enough money in their bank to buy "+ChatColor.GREEN+(int)(getPlayerBankMoney(shop.GetOwner())/shop.GetUnitPrice())+ChatColor.WHITE+" of "+ChatColor.GREEN+shop.GetItemName()+ChatColor.WHITE+"! Please try again.");
} }
} else { } else {
ev.getPlayer().sendMessage("The shop owner is only requesting "+ChatColor.GREEN+shop.GetAmount()+ChatColor.WHITE+" of "+ChatColor.GREEN+shop.GetItemName()+ChatColor.WHITE+"! Please try again."); ev.getPlayer().sendMessage("The shop owner is only requesting "+ChatColor.GREEN+shop.GetAmount()+ChatColor.WHITE+" of "+ChatColor.GREEN+shop.GetItemName()+ChatColor.WHITE+"! Please try again.");
@ -4282,8 +4286,8 @@ public class TwosideKeeper extends JavaPlugin implements Listener {
if (shopsign!=null) { if (shopsign!=null) {
//Now grab the owner of the shop. //Now grab the owner of the shop.
WorldShop shop = TwosideShops.LoadWorldShopData(shopsign); WorldShop shop = TwosideShops.LoadWorldShopData(shopsign);
if (!shop.GetOwner().equalsIgnoreCase(ev.getPlayer().getName())) { if (!shop.GetOwner().equals(ev.getPlayer().getUniqueId())) {
ev.getPlayer().sendMessage("This shop belongs to "+ChatColor.LIGHT_PURPLE+shop.GetOwner()+ChatColor.WHITE+"! You cannot look at other's shops!"); ev.getPlayer().sendMessage("This shop belongs to "+ChatColor.LIGHT_PURPLE+WorldShop.getFriendlyOwnerName(shop.GetOwner())+ChatColor.WHITE+"! You cannot look at other's shops!");
ev.setCancelled(true); ev.setCancelled(true);
return; return;
} }
@ -4402,10 +4406,10 @@ public class TwosideKeeper extends JavaPlugin implements Listener {
//We need to make sure the chest is not a world shop. If it is, we can see if we're the owner of it. //We need to make sure the chest is not a world shop. If it is, we can see if we're the owner of it.
boolean allowed=true; boolean allowed=true;
String owner=""; UUID owner=WorldShop.ADMIN_UUID;
if (WorldShop.hasShopSignAttached(ev.getClickedBlock())) { if (WorldShop.hasShopSignAttached(ev.getClickedBlock())) {
WorldShop s = TwosideShops.LoadWorldShopData(WorldShop.grabShopSign(ev.getClickedBlock())); WorldShop s = TwosideShops.LoadWorldShopData(WorldShop.grabShopSign(ev.getClickedBlock()));
if (!s.GetOwner().equalsIgnoreCase(ev.getPlayer().getName())) { if (!s.GetOwner().equals(ev.getPlayer().getUniqueId())) {
allowed=false; allowed=false;
owner=s.GetOwner(); owner=s.GetOwner();
} }
@ -4499,7 +4503,7 @@ public class TwosideKeeper extends JavaPlugin implements Listener {
ev.setCancelled(true); ev.setCancelled(true);
return; return;
} else { } else {
ev.getPlayer().sendMessage("This shop is owned by "+ChatColor.LIGHT_PURPLE+owner+ChatColor.WHITE+". You cannot dump item cubes into others' shops!"); ev.getPlayer().sendMessage("This shop is owned by "+ChatColor.LIGHT_PURPLE+WorldShop.getFriendlyOwnerName(owner)+ChatColor.WHITE+". You cannot dump item cubes into others' shops!");
ev.setCancelled(true); ev.setCancelled(true);
return; return;
} }
@ -4575,7 +4579,7 @@ public class TwosideKeeper extends JavaPlugin implements Listener {
WorldShop.spawnShopItem(ev,newloc,shop); WorldShop.spawnShopItem(ev,newloc,shop);
if (shop.GetOwner().equalsIgnoreCase(ev.getPlayer().getName())) { if (shop.GetOwner().equals(ev.getPlayer().getUniqueId())) {
p.sendMessage(ChatColor.DARK_PURPLE+"Editing shop..."); p.sendMessage(ChatColor.DARK_PURPLE+"Editing shop...");
//player.sendMessage("Insert more "+ChatColor.GREEN+shop.GetItemName()+ChatColor.WHITE+" by typing a positive amount "+ChatColor.GREEN+"(MAX:"+GenericFunctions.CountItems(player,shop.GetItem())+")"+ChatColor.WHITE+". Or withdraw "+ChatColor.GREEN+shop.GetItemName()+ChatColor.WHITE+" by typing a negative amount "+ChatColor.GREEN+"(MAX:"+shop.GetAmount()+")"+ChatColor.WHITE+"."); //OBSOLETE! //player.sendMessage("Insert more "+ChatColor.GREEN+shop.GetItemName()+ChatColor.WHITE+" by typing a positive amount "+ChatColor.GREEN+"(MAX:"+GenericFunctions.CountItems(player,shop.GetItem())+")"+ChatColor.WHITE+". Or withdraw "+ChatColor.GREEN+shop.GetItemName()+ChatColor.WHITE+" by typing a negative amount "+ChatColor.GREEN+"(MAX:"+shop.GetAmount()+")"+ChatColor.WHITE+"."); //OBSOLETE!
DecimalFormat df = new DecimalFormat("0.00"); DecimalFormat df = new DecimalFormat("0.00");
@ -4610,7 +4614,7 @@ public class TwosideKeeper extends JavaPlugin implements Listener {
ev.setCancelled(true); ev.setCancelled(true);
return; return;
} else { } else {
p.sendMessage(ChatColor.GOLD+"Sorry! "+ChatColor.WHITE+"This shop is sold out! Let "+ChatColor.LIGHT_PURPLE+shop.GetOwner()+ChatColor.WHITE+" know to restock the shop!"); p.sendMessage(ChatColor.GOLD+"Sorry! "+ChatColor.WHITE+"This shop is sold out! Let "+ChatColor.LIGHT_PURPLE+WorldShop.getFriendlyOwnerName(shop.GetOwner())+ChatColor.WHITE+" know to restock the shop!");
ev.setCancelled(true); ev.setCancelled(true);
return; return;
} }
@ -4674,7 +4678,7 @@ public class TwosideKeeper extends JavaPlugin implements Listener {
WorldShop.spawnShopItem(ev,newloc,shop); WorldShop.spawnShopItem(ev,newloc,shop);
if (shop.GetOwner().equalsIgnoreCase(ev.getPlayer().getName())) { if (shop.GetOwner().equals(ev.getPlayer().getUniqueId())) {
p.sendMessage(ChatColor.DARK_PURPLE+"Editing shop..."); p.sendMessage(ChatColor.DARK_PURPLE+"Editing shop...");
DecimalFormat df = new DecimalFormat("0.00"); DecimalFormat df = new DecimalFormat("0.00");
//player.sendMessage("Request more "+ChatColor.GREEN+shop.GetItemName()+ChatColor.WHITE+" by typing a positive amount "+ChatColor.WHITE+". Or withdraw stored "+ChatColor.GREEN+shop.GetItemName()+ChatColor.WHITE+" by typing a negative amount "+ChatColor.GREEN+"(MAX:"+shop.GetStoredAmount()+")"+ChatColor.WHITE+"."); //player.sendMessage("Request more "+ChatColor.GREEN+shop.GetItemName()+ChatColor.WHITE+" by typing a positive amount "+ChatColor.WHITE+". Or withdraw stored "+ChatColor.GREEN+shop.GetItemName()+ChatColor.WHITE+" by typing a negative amount "+ChatColor.GREEN+"(MAX:"+shop.GetStoredAmount()+")"+ChatColor.WHITE+".");
@ -5114,9 +5118,9 @@ public class TwosideKeeper extends JavaPlugin implements Listener {
if (WorldShop.hasShopSignAttached(ev.getBlockPlaced().getRelative(x,0,z))) { if (WorldShop.hasShopSignAttached(ev.getBlockPlaced().getRelative(x,0,z))) {
Sign s = WorldShop.grabShopSign(ev.getBlockPlaced().getRelative(x,0,z)); Sign s = WorldShop.grabShopSign(ev.getBlockPlaced().getRelative(x,0,z));
WorldShop shop = TwosideShops.LoadWorldShopData(s); WorldShop shop = TwosideShops.LoadWorldShopData(s);
if (!shop.GetOwner().equalsIgnoreCase(ev.getPlayer().getName())) { if (!shop.GetOwner().equals(ev.getPlayer().getUniqueId())) {
//This is not allowed! We can't expand shops that are not ours. //This is not allowed! We can't expand shops that are not ours.
ev.getPlayer().sendMessage("There's a shop owned by "+ChatColor.LIGHT_PURPLE+shop.GetOwner()+ChatColor.WHITE+" right next to your chest! You cannot expand others' shops!"); ev.getPlayer().sendMessage("There's a shop owned by "+ChatColor.LIGHT_PURPLE+WorldShop.getFriendlyOwnerName(shop.GetOwner())+ChatColor.WHITE+" right next to your chest! You cannot expand others' shops!");
ev.setCancelled(true); ev.setCancelled(true);
return; return;
} }
@ -6379,6 +6383,13 @@ public class TwosideKeeper extends JavaPlugin implements Listener {
ev.setCurrentItem(new ItemStack(Material.AIR)); ev.setCurrentItem(new ItemStack(Material.AIR));
ev.setResult(Result.DENY); ev.setResult(Result.DENY);
ev.setCancelled(true); ev.setCancelled(true);
Bukkit.getScheduler().scheduleSyncDelayedTask(this, new Runnable() {
@Override
public void run() {
ItemSet.updateItemSets(player);
setPlayerMaxHealth(player,player.getHealth()/player.getMaxHealth());
}
},1);
return; return;
} }
@ -8439,8 +8450,8 @@ public class TwosideKeeper extends JavaPlugin implements Listener {
} }
} }
} }
Bukkit.getServer().broadcastMessage(ChatColor.GREEN+participants_list.toString()+ChatColor.WHITE+" "+(participants_list.length()==1?"has single-handedly taken down the ":"have successfully slain ")+GenericFunctions.getDisplayName(m)+ChatColor.WHITE+"!"); Bukkit.getServer().broadcastMessage(ChatColor.GREEN+participants_list.toString()+ChatColor.WHITE+" "+(participants.size()==1?"has single-handedly taken down the ":"have successfully slain ")+GenericFunctions.getDisplayName(m)+ChatColor.WHITE+"!");
aPlugin.API.discordSendRaw(ChatColor.GREEN+participants_list.toString()+ChatColor.WHITE+" "+(participants_list.length()==1?"has single-handedly taken down the ":"have successfully slain ")+"**"+GenericFunctions.getDisplayName(m)+ChatColor.WHITE+"**!"); aPlugin.API.discordSendRaw(ChatColor.GREEN+participants_list.toString()+ChatColor.WHITE+" "+(participants.size()==1?"has single-handedly taken down the ":"have successfully slain ")+"**"+GenericFunctions.getDisplayName(m)+ChatColor.WHITE+"**!");
m.getWorld().spawnEntity(m.getLocation(), EntityType.LIGHTNING); m.getWorld().spawnEntity(m.getLocation(), EntityType.LIGHTNING);
m.getWorld().setStorm(true); m.getWorld().setStorm(true);
m.getWorld().setWeatherDuration(20*60*15); m.getWorld().setWeatherDuration(20*60*15);
@ -8967,8 +8978,8 @@ public class TwosideKeeper extends JavaPlugin implements Listener {
//This is a shop. Let's find out who the owner is. //This is a shop. Let's find out who the owner is.
int shopID = TwosideShops.GetShopID(s); int shopID = TwosideShops.GetShopID(s);
WorldShop shop = TwosideShops.LoadWorldShopData(shopID); WorldShop shop = TwosideShops.LoadWorldShopData(shopID);
String owner = shop.GetOwner(); UUID owner = shop.GetOwner();
if (owner.equalsIgnoreCase(p.getName()) || p.isOp() || owner.equalsIgnoreCase("admin")) { if (owner.equals(p.getUniqueId()) || p.isOp() || owner.equals(WorldShop.ADMIN_UUID)) {
//We are going to see if this shop had items in it. //We are going to see if this shop had items in it.
/*if (shop.GetAmount()>0) { //LEGACY CODE. /*if (shop.GetAmount()>0) { //LEGACY CODE.
//It did, we are going to release those items. //It did, we are going to release those items.
@ -8993,7 +9004,7 @@ public class TwosideKeeper extends JavaPlugin implements Listener {
return; return;
} else { } else {
//They are not the owner! Do not allow this shop to be broken. //They are not the owner! Do not allow this shop to be broken.
p.sendMessage("This shop belongs to "+ChatColor.LIGHT_PURPLE+owner+ChatColor.WHITE+"! You cannot break others' shops!"); p.sendMessage("This shop belongs to "+ChatColor.LIGHT_PURPLE+WorldShop.getFriendlyOwnerName(owner)+ChatColor.WHITE+"! You cannot break others' shops!");
ev.setCancelled(true); ev.setCancelled(true);
return; return;
} }
@ -9004,8 +9015,8 @@ public class TwosideKeeper extends JavaPlugin implements Listener {
//This is a shop. Let's find out who the owner is. //This is a shop. Let's find out who the owner is.
int shopID = TwosideShops.GetShopID(s); int shopID = TwosideShops.GetShopID(s);
WorldShop shop = TwosideShops.LoadWorldShopData(shopID); WorldShop shop = TwosideShops.LoadWorldShopData(shopID);
String owner = shop.GetOwner(); UUID owner = shop.GetOwner();
if (owner.equalsIgnoreCase(p.getName()) || p.isOp()) { if (owner.equals(p.getUniqueId()) || p.isOp()) {
//We are going to see if this shop had items in it. //We are going to see if this shop had items in it.
/*if (shop.GetStoredAmount()>0) { //LEGACY CODE. /*if (shop.GetStoredAmount()>0) { //LEGACY CODE.
//It did, we are going to release those items. //It did, we are going to release those items.
@ -9055,7 +9066,7 @@ public class TwosideKeeper extends JavaPlugin implements Listener {
return; return;
} else { } else {
//They are not the owner! Do not allow this shop to be broken. //They are not the owner! Do not allow this shop to be broken.
p.sendMessage("This shop belongs to "+ChatColor.LIGHT_PURPLE+owner+ChatColor.WHITE+"! You cannot break others' shops!"); p.sendMessage("This shop belongs to "+ChatColor.LIGHT_PURPLE+WorldShop.getFriendlyOwnerName(owner)+ChatColor.WHITE+"! You cannot break others' shops!");
ev.setCancelled(true); ev.setCancelled(true);
return; return;
} }
@ -10848,24 +10859,38 @@ public class TwosideKeeper extends JavaPlugin implements Listener {
DecimalFormat df = new DecimalFormat("0.00"); DecimalFormat df = new DecimalFormat("0.00");
return Double.parseDouble(df.format(d)); return Double.parseDouble(df.format(d));
} }
@Deprecated
public static double getPlayerMoney(String p) { public static double getPlayerMoney(String p) {
//See if the data file exists, open it. //See if the data file exists, open it.
if (Bukkit.getPlayer(p)!=null) { if (Bukkit.getPlayer(p)!=null) {
DecimalFormat df = new DecimalFormat("0.00"); DecimalFormat df = new DecimalFormat("0.00");
return Double.parseDouble(df.format(getPlayerMoney(Bukkit.getPlayer(p)))); return Double.parseDouble(df.format(getPlayerMoney(Bukkit.getPlayer(p))));
} else {
if (Bukkit.getOfflinePlayer(p)!=null) {
return getPlayerMoney(Bukkit.getOfflinePlayer(p).getUniqueId());
} else {
log("[WARNING] Could not find Player "+p+"'s offline profile!!",1);
DebugUtils.showStackTrace();
return -1;
}
}
}
public static double getPlayerMoney(UUID id) {
if (Bukkit.getPlayer(id)!=null) {
return getPlayerMoney(Bukkit.getPlayer(id));
} else { } else {
File config; File config;
config = new File(TwosideKeeper.filesave,"users/"+Bukkit.getOfflinePlayer(p).getUniqueId()+".data"); config = new File(TwosideKeeper.filesave,"users/"+id+".data");
FileConfiguration workable = YamlConfiguration.loadConfiguration(config); FileConfiguration workable = YamlConfiguration.loadConfiguration(config);
if (!config.exists()) { if (!config.exists()) {
//Something bad happened if we got here. //Something bad happened if we got here.
log("[WARNING] Could not find the correct player data file for "+p+" to get money data from.",1); log("[WARNING] Could not find the correct player data file for "+id+" to get money data from.",1);
return -1; return -1;
} }
return workable.getDouble("money"); return workable.getDouble("money");
} }
} }
public static double getPlayerBankMoney(Player p) { public static double getPlayerBankMoney(Player p) {
//Tells a player how much money they have. //Tells a player how much money they have.
PlayerStructure pd = (PlayerStructure)playerdata.get(p.getUniqueId()); PlayerStructure pd = (PlayerStructure)playerdata.get(p.getUniqueId());
@ -10874,44 +10899,59 @@ public class TwosideKeeper extends JavaPlugin implements Listener {
DecimalFormat df = new DecimalFormat("0.00"); DecimalFormat df = new DecimalFormat("0.00");
return Double.parseDouble(df.format(d)); return Double.parseDouble(df.format(d));
} }
public static double getPlayerBankMoney(UUID id) {
public static double getPlayerBankMoney(String p) { if (Bukkit.getPlayer(id)!=null) {
if (Bukkit.getPlayer(p)!=null) { return getPlayerBankMoney(Bukkit.getPlayer(id));
DecimalFormat df = new DecimalFormat("0.00");
return Double.parseDouble(df.format(getPlayerBankMoney(Bukkit.getPlayer(p))));
} else { } else {
//See if the data file exists, open it.
File config; File config;
config = new File(TwosideKeeper.filesave,"users/"+Bukkit.getOfflinePlayer(p).getUniqueId()+".data"); config = new File(TwosideKeeper.filesave,"users/"+id+".data");
FileConfiguration workable = YamlConfiguration.loadConfiguration(config); FileConfiguration workable = YamlConfiguration.loadConfiguration(config);
if (!config.exists()) { if (!config.exists()) {
//Something bad happened if we got here. //Something bad happened if we got here.
log("[WARNING] Could not find the correct player data file for "+p+" to get money data from.",1); log("[WARNING] Could not find the correct player data file for "+id+" to get money data from.",1);
return -1; return -1;
} }
return workable.getDouble("bank_money"); return workable.getDouble("bank_money");
} }
} }
@Deprecated
public static double getPlayerBankMoney(String p) {
if (Bukkit.getPlayer(p)!=null) {
DecimalFormat df = new DecimalFormat("0.00");
return Double.parseDouble(df.format(getPlayerBankMoney(Bukkit.getPlayer(p))));
} else {
//See if the data file exists, open it.
if (Bukkit.getOfflinePlayer(p)!=null) {
return getPlayerBankMoney(Bukkit.getOfflinePlayer(p).getUniqueId());
} else {
log("[WARNING] Could not find Player "+p+"'s offline profile!!",1);
DebugUtils.showStackTrace();
return -1;
}
}
}
public static void givePlayerMoney(Player p, double amt) { public static void givePlayerMoney(Player p, double amt) {
PlayerStructure pd = (PlayerStructure)playerdata.get(p.getUniqueId()); PlayerStructure pd = (PlayerStructure)playerdata.get(p.getUniqueId());
//Found it. Read money and quit. //Found it. Read money and quit.
pd.money+=amt; pd.money+=amt;
} }
public static void givePlayerMoney(String p, double amt) { public static void givePlayerMoney(UUID id, double amt) {
if (Bukkit.getPlayer(p)!=null) { /*PlayerStructure pd = (PlayerStructure)playerdata.get(p.getUniqueId());
givePlayerMoney(Bukkit.getPlayer(p),amt); //Found it. Read money and quit.
pd.money+=amt;*/
if (Bukkit.getPlayer(id)!=null) {
givePlayerMoney(Bukkit.getPlayer(id),amt);
} else { } else {
//See if the data file exists, open it.
File config; File config;
config = new File(TwosideKeeper.filesave,"users/"+Bukkit.getOfflinePlayer(p).getUniqueId()+".data"); config = new File(TwosideKeeper.filesave,"users/"+id+".data");
FileConfiguration workable = YamlConfiguration.loadConfiguration(config); FileConfiguration workable = YamlConfiguration.loadConfiguration(config);
if (!config.exists()) { if (!config.exists()) {
//Something bad happened if we got here. //Something bad happened if we got here.
log("[WARNING] Could not find the correct player data file for "+p+" to get money data from.",1); log("[WARNING] Could not find the correct player data file for "+id+" to get money data from.",1);
} else { } else {
double money = workable.getDouble("money"); double money = workable.getDouble("money");
@ -10922,24 +10962,51 @@ public class TwosideKeeper extends JavaPlugin implements Listener {
try { try {
workable.save(config); workable.save(config);
} catch (IOException e) { } catch (IOException e) {
log("[WARNING] Could not find the correct player data file for "+p+" to get money data from.",1); log("[WARNING] Could not find the correct player data file for "+id+" to get money data from.",1);
e.printStackTrace(); e.printStackTrace();
} }
} }
} }
} }
@Deprecated
public static void givePlayerMoney(String p, double amt) {
if (Bukkit.getPlayer(p)!=null) {
givePlayerMoney(Bukkit.getPlayer(p),amt);
} else {
//See if the data file exists, open it.
if (Bukkit.getOfflinePlayer(p)!=null) {
givePlayerMoney(Bukkit.getOfflinePlayer(p).getUniqueId(),amt);
} else {
log("[WARNING] Could not find Player "+p+"'s offline profile!!",1);
DebugUtils.showStackTrace();
}
}
}
public static void givePlayerBankMoney(Player p, double amt) { public static void givePlayerBankMoney(Player p, double amt) {
PlayerStructure pd = (PlayerStructure)playerdata.get(p.getUniqueId()); PlayerStructure pd = (PlayerStructure)playerdata.get(p.getUniqueId());
//Found it. Read money and quit. //Found it. Read money and quit.
pd.bank_money+=amt; pd.bank_money+=amt;
} }
@Deprecated
public static void givePlayerBankMoney(String p, double amt) { public static void givePlayerBankMoney(String p, double amt) {
if (Bukkit.getPlayer(p)!=null) { if (Bukkit.getPlayer(p)!=null) {
givePlayerBankMoney(Bukkit.getPlayer(p),amt); givePlayerBankMoney(Bukkit.getPlayer(p),amt);
} else { } else {
//See if the data file exists, open it. //See if the data file exists, open it.
if (Bukkit.getOfflinePlayer(p)!=null) {
givePlayerBankMoney(Bukkit.getOfflinePlayer(p).getUniqueId(),amt);
} else {
log("[WARNING] Could not find Player "+p+"'s offline profile!!",1);
DebugUtils.showStackTrace();
}
}
}
public static void givePlayerBankMoney(UUID id, double amt) {
if (Bukkit.getPlayer(id)!=null) {
givePlayerBankMoney(Bukkit.getPlayer(id),amt);
} else {
File config; File config;
config = new File(TwosideKeeper.filesave,"users/"+Bukkit.getOfflinePlayer(p).getUniqueId()+".data"); config = new File(TwosideKeeper.filesave,"users/"+id+".data");
FileConfiguration workable = YamlConfiguration.loadConfiguration(config); FileConfiguration workable = YamlConfiguration.loadConfiguration(config);
double money = workable.getDouble("bank_money"); double money = workable.getDouble("bank_money");
@ -10951,7 +11018,7 @@ public class TwosideKeeper extends JavaPlugin implements Listener {
try { try {
workable.save(config); workable.save(config);
} catch (IOException e) { } catch (IOException e) {
log("[WARNING] Could not find the correct player data file for "+p+" to get bank money data from.",1); log("[WARNING] Could not find the correct player data file for "+id+" to get bank money data from.",1);
e.printStackTrace(); e.printStackTrace();
} }
} }

@ -3,6 +3,7 @@ package sig.plugin.TwosideKeeper;
import java.util.Collection; import java.util.Collection;
import java.util.HashMap; import java.util.HashMap;
import java.util.List; import java.util.List;
import java.util.UUID;
import org.bukkit.Location; import org.bukkit.Location;
import org.bukkit.Material; import org.bukkit.Material;
@ -39,12 +40,26 @@ public final class TwosideKeeperAPI {
public static void givePlayerMoney(Player p, double amt) { public static void givePlayerMoney(Player p, double amt) {
TwosideKeeper.givePlayerMoney(p, amt); TwosideKeeper.givePlayerMoney(p, amt);
} }
public static void givePlayerMoney(UUID id, double amt) {
TwosideKeeper.givePlayerMoney(id, amt);
}
/**
* Use UUID version instead.
*/
@Deprecated
public static void givePlayerMoney(String p, double amt) { public static void givePlayerMoney(String p, double amt) {
TwosideKeeper.givePlayerMoney(p, amt); TwosideKeeper.givePlayerMoney(p, amt);
} }
public static double getPlayerMoney(UUID id) {
return TwosideKeeper.getPlayerMoney(id);
}
public static double getPlayerMoney(Player p) { public static double getPlayerMoney(Player p) {
return TwosideKeeper.getPlayerMoney(p); return TwosideKeeper.getPlayerMoney(p);
} }
/**
* Use UUID version instead.
*/
@Deprecated
public static double getPlayerMoney(String p) { public static double getPlayerMoney(String p) {
return TwosideKeeper.getPlayerMoney(p); return TwosideKeeper.getPlayerMoney(p);
} }
@ -53,12 +68,26 @@ public final class TwosideKeeperAPI {
public static void givePlayerBankMoney(Player p, double amt) { public static void givePlayerBankMoney(Player p, double amt) {
TwosideKeeper.givePlayerBankMoney(p, amt); TwosideKeeper.givePlayerBankMoney(p, amt);
} }
public static void givePlayerBankMoney(UUID id, double amt) {
TwosideKeeper.givePlayerBankMoney(id, amt);
}
/**
* Use UUID version instead.
*/
@Deprecated
public static void givePlayerBankMoney(String p, double amt) { public static void givePlayerBankMoney(String p, double amt) {
TwosideKeeper.givePlayerBankMoney(p, amt); TwosideKeeper.givePlayerBankMoney(p, amt);
} }
public static double getPlayerBankMoney(Player p) { public static double getPlayerBankMoney(Player p) {
return TwosideKeeper.getPlayerBankMoney(p); return TwosideKeeper.getPlayerBankMoney(p);
} }
public static double getPlayerBankMoney(UUID id) {
return TwosideKeeper.getPlayerBankMoney(id);
}
/**
* Use UUID version instead.
*/
@Deprecated
public static double getPlayerBankMoney(String p) { public static double getPlayerBankMoney(String p) {
return TwosideKeeper.getPlayerBankMoney(p); return TwosideKeeper.getPlayerBankMoney(p);
} }

@ -5,11 +5,13 @@ import java.io.IOException;
import java.text.DecimalFormat; import java.text.DecimalFormat;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.List; import java.util.List;
import java.util.UUID;
import org.bukkit.Bukkit; import org.bukkit.Bukkit;
import org.bukkit.ChatColor; import org.bukkit.ChatColor;
import org.bukkit.Location; import org.bukkit.Location;
import org.bukkit.Material; import org.bukkit.Material;
import org.bukkit.OfflinePlayer;
import org.bukkit.block.Chest; import org.bukkit.block.Chest;
import org.bukkit.block.Sign; import org.bukkit.block.Sign;
import org.bukkit.configuration.file.FileConfiguration; import org.bukkit.configuration.file.FileConfiguration;
@ -37,12 +39,12 @@ public class WorldShopManager {
* @param price The unit price of the item. * @param price The unit price of the item.
* @param owner Owner of the shop. * @param owner Owner of the shop.
*/ */
public WorldShop CreateWorldShop(Sign s, ItemStack item, int amt, double price, String owner) { public WorldShop CreateWorldShop(Sign s, ItemStack item, int amt, double price, UUID owner) {
//Convert the sign. //Convert the sign.
return CreateWorldShop(s,item,amt,price,owner,false); return CreateWorldShop(s,item,amt,price,owner,false);
} }
public WorldShop CreateWorldShop(Sign s, ItemStack item, int amt, double price, String owner, boolean purchaseshop) { public WorldShop CreateWorldShop(Sign s, ItemStack item, int amt, double price, UUID owner, boolean purchaseshop) {
//Convert the sign. //Convert the sign.
String[] lines = s.getLines(); String[] lines = s.getLines();
WorldShop newshop = new WorldShop(item, amt, 0, price, owner, TwosideKeeper.WORLD_SHOP_ID, s.getLocation()); WorldShop newshop = new WorldShop(item, amt, 0, price, owner, TwosideKeeper.WORLD_SHOP_ID, s.getLocation());
@ -131,11 +133,29 @@ public class WorldShopManager {
config = new File(TwosideKeeper.filesave,"worldshop.data"); config = new File(TwosideKeeper.filesave,"worldshop.data");
FileConfiguration workable = YamlConfiguration.loadConfiguration(config); FileConfiguration workable = YamlConfiguration.loadConfiguration(config);
if (!workable.contains("uuid"+id)) {
//Update world shop to latest version.
TwosideKeeper.log("Old World Shop detected for ID "+id+". Attempting to convert...", 2);
OfflinePlayer op = Bukkit.getOfflinePlayer(workable.getString("owner"+id));
TwosideKeeper.log("Offline Player: "+op.getName()+","+op.getUniqueId(), 0);
if (op!=null && !op.getName().equalsIgnoreCase("admin")) {
workable.set("uuid"+id, op.getUniqueId().toString());
TwosideKeeper.log(" Converted to UUID standard. Owner is now "+op.getUniqueId()+".", 2);
} else {
TwosideKeeper.log(" WARNING ! Failed to convert this World Shop! Could not find player "+workable.getString("owner"+id)+". Converting to admin shop...", 1);
workable.set("uuid"+id, WorldShop.ADMIN_UUID.toString());
}
try {
workable.save(config);
} catch (IOException e) {
e.printStackTrace();
}
}
if (workable.contains("locationdata"+id)) { if (workable.contains("locationdata"+id)) {
String[] splitloc = workable.getString("locationdata"+id).split(","); String[] splitloc = workable.getString("locationdata"+id).split(",");
return new WorldShop(workable.getItemStack("item"+id),workable.getInt("amt"+id),workable.getInt("storedamt"+id),workable.getDouble("item_price"+id),workable.getString("owner"+id),id,new Location(Bukkit.getWorld(splitloc[0]),Integer.parseInt(splitloc[1]),Integer.parseInt(splitloc[2]),Integer.parseInt(splitloc[3]))); return new WorldShop(workable.getItemStack("item"+id),workable.getInt("amt"+id),workable.getInt("storedamt"+id),workable.getDouble("item_price"+id),UUID.fromString(workable.getString("uuid"+id)),id,new Location(Bukkit.getWorld(splitloc[0]),Integer.parseInt(splitloc[1]),Integer.parseInt(splitloc[2]),Integer.parseInt(splitloc[3])));
} else { } else {
return new WorldShop(workable.getItemStack("item"+id),workable.getInt("amt"+id),workable.getInt("storedamt"+id),workable.getDouble("item_price"+id),workable.getString("owner"+id),id,TwosideKeeper.TWOSIDE_LOCATION); return new WorldShop(workable.getItemStack("item"+id),workable.getInt("amt"+id),workable.getInt("storedamt"+id),workable.getDouble("item_price"+id),UUID.fromString(workable.getString("uuid"+id)),id,TwosideKeeper.TWOSIDE_LOCATION);
} }
} }
@ -149,7 +169,7 @@ public class WorldShopManager {
workable.set("item"+id,shop.GetItem()); workable.set("item"+id,shop.GetItem());
workable.set("item_price"+id,shop.GetUnitPrice()); workable.set("item_price"+id,shop.GetUnitPrice());
workable.set("amt"+id,shop.GetAmount()); workable.set("amt"+id,shop.GetAmount());
workable.set("owner"+id,shop.GetOwner()); workable.set("uuid"+id,shop.GetOwner().toString());
workable.set("storedamt"+id,shop.GetStoredAmount()); workable.set("storedamt"+id,shop.GetStoredAmount());
workable.set("locationdata"+id,shop.GetLocString()); workable.set("locationdata"+id,shop.GetLocString());
@ -220,15 +240,15 @@ public class WorldShopManager {
sessions.remove(ss); sessions.remove(ss);
} }
public void AddNewPurchase(String owner, String purchaser, ItemStack item, double price, int amt) { public void AddNewPurchase(UUID owner, UUID purchaser, ItemStack item, double price, int amt) {
purchases.add(new ShopPurchase(owner, purchaser, item, price, amt)); purchases.add(new ShopPurchase(owner, purchaser, item, price, amt));
} }
public void AddNewPurchase(String owner, String purchaser, ItemStack item, double price, int amt, boolean sell) { public void AddNewPurchase(UUID owner, UUID purchaser, ItemStack item, double price, int amt, boolean sell) {
purchases.add(new ShopPurchase(owner, purchaser, item, price, amt, sell)); purchases.add(new ShopPurchase(owner, purchaser, item, price, amt, sell));
} }
public boolean PlayerHasPurchases(Player p) { public boolean PlayerHasPurchases(Player p) {
for (int i=0;i<purchases.size();i++) { for (int i=0;i<purchases.size();i++) {
if (p.getName().equalsIgnoreCase(purchases.get(i).getSeller())) { if (p.getUniqueId().equals(purchases.get(i).getSeller())) {
return true; return true;
} }
} }
@ -236,7 +256,7 @@ public class WorldShopManager {
} }
public void PlayerSendPurchases(Player p) { public void PlayerSendPurchases(Player p) {
for (int i=0;i<purchases.size();i++) { for (int i=0;i<purchases.size();i++) {
if (p.getName().equalsIgnoreCase(purchases.get(i).getSeller())) { if (p.getUniqueId().equals(purchases.get(i).getSeller())) {
p.spigot().sendMessage(purchases.get(i).announcementString()); p.spigot().sendMessage(purchases.get(i).announcementString());
purchases.remove(i); purchases.remove(i);
i--; i--;
@ -282,7 +302,7 @@ public class WorldShopManager {
int counter=0; int counter=0;
for (int i=0;i<purchases.size();i++) { for (int i=0;i<purchases.size();i++) {
if (!purchases.get(i).getSeller().equalsIgnoreCase("admin")) { if (!purchases.get(i).getSeller().equals(WorldShop.ADMIN_UUID)) {
workable.set("player"+counter, purchases.get(i).getSeller()); workable.set("player"+counter, purchases.get(i).getSeller());
workable.set("customer"+counter, purchases.get(i).getCustomer()); workable.set("customer"+counter, purchases.get(i).getCustomer());
workable.set("item"+counter, purchases.get(i).getItem()); workable.set("item"+counter, purchases.get(i).getItem());
@ -306,10 +326,11 @@ public class WorldShopManager {
TwosideKeeper.log("Config exists. Entering.",5); TwosideKeeper.log("Config exists. Entering.",5);
FileConfiguration workable = YamlConfiguration.loadConfiguration(config); FileConfiguration workable = YamlConfiguration.loadConfiguration(config);
for (int i=0;i<workable.getKeys(false).size()/6;i++) { for (int i=0;i<workable.getKeys(false).size()/6;i++) {
try {
ShopPurchase sp = ShopPurchase sp =
new ShopPurchase( new ShopPurchase(
workable.getString("player"+i), UUID.fromString(workable.getString("player"+i)),
workable.getString("customer"+i), UUID.fromString(workable.getString("customer"+i)),
workable.getItemStack("item"+i), workable.getItemStack("item"+i),
workable.getDouble("money"+i), workable.getDouble("money"+i),
workable.getInt("amt"+i), workable.getInt("amt"+i),
@ -317,6 +338,10 @@ public class WorldShopManager {
); );
purchases.add(sp); purchases.add(sp);
TwosideKeeper.log("--Added Purchase: "+sp.toString(),5); TwosideKeeper.log("--Added Purchase: "+sp.toString(),5);
} catch (IllegalArgumentException e) {
TwosideKeeper.log("WARNING! Bad Shop purchase string detected: "+workable.getString("player"+i),1);
TwosideKeeper.log("Deleting entry.", 1);
}
} }
TwosideKeeper.log("Purchase List: "+purchases.toString(), 5); TwosideKeeper.log("Purchase List: "+purchases.toString(), 5);
} }

Loading…
Cancel
Save