Facebook
From Morose Cat, 4 Years ago, written in Plain Text.
This paste is a reply to Untitled from Emerald Flamingo - view diff
Embed
Download Paste or View Raw
Hits: 196
  1. /**
  2.  * This file is part of Aion-Lightning <aion-lightning.org>.
  3.  *
  4.  *  Aion-Lightning is free software: you can redistribute it and/or modify
  5.  *  it under the terms of the GNU General Public License as published by
  6.  *  the Free Software Foundation, either version 3 of the License, or
  7.  *  (at your option) any later version.
  8.  *
  9.  *  Aion-Lightning is distributed in the hope that it will be useful,
  10.  *  but WITHOUT ANY WARRANTY; without even the implied warranty of
  11.  *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
  12.  *  GNU General Public License for more details. *
  13.  *  You should have received a copy of the GNU General Public License
  14.  *  along with Aion-Lightning.
  15.  *  If not, see <http://www.gnu.org/licenses/>.
  16.  */
  17. package admincommands;
  18.  
  19. import com.aionemu.gameserver.model.gameobjects.player.Player;
  20. import com.aionemu.gameserver.network.aion.serverpackets.SM_MOTION;
  21. import com.aionemu.gameserver.network.aion.serverpackets.SM_PLAYER_INFO;
  22. import com.aionemu.gameserver.utils.PacketSendUtility;
  23. import com.aionemu.gameserver.utils.audit.GMService;
  24. import com.aionemu.gameserver.utils.chathandlers.AdminCommand;
  25.  
  26. /**
  27.  * @author Eloann
  28.  */
  29. public class GMMode extends AdminCommand {
  30.  
  31.         public GMMode() {
  32.                 super("gm");
  33.         }
  34.  
  35.         @Override
  36.         public void execute(Player admin, String... params) {
  37.                 if (admin.getAccessLevel() < 1) {
  38.                         PacketSendUtility.sendMessage(admin, "You cannot use this command.");
  39.                         return;
  40.                 }
  41.  
  42.                 if (params.length != 1) {
  43.                         onFail(admin, null);
  44.                         return;
  45.                 }
  46.  
  47.                 if (params[0].toLowerCase().equals("on")) {
  48.                         if (!admin.isGmMode()) {
  49.                                 admin.setGmMode(true);
  50.                                 admin.setWispable();
  51.  
  52.                                 GMService.getInstance().onPlayerLogin(admin); // put gm into
  53.                                 // gmlist
  54.                                 GMService.getInstance().onPlayerAvailable(admin); // send
  55.                                 // available
  56.                                 // message
  57.                                 admin.clearKnownlist();
  58.                                 PacketSendUtility.sendPacket(admin, new SM_PLAYER_INFO(admin, false));
  59.                                 PacketSendUtility.sendPacket(admin, new SM_MOTION(admin.getObjectId(), admin.getMotions().getActiveMotions()));
  60.                                 admin.updateKnownlist();
  61.                                 PacketSendUtility.sendMessage(admin, "you are now Available and Wispable by players");
  62.  
  63.                         }
  64.                 }
  65.                 if (params[0].equals("off")) {
  66.                         if (admin.isGmMode()) {
  67.                                 admin.setGmMode(false);
  68.                                 admin.setUnWispable();
  69.  
  70.                                 GMService.getInstance().onPlayerLogedOut(admin); // remove gm
  71.                                 // into
  72.                                 // gmlist
  73.                                 GMService.getInstance().onPlayerUnavailable(admin); // send
  74.                                 // unavailable
  75.                                 // message
  76.                                 admin.clearKnownlist();
  77.                                 PacketSendUtility.sendPacket(admin, new SM_PLAYER_INFO(admin, false));
  78.                                 PacketSendUtility.sendPacket(admin, new SM_MOTION(admin.getObjectId(), admin.getMotions().getActiveMotions()));
  79.                                 admin.updateKnownlist();
  80.                                 PacketSendUtility.sendMessage(admin, "you are now Unavailable and Unwispable by players");
  81.                         }
  82.                 }
  83.         }
  84.  
  85.         @Override
  86.         public void onFail(Player admin, String message) {
  87.                 String syntax = "syntax //gm <on|off>";
  88.                 PacketSendUtility.sendMessage(admin, syntax);
  89.         }
  90. }
  91.  
  92.