mirror of
https://github.com/darksaid98/AntiCheatReloaded.git
synced 2026-12-01 14:38:56 +00:00
Added pastebin reporting. This should make ticket reporting life so much easier, it's like a requirement.
This commit is contained in:
1 parent
137d968a70
commit
e298173735
4 files changed
+273
-1
No files matched your search
@@ -19,6 +19,8 @@
|
||||
package net.h31ix.anticheat;
|
||||
|
||||
import net.h31ix.anticheat.util.Configuration;
|
||||
import net.h31ix.anticheat.util.PastebinReport;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
@@ -95,6 +97,17 @@ public class CommandHandler implements CommandExecutor
|
||||
}
|
||||
}
|
||||
|
||||
public void handlePastebin(CommandSender cs)
|
||||
{
|
||||
if (Permission.SYSTEM_REPORT.get(cs))
|
||||
{
|
||||
PastebinReport report = new PastebinReport();
|
||||
cs.sendMessage(GREEN + "Your URL is: " + report.getURL());
|
||||
cs.sendMessage("If you are making a new issue, use this tool every time.");
|
||||
cs.sendMessage("It will help us resolve your issues faster.");
|
||||
}
|
||||
}
|
||||
|
||||
public void handleXRay(CommandSender cs, String[] args)
|
||||
{
|
||||
if (Permission.SYSTEM_XRAY.get(cs))
|
||||
@@ -248,6 +261,7 @@ public class CommandHandler implements CommandExecutor
|
||||
cs.sendMessage(base + GREEN + "xray [user]" + WHITE + " - check user's xray levels");
|
||||
cs.sendMessage(base + GREEN + "spy [user]" + WHITE + " - spy on a user in secret");
|
||||
cs.sendMessage(base + GREEN + "help" + WHITE + " - access this page");
|
||||
cs.sendMessage(base + GREEN + "pastebin" + WHITE + " - create a anticheat report");
|
||||
cs.sendMessage(base + GREEN + "update" + WHITE + " - check update status");
|
||||
cs.sendMessage("-----------------------------------------------------");
|
||||
}
|
||||
@@ -493,6 +507,10 @@ public class CommandHandler implements CommandExecutor
|
||||
{
|
||||
handleHelp(cs);
|
||||
}
|
||||
else if (args[0].equalsIgnoreCase("pastebin"))
|
||||
{
|
||||
handlePastebin(cs);
|
||||
}
|
||||
else if (args[0].equalsIgnoreCase("report"))
|
||||
{
|
||||
handleReport(cs);
|
||||
|
||||
@@ -19,6 +19,8 @@
|
||||
package net.h31ix.anticheat.manage;
|
||||
|
||||
import java.io.File;
|
||||
import java.util.List;
|
||||
import java.util.concurrent.CopyOnWriteArrayList;
|
||||
import java.util.logging.*;
|
||||
import net.h31ix.anticheat.Anticheat;
|
||||
import net.h31ix.anticheat.util.Configuration;
|
||||
@@ -40,6 +42,7 @@ public class AnticheatManager
|
||||
private CheckManager checkManager = null;
|
||||
private Backend backend = null;
|
||||
private static Logger LOGGER, FILE_LOGGER;
|
||||
private static List<String> logs = new CopyOnWriteArrayList<String>();
|
||||
private static Handler fileHandler;
|
||||
private static final int LOG_LEVEL_HIGH = 3;
|
||||
|
||||
@@ -82,6 +85,7 @@ public class AnticheatManager
|
||||
{
|
||||
fileLog(ChatColor.stripColor(message));
|
||||
}
|
||||
logs.add(ChatColor.stripColor(message));
|
||||
}
|
||||
|
||||
public void fileLog(String message)
|
||||
@@ -89,6 +93,18 @@ public class AnticheatManager
|
||||
FILE_LOGGER.info(message);
|
||||
}
|
||||
|
||||
public List<String> getLastLogs()
|
||||
{
|
||||
List<String> log = new CopyOnWriteArrayList<String>();
|
||||
if (logs.size() < 30)
|
||||
return logs;
|
||||
for(int i = 1; i < 31; i++) {
|
||||
log.add(logs.get(logs.size() - i));
|
||||
}
|
||||
logs.clear();
|
||||
return log;
|
||||
}
|
||||
|
||||
public Anticheat getPlugin()
|
||||
{
|
||||
return plugin;
|
||||
|
||||
@@ -25,6 +25,8 @@ import java.util.List;
|
||||
import java.util.Map;
|
||||
import net.h31ix.anticheat.event.EventListener;
|
||||
import net.h31ix.anticheat.util.Utilities;
|
||||
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.ChatColor;
|
||||
import org.bukkit.GameMode;
|
||||
import org.bukkit.Location;
|
||||
@@ -162,6 +164,85 @@ public class Backend
|
||||
micromanage = instance;
|
||||
}
|
||||
|
||||
public void buildAdvancedInformation(StringBuilder r)
|
||||
{
|
||||
r.append("Dropped Items List:" + '\n');
|
||||
for (String l : droppedItem)
|
||||
{
|
||||
r.append(l + '\n');
|
||||
}
|
||||
r.append("Moving Exempt List:" + '\n');
|
||||
for (String l : movingExempt)
|
||||
{
|
||||
r.append(l + '\n');
|
||||
}
|
||||
r.append("Broken Block List:" + '\n');
|
||||
for (String l : brokenBlock)
|
||||
{
|
||||
r.append(l + '\n');
|
||||
}
|
||||
r.append("Placed Block List:" + '\n');
|
||||
for (String l : placedBlock)
|
||||
{
|
||||
r.append(l + '\n');
|
||||
}
|
||||
r.append("Bow Wind Up List:" + '\n');
|
||||
for (String l : bowWindUp)
|
||||
{
|
||||
r.append(l + '\n');
|
||||
}
|
||||
r.append("Start Eating List:" + '\n');
|
||||
for (String l : startEat)
|
||||
{
|
||||
r.append(l + '\n');
|
||||
}
|
||||
r.append("Healed List:" + '\n');
|
||||
for (String l : healed)
|
||||
{
|
||||
r.append(l + '\n');
|
||||
}
|
||||
r.append("Sprinted List:" + '\n');
|
||||
for (String l : sprinted)
|
||||
{
|
||||
r.append(l + '\n');
|
||||
}
|
||||
r.append("Is In Water List:" + '\n');
|
||||
for (String l : isInWater)
|
||||
{
|
||||
r.append(l + '\n');
|
||||
}
|
||||
r.append("Is In Water (cached) List:" + '\n');
|
||||
for (String l : isInWaterCache)
|
||||
{
|
||||
r.append(l + '\n');
|
||||
}
|
||||
r.append("Instant Break Exempt List:" + '\n');
|
||||
for (String l : instantBreakExempt)
|
||||
{
|
||||
r.append(l + '\n');
|
||||
}
|
||||
r.append("Is Ascending List:" + '\n');
|
||||
for (String l : isAscending)
|
||||
{
|
||||
r.append(l + '\n');
|
||||
}
|
||||
r.append("Tracking Projectiles List:" + '\n');
|
||||
for (String l : trackingProjectiles)
|
||||
{
|
||||
r.append(l + '\n');
|
||||
}
|
||||
r.append("Velocitizing List:" + '\n');
|
||||
for (String l : velocitizing)
|
||||
{
|
||||
r.append(l + '\n');
|
||||
}
|
||||
r.append("Interacting List:" + '\n');
|
||||
for (String l : interacting)
|
||||
{
|
||||
r.append(l + '\n');
|
||||
}
|
||||
}
|
||||
|
||||
public boolean checkLongReachBlock(Player player, double x, double y, double z)
|
||||
{
|
||||
return !Utilities.isUsingMcMMOAbility(player) && (x >= BLOCK_MAX_DISTANCE || y > BLOCK_MAX_DISTANCE || z > BLOCK_MAX_DISTANCE);
|
||||
@@ -283,7 +364,7 @@ public class Backend
|
||||
{
|
||||
return false;
|
||||
}*/
|
||||
if(!Utilities.isInteractable(targetBlock.getType()))
|
||||
if (!Utilities.isInteractable(targetBlock.getType()))
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
@@ -0,0 +1,157 @@
|
||||
/*
|
||||
* AntiCheat for Bukkit.
|
||||
* Copyright (C) 2012 AntiCheat Team | http://h31ix.net
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
package net.h31ix.anticheat.util;
|
||||
|
||||
import java.io.BufferedReader;
|
||||
import java.io.BufferedWriter;
|
||||
import java.io.File;
|
||||
import java.io.FileWriter;
|
||||
import java.io.IOException;
|
||||
import java.io.InputStream;
|
||||
import java.io.InputStreamReader;
|
||||
import java.io.OutputStream;
|
||||
import java.io.Writer;
|
||||
import java.net.HttpURLConnection;
|
||||
import java.net.URL;
|
||||
import java.net.URLEncoder;
|
||||
import java.text.SimpleDateFormat;
|
||||
import java.util.Date;
|
||||
|
||||
import org.bukkit.Bukkit;
|
||||
|
||||
import net.h31ix.anticheat.Anticheat;
|
||||
|
||||
public class PastebinReport
|
||||
{
|
||||
private StringBuilder report = new StringBuilder();
|
||||
private String url = "";
|
||||
private Date date = new Date();
|
||||
private SimpleDateFormat format = new SimpleDateFormat("yyyy-MM-dd kk:mm Z");
|
||||
|
||||
public PastebinReport()
|
||||
{
|
||||
createReport();
|
||||
try
|
||||
{
|
||||
writeReport();
|
||||
}
|
||||
catch (IOException e)
|
||||
{
|
||||
// TODO Auto-generated catch block
|
||||
//e.printStackTrace();
|
||||
}
|
||||
postReport();
|
||||
}
|
||||
|
||||
public String getURL()
|
||||
{
|
||||
return url;
|
||||
}
|
||||
|
||||
private void createReport()
|
||||
{
|
||||
report.append("------------ AntiCheat Report - " + format.format(date) + " ------------" + '\n');
|
||||
report.append("Version: " + Anticheat.getVersion() + '\n');
|
||||
report.append("CraftBukkit: " + Bukkit.getVersion() + '\n');
|
||||
appendSystemInfo();
|
||||
report.append("------------Last 30 logs------------" + '\n');
|
||||
for (String log : Anticheat.getManager().getLastLogs())
|
||||
{
|
||||
report.append("[AntiCheat] " + log + '\n');
|
||||
}
|
||||
report.append("------------Advanced Information------------" + '\n');
|
||||
Anticheat.getManager().getBackend().buildAdvancedInformation(report);
|
||||
report.append("-----------End Of Report------------");
|
||||
}
|
||||
|
||||
private void appendSystemInfo()
|
||||
{
|
||||
Runtime runtime = Runtime.getRuntime();
|
||||
report.append("Java: " + System.getProperty("java.vendor") + " " + System.getProperty("java.version") + " (" + System.getProperty("java.vendor.url") + ")" + '\n');
|
||||
report.append("OS: " + System.getProperty("os.name") + " " + System.getProperty("os.version") + " (" + System.getProperty("os.arch") + ")" + '\n');
|
||||
report.append("Free Memory: " + runtime.freeMemory() / 1024 / 1024 + "MB" + '\n');
|
||||
report.append("Max Memory: " + runtime.maxMemory() / 1024 / 1024 + "MB" + '\n');
|
||||
report.append("Total Memory: " + runtime.totalMemory() / 1024 / 1024 + "MB" + '\n');
|
||||
report.append("Server ID + Name: " + Bukkit.getServerId() + " - " + Bukkit.getName() + '\n');
|
||||
report.append("Players: " + Bukkit.getOnlinePlayers().length + "/" + Bukkit.getMaxPlayers() + '\n');
|
||||
}
|
||||
|
||||
private void writeReport() throws IOException
|
||||
{
|
||||
File f = new File(Anticheat.getPlugin().getDataFolder() + "/report.txt");
|
||||
FileWriter r = new FileWriter(f);
|
||||
BufferedWriter writer = new BufferedWriter(r);
|
||||
writer.write(report.toString());
|
||||
writer.close();
|
||||
}
|
||||
|
||||
private void postReport()
|
||||
{
|
||||
try
|
||||
{
|
||||
URL urls = new URL("http://pastebin.com/api/api_post.php");
|
||||
HttpURLConnection conn = (HttpURLConnection) urls.openConnection();
|
||||
conn.setConnectTimeout(5000);
|
||||
conn.setReadTimeout(5000);
|
||||
conn.setRequestMethod("POST");
|
||||
conn.addRequestProperty("Content-type", "application/x-www-form-urlencoded");
|
||||
conn.setInstanceFollowRedirects(false);
|
||||
conn.setDoOutput(true);
|
||||
OutputStream out = conn.getOutputStream();
|
||||
|
||||
out.write(("api_option=paste" + "&api_dev_key=" + URLEncoder.encode("c0616def494dcb5b7632304f8c52c0f1", "utf-8") + "&api_paste_code=" + URLEncoder.encode(report.toString(), "utf-8") + "&api_paste_private=" + URLEncoder.encode("0", "utf-8") + "&api_paste_name=" + URLEncoder.encode("", "utf-8") + "&api_paste_expire_date=" + URLEncoder.encode("1D", "utf-8") + "&api_paste_format=" + URLEncoder.encode("text", "utf-8") + "&api_user_key=" + URLEncoder.encode("", "utf-8")).getBytes());
|
||||
out.flush();
|
||||
out.close();
|
||||
|
||||
if (conn.getResponseCode() == 200)
|
||||
{
|
||||
InputStream receive = conn.getInputStream();
|
||||
BufferedReader reader = new BufferedReader(new InputStreamReader(receive));
|
||||
String line;
|
||||
StringBuffer response = new StringBuffer();
|
||||
while ((line = reader.readLine()) != null)
|
||||
{
|
||||
response.append(line);
|
||||
response.append("\r\n");
|
||||
}
|
||||
reader.close();
|
||||
|
||||
String result = response.toString().trim();
|
||||
|
||||
if (!result.contains("http://"))
|
||||
{
|
||||
url = "Failed to post. Check report.txt";
|
||||
}
|
||||
else
|
||||
{
|
||||
url = result.trim();
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
url = "Failed to post. Check report.txt";
|
||||
}
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
url = "Failed to post. Check report.txt";
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
Reference in new issue
Block a user