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

@ -216,6 +216,12 @@ public class BukkitPlayer extends PlotPlayer {
player.kickPlayer(message); player.kickPlayer(message);
} }
@Override public void stopSpectating() {
if (getGamemode() == PlotGamemode.SPECTATOR) {
player.setSpectatorTarget(null);
}
}
@Override @Override
public boolean isBanned() { public boolean isBanned() {
return player.isBanned(); return player.isBanned();

View File

@ -20,8 +20,6 @@
//////////////////////////////////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////////////////////////////////
package com.intellectualcrafters.plot.commands; package com.intellectualcrafters.plot.commands;
import java.util.UUID;
import com.intellectualcrafters.plot.config.C; import com.intellectualcrafters.plot.config.C;
import com.intellectualcrafters.plot.database.DBFunc; import com.intellectualcrafters.plot.database.DBFunc;
import com.intellectualcrafters.plot.object.Location; 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.EventUtil;
import com.intellectualcrafters.plot.util.MainUtil; import com.intellectualcrafters.plot.util.MainUtil;
import com.intellectualcrafters.plot.util.Permissions; import com.intellectualcrafters.plot.util.Permissions;
import com.intellectualcrafters.plot.util.PlotGamemode;
import com.intellectualcrafters.plot.util.UUIDHandler; import com.intellectualcrafters.plot.util.UUIDHandler;
import com.intellectualcrafters.plot.util.WorldUtil; import com.intellectualcrafters.plot.util.WorldUtil;
import com.plotsquared.general.commands.Argument; import com.plotsquared.general.commands.Argument;
import com.plotsquared.general.commands.CommandDeclaration; 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) @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 { public class Deny extends SubCommand {
@ -102,6 +103,9 @@ public class Deny extends SubCommand {
if (pp.hasPermission("plots.admin.entry.denied")) { if (pp.hasPermission("plots.admin.entry.denied")) {
return; return;
} }
if (pp.getGamemode() == PlotGamemode.SPECTATOR) {
pp.stopSpectating();
}
pp.teleport(WorldUtil.IMP.getSpawn(pp.getLocation().getWorld())); pp.teleport(WorldUtil.IMP.getSpawn(pp.getLocation().getWorld()));
MainUtil.sendMessage(pp, C.YOU_GOT_DENIED); MainUtil.sendMessage(pp, C.YOU_GOT_DENIED);
} }

View File

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

View File

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

View File

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