-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #2 from MSWS/1.2.2-dev
1.2.2 dev
- Loading branch information
Showing
16 changed files
with
702 additions
and
118 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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()); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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(); | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
20 changes: 0 additions & 20 deletions
20
src/main/java/xyz/msws/admintools/data/JailActionType.java
This file was deleted.
Oops, something went wrong.
Oops, something went wrong.