Thread: PI Mute doesnt work

Results 1 to 7 of 7
  1. #1 PI Mute doesnt work 
    Donator

    Join Date
    Jun 2012
    Posts
    637
    Thanks given
    129
    Thanks received
    87
    Rep Power
    57
    What am i doing wrong?

    Connection.java
    Code:
    	public static boolean isMuted(Client c) {
    	    return mutedNames.contains(c.playerName) || mutedIps.contains(c.connectedFrom);
    	}
    Command:
    Code:
    if (playerCommand.startsWith("mute")) {
    	try {
    		Client v = c.getPA().getClient(playerCommand.substring(5));
    		if (v != null) {
    			v.sendMessage("You have been muted by "+Misc.optimizeText(c.playerName)+".");
    			c.sendMessage("You have successfully muted "+Misc.optimizeText(v.playerName)+".");
    			Connection.addNameToMuteList(v.playerName);
    		}
    	} catch (Exception e) {
    		c.sendMessage("The player must be online in order to mute them!");
    	}
    }
    The player can still talk after i muted him, Can somebody help?

    will rep++
    Reply With Quote  
     

  2. #2  
    Project Drop-Zone Owner & The BLOOD Gang Always Banging RED


    Join Date
    May 2013
    Age
    28
    Posts
    2,992
    Thanks given
    5
    Thanks received
    937
    Rep Power
    183
    if (c.playerRights >= 1) {
    if (playerCommand.startsWith("mute")) {
    try {
    String playerToBan = playerCommand.substring(5);
    Connection.addNameToMuteList(playerToBan);
    for (int i = 0; i < Config.MAX_PLAYERS; i++) {
    if (Server.playerHandler.getPlayers()[i] != null) {
    if (Server.playerHandler.getPlayers()[i].playerName.equalsIgnoreCase(playerToBan)) {
    Client c2 = (Client) Server.playerHandler.getPlayers()[i];
    c2.sendMessage("You have been muted by: " + Misc.capitalize(c.playerName) + ".");
    break;
    }
    }
    }
    } catch (Exception e) {
    c.sendMessage("Player is probably offline.");
    }
    }
    Let me know if this works.
    Reply With Quote  
     

  3. #3  
    Donator

    Join Date
    Jun 2012
    Posts
    637
    Thanks given
    129
    Thanks received
    87
    Rep Power
    57
    Quote Originally Posted by Demolition View Post
    Let me know if this works.
    I dont got getplayers() in playerassistant :l
    Reply With Quote  
     

  4. #4  
    Project Drop-Zone Owner & The BLOOD Gang Always Banging RED


    Join Date
    May 2013
    Age
    28
    Posts
    2,992
    Thanks given
    5
    Thanks received
    937
    Rep Power
    183
    Download eclipse for me
    Reply With Quote  
     

  5. #5 PI Mute doesnt work 
    Registered Member
    Join Date
    Mar 2013
    Posts
    28
    Thanks given
    0
    Thanks received
    2
    Rep Power
    11
    If the name gets added to the file, but the player can still talk, then you're probably missing the following check in Chat.java

    Below:
    Code:
    	public void processPacket(Client c, int packetType, int packetSize) {
    		c.setChatTextEffects(c.getInStream().readUnsignedByteS());
    		c.setChatTextColor(c.getInStream().readUnsignedByteS());
            c.setChatTextSize((byte)(c.packetSize - 2));
            c.inStream.readBytes_reverseA(c.getChatText(), c.getChatTextSize(), 0);
    Add:

    Code:
    		if (!Connection.isMuted(c)){
                        lastUser = c.playerName;
                        lastMessage = Misc.textUnpack(c.getChatText(), c.getChatTextSize());
                        newMessage = true;
    			c.setChatTextUpdateRequired(true);
                }
    If it's not being added to the file, make sure the path to the file in Connection.java is correct.

    Make sure you have the following methods in Connection.java

    Code:
    public static void muteUsers() {
    		try {
    			BufferedReader in = new BufferedReader(new FileReader("./Data/bans/UsersMuted.txt"));
    			String data = null;
    			try {
    				while ((data = in.readLine()) != null) {
    					mutedNames.add(data);
    				}
    			} finally {
    				in.close();
    			}
    		} catch (IOException e) {
    			e.printStackTrace();
    		}
    	}
    Code:
    muteUsers();
    Under:
    Code:
    public static void initialize() {
    Code:
    public static void addNameToMuteList(String name) {
    		mutedNames.add(name.toLowerCase());
    		addUserToFile(name);
    	}
    Code:
    public static void addUserToFile(String Name) {
    		try {
    			BufferedWriter out = new BufferedWriter(new FileWriter("###PATH TO UsersMuted.txt###", true));
    		    try {
    				out.newLine();
    				out.write(Name);
    		    } finally {
    				out.close();
    		    }
    		} catch (IOException e) {
    			e.printStackTrace();
    		}
    	}
    End finally, here's my ::mute command.

    Code:
    if (playerCommand.startsWith("mute") || playerCommand.startsWith("Mute") || playerCommand.startsWith("MUTE")) {
    			try {	
    				String playerToBan = playerCommand.substring(5);
    				Connection.addNameToMuteList(playerToBan);
    				for(int i = 0; i < Config.MAX_PLAYERS; i++) {
    					if(Server.playerHandler.players[i] != null) {
    						if(Server.playerHandler.players[i].playerName.equalsIgnoreCase(playerToBan)) {
    							Client c2 = (Client)Server.playerHandler.players[i];
    							c2.sendMessage("You have been muted by: " + c.playerName+".");
    							c.sendMessage("You have muted: " + c2.playerName+".");
    							break;
    						} 
    					}
    				}
    			} catch(Exception e) {
    				c.sendMessage("Player Must Be Offline.");
    			}			
    		}
    To clear a little thing up, "muteUsers();" needs to be in method "public static void initialize() {"
    Reply With Quote  
     

  6. #6  
    Donator

    Join Date
    Jun 2012
    Posts
    637
    Thanks given
    129
    Thanks received
    87
    Rep Power
    57
    Quote Originally Posted by The7thSanctum View Post
    If the name gets added to the file, but the player can still talk, then you're probably missing the following check in Chat.java

    Below:
    Code:
    	public void processPacket(Client c, int packetType, int packetSize) {
    		c.setChatTextEffects(c.getInStream().readUnsignedByteS());
    		c.setChatTextColor(c.getInStream().readUnsignedByteS());
            c.setChatTextSize((byte)(c.packetSize - 2));
            c.inStream.readBytes_reverseA(c.getChatText(), c.getChatTextSize(), 0);
    Add:

    Code:
    		if (!Connection.isMuted(c)){
                        lastUser = c.playerName;
                        lastMessage = Misc.textUnpack(c.getChatText(), c.getChatTextSize());
                        newMessage = true;
    			c.setChatTextUpdateRequired(true);
                }
    If it's not being added to the file, make sure the path to the file in Connection.java is correct.

    Make sure you have the following methods in Connection.java

    Code:
    public static void muteUsers() {
    		try {
    			BufferedReader in = new BufferedReader(new FileReader("./Data/bans/UsersMuted.txt"));
    			String data = null;
    			try {
    				while ((data = in.readLine()) != null) {
    					mutedNames.add(data);
    				}
    			} finally {
    				in.close();
    			}
    		} catch (IOException e) {
    			e.printStackTrace();
    		}
    	}
    Code:
    muteUsers();
    Under:
    Code:
    public static void initialize() {
    Code:
    public static void addNameToMuteList(String name) {
    		mutedNames.add(name.toLowerCase());
    		addUserToFile(name);
    	}
    Code:
    public static void addUserToFile(String Name) {
    		try {
    			BufferedWriter out = new BufferedWriter(new FileWriter("###PATH TO UsersMuted.txt###", true));
    		    try {
    				out.newLine();
    				out.write(Name);
    		    } finally {
    				out.close();
    		    }
    		} catch (IOException e) {
    			e.printStackTrace();
    		}
    	}
    End finally, here's my ::mute command.

    Code:
    if (playerCommand.startsWith("mute") || playerCommand.startsWith("Mute") || playerCommand.startsWith("MUTE")) {
    			try {	
    				String playerToBan = playerCommand.substring(5);
    				Connection.addNameToMuteList(playerToBan);
    				for(int i = 0; i < Config.MAX_PLAYERS; i++) {
    					if(Server.playerHandler.players[i] != null) {
    						if(Server.playerHandler.players[i].playerName.equalsIgnoreCase(playerToBan)) {
    							Client c2 = (Client)Server.playerHandler.players[i];
    							c2.sendMessage("You have been muted by: " + c.playerName+".");
    							c.sendMessage("You have muted: " + c2.playerName+".");
    							break;
    						} 
    					}
    				}
    			} catch(Exception e) {
    				c.sendMessage("Player Must Be Offline.");
    			}			
    		}
    To clear a little thing up, "muteUsers();" needs to be in method "public static void initialize() {"
    The player is only muted after aserver restart :l
    Reply With Quote  
     

  7. #7  
    Registered Member
    Join Date
    Mar 2013
    Posts
    28
    Thanks given
    0
    Thanks received
    2
    Rep Power
    11
    Then it's not loading it properly. Are you sure you added "muteUsers();" under the method "public static void initialize() {"? And do you have the array at the top?
    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. [PI] compiler doesnt work on linux vps[PI]
    By Hi Im Carsii in forum Help
    Replies: 4
    Last Post: 07-06-2012, 12:23 AM
  2. [PI] Farming doesnt work :|
    By DragonXile in forum Help
    Replies: 7
    Last Post: 12-12-2011, 07:13 PM
  3. [PI]Lunar doesnt work?
    By Eletides in forum Help
    Replies: 5
    Last Post: 09-05-2011, 02:57 PM
  4. PI firstclickobject doesnt work
    By jordan641 in forum Help
    Replies: 0
    Last Post: 11-04-2010, 11:16 PM
  5. [PI]Mute isn't not working
    By Harambe_ in forum Help
    Replies: 4
    Last Post: 08-22-2010, 11:24 AM
Posting Permissions
  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •