• 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!

Spigot Minecraft programmieren Worldspawn verändern?

Mr_Redstone19

Schafhirte
Registriert
31 Januar 2018
Beiträge
103
Alter
50
Diamanten
0
Hallo.
Ich habe eine Frage bezüglich dieses Codes (Codeausschnitt aus einem Alle gegen Alle Minigame mit Map und Kitwechsler):

java:
File file2 = new File("plugins//Surf//map.yml");
YamlConfiguration cfg2 = YamlConfiguration.loadConfiguration(file2);

Random r = new Random();
        int zufall = r.nextInt(2);
        switch(zufall) {
            case 0:
                cfg2.set("map.forest", "is");
                try {
                cfg2.save(file2);
                } catch (IOException e1) {
                // TODO Auto-generated catch block
                e1.printStackTrace();
                }
                break;
            case 1:
                cfg2.set("map.lobby", "is");
                try {
                cfg2.save(file2);
                } catch (IOException e1) {
                // TODO Auto-generated catch block
                e1.printStackTrace();
                }
                break;
        }

java:
@EventHandler
    public void onRespawn(PlayerRespawnEvent e) {
        File file2 = new File("plugins//Surf//map.yml");
        YamlConfiguration cfg2 = YamlConfiguration.loadConfiguration(file2);
        
        File file3 = new File("plugins//Surf//kit.yml");
        YamlConfiguration cfg3 = YamlConfiguration.loadConfiguration(file3);
        Player p = e.getPlayer();
        if(cfg2.isSet("map.forest")) {
            
            
            Location forest = new Location(p.getWorld(), 602, 76, -1247);
            forest.setPitch(2f);
            forest.setYaw(180f);
            
            p.teleport(forest);
            if(cfg3.isSet("kit.tank")) {
                INVENTKITTank.setKitInv(p);
            }else if(cfg3.isSet("kit.flamebow")) {
                INVENTKITFlameBow.setKitInv(p);
            }else if(cfg3.isSet("kit.hero")) {
                INVENTKITHero.setKitInv(p);
            }else if(cfg3.isSet("kit.knock")) {
                INVENTKITKnock.setKitInv(p);
            }else if(cfg3.isSet("kit.noob")) {
                INVENTKITNoob.setKitInv(p);
            }else if(cfg3.isSet("kit.opbow")) {
                INVENTKITOPBow.setKitInv(p);
            }
        }else if(cfg2.isSet("map.lobby")){
            Location lobby = new Location(p.getWorld(), 608.5, 68, -1369.5);
            lobby.setPitch(2f);
            lobby.setYaw(0f);
            
            p.teleport(lobby);
            if(cfg3.isSet("kit.tank")) {
                INVENTKITTank.setKitInv(p);
            }else if(cfg3.isSet("kit.flamebow")) {
                INVENTKITFlameBow.setKitInv(p);
            }else if(cfg3.isSet("kit.hero")) {
                INVENTKITHero.setKitInv(p);
            }else if(cfg3.isSet("kit.knock")) {
                INVENTKITKnock.setKitInv(p);
            }else if(cfg3.isSet("kit.noob")) {
                INVENTKITNoob.setKitInv(p);
            }else if(cfg3.isSet("kit.opbow")) {
                INVENTKITOPBow.setKitInv(p);
            }
        }
    }

Sobald die RandomMethode ausgeführt wurde, sieht es folgendermaßen aus (In der Config):

map:
forest: is

(Zum Beispiel)

Doch wenn man jetzt stirbt, dann wird man egal bei welchem Eintrag immer zu der Map "Lobby" teleportiert. Stimmt etwas an dem Code oben (Respawn-Methode) nicht?

Ich hoffe ihr könnt mir helfen. Ich weiß nämlich echt nicht mehr, was ich tun soll
 
Registriert
10 Dezember 2017
Beiträge
161
Alter
26
Diamanten
322
Minecraft
DerFrZocker
Oben