Error occurred while enabling [Plugin] (Is it up to date?)

Discussion in 'Plugin Development' started by DevMax_Plg, Jul 9, 2019.

  1. Offline

    DevMax_Plg

    Please help me

    I'm getting this error everytime my server loads:

    Code:java
    1. Error occurred while enabling LobbySystem v1.0 Beta (Is it up to date?)
    2. at de.max.lobby.voting.Voting.initVotingInventorys(Voting.java:42) ~[?:?]
    3. at de.max.lobby.voting.Voting.<init>(Voting.java:33) ~[?:?]
    4. at de.max.lobby.main.Main.initVoting(Main.java:88) ~[?:?]
    5. at de.max.lobby.main.Main.init(Main.java:96) ~[?:?]
    6. at de.max.lobby.main.Main.onEnable(Main.java:51) ~[?:?]
    7. at org.bukkit.plugin.java.JavaPlugin.setEnabled(JavaPlugin.java:291) ~[spigot.jar:git-Spigot-7d15d07-c194444]
    8. at org.bukkit.plugin.java.JavaPluginLoader.enablePlugin(JavaPluginLoader.java:340) [spigot.jar:git-Spigot-7d15d07-c194444]
    9. at org.bukkit.plugin.SimplePluginManager.enablePlugin(SimplePluginManager.java:405) [spigot.jar:git-Spigot-7d15d07-c194444]
    10. at org.bukkit.craftbukkit.v1_9_R1.CraftServer.loadPlugin(CraftServer.java:361) [spigot.jar:git-Spigot-7d15d07-c194444]
    11. at org.bukkit.craftbukkit.v1_9_R1.CraftServer.enablePlugins(CraftServer.java:321) [spigot.jar:git-Spigot-7d15d07-c194444]
    12. at org.bukkit.craftbukkit.v1_9_R1.CraftServer.reload(CraftServer.java:745) [spigot.jar:git-Spigot-7d15d07-c194444]
    13. at org.bukkit.Bukkit.reload(Bukkit.java:539) [spigot.jar:git-Spigot-7d15d07-c194444]
    14. at org.bukkit.command.defaults.ReloadCommand.execute(ReloadCommand.java:25) [spigot.jar:git-Spigot-7d15d07-c194444]
    15. at org.bukkit.command.SimpleCommandMap.dispatch(SimpleCommandMap.java:141) [spigot.jar:git-Spigot-7d15d07-c194444]
    16. at org.bukkit.craftbukkit.v1_9_R1.CraftServer.dispatchCommand(CraftServer.java:645) [spigot.jar:git-Spigot-7d15d07-c194444]
    17. at org.bukkit.craftbukkit.v1_9_R1.CraftServer.dispatchServerCommand(CraftServer.java:631) [spigot.jar:git-Spigot-7d15d07-c194444]
    18. at net.minecraft.server.v1_9_R1.DedicatedServer.aL(DedicatedServer.java:437) [spigot.jar:git-Spigot-7d15d07-c194444]
    19. at net.minecraft.server.v1_9_R1.DedicatedServer.D(DedicatedServer.java:401) [spigot.jar:git-Spigot-7d15d07-c194444]
    20. at net.minecraft.server.v1_9_R1.MinecraftServer.C(MinecraftServer.java:655) [spigot.jar:git-Spigot-7d15d07-c194444]
    21. at net.minecraft.server.v1_9_R1.MinecraftServer.run(MinecraftServer.java:554) [spigot.jar:git-Spigot-7d15d07-c194444]


    That's my Voting.java:
    Code:Java
    1. package de.max.lobby.voting;
    2.  
    3. import java.util.ArrayList;
    4. import java.util.Collections;
    5. import java.util.HashMap;
    6.  
    7. import org.bukkit.Bukkit;
    8. import org.bukkit.Material;
    9. import org.bukkit.entity.Player;
    10. import org.bukkit.inventory.Inventory;
    11.  
    12. import de.max.lobby.main.Main;
    13. import de.max.lobby.util.ItemBuilder;
    14.  
    15. public class Voting {
    16.  
    17. public static final int MAP_AMOUNT = 2;
    18. public static final String VOTING_INVENTORY_TITLE = "§6§lMap-Voting";
    19.  
    20. private Main plugin;
    21. private ArrayList<Map> maps;
    22. private Map[] votingMaps;
    23. private int[] votingInventoryOrder = new int[]{3, 5};
    24. private HashMap<String, Integer> playerVotes;
    25. private Inventory votingInventory;
    26.  
    27. public Voting(Main plugin, ArrayList<Map> maps) {
    28. this.plugin = plugin;
    29. this.maps = maps;
    30. votingMaps = new Map[Voting.MAP_AMOUNT];
    31. playerVotes = new HashMap<>();
    32.  
    33. initVotingInventorys();
    34. chooseRandomMaps();
    35. }
    36.  
    37. public void initVotingInventorys() {
    38. votingInventory = Bukkit.createInventory(null, 9 * 1, Voting.VOTING_INVENTORY_TITLE);
    39. for(int i = 0; i < votingMaps.length; i++) {
    40. Map currentMap = votingMaps[i];
    41. votingInventory.setItem(votingInventoryOrder[i], new ItemBuilder(Material.PAPER)
    42. .setDisplayName("§6" + currentMap.getName() + "§c - §c§l" + currentMap.getVotes() + " Votes")
    43. .setLore(" ", "§7Erbauer: §a" + currentMap.getBuilder()).build());
    44. }
    45. }
    46.  
    47.  
    48. private void chooseRandomMaps() {
    49. for(int i = 0; i < votingMaps.length; i++) {
    50. Collections.shuffle(maps);
    51. votingMaps[i] = maps.remove(0);
    52. }
    53. }
    54.  
    55.  
    56. public Map getWinnerMap() {
    57. Map winnerMap = votingMaps[0];
    58. for(int i = 0; i < votingMaps.length; i++) {
    59. if(votingMaps[i].getVotes() >= winnerMap.getVotes()) {
    60. winnerMap = votingMaps[i];
    61. }
    62. }
    63. return winnerMap;
    64. }
    65.  
    66. public void vote(Player player, int votingMap) {
    67. if(playerVotes.containsKey(player.getName())) {
    68. votingMaps[votingMap].addVote();
    69. player.closeInventory();
    70. player.sendMessage(Main.PREFIX + "§aDu hast für die Map §6" + votingMaps[votingMap].getName() + "§a abgestimmt.");
    71. playerVotes.put(player.getName(), votingMap);
    72. initVotingInventorys();
    73. } else {
    74. player.sendMessage(Main.PREFIX + "§cDu hast bereits gevotet.");
    75. }
    76. }
    77.  
    78. public HashMap<String, Integer> getPlayerVotes() {
    79. return playerVotes;
    80. }
    81.  
    82. public Inventory getVotingInventory() {
    83. return votingInventory;
    84. }
    85.  
    86. public int[] getVotingInventoryOrder() {
    87. return votingInventoryOrder;
    88. }
    89.  
    90. public Map[] getVotingMaps() {
    91. return votingMaps;
    92. }
    93.  
    94. }[/i][/i][/i][/i][/i]



    I don't know what is null.
     
  2. Online

    KarimAKL

  3. Offline

    Kars

    @KarimAKL is right currentMap is null. You're initialising votingMaps to be an array of Map. After that you are assigning votingMaps (which is null) to currentMap.

    Line 43 in your example (currentMap.getName) is causing the exception.
     

Share This Page