Skip to content

Commit

Permalink
Unnecessary commit due to LabYMod.
Browse files Browse the repository at this point in the history
  • Loading branch information
tmbRandy committed Nov 26, 2023
1 parent 22b2a40 commit 87fadad
Show file tree
Hide file tree
Showing 72 changed files with 4,651 additions and 260 deletions.
16 changes: 5 additions & 11 deletions build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ plugins {
}

group = "tmb.randy"
version = "1.0.1"
version = "1.1"

java.toolchain.languageVersion.set(JavaLanguageVersion.of(17))

Expand All @@ -20,21 +20,14 @@ labyMod {
displayName = "GrieferGames Addon by TMB"
author = "TMB Clan"
description = "Eine Sammlung nützlicher Erweiterungen für das GrieferGames Netzwerk."
minecraftVersion = "*"
version = System.getenv().getOrDefault("VERSION", "1.0.1")
minecraftVersion = "1.8.9,1.12.2"
version = System.getenv().getOrDefault("VERSION", "1.1")
}

minecraft {
registerVersions(
"1.8.9",
"1.12.2",
"1.16.5",
"1.17.1",
"1.18.2",
"1.19.2",
"1.19.3",
"1.19.4",
"1.20.1"
"1.12.2"
) { version, provider ->
configureRun(provider, version)
}
Expand All @@ -59,6 +52,7 @@ subprojects {
repositories {
maven("https://libraries.minecraft.net/")
maven("https://repo.spongepowered.org/repository/maven-public/")
mavenLocal()
}
}

Expand Down
80 changes: 58 additions & 22 deletions core/src/main/java/tmb/randy/tmbgriefergames/core/Addon.java
Original file line number Diff line number Diff line change
Expand Up @@ -2,40 +2,45 @@

import net.labymod.api.Laby;
import net.labymod.api.addon.LabyAddon;
import net.labymod.api.client.gui.screen.activity.types.IngameOverlayActivity;
import net.labymod.api.client.gui.screen.key.Key;
import net.labymod.api.models.addon.annotation.AddonMain;
import tmb.randy.tmbgriefergames.core.commands.DKsCommand;
import tmb.randy.tmbgriefergames.core.commands.PayAllCommand;
import tmb.randy.tmbgriefergames.core.commands.PlayerTracerCommand;
import tmb.randy.tmbgriefergames.core.config.Configuration;
import tmb.randy.tmbgriefergames.core.util.ItemSaver;
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.NewsBlocker;
import tmb.randy.tmbgriefergames.core.util.chat.PaymentValidator;
import tmb.randy.tmbgriefergames.core.util.TooltipExtension;
import tmb.randy.tmbgriefergames.core.util.chat.TypeCorrection;
import tmb.randy.tmbgriefergames.core.generated.DefaultReferenceStorage;
import tmb.randy.tmbgriefergames.core.widgets.FlyTimerWidget;
import tmb.randy.tmbgriefergames.core.widgets.GameInfoWidget;
import tmb.randy.tmbgriefergames.core.widgets.ItemClearWidget;
import tmb.randy.tmbgriefergames.core.widgets.NearbyWidget;
import java.util.Objects;

@AddonMain
public class Addon extends LabyAddon<Configuration> {

private IBridge bridge;
private static Addon SharedInstance;
private GameInfoWidget gameInfoWidget;
private final String ADDON_PREFIX = "§6[§5§l§oT§b§l§oM§5§l§oB§6] ";

@Override
protected void enable() {
this.registerSettingCategory();
SharedInstance = this;
bridge = getReferenceStorage().iBridge();
this.registerListener(bridge);

this.registerListener(new TypeCorrection());
this.registerListener(new TooltipExtension());
this.registerListener(new NewsBlocker());
this.registerListener(new PaymentValidator());
this.registerListener(new ChatCleaner());
this.registerListener(new EmptyLinesRemover());
this.registerListener(new ItemSaver());
this.registerListener(new CooldownNotifier());
this.registerListener(new PlotSwitch());
this.registerCommand(new DKsCommand());
this.registerCommand(new PayAllCommand());
this.registerCommand(new PlayerTracerCommand());

SharedInstance = this;
gameInfoWidget = new GameInfoWidget();

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

this.logger().info("Enabled the Addon");
}
Expand All @@ -49,9 +54,9 @@ public void displayNotification(String msg) {
Laby.labyAPI().minecraft().chatExecutor().displayClientMessage(ADDON_PREFIX + msg);
}

public static Addon getSharedInstance() {
return SharedInstance;
}
public static Addon getSharedInstance() {return SharedInstance;}

public DefaultReferenceStorage getReferenceStorage() {return (this.referenceStorageAccessor()); }

public static boolean isGG() {
if(!Laby.labyAPI().serverController().isConnected()) {
Expand All @@ -60,4 +65,35 @@ public static boolean isGG() {

return Objects.requireNonNull(Laby.labyAPI().serverController().getCurrentServerData()).getName().equals("GrieferGames");
}

public IBridge getBridge() {
return bridge;
}

public GameInfoWidget getGameInfoWidget() {
return gameInfoWidget;
}

public static boolean isChatGuiOpen() {
for (IngameOverlayActivity activity : Laby.labyAPI().ingameOverlay().getActivities()) {
if(activity.isAcceptingInput()) {
return true;
}
}

return false;
}

public static boolean areKeysPressed(Key[] keys) {
if(isChatGuiOpen() || keys.length == 0)
return false;

for (Key key : keys) {
if(!key.isPressed() || key == Key.NONE) {
return false;
}
}

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

import net.labymod.api.reference.annotation.Referenceable;

@Referenceable
public interface IBridge {
public void startPlayerTracer(String name);
public void cbChanged();
public boolean isFlyCountdownActive();
public String getWidgetString();
public String getItemRemoverValue();
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,138 @@
package tmb.randy.tmbgriefergames.core.commands;

import net.labymod.api.client.chat.command.Command;
import tmb.randy.tmbgriefergames.core.Addon;

public class DKsCommand extends Command {

private final String LEVELSTYLE = "§6";
private final String SEPARATORSTYLE = "§7";

public DKsCommand() {
super("dks", "dk");
}
@Override
public boolean execute(String prefix, String[] arguments) {
if(!Addon.isGG())
return false;

int dksLevel7;
int dksLevel6;
int dksLevel5;
int dksLevel4;
int dksLevel3;
int dksLevel2;
int dksLevel1;

if(arguments.length == 1) {
String arg = arguments[0];
int numberOfDKs = Integer.parseInt(arg);

if(numberOfDKs > 99999) {
return true;
}

int itemsPerDK = 64*9*6;
double restItems = numberOfDKs * itemsPerDK;
double itemsForLevel;

//Stufe 7
itemsForLevel = getItemsForLevel(7);
dksLevel7 = (int)(restItems / itemsForLevel);
restItems -= (itemsForLevel * dksLevel7);

//Stufe 6
itemsForLevel = getItemsForLevel(6);
dksLevel6 = (int)(restItems / itemsForLevel);
restItems -= (itemsForLevel * dksLevel6);

//Stufe 5
itemsForLevel = getItemsForLevel(5);
dksLevel5 = (int)(restItems / itemsForLevel);
restItems -= (itemsForLevel * dksLevel5);

//Stufe 4
itemsForLevel = getItemsForLevel(4);
dksLevel4 = (int)(restItems / itemsForLevel);
restItems -= (itemsForLevel * dksLevel4);

//Stufe 3
itemsForLevel = getItemsForLevel(3);
dksLevel3 = (int)(restItems / itemsForLevel);
restItems -= (itemsForLevel * dksLevel3);

//Stufe 2
itemsForLevel = getItemsForLevel(2);
dksLevel2 = (int)(restItems / itemsForLevel);
restItems -= (itemsForLevel * dksLevel2);

//Stufe 1
itemsForLevel = getItemsForLevel(1);
dksLevel1 = (int)(restItems / itemsForLevel);
restItems -= (itemsForLevel * dksLevel1);

StringBuilder builder = new StringBuilder();

if(dksLevel7 > 0) {
builder.append(LEVELSTYLE).append(dksLevel7).append(" * Ⅶ").append(SEPARATORSTYLE);
}

if(dksLevel6 > 0) {
if(!builder.isEmpty()) {
builder.append(" • ");
}
builder.append(LEVELSTYLE).append(dksLevel6).append(" * Ⅵ").append(SEPARATORSTYLE);
}

if(dksLevel5 > 0) {
if(!builder.isEmpty()) {
builder.append(" • ");
}
builder.append(LEVELSTYLE).append(dksLevel5).append(" * Ⅴ").append(SEPARATORSTYLE);
}

if(dksLevel4 > 0) {
if(!builder.isEmpty()) {
builder.append(" • ");
}
builder.append(LEVELSTYLE).append(dksLevel4).append(" * Ⅳ").append(SEPARATORSTYLE);
}

if(dksLevel3 > 0) {
if(!builder.isEmpty()) {
builder.append(" • ");
}
builder.append(LEVELSTYLE).append(dksLevel3).append(" * Ⅲ").append(SEPARATORSTYLE);
}

if(dksLevel2 > 0) {
if(!builder.isEmpty()) {
builder.append(" • ");
}
builder.append(LEVELSTYLE).append(dksLevel2).append(" * Ⅱ").append(SEPARATORSTYLE);
}

if(dksLevel1 > 0) {
if(!builder.isEmpty()) {
builder.append(" • ");
}
builder.append(LEVELSTYLE).append(dksLevel1).append(" * Ⅰ").append(SEPARATORSTYLE);
}

if(restItems > 0) {
if(!builder.isEmpty()) {
builder.append(" • ");
}
builder.append(LEVELSTYLE).append(restItems).append(" Items").append(SEPARATORSTYLE);
}

Addon.getSharedInstance().displayNotification("§e" + numberOfDKs + " DKs" + SEPARATORSTYLE + " = " + builder);
}

return true;
}

private double getItemsForLevel(int level) {
return Math.pow(9, level);
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,60 @@
package tmb.randy.tmbgriefergames.core.commands;

import net.labymod.api.Laby;
import net.labymod.api.client.chat.command.Command;
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.util.I18n;
import tmb.randy.tmbgriefergames.core.Addon;

public class PayAllCommand extends Command {
public PayAllCommand() {
super("pay");
}

@Override
public boolean execute(String prefix, String[] arguments) {
if(!Addon.isGG())
return true;

if(arguments.length == 2) {
if((arguments[0].equals("**") || arguments[0].equals("/")) && Float.parseFloat(arguments[1]) >= 1F) {
String playersString = getPlayersString();
int players = Integer.parseInt(playersString);
if(players > 1) {
float totalAmount = Float.parseFloat(arguments[1]);
int perPlayer = (int) (totalAmount / (float) players);
int realTotalAmount = players * perPlayer;

if(perPlayer < 1) {
Addon.getSharedInstance().displayNotification(I18n.getTranslation("tmbgriefergames.payAll.amountTooLow"));
return false;
}

Laby.labyAPI().minecraft().chatExecutor().chat("/pay * " + perPlayer);
Addon.getSharedInstance().displayNotification(I18n.getTranslation("tmbgriefergames.payAll.response", players, perPlayer, realTotalAmount));
}
return true;
}
}

return false;
}

private String getPlayersString() {
Scoreboard scoreboard = Laby.labyAPI().minecraft().getScoreboard();

if(scoreboard == null)
return "";

for (ScoreboardTeam team : scoreboard.getTeams()) {
if(team.getTeamName().equals("online_value")) {
String onlineString = ((TextComponent)team.getPrefix()).getText();
return onlineString.split("/")[0];
}
}
return "";
}
}

Loading

0 comments on commit 87fadad

Please sign in to comment.