Add in '/jobs members' command.

master_event
sigonasr2 11 years ago
parent 70a92aeaac
commit 9fdb87addb
  1. 51
      BankEconomyMod/src/me/kaZep/Base/Main.java
  2. 51
      BankEconomyMod/src/me/kaZep/Commands/commandBankEconomy.java

@ -65,9 +65,9 @@ import org.bukkit.entity.Zombie;
import org.bukkit.inventory.Inventory;
import org.bukkit.inventory.ItemStack;
import org.bukkit.inventory.PlayerInventory;
import org.bukkit.inventory.ShapedRecipe;
import org.bukkit.inventory.meta.FireworkMeta;
import org.bukkit.inventory.ShapelessRecipe;
import org.bukkit.inventory.ShapedRecipe;
import org.bukkit.inventory.meta.FireworkMeta;
import org.bukkit.inventory.ShapelessRecipe;
import org.bukkit.inventory.meta.ItemMeta;
import org.bukkit.inventory.meta.SkullMeta;
import org.bukkit.map.MapRenderer;
@ -2573,7 +2573,7 @@ public void runTick() {
}
public String healthbar(double curHP,double maxHP) {
//<EFBFBD><EFBFBD>
//<EFBFBD>ソス隨<EFBFBD>ソス
int bits=(int)(Math.ceil(curHP/maxHP*10));
String bar=" ";
if (bits>6) {
@ -2595,7 +2595,7 @@ public String healthbar(double curHP,double maxHP) {
}
public String healthbar(double curHP,double maxHP,int hunger) {
//<EFBFBD><EFBFBD>
//<EFBFBD>ソス隨<EFBFBD>ソス
int bits=(int)(Math.ceil(curHP/maxHP*10));
String bar=" ";
if (hunger>=17) {
@ -3601,6 +3601,13 @@ public void payDay(int time)
if (getConfig().getInt("jobs."+ValidJobs[matchedjob])>=getConfig().getInt("jobs.MAX_JOBS")) {
p.sendMessage(ChatColor.GOLD+"Sorry, there are already "+getConfig().getInt("jobs.MAX_JOBS")+" people in this job!");
return false;
}
if (getConfig().getInt("jobs."+ValidJobs[matchedjob])==0) {
//Simply set the string.
getConfig().set("jobs."+ValidJobs[matchedjob]+"_members",String.valueOf(p.getName().toLowerCase()));
} else {
//Append to list.
getConfig().set("jobs."+ValidJobs[matchedjob]+"_members",String.valueOf(getConfig().getString("jobs."+ValidJobs[matchedjob]+"_members")+", "+p.getName().toLowerCase()));
}
Bukkit.getLogger().info("Well, they are allowed to join this job.");
//Add 1 to main config.
@ -3716,7 +3723,7 @@ public void payDay(int time)
}
}
JobsDataInfo info = Jobsinfo[getJobSlot(job)];
economy.depositPlayer(p.getName().toLowerCase(), amount*(1d+(info.moneymult*getAccountsConfig().getInt(p.getName().toLowerCase()+".jobs.job"+(slot+1)+"lv"))));
economy.depositPlayer(p.getName(), amount*(1d+(info.moneymult*getAccountsConfig().getInt(p.getName().toLowerCase()+".jobs.job"+(slot+1)+"lv"))));
getAccountsConfig().set(p.getName().toLowerCase()+".jobs.job"+(slot+1)+"exp", Double.valueOf(getAccountsConfig().getDouble(p.getName().toLowerCase()+".jobs.job"+(slot+1)+"exp")+exp));
if (getAccountsConfig().getDouble(p.getName().toLowerCase()+".jobs.job"+(slot+1)+"exp")<0) {
//It can't be negative.
@ -3763,7 +3770,7 @@ public void payDay(int time)
JobsDataInfo info = Jobsinfo[getJobSlot(job)];
if (getJobLv(job,p)<40) {
getAccountsConfig().set(p.getName().toLowerCase()+".jobs.job"+(slot+1)+"lv", Integer.valueOf(getAccountsConfig().getInt(p.getName().toLowerCase()+".jobs.job"+(slot+1)+"lv")+1));
Bukkit.broadcastMessage(p.getName().toLowerCase()+" is now a Level "+getAccountsConfig().getInt(p.getName().toLowerCase()+".jobs.job"+(slot+1)+"lv")+" "+getJobColor(job)+job+ChatColor.WHITE+".");
Bukkit.broadcastMessage(p.getName()+" is now a Level "+getAccountsConfig().getInt(p.getName().toLowerCase()+".jobs.job"+(slot+1)+"lv")+" "+getJobColor(job)+job+ChatColor.WHITE+".");
if (getJobTotalLvs(p)%5==0) {
Bukkit.broadcastMessage(ChatColor.GREEN+p.getName()+" has reached Level "+getJobTotalLvs(p)+"!");
if ((((getJobTotalLvs(p)/5+1)-getStatPointTotal(p)))>0) {
@ -3804,7 +3811,7 @@ public void payDay(int time)
}
}
JobsDataInfo info = Jobsinfo[getJobSlot(job)];
economy.depositPlayer(p.getName().toLowerCase(), amount*(1d+(info.moneymult*getAccountsConfig().getInt(p.getName().toLowerCase()+".jobs.job"+slot+"lv"))));
economy.depositPlayer(p.getName(), amount*(1d+(info.moneymult*getAccountsConfig().getInt(p.getName().toLowerCase()+".jobs.job"+slot+"lv"))));
}
public ChatColor getJobColor(String job) {
@ -4535,35 +4542,47 @@ public void payDay(int time)
String[] jobs = getJobs(p);
//We can remove them from this job.
if (job.equalsIgnoreCase(getAccountsConfig().getString(p.getName().toLowerCase()+".jobs.job1"))) {
//Remove from job members list.
getConfig().set("jobs."+job.equalsIgnoreCase(getAccountsConfig().getString(p.getName().toLowerCase()+".jobs.job1"))+"_members", getConfig().getString("jobs."+job.equalsIgnoreCase(getAccountsConfig().getString(p.getName().toLowerCase()+".jobs.job1"))+"_members").replace(", "+p.getName().toLowerCase(), ""));
/*Try again in case it's the only entry.*/
getConfig().set("jobs."+job.equalsIgnoreCase(getAccountsConfig().getString(p.getName().toLowerCase()+".jobs.job1"))+"_members", getConfig().getString("jobs."+job.equalsIgnoreCase(getAccountsConfig().getString(p.getName().toLowerCase()+".jobs.job1"))+"_members").replace(p.getName().toLowerCase(), ""));
//Remove 1 from main config.
getConfig().set("jobs."+getAccountsConfig().getString(p.getName().toLowerCase()+".jobs.job1"), Integer.valueOf(getConfig().getInt("jobs."+getAccountsConfig().getString(p.getName().toLowerCase()+".jobs.job1"))-1));
saveConfig();
//Remove from job 1.
Bukkit.broadcastMessage(p.getName().toLowerCase()+" has left the "+getJobColor(getAccountsConfig().getString(p.getName().toLowerCase()+".jobs.job1"))+getAccountsConfig().getString(p.getName().toLowerCase()+".jobs.job1")+ChatColor.WHITE+" job!");
Bukkit.broadcastMessage(p.getName()+" has left the "+getJobColor(getAccountsConfig().getString(p.getName().toLowerCase()+".jobs.job1"))+getAccountsConfig().getString(p.getName().toLowerCase()+".jobs.job1")+ChatColor.WHITE+" job!");
getAccountsConfig().set(p.getName().toLowerCase()+".jobs.job1", String.valueOf("None"));
getAccountsConfig().set(p.getName().toLowerCase()+".jobs.job1lv", Integer.valueOf(0));
getAccountsConfig().set(p.getName().toLowerCase()+".jobs.job1exp", Double.valueOf(0));
//saveAccountsConfig();
return true;
} else
if (job.equalsIgnoreCase(getAccountsConfig().getString(p.getName().toLowerCase()+".jobs.job2"))) {
//Remove 1 from main config.
if (job.equalsIgnoreCase(getAccountsConfig().getString(p.getName().toLowerCase()+".jobs.job2"))) {
//Remove from job members list.
getConfig().set("jobs."+job.equalsIgnoreCase(getAccountsConfig().getString(p.getName().toLowerCase()+".jobs.job2"))+"_members", getConfig().getString("jobs."+job.equalsIgnoreCase(getAccountsConfig().getString(p.getName().toLowerCase()+".jobs.job2"))+"_members").replace(", "+p.getName().toLowerCase(), ""));
/*Try again in case it's the only entry.*/
getConfig().set("jobs."+job.equalsIgnoreCase(getAccountsConfig().getString(p.getName().toLowerCase()+".jobs.job2"))+"_members", getConfig().getString("jobs."+job.equalsIgnoreCase(getAccountsConfig().getString(p.getName().toLowerCase()+".jobs.job2"))+"_members").replace(p.getName().toLowerCase(), ""));
//Remove 1 from main config.
getConfig().set("jobs."+getAccountsConfig().getString(p.getName().toLowerCase()+".jobs.job2"), Integer.valueOf(getConfig().getInt("jobs."+getAccountsConfig().getString(p.getName().toLowerCase()+".jobs.job2"))-1));
saveConfig();
//Remove from job 2.
Bukkit.broadcastMessage(p.getName().toLowerCase()+" has left the "+getJobColor(getAccountsConfig().getString(p.getName().toLowerCase()+".jobs.job2"))+getAccountsConfig().getString(p.getName().toLowerCase()+".jobs.job2")+ChatColor.WHITE+" job!");
Bukkit.broadcastMessage(p.getName()+" has left the "+getJobColor(getAccountsConfig().getString(p.getName().toLowerCase()+".jobs.job2"))+getAccountsConfig().getString(p.getName().toLowerCase()+".jobs.job2")+ChatColor.WHITE+" job!");
getAccountsConfig().set(p.getName().toLowerCase()+".jobs.job2", String.valueOf("None"));
getAccountsConfig().set(p.getName().toLowerCase()+".jobs.job2lv", Integer.valueOf(0));
getAccountsConfig().set(p.getName().toLowerCase()+".jobs.job2exp", Double.valueOf(0));
//saveAccountsConfig();
return true;
} else
if (job.equalsIgnoreCase(getAccountsConfig().getString(p.getName().toLowerCase()+".jobs.job3"))) {
//Remove 1 from main config.
if (job.equalsIgnoreCase(getAccountsConfig().getString(p.getName().toLowerCase()+".jobs.job3"))) {
//Remove from job members list.
getConfig().set("jobs."+job.equalsIgnoreCase(getAccountsConfig().getString(p.getName().toLowerCase()+".jobs.job3"))+"_members", getConfig().getString("jobs."+job.equalsIgnoreCase(getAccountsConfig().getString(p.getName().toLowerCase()+".jobs.job3"))+"_members").replace(", "+p.getName().toLowerCase(), ""));
/*Try again in case it's the only entry.*/
getConfig().set("jobs."+job.equalsIgnoreCase(getAccountsConfig().getString(p.getName().toLowerCase()+".jobs.job3"))+"_members", getConfig().getString("jobs."+job.equalsIgnoreCase(getAccountsConfig().getString(p.getName().toLowerCase()+".jobs.job3"))+"_members").replace(p.getName().toLowerCase(), ""));
//Remove 1 from main config.
getConfig().set("jobs."+getAccountsConfig().getString(p.getName().toLowerCase()+".jobs.job3"), Integer.valueOf(getConfig().getInt("jobs."+getAccountsConfig().getString(p.getName().toLowerCase()+".jobs.job3"))-1));
saveConfig();
//Remove from job 3.
Bukkit.broadcastMessage(p.getName().toLowerCase()+" has left the "+getJobColor(getAccountsConfig().getString(p.getName().toLowerCase()+".jobs.job3"))+getAccountsConfig().getString(p.getName().toLowerCase()+".jobs.job3")+ChatColor.WHITE+" job!");
Bukkit.broadcastMessage(p.getName()+" has left the "+getJobColor(getAccountsConfig().getString(p.getName().toLowerCase()+".jobs.job3"))+getAccountsConfig().getString(p.getName().toLowerCase()+".jobs.job3")+ChatColor.WHITE+" job!");
getAccountsConfig().set(p.getName().toLowerCase()+".jobs.job3", String.valueOf("None"));
getAccountsConfig().set(p.getName().toLowerCase()+".jobs.job3lv", Integer.valueOf(0));
getAccountsConfig().set(p.getName().toLowerCase()+".jobs.job3exp", Double.valueOf(0));
@ -4750,4 +4769,4 @@ public void payDay(int time)
// not a Beta1.4.6R0.2 Server
}
}
}
}

@ -1691,6 +1691,9 @@ public String convertToItemName(String val) {
if (cmd.getName().toLowerCase().equalsIgnoreCase("jobs") && args.length == 1 && args[0].equalsIgnoreCase("join")) {
p.sendMessage("Usage: "+ChatColor.GREEN+"/jobs join [JobName]"+ChatColor.WHITE+" - Join a job. Type /jobs to see the jobs.");
} else
if (cmd.getName().equalsIgnoreCase("jobs") && args.length == 1 && args[0].equalsIgnoreCase("members")) {
p.sendMessage("Usage: "+ChatColor.GREEN+"/jobs members [JobName]"+ChatColor.WHITE+" - Check all members in a job.");
} else
if (cmd.getName().toLowerCase().equalsIgnoreCase("jobs") && args.length == 1 && args[0].equalsIgnoreCase("leave")) {
p.sendMessage("Usage: "+ChatColor.GREEN+"/jobs leave [JobName]"+ChatColor.WHITE+" - Leave a job. Type /jobs stats to see your jobs.");
} else
@ -1713,6 +1716,54 @@ public String convertToItemName(String val) {
//Attempt to join the job.
this.plugin.leaveJob(p,args[1]);
} else
if (cmd.getName().equalsIgnoreCase("jobs") && args.length == 2 && args[0].equalsIgnoreCase("members")) {
JobsDataInfo[] Jobsinfo = {this.plugin.Woodcutter_job,this.plugin.Miner_job,this.plugin.Builder_job,this.plugin.Digger_job,this.plugin.Farmer_job,this.plugin.Hunter_job,this.plugin.Fisherman_job,this.plugin.Weaponsmith_job,this.plugin.Blacksmith_job,this.plugin.Cook_job,this.plugin.Brewer_job,this.plugin.Enchanter_job,this.plugin.Breeder_job,this.plugin.Explorer_job,this.plugin.Support_job};
boolean found=false;
String job = "";
ChatColor job_color = null;
for (int i=0;i<this.plugin.ValidJobs.length;i++) {
if (this.plugin.ValidJobs[i].toLowerCase().equalsIgnoreCase(args[1])) {
found=true;
job = this.plugin.ValidJobs[i];
job_color = this.plugin.getJobColor(this.plugin.ValidJobs[i]);
break;
}
}
if (found) {
if (this.plugin.getConfig().contains("jobs."+job+"_members")) {
p.sendMessage("Players in the "+job_color+job+" job:");
String[] players = this.plugin.getConfig().getString("jobs."+job+"_members").split(", ");
char lowest = 'z'+1;
List<String> sorted_players = new ArrayList<String>();
for (int i=0;i<players.length;i++) {
sorted_players.add(players[i]); //Add everyone to the list.
}
//Sort them.
List<String> sorted_list_players = new ArrayList<String>();
int lowest_slot = -1;
while (sorted_players.size()>0) {
for (int i=0;i<sorted_players.size();i++) {
if (sorted_players.get(i).toCharArray()[0]<lowest) {
lowest=sorted_players.get(i).toCharArray()[0];
lowest_slot=i;
}
}
sorted_list_players.add(sorted_players.get(lowest_slot));
sorted_players.remove(lowest_slot);
lowest_slot=-1;
lowest='z'+1;
}
for (int i=0;i<sorted_list_players.size();i++) {
OfflinePlayer q = Bukkit.getOfflinePlayer(sorted_list_players.get(i));
p.sendMessage(" "+q.getName()+ChatColor.GRAY+ChatColor.ITALIC+" (Lv"+this.plugin.getJobLv(job, q.getName())+")");
}
} else {
p.sendMessage(ChatColor.GOLD+"Sorry, something bad happened! Please report this to an administrator.");
}
} else {
p.sendMessage(ChatColor.RED+"Sorry, that is not a valid job!");
}
} else
if (cmd.getName().toLowerCase().equalsIgnoreCase("jobs") && (args.length == 2 || args.length==3) && args[0].equalsIgnoreCase("info")) {
JobsDataInfo[] Jobsinfo = {this.plugin.Woodcutter_job,this.plugin.Miner_job,this.plugin.Builder_job,this.plugin.Digger_job,this.plugin.Farmer_job,this.plugin.Hunter_job,this.plugin.Fisherman_job,this.plugin.Weaponsmith_job,this.plugin.Blacksmith_job,this.plugin.Cook_job,this.plugin.Brewer_job,this.plugin.Enchanter_job,this.plugin.Breeder_job,this.plugin.Explorer_job,this.plugin.Support_job};
boolean found=false;

Loading…
Cancel
Save