|
@@ -11,7 +11,7 @@ import org.bukkit.GameMode;
|
|
|
import org.bukkit.entity.Player;
|
|
|
import org.bukkit.inventory.ItemStack;
|
|
|
|
|
|
-import com.gmail.nossr50.mcMMO;
|
|
|
+import com.gmail.nossr50.McMMO;
|
|
|
import com.gmail.nossr50.config.Config;
|
|
|
import com.gmail.nossr50.config.SpoutConfig;
|
|
|
import com.gmail.nossr50.datatypes.mods.CustomTool;
|
|
@@ -62,7 +62,7 @@ public class PlayerProfile {
|
|
|
|
|
|
private Player player;
|
|
|
private String playerName;
|
|
|
- private final static String location = mcMMO.usersFile;
|
|
|
+ private final static String location = McMMO.usersFile;
|
|
|
|
|
|
public PlayerProfile(Player player, boolean addNew) {
|
|
|
hud = SpoutConfig.getInstance().defaulthud;
|
|
@@ -100,15 +100,15 @@ public class PlayerProfile {
|
|
|
|
|
|
public boolean loadMySQL() {
|
|
|
int id = 0;
|
|
|
- id = mcMMO.database.getInt("SELECT id FROM "+Config.getInstance().getMySQLTablePrefix()+"users WHERE user = '" + playerName + "'");
|
|
|
+ id = McMMO.database.getInt("SELECT id FROM "+Config.getInstance().getMySQLTablePrefix()+"users WHERE user = '" + playerName + "'");
|
|
|
|
|
|
this.userid = id;
|
|
|
|
|
|
if (id > 0) {
|
|
|
- HashMap<Integer, ArrayList<String>> huds = mcMMO.database.read("SELECT hudtype FROM "+Config.getInstance().getMySQLTablePrefix()+"huds WHERE user_id = " + id);
|
|
|
+ HashMap<Integer, ArrayList<String>> huds = McMMO.database.read("SELECT hudtype FROM "+Config.getInstance().getMySQLTablePrefix()+"huds WHERE user_id = " + id);
|
|
|
if(huds.get(1) == null)
|
|
|
{
|
|
|
- mcMMO.database.write("INSERT INTO "+Config.getInstance().getMySQLTablePrefix()+"huds (user_id) VALUES ("+id+")");
|
|
|
+ McMMO.database.write("INSERT INTO "+Config.getInstance().getMySQLTablePrefix()+"huds (user_id) VALUES ("+id+")");
|
|
|
} else {
|
|
|
if(huds.get(1).get(0) != null)
|
|
|
{
|
|
@@ -123,17 +123,17 @@ public class PlayerProfile {
|
|
|
hud = SpoutConfig.getInstance().defaulthud;
|
|
|
}
|
|
|
}
|
|
|
- HashMap<Integer, ArrayList<String>> users = mcMMO.database.read("SELECT lastlogin, party FROM "+Config.getInstance().getMySQLTablePrefix()+"users WHERE id = " + id);
|
|
|
+ HashMap<Integer, ArrayList<String>> users = McMMO.database.read("SELECT lastlogin, party FROM "+Config.getInstance().getMySQLTablePrefix()+"users WHERE id = " + id);
|
|
|
//lastlogin = Integer.parseInt(users.get(1).get(0));
|
|
|
party = users.get(1).get(1);
|
|
|
- HashMap<Integer, ArrayList<String>> cooldowns = mcMMO.database.read("SELECT mining, woodcutting, unarmed, herbalism, excavation, swords, axes, blast_mining FROM "+Config.getInstance().getMySQLTablePrefix()+"cooldowns WHERE user_id = " + id);
|
|
|
+ HashMap<Integer, ArrayList<String>> cooldowns = McMMO.database.read("SELECT mining, woodcutting, unarmed, herbalism, excavation, swords, axes, blast_mining FROM "+Config.getInstance().getMySQLTablePrefix()+"cooldowns WHERE user_id = " + id);
|
|
|
/*
|
|
|
* I'm still learning MySQL, this is a fix for adding a new table
|
|
|
* its not pretty but it works
|
|
|
*/
|
|
|
if(cooldowns.get(1) == null)
|
|
|
{
|
|
|
- mcMMO.database.write("INSERT INTO "+Config.getInstance().getMySQLTablePrefix()+"cooldowns (user_id) VALUES ("+id+")");
|
|
|
+ McMMO.database.write("INSERT INTO "+Config.getInstance().getMySQLTablePrefix()+"cooldowns (user_id) VALUES ("+id+")");
|
|
|
}
|
|
|
else
|
|
|
{
|
|
@@ -146,7 +146,7 @@ public class PlayerProfile {
|
|
|
skillsDATS.put(AbilityType.SKULL_SPLIITER, Integer.valueOf(cooldowns.get(1).get(6)));
|
|
|
skillsDATS.put(AbilityType.BLAST_MINING, Integer.valueOf(cooldowns.get(1).get(7)));
|
|
|
}
|
|
|
- HashMap<Integer, ArrayList<String>> stats = mcMMO.database.read("SELECT taming, mining, repair, woodcutting, unarmed, herbalism, excavation, archery, swords, axes, acrobatics, fishing FROM "+Config.getInstance().getMySQLTablePrefix()+"skills WHERE user_id = " + id);
|
|
|
+ HashMap<Integer, ArrayList<String>> stats = McMMO.database.read("SELECT taming, mining, repair, woodcutting, unarmed, herbalism, excavation, archery, swords, axes, acrobatics, fishing FROM "+Config.getInstance().getMySQLTablePrefix()+"skills WHERE user_id = " + id);
|
|
|
skills.put(SkillType.TAMING, Integer.valueOf(stats.get(1).get(0)));
|
|
|
skills.put(SkillType.MINING, Integer.valueOf(stats.get(1).get(1)));
|
|
|
skills.put(SkillType.REPAIR, Integer.valueOf(stats.get(1).get(2)));
|
|
@@ -159,7 +159,7 @@ public class PlayerProfile {
|
|
|
skills.put(SkillType.AXES, Integer.valueOf(stats.get(1).get(9)));
|
|
|
skills.put(SkillType.ACROBATICS, Integer.valueOf(stats.get(1).get(10)));
|
|
|
skills.put(SkillType.FISHING, Integer.valueOf(stats.get(1).get(11)));
|
|
|
- HashMap<Integer, ArrayList<String>> experience = mcMMO.database.read("SELECT taming, mining, repair, woodcutting, unarmed, herbalism, excavation, archery, swords, axes, acrobatics, fishing FROM "+Config.getInstance().getMySQLTablePrefix()+"experience WHERE user_id = " + id);
|
|
|
+ HashMap<Integer, ArrayList<String>> experience = McMMO.database.read("SELECT taming, mining, repair, woodcutting, unarmed, herbalism, excavation, archery, swords, axes, acrobatics, fishing FROM "+Config.getInstance().getMySQLTablePrefix()+"experience WHERE user_id = " + id);
|
|
|
skillsXp.put(SkillType.TAMING, Integer.valueOf(experience.get(1).get(0)));
|
|
|
skillsXp.put(SkillType.MINING, Integer.valueOf(experience.get(1).get(1)));
|
|
|
skillsXp.put(SkillType.REPAIR, Integer.valueOf(experience.get(1).get(2)));
|
|
@@ -182,11 +182,11 @@ public class PlayerProfile {
|
|
|
|
|
|
public void addMySQLPlayer() {
|
|
|
int id = 0;
|
|
|
- mcMMO.database.write("INSERT INTO "+Config.getInstance().getMySQLTablePrefix()+"users (user, lastlogin) VALUES ('" + playerName + "'," + System.currentTimeMillis() / 1000 +")");
|
|
|
- id = mcMMO.database.getInt("SELECT id FROM "+Config.getInstance().getMySQLTablePrefix()+"users WHERE user = '" + playerName + "'");
|
|
|
- mcMMO.database.write("INSERT INTO "+Config.getInstance().getMySQLTablePrefix()+"cooldowns (user_id) VALUES ("+id+")");
|
|
|
- mcMMO.database.write("INSERT INTO "+Config.getInstance().getMySQLTablePrefix()+"skills (user_id) VALUES ("+id+")");
|
|
|
- mcMMO.database.write("INSERT INTO "+Config.getInstance().getMySQLTablePrefix()+"experience (user_id) VALUES ("+id+")");
|
|
|
+ McMMO.database.write("INSERT INTO "+Config.getInstance().getMySQLTablePrefix()+"users (user, lastlogin) VALUES ('" + playerName + "'," + System.currentTimeMillis() / 1000 +")");
|
|
|
+ id = McMMO.database.getInt("SELECT id FROM "+Config.getInstance().getMySQLTablePrefix()+"users WHERE user = '" + playerName + "'");
|
|
|
+ McMMO.database.write("INSERT INTO "+Config.getInstance().getMySQLTablePrefix()+"cooldowns (user_id) VALUES ("+id+")");
|
|
|
+ McMMO.database.write("INSERT INTO "+Config.getInstance().getMySQLTablePrefix()+"skills (user_id) VALUES ("+id+")");
|
|
|
+ McMMO.database.write("INSERT INTO "+Config.getInstance().getMySQLTablePrefix()+"experience (user_id) VALUES ("+id+")");
|
|
|
this.userid = id;
|
|
|
}
|
|
|
|
|
@@ -289,7 +289,7 @@ public class PlayerProfile {
|
|
|
}
|
|
|
in.close();
|
|
|
} catch (Exception e) {
|
|
|
- mcMMO.p.getLogger().severe("Exception while reading " + location + " (Are you sure you formatted it correctly?)" + e.toString());
|
|
|
+ McMMO.p.getLogger().severe("Exception while reading " + location + " (Are you sure you formatted it correctly?)" + e.toString());
|
|
|
}
|
|
|
return false;
|
|
|
}
|
|
@@ -299,10 +299,10 @@ public class PlayerProfile {
|
|
|
// if we are using mysql save to database
|
|
|
if (Config.getInstance().getUseMySQL()) {
|
|
|
|
|
|
- mcMMO.database.write("UPDATE "+Config.getInstance().getMySQLTablePrefix()+"huds SET hudtype = '"+hud.toString()+"' WHERE user_id = "+this.userid);
|
|
|
- mcMMO.database.write("UPDATE "+Config.getInstance().getMySQLTablePrefix()+"users SET lastlogin = " + timestamp.intValue() + " WHERE id = " + this.userid);
|
|
|
- mcMMO.database.write("UPDATE "+Config.getInstance().getMySQLTablePrefix()+"users SET party = '"+this.party+"' WHERE id = " +this.userid);
|
|
|
- mcMMO.database.write("UPDATE "+Config.getInstance().getMySQLTablePrefix()+"cooldowns SET "
|
|
|
+ McMMO.database.write("UPDATE "+Config.getInstance().getMySQLTablePrefix()+"huds SET hudtype = '"+hud.toString()+"' WHERE user_id = "+this.userid);
|
|
|
+ McMMO.database.write("UPDATE "+Config.getInstance().getMySQLTablePrefix()+"users SET lastlogin = " + timestamp.intValue() + " WHERE id = " + this.userid);
|
|
|
+ McMMO.database.write("UPDATE "+Config.getInstance().getMySQLTablePrefix()+"users SET party = '"+this.party+"' WHERE id = " +this.userid);
|
|
|
+ McMMO.database.write("UPDATE "+Config.getInstance().getMySQLTablePrefix()+"cooldowns SET "
|
|
|
+" mining = " + skillsDATS.get(AbilityType.SUPER_BREAKER)
|
|
|
+", woodcutting = " + skillsDATS.get(AbilityType.TREE_FELLER)
|
|
|
+", unarmed = " + skillsDATS.get(AbilityType.BERSERK)
|
|
@@ -312,7 +312,7 @@ public class PlayerProfile {
|
|
|
+", axes = " + skillsDATS.get(AbilityType.SKULL_SPLIITER)
|
|
|
+", blast_mining = " + skillsDATS.get(AbilityType.BLAST_MINING)
|
|
|
+" WHERE user_id = "+this.userid);
|
|
|
- mcMMO.database.write("UPDATE "+Config.getInstance().getMySQLTablePrefix()+"skills SET "
|
|
|
+ McMMO.database.write("UPDATE "+Config.getInstance().getMySQLTablePrefix()+"skills SET "
|
|
|
+" taming = "+skills.get(SkillType.TAMING)
|
|
|
+", mining = "+skills.get(SkillType.MINING)
|
|
|
+", repair = "+skills.get(SkillType.REPAIR)
|
|
@@ -326,7 +326,7 @@ public class PlayerProfile {
|
|
|
+", acrobatics = "+skills.get(SkillType.ACROBATICS)
|
|
|
+", fishing = "+skills.get(SkillType.FISHING)
|
|
|
+" WHERE user_id = "+this.userid);
|
|
|
- mcMMO.database.write("UPDATE "+Config.getInstance().getMySQLTablePrefix()+"experience SET "
|
|
|
+ McMMO.database.write("UPDATE "+Config.getInstance().getMySQLTablePrefix()+"experience SET "
|
|
|
+" taming = "+skillsXp.get(SkillType.TAMING)
|
|
|
+", mining = "+skillsXp.get(SkillType.MINING)
|
|
|
+", repair = "+skillsXp.get(SkillType.REPAIR)
|
|
@@ -409,7 +409,7 @@ public class PlayerProfile {
|
|
|
out.close();
|
|
|
}
|
|
|
catch (Exception e) {
|
|
|
- mcMMO.p.getLogger().severe("Exception while writing to " + location + " (Are you sure you formatted it correctly?)" + e.toString());
|
|
|
+ McMMO.p.getLogger().severe("Exception while writing to " + location + " (Are you sure you formatted it correctly?)" + e.toString());
|
|
|
}
|
|
|
}
|
|
|
}
|
|
@@ -484,7 +484,7 @@ public class PlayerProfile {
|
|
|
out.newLine();
|
|
|
out.close();
|
|
|
} catch (Exception e) {
|
|
|
- mcMMO.p.getLogger().severe("Exception while writing to " + location + " (Are you sure you formatted it correctly?)" + e.toString());
|
|
|
+ McMMO.p.getLogger().severe("Exception while writing to " + location + " (Are you sure you formatted it correctly?)" + e.toString());
|
|
|
}
|
|
|
}
|
|
|
|
|
@@ -976,12 +976,12 @@ public class PlayerProfile {
|
|
|
continue;
|
|
|
}
|
|
|
|
|
|
- mcMMO.p.getServer().getPluginManager().callEvent(new McMMOPlayerXpGainEvent(player, x, newValue));
|
|
|
+ McMMO.p.getServer().getPluginManager().callEvent(new McMMOPlayerXpGainEvent(player, x, newValue));
|
|
|
skillsXp.put(x, skillsXp.get(x) + newValue);
|
|
|
}
|
|
|
}
|
|
|
else {
|
|
|
- mcMMO.p.getServer().getPluginManager().callEvent(new McMMOPlayerXpGainEvent(player, skillType, newValue));
|
|
|
+ McMMO.p.getServer().getPluginManager().callEvent(new McMMOPlayerXpGainEvent(player, skillType, newValue));
|
|
|
skillsXp.put(skillType, skillsXp.get(skillType) + newValue);
|
|
|
lastgained = skillType;
|
|
|
}
|
|
@@ -1046,7 +1046,7 @@ public class PlayerProfile {
|
|
|
xp = xp * 2;
|
|
|
}
|
|
|
|
|
|
- mcMMO.p.getServer().getPluginManager().callEvent(new McMMOPlayerXpGainEvent(player, skillType, xp));
|
|
|
+ McMMO.p.getServer().getPluginManager().callEvent(new McMMOPlayerXpGainEvent(player, skillType, xp));
|
|
|
skillsXp.put(skillType, skillsXp.get(skillType) + xp);
|
|
|
lastgained = skillType;
|
|
|
}
|