Disconnect client with TransitionService
This commit is contained in:
@@ -42,6 +42,7 @@ import constants.id.MobId;
|
||||
import constants.inventory.ItemConstants;
|
||||
import constants.skills.*;
|
||||
import model.CharacterIdentity;
|
||||
import net.netty.GameViolationException;
|
||||
import net.packet.Packet;
|
||||
import net.server.PlayerBuffValueHolder;
|
||||
import net.server.PlayerCoolDownValueHolder;
|
||||
@@ -1379,6 +1380,7 @@ public class Character extends AbstractCharacterObject {
|
||||
eventAfterChangedMap(this.getMapId());
|
||||
}
|
||||
|
||||
// Only used when entering Magic Door (Priest skill).
|
||||
public void changeMap(final MapleMap target, final Point pos) {
|
||||
canWarpCounter++;
|
||||
|
||||
@@ -8639,34 +8641,14 @@ public class Character extends AbstractCharacterObject {
|
||||
}
|
||||
}
|
||||
|
||||
public void sendPolice(int greason, String reason, int duration) {
|
||||
sendPacket(PacketCreator.sendPolice(String.format("You have been blocked by the#b %s Police for %s.#k", "Cosmic", reason)));
|
||||
this.isbanned = true;
|
||||
TimerManager.getInstance().schedule(new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
client.disconnect(false, false);
|
||||
}
|
||||
}, duration);
|
||||
}
|
||||
|
||||
public void sendPolice(String text) {
|
||||
final String message = getName() + " received this - " + text;
|
||||
log.info(message);
|
||||
if (Server.getInstance().isGmOnline(this.getWorld())) { //Alert and log if a GM is online
|
||||
Server.getInstance().broadcastGMMessage(this.getWorld(), PacketCreator.sendYellowTip(message));
|
||||
} else { //Auto DC and log if no GM is online
|
||||
client.disconnect(false, false);
|
||||
throw new GameViolationException(text);
|
||||
}
|
||||
log.info(message);
|
||||
//Server.getInstance().broadcastGMMessage(0, PacketCreator.serverNotice(1, getName() + " received this - " + text));
|
||||
//sendPacket(PacketCreator.sendPolice(text));
|
||||
//this.isbanned = true;
|
||||
//TimerManager.getInstance().schedule(new Runnable() {
|
||||
// @Override
|
||||
// public void run() {
|
||||
// client.disconnect(false, false);
|
||||
// }
|
||||
//}, 6000);
|
||||
}
|
||||
|
||||
public void sendKeymap() {
|
||||
@@ -10071,6 +10053,10 @@ public class Character extends AbstractCharacterObject {
|
||||
return isbanned;
|
||||
}
|
||||
|
||||
public void setBanned() {
|
||||
isbanned = true;
|
||||
}
|
||||
|
||||
public List<Integer> getTrockMaps() {
|
||||
return trockmaps;
|
||||
}
|
||||
|
||||
@@ -41,14 +41,15 @@ public class DcCommand extends Command {
|
||||
return;
|
||||
}
|
||||
|
||||
Character victim = c.getWorldServer().getPlayerStorage().getCharacterByName(params[0]);
|
||||
String chrName = params[0];
|
||||
Character victim = c.getWorldServer().getPlayerStorage().getCharacterByName(chrName);
|
||||
if (victim == null) {
|
||||
victim = c.getChannelServer().getPlayerStorage().getCharacterByName(params[0]);
|
||||
victim = c.getChannelServer().getPlayerStorage().getCharacterByName(chrName);
|
||||
if (victim == null) {
|
||||
victim = player.getMap().getCharacterByName(params[0]);
|
||||
victim = player.getMap().getCharacterByName(chrName);
|
||||
if (victim != null) {
|
||||
try {//sometimes bugged because the map = null
|
||||
victim.getClient().disconnect(true, false);
|
||||
ctx.transitionService().disconnect(victim.getClient(), true, false);
|
||||
player.getMap().removePlayer(victim);
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
@@ -61,6 +62,6 @@ public class DcCommand extends Command {
|
||||
if (player.gmLevel() < victim.gmLevel()) {
|
||||
victim = player;
|
||||
}
|
||||
victim.getClient().disconnect(false, false);
|
||||
ctx.transitionService().disconnect(victim.getClient(), false, false);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -35,6 +35,7 @@ import tools.PacketCreator;
|
||||
import java.sql.Connection;
|
||||
import java.sql.PreparedStatement;
|
||||
import java.sql.SQLException;
|
||||
import java.util.concurrent.TimeUnit;
|
||||
|
||||
public class BanCommand extends Command {
|
||||
{
|
||||
@@ -76,7 +77,10 @@ public class BanCommand extends Command {
|
||||
target.yellowMessage("Reason: " + reason);
|
||||
c.sendPacket(PacketCreator.getGMEffect(4, (byte) 0));
|
||||
final Character rip = target;
|
||||
TimerManager.getInstance().schedule(() -> rip.getClient().disconnect(false, false), 5000); //5 Seconds
|
||||
TimerManager.getInstance().schedule(
|
||||
() -> ctx.transitionService().disconnect(rip.getClient(), false, false),
|
||||
TimeUnit.SECONDS.toMillis(5)
|
||||
);
|
||||
Server.getInstance().broadcastMessage(c.getWorld(), PacketCreator.serverNotice(6, "[RIP]: " + ign + " has been banned."));
|
||||
} else if (Character.ban(ign, reason, false)) {
|
||||
c.sendPacket(PacketCreator.getGMEffect(4, (byte) 0));
|
||||
|
||||
@@ -41,7 +41,7 @@ public class DCAllCommand extends Command {
|
||||
for (World world : Server.getInstance().getWorlds()) {
|
||||
for (Character chr : world.getPlayerStorage().getAllCharacters()) {
|
||||
if (!chr.isGM()) {
|
||||
chr.getClient().disconnect(false, false);
|
||||
ctx.transitionService().disconnect(chr.getClient(), false, false);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user