Add close shop command

This commit is contained in:
RedSparr0w
2019-11-23 13:29:17 +13:00
parent aa61fc5cbf
commit 5a520fa316
14 changed files with 16 additions and 5 deletions
@@ -102,6 +102,13 @@ public class BotHandler
return null; return null;
} }
public static void closeShop(Client player){
Client shop = getPlayerShop(player);
if (shop == null) return;
shop.disconnected = true;
shop.logout(true);
}
public static void addCoins(int shop_id, int amount){ public static void addCoins(int shop_id, int amount){
Client shop = getPlayerShop(shop_id); Client shop = getPlayerShop(shop_id);
if (shop == null) return; if (shop == null) return;
@@ -820,7 +820,8 @@ public class Client extends Player {
getSummon().pickUpClean(this, summonId); getSummon().pickUpClean(this, summonId);
} }
if (forceLogout || System.currentTimeMillis() - logoutDelay > 2500) { if (forceLogout || System.currentTimeMillis() - logoutDelay > 2500) {
outStream.createFrame(109); if (!isBot)
outStream.createFrame(109);
properLogout = true; properLogout = true;
} else { } else {
getActionSender().sendMessage("You must wait a few seconds from being out of combat to logout."); getActionSender().sendMessage("You must wait a few seconds from being out of combat to logout.");
@@ -34,8 +34,7 @@ public class ConnectionHandler implements IoHandler {
public void sessionClosed(IoSession arg0) throws Exception { public void sessionClosed(IoSession arg0) throws Exception {
if (arg0.getAttachment() != null) { if (arg0.getAttachment() != null) {
Client plr = (Client) arg0.getAttachment(); Client plr = (Client) arg0.getAttachment();
if (!plr.isBot) plr.disconnected = true;
plr.disconnected = true;
} }
HostList.getHostList().remove(arg0); HostList.getHostList().remove(arg0);
} }
@@ -96,9 +96,14 @@ public class Commands implements PacketType {
case "shop": case "shop":
BotHandler.playerShop(player); BotHandler.playerShop(player);
break; break;
case "withdrawshop":
case "wshop": case "wshop":
BotHandler.takeCoins(player); BotHandler.takeCoins(player);
break; break;
case "closeshop":
case "cshop":
BotHandler.closeShop(player);
break;
case "wealth": case "wealth":
int totalWealth = player.getPlayerAssistant().totalGold(); int totalWealth = player.getPlayerAssistant().totalGold();
player.getActionSender().sendMessage("You currently have " + totalWealth + "gp."); player.getActionSender().sendMessage("You currently have " + totalWealth + "gp.");
@@ -137,7 +142,7 @@ public class Commands implements PacketType {
player.getPlayerAssistant().closeAllWindows(); player.getPlayerAssistant().closeAllWindows();
break; break;
case "commands": case "commands":
player.getActionSender().sendMessage("::players, ::highscores, ::loc, ::stuck, ::randomtoggle, ::debug, ::togglegfx, ::shop, ::wshop"); player.getActionSender().sendMessage("::players, ::highscores, ::loc, ::stuck, ::randomtoggle, ::debug, ::togglegfx, ::shop, ::withdrawshop, ::closeshop");
break; break;
case "loc": case "loc":
player.getActionSender().sendMessage(player.absX + "," + player.absY); player.getActionSender().sendMessage(player.absX + "," + player.absY);
@@ -15,7 +15,6 @@ public class IdleLogout implements PacketType {
return; return;
} else { } else {
player.logout(); player.logout();
//Misc.println(player.playerName + " is idle, kicked.");
} }
} }
} }