Different classes

Discussion in 'Plugin Development' started by CheeseNips, Dec 26, 2015.

Thread Status:
Not open for further replies.
  1. Offline


    how would i make this into a different class so i can have a Healing and a Power lores with different effects in different classes heres my code

    package xyz.cheesenips;
    import java.util.HashMap;
    import java.util.List;
    import java.util.Map;
    import java.util.UUID;
    import org.bukkit.Bukkit;
    import org.bukkit.entity.Player;
    import org.bukkit.event.EventHandler;
    import org.bukkit.event.Listener;
    import org.bukkit.event.player.PlayerJoinEvent;
    import org.bukkit.event.player.PlayerQuitEvent;
    import org.bukkit.inventory.ItemStack;
    import org.bukkit.inventory.PlayerInventory;
    import org.bukkit.plugin.java.JavaPlugin;
    import org.bukkit.potion.PotionEffect;
    import org.bukkit.potion.PotionEffectType;
    public class Main extends JavaPlugin implements Listener {
        public Map<UUID, Integer> tasks = new HashMap<UUID, Integer>();
        public void onLogin(final PlayerJoinEvent e) {
            int task = Bukkit.getScheduler().scheduleSyncRepeatingTask(this, new Runnable() {
                public void run() {
                    PlayerInventory inv = e.getPlayer().getInventory();
                    if (inv.getChestplate() != null && isHealingChestPlate(inv.getChestplate())) {
                        Player p = e.getPlayer();
                        p.addPotionEffect(new PotionEffect(PotionEffectType.REGENERATION, 2, 1), true);
            }, 20L, 20L);
            tasks.put(e.getPlayer().getUniqueId(), task);
        private boolean isHealingChestPlate(ItemStack item) {
            if (!item.hasItemMeta()) {
                return false;
            List<String> lore = item.getItemMeta().getLore();
            return (lore != null && lore.size() > 0 && lore.get(0).equals("Healing"));
        public void onLogin(PlayerQuitEvent e) {
        public void onEnable() {
            getServer().getPluginManager().registerEvents(this, this);
  2. Offline


    Why, oh Why?
    Zombie_Striker likes this.
  3. Offline


    This is not long enough to worry abboit classes.
  4. Offline


    And? Whats your problem? You want guidance on how to move those events? Can't you just move the the methods into another class and register it?
  5. Offline


Thread Status:
Not open for further replies.

Share This Page