Skip to content

Commit

Permalink
- Cleaned project and reduced boilerplate code
Browse files Browse the repository at this point in the history
- Added visual hopper connections
- Added Hopper connection mode widget
- Added mod counter to "nearby" widget
- Fixed a bug. /fahndung now works correctly
  • Loading branch information
tmbRandy committed Oct 6, 2024
1 parent f008a8a commit 36fac05
Show file tree
Hide file tree
Showing 83 changed files with 2,372 additions and 1,829 deletions.
11 changes: 10 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -35,9 +35,15 @@ Die Plotgrenzen auf den beiden Natur-CBs können mit Linien grafisch dargestellt
### Automatische Trichtereinstellung
Wenn du eine Vielzahl an Trichtern einstellen musst, kannst du die gewünschten Einstellungen festlegen. Sobald du dann ein Trichtermenü öffnest, werden je nach Einstellung Filteritem, Einsaugradius, Stackgröße und Schlussaktion, wie die Verbindung mit einem anderen Trichter automatisch vorgenommen. Du kannst außerdem festlegen, dass du bei Rechtsklick auf einen Trichter automatisch sneakst.

### Optische Hilfe für Trichterverbindungen
Du kannst die Verbindungen von Trichtern mit Linien darstellen lassen. Direktverbindungen erscheinen blau, Multiverbindungen rot. Bei Multiverbindungen siehst du außerdem, welches Item wohin geleitet wird. Du siehst die Verbindungslinien, nachdem du eine Verbindung gesetzt hast, oder wenn du das entsprechende Trichtermenü öffnest. Beachte, dass die Linien nicht persistent gespeichert werden. Die Verbindungsgrenze von 30 Blöcken kannst du während des Verbindungsmodus außerdem durch eine rote Sphere darstellen lassen. So weißt du immer, wie weit du verbinden kannst.

### Lobby automatisch überspringen
Wenn du willst, kannst du direkt im Portalraum spawnen.

### Auto Loot
Deine /freekiste und /grieferboost kann das Addon automatisch für dich abholen. Es merkt sich, wenn diese abgeholt wurden und führt die Befehle automatisch aus, sobald die Cooldowns abgelaufen sind. Außerdem erinnert es dich, sobald du wieder /kopf nutzen kannst.

### Automatische Annahme von /tpa und /tpahere
Wenn du mehrere Accounts besitzt, kannst du dir von einem Account zum anderen eine /tpa oder /tpahere senden und diese wird sofort angenommen. Du musst dafür nur in LabyMod deine Accounts registrieren, was du normalerweise ohnehin schon getan hast.

Expand Down Expand Up @@ -75,7 +81,10 @@ Wenn dich die große Anzeigetafel rechts stört, kannst du diese nun ausblenden.
Wenn du wisst, kannst du dir nach Einnahme eines Flugtranks einen 15 Minuten Countdown einblenden lassen, sodass du immer siehst, wann dein Flugeffekt ausläuft.

### Widget In der Nähe
Dieses Widget zeigt dir eine Liste von Spielern in deiner unmittelbaren Umgebung an.
Dieses Widget zeigt dir eine Liste von Spielern in deiner unmittelbaren Umgebung an. Auch Mobs werden angezeigt und zählt diese sogar zusammen - selbst wenn sie gestackt sind.

### Widget Verbindungsmodus
Beim Verbinden von Trichtern kann der Chat durch die Benachrichtigungen zum Verbindungsmodus des Trichters schnell unübersichtlich werden. Ziehe einfach das Widget "Verbindungsmodus" in deine GUI. Dadurch werden die Trichternachrichten unterdrückt und du siehst stattdessen per Symbol, ob du im Verbindungsmodus oder im Multi-Verbindungsmodus bist.

### Chatfunktionen

Expand Down
16 changes: 4 additions & 12 deletions api/build.gradle.kts
Original file line number Diff line number Diff line change
@@ -1,18 +1,10 @@
version = "0.1.0"

plugins {
id("java-library")
}
import net.labymod.labygradle.common.extension.LabyModAnnotationProcessorExtension.ReferenceType

dependencies {
labyProcessor()
labyApi("api")
}

labyModProcessor {
referenceType = net.labymod.gradle.core.processor.ReferenceType.INTERFACE
}

java {
sourceCompatibility = JavaVersion.VERSION_21
targetCompatibility = JavaVersion.VERSION_21
labyModAnnotationProcessor {
referenceType = ReferenceType.INTERFACE
}
94 changes: 22 additions & 72 deletions build.gradle.kts
Original file line number Diff line number Diff line change
@@ -1,91 +1,41 @@
plugins {
id("java-library")
id("net.labymod.gradle")
id("net.labymod.gradle.addon")
id("net.labymod.labygradle")
id("net.labymod.labygradle.addon")
}

group = "tmb.randy"
version = "1.5.3"

java.toolchain.languageVersion.set(JavaLanguageVersion.of(17))
val versions = providers.gradleProperty("net.labymod.minecraft-versions").get().split(";")

tasks.withType<JavaCompile> {
options.encoding = "UTF-8"
}
group = "tmb.randy"
version = providers.environmentVariable("VERSION").getOrElse("1.6.0")

labyMod {
defaultPackageName = "tmb.randy.tmbgriefergames"
addonInfo {
namespace = "tmbgriefergames"
displayName = "GrieferGames Addon by TMB"
author = "TMB Clan"
description = "Eine Sammlung nützlicher Erweiterungen für das GrieferGames Netzwerk."
minecraftVersion = "1.8.9,1.12.2"
version = System.getenv().getOrDefault("VERSION", "1.1")
}

minecraft {
registerVersions(
"1.8.9",
"1.12.2"
) { version, provider ->
configureRun(provider, version)
}

subprojects.forEach {
if (it.name != "game-runner") {
filter(it.name)
registerVersion(versions.toTypedArray()) {
runs {
getByName("client") {
// When the property is set to true, you can log in with a Minecraft account
// devLogin = true
}
}
}
}

addonDev {
productionRelease()
addonInfo {
namespace = "tmbgriefergames"
displayName = "GrieferGames Addon by TMB"
author = "TMB Clan"
description = "Eine Sammlung nützlicher Erweiterungen für das GrieferGames Netzwerk."
minecraftVersion = "1.8.9,1.12.2"
version = rootProject.version.toString()
}
}

subprojects {
plugins.apply("java-library")
plugins.apply("net.labymod.gradle")
plugins.apply("net.labymod.gradle.addon")

repositories {
maven("https://libraries.minecraft.net/")
maven("https://repo.spongepowered.org/repository/maven-public/")
mavenLocal()
}
}
plugins.apply("net.labymod.labygradle")
plugins.apply("net.labymod.labygradle.addon")

fun configureRun(provider: net.labymod.gradle.core.minecraft.provider.VersionProvider, gameVersion: String) {
provider.runConfiguration {
mainClass = "net.minecraft.launchwrapper.Launch"
jvmArgs("-Dnet.labymod.running-version=${gameVersion}")
jvmArgs("-Dmixin.debug=true")
jvmArgs("-Dnet.labymod.debugging.all=true")
jvmArgs("-Dmixin.env.disableRefMap=true")

args("--tweakClass", "net.labymod.core.loader.vanilla.launchwrapper.LabyModLaunchWrapperTweaker")
args("--labymod-dev-environment", "true")
args("--addon-dev-environment", "true")
}

provider.javaVersion = when (gameVersion) {
else -> {
JavaVersion.VERSION_21
}
}

provider.mixin {
val mixinMinVersion = when (gameVersion) {
"1.8.9", "1.12.2", "1.16.5" -> {
"0.6.6"
}

else -> {
"0.8.2"
}
}

minVersion = mixinMinVersion
}
group = rootProject.group
version = rootProject.version
}
33 changes: 6 additions & 27 deletions core/build.gradle.kts
Original file line number Diff line number Diff line change
@@ -1,34 +1,13 @@
version = "0.1.0"

plugins {
id("java-library")
}

tasks.withType<JavaCompile> {
options.encoding = "UTF-8"
}

repositories {
mavenCentral()
}
import net.labymod.labygradle.common.extension.LabyModAnnotationProcessorExtension.ReferenceType

dependencies {
labyProcessor()
api(project(":api"))

// If you want to use external libraries, you can do that here.
// The dependencies that are specified here are loaded into your project but will also
// automatically be downloaded by labymod, but only if the repository is public.
// If it is private, you have to add and compile the dependency manually.
// You have to specify the repository, there are getters for maven central and sonatype, every
// other repository has to be specified with their url. Example:
// maven(mavenCentral(), "org.apache.httpcomponents:httpclient:4.5.13")
}

labyModProcessor {
referenceType = net.labymod.gradle.core.processor.ReferenceType.DEFAULT
// An example of how to add an external dependency that is used by the addon.
// addonMavenDependency("org.jeasy:easy-random:5.0.0")
}

java {
sourceCompatibility = JavaVersion.VERSION_21
targetCompatibility = JavaVersion.VERSION_21
labyModAnnotationProcessor {
referenceType = ReferenceType.DEFAULT
}
66 changes: 61 additions & 5 deletions core/src/main/java/tmb/randy/tmbgriefergames/core/Addon.java
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

import net.labymod.api.Laby;
import net.labymod.api.addon.LabyAddon;
import net.labymod.api.client.gui.hud.binding.category.HudWidgetCategory;
import net.labymod.api.client.gui.screen.activity.types.IngameOverlayActivity;
import net.labymod.api.models.addon.annotation.AddonMain;
import tmb.randy.tmbgriefergames.core.commands.AutocraftV2Command;
Expand All @@ -12,8 +13,23 @@
import tmb.randy.tmbgriefergames.core.commands.PlayerTracerCommand;
import tmb.randy.tmbgriefergames.core.config.Configuration;
import tmb.randy.tmbgriefergames.core.generated.DefaultReferenceStorage;
import tmb.randy.tmbgriefergames.core.util.AccountUnity;
import tmb.randy.tmbgriefergames.core.util.HopperTracker;
import tmb.randy.tmbgriefergames.core.util.ItemClearTimerListener;
import tmb.randy.tmbgriefergames.core.util.ItemSaver;
import tmb.randy.tmbgriefergames.core.util.PlayerTracer;
import tmb.randy.tmbgriefergames.core.util.PlotSwitch;
import tmb.randy.tmbgriefergames.core.util.chat.ChatCleaner;
import tmb.randy.tmbgriefergames.core.util.chat.CooldownNotifier;
import tmb.randy.tmbgriefergames.core.util.chat.EmptyLinesRemover;
import tmb.randy.tmbgriefergames.core.util.chat.MsgTabs;
import tmb.randy.tmbgriefergames.core.util.chat.NewsBlocker;
import tmb.randy.tmbgriefergames.core.util.chat.PaymentValidator;
import tmb.randy.tmbgriefergames.core.util.chat.StreamerMute;
import tmb.randy.tmbgriefergames.core.util.chat.TypeCorrection;
import tmb.randy.tmbgriefergames.core.widgets.FlyTimerWidget;
import tmb.randy.tmbgriefergames.core.widgets.GameInfoWidget;
import tmb.randy.tmbgriefergames.core.widgets.HopperModeWidget;
import tmb.randy.tmbgriefergames.core.widgets.ItemClearWidget;
import tmb.randy.tmbgriefergames.core.widgets.NearbyWidget;
import java.util.Objects;
Expand All @@ -23,7 +39,24 @@ public class Addon extends LabyAddon<Configuration> {

private IBridge bridge;
private static Addon SharedInstance;
private GameInfoWidget gameInfoWidget;
private GameInfoWidget gameInfoWidget;
private final CBtracker CBtracker = new CBtracker();
private final PlayerTracer playerTracer = new PlayerTracer();
private final HopperTracker hopperTracker = new HopperTracker();
private final PlotSwitch plotSwitch = new PlotSwitch();

private final ChatCleaner chatCleaner = new ChatCleaner();
private final CooldownNotifier cooldownNotifier = new CooldownNotifier();
private final EmptyLinesRemover emptyLinesRemover = new EmptyLinesRemover();
private final MsgTabs msgTabs = new MsgTabs();
private final NewsBlocker newsBlocker = new NewsBlocker();
private final PaymentValidator paymentValidator = new PaymentValidator();
private final StreamerMute streamerMute = new StreamerMute();
private final TypeCorrection typeCorrection = new TypeCorrection();
private final ItemSaver itemSaver = new ItemSaver();
private final AccountUnity accountUnity = new AccountUnity();
private final ItemClearTimerListener itemClearTimerListener = new ItemClearTimerListener();

private final String ADDON_PREFIX = "§6[§5§l§oT§b§l§oM§5§l§oB§6] ";

@Override
Expand All @@ -32,6 +65,21 @@ protected void enable() {
SharedInstance = this;
bridge = getReferenceStorage().iBridge();
this.registerListener(bridge);
this.registerListener(CBtracker);
this.registerListener(playerTracer);
this.registerListener(chatCleaner);
this.registerListener(cooldownNotifier);
this.registerListener(emptyLinesRemover);
this.registerListener(msgTabs);
this.registerListener(newsBlocker);
this.registerListener(paymentValidator);
this.registerListener(streamerMute);
this.registerListener(typeCorrection);
this.registerListener(hopperTracker);
this.registerListener(plotSwitch);
this.registerListener(itemSaver);
this.registerListener(accountUnity);
this.registerListener(itemClearTimerListener);

this.registerCommand(new DKsCommand());
this.registerCommand(new PayAllCommand());
Expand All @@ -40,12 +88,16 @@ protected void enable() {
this.registerCommand(new AutocraftV3Command());
this.registerCommand(new EjectCommand());

gameInfoWidget = new GameInfoWidget();
HudWidgetCategory category = new HudWidgetCategory("tmbgriefergames");
labyAPI().hudWidgetRegistry().categoryRegistry().register(category);

gameInfoWidget = new GameInfoWidget(category);

labyAPI().hudWidgetRegistry().register(new FlyTimerWidget());
labyAPI().hudWidgetRegistry().register(new ItemClearWidget());
labyAPI().hudWidgetRegistry().register(new FlyTimerWidget(category));
labyAPI().hudWidgetRegistry().register(new ItemClearWidget(category));
labyAPI().hudWidgetRegistry().register(gameInfoWidget);
labyAPI().hudWidgetRegistry().register(new NearbyWidget());
labyAPI().hudWidgetRegistry().register(new NearbyWidget(category));
labyAPI().hudWidgetRegistry().register(new HopperModeWidget(category));

this.logger().info("Enabled the Addon");
}
Expand Down Expand Up @@ -91,4 +143,8 @@ public static boolean isChatGuiOpen() {

return false;
}

public PlayerTracer getPlayerTracer() {return playerTracer;}


}
57 changes: 57 additions & 0 deletions core/src/main/java/tmb/randy/tmbgriefergames/core/CBtracker.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,57 @@
package tmb.randy.tmbgriefergames.core;

import net.labymod.api.Laby;
import net.labymod.api.client.component.TextComponent;
import net.labymod.api.client.scoreboard.Scoreboard;
import net.labymod.api.client.scoreboard.ScoreboardTeam;
import net.labymod.api.event.Subscribe;
import net.labymod.api.event.client.scoreboard.ScoreboardTeamUpdateEvent;
import tmb.randy.tmbgriefergames.core.enums.CBs;
import tmb.randy.tmbgriefergames.core.events.CbChangedEvent;
import javax.inject.Singleton;

@Singleton
public class CBtracker {
private static CBs currentCB = CBs.NONE;

@Subscribe
public void worldEnterEvent(ScoreboardTeamUpdateEvent event) {
if(!Addon.isGG()) return;
Scoreboard scoreboard = Laby.labyAPI().minecraft().getScoreboard();
for (ScoreboardTeam team : scoreboard.getTeams()) {
if(team.getTeamName().equals("server_value")) {
String CBString = ((TextComponent)team.getPrefix()).getText();

CBs newCB = CBs.NONE;

try {
newCB = CBs.valueOf(CBString.toUpperCase());
} catch (IllegalArgumentException e) {
Addon.getSharedInstance().logger().warn(e.getMessage());
}

if(newCB != currentCB) {
currentCB = newCB;
Addon.getSharedInstance().logger().info("Joined CityBuild " + newCB.getName());
Laby.fireEvent(new CbChangedEvent(newCB));
}
}
}

}

public static CBs getCurrentCB() {return currentCB;}
public static boolean isNatureWorldCB() {return currentCB == CBs.NATURE || currentCB == CBs.EXTREME;}
public static boolean isPlotworldCB() {
return switch (currentCB) {
case WASSER, LAVA, PORTAL, LOBBY, NONE -> false;
default -> true;
};
}
public static boolean canSendPayment() {
return switch (currentCB) {
case PORTAL, LOBBY, NONE -> false;
default -> true;
};
}
}
Loading

0 comments on commit 36fac05

Please sign in to comment.