Package com.mcbans.firestar.mcbans.org.json

Examples of com.mcbans.firestar.mcbans.org.json.JSONObject


        this.config = plugin.getConfigs();
    }

    public JSONObject get_data(String json_text) {
        try {
            return new JSONObject(json_text);
        } catch (JSONException e) {
            if (config.isDebug()) {
                e.printStackTrace();
            }
        }
View Full Code Here


            if (config.isDebug()) log.severe("Null Response! Please contact MCBans administrator");
            out.clear();
            return out;
        }
       
        JSONObject output = this.get_data(json_text);
        if (output != null) {
            Iterator<String> i = output.keys();
            if (i != null) {
                while (i.hasNext()) {
                    String next = i.next();
                    try {
                        out.put(next, output.getString(next));
                    } catch (JSONException e) {
                        if (config.isDebug()) {
                            log.severe("JSON Error On Retrieve");
                            e.printStackTrace();
                        }
View Full Code Here

        this.reason = reason;
        this.rollback = rollback;
        this.duration = duration;
        this.measure = measure;
        this.action = action;
        this.actionData = (actionData != null) ? actionData : new JSONObject();

        responses.put("globalBan", 0);
        responses.put("localBan", 1);
        responses.put("tempBan", 2);
        responses.put("unBan", 3);
View Full Code Here

    protected void execute() {
        if (callback.getSender() != null){
            log.info(callback.getSender().getName() + " has looked up the " + targetName + "!");
        }

        JSONObject result = this.request_JOBJ();

        try{
            callback.success(new PlayerLookupData(targetName, result));
        }
        catch (JSONException ex) {
            if (result.toString().contains("error")) {
                if (result.toString().contains("Server Disabled")) {
                    ActionLog.getInstance().severe("Server Disabled by an MCBans Admin");
                    ActionLog.getInstance().severe("To appeal this decision, please file ticket on support.mcbans.com");

                    callback.error("This server disabled by MCBans Administration.");
                    return;
View Full Code Here

        this.issuedByUUID = issuedByUUID;
    }

    @Override
    protected void execute() {
        JSONObject response = this.request_JOBJ();
       
        PlayerIPBanEvent ipBanEvent = new PlayerIPBanEvent(ip, issuedBy, issuedByUUID, reason);
        plugin.getServer().getPluginManager().callEvent(ipBanEvent);
        if (ipBanEvent.isCancelled()){
            return;
        }
        issuedBy = ipBanEvent.getSenderName();
        reason = ipBanEvent.getReason();
       
        // Add default bukkit ipban
        if (Util.isValidIP(ip)){
            Bukkit.getServer().banIP(ip);
        }
       
        try {
            if (response != null && response.has("result")){
                final String result = response.getString("result").trim().toLowerCase(Locale.ENGLISH);
                if (result.equals("y")){
                    //callback.setMessage(Util.color(msg))
                    callback.setBroadcastMessage(ChatColor.GREEN + _("ipBanSuccess", I18n.IP, this.ip, I18n.SENDER, this.issuedBy, I18n.REASON, this.reason));
                    callback.success();
                   
                    kickPlayerByIP(this.ip, reason);
                   
                    log.info("IP " + ip + " has been banned [" + reason + "] [" + issuedBy + "]!");
                    plugin.getServer().getPluginManager().callEvent(new PlayerIPBannedEvent(ip, issuedBy, issuedByUUID, reason));
                }else if (result.equals("a")){
                    // equals("a") if already banned ip
                    callback.error(ChatColor.RED + _("ipBanAlready", I18n.IP, this.ip, I18n.SENDER, this.issuedBy, I18n.REASON, this.reason));
                    log.info(issuedBy + " tried to IPBan " + ip + "!");
                }else if (result.equals("n")){
                    // equals("n") if banning ip is formatted improperly
                    callback.error(ChatColor.RED + _("invalidIP"));
                    log.info(issuedBy + " tried to IPBan " + ip + "!");
                }else if (result.equals("e")){
                    // other error
                    callback.error(ChatColor.RED + _("invalidIP"));
                    log.info(issuedBy + " tried to IPBan " + ip + "!");
                }else{
                    log.severe("Invalid response result: " + result);
                }
            }else{
                callback.error(ChatColor.RED + "API appears to be down!");
            }
        } catch (JSONException ex) {
            if (response.toString().contains("error")) {
                if (response.toString().contains("Server Disabled")) {
                    ActionLog.getInstance().severe("Server Disabled by an MCBans Admin");
                    ActionLog.getInstance().severe("To appeal this decision, please file ticket on support.mcbans.com");

                    callback.error("This server disabled by MCBans Administration.");
                    return;
View Full Code Here

  protected void execute() {
    // TODO Auto-generated method stub
    if (callback.getSender() != null){
            log.info(callback.getSender().getName() + "  looked up the player history for " + target + "!");
        }
    JSONObject result = this.request_JOBJ();
    try{
            callback.success(result.getString("player"), result.getString("players"));
        }
        catch (JSONException ex) {
            if (result.toString().contains("error")) {
                if (result.toString().contains("dne")){
                    callback.error("Player record not found: " + target);
                    return;
                }
                else if (result.toString().contains("Server Disabled")) {
                    ActionLog.getInstance().severe("Server Disabled by an MCBans Admin");
                    ActionLog.getInstance().severe("To appeal this decision, please file ticket on support.mcbans.com");

                    callback.error("This server disabled by MCBans Administration.");
                    return;
View Full Code Here

                JsonHandler webHandle = new JsonHandler( plugin );
                HashMap<String, String> url_items = new HashMap<String, String>();
                url_items.put( "lastId", String.valueOf(plugin.lastID) );
                url_items.put( "lastType", String.valueOf(plugin.lastType) );
                url_items.put( "exec", "banSync" );
                JSONObject response = webHandle.hdl_jobj(url_items);
                try {
                    if(response.has("actions")){
                        if (response.getJSONArray("actions").length() > 0) {
                            for (int v = 0; v < response.getJSONArray("actions").length(); v++) {
                              JSONObject plyer = response.getJSONArray("actions").getJSONObject(v);
                              //plugin.act( plyer.getString("do"), plyer.getString("uuid"));
                              OfflinePlayer d = plugin.getServer().getOfflinePlayer(plyer.getString("name"));
                            if (d != null){
                              if(d.isBanned()){
                                    if(plyer.getString("do").equals("unban")){
                                        d.setBanned(false);
                                    }
                                }else{
                                    if(plyer.getString("do").equals("ban")){
                                        d.setBanned(true);
                                    }
                                }
                            }
                            }
View Full Code Here

                JsonHandler webHandle = new JsonHandler( plugin );
                HashMap<String, String> url_items = new HashMap<String, String>();
                url_items.put( "lastId", String.valueOf(plugin.lastID) );
                url_items.put( "lastType", String.valueOf(plugin.lastType) );
                url_items.put( "exec", "banSync" );
                JSONObject response = webHandle.hdl_jobj(url_items);
                try {
                    if(response.has("actions")){
                        if (response.getJSONArray("actions").length() > 0) {
                            for (int v = 0; v < response.getJSONArray("actions").length(); v++) {
                              JSONObject plyer = response.getJSONArray("actions").getJSONObject(v);
                              //plugin.act( plyer.getString("do"), plyer.getString("uuid"));
                              OfflinePlayer d = plugin.getServer().getOfflinePlayer(plyer.getString("name"));
                            if (d != null){
                              if(d.isBanned()){
                                    if(plyer.getString("do").equals("unban")){
                                        d.setBanned(false);
                                    }
                                }else{
                                    if(plyer.getString("do").equals("ban")){
                                        d.setBanned(true);
                                    }
                                }
                            }
                            }
View Full Code Here

                JsonHandler webHandle = new JsonHandler( plugin );
                HashMap<String, String> url_items = new HashMap<String, String>();
                url_items.put( "lastId", String.valueOf(plugin.lastID) );
                url_items.put( "lastType", String.valueOf(plugin.lastType) );
                url_items.put( "exec", "banSync" );
                JSONObject response = webHandle.hdl_jobj(url_items);
                try {
                    if(response.has("actions")){
                        if (response.getJSONArray("actions").length() > 0) {
                            for (int v = 0; v < response.getJSONArray("actions").length(); v++) {
                              JSONObject plyer = response.getJSONArray("actions").getJSONObject(v);
                              //plugin.act( plyer.getString("do"), plyer.getString("uuid"));
                              OfflinePlayer d = plugin.getServer().getOfflinePlayer(plyer.getString("name"));
                            if (d != null){
                              if(d.isBanned()){
                                    if(plyer.getString("do").equals("unban")){
                                        d.setBanned(false);
                                    }
                                }else{
                                    if(plyer.getString("do").equals("ban")){
                                        d.setBanned(true);
                                    }
                                }
                            }
                              changes++;
View Full Code Here

    protected void execute() {
        if (callback.getSender() != null){
            log.info(callback.getSender().getName() + " has looked up " + playerName + "'s alts!");
        }

        JSONObject result = this.request_JOBJ();

        try{
            if (result != null && result.has("result") && result.getString("result").trim().equals("n")){
                callback.error("This server is not premium!");
            }else{
                callback.success(new AltLookupData(playerName, result));
            }
        }
        catch (JSONException ex) {
            if (result.toString().contains("error")) {
                if (result.toString().contains("Server Disabled")) {
                    ActionLog.getInstance().severe("Server Disabled by an MCBans Admin");
                    ActionLog.getInstance().severe("To appeal this decision, please file a ticket on support.mcbans.com");

                    callback.error("This server is disabled by MCBans Administration.");
                    return;
View Full Code Here

TOP

Related Classes of com.mcbans.firestar.mcbans.org.json.JSONObject

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.