mirror of
https://github.com/mcMMO-Dev/mcMMO.git
synced 2025-01-19 16:59:37 +01:00
No longer use/save party name in database and users flat file
This commit is contained in:
parent
dfff0efc0b
commit
81eadc1418
@ -70,6 +70,8 @@ public class PlayerProfile {
|
|||||||
this.player = player;
|
this.player = player;
|
||||||
this.playerName = player.getName();
|
this.playerName = player.getName();
|
||||||
|
|
||||||
|
party = PartyManager.getInstance().getPlayerParty(playerName);
|
||||||
|
|
||||||
for (AbilityType abilityType : AbilityType.values()) {
|
for (AbilityType abilityType : AbilityType.values()) {
|
||||||
skillsDATS.put(abilityType, 0);
|
skillsDATS.put(abilityType, 0);
|
||||||
}
|
}
|
||||||
@ -132,15 +134,12 @@ public class PlayerProfile {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
HashMap<Integer, ArrayList<String>> users = mcMMO.database.read("SELECT lastlogin, party FROM " + Config.getInstance().getMySQLTablePrefix() + "users WHERE id = " + userid);
|
|
||||||
//lastlogin = Integer.parseInt(users.get(1).get(0));
|
|
||||||
party = PartyManager.getInstance().getParty(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 = " + userid);
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* I'm still learning MySQL, this is a fix for adding a new table
|
* I'm still learning MySQL, this is a fix for adding a new table
|
||||||
* its not pretty but it works
|
* its not pretty but it works
|
||||||
*/
|
*/
|
||||||
|
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 = " + userid);
|
||||||
|
|
||||||
if(cooldowns.get(1) == null) {
|
if(cooldowns.get(1) == null) {
|
||||||
mcMMO.database.write("INSERT INTO " + Config.getInstance().getMySQLTablePrefix() + "cooldowns (user_id) VALUES (" + userid + ")");
|
mcMMO.database.write("INSERT INTO " + Config.getInstance().getMySQLTablePrefix() + "cooldowns (user_id) VALUES (" + userid + ")");
|
||||||
}
|
}
|
||||||
@ -209,13 +208,8 @@ public class PlayerProfile {
|
|||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
//Get Mining
|
|
||||||
if (character.length > 1 && Misc.isInt(character[1]))
|
if (character.length > 1 && Misc.isInt(character[1]))
|
||||||
skills.put(SkillType.MINING, Integer.valueOf(character[1]));
|
skills.put(SkillType.MINING, Integer.valueOf(character[1]));
|
||||||
//Party
|
|
||||||
if (character.length > 3)
|
|
||||||
party = PartyManager.getInstance().getParty(character[3]);
|
|
||||||
//Mining XP
|
|
||||||
if (character.length > 4 && Misc.isInt(character[4]))
|
if (character.length > 4 && Misc.isInt(character[4]))
|
||||||
skillsXp.put(SkillType.MINING, Integer.valueOf(character[4]));
|
skillsXp.put(SkillType.MINING, Integer.valueOf(character[4]));
|
||||||
if (character.length > 5 && Misc.isInt(character[5]))
|
if (character.length > 5 && Misc.isInt(character[5]))
|
||||||
@ -306,14 +300,6 @@ public class PlayerProfile {
|
|||||||
|
|
||||||
mcMMO.database.write("UPDATE " + Config.getInstance().getMySQLTablePrefix() + "huds SET hudtype = '" + hud.toString() + "' WHERE user_id = " + userid);
|
mcMMO.database.write("UPDATE " + Config.getInstance().getMySQLTablePrefix() + "huds SET hudtype = '" + hud.toString() + "' WHERE user_id = " + userid);
|
||||||
mcMMO.database.write("UPDATE " + Config.getInstance().getMySQLTablePrefix() + "users SET lastlogin = " + timestamp.intValue() + " WHERE id = " + userid);
|
mcMMO.database.write("UPDATE " + Config.getInstance().getMySQLTablePrefix() + "users SET lastlogin = " + timestamp.intValue() + " WHERE id = " + userid);
|
||||||
|
|
||||||
String partyName = "";
|
|
||||||
|
|
||||||
if (party != null) {
|
|
||||||
partyName = party.getName();
|
|
||||||
}
|
|
||||||
|
|
||||||
mcMMO.database.write("UPDATE " + Config.getInstance().getMySQLTablePrefix() + "users SET party = '" + partyName + "' WHERE id = " + userid);
|
|
||||||
mcMMO.database.write("UPDATE " + Config.getInstance().getMySQLTablePrefix() + "cooldowns SET "
|
mcMMO.database.write("UPDATE " + Config.getInstance().getMySQLTablePrefix() + "cooldowns SET "
|
||||||
+ " mining = " + skillsDATS.get(AbilityType.SUPER_BREAKER)
|
+ " mining = " + skillsDATS.get(AbilityType.SUPER_BREAKER)
|
||||||
+ ", woodcutting = " + skillsDATS.get(AbilityType.TREE_FELLER)
|
+ ", woodcutting = " + skillsDATS.get(AbilityType.TREE_FELLER)
|
||||||
@ -374,14 +360,7 @@ public class PlayerProfile {
|
|||||||
writer.append(playerName + ":");
|
writer.append(playerName + ":");
|
||||||
writer.append(skills.get(SkillType.MINING) + ":");
|
writer.append(skills.get(SkillType.MINING) + ":");
|
||||||
writer.append("" + ":");
|
writer.append("" + ":");
|
||||||
|
writer.append("" + ":");
|
||||||
String partyName = "";
|
|
||||||
|
|
||||||
if (party != null) {
|
|
||||||
partyName = party.getName();
|
|
||||||
}
|
|
||||||
|
|
||||||
writer.append(partyName + ":");
|
|
||||||
writer.append(skillsXp.get(SkillType.MINING) + ":");
|
writer.append(skillsXp.get(SkillType.MINING) + ":");
|
||||||
writer.append(skills.get(SkillType.WOODCUTTING) + ":");
|
writer.append(skills.get(SkillType.WOODCUTTING) + ":");
|
||||||
writer.append(skillsXp.get(SkillType.WOODCUTTING) + ":");
|
writer.append(skillsXp.get(SkillType.WOODCUTTING) + ":");
|
||||||
@ -443,14 +422,7 @@ public class PlayerProfile {
|
|||||||
out.append(playerName + ":");
|
out.append(playerName + ":");
|
||||||
out.append(0 + ":"); //mining
|
out.append(0 + ":"); //mining
|
||||||
out.append("" + ":");
|
out.append("" + ":");
|
||||||
|
out.append("" + ":");
|
||||||
String partyName = "";
|
|
||||||
|
|
||||||
if (party != null) {
|
|
||||||
partyName = party.getName();
|
|
||||||
}
|
|
||||||
|
|
||||||
out.append(partyName + ":");
|
|
||||||
out.append(0 + ":"); //XP
|
out.append(0 + ":"); //XP
|
||||||
out.append(0 + ":"); //woodcutting
|
out.append(0 + ":"); //woodcutting
|
||||||
out.append(0 + ":"); //woodCuttingXP
|
out.append(0 + ":"); //woodCuttingXP
|
||||||
|
@ -166,6 +166,22 @@ public class PartyManager {
|
|||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Retrieve a party by a member name
|
||||||
|
*
|
||||||
|
* @param playerName The member name
|
||||||
|
* @return the existing party, null otherwise
|
||||||
|
*/
|
||||||
|
public Party getPlayerParty(String playerName) {
|
||||||
|
for (Party party : parties) {
|
||||||
|
if (party.getMembers().contains(playerName)) {
|
||||||
|
return party;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Get a list of all current party names.
|
* Get a list of all current party names.
|
||||||
*
|
*
|
||||||
|
@ -69,7 +69,6 @@ public class Database {
|
|||||||
write("CREATE TABLE IF NOT EXISTS `" + tablePrefix + "users` (`id` int(10) unsigned NOT NULL AUTO_INCREMENT,"
|
write("CREATE TABLE IF NOT EXISTS `" + tablePrefix + "users` (`id` int(10) unsigned NOT NULL AUTO_INCREMENT,"
|
||||||
+ "`user` varchar(40) NOT NULL,"
|
+ "`user` varchar(40) NOT NULL,"
|
||||||
+ "`lastlogin` int(32) unsigned NOT NULL,"
|
+ "`lastlogin` int(32) unsigned NOT NULL,"
|
||||||
+ "`party` varchar(100) NOT NULL DEFAULT '',"
|
|
||||||
+ "PRIMARY KEY (`id`),"
|
+ "PRIMARY KEY (`id`),"
|
||||||
+ "UNIQUE KEY `user` (`user`)) ENGINE=MyISAM DEFAULT CHARSET=latin1 AUTO_INCREMENT=1;");
|
+ "UNIQUE KEY `user` (`user`)) ENGINE=MyISAM DEFAULT CHARSET=latin1 AUTO_INCREMENT=1;");
|
||||||
write("CREATE TABLE IF NOT EXISTS `" + tablePrefix + "cooldowns` (`user_id` int(10) unsigned NOT NULL,"
|
write("CREATE TABLE IF NOT EXISTS `" + tablePrefix + "cooldowns` (`user_id` int(10) unsigned NOT NULL,"
|
||||||
|
@ -90,7 +90,7 @@ public class Users {
|
|||||||
*/
|
*/
|
||||||
public static void removeUser(String playerName) {
|
public static void removeUser(String playerName) {
|
||||||
for (Iterator<PlayerProfile> it = profiles.iterator() ; it.hasNext() ; ) {
|
for (Iterator<PlayerProfile> it = profiles.iterator() ; it.hasNext() ; ) {
|
||||||
if (it.next().getPlayer().getName().equals(playerName)) {
|
if (it.next().getPlayerName().equals(playerName)) {
|
||||||
it.remove();
|
it.remove();
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user