use of au.com.mineauz.minigames.events.StartGlobalMinigameEvent in project Minigames by AddstarMC.
the class MinigameData method startGlobalMinigame.
public void startGlobalMinigame(Minigame minigame, MinigamePlayer caller) {
boolean canStart = minigame.getMechanic().checkCanStart(minigame, caller);
if (minigame.getType() == MinigameType.GLOBAL && minigame.getMechanic().validTypes().contains(MinigameType.GLOBAL) && canStart) {
StartGlobalMinigameEvent ev = new StartGlobalMinigameEvent(minigame, caller);
Bukkit.getPluginManager().callEvent(ev);
minigame.getMechanic().startMinigame(minigame, caller);
minigame.setEnabled(true);
minigame.saveMinigame();
} else if (!minigame.getMechanic().validTypes().contains(MinigameType.GLOBAL)) {
if (caller == null)
Bukkit.getLogger().info(MinigameUtils.getLang("minigame.error.invalidMechanic"));
else
caller.sendMessage(MinigameUtils.getLang("minigame.error.invalidMechanic"), "error");
} else if (!canStart) {
if (caller == null)
Bukkit.getLogger().info(MinigameUtils.getLang("minigame.error.mechanicStartFail"));
else
caller.sendMessage(MinigameUtils.getLang("minigame.error.mechanicStartFail"), "error");
}
}
use of au.com.mineauz.minigames.events.StartGlobalMinigameEvent in project Minigames by AddstarMC.
the class MinigameManager method startGlobalMinigame.
public void startGlobalMinigame(final Minigame minigame, final MinigamePlayer caller) {
final boolean canStart = minigame.getMechanic().checkCanStart(minigame, caller);
if (minigame.getType() == MinigameType.GLOBAL && minigame.getMechanic().validTypes().contains(MinigameType.GLOBAL) && canStart) {
final StartGlobalMinigameEvent ev = new StartGlobalMinigameEvent(minigame, caller);
Bukkit.getPluginManager().callEvent(ev);
minigame.getMechanic().startMinigame(minigame, caller);
final ResourcePackModule module = (ResourcePackModule) minigame.getModule("ResourcePack");
if (module != null) {
if (module.isEnabled()) {
final String name = module.getResourcePackName();
final ResourcePack pack = PLUGIN.getResourceManager().getResourcePack(name);
if (pack.isValid()) {
for (final MinigamePlayer player : minigame.getPlayers()) {
player.applyResourcePack(pack);
}
}
}
}
minigame.setEnabled(true);
minigame.saveMinigame();
} else if (!minigame.getMechanic().validTypes().contains(MinigameType.GLOBAL)) {
if (caller == null) {
Bukkit.getLogger().info(MinigameUtils.getLang("minigame.error.invalidMechanic"));
} else {
caller.sendMessage(MinigameUtils.getLang("minigame.error.invalidMechanic"), MinigameMessageType.ERROR);
}
} else if (!canStart) {
if (caller == null) {
Bukkit.getLogger().info(MinigameUtils.getLang("minigame.error.mechanicStartFail"));
} else {
caller.sendMessage(MinigameUtils.getLang("minigame.error.mechanicStartFail"), MinigameMessageType.ERROR);
}
}
}
Aggregations