1. Es freut uns dass du in unser Minecraft Forum gefunden hast. Hier kannst du mit über 130.000 Minecraft Fans über Minecraft diskutieren, Fragen stellen und anderen helfen. In diesem Minecraft Forum kannst du auch nach Teammitgliedern, Administratoren, Moderatoren , Supporter oder Sponsoren suchen. Gerne kannst du im Offtopic Bereich unseres Minecraft Forums auch über nicht Minecraft spezifische Themen reden. Wir hoffen dir gefällt es in unserem Minecraft Forum!

[GELÖST]Meine AutoRespawn Methode funktionert nicht. HILFE

Dieses Thema im Forum "Programmierung" wurde erstellt von Walfisch, 29. Oktober 2015.

Status des Themas:
Es sind keine weiteren Antworten möglich.
  1. Walfisch
    Offline

    Walfisch

    Registriert seit:
    23. Mai 2015
    Beiträge:
    26
    Minecraft:
    Walfisch
    Hey , ich bin momentan dabei ein Minigame zu programmieren. Nun war ich dabei, eine AutoRespawn Methode zu programmieren.
    Mit wird als Fehler angezeigt :
    "Caused by: java.lang.IllegalArgumentException: Plugin cannot be null"
    Heißt also, dass "Plugin" nicht null sein darf, allerdings habe ich Plugin ja Code definiert ( siehe code).
    Nun weiß ich nicht weiter und stelle die Frage an die Community. :)

    Code (Text):
    1. package de.flaming.Listeners;
    2.  
    3. import net.minecraft.server.v1_8_R3.PacketPlayInClientCommand;
    4. import net.minecraft.server.v1_8_R3.PacketPlayInClientCommand.EnumClientCommand;
    5.  
    6. import org.bukkit.Bukkit;
    7. import org.bukkit.Material;
    8. import org.bukkit.craftbukkit.v1_8_R3.entity.CraftPlayer;
    9. import org.bukkit.entity.Entity;
    10. import org.bukkit.entity.Player;
    11. import org.bukkit.event.EventHandler;
    12. import org.bukkit.event.Listener;
    13. import org.bukkit.event.entity.PlayerDeathEvent;
    14. import org.bukkit.inventory.ItemStack;
    15. import org.bukkit.inventory.meta.ItemMeta;
    16. import org.bukkit.plugin.Plugin;
    17.  
    18. import de.flaming.main.Main;
    19. import de.flaming.main.Manager;
    20.  
    21. public class PlayerDeathListener implements Listener{
    22.    
    23.     public static Plugin plugin;
    24.    
    25.     public PlayerDeathListener(Plugin plugin){
    26.         this.plugin = plugin;
    27.    
    28.     }
    29.    
    30.    
    31.     public void Autorespawn(final Player player,int Time){
    32.         Bukkit.getScheduler().runTaskLater(PlayerDeathListener.plugin, new Runnable() {
    33.            
    34.             @Override
    35.             public void run() {
    36.                 player.spigot().respawn();
    37.                
    38.             }
    39.         }, Time);
    40.     }
    41.    
    42.    
    43.    
    44.     @EventHandler
    45.     public void onDeath(PlayerDeathEvent e){
    46.         Player player =(Player)  e.getEntity();
    47.         Manager.Autorespawn(player, 2);
    48.        
    49.     }      
    50. }

    Code (Text):
    1. import java.util.ArrayList;
    2.  
    3. import org.bukkit.Bukkit;
    4. import org.bukkit.Material;
    5. import org.bukkit.command.Command;
    6. import org.bukkit.command.CommandExecutor;
    7. import org.bukkit.command.CommandSender;
    8. import org.bukkit.configuration.file.FileConfiguration;
    9. import org.bukkit.configuration.file.YamlConfiguration;
    10. import org.bukkit.event.player.PlayerKickEvent;
    11. import org.bukkit.inventory.Inventory;
    12. import org.bukkit.inventory.ItemStack;
    13. import org.bukkit.inventory.meta.ItemMeta;
    14. import org.bukkit.plugin.PluginManager;
    15. import org.bukkit.plugin.java.JavaPlugin;
    16. import org.bukkit.scheduler.BukkitTask;
    17.  
    18. import de.flaming.COMMANDS.command_kits;
    19. import de.flaming.COMMANDS.command_setspawn;
    20. import de.flaming.COMMANDS.command_spawn;
    21. import de.flaming.Listeners.InteractListener;
    22. import de.flaming.Listeners.InventoryClickListener;
    23. import de.flaming.Listeners.PlayerDeathListener;
    24. import de.flaming.Listeners.PlayerJoinListener;
    25. import de.flaming.Listeners.PlayerMoveListener;
    26. import de.flaming.Listeners.PlayerRespawnListener;
    27.  
    28. public class Main extends JavaPlugin{
    29.    
    30.     public static String prefix = " §8[§cFFA§8]";
    31.     public static String noperm = prefix + "§8 Du hast dafür keine Rechte";
    32.    
    33.     public static Inventory inv = null;
    34.    
    35.     public static ArrayList<String> hatkit = new ArrayList<String>();
    36.     public static ArrayList<String> db = new ArrayList<String>();    
    37.     public static ArrayList<String> hatkit1 = new ArrayList<String>();
    38.     public static ArrayList<String> hatkit2 = new ArrayList<String>();
    39.     public static ArrayList<String> hatkit3 = new ArrayList<String>();
    40.    
    41.    
    42.     public static BukkitTask shed;
    43.    
    44.    
    45.     public static File config = new File("plugins/FFA", "config.yml");
    46.     public static FileConfiguration cfg = YamlConfiguration.loadConfiguration(config);
    47.  
    48.    
    49.  
    50.    
    51.     public void onEnable(){
    52.         System.out.println();
    53.         //itemstacks
    54.        
    55.         ItemStack Kit1 = new ItemStack(Material.IRON_SWORD);
    56.         ItemMeta Kit1Meta = Kit1.getItemMeta();
    57.         Kit1Meta.setDisplayName("§4'§bDas §cKrieger §bKIT§4'");
    58.         Kit1.setItemMeta(Kit1Meta);
    59.        
    60.         ItemStack Kit2 = new ItemStack(Material.POTION);
    61.         ItemMeta Kit2Meta = Kit2.getItemMeta();
    62.         Kit2Meta.setDisplayName("§4'§bDas §5Magier §bKit§4'");
    63.         Kit2.setItemMeta(Kit2Meta);
    64.        
    65.         ItemStack Kit3 = new ItemStack(Material.BOW);
    66.         ItemMeta Kit3Meta = Kit3.getItemMeta();
    67.         Kit3Meta.setDisplayName("§4'§bDas §3Archer §bKit§4'");
    68.         Kit3.setItemMeta(Kit3Meta);
    69.        
    70.         inv  = Bukkit.createInventory(null, 9, "§2 Bitte Wähle ein §b Kit!");
    71.         inv.setItem(2, Kit1);
    72.         inv.setItem(4, Kit2);
    73.         inv.setItem(6, Kit3);
    74.        
    75.         PluginManager pm = Bukkit.getPluginManager();
    76.         pm.registerEvents(new PlayerJoinListener(this), this);
    77.         pm.registerEvents(new InteractListener(), this);
    78.         pm.registerEvents(new InventoryClickListener(), this);
    79.         pm.registerEvents(new PlayerMoveListener(this), this);
    80.         pm.registerEvents(new PlayerDeathListener(this), this);
    81.         pm.registerEvents(new PlayerRespawnListener(this), this);
    82.         getCommand("setspawn").setExecutor(new command_setspawn());
    83.         getCommand("spawn").setExecutor(new command_spawn());  
    84.         getCommand("setffa").setExecutor(new command_setspawn());
    85.         getCommand("kits").setExecutor(new command_kits());
    86.  
    87.    
    88.    
    89.        
    90.        
    91.     }
    92.    
    93.    
    94.    
    95. }
    96.  

    Code (Text):
    1. org.bukkit.event.EventException
    2.         at org.bukkit.plugin.java.JavaPluginLoader$1.execute(JavaPluginLoader.java:310) ~[spigot.jar:git-Spigot-f94fe8f-219686b]
    3.         at org.bukkit.plugin.RegisteredListener.callEvent(RegisteredListener.java:62) ~[spigot.jar:git-Spigot-f94fe8f-219686b]
    4.         at org.bukkit.plugin.SimplePluginManager.fireEvent(SimplePluginManager.java:502) [spigot.jar:git-Spigot-f94fe8f-219686b]
    5.         at org.bukkit.plugin.SimplePluginManager.callEvent(SimplePluginManager.java:487) [spigot.jar:git-Spigot-f94fe8f-219686b]
    6.         at org.bukkit.craftbukkit.v1_8_R3.event.CraftEventFactory.callPlayerDeathEvent(CraftEventFactory.java:395) [spigot.jar:git-Spigot-f94fe8f-219686b]
    7.         at net.minecraft.server.v1_8_R3.EntityPlayer.die(EntityPlayer.java:417) [spigot.jar:git-Spigot-f94fe8f-219686b]
    8.         at net.minecraft.server.v1_8_R3.EntityLiving.damageEntity(EntityLiving.java:811) [spigot.jar:git-Spigot-f94fe8f-219686b]
    9.         at net.minecraft.server.v1_8_R3.EntityHuman.damageEntity(EntityHuman.java:800) [spigot.jar:git-Spigot-f94fe8f-219686b]
    10.         at net.minecraft.server.v1_8_R3.EntityPlayer.damageEntity(EntityPlayer.java:496) [spigot.jar:git-Spigot-f94fe8f-219686b]
    11.         at net.minecraft.server.v1_8_R3.EntityLiving.G(EntityLiving.java:101) [spigot.jar:git-Spigot-f94fe8f-219686b]
    12.         at net.minecraft.server.v1_8_R3.CommandKill.execute(SourceFile:34) [spigot.jar:git-Spigot-f94fe8f-219686b]
    13.         at org.bukkit.craftbukkit.v1_8_R3.command.VanillaCommandWrapper.dispatchVanillaCommand(VanillaCommandWrapper.java:108) [spigot.jar:git-Spigot-f94fe8f-219686b]
    14.         at org.bukkit.craftbukkit.v1_8_R3.command.VanillaCommandWrapper.execute(VanillaCommandWrapper.java:43) [spigot.jar:git-Spigot-f94fe8f-219686b]
    15.         at org.bukkit.command.SimpleCommandMap.dispatch(SimpleCommandMap.java:141) [spigot.jar:git-Spigot-f94fe8f-219686b]
    16.         at org.bukkit.craftbukkit.v1_8_R3.CraftServer.dispatchCommand(CraftServer.java:640) [spigot.jar:git-Spigot-f94fe8f-219686b]
    17.         at net.minecraft.server.v1_8_R3.PlayerConnection.handleCommand(PlayerConnection.java:1162) [spigot.jar:git-Spigot-f94fe8f-219686b]
    18.         at net.minecraft.server.v1_8_R3.PlayerConnection.a(PlayerConnection.java:997) [spigot.jar:git-Spigot-f94fe8f-219686b]
    19.         at net.minecraft.server.v1_8_R3.PacketPlayInChat.a(PacketPlayInChat.java:45) [spigot.jar:git-Spigot-f94fe8f-219686b]
    20.         at net.minecraft.server.v1_8_R3.PacketPlayInChat.a(PacketPlayInChat.java:1) [spigot.jar:git-Spigot-f94fe8f-219686b]
    21.         at net.minecraft.server.v1_8_R3.PlayerConnectionUtils$1.run(SourceFile:13) [spigot.jar:git-Spigot-f94fe8f-219686b]
    22.         at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:471) [?:1.7.0_79]
    23.         at java.util.concurrent.FutureTask.run(FutureTask.java:262) [?:1.7.0_79]
    24.         at net.minecraft.server.v1_8_R3.SystemUtils.a(SystemUtils.java:19) [spigot.jar:git-Spigot-f94fe8f-219686b]
    25.         at net.minecraft.server.v1_8_R3.MinecraftServer.B(MinecraftServer.java:714) [spigot.jar:git-Spigot-f94fe8f-219686b]
    26.         at net.minecraft.server.v1_8_R3.DedicatedServer.B(DedicatedServer.java:374) [spigot.jar:git-Spigot-f94fe8f-219686b]
    27.         at net.minecraft.server.v1_8_R3.MinecraftServer.A(MinecraftServer.java:653) [spigot.jar:git-Spigot-f94fe8f-219686b]
    28.         at net.minecraft.server.v1_8_R3.MinecraftServer.run(MinecraftServer.java:556) [spigot.jar:git-Spigot-f94fe8f-219686b]
    29.         at java.lang.Thread.run(Thread.java:745) [?:1.7.0_79]
    30. Caused by: java.lang.IllegalArgumentException: Plugin cannot be null
    31.         at org.apache.commons.lang.Validate.notNull(Validate.java:192) ~[spigot.jar:git-Spigot-f94fe8f-219686b]
    32.         at org.bukkit.craftbukkit.v1_8_R3.scheduler.CraftScheduler.validate(CraftScheduler.java:397) ~[spigot.jar:git-Spigot-f94fe8f-219686b]
    33.         at org.bukkit.craftbukkit.v1_8_R3.scheduler.CraftScheduler.runTaskTimer(CraftScheduler.java:123) ~[spigot.jar:git-Spigot-f94fe8f-219686b]
    34.         at org.bukkit.craftbukkit.v1_8_R3.scheduler.CraftScheduler.runTaskLater(CraftScheduler.java:106) ~[spigot.jar:git-Spigot-f94fe8f-219686b]
    35.         at de.flaming.main.Manager.Autorespawn(Manager.java:173) ~[?:?]
    36.         at de.flaming.Listeners.PlayerDeathListener.onDeath(PlayerDeathListener.java:47) ~[?:?]
    37.         at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) ~[?:1.7.0_79]
    38.         at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57) ~[?:1.7.0_79]
    39.         at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) ~[?:1.7.0_79]
    40.         at java.lang.reflect.Method.invoke(Method.java:606) ~[?:1.7.0_79]
    41.         at org.bukkit.plugin.java.JavaPluginLoader$1.execute(JavaPluginLoader.java:306) ~[spigot.jar:git-Spigot-f94fe8f-219686b]
    42.         ... 27 more
    43.  

    Schonmal vielen Dank im Voraus! :)
     
    #1
  2. Werbung
    Online

    Werbung

  3. Walfisch
    Offline

    Walfisch

    Registriert seit:
    23. Mai 2015
    Beiträge:
    26
    Minecraft:
    Walfisch
    Hat sich schon erledigt...* BigFacepalmp* :D
     
    #2
Status des Themas:
Es sind keine weiteren Antworten möglich.