Problem to use Multiverse in my plugin

Discussion in 'Plugin Development' started by MrR4P70R, Jun 23, 2013.

Thread Status:
Not open for further replies.
  1. Offline

    MrR4P70R

    Hi guys,

    to start this post, I need to say: I'm french, so sorry if my english sucks ^^

    So, I go try to explain my problem.

    I make a plugin named "Multi Game With Signs" (MGWS), do you know the Hypixel's Server ? it's like the same but for play any friend's PvP maps.

    My problem is for "create a game", when I put a sign on a wall, I need to clone an existant world and import it in the Multiverse World's list.

    So, I have my "AirJumpV2" world, and when i put a sign on a wall, I try to use the "cloneWorld" Multiverse function to copy the folder "AirJumpV2" to "jump-1" for example.
    When the copy is finished, I try to import it with the "addWorld()" Multiverse function.

    My problem: the "cloneWorld()" function need some time to be finished and if I just send the command and send the addWorld() command just after.. it's too early and the second command has send on the void :eek:

    I think it's more simple for you guys if I put my code here, so:

    Code:java
    1. Bukkit.getServer().dispatchCommand(Bukkit.getConsoleSender(), "mv clone AirJumpV2 "+gameFolderName);
    2. Bukkit.getServer().dispatchCommand(Bukkit.getConsoleSender(), "mvconfirm");
    3. Bukkit.getServer().dispatchCommand(Bukkit.getConsoleSender(), "mv import "+gameFolderName+" NORMAL");


    I've try to put the "mvconfirm" command in a if for try to send the "import" command only when the mvconfirm return true but it's not a win ^^

    I've try any solutions, in this code I use the consoleSender for send the command, but I've try to use the Multiverse functions directly in the code with:

    Code:java
    1. public final MultiverseCore mv = new MultiverseCore();
    2.  
    3. if(mv.cloneWorld("AirJumpV2", gameFolderName, "2;0;1;")){
    4. p.sendMessage("[CLONE] OK");
    5. if(mv.getMVWorldManager().addWorld(gameFolderName, Environment.NORMAL, "", WorldType.FLAT, false, "2;0;1;")){
    6. p.sendMessage("[IMPORT] OK");
    7. }else{
    8. p.sendMessage("[IMPORT] FAIL");
    9. }
    10. }else{
    11. p.sendMessage("[CLONE] FAIL");
    12. }


    It's not a win again :s

    I need your help guys, It's verry difficult for me to explain my problem in english so I hope I have well explained.

    If you have any questions or need any informations, ask me and I answer you quickly if possible :)

    Thank you beforehand for your help and have a nice day.
     
  2. Offline

    MylesIsCool

    You haven't explained what's the issue with the code? What happens when you do the Multiverse API code etc.

    Please explain what you're trying to do and what's not working properly so I can help with your issue.

    Also, if(mv.getMVWorldManager().addWorld(gameFolderName, Environment.NORMAL, "", WorldType.FLAT, false, "2;0;1;")){

    Might not be what you want to do as that generates a world? You might be looking into loadWorld api function.
     
  3. Offline

    MrR4P70R

    Hi, sorry for this response too late but I've delete my plugin for rewrite it and... I'm blocked again with the same problem :s

    So, I put my code and the error in console... but I don't know why it's not work :s

    Console:

    Code:
    26.06 23:23:32 [Server] INFO ... 16 more
    26.06 23:23:32 [Server] INFO at org.bukkit.plugin.java.JavaPluginLoader$1.execute(JavaPluginLoader.java:425)
    26.06 23:23:32 [Server] INFO at java.lang.reflect.Method.invoke(Method.java:601)
    26.06 23:23:32 [Server] INFO at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
    26.06 23:23:32 [Server] INFO at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)
    26.06 23:23:32 [Server] INFO at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    26.06 23:23:32 [Server] INFO at fr.raptor.Mgws.MgwsListener.onPlayerCommandPreprocess(MgwsListener.java:136)
    26.06 23:23:32 [Server] INFO at fr.raptor.Mgws.Mgws.createGame(Mgws.java:139)
    26.06 23:23:32 [Server] INFO Caused by: java.lang.NullPointerException
    26.06 23:23:32 [Server] INFO at net.minecraft.server.v1_5_R3.ThreadServerApplication.run(SourceFile:573)
    26.06 23:23:32 [Server] INFO at net.minecraft.server.v1_5_R3.MinecraftServer.run(MinecraftServer.java:410)
    26.06 23:23:32 [Server] INFO at net.minecraft.server.v1_5_R3.MinecraftServer.q(MinecraftServer.java:477)
    26.06 23:23:32 [Server] INFO at net.minecraft.server.v1_5_R3.DedicatedServer.r(DedicatedServer.java:226)
    26.06 23:23:32 [Server] INFO at net.minecraft.server.v1_5_R3.MinecraftServer.r(MinecraftServer.java:581)
    26.06 23:23:32 [Server] INFO at net.minecraft.server.v1_5_R3.DedicatedServerConnection.b(SourceFile:30)
    26.06 23:23:32 [Server] INFO at net.minecraft.server.v1_5_R3.ServerConnection.b(SourceFile:35)
    26.06 23:23:32 [Server] INFO at net.minecraft.server.v1_5_R3.PlayerConnection.d(PlayerConnection.java:115)
    26.06 23:23:32 [Server] INFO at net.minecraft.server.v1_5_R3.NetworkManager.b(NetworkManager.java:292)
    26.06 23:23:32 [Server] INFO at net.minecraft.server.v1_5_R3.Packet3Chat.handle(Packet3Chat.java:44)
    26.06 23:23:32 [Server] INFO at net.minecraft.server.v1_5_R3.PlayerConnection.a(PlayerConnection.java:846)
    26.06 23:23:32 [Server] INFO at net.minecraft.server.v1_5_R3.PlayerConnection.chat(PlayerConnection.java:889)
    26.06 23:23:32 [Server] INFO at net.minecraft.server.v1_5_R3.PlayerConnection.handleCommand(PlayerConnection.java:963)
    26.06 23:23:32 [Server] INFO at org.bukkit.plugin.SimplePluginManager.callEvent(SimplePluginManager.java:462)
    26.06 23:23:32 [Server] INFO at org.bukkit.plugin.SimplePluginManager.fireEvent(SimplePluginManager.java:477)
    26.06 23:23:32 [Server] INFO at org.bukkit.plugin.RegisteredListener.callEvent(RegisteredListener.java:62)
    26.06 23:23:32 [Server] INFO at org.bukkit.plugin.java.JavaPluginLoader$1.execute(JavaPluginLoader.java:427)
    26.06 23:23:32 [Server] INFO org.bukkit.event.EventException
    26.06 23:23:32 [Server] SEVERE Could not pass event PlayerCommandPreprocessEvent to MGWS v1.0
    Multicraft (My server panel) show me the log in reverse so read this code from bottom to top ^^

    Here is my code:
    Code:java
    1. public boolean createGame(String map, int maxPlayers, int vip){
    2.  
    3. map.trim().toLowerCase();
    4.  
    5. int gameType = 0;
    6. if(map.equalsIgnoreCase("jump")){
    7. gameType = 1;
    8. }else if(map.equalsIgnoreCase("cake")){
    9. gameType = 2;
    10. }
    11.  
    12. if(gameType > 0){
    13. try{
    14. PreparedStatement stateP = conn.prepareStatement("SELECT * FROM games WHERE gameType="+gameType);
    15. boolean state = stateP.execute();
    16. if(state){
    17. ResultSet result = stateP.getResultSet();
    18. try{
    19. int nbGames = result.getFetchSize();
    20. nbGames++;
    21.  
    22. String newMap = map+"-"+nbGames;
    23.  
    24. Boolean cont = false;
    25. Boolean clone = mv.cloneWorld(map, newMap, "CleanRoomGenerator");
    26. Boolean load = false;
    27.  
    28. if(clone){
    29. cont = true;
    30. }else{
    31. load = mv.getMVWorldManager().loadWorld(map);
    32. }
    33. if(load){
    34. cont = mv.cloneWorld(map, newMap, "CleanRoomGenerator");
    35. }
    36.  
    37. if(cont){
    38.  
    39. Boolean simport = mv.getMVWorldManager().addWorld(newMap, Environment.NORMAL, "-5090228978844984031", WorldType.FLAT, false, "CleanRoomGenerator");
    40.  
    41. if(simport){
    42. try{
    43. Statement state1 = conn.createStatement();
    44. state1.executeUpdate("INSERT INTO games (id, gameType, map, maxPlayers, vip, state) VALUES("+nbGames+", "+gameType+", '"+map+"', "+maxPlayers+", "+vip+", 'free')");
    45. state1.close();
    46. return true;
    47. }catch(SQLException e){
    48. e.printStackTrace();
    49. getServer().broadcastMessage(ChatColor.RESET+""+ChatColor.RED+""+e.getStackTrace().toString());
    50. }
    51. }else{
    52. getServer().broadcastMessage(ChatColor.RESET+""+ChatColor.RED+"Impossible d'importer le monde "+map+"");
    53. }
    54. }else{
    55. getServer().broadcastMessage(ChatColor.RESET+""+ChatColor.RED+"Impossible de cloner le monde "+map);
    56. }
    57. }catch(SQLException e){
    58. e.printStackTrace();
    59. getServer().broadcastMessage(ChatColor.RESET+""+ChatColor.RED+""+e.getStackTrace().toString());
    60. }
    61. }
    62. }catch(SQLException e){
    63. e.printStackTrace();
    64. getServer().broadcastMessage(ChatColor.RESET+""+ChatColor.RED+""+e.getStackTrace().toString());
    65. }
    66. }else{
    67. return false;
    68. }
    69. return false;
    70. }


    I use this code for construct the "mv " tag:

    Code:java
    1. MultiverseCore mv = (MultiverseCore) Bukkit.getServer().getPluginManager().getPlugin("MultiverseCore");


    I've never understand the "NullPointerException" error so do you have any ideas please ? :s
     
  4. Offline

    MrR4P70R

    Do you have any ideas guys ? :s
     
Thread Status:
Not open for further replies.

Share This Page