Stop spectating before being kicked when denied.

Fixes #886
This commit is contained in:
Matt 2016-02-27 20:11:18 -05:00
parent 7d340b58b4
commit 911bef974a
5 changed files with 26 additions and 9 deletions

View File

@ -215,7 +215,13 @@ public class BukkitPlayer extends PlotPlayer {
public void kick(final String message) {
player.kickPlayer(message);
}
@Override public void stopSpectating() {
if (getGamemode() == PlotGamemode.SPECTATOR) {
player.setSpectatorTarget(null);
}
}
@Override
public boolean isBanned() {
return player.isBanned();

View File

@ -20,8 +20,6 @@
////////////////////////////////////////////////////////////////////////////////////////////////////
package com.intellectualcrafters.plot.commands;
import java.util.UUID;
import com.intellectualcrafters.plot.config.C;
import com.intellectualcrafters.plot.database.DBFunc;
import com.intellectualcrafters.plot.object.Location;
@ -30,11 +28,14 @@ import com.intellectualcrafters.plot.object.PlotPlayer;
import com.intellectualcrafters.plot.util.EventUtil;
import com.intellectualcrafters.plot.util.MainUtil;
import com.intellectualcrafters.plot.util.Permissions;
import com.intellectualcrafters.plot.util.PlotGamemode;
import com.intellectualcrafters.plot.util.UUIDHandler;
import com.intellectualcrafters.plot.util.WorldUtil;
import com.plotsquared.general.commands.Argument;
import com.plotsquared.general.commands.CommandDeclaration;
import java.util.UUID;
@CommandDeclaration(command = "deny", aliases = { "d", "ban" }, description = "Deny a user from a plot", usage = "/plot deny <player>", category = CommandCategory.SETTINGS, requiredType = RequiredType.NONE)
public class Deny extends SubCommand {
@ -102,6 +103,9 @@ public class Deny extends SubCommand {
if (pp.hasPermission("plots.admin.entry.denied")) {
return;
}
if (pp.getGamemode() == PlotGamemode.SPECTATOR) {
pp.stopSpectating();
}
pp.teleport(WorldUtil.IMP.getSpawn(pp.getLocation().getWorld()));
MainUtil.sendMessage(pp, C.YOU_GOT_DENIED);
}

View File

@ -1,14 +1,14 @@
package com.intellectualcrafters.plot.object;
import java.util.HashMap;
import java.util.UUID;
import com.intellectualcrafters.plot.PS;
import com.intellectualcrafters.plot.commands.RequiredType;
import com.intellectualcrafters.plot.database.DBFunc;
import com.intellectualcrafters.plot.util.PlotGamemode;
import com.intellectualcrafters.plot.util.PlotWeather;
import java.util.HashMap;
import java.util.UUID;
public class ConsolePlayer extends PlotPlayer {
private static ConsolePlayer instance;
@ -152,7 +152,9 @@ public class ConsolePlayer extends PlotPlayer {
@Override
public void kick(final String message) {}
@Override public void stopSpectating() {}
@Override
public boolean isBanned() {
return false;

View File

@ -460,4 +460,6 @@ public abstract class PlotPlayer implements CommandCaller {
public boolean hasPersistentMeta(String key) {
return metaMap.containsKey(key);
}
public abstract void stopSpectating();
}

View File

@ -142,7 +142,6 @@ public class SpongePlayer extends PlotPlayer {
@Override
public void saveData() {
// TODO Auto-generated method stub
throw new UnsupportedOperationException("NOT IMPLEMENTED YET");
}
@ -250,7 +249,11 @@ public class SpongePlayer extends PlotPlayer {
public void kick(final String message) {
player.kick(SpongeUtil.getText(message));
}
@Override public void stopSpectating() {
//Not Implemented
}
@Override
public boolean isBanned() {
BanService service = Sponge.getServiceManager().provide(BanService.class).get();