Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- package mext.maou.v2.requests.aqw;
- import it.gotoandplay.smartfoxserver.data.Room;
- import it.gotoandplay.smartfoxserver.data.User;
- import it.gotoandplay.smartfoxserver.data.Zone;
- import java.util.Iterator;
- import java.util.Map;
- import mext.maou.v2.helpers.Database;
- import mext.maou.v2.helpers.Party;
- import mext.maou.v2.requests.IRequest;
- import mext.maou.v2.requests.RequestException;
- import mext.maou.v2.world.World;
- import mext.maou.v2.world.objects.PartyInfo;
- import net.sf.json.JSONArray;
- import net.sf.json.JSONObject;
- public class Message
- implements IRequest
- {
- public void process(String[] params, User user)
- throws RequestException
- {
- String channel = params[1];
- String message = params[0];
- String[] response = { "chatm", channel + "~" + message, user.getName(), String.valueOf(user.getRoom()) };
- if (((Integer)user.properties.get("permamute")).intValue() > 0) {
- throw new RequestException("You are muted! Chat privileges have been permanently revoked.");
- }
- if (World.instance.userMute.containsKey(user.getName()))
- {
- long remainingMute = ((Long)World.instance.userMute.get(user.getName())).longValue();
- long diffTime = remainingMute - System.currentTimeMillis();
- if (diffTime > 0L) {
- throw new RequestException("You are muted! Chat privileges have been temporarily revoked.");
- }
- }
- if (channel.equals("world"))
- {
- if (((Integer)user.properties.get("coin")).intValue() < 100) {
- throw new RequestException("You need at least 100ACs to send a message in world channel.", "server");
- }
- int coinsLeft = ((Integer)user.properties.get("coin")).intValue() - 100;
- user.properties.put("coin", Integer.valueOf(coinsLeft));
- JSONObject sell = new JSONObject();
- sell.put("cmd", "sellItem");
- sell.put("intAmount", Integer.valueOf(-100));
- sell.put("CharItemID", Integer.valueOf(user.hashCode()));
- sell.put("bCoins", Integer.valueOf(1));
- Database.instance.asyncExecute("UPDATE meh_users SET Coins=Coins-100 WHERE id=?", new Object[] { user.properties.get("dbId") });
- World.instance.sendResponse(sell, user);
- World.instance.sendResponse(response, World.instance.zone.getChannelList());
- }
- else if (channel.equals("party"))
- {
- int partyId = ((Integer)user.properties.get("partyid")).intValue();
- if (partyId < 0) {
- throw new RequestException("You are not in a party.", "server");
- }
- PartyInfo pi = Party.instance.getPartyInfo(partyId);
- World.instance.sendResponse(response, pi.getChannelList());
- }
- else if (channel.equals("guild"))
- {
- Iterator<JSONObject> it;
- if (((Integer)user.properties.get("guildid")).intValue() > 0)
- {
- JSONObject guildData = (JSONObject)user.properties.get("guildobj");
- JSONArray members = (JSONArray)guildData.get("ul");
- if ((members != null) && (members.size() > 0)) {
- for (it = members.iterator(); it.hasNext();)
- {
- JSONObject member = (JSONObject)it.next();
- User others = World.instance.zone.getUserByName(member.get("userName").toString().toLowerCase());
- if (others != null) {
- World.instance.sendResponse(response, others);
- }
- }
- }
- }
- else
- {
- throw new RequestException("You are not in a guild.", "server");
- }
- }
- else
- {
- int access = ((Integer)user.properties.get("access")).intValue();
- switch (access)
- {
- case 100:
- channel1 = "owners";
- break;
- case 60:
- channel = "administrator";
- break;
- case 40:
- channel = "mod";
- break;
- case 4:
- channel = "ps";
- break;
- case 3:
- channel = "vip";
- break;
- default:
- channel = "zone";
- }
- response = new String[] { "chatm", channel + "~" + message, user.getName(), String.valueOf(user.getRoom()) };
- World.instance.sendResponse(response, World.instance.zone.getRoom(user.getRoom()).getChannellList());
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement