SHARE
TWEET

Untitled

a guest Jul 9th, 2019 141 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. package mext.maou.v2.requests.aqw;
  2.  
  3. import it.gotoandplay.smartfoxserver.data.Room;
  4. import it.gotoandplay.smartfoxserver.data.User;
  5. import it.gotoandplay.smartfoxserver.data.Zone;
  6. import java.util.Iterator;
  7. import java.util.Map;
  8. import mext.maou.v2.helpers.Database;
  9. import mext.maou.v2.helpers.Party;
  10. import mext.maou.v2.requests.IRequest;
  11. import mext.maou.v2.requests.RequestException;
  12. import mext.maou.v2.world.World;
  13. import mext.maou.v2.world.objects.PartyInfo;
  14. import net.sf.json.JSONArray;
  15. import net.sf.json.JSONObject;
  16.  
  17. public class Message
  18.   implements IRequest
  19. {
  20.   public void process(String[] params, User user)
  21.     throws RequestException
  22.   {
  23.     String channel = params[1];
  24.     String message = params[0];
  25.     String[] response = { "chatm", channel + "~" + message, user.getName(), String.valueOf(user.getRoom()) };
  26.     if (((Integer)user.properties.get("permamute")).intValue() > 0) {
  27.       throw new RequestException("You are muted! Chat privileges have been permanently revoked.");
  28.     }
  29.     if (World.instance.userMute.containsKey(user.getName()))
  30.     {
  31.       long remainingMute = ((Long)World.instance.userMute.get(user.getName())).longValue();
  32.       long diffTime = remainingMute - System.currentTimeMillis();
  33.       if (diffTime > 0L) {
  34.         throw new RequestException("You are muted! Chat privileges have been temporarily revoked.");
  35.       }
  36.     }
  37.     if (channel.equals("world"))
  38.     {
  39.       if (((Integer)user.properties.get("coin")).intValue() < 100) {
  40.         throw new RequestException("You need at least 100ACs to send a message in world channel.", "server");
  41.       }
  42.       int coinsLeft = ((Integer)user.properties.get("coin")).intValue() - 100;
  43.       user.properties.put("coin", Integer.valueOf(coinsLeft));
  44.       JSONObject sell = new JSONObject();
  45.       sell.put("cmd", "sellItem");
  46.       sell.put("intAmount", Integer.valueOf(-100));
  47.       sell.put("CharItemID", Integer.valueOf(user.hashCode()));
  48.       sell.put("bCoins", Integer.valueOf(1));
  49.       Database.instance.asyncExecute("UPDATE meh_users SET Coins=Coins-100 WHERE id=?", new Object[] { user.properties.get("dbId") });
  50.       World.instance.sendResponse(sell, user);
  51.       World.instance.sendResponse(response, World.instance.zone.getChannelList());
  52.     }
  53.     else if (channel.equals("party"))
  54.     {
  55.       int partyId = ((Integer)user.properties.get("partyid")).intValue();
  56.       if (partyId < 0) {
  57.         throw new RequestException("You are not in a party.", "server");
  58.       }
  59.       PartyInfo pi = Party.instance.getPartyInfo(partyId);
  60.       World.instance.sendResponse(response, pi.getChannelList());
  61.     }
  62.     else if (channel.equals("guild"))
  63.     {
  64.       Iterator<JSONObject> it;
  65.       if (((Integer)user.properties.get("guildid")).intValue() > 0)
  66.       {
  67.         JSONObject guildData = (JSONObject)user.properties.get("guildobj");
  68.         JSONArray members = (JSONArray)guildData.get("ul");
  69.         if ((members != null) && (members.size() > 0)) {
  70.           for (it = members.iterator(); it.hasNext();)
  71.           {
  72.             JSONObject member = (JSONObject)it.next();
  73.             User others = World.instance.zone.getUserByName(member.get("userName").toString().toLowerCase());
  74.             if (others != null) {
  75.               World.instance.sendResponse(response, others);
  76.             }
  77.           }
  78.         }
  79.       }
  80.       else
  81.       {
  82.         throw new RequestException("You are not in a guild.", "server");
  83.       }
  84.     }
  85.     else
  86.     {
  87.       int access = ((Integer)user.properties.get("access")).intValue();
  88.       switch (access)
  89.       {
  90.     case 100:
  91.                channel1 = "owners";
  92.                break;
  93.       case 60:
  94.         channel = "administrator";
  95.         break;
  96.       case 40:
  97.         channel = "mod";
  98.         break;
  99.       case 4:
  100.         channel = "ps";
  101.         break;
  102.       case 3:
  103.         channel = "vip";
  104.         break;
  105.       default:
  106.         channel = "zone";
  107.       }
  108.       response = new String[] { "chatm", channel + "~" + message, user.getName(), String.valueOf(user.getRoom()) };
  109.       World.instance.sendResponse(response, World.instance.zone.getRoom(user.getRoom()).getChannellList());
  110.     }
  111.   }
  112. }
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
Not a member of Pastebin yet?
Sign Up, it unlocks many cool features!
 
Top