Guest User

Drug.java

a guest
Dec 30th, 2012
44
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 1.33 KB | None | 0 0
  1. package com.gmail.lopezitospriter.Weed;
  2.  
  3. import java.util.Collection;
  4. import java.util.HashSet;
  5.  
  6. import org.bukkit.Bukkit;
  7. import org.bukkit.entity.LivingEntity;
  8. import org.bukkit.event.Event;
  9.  
  10. public class Drug {
  11.     private Activation activation;
  12.     private String[] args;
  13.     private HashSet<WEffect> effects;
  14.  
  15.     public Drug(Activation activation, String[] args, HashSet<WEffect> effects) {
  16.         setActivation(activation);
  17.         setArgs(args);
  18.         setEffects(effects);
  19.     }
  20.  
  21.     public Activation getActivation() {
  22.         return activation;
  23.     }
  24.  
  25.     public void setActivation(Activation activation) {
  26.         this.activation = activation;
  27.     }
  28.  
  29.     public String[] getArgs() {
  30.         return args;
  31.     }
  32.  
  33.     public void setArgs(String[] args) {
  34.         this.args = args;
  35.     }
  36.  
  37.     public HashSet<WEffect> getEffects() {
  38.         return effects;
  39.     }
  40.  
  41.     public void setEffects(HashSet<WEffect> effects) {
  42.         this.effects = effects;
  43.     }
  44.  
  45.     public void activate(Event event) {
  46.         Collection<LivingEntity> c = activation.activate(event, args);
  47.  
  48.         if (c != null)
  49.             for (final LivingEntity e : c)
  50.                 for (final WEffect effect : effects)
  51.                     Bukkit.getScheduler().scheduleSyncDelayedTask(Weed.plugin,
  52.                             new Runnable() {
  53.                                 @Override
  54.                                 public void run() {
  55.                                     if (e != null && !e.isDead())
  56.                                         effect.apply(e);
  57.                                 }
  58.                             }, effect.getDelay() * 20);
  59.     }
  60. }
Advertisement
Add Comment
Please, Sign In to add comment