Mein Plugin funktioniert nicht?

Bitte aktiviere JavaScript!
Hey ich habe ein Plugin geschrieben und das funktioniert irgendwie nicht. Weiß jmd woran das liegt?
Ich habe eine Fehlermeldung bei

Code:
        public void getTeam(Player p) {
Alles andere sollte gehen :D
Das Plugin soll ScoreBoard und Tabliste beinhalten

Java:
package de.rainijdev.scoreboard;

import org.bukkit.Bukkit;
import org.bukkit.entity.Player;
import org.bukkit.scoreboard.Scoreboard;
import org.bukkit.scoreboard.Team;

import ru.tehkode.permissions.bukkit.PermissionsEx;

public class SortTab {
   
    public static void registerTeams(Scoreboard board) {
        Team owner = board.getTeam("00Owner");
        Team admin = board.getTeam("01Admin");
        Team dev = board.getTeam("02Developer");
        Team mod = board.getTeam("03Moderator");
        Team supp = board.getTeam("04Supporter");
        Team build = board.getTeam("05Builder");
        Team farmer = board.getTeam("06Farmer");
        Team yter = board.getTeam("07YTer+");
        Team yter2 = board.getTeam("08YouTuber");
        Team supreme = board.getTeam("09Supreme");
        Team griefer = board.getTeam("10Griefer");
        Team titan = board.getTeam("11Titan");
        Team legende = board.getTeam("12Legende");
        Team ultra = board.getTeam("13Ultra");
        Team premium = board.getTeam("14Premium");
        Team spieler = board.getTeam("15Spieler");
       
        if(owner == null) {
            owner = board.registerNewTeam("00Owner");
        }
        if(admin == null) {
            admin = board.registerNewTeam("01Admin");
        }
        if(dev == null) {
            dev = board.registerNewTeam("02Developer");
        }
        if(mod == null) {
            mod = board.registerNewTeam("03Moderator");
        }
        if(supp == null) {
            supp = board.registerNewTeam("04Supporter");
        }
        if(build == null) {
            build = board.registerNewTeam("05Builder");
        }
        if(farmer == null) {
            farmer = board.registerNewTeam("06Farmer");
        }
        if(yter == null) {
            yter = board.registerNewTeam("07Yter+");
        }
        if(yter2 == null) {
            yter2 = board.registerNewTeam("08YouTuber");
        }
        if(supreme == null) {
            supreme = board.registerNewTeam("09Supreme");
        }
        if(griefer == null) {
            griefer = board.registerNewTeam("10Griefer");
        }
        if(titan == null) {
            titan = board.registerNewTeam("11Titan");
        }
        if(legende == null) {
            legende = board.registerNewTeam("12Legende");
        }
        if(ultra == null) {
            ultra = board.registerNewTeam("13Ultra");
        }
        if(premium == null) {
            premium = board.registerNewTeam("14Premium");
        }
        if(spieler == null) {
            spieler = board.registerNewTeam("15Spieler");
        }

        owner.setPrefix("§4Owner §7\u2503 §4");
        admin.setPrefix("§4Admin §7\u2503 §4");
        dev.setPrefix("§eDev §7\u2503 §e");
        mod.setPrefix("§cMod §7\u2503 §c");
        supp.setPrefix("§9Supp §7\u2503 §9");
        build.setPrefix("§2Build §7\u2503 §2");
        farmer.setPrefix("§9T-Supp §7\u2503 §9");
        yter.setPrefix("§2T-Build §7\u2503 §2");
        yter2.setPrefix("§2OF \u2503 §2");
        supreme.setPrefix("§5YouTuber \u2503 §5");
        griefer.setPrefix("§aEmerald \u2503 §a");
        titan.setPrefix("§bDiamond \u2503 §b");
        legende.setPrefix("§dVIP \u2503 §d");
        ultra.setPrefix("§dVIP \u2503 §d");
        premium.setPrefix("§dVIP \u2503 §d");
        spieler.setPrefix("§7Spieler \u2503 ");
       
       
    }
   
    @SuppressWarnings("deprecation")
    public static void registerPlayer(Scoreboard board) {
        public void getTeam(Player p) {
           
        }
        for(Player p2 : Bukkit.getOnlinePlayers()) {
            if (p.hasPermission("raini.owner")) {
                board.getTeam("00owner").addPlayer(p2);
            } else if(p.hasPermission("raini.admin")) {
                board.getTeam("01admin").addPlayer(p2);
            } else if(p.hasPermission("raini.developer")) {
                board.getTeam("02developer").addPlayer(p2);
            } else if(p.hasPermission("raini.moderator")) {
                board.getTeam("03moderator").addPlayer(p2);
            } else if(p.hasPermission("raini.supporter")) {
                board.getTeam("04supporter").addPlayer(p2);
            } else if(p.hasPermission("raini.builder")) {
                board.getTeam("05builder").addPlayer(p2);
            } else if(p.hasPermission("raini.farmer")) {
                board.getTeam("06farmer").addPlayer(p2);
            } else if(p.hasPermission("raini.yter+")) {
                board.getTeam("07yter").addPlayer(p2);
            } else if(p.hasPermission("raini.yter")) {
                board.getTeam("08yter2").addPlayer(p2);
            } else if(p.hasPermission("raini.supreme")) {
                board.getTeam("09supreme").addPlayer(p2);
            } else if(p.hasPermission("raini.griefer")) {
                board.getTeam("10griefer").addPlayer(p2);
            } else if(p.hasPermission("raini.titan")) {
                board.getTeam("11titan").addPlayer(p2);
            } else if(p.hasPermission("raini.legende")) {
                board.getTeam("12legende").addPlayer(p2);
            } else if(p.hasPermission("raini.ultra")) {
                board.getTeam("13ultra").addPlayer(p2);
            } else if(p.hasPermission("raini.premium")) {
                board.getTeam("14premium").addPlayer(p2);
            } else {
                board.getTeam("15spieler").addPlayer(p2);
            }
        }
       
    }
   
    public static String getTeamName(Player p) {
        if(PermissionsEx.getUser(p).inGroup("owner")) {
            return "00owner";
        } else if(PermissionsEx.getUser(p).inGroup("admin")) {
            return "01admin";
        } else if(PermissionsEx.getUser(p).inGroup("developer")) {
            return "02developer";
        } else if(PermissionsEx.getUser(p).inGroup("moderator")) {
            return "03moderator";
        } else if(PermissionsEx.getUser(p).inGroup("supporter")) {
            return "04supporter";
        } else if(PermissionsEx.getUser(p).inGroup("builder")) {
            return "05builder";
        } else if(PermissionsEx.getUser(p).inGroup("farmer")) {
            return "06farmer";
        } else if(PermissionsEx.getUser(p).inGroup("yter+")) {
            return "07yter";
        } else if(PermissionsEx.getUser(p).inGroup("yter")) {
            return "08yter2";
        } else if(PermissionsEx.getUser(p).inGroup("supreme")) {
            return "09supreme";
        } else if(PermissionsEx.getUser(p).inGroup("griefer")) {
            return "10griefer";
        } else if(PermissionsEx.getUser(p).inGroup("titan")) {
            return "11titan";
        } else if(PermissionsEx.getUser(p).inGroup("legende")) {
            return "legende";
        } else if(PermissionsEx.getUser(p).inGroup("ultra")) {
            return "12ultra";
        } else if(PermissionsEx.getUser(p).inGroup("premium")) {
            return "12premium";
        } else {
            return "13spieler";
        }
    }
   
   
   
}
 
Zuletzt bearbeitet von einem Moderator:
Du deklarierst eine Methode `getTeam(Player p)` innerhalb einer anderen Methode `registerPlayer(Scoreboard board)`. So etwas geht nicht in Java.
Java:
public static void registerPlayer(Scoreboard board) {
    public void getTeam(Player p) {
    }
    ...
}
 
Habe das jetzt so geändert aber leider kommt immer noch die Fehlermeldung bei

Java:
        public void getTeam(Player p) {
mhh...

Java:
package de.rainijdev.scoreboard;

import org.bukkit.Bukkit;
import org.bukkit.entity.Player;
import org.bukkit.scoreboard.Scoreboard;
import org.bukkit.scoreboard.Team;

import ru.tehkode.permissions.bukkit.PermissionsEx;

public class SortTab {
   
    public static void registerTeams(Scoreboard board) {
        Team owner = board.getTeam("00Owner");
        Team admin = board.getTeam("01Admin");
        Team dev = board.getTeam("02Developer");
        Team mod = board.getTeam("03Moderator");
        Team supp = board.getTeam("04Supporter");
        Team build = board.getTeam("05Builder");
        Team farmer = board.getTeam("06Farmer");
        Team yter = board.getTeam("07YTer+");
        Team yter2 = board.getTeam("08YouTuber");
        Team supreme = board.getTeam("09Supreme");
        Team griefer = board.getTeam("10Griefer");
        Team titan = board.getTeam("11Titan");
        Team legende = board.getTeam("12Legende");
        Team ultra = board.getTeam("13Ultra");
        Team premium = board.getTeam("14Premium");
        Team spieler = board.getTeam("15Spieler");
       
        if(owner == null) {
            owner = board.registerNewTeam("00Owner");
        }
        if(admin == null) {
            admin = board.registerNewTeam("01Admin");
        }
        if(dev == null) {
            dev = board.registerNewTeam("02Developer");
        }
        if(mod == null) {
            mod = board.registerNewTeam("03Moderator");
        }
        if(supp == null) {
            supp = board.registerNewTeam("04Supporter");
        }
        if(build == null) {
            build = board.registerNewTeam("05Builder");
        }
        if(farmer == null) {
            farmer = board.registerNewTeam("06Farmer");
        }
        if(yter == null) {
            yter = board.registerNewTeam("07Yter+");
        }
        if(yter2 == null) {
            yter2 = board.registerNewTeam("08YouTuber");
        }
        if(supreme == null) {
            supreme = board.registerNewTeam("09Supreme");
        }
        if(griefer == null) {
            griefer = board.registerNewTeam("10Griefer");
        }
        if(titan == null) {
            titan = board.registerNewTeam("11Titan");
        }
        if(legende == null) {
            legende = board.registerNewTeam("12Legende");
        }
        if(ultra == null) {
            ultra = board.registerNewTeam("13Ultra");
        }
        if(premium == null) {
            premium = board.registerNewTeam("14Premium");
        }
        if(spieler == null) {
            spieler = board.registerNewTeam("15Spieler");
        }

        owner.setPrefix("§4Owner §7\u2503 §4");
        admin.setPrefix("§4Admin §7\u2503 §4");
        dev.setPrefix("§eDev §7\u2503 §e");
        mod.setPrefix("§cMod §7\u2503 §c");
        supp.setPrefix("§9Supp §7\u2503 §9");
        build.setPrefix("§2Build §7\u2503 §2");
        farmer.setPrefix("§9T-Supp §7\u2503 §9");
        yter.setPrefix("§2T-Build §7\u2503 §2");
        yter2.setPrefix("§2OF \u2503 §2");
        supreme.setPrefix("§5YouTuber \u2503 §5");
        griefer.setPrefix("§aEmerald \u2503 §a");
        titan.setPrefix("§bDiamond \u2503 §b");
        legende.setPrefix("§dVIP \u2503 §d");
        ultra.setPrefix("§dVIP \u2503 §d");
        premium.setPrefix("§dVIP \u2503 §d");
        spieler.setPrefix("§7Spieler \u2503 ");
       
       
    }
   
    @SuppressWarnings("deprecation")
    public static void registerPlayer(Scoreboard board) {
        public void getTeam(Player p) {
           
        }
        for(Player p2 : Bukkit.getOnlinePlayers()) {
            if (p.hasPermission("raini.owner")) {
                board.getTeam("00owner").addPlayer(p2);
            } else if(p.hasPermission("raini.admin")) {
                board.getTeam("01admin").addPlayer(p2);
            } else if(p.hasPermission("raini.developer")) {
                board.getTeam("02developer").addPlayer(p2);
            } else if(p.hasPermission("raini.moderator")) {
                board.getTeam("03moderator").addPlayer(p2);
            } else if(p.hasPermission("raini.supporter")) {
                board.getTeam("04supporter").addPlayer(p2);
            } else if(p.hasPermission("raini.builder")) {
                board.getTeam("05builder").addPlayer(p2);
            } else if(p.hasPermission("raini.farmer")) {
                board.getTeam("06farmer").addPlayer(p2);
            } else if(p.hasPermission("raini.yter+")) {
                board.getTeam("07yter").addPlayer(p2);
            } else if(p.hasPermission("raini.yter")) {
                board.getTeam("08yter2").addPlayer(p2);
            } else if(p.hasPermission("raini.supreme")) {
                board.getTeam("09supreme").addPlayer(p2);
            } else if(p.hasPermission("raini.griefer")) {
                board.getTeam("10griefer").addPlayer(p2);
            } else if(p.hasPermission("raini.titan")) {
                board.getTeam("11titan").addPlayer(p2);
            } else if(p.hasPermission("raini.legende")) {
                board.getTeam("12legende").addPlayer(p2);
            } else if(p.hasPermission("raini.ultra")) {
                board.getTeam("13ultra").addPlayer(p2);
            } else if(p.hasPermission("raini.premium")) {
                board.getTeam("14premium").addPlayer(p2);
            } else {
                board.getTeam("15spieler").addPlayer(p2);
            }
        }
       
    }
   
    public static String getTeamName(Player p) {
        if(PermissionsEx.getUser(p).inGroup("owner")) {
            return "00owner";
        } else if(PermissionsEx.getUser(p).inGroup("admin")) {
            return "01admin";
        } else if(PermissionsEx.getUser(p).inGroup("developer")) {
            return "02developer";
        } else if(PermissionsEx.getUser(p).inGroup("moderator")) {
            return "03moderator";
        } else if(PermissionsEx.getUser(p).inGroup("supporter")) {
            return "04supporter";
        } else if(PermissionsEx.getUser(p).inGroup("builder")) {
            return "05builder";
        } else if(PermissionsEx.getUser(p).inGroup("farmer")) {
            return "06farmer";
        } else if(PermissionsEx.getUser(p).inGroup("yter+")) {
            return "07yter";
        } else if(PermissionsEx.getUser(p).inGroup("yter")) {
            return "08yter2";
        } else if(PermissionsEx.getUser(p).inGroup("supreme")) {
            return "09supreme";
        } else if(PermissionsEx.getUser(p).inGroup("griefer")) {
            return "10griefer";
        } else if(PermissionsEx.getUser(p).inGroup("titan")) {
            return "11titan";
        } else if(PermissionsEx.getUser(p).inGroup("legende")) {
            return "legende";
        } else if(PermissionsEx.getUser(p).inGroup("ultra")) {
            return "12ultra";
        } else if(PermissionsEx.getUser(p).inGroup("premium")) {
            return "12premium";
        } else {
            return "13spieler";
        }
    }
   
   
   
}
 
Zuletzt bearbeitet von einem Moderator:
Was hast du denn geändert? Du deklarierst _immer noch_ eine Methode innerhalb einer anderen Methode...
Was ich dir zeigen wollte, war das Problem bzw. die Ursache und nicht die Lösung.
 
Also nur noch einmal zum klaren Verständnis:
public static void registerPlayer(Scoreboard board) {
Ist der Kopf einer Methode. Diese geht, bis diese Öffnende Klammer wieder geschlossen wird.

public void getTeam(Player p) { ist auch der Kopf einer Methode. Dieser kommt aber direkt in der Methode registerPlayer.

Da nicht klar ist, was Du genau machen willst, kann also nur allgemein etwas gesagt werden:
Code:
public static void registerPlayer(Scoreboard board) {
  // Code der Methode registerPlayer kommt hier hin!
  // ...
} // Hier endet die Methode register Player!

public void getTeam(Player p) {
  // Hier kommt dann der Code der Methode getTeam hin!
  // ....
} // Und hier endet dann die Methode getTeam
Moderne IDEs rücken Code auch ein, so dass man gut sehen kann, auf welcher Ebene man gerade ist.
 
Also solche Dinge bei einem Anfänger? Wenn die Basis Syntax nicht sitzt, dann sollte man von inneren Klassen und so komplett die Finger lassen. (ggf. bei GUI Entwicklung dann die anonymen Klassen, aber Anfänger und GUI? Da gab es hier im Forum auch schon regelmäßig entsprechende Aussagen.)

Und Tobias hat natürlich Recht: Methode direkt in einer Methode geht nicht und wenn man da irgendwas sieht, dann hat man in der Methode eben eine Klasse ... Sprich: Lambda definiert eine anonyme Klasse oder man hat eine benannte, lokale Klasse,
 
Passende Stellenanzeigen aus deiner Region:

Neue Themen

Oben