2
0
Эх сурвалжийг харах

Made mcremove work for FlatFile (sort of).

nossr50 13 жил өмнө
parent
commit
7aa7de75a2

+ 17 - 1
src/main/java/com/gmail/nossr50/commands/mc/McremoveCommand.java

@@ -73,9 +73,25 @@ public class McremoveCommand implements CommandExecutor {
 
             System.out.println("User "+playerName+" removed from MySQL DB!");
         } else {
-            
+            //FlatFile removal
+            //TODO: Properly remove users from FlatFile, it's going to be a huge bitch with how our FlatFile system works. Let's adopt SQLite support.
+            if(Bukkit.getServer().getPlayer(playerName) != null)
+            {
+                Player targetPlayer = Bukkit.getServer().getPlayer(playerName);
+                if(targetPlayer.isOnline()) 
+                {
+                    Users.getProfile(targetPlayer).resetAllData();
+                } else {
+                    sender.sendMessage("[mcMMO] This command is not fully functional for FlatFile yet, the player needs to be online.");
+                    return true;
+                }
+            } else {
+                sender.sendMessage("[mcMMO] This command is not fully functional for FlatFile yet, the player needs to be online.");
+                return true;
+            }
         }
         
+        //Force PlayerProfile stuff to update
         if(Bukkit.getServer().getPlayer(playerName) != null)
         {
             Player targetPlayer = Bukkit.getServer().getPlayer(playerName);

+ 25 - 0
src/main/java/com/gmail/nossr50/datatypes/PlayerProfile.java

@@ -434,6 +434,31 @@ public class PlayerProfile
 	        }
     	}
 	}
+
+    public void resetAllData()
+    {
+        //This will reset everything to default values and then save the information to FlatFile/MySQL
+        for(SkillType skillType : SkillType.values())
+        {
+            if(skillType == SkillType.ALL)
+                continue;
+            skills.put(skillType, 0);
+            skillsXp.put(skillType, 0);
+        }
+        
+        for(AbilityType abilityType : AbilityType.values())
+        {
+            skillsDATS.put(abilityType, 0);
+        }
+        
+        //Misc stuff
+        myspawn = "";
+        party = "";
+        myspawnworld = "";
+        
+        save();
+    }
+    
     public void addPlayer()
     {
         try {