[#718] Making Report abuse work

Oct 31, 2012
120
3
0
ReportAbuse Class:

Code:
package com.rs.game.player.content;

import java.io.BufferedWriter;
import java.io.FileWriter;
import java.io.IOException;
import java.util.Calendar;

public class ReportAbuse {

	public static void handle(String reportName, String username, int offense, boolean muted) {
		Calendar c = Calendar.getInstance();
		
		String date= "[" + ((c.get(c.MONTH))+1) + "/" + c.get(c.DATE) + "/" + c.get(c.YEAR) + "]";// You may want to add time
		
			String filepath = "data/reports/report.txt";
			BufferedWriter out;
			try {
				out = new BufferedWriter(new FileWriter(filepath, true));
				out.write(date + " Report by " + reportName + " - Offender: " + username + " Offense: " + getType(offense));
				out.newLine();
				out.flush();
			} catch (IOException e) {
				// TODO Auto-generated catch block
				e.printStackTrace();
			}
		
	}
	
	public static String getType(int id) {
		
		switch(id) {
		case 6:return "Buying or selling account";
		case 9:return "encourage rule breaking";
		case 5:return "staff impersonation";
		case 7:return "macroing/use of bots";
		case 15:return "scamming";
		case 4:return "Exploiting a bug";
		case 16:return "seriously offensive language";
		case 17:return "solicitation";
		case 18:return "Disruptive behaviour";
		case 19:return "offensive account name";
		case 20:return "real life threats";
		case 13:return "asking for real life info";
		case 21:return "breaking real world laws";
		case 11:return "advertising websites";
		}
		
		return "unknown";
	}
	
}

Code:
private final static int REPORT_ABUSE_PACKET = 11;

Code:
}else if (packetId == REPORT_ABUSE_PACKET) {
			if (!player.hasStarted())
				return;
			@SuppressWarnings("unused")
			String username = stream.readString();
			@SuppressWarnings("unused")
			int type = stream.readUnsignedByte();
			@SuppressWarnings("unused")
			boolean mute = stream.readUnsignedByte() == 1;
			
			System.out.print("username=" + username + " type=" + type + " mute? " + ("" + mute) + " \n");
			
			ReportAbuse.handle(player.getUsername(), username, type, mute);
			
			player.getPackets().sendGameMessage("Thank you for reporting this player. We will investigate your case.");
 
  • Like
Reactions: Dumb Dork
Thanks for the packet id, it worked, here's mine.

Spoiler for Code:
Code:
	private final static int REPORT_ABUSE_PACKET = 11;
Code:
} else if (packetId == REPORT_ABUSE_PACKET) {
            if (!player.hasStarted())
                return;
            String username = stream.readString();
            int type = stream.readUnsignedByte();
	    boolean mute = stream.readUnsignedByte() == 1;
            ReportAbuse.handleReport(player, username, type, mute);
Code:
package com.rs.game.player.content;

import java.io.BufferedWriter;
import java.io.FileWriter;
import java.io.IOException;
import java.text.DateFormat;
import java.util.Calendar;
import java.util.Date;

import com.rs.game.World;
import com.rs.game.player.Player;
import com.rs.utils.Utils;

/**
 * @author Lumby <[email protected]>
 * This feature will not work correctly until we have the Report abuse packet id.
 */

public class ReportAbuse {	
	
	public static void openReport(Player player, String offender) {
		if (player.getAttackedByDelay() + 10000 > Utils.currentTimeMillis()) {
			player.getPackets()
					.sendGameMessage(
							"You cannot do that while under attack!");
			return;
		}
			if (player.getInterfaceManager().containsScreenInter()) {
				player.getPackets()
				.sendGameMessage(
						"Please finish what you're doing before opening Report Abuse.");
				return;
			}
		player.getInterfaceManager().sendInterface(594);
	}
	
	public static void handleReport(Player player, String username, int ruleId, boolean mute) {
		Player offender;
		offender = World.getPlayerByDisplayName(username);
		player.sm("Thank-you, your abuse report has been received.");
		World.sendWorldMessage(("<col=A901DB><img=5>Abuse Report: "+player.getDisplayName() + " has reported "+username+" for \""+getOffense(ruleId)+"\"."),
				true);
		logReport(player, username, ruleId);
		if(mute)
		offender.setMuted(Utils.currentTimeMillis() + 48 * 60 * 60 * 1000);
	}

	private static void logReport(Player player, String offender, int offense) {
		try {
			BufferedWriter bf = new BufferedWriter(new FileWriter(
					"data/logs/reports.txt", true));
			bf.write("[" + DateFormat.getDateTimeInstance().format(new Date())
					+ " "
					+ Calendar.getInstance().getTimeZone().getDisplayName()
					+ "] "
					+ Utils.formatPlayerNameForDisplay(player.getUsername())
					+ " has reported: " + offender + " for: " + getOffense(offense));
			System.err.println("[" + DateFormat.getDateTimeInstance().format(new Date())
					+ " "
					+ Calendar.getInstance().getTimeZone().getDisplayName()
					+ "] "
					+ Utils.formatPlayerNameForDisplay(player.getUsername())
					+ " has reported a "+offender+". ");
			bf.newLine();
			bf.flush();
			bf.close();
		} catch (IOException ignored) {
		}
	}
	
	public static String getOffense(int ruleId) {
		String ruleName = "";
		        switch (ruleId) {
		        case 6:
		        	return "Buying or selling account";
		        case 9:
		        	return "Encouraging rule breaking";
		        case 5:
		        	return "Staff impersonation";
		        case 7:
		        	return "Macroing/use of bots";
		        case 15:
		        	return "Scamming";
		        case 4:
		        	return "Exploiting a bug";
		        case 16:
		        	return "Seriously offensive language";
		        case 17:
		        	return "Solicitation";
		        case 18:
		        	return "Disruptive behaviour";
		        case 19:
		        	return "Offensive account name";
		        case 20:
		        	return "Real life threats";
		        case 13:
		        	return "Asking for real life info";
		        case 21:
		        	return "Breaking real world laws";
		        case 11:
		            return "Advertising websites";
		        }
		        return ruleName;
		    }

}
Spoiler for Random picture:
1kPt8

Credits to Lumby from dementhium, and you.



I also used this snippet to enable right-click reporting.
http://www.rune-server.org/runescap...pets/449451-718-view-stats-player-option.html
 
Last edited:
Make it open the report abuse interface when clicking the report abuse button?

Code:
		} else if (interfaceId == 751) {
			if (componentId == 14) {
				player.getInterfaceManager().sendInterface(594);
		}
 
Thanks for the packet id, it worked, here's mine.

Spoiler for Code:
Code:
	private final static int REPORT_ABUSE_PACKET = 11;
Code:
} else if (packetId == REPORT_ABUSE_PACKET) {
            if (!player.hasStarted())
                return;
            String username = stream.readString();
            int type = stream.readUnsignedByte();
            @SuppressWarnings("unused")
			boolean mute = stream.readUnsignedByte() == 1;
            ReportAbuse.handleReport(player, username, type);
Code:
package com.rs.game.player.content;

import java.io.BufferedWriter;
import java.io.FileWriter;
import java.io.IOException;
import java.text.DateFormat;
import java.util.Calendar;
import java.util.Date;

import com.rs.game.World;
import com.rs.game.player.Player;
import com.rs.utils.Utils;

/**
 * @author Lumby <[email protected]>
 * This feature will not work correctly until we have the Report abuse packet id.
 */

public class ReportAbuse {	
	public static void openReport(Player player, String offender) {
		if (player.getAttackedByDelay() + 10000 > Utils.currentTimeMillis()) {
			player.getPackets()
					.sendGameMessage(
							"You cannot do that while under attack!");
			return;
		}
			if (player.getInterfaceManager().containsScreenInter()) {
				player.getPackets()
				.sendGameMessage(
						"Please finish what you're doing before opening Report Abuse.");
				return;
			}
		player.getInterfaceManager().sendInterface(594);
	}
	
	public static void handleReport(Player player, String offender, int ruleId) {
		player.sm("Thank-you, your abuse report has been received.");
				World.sendWorldMessage(("<col=A901DB><img=5>Abuse Report: "+player.getDisplayName() + " has reported "+offender+" for \""
			+getOffense(ruleId)+"\"."), true);
				System.err.println("[" + DateFormat.getDateTimeInstance().format(new Date())
						+ " "
						+ Calendar.getInstance().getTimeZone().getDisplayName()
						+ "] "
						+ Utils.formatPlayerNameForDisplay(player.getUsername())
						+ " has reported a "+offender+". ");
				logReport(player, offender, ruleId);
	}

	private static void logReport(Player player, String Offender, int offense) {
		try {
			BufferedWriter bf = new BufferedWriter(new FileWriter(
					"data/logs/reports.txt", true));
			bf.write("[" + DateFormat.getDateTimeInstance().format(new Date())
					+ " "
					+ Calendar.getInstance().getTimeZone().getDisplayName()
					+ "] "
					+ Utils.formatPlayerNameForDisplay(player.getUsername())
					+ " has reported: " + Offender + " for: " + getOffense(offense));
			bf.newLine();
			bf.flush();
			bf.close();
		} catch (IOException ignored) {
		}
	}
	
	public static String getOffense(int ruleId) {
		String ruleName = "";
		switch (ruleId) {
		case 6:
			ruleName = "Buying or selling account";
			break;
		case 9:
			ruleName = "Encouraging rule breaking";
			break;
		case 5:
			ruleName = "Staff impersonation";
			break;
		case 7:
			ruleName = "Macroing/use of bots";
			break;
		case 15:
			ruleName = "Scamming";
			break;
		case 4:
			ruleName = "Exploiting a bug";
			break;
		case 16:
			ruleName = "Seriously offensive language";
			break;
		case 17:
			ruleName = "Solicitation";
			break;
		case 18:
			ruleName = "Disruptive behaviour";
			break;
		case 19:
			ruleName = "Offensive account name";
			break;
		case 20:
			ruleName = "Real life threats";
			break;
		case 13:
			ruleName = "Asking for real life info";
			break;
		case 21:
			ruleName = "Breaking real world laws";
			break;
		case 11:
			ruleName = "Advertising websites";
			break;
		}
		return ruleName;
	}

}
Spoiler for Random picture:
1kPt8

Credits to Lumby from dementhium, and you.



I also used this snippet to enable right-click reporting.
http://www.rune-server.org/runescap...pets/449451-718-view-stats-player-option.html

Nice^^ Was going to work on mine too but I stoped coding for a while. :)
 
This is not how it should. Add 60 last chat messages, recent trades and private messages. Nobody has use for this if those are not added. At least, I prefer how mine is done.
 
This is not how it should. Add 60 last chat messages, recent trades and private messages. Nobody has use for this if those are not added. At least, I prefer how mine is done.


Well, mine is actually also done differently but this is just what I decided to release and people can do with this whatever they want and ofc they can add a lot more stuff. I'm not spoonfeeding everybody.
 
Does anyone know the second part of that screen's interface id? The part where you choose what you're reporting them for.

Edit - Found the newest report interface - 914 (page 1) 915 (page 2) and 913 for the temp ignore the player after reporting them.
 
Use 594, it auto does all that stuff like ignore until logout, select a reason etc...
And btw. 914, 915 and 913 is lobby reporting ;)
 
Use 594, it auto does all that stuff like ignore until logout, select a reason etc...
And btw. 914, 915 and 913 is lobby reporting ;)

But using 594, it doesn't go to the next part of the interface, to choose which you're reporting for?
 

Users who are viewing this thread (total: 1, members: 0, guests: 1)

Who read this thread (total members: 4)