minor updates for the eventnotifier to run on ze again and minor adjustment for racetimer to detect teleport abuse
This commit is contained in:
parent
0ab0414f53
commit
00f91030f9
@ -62,7 +62,7 @@ public class DataMapper {
|
|||||||
int i = 1;
|
int i = 1;
|
||||||
for (String str : EventContentMap.values()) {
|
for (String str : EventContentMap.values()) {
|
||||||
if (i < 6) {
|
if (i < 6) {
|
||||||
System.out.println("str: " + str + "\n");
|
//System.out.println("str: " + str + "\n");
|
||||||
s.setString(i, str);
|
s.setString(i, str);
|
||||||
i++;
|
i++;
|
||||||
} else {
|
} else {
|
||||||
|
@ -30,6 +30,8 @@ import java.util.concurrent.ConcurrentMap;
|
|||||||
import java.util.concurrent.TimeUnit;
|
import java.util.concurrent.TimeUnit;
|
||||||
import java.util.logging.Level;
|
import java.util.logging.Level;
|
||||||
import java.util.logging.Logger;
|
import java.util.logging.Logger;
|
||||||
|
import java.util.regex.Pattern;
|
||||||
|
import static jdk.nashorn.internal.objects.NativeRegExp.source;
|
||||||
import org.javacord.api.DiscordApi;
|
import org.javacord.api.DiscordApi;
|
||||||
import org.javacord.api.DiscordApiBuilder;
|
import org.javacord.api.DiscordApiBuilder;
|
||||||
import org.javacord.api.event.message.MessageCreateEvent;
|
import org.javacord.api.event.message.MessageCreateEvent;
|
||||||
@ -57,52 +59,82 @@ public class EventNotifier {
|
|||||||
int firstEventForZEFinder = 0;
|
int firstEventForZEFinder = 0;
|
||||||
while ((inputLine = in.readLine()) != null) {
|
while ((inputLine = in.readLine()) != null) {
|
||||||
content.append(inputLine).append("\n");
|
content.append(inputLine).append("\n");
|
||||||
if (inputLine.contains(">Event #") && firstEventForZEFinder == 0) {
|
if (inputLine.contains(">Event #") && inputLine.contains("data-previewUrl=\"") && firstEventForZEFinder == 0) {
|
||||||
if (!inputLine.contains("Nomination") && !inputLine.contains("Poll")) {
|
//System.out.println("inputLine: " + inputLine);
|
||||||
int diff = content.length() - inputLine.length();
|
boolean find = Pattern.compile(Pattern.quote("nomination"), Pattern.CASE_INSENSITIVE).matcher(inputLine).find();
|
||||||
firstEventForZEFinder = diff > 0 ? diff : 0;
|
if (!find) {
|
||||||
|
find = Pattern.compile(Pattern.quote("poll"), Pattern.CASE_INSENSITIVE).matcher(inputLine).find();
|
||||||
|
if (!find) {
|
||||||
|
int diff = content.length() - inputLine.length();
|
||||||
|
firstEventForZEFinder = diff > 0 ? diff : 0;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
String str = content.toString();
|
String str = content.toString();
|
||||||
String hRef = "<a href=\"";
|
String hRef = "data-previewUrl=\"";
|
||||||
str = str.substring(firstEventForZEFinder);
|
str = str.substring(firstEventForZEFinder);
|
||||||
|
//System.out.println("str post firstEventForZEFinder: " + str);
|
||||||
str = str.substring(0, str.indexOf(">Event #"));
|
str = str.substring(0, str.indexOf(">Event #"));
|
||||||
str = str.substring(str.lastIndexOf(hRef), str.lastIndexOf("\" title="));
|
str = str.trim();
|
||||||
|
str = str.substring(str.indexOf(hRef), str.lastIndexOf("/preview\""));
|
||||||
str = str.replace(hRef, "");
|
str = str.replace(hRef, "");
|
||||||
String urlFirstEvent = "https://unloze.com/" + str;
|
String urlFirstEvent = "https://unloze.com/" + str;
|
||||||
System.out.println(urlFirstEvent);
|
System.out.println("urlFirstEvent: " + urlFirstEvent);
|
||||||
url = new URL(urlFirstEvent);
|
url = new URL(urlFirstEvent);
|
||||||
con = (HttpURLConnection) url.openConnection();
|
con = (HttpURLConnection) url.openConnection();
|
||||||
con.setRequestMethod("GET");
|
con.setRequestMethod("GET");
|
||||||
in = new BufferedReader(new InputStreamReader(con.getInputStream()));
|
in = new BufferedReader(new InputStreamReader(con.getInputStream()));
|
||||||
content = new StringBuffer();
|
content = new StringBuffer();
|
||||||
|
String title = "";
|
||||||
while ((inputLine = in.readLine()) != null) {
|
while ((inputLine = in.readLine()) != null) {
|
||||||
content.append(inputLine).append("\n");
|
content.append(inputLine).append("\n");
|
||||||
|
if (inputLine.contains("Server :")) {
|
||||||
|
int diff = content.length() - inputLine.length();
|
||||||
|
firstEventForZEFinder = diff > 0 ? diff : 0;
|
||||||
|
}
|
||||||
|
if (inputLine.contains("<title>Event #")) {
|
||||||
|
title = inputLine;
|
||||||
|
}
|
||||||
|
if (inputLine.contains("Prize :")) {
|
||||||
|
break;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
str = content.toString();
|
str = content.toString();
|
||||||
if (str.contains("Server :") && str.contains("Maps :") && str.contains("Prize :")) {
|
str = str.substring(firstEventForZEFinder);
|
||||||
ConcurrentMap<Integer, String> eventContentMap = new MapMaker().concurrencyLevel(2).makeMap();
|
//System.out.println("str pre thread check: " + str);
|
||||||
String html2text = html2text(str);
|
ConcurrentMap<Integer, String> eventContentMap = new MapMaker().concurrencyLevel(2).makeMap();
|
||||||
System.out.println(html2text);
|
String html2text = html2text(str);
|
||||||
String title = html2text.substring(0, html2text.indexOf("| UNLOZE"));
|
//System.out.println("html2text: " + html2text);
|
||||||
eventContentMap.put(eventContentMap.size(), title);
|
title = html2text(title);
|
||||||
String rewards = html2text.substring(html2text.indexOf("Prize :") + 7, html2text.lastIndexOf("won"));
|
title = title.substring(0, title.length() - 8);
|
||||||
rewards = rewards + "won";
|
// System.out.println("title: " + title);
|
||||||
eventContentMap.put(eventContentMap.size(), rewards);
|
eventContentMap.put(eventContentMap.size(), title);
|
||||||
String leaders = html2text.substring(html2text.indexOf("Leader :") + 7, html2text.indexOf("Prize :"));
|
String rewards = html2text.substring(html2text.indexOf("Prize :") + 7);
|
||||||
eventContentMap.put(eventContentMap.size(), leaders);
|
// System.out.println("rewards: " + rewards);
|
||||||
String date = html2text.substring(html2text.indexOf("Date :") + 6, html2text.indexOf("Time :"));
|
eventContentMap.put(eventContentMap.size(), rewards);
|
||||||
eventContentMap.put(eventContentMap.size(), date);
|
String leaders = html2text.substring(html2text.indexOf("Leader :") + 7, html2text.indexOf("Prize :"));
|
||||||
String Time = html2text.substring(html2text.indexOf("Time :") + 6, html2text.indexOf("Leader :"));
|
eventContentMap.put(eventContentMap.size(), leaders);
|
||||||
eventContentMap.put(eventContentMap.size(), Time);
|
String date = html2text.substring(html2text.indexOf("Date :") + 6, html2text.indexOf("Time :"));
|
||||||
String maps = html2text.substring(html2text.indexOf("Maps : -") + 6, html2text.indexOf("Date :"));
|
eventContentMap.put(eventContentMap.size(), date);
|
||||||
|
String Time = html2text.substring(html2text.indexOf("Time :") + 6, html2text.indexOf("Leader :"));
|
||||||
|
eventContentMap.put(eventContentMap.size(), Time);
|
||||||
|
String maps = html2text.substring(html2text.indexOf("Maps : -") + 6, html2text.indexOf("Date :"));
|
||||||
|
if (maps.contains("CS:S Zombie Escape Server IP")){
|
||||||
|
maps = maps.substring(maps.indexOf("Map :") + 5);
|
||||||
|
}
|
||||||
|
maps = maps.trim();
|
||||||
|
System.out.println("maps: " + maps);
|
||||||
|
if (!maps.contains("-")) {
|
||||||
|
eventContentMap.put(eventContentMap.size(), maps);
|
||||||
|
} else {
|
||||||
String[] split = maps.split("-");
|
String[] split = maps.split("-");
|
||||||
for (String strsplit : split) {
|
for (String strsplit : split) {
|
||||||
eventContentMap.put(eventContentMap.size(), strsplit);
|
eventContentMap.put(eventContentMap.size(), strsplit);
|
||||||
}
|
}
|
||||||
DataMapper.instance.insertIntoDBEventContent(eventContentMap);
|
|
||||||
}
|
}
|
||||||
|
//System.out.println("pre insertIntoDBEventContent");
|
||||||
|
DataMapper.instance.insertIntoDBEventContent(eventContentMap);
|
||||||
con.disconnect();
|
con.disconnect();
|
||||||
in.close();
|
in.close();
|
||||||
} catch (MalformedURLException | ProtocolException ex) {
|
} catch (MalformedURLException | ProtocolException ex) {
|
||||||
|
@ -172,7 +172,7 @@ public Action OnPlayerRunCmd(int client, int &buttons, int &impulse, float vel[3
|
|||||||
g_iClientFrames[client] = 0;
|
g_iClientFrames[client] = 0;
|
||||||
float clientVectors[3];
|
float clientVectors[3];
|
||||||
GetClientAbsOrigin(client, clientVectors);
|
GetClientAbsOrigin(client, clientVectors);
|
||||||
if (checkClientOrigin(g_fClientVectors[client], clientVectors, client, vel))
|
if (checkClientOrigin(g_fClientVectors[client], clientVectors, client))
|
||||||
{
|
{
|
||||||
g_bHumansAllowedTime[client] = false;
|
g_bHumansAllowedTime[client] = false;
|
||||||
resetClientVectors(client);
|
resetClientVectors(client);
|
||||||
@ -204,7 +204,7 @@ public Action OnPlayerRunCmd(int client, int &buttons, int &impulse, float vel[3
|
|||||||
float gravityFloat = gravity.FloatValue;
|
float gravityFloat = gravity.FloatValue;
|
||||||
int minimalPermitedGravity = 610;
|
int minimalPermitedGravity = 610;
|
||||||
//PrintToChat(client, "client_gravity: %f\ngravityFloat: %f", client_gravity, gravityFloat);
|
//PrintToChat(client, "client_gravity: %f\ngravityFloat: %f", client_gravity, gravityFloat);
|
||||||
if ((client_gravity > 1.3 || client_gravity < 0.8000) || gravityFloat < minimalPermitedGravity)
|
if (((client_gravity > 1.3 || client_gravity < 0.8000) && client_gravity != 0.000000) || gravityFloat < minimalPermitedGravity)
|
||||||
{
|
{
|
||||||
g_bHumansAllowedTime[client] = false;
|
g_bHumansAllowedTime[client] = false;
|
||||||
resetClientVectors(client);
|
resetClientVectors(client);
|
||||||
@ -219,7 +219,7 @@ public Action OnPlayerRunCmd(int client, int &buttons, int &impulse, float vel[3
|
|||||||
SetHudTextParams(0.35, 0.85, 0.1, 125, 255, 255, 85);
|
SetHudTextParams(0.35, 0.85, 0.1, 125, 255, 255, 85);
|
||||||
int l_iCalculateMins = CalculateValuesMinutes(client);
|
int l_iCalculateMins = CalculateValuesMinutes(client);
|
||||||
float l_fCalculateSecs = CalculateValues(client);
|
float l_fCalculateSecs = CalculateValues(client);
|
||||||
ShowSyncHudText(client, hText, "%N Time: 0%i:%.1f\nRecord: 0%i:%.1f\nMap: %s\nStage: %i", client, l_iCalculateMins,
|
ShowSyncHudText(client, hText, "%N Time: 0%i:%.1f\nRecord: 0%i:%.1f\nMap: %s\nCourse: %i", client, l_iCalculateMins,
|
||||||
l_fCalculateSecs, g_iRecordMinutes[client][g_iClientStage[client]], g_fRecordSeconds[client][g_iClientStage[client]],
|
l_fCalculateSecs, g_iRecordMinutes[client][g_iClientStage[client]], g_fRecordSeconds[client][g_iClientStage[client]],
|
||||||
g_cMapname, g_iClientStage[client]);
|
g_cMapname, g_iClientStage[client]);
|
||||||
}
|
}
|
||||||
@ -242,25 +242,27 @@ public void resetClientVectors(int client)
|
|||||||
//----------------------------------------------------------------------------------------------------
|
//----------------------------------------------------------------------------------------------------
|
||||||
// Purpose:
|
// Purpose:
|
||||||
//----------------------------------------------------------------------------------------------------
|
//----------------------------------------------------------------------------------------------------
|
||||||
public bool checkClientOrigin(float oldVals[3], float newVals[3], int client, float vel[3])
|
public bool checkClientOrigin(float oldVals[3], float newVals[3], int client)
|
||||||
{
|
{
|
||||||
float zero = 0.000000;
|
float zero = 0.000000;
|
||||||
int velocityCap = 600;
|
|
||||||
if ((oldVals[0] == zero && oldVals[1] == zero && oldVals[2] == zero) || (newVals[0] == zero && newVals[1] == zero && newVals[2] == zero))
|
if ((oldVals[0] == zero && oldVals[1] == zero && oldVals[2] == zero) || (newVals[0] == zero && newVals[1] == zero && newVals[2] == zero))
|
||||||
{
|
{
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
float teleport_range = 50000.0;
|
float teleport_range = 50000.0;
|
||||||
|
int velocityCap = 525;
|
||||||
float distance = GetVectorDistance(oldVals, newVals, true);
|
float distance = GetVectorDistance(oldVals, newVals, true);
|
||||||
//PrintToChatAll("distance: %f", distance);
|
//PrintToChatAll("distance: %f", distance);
|
||||||
bool bInAir = (GetEntPropEnt(client, Prop_Send, "m_hGroundEntity") == -1);
|
bool bInAir = (GetEntPropEnt(client, Prop_Send, "m_hGroundEntity") == -1);
|
||||||
if (distance > teleport_range)
|
if (distance > teleport_range)
|
||||||
{
|
{
|
||||||
//PrintToChat(client, "distance: %f", distance);
|
|
||||||
//PrintToChat(client, "vel[0] %f \nvel[1] %f \nvel[2] %f", vel[0], vel[1], vel[2]);
|
|
||||||
if (StrContains(g_cMapname, "surf", false) != -1)
|
if (StrContains(g_cMapname, "surf", false) != -1)
|
||||||
return false;
|
return false;
|
||||||
if ((vel[0] > velocityCap || vel[1] > velocityCap || vel[2] > velocityCap) && bInAir)
|
float fVelocity[3];
|
||||||
|
GetEntPropVector(client, Prop_Data, "m_vecVelocity", fVelocity);
|
||||||
|
float currentspeed = SquareRoot(Pow(fVelocity[0],2.0)+Pow(fVelocity[1],2.0));
|
||||||
|
//PrintToChat(client, "currentspeed: %f", currentspeed);
|
||||||
|
if (bInAir && currentspeed > velocityCap)
|
||||||
return false;
|
return false;
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
@ -300,7 +302,7 @@ public void unloze_zoneLeave(int client, char[] zone)
|
|||||||
float notRounded = float(RetrieveZoneIndex(zone));
|
float notRounded = float(RetrieveZoneIndex(zone));
|
||||||
g_iClientStage[client] = RoundToCeil(notRounded / 2);
|
g_iClientStage[client] = RoundToCeil(notRounded / 2);
|
||||||
g_bHumansAllowedTime[client] = true;
|
g_bHumansAllowedTime[client] = true;
|
||||||
CPrintToChat(client, "Timer started for stage: %i", g_iClientStage[client]);
|
CPrintToChat(client, "Timer started for Course: %i", g_iClientStage[client]);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
//----------------------------------------------------------------------------------------------------
|
//----------------------------------------------------------------------------------------------------
|
||||||
|
Loading…
Reference in New Issue
Block a user