Problem/Bug PlayerJoinEvent, Scanner, teleport

Discussion in 'General Help' started by 0LUMIN4T0R, Jul 9, 2015.

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

    0LUMIN4T0R

    Hey Guys,
    i have a Problem with the following code.


    Code:
    @EventHandler
        public void onJoin(PlayerJoinEvent e) throws FileNotFoundException{
            Location GelbSpa = new Location(world, 91, 29, -33);
            Scanner s;
           
                s = new Scanner(new File("C:/Users/Ole/Dropbox/Minecraft/Run's/Server-Running/Lobby/Gelb.txt"));
           
            ArrayList<String> Gelb = new ArrayList<String>();
            while (s.hasNext()){
                Gelb.add(s.next());
               
            }
            s.close();
            for(String str : Gelb){
            Player    p = Bukkit.getPlayer(str);
            p.teleport(GelbSpa);
                p.sendMessage("Du wurdest zu Gelb teleportiert!");
            }
    The Server sends an error. I want to teleport all Players from Gelb.txt.

    Thanks for all answers.
    Ole
     
  2. Offline

    timtower Administrator Administrator Moderator

    @0LUMIN4T0R And what is the error? On what line is the error occurring?
     
  3. Offline

    0LUMIN4T0R

    How can i copy the error from the server?
     
  4. @0LUMIN4T0R You will have a server log, give us the latest one in pastebin.com
     
  5. Offline

    0LUMIN4T0R

    I found it thanks.

    Code:
    [15:09:30] [Server thread/ERROR]: Could not pass event PlayerJoinEvent to Run v0.5
    org.bukkit.event.EventException
        at org.bukkit.plugin.java.JavaPluginLoader$1.execute(JavaPluginLoader.java:302) ~[spigot.jar:git-Spigot-1649]
        at org.bukkit.plugin.RegisteredListener.callEvent(RegisteredListener.java:62) ~[spigot.jar:git-Spigot-1649]
        at org.bukkit.plugin.SimplePluginManager.fireEvent(SimplePluginManager.java:514) [spigot.jar:git-Spigot-1649]
        at org.bukkit.plugin.SimplePluginManager.callEvent(SimplePluginManager.java:499) [spigot.jar:git-Spigot-1649]
        at net.minecraft.server.v1_7_R4.PlayerList.c(PlayerList.java:265) [spigot.jar:git-Spigot-1649]
        at net.minecraft.server.v1_7_R4.PlayerList.a(PlayerList.java:152) [spigot.jar:git-Spigot-1649]
        at net.minecraft.server.v1_7_R4.LoginListener.c(LoginListener.java:119) [spigot.jar:git-Spigot-1649]
        at net.minecraft.server.v1_7_R4.LoginListener.a(LoginListener.java:44) [spigot.jar:git-Spigot-1649]
        at net.minecraft.server.v1_7_R4.NetworkManager.a(NetworkManager.java:189) [spigot.jar:git-Spigot-1649]
        at net.minecraft.server.v1_7_R4.ServerConnection.c(ServerConnection.java:81) [spigot.jar:git-Spigot-1649]
        at net.minecraft.server.v1_7_R4.MinecraftServer.v(MinecraftServer.java:734) [spigot.jar:git-Spigot-1649]
        at net.minecraft.server.v1_7_R4.DedicatedServer.v(DedicatedServer.java:289) [spigot.jar:git-Spigot-1649]
        at net.minecraft.server.v1_7_R4.MinecraftServer.u(MinecraftServer.java:584) [spigot.jar:git-Spigot-1649]
        at net.minecraft.server.v1_7_R4.MinecraftServer.run(MinecraftServer.java:490) [spigot.jar:git-Spigot-1649]
        at net.minecraft.server.v1_7_R4.ThreadServerApplication.run(SourceFile:628) [spigot.jar:git-Spigot-1649]
    Caused by: java.lang.UnsupportedOperationException
        at java.util.Scanner.remove(Unknown Source) ~[?:1.8.0_31]
        at Game.Main.onJoin(Main.java:109) ~[?:?]
        at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) ~[?:1.8.0_31]
        at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source) ~[?:1.8.0_31]
        at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source) ~[?:1.8.0_31]
        at java.lang.reflect.Method.invoke(Unknown Source) ~[?:1.8.0_31]
        at org.bukkit.plugin.java.JavaPluginLoader$1.execute(JavaPluginLoader.java:298) ~[spigot.jar:git-Spigot-1649]
        ... 14 more
    
     
  6. Moved to Bukkit Alternates.
     
  7. Offline

    0LUMIN4T0R

    I hope so.
    @bwfcwalshy

    When i delet the last 5 lines, there is no error. So the fault is in the last 5 lines

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

    0LUMIN4T0R

    Is there nobody who can help me? I changed the code a little bit.

    Code:
    @EventHandler
        public void onJoin(PlayerJoinEvent e) throws FileNotFoundException{
            Player p = e.getPlayer();
            Location GelbSpa = new Location(world, 91, 29, -33);
            Scanner s;
           
                s = new Scanner(new File("C:/Users/Ole/Dropbox/Minecraft/Run's/Server-Running/Lobby/Gelb.txt"));
           
            ArrayList<String> Gelb = new ArrayList<String>();
            while (s.hasNext()){
                Gelb.add(s.next());
               
            }
            s.close();
            if(Gelb.contains(p.getDisplayName())){
                gelb.addPlayer(p);
                p.teleport(GelbSpa);
               
            }
     
  9. Offline

    Tecno_Wizard

    @0LUMIN4T0R, please, no scanner. Scanner is one of the most bugged classes Sun ever wrote. Use BufferedReader and see if the issue goes away.
     
  10. Offline

    0LUMIN4T0R

    I tried it, but i won't be teleportet. But it prints that it read the file.

    Code:
        @EventHandler
        public void onJoin(PlayerJoinEvent e){
            Player p = e.getPlayer();
            world = p.getWorld();
            Location GelbSpa = new Location(world, 91, 29, -33);
            try{
             BufferedReader in = new BufferedReader(new FileReader(new File("C:/Users/Ole/Dropbox/Minecraft/Run's/Server-Running/Lobby/Gelb.txt")));
             System.out.println("Gelb.txt wurde erfolgreich geƶffnet!");
             ArrayList<String> Gelb = new ArrayList<String>();
             int line = 0;
             for (String x = in.readLine(); x != null; x = in.readLine())
             {
              
    
                 line++;
                 Gelb.add(x);
              
             }
             
         
         
            if(Gelb.contains(p.getPlayer().getDisplayName())){
                gelb.addPlayer(p);
                p.teleport(GelbSpa);
             
            }
            }
            catch(IOException er){
                System.out.println("Gelb.txt konnte nicht ausgelesen werden!");
            }
    
     
    Last edited: Jul 13, 2015
Thread Status:
Not open for further replies.

Share This Page