mirror of
https://github.com/PolyhedralDev/Terra.git
synced 2025-07-18 10:32:30 +00:00
Refactor commands
This commit is contained in:
parent
efd52a2002
commit
88067a04c8
@ -2,6 +2,7 @@ package com.dfsek.terra.command;
|
||||
|
||||
import com.dfsek.terra.biome.TerraBiomeGrid;
|
||||
import com.dfsek.terra.biome.UserDefinedBiome;
|
||||
import com.dfsek.terra.command.type.PlayerCommand;
|
||||
import com.dfsek.terra.config.genconfig.BiomeConfig;
|
||||
import org.bukkit.command.Command;
|
||||
import org.bukkit.entity.Player;
|
||||
@ -30,7 +31,7 @@ public class BiomeCommand extends PlayerCommand {
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<com.dfsek.terra.command.Command> getSubCommands() {
|
||||
public List<com.dfsek.terra.command.type.Command> getSubCommands() {
|
||||
return Collections.emptyList();
|
||||
}
|
||||
|
||||
|
@ -1,5 +1,6 @@
|
||||
package com.dfsek.terra.command;
|
||||
|
||||
import com.dfsek.terra.command.type.PlayerCommand;
|
||||
import com.dfsek.terra.config.genconfig.OreConfig;
|
||||
import org.bukkit.block.Block;
|
||||
import org.bukkit.command.Command;
|
||||
@ -33,7 +34,7 @@ public class OreCommand extends PlayerCommand {
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<com.dfsek.terra.command.Command> getSubCommands() {
|
||||
public List<com.dfsek.terra.command.type.Command> getSubCommands() {
|
||||
return Collections.emptyList();
|
||||
}
|
||||
|
||||
|
@ -1,6 +1,7 @@
|
||||
package com.dfsek.terra.command;
|
||||
|
||||
import com.dfsek.terra.Terra;
|
||||
import com.dfsek.terra.command.type.Command;
|
||||
import com.dfsek.terra.config.ConfigUtil;
|
||||
import org.bukkit.command.CommandSender;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
@ -1,5 +1,6 @@
|
||||
package com.dfsek.terra.command;
|
||||
|
||||
import com.dfsek.terra.command.type.Command;
|
||||
import com.dfsek.terra.generation.TerraChunkGenerator;
|
||||
import org.bukkit.command.CommandSender;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
@ -5,20 +5,18 @@ import com.dfsek.terra.command.profile.ProfileCommand;
|
||||
import com.dfsek.terra.command.structure.StructureCommand;
|
||||
import com.dfsek.terra.config.genconfig.BiomeConfig;
|
||||
import com.dfsek.terra.config.genconfig.OreConfig;
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.command.Command;
|
||||
import org.bukkit.command.CommandExecutor;
|
||||
import org.bukkit.command.CommandSender;
|
||||
import org.bukkit.command.TabExecutor;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
|
||||
public class TerraCommand implements CommandExecutor, TabExecutor {
|
||||
private final List<com.dfsek.terra.command.Command> commands = Arrays.asList(new ReloadCommand(),
|
||||
private final List<com.dfsek.terra.command.type.Command> commands = Arrays.asList(new ReloadCommand(),
|
||||
new BiomeCommand(),
|
||||
new OreCommand(),
|
||||
new ProfileCommand(),
|
||||
@ -29,7 +27,7 @@ public class TerraCommand implements CommandExecutor, TabExecutor {
|
||||
@Override
|
||||
public boolean onCommand(@NotNull CommandSender sender, @NotNull Command command, @NotNull String label, @NotNull String[] args) {
|
||||
if(args.length > 0) {
|
||||
for(com.dfsek.terra.command.Command c : commands) {
|
||||
for(com.dfsek.terra.command.type.Command c : commands) {
|
||||
if(c.getName().equals(args[0])) return c.execute(sender, command, label, Arrays.stream(args, 1, args.length).toArray(String[]::new));
|
||||
}
|
||||
sender.sendMessage("Invalid command.");
|
||||
|
@ -1,19 +1,13 @@
|
||||
package com.dfsek.terra.command.image;
|
||||
|
||||
import com.dfsek.terra.Terra;
|
||||
import com.dfsek.terra.command.PlayerCommand;
|
||||
import com.dfsek.terra.command.WorldCommand;
|
||||
import com.dfsek.terra.command.type.WorldCommand;
|
||||
import com.dfsek.terra.command.image.gui.GUICommand;
|
||||
import com.dfsek.terra.config.WorldConfig;
|
||||
import com.dfsek.terra.image.WorldImageGenerator;
|
||||
import org.bukkit.World;
|
||||
import org.bukkit.command.Command;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
import java.io.File;
|
||||
import java.util.Arrays;
|
||||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
|
||||
public class ImageCommand extends WorldCommand {
|
||||
@ -26,7 +20,7 @@ public class ImageCommand extends WorldCommand {
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<com.dfsek.terra.command.Command> getSubCommands() {
|
||||
public List<com.dfsek.terra.command.type.Command> getSubCommands() {
|
||||
return Arrays.asList(new RenderCommand(), new GUICommand());
|
||||
}
|
||||
|
||||
|
@ -1,7 +1,7 @@
|
||||
package com.dfsek.terra.command.image;
|
||||
|
||||
import com.dfsek.terra.Terra;
|
||||
import com.dfsek.terra.command.WorldCommand;
|
||||
import com.dfsek.terra.command.type.WorldCommand;
|
||||
import com.dfsek.terra.image.WorldImageGenerator;
|
||||
import org.bukkit.World;
|
||||
import org.bukkit.command.Command;
|
||||
@ -37,7 +37,7 @@ public class RenderCommand extends WorldCommand {
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<com.dfsek.terra.command.Command> getSubCommands() {
|
||||
public List<com.dfsek.terra.command.type.Command> getSubCommands() {
|
||||
return Collections.emptyList();
|
||||
}
|
||||
|
||||
|
@ -1,7 +1,6 @@
|
||||
package com.dfsek.terra.command.image.gui;
|
||||
|
||||
import com.dfsek.terra.command.WorldCommand;
|
||||
import com.dfsek.terra.config.WorldConfig;
|
||||
import com.dfsek.terra.command.type.WorldCommand;
|
||||
import org.bukkit.World;
|
||||
import org.bukkit.command.Command;
|
||||
import org.bukkit.entity.Player;
|
||||
@ -25,7 +24,7 @@ public class GUICommand extends WorldCommand {
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<com.dfsek.terra.command.Command> getSubCommands() {
|
||||
public List<com.dfsek.terra.command.type.Command> getSubCommands() {
|
||||
return Arrays.asList(new StepGUICommand(), new RawGUICommand());
|
||||
}
|
||||
|
||||
|
@ -1,6 +1,6 @@
|
||||
package com.dfsek.terra.command.image.gui;
|
||||
|
||||
import com.dfsek.terra.command.WorldCommand;
|
||||
import com.dfsek.terra.command.type.WorldCommand;
|
||||
import com.dfsek.terra.config.ConfigUtil;
|
||||
import com.dfsek.terra.config.WorldConfig;
|
||||
import com.dfsek.terra.image.ImageLoader;
|
||||
@ -31,7 +31,7 @@ public class RawGUICommand extends WorldCommand {
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<com.dfsek.terra.command.Command> getSubCommands() {
|
||||
public List<com.dfsek.terra.command.type.Command> getSubCommands() {
|
||||
return Collections.emptyList();
|
||||
}
|
||||
|
||||
|
@ -1,6 +1,6 @@
|
||||
package com.dfsek.terra.command.image.gui;
|
||||
|
||||
import com.dfsek.terra.command.WorldCommand;
|
||||
import com.dfsek.terra.command.type.WorldCommand;
|
||||
import com.dfsek.terra.config.ConfigUtil;
|
||||
import com.dfsek.terra.config.WorldConfig;
|
||||
import com.dfsek.terra.image.ImageLoader;
|
||||
@ -31,7 +31,7 @@ public class StepGUICommand extends WorldCommand {
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<com.dfsek.terra.command.Command> getSubCommands() {
|
||||
public List<com.dfsek.terra.command.type.Command> getSubCommands() {
|
||||
return Collections.emptyList();
|
||||
}
|
||||
|
||||
|
@ -1,6 +1,6 @@
|
||||
package com.dfsek.terra.command.profile;
|
||||
|
||||
import com.dfsek.terra.command.WorldCommand;
|
||||
import com.dfsek.terra.command.type.WorldCommand;
|
||||
import org.bukkit.World;
|
||||
import org.bukkit.command.Command;
|
||||
import org.bukkit.entity.Player;
|
||||
@ -26,7 +26,7 @@ public class ProfileCommand extends WorldCommand {
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<com.dfsek.terra.command.Command> getSubCommands() {
|
||||
public List<com.dfsek.terra.command.type.Command> getSubCommands() {
|
||||
return Arrays.asList(new QueryCommand(), new ResetCommand(), new StartCommand(), new StopCommand());
|
||||
}
|
||||
|
||||
|
@ -1,8 +1,7 @@
|
||||
package com.dfsek.terra.command.profile;
|
||||
|
||||
import com.dfsek.terra.TerraProfiler;
|
||||
import com.dfsek.terra.command.PlayerCommand;
|
||||
import com.dfsek.terra.command.WorldCommand;
|
||||
import com.dfsek.terra.command.type.WorldCommand;
|
||||
import org.bukkit.World;
|
||||
import org.bukkit.command.Command;
|
||||
import org.bukkit.entity.Player;
|
||||
@ -26,7 +25,7 @@ public class QueryCommand extends WorldCommand {
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<com.dfsek.terra.command.Command> getSubCommands() {
|
||||
public List<com.dfsek.terra.command.type.Command> getSubCommands() {
|
||||
return Collections.emptyList();
|
||||
}
|
||||
|
||||
|
@ -1,7 +1,7 @@
|
||||
package com.dfsek.terra.command.profile;
|
||||
|
||||
import com.dfsek.terra.TerraProfiler;
|
||||
import com.dfsek.terra.command.WorldCommand;
|
||||
import com.dfsek.terra.command.type.WorldCommand;
|
||||
import org.bukkit.World;
|
||||
import org.bukkit.command.Command;
|
||||
import org.bukkit.entity.Player;
|
||||
@ -26,7 +26,7 @@ public class ResetCommand extends WorldCommand {
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<com.dfsek.terra.command.Command> getSubCommands() {
|
||||
public List<com.dfsek.terra.command.type.Command> getSubCommands() {
|
||||
return Collections.emptyList();
|
||||
}
|
||||
|
||||
|
@ -1,7 +1,7 @@
|
||||
package com.dfsek.terra.command.profile;
|
||||
|
||||
import com.dfsek.terra.TerraProfiler;
|
||||
import com.dfsek.terra.command.WorldCommand;
|
||||
import com.dfsek.terra.command.type.WorldCommand;
|
||||
import org.bukkit.World;
|
||||
import org.bukkit.command.Command;
|
||||
import org.bukkit.entity.Player;
|
||||
@ -26,7 +26,7 @@ public class StartCommand extends WorldCommand {
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<com.dfsek.terra.command.Command> getSubCommands() {
|
||||
public List<com.dfsek.terra.command.type.Command> getSubCommands() {
|
||||
return Collections.emptyList();
|
||||
}
|
||||
|
||||
|
@ -1,7 +1,7 @@
|
||||
package com.dfsek.terra.command.profile;
|
||||
|
||||
import com.dfsek.terra.TerraProfiler;
|
||||
import com.dfsek.terra.command.WorldCommand;
|
||||
import com.dfsek.terra.command.type.WorldCommand;
|
||||
import org.bukkit.World;
|
||||
import org.bukkit.command.Command;
|
||||
import org.bukkit.entity.Player;
|
||||
@ -26,7 +26,7 @@ public class StopCommand extends WorldCommand {
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<com.dfsek.terra.command.Command> getSubCommands() {
|
||||
public List<com.dfsek.terra.command.type.Command> getSubCommands() {
|
||||
return Collections.emptyList();
|
||||
}
|
||||
|
||||
|
@ -2,7 +2,7 @@ package com.dfsek.terra.command.structure;
|
||||
|
||||
import com.dfsek.terra.Terra;
|
||||
import com.dfsek.terra.WorldEditUtil;
|
||||
import com.dfsek.terra.command.PlayerCommand;
|
||||
import com.dfsek.terra.command.type.PlayerCommand;
|
||||
import com.dfsek.terra.structure.GaeaStructure;
|
||||
import com.dfsek.terra.structure.InitializationException;
|
||||
import com.sk89q.worldedit.IncompleteRegionException;
|
||||
@ -69,7 +69,7 @@ public class ExportCommand extends PlayerCommand {
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<com.dfsek.terra.command.Command> getSubCommands() {
|
||||
public List<com.dfsek.terra.command.type.Command> getSubCommands() {
|
||||
return Collections.emptyList();
|
||||
}
|
||||
|
||||
|
@ -1,7 +1,7 @@
|
||||
package com.dfsek.terra.command.structure;
|
||||
|
||||
import com.dfsek.terra.Terra;
|
||||
import com.dfsek.terra.command.PlayerCommand;
|
||||
import com.dfsek.terra.command.type.PlayerCommand;
|
||||
import com.dfsek.terra.structure.GaeaStructure;
|
||||
import org.bukkit.command.Command;
|
||||
import org.bukkit.entity.Player;
|
||||
@ -33,7 +33,7 @@ public class LoadCommand extends PlayerCommand {
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<com.dfsek.terra.command.Command> getSubCommands() {
|
||||
public List<com.dfsek.terra.command.type.Command> getSubCommands() {
|
||||
return Collections.emptyList();
|
||||
}
|
||||
|
||||
|
@ -1,6 +1,6 @@
|
||||
package com.dfsek.terra.command.structure;
|
||||
|
||||
import com.dfsek.terra.command.PlayerCommand;
|
||||
import com.dfsek.terra.command.type.PlayerCommand;
|
||||
import org.bukkit.command.Command;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
@ -18,7 +18,7 @@ public class StructureCommand extends PlayerCommand {
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<com.dfsek.terra.command.Command> getSubCommands() {
|
||||
public List<com.dfsek.terra.command.type.Command> getSubCommands() {
|
||||
return Arrays.asList(new ExportCommand(), new LoadCommand());
|
||||
}
|
||||
|
||||
|
@ -1,4 +1,4 @@
|
||||
package com.dfsek.terra.command;
|
||||
package com.dfsek.terra.command.type;
|
||||
|
||||
import org.bukkit.command.CommandSender;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
@ -13,7 +13,7 @@ public abstract class Command {
|
||||
public abstract int arguments();
|
||||
public final boolean execute(@NotNull CommandSender sender, @NotNull org.bukkit.command.Command command, @NotNull String label, @NotNull String[] args) {
|
||||
if(args.length > 0) {
|
||||
for(com.dfsek.terra.command.Command c : getSubCommands()) {
|
||||
for(Command c : getSubCommands()) {
|
||||
if(c.getName().equals(args[0])) return c.execute(sender, command, label, Arrays.stream(args, 1, args.length).toArray(String[]::new));
|
||||
}
|
||||
if(args.length != arguments()) {
|
@ -1,4 +1,4 @@
|
||||
package com.dfsek.terra.command;
|
||||
package com.dfsek.terra.command.type;
|
||||
|
||||
import org.bukkit.command.CommandSender;
|
||||
import org.bukkit.entity.Player;
|
@ -1,4 +1,4 @@
|
||||
package com.dfsek.terra.command;
|
||||
package com.dfsek.terra.command.type;
|
||||
|
||||
import com.dfsek.terra.generation.TerraChunkGenerator;
|
||||
import org.bukkit.World;
|
Loading…
x
Reference in New Issue
Block a user