@Commander(
name = "edit",
description = "config edit command"
)
public class TestConfigEditCommand implements CommandNode {
private final Random random = new Random();
@Inject
private TestConfig config;
@Override
public void execute(CommandSender commandSender) {
config.bool = random.nextBoolean();
config.name = UUID.randomUUID().toString();
config.number = random.nextInt();
config.box = new TestConfig.Box();
config.box.color = ChatColor.values()[random.nextInt(ChatColor.values().length)];
config.box.name = UUID.randomUUID().toString()+" box";
config.box.size = random.nextInt();
try {
config.getController().save(); // 儲存文件
commandSender.sendMessage("save completed");
} catch (IOException e) {
e.printStackTrace();
}
}
}
@Commander(
name = "reload",
description = "config reload command"
)
public class TestConfigReloadCommand implements CommandNode {
@Inject
private TestConfig config;
@Override
public void execute(CommandSender commandSender) {
config.getController().reload(); // 重載文件
commandSender.sendMessage("reload completed");
}
}