use of au.com.mineauz.minigames.minigame.modules.LoadoutModule.LoadoutAddon in project Minigames by AddstarMC.
the class PlayerLoadout method equiptLoadout.
public void equiptLoadout(MinigamePlayer player) {
player.getPlayer().getInventory().clear();
player.getPlayer().getInventory().setHelmet(null);
player.getPlayer().getInventory().setChestplate(null);
player.getPlayer().getInventory().setLeggings(null);
player.getPlayer().getInventory().setBoots(null);
for (PotionEffect potion : player.getPlayer().getActivePotionEffects()) {
player.getPlayer().removePotionEffect(potion.getType());
}
if (!itemSlot.isEmpty()) {
for (Integer slot : itemSlot.keySet()) {
if (slot < 100)
player.getPlayer().getInventory().setItem(slot, getItem(slot));
else if (slot == 100)
player.getPlayer().getInventory().setBoots(getItem(slot));
else if (slot == 101)
player.getPlayer().getInventory().setLeggings(getItem(slot));
else if (slot == 102)
player.getPlayer().getInventory().setChestplate(getItem(slot));
else if (slot == 103)
player.getPlayer().getInventory().setHelmet(getItem(slot));
}
player.updateInventory();
}
final MinigamePlayer fplayer = player;
Bukkit.getScheduler().scheduleSyncDelayedTask(Minigames.plugin, new Runnable() {
@Override
public void run() {
fplayer.getPlayer().addPotionEffects(potions);
}
});
for (Entry<Class<? extends LoadoutAddon>, Object> addonValue : addonValues.entrySet()) {
LoadoutAddon<Object> addon = LoadoutModule.getAddon(addonValue.getKey());
if (addon != null) {
addon.applyLoadout(player, addonValue.getValue());
}
}
if (level != -1)
player.getPlayer().setLevel(level);
}
use of au.com.mineauz.minigames.minigame.modules.LoadoutModule.LoadoutAddon in project Minigames by AddstarMC.
the class PlayerLoadout method save.
public void save(ConfigurationSection section) {
for (Integer slot : getItems()) section.set("items." + slot, getItem(slot));
for (PotionEffect eff : getAllPotionEffects()) {
section.set("potions." + eff.getType().getName() + ".amp", eff.getAmplifier());
section.set("potions." + eff.getType().getName() + ".dur", eff.getDuration());
}
if (getUsePermissions())
section.set("usepermissions", true);
if (!hasFallDamage())
section.set("falldamage", hasFallDamage());
if (hasHunger())
section.set("hunger", hasHunger());
if (getDisplayName() != null)
section.set("displayName", getDisplayName());
if (isArmourLocked())
section.set("armourLocked", isArmourLocked());
if (isInventoryLocked())
section.set("inventoryLocked", isInventoryLocked());
if (getTeamColor() != null)
section.set("team", getTeamColor().toString());
if (!isDisplayedInMenu())
section.set("displayInMenu", isDisplayedInMenu());
if (!allowOffHand())
section.set("allowOffhand", allowOffHand());
for (Entry<Class<? extends LoadoutAddon>, Object> addonValue : addonValues.entrySet()) {
ConfigurationSection subSection = section.createSection("addons." + addonValue.getKey().getName().replace('.', '-'));
LoadoutAddon<Object> addon = LoadoutModule.getAddon(addonValue.getKey());
addon.save(subSection, addonValue.getValue());
}
}
Aggregations