Add Game#PlayerGameMode which is set in PlayerPrepareTeleportEvent, and UtilPlayer#getProtocolVersion

This commit is contained in:
Spencer 2017-12-31 20:36:00 -05:00 committed by Alexander Meech
parent c31e387b2a
commit 0bb75c3a8f
5 changed files with 21 additions and 1 deletions

View File

@ -1209,4 +1209,9 @@ public class UtilPlayer
{
teleportUniform(players, locations, Entity::teleport);
}
public static int getProtocolVersion(Player player)
{
return ((CraftPlayer) player).getHandle().getProtocol();
}
}

View File

@ -20,6 +20,7 @@ import net.minecraft.server.v1_8_R3.PacketPlayInUseEntity;
import org.apache.commons.lang3.tuple.Triple;
import org.bukkit.Bukkit;
import org.bukkit.ChatColor;
import org.bukkit.GameMode;
import org.bukkit.Location;
import org.bukkit.Material;
import org.bukkit.Sound;
@ -90,6 +91,7 @@ import nautilus.game.arcade.ArcadeManager;
import nautilus.game.arcade.GameType;
import nautilus.game.arcade.events.GameStateChangeEvent;
import nautilus.game.arcade.events.PlayerGameRespawnEvent;
import nautilus.game.arcade.events.PlayerPrepareTeleportEvent;
import nautilus.game.arcade.events.PlayerStateChangeEvent;
import nautilus.game.arcade.game.GameTeam.PlayerState;
import nautilus.game.arcade.game.games.build.Build;
@ -300,6 +302,8 @@ public abstract class Game extends ListenerComponent implements Lifetimed
public boolean DontAllowOverfill = false;
public GameMode PlayerGameMode = GameMode.SURVIVAL;
// Addons
public boolean SoupEnabled = true;
@ -1977,6 +1981,12 @@ public abstract class Game extends ListenerComponent implements Lifetimed
SetState(GameState.End);
}
@EventHandler
public void onTeleportPrepare(PlayerPrepareTeleportEvent event)
{
event.GetPlayer().setGameMode(PlayerGameMode);
}
@EventHandler
public void onGameStart(GameStateChangeEvent event)
{

View File

@ -228,6 +228,8 @@ public class Build extends Game
this.AnticheatDisabled = true;
this.PlayerGameMode = GameMode.CREATIVE;
UtilServer.getServer().spigot().getConfig().set("view-distance", 4);
_words = new String[]
@ -316,7 +318,6 @@ public class Build extends Game
@EventHandler
public void prepare(PlayerPrepareTeleportEvent event)
{
event.GetPlayer().setGameMode(GameMode.CREATIVE);
event.GetPlayer().setFlying(true);
event.GetPlayer().setFlySpeed(0.04f);
}

View File

@ -158,6 +158,8 @@ public class Minestrike extends TeamGame
this.AllowParticles = false;
this.PlayerGameMode = GameMode.ADVENTURE;
_scoreObj = Scoreboard.getScoreboard().registerNewObjective("HP", "dummy");
_scoreObj.setDisplaySlot(DisplaySlot.BELOW_NAME);

View File

@ -8,6 +8,7 @@ import java.util.concurrent.TimeUnit;
import org.bukkit.ChatColor;
import org.bukkit.Color;
import org.bukkit.FireworkEffect.Type;
import org.bukkit.GameMode;
import org.bukkit.Location;
import org.bukkit.Material;
import org.bukkit.Sound;
@ -139,6 +140,7 @@ public abstract class SuperSmash extends Game
HideTeamSheep = true;
ReplaceTeamsWithKits = true;
AllowParticles = false;
PlayerGameMode = GameMode.ADVENTURE;
manager.GetExplosion().SetRegenerate(true);
manager.GetExplosion().setRegenerateTime(TimeUnit.SECONDS.toMillis(30));