mirror of
https://github.com/PolyhedralDev/Terra.git
synced 2025-07-18 18:42:30 +00:00
Make some commands debug only, update Mesa biome
This commit is contained in:
parent
fd82d645a1
commit
3ca1c5980c
@ -2,6 +2,7 @@ package com.dfsek.terra.command;
|
|||||||
|
|
||||||
import com.dfsek.terra.Terra;
|
import com.dfsek.terra.Terra;
|
||||||
import com.dfsek.terra.command.type.Command;
|
import com.dfsek.terra.command.type.Command;
|
||||||
|
import com.dfsek.terra.command.type.DebugCommand;
|
||||||
import com.dfsek.terra.config.base.ConfigUtil;
|
import com.dfsek.terra.config.base.ConfigUtil;
|
||||||
import com.dfsek.terra.config.lang.LangUtil;
|
import com.dfsek.terra.config.lang.LangUtil;
|
||||||
import org.bukkit.command.CommandSender;
|
import org.bukkit.command.CommandSender;
|
||||||
@ -10,7 +11,7 @@ import org.jetbrains.annotations.NotNull;
|
|||||||
import java.util.Collections;
|
import java.util.Collections;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
public class ReloadCommand extends Command {
|
public class ReloadCommand extends Command implements DebugCommand {
|
||||||
@Override
|
@Override
|
||||||
public String getName() {
|
public String getName() {
|
||||||
return "reload";
|
return "reload";
|
||||||
|
@ -1,5 +1,6 @@
|
|||||||
package com.dfsek.terra.command.geometry;
|
package com.dfsek.terra.command.geometry;
|
||||||
|
|
||||||
|
import com.dfsek.terra.command.type.DebugCommand;
|
||||||
import com.dfsek.terra.command.type.PlayerCommand;
|
import com.dfsek.terra.command.type.PlayerCommand;
|
||||||
import com.dfsek.terra.config.lang.LangUtil;
|
import com.dfsek.terra.config.lang.LangUtil;
|
||||||
import org.bukkit.command.Command;
|
import org.bukkit.command.Command;
|
||||||
@ -11,7 +12,7 @@ import java.util.Arrays;
|
|||||||
import java.util.Collections;
|
import java.util.Collections;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
public class GeometryCommand extends PlayerCommand {
|
public class GeometryCommand extends PlayerCommand implements DebugCommand {
|
||||||
@Override
|
@Override
|
||||||
public boolean execute(@NotNull Player sender, @NotNull Command command, @NotNull String label, @NotNull String[] args) {
|
public boolean execute(@NotNull Player sender, @NotNull Command command, @NotNull String label, @NotNull String[] args) {
|
||||||
LangUtil.send("command.geometry.main-menu", sender);
|
LangUtil.send("command.geometry.main-menu", sender);
|
||||||
|
@ -1,5 +1,6 @@
|
|||||||
package com.dfsek.terra.command.image.gui;
|
package com.dfsek.terra.command.image.gui;
|
||||||
|
|
||||||
|
import com.dfsek.terra.command.type.DebugCommand;
|
||||||
import com.dfsek.terra.command.type.WorldCommand;
|
import com.dfsek.terra.command.type.WorldCommand;
|
||||||
import com.dfsek.terra.config.lang.LangUtil;
|
import com.dfsek.terra.config.lang.LangUtil;
|
||||||
import org.bukkit.World;
|
import org.bukkit.World;
|
||||||
@ -12,7 +13,7 @@ import java.util.Arrays;
|
|||||||
import java.util.Collections;
|
import java.util.Collections;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
public class GUICommand extends WorldCommand {
|
public class GUICommand extends WorldCommand implements DebugCommand {
|
||||||
@Override
|
@Override
|
||||||
public boolean execute(@NotNull Player sender, @NotNull Command command, @NotNull String label, @NotNull String[] args, World world) {
|
public boolean execute(@NotNull Player sender, @NotNull Command command, @NotNull String label, @NotNull String[] args, World world) {
|
||||||
LangUtil.send("command.image.gui.main-menu", sender);
|
LangUtil.send("command.image.gui.main-menu", sender);
|
||||||
|
@ -1,6 +1,7 @@
|
|||||||
package com.dfsek.terra.command.structure;
|
package com.dfsek.terra.command.structure;
|
||||||
|
|
||||||
import com.dfsek.terra.Terra;
|
import com.dfsek.terra.Terra;
|
||||||
|
import com.dfsek.terra.command.type.DebugCommand;
|
||||||
import com.dfsek.terra.command.type.PlayerCommand;
|
import com.dfsek.terra.command.type.PlayerCommand;
|
||||||
import com.dfsek.terra.config.lang.LangUtil;
|
import com.dfsek.terra.config.lang.LangUtil;
|
||||||
import com.dfsek.terra.structure.GaeaStructure;
|
import com.dfsek.terra.structure.GaeaStructure;
|
||||||
@ -14,7 +15,7 @@ import java.io.IOException;
|
|||||||
import java.util.Collections;
|
import java.util.Collections;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
public class LoadCommand extends PlayerCommand {
|
public class LoadCommand extends PlayerCommand implements DebugCommand {
|
||||||
@Override
|
@Override
|
||||||
public boolean execute(@NotNull Player sender, @NotNull Command command, @NotNull String label, @NotNull String[] args) {
|
public boolean execute(@NotNull Player sender, @NotNull Command command, @NotNull String label, @NotNull String[] args) {
|
||||||
try {
|
try {
|
||||||
|
@ -1,6 +1,7 @@
|
|||||||
package com.dfsek.terra.command.type;
|
package com.dfsek.terra.command.type;
|
||||||
|
|
||||||
import com.dfsek.terra.Debug;
|
import com.dfsek.terra.Debug;
|
||||||
|
import com.dfsek.terra.config.base.ConfigUtil;
|
||||||
import com.dfsek.terra.config.lang.LangUtil;
|
import com.dfsek.terra.config.lang.LangUtil;
|
||||||
import org.bukkit.command.CommandExecutor;
|
import org.bukkit.command.CommandExecutor;
|
||||||
import org.bukkit.command.CommandSender;
|
import org.bukkit.command.CommandSender;
|
||||||
@ -63,9 +64,15 @@ public abstract class Command implements CommandExecutor, TabCompleter {
|
|||||||
*/
|
*/
|
||||||
@Override
|
@Override
|
||||||
public final boolean onCommand(@NotNull CommandSender sender, @NotNull org.bukkit.command.Command command, @NotNull String label, @NotNull String[] args) {
|
public final boolean onCommand(@NotNull CommandSender sender, @NotNull org.bukkit.command.Command command, @NotNull String label, @NotNull String[] args) {
|
||||||
|
if(this instanceof DebugCommand && ! ConfigUtil.debug) {
|
||||||
|
LangUtil.send("command.debug-only", sender);
|
||||||
|
return true;
|
||||||
|
}
|
||||||
if(args.length > 0) {
|
if(args.length > 0) {
|
||||||
for(Command c : getSubCommands()) {
|
for(Command c : getSubCommands()) {
|
||||||
if(c.getName().equals(args[0])) return c.onCommand(sender, command, label, Arrays.stream(args, 1, args.length).toArray(String[]::new));
|
if(c.getName().equals(args[0])) {
|
||||||
|
return c.onCommand(sender, command, label, Arrays.stream(args, 1, args.length).toArray(String[]::new));
|
||||||
|
}
|
||||||
}
|
}
|
||||||
if(args.length != arguments()) {
|
if(args.length != arguments()) {
|
||||||
LangUtil.send("command.invalid", sender, String.valueOf(arguments()), String.valueOf(args.length));
|
LangUtil.send("command.invalid", sender, String.valueOf(arguments()), String.valueOf(args.length));
|
||||||
|
@ -0,0 +1,8 @@
|
|||||||
|
package com.dfsek.terra.command.type;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Implementing this interface marks a command as debug-only.
|
||||||
|
* If a parent command implements this interface, all child commands will be considered debug commands, regardless of whether they implement DebugCommand as well.
|
||||||
|
*/
|
||||||
|
public interface DebugCommand {
|
||||||
|
}
|
@ -5,6 +5,7 @@ enable:
|
|||||||
disable:
|
disable:
|
||||||
- "Thank you for using Terra!"
|
- "Thank you for using Terra!"
|
||||||
command:
|
command:
|
||||||
|
debug-only: "This command must be used with debug mode enabled!"
|
||||||
player-only: "This command is for players only!"
|
player-only: "This command is for players only!"
|
||||||
terra-world: "This command must be executed in a Terra world!"
|
terra-world: "This command must be executed in a Terra world!"
|
||||||
invalid: "Invalid command. (Expected %1$s arguments, found %2$s)."
|
invalid: "Invalid command. (Expected %1$s arguments, found %2$s)."
|
||||||
|
Loading…
x
Reference in New Issue
Block a user