Skip to content

Commit

Permalink
refactor(bukkit): kotlin migration
Browse files Browse the repository at this point in the history
  • Loading branch information
HaHaWTH committed Sep 27, 2024
1 parent 92f6adc commit b3795fb
Show file tree
Hide file tree
Showing 34 changed files with 607 additions and 627 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@
import java.util.concurrent.atomic.AtomicReference;
import java.util.logging.Logger;

import static io.wdsj.asw.bukkit.util.TimingUtils.cleanStatisticCache;
import static io.wdsj.asw.bukkit.util.TimingUtils.resetStatistics;
import static io.wdsj.asw.bukkit.util.Utils.*;


Expand Down Expand Up @@ -124,7 +124,7 @@ public void onEnable() {
long startTime = System.currentTimeMillis();
libraryService.loadRequired();
LOGGER.info("Initializing DFA system...");
cleanStatisticCache();
resetStatistics();
scheduler = UniversalScheduler.getScheduler(this);
permCache = CachingPermTool.enable(this);
BookCache.initialize();
Expand Down Expand Up @@ -279,7 +279,7 @@ public void onDisable() {
getServer().getMessenger().unregisterOutgoingPluginChannel(this);
getServer().getMessenger().unregisterIncomingPluginChannel(this);
HandlerList.unregisterAll(this);
TimingUtils.cleanStatisticCache();
TimingUtils.resetStatistics();
ChatContext.forceClearContext();
SignContext.forceClearContext();
PlayerShadowController.clear();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,10 @@ public static void punish(Player player) {

public static void processSinglePunish(Player player, String method) throws IllegalArgumentException {
String[] normalPunish = method.split("\\|");
PunishmentType punishMethod = PunishmentType.valueOf(normalPunish[0].toUpperCase(Locale.ROOT));
PunishmentType punishMethod = PunishmentType.getType(normalPunish[0].toUpperCase(Locale.ROOT));
if (punishMethod == null) {
throw new IllegalArgumentException("Invalid punishment method");
}
long violationCount = ViolationCounter.getViolationCount(player);
if (normalPunish.length > 2 && normalPunish[normalPunish.length - 1].toUpperCase(Locale.ROOT).startsWith("VL") && normalPunish[normalPunish.length - 1].length() > 2) {
String vlCondition = normalPunish[normalPunish.length - 1].substring(2);
Expand Down Expand Up @@ -107,8 +110,7 @@ public static void processSinglePunish(Player player, String method) throws Ille
}
break;
default:
LOGGER.warning("Unknown punishment type");
break;
throw new IllegalArgumentException("Invalid punishment method");
}
}

Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,9 @@
package io.wdsj.asw.bukkit.manage.punish;

import org.jetbrains.annotations.Nullable;

import java.util.Locale;

public enum PunishmentType {
COMMAND,

Expand All @@ -11,5 +15,14 @@ public enum PunishmentType {

EFFECT,

SHADOW
SHADOW;

@Nullable
public static PunishmentType getType(String type) {
try {
return valueOf(type.trim().toUpperCase(Locale.ROOT));
} catch (IllegalArgumentException e) {
return null;
}
}
}
48 changes: 0 additions & 48 deletions bukkit/src/main/java/io/wdsj/asw/bukkit/util/LoggingUtils.java

This file was deleted.

19 changes: 0 additions & 19 deletions bukkit/src/main/java/io/wdsj/asw/bukkit/util/PlayerUtils.java

This file was deleted.

73 changes: 0 additions & 73 deletions bukkit/src/main/java/io/wdsj/asw/bukkit/util/SchedulingUtils.java

This file was deleted.

46 changes: 0 additions & 46 deletions bukkit/src/main/java/io/wdsj/asw/bukkit/util/TimingUtils.java

This file was deleted.

117 changes: 0 additions & 117 deletions bukkit/src/main/java/io/wdsj/asw/bukkit/util/Utils.java

This file was deleted.

Loading

0 comments on commit b3795fb

Please sign in to comment.