Two of my plugins are conflicting...

Discussion in 'Plugin Development' started by ib4est123, Aug 7, 2014.

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

    ib4est123

    Code:java
    1. Plugin 1
    2.  
    3. package me.ib4est123;
    4.  
    5. import org.bukkit.ChatColor;
    6. import org.bukkit.entity.Player;
    7. import org.bukkit.event.EventHandler;
    8. import org.bukkit.event.Listener;
    9. import org.bukkit.event.entity.EntityDamageByEntityEvent;
    10. import org.bukkit.event.entity.EntityDamageEvent;
    11. import org.bukkit.plugin.java.JavaPlugin;
    12. import org.bukkit.potion.PotionEffectType;
    13.  
    14. public class Main extends JavaPlugin implements Listener{
    15. @Override
    16. public void onDisable() {
    17.  
    18.  
    19. }
    20. @Override
    21. public void onEnable() {
    22. getServer().getPluginManager().registerEvents(this, this);
    23. }
    24.  
    25.  
    26. @EventHandler
    27. public void onEntityDamage(EntityDamageEvent event){
    28. if(event.getEntity() instanceof Player){
    29. if(event.getCause() == EntityDamageEvent.DamageCause.ENTITY_ATTACK){
    30. Player p = (Player) event.getEntity();
    31. p.removePotionEffect(PotionEffectType.INVISIBILITY);
    32. if(p.isFlying()){
    33. p.setFlying(false);
    34. p.setAllowFlight(false);
    35. p.sendMessage(ChatColor.RED+"Unfair abilities have been removed due to combat!"); }
    36. }
    37.  
    38. }
    39.  
    40.  
    41. }
    42. @EventHandler
    43. public void HittingOthers(EntityDamageByEntityEvent event)
    44. {
    45. if(event.getDamager() instanceof Player && event.getEntity() instanceof Player)
    46. {
    47.  
    48. Player damager = (Player) event.getDamager();
    49. damager.removePotionEffect(PotionEffectType.INVISIBILITY);
    50. if(damager.isFlying()){
    51. damager.setAllowFlight(false);
    52. damager.removePotionEffect(PotionEffectType.INVISIBILITY);
    53. damager.sendMessage(ChatColor.RED+"Unfair abilities have been removed due to combat!");
    54.  
    55. }
    56. }
    57. }
    58. }
    59.  

    Code:
    Plugin 2
     
    package me.ib4est123;
     
    import java.util.Collection;
    import java.util.Iterator;
     
    import org.bukkit.Server;
    import org.bukkit.configuration.file.FileConfiguration;
    import org.bukkit.entity.Player;
    import org.bukkit.event.EventHandler;
    import org.bukkit.event.Listener;
    import org.bukkit.event.entity.EntityDamageByEntityEvent;
    import org.bukkit.event.entity.EntityDamageEvent;
    import org.bukkit.event.entity.EntityDamageEvent.DamageCause;
    import org.bukkit.plugin.PluginManager;
    import org.bukkit.plugin.java.JavaPlugin;
    import org.bukkit.potion.PotionEffect;
    import org.bukkit.potion.PotionEffectType;
     
    public class Main
      extends JavaPlugin
      implements Listener
    {
      int percent;
     
      public void onEnable()
      {
        getServer().getPluginManager().registerEvents(this, this);
      }
     
      @EventHandler
      public void onPlayerDamage(EntityDamageByEntityEvent event)
      {
        if (event.getCause().equals(EntityDamageEvent.DamageCause.ENTITY_ATTACK)) {
          if (event.getDamager() != null) {
            if ((event.getDamager() instanceof Player))
            {
              Player player = (Player)event.getDamager();
              Iterator<PotionEffect> iterator = player.getActivePotionEffects().iterator();
              for (PotionEffect Effect : player.getActivePotionEffects()){
              while (iterator.hasNext())
              {
                PotionEffect eff = (PotionEffect)iterator.next();
                if (eff.getType().equals(PotionEffectType.INCREASE_DAMAGE)) {
                    if(Effect.getAmplifier() >= 1) {
                        int duration = Effect.getDuration();
                        player.removePotionEffect(PotionEffectType.INCREASE_DAMAGE);
                        player.addPotionEffect(new PotionEffect(PotionEffectType.INCREASE_DAMAGE, duration, 0));
                    }
                    }
               
                }
              }
              }
            }
          }
        }
    }
    
    If you can help by today that would be great... Thanks
     
  2. Offline

    RawCode

    provide unique namespace for your plugins
     
  3. Offline

    ib4est123

    I don't quite understand what you mean? Can you please explain more?
     
  4. Offline

    KaitouKidFTW

    Your packages and classes are the same on both plugins
     
  5. Offline

    ib4est123

    So... just change those?
     
  6. Offline

    ZodiacTheories

  7. Offline

    excusemyluck

    This is off topic here but I like your signature... this part exactly: "98% of statistics are made up"
     
    ZodiacTheories likes this.
  8. Offline

    ib4est123

    Umm... Its not working
     
  9. Offline

    ZodiacTheories

  10. Offline

    ib4est123

    Okay.

    I can't I don't know how to do it on CMD

    EDIT by Moderator: merged posts, please use the edit button instead of double posting.
     
    Last edited by a moderator: Jun 9, 2016
  11. ib4est123 right click select (not to sure something like marker) highlight the error then press enter and go to pastebin paste create and then post link here.
     
  12. Offline

    ib4est123

  13. Offline

    KaitouKidFTW

    ib4est123 Do you have a plugin.yml if you do can you show us please
     
  14. Offline

    ib4est123

    Okay, I fixed it
     
Thread Status:
Not open for further replies.

Share This Page