From 46d335bf0e0519bf4dd7d8e88ce412e9fd716b9c Mon Sep 17 00:00:00 2001 From: cswhite2000 <18whitechristop@gmail.com> Date: Tue, 27 Jun 2017 04:36:34 -0700 Subject: [PATCH] Add togglegravity command --- .../tc/oc/commons/bukkit/commands/MiscCommands.java | 13 +++++++++++++ .../oc/commons/bukkit/listeners/LoginListener.java | 2 ++ Lobby/src/main/java/tc/oc/lobby/bukkit/Utils.java | 1 + .../main/java/tc/oc/pgm/spawns/states/Alive.java | 1 + .../java/tc/oc/pgm/spawns/states/Observing.java | 1 + 5 files changed, 18 insertions(+) diff --git a/Commons/bukkit/src/main/java/tc/oc/commons/bukkit/commands/MiscCommands.java b/Commons/bukkit/src/main/java/tc/oc/commons/bukkit/commands/MiscCommands.java index 45f8e2f..348f239 100644 --- a/Commons/bukkit/src/main/java/tc/oc/commons/bukkit/commands/MiscCommands.java +++ b/Commons/bukkit/src/main/java/tc/oc/commons/bukkit/commands/MiscCommands.java @@ -54,6 +54,19 @@ public class MiscCommands implements Commands { } } + @Command( + aliases = { "togglegravity" }, + usage = "", + desc = "Toggle a player's gravity.", + min = 0, + max = 1 + ) + @CommandPermissions("togglegravity") + public void noGravity(final CommandContext args, final CommandSender sender) throws CommandException { + Player player = CommandUtils.getPlayerOrSelf(args, sender, 0); + player.setGravity(!player.hasGravity()); + } + @Command( aliases = { "sudo" }, usage = " [command... (rand|mode|near|color|*)=value]", diff --git a/Commons/bukkit/src/main/java/tc/oc/commons/bukkit/listeners/LoginListener.java b/Commons/bukkit/src/main/java/tc/oc/commons/bukkit/listeners/LoginListener.java index decb738..848d1b7 100644 --- a/Commons/bukkit/src/main/java/tc/oc/commons/bukkit/listeners/LoginListener.java +++ b/Commons/bukkit/src/main/java/tc/oc/commons/bukkit/listeners/LoginListener.java @@ -144,6 +144,8 @@ public class LoginListener implements Listener, PluginFacet { final Player player = event.getPlayer(); final UUID uuid = player.getUniqueId(); + player.setGravity(true); + this.logins.cleanUp(); final LoginResponse response = this.logins.getIfPresent(uuid); this.logins.invalidate(uuid); diff --git a/Lobby/src/main/java/tc/oc/lobby/bukkit/Utils.java b/Lobby/src/main/java/tc/oc/lobby/bukkit/Utils.java index 7dd0b31..49c01bd 100644 --- a/Lobby/src/main/java/tc/oc/lobby/bukkit/Utils.java +++ b/Lobby/src/main/java/tc/oc/lobby/bukkit/Utils.java @@ -54,6 +54,7 @@ public class Utils { player.setAllowFlight(player.hasPermission("lobby.fly")); player.setWalkSpeed(0.2f); player.setFlySpeed(0.1f); + player.setGravity(true); player.setPotionParticles(false); player.hideTitle(); player.getWorld().spawnParticle(Particle.CLOUD, player.getLocation(), 15, 0.5, 0.5, 0.5, 0); diff --git a/PGM/src/main/java/tc/oc/pgm/spawns/states/Alive.java b/PGM/src/main/java/tc/oc/pgm/spawns/states/Alive.java index 6aad31d..ce6ebc3 100644 --- a/PGM/src/main/java/tc/oc/pgm/spawns/states/Alive.java +++ b/PGM/src/main/java/tc/oc/pgm/spawns/states/Alive.java @@ -69,6 +69,7 @@ public class Alive extends Participating { player.setVisible(true); player.refreshVisibility(); bukkit.setGameMode(GameMode.SURVIVAL); + bukkit.setGravity(true); // Apply spawn kit for(Kit kit : smm.getPlayerKits()) { diff --git a/PGM/src/main/java/tc/oc/pgm/spawns/states/Observing.java b/PGM/src/main/java/tc/oc/pgm/spawns/states/Observing.java index 1fa30e3..1975319 100644 --- a/PGM/src/main/java/tc/oc/pgm/spawns/states/Observing.java +++ b/PGM/src/main/java/tc/oc/pgm/spawns/states/Observing.java @@ -43,6 +43,7 @@ public class Observing extends State { player.refreshVisibility(); bukkit.setGameMode(GameMode.CREATIVE); bukkit.setAllowFlight(true); + bukkit.setGravity(true); Spawn spawn = smm.getDefaultSpawn();