[Closed]Problem mit MongoDB

Wenn ihr bei eurem Plugin nicht weiter kommt, könnt ihr hier euer Problem beschreiben und um Hilfe bitten.

[Closed]Problem mit MongoDB

Beitragvon Letsplaybar » Mo 25. Jul 2016, 10:18

hallo ich schreibe grade mein altes nickplugin um und verwende nun um dieses plugin über mehrere Server zu syncronisieren dafür MongoDB nun hab ich nach mehrfachen probieren festsellen müssen das er mir andere werte wiedergibt als ich gesetzt habe.
die Methoden hab ich aus einem Tutorial von Shortbyte zu teil und bei ihm funktionniert alles.
Hier der Log woran man das sieht:
Code: Alles auswählen
  1. [11:10:35] [Server thread/INFO]: Starting minecraft server version 1.8.8
  2. [11:10:35] [Server thread/INFO]: Loading properties
  3. [11:10:35] [Server thread/INFO]: Default game type: SURVIVAL
  4. [11:10:35] [Server thread/INFO]: This server is running CraftBukkit version git-Spigot-db6de12-18fbb24 (MC: 1.8.8) (Implementing API version 1.8.8-R0.1-SNAPSHOT)
  5. [11:10:35] [Server thread/INFO]: Debug logging is disabled
  6. [11:10:35] [Server thread/INFO]: Using 4 threads for Netty based IO
  7. [11:10:35] [Server thread/INFO]: Server Ping Player Sample Count: 12
  8. [11:10:35] [Server thread/INFO]: Generating keypair
  9. [11:10:36] [Server thread/INFO]: Starting Minecraft server on *:25566
  10. [11:10:36] [Server thread/INFO]: Using default channel type
  11. [11:10:36] [Server thread/INFO]: Set PluginClassLoader as parallel capable
  12. [11:10:36] [Server thread/INFO]: [PermissionsEx] Loading PermissionsEx v1.23.4
  13. [11:10:36] [Server thread/INFO]: [ViaVersion] Loading ViaVersion v0.6.5
  14. [11:10:36] [Server thread/INFO]: [Permissions] Loading Permissions v1.0
  15. [11:10:36] [Server thread/INFO]: [Nickname] Loading Nickname v1.0
  16. [11:10:36] [Server thread/INFO]: [ViaVersion] Enabling ViaVersion v0.6.5
  17. [11:10:36] [Server thread/INFO]: [ViaVersion] ViaVersion 0.6.5 is now enabled, injecting. (Allows 1.8 to be accessed via 1.9)
  18. [11:10:36] [Server thread/INFO]: **** Beginning UUID conversion, this may take A LONG time ****
  19. [11:10:36] [Server thread/INFO]: Preparing level "world"
  20. [11:10:36] [Server thread/INFO]: -------- World Settings For [world] --------
  21. [11:10:36] [Server thread/INFO]: Chunks to Grow per Tick: 650
  22. [11:10:36] [Server thread/INFO]: Clear tick list: false
  23. [11:10:36] [Server thread/INFO]: Experience Merge Radius: 3.0
  24. [11:10:36] [Server thread/INFO]: Allow Zombie Pigmen to spawn from portal blocks: true
  25. [11:10:36] [Server thread/INFO]: Anti X-Ray: true
  26. [11:10:36] [Server thread/INFO]:    Engine Mode: 1
  27. [11:10:36] [Server thread/INFO]:    Hidden Blocks: [14, 15, 16, 21, 48, 49, 54, 56, 73, 74, 82, 129, 130]
  28. [11:10:36] [Server thread/INFO]:    Replace Blocks: [1, 5]
  29. [11:10:36] [Server thread/INFO]: Hopper Transfer: 8 Hopper Check: 8 Hopper Amount: 1
  30. [11:10:36] [Server thread/INFO]: Nerfing mobs spawned from spawners: false
  31. [11:10:36] [Server thread/INFO]: Random Lighting Updates: false
  32. [11:10:36] [Server thread/INFO]: Structure Info Saving: true
  33. [11:10:36] [Server thread/INFO]: Entity Activation Range: An 32 / Mo 32 / Mi 16
  34. [11:10:36] [Server thread/INFO]: Entity Tracking Range: Pl 48 / An 48 / Mo 48 / Mi 32 / Other 64
  35. [11:10:36] [Server thread/INFO]: Sending up to 10 chunks per packet
  36. [11:10:36] [Server thread/INFO]: Mob Spawn Range: 4
  37. [11:10:36] [Server thread/INFO]: Cactus Growth Modifier: 100%
  38. [11:10:36] [Server thread/INFO]: Cane Growth Modifier: 100%
  39. [11:10:36] [Server thread/INFO]: Melon Growth Modifier: 100%
  40. [11:10:36] [Server thread/INFO]: Mushroom Growth Modifier: 100%
  41. [11:10:36] [Server thread/INFO]: Pumpkin Growth Modifier: 100%
  42. [11:10:36] [Server thread/INFO]: Sapling Growth Modifier: 100%
  43. [11:10:36] [Server thread/INFO]: Wheat Growth Modifier: 100%
  44. [11:10:36] [Server thread/INFO]: NetherWart Growth Modifier: 100%
  45. [11:10:36] [Server thread/INFO]: Tile Max Tick Time: 50ms Entity max Tick Time: 50ms
  46. [11:10:36] [Server thread/INFO]: Max TNT Explosions: 100
  47. [11:10:36] [Server thread/INFO]: Item Merge Radius: 2.5
  48. [11:10:36] [Server thread/INFO]: Item Despawn Rate: 6000
  49. [11:10:36] [Server thread/INFO]: View Distance: 10
  50. [11:10:36] [Server thread/INFO]: Arrow Despawn Rate: 1200
  51. [11:10:36] [Server thread/INFO]: Zombie Aggressive Towards Villager: true
  52. [11:10:36] [Server thread/INFO]: Max Entity Collisions: 8
  53. [11:10:36] [Server thread/INFO]: Custom Map Seeds:  Village: 10387312 Feature: 14357617
  54. [11:10:36] [Server thread/INFO]: -------- World Settings For [world_nether] --------
  55. [11:10:36] [Server thread/INFO]: Chunks to Grow per Tick: 650
  56. [11:10:36] [Server thread/INFO]: Clear tick list: false
  57. [11:10:36] [Server thread/INFO]: Experience Merge Radius: 3.0
  58. [11:10:36] [Server thread/INFO]: Allow Zombie Pigmen to spawn from portal blocks: true
  59. [11:10:36] [Server thread/INFO]: Anti X-Ray: true
  60. [11:10:36] [Server thread/INFO]:    Engine Mode: 1
  61. [11:10:36] [Server thread/INFO]:    Hidden Blocks: [14, 15, 16, 21, 48, 49, 54, 56, 73, 74, 82, 129, 130]
  62. [11:10:36] [Server thread/INFO]:    Replace Blocks: [1, 5]
  63. [11:10:36] [Server thread/INFO]: Hopper Transfer: 8 Hopper Check: 8 Hopper Amount: 1
  64. [11:10:36] [Server thread/INFO]: Nerfing mobs spawned from spawners: false
  65. [11:10:36] [Server thread/INFO]: Random Lighting Updates: false
  66. [11:10:36] [Server thread/INFO]: Structure Info Saving: true
  67. [11:10:36] [Server thread/INFO]: Entity Activation Range: An 32 / Mo 32 / Mi 16
  68. [11:10:36] [Server thread/INFO]: Entity Tracking Range: Pl 48 / An 48 / Mo 48 / Mi 32 / Other 64
  69. [11:10:36] [Server thread/INFO]: Sending up to 10 chunks per packet
  70. [11:10:36] [Server thread/INFO]: Mob Spawn Range: 4
  71. [11:10:36] [Server thread/INFO]: Cactus Growth Modifier: 100%
  72. [11:10:36] [Server thread/INFO]: Cane Growth Modifier: 100%
  73. [11:10:36] [Server thread/INFO]: Melon Growth Modifier: 100%
  74. [11:10:36] [Server thread/INFO]: Mushroom Growth Modifier: 100%
  75. [11:10:36] [Server thread/INFO]: Pumpkin Growth Modifier: 100%
  76. [11:10:36] [Server thread/INFO]: Sapling Growth Modifier: 100%
  77. [11:10:36] [Server thread/INFO]: Wheat Growth Modifier: 100%
  78. [11:10:36] [Server thread/INFO]: NetherWart Growth Modifier: 100%
  79. [11:10:36] [Server thread/INFO]: Tile Max Tick Time: 50ms Entity max Tick Time: 50ms
  80. [11:10:36] [Server thread/INFO]: Max TNT Explosions: 100
  81. [11:10:36] [Server thread/INFO]: Item Merge Radius: 2.5
  82. [11:10:36] [Server thread/INFO]: Item Despawn Rate: 6000
  83. [11:10:36] [Server thread/INFO]: View Distance: 10
  84. [11:10:36] [Server thread/INFO]: Arrow Despawn Rate: 1200
  85. [11:10:36] [Server thread/INFO]: Zombie Aggressive Towards Villager: true
  86. [11:10:36] [Server thread/INFO]: Max Entity Collisions: 8
  87. [11:10:36] [Server thread/INFO]: Custom Map Seeds:  Village: 10387312 Feature: 14357617
  88. [11:10:36] [Server thread/INFO]: -------- World Settings For [world_the_end] --------
  89. [11:10:36] [Server thread/INFO]: Chunks to Grow per Tick: 650
  90. [11:10:36] [Server thread/INFO]: Clear tick list: false
  91. [11:10:36] [Server thread/INFO]: Experience Merge Radius: 3.0
  92. [11:10:36] [Server thread/INFO]: Allow Zombie Pigmen to spawn from portal blocks: true
  93. [11:10:36] [Server thread/INFO]: Anti X-Ray: true
  94. [11:10:36] [Server thread/INFO]:    Engine Mode: 1
  95. [11:10:36] [Server thread/INFO]:    Hidden Blocks: [14, 15, 16, 21, 48, 49, 54, 56, 73, 74, 82, 129, 130]
  96. [11:10:36] [Server thread/INFO]:    Replace Blocks: [1, 5]
  97. [11:10:36] [Server thread/INFO]: Hopper Transfer: 8 Hopper Check: 8 Hopper Amount: 1
  98. [11:10:36] [Server thread/INFO]: Nerfing mobs spawned from spawners: false
  99. [11:10:36] [Server thread/INFO]: Random Lighting Updates: false
  100. [11:10:36] [Server thread/INFO]: Structure Info Saving: true
  101. [11:10:36] [Server thread/INFO]: Entity Activation Range: An 32 / Mo 32 / Mi 16
  102. [11:10:36] [Server thread/INFO]: Entity Tracking Range: Pl 48 / An 48 / Mo 48 / Mi 32 / Other 64
  103. [11:10:36] [Server thread/INFO]: Sending up to 10 chunks per packet
  104. [11:10:36] [Server thread/INFO]: Mob Spawn Range: 4
  105. [11:10:36] [Server thread/INFO]: Cactus Growth Modifier: 100%
  106. [11:10:36] [Server thread/INFO]: Cane Growth Modifier: 100%
  107. [11:10:36] [Server thread/INFO]: Melon Growth Modifier: 100%
  108. [11:10:36] [Server thread/INFO]: Mushroom Growth Modifier: 100%
  109. [11:10:36] [Server thread/INFO]: Pumpkin Growth Modifier: 100%
  110. [11:10:36] [Server thread/INFO]: Sapling Growth Modifier: 100%
  111. [11:10:36] [Server thread/INFO]: Wheat Growth Modifier: 100%
  112. [11:10:36] [Server thread/INFO]: NetherWart Growth Modifier: 100%
  113. [11:10:36] [Server thread/INFO]: Tile Max Tick Time: 50ms Entity max Tick Time: 50ms
  114. [11:10:36] [Server thread/INFO]: Max TNT Explosions: 100
  115. [11:10:36] [Server thread/INFO]: Item Merge Radius: 2.5
  116. [11:10:36] [Server thread/INFO]: Item Despawn Rate: 6000
  117. [11:10:36] [Server thread/INFO]: View Distance: 10
  118. [11:10:36] [Server thread/INFO]: Arrow Despawn Rate: 1200
  119. [11:10:36] [Server thread/INFO]: Zombie Aggressive Towards Villager: true
  120. [11:10:36] [Server thread/INFO]: Max Entity Collisions: 8
  121. [11:10:36] [Server thread/INFO]: Custom Map Seeds:  Village: 10387312 Feature: 14357617
  122. [11:10:36] [Server thread/INFO]: Preparing start region for level 0 (Seed: -9064176738448255025)
  123. [11:10:37] [Server thread/INFO]: Preparing spawn area: 74%
  124. [11:10:37] [Server thread/INFO]: Preparing start region for level 1 (Seed: -9064176738448255025)
  125. [11:10:38] [Server thread/INFO]: Preparing start region for level 2 (Seed: -9064176738448255025)
  126. [11:10:39] [Server thread/INFO]: [PermissionsEx] Enabling PermissionsEx v1.23.4
  127. [11:10:39] [Server thread/INFO]: [PermissionsEx] Initializing file backend
  128. [11:10:39] [Server thread/INFO]: [PermissionsEx] Permissions file successfully reloaded
  129. [11:10:39] [Server thread/INFO]: [Permissions] Enabling Permissions v1.0
  130. [11:10:39] [Server thread/INFO]: [Nickname] Enabling Nickname v1.0
  131. [11:10:39] [Server thread/INFO]: [Nickname] Dieses Plugin ist Nicht für Kommerziale Zwecke Zugebrauchen
  132. [11:10:39] [Server thread/INFO]: [Nickname] Developer ist Letsplaybar
  133. [11:10:39] [Server thread/INFO]: Cluster created with settings {hosts=[localhost:27017], mode=SINGLE, requiredClusterType=UNKNOWN, serverSelectionTimeout='30000 ms', maxWaitQueueSize=500}
  134. [11:10:39] [Server thread/INFO]: [Nickname] Plugin ist Fehlerfrei gestartet
  135. [11:10:39] [Server thread/INFO]: Server permissions file permissions.yml is empty, ignoring it
  136. [11:10:39] [cluster-ClusterId{value='5795d78f8a31e23a10948d66', description='null'}-localhost:27017/INFO]: Opened connection [connectionId{localValue:1, serverValue:27}] to localhost:27017
  137. [11:10:39] [cluster-ClusterId{value='5795d78f8a31e23a10948d66', description='null'}-localhost:27017/INFO]: Monitor thread successfully connected to server with description ServerDescription{address=localhost:27017, type=STANDALONE, state=CONNECTED, ok=true, version=ServerVersion{versionList=[3, 2, 8]}, minWireVersion=0, maxWireVersion=4, maxDocumentSize=16777216, roundTripTimeNanos=1027191}
  138. [11:10:39] [Server thread/INFO]: Done (2,834s)! For help, type "help" or "?"
  139. [11:10:39] [Server thread/WARN]: [ViaVersion] There is a newer version available: 0.9.7
  140. [11:10:41] [Thread-8/WARN]: [PermissionsEx] The updater could not find any files for the project id 31279
  141. [11:10:49] [User Authenticator #1/INFO]: UUID of player Letsplaybar is 7524632d-021e-4ef7-88c8-4588447b66bd
  142. [11:10:49] [Server thread/INFO]: Opened connection [connectionId{localValue:2, serverValue:28}] to localhost:27017
  143. [11:10:49] [Server thread/INFO]: de.letsplaybar.nickname.mongodb.ServerPlayer.setLastName()
  144. [11:10:49] [Server thread/INFO]: Letsplaybar
  145. [11:10:49] [Server thread/INFO]: de.letsplaybar.nickname.mongodb.ServerPlayer.setNickname()
  146. [11:10:49] [Server thread/INFO]: 
  147. [11:10:49] [Server thread/INFO]: de.letsplaybar.nickname.mongodb.ServerPlayer.setGroupName()
  148. [11:10:49] [Server thread/INFO]: player
  149. [11:10:49] [Server thread/INFO]: de.letsplaybar.nickname.mongodb.ServerPlayer.setFirstLoginDate()
  150. [11:10:49] [Server thread/INFO]: 1469437849825
  151. [11:10:49] [Server thread/INFO]: de.letsplaybar.nickname.mongodb.ServerPlayer.setLastLoginDate()
  152. [11:10:49] [Server thread/INFO]: 1469437849825
  153. [11:10:49] [Server thread/INFO]: de.letsplaybar.nickname.mongodb.ServerPlayer.setOnline()
  154. [11:10:49] [Server thread/INFO]: 0
  155. [11:10:49] [Server thread/INFO]: de.letsplaybar.nickname.mongodb.ServerPlayer.setIsNicked()
  156. [11:10:49] [Server thread/INFO]: false
  157. [11:10:49] [Server thread/INFO]: de.letsplaybar.nickname.mongodb.ServerPlayer.setLastLoginDate()
  158. [11:10:49] [Server thread/INFO]: 1469437849839
  159. [11:10:49] [Server thread/INFO]: de.letsplaybar.nickname.mongodb.ServerPlayer.setLastName()
  160. [11:10:49] [Server thread/INFO]: Letsplaybar
  161. [11:10:49] [Server thread/INFO]: de.letsplaybar.nickname.mongodb.ServerPlayer.getNickname()
  162. [11:10:49] [Server thread/INFO]: 
  163. [11:10:49] [Server thread/INFO]: de.letsplaybar.nickname.mongodb.ServerPlayer.getOnline()
  164. [11:10:49] [Server thread/INFO]: 0
  165. [11:10:49] [Server thread/INFO]: de.letsplaybar.nickname.mongodb.ServerPlayer.getFirstLoginDate()
  166. [11:10:49] [Server thread/INFO]: 0
  167. [11:10:49] [Server thread/INFO]: de.letsplaybar.nickname.mongodb.ServerPlayer.getIsNicked()
  168. [11:10:49] [Server thread/INFO]: false
  169. [11:10:49] [Server thread/INFO]: de.letsplaybar.nickname.mongodb.ServerPlayer.getGroupName()
  170. [11:10:49] [Server thread/INFO]: null
  171. [11:10:49] [Server thread/ERROR]: Could not pass event PlayerJoinEvent to Nickname v1.0
  172. org.bukkit.event.EventException
  173.    at org.bukkit.plugin.java.JavaPluginLoader$1.execute(JavaPluginLoader.java:310) ~[spigot.jar:git-Spigot-db6de12-18fbb24]
  174.    at org.bukkit.plugin.RegisteredListener.callEvent(RegisteredListener.java:62) ~[spigot.jar:git-Spigot-db6de12-18fbb24]
  175.    at org.bukkit.plugin.SimplePluginManager.fireEvent(SimplePluginManager.java:502) [spigot.jar:git-Spigot-db6de12-18fbb24]
  176.    at org.bukkit.plugin.SimplePluginManager.callEvent(SimplePluginManager.java:487) [spigot.jar:git-Spigot-db6de12-18fbb24]
  177.    at net.minecraft.server.v1_8_R3.PlayerList.onPlayerJoin(PlayerList.java:298) [spigot.jar:git-Spigot-db6de12-18fbb24]
  178.    at net.minecraft.server.v1_8_R3.PlayerList.a(PlayerList.java:157) [spigot.jar:git-Spigot-db6de12-18fbb24]
  179.    at net.minecraft.server.v1_8_R3.LoginListener.b(LoginListener.java:144) [spigot.jar:git-Spigot-db6de12-18fbb24]
  180.    at net.minecraft.server.v1_8_R3.LoginListener.c(LoginListener.java:54) [spigot.jar:git-Spigot-db6de12-18fbb24]
  181.    at net.minecraft.server.v1_8_R3.NetworkManager.a(NetworkManager.java:231) [spigot.jar:git-Spigot-db6de12-18fbb24]
  182.    at net.minecraft.server.v1_8_R3.ServerConnection.c(ServerConnection.java:148) [spigot.jar:git-Spigot-db6de12-18fbb24]
  183.    at net.minecraft.server.v1_8_R3.MinecraftServer.B(MinecraftServer.java:814) [spigot.jar:git-Spigot-db6de12-18fbb24]
  184.    at net.minecraft.server.v1_8_R3.DedicatedServer.B(DedicatedServer.java:374) [spigot.jar:git-Spigot-db6de12-18fbb24]
  185.    at net.minecraft.server.v1_8_R3.MinecraftServer.A(MinecraftServer.java:654) [spigot.jar:git-Spigot-db6de12-18fbb24]
  186.    at net.minecraft.server.v1_8_R3.MinecraftServer.run(MinecraftServer.java:557) [spigot.jar:git-Spigot-db6de12-18fbb24]
  187.    at java.lang.Thread.run(Unknown Source) [?:1.8.0_77]
  188. Caused by: java.lang.NullPointerException
  189.    at de.letsplaybar.nickname.enums.Group.getGroupByName(Group.java:58) ~[?:?]
  190.    at de.letsplaybar.nickname.methode.Prefix.setPrefix(Prefix.java:26) ~[?:?]
  191.    at de.letsplaybar.nickname.listener.PlayerJoinEvent_Listener.onJoin(PlayerJoinEvent_Listener.java:44) ~[?:?]
  192.    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) ~[?:1.8.0_77]
  193.    at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source) ~[?:1.8.0_77]
  194.    at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source) ~[?:1.8.0_77]
  195.    at java.lang.reflect.Method.invoke(Unknown Source) ~[?:1.8.0_77]
  196.    at org.bukkit.plugin.java.JavaPluginLoader$1.execute(JavaPluginLoader.java:306) ~[spigot.jar:git-Spigot-db6de12-18fbb24]
  197.    ... 14 more
  198. [11:10:50] [Server thread/INFO]: Letsplaybar[/127.0.0.1:59741] logged in with entity id 99 at ([world]327.21598698125314, 65.0, 564.0493201633193)
  199. [11:10:51] [Async Chat Thread - #0/INFO]: Letsplaybar » hi
  200. [11:10:52] [Server thread/INFO]: Letsplaybar lost connection: Disconnected
  201. [11:10:52] [Server thread/INFO]: de.letsplaybar.nickname.mongodb.ServerPlayer.getOnline()
  202. [11:10:52] [Server thread/INFO]: 0
  203. [11:10:52] [Server thread/INFO]: de.letsplaybar.nickname.mongodb.ServerPlayer.getLastLoginDate()
  204. [11:10:52] [Server thread/INFO]: 0
  205. [11:10:52] [Server thread/INFO]: de.letsplaybar.nickname.mongodb.ServerPlayer.setOnline()
  206. [11:10:52] [Server thread/INFO]: 1469437852
  207. [11:10:52] [Server thread/INFO]: Letsplaybar left the game.


und hier die MongoDB klasse die betroffen ist:
Code: Alles auswählen
  1. package de.letsplaybar.nickname.mongodb;
  2. import java.util.UUID;
  3. import org.bson.Document;
  4. import com.mongodb.client.FindIterable;
  5. import com.mongodb.client.model.Filters;
  6. import de.letsplaybar.nickname.enums.Group;
  7. import de.letsplaybar.nickname.methode.UUIDFetcher;
  8. import de.letsplaybar.nickname.system.Main;
  9. public class ServerPlayer {
  10.    
  11.    private Main plugin;
  12.    
  13.    private String uuid;
  14.    private FindIterable<Document>find;
  15.    
  16.    private Document document;
  17.    
  18.    private String lastName;
  19.    private String groupName;
  20.    
  21.    private String nickname;
  22.    
  23.    private long firstLoginDate;
  24.    private long lastLoginDate;
  25.    
  26.    private long online;
  27.    private boolean isNicked;
  28.    
  29.    public ServerPlayer(Main main, String uuid) {
  30.       this.plugin = main;
  31.       this.uuid = uuid;
  32.       this.find = plugin.getManager()
  33.                         .getPlayers()
  34.                         .find(Filters.eq("uuid", uuid));
  35.       this.document = this.find.first();
  36.    }
  37.    
  38.    public static ServerPlayer getPlayer(Main main, String uuid) {
  39.       return new ServerPlayer(main, uuid);
  40.    }
  41.    
  42.    public static ServerPlayer getPlayeByName(Main main, String lastName) {
  43.       FindIterable<Document> find = main.getManager().getPlayers().find(Filters.eq("lastName", lastName));
  44.       Document document = find.first();
  45.       if(document == null)
  46.          return null;
  47.       return new ServerPlayer(main, (String)document.get("uuid"));       
  48.    }
  49.    
  50.    public void create(){
  51.       if(document != null){
  52.          get();
  53.          return;
  54.       }
  55.       document = new Document("uuid",this.uuid)
  56.       .append("lastName", UUIDFetcher.getName(UUID.fromString(uuid)))
  57.       .append("nickname", " ")
  58.       .append("groupName", Group.PLAYER.getName())
  59.       .append("firstLoginDate", System.currentTimeMillis())
  60.       .append("lastLoginDate", System.currentTimeMillis())
  61.       .append("online", (long)0)
  62.                 .append("isNicked", false);
  63.                
  64.       
  65.       plugin.getManager().getPlayers().insertOne(document);
  66.       get();
  67.    }
  68.    
  69.    public void save(){
  70.       Document doc = new Document("uuid",this.uuid)
  71.       .append("lastName", lastName)
  72.       .append("nickname", nickname)
  73.       .append("groupName", groupName)
  74.       .append("firstLoginDate", firstLoginDate)
  75.       .append("lastLoginDate", lastLoginDate)
  76.       .append("online", online)
  77.                 .append("isNicked", isNicked);
  78.       plugin.getManager().getPlayers().updateOne(Filters.eq("uuid", this.uuid), new Document("$set", doc));
  79.    }
  80.    
  81.    private void get(){
  82.       setLastName((String) document.get("lastName"));
  83.       setNickname((String)document.get("nickname"));
  84.       setGroupName((String)document.get("groupName"));
  85.       setFirstLoginDate((long)document.get("firstLoginDate"));
  86.       setLastLoginDate((long)document.get("lastLoginDate"));
  87.       setOnline((long)document.get("online"));
  88.                 setIsNicked((boolean)document.get("isNicked"));
  89.    }
  90.    public String getLastName() {
  91.             System.out.println("de.letsplaybar.nickname.mongodb.ServerPlayer.getLastName()");
  92.             System.out.println(lastName);
  93.       return lastName;
  94.    }
  95.    public void setLastName(String lastName) {
  96.             System.out.println("de.letsplaybar.nickname.mongodb.ServerPlayer.setLastName()");
  97.             System.out.println(lastName);
  98.       this.lastName = lastName;
  99.    }
  100.    public String getGroupName() {
  101.             System.out.println("de.letsplaybar.nickname.mongodb.ServerPlayer.getGroupName()");
  102.             System.out.println(groupName);
  103.       return groupName;
  104.    }
  105.    public void setGroupName(String groupName) {
  106.             System.out.println("de.letsplaybar.nickname.mongodb.ServerPlayer.setGroupName()");
  107.             System.out.println(groupName);
  108.       this.groupName = groupName;
  109.    }
  110.    public String getNickname() {
  111.             System.out.println("de.letsplaybar.nickname.mongodb.ServerPlayer.getNickname()");
  112.             System.out.println(nickname);
  113.       return nickname;
  114.    }
  115.    public void setNickname(String nickname) {
  116.             System.out.println("de.letsplaybar.nickname.mongodb.ServerPlayer.setNickname()");
  117.             System.out.println(nickname);
  118.       this.nickname = nickname;
  119.    }
  120.    public long getFirstLoginDate() {
  121.             System.out.println("de.letsplaybar.nickname.mongodb.ServerPlayer.getFirstLoginDate()");
  122.             System.out.println(firstLoginDate);
  123.       return firstLoginDate;
  124.    }
  125.    public void setFirstLoginDate(long firstLoginDate) {
  126.             System.out.println("de.letsplaybar.nickname.mongodb.ServerPlayer.setFirstLoginDate()");
  127.             System.out.println(firstLoginDate);
  128.       this.firstLoginDate = firstLoginDate;
  129.    }
  130.    public long getLastLoginDate() {
  131.             System.out.println("de.letsplaybar.nickname.mongodb.ServerPlayer.getLastLoginDate()");
  132.             System.out.println(lastLoginDate);
  133.       return lastLoginDate;
  134.    }
  135.    public void setLastLoginDate(long lastLoginDate) {
  136.             System.out.println("de.letsplaybar.nickname.mongodb.ServerPlayer.setLastLoginDate()");
  137.       this.lastLoginDate = lastLoginDate;
  138.                 System.out.println(lastLoginDate);
  139.    }
  140.    
  141.    public String getUuid() {
  142.             System.out.println("de.letsplaybar.nickname.mongodb.ServerPlayer.getUuid()");
  143.             System.out.println(uuid);
  144.       return uuid;
  145.    }
  146.    public long getOnline() {
  147.             System.out.println("de.letsplaybar.nickname.mongodb.ServerPlayer.getOnline()");
  148.             System.out.println(online);
  149.       return online;
  150.    }
  151.    public void setOnline(long online) {
  152.             System.out.println("de.letsplaybar.nickname.mongodb.ServerPlayer.setOnline()");
  153.             System.out.println(online);
  154.       this.online = online;
  155.    }
  156.         public void setIsNicked(boolean isNicked) {
  157.             System.out.println("de.letsplaybar.nickname.mongodb.ServerPlayer.setIsNicked()");
  158.             System.out.println(isNicked);
  159.             this.isNicked = isNicked;
  160.         }
  161.        
  162.         public boolean getIsNicked(){
  163.             System.out.println("de.letsplaybar.nickname.mongodb.ServerPlayer.getIsNicked()");
  164.             System.out.println(isNicked);
  165.             return isNicked;
  166.         }
  167.    
  168.    
  169.    
  170. }


und hier die 3. klassen die da aufgerufen werden und die werte abfordern:
Code: Alles auswählen
  1. package de.letsplaybar.nickname.listener;
  2. import org.bukkit.craftbukkit.v1_8_R3.entity.CraftPlayer;
  3. import org.bukkit.entity.Player;
  4. import org.bukkit.event.EventHandler;
  5. import org.bukkit.event.Listener;
  6. import org.bukkit.event.player.PlayerLoginEvent;
  7. import de.letsplaybar.nickname.mongodb.ServerPlayer;
  8. import de.letsplaybar.nickname.system.Main;
  9. public class PlayerLoginEvent_Listener implements Listener {
  10.    
  11.    private Main plugin;
  12.    
  13.    public PlayerLoginEvent_Listener(Main main) {
  14.       this.plugin = main;
  15.       plugin.getServer().getPluginManager().registerEvents(this, main);
  16.    }
  17.    
  18.    @EventHandler
  19.    public void onLogin(PlayerLoginEvent e){
  20.       Player player = e.getPlayer();
  21.       if(player.hasMetadata("serverPlayer"))
  22.          player.removeMetadata("serverPlayer", plugin);
  23.       
  24.       
  25.       ServerPlayer p =plugin.getPlayer(player);
  26.       p.create();
  27.       p.setLastLoginDate(System.currentTimeMillis());
  28.       p.setLastName(player.getName());
  29.       
  30.       if(!p.getNickname().equalsIgnoreCase(" ")){
  31.          plugin.um.setNick(p.getNickname(), (CraftPlayer)player);
  32.          plugin.s.changeSkin((CraftPlayer)player, p.getNickname());
  33.       }
  34.    }
  35.    
  36. }

Code: Alles auswählen
  1. package de.letsplaybar.nickname.listener;
  2. import java.text.SimpleDateFormat;
  3. import java.util.Date;
  4. import org.bukkit.Bukkit;
  5. import org.bukkit.Material;
  6. import org.bukkit.entity.Player;
  7. import org.bukkit.event.EventHandler;
  8. import org.bukkit.event.Listener;
  9. import org.bukkit.event.player.PlayerJoinEvent;
  10. import org.bukkit.inventory.ItemStack;
  11. import org.bukkit.inventory.meta.ItemMeta;
  12. import de.letsplaybar.nickname.system.Main;
  13. public class PlayerJoinEvent_Listener implements Listener {
  14.    private Main plugin;
  15.    
  16.    public PlayerJoinEvent_Listener(Main main) {
  17.       this.plugin = main;
  18.       plugin.getServer().getPluginManager().registerEvents(this, main);
  19.    }
  20.    
  21.    @EventHandler
  22.    public void onJoin(PlayerJoinEvent e){
  23.       Player p = e.getPlayer();
  24.       if(!plugin.p.getOnlineTime(p).equalsIgnoreCase(""))
  25.          p.sendMessage(plugin.prefix+"Du warst schon §5"+plugin.p.getOnlineTime(p)+" §7online");
  26.       
  27.       SimpleDateFormat sdf = new SimpleDateFormat("MMM dd ,yyyy HH:mm");
  28.       Date resultdate = new Date(plugin.getPlayer(p).getFirstLoginDate());
  29.       p.sendMessage(plugin.prefix+"Du Spielst seit dem "+sdf.format(resultdate)+" §7auf unserem Netzwerk");
  30.       if(p.hasPermission("nick.item")||plugin.getConfig().getBoolean("Item")){
  31.          ItemStack is = new ItemStack(Material.NAME_TAG);
  32.          ItemMeta im = is.getItemMeta();
  33.          im.setDisplayName("§5Nick-Item");
  34.          is.setItemMeta(im);
  35.          p.getInventory().setItem(4, is);
  36.       }
  37.       for(Player pl : Bukkit.getOnlinePlayers()){
  38.          plugin.p.setPrefix(pl);
  39.          if(plugin.vanish.contains(pl))
  40.          p.hidePlayer(pl);   
  41.       }
  42.    }
  43. }

Code: Alles auswählen
  1. package de.letsplaybar.nickname.listener;
  2. import org.bukkit.entity.Player;
  3. import org.bukkit.event.EventHandler;
  4. import org.bukkit.event.Listener;
  5. import org.bukkit.event.player.PlayerQuitEvent;
  6. import de.letsplaybar.nickname.mongodb.ServerPlayer;
  7. import de.letsplaybar.nickname.system.Main;
  8. public class PlayerQuitEvent_Listener implements Listener {
  9.    
  10.    private Main plugin;
  11.    public PlayerQuitEvent_Listener(Main main) {
  12.       this.plugin = main;
  13.       plugin.getServer().getPluginManager().registerEvents(this, main);
  14.    }
  15.    
  16.    @EventHandler
  17.    public void onDisconnect(PlayerQuitEvent e){
  18.       Player player = e.getPlayer();
  19.       ServerPlayer p = plugin.getPlayer(player);
  20.       p.setOnline(p.getOnline()+((System.currentTimeMillis()-p.getLastLoginDate())/1000));
  21.       p.save();
  22.    }
  23.    
  24. }

Code: Alles auswählen
  1. package de.letsplaybar.nickname.system;
  2. import java.lang.reflect.Field;
  3. import java.util.ArrayList;
  4. import java.util.List;
  5. import org.bukkit.Bukkit;
  6. import org.bukkit.entity.Player;
  7. import org.bukkit.metadata.FixedMetadataValue;
  8. import org.bukkit.plugin.java.JavaPlugin;
  9. import com.mojang.authlib.GameProfile;
  10. import de.letsplaybar.nickname.commands.Command_Fix;
  11. import de.letsplaybar.nickname.commands.Command_Nick;
  12. import de.letsplaybar.nickname.commands.Command_Realname;
  13. import de.letsplaybar.nickname.commands.Command_SetGroup;
  14. import de.letsplaybar.nickname.commands.Command_UnNick;
  15. import de.letsplaybar.nickname.commands.Command_Vanish;
  16. import de.letsplaybar.nickname.listener.AsyncPlayerChatEvent_Listener;
  17. import de.letsplaybar.nickname.listener.PlayerInteractEvent_Listener;
  18. import de.letsplaybar.nickname.listener.PlayerJoinEvent_Listener;
  19. import de.letsplaybar.nickname.listener.PlayerLoginEvent_Listener;
  20. import de.letsplaybar.nickname.listener.PlayerQuitEvent_Listener;
  21. import de.letsplaybar.nickname.methode.Nicks_Methode;
  22. import de.letsplaybar.nickname.methode.Prefix;
  23. import de.letsplaybar.nickname.methode.Skin;
  24. import de.letsplaybar.nickname.methode.Umbennenen_Methoden;
  25. import de.letsplaybar.nickname.mongodb.MongoDBManager;
  26. import de.letsplaybar.nickname.mongodb.ServerPlayer;
  27. public class Main extends JavaPlugin{
  28.    //=====<Reflection>=====
  29.    public Field nameField;
  30.    public Umbennenen_Methoden um;
  31.    
  32.    //=====<Methoden>=====
  33.    public Skin s;
  34.    public Prefix p;
  35.    public Command_Fix f;
  36.    public Nicks_Methode n;
  37.    
  38.    //=====<ArrayList>=====
  39.    public List<String> nicks;
  40.    public List<Player> vanish;
  41.    
  42.    //=====<MongoDB>=====
  43.    private MongoDBManager manager;
  44.    
  45.    
  46.    //=====<boolean>=====
  47.    public boolean isSkinchange;
  48.    
  49.    //=====<String>=====
  50.    public String prefix;
  51.    
  52.    @SuppressWarnings("deprecation")
  53.    @Override
  54.    public void onEnable() {
  55.       getLogger().info("Dieses Plugin ist Nicht für Kommerziale Zwecke Zugebrauchen");
  56.       getLogger().info("Developer ist Letsplaybar");
  57.       
  58.                 getConfig().addDefault("Item", true);
  59.                 getConfig().options().copyDefaults(true);
  60.                 saveConfig();
  61.                
  62.                 manager = new MongoDBManager("localhost", 27017, "Minecraft");
  63.       manager.connect();
  64.       
  65.       
  66.       p = new Prefix(this);
  67.       nicks = new ArrayList<String>();
  68.       vanish = new ArrayList<Player>();
  69.       isSkinchange = false;
  70.       prefix="§6§lSystem §8» §7";
  71.       um = new Umbennenen_Methoden(this);
  72.       s = new Skin(this);
  73.       n = new Nicks_Methode(this);
  74.       f = new Command_Fix(this);
  75.       try {
  76.          nameField = um.getField(GameProfile.class, "name");
  77.       } catch (NoSuchFieldException e) {
  78.          e.printStackTrace();
  79.       } catch (SecurityException e) {
  80.          e.printStackTrace();
  81.       }
  82.       Bukkit.getScheduler().scheduleAsyncRepeatingTask(this, new Updater(this), 20*30, 20*30);
  83.       Bukkit.getScheduler().scheduleAsyncRepeatingTask(this, new Fix(this), 20*30, 20*30);
  84.       
  85.                 new AsyncPlayerChatEvent_Listener(this);
  86.                 new PlayerInteractEvent_Listener(this);
  87.                 new PlayerJoinEvent_Listener(this);
  88.                 new PlayerLoginEvent_Listener(this);
  89.                 new PlayerQuitEvent_Listener(this);
  90.       
  91.       getCommand("fix").setExecutor(f);
  92.                 getCommand("nick").setExecutor(new Command_Nick(this));
  93.                 getCommand("realname").setExecutor(new Command_Realname(this));
  94.                 getCommand("setGroup").setExecutor(new Command_SetGroup(this));
  95.                 getCommand("unnick").setExecutor(new Command_UnNick(this));
  96.                 getCommand("vanish").setExecutor(new Command_Vanish(this));
  97.       getLogger().info("Plugin ist Fehlerfrei gestartet");
  98.    }
  99.    
  100.    @Override
  101.    public void onDisable() {
  102.       for(Player player : Bukkit.getOnlinePlayers())
  103.                     player.kickPlayer("Server Reloadet");
  104.    }
  105.    
  106.    public ServerPlayer getPlayer(Player player){
  107.       if(player.hasMetadata("serverPlayer"))
  108.          return (ServerPlayer) player.getMetadata("serverPlayer").get(0).value();
  109.       ServerPlayer p = getPlayer(player.getUniqueId().toString());
  110.       return p;
  111.    }
  112.    
  113.    public ServerPlayer getPlayer(String uuid){
  114.       
  115.       return ServerPlayer.getPlayer(this, uuid);
  116.    }
  117.    
  118.    public ServerPlayer getPlayerByName(String lastName){
  119.       return ServerPlayer.getPlayeByName(this, lastName);
  120.    }
  121.     public MongoDBManager getManager() {
  122.         return manager;
  123.     }
  124.        
  125. }


schonmal Danke fürs helfen im vorraus.
Bild
Helfe Wo ich kann.
Mein MinecraftServer: Letsplaybaro.de - Suchen Developer/Bilder

I hacked 127.0.0.1!!! :)
Benutzeravatar
Letsplaybar
 
Beiträge: 195
Registriert: Mo 1. Feb 2016, 17:21
Wohnort: Berlin

Re: [Closed]Problem mit MongoDB

Beitragvon Letsplaybar » Mi 27. Jul 2016, 22:49

der fehler war in der main das ich den Serverplayer in die Metadaten des Spielers gesetzt habe. gelößt in dem ich die Hashmap als alternative verwende.
Bild
Helfe Wo ich kann.
Mein MinecraftServer: Letsplaybaro.de - Suchen Developer/Bilder

I hacked 127.0.0.1!!! :)
Benutzeravatar
Letsplaybar
 
Beiträge: 195
Registriert: Mo 1. Feb 2016, 17:21
Wohnort: Berlin


Zurück zu Hilfe und Support

Wer ist online?

Mitglieder in diesem Forum: 0 Mitglieder und 25 Gäste