Jump to content

Hast du schon das Minecraftforum.de-Gütesiegel gesehen? Hier kommst du dorthin!

JurassicBeast

Wie kann ich diesen Fehler lösen?

Empfohlene Beiträge

Hey Leute, ich habe ein MLG-Rush-Plugin programmiert und bin üblicherweise nicht schlecht darin Fehler zu lösen, aber solch ein Fehler ist mir noch nie vorgekommen, könnt ihr mir bitte helfen? 

Das ist der Fehler, der in der Konsole ausgegeben wird:

Bitte klicke auf den Link: http://prntscr.com/me8hft

 

Danke für deine Hilfe!

Liebe Grüsse JurassicBeast

Diesen Beitrag teilen


Link zum Beitrag
Auf anderen Seiten teilen

Du musst uns schon den Code dazu geben... Einmal von deinem SetupCommand und einmal von deiner MLGRush-Klasse.

Diesen Beitrag teilen


Link zum Beitrag
Auf anderen Seiten teilen

Das ist die MLG-Rush Klasse:

package de.pxav.mlgrush;

 

import de.pxav.mlgrush.commands.BuildCommand;
import de.pxav.mlgrush.commands.MainCommand;
import de.pxav.mlgrush.commands.SetupCommand;
import de.pxav.mlgrush.enums.GameState;
import de.pxav.mlgrush.gamestates.*;
import de.pxav.mlgrush.handler.PointsHandler;
import de.pxav.mlgrush.handler.ScoreboardHandler;
import de.pxav.mlgrush.handler.TabListHandler;
import de.pxav.mlgrush.handler.TeamHandler;
import de.pxav.mlgrush.items.InventoryManager;
import de.pxav.mlgrush.listener.*;
import de.pxav.mlgrush.maps.LocationHandler;
import de.pxav.mlgrush.maps.MapResetHandler;
import de.pxav.mlgrush.maps.RegionManager;
import de.pxav.mlgrush.maps.WorldManager;
import de.pxav.mlgrush.settings.ConfigManager;
import de.pxav.mlgrush.utils.*;
import org.bukkit.Bukkit;
import org.bukkit.plugin.PluginManager;
import org.bukkit.plugin.java.JavaPlugin;

public class MLGRush extends JavaPlugin {

    private final String PREFIX = "§8[§bMLGRush§8] §r";


    private IdleCountdown idleCountdown = new IdleCountdown();
    private LobbyCountdown lobbyCountdown = new LobbyCountdown();
    private WorldManager worldManager = new WorldManager();
    private LocationHandler locationHandler = new LocationHandler();
    private EndingCountdown endingCountdown = new EndingCountdown();
    private InventoryManager inventoryManager = new InventoryManager();
    private TeamHandler teamHandler = new TeamHandler();
    private ScoreboardHandler scoreboardHandler = new ScoreboardHandler();
    private TabListHandler tabListHandler = new TabListHandler();
    private PointsHandler pointsHandler = new PointsHandler();
    private PlayerMoveScheduler playerMoveScheduler = new PlayerMoveScheduler();
    private StartCountDown startCountDown = new StartCountDown();
    private MapResetHandler mapResetHandler = new MapResetHandler();
    private ConfigManager configManager = new ConfigManager();
    private RegionManager regionManager = new RegionManager();

    private static MLGRush instance;

    @Override
    public void onEnable() {
        setInstance(this);
        GameStateHandler.setGameState(GameState.LOBBY);
        GameStateHandler.setAllowMove(true);

        this.loadConfigurations();
        this.registerCommands();
        this.registerEvents();

        Bukkit.getScheduler().scheduleSyncDelayedTask(this, () -> {
            this.getWorldManager().prepareMaps();
            this.getScoreboardHandler().startUpdater();

        }, 4);

    }

    @Override
    public void onDisable() {
        this.getMapResetHandler().resetMap(true);
        setInstance(null);
    }

    private void loadConfigurations() {
        this.getConfigManager().loadFile();
        this.getConfigManager().loadSettings();

        this.getLocationHandler().loadFile();
        if(this.getConfigManager().isCacheLoader())
            this.getLocationHandler().loadLocations();
    }

    private void registerCommands() {
        new SetupCommand("setup");
        new MainCommand("mlgrush");
        new BuildCommand("build");
    }

    private void registerEvents() {
        final PluginManager pluginManager = Bukkit.getPluginManager();
        pluginManager.registerEvents(new PlayerJoinListener(), this);
        pluginManager.registerEvents(new ServerListPingListener(), this);
        pluginManager.registerEvents(new BlockBreakListener(), this);
        pluginManager.registerEvents(new PlayerQuitListener(), this);
        pluginManager.registerEvents(new PlayerInteractListener(), this);
        pluginManager.registerEvents(new InventoryClickListener(), this);
        pluginManager.registerEvents(new PlayerMoveListener(), this);
        pluginManager.registerEvents(new BlockPlaceListener(), this);
        pluginManager.registerEvents(new WeatherChangeListener(), this);
        pluginManager.registerEvents(new FoodLevelChangeListener(), this);
        pluginManager.registerEvents(new CraftItemListener(), this);
        pluginManager.registerEvents(new EntityDamageByEntityListener(), this);
        pluginManager.registerEvents(new EntityDamageListener(), this);
        pluginManager.registerEvents(new PlayerLoginListener(), this);
        pluginManager.registerEvents(new PlayerDropItemListener(), this);
        if(this.getConfigManager().isUseChatFormat())
            pluginManager.registerEvents(new AsyncPlayerChatListener(), this);
    }

    public static MLGRush getInstance() {
        return instance;
    }

    private static void setInstance(final MLGRush instance) {
        MLGRush.instance = instance;
    }

    public IdleCountdown getIdleCountdown() {
        return idleCountdown;
    }

    public LobbyCountdown getLobbyCountdown() {
        return lobbyCountdown;
    }

    public String getPrefix() {
        return PREFIX;
    }

    public WorldManager getWorldManager() {
        return worldManager;
    }

    public LocationHandler getLocationHandler() {
        return locationHandler;
    }

    public EndingCountdown getEndingCountdown() {
        return endingCountdown;
    }

    public InventoryManager getInventoryManager() {
        return inventoryManager;
    }

    public TeamHandler getTeamHandler() {
        return teamHandler;
    }

    public TabListHandler getTabListHandler() {
        return tabListHandler;
    }

    public ScoreboardHandler getScoreboardHandler() {
        return scoreboardHandler;
    }

    public PointsHandler getPointsHandler() {
        return pointsHandler;
    }

    public PlayerMoveScheduler getPlayerMoveScheduler() {
        return playerMoveScheduler;
    }

    public StartCountDown getStartCountDown() {
        return startCountDown;
    }

    public MapResetHandler getMapResetHandler() {
        return mapResetHandler;
    }

    public ConfigManager getConfigManager() {
        return configManager;
    }

    public RegionManager getRegionManager() {
        return regionManager;
    }
}

 

 

Das ist der SetupCommand:

package de.pxav.mlgrush.commands;

import de.pxav.mlgrush.MLGRush;
import de.pxav.mlgrush.enums.LocationType;
import de.pxav.mlgrush.utils.PlayerManager;
import org.bukkit.Bukkit;
import org.bukkit.Sound;
import org.bukkit.command.Command;
import org.bukkit.command.CommandExecutor;
import org.bukkit.command.CommandSender;
import org.bukkit.command.TabCompleter;
import org.bukkit.entity.Player;

import java.util.ArrayList;
import java.util.List;

public class SetupCommand implements CommandExecutor, TabCompleter {

    public SetupCommand(final String command) {
        Bukkit.getPluginCommand(command).setExecutor(this);
    }

    @Override
    public boolean onCommand(final CommandSender sender, final Command command, final String s, final String[] args) {

        if(sender instanceof Player) {
            final Player player = (Player) sender;
            final PlayerManager playerManager = new PlayerManager(player);
            if (player.hasPermission("mlgrush.setup")) {

                if(args.length == 1) {
                    boolean found = false;
                    for (LocationType locationType : LocationType.values()) {
                        if(args[0].equalsIgnoreCase(locationType.name())) {
                            if(locationType == LocationType.SPECTATOR) {
                                if(MLGRush.getInstance().getLocationHandler().getLocationByFile(LocationType.POS_1) != null
                                        && MLGRush.getInstance().getLocationHandler().getLocationByFile(LocationType.POS_2) != null) {
                                    if(MLGRush.getInstance().getRegionManager().isInRegion(player.getLocation())) {
                                        MLGRush.getInstance().getLocationHandler().addLocation(locationType.name(), player.getLocation());
                                        player.sendMessage(MLGRush.getInstance().getPrefix() + "§7Du hast die Location §a" + locationType.name() + " §7gesetzt!");
                                        found = true;
                                        break;
                                    } else {
                                        player.sendMessage(MLGRush.getInstance().getPrefix() + "§cDer Spectator Spawn muss sich in der gesetzten Region befinden.");
                                        return false;
                                    }
                                } else {
                                    player.sendMessage(MLGRush.getInstance().getPrefix() + "§7Bevor du den Spectator Spawn setzen kannst, musst du alle Positionen der Region setzen.");
                                    return false;
                                }
                            }
                            MLGRush.getInstance().getLocationHandler().addLocation(locationType.name(), player.getLocation());
                            player.sendMessage(MLGRush.getInstance().getPrefix() + "§7Du hast die Location §a" + locationType.name() + " §7gesetzt!");
                            found = true;
                            break;
                        }
                    }

                    if(!found)
                        player.sendMessage(MLGRush.getInstance().getPrefix() + "§cDiese Location existiert nicht.");

                } else if (args.length == 0) {
                    player.sendMessage(MLGRush.getInstance().getPrefix() + "§8§m-------------------");
                    player.sendMessage(MLGRush.getInstance().getPrefix() + "§7");
                    for (LocationType locationType : LocationType.values()) {

                        if(!locationType.toString().contains("BED")) {
                            player.sendMessage(MLGRush.getInstance().getPrefix() + "§a/setup " + locationType.name());
                            player.sendMessage(MLGRush.getInstance().getPrefix() + "§8➥ §7" + locationType.getDescription());
                            player.sendMessage(MLGRush.getInstance().getPrefix() + "");
                        }

                    }

                    player.sendMessage(MLGRush.getInstance().getPrefix() + "§a/setup setBed <T1 | T2> ");
                    player.sendMessage(MLGRush.getInstance().getPrefix() + "§8➥ §7Setzt das Bett für ein Team");
                    player.sendMessage(MLGRush.getInstance().getPrefix() + "");
                    player.sendMessage(MLGRush.getInstance().getPrefix() + "§8§m-------------------");
                } else if (args.length == 2 && args[0].equalsIgnoreCase("setBed")) {
                    if (args[1].equalsIgnoreCase("T1")) {
                        playerManager.setCurrentSetupBed(LocationType.BED_TOP_1);
                        player.playSound(player.getLocation(), Sound.ORB_PICKUP, 3, 1);
                        player.sendMessage(MLGRush.getInstance().getPrefix() + "§7Bitte schlage den §aoberen §7Teil des Bettes von Team" +
                                " §a#1§7.");
                    } else if(args[1].equalsIgnoreCase("T2")) {
                        playerManager.setCurrentSetupBed(LocationType.BED_TOP_2);
                        player.playSound(player.getLocation(), Sound.ORB_PICKUP, 3, 1);
                        player.sendMessage(MLGRush.getInstance().getPrefix() + "§7Bitte schlage den §aoberen §7Teil des Bettes von Team" +
                                " §a#2§7.");
                    }
                } else
                    player.sendMessage(MLGRush.getInstance().getPrefix() + "");
            } else
                player.sendMessage(MLGRush.getInstance().getPrefix() + "§cDazu hast du keine Rechte!");
        } else
            sender.sendMessage(MLGRush.getInstance().getPrefix() + "§cDu musst ein Spieler sein!");

        return true;
    }


    @Override
    public List<String> onTabComplete(CommandSender commandSender, Command command, String s, String[] strings) {

        final List<String> completeOptions = new ArrayList<>();
        for (LocationType current : LocationType.values()) {
            if(!this.isBedLocation(current))
                completeOptions.add(current.toString());
        }

        return completeOptions;
    }

    private boolean isBedLocation(final LocationType locationType) {
        return locationType == LocationType.BED_BOTTOM_1 || locationType == LocationType.BED_BOTTOM_2
                || locationType == LocationType.BED_TOP_1 || locationType == LocationType.BED_TOP_2;
    }
}
 

Diesen Beitrag teilen


Link zum Beitrag
Auf anderen Seiten teilen
Gerade eben schrieb JurassicBeast:

Ich habe gar nicht in der plugin.yml für commands?

Das ist dein Problem. Alle Commands müssen dort eingetragen werden, sonst geht nix.

Diesen Beitrag teilen


Link zum Beitrag
Auf anderen Seiten teilen

Da wäre der Scoreboard handler

package de.pxav.mlgrush.handler;

import de.pxav.mlgrush.MLGRush;
import de.pxav.mlgrush.enums.GameState;
import de.pxav.mlgrush.enums.TeamType;
import de.pxav.mlgrush.gamestates.GameStateHandler;
import de.pxav.mlgrush.utils.PlayerManager;
import org.bukkit.Bukkit;
import org.bukkit.entity.Player;
import org.bukkit.scoreboard.DisplaySlot;
import org.bukkit.scoreboard.Objective;
import org.bukkit.scoreboard.Scoreboard;
import org.bukkit.scoreboard.Team;

public class ScoreboardHandler {

    public void setScoreboard(final Player player) {
        final PlayerManager playerManager = new PlayerManager(player);
        final Scoreboard scoreboard;
        final Objective objective;
        final Team playerTeam;
        final Team ingamePlayerTeam;
        final Team roundDeaths;
        final Team points;
        scoreboard = Bukkit.getScoreboardManager().getNewScoreboard();
        objective = scoreboard.registerNewObjective("main", "dummy");
        playerTeam = scoreboard.registerNewTeam("playerTeam");
        ingamePlayerTeam = scoreboard.registerNewTeam("ingamePlayerTeam");
        roundDeaths = scoreboard.registerNewTeam("deaths");
        points = scoreboard.registerNewTeam("points");


        objective.setDisplayName("  Â§8§l« §3§lMLGRUSH §8§l»  ");
        objective.setDisplaySlot(DisplaySlot.SIDEBAR);

        if (GameStateHandler.getGameState() == GameState.LOBBY) {

            objective.getScore("§d").setScore(6);
            objective.getScore("§7Aktuelle Karte").setScore(5);
            objective.getScore("§8âžœ §a" + MLGRush.getInstance().getConfigManager().getMapName()).setScore(4);
            objective.getScore("§d§b§c§n§m§6").setScore(3);
            objective.getScore("§7Dein Team").setScore(2);
            objective.getScore("§1§a").setScore(1);
            objective.getScore("§e").setScore(0);

            playerTeam.addEntry("§1§a");
            if(MLGRush.getInstance().getTeamHandler().getPlayerTeam(player) == TeamType.TEAM_1)
                playerTeam.setPrefix("§8âžœ §aTEAM #1");
            else if(MLGRush.getInstance().getTeamHandler().getPlayerTeam(player) == TeamType.TEAM_2)
                playerTeam.setPrefix("§8âžœ §aTEAM #2");
            else
                playerTeam.setPrefix("§8âžœ §cKeins");

        } else if (GameStateHandler.getGameState() == GameState.INGAME || GameStateHandler.getGameState() == GameState.ENDING) {

            objective.getScore("").setScore(9);
            objective.getScore("§7Dein Team").setScore(8);
            objective.getScore("§m§r§f§k").setScore(7);
            objective.getScore("§d").setScore(6);
            objective.getScore("§7Tode").setScore(5);
            objective.getScore("§1§a§k").setScore(4);
            objective.getScore("§e").setScore(3);
            objective.getScore("§7Punkte").setScore(2);
            objective.getScore("§e§l§a§r").setScore(1);
            objective.getScore("§e§l§k").setScore(0);

            roundDeaths.addEntry("§1§a§k");
            roundDeaths.setPrefix("§8âžœ §a" + playerManager.getRoundDeaths());

            points.addEntry("§e§l§a§r");
            points.setPrefix("§8âžœ " + MLGRush.getInstance().getPointsHandler().getGlobalPoints());


            ingamePlayerTeam.addEntry("§m§r§f§k");
            if (MLGRush.getInstance().getTeamHandler().getPlayerTeam(player) == TeamType.TEAM_1)
                ingamePlayerTeam.setPrefix("§8âžœ §aTEAM #1" + "§b");
            else if (MLGRush.getInstance().getTeamHandler().getPlayerTeam(player) == TeamType.TEAM_2)
                ingamePlayerTeam.setPrefix("§8âžœ §aTEAM #2");
            else
                ingamePlayerTeam.setPrefix("§8âžœ §cKeins");
        }
        player.setScoreboard(scoreboard);
    }

    private void update(final Player player) {
        final PlayerManager playerManager = new PlayerManager(player);

        if(GameStateHandler.getGameState() == GameState.LOBBY) {

            final Team playerTeam = player.getScoreboard().getTeam("playerTeam");
            if (MLGRush.getInstance().getTeamHandler().getPlayerTeam(player) == TeamType.TEAM_1)
                playerTeam.setPrefix("§8âžœ §aTEAM #1");
            else if (MLGRush.getInstance().getTeamHandler().getPlayerTeam(player) == TeamType.TEAM_2)
                playerTeam.setPrefix("§8âžœ §aTEAM #2§c");
            else
                playerTeam.setPrefix("§8âžœ §cKeins");

        } else if(GameStateHandler.getGameState() == GameState.INGAME) {

            final Team roundDeaths = player.getScoreboard().getTeam("deaths");
            roundDeaths.setPrefix("§8âžœ §a" + playerManager.getRoundDeaths());

            final Team points = player.getScoreboard().getTeam("points");
            points.setPrefix("§8âžœ " + MLGRush.getInstance().getPointsHandler().getGlobalPoints());

            final Team ingamePlayerTeam = player.getScoreboard().getTeam("ingamePlayerTeam");
            if(MLGRush.getInstance().getTeamHandler().getPlayerTeam(player) == TeamType.TEAM_1)
                ingamePlayerTeam.setPrefix("§8âžœ §aTEAM #1");
            else if(MLGRush.getInstance().getTeamHandler().getPlayerTeam(player) == TeamType.TEAM_2)
                ingamePlayerTeam.setPrefix("§8âžœ §aTEAM #2" + "§b");
            else
                ingamePlayerTeam.setPrefix("§8âžœ §cKeins");

        }
    }

    public void startUpdater() {
        Bukkit.getScheduler().runTaskTimer(MLGRush.getInstance(), () -> {
            for (Player player : MLGRush.getInstance().getTeamHandler().playing)
                this.update(player);
        }, 0, 2);
    }

}

Diesen Beitrag teilen


Link zum Beitrag
Auf anderen Seiten teilen

final Team playerTeam = player.getScoreboard().getTeam("playerTeam");

 

Du musst das Team natürlich vorher anlegen, sonst geht's nicht...

Diesen Beitrag teilen


Link zum Beitrag
Auf anderen Seiten teilen

Das musst du wissen... Tipp: wenn das getTeam() null liefert, musst du das Team erstellen. Ab da funktioniert getTeam auch.

Diesen Beitrag teilen


Link zum Beitrag
Auf anderen Seiten teilen

Erstelle ein Benutzerkonto oder melde dich an, um zu kommentieren

Du musst ein Benutzerkonto haben, um einen Kommentar verfassen zu können

Benutzerkonto erstellen

Neues Benutzerkonto für unsere Community erstellen. Es ist einfach!

Neues Benutzerkonto erstellen

Anmelden

Du hast bereits ein Benutzerkonto? Melde dich hier an.

Jetzt anmelden

×