Add WorldChange
Dieser Commit ist enthalten in:
Ursprung
6aa47a9350
Commit
38428ef7a2
@ -1,14 +1,24 @@
|
||||
package de.steamwar;
|
||||
|
||||
import de.steamwar.command.GamemodeCommand;
|
||||
import de.steamwar.listener.WorldChange;
|
||||
import lombok.Getter;
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.plugin.java.JavaPlugin;
|
||||
|
||||
public final class Teamserver extends JavaPlugin {
|
||||
|
||||
@Getter
|
||||
private static Teamserver instance;
|
||||
|
||||
@Override
|
||||
public void onEnable() {
|
||||
// Plugin startup logic
|
||||
instance = this;
|
||||
|
||||
new GamemodeCommand();
|
||||
|
||||
Bukkit.getPluginManager().registerEvents(new WorldChange(), this);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
27
src/de/steamwar/listener/WorldChange.java
Normale Datei
27
src/de/steamwar/listener/WorldChange.java
Normale Datei
@ -0,0 +1,27 @@
|
||||
package de.steamwar.listener;
|
||||
|
||||
import de.steamwar.Teamserver;
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.GameMode;
|
||||
import org.bukkit.event.EventHandler;
|
||||
import org.bukkit.event.EventPriority;
|
||||
import org.bukkit.event.Listener;
|
||||
import org.bukkit.event.player.PlayerChangedWorldEvent;
|
||||
import org.bukkit.event.player.PlayerJoinEvent;
|
||||
|
||||
public class WorldChange implements Listener {
|
||||
|
||||
@EventHandler(priority = EventPriority.HIGHEST)
|
||||
public void onPlayerJoin(PlayerJoinEvent event) {
|
||||
Bukkit.getScheduler().runTaskLater(Teamserver.getInstance(), () -> {
|
||||
event.getPlayer().setGameMode(GameMode.CREATIVE);
|
||||
}, 1L);
|
||||
}
|
||||
|
||||
@EventHandler(priority = EventPriority.HIGHEST)
|
||||
public void onPlayerChangedWorld(PlayerChangedWorldEvent event) {
|
||||
Bukkit.getScheduler().runTaskLater(Teamserver.getInstance(), () -> {
|
||||
event.getPlayer().setGameMode(GameMode.CREATIVE);
|
||||
}, 1L);
|
||||
}
|
||||
}
|
In neuem Issue referenzieren
Einen Benutzer sperren