forked from SteamWar/SteamWar
Add AntiPlayerCollision
This commit is contained in:
+5
-17
@@ -20,34 +20,22 @@
|
||||
package de.steamwar.bausystem.features.world;
|
||||
|
||||
import de.steamwar.linkage.Linked;
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.event.EventHandler;
|
||||
import org.bukkit.event.EventPriority;
|
||||
import org.bukkit.event.Listener;
|
||||
import org.bukkit.event.player.PlayerJoinEvent;
|
||||
import org.bukkit.event.player.PlayerQuitEvent;
|
||||
import org.bukkit.scoreboard.Scoreboard;
|
||||
import org.bukkit.scoreboard.Team;
|
||||
|
||||
@Linked
|
||||
public class AntiPlayerCollision implements Listener {
|
||||
|
||||
private static Team TEAM = getTeam();
|
||||
|
||||
private static Team getTeam() {
|
||||
Scoreboard board = Bukkit.getScoreboardManager().getMainScoreboard();
|
||||
@EventHandler(priority = EventPriority.MONITOR)
|
||||
public void onPlayerJoin(PlayerJoinEvent event) {
|
||||
Scoreboard board = event.getPlayer().getScoreboard();
|
||||
Team team = board.getTeam("players");
|
||||
if (team == null) team = board.registerNewTeam("players");
|
||||
team.setOption(Team.Option.COLLISION_RULE, Team.OptionStatus.NEVER);
|
||||
return team;
|
||||
}
|
||||
|
||||
@EventHandler
|
||||
public void onPlayerJoin(PlayerJoinEvent event) {
|
||||
TEAM.addPlayer(event.getPlayer());
|
||||
}
|
||||
|
||||
@EventHandler
|
||||
public void onPlayerQuit(PlayerQuitEvent event) {
|
||||
TEAM.removePlayer(event.getPlayer());
|
||||
team.addPlayer(event.getPlayer());
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user