use of com.sk89q.worldguard.session.Session in project WorldGuard by EngineHub.
the class GeneralCommands method ungod.
@Command(aliases = { "ungod" }, usage = "[player]", desc = "Disable godmode on a player", flags = "s", max = 1)
public void ungod(CommandContext args, Actor sender) throws CommandException, AuthorizationException {
Iterable<? extends LocalPlayer> targets;
boolean included = false;
// Detect arguments based on the number of arguments provided
if (args.argsLength() == 0) {
targets = worldGuard.getPlatform().getMatcher().matchPlayers(worldGuard.checkPlayer(sender));
// Check permissions!
sender.checkPermission("worldguard.god");
} else {
targets = worldGuard.getPlatform().getMatcher().matchPlayers(sender, args.getString(0));
// Check permissions!
sender.checkPermission("worldguard.god.other");
}
for (LocalPlayer player : targets) {
Session session = WorldGuard.getInstance().getPlatform().getSessionManager().get(player);
if (GodMode.set(player, session, false)) {
// Tell the user
if (player.equals(sender)) {
player.print("God mode disabled!");
// Keep track of this
included = true;
} else {
player.print("God disabled by " + sender.getDisplayName() + ".");
}
}
}
// user a message so s/he know that something is indeed working
if (!included && args.hasFlag('s')) {
sender.print("Players no longer have god mode.");
}
}
use of com.sk89q.worldguard.session.Session in project WorldGuard by EngineHub.
the class PlayerModesListener method onProcessPlayer.
@EventHandler
public void onProcessPlayer(ProcessPlayerEvent event) {
Player player = event.getPlayer();
LocalPlayer localPlayer = WorldGuardPlugin.inst().wrapPlayer(player);
Session session = WorldGuard.getInstance().getPlatform().getSessionManager().get(localPlayer);
if (hasGodModeGroup(player) || hasGodModePermission(player)) {
if (GodMode.set(localPlayer, session, true)) {
log.log(Level.INFO, "Enabled auto-god mode for " + player.getName());
}
}
if (hasAmphibiousGroup(player)) {
if (WaterBreathing.set(localPlayer, session, true)) {
log.log(Level.INFO, "Enabled water breathing mode for " + player.getName() + " (player is in group 'wg-amphibious')");
}
}
}
use of com.sk89q.worldguard.session.Session in project WorldGuard by EngineHub.
the class PlayerMoveListener method onVehicleEnter.
@EventHandler
public void onVehicleEnter(VehicleEnterEvent event) {
Entity entity = event.getEntered();
if (entity instanceof Player) {
LocalPlayer player = getPlugin().wrapPlayer((Player) entity);
Session session = WorldGuard.getInstance().getPlatform().getSessionManager().get(player);
if (null != session.testMoveTo(player, BukkitAdapter.adapt(event.getVehicle().getLocation()), MoveType.EMBARK, true)) {
event.setCancelled(true);
}
}
}
use of com.sk89q.worldguard.session.Session in project WorldGuard by EngineHub.
the class BukkitSessionManager method resetAllStates.
/**
* Re-initialize handlers and clear "last position," "last state," etc.
* information for all players.
*/
@Override
public void resetAllStates() {
Collection<? extends Player> players = Bukkit.getServer().getOnlinePlayers();
for (Player player : players) {
BukkitPlayer bukkitPlayer = new BukkitPlayer(WorldGuardPlugin.inst(), player);
Session session = getIfPresent(bukkitPlayer);
if (session != null) {
session.resetState(bukkitPlayer);
}
}
}
use of com.sk89q.worldguard.session.Session in project WorldGuard by EngineHub.
the class GeneralCommands method god.
@Command(aliases = { "god" }, usage = "[player]", desc = "Enable godmode on a player", flags = "s", max = 1)
public void god(CommandContext args, Actor sender) throws CommandException, AuthorizationException {
Iterable<? extends LocalPlayer> targets = null;
boolean included = false;
// Detect arguments based on the number of arguments provided
if (args.argsLength() == 0) {
targets = worldGuard.getPlatform().getMatcher().matchPlayers(worldGuard.checkPlayer(sender));
// Check permissions!
sender.checkPermission("worldguard.god");
} else {
targets = worldGuard.getPlatform().getMatcher().matchPlayers(sender, args.getString(0));
// Check permissions!
sender.checkPermission("worldguard.god.other");
}
for (LocalPlayer player : targets) {
Session session = WorldGuard.getInstance().getPlatform().getSessionManager().get(player);
if (GodMode.set(player, session, true)) {
player.setFireTicks(0);
// Tell the user
if (player.equals(sender)) {
player.print("God mode enabled! Use /ungod to disable.");
// Keep track of this
included = true;
} else {
player.print("God enabled by " + sender.getDisplayName() + ".");
}
}
}
// user a message so s/he know that something is indeed working
if (!included && args.hasFlag('s')) {
sender.print("Players now have god mode.");
}
}
Aggregations