Problem Forcing Spawn

Discussion in 'Plugin Development' started by thegarfish, Aug 17, 2013.

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

    thegarfish

    Hey guys I just made a simple plugin for my server that forces the play to the spawnpoint of the server.

    My main issue is that when they join via bungee the will remain in the portal. I want a plugin to counteract this.

    Code:
    Code:java
    1. package me.thegarfish.force;
    2.  
    3. import java.util.logging.Logger;
    4.  
    5.  
    6.  
    7.  
    8. import org.bukkit.Bukkit;
    9. import org.bukkit.Location;
    10. import org.bukkit.event.EventHandler;
    11. import org.bukkit.event.player.PlayerJoinEvent;
    12. import org.bukkit.plugin.java.JavaPlugin;
    13.  
    14. public class Force extends JavaPlugin{
    15.  
    16. Location spawn = new Location(Bukkit.getWorlds().get(0), 14, 64, 392);
    17.  
    18. @EventHandler
    19. public void onPlayerJoinEvent(PlayerJoinEvent event){
    20. event.getPlayer().teleport(this.spawn);
    21. }
    22. }


    Here is the crashlog:

    Code:
    2013-08-17 22:09:11 [SEVERE] Could not load 'plugins\ForceSpawn.jar' in folder 'plugins'
    org.bukkit.plugin.InvalidPluginException: java.lang.IndexOutOfBoundsException: Index: 0, Size: 0
        at org.bukkit.plugin.java.JavaPluginLoader.loadPlugin(JavaPluginLoader.java:182)
        at org.bukkit.plugin.SimplePluginManager.loadPlugin(SimplePluginManager.java:306)
        at org.bukkit.plugin.SimplePluginManager.loadPlugins(SimplePluginManager.java:230)
        at org.bukkit.craftbukkit.v1_6_R2.CraftServer.loadPlugins(CraftServer.java:243)
        at net.minecraft.server.v1_6_R2.DedicatedServer.init(DedicatedServer.java:117)
        at net.minecraft.server.v1_6_R2.MinecraftServer.run(MinecraftServer.java:397)
        at net.minecraft.server.v1_6_R2.ThreadServerApplication.run(SourceFile:582)
    Caused by: java.lang.IndexOutOfBoundsException: Index: 0, Size: 0
        at java.util.ArrayList.rangeCheck(Unknown Source)
        at java.util.ArrayList.get(Unknown Source)
        at me.thegarfish.force.Force.<init>(Force.java:19)
        at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
        at sun.reflect.NativeConstructorAccessorImpl.newInstance(Unknown Source)
        at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(Unknown Source)
        at java.lang.reflect.Constructor.newInstance(Unknown Source)
        at org.bukkit.plugin.java.JavaPluginLoader.loadPlugin(JavaPluginLoader.java:178)
        ... 6 more
     
  2. Offline

    fireblast709

    Code:
     Location spawn;
     
    @Override
    public void onEnable()
    {
        this.spawn = new Location(Bukkit.getWorlds().get(0), 14, 64, 392);
    }
     
  3. Offline

    The_Doctor_123

    By the way.. if you didn't know, your class does not implement Listener and you did not register events to that class.
     
  4. Offline

    thegarfish

    Here is what I have, when I join nothing happens still.

    Code:java
    1. package me.thegarfish.force;
    2.  
    3. import org.bukkit.Bukkit;
    4. import org.bukkit.Location;
    5. import org.bukkit.event.EventHandler;
    6. import org.bukkit.event.player.PlayerJoinEvent;
    7. import org.bukkit.plugin.java.JavaPlugin;
    8.  
    9. public class Force extends JavaPlugin {
    10.  
    11. Location spawn;
    12.  
    13. @Override
    14. public void onEnable()
    15. {
    16. this.spawn = new Location(Bukkit.getWorlds().get(0), 14, 64, 392);
    17. }
    18. @EventHandler
    19. public void onPlayerJoinEvent(PlayerJoinEvent event){
    20. event.getPlayer().teleport(this.spawn);
    21. }
    22. }
     
Thread Status:
Not open for further replies.

Share This Page