Solved MiniGame help

Discussion in 'Plugin Development' started by fls1234, Oct 21, 2013.

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

    fls1234

    Hey there,

    Okay so i'm in process with a mini game called FeastGames, and then i get a this

    Code:
    org.bukkit.command.CommandException: Unhandled exception executing command 'feastgame' in plugin FeastGame v0.1
        at org.bukkit.command.PluginCommand.execute(PluginCommand.java:46)
        at org.bukkit.command.SimpleCommandMap.dispatch(SimpleCommandMap.java:192)
        at org.bukkit.craftbukkit.v1_6_R3.CraftServer.dispatchCommand(CraftServer.java:523)
        at net.minecraft.server.v1_6_R3.PlayerConnection.handleCommand(PlayerConnection.java:959)
        at net.minecraft.server.v1_6_R3.PlayerConnection.chat(PlayerConnection.java:877)
        at net.minecraft.server.v1_6_R3.PlayerConnection.a(PlayerConnection.java:834)
        at net.minecraft.server.v1_6_R3.Packet3Chat.handle(SourceFile:49)
        at net.minecraft.server.v1_6_R3.NetworkManager.b(NetworkManager.java:296)
        at net.minecraft.server.v1_6_R3.PlayerConnection.e(PlayerConnection.java:116)
        at net.minecraft.server.v1_6_R3.ServerConnection.b(SourceFile:37)
        at net.minecraft.server.v1_6_R3.DedicatedServerConnection.b(SourceFile:30)
        at net.minecraft.server.v1_6_R3.MinecraftServer.t(MinecraftServer.java:592)
        at net.minecraft.server.v1_6_R3.DedicatedServer.t(DedicatedServer.java:227)
        at net.minecraft.server.v1_6_R3.MinecraftServer.s(MinecraftServer.java:488)
        at net.minecraft.server.v1_6_R3.MinecraftServer.run(MinecraftServer.java:421)
        at net.minecraft.server.v1_6_R3.ThreadServerApplication.run(SourceFile:583)
    Caused by: java.lang.IllegalArgumentException: Plugin cannot be null
        at org.apache.commons.lang.Validate.notNull(Validate.java:203)
        at org.bukkit.craftbukkit.v1_6_R3.scheduler.CraftScheduler.validate(CraftScheduler.java:391)
        at org.bukkit.craftbukkit.v1_6_R3.scheduler.CraftScheduler.runTaskTimer(CraftScheduler.java:120)
        at org.bukkit.craftbukkit.v1_6_R3.scheduler.CraftScheduler.scheduleSyncRepeatingTask(CraftScheduler.java:116)
        at fls1234.kami.feast.utils.FeastGameUtil.Countdown(FeastGameUtil.java:34)
        at fls1234.kami.feast.utils.FeastGameUtil.StartUpGame(FeastGameUtil.java:24)
        at fls1234.kami.feast.main.Main.onCommand(Main.java:58)
        at org.bukkit.command.PluginCommand.execute(PluginCommand.java:44)
        ... 15 more
    
    I know its something with the timer, and also i can't configure out how to check if an Admin did /feastgame host and then players can join but now can players join still if no one did /feastgame host Please help me!

    and here is my main.
    Code:java
    1. public class Main extends JavaPlugin{
    2.  
    3. public static ArrayList<String> ViperKit = new ArrayList<String>();
    4. public static ArrayList<String> KangarooKit = new ArrayList<String>();
    5. public static ArrayList<String> SwitcherKit = new ArrayList<String>();
    6. public static ArrayList<String> EndermageKit = new ArrayList<String>();
    7. public static ArrayList<String> StomperKit = new ArrayList<String>();
    8. public static ArrayList<String> FishermanKit = new ArrayList<String>();
    9. public static ArrayList<String> JoinedPlayers = new ArrayList<String>();
    10.  
    11.  
    12. public static Main plugin;
    13. public void onEnable(){
    14. Bukkit.getServer().getPluginManager().registerEvents(new Switcher(this), this);
    15. Bukkit.getServer().getPluginManager().registerEvents(new Stomper(), this);
    16. Bukkit.getServer().getPluginManager().registerEvents(new Endermage(), this);
    17. Bukkit.getServer().getPluginManager().registerEvents(new Fisherman(), this);
    18. Bukkit.getServer().getPluginManager().registerEvents(new Viper(), this);
    19. Bukkit.getServer().getPluginManager().registerEvents(new Kangaroo(), this);
    20. }
    21.  
    22.  
    23.  
    24. public boolean onCommand(CommandSender sender, Command cmd, String commandLabel, String[] args){
    25. final Player player = (Player) sender;
    26.  
    27. if(commandLabel.equalsIgnoreCase("feastgame")){
    28. if(args.length == 0){
    29. player.sendMessage(ChatColor.RED+"Usage: /feastgame join");
    30. }else if(args[0].equalsIgnoreCase("join")){
    31.  
    32. FeastGameUtil.addPlayer(player);
    33.  
    34. }
    35.  
    36.  
    37. else if(args[0].equalsIgnoreCase("host")){
    38.  
    39. FeastGameUtil.StartUpGame();
    40.  
    41. }
    42. }
    43. return false;
    44. }
    45.  
    46.  
    47. }


    Here is my Util
    Code:java
    1. public class FeastGameUtil {
    2.  
    3. private static GameStatus status = GameStatus.NOT_RUNNING();
    4. public static ArrayList<String> JoinedPlayers = new ArrayList<String>();
    5.  
    6. public static Main plugin;
    7.  
    8.  
    9. public static void inGame(Player player){
    10.  
    11. }
    12.  
    13. public static void StartUpGame(){
    14. Countdown();
    15.  
    16.  
    17.  
    18. }
    19. public static void Countdown(){
    20.  
    21. if(status == GameStatus.NOT_RUNNING()){
    22. status = GameStatus.COUNTDOWN();
    23. Bukkit.broadcastMessage(ChatColor.GOLD+"A FeastGame has been hosted! Do '/feastgame join'");
    24. Bukkit.getServer().getScheduler().scheduleSyncRepeatingTask(Main.plugin, new Runnable(){
    25. int timer=120;
    26. public void run(){
    27. if (timer != 0){
    28.  
    29. if(timer==120){
    30. Bukkit.broadcastMessage(ChatColor.GOLD+"2 Minutes to start!");
    31. }
    32. else if(timer==60){
    33. Bukkit.broadcastMessage(ChatColor.GOLD+"1 Minutes to start!");
    34. }
    35. else if(timer==45){
    36. Bukkit.broadcastMessage(ChatColor.GOLD+"45 Seconds to start!");
    37. }
    38. else if(timer==30){
    39. Bukkit.broadcastMessage(ChatColor.GOLD+"30 Seconds to start!");
    40. }
    41. else if(timer==15){
    42. Bukkit.broadcastMessage(ChatColor.GOLD+"15 Seconds to start!");
    43. }
    44. else if(timer==10){
    45. Bukkit.broadcastMessage(ChatColor.GOLD+"10 Seconds to start!");
    46. }
    47. else if(timer==5){
    48. Bukkit.broadcastMessage(ChatColor.GOLD+"5 Seconds to start!");
    49. }
    50. else if(timer==4){
    51. Bukkit.broadcastMessage(ChatColor.GOLD+"4 Seconds to start!");
    52. }
    53. else if(timer==3){
    54. Bukkit.broadcastMessage(ChatColor.GOLD+"3 Seconds to start!");
    55. }
    56. else if(timer==2){
    57. Bukkit.broadcastMessage(ChatColor.GOLD+"2 Seconds to start!");
    58. }
    59. else if(timer==1){
    60. Bukkit.broadcastMessage(ChatColor.GOLD+"1 Seconds to start!");
    61. }
    62. timer = timer-1;
    63.  
    64. }else {
    65. if(JoinedPlayers.size() == 12){
    66. Bukkit.broadcastMessage(ChatColor.GOLD+"Game starting!");
    67. status = GameStatus.INGAME();
    68.  
    69.  
    70. timer--;
    71. }else{
    72. Bukkit.broadcastMessage(ChatColor.RED+"There is not enough player(s) to start!");
    73. timer--;
    74. status = GameStatus.NOT_RUNNING();
    75. }
    76. }
    77. }
    78.  
    79. }, 0L, 20L);
    80. }
    81.  
    82. }
    83.  
    84. public static void endGame(){
    85.  
    86.  
    87.  
    88. }
    89. public static void addPlayer(Player player){
    90. if(status == GameStatus.COUNTDOWN()){
    91.  
    92. if(JoinedPlayers.size() != 12){
    93. if(!(JoinedPlayers.contains(player.getName()))){
    94.  
    95. JoinedPlayers.add(player.getName());
    96. player.sendMessage(ChatColor.GREEN+"You joined the FeastGames!");
    97.  
    98. }else{
    99. player.sendMessage(ChatColor.RED+"Error: You are allready in!");
    100. }
    101.  
    102. }else{
    103. player.sendMessage(ChatColor.RED+"The FeastGames is full!");
    104. }
    105.  
    106. }else{
    107. player.sendMessage(ChatColor.RED+"Sorry no one has hosted a FeastGame, or its in game!");
    108. }
    109. }
    110. public static void removePlayer(Player player){
    111. if(JoinedPlayers.contains(player.getName())){
    112. JoinedPlayers.remove(player.getName());
    113. }
    114.  
    115. }
    116.  
    117. }
    118.  


    and the GameStatus util
    Code:java
    1. package fls1234.kami.feast.utils;
    2.  
    3.  
    4.  
    5.  
    6. public class GameStatus {
    7.  
    8. private static final GameStatus status_NOT_RUNNING = GameStatus.NOT_RUNNING();
    9. private static final GameStatus status_COUNTDOWN = GameStatus.COUNTDOWN();
    10. private static final GameStatus status_INGAME = GameStatus.INGAME();
    11.  
    12. public static GameStatus INGAME(){
    13.  
    14.  
    15.  
    16. return status_INGAME;
    17. }
    18. public static GameStatus NOT_RUNNING(){
    19.  
    20.  
    21. return status_NOT_RUNNING;
    22. }
    23. public static GameStatus COUNTDOWN(){
    24.  
    25.  
    26.  
    27. return status_COUNTDOWN;
    28. }
    29.  
    30. }
    31.  


    Please help me :)
     
  2. Offline

    xTrollxDudex

    fls1234
    Plugin in FeastGameUtil is null, you need to initialize it.
     
  3. Offline

    fls1234

    Bumb

    How do i initialize it

    EDIT by Moderator: merged posts, please use the edit button instead of double posting.
     
    Last edited by a moderator: Jun 5, 2016
  4. Offline

    ampayne2

    Put plugin = this; in onEnable
     
  5. Offline

    fls1234

    Yay itt works, But i can still do /feastgame join before an admin did /feastgame host do you guys know what i mean?
     
  6. Offline

    xTrollxDudex

    fls1234
    Well you need to make sure FeastGame host is run before the join command, try using a Boolean.
     
  7. Offline

    fls1234

    I tried that but its not working.

    Some one?

    Bumb

    EDIT by Moderator: merged posts, please use the edit button instead of double posting.
     
    Last edited by a moderator: Jun 5, 2016
  8. Offline

    Jalau

    FeastGameUtil.StartUpGame(); This in on enable? Or try this:


    }else if(args[0].equalsIgnoreCase("join")){
    FeastGameUtil.StartUpGame();

    FeastGameUtil.addPlayer(player);
     
  9. Offline

    kevinspl2000

    You are trying to copy McPvP aren't you :p
     
  10. Offline

    DarkBladee12

    fls1234 Learn Java before trying to make plugins and asking every little thing which is obvious on the forums!
     
  11. Offline

    fls1234

    Not copying mcpvp

    I can code in java but i just got a problem and its not everybody there is pro to coding.

    EDIT by Moderator: merged posts, please use the edit button instead of double posting.
     
    Last edited by a moderator: Jun 5, 2016
  12. Offline

    DarkBladee12

    fls1234 If you've learned the basics you should know how to initialize variables...
     
  13. Offline

    fls1234

    I forgot it
     
  14. Offline

    xTrollxDudex

    fls1234
    Then what is the error now?
     
  15. Offline

    fls1234

    I dont get a error Its because i can do /feastgame join before an Admin did /feastgame host
     
  16. Offline

    xTrollxDudex

    fls1234
    Well i don't see your boolean. Also, use an enum for game status, that's a recursive call when you use it
     
  17. Offline

    fls1234

    I tryed with booleans but it dont Work.
     
  18. Offline

    Jalau

  19. Offline

    fls1234

    The problem is i don't need any thing from that i only need help with the /feastgame join before an Admin did /featgame host and there is nothing there that can help me.

    Emm i tried with the Enum
    Code:java
    1. public enum GameStatus {
    2.  
    3. GameStatus{
    4.  
    5. };
    6.  
    7. public static GameStatus NOT_RUNNING() {
    8.  
    9. return GameStatus;
    10. };
    11.  
    12.  
    13. public static GameStatus INGAME(){
    14.  
    15. return GameStatus;
    16. };
    17. public static GameStatus COUNTDOWN(){
    18. return GameStatus;
    19. };
    20.  
    21. }


    EDIT by Moderator: merged posts, please use the edit button instead of double posting.
     
    Last edited by a moderator: Jun 5, 2016
  20. Offline

    xTrollxDudex

    fls1234
    Yeah. You need to learn java.

    Post what you did with the booleans please
     
  21. Offline

    fls1234

    I configured it out :D
     
Thread Status:
Not open for further replies.

Share This Page