listeners only listen for their own parties
This commit is contained in:
parent
12cbf80d55
commit
d8fe7b480d
@ -460,7 +460,7 @@ public class DiscoParty {
|
||||
this.scheduleUpdate();
|
||||
parent.getPartyMap().put(this.player.getName(), this);
|
||||
// start listening
|
||||
this.partyEvents = new PartyEvents(this.parent);
|
||||
this.partyEvents = new PartyEvents(this.parent, this);
|
||||
parent.getServer().getPluginManager().registerEvents(this.partyEvents, this.parent);
|
||||
}
|
||||
|
||||
|
@ -17,54 +17,54 @@ import org.bukkit.event.player.PlayerShearEntityEvent;
|
||||
public class PartyEvents implements Listener {
|
||||
|
||||
DiscoSheep parent;
|
||||
DiscoParty party;
|
||||
|
||||
public PartyEvents(DiscoSheep parent) {
|
||||
public PartyEvents(DiscoSheep parent, DiscoParty party) {
|
||||
this.parent = parent;
|
||||
this.party = party;
|
||||
}
|
||||
|
||||
// prevent sheep shearing
|
||||
@EventHandler (priority = EventPriority.HIGHEST, ignoreCancelled = true)
|
||||
@EventHandler(priority = EventPriority.HIGHEST, ignoreCancelled = true)
|
||||
public void onPlayerShear(PlayerShearEntityEvent e) {
|
||||
if (e.getEntity() instanceof Sheep) {
|
||||
for (DiscoParty party : parent.getParties()) {
|
||||
if (party.getSheepList().contains((Sheep) e.getEntity())) {
|
||||
e.setCancelled(true);
|
||||
}
|
||||
|
||||
if (party.getSheepList().contains((Sheep) e.getEntity())) {
|
||||
e.setCancelled(true);
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
// actually make sheep and other guests invincible
|
||||
@EventHandler (priority = EventPriority.HIGHEST, ignoreCancelled = true)
|
||||
@EventHandler(priority = EventPriority.HIGHEST, ignoreCancelled = true)
|
||||
public void onLivingEntityDamageEvent(EntityDamageEvent e) {
|
||||
if (e.getEntity() instanceof Sheep) {
|
||||
for (DiscoParty party : parent.getParties()) {
|
||||
if (party.getSheepList().contains((Sheep) e.getEntity())) {
|
||||
{
|
||||
party.jump((LivingEntity) e.getEntity()); // for kicks
|
||||
e.setCancelled(true);
|
||||
}
|
||||
if (party.getSheepList().contains((Sheep) e.getEntity())) {
|
||||
{
|
||||
party.jump((LivingEntity) e.getEntity()); // for kicks
|
||||
e.setCancelled(true);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
for (DiscoParty party : parent.getParties()) {
|
||||
if (party.getGuestList().contains(e.getEntity())) {
|
||||
party.jump((LivingEntity) e.getEntity());
|
||||
e.setCancelled(true);
|
||||
}
|
||||
|
||||
if (party.getGuestList().contains(e.getEntity())) {
|
||||
party.jump((LivingEntity) e.getEntity());
|
||||
e.setCancelled(true);
|
||||
}
|
||||
|
||||
parent.getLogger().log(Level.INFO, "Debug: EVENT TRIGGERED");
|
||||
}
|
||||
|
||||
// prevent uninvited guests from targetting players
|
||||
@EventHandler (priority = EventPriority.HIGHEST, ignoreCancelled = true)
|
||||
@EventHandler(priority = EventPriority.HIGHEST, ignoreCancelled = true)
|
||||
public void onEntityTargetLivingEntityEvent(EntityTargetEvent e) {
|
||||
for (DiscoParty party : parent.getParties()) {
|
||||
if (party.getGuestList().contains(e.getEntity())) { // safe; event is only triggered by LivingEntity targetting LivingEntity
|
||||
e.setCancelled(true);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (party.getGuestList().contains(e.getEntity())) { // safe; event is only triggered by LivingEntity targetting LivingEntity
|
||||
e.setCancelled(true);
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user