Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 7 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -95,3 +95,10 @@ modules.xml
.idea/sonarlint

# End of https://www.toptal.com/developers/gitignore/api/intellij+all
target/*
cache.txt
clone.log
data.txt
Sonitor.jar
.vscode/launch.json
.vscode/tasks.json
24 changes: 17 additions & 7 deletions src/main/java/xyz/msws/admintools/Monitor.java
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
import xyz.msws.admintools.parsers.JBParser;
import xyz.msws.admintools.parsers.Parser;
import xyz.msws.admintools.parsers.PlaytimeParser;
import xyz.msws.admintools.parsers.TTTParser;

import java.io.File;
import java.io.FileWriter;
Expand Down Expand Up @@ -33,6 +34,8 @@ public Monitor() {
parsers.add(new PlaytimeParser(this));
if (config.doJailbreak())
parsers.add(new JBParser(this));
if (config.doTTT())
parsers.add(new TTTParser(this));
timer.schedule(this, 0, config.getRate());
}

Expand Down Expand Up @@ -82,13 +85,16 @@ private boolean setupFiles() {
}

// Drive Specific
directories.add(master.getAbsolutePath().charAt(0) + ":\\Program Files (x86)\\Steam\\steamapps\\common\\Counter-Strike Global Offensive\\csgo");
directories.add(master.getAbsolutePath().charAt(0) + ":\\Program Files\\Steam\\steamapps\\common\\Counter-Strike Global Offensive\\csgo");
directories.add(master.getAbsolutePath().charAt(0)
+ ":\\Program Files (x86)\\Steam\\steamapps\\common\\Counter-Strike Global Offensive\\csgo");
directories.add(master.getAbsolutePath().charAt(0)
+ ":\\Program Files\\Steam\\steamapps\\common\\Counter-Strike Global Offensive\\csgo");

// Default Computer
directories.add("C:\\Program Files (x86)\\Steam\\steamapps\\common\\Counter-Strike Global Offensive\\csgo");
directories.add("C:\\Program Files\\Steam\\steamapps\\common\\Counter-Strike Global Offensive\\csgo");
directories.add("C:\\Program Files\\Steam\\steamapps\\common\\Counter-Strike Global Offensive\\csgo\\output.log");
directories
.add("C:\\Program Files\\Steam\\steamapps\\common\\Counter-Strike Global Offensive\\csgo\\output.log");

// Mac
directories.add("~/Library/Application Support/Steam/steamapps/common/Counter-Strike Global Offensive/csgo");
Expand All @@ -97,8 +103,10 @@ private boolean setupFiles() {
directories.add("~/.steam/steam/SteamApps/common/Counter-Strike Global Offensive/csgo");

for (int i = 'A'; i <= 'Z'; i++) {
directories.add((char) i + ":\\Program Files (x86)\\Steam\\steamapps\\common\\Counter-Strike Global Offensive\\csgo");
directories.add((char) i + ":\\Program Files\\Steam\\steamapps\\common\\Counter-Strike Global Offensive\\csgo");
directories.add((char) i
+ ":\\Program Files (x86)\\Steam\\steamapps\\common\\Counter-Strike Global Offensive\\csgo");
directories.add(
(char) i + ":\\Program Files\\Steam\\steamapps\\common\\Counter-Strike Global Offensive\\csgo");
}

File parent = null;
Expand All @@ -112,7 +120,8 @@ private boolean setupFiles() {
}
}
if (!parent.exists()) {
System.out.println("Could not locate CS:GO directory. Please specify the proper directory in the settings.txt");
System.out.println(
"Could not locate CS:GO directory. Please specify the proper directory in the settings.txt");
return false;
}

Expand Down Expand Up @@ -154,7 +163,8 @@ private boolean setupFiles() {
System.out.println("Supplied path is a folder, searching for " + logFile);
output = new File(output, logFile);
if (!output.exists())
output = new File("C:\\Program Files (x86)\\Steam\\steamapps\\common\\Counter-Strike Global Offensive\\csgo\\output.log");
output = new File(
"C:\\Program Files (x86)\\Steam\\steamapps\\common\\Counter-Strike Global Offensive\\csgo\\output.log");
}
if (!output.exists()) {
output = new File(parent, logFile);
Expand Down
88 changes: 88 additions & 0 deletions src/main/java/xyz/msws/admintools/data/Action.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,88 @@
package xyz.msws.admintools.data;

import java.util.ArrayList;
import java.util.List;

import xyz.msws.admintools.data.DataStructs.ActionType;
import xyz.msws.admintools.data.DataStructs.Role;
import xyz.msws.admintools.data.jb.JailRole;

/**
* Represents a line in Jailbreak Logs
* <p>
* Compares by time
*/
public abstract class Action implements Comparable<Action> {
protected ActionType type;
protected String player, target;
protected Role playerRole, targetRole;
protected String[] other;
protected String line;

protected int playerRoleStart = Integer.MAX_VALUE, playerRoleEnd, targetRoleStart = -1, targetRoleEnd = -1;
protected int playerStart, playerEnd;
protected int targetStart, targetEnd;

protected long time;

public Action(String line) {
this.line = line;
}

public String getPlayer() {
return player;
}

public String getTarget() {
return target;
}

public Role getPlayerRole() {
return playerRole;
}

public Role getTargetRole() {
return targetRole;
}

public ActionType getType() {
return type;
}

public String[] getOther() {
return other;
}

public String getLine() {
return line;
}

public String simplify() {
String[] opts;
if (target == null || target.isEmpty()) {
opts = other;
} else {
List<String> s = new ArrayList<>();
s.add(target);
s.addAll(List.of(other));
opts = s.toArray(new String[0]);
}
if (playerRole == JailRole.WORLD)
return player + " " + type.getSummary(opts);

return player + " (" + getPlayerRole().getIcon() + ") " + type.getSummary(opts);
}

public long getTime() {
return time;
}

public String getTimeString() {
return String.format("%02d:%02d", (int) Math.floor((float) time / 60), time % 60);
}

@Override
public int compareTo(Action o) {
return (int) (this.getTime() - o.getTime());
}
}
23 changes: 17 additions & 6 deletions src/main/java/xyz/msws/admintools/data/Config.java
Original file line number Diff line number Diff line change
@@ -1,8 +1,13 @@
package xyz.msws.admintools.data;

import xyz.msws.admintools.utils.Convert;
import java.util.Arrays;
import java.util.HashSet;
import java.util.Set;

import java.util.EnumSet;
import xyz.msws.admintools.data.DataStructs.ActionType;
import xyz.msws.admintools.data.DataStructs.GenericActionType;
import xyz.msws.admintools.data.jb.JailActionType;
import xyz.msws.admintools.utils.Convert;

/**
* Represents the configurable values that the user can specify
Expand All @@ -14,10 +19,12 @@ public abstract class Config {
protected String header = "";
protected String outputPath = null, apiKey = null, clonePath = null;
protected String webId = "";
protected EnumSet<JailActionType> actions = EnumSet.of(JailActionType.KILL, JailActionType.WARDEN, JailActionType.WARDEN_DEATH, JailActionType.FIRE, JailActionType.PASS, JailActionType.RESKIN);
protected Set<ActionType> actions = new HashSet<>(Arrays.asList(GenericActionType.KILL, JailActionType.WARDEN,
JailActionType.WARDEN_DEATH, JailActionType.FIRE, JailActionType.PASS, JailActionType.RESKIN));
protected int gunTimeout = 10, buttonTimeout = 5, nadeTimeout = 10, wardenTimeout = 5, freeTime = 10;
protected boolean showEarlyVents = true, showEarlyKills = true, showGameButtons = true, showNades = true, showGunPlants = true;
protected boolean doJailbreak = true, doPlaytime = true;
protected boolean showEarlyVents = true, showEarlyKills = true, showGameButtons = true, showNades = true,
showGunPlants = true;
protected boolean doJailbreak = true, doPlaytime = true, doTTT = true;
protected boolean cacheGametimes = true, requestGametimes = true;
protected int appId = 730;
protected Convert.TimeUnit limitPlaytime = Convert.TimeUnit.YEARS;
Expand All @@ -38,6 +45,10 @@ public boolean doJailbreak() {
return doJailbreak;
}

public boolean doTTT() {
return doJailbreak;
}

public boolean doPlaytime() {
return doPlaytime;
}
Expand All @@ -54,7 +65,7 @@ public int getAppId() {
return appId;
}

public EnumSet<JailActionType> getActions() {
public Set<ActionType> getActions() {
return actions;
}

Expand Down
35 changes: 35 additions & 0 deletions src/main/java/xyz/msws/admintools/data/DataStructs.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
package xyz.msws.admintools.data;

public class DataStructs {
public static interface ActionType {
String getSummary(String... opts);
}

public static enum GenericActionType implements ActionType {
DAMAGE("damaged %s (%s) for %s"), KILL("killed %s (%s)"), NADE("threw a(n) %s"), GHOST_RESPAWN("respawned as ghost");

String sum;

GenericActionType(String summary) {
this.sum = summary;
}

@Override
public String getSummary(String... opts) {
return String.format(sum, (Object[]) opts);
}

}

public static interface Role {
String getIcon();

boolean isCT();

boolean isT();

default boolean isAlive() {
return isCT() || isT();
}
}
}
28 changes: 26 additions & 2 deletions src/main/java/xyz/msws/admintools/data/FileConfig.java
Original file line number Diff line number Diff line change
@@ -1,5 +1,9 @@
package xyz.msws.admintools.data;

import xyz.msws.admintools.data.DataStructs.ActionType;
import xyz.msws.admintools.data.DataStructs.GenericActionType;
import xyz.msws.admintools.data.jb.JailActionType;
import xyz.msws.admintools.data.ttt.TTTActionType;
import xyz.msws.admintools.utils.Convert;
import xyz.msws.admintools.utils.Utils;

Expand Down Expand Up @@ -52,8 +56,26 @@ public FileConfig(File file) {
} else if (line.startsWith("showTypes=")) {
String[] acts = getValue(line, "showTypes=").split(",");
actions.clear();
for (String s : acts)
actions.add(JailActionType.valueOf(s.toUpperCase()));
for (String s : acts) {
ActionType type = null;
try {
type = GenericActionType.valueOf(s.toUpperCase());
} catch (IllegalArgumentException e1) {
try {
type = JailActionType.valueOf(s.toUpperCase());
} catch (IllegalArgumentException e2) {
try {
type = TTTActionType.valueOf(s.toUpperCase());
} catch (IllegalArgumentException e3) {
}
}
}
if (type == null) {
System.out.println("Invalid action type: " + s);
continue;
}
actions.add(type);
}
} else if (line.startsWith("gundropTimeout=")) {
gunTimeout = getValue(line, "gundropTimeout=", Integer.class);
} else if (line.startsWith("nadeTimeout=")) {
Expand All @@ -76,6 +98,8 @@ public FileConfig(File file) {
freeTime = getValue(line, "freeTime=", Integer.class);
} else if (line.startsWith("doJailbreak=")) {
doJailbreak = getValue(line, "doJailbreak=", Boolean.class);
} else if (line.startsWith("doTTT=")) {
doTTT = getValue(line, "doTTT=", Boolean.class);
} else if (line.startsWith("cacheGametimes=")) {
cacheGametimes = getValue(line, "cacheGametimes=", Boolean.class);
} else if (line.startsWith("requestGametimes=")) {
Expand Down
20 changes: 0 additions & 20 deletions src/main/java/xyz/msws/admintools/data/JailActionType.java

This file was deleted.

Loading