use of au.com.mineauz.minigames.managers.MinigameManager in project Minigames by AddstarMC.
the class DisableAllCommand method onCommand.
@Override
public boolean onCommand(CommandSender sender, Minigame minigame, String label, String[] args) {
MinigameManager mdata = Minigames.getPlugin().getMinigameManager();
List<Minigame> minigames = new ArrayList<>(mdata.getAllMinigames().values());
if (args != null) {
for (String arg : args) {
if (mdata.hasMinigame(arg))
minigames.remove(mdata.getMinigame(arg));
else
sender.sendMessage(ChatColor.RED + "No Minigame found by the name \"" + arg + "\"; Ignoring...");
}
}
for (Minigame mg : minigames) {
mg.setEnabled(false);
}
sender.sendMessage(ChatColor.GRAY + String.valueOf(minigames.size()) + " Minigames disabled!");
return true;
}
use of au.com.mineauz.minigames.managers.MinigameManager in project Minigames by AddstarMC.
the class EnableAllCommand method onCommand.
@Override
public boolean onCommand(CommandSender sender, Minigame minigame, String label, String[] args) {
MinigameManager mdata = Minigames.getPlugin().getMinigameManager();
List<Minigame> minigames = new ArrayList<>(mdata.getAllMinigames().values());
if (args != null) {
for (String arg : args) {
if (mdata.hasMinigame(arg))
minigames.remove(mdata.getMinigame(arg));
else
MessageManager.sendMessage(sender, MinigameMessageType.ERROR, null, "command.enable.notfound", arg);
}
}
for (Minigame mg : minigames) {
mg.setEnabled(true);
}
MessageManager.sendMessage(sender, MinigameMessageType.INFO, null, "command.enable.resultnum", minigames.size());
return true;
}
use of au.com.mineauz.minigames.managers.MinigameManager in project Minigames by AddstarMC.
the class Minigames method setupMinigames.
private void setupMinigames() {
this.minigameManager = new MinigameManager();
this.playerManager = new MinigamePlayerManager();
this.display = new DisplayManager();
this.resourceManager = new ResourcePackManager();
final MinigameSave resources = new MinigameSave("resources");
this.minigameManager.addConfigurationFile("resources", resources.getConfig());
this.resourceManager.initialize(resources);
this.minigameManager.addMinigameType(new SingleplayerType());
this.minigameManager.addMinigameType(new MultiplayerType());
final MinigameSave completion = new MinigameSave("completion");
this.minigameManager.addConfigurationFile("completion", completion.getConfig());
this.getServer().getPluginManager().registerEvents(new Events(), this);
this.getServer().getPluginManager().registerEvents(new BasicRecorder(), this);
try {
this.getConfig().load(this.getDataFolder() + "/config.yml");
List<String> mgs = new ArrayList<>();
if (this.getConfig().contains("minigames")) {
mgs = this.getConfig().getStringList("minigames");
}
this.debug = this.getConfig().getBoolean("debug", false);
final List<String> allMGS = new ArrayList<>(mgs);
if (!mgs.isEmpty()) {
Bukkit.getScheduler().scheduleSyncDelayedTask(plugin, () -> {
for (final String minigame : allMGS) {
final Minigame game = new Minigame(minigame);
try {
game.loadMinigame();
this.minigameManager.addMinigame(game);
} catch (final Exception e) {
this.getLogger().severe(ChatColor.RED + "Failed to load \"" + minigame + "\"! The configuration file may be corrupt or missing!");
e.printStackTrace();
}
}
}, 1L);
}
} catch (final FileNotFoundException ex) {
log().info("Failed to load config, creating one.");
try {
this.getConfig().save(this.getDataFolder() + "/config.yml");
} catch (final IOException e) {
log().log(Level.SEVERE, "Could not save config.yml!");
e.printStackTrace();
}
} catch (final Exception e) {
log().log(Level.SEVERE, "Failed to load config!");
e.printStackTrace();
}
}
Aggregations