Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- package mc.Bancey.PT;
- import java.io.IOException;
- import java.util.ArrayList;
- import java.util.logging.Logger;
- import org.bukkit.Bukkit;
- import org.bukkit.ChatColor;
- import org.bukkit.command.Command;
- import org.bukkit.command.CommandSender;
- import org.bukkit.entity.Player;
- import org.bukkit.inventory.PlayerInventory;
- import org.bukkit.plugin.PluginDescriptionFile;
- import org.bukkit.plugin.java.JavaPlugin;
- import org.bukkit.potion.PotionEffect;
- import org.bukkit.potion.PotionEffectType;
- public class PTMain extends JavaPlugin {
- public final Logger logger = Logger.getLogger("Minecraft");
- public static PTMain plugin;
- public void onEnable() {
- try {
- Metrics metrics = new Metrics(this);
- metrics.start();
- } catch (IOException e) {
- // Failed to submit the stats :-(
- }
- // get Lore Checking from config
- final ArrayList<String> Lore1 = (ArrayList<String>) this.getConfig().getStringList("Preset1Lore");
- final ArrayList<String> Lore2 = (ArrayList<String>) this.getConfig().getStringList("Preset2Lore");
- final ArrayList<String> Lore3 = (ArrayList<String>) this.getConfig().getStringList("Preset3Lore");
- final ArrayList<String> Lore4 = (ArrayList<String>) this.getConfig().getStringList("Preset4Lore");
- final ArrayList<String> Lore5 = (ArrayList<String>) this.getConfig().getStringList("Preset5Lore");
- final ArrayList<String> Lore6 = (ArrayList<String>) this.getConfig().getStringList("Preset6Lore");
- // get Item Id's from config.
- final int Preset1 = this.getConfig().getInt("Preset1-Item-ID");
- final int Preset2 = this.getConfig().getInt("Preset2-Item-ID");
- final int Preset3 = this.getConfig().getInt("Preset3-Item-ID");
- final int Preset4 = this.getConfig().getInt("Preset4-Item-ID");
- final int Preset5 = this.getConfig().getInt("Preset5-Item-ID");
- final int Preset6 = this.getConfig().getInt("Preset6-Item-ID");
- // get the potion effects from the config.
- final String Preset1PE1 = this.getConfig().getString("Preset1-PotionEffect-1");
- final String Preset1PE2 = this.getConfig().getString("Preset1-PotionEffect-2");
- final String Preset1PE3 = this.getConfig().getString("Preset1-PotionEffect-3");
- final String Preset1PE4 = this.getConfig().getString("Preset1-PotionEffect-4");
- final String Preset1PE5 = this.getConfig().getString("Preset1-PotionEffect-5");
- final String Preset2PE1 = this.getConfig().getString("Preset2-PotionEffect-1");
- final String Preset2PE2 = this.getConfig().getString("Preset2-PotionEffect-2");
- final String Preset2PE3 = this.getConfig().getString("Preset2-PotionEffect-3");
- final String Preset2PE4 = this.getConfig().getString("Preset2-PotionEffect-4");
- final String Preset2PE5 = this.getConfig().getString("Preset2-PotionEffect-5");
- final String Preset3PE1 = this.getConfig().getString("Preset3-PotionEffect-1");
- final String Preset3PE2 = this.getConfig().getString("Preset3-PotionEffect-2");
- final String Preset3PE3 = this.getConfig().getString("Preset3-PotionEffect-3");
- final String Preset3PE4 = this.getConfig().getString("Preset3-PotionEffect-4");
- final String Preset3PE5 = this.getConfig().getString("Preset3-PotionEffect-5");
- final String Preset4PE1 = this.getConfig().getString("Preset4-PotionEffect-1");
- final String Preset4PE2 = this.getConfig().getString("Preset4-PotionEffect-2");
- final String Preset4PE3 = this.getConfig().getString("Preset4-PotionEffect-3");
- final String Preset4PE4 = this.getConfig().getString("Preset4-PotionEffect-4");
- final String Preset4PE5 = this.getConfig().getString("Preset4-PotionEffect-5");
- final String Preset5PE1 = this.getConfig().getString("Preset5-PotionEffect-1");
- final String Preset5PE2 = this.getConfig().getString("Preset5-PotionEffect-2");
- final String Preset5PE3 = this.getConfig().getString("Preset5-PotionEffect-3");
- final String Preset5PE4 = this.getConfig().getString("Preset5-PotionEffect-4");
- final String Preset5PE5 = this.getConfig().getString("Preset5-PotionEffect-5");
- final String Preset6PE1 = this.getConfig().getString("Preset6-PotionEffect-1");
- final String Preset6PE2 = this.getConfig().getString("Preset6-PotionEffect-2");
- final String Preset6PE3 = this.getConfig().getString("Preset6-PotionEffect-3");
- final String Preset6PE4 = this.getConfig().getString("Preset6-PotionEffect-4");
- final String Preset6PE5 = this.getConfig().getString("Preset6-PotionEffect-5");
- // get the potencey from the config.
- final int Preset1Potencey = this.getConfig().getInt("Preset1-PotionPotencey");
- final int Preset2Potencey = this.getConfig().getInt("Preset2-PotionPotencey");
- final int Preset3Potencey = this.getConfig().getInt("Preset3-PotionPotencey");
- final int Preset4Potencey = this.getConfig().getInt("Preset4-PotionPotencey");
- final int Preset5Potencey = this.getConfig().getInt("Preset5-PotionPotencey");
- final int Preset6Potencey = this.getConfig().getInt("Preset6-PotionPotencey");
- PluginDescriptionFile pdfFile = this.getDescription();
- this.logger.info(pdfFile.getName() + " Version " + pdfFile.getVersion() + " By Bancey, Has Been Enabled!");
- saveDefaultConfig();
- getServer().getPluginManager().registerEvents(new PlayerInventoryListener(this), this);
- Bukkit.getServer().getScheduler().scheduleSyncRepeatingTask(this, new Runnable() {
- public void run() {
- for (Player online : Bukkit.getOnlinePlayers()) {
- PlayerInventory inv = online.getInventory();
- Player player = online.getPlayer();
- if (player.hasPermission("PT.getpotion")) {
- // if the player has the permission. Apply the potion effects.
- if ((inv.getItemInHand().getTypeId() == Preset1) && (inv.getItemInHand().getItemMeta().getLore().equals(Lore1))) {
- player.addPotionEffect(new PotionEffect(PotionEffectType.getByName(Preset1PE1),Integer.MAX_VALUE, Preset1Potencey));
- player.addPotionEffect(new PotionEffect(PotionEffectType.getByName(Preset1PE2),Integer.MAX_VALUE, Preset1Potencey));
- player.addPotionEffect(new PotionEffect(PotionEffectType.getByName(Preset1PE3),Integer.MAX_VALUE, Preset1Potencey));
- player.addPotionEffect(new PotionEffect(PotionEffectType.getByName(Preset1PE4),Integer.MAX_VALUE, Preset1Potencey));
- player.addPotionEffect(new PotionEffect(PotionEffectType.getByName(Preset1PE5),Integer.MAX_VALUE, Preset1Potencey));
- } else if ((inv.getItemInHand().getTypeId() == Preset2) && (inv.getItemInHand().getItemMeta().getLore().equals(Lore2))) {
- player.addPotionEffect(new PotionEffect(PotionEffectType.getByName(Preset2PE1),Integer.MAX_VALUE, Preset2Potencey));
- player.addPotionEffect(new PotionEffect(PotionEffectType.getByName(Preset2PE2),Integer.MAX_VALUE, Preset2Potencey));
- player.addPotionEffect(new PotionEffect(PotionEffectType.getByName(Preset2PE3),Integer.MAX_VALUE, Preset2Potencey));
- player.addPotionEffect(new PotionEffect(PotionEffectType.getByName(Preset2PE4),Integer.MAX_VALUE, Preset2Potencey));
- player.addPotionEffect(new PotionEffect(PotionEffectType.getByName(Preset2PE5),Integer.MAX_VALUE, Preset2Potencey));
- } else if ((inv.getItemInHand().getTypeId() == Preset3) && (inv.getItemInHand().getItemMeta().getLore().equals(Lore3))) {
- player.addPotionEffect(new PotionEffect(PotionEffectType.getByName(Preset3PE1),Integer.MAX_VALUE, Preset3Potencey));
- player.addPotionEffect(new PotionEffect(PotionEffectType.getByName(Preset3PE2),Integer.MAX_VALUE, Preset3Potencey));
- player.addPotionEffect(new PotionEffect(PotionEffectType.getByName(Preset3PE3),Integer.MAX_VALUE, Preset3Potencey));
- player.addPotionEffect(new PotionEffect(PotionEffectType.getByName(Preset3PE4),Integer.MAX_VALUE, Preset3Potencey));
- player.addPotionEffect(new PotionEffect(PotionEffectType.getByName(Preset3PE5),Integer.MAX_VALUE, Preset3Potencey));
- } else if ((inv.getItemInHand().getTypeId() == Preset4) && (inv.getItemInHand().getItemMeta().getLore().equals(Lore4))) {
- player.addPotionEffect(new PotionEffect(PotionEffectType.getByName(Preset4PE1),Integer.MAX_VALUE, Preset4Potencey));
- player.addPotionEffect(new PotionEffect(PotionEffectType.getByName(Preset4PE2),Integer.MAX_VALUE, Preset4Potencey));
- player.addPotionEffect(new PotionEffect(PotionEffectType.getByName(Preset4PE3),Integer.MAX_VALUE, Preset4Potencey));
- player.addPotionEffect(new PotionEffect(PotionEffectType.getByName(Preset4PE4),Integer.MAX_VALUE, Preset4Potencey));
- player.addPotionEffect(new PotionEffect(PotionEffectType.getByName(Preset4PE5),Integer.MAX_VALUE, Preset4Potencey));
- } else if ((inv.getItemInHand().getTypeId() == Preset5) && (inv.getItemInHand().getItemMeta().getLore().equals(Lore5))) {
- player.addPotionEffect(new PotionEffect(PotionEffectType.getByName(Preset5PE1),Integer.MAX_VALUE, Preset5Potencey));
- player.addPotionEffect(new PotionEffect(PotionEffectType.getByName(Preset5PE2),Integer.MAX_VALUE, Preset5Potencey));
- player.addPotionEffect(new PotionEffect(PotionEffectType.getByName(Preset5PE3),Integer.MAX_VALUE, Preset5Potencey));
- player.addPotionEffect(new PotionEffect(PotionEffectType.getByName(Preset5PE4),Integer.MAX_VALUE, Preset5Potencey));
- player.addPotionEffect(new PotionEffect(PotionEffectType.getByName(Preset5PE5),Integer.MAX_VALUE, Preset5Potencey));
- } else if ((inv.getItemInHand().getTypeId() == Preset6) && (inv.getItemInHand().getItemMeta().getLore().equals(Lore6))) {
- player.addPotionEffect(new PotionEffect(PotionEffectType.getByName(Preset6PE1),Integer.MAX_VALUE, Preset6Potencey));
- player.addPotionEffect(new PotionEffect(PotionEffectType.getByName(Preset6PE2),Integer.MAX_VALUE, Preset6Potencey));
- player.addPotionEffect(new PotionEffect(PotionEffectType.getByName(Preset6PE3),Integer.MAX_VALUE, Preset6Potencey));
- player.addPotionEffect(new PotionEffect(PotionEffectType.getByName(Preset6PE4),Integer.MAX_VALUE, Preset6Potencey));
- player.addPotionEffect(new PotionEffect(PotionEffectType.getByName(Preset6PE5),Integer.MAX_VALUE, Preset6Potencey));
- }
- }
- }
- }
- }, 20, 40);
- }
- public void onDisable() {
- PluginDescriptionFile pdfFile = this.getDescription();
- this.logger.info(pdfFile.getName() + " Version " + pdfFile.getVersion() + " By Bancey, Has Been Disabled!");
- }
- public boolean onCommand(CommandSender sender, Command cmd,String commandLabel, String[] args) {
- Player p = (Player) sender;
- if (p instanceof Player) {
- if(commandLabel.equalsIgnoreCase("checkpermissions")) {
- if (!(p.hasPermission("PT.getPotion"))) {
- p.sendMessage(ChatColor.DARK_AQUA + "You do not have permission to use ItemPotion by Bancey");
- } else
- p.sendMessage(ChatColor.DARK_AQUA + "You do have permission to use ItemPotion by Bancey");
- }
- }
- return false;
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement