- Added config options to change messages you get when receiving an armored elytra and when you are not allowed to wear a certain tier of elytra. Changing the messages to "NONE" will cause no message to be printed.
- You can now give armored elytras to players from the console using the command: /armoredelytra <player> <armor>
This commit is contained in:
parent
b7059d4544
commit
9fb779f495
2
pom.xml
2
pom.xml
@ -2,7 +2,7 @@
|
|||||||
<modelVersion>4.0.0</modelVersion>
|
<modelVersion>4.0.0</modelVersion>
|
||||||
<groupId>nl.pim16aap2</groupId>
|
<groupId>nl.pim16aap2</groupId>
|
||||||
<artifactId>ArmoredElytra</artifactId>
|
<artifactId>ArmoredElytra</artifactId>
|
||||||
<version>1.4.0-SNAPSHOT</version>
|
<version>1.5.0-SNAPSHOT</version>
|
||||||
<repositories>
|
<repositories>
|
||||||
<repository>
|
<repository>
|
||||||
<id>spigot-repo</id>
|
<id>spigot-repo</id>
|
||||||
|
@ -1,12 +1,14 @@
|
|||||||
package nl.pim16aap2.armoredElytra;
|
package nl.pim16aap2.armoredElytra;
|
||||||
|
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
import java.util.Objects;
|
||||||
import java.util.logging.Level;
|
import java.util.logging.Level;
|
||||||
|
|
||||||
import org.bukkit.Bukkit;
|
import org.bukkit.Bukkit;
|
||||||
import org.bukkit.Material;
|
import org.bukkit.Material;
|
||||||
import org.bukkit.command.Command;
|
import org.bukkit.command.Command;
|
||||||
import org.bukkit.command.CommandSender;
|
import org.bukkit.command.CommandSender;
|
||||||
|
import org.bukkit.configuration.file.FileConfiguration;
|
||||||
import org.bukkit.entity.Player;
|
import org.bukkit.entity.Player;
|
||||||
import org.bukkit.event.Listener;
|
import org.bukkit.event.Listener;
|
||||||
import org.bukkit.inventory.ItemStack;
|
import org.bukkit.inventory.ItemStack;
|
||||||
@ -25,18 +27,46 @@ public class ArmoredElytra extends JavaPlugin implements Listener
|
|||||||
private int IRON_TO_FULL;
|
private int IRON_TO_FULL;
|
||||||
private int DIAMONDS_TO_FULL;
|
private int DIAMONDS_TO_FULL;
|
||||||
private String[] allowedEnchants;
|
private String[] allowedEnchants;
|
||||||
|
private String usageDeniedMessage;
|
||||||
|
private String elytraReceivedMessage;
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onEnable()
|
public void onEnable()
|
||||||
{
|
{
|
||||||
|
FileConfiguration config = this.getConfig();
|
||||||
|
config.addDefault("leatherRepair", 6);
|
||||||
|
config.addDefault("goldRepair", 5);
|
||||||
|
config.addDefault("ironRepair", 4);
|
||||||
|
config.addDefault("diamondsRepair", 3);
|
||||||
|
config.addDefault("allowCurses", true);
|
||||||
|
config.addDefault("allowedEnchantments", new String[]{"DURABILITY","PROTECTION_FIRE","PROTECTION_EXPLOSIONS",
|
||||||
|
"PROTECTION_PROJECTILE","PROTECTION_ENVIRONMENTAL","THORNS"});
|
||||||
|
config.addDefault("usageDeniedMessage", "You do not have the required permission node for this armor tier!");
|
||||||
|
config.addDefault("elytraReceivedMessage", "An armored elytra has been bestowed upon you!");
|
||||||
saveDefaultConfig();
|
saveDefaultConfig();
|
||||||
LEATHER_TO_FULL = this.getConfig().getInt("leatherRepair", 6);
|
|
||||||
GOLD_TO_FULL = this.getConfig().getInt("goldRepair", 5);
|
LEATHER_TO_FULL = config.getInt("leatherRepair", 6);
|
||||||
IRON_TO_FULL = this.getConfig().getInt("ironRepair", 4);
|
GOLD_TO_FULL = config.getInt("goldRepair", 5);
|
||||||
DIAMONDS_TO_FULL = this.getConfig().getInt("diamondsRepair", 3);
|
IRON_TO_FULL = config.getInt("ironRepair", 4);
|
||||||
cursesAllowed = this.getConfig().getBoolean("allowCurses", true);
|
DIAMONDS_TO_FULL = config.getInt("diamondsRepair", 3);
|
||||||
List<String> list = this.getConfig().getStringList("allowedEnchantments");
|
cursesAllowed = config.getBoolean("allowCurses", true);
|
||||||
allowedEnchants = list.toArray(new String[0]);
|
List<String> list = config.getStringList("allowedEnchantments");
|
||||||
|
allowedEnchants = list.toArray(new String[0]);
|
||||||
|
usageDeniedMessage = config.getString("usageDeniedMessage");
|
||||||
|
elytraReceivedMessage = config.getString("elytraReceivedMessage");
|
||||||
|
|
||||||
|
if (Objects.equals(usageDeniedMessage, new String("NONE")))
|
||||||
|
{
|
||||||
|
usageDeniedMessage = null;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (Objects.equals(elytraReceivedMessage, new String("NONE")))
|
||||||
|
{
|
||||||
|
elytraReceivedMessage = null;
|
||||||
|
}
|
||||||
|
|
||||||
|
config.options().copyDefaults(true);
|
||||||
|
saveConfig();
|
||||||
|
|
||||||
Bukkit.getLogger().log(Level.INFO, "["+this.getName()+"] "+"Allowed enchantments:");
|
Bukkit.getLogger().log(Level.INFO, "["+this.getName()+"] "+"Allowed enchantments:");
|
||||||
for (String s : allowedEnchants)
|
for (String s : allowedEnchants)
|
||||||
@ -46,7 +76,7 @@ public class ArmoredElytra extends JavaPlugin implements Listener
|
|||||||
|
|
||||||
if (compatibleMCVer())
|
if (compatibleMCVer())
|
||||||
{
|
{
|
||||||
Bukkit.getPluginManager().registerEvents(new EventHandlers(this, nbtEditor, cursesAllowed, LEATHER_TO_FULL, GOLD_TO_FULL, IRON_TO_FULL, DIAMONDS_TO_FULL, allowedEnchants), this);
|
Bukkit.getPluginManager().registerEvents(new EventHandlers(this, nbtEditor, cursesAllowed, LEATHER_TO_FULL, GOLD_TO_FULL, IRON_TO_FULL, DIAMONDS_TO_FULL, allowedEnchants, usageDeniedMessage), this);
|
||||||
} else {
|
} else {
|
||||||
Bukkit.getLogger().log(Level.WARNING, "Trying to load the plugin on an incompatible version of Minecraft!");
|
Bukkit.getLogger().log(Level.WARNING, "Trying to load the plugin on an incompatible version of Minecraft!");
|
||||||
}
|
}
|
||||||
@ -55,22 +85,26 @@ public class ArmoredElytra extends JavaPlugin implements Listener
|
|||||||
@Override
|
@Override
|
||||||
public boolean onCommand(CommandSender sender, Command cmd, String label, String[] args)
|
public boolean onCommand(CommandSender sender, Command cmd, String label, String[] args)
|
||||||
{
|
{
|
||||||
|
Player player;
|
||||||
|
|
||||||
if (sender instanceof Player)
|
if (sender instanceof Player)
|
||||||
{
|
{
|
||||||
Player player = (Player) sender;
|
player = (Player) sender;
|
||||||
if (cmd.getName().equalsIgnoreCase("ArmoredElytra"))
|
if (cmd.getName().equalsIgnoreCase("ArmoredElytra"))
|
||||||
{
|
{
|
||||||
if (args.length == 1)
|
if (args.length == 1)
|
||||||
{
|
{
|
||||||
ItemStack newElytra = null;
|
ItemStack newElytra = null;
|
||||||
|
|
||||||
String tier = args[0];
|
String tier = args[0];
|
||||||
// Leather armor.
|
// Leather armor.
|
||||||
if (tier.equalsIgnoreCase("leather"))
|
if (tier.equalsIgnoreCase("leather"))
|
||||||
{
|
{
|
||||||
if (player.hasPermission("armoredelytra.give.leather"))
|
if (player.hasPermission("armoredelytra.give.leather"))
|
||||||
{
|
{
|
||||||
player.sendMessage("Giving you an armored elytra of the leather armor tier!");
|
if (elytraReceivedMessage != null)
|
||||||
|
{
|
||||||
|
player.sendMessage(elytraReceivedMessage);
|
||||||
|
}
|
||||||
newElytra = nbtEditor.addArmorNBTTags(new ItemStack(Material.ELYTRA, 1), 1);
|
newElytra = nbtEditor.addArmorNBTTags(new ItemStack(Material.ELYTRA, 1), 1);
|
||||||
} else
|
} else
|
||||||
{
|
{
|
||||||
@ -82,7 +116,10 @@ public class ArmoredElytra extends JavaPlugin implements Listener
|
|||||||
{
|
{
|
||||||
if (player.hasPermission("armoredelytra.give.gold"))
|
if (player.hasPermission("armoredelytra.give.gold"))
|
||||||
{
|
{
|
||||||
player.sendMessage("Giving you an armored elytra of the gold armor tier!");
|
if (elytraReceivedMessage != null)
|
||||||
|
{
|
||||||
|
player.sendMessage(elytraReceivedMessage);
|
||||||
|
}
|
||||||
newElytra = nbtEditor.addArmorNBTTags(new ItemStack(Material.ELYTRA, 1), 2);
|
newElytra = nbtEditor.addArmorNBTTags(new ItemStack(Material.ELYTRA, 1), 2);
|
||||||
} else
|
} else
|
||||||
{
|
{
|
||||||
@ -94,7 +131,10 @@ public class ArmoredElytra extends JavaPlugin implements Listener
|
|||||||
{
|
{
|
||||||
if (player.hasPermission("armoredelytra.give.chain"))
|
if (player.hasPermission("armoredelytra.give.chain"))
|
||||||
{
|
{
|
||||||
player.sendMessage("Giving you an armored elytra of the chain armor tier!");
|
if (elytraReceivedMessage != null)
|
||||||
|
{
|
||||||
|
player.sendMessage(elytraReceivedMessage);
|
||||||
|
}
|
||||||
newElytra = nbtEditor.addArmorNBTTags(new ItemStack(Material.ELYTRA, 1), 3);
|
newElytra = nbtEditor.addArmorNBTTags(new ItemStack(Material.ELYTRA, 1), 3);
|
||||||
} else
|
} else
|
||||||
{
|
{
|
||||||
@ -106,7 +146,10 @@ public class ArmoredElytra extends JavaPlugin implements Listener
|
|||||||
{
|
{
|
||||||
if (player.hasPermission("armoredelytra.give.iron"))
|
if (player.hasPermission("armoredelytra.give.iron"))
|
||||||
{
|
{
|
||||||
player.sendMessage("Giving you an armored elytra of the iron armor tier!");
|
if (elytraReceivedMessage != null)
|
||||||
|
{
|
||||||
|
player.sendMessage(elytraReceivedMessage);
|
||||||
|
}
|
||||||
newElytra = nbtEditor.addArmorNBTTags(new ItemStack(Material.ELYTRA, 1), 4);
|
newElytra = nbtEditor.addArmorNBTTags(new ItemStack(Material.ELYTRA, 1), 4);
|
||||||
} else
|
} else
|
||||||
{
|
{
|
||||||
@ -118,7 +161,10 @@ public class ArmoredElytra extends JavaPlugin implements Listener
|
|||||||
{
|
{
|
||||||
if (player.hasPermission("armoredelytra.give.diamond"))
|
if (player.hasPermission("armoredelytra.give.diamond"))
|
||||||
{
|
{
|
||||||
player.sendMessage("Giving you an armored elytra of the diamond armor tier!");
|
if (elytraReceivedMessage != null)
|
||||||
|
{
|
||||||
|
player.sendMessage(elytraReceivedMessage);
|
||||||
|
}
|
||||||
newElytra = nbtEditor.addArmorNBTTags(new ItemStack(Material.ELYTRA, 1), 5);
|
newElytra = nbtEditor.addArmorNBTTags(new ItemStack(Material.ELYTRA, 1), 5);
|
||||||
} else
|
} else
|
||||||
{
|
{
|
||||||
@ -133,6 +179,70 @@ public class ArmoredElytra extends JavaPlugin implements Listener
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
} else
|
||||||
|
{
|
||||||
|
if (args.length == 2)
|
||||||
|
{
|
||||||
|
ItemStack newElytra = null;
|
||||||
|
String tier = args[1];
|
||||||
|
if (Bukkit.getPlayer(args[0]) != null)
|
||||||
|
{
|
||||||
|
player = Bukkit.getPlayer(args[0]);
|
||||||
|
|
||||||
|
// Leather armor tier.
|
||||||
|
if (tier.equalsIgnoreCase("leather"))
|
||||||
|
{
|
||||||
|
if (elytraReceivedMessage != null)
|
||||||
|
{
|
||||||
|
player.sendMessage(elytraReceivedMessage);
|
||||||
|
}
|
||||||
|
Bukkit.getLogger().log(Level.INFO, "Giving an armored elytra of the leather armor tier to player "+player.getName());
|
||||||
|
newElytra = nbtEditor.addArmorNBTTags(new ItemStack(Material.ELYTRA, 1), 1);
|
||||||
|
// Gold armor tier.
|
||||||
|
} else if (tier.equalsIgnoreCase("gold"))
|
||||||
|
{
|
||||||
|
if (elytraReceivedMessage != null)
|
||||||
|
{
|
||||||
|
player.sendMessage(elytraReceivedMessage);
|
||||||
|
}
|
||||||
|
Bukkit.getLogger().log(Level.INFO, "Giving an armored elytra of the gold armor tier to player "+player.getName());
|
||||||
|
newElytra = nbtEditor.addArmorNBTTags(new ItemStack(Material.ELYTRA, 1), 2);
|
||||||
|
// Chain armor tier.
|
||||||
|
} else if (tier.equalsIgnoreCase("chain"))
|
||||||
|
{
|
||||||
|
if (elytraReceivedMessage != null)
|
||||||
|
{
|
||||||
|
player.sendMessage(elytraReceivedMessage);
|
||||||
|
}
|
||||||
|
Bukkit.getLogger().log(Level.INFO, "Giving an armored elytra of the chain armor tier to player "+player.getName());
|
||||||
|
newElytra = nbtEditor.addArmorNBTTags(new ItemStack(Material.ELYTRA, 1), 3);
|
||||||
|
// Iron armor tier.
|
||||||
|
} else if (tier.equalsIgnoreCase("iron"))
|
||||||
|
{
|
||||||
|
if (elytraReceivedMessage != null)
|
||||||
|
{
|
||||||
|
player.sendMessage(elytraReceivedMessage);
|
||||||
|
}
|
||||||
|
Bukkit.getLogger().log(Level.INFO, "Giving an armored elytra of the iron armor tier to player "+player.getName());
|
||||||
|
newElytra = nbtEditor.addArmorNBTTags(new ItemStack(Material.ELYTRA, 1), 4);
|
||||||
|
// Diamond armor tier.
|
||||||
|
} else if (tier.equalsIgnoreCase("diamond"))
|
||||||
|
{
|
||||||
|
if (elytraReceivedMessage != null)
|
||||||
|
{
|
||||||
|
player.sendMessage(elytraReceivedMessage);
|
||||||
|
}
|
||||||
|
Bukkit.getLogger().log(Level.INFO, "Giving an armored elytra of the armor armor tier to player "+player.getName());
|
||||||
|
newElytra = nbtEditor.addArmorNBTTags(new ItemStack(Material.ELYTRA, 1), 5);
|
||||||
|
}
|
||||||
|
giveArmoredElytraToPlayer(player, newElytra);
|
||||||
|
return true;
|
||||||
|
} else
|
||||||
|
{
|
||||||
|
Bukkit.getLogger().log(Level.INFO, "Player "+args[1]+" not found!");
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
@ -33,12 +33,13 @@ public class EventHandlers implements Listener
|
|||||||
private boolean cursesAllowed;
|
private boolean cursesAllowed;
|
||||||
private NBTEditor nbtEditor;
|
private NBTEditor nbtEditor;
|
||||||
private final ArmoredElytra plugin;
|
private final ArmoredElytra plugin;
|
||||||
|
private String usageDeniedMessage;
|
||||||
private String[] allowedEnchantments;
|
private String[] allowedEnchantments;
|
||||||
private String[] cursedEnchantments = {"MENDING",
|
private String[] cursedEnchantments = {"MENDING",
|
||||||
"VANISHING_CURSE",
|
"VANISHING_CURSE",
|
||||||
"BINDING_CURSE"};
|
"BINDING_CURSE"};
|
||||||
|
|
||||||
public EventHandlers(ArmoredElytra plugin, NBTEditor nbtEditor, boolean allowCurses, int LEATHER_TO_FULL, int GOLD_TO_FULL, int IRON_TO_FULL, int DIAMONDS_TO_FULL, String[] allowedEnchantments)
|
public EventHandlers(ArmoredElytra plugin, NBTEditor nbtEditor, boolean allowCurses, int LEATHER_TO_FULL, int GOLD_TO_FULL, int IRON_TO_FULL, int DIAMONDS_TO_FULL, String[] allowedEnchantments, String usageDeniedMessage)
|
||||||
{
|
{
|
||||||
this.plugin = plugin;
|
this.plugin = plugin;
|
||||||
this.nbtEditor = nbtEditor;
|
this.nbtEditor = nbtEditor;
|
||||||
@ -48,6 +49,7 @@ public class EventHandlers implements Listener
|
|||||||
this.LEATHER_TO_FULL = LEATHER_TO_FULL;
|
this.LEATHER_TO_FULL = LEATHER_TO_FULL;
|
||||||
this.GOLD_TO_FULL = GOLD_TO_FULL;
|
this.GOLD_TO_FULL = GOLD_TO_FULL;
|
||||||
this.IRON_TO_FULL = IRON_TO_FULL;
|
this.IRON_TO_FULL = IRON_TO_FULL;
|
||||||
|
this.usageDeniedMessage = usageDeniedMessage;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -425,7 +427,10 @@ public class EventHandlers implements Listener
|
|||||||
(armorTier == 4 && !player.hasPermission("armoredelytra.wear.iron")) ||
|
(armorTier == 4 && !player.hasPermission("armoredelytra.wear.iron")) ||
|
||||||
(armorTier == 5 && !player.hasPermission("armoredelytra.wear.diamond")))
|
(armorTier == 5 && !player.hasPermission("armoredelytra.wear.diamond")))
|
||||||
{
|
{
|
||||||
player.sendMessage(ChatColor.RED + "You do not have the required permission to wear this armor tier!.");
|
if (usageDeniedMessage != null)
|
||||||
|
{
|
||||||
|
player.sendMessage(ChatColor.RED + usageDeniedMessage);
|
||||||
|
}
|
||||||
event.setCancelled(true);
|
event.setCancelled(true);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -463,7 +468,10 @@ public class EventHandlers implements Listener
|
|||||||
(armorTier == 4 && !player.hasPermission("armoredelytra.wear.iron")) ||
|
(armorTier == 4 && !player.hasPermission("armoredelytra.wear.iron")) ||
|
||||||
(armorTier == 5 && !player.hasPermission("armoredelytra.wear.diamond")))
|
(armorTier == 5 && !player.hasPermission("armoredelytra.wear.diamond")))
|
||||||
{
|
{
|
||||||
player.sendMessage(ChatColor.RED + "You do not have the required permission to wear this armor tier!.");
|
if (usageDeniedMessage != null)
|
||||||
|
{
|
||||||
|
player.sendMessage(ChatColor.RED + usageDeniedMessage);
|
||||||
|
}
|
||||||
unenquipChestPlayer(player);
|
unenquipChestPlayer(player);
|
||||||
}
|
}
|
||||||
player.updateInventory();
|
player.updateInventory();
|
||||||
|
@ -16,5 +16,10 @@ allowedEnchantments:
|
|||||||
- PROTECTION_EXPLOSIONS
|
- PROTECTION_EXPLOSIONS
|
||||||
- PROTECTION_PROJECTILE
|
- PROTECTION_PROJECTILE
|
||||||
- PROTECTION_ENVIRONMENTAL
|
- PROTECTION_ENVIRONMENTAL
|
||||||
- DIAMOND_ARMOR_ITEMS
|
|
||||||
- THORNS
|
- THORNS
|
||||||
|
|
||||||
|
# Message players receive when they lack the required permissions to wear a certain armor tier. "NONE" = no message
|
||||||
|
usageDeniedMessage: "You do not have the required permission node for this armor tier!"
|
||||||
|
|
||||||
|
# Message players receive when they are given an armored elytra using commands. "NONE" = no message
|
||||||
|
elytraReceivedMessage: "An armored elytra has been bestowed upon you!"
|
@ -1,6 +1,6 @@
|
|||||||
name: ArmoredElytra
|
name: ArmoredElytra
|
||||||
main: nl.pim16aap2.armoredElytra.ArmoredElytra
|
main: nl.pim16aap2.armoredElytra.ArmoredElytra
|
||||||
version: 1.4.0
|
version: 1.5.0
|
||||||
author: Pim
|
author: Pim
|
||||||
commands:
|
commands:
|
||||||
ArmoredElytra:
|
ArmoredElytra:
|
||||||
|
Loading…
x
Reference in New Issue
Block a user