The released version of 1.0, now to brace for cruel months of no internet.

This commit is contained in:
nossr50 2011-04-28 01:49:40 -07:00
parent f9c941af6e
commit ecb03aebaf
15 changed files with 499 additions and 450 deletions

View File

@ -1,6 +1,7 @@
Changelog: Changelog:
#Versions without changelogs probably had very small misc fixes, like tweaks to the source code# #Versions without changelogs probably had very small misc fixes, like tweaks to the source code#
Version 1.0 Version 1.0
Players can now repair Stone/Wood tools
Fixed duping bug with WG/Block Protection Plugins Fixed duping bug with WG/Block Protection Plugins
Added Leaf Blower to WoodCutting Added Leaf Blower to WoodCutting
Different Trees give different WoodCutting XP Different Trees give different WoodCutting XP

View File

@ -119,7 +119,9 @@ public class Combat {
//Taming Debug Stuff //Taming Debug Stuff
if(event.getEntity() instanceof Wolf) if(event.getEntity() instanceof Wolf)
{ {
if(attacker.getItemInHand().getTypeId() == 352) if(Party.getInstance().inSameParty(attacker, Taming.getOwner(event.getEntity(), pluginx)))
event.setCancelled(true);
if(attacker.getItemInHand().getTypeId() == 352 && mcPermissions.getInstance().taming(attacker))
{ {
attacker.sendMessage(ChatColor.GREEN+"**You examine the Wolf using Beast Lore**"); attacker.sendMessage(ChatColor.GREEN+"**You examine the Wolf using Beast Lore**");
if(Taming.getOwnerName(event.getEntity()) != null) if(Taming.getOwnerName(event.getEntity()) != null)
@ -136,11 +138,6 @@ public class Combat {
*/ */
if(event instanceof EntityDamageByEntityEvent && ((EntityDamageByEntityEvent) event).getDamager() instanceof Wolf) if(event instanceof EntityDamageByEntityEvent && ((EntityDamageByEntityEvent) event).getDamager() instanceof Wolf)
{ {
//DEBUG STUFF
for(Player x : pluginx.getServer().getOnlinePlayers())
{
x.sendMessage("Wolf Versus Entity Triggered");
}
EntityDamageByEntityEvent eventb = (EntityDamageByEntityEvent) event; EntityDamageByEntityEvent eventb = (EntityDamageByEntityEvent) event;
if(Taming.hasOwner(eventb.getDamager(), pluginx)) if(Taming.hasOwner(eventb.getDamager(), pluginx))
{ {
@ -197,8 +194,10 @@ public class Combat {
/* /*
* TEMPORARY FIX AS WOLVES AREN'T TRIGGERING DAMAGE EVENTS WHEN ATTACKING NON PLAYERS AT THE TIME OF WRITING * TEMPORARY FIX AS WOLVES AREN'T TRIGGERING DAMAGE EVENTS WHEN ATTACKING NON PLAYERS AT THE TIME OF WRITING
*/ */
if(!event.isCancelled()){
PPo.addTamingXP(event.getDamage() * 3); PPo.addTamingXP(event.getDamage() * 3);
Skills.XpCheck(master); Skills.XpCheck(master);
}
//Shock-Proof //Shock-Proof
if((event.getCause() == DamageCause.ENTITY_EXPLOSION || event.getCause() == DamageCause.BLOCK_EXPLOSION) && PPo.getTamingInt() >= 500) if((event.getCause() == DamageCause.ENTITY_EXPLOSION || event.getCause() == DamageCause.BLOCK_EXPLOSION) && PPo.getTamingInt() >= 500)

View File

@ -147,6 +147,8 @@ public class Leaderboard {
String line = ""; String line = "";
for(PlayerStat p : ps) for(PlayerStat p : ps)
{ {
if(p.name.equals("$mcMMO_DummyInfo"))
continue;
writer.append(p.name + ":" + p.statVal); writer.append(p.name + ":" + p.statVal);
writer.append("\r\n"); writer.append("\r\n");
} }

View File

@ -43,7 +43,7 @@ public class Users {
FileWriter writer = null; FileWriter writer = null;
try { try {
writer = new FileWriter(location); writer = new FileWriter(location);
writer.write("#Storage place for user information\r\n"); //writer.write("#Storage place for user information\r\n");
} catch (Exception e) { } catch (Exception e) {
log.log(Level.SEVERE, "Exception while creating " + location, e); log.log(Level.SEVERE, "Exception while creating " + location, e);
} finally { } finally {
@ -57,7 +57,6 @@ public class Users {
} }
} else { } else {
//properties = new PropertiesFile(location);
try { try {
load(); load();
} catch (IOException e) { } catch (IOException e) {

View File

@ -33,7 +33,7 @@ public class LoadProperties {
MySQLuserName = properties.getString("MySQLuserName", "defaultusername"); MySQLuserName = properties.getString("MySQLuserName", "defaultusername");
MySQLtablePrefix = properties.getString("MySQLTablePrefix", "mcmmo_"); MySQLtablePrefix = properties.getString("MySQLTablePrefix", "mcmmo_");
MySQLport = properties.getInteger("MySQLport", 3306); MySQLport = properties.getInteger("MySQLport", 3306);
useMySQL = properties.getBoolean("mysql", false); useMySQL = properties.getBoolean("UseMySQL", false);
/* /*
* OTHER * OTHER

View File

@ -25,8 +25,8 @@ import com.gmail.nossr50.skills.*;
public class PlayerProfile public class PlayerProfile
{ {
protected final Logger log = Logger.getLogger("Minecraft"); protected final Logger log = Logger.getLogger("Minecraft");
private String taming, tamingXP, playerName, miningXP, woodCuttingXP, woodcutting, repair, mining, party, myspawn, myspawnworld, unarmed, herbalism, excavation, private String taming="0", tamingXP="0", miningXP="0", woodCuttingXP="0", woodcutting="0", repair="0", mining="0", party, myspawn, myspawnworld, unarmed="0", herbalism="0", excavation="0",
archery, swords, axes, invite, acrobatics, repairXP, unarmedXP, herbalismXP, excavationXP, archeryXP, swordsXP, axesXP, acrobaticsXP; archery="0", swords="0", axes="0", invite, acrobatics="0", repairXP="0", unarmedXP="0", herbalismXP="0", excavationXP="0", archeryXP="0", swordsXP="0", axesXP="0", acrobaticsXP="0";
private boolean greenTerraMode, partyChatOnly = false, greenTerraInformed = true, berserkInformed = true, skullSplitterInformed = true, gigaDrillBreakerInformed = true, private boolean greenTerraMode, partyChatOnly = false, greenTerraInformed = true, berserkInformed = true, skullSplitterInformed = true, gigaDrillBreakerInformed = true,
superBreakerInformed = true, serratedStrikesInformed = true, treeFellerInformed = true, dead, abilityuse = true, treeFellerMode, superBreakerMode, gigaDrillBreakerMode, superBreakerInformed = true, serratedStrikesInformed = true, treeFellerInformed = true, dead, abilityuse = true, treeFellerMode, superBreakerMode, gigaDrillBreakerMode,
serratedStrikesMode, hoePreparationMode, shovelPreparationMode, swordsPreparationMode, fistsPreparationMode, pickaxePreparationMode, axePreparationMode, skullSplitterMode, berserkMode; serratedStrikesMode, hoePreparationMode, shovelPreparationMode, swordsPreparationMode, fistsPreparationMode, pickaxePreparationMode, axePreparationMode, skullSplitterMode, berserkMode;
@ -46,21 +46,17 @@ public class PlayerProfile
public PlayerProfile(Player player) public PlayerProfile(Player player)
{ {
thisplayer = player;
if (LoadProperties.useMySQL) { if (LoadProperties.useMySQL) {
// if usemysql load from database
if(!loadMySQL(player)) { if(!loadMySQL(player)) {
addMySQLPlayer(player); addMySQLPlayer(player);
/* loadMySQL(player);//This is probably not needed anymore, could just delete
* REMEMBER TO FIX THIS!
*/
loadMySQL(player); //For some reason its not loading the users after adding them, so heres this, this is a temporary solution
} }
} else { } else {
// load from flat file
if(!load()) { addPlayer(); } if(!load()) { addPlayer(); }
} }
} }
public int getMySQLuserId(){ public int getMySQLuserId(){
return userid; return userid;
} }
@ -131,7 +127,7 @@ public class PlayerProfile
//Find if the line contains the player we want. //Find if the line contains the player we want.
String[] character = line.split(":"); String[] character = line.split(":");
if(!character[0].equals(playerName)){continue;} if(!character[0].equals(thisplayer.getName())){continue;}
//Get Mining //Get Mining
if(character.length > 1) if(character.length > 1)
@ -247,13 +243,13 @@ public class PlayerProfile
{ {
//Read the line in and copy it to the output it's not the player //Read the line in and copy it to the output it's not the player
//we want to edit //we want to edit
if(!line.split(":")[0].equalsIgnoreCase(playerName)) if(!line.split(":")[0].equalsIgnoreCase(thisplayer.getName()))
{ {
writer.append(line).append("\r\n"); writer.append(line).append("\r\n");
//Otherwise write the new player information //Otherwise write the new player information
} else { } else {
writer.append(playerName + ":"); writer.append(thisplayer.getName() + ":");
writer.append(mining + ":"); writer.append(mining + ":");
writer.append(myspawn + ":"); writer.append(myspawn + ":");
writer.append(party+":"); writer.append(party+":");
@ -300,7 +296,7 @@ public class PlayerProfile
BufferedWriter out = new BufferedWriter(file); BufferedWriter out = new BufferedWriter(file);
//Add the player to the end //Add the player to the end
out.append(playerName + ":"); out.append(thisplayer.getName() + ":");
out.append(0 + ":"); //mining out.append(0 + ":"); //mining
out.append(myspawn+":"); out.append(myspawn+":");
out.append(party+":"); out.append(party+":");
@ -338,7 +334,7 @@ public class PlayerProfile
public boolean isPlayer(String player) public boolean isPlayer(String player)
{ {
return player.equals(playerName); return player.equals(thisplayer.getName());
} }
public boolean getPartyChatOnlyToggle(){return partyChatOnly;} public boolean getPartyChatOnlyToggle(){return partyChatOnly;}
public void togglePartyChatOnly(){partyChatOnly = !partyChatOnly;} public void togglePartyChatOnly(){partyChatOnly = !partyChatOnly;}
@ -918,8 +914,7 @@ public class PlayerProfile
} }
public int getTamingInt(){ public int getTamingInt(){
if(isInt(taming)){ if(isInt(taming)){
int x = Integer.parseInt(taming); return Integer.parseInt(taming);
return x;
} else{ } else{
return 0; return 0;
} }
@ -1255,7 +1250,7 @@ public class PlayerProfile
public boolean isInt(String string){ public boolean isInt(String string){
try { try {
//int x = Integer.parseInt(string); int x = Integer.parseInt(string);
} }
catch(NumberFormatException nFE) { catch(NumberFormatException nFE) {
return false; return false;
@ -1448,7 +1443,7 @@ public class PlayerProfile
return 0; return 0;
} }
} }
public void addXpToSkill(int newvalue, String skillname){ public void addXpToSkill(int newvalue, String skillname, Player targetPlayer){
if(!isInt(tamingXP)) if(!isInt(tamingXP))
tamingXP = String.valueOf(0); tamingXP = String.valueOf(0);
if(!isInt(miningXP)) if(!isInt(miningXP))
@ -1506,20 +1501,20 @@ public class PlayerProfile
axesXP = String.valueOf(Integer.valueOf(axesXP)+newvalue); axesXP = String.valueOf(Integer.valueOf(axesXP)+newvalue);
} }
if(skillname.toLowerCase().equals("all")){ if(skillname.toLowerCase().equals("all")){
tamingXP = String.valueOf(Integer.valueOf(tamingXP)+newvalue); tamingXP = String.valueOf(getTamingXPInt()+newvalue);
miningXP = String.valueOf(Integer.valueOf(miningXP)+newvalue); miningXP = String.valueOf(getMiningXPInt()+newvalue);
woodCuttingXP = String.valueOf(Integer.valueOf(woodCuttingXP)+newvalue); woodCuttingXP = String.valueOf(getWoodCuttingXPInt()+newvalue);
repairXP = String.valueOf(Integer.valueOf(repairXP)+newvalue); repairXP = String.valueOf(getRepairXPInt()+newvalue);
herbalismXP = String.valueOf(Integer.valueOf(herbalismXP)+newvalue); herbalismXP = String.valueOf(getHerbalismXPInt()+newvalue);
acrobaticsXP = String.valueOf(Integer.valueOf(acrobaticsXP)+newvalue); acrobaticsXP = String.valueOf(getAcrobaticsXPInt()+newvalue);
swordsXP = String.valueOf(Integer.valueOf(swordsXP)+newvalue); swordsXP = String.valueOf(getSwordsXPInt()+newvalue);
archeryXP = String.valueOf(Integer.valueOf(archeryXP)+newvalue); archeryXP = String.valueOf(getArcheryXPInt()+newvalue);
unarmedXP = String.valueOf(Integer.valueOf(unarmedXP)+newvalue); unarmedXP = String.valueOf(getUnarmedXPInt()+newvalue);
excavationXP = String.valueOf(Integer.valueOf(excavationXP)+newvalue); excavationXP = String.valueOf(getExcavationXPInt()+newvalue);
axesXP = String.valueOf(Integer.valueOf(axesXP)+newvalue); axesXP = String.valueOf(getAxesXPInt()+newvalue);
} }
save(); save();
Skills.XpCheck(thisplayer); Skills.XpCheck(targetPlayer);
} }
public void modifyskill(int newvalue, String skillname){ public void modifyskill(int newvalue, String skillname){
if(skillname.toLowerCase().equals("taming")){ if(skillname.toLowerCase().equals("taming")){
@ -1682,7 +1677,12 @@ public class PlayerProfile
return dead; return dead;
} }
public Location getMySpawn(Player player){ public Location getMySpawn(Player player){
Location loc = new Location(player.getWorld(),(Double.parseDouble(getX())), Double.parseDouble(getY()), Double.parseDouble(getZ())); Location loc = null;
if(isDouble(getX()) && isDouble(getY()) && isDouble(getZ()))
loc = new Location(player.getWorld(),(Double.parseDouble(getX())), Double.parseDouble(getY()), Double.parseDouble(getZ()));
else
return null;
loc.setYaw(0); loc.setYaw(0);
loc.setPitch(0); loc.setPitch(0);
if(loc.getX() != 0 && loc.getY() != 0 && loc.getZ() != 0 && loc.getWorld() != null){ if(loc.getX() != 0 && loc.getY() != 0 && loc.getZ() != 0 && loc.getWorld() != null){

View File

@ -14,16 +14,28 @@ public class Tree {
public void add(String p, int in) public void add(String p, int in)
{ {
if(root == null) if(root == null){
root = new TreeNode(p, in); root = new TreeNode(p, in);
}
else else
root.add(p,in); root.add(p,in);
} }
public PlayerStat[] inOrder() public PlayerStat[] inOrder()
{ {
if(root != null){
ArrayList<PlayerStat> order = root.inOrder(new ArrayList<PlayerStat>()); ArrayList<PlayerStat> order = root.inOrder(new ArrayList<PlayerStat>());
return order.toArray(new PlayerStat[order.size()]); return order.toArray(new PlayerStat[order.size()]);
} else {
//Throw some dummy info in case the users file is empty
//It's not a good fix but its better than rewriting the whole system
ArrayList<PlayerStat> x = new ArrayList<PlayerStat>();
PlayerStat y = new PlayerStat();
y.name = "$mcMMO_DummyInfo";
y.statVal = 0;
x.add(y);
return x.toArray(new PlayerStat[x.size()]);
}
} }
} }

View File

@ -348,13 +348,14 @@ public class m {
String x = null, y = null, z = null, playerName = null, mining = null, myspawn = null, party = null, miningXP = null, woodcutting = null, woodCuttingXP = null, repair = null, unarmed = null, herbalism = null, String x = null, y = null, z = null, playerName = null, mining = null, myspawn = null, party = null, miningXP = null, woodcutting = null, woodCuttingXP = null, repair = null, unarmed = null, herbalism = null,
excavation = null, archery = null, swords = null, axes = null, acrobatics = null, repairXP = null, unarmedXP = null, herbalismXP = null, excavationXP = null, archeryXP = null, swordsXP = null, axesXP = null, excavation = null, archery = null, swords = null, axes = null, acrobatics = null, repairXP = null, unarmedXP = null, herbalismXP = null, excavationXP = null, archeryXP = null, swordsXP = null, axesXP = null,
acrobaticsXP = null, myspawnworld = null, taming = null, tamingXP = null; acrobaticsXP = null, myspawnworld = null, taming = null, tamingXP = null;
int id = 0; int id = 0, theCount = 0;
while((line = in.readLine()) != null) while((line = in.readLine()) != null)
{ {
//Find if the line contains the player we want. //Find if the line contains the player we want.
String[] character = line.split(":"); String[] character = line.split(":");
playerName = character[0]; playerName = character[0];
if(playerName == null) //Check for things we don't want put in the DB
if(playerName == null || playerName.equals("null") || playerName.equals("#Storage place for user information"))
continue; continue;
//Get Mining //Get Mining
@ -429,6 +430,7 @@ public class m {
*/ */
if(id > 0) if(id > 0)
{ {
theCount++;
//Update the skill values //Update the skill values
mcMMO.database.Write("UPDATE "+LoadProperties.MySQLtablePrefix+"users SET lastlogin = " + 0 + " WHERE id = " + id); mcMMO.database.Write("UPDATE "+LoadProperties.MySQLtablePrefix+"users SET lastlogin = " + 0 + " WHERE id = " + id);
//if(getDouble(x) > 0 && getDouble(y) > 0 && getDouble(z) > 0) //if(getDouble(x) > 0 && getDouble(y) > 0 && getDouble(z) > 0)
@ -462,6 +464,7 @@ public class m {
} }
else else
{ {
theCount++;
//Create the user in the DB //Create the user in the DB
mcMMO.database.Write("INSERT INTO "+LoadProperties.MySQLtablePrefix+"users (user, lastlogin) VALUES ('" + playerName + "'," + System.currentTimeMillis() / 1000 +")"); mcMMO.database.Write("INSERT INTO "+LoadProperties.MySQLtablePrefix+"users (user, lastlogin) VALUES ('" + playerName + "'," + System.currentTimeMillis() / 1000 +")");
id = mcMMO.database.GetInt("SELECT id FROM "+LoadProperties.MySQLtablePrefix+"users WHERE user = '" + playerName + "'"); id = mcMMO.database.GetInt("SELECT id FROM "+LoadProperties.MySQLtablePrefix+"users WHERE user = '" + playerName + "'");
@ -503,6 +506,7 @@ public class m {
+" WHERE user_id = "+id); +" WHERE user_id = "+id);
} }
} }
System.out.println("[mcMMO] MySQL Updated from users file, "+theCount+" items added/updated to MySQL DB");
in.close(); in.close();
} catch (Exception e) { } catch (Exception e) {
log.log(Level.SEVERE, "Exception while reading " log.log(Level.SEVERE, "Exception while reading "
@ -517,8 +521,10 @@ public class m {
String percentage = String.valueOf((skillvalue / 1000) * 100); String percentage = String.valueOf((skillvalue / 1000) * 100);
player.sendMessage(ChatColor.RED+"-----[]"+ChatColor.GREEN+"TAMING"+ChatColor.RED+"[]-----"); player.sendMessage(ChatColor.RED+"-----[]"+ChatColor.GREEN+"TAMING"+ChatColor.RED+"[]-----");
player.sendMessage(ChatColor.DARK_GRAY+"XP GAIN: "+ChatColor.WHITE+"Fighting with your wolves"); player.sendMessage(ChatColor.DARK_GRAY+"XP GAIN: "+ChatColor.WHITE+"Wolves getting harmed");
player.sendMessage(ChatColor.GRAY+"**NOTE** Offensive skills are bugged due to a bukkit bug");
player.sendMessage(ChatColor.RED+"---[]"+ChatColor.GREEN+"EFFECTS"+ChatColor.RED+"[]---"); player.sendMessage(ChatColor.RED+"---[]"+ChatColor.GREEN+"EFFECTS"+ChatColor.RED+"[]---");
player.sendMessage(ChatColor.DARK_AQUA+"Beast Lore: "+ChatColor.YELLOW+ChatColor.GREEN+"Bone-whacking inspects wolves");
player.sendMessage(ChatColor.DARK_AQUA+"Gore: "+ChatColor.YELLOW+ChatColor.GREEN+"Critical Strike that applies Bleed"); player.sendMessage(ChatColor.DARK_AQUA+"Gore: "+ChatColor.YELLOW+ChatColor.GREEN+"Critical Strike that applies Bleed");
player.sendMessage(ChatColor.DARK_AQUA+"Sharpened Claws: "+ChatColor.YELLOW+ChatColor.GREEN+"Damage Bonus"); player.sendMessage(ChatColor.DARK_AQUA+"Sharpened Claws: "+ChatColor.YELLOW+ChatColor.GREEN+"Damage Bonus");
player.sendMessage(ChatColor.DARK_AQUA+"Environmentally Aware: "+ChatColor.YELLOW+ChatColor.GREEN+"Cactus/Lava Phobia, Fall DMG Immune"); player.sendMessage(ChatColor.DARK_AQUA+"Environmentally Aware: "+ChatColor.YELLOW+ChatColor.GREEN+"Cactus/Lava Phobia, Fall DMG Immune");
@ -869,8 +875,8 @@ public class m {
if(split[0].equalsIgnoreCase("/"+LoadProperties.mcmmo)){ if(split[0].equalsIgnoreCase("/"+LoadProperties.mcmmo)){
event.setCancelled(true); event.setCancelled(true);
player.sendMessage(ChatColor.RED+"-----[]"+ChatColor.GREEN+"mMO"+ChatColor.RED+"[]-----"); player.sendMessage(ChatColor.RED+"-----[]"+ChatColor.GREEN+"mMO"+ChatColor.RED+"[]-----");
player.sendMessage(ChatColor.YELLOW+"mMO is an RPG server mod for minecraft."); player.sendMessage(ChatColor.YELLOW+"mcMMO is an RPG server mod for minecraft.");
player.sendMessage(ChatColor.YELLOW+"There are many skills added by mMO to minecraft."); player.sendMessage(ChatColor.YELLOW+"There are many skills added by mcMMO to minecraft.");
player.sendMessage(ChatColor.YELLOW+"They can do anything from giving a chance"); player.sendMessage(ChatColor.YELLOW+"They can do anything from giving a chance");
player.sendMessage(ChatColor.YELLOW+"for double drops to letting you break materials instantly."); player.sendMessage(ChatColor.YELLOW+"for double drops to letting you break materials instantly.");
player.sendMessage(ChatColor.YELLOW+"For example, by harvesting logs from trees you will gain"); player.sendMessage(ChatColor.YELLOW+"For example, by harvesting logs from trees you will gain");
@ -885,13 +891,13 @@ public class m {
player.sendMessage(ChatColor.YELLOW+"For example, if you hold a Mining Pick and right click"); player.sendMessage(ChatColor.YELLOW+"For example, if you hold a Mining Pick and right click");
player.sendMessage(ChatColor.YELLOW+"you will ready your Pickaxe, attack mining materials"); player.sendMessage(ChatColor.YELLOW+"you will ready your Pickaxe, attack mining materials");
player.sendMessage(ChatColor.YELLOW+"and then "+ChatColor.RED+"Super Breaker "+ChatColor.YELLOW+"will activate."); player.sendMessage(ChatColor.YELLOW+"and then "+ChatColor.RED+"Super Breaker "+ChatColor.YELLOW+"will activate.");
player.sendMessage(ChatColor.GREEN+"Find out mMO commands with "+ChatColor.DARK_AQUA+"/"+LoadProperties.mcc); player.sendMessage(ChatColor.GREEN+"Find out mcMMO commands with "+ChatColor.DARK_AQUA+"/"+LoadProperties.mcc);
player.sendMessage(ChatColor.GREEN+"You can donate via paypal to"+ChatColor.DARK_RED+" nossr50@gmail.com"); player.sendMessage(ChatColor.GREEN+"You can donate via paypal to"+ChatColor.DARK_RED+" nossr50@gmail.com");
} }
if(split[0].equalsIgnoreCase("/"+LoadProperties.mcc)){ if(split[0].equalsIgnoreCase("/"+LoadProperties.mcc)){
event.setCancelled(true); event.setCancelled(true);
player.sendMessage(ChatColor.RED+"---[]"+ChatColor.YELLOW+"mMO Commands"+ChatColor.RED+"[]---"); player.sendMessage(ChatColor.RED+"---[]"+ChatColor.YELLOW+"mcMMO Commands"+ChatColor.RED+"[]---");
player.sendMessage("/"+LoadProperties.stats+ChatColor.RED+" - View your mMO stats"); player.sendMessage("/"+LoadProperties.stats+ChatColor.RED+" - View your mcMMO stats");
if(mcPermissions.getInstance().party(player)){ if(mcPermissions.getInstance().party(player)){
player.sendMessage(ChatColor.GREEN+"--PARTY COMMANDS--"); player.sendMessage(ChatColor.GREEN+"--PARTY COMMANDS--");
player.sendMessage("/"+LoadProperties.party+" [party name] "+ChatColor.RED+"- Create/Join designated party"); player.sendMessage("/"+LoadProperties.party+" [party name] "+ChatColor.RED+"- Create/Join designated party");

View File

@ -53,14 +53,13 @@ public class mcMMO extends JavaPlugin {
public void onEnable() { public void onEnable() {
mcMMO_Timer.schedule(new mcTimer(this), (long)0, (long)(1000)); mcMMO_Timer.schedule(new mcTimer(this), (long)0, (long)(1000));
new File(maindirectory).mkdir(); new File(maindirectory).mkdir();
//Check if props file exists, if not make it mcProperties.makeProperties(Properties, log); //Make Props file
mcProperties.makeProperties(Properties, log); LoadProperties.loadMain(); //Load Props file
//Load the file Users.getInstance().loadUsers(); //Load Users file
LoadProperties.loadMain(); for(Player player : getServer().getOnlinePlayers()){Users.addUser(player);} //In case of reload add all users back into PlayerProfile
Users.getInstance().loadUsers(); /*
for(Player player : getServer().getOnlinePlayers()){ * REGISTER EVENTS
Users.addUser(player); */
}
PluginManager pm = getServer().getPluginManager(); PluginManager pm = getServer().getPluginManager();
pm.registerEvent(Event.Type.PLAYER_JOIN, playerListener, Priority.Normal, this); pm.registerEvent(Event.Type.PLAYER_JOIN, playerListener, Priority.Normal, this);
pm.registerEvent(Event.Type.PLAYER_LOGIN, playerListener, Priority.Normal, this); pm.registerEvent(Event.Type.PLAYER_LOGIN, playerListener, Priority.Normal, this);
@ -80,6 +79,7 @@ public class mcMMO extends JavaPlugin {
PluginDescriptionFile pdfFile = this.getDescription(); PluginDescriptionFile pdfFile = this.getDescription();
mcPermissions.initialize(getServer()); mcPermissions.initialize(getServer());
mcLoadMySQL(); mcLoadMySQL();
if(LoadProperties.useMySQL)
database.createStructure(); //Make Structure database.createStructure(); //Make Structure
if(!LoadProperties.useMySQL) if(!LoadProperties.useMySQL)
Leaderboard.makeLeaderboards(); //Make the leaderboards Leaderboard.makeLeaderboards(); //Make the leaderboards
@ -124,7 +124,7 @@ public class mcMMO extends JavaPlugin {
} }
public void addXp(Player player, String skillname, Integer newvalue){ public void addXp(Player player, String skillname, Integer newvalue){
PlayerProfile PP = Users.getProfile(player); PlayerProfile PP = Users.getProfile(player);
PP.addXpToSkill(newvalue, skillname); PP.addXpToSkill(newvalue, skillname, player);
Skills.XpCheck(player); Skills.XpCheck(player);
} }
public void modifySkill(Player player, String skillname, Integer newvalue){ public void modifySkill(Player player, String skillname, Integer newvalue){

View File

@ -77,8 +77,7 @@ public class mcPlayerListener extends PlayerListener {
return null; return null;
} }
public void onPlayerLogin(PlayerLoginEvent event) { public void onPlayerLogin(PlayerLoginEvent event) {
Player player = event.getPlayer(); Users.addUser(event.getPlayer());
Users.addUser(player);
} }
public void onPlayerQuit(PlayerQuitEvent event) { public void onPlayerQuit(PlayerQuitEvent event) {
Users.removeUser(event.getPlayer()); Users.removeUser(event.getPlayer());
@ -86,8 +85,8 @@ public class mcPlayerListener extends PlayerListener {
public void onPlayerJoin(PlayerJoinEvent event) { public void onPlayerJoin(PlayerJoinEvent event) {
Player player = event.getPlayer(); Player player = event.getPlayer();
if(mcPermissions.getInstance().motd(player)){ if(mcPermissions.getInstance().motd(player)){
player.sendMessage(ChatColor.BLUE +"This server is running MMO "+plugin.getDescription().getVersion()+" type /"+ChatColor.YELLOW+LoadProperties.mcmmo+ChatColor.BLUE+ " for help."); player.sendMessage(ChatColor.BLUE +"This server is running mcMMO "+plugin.getDescription().getVersion()+" type /"+ChatColor.YELLOW+LoadProperties.mcmmo+ChatColor.BLUE+ " for help.");
player.sendMessage(ChatColor.GREEN+"http://mmo.wikia.com"+ChatColor.BLUE+" - MMO Wiki"); player.sendMessage(ChatColor.GREEN+"http://mcmmo.wikia.com"+ChatColor.BLUE+" - mcMMO Wiki");
} }
} }
public void onPlayerInteract(PlayerInteractEvent event) { public void onPlayerInteract(PlayerInteractEvent event) {
@ -96,17 +95,6 @@ public class mcPlayerListener extends PlayerListener {
Action action = event.getAction(); Action action = event.getAction();
Block block = event.getClickedBlock(); Block block = event.getClickedBlock();
//Archery Nerf //Archery Nerf
if(action == Action.LEFT_CLICK_AIR)
{
if(player.getItemInHand().getTypeId() == 352)
{
Block targetBlock = player.getTargetBlock(null, 20);
player.sendMessage("Target Block TypeID = "+targetBlock.getTypeId());
player.sendMessage("Target Block Byte Data = "+targetBlock.getData());
player.sendMessage("Wold Entity List SIZE : "+targetBlock.getWorld().getEntities().size());
player.sendMessage("Chunk Entity List SIZE : "+targetBlock.getChunk().getEntities().length);
}
}
if(player.getItemInHand().getTypeId() == 261 && LoadProperties.archeryFireRateLimit){ if(player.getItemInHand().getTypeId() == 261 && LoadProperties.archeryFireRateLimit){
if(System.currentTimeMillis() < PP.getArcheryShotATS() + 1000){ if(System.currentTimeMillis() < PP.getArcheryShotATS() + 1000){
/* /*
@ -213,6 +201,10 @@ public class mcPlayerListener extends PlayerListener {
player.sendMessage("Type ID : "+player.getItemInHand().getTypeId()); player.sendMessage("Type ID : "+player.getItemInHand().getTypeId());
player.sendMessage("Byte Data : "+player.getItemInHand().getDurability()); player.sendMessage("Byte Data : "+player.getItemInHand().getDurability());
} }
/*
* FFS -> MySQL
*/
if(split[0].equalsIgnoreCase("/mmoupdate") && mcPermissions.getInstance().admin(player)) if(split[0].equalsIgnoreCase("/mmoupdate") && mcPermissions.getInstance().admin(player))
{ {
event.setCancelled(true); event.setCancelled(true);
@ -225,6 +217,7 @@ public class mcPlayerListener extends PlayerListener {
} }
player.sendMessage(ChatColor.GREEN+"Conversion finished!"); player.sendMessage(ChatColor.GREEN+"Conversion finished!");
} }
/* /*
* LEADER BOARD COMMAND * LEADER BOARD COMMAND
*/ */
@ -533,17 +526,15 @@ public class mcPlayerListener extends PlayerListener {
if(split.length == 4){ if(split.length == 4){
if(isPlayer(split[1]) && m.isInt(split[3]) && Skills.isSkill(split[2])){ if(isPlayer(split[1]) && m.isInt(split[3]) && Skills.isSkill(split[2])){
int newvalue = Integer.valueOf(split[3]); int newvalue = Integer.valueOf(split[3]);
Users.getProfile(getPlayer(split[1])).addXpToSkill(newvalue, split[2]); Users.getProfile(getPlayer(split[1])).addXpToSkill(newvalue, split[2], getPlayer(split[1]));
getPlayer(split[1]).sendMessage(ChatColor.GREEN+"Experience granted!"); getPlayer(split[1]).sendMessage(ChatColor.GREEN+"Experience granted!");
player.sendMessage(ChatColor.RED+split[2]+" has been modified."); player.sendMessage(ChatColor.RED+split[2]+" has been modified.");
} }
} }
else if(split.length == 3){ else if(split.length == 3 && m.isInt(split[2]) && Skills.isSkill(split[1])){
if(m.isInt(split[2]) && Skills.isSkill(split[1])){
int newvalue = Integer.valueOf(split[2]); int newvalue = Integer.valueOf(split[2]);
PP.addXpToSkill(newvalue, split[1]); PP.addXpToSkill(newvalue, split[1], player);
player.sendMessage(ChatColor.RED+split[1]+" has been modified."); player.sendMessage(ChatColor.RED+split[1]+" has been modified.");
}
} else { } else {
player.sendMessage(ChatColor.RED+"Usage is /"+LoadProperties.addxp+" playername skillname xp"); player.sendMessage(ChatColor.RED+"Usage is /"+LoadProperties.addxp+" playername skillname xp");
} }

View File

@ -35,28 +35,29 @@ public class Repair {
/* /*
* DIAMOND ARMOR * DIAMOND ARMOR
*/ */
if(isDiamondArmor(is) && hasDiamond(player) && PP.getRepairInt() >= LoadProperties.repairdiamondlevel){ if(isDiamondArmor(is) && hasItem(player, 264) && PP.getRepairInt() >= LoadProperties.repairdiamondlevel){
removeDiamond(player); removeItem(player, 264);
player.getItemInHand().setDurability(getArmorRepairAmount(is, player)); player.getItemInHand().setDurability(getRepairAmount(is, player));
durabilityAfter = player.getItemInHand().getDurability(); durabilityAfter = player.getItemInHand().getDurability();
player.sendMessage(String.valueOf(durabilityBefore - durabilityAfter)); player.sendMessage(String.valueOf(durabilityBefore - durabilityAfter));
dif = (short) (durabilityBefore - durabilityAfter); dif = (short) (durabilityBefore - durabilityAfter);
dif = (short) (dif * 6); //Boost XP dif = (short) (dif * 6); //Boost XP
PP.addRepairXP(dif * LoadProperties.xpGainMultiplier); PP.addRepairXP(dif * LoadProperties.xpGainMultiplier);
} else if (isIronArmor(is) && hasIron(player)){ }
else if (isIronArmor(is) && hasItem(player, 265)){
/* /*
* IRON ARMOR * IRON ARMOR
*/ */
removeIron(player); removeItem(player, 265);
player.getItemInHand().setDurability(getArmorRepairAmount(is, player)); player.getItemInHand().setDurability(getRepairAmount(is, player));
durabilityAfter = player.getItemInHand().getDurability(); durabilityAfter = player.getItemInHand().getDurability();
dif = (short) (durabilityBefore - durabilityAfter); dif = (short) (durabilityBefore - durabilityAfter);
dif = (short) (dif * 2); //Boost XP dif = (short) (dif * 2); //Boost XP
PP.addRepairXP(dif * LoadProperties.xpGainMultiplier); PP.addRepairXP(dif * LoadProperties.xpGainMultiplier);
//GOLD ARMOR //GOLD ARMOR
} else if (isGoldArmor(is) && hasGold(player)){ } else if (isGoldArmor(is) && hasItem(player, 266)){
removeGold(player); removeItem(player, 266);
player.getItemInHand().setDurability(getArmorRepairAmount(is, player)); player.getItemInHand().setDurability(getRepairAmount(is, player));
durabilityAfter = player.getItemInHand().getDurability(); durabilityAfter = player.getItemInHand().getDurability();
dif = (short) (durabilityBefore - durabilityAfter); dif = (short) (durabilityBefore - durabilityAfter);
dif = (short) (dif * 4); //Boost XP of Gold to around Iron dif = (short) (dif * 4); //Boost XP of Gold to around Iron
@ -69,15 +70,48 @@ public class Repair {
* TOOLS * TOOLS
*/ */
if(isTools(is)){ if(isTools(is)){
/* if(isStoneTools(is) && hasItem(player, 4)){
* IRON TOOLS removeItem(player, 4);
*/
if(isIronTools(is) && hasIron(player)){
removeIron(player);
/* /*
* Repair Durability and calculate dif * Repair Durability and calculate dif
*/ */
player.getItemInHand().setDurability(getToolRepairAmount(is, player)); player.getItemInHand().setDurability(getRepairAmount(is, player));
durabilityAfter = player.getItemInHand().getDurability();
dif = (short) (durabilityBefore - durabilityAfter);
if(m.isShovel(is))
dif = (short) (dif / 3);
if(m.isSwords(is))
dif = (short) (dif / 2);
if(m.isHoe(is))
dif = (short) (dif / 2);
//STONE NERF
dif = (short) (dif / 2);
PP.addRepairXP(dif * LoadProperties.xpGainMultiplier);
} else if(isWoodTools(is) && hasItem(player, 5)){
removeItem(player, 5);
/*
* Repair Durability and calculate dif
*/
player.getItemInHand().setDurability(getRepairAmount(is, player));
durabilityAfter = player.getItemInHand().getDurability();
dif = (short) (durabilityBefore - durabilityAfter);
if(m.isShovel(is))
dif = (short) (dif / 3);
if(m.isSwords(is))
dif = (short) (dif / 2);
if(m.isHoe(is))
dif = (short) (dif / 2);
//WOOD NERF
dif = (short) (dif / 2);
PP.addRepairXP(dif * LoadProperties.xpGainMultiplier);
} else if(isIronTools(is) && hasItem(player, 265)){
removeItem(player, 265);
/*
* Repair Durability and calculate dif
*/
player.getItemInHand().setDurability(getRepairAmount(is, player));
durabilityAfter = player.getItemInHand().getDurability(); durabilityAfter = player.getItemInHand().getDurability();
dif = (short) (durabilityBefore - durabilityAfter); dif = (short) (durabilityBefore - durabilityAfter);
if(m.isShovel(is)) if(m.isShovel(is))
@ -87,12 +121,12 @@ public class Repair {
if(m.isHoe(is)) if(m.isHoe(is))
dif = (short) (dif / 2); dif = (short) (dif / 2);
PP.addRepairXP(dif * LoadProperties.xpGainMultiplier); PP.addRepairXP(dif * LoadProperties.xpGainMultiplier);
} else if (isDiamondTools(is) && hasDiamond(player) && PP.getRepairInt() >= LoadProperties.repairdiamondlevel){ //Check if its diamond and the player has diamonds } else if (isDiamondTools(is) && hasItem(player, 264) && PP.getRepairInt() >= LoadProperties.repairdiamondlevel){ //Check if its diamond and the player has diamonds
/* /*
* DIAMOND TOOLS * DIAMOND TOOLS
*/ */
player.getItemInHand().setDurability(getToolRepairAmount(is, player)); player.getItemInHand().setDurability(getRepairAmount(is, player));
removeDiamond(player); removeItem(player, 264);
durabilityAfter = player.getItemInHand().getDurability(); durabilityAfter = player.getItemInHand().getDurability();
dif = (short) (durabilityBefore - durabilityAfter); dif = (short) (durabilityBefore - durabilityAfter);
if(m.isShovel(is)) if(m.isShovel(is))
@ -102,9 +136,9 @@ public class Repair {
if(m.isHoe(is)) if(m.isHoe(is))
dif = (short) (dif / 2); dif = (short) (dif / 2);
PP.addRepairXP(dif * LoadProperties.xpGainMultiplier); PP.addRepairXP(dif * LoadProperties.xpGainMultiplier);
} else if(isGoldTools(is) && hasGold(player)){ } else if(isGoldTools(is) && hasItem(player, 266)){
player.getItemInHand().setDurability(getToolRepairAmount(is, player)); player.getItemInHand().setDurability(getRepairAmount(is, player));
removeGold(player); removeItem(player, 266);
durabilityAfter = player.getItemInHand().getDurability(); durabilityAfter = player.getItemInHand().getDurability();
dif = (short) (durabilityBefore - durabilityAfter); dif = (short) (durabilityBefore - durabilityAfter);
dif = (short) (dif * 7.6); //Boost XP for Gold to that of around Iron dif = (short) (dif * 7.6); //Boost XP for Gold to that of around Iron
@ -165,13 +199,29 @@ public class Repair {
public static boolean isTools(ItemStack is){ public static boolean isTools(ItemStack is){
if(is.getTypeId() == 256 || is.getTypeId() == 257 || is.getTypeId() == 258 || is.getTypeId() == 267 || is.getTypeId() == 292 || //IRON if(is.getTypeId() == 256 || is.getTypeId() == 257 || is.getTypeId() == 258 || is.getTypeId() == 267 || is.getTypeId() == 292 || //IRON
is.getTypeId() == 276 || is.getTypeId() == 277 || is.getTypeId() == 278 || is.getTypeId() == 279 || is.getTypeId() == 293 || //DIAMOND is.getTypeId() == 276 || is.getTypeId() == 277 || is.getTypeId() == 278 || is.getTypeId() == 279 || is.getTypeId() == 293 || //DIAMOND
is.getTypeId() == 283 || is.getTypeId() == 285 || is.getTypeId() == 286 || is.getTypeId() == 284) //GOLD is.getTypeId() == 283 || is.getTypeId() == 285 || is.getTypeId() == 286 || is.getTypeId() == 284 || //GOLD
is.getTypeId() == 268 || is.getTypeId() == 269 || is.getTypeId() == 270 || is.getTypeId() == 271 || //WOOD
is.getTypeId() == 272 || is.getTypeId() == 273 || is.getTypeId() == 274 || is.getTypeId() == 275) //STONE
{ {
return true; return true;
} else { } else {
return false; return false;
} }
} }
public static boolean isStoneTools(ItemStack is){
if(is.getTypeId() == 272 || is.getTypeId() == 273 || is.getTypeId() == 274 || is.getTypeId() == 275){
return true;
} else {
return false;
}
}
public static boolean isWoodTools(ItemStack is){
if(is.getTypeId() == 268 || is.getTypeId() == 269 || is.getTypeId() == 270 || is.getTypeId() == 271){
return true;
} else {
return false;
}
}
public static boolean isGoldTools(ItemStack is){ public static boolean isGoldTools(ItemStack is){
if(is.getTypeId() == 283 || is.getTypeId() == 285 || is.getTypeId() == 286 || is.getTypeId() == 284 || is.getTypeId() == 294){ if(is.getTypeId() == 283 || is.getTypeId() == 285 || is.getTypeId() == 286 || is.getTypeId() == 284 || is.getTypeId() == 294){
return true; return true;
@ -196,10 +246,10 @@ public class Repair {
return false; return false;
} }
} }
public static void removeIron(Player player){ public static void removeItem(Player player, int typeid){
ItemStack[] inventory = player.getInventory().getContents(); ItemStack[] inventory = player.getInventory().getContents();
for(ItemStack x : inventory){ for(ItemStack x : inventory){
if(x != null && x.getTypeId() == 265){ if(x != null && x.getTypeId() == typeid){
if(x.getAmount() == 1){ if(x.getAmount() == 1){
x.setTypeId(0); x.setTypeId(0);
x.setAmount(0); x.setAmount(0);
@ -212,60 +262,10 @@ public class Repair {
} }
} }
} }
public static void removeGold(Player player){ public static boolean hasItem(Player player, int typeid){
ItemStack[] inventory = player.getInventory().getContents(); ItemStack[] inventory = player.getInventory().getContents();
for(ItemStack x : inventory){ for(ItemStack x : inventory){
if(x != null && x.getTypeId() == 266){ if(x != null && x.getTypeId() == typeid){
if(x.getAmount() == 1){
x.setTypeId(0);
x.setAmount(0);
player.getInventory().setContents(inventory);
} else{
x.setAmount(x.getAmount() - 1);
player.getInventory().setContents(inventory);
}
return;
}
}
}
public static void removeDiamond(Player player){
ItemStack[] inventory = player.getInventory().getContents();
for(ItemStack x : inventory){
if(x != null && x.getTypeId() == 264){
if(x.getAmount() == 1){
x.setTypeId(0);
x.setAmount(0);
player.getInventory().setContents(inventory);
} else{
x.setAmount(x.getAmount() - 1);
player.getInventory().setContents(inventory);
}
return;
}
}
}
public static boolean hasGold(Player player){
ItemStack[] inventory = player.getInventory().getContents();
for(ItemStack x : inventory){
if(x != null && x.getTypeId() == 266){
return true;
}
}
return false;
}
public static boolean hasDiamond(Player player){
ItemStack[] inventory = player.getInventory().getContents();
for(ItemStack x : inventory){
if(x != null && x.getTypeId() == 264){
return true;
}
}
return false;
}
public static boolean hasIron(Player player){
ItemStack[] inventory = player.getInventory().getContents();
for(ItemStack x : inventory){
if(x != null && x.getTypeId() == 265){
return true; return true;
} }
} }
@ -285,11 +285,46 @@ public class Repair {
} }
return durability; return durability;
} }
public static short getToolRepairAmount(ItemStack is, Player player){ public static short getRepairAmount(ItemStack is, Player player){
short durability = is.getDurability(); short durability = is.getDurability();
short ramt = 0; short ramt = 0;
switch(is.getTypeId()) switch(is.getTypeId())
{ {
/*
* TOOLS
*/
//WOOD SWORD
case 268:
ramt = 30;
break;
//WOOD SHOVEL
case 269:
ramt = 60;
break;
//WOOD PICKAXE
case 270:
ramt = 20;
break;
//WOOD AXE
case 271:
ramt = 20;
break;
//STONE SWORD
case 272:
ramt = 44;
break;
//STONE SHOVEL
case 273:
ramt = 132;
break;
//STONE PICKAXE
case 274:
ramt = 44;
break;
//STONE AXE
case 275:
ramt = 44;
break;
//GOLD SHOVEL //GOLD SHOVEL
case 284: case 284:
ramt = 33; ramt = 33;
@ -350,15 +385,9 @@ public class Repair {
case 294: case 294:
ramt = 17; ramt = 17;
break; break;
} /*
return repairCalculate(player, durability, ramt); * ARMOR
} */
//This determines how much we repair
public static short getArmorRepairAmount(ItemStack is, Player player){
short durability = is.getDurability();
short ramt = 0;
switch(is.getTypeId())
{
case 306: case 306:
ramt = 27; ramt = 27;
break; break;
@ -396,27 +425,28 @@ public class Repair {
ramt = 20; ramt = 20;
break; break;
} }
if(durability < 0)
durability = 0;
return repairCalculate(player, durability, ramt); return repairCalculate(player, durability, ramt);
} }
public static void needMoreVespeneGas(ItemStack is, Player player){ public static void needMoreVespeneGas(ItemStack is, Player player){
PlayerProfile PP = Users.getProfile(player); PlayerProfile PP = Users.getProfile(player);
if ((isDiamondTools(is) || isDiamondArmor(is)) && PP.getRepairInt() < LoadProperties.repairdiamondlevel){ if ((isDiamondTools(is) || isDiamondArmor(is)) && PP.getRepairInt() < LoadProperties.repairdiamondlevel){
player.sendMessage(ChatColor.DARK_RED +"You're not adept enough to repair Diamond"); player.sendMessage(ChatColor.DARK_RED +"You're not adept enough to repair Diamond");
} else if (isDiamondTools(is) && !hasDiamond(player) || isIronTools(is) && !hasIron(player) || isGoldTools(is) && !hasGold(player)){ } else if (isDiamondTools(is) && !hasItem(player, 264) || isIronTools(is) && !hasItem(player, 265) || isGoldTools(is) && !hasItem(player, 266)){
if(isDiamondTools(is) && !hasDiamond(player)) if(isDiamondTools(is) && !hasItem(player, 264))
player.sendMessage(ChatColor.DARK_RED+"You need more "+ChatColor.BLUE+ "Diamonds"); player.sendMessage(ChatColor.DARK_RED+"You need more "+ChatColor.BLUE+ "Diamonds");
if(isIronTools(is) && !hasIron(player)) if(isIronTools(is) && !hasItem(player, 265))
player.sendMessage(ChatColor.DARK_RED+"You need more "+ChatColor.GRAY+ "Iron"); player.sendMessage(ChatColor.DARK_RED+"You need more "+ChatColor.GRAY+ "Iron");
//herp if(isGoldTools(is) && !hasItem(player, 266))
if(isGoldTools(is) && !hasGold(player))
player.sendMessage(ChatColor.DARK_RED+"You need more "+ChatColor.GOLD+"Gold"); player.sendMessage(ChatColor.DARK_RED+"You need more "+ChatColor.GOLD+"Gold");
} else if (isDiamondArmor(is) && !hasDiamond(player)){ if(isWoodTools(is) && !hasItem(player, 5))
player.sendMessage(ChatColor.DARK_RED+"You need more "+ChatColor.DARK_GREEN+"Wood");
if(isStoneTools(is) && !hasItem(player, 4))
player.sendMessage(ChatColor.DARK_RED+"You need more "+ChatColor.GRAY+"Stone");
} else if (isDiamondArmor(is) && !hasItem(player, 264)){
player.sendMessage(ChatColor.DARK_RED+"You need more "+ChatColor.BLUE+ "Diamonds"); player.sendMessage(ChatColor.DARK_RED+"You need more "+ChatColor.BLUE+ "Diamonds");
} else if (isIronArmor(is) && !hasIron(player)){ } else if (isIronArmor(is) && !hasItem(player, 265)){
player.sendMessage(ChatColor.DARK_RED+"You need more "+ChatColor.GRAY+ "Iron"); player.sendMessage(ChatColor.DARK_RED+"You need more "+ChatColor.GRAY+ "Iron");
} else if (isGoldArmor(is) && !hasGold(player)){ } else if (isGoldArmor(is) && !hasItem(player, 266)){
player.sendMessage(ChatColor.DARK_RED+"You need more "+ChatColor.GOLD+"Gold"); player.sendMessage(ChatColor.DARK_RED+"You need more "+ChatColor.GOLD+"Gold");
} else if (is.getAmount() > 1) } else if (is.getAmount() > 1)
player.sendMessage(ChatColor.DARK_RED+"You can't repair stacked items"); player.sendMessage(ChatColor.DARK_RED+"You can't repair stacked items");

View File

@ -1,14 +1,8 @@
package com.gmail.nossr50.skills; package com.gmail.nossr50.skills;
import java.io.BufferedReader;
import java.io.FileReader;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.logging.Level;
import java.util.logging.Logger; import java.util.logging.Logger;
import org.bukkit.ChatColor; import org.bukkit.ChatColor;
import org.bukkit.block.Block;
import org.bukkit.entity.Entity; import org.bukkit.entity.Entity;
import org.bukkit.entity.Player; import org.bukkit.entity.Player;
import org.bukkit.inventory.ItemStack; import org.bukkit.inventory.ItemStack;
@ -26,10 +20,7 @@ import com.gmail.nossr50.datatypes.PlayerStat;
public class Skills { public class Skills {
private static mcMMO plugin;
public Skills(mcMMO instance) {
plugin = instance;
}
private static volatile Skills instance; private static volatile Skills instance;
protected static final Logger log = Logger.getLogger("Minecraft"); protected static final Logger log = Logger.getLogger("Minecraft");
@ -359,7 +350,8 @@ public class Skills {
/* /*
* TAMING * TAMING
*/ */
if(player != null && PP.getTamingXPInt() >= PP.getXpToLevel("taming")){ if(player != null){
if(PP.getTamingXPInt() >= PP.getXpToLevel("taming")){
int skillups = 0; int skillups = 0;
while(PP.getTamingXPInt() >= PP.getXpToLevel("taming")){ while(PP.getTamingXPInt() >= PP.getXpToLevel("taming")){
skillups++; skillups++;
@ -370,16 +362,18 @@ public class Skills {
* Leaderboard updating stuff * Leaderboard updating stuff
*/ */
PlayerStat ps = new PlayerStat(); PlayerStat ps = new PlayerStat();
if(!LoadProperties.useMySQL){
ps.statVal = PP.getTamingInt(); ps.statVal = PP.getTamingInt();
ps.name = player.getName(); ps.name = player.getName();
Leaderboard.updateLeaderboard(ps, "taming"); Leaderboard.updateLeaderboard(ps, "taming");
if(player != null && PP.getTaming() != null) }
player.sendMessage(ChatColor.YELLOW+"Taming skill increased by "+skillups+"."+" Total ("+PP.getTaming()+")"); if(player != null && PP != null && PP.getTaming() != null)
player.sendMessage(ChatColor.YELLOW+"Taming skill increased by "+String.valueOf(skillups)+"."+" Total ("+PP.getTaming()+")");
} }
/* /*
* ACROBATICS * ACROBATICS
*/ */
if(player != null && PP.getAcrobaticsXPInt() >= PP.getXpToLevel("acrobatics")){ if(PP.getAcrobaticsXPInt() >= PP.getXpToLevel("acrobatics")){
int skillups = 0; int skillups = 0;
while(PP.getAcrobaticsXPInt() >= PP.getXpToLevel("acrobatics")){ while(PP.getAcrobaticsXPInt() >= PP.getXpToLevel("acrobatics")){
skillups++; skillups++;
@ -389,13 +383,15 @@ public class Skills {
/* /*
* Leaderboard updating stuff * Leaderboard updating stuff
*/ */
if(!LoadProperties.useMySQL){
PlayerStat ps = new PlayerStat(); PlayerStat ps = new PlayerStat();
ps.statVal = PP.getAcrobaticsInt(); ps.statVal = PP.getAcrobaticsInt();
ps.name = player.getName(); ps.name = player.getName();
Leaderboard.updateLeaderboard(ps, "acrobatics"); Leaderboard.updateLeaderboard(ps, "acrobatics");
}
if(player != null && PP.getAcrobatics() != null) if(player != null && PP != null && PP.getAcrobatics() != null)
player.sendMessage(ChatColor.YELLOW+"Acrobatics skill increased by "+skillups+"."+" Total ("+PP.getAcrobatics()+")"); player.sendMessage(ChatColor.YELLOW+"Acrobatics skill increased by "+String.valueOf(skillups)+"."+" Total ("+PP.getAcrobatics()+")");
} }
/* /*
* ARCHERY * ARCHERY
@ -410,13 +406,14 @@ public class Skills {
/* /*
* Leaderboard updating stuff * Leaderboard updating stuff
*/ */
if(!LoadProperties.useMySQL){
PlayerStat ps = new PlayerStat(); PlayerStat ps = new PlayerStat();
ps.statVal = PP.getArcheryInt(); ps.statVal = PP.getArcheryInt();
ps.name = player.getName(); ps.name = player.getName();
Leaderboard.updateLeaderboard(ps, "archery"); Leaderboard.updateLeaderboard(ps, "archery");
}
if(player != null && PP.getArchery() != null) if(player != null && PP != null && PP.getArchery() != null)
player.sendMessage(ChatColor.YELLOW+"Archery skill increased by "+skillups+"."+" Total ("+PP.getArchery()+")"); player.sendMessage(ChatColor.YELLOW+"Archery skill increased by "+String.valueOf(skillups)+"."+" Total ("+PP.getArchery()+")");
} }
/* /*
* SWORDS * SWORDS
@ -431,13 +428,15 @@ public class Skills {
/* /*
* Leaderboard updating stuff * Leaderboard updating stuff
*/ */
if(!LoadProperties.useMySQL){
PlayerStat ps = new PlayerStat(); PlayerStat ps = new PlayerStat();
ps.statVal = PP.getSwordsInt(); ps.statVal = PP.getSwordsInt();
ps.name = player.getName(); ps.name = player.getName();
Leaderboard.updateLeaderboard(ps, "swords"); Leaderboard.updateLeaderboard(ps, "swords");
}
if(player != null && PP.getSwords() != null) if(player != null && PP != null && PP.getSwords() != null)
player.sendMessage(ChatColor.YELLOW+"Swords skill increased by "+skillups+"."+" Total ("+PP.getSwords()+")"); player.sendMessage(ChatColor.YELLOW+"Swords skill increased by "+String.valueOf(skillups)+"."+" Total ("+PP.getSwords()+")");
} }
/* /*
* AXES * AXES
@ -452,13 +451,14 @@ public class Skills {
/* /*
* Leaderboard updating stuff * Leaderboard updating stuff
*/ */
if(!LoadProperties.useMySQL){
PlayerStat ps = new PlayerStat(); PlayerStat ps = new PlayerStat();
ps.statVal = PP.getAxesInt(); ps.statVal = PP.getAxesInt();
ps.name = player.getName(); ps.name = player.getName();
Leaderboard.updateLeaderboard(ps, "axes"); Leaderboard.updateLeaderboard(ps, "axes");
}
if(player != null && PP.getAxes() != null) if(player != null && PP != null && PP.getAxes() != null)
player.sendMessage(ChatColor.YELLOW+"Axes skill increased by "+skillups+"."+" Total ("+PP.getAxes()+")"); player.sendMessage(ChatColor.YELLOW+"Axes skill increased by "+String.valueOf(skillups)+"."+" Total ("+PP.getAxes()+")");
} }
/* /*
* UNARMED * UNARMED
@ -473,13 +473,14 @@ public class Skills {
/* /*
* Leaderboard updating stuff * Leaderboard updating stuff
*/ */
if(!LoadProperties.useMySQL){
PlayerStat ps = new PlayerStat(); PlayerStat ps = new PlayerStat();
ps.statVal = PP.getUnarmedInt(); ps.statVal = PP.getUnarmedInt();
ps.name = player.getName(); ps.name = player.getName();
Leaderboard.updateLeaderboard(ps, "unarmed"); Leaderboard.updateLeaderboard(ps, "unarmed");
}
if(player != null && PP.getUnarmed() != null) if(player != null && PP != null && PP.getUnarmed() != null)
player.sendMessage(ChatColor.YELLOW+"Unarmed skill increased by "+skillups+"."+" Total ("+PP.getUnarmed()+")"); player.sendMessage(ChatColor.YELLOW+"Unarmed skill increased by "+String.valueOf(skillups)+"."+" Total ("+PP.getUnarmed()+")");
} }
/* /*
* HERBALISM * HERBALISM
@ -494,13 +495,14 @@ public class Skills {
/* /*
* Leaderboard updating stuff * Leaderboard updating stuff
*/ */
if(!LoadProperties.useMySQL){
PlayerStat ps = new PlayerStat(); PlayerStat ps = new PlayerStat();
ps.statVal = PP.getHerbalismInt(); ps.statVal = PP.getHerbalismInt();
ps.name = player.getName(); ps.name = player.getName();
Leaderboard.updateLeaderboard(ps, "herbalism"); Leaderboard.updateLeaderboard(ps, "herbalism");
}
if(player != null && PP.getHerbalism() != null) if(player != null && PP != null && PP.getHerbalism() != null)
player.sendMessage(ChatColor.YELLOW+"Herbalism skill increased by "+skillups+"."+" Total ("+PP.getHerbalism()+")"); player.sendMessage(ChatColor.YELLOW+"Herbalism skill increased by "+String.valueOf(skillups)+"."+" Total ("+PP.getHerbalism()+")");
} }
/* /*
* MINING * MINING
@ -515,13 +517,14 @@ public class Skills {
/* /*
* Leaderboard updating stuff * Leaderboard updating stuff
*/ */
if(!LoadProperties.useMySQL){
PlayerStat ps = new PlayerStat(); PlayerStat ps = new PlayerStat();
ps.statVal = PP.getMiningInt(); ps.statVal = PP.getMiningInt();
ps.name = player.getName(); ps.name = player.getName();
Leaderboard.updateLeaderboard(ps, "mining"); Leaderboard.updateLeaderboard(ps, "mining");
}
if(player != null && PP.getMining() != null) if(player != null && PP != null && PP.getMining() != null)
player.sendMessage(ChatColor.YELLOW+"Mining skill increased by "+skillups+"."+" Total ("+PP.getMining()+")"); player.sendMessage(ChatColor.YELLOW+"Mining skill increased by "+String.valueOf(skillups)+"."+" Total ("+PP.getMining()+")");
} }
/* /*
* WOODCUTTING * WOODCUTTING
@ -536,13 +539,14 @@ public class Skills {
/* /*
* Leaderboard updating stuff * Leaderboard updating stuff
*/ */
if(!LoadProperties.useMySQL){
PlayerStat ps = new PlayerStat(); PlayerStat ps = new PlayerStat();
ps.statVal = PP.getWoodCuttingInt(); ps.statVal = PP.getWoodCuttingInt();
ps.name = player.getName(); ps.name = player.getName();
Leaderboard.updateLeaderboard(ps, "woodcutting"); Leaderboard.updateLeaderboard(ps, "woodcutting");
}
if(player != null && PP.getWoodCutting() != null) if(player != null && PP != null && PP.getWoodCutting() != null)
player.sendMessage(ChatColor.YELLOW+"WoodCutting skill increased by "+skillups+"."+" Total ("+PP.getWoodCutting()+")"); player.sendMessage(ChatColor.YELLOW+"WoodCutting skill increased by "+String.valueOf(skillups)+"."+" Total ("+PP.getWoodCutting()+")");
} }
/* /*
* REPAIR * REPAIR
@ -557,13 +561,14 @@ public class Skills {
/* /*
* Leaderboard updating stuff * Leaderboard updating stuff
*/ */
if(!LoadProperties.useMySQL){
PlayerStat ps = new PlayerStat(); PlayerStat ps = new PlayerStat();
ps.statVal = PP.getRepairInt(); ps.statVal = PP.getRepairInt();
ps.name = player.getName(); ps.name = player.getName();
Leaderboard.updateLeaderboard(ps, "repair"); Leaderboard.updateLeaderboard(ps, "repair");
}
if(player != null && PP.getRepair() != null) if(player != null && PP != null && PP.getRepair() != null)
player.sendMessage(ChatColor.YELLOW+"Repair skill increased by "+skillups+"."+" Total ("+PP.getRepair()+")"); player.sendMessage(ChatColor.YELLOW+"Repair skill increased by "+String.valueOf(skillups)+"."+" Total ("+PP.getRepair()+")");
} }
/* /*
* EXCAVATION * EXCAVATION
@ -578,22 +583,26 @@ public class Skills {
/* /*
* Leaderboard updating stuff * Leaderboard updating stuff
*/ */
if(!LoadProperties.useMySQL){
PlayerStat ps = new PlayerStat(); PlayerStat ps = new PlayerStat();
ps.statVal = PP.getExcavationInt(); ps.statVal = PP.getExcavationInt();
ps.name = player.getName(); ps.name = player.getName();
Leaderboard.updateLeaderboard(ps, "excavation"); Leaderboard.updateLeaderboard(ps, "excavation");
}
if(player != null && PP.getExcavation() != null) if(player != null && PP != null && PP.getExcavation() != null)
player.sendMessage(ChatColor.YELLOW+"Excavation skill increased by "+skillups+"."+" Total ("+PP.getExcavation()+")"); player.sendMessage(ChatColor.YELLOW+"Excavation skill increased by "+String.valueOf(skillups)+"."+" Total ("+PP.getExcavation()+")");
}
} }
/* /*
* Leaderboard updating stuff * Leaderboard updating stuff
*/ */
if(!LoadProperties.useMySQL){
PlayerStat ps = new PlayerStat(); PlayerStat ps = new PlayerStat();
ps.statVal = m.getPowerLevel(player); ps.statVal = m.getPowerLevel(player);
ps.name = player.getName(); ps.name = player.getName();
Leaderboard.updateLeaderboard(ps, "powerlevel"); Leaderboard.updateLeaderboard(ps, "powerlevel");
} }
}
public static boolean isSkill(String skillname){ public static boolean isSkill(String skillname){
skillname = skillname.toLowerCase(); skillname = skillname.toLowerCase();
if(skillname.equals("all")){ if(skillname.equals("all")){

View File

@ -1,3 +1,3 @@
name: mcMMO name: mcMMO
main: com.gmail.nossr50.mcMMO main: com.gmail.nossr50.mcMMO
version: 1.0 WIP version: 1.0