<init>() error.

Discussion in 'Plugin Development' started by tuskiomi, Aug 21, 2013.

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

    tuskiomi

    what would be the cause of a
    org.bukkit.plugin.InvalidPluginException: java.lang.NoSuchMethodException: plugins.plugin.<init>()
    i'm getting one and i have no clue what it means
    A) i want to know the cause.
    B)thanks in advance
    C) no code. i want to know the cause.
     
  2. Offline

    tommycake50

    Can you show us the WHOLE stacktrace?
     
  3. Offline

    tuskiomi

    4:10:52 PM [SEVERE] Could not load 'plugins\plugin.jar in folder 'plugins'
    4:10:52 PM org.bukkit.plugin.InvalidPluginException: java.lang.NoSuchMethodException: plugins.plugin.<init>()
    4:10:52 PM at org.bukkit.plugin.java.JavaPluginLoader.loadPlugin(JavaPluginLoader.java:184)
    4:10:52 PM at org.bukkit.plugin.SimplePluginManager.loadPlugin(SimplePluginManager.java:305)
    4:10:52 PM at org.bukkit.plugin.SimplePluginManager.loadPlugins(SimplePluginManager.java:230)
    4:10:52 PM at org.bukkit.craftbukkit.v1_6_R2.CraftServer.loadPlugins(CraftServer.java:239)
    4:10:52 PM at org.bukkit.craftbukkit.v1_6_R2.CraftServer.<init>(CraftServer.java:217)
    4:10:53 PM at net.minecraft.server.v1_6_R2.PlayerList.<init>(PlayerList.java:56)
    4:10:53 PM at net.minecraft.server.v1_6_R2.DedicatedPlayerList.<init>(SourceFile:11)
    4:10:53 PM at net.minecraft.server.v1_6_R2.DedicatedServer.init(DedicatedServer.java:106)
    4:10:53 PM at net.minecraft.server.v1_6_R2.MinecraftServer.run(MinecraftServer.java:391)
    4:10:53 PM at net.minecraft.server.v1_6_R2.ThreadServerApplication.run(SourceFile:582)
    4:10:53 PM Caused by: java.lang.NoSuchMethodException: plugins.plugin.<init>()
    4:10:53 PM at java.lang.Class.getConstructor0(Unknown Source)
    4:10:53 PM at java.lang.Class.getConstructor(Unknown Source)
    4:10:53 PM at org.bukkit.plugin.java.JavaPluginLoader.loadPlugin(JavaPluginLoader.java:176)
     
  4. Offline

    tommycake50

    Well, obviously it means it doesn't have a constructor.
    But i don't see why that wouldn't allow a plugin to load.
    Although i think i saw this error a while ago on these forums.
    I don't even know why it wants a constructor.
    Unless you have a private constructor and it cant load it but that would cause an IllegalAccessException.
    My guess is as good as your's tbh xD.
     
  5. Offline

    Saposhiente

    What's your plugin code?
     
    tommycake50 likes this.
  6. Offline

    Technius

    Your main class can only have a constructor with no parameters.
     
  7. Offline

    tuskiomi

    code:
    Code:java
    1. package plugins.MDFix;
    2.  
    3. import java.util.ArrayList;
    4. import java.util.logging.Logger;
    5.  
    6. import me.drakespirit.plugins.moneydrop.MoneyDrop;
    7. import me.drakespirit.plugins.moneydrop.events.MoneyDropEvent;
    8.  
    9. import org.bukkit.Location;
    10. import org.bukkit.command.Command;
    11. import org.bukkit.command.CommandSender;
    12. import org.bukkit.entity.EntityType;
    13. import org.bukkit.entity.Player;
    14. import org.bukkit.event.Listener;
    15. import org.bukkit.event.entity.CreatureSpawnEvent;
    16. import org.bukkit.event.entity.EntityDeathEvent;
    17. import org.bukkit.plugin.java.JavaPlugin;
    18.  
    19. class fix extends JavaPlugin implements Listener {
    20. protected static fix instance;
    21. protected static ArrayList<Long> tracker = new ArrayList<Long>();
    22.  
    23. //you can configure this. higher = more lag. less = less of a chance of finding a grinder.
    24. private static final int loghist = 10;
    25. //you can configure this. search radius for players. won't affect lag. more = higher chance of catching innocent players.
    26. //less = less chance of finding guilty players.
    27. private static final int radius = 2;
    28.  
    29.  
    30. protected static ArrayList<String> revokedPlayers = new ArrayList<String>();
    31. protected static ArrayList<Location> Ltrack = new ArrayList<Location>();
    32. protected static short[] LtrackS = new short[loghist];
    33. private static int trackindex = 0;
    34. protected static Logger log = Logger.getLogger("Minecraft");
    35.  
    36. protected static MoneyDrop min;
    37.  
    38. @Override
    39. public void onEnable() {
    40. getServer().getPluginManager().registerEvents(this, this);
    41.  
    42. for (int x = 0; x < LtrackS.length; x++) {
    43. LtrackS[x] = 0;
    44. }
    45.  
    46. }
    47.  
    48. public boolean onCommand(CommandSender SND, Command CMD, String CMDLabel,
    49. String[] args) {return false;}
    50. public void onDisable() {
    51. }
    52.  
    53. // add creature to list on spawn
    54. public void CSE(CreatureSpawnEvent e) {
    55. for (int x = -5; x < 6; x++) {
    56. for (int y = -5; y < 6; y++) {
    57. for (int z = -5; z < 6; z++) {
    58. if (e.getEntity()
    59. .getWorld()
    60. .getBlockAt(
    61. e.getEntity().getLocation().getBlockX() + x,
    62. e.getEntity().getLocation().getBlockY() + y,
    63. e.getEntity().getLocation().getBlockZ() + z)
    64. .getTypeId() == 52) {
    65. // only check for vanilla spawners
    66. tracker.add(e.getEntity().getUniqueId().node());
    67. }
    68.  
    69. }
    70. }
    71. }
    72.  
    73. }
    74.  
    75. public void EDE(EntityDeathEvent e) {
    76. int index = -1;
    77. if(e.getEntityType().equals(EntityType.PLAYER)){// if the killer is not a player we won't go thru this hoopla.
    78. Player p = (Player) e.getEntity();
    79. for (int i = 0; i < Ltrack.size(); i++) {// tracker itreator
    80.  
    81.  
    82.  
    83. // IF Add
    84. if (getL(e.getEntity().getLocation().getBlockX(),
    85. Ltrack.get(i).getBlockX()) <= radius) {
    86. if (getL(e.getEntity().getLocation().getBlockY(),
    87. Ltrack.get(i).getBlockY()) <= radius) {
    88. if (getL(e.getEntity().getLocation().getBlockZ(),
    89. Ltrack.get(i).getBlockZ()) <= radius) {
    90.  
    91. index = i;
    92. LtrackS[i]++;// found a match!!!!! now we break &check
    93. break;
    94. }
    95.  
    96. }
    97.  
    98. }
    99. // IF Add end
    100.  
    101. }
    102.  
    103. if (index != -1) {
    104. if (LtrackS[index] == 3) {// if we hit the same location 3 times
    105. p.sendMessage("[BugFix] Spawners aren't made to give money, please stop");
    106. p.sendMessage("[BugFix] warning level: 1/3");
    107.  
    108. }
    109. if(LtrackS[index] == 5){
    110. p.sendMessage("[BugFix] warning level: 2/3");
    111. }
    112. if(LtrackS[index] == 6){
    113. p.sendMessage("[BugFix] warning level: 3/3. moneydrop privilages revoked until next restart.");
    114. revokedPlayers.add(p.getDisplayName());
    115. }
    116. } else {// if we didn't hit that location
    117. Ltrack.set(trackindex, e.getEntity().getLocation());
    118. }
    119. }// we want to add indexes in not an infinite series.
    120. if(trackindex == loghist - 1){
    121. trackindex = 0;
    122. }else {
    123. trackindex++;
    124. }
    125. }
    126.  
    127. private int getL(int blockX, int blockX2) {// simple distance value
    128.  
    129. return Math.abs(Math.abs(blockX) - Math.abs(blockX2));
    130. }
    131.  
    132. public void MDE(MoneyDropEvent e) {// when money is dropped
    133. if (tracker.contains(e.getEntity().getUniqueId().node())) {
    134. e.setCancelled(true);
    135. return;
    136. }
    137. Player p = (Player) e.getEntity();
    138. if(revokedPlayers.contains(p.getDisplayName())){
    139. e.setCancelled(true);
    140. }
    141. }
    142.  
    143. }
    144. [/i]
     
  8. Offline

    Saposhiente

    Does your plugin.yml properly point to your main class?
    Meanwhile:
    Your class name should start with a capital letter and be more descriptive
    Your variable "instance" has no purpose; use "this" instead.
    You need to mark your event methods as EventHandlers with @EventHandler(priority = EventPriority.<some priority>, ignoreCancelled = true)
    see http://forums.bukkit.org/threads/getting-your-priorities-straight-the-plugin-version.788/ for choosing a priority
    You want PlayerDeathEvent, not EntityDeathEvent
    More names:
    loghist -> logHistory or logHist
    trackindex -> trackIndex
    CSE -> onCreatureSpawn
    EDE -> onPlayerDeath
    everything with L -> whatever L stands for (I certainly can't tell)
     
  9. Offline

    Polaris29

  10. Offline

    tuskiomi

    the instance varible is static, and can be used statically across my classes
    I will look into event priority, but as of now it is irrellevant
    no, i want entity death event. as in when a creature dies.
    all below
    yes, I get that my naming is vague, but it doesn't mave the method istelf any harder to understand.

    post under him:
    I tried making a whole new project but i get the same exact stacktrace as above ( with adjusted names for my classes)
     
  11. Offline

    tuskiomi

    anyone else??? i'm still not sure the cause.
     
Thread Status:
Not open for further replies.

Share This Page