Skip to content

Commit

Permalink
update to fabric 1.20.4
Browse files Browse the repository at this point in the history
  • Loading branch information
WildBamaBoy committed Apr 17, 2024
1 parent cd3b30d commit 4366fc3
Show file tree
Hide file tree
Showing 21 changed files with 155 additions and 113 deletions.
2 changes: 1 addition & 1 deletion build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ plugins {
defaultTasks("shadowJar")

group = "io.tebex"
version = "2.0.5"
version = "2.0.6"

subprojects {
plugins.apply("java")
Expand Down
4 changes: 2 additions & 2 deletions fabric/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -30,8 +30,8 @@ dependencies {
minecraft("com.mojang:minecraft:${minecraftVersion}")
mappings("net.fabricmc:yarn:${yarnMappings}:v2")

modImplementation("eu.pb4:sgui:0.5.0")
include("eu.pb4:sgui:0.5.0")
modImplementation("eu.pb4:sgui:1.4.2+1.20.4")
include("eu.pb4:sgui:1.4.2+1.20.4")

modImplementation("net.fabricmc:fabric-loader:${loaderVersion}")
modImplementation("net.fabricmc.fabric-api:fabric-api:${fabricVersion}")
Expand Down
13 changes: 7 additions & 6 deletions fabric/gradle.properties
Original file line number Diff line number Diff line change
@@ -1,13 +1,14 @@
# Fabric Properties
# check these on https://fabricmc.net/develop
minecraft_version=1.16.5
yarn_mappings=1.16.5+build.10
loader_version=0.14.21
minecraft_version=1.20.4
yarn_mappings=1.20.4+build.3
loader_version=0.15.10

#Fabric api
fabric_version=0.97.0+1.20.4

# Mod Properties
mod_version=1.0.0
mod_version=2.0.6
maven_group=io.tebex.plugin
archives_base_name=tebexplugin

# Dependencies
fabric_version=0.42.0+1.16
4 changes: 2 additions & 2 deletions fabric/src/main/java/io/tebex/plugin/TebexPlugin.java
Original file line number Diff line number Diff line change
Expand Up @@ -203,7 +203,7 @@ public Map<Object, Integer> getQueuedPlayers() {

@Override
public void dispatchCommand(String command) {
server.getCommandManager().execute(server.getCommandSource(), command);
server.getCommandManager().execute(server.getCommandSource().getDispatcher().parse(command, server.getCommandSource()), command);
}

@Override
Expand Down Expand Up @@ -254,7 +254,7 @@ public int getFreeSlots(Object playerId) {
ServerPlayerEntity player = getPlayer(playerId).orElse(null);
if (player == null) return -1;

DefaultedList<ItemStack> inv = player.inventory.main;
DefaultedList<ItemStack> inv = player.getInventory().main;
return (int) inv.stream()
.filter(obj -> obj == null || obj.isEmpty())
.count();
Expand Down
7 changes: 3 additions & 4 deletions fabric/src/main/java/io/tebex/plugin/command/BuyCommand.java
Original file line number Diff line number Diff line change
@@ -1,12 +1,11 @@
package io.tebex.plugin.command;

import com.mojang.brigadier.context.CommandContext;
import com.mojang.brigadier.exceptions.CommandSyntaxException;
import io.tebex.plugin.TebexPlugin;
import io.tebex.plugin.gui.BuyGUI;
import net.minecraft.server.command.ServerCommandSource;
import net.minecraft.server.network.ServerPlayerEntity;
import net.minecraft.text.LiteralText;
import net.minecraft.text.Text;

public class BuyCommand {
private final TebexPlugin plugin;
Expand All @@ -20,8 +19,8 @@ public int execute(CommandContext<ServerCommandSource> context) {
try {
ServerPlayerEntity player = source.getPlayer();
new BuyGUI(plugin).open(player);
} catch (CommandSyntaxException e) {
source.sendFeedback(new LiteralText("§b[Tebex] §7You must be a player to run this command!"), false);
} catch (Exception e) {
source.sendMessage(Text.of("§b[Tebex] §7You must be a player to run this command!"));
}

return 1;
Expand Down
12 changes: 6 additions & 6 deletions fabric/src/main/java/io/tebex/plugin/command/sub/BanCommand.java
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
import io.tebex.plugin.TebexPlugin;
import io.tebex.plugin.command.SubCommand;
import net.minecraft.server.command.ServerCommandSource;
import net.minecraft.text.LiteralText;
import net.minecraft.text.Text;

import java.util.concurrent.ExecutionException;

Expand All @@ -28,19 +28,19 @@ public void execute(CommandContext<ServerCommandSource> context) {
} catch (IllegalArgumentException ignored) {}

if (!platform.isSetup()) {
source.sendFeedback(new LiteralText("§b[Tebex] §7This server is not connected to a webstore. Use /tebex secret to set your store key."), false);
source.sendMessage(Text.of("§b[Tebex] §7This server is not connected to a webstore. Use /tebex secret to set your store key."));
return;
}

try {
boolean success = platform.getSDK().createBan(playerName, ip, reason).get();
if (success) {
source.sendFeedback(new LiteralText("§b[Tebex] §7Player banned successfully."), false);
source.sendMessage(Text.of("§b[Tebex] §7Player banned successfully."));
} else {
source.sendFeedback(new LiteralText("§b[Tebex] §7Failed to ban player."), false);
source.sendMessage(Text.of("§b[Tebex] §7Failed to ban player."));
}
} catch (InterruptedException | ExecutionException e) {
source.sendFeedback(new LiteralText("§b[Tebex] §7Error while banning player: " + e.getMessage()), false);
source.sendMessage(Text.of("§b[Tebex] §7Error while banning player: " + e.getMessage()));
}
}

Expand All @@ -51,6 +51,6 @@ public String getDescription() {

@Override
public String getUsage() {
return "<playerName> <opt:reason> <opt:ip>";
return "<playerName>";
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
import io.tebex.sdk.obj.CheckoutUrl;
import io.tebex.sdk.platform.config.ServerPlatformConfig;
import net.minecraft.server.command.ServerCommandSource;
import net.minecraft.text.LiteralText;
import net.minecraft.text.Text;

import java.util.concurrent.ExecutionException;

Expand All @@ -21,16 +21,16 @@ public void execute(CommandContext<ServerCommandSource> context) {
TebexPlugin platform = getPlatform();

if (!platform.isSetup()) {
context.getSource().sendFeedback(new LiteralText("§b[Tebex] §7This server is not connected to a webstore. Use /tebex secret to set your store key."), false);
context.getSource().sendMessage(Text.of("§b[Tebex] §7This server is not connected to a webstore. Use /tebex secret to set your store key."));
return;
}

Integer packageId = context.getArgument("packageId", Integer.class);
try {
CheckoutUrl checkoutUrl = platform.getSDK().createCheckoutUrl(packageId, context.getSource().getName()).get();
context.getSource().sendFeedback(new LiteralText("§b[Tebex] §7Checkout started! Click here to complete payment: " + checkoutUrl.getUrl()), false);
context.getSource().sendMessage(Text.of("§b[Tebex] §7Checkout started! Click here to complete payment: " + checkoutUrl.getUrl()));
} catch (InterruptedException|ExecutionException e) {
context.getSource().sendError(new LiteralText("§b[Tebex] §7Failed to get checkout link for package: " + e.getMessage()));
context.getSource().sendError(Text.of("§b[Tebex] §7Failed to get checkout link for package: " + e.getMessage()));
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
import io.tebex.sdk.platform.config.ServerPlatformConfig;
import io.tebex.sdk.util.StringUtil;
import net.minecraft.server.command.ServerCommandSource;
import net.minecraft.text.LiteralText;
import net.minecraft.text.Text;

import java.io.IOException;

Expand All @@ -28,21 +28,21 @@ public void execute(CommandContext<ServerCommandSource> context) {

String input = context.getArgument("trueOrFalse", String.class);
if (StringUtil.isTruthy(input)) {
context.getSource().sendFeedback(new LiteralText("§b[Tebex] §7Debug mode enabled."), false);
context.getSource().sendMessage(Text.of("§b[Tebex] §7Debug mode enabled."));
config.setVerbose(true);
configFile.set("verbose", true);
} else if (StringUtil.isFalsy(input)) {
context.getSource().sendFeedback(new LiteralText("§b[Tebex] §7Debug mode disabled."), false);
context.getSource().sendMessage(Text.of("§b[Tebex] §7Debug mode disabled."));
config.setVerbose(false);
configFile.set("verbose", false);
} else {
context.getSource().sendFeedback(new LiteralText("§b[Tebex] §7Invalid command usage. Use /tebex " + this.getName() + " " + getUsage()), false);
context.getSource().sendMessage(Text.of("§b[Tebex] §7Invalid command usage. Use /tebex " + this.getName() + " " + getUsage()));
}

try {
configFile.save();
} catch (IOException e) {
context.getSource().sendFeedback(new LiteralText("§b[Tebex] §7Failed to save configuration file."), false);
context.getSource().sendMessage(Text.of("§b[Tebex] §7Failed to save configuration file."));
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
import io.tebex.plugin.TebexPlugin;
import io.tebex.plugin.command.SubCommand;
import net.minecraft.server.command.ServerCommandSource;
import net.minecraft.text.LiteralText;
import net.minecraft.text.Text;

public class ForceCheckCommand extends SubCommand {
private final TebexPlugin platform;
Expand All @@ -17,13 +17,13 @@ public ForceCheckCommand(TebexPlugin platform) {
@Override
public void execute(CommandContext<ServerCommandSource> context) {
if(! platform.isSetup()) {
context.getSource().sendFeedback(new LiteralText("§cTebex is not setup yet!"), false);
context.getSource().sendMessage(Text.of("§cTebex is not setup yet!"));
return;
}

// if running from console, return
if (context.getSource().getEntity() != null) {
context.getSource().sendFeedback(new LiteralText("§b[Tebex] §7Performing force check..."), false);
context.getSource().sendMessage(Text.of("§b[Tebex] §7Performing force check..."));
}

getPlatform().performCheck(false);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
import io.tebex.plugin.command.SubCommand;
import io.tebex.sdk.obj.CommunityGoal;
import net.minecraft.server.command.ServerCommandSource;
import net.minecraft.text.LiteralText;
import net.minecraft.text.Text;

import java.util.List;
import java.util.concurrent.ExecutionException;
Expand All @@ -23,12 +23,12 @@ public void execute(CommandContext<ServerCommandSource> sender) {
List<CommunityGoal> goals = platform.getSDK().getCommunityGoals().get();
for (CommunityGoal goal: goals) {
if (goal.getStatus() != CommunityGoal.Status.DISABLED) {
sender.getSource().sendFeedback(new LiteralText("§b[Tebex] §7Community Goals: "), false);
sender.getSource().sendFeedback(new LiteralText(String.format("§b[Tebex] §7- %s (%.2f/%.2f) [%s]", goal.getName(), goal.getCurrent(), goal.getTarget(), goal.getStatus())), false);
sender.getSource().sendMessage(Text.of("§b[Tebex] §7Community Goals: "));
sender.getSource().sendMessage(Text.of(String.format("§b[Tebex] §7- %s (%.2f/%.2f) [%s]", goal.getName(), goal.getCurrent(), goal.getTarget(), goal.getStatus())));
}
}
} catch (InterruptedException | ExecutionException e) {
sender.getSource().sendFeedback(new LiteralText("§b[Tebex] §7Unexpected response: " + e.getMessage()), false);
sender.getSource().sendMessage(Text.of("§b[Tebex] §7Unexpected response: " + e.getMessage()));
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@
import io.tebex.plugin.command.SubCommand;
import io.tebex.plugin.manager.CommandManager;
import net.minecraft.server.command.ServerCommandSource;
import net.minecraft.text.LiteralText;
import net.minecraft.text.Text;

import java.util.Comparator;
Expand All @@ -21,13 +20,13 @@ public HelpCommand(TebexPlugin platform, CommandManager commandManager) {
public void execute(CommandContext<ServerCommandSource> context) {
final ServerCommandSource source = context.getSource();

source.sendFeedback(new LiteralText("§b[Tebex] §7Plugin Commands:"), false);
source.sendMessage(Text.of("§b[Tebex] §7Plugin Commands:"));

commandManager
.getCommands()
.stream()
.sorted(Comparator.comparing(SubCommand::getName))
.forEach(subCommand -> source.sendFeedback(new LiteralText(" §8- §f/tebex " + subCommand.getName() + "§f" + (!subCommand.getUsage().isBlank() ? " §3" + subCommand.getUsage() + " " : " ") + "§7§o(" + subCommand.getDescription() + ")"), false));
.forEach(subCommand -> source.sendMessage(Text.of(" §8- §f/tebex " + subCommand.getName() + "§f" + (!subCommand.getUsage().isBlank() ? " §3" + subCommand.getUsage() + " " : " ") + "§7§o(" + subCommand.getDescription() + ")")));
}

@Override
Expand Down
18 changes: 6 additions & 12 deletions fabric/src/main/java/io/tebex/plugin/command/sub/InfoCommand.java
Original file line number Diff line number Diff line change
@@ -1,16 +1,10 @@
package io.tebex.plugin.command.sub;

import com.mojang.brigadier.context.CommandContext;
import dev.dejvokep.boostedyaml.YamlDocument;
import io.tebex.plugin.TebexPlugin;
import io.tebex.plugin.command.SubCommand;
import io.tebex.sdk.SDK;
import io.tebex.sdk.exception.ServerNotFoundException;
import io.tebex.sdk.platform.config.ServerPlatformConfig;
import net.minecraft.server.command.ServerCommandSource;
import net.minecraft.text.LiteralText;

import java.io.IOException;
import net.minecraft.text.Text;

public class InfoCommand extends SubCommand {
public InfoCommand(TebexPlugin platform) {
Expand All @@ -23,12 +17,12 @@ public void execute(CommandContext<ServerCommandSource> context) {
TebexPlugin platform = getPlatform();

if (platform.isSetup()) {
source.sendFeedback(new LiteralText("§b[Tebex] §7Information for this server:"), false);
source.sendFeedback(new LiteralText("§b[Tebex] §7" + platform.getStoreInformation().getServer().getName() + " for webstore " + platform.getStoreInformation().getStore().getName()), false);
source.sendFeedback(new LiteralText("§b[Tebex] §7Server prices are in " + platform.getStoreInformation().getStore().getCurrency().getIso4217()), false);
source.sendFeedback(new LiteralText("§b[Tebex] §7Webstore domain " + platform.getStoreInformation().getStore().getDomain()), false);
source.sendMessage(Text.of("§b[Tebex] §7Information for this server:"));
source.sendMessage(Text.of("§b[Tebex] §7" + platform.getStoreInformation().getServer().getName() + " for webstore " + platform.getStoreInformation().getStore().getName()));
source.sendMessage(Text.of("§b[Tebex] §7Server prices are in " + platform.getStoreInformation().getStore().getCurrency().getIso4217()));
source.sendMessage(Text.of("§b[Tebex] §7Webstore domain " + platform.getStoreInformation().getStore().getDomain()));
} else {
source.sendFeedback(new LiteralText("§b[Tebex] §7This server is not connected to a webstore. Use /tebex secret to set your store key."), false);
source.sendMessage(Text.of("§b[Tebex] §7This server is not connected to a webstore. Use /tebex secret to set your store key."));
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
import io.tebex.plugin.command.SubCommand;
import io.tebex.sdk.obj.PlayerLookupInfo;
import net.minecraft.server.command.ServerCommandSource;
import net.minecraft.text.LiteralText;
import net.minecraft.text.Text;

import java.util.concurrent.ExecutionException;

Expand All @@ -20,7 +20,7 @@ public void execute(CommandContext<ServerCommandSource> context) {
TebexPlugin platform = getPlatform();

if (!platform.isSetup()) {
source.sendFeedback(new LiteralText("§b[Tebex] §7This server is not connected to a webstore. Use /tebex secret to set your store key."), false);
source.sendMessage(Text.of("§b[Tebex] §7This server is not connected to a webstore. Use /tebex secret to set your store key."));
return;
}

Expand All @@ -30,15 +30,15 @@ public void execute(CommandContext<ServerCommandSource> context) {
try {
lookupInfo = platform.getSDK().getPlayerLookupInfo(username).get();
} catch (InterruptedException|ExecutionException e) {
source.sendError(new LiteralText("§b[Tebex] §7Failed to complete player lookup. " + e.getMessage()));
source.sendError(Text.of("§b[Tebex] §7Failed to complete player lookup. " + e.getMessage()));
return;
}

source.sendFeedback(new LiteralText("§b[Tebex] §7Username: " + lookupInfo.getLookupPlayer().getUsername()), false);
source.sendFeedback(new LiteralText("§b[Tebex] §7Id: " + lookupInfo.getLookupPlayer().getId()), false);
source.sendFeedback(new LiteralText("§b[Tebex] §7Chargeback Rate: " + lookupInfo.chargebackRate), false);
source.sendFeedback(new LiteralText("§b[Tebex] §7Bans Total: " + lookupInfo.banCount), false);
source.sendFeedback(new LiteralText("§b[Tebex] §7Payments: " + lookupInfo.payments.size()), false);
source.sendMessage(Text.of("§b[Tebex] §7Username: " + lookupInfo.getLookupPlayer().getUsername()));
source.sendMessage(Text.of("§b[Tebex] §7Id: " + lookupInfo.getLookupPlayer().getId()));
source.sendMessage(Text.of("§b[Tebex] §7Chargeback Rate: " + lookupInfo.chargebackRate));
source.sendMessage(Text.of("§b[Tebex] §7Bans Total: " + lookupInfo.banCount));
source.sendMessage(Text.of("§b[Tebex] §7Payments: " + lookupInfo.payments.size()));
}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
import io.tebex.plugin.TebexPlugin;
import io.tebex.plugin.command.SubCommand;
import net.minecraft.server.command.ServerCommandSource;
import net.minecraft.text.LiteralText;
import net.minecraft.text.Text;

import java.io.IOException;

Expand All @@ -25,9 +25,9 @@ public void execute(CommandContext<ServerCommandSource> context) {
platform.refreshListings();
// platform.setBuyGUI(new BuyGUI(platform));

source.sendFeedback(new LiteralText("§8[Tebex] §7Successfully reloaded."), false);
source.sendMessage(Text.of("§8[Tebex] §7Successfully reloaded."));
} catch (IOException e) {
source.sendFeedback(new LiteralText("§8[Tebex] §cFailed to reload the plugin: Check Console."), false);
source.sendMessage(Text.of("§8[Tebex] §cFailed to reload the plugin: Check Console."));
throw new RuntimeException(e);
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
import io.tebex.plugin.command.SubCommand;
import io.tebex.sdk.platform.config.ServerPlatformConfig;
import net.minecraft.server.command.ServerCommandSource;
import net.minecraft.text.LiteralText;
import net.minecraft.text.Text;

public class ReportCommand extends SubCommand {
public ReportCommand(TebexPlugin platform) {
Expand All @@ -23,11 +23,11 @@ public void execute(CommandContext<ServerCommandSource> context) {
String message = context.getArgument("message", String.class);

if (message.isBlank()) {
context.getSource().sendFeedback(new LiteralText("§b[Tebex] §7A message is required for your report."), false);
context.getSource().sendMessage(Text.of("§b[Tebex] §7A message is required for your report."));
} else {
context.getSource().sendFeedback(new LiteralText("§b[Tebex] §7Sending your report to Tebex..."), false);
context.getSource().sendMessage(Text.of("§b[Tebex] §7Sending your report to Tebex..."));
platform.sendTriageEvent(new Error("User reported error in-game: " + message));
context.getSource().sendFeedback(new LiteralText("§b[Tebex] §7Report sent successfully."), false);
context.getSource().sendMessage(Text.of("§b[Tebex] §7Report sent successfully."));
}
}

Expand Down
Loading

0 comments on commit 4366fc3

Please sign in to comment.