Added permission check to PlayerSpawn listener and tidied up the code and even placed equipping armor into it's own method/function.
This commit is contained in:
parent
94f96bbd40
commit
03019ed1bc
|
@ -16,108 +16,50 @@ public class PlayerSpawn implements Listener {
|
|||
public void onPlayerJoin(PlayerJoinEvent event) {
|
||||
Player joinedPlayer = event.getPlayer();
|
||||
|
||||
// Create Prisoner Armor
|
||||
ItemStack LeatherHelmetPrison = new ItemStack(Material.LEATHER_HELMET);
|
||||
{
|
||||
LeatherArmorMeta meta = (LeatherArmorMeta) LeatherHelmetPrison.getItemMeta();
|
||||
meta.setColor(Color.ORANGE);
|
||||
LeatherHelmetPrison.setItemMeta(meta);
|
||||
// Check if the player has the permission
|
||||
if (joinedPlayer.hasPermission("nvus.prisoner")) {
|
||||
// Create and equip prisoner armor
|
||||
equipPrisonerArmor(joinedPlayer);
|
||||
}
|
||||
|
||||
ItemStack LeatherChestplatePrison = new ItemStack(Material.LEATHER_CHESTPLATE);
|
||||
{
|
||||
LeatherArmorMeta meta = (LeatherArmorMeta) LeatherChestplatePrison.getItemMeta();
|
||||
meta.setColor(Color.ORANGE);
|
||||
LeatherChestplatePrison.setItemMeta(meta);
|
||||
}
|
||||
|
||||
ItemStack LeatherLeggingsPrison = new ItemStack(Material.LEATHER_LEGGINGS);
|
||||
{
|
||||
LeatherArmorMeta meta = (LeatherArmorMeta) LeatherLeggingsPrison.getItemMeta();
|
||||
meta.setColor(Color.ORANGE);
|
||||
LeatherLeggingsPrison.setItemMeta(meta);
|
||||
}
|
||||
|
||||
ItemStack LeatherBootsPrison = new ItemStack(Material.LEATHER_BOOTS);
|
||||
{
|
||||
LeatherArmorMeta meta = (LeatherArmorMeta) LeatherBootsPrison.getItemMeta();
|
||||
meta.setColor(Color.ORANGE);
|
||||
LeatherBootsPrison.setItemMeta(meta);
|
||||
}
|
||||
|
||||
// Equip Prisoner Armor
|
||||
joinedPlayer.getInventory().setHelmet(LeatherHelmetPrison);
|
||||
joinedPlayer.getInventory().setChestplate(LeatherChestplatePrison);
|
||||
joinedPlayer.getInventory().setLeggings(LeatherLeggingsPrison);
|
||||
joinedPlayer.getInventory().setBoots(LeatherBootsPrison);
|
||||
|
||||
// Equip Prisoner Tools
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
/*
|
||||
// Jank City: Update health for all online players within a radius
|
||||
for (Player onlinePlayer : Bukkit.getOnlinePlayers()) {
|
||||
if (onlinePlayer.getLocation().distance(joinedPlayer.getLocation()) <= 20) {
|
||||
// Slightly damage the nearby already connected players
|
||||
double damageAmount = 0.01;
|
||||
onlinePlayer.damage(damageAmount);
|
||||
|
||||
// Heal the nearby already connected players
|
||||
updateHealth(onlinePlayer, damageAmount);
|
||||
}
|
||||
}
|
||||
*/
|
||||
|
||||
}
|
||||
|
||||
@EventHandler
|
||||
public void onPlayerRespawn(PlayerRespawnEvent event) {
|
||||
Player respawnedPlayer = event.getPlayer();
|
||||
|
||||
// Create Prisoner Armor
|
||||
ItemStack LeatherHelmetPrison = new ItemStack(Material.LEATHER_HELMET);
|
||||
{
|
||||
LeatherArmorMeta meta = (LeatherArmorMeta) LeatherHelmetPrison.getItemMeta();
|
||||
meta.setColor(Color.ORANGE);
|
||||
LeatherHelmetPrison.setItemMeta(meta);
|
||||
// Check if the player has the permission
|
||||
if (respawnedPlayer.hasPermission("nvus.prisoner")) {
|
||||
// Create and equip prisoner armor
|
||||
equipPrisonerArmor(respawnedPlayer);
|
||||
}
|
||||
|
||||
ItemStack LeatherChestplatePrison = new ItemStack(Material.LEATHER_CHESTPLATE);
|
||||
{
|
||||
LeatherArmorMeta meta = (LeatherArmorMeta) LeatherChestplatePrison.getItemMeta();
|
||||
meta.setColor(Color.ORANGE);
|
||||
LeatherChestplatePrison.setItemMeta(meta);
|
||||
}
|
||||
|
||||
ItemStack LeatherLeggingsPrison = new ItemStack(Material.LEATHER_LEGGINGS);
|
||||
{
|
||||
LeatherArmorMeta meta = (LeatherArmorMeta) LeatherLeggingsPrison.getItemMeta();
|
||||
meta.setColor(Color.ORANGE);
|
||||
LeatherLeggingsPrison.setItemMeta(meta);
|
||||
}
|
||||
|
||||
ItemStack LeatherBootsPrison = new ItemStack(Material.LEATHER_BOOTS);
|
||||
{
|
||||
LeatherArmorMeta meta = (LeatherArmorMeta) LeatherBootsPrison.getItemMeta();
|
||||
meta.setColor(Color.ORANGE);
|
||||
LeatherBootsPrison.setItemMeta(meta);
|
||||
}
|
||||
|
||||
// Equip Prisoner Armor
|
||||
respawnedPlayer.getInventory().setHelmet(LeatherHelmetPrison);
|
||||
respawnedPlayer.getInventory().setChestplate(LeatherChestplatePrison);
|
||||
respawnedPlayer.getInventory().setLeggings(LeatherLeggingsPrison);
|
||||
respawnedPlayer.getInventory().setBoots(LeatherBootsPrison);
|
||||
|
||||
// Equip Prisoner Tools
|
||||
|
||||
|
||||
}
|
||||
|
||||
private void equipPrisonerArmor(Player player) {
|
||||
// Create Prisoner Armor
|
||||
ItemStack leatherHelmetPrison = new ItemStack(Material.LEATHER_HELMET);
|
||||
LeatherArmorMeta helmetMeta = (LeatherArmorMeta) leatherHelmetPrison.getItemMeta();
|
||||
helmetMeta.setColor(Color.ORANGE);
|
||||
leatherHelmetPrison.setItemMeta(helmetMeta);
|
||||
|
||||
ItemStack leatherChestplatePrison = new ItemStack(Material.LEATHER_CHESTPLATE);
|
||||
LeatherArmorMeta chestplateMeta = (LeatherArmorMeta) leatherChestplatePrison.getItemMeta();
|
||||
chestplateMeta.setColor(Color.ORANGE);
|
||||
leatherChestplatePrison.setItemMeta(chestplateMeta);
|
||||
|
||||
ItemStack leatherLeggingsPrison = new ItemStack(Material.LEATHER_LEGGINGS);
|
||||
LeatherArmorMeta leggingsMeta = (LeatherArmorMeta) leatherLeggingsPrison.getItemMeta();
|
||||
leggingsMeta.setColor(Color.ORANGE);
|
||||
leatherLeggingsPrison.setItemMeta(leggingsMeta);
|
||||
|
||||
ItemStack leatherBootsPrison = new ItemStack(Material.LEATHER_BOOTS);
|
||||
LeatherArmorMeta bootsMeta = (LeatherArmorMeta) leatherBootsPrison.getItemMeta();
|
||||
bootsMeta.setColor(Color.ORANGE);
|
||||
leatherBootsPrison.setItemMeta(bootsMeta);
|
||||
|
||||
// Equip Prisoner Armor
|
||||
player.getInventory().setHelmet(leatherHelmetPrison);
|
||||
player.getInventory().setChestplate(leatherChestplatePrison);
|
||||
player.getInventory().setLeggings(leatherLeggingsPrison);
|
||||
player.getInventory().setBoots(leatherBootsPrison);
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue