Skip to content

Commit

Permalink
more cleanups and tweaks
Browse files Browse the repository at this point in the history
  • Loading branch information
mcmonkey4eva committed Jan 31, 2022
1 parent 6869399 commit 4e0a653
Show file tree
Hide file tree
Showing 7 changed files with 22 additions and 73 deletions.
Expand Up @@ -48,13 +48,13 @@ public void setRiptide(Entity entity, boolean state) {
Debug.echoError("Riptide control not available on this server version.");
}

public void setCarriedItem(Enderman entity, ItemStack item) {
entity.setCarriedMaterial(item.getData());
public int getBodyArrows(Entity entity) {
return ((LivingEntity) entity).getArrowsInBody();
}

public abstract int getBodyArrows(Entity entity);

public abstract void setBodyArrows(Entity entity, int numArrows);
public void setBodyArrows(Entity entity, int numArrows) {
((LivingEntity) entity).setArrowsInBody(numArrows);
}

public abstract double getArrowDamage(Entity arrow);

Expand Down
Expand Up @@ -11,7 +11,6 @@
import org.bukkit.Sound;

import javax.sound.midi.*;
import java.io.IOException;
import java.util.List;
import java.util.Map;

Expand All @@ -30,14 +29,14 @@ public class NoteBlockReceiver implements Receiver, MetaEventListener {
public Sequencer sequencer;
public boolean closing = false;

public NoteBlockReceiver(List<EntityTag> entities, String _Key) throws InvalidMidiDataException, IOException {
public NoteBlockReceiver(List<EntityTag> entities, String _Key) {
this.entities = entities;
this.location = null;
this.channelPatches = Maps.newHashMap();
this.key = _Key;
}

public NoteBlockReceiver(LocationTag location, String _Key) throws InvalidMidiDataException, IOException {
public NoteBlockReceiver(LocationTag location, String _Key) {
this.entities = null;
this.location = location;
this.channelPatches = Maps.newHashMap();
Expand Down Expand Up @@ -150,17 +149,22 @@ public void close() {
}
closing = true;
Bukkit.getScheduler().scheduleSyncDelayedTask(Denizen.getInstance(), () -> {
MidiUtil.receivers.remove(key);
if (sequencer != null) {
sequencer.close();
sequencer = null;
try {
MidiUtil.receivers.remove(key);
if (sequencer != null) {
sequencer.close();
sequencer = null;
}
channelPatches.clear();
channelPatches = null;
entities = null;
location = null;
if (onFinish != null) {
onFinish.run();
}
}
channelPatches.clear();
channelPatches = null;
entities = null;
location = null;
if (onFinish != null) {
onFinish.run();
catch (Throwable ex) {
Debug.echoError(ex);
}
}, 1);
}
Expand Down
Expand Up @@ -159,11 +159,6 @@ public void setArrowDamage(Entity arrow, double damage) {
((Arrow) arrow).setDamage(damage);
}

@Override
public void setCarriedItem(Enderman entity, ItemStack item) {
entity.setCarriedBlock(Bukkit.createBlockData(item.getType()));
}

@Override
public void setRiptide(Entity entity, boolean state) {
((CraftLivingEntity) entity).getHandle().q(state ? 0 : 1);
Expand Down
Expand Up @@ -158,11 +158,6 @@ public void setArrowDamage(Entity arrow, double damage) {
((Arrow) arrow).setDamage(damage);
}

@Override
public void setCarriedItem(Enderman entity, ItemStack item) {
entity.setCarriedBlock(Bukkit.createBlockData(item.getType()));
}

@Override
public void setRiptide(Entity entity, boolean state) {
((CraftLivingEntity) entity).getHandle().r(state ? 0 : 1);
Expand Down
Expand Up @@ -158,26 +158,11 @@ public void setArrowDamage(Entity arrow, double damage) {
((Arrow) arrow).setDamage(damage);
}

@Override
public void setCarriedItem(Enderman entity, ItemStack item) {
entity.setCarriedBlock(Bukkit.createBlockData(item.getType()));
}

@Override
public void setRiptide(Entity entity, boolean state) {
((CraftLivingEntity) entity).getHandle().r(state ? 0 : 1);
}

@Override
public int getBodyArrows(Entity entity) {
return ((CraftLivingEntity) entity).getHandle().getArrowCount();
}

@Override
public void setBodyArrows(Entity entity, int numArrows) {
((CraftLivingEntity) entity).getHandle().setArrowCount(numArrows);
}

@Override
public Entity getFishHook(PlayerFishEvent event) {
return event.getHook();
Expand Down
Expand Up @@ -196,26 +196,11 @@ public void setArrowDamage(Entity arrow, double damage) {
((Arrow) arrow).setDamage(damage);
}

@Override
public void setCarriedItem(Enderman entity, ItemStack item) {
entity.setCarriedBlock(Bukkit.createBlockData(item.getType()));
}

@Override
public void setRiptide(Entity entity, boolean state) {
((CraftLivingEntity) entity).getHandle().startAutoSpinAttack(state ? 0 : 1);
}

@Override
public int getBodyArrows(Entity entity) {
return ((CraftLivingEntity) entity).getHandle().getArrowCount();
}

@Override
public void setBodyArrows(Entity entity, int numArrows) {
((CraftLivingEntity) entity).getHandle().setArrowCount(numArrows);
}

@Override
public Entity getFishHook(PlayerFishEvent event) {
return event.getHook();
Expand Down
Expand Up @@ -196,26 +196,11 @@ public void setArrowDamage(Entity arrow, double damage) {
((Arrow) arrow).setDamage(damage);
}

@Override
public void setCarriedItem(Enderman entity, ItemStack item) {
entity.setCarriedBlock(Bukkit.createBlockData(item.getType()));
}

@Override
public void setRiptide(Entity entity, boolean state) {
((CraftLivingEntity) entity).getHandle().startAutoSpinAttack(state ? 0 : 1);
}

@Override
public int getBodyArrows(Entity entity) {
return ((CraftLivingEntity) entity).getHandle().getArrowCount();
}

@Override
public void setBodyArrows(Entity entity, int numArrows) {
((CraftLivingEntity) entity).getHandle().setArrowCount(numArrows);
}

@Override
public Entity getFishHook(PlayerFishEvent event) {
return event.getHook();
Expand Down

0 comments on commit 4e0a653

Please sign in to comment.