Halloween gizmo fixes (#53)
* fixes mounting issue and reduce volume * don't destroy elytra * more fixes
This commit is contained in:
parent
7b32649e69
commit
4f095f5566
|
@ -2,10 +2,13 @@ package tc.oc.lobby.bukkit.gizmos.halloween;
|
|||
|
||||
import com.google.common.collect.ImmutableList;
|
||||
import org.bukkit.Location;
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.entity.AbstractHorse;
|
||||
import org.bukkit.entity.Horse;
|
||||
import org.bukkit.entity.LivingEntity;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.inventory.EntityEquipment;
|
||||
import org.bukkit.inventory.ItemStack;
|
||||
import tc.oc.commons.core.util.Optionals;
|
||||
|
||||
/**
|
||||
|
@ -24,16 +27,19 @@ public class HeadlessHorse {
|
|||
protected AbstractHorse spawn(Location location, Class<AbstractHorse> horse) {
|
||||
AbstractHorse entity = viewer.getWorld().spawn(location, horse);
|
||||
this.horse = entity;
|
||||
Optionals.cast(horse, LivingEntity.class).ifPresent(living -> {
|
||||
Optionals.cast(horse, Horse.class).ifPresent(living -> {
|
||||
living.setRemoveWhenFarAway(true);
|
||||
living.setCollidable(false);
|
||||
living.setCanPickupItems(false);
|
||||
living.setInvulnerable(true);
|
||||
living.setAdult();
|
||||
EntityEquipment entityEquipment = living.getEquipment();
|
||||
entityEquipment.setHelmetDropChance(0);
|
||||
entityEquipment.setChestplateDropChance(0);
|
||||
entityEquipment.setLeggingsDropChance(0);
|
||||
entityEquipment.setBootsDropChance(0);
|
||||
entity.setTamed(true);
|
||||
living.getInventory().setSaddle(new ItemStack(Material.SADDLE));
|
||||
living.setPassengers(ImmutableList.of(viewer));
|
||||
});
|
||||
return entity;
|
||||
|
|
|
@ -35,7 +35,7 @@ public class HeadlessHorseman {
|
|||
private void mutate() {
|
||||
headlessHorse.spawn(viewer.getLocation(), (Class<AbstractHorse>) HORSE_TYPE.getEntityClass());
|
||||
ARMOR_MAP.forEach(this::colorAndEquip);
|
||||
viewer.playSound(viewer.getLocation(), Sound.ENTITY_SKELETON_HORSE_DEATH, 1.5f, 1.5f);
|
||||
viewer.playSound(viewer.getLocation(), Sound.ENTITY_SKELETON_HORSE_DEATH, 1.25f, 1.25f);
|
||||
}
|
||||
|
||||
private void colorAndEquip(Slot slot, ItemStack item) {
|
||||
|
@ -51,6 +51,7 @@ public class HeadlessHorseman {
|
|||
public void restore() {
|
||||
headlessHorse.despawn();
|
||||
viewer.getInventory().armor().clear();
|
||||
viewer.getInventory().setChestplate(new ItemStack(Material.ELYTRA));
|
||||
viewer.playSound(viewer.getLocation(), Sound.ENTITY_ZOMBIE_VILLAGER_CURE, 1f, 1f);
|
||||
}
|
||||
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
package tc.oc.lobby.bukkit.gizmos.halloween;
|
||||
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
import java.util.WeakHashMap;
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.Effect;
|
||||
import org.bukkit.Location;
|
||||
|
@ -9,9 +9,7 @@ import org.bukkit.Material;
|
|||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.event.EventHandler;
|
||||
import org.bukkit.event.Listener;
|
||||
import org.bukkit.event.block.Action;
|
||||
import org.bukkit.event.player.PlayerInteractEvent;
|
||||
import org.bukkit.event.player.PlayerQuitEvent;
|
||||
import org.bukkit.scheduler.BukkitRunnable;
|
||||
import tc.oc.lobby.bukkit.Lobby;
|
||||
import tc.oc.lobby.bukkit.gizmos.Gizmo;
|
||||
|
@ -23,8 +21,8 @@ public class HeadlessHorsemanGizmo extends Gizmo implements Listener {
|
|||
|
||||
public HeadlessHorsemanGizmo(String name, String prefix, String description, Material icon, int cost) {
|
||||
super(name, prefix, description, icon, cost);
|
||||
this.mutated = new HashMap<>();
|
||||
this.horseByPlayer = new HashMap<>();
|
||||
this.mutated = new WeakHashMap<>();
|
||||
this.horseByPlayer = new WeakHashMap<>();
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -34,8 +32,7 @@ public class HeadlessHorsemanGizmo extends Gizmo implements Listener {
|
|||
|
||||
@EventHandler(ignoreCancelled = true)
|
||||
public void onPlayerInteract(PlayerInteractEvent e) {
|
||||
if(e.getAction() == Action.PHYSICAL
|
||||
|| !(Gizmos.gizmoMap.get(e.getPlayer()) instanceof HeadlessHorsemanGizmo)
|
||||
if(!(Gizmos.gizmoMap.get(e.getPlayer()) instanceof HeadlessHorsemanGizmo)
|
||||
|| e.getItem() == null || e.getItem().getType() != this.getIcon()) return;
|
||||
|
||||
final Player player = e.getPlayer();
|
||||
|
@ -51,14 +48,6 @@ public class HeadlessHorsemanGizmo extends Gizmo implements Listener {
|
|||
}
|
||||
}
|
||||
|
||||
@EventHandler
|
||||
public void onPlayerLeave(PlayerQuitEvent e) {
|
||||
Player player = e.getPlayer();
|
||||
mutated.remove(player);
|
||||
horseByPlayer.get(player).despawn();
|
||||
horseByPlayer.remove(player);
|
||||
}
|
||||
|
||||
private void createEffect(Player viewer) {
|
||||
new BukkitRunnable() {
|
||||
@Override
|
||||
|
|
Loading…
Reference in New Issue