mirror of
https://github.com/darksaid98/HuskHomes.git
synced 2026-12-02 14:38:52 +00:00
More work on commands
This commit is contained in:
33 files changed
+445
-382
No files matched your search
@@ -1,34 +0,0 @@
|
||||
package net.william278.huskhomes.util;
|
||||
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
import java.util.logging.Level;
|
||||
|
||||
/**
|
||||
* An abstract, cross-platform representation of a logger
|
||||
*/
|
||||
public abstract class Logger {
|
||||
|
||||
private boolean debug;
|
||||
|
||||
public abstract void log(@NotNull Level level, @NotNull String message, @NotNull Throwable e);
|
||||
|
||||
public abstract void log(@NotNull Level level, @NotNull String message);
|
||||
|
||||
public abstract void info(@NotNull String message);
|
||||
|
||||
public abstract void severe(@NotNull String message);
|
||||
|
||||
public final void debug(@NotNull String message) {
|
||||
if (debug) {
|
||||
log(Level.INFO, "[DEBUG] " + message);
|
||||
}
|
||||
}
|
||||
|
||||
public abstract void config(@NotNull String message);
|
||||
|
||||
public final void showDebugLogs(boolean debug) {
|
||||
this.debug = debug;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -1,18 +1,45 @@
|
||||
package net.william278.huskhomes.util;
|
||||
|
||||
import net.william278.huskhomes.HuskHomes;
|
||||
import net.william278.huskhomes.user.CommandUser;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
public class ValidationException extends IllegalArgumentException {
|
||||
|
||||
private final Type error;
|
||||
|
||||
public ValidationException(@NotNull ValidationException.Type error) {
|
||||
super("Error validating position: " + error.name());
|
||||
this.error = error;
|
||||
}
|
||||
|
||||
public void dispatchHomeError(@NotNull CommandUser viewer, boolean other, @NotNull HuskHomes plugin, @NotNull String... args) {
|
||||
plugin.getLocales()
|
||||
.getLocale(switch (error) {
|
||||
case NOT_FOUND -> other ? "error_home_invalid_other" : "error_home_invalid";
|
||||
case NAME_TAKEN -> "error_home_name_taken";
|
||||
case NAME_INVALID -> "error_home_name_characters";
|
||||
case DESCRIPTION_INVALID -> "error_home_description_characters";
|
||||
}, args)
|
||||
.ifPresent(viewer::sendMessage);
|
||||
}
|
||||
|
||||
public void dispatchWarpError(@NotNull CommandUser viewer, @NotNull HuskHomes plugin) {
|
||||
plugin.getLocales()
|
||||
.getLocale(switch (error) {
|
||||
case NOT_FOUND -> "error_warp_invalid";
|
||||
case NAME_TAKEN -> "error_warp_name_taken";
|
||||
case NAME_INVALID -> "error_warp_name_characters";
|
||||
case DESCRIPTION_INVALID -> "error_warp_description_characters";
|
||||
})
|
||||
.ifPresent(viewer::sendMessage);
|
||||
}
|
||||
|
||||
public enum Type {
|
||||
NOT_FOUND,
|
||||
NAME_TAKEN,
|
||||
NAME_INVALID,
|
||||
DESCRIPTION_INVALID
|
||||
REACHED_MAX_HOMES, NOT_ENOUGH_HOME_SLOTS, REACHED_MAX_PUBLIC_HOMES, DESCRIPTION_INVALID
|
||||
}
|
||||
|
||||
}
|
||||
Reference in new issue
Block a user