-
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.
fixed crash, no cheat anymore, added gommehd rule
- Loading branch information
Showing
4 changed files
with
116 additions
and
7 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
72 changes: 72 additions & 0 deletions
72
src/main/java/de/raik/tnttimer/restrictions/GommeHDBedWarsRestriction.java
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,72 @@ | ||
package de.raik.tnttimer.restrictions; | ||
|
||
import de.raik.tnttimer.TNTTimerAddon; | ||
import net.labymod.api.events.TabListEvent; | ||
import net.labymod.utils.Consumer; | ||
import net.labymod.utils.ServerData; | ||
|
||
/** | ||
* Restriction for being allowd on GommeHD | ||
* because TNT timers are forbidden in BedWars | ||
* | ||
* @author Raik | ||
* @version 1.0 | ||
*/ | ||
public class GommeHDBedWarsRestriction implements Restriction, TabListEvent, Consumer<ServerData> { | ||
|
||
/** | ||
* Indicator whether the user is playing bed wars or not | ||
*/ | ||
private boolean isBedWars = false; | ||
|
||
/** | ||
* Constructor to register events | ||
* | ||
* @param addon The addon instance | ||
*/ | ||
public GommeHDBedWarsRestriction(TNTTimerAddon addon) { | ||
addon.api.getEventManager().register(this); | ||
addon.api.getEventManager().registerOnQuit(this); | ||
} | ||
|
||
/** | ||
* Method to indicate whether it's restricted | ||
* or not | ||
* | ||
* @return The state of the restriction | ||
*/ | ||
@Override | ||
public boolean isRestricted() { | ||
return this.isBedWars; | ||
} | ||
|
||
/** | ||
* Event method called when the tablist gets updated to check gomme hd | ||
* and bedwars | ||
* | ||
* @param type The type whether is'ts the header or footer | ||
* @param formattedText The formatted text | ||
* @param unformattedText The unformatted text | ||
*/ | ||
@Override | ||
public void onUpdate(Type type, String formattedText, String unformattedText) { | ||
//Check type | ||
if (!type.equals(Type.HEADER)) { | ||
return; | ||
} | ||
|
||
unformattedText = unformattedText.toLowerCase(); | ||
this.isBedWars = unformattedText.contains("gommehd.net") | ||
&& unformattedText.contains("bedwars"); | ||
} | ||
|
||
/** | ||
* Method call to reset on server quit | ||
* | ||
* @param serverData The server data | ||
*/ | ||
@Override | ||
public void accept(ServerData serverData) { | ||
this.isBedWars = false; | ||
} | ||
} |
20 changes: 20 additions & 0 deletions
20
src/main/java/de/raik/tnttimer/restrictions/Restriction.java
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,20 @@ | ||
package de.raik.tnttimer.restrictions; | ||
|
||
/** | ||
* Interface indicating a restriction | ||
* of the use of the addon | ||
* | ||
* @author Raik | ||
* @version 1.0 | ||
*/ | ||
public interface Restriction { | ||
|
||
/** | ||
* Method to indicate whether it's restricted | ||
* or not | ||
* | ||
* @return The state of the restriction | ||
*/ | ||
boolean isRestricted(); | ||
|
||
} |