use of au.com.mineauz.minigames.objects.ResourcePack in project Minigames by AddstarMC.
the class ResourcePackModule method addEditMenuOptions.
@Override
public void addEditMenuOptions(Menu menu) {
Menu m = new Menu(3, "Teams", menu.getViewer());
m.setPreviousPage(menu);
m.addItem(enabled.getMenuItem("Enable Resource Pack", Material.MAP));
MenuItem item = new MenuItemString("Resource Pack Name", Material.PAPER, new Callback<String>() {
@Override
public String getValue() {
return resourcePackName.getFlag();
}
@Override
public void setValue(String value) {
resourcePackName.setFlag(value);
}
}) {
@Override
public void checkValidEntry(String entry) {
if (entry.length() == 0) {
super.checkValidEntry(entry);
return;
}
ResourcePack pack = Minigames.getPlugin().getResourceManager().getResourcePack(entry);
if (pack == null) {
getContainer().cancelReopenTimer();
getContainer().displayMenu(getContainer().getViewer());
getContainer().getViewer().sendMessage("No resource pack exists for the name, \"" + entry + "\".", MinigameMessageType.ERROR);
} else {
super.checkValidEntry(entry);
}
}
};
m.addItem(item);
m.addItem(forced.getMenuItem("Force Resource Pack", Material.SKELETON_SKULL));
MenuItemPage p = new MenuItemPage("Resource Pack Options", Material.MAP, m);
m.addItem(new MenuItemPage("Back", getBackMaterial(), menu), m.getSize() - 9);
menu.addItem(p);
}
use of au.com.mineauz.minigames.objects.ResourcePack in project Minigames by AddstarMC.
the class ResourcePackCommand method onCommand.
@Override
public boolean onCommand(final CommandSender sender, Minigame minigame, String label, String[] args) {
ResourcePack pack;
switch(args[0]) {
case "apply":
if (args.length < 3) {
sender.sendMessage(getUsage());
return false;
}
pack = plugin.getResourceManager().getResourcePack(args[1]);
if (pack != null && pack.isValid()) {
MinigamePlayer player = plugin.getPlayerManager().getMinigamePlayer(args[2]);
player.applyResourcePack(pack);
player.sendInfoMessage(MinigameUtils.getLang("minigame.resourcepack.apply"));
return true;
}
case "remove":
if (args.length < 2) {
return false;
}
pack = plugin.getResourceManager().getResourcePack(args[1]);
plugin.getResourceManager().removeResourcePack(pack);
sender.sendMessage(MinigameUtils.getLang("minigame.resourcepack.command.remove"));
return sendList(sender);
case "addnew":
if (args.length < 3) {
sender.sendMessage(getUsage());
return false;
}
String name = args[1];
String u = args[2];
try {
URL url = new URL(u);
final ResourcePack newPack = new ResourcePack(name, url);
plugin.getServer().getScheduler().runTaskLaterAsynchronously(plugin, () -> {
if (newPack.isValid()) {
plugin.getResourceManager().addResourcePack(newPack);
sender.sendMessage(MinigameUtils.getLang("minigame.resourcepack.command.addresource"));
sendList(sender);
} else {
sender.sendMessage(MinigameUtils.getLang("minigame.resourcepack.command.invalidpack"));
}
}, 100);
return true;
} catch (MalformedURLException e) {
sender.sendMessage(MinigameUtils.getLang("minigame.resourcepack.command.badurl"));
return false;
}
case "list":
return sendList(sender);
case "clear":
for (MinigamePlayer p : plugin.getPlayerManager().getAllMinigamePlayers()) {
p.applyResourcePack(plugin.getResourceManager().getResourcePack("empty"));
}
return true;
}
return false;
}
use of au.com.mineauz.minigames.objects.ResourcePack in project Minigames by AddstarMC.
the class MinigamePlayerManager method joinMinigame.
public void joinMinigame(MinigamePlayer player, Minigame minigame, boolean isBetting, Double betAmount) {
MinigameType type = minigame.getType();
JoinMinigameEvent event = new JoinMinigameEvent(player, minigame);
Bukkit.getServer().getPluginManager().callEvent(event);
if (event.isCancelled()) {
Minigames.log.info("Start Event was cancelled..: " + event.toString());
return;
}
if (!mgManager.minigameStartStateCheck(minigame, player))
return;
// Do betting stuff
if (isBetting)
handleBets(minigame, player, betAmount);
// Try teleport the player to their designated area.
ResourcePack pack = getResourcePack(minigame);
if (pack != null && pack.isValid()) {
if (player.applyResourcePack(pack))
player.sendInfoMessage(MinigameUtils.getLang("minigame.resourcepack.apply"));
}
// Check if Minigame is full
if (minigame.isGameFull()) {
player.sendMessage(MinigameUtils.getLang("minigame.full"), MinigameMessageType.ERROR);
return;
}
if (!mgManager.teleportPlayerOnJoin(minigame, player)) {
player.sendMessage(MinigameUtils.getLang("minigame.error.noTeleport"), MinigameMessageType.ERROR);
return;
}
// Give them the game type name
if (minigame.getGametypeName() == null)
player.sendMessage(MinigameUtils.formStr("player.join.plyInfo", minigame.getType().getName()), MinigameMessageType.WIN);
else
player.sendMessage(MinigameUtils.formStr("player.join.plyInfo", minigame.getGametypeName()), MinigameMessageType.WIN);
// Give them the objective
if (minigame.getObjective() != null) {
player.sendUnprefixedMessage(ChatColor.GREEN + "----------------------------------------------------");
player.sendInfoMessage(ChatColor.AQUA.toString() + ChatColor.BOLD + MinigameUtils.formStr("player.join.objective", ChatColor.RESET.toString() + ChatColor.WHITE + minigame.getObjective()));
player.sendUnprefixedMessage(ChatColor.GREEN + "----------------------------------------------------");
}
// Prepare regeneration region for rollback.
mgManager.addBlockRecorderData(minigame);
// Standardize player
player.storePlayerData();
player.setMinigame(minigame);
minigame.addPlayer(player);
WeatherTimeModule mod = WeatherTimeModule.getMinigameModule(minigame);
if (mod != null) {
mod.applyCustomTime(player);
mod.applyCustomWeather(player);
}
player.setCheckpoint(player.getPlayer().getLocation());
player.getPlayer().setFallDistance(0);
player.getPlayer().setWalkSpeed(0.2f);
player.setStartTime(Calendar.getInstance().getTimeInMillis());
player.setGamemode(minigame.getDefaultGamemode());
player.getPlayer().setAllowFlight(false);
for (PotionEffect potion : player.getPlayer().getActivePotionEffects()) {
player.getPlayer().removePotionEffect(potion.getType());
}
// Hide Spectators
for (MinigamePlayer pl : minigame.getSpectators()) {
player.getPlayer().hidePlayer(plugin, pl.getPlayer());
}
if (minigame.getPlayers().size() == 1) {
// Register regen recorder events
if (minigame.getBlockRecorder().hasRegenArea())
Bukkit.getServer().getPluginManager().registerEvents(minigame.getBlockRecorder(), plugin);
if (mod != null)
mod.startTimeLoop();
}
// Call Type specific join
mgManager.minigameType(type).joinMinigame(player, minigame);
// Call Mechanic specific join
minigame.getMechanic().onJoinMinigame(minigame, player);
// Send other players the join message.
mgManager.sendMinigameMessage(minigame, MinigameUtils.formStr("player.join.plyMsg", player.getName(), minigame.getName(true)), null, player);
player.updateInventory();
if (minigame.canDisplayScoreboard()) {
player.getPlayer().setScoreboard(minigame.getScoreboardManager());
minigame.setScore(player, 1);
minigame.setScore(player, 0);
}
if (minigame.getState() == MinigameState.STARTING && minigame.canLateJoin()) {
player.sendInfoMessage(MinigameUtils.formStr("minigame.lateJoinWait", minigame.getMpTimer().getStartWaitTimeLeft()));
}
}
use of au.com.mineauz.minigames.objects.ResourcePack in project Minigames by AddstarMC.
the class MinigameManager method stopGlobalMinigame.
public void stopGlobalMinigame(final Minigame minigame, final MinigamePlayer caller) {
if (minigame.getType() == MinigameType.GLOBAL) {
final StopGlobalMinigameEvent ev = new StopGlobalMinigameEvent(minigame, caller);
Bukkit.getPluginManager().callEvent(ev);
minigame.getMechanic().stopMinigame(minigame, caller);
minigame.setEnabled(false);
final ResourcePackModule module = (ResourcePackModule) minigame.getModule("ResourcePack");
if (module != null) {
if (module.isEnabled()) {
final ResourcePack pack = PLUGIN.getResourceManager().getResourcePack("empty");
if (pack.isValid()) {
for (final MinigamePlayer player : minigame.getPlayers()) {
player.applyResourcePack(pack);
}
}
}
}
minigame.saveMinigame();
}
}
use of au.com.mineauz.minigames.objects.ResourcePack in project Minigames by AddstarMC.
the class ResourcePackManager method initialize.
public boolean initialize(final MinigameSave c) {
this.config = c;
boolean emptyPresent = false;
final List<ResourcePack> resources = new ArrayList<>();
final Object objects = this.config.getConfig().get("resources");
if (objects instanceof List) {
final List obj = (List) objects;
for (final Object object : obj) {
if (object instanceof ResourcePack) {
resources.add((ResourcePack) object);
}
}
}
for (final ResourcePack pack : resources) {
if (pack.getName().equals("empty")) {
emptyPresent = true;
enabled = true;
}
addResourcePack(pack);
}
if (!emptyPresent) {
if (!loadEmptyPack()) {
Minigames.log().warning("Minigames Resource Manager could not create the empty reset pack");
enabled = false;
return false;
}
enabled = true;
}
enabled = true;
return true;
}
Aggregations