Thread: Unban command not working.

Results 1 to 4 of 4
  1. #1 Unban command not working. 
    Registered Member
    Join Date
    Aug 2015
    Posts
    28
    Thanks given
    1
    Thanks received
    4
    Rep Power
    11
    Okay hey guys - I'm using a 667 source and I was developing a section of code in commands.java so that no staff can ban each other (because you know, you get that odd one who tries to ban other staff for fun) - and I tried banning myself, owner and I got banned haha. My code now works, tested it with another owner account and kills the player who tries banning staff - however, I found that my unban command doesn't work?

    Here's the ban command and unban command:

    ::ban
    [SPOIL]
    Code:
    if (cmd[0].equalsIgnoreCase("ban")) {
        
        if (cmd[1].equalsIgnoreCase("Zodiac")) {
            player.getPackets().sendGameMessage("Don't try ban me.");
        }
        if	(cmd[1].equalsIgnoreCase("Callum")) {
            player.getPackets().sendGameMessage("Don't bother.");
            
        }
        
        else {
            
            String name = "";
            for (int i = 1; i < cmd.length; i++)
                name += cmd[i] + ((i == cmd.length - 1) ? "" : " ");
            
            Player target = World.getPlayerByDisplayName(name);
            if (target != null) {
                target.setBanned(Utils.currentTimeMillis()
                + (48 * 60 * 60 * 1000));
                target.getSession().getChannel().close();
                player.getPackets().sendGameMessage("You have banned 48 hours: "+ target.getDisplayName() + ".");
            } else {
                player.getPackets().sendGameMessage("Couldn't find player " + name + ".");
            }
            
            try {
                File file = new File("data/logs/ban.txt");
                BufferedWriter writer = new BufferedWriter(new FileWriter(
                file, true));
                writer.write ("[" + DateFormat.getDateTimeInstance().format(new Date()) + "]" + player.getDisplayName() + " banned " + target.getDisplayName());
                writer.newLine();
                writer.flush();
            } catch (IOException e) {A
                e.printStackTrace();
            }
            return true;
    [/SPOIL]

    ::unban
    [SPOIL]
    Code:
    if (cmd[0].equalsIgnoreCase("unban")) {
        String name = "";
        for (int i = 1; i < cmd.length; i++)
            name += cmd[i] + ((i == cmd.length - 1) ? "" : " ");
        Player target = null;
        if (target == null) {
            target = SerializableFilesManager.loadPlayer(Utils.formatPlayerNameForProtocol(name));
            player.setPermBanned(false);
            player.setBanned(0);
            SerializableFilesManager.savePlayer(target);
            if (!IPBanL.getList().contains(player.getLastIP()))
                player.getPackets().sendGameMessage("You unbanned "+ Utils.formatPlayerNameForProtocol(name) + ".", true);
            else
                player.getPackets().sendGameMessage("Something went wrong. Contact a developer.", true);
        }
    }
    [/SPOIL]

    And here's what's confusing me - it's notifying me saying "You have unbanned (playername) but it's still not working?

    - Is it something to do with
    Code:
    player.setBanned(0);
    Would that need to be changed to
    Code:
    player.setBanned(false);
    Update:

    Tried changing it from '0' to 'false' - compile error so no go. Any help?
    Reply With Quote  
     

  2. #2  
    Registered Member

    Join Date
    Dec 2010
    Posts
    1,982
    Thanks given
    174
    Thanks received
    256
    Rep Power
    223
    Quote Originally Posted by iZodiac View Post
    Okay hey guys - I'm using a 667 source and I was developing a section of code in commands.java so that no staff can ban each other (because you know, you get that odd one who tries to ban other staff for fun) - and I tried banning myself, owner and I got banned haha. My code now works, tested it with another owner account and kills the player who tries banning staff - however, I found that my unban command doesn't work?

    Here's the ban command and unban command:

    ::ban
    [SPOIL]
    Code:
    if (cmd[0].equalsIgnoreCase("ban")) {
        
        if (cmd[1].equalsIgnoreCase("Zodiac")) {
            player.getPackets().sendGameMessage("Don't try ban me.");
        }
        if	(cmd[1].equalsIgnoreCase("Callum")) {
            player.getPackets().sendGameMessage("Don't bother.");
            
        }
        
        else {
            
            String name = "";
            for (int i = 1; i < cmd.length; i++)
                name += cmd[i] + ((i == cmd.length - 1) ? "" : " ");
            
            Player target = World.getPlayerByDisplayName(name);
            if (target != null) {
                target.setBanned(Utils.currentTimeMillis()
                + (48 * 60 * 60 * 1000));
                target.getSession().getChannel().close();
                player.getPackets().sendGameMessage("You have banned 48 hours: "+ target.getDisplayName() + ".");
            } else {
                player.getPackets().sendGameMessage("Couldn't find player " + name + ".");
            }
            
            try {
                File file = new File("data/logs/ban.txt");
                BufferedWriter writer = new BufferedWriter(new FileWriter(
                file, true));
                writer.write ("[" + DateFormat.getDateTimeInstance().format(new Date()) + "]" + player.getDisplayName() + " banned " + target.getDisplayName());
                writer.newLine();
                writer.flush();
            } catch (IOException e) {A
                e.printStackTrace();
            }
            return true;
    [/SPOIL]

    ::unban
    [SPOIL]
    Code:
    if (cmd[0].equalsIgnoreCase("unban")) {
        String name = "";
        for (int i = 1; i < cmd.length; i++)
            name += cmd[i] + ((i == cmd.length - 1) ? "" : " ");
        Player target = null;
        if (target == null) {
            target = SerializableFilesManager.loadPlayer(Utils.formatPlayerNameForProtocol(name));
            player.setPermBanned(false);
            player.setBanned(0);
            SerializableFilesManager.savePlayer(target);
            if (!IPBanL.getList().contains(player.getLastIP()))
                player.getPackets().sendGameMessage("You unbanned "+ Utils.formatPlayerNameForProtocol(name) + ".", true);
            else
                player.getPackets().sendGameMessage("Something went wrong. Contact a developer.", true);
        }
    }
    [/SPOIL]

    And here's what's confusing me - it's notifying me saying "You have unbanned (playername) but it's still not working?

    - Is it something to do with
    Code:
    player.setBanned(0);
    Would that need to be changed to
    Code:
    player.setBanned(false);
    Update:

    Tried changing it from '0' to 'false' - compile error so no go. Any help?
    That depends on the getter, is it a integer or a boolean
    Reply With Quote  
     

  3. #3  
    Extreme Donator


    Join Date
    Mar 2009
    Posts
    1,461
    Thanks given
    111
    Thanks received
    184
    Rep Power
    79
    try IPBanL.unban(target);
    Attached image
    Quote Originally Posted by MaxXi View Post
    Your combat is so awsome that i almost forgot its the combat matrix coded.
    Quote Originally Posted by twobrosplay View Post
    Try allowing the batch file through your firewall?
    Quote Originally Posted by SS_Alophonse View Post
    i have no life u say ha anything u say kid.i doubt u can even get a girlfriend
    i bet u cant even code anything.
    Reply With Quote  
     

  4. #4  
    Registered Member

    Join Date
    Feb 2013
    Posts
    4,409
    Thanks given
    59
    Thanks received
    478
    Rep Power
    138
    Post the code that stops them from logging in.
    Reply With Quote  
     


Thread Information
Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)


User Tag List

Similar Threads

  1. Replies: 5
    Last Post: 01-23-2013, 12:43 AM
  2. commands not working !!!
    By RuneBlaze in forum Help
    Replies: 14
    Last Post: 05-11-2009, 01:41 PM
  3. [banuser/unban] commands not workin!!!!
    By shassan in forum Help
    Replies: 5
    Last Post: 03-23-2009, 06:31 PM
  4. making commands not work in wildy
    By Jared1220 in forum Requests
    Replies: 9
    Last Post: 11-10-2008, 06:37 PM
  5. Yell command not working
    By mitch123hoff in forum Help
    Replies: 7
    Last Post: 10-31-2008, 06:42 AM
Tags for this Thread

View Tag Cloud

Posting Permissions
  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •