-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Added basic support for Griefergames Cloud
- Loading branch information
Showing
11 changed files
with
146 additions
and
71 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
6 changes: 6 additions & 0 deletions
6
core/src/main/java/de/neocraftr/griefergames/enums/SubServerType.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,6 @@ | ||
package de.neocraftr.griefergames.enums; | ||
|
||
public enum SubServerType { | ||
REGULAR, | ||
CLOUD | ||
} |
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
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
41 changes: 41 additions & 0 deletions
41
core/src/main/java/de/neocraftr/griefergames/listener/GGTablistListener.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,41 @@ | ||
package de.neocraftr.griefergames.listener; | ||
|
||
import de.neocraftr.griefergames.GrieferGames; | ||
import de.neocraftr.griefergames.chat.events.GGSubServerChangeEvent; | ||
import de.neocraftr.griefergames.enums.SubServerType; | ||
import net.labymod.api.Laby; | ||
import net.labymod.api.client.component.Component; | ||
import net.labymod.api.client.scoreboard.TabList; | ||
import net.labymod.api.event.Subscribe; | ||
import net.labymod.api.event.client.scoreboard.TabListUpdateEvent; | ||
import java.util.regex.Matcher; | ||
import java.util.regex.Pattern; | ||
|
||
public class GGTablistListener { | ||
private final GrieferGames griefergames; | ||
private final Pattern tabListServerRegex = Pattern.compile("Current Server: (.+) ", Pattern.MULTILINE); | ||
|
||
public GGTablistListener(GrieferGames griefergames) { | ||
this.griefergames = griefergames; | ||
} | ||
|
||
@Subscribe | ||
public void onTablistUpdate(TabListUpdateEvent event) { | ||
TabList tablist = Laby.labyAPI().minecraft().getTabList(); | ||
if(tablist == null) return; | ||
Component header = tablist.header(); | ||
if(header != null) { | ||
String headerText = griefergames.helper().componentToPlainText(header); | ||
Matcher matcher = tabListServerRegex.matcher(headerText); | ||
if(matcher.find()) { | ||
String subServerName = "cloud_"+matcher.group(1).toLowerCase().split("-")[0]; | ||
griefergames.setSubServerType(SubServerType.CLOUD); | ||
if(!griefergames.getSubServer().equals(subServerName)) { | ||
griefergames.setSubServer(subServerName); | ||
GGSubServerChangeEvent changeEvent = new GGSubServerChangeEvent(subServerName); | ||
Laby.labyAPI().eventBus().fire(changeEvent); | ||
} | ||
} | ||
} | ||
} | ||
} |
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