MassiveCore - 1.9 pass 1
This commit is contained in:
parent
2e019823d5
commit
5b835073e0
@ -7,6 +7,7 @@ import java.util.Set;
|
|||||||
import java.util.UUID;
|
import java.util.UUID;
|
||||||
|
|
||||||
import org.bukkit.Bukkit;
|
import org.bukkit.Bukkit;
|
||||||
|
import org.bukkit.Sound;
|
||||||
import org.bukkit.inventory.Inventory;
|
import org.bukkit.inventory.Inventory;
|
||||||
import org.bukkit.inventory.ItemStack;
|
import org.bukkit.inventory.ItemStack;
|
||||||
import org.bukkit.inventory.PlayerInventory;
|
import org.bukkit.inventory.PlayerInventory;
|
||||||
@ -25,6 +26,7 @@ import com.massivecraft.massivecore.adapter.ModdedEnumTypeAdapter;
|
|||||||
import com.massivecraft.massivecore.adapter.MsonAdapter;
|
import com.massivecraft.massivecore.adapter.MsonAdapter;
|
||||||
import com.massivecraft.massivecore.adapter.MsonEventAdapter;
|
import com.massivecraft.massivecore.adapter.MsonEventAdapter;
|
||||||
import com.massivecraft.massivecore.adapter.PlayerInventoryAdapter;
|
import com.massivecraft.massivecore.adapter.PlayerInventoryAdapter;
|
||||||
|
import com.massivecraft.massivecore.adapter.SoundAdapter;
|
||||||
import com.massivecraft.massivecore.adapter.UUIDAdapter;
|
import com.massivecraft.massivecore.adapter.UUIDAdapter;
|
||||||
import com.massivecraft.massivecore.collections.BackstringEnumSet;
|
import com.massivecraft.massivecore.collections.BackstringEnumSet;
|
||||||
import com.massivecraft.massivecore.collections.MassiveList;
|
import com.massivecraft.massivecore.collections.MassiveList;
|
||||||
@ -118,6 +120,7 @@ public class MassiveCore extends MassivePlugin
|
|||||||
.registerTypeAdapter(JsonPrimitive.class, JsonElementAdapter.get())
|
.registerTypeAdapter(JsonPrimitive.class, JsonElementAdapter.get())
|
||||||
.registerTypeAdapter(JsonArray.class, JsonElementAdapter.get())
|
.registerTypeAdapter(JsonArray.class, JsonElementAdapter.get())
|
||||||
.registerTypeAdapter(JsonObject.class, JsonElementAdapter.get())
|
.registerTypeAdapter(JsonObject.class, JsonElementAdapter.get())
|
||||||
|
.registerTypeAdapter(Sound.class, SoundAdapter.get())
|
||||||
.registerTypeAdapter(UUID.class, UUIDAdapter.get())
|
.registerTypeAdapter(UUID.class, UUIDAdapter.get())
|
||||||
.registerTypeAdapter(ItemStack.class, ItemStackAdapter.get())
|
.registerTypeAdapter(ItemStack.class, ItemStackAdapter.get())
|
||||||
.registerTypeAdapter(Inventory.class, InventoryAdapter.get())
|
.registerTypeAdapter(Inventory.class, InventoryAdapter.get())
|
||||||
|
@ -5,9 +5,13 @@ import java.util.Collection;
|
|||||||
|
|
||||||
import org.bukkit.Location;
|
import org.bukkit.Location;
|
||||||
import org.bukkit.Sound;
|
import org.bukkit.Sound;
|
||||||
|
import org.bukkit.entity.HumanEntity;
|
||||||
import org.bukkit.entity.Player;
|
import org.bukkit.entity.Player;
|
||||||
|
|
||||||
public final class SoundEffect implements Cloneable, Serializable
|
import com.massivecraft.massivecore.command.type.enumeration.TypeSound;
|
||||||
|
import com.massivecraft.massivecore.util.MUtil;
|
||||||
|
|
||||||
|
public final class SoundEffect implements Serializable
|
||||||
{
|
{
|
||||||
private static final transient long serialVersionUID = 1L;
|
private static final transient long serialVersionUID = 1L;
|
||||||
|
|
||||||
@ -15,8 +19,12 @@ public final class SoundEffect implements Cloneable, Serializable
|
|||||||
// FIELDS: RAW
|
// FIELDS: RAW
|
||||||
// -------------------------------------------- //
|
// -------------------------------------------- //
|
||||||
|
|
||||||
private final Sound sound;
|
private final String soundId;
|
||||||
public Sound getSound() { return this.sound; }
|
public String getSoundId() { return this.soundId; }
|
||||||
|
public Sound getSound()
|
||||||
|
{
|
||||||
|
return TypeSound.valueOf(this.getSoundId());
|
||||||
|
}
|
||||||
|
|
||||||
private final float volume;
|
private final float volume;
|
||||||
public float getVolume() { return this.volume; }
|
public float getVolume() { return this.volume; }
|
||||||
@ -28,17 +36,17 @@ public final class SoundEffect implements Cloneable, Serializable
|
|||||||
// FIELDS: WITH
|
// FIELDS: WITH
|
||||||
// -------------------------------------------- //
|
// -------------------------------------------- //
|
||||||
|
|
||||||
public SoundEffect withSound(Sound sound) { return new SoundEffect(sound, volume, pitch); }
|
public SoundEffect withSound(Sound sound) { return new SoundEffect(soundId, volume, pitch); }
|
||||||
public SoundEffect withVolume(float volume) { return new SoundEffect(sound, volume, pitch); }
|
public SoundEffect withVolume(float volume) { return new SoundEffect(soundId, volume, pitch); }
|
||||||
public SoundEffect withPitch(float pitch) { return new SoundEffect(sound, volume, pitch); }
|
public SoundEffect withPitch(float pitch) { return new SoundEffect(soundId, volume, pitch); }
|
||||||
|
|
||||||
// -------------------------------------------- //
|
// -------------------------------------------- //
|
||||||
// CONSTUCT
|
// CONSTUCT
|
||||||
// -------------------------------------------- //
|
// -------------------------------------------- //
|
||||||
|
|
||||||
private SoundEffect(Sound sound, float volume, float pitch)
|
private SoundEffect(String soundId, float volume, float pitch)
|
||||||
{
|
{
|
||||||
this.sound = sound;
|
this.soundId = soundId;
|
||||||
this.volume = volume;
|
this.volume = volume;
|
||||||
this.pitch = pitch;
|
this.pitch = pitch;
|
||||||
}
|
}
|
||||||
@ -53,9 +61,14 @@ public final class SoundEffect implements Cloneable, Serializable
|
|||||||
// VALUE OF
|
// VALUE OF
|
||||||
// -------------------------------------------- //
|
// -------------------------------------------- //
|
||||||
|
|
||||||
|
public static SoundEffect valueOf(String soundId, float volume, float pitch)
|
||||||
|
{
|
||||||
|
return new SoundEffect(soundId, volume, pitch);
|
||||||
|
}
|
||||||
|
|
||||||
public static SoundEffect valueOf(Sound sound, float volume, float pitch)
|
public static SoundEffect valueOf(Sound sound, float volume, float pitch)
|
||||||
{
|
{
|
||||||
return new SoundEffect(sound, volume, pitch);
|
return valueOf(TypeSound.get().getId(sound), volume, pitch);
|
||||||
}
|
}
|
||||||
|
|
||||||
// -------------------------------------------- //
|
// -------------------------------------------- //
|
||||||
@ -67,14 +80,16 @@ public final class SoundEffect implements Cloneable, Serializable
|
|||||||
location.getWorld().playSound(location, this.getSound(), this.getVolume(), this.getPitch());
|
location.getWorld().playSound(location, this.getSound(), this.getVolume(), this.getPitch());
|
||||||
}
|
}
|
||||||
|
|
||||||
public void run(Player player, Location location)
|
public void run(HumanEntity human, Location location)
|
||||||
{
|
{
|
||||||
|
if (MUtil.isntPlayer(human)) return;
|
||||||
|
Player player = (Player)human;
|
||||||
player.playSound(location, this.getSound(), this.getVolume(), this.getPitch());
|
player.playSound(location, this.getSound(), this.getVolume(), this.getPitch());
|
||||||
}
|
}
|
||||||
|
|
||||||
public void run(Player player)
|
public void run(HumanEntity human)
|
||||||
{
|
{
|
||||||
this.run(player, player.getEyeLocation());
|
this.run(human, human.getEyeLocation());
|
||||||
}
|
}
|
||||||
|
|
||||||
// -------------------------------------------- //
|
// -------------------------------------------- //
|
||||||
@ -89,32 +104,22 @@ public final class SoundEffect implements Cloneable, Serializable
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void runAll(Collection<SoundEffect> soundEffects, Player player, Location location)
|
public static void runAll(Collection<SoundEffect> soundEffects, HumanEntity human, Location location)
|
||||||
{
|
{
|
||||||
for (SoundEffect soundEffect : soundEffects)
|
for (SoundEffect soundEffect : soundEffects)
|
||||||
{
|
{
|
||||||
soundEffect.run(player, location);
|
soundEffect.run(human, location);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void runAll(Collection<SoundEffect> soundEffects, Player player)
|
public static void runAll(Collection<SoundEffect> soundEffects, HumanEntity human)
|
||||||
{
|
{
|
||||||
for (SoundEffect soundEffect : soundEffects)
|
for (SoundEffect soundEffect : soundEffects)
|
||||||
{
|
{
|
||||||
soundEffect.run(player);
|
soundEffect.run(human);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// -------------------------------------------- //
|
|
||||||
// CLONE
|
|
||||||
// -------------------------------------------- //
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public SoundEffect clone()
|
|
||||||
{
|
|
||||||
return this;
|
|
||||||
}
|
|
||||||
|
|
||||||
// -------------------------------------------- //
|
// -------------------------------------------- //
|
||||||
// EQUALS & HASHCODE
|
// EQUALS & HASHCODE
|
||||||
// -------------------------------------------- //
|
// -------------------------------------------- //
|
||||||
@ -125,11 +130,11 @@ public final class SoundEffect implements Cloneable, Serializable
|
|||||||
final int prime = 31;
|
final int prime = 31;
|
||||||
int result = 1;
|
int result = 1;
|
||||||
result = prime * result + Float.floatToIntBits(pitch);
|
result = prime * result + Float.floatToIntBits(pitch);
|
||||||
result = prime * result + ((sound == null) ? 0 : sound.hashCode());
|
result = prime * result + ((soundId == null) ? 0 : soundId.hashCode());
|
||||||
result = prime * result + Float.floatToIntBits(volume);
|
result = prime * result + Float.floatToIntBits(volume);
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean equals(Object obj)
|
public boolean equals(Object obj)
|
||||||
{
|
{
|
||||||
@ -138,7 +143,11 @@ public final class SoundEffect implements Cloneable, Serializable
|
|||||||
if (!(obj instanceof SoundEffect)) return false;
|
if (!(obj instanceof SoundEffect)) return false;
|
||||||
SoundEffect other = (SoundEffect) obj;
|
SoundEffect other = (SoundEffect) obj;
|
||||||
if (Float.floatToIntBits(pitch) != Float.floatToIntBits(other.pitch)) return false;
|
if (Float.floatToIntBits(pitch) != Float.floatToIntBits(other.pitch)) return false;
|
||||||
if (sound != other.sound) return false;
|
if (soundId == null)
|
||||||
|
{
|
||||||
|
if (other.soundId != null) return false;
|
||||||
|
}
|
||||||
|
else if (!soundId.equals(other.soundId)) return false;
|
||||||
if (Float.floatToIntBits(volume) != Float.floatToIntBits(other.volume)) return false;
|
if (Float.floatToIntBits(volume) != Float.floatToIntBits(other.volume)) return false;
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
45
src/com/massivecraft/massivecore/adapter/SoundAdapter.java
Normal file
45
src/com/massivecraft/massivecore/adapter/SoundAdapter.java
Normal file
@ -0,0 +1,45 @@
|
|||||||
|
package com.massivecraft.massivecore.adapter;
|
||||||
|
|
||||||
|
import java.lang.reflect.Type;
|
||||||
|
|
||||||
|
import org.bukkit.Sound;
|
||||||
|
|
||||||
|
import com.massivecraft.massivecore.xlib.gson.JsonDeserializationContext;
|
||||||
|
import com.massivecraft.massivecore.xlib.gson.JsonDeserializer;
|
||||||
|
import com.massivecraft.massivecore.xlib.gson.JsonElement;
|
||||||
|
import com.massivecraft.massivecore.xlib.gson.JsonNull;
|
||||||
|
import com.massivecraft.massivecore.xlib.gson.JsonParseException;
|
||||||
|
import com.massivecraft.massivecore.xlib.gson.JsonPrimitive;
|
||||||
|
import com.massivecraft.massivecore.xlib.gson.JsonSerializationContext;
|
||||||
|
import com.massivecraft.massivecore.xlib.gson.JsonSerializer;
|
||||||
|
|
||||||
|
public class SoundAdapter implements JsonDeserializer<Sound>, JsonSerializer<Sound>
|
||||||
|
{
|
||||||
|
// -------------------------------------------- //
|
||||||
|
// INSTANCE & CONSTRUCT
|
||||||
|
// -------------------------------------------- //
|
||||||
|
|
||||||
|
public static SoundAdapter i = new SoundAdapter();
|
||||||
|
public static SoundAdapter get() { return i; }
|
||||||
|
public SoundAdapter() {}
|
||||||
|
|
||||||
|
// -------------------------------------------- //
|
||||||
|
// OVERRIDE
|
||||||
|
// -------------------------------------------- //
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public JsonElement serialize(Sound src, Type typeOfSrc, JsonSerializationContext context)
|
||||||
|
{
|
||||||
|
if (src == null) return JsonNull.INSTANCE;
|
||||||
|
return new JsonPrimitive(src.name());
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public Sound deserialize(JsonElement json, Type typeOfT, JsonDeserializationContext context) throws JsonParseException
|
||||||
|
{
|
||||||
|
if (json == null) return null;
|
||||||
|
if (json.equals(JsonNull.INSTANCE)) return null;
|
||||||
|
return Sound.valueOf(json.getAsString());
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
@ -2,14 +2,11 @@ package com.massivecraft.massivecore.chestgui;
|
|||||||
|
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
|
|
||||||
import org.bukkit.Sound;
|
|
||||||
import org.bukkit.entity.HumanEntity;
|
|
||||||
import org.bukkit.entity.Player;
|
|
||||||
import org.bukkit.inventory.Inventory;
|
import org.bukkit.inventory.Inventory;
|
||||||
import org.bukkit.inventory.ItemStack;
|
import org.bukkit.inventory.ItemStack;
|
||||||
|
|
||||||
|
import com.massivecraft.massivecore.SoundEffect;
|
||||||
import com.massivecraft.massivecore.collections.MassiveMap;
|
import com.massivecraft.massivecore.collections.MassiveMap;
|
||||||
import com.massivecraft.massivecore.util.MUtil;
|
|
||||||
|
|
||||||
public class ChestGui
|
public class ChestGui
|
||||||
{
|
{
|
||||||
@ -46,28 +43,9 @@ public class ChestGui
|
|||||||
// FIELDS: SOUND
|
// FIELDS: SOUND
|
||||||
// -------------------------------------------- //
|
// -------------------------------------------- //
|
||||||
|
|
||||||
protected Sound sound = Sound.CLICK;
|
protected SoundEffect soundEffect = SoundEffect.valueOf("CLICK", 1.0f, 1.0f);
|
||||||
public Sound getSound() { return this.sound; }
|
public SoundEffect getSoundEffect() { return this.soundEffect; }
|
||||||
|
public ChestGui setSoundEffect(SoundEffect soundEffect) { this.soundEffect = soundEffect; return this; }
|
||||||
protected float volume = 1.0f;
|
|
||||||
public float getVolume() { return this.volume; }
|
|
||||||
public ChestGui setVolume(float volume) { this.volume = volume; return this; }
|
|
||||||
|
|
||||||
protected float pitch = 1.0f;
|
|
||||||
public float getPitch() { return this.pitch; }
|
|
||||||
public ChestGui setPitch(float pitch) { this.pitch = pitch; return this; }
|
|
||||||
|
|
||||||
public void playSound(Player player)
|
|
||||||
{
|
|
||||||
player.playSound(player.getEyeLocation(), this.getSound(), this.getVolume(), this.getPitch());
|
|
||||||
}
|
|
||||||
|
|
||||||
public void playSound(HumanEntity human)
|
|
||||||
{
|
|
||||||
if (MUtil.isntPlayer(human)) return;
|
|
||||||
Player player = (Player)human;
|
|
||||||
this.playSound(player);
|
|
||||||
}
|
|
||||||
|
|
||||||
// -------------------------------------------- //
|
// -------------------------------------------- //
|
||||||
// CONSTRUCT
|
// CONSTRUCT
|
||||||
|
@ -1,11 +1,270 @@
|
|||||||
package com.massivecraft.massivecore.command.type.enumeration;
|
package com.massivecraft.massivecore.command.type.enumeration;
|
||||||
|
|
||||||
|
import java.util.Map;
|
||||||
|
import java.util.Set;
|
||||||
|
|
||||||
import org.bukkit.Sound;
|
import org.bukkit.Sound;
|
||||||
|
|
||||||
|
import com.massivecraft.massivecore.collections.MassiveSet;
|
||||||
|
import com.massivecraft.massivecore.collections.MassiveMap;
|
||||||
|
import com.massivecraft.massivecore.util.MUtil;
|
||||||
import com.massivecraft.massivecore.util.Txt;
|
import com.massivecraft.massivecore.util.Txt;
|
||||||
|
|
||||||
public class TypeSound extends TypeEnum<Sound>
|
public class TypeSound extends TypeEnum<Sound>
|
||||||
{
|
{
|
||||||
|
// -------------------------------------------- //
|
||||||
|
// DATA
|
||||||
|
// -------------------------------------------- //
|
||||||
|
// https://hub.spigotmc.org/stash/projects/SPIGOT/repos/bukkit/diff/src/main/java/org/bukkit/Sound.java?until=7898a2a2d2d81308e73e9ed37725f53d7ad37bfc&at=refs%2Fheads%2Fmaster
|
||||||
|
|
||||||
|
// Maps every sound in Minecraft 1.8 to the new sound in Minecraft 1.9
|
||||||
|
public static Map<String, String> FROM_18_TO_19 = new MassiveMap<String, String>(
|
||||||
|
"AMBIENCE_CAVE", "AMBIENT_CAVE",
|
||||||
|
"AMBIENCE_RAIN", "WEATHER_RAIN",
|
||||||
|
"AMBIENCE_THUNDER", "ENTITY_LIGHTNING_THUNDER",
|
||||||
|
"ANVIL_BREAK", "BLOCK_ANVIL_BREAK",
|
||||||
|
"ANVIL_LAND", "BLOCK_ANVIL_LAND",
|
||||||
|
"ANVIL_USE", "BLOCK_ANVIL_USE",
|
||||||
|
"ARROW_HIT", "ENTITY_ARROW_HIT",
|
||||||
|
"BURP", "ENTITY_PLAYER_BURP",
|
||||||
|
"CHEST_CLOSE", "BLOCK_CHEST_CLOSE",
|
||||||
|
"CHEST_OPEN", "BLOCK_CHEST_OPEN",
|
||||||
|
"CLICK", "UI_BUTTON_CLICK",
|
||||||
|
"DOOR_CLOSE", "BLOCK_WOODEN_DOOR_CLOSE",
|
||||||
|
"DOOR_OPEN", "BLOCK_WOODEN_DOOR_OPEN",
|
||||||
|
"DRINK", "ENTITY_GENERIC_DRINK",
|
||||||
|
"EAT", "ENTITY_GENERIC_EAT",
|
||||||
|
"EXPLODE", "ENTITY_GENERIC_EXPLODE",
|
||||||
|
"FALL_BIG", "ENTITY_GENERIC_BIG_FALL",
|
||||||
|
"FALL_SMALL", "ENTITY_GENERIC_SMALL_FALL",
|
||||||
|
|
||||||
|
"FIRE", "BLOCK_FIRE_AMBIENT",
|
||||||
|
"FIRE_IGNITE", "ITEM_FLINTANDSTEEL_USE",
|
||||||
|
"FIZZ", "ENTITY_GENERIC_EXTINGUISH_FIRE",
|
||||||
|
"FUSE", "ENTITY_TNT_PRIMED",
|
||||||
|
|
||||||
|
"GLASS", "BLOCK_GLASS_BREAK",
|
||||||
|
"HURT_FLESH", "ENTITY_GENERIC_HURT",
|
||||||
|
"ITEM_BREAK", "ENTITY_ITEM_BREAK",
|
||||||
|
"ITEM_PICKUP", "ENTITY_ITEM_PICKUP",
|
||||||
|
"LAVA", "BLOCK_LAVA_AMBIENT",
|
||||||
|
"LAVA_POP", "BLOCK_LAVA_POP",
|
||||||
|
"LEVEL_UP", "ENTITY_PLAYER_LEVELUP",
|
||||||
|
"MINECART_BASE", "ENTITY_MINECART_RIDING",
|
||||||
|
"MINECART_INSIDE", "ENTITY_MINECART_INSIDE",
|
||||||
|
|
||||||
|
"NOTE_BASS", "BLOCK_NOTE_BASS", // NOTE: Duplicate since 1 less sound in 1.9.
|
||||||
|
"NOTE_PIANO", "BLOCK_NOTE_HARP",
|
||||||
|
"NOTE_BASS_DRUM", "BLOCK_NOTE_BASEDRUM",
|
||||||
|
"NOTE_STICKS", "BLOCK_NOTE_HAT",
|
||||||
|
"NOTE_BASS_GUITAR", "BLOCK_NOTE_BASS", // NOTE: Duplicate since 1 less sound in 1.9.
|
||||||
|
"NOTE_SNARE_DRUM", "BLOCK_NOTE_SNARE",
|
||||||
|
"NOTE_PLING", "BLOCK_NOTE_PLING",
|
||||||
|
|
||||||
|
"ORB_PICKUP", "ENTITY_EXPERIENCE_ORB_PICKUP",
|
||||||
|
"PISTON_EXTEND", "BLOCK_PISTON_EXTEND",
|
||||||
|
"PISTON_RETRACT", "BLOCK_PISTON_CONTRACT",
|
||||||
|
"PORTAL", "BLOCK_PORTAL_AMBIENT",
|
||||||
|
"PORTAL_TRAVEL", "BLOCK_PORTAL_TRAVEL",
|
||||||
|
"PORTAL_TRIGGER", "BLOCK_PORTAL_TRIGGER",
|
||||||
|
"SHOOT_ARROW", "ENTITY_ARROW_SHOOT",
|
||||||
|
"SPLASH", "ENTITY_GENERIC_SPLASH", // TODO: I'm not sure about this one.
|
||||||
|
"SPLASH2", "ENTITY_BOBBER_SPLASH", // TODO: I'm not sure about this one.
|
||||||
|
"STEP_GRASS", "BLOCK_GRASS_STEP",
|
||||||
|
"STEP_GRAVEL", "BLOCK_GRAVEL_STEP",
|
||||||
|
"STEP_LADDER", "BLOCK_LADDER_STEP",
|
||||||
|
"STEP_SAND", "BLOCK_SAND_STEP",
|
||||||
|
"STEP_SNOW", "BLOCK_SNOW_STEP",
|
||||||
|
"STEP_STONE", "BLOCK_STONE_STEP",
|
||||||
|
"STEP_WOOD", "BLOCK_WOOD_STEP",
|
||||||
|
"STEP_WOOL", "BLOCK_CLOTH_STEP",
|
||||||
|
"SWIM", "ENTITY_GENERIC_SWIM",
|
||||||
|
"WATER", "BLOCK_WATER_AMBIENT",
|
||||||
|
"WOOD_CLICK", "BLOCK_WOOD_BUTTON_CLICK_ON",
|
||||||
|
|
||||||
|
// Mob sounds
|
||||||
|
"BAT_DEATH", "ENTITY_BAT_DEATH",
|
||||||
|
"BAT_HURT", "ENTITY_BAT_HURT",
|
||||||
|
"BAT_IDLE", "ENTITY_BAT_AMBIENT",
|
||||||
|
"BAT_LOOP", "ENTITY_BAT_LOOP",
|
||||||
|
"BAT_TAKEOFF", "ENTITY_BAT_TAKEOFF",
|
||||||
|
|
||||||
|
"BLAZE_BREATH", "ENTITY_BLAZE_AMBIENT",
|
||||||
|
"BLAZE_DEATH", "ENTITY_BLAZE_DEATH",
|
||||||
|
"BLAZE_HIT", "ENTITY_BLAZE_HURT",
|
||||||
|
|
||||||
|
"CAT_HISS", "ENTITY_CAT_HISS",
|
||||||
|
"CAT_HIT", "ENTITY_CAT_HURT",
|
||||||
|
"CAT_MEOW", "ENTITY_CAT_AMBIENT",
|
||||||
|
"CAT_PURR", "ENTITY_CAT_PURR",
|
||||||
|
"CAT_PURREOW", "ENTITY_CAT_PURREOW",
|
||||||
|
|
||||||
|
"CHICKEN_IDLE", "ENTITY_CHICKEN_AMBIENT",
|
||||||
|
"CHICKEN_HURT", "ENTITY_CHICKEN_HURT",
|
||||||
|
"CHICKEN_EGG_POP", "ENTITY_CHICKEN_EGG",
|
||||||
|
"CHICKEN_WALK", "ENTITY_CHICKEN_STEP",
|
||||||
|
|
||||||
|
"COW_IDLE", "ENTITY_COW_AMBIENT",
|
||||||
|
"COW_HURT", "ENTITY_COW_HURT",
|
||||||
|
"COW_WALK", "ENTITY_COW_STEP",
|
||||||
|
|
||||||
|
"CREEPER_HISS", "ENTITY_CREEPER_PRIMED",
|
||||||
|
"CREEPER_DEATH", "ENTITY_CREEPER_DEATH",
|
||||||
|
|
||||||
|
"ENDERDRAGON_DEATH", "ENTITY_ENDERDRAGON_DEATH",
|
||||||
|
"ENDERDRAGON_GROWL", "ENTITY_ENDERDRAGON_GROWL",
|
||||||
|
"ENDERDRAGON_HIT", "ENTITY_ENDERDRAGON_HURT",
|
||||||
|
"ENDERDRAGON_WINGS", "ENTITY_ENDERDRAGON_FLAP",
|
||||||
|
|
||||||
|
"ENDERMAN_DEATH", "ENTITY_ENDERMEN_DEATH",
|
||||||
|
"ENDERMAN_HIT", "ENTITY_ENDERMEN_HURT",
|
||||||
|
"ENDERMAN_IDLE", "ENTITY_ENDERMEN_AMBIENT",
|
||||||
|
"ENDERMAN_TELEPORT", "ENTITY_ENDERMEN_TELEPORT",
|
||||||
|
"ENDERMAN_SCREAM", "ENTITY_ENDERMEN_SCREAM",
|
||||||
|
"ENDERMAN_STARE", "ENTITY_ENDERMEN_STARE",
|
||||||
|
|
||||||
|
// Really unsure about all of these
|
||||||
|
"GHAST_SCREAM", "ENTITY_GHAST_AMBIENT",
|
||||||
|
"GHAST_SCREAM2", "ENTITY_GHAST_SCREAM",
|
||||||
|
"GHAST_CHARGE", "ENTITY_GHAST_WARN",
|
||||||
|
"GHAST_DEATH", "ENTITY_GHAST_DEATH",
|
||||||
|
"GHAST_FIREBALL", "ENTITY_GHAST_SHOOT",
|
||||||
|
"GHAST_MOAN", "ENTITY_GHAST_HURT",
|
||||||
|
|
||||||
|
"IRONGOLEM_DEATH", "ENTITY_IRONGOLEM_DEATH",
|
||||||
|
"IRONGOLEM_HIT", "ENTITY_IRONGOLEM_HURT",
|
||||||
|
"IRONGOLEM_THROW", "ENTITY_IRONGOLEM_ATTACK",
|
||||||
|
"IRONGOLEM_WALK", "ENTITY_IRONGOLEM_STEP",
|
||||||
|
|
||||||
|
"MAGMACUBE_WALK", "ENTITY_MAGMACUBE_SQUISH", // TODO: This is a wild guess.
|
||||||
|
"MAGMACUBE_WALK2", "ENTITY_MAGMACUBE_HURT", // TODO: This is a wild guess.
|
||||||
|
"MAGMACUBE_JUMP", "ENTITY_MAGMACUBE_JUMP",
|
||||||
|
|
||||||
|
"PIG_IDLE", "ENTITY_PIG_AMBIENT",
|
||||||
|
"PIG_DEATH", "ENTITY_PIG_DEATH",
|
||||||
|
"PIG_WALK", "ENTITY_PIG_STEP",
|
||||||
|
|
||||||
|
"SHEEP_IDLE", "ENTITY_SHEEP_AMBIENT",
|
||||||
|
"SHEEP_SHEAR", "ENTITY_SHEEP_SHEAR",
|
||||||
|
"SHEEP_WALK", "ENTITY_SHEEP_STEP",
|
||||||
|
|
||||||
|
"SILVERFISH_HIT", "ENTITY_SILVERFISH_HURT",
|
||||||
|
"SILVERFISH_KILL", "ENTITY_SILVERFISH_DEATH",
|
||||||
|
"SILVERFISH_IDLE", "ENTITY_SILVERFISH_AMBIENT",
|
||||||
|
"SILVERFISH_WALK", "ENTITY_SILVERFISH_STEP",
|
||||||
|
|
||||||
|
"SKELETON_IDLE", "ENTITY_SKELETON_AMBIENT",
|
||||||
|
"SKELETON_DEATH", "ENTITY_SKELETON_DEATH",
|
||||||
|
"SKELETON_HURT", "ENTITY_SKELETON_HURT",
|
||||||
|
"SKELETON_WALK", "ENTITY_SKELETON_STEP",
|
||||||
|
|
||||||
|
"SLIME_ATTACK", "ENTITY_SLIME_ATTACK",
|
||||||
|
"SLIME_WALK", "ENTITY_SLIME_SQUISH",
|
||||||
|
"SLIME_WALK2", "ENTITY_SLIME_JUMP",
|
||||||
|
|
||||||
|
"SPIDER_IDLE", "ENTITY_SPIDER_AMBIENT",
|
||||||
|
"SPIDER_DEATH", "ENTITY_SPIDER_DEATH",
|
||||||
|
"SPIDER_WALK", "ENTITY_SPIDER_STEP",
|
||||||
|
|
||||||
|
"WITHER_DEATH", "ENTITY_WITHER_DEATH",
|
||||||
|
"WITHER_HURT", "ENTITY_WITHER_HURT",
|
||||||
|
"WITHER_IDLE", "ENTITY_WITHER_AMBIENT",
|
||||||
|
"WITHER_SHOOT", "ENTITY_WITHER_SHOOT",
|
||||||
|
"WITHER_SPAWN", "ENTITY_WITHER_SPAWN",
|
||||||
|
|
||||||
|
"WOLF_BARK", "ENTITY_WOLF_AMBIENT",
|
||||||
|
"WOLF_DEATH", "ENTITY_WOLF_DEATH",
|
||||||
|
"WOLF_GROWL", "ENTITY_WOLF_GROWL",
|
||||||
|
"WOLF_HOWL", "ENTITY_WOLF_HOWL",
|
||||||
|
"WOLF_HURT", "ENTITY_WOLF_HURT",
|
||||||
|
"WOLF_PANT", "ENTITY_WOLF_PANT",
|
||||||
|
"WOLF_SHAKE", "ENTITY_WOLF_SHAKE",
|
||||||
|
"WOLF_WALK", "ENTITY_WOLF_STEP",
|
||||||
|
"WOLF_WHINE", "ENTITY_WOLF_WHINE",
|
||||||
|
|
||||||
|
"ZOMBIE_METAL", "ENTITY_ZOMBIE_ATTACK_IRON_DOOR",
|
||||||
|
"ZOMBIE_WOOD", "ENTITY_ZOMBIE_ATTACK_DOOR_WOOD",
|
||||||
|
"ZOMBIE_WOODBREAK", "ENTITY_ZOMBIE_BREAK_DOOR_WOOD",
|
||||||
|
"ZOMBIE_IDLE", "ENTITY_ZOMBIE_AMBIENT",
|
||||||
|
"ZOMBIE_DEATH", "ENTITY_ZOMBIE_DEATH",
|
||||||
|
"ZOMBIE_HURT", "ENTITY_ZOMBIE_HURT",
|
||||||
|
"ZOMBIE_INFECT", "ENTITY_ZOMBIE_INFECT",
|
||||||
|
"ZOMBIE_UNFECT", "ENTITY_ZOMBIE_VILLAGER_CONVERTED", // TODO: I'm not sure about this one.
|
||||||
|
"ZOMBIE_REMEDY", "ENTITY_ZOMBIE_VILLAGER_CURE", // TODO: I'm not sure about this one.
|
||||||
|
"ZOMBIE_WALK", "ENTITY_ZOMBIE_STEP",
|
||||||
|
|
||||||
|
"ZOMBIE_PIG_IDLE", "ENTITY_ZOMBIE_PIG_AMBIENT",
|
||||||
|
"ZOMBIE_PIG_ANGRY", "ENTITY_ZOMBIE_PIG_ANGRY",
|
||||||
|
"ZOMBIE_PIG_DEATH", "ENTITY_ZOMBIE_PIG_DEATH",
|
||||||
|
"ZOMBIE_PIG_HURT", "ENTITY_ZOMBIE_PIG_HURT",
|
||||||
|
|
||||||
|
// Dig Sounds
|
||||||
|
"DIG_WOOL", "BLOCK_CLOTH_BREAK",
|
||||||
|
"DIG_GRASS", "BLOCK_GRASS_BREAK",
|
||||||
|
"DIG_GRAVEL", "BLOCK_GRAVEL_BREAK",
|
||||||
|
"DIG_SAND", "BLOCK_SAND_BREAK",
|
||||||
|
"DIG_SNOW", "BLOCK_SNOW_BREAK",
|
||||||
|
"DIG_STONE", "BLOCK_STONE_BREAK",
|
||||||
|
"DIG_WOOD", "BLOCK_WOOD_BREAK",
|
||||||
|
|
||||||
|
// Fireworks
|
||||||
|
"FIREWORK_BLAST", "ENTITY_FIREWORK_BLAST",
|
||||||
|
"FIREWORK_BLAST2", "ENTITY_FIREWORK_BLAST_FAR",
|
||||||
|
"FIREWORK_LARGE_BLAST", "ENTITY_FIREWORK_LARGE_BLAST",
|
||||||
|
"FIREWORK_LARGE_BLAST2", "ENTITY_FIREWORK_LARGE_BLAST_FAR",
|
||||||
|
"FIREWORK_TWINKLE", "ENTITY_FIREWORK_TWINKLE",
|
||||||
|
"FIREWORK_TWINKLE2", "ENTITY_FIREWORK_TWINKLE_FAR",
|
||||||
|
"FIREWORK_LAUNCH", "ENTITY_FIREWORK_LAUNCH",
|
||||||
|
"SUCCESSFUL_HIT", "ENTITY_FIREWORK_SHOOT",
|
||||||
|
|
||||||
|
// Horses
|
||||||
|
"HORSE_ANGRY", "ENTITY_HORSE_ANGRY",
|
||||||
|
"HORSE_ARMOR", "ENTITY_HORSE_ARMOR",
|
||||||
|
"HORSE_BREATHE", "ENTITY_HORSE_BREATHE",
|
||||||
|
"HORSE_DEATH", "ENTITY_HORSE_DEATH",
|
||||||
|
"HORSE_GALLOP", "ENTITY_HORSE_GALLOP",
|
||||||
|
"HORSE_HIT", "ENTITY_HORSE_HURT",
|
||||||
|
"HORSE_IDLE", "ENTITY_HORSE_AMBIENT",
|
||||||
|
"HORSE_JUMP", "ENTITY_HORSE_JUMP",
|
||||||
|
"HORSE_LAND", "ENTITY_HORSE_LAND",
|
||||||
|
"HORSE_SADDLE", "ENTITY_HORSE_SADDLE",
|
||||||
|
"HORSE_SOFT", "ENTITY_HORSE_STEP",
|
||||||
|
"HORSE_WOOD", "ENTITY_HORSE_STEP_WOOD",
|
||||||
|
|
||||||
|
"DONKEY_ANGRY", "ENTITY_DONKEY_ANGRY",
|
||||||
|
"DONKEY_DEATH", "ENTITY_DONKEY_DEATH",
|
||||||
|
"DONKEY_HIT", "ENTITY_DONKEY_HURT",
|
||||||
|
"DONKEY_IDLE", "ENTITY_DONKEY_AMBIENT",
|
||||||
|
|
||||||
|
"HORSE_SKELETON_DEATH", "ENTITY_SKELETON_HORSE_DEATH",
|
||||||
|
"HORSE_SKELETON_HIT", "ENTITY_SKELETON_HORSE_HURT",
|
||||||
|
"HORSE_SKELETON_IDLE", "ENTITY_SKELETON_HORSE_AMBIENT",
|
||||||
|
|
||||||
|
"HORSE_ZOMBIE_DEATH", "ENTITY_ZOMBIE_HORSE_DEATH",
|
||||||
|
"HORSE_ZOMBIE_HIT", "ENTITY_ZOMBIE_HORSE_HURT",
|
||||||
|
"HORSE_ZOMBIE_IDLE", "ENTITY_ZOMBIE_HORSE_AMBIENT",
|
||||||
|
|
||||||
|
// Villager
|
||||||
|
"VILLAGER_DEATH", "ENTITY_VILLAGER_DEATH",
|
||||||
|
"VILLAGER_HAGGLE", "ENTITY_VILLAGER_TRADING",
|
||||||
|
"VILLAGER_HIT", "ENTITY_VILLAGER_HURT",
|
||||||
|
"VILLAGER_IDLE", "ENTITY_VILLAGER_AMBIENT",
|
||||||
|
"VILLAGER_NO", "ENTITY_VILLAGER_NO",
|
||||||
|
"VILLAGER_YES", "ENTITY_VILLAGER_YES"
|
||||||
|
);
|
||||||
|
|
||||||
|
public static Map<String, Set<String>> FROM_19_TO_18 = MUtil.reverseIndex(FROM_18_TO_19);
|
||||||
|
|
||||||
|
// -------------------------------------------- //
|
||||||
|
// VALUE OF
|
||||||
|
// -------------------------------------------- //
|
||||||
|
|
||||||
|
public static Sound valueOf(String string)
|
||||||
|
{
|
||||||
|
string = get().prepareOptionKey(string);
|
||||||
|
return get().getOptions().get(string);
|
||||||
|
}
|
||||||
|
|
||||||
// -------------------------------------------- //
|
// -------------------------------------------- //
|
||||||
// INSTANCE & CONSTRUCT
|
// INSTANCE & CONSTRUCT
|
||||||
// -------------------------------------------- //
|
// -------------------------------------------- //
|
||||||
@ -19,5 +278,45 @@ public class TypeSound extends TypeEnum<Sound>
|
|||||||
Txt.parse("<aqua>https://hub.spigotmc.org/stash/projects/SPIGOT/repos/bukkit/browse/src/main/java/org/bukkit/Sound.java")
|
Txt.parse("<aqua>https://hub.spigotmc.org/stash/projects/SPIGOT/repos/bukkit/browse/src/main/java/org/bukkit/Sound.java")
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// -------------------------------------------- //
|
||||||
|
// OVERRIDE
|
||||||
|
// -------------------------------------------- //
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public Set<String> getNamesInner(Sound value)
|
||||||
|
{
|
||||||
|
// Create
|
||||||
|
Set<String> ret = new MassiveSet<>();
|
||||||
|
|
||||||
|
// Fill
|
||||||
|
for (String id : this.getIdsInner(value))
|
||||||
|
{
|
||||||
|
ret.add(Txt.getNicedEnumString(id));
|
||||||
|
}
|
||||||
|
|
||||||
|
// Return
|
||||||
|
return ret;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public Set<String> getIdsInner(Sound value)
|
||||||
|
{
|
||||||
|
// Create
|
||||||
|
Set<String> ret = new MassiveSet<String>();
|
||||||
|
|
||||||
|
// Fill
|
||||||
|
String current = value.name();
|
||||||
|
ret.add(current);
|
||||||
|
|
||||||
|
String from18to19 = FROM_18_TO_19.get(current);
|
||||||
|
if (from18to19 != null) ret.add(from18to19);
|
||||||
|
|
||||||
|
Set<String> from19to18 = FROM_19_TO_18.get(current);
|
||||||
|
if (from19to18 != null) ret.addAll(from19to18);
|
||||||
|
|
||||||
|
// Return
|
||||||
|
return ret;
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -55,7 +55,7 @@ public class EngineMassiveCoreChestGui extends Engine
|
|||||||
if (action == null) return;
|
if (action == null) return;
|
||||||
|
|
||||||
// ... then play the sound ...
|
// ... then play the sound ...
|
||||||
gui.playSound(event.getWhoClicked());
|
gui.getSoundEffect().run(event.getWhoClicked());
|
||||||
|
|
||||||
// ... close the GUI ...
|
// ... close the GUI ...
|
||||||
event.getView().close();
|
event.getView().close();
|
||||||
|
@ -13,6 +13,7 @@ import org.bukkit.event.EventPriority;
|
|||||||
import org.bukkit.event.player.AsyncPlayerChatEvent;
|
import org.bukkit.event.player.AsyncPlayerChatEvent;
|
||||||
import org.bukkit.event.player.PlayerCommandPreprocessEvent;
|
import org.bukkit.event.player.PlayerCommandPreprocessEvent;
|
||||||
import org.bukkit.inventory.ItemStack;
|
import org.bukkit.inventory.ItemStack;
|
||||||
|
import org.bukkit.inventory.PlayerInventory;
|
||||||
import org.bukkit.inventory.meta.BookMeta;
|
import org.bukkit.inventory.meta.BookMeta;
|
||||||
import org.bukkit.inventory.meta.ItemMeta;
|
import org.bukkit.inventory.meta.ItemMeta;
|
||||||
import com.massivecraft.massivecore.Engine;
|
import com.massivecraft.massivecore.Engine;
|
||||||
@ -69,7 +70,26 @@ public class EngineMassiveCoreVariable extends Engine
|
|||||||
if (sender == null) return null;
|
if (sender == null) return null;
|
||||||
if (!(sender instanceof HumanEntity)) return null;
|
if (!(sender instanceof HumanEntity)) return null;
|
||||||
HumanEntity human = (HumanEntity)sender;
|
HumanEntity human = (HumanEntity)sender;
|
||||||
ItemStack item = human.getItemInHand();
|
|
||||||
|
PlayerInventory inventory = human.getInventory();
|
||||||
|
String ret;
|
||||||
|
|
||||||
|
ret = getBookText(inventory.getItemInHand());
|
||||||
|
if (ret != null) return ret;
|
||||||
|
|
||||||
|
// TODO: Handle 1.9 API without breaking 1.8 support
|
||||||
|
|
||||||
|
// ret = getBookText(inventory.getItemInMainHand());
|
||||||
|
// if (ret != null) return ret;
|
||||||
|
|
||||||
|
// ret = getBookText(inventory.getItemInOffHand());
|
||||||
|
// if (ret != null) return ret;
|
||||||
|
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
public static String getBookText(ItemStack item)
|
||||||
|
{
|
||||||
if (item == null) return null;
|
if (item == null) return null;
|
||||||
if (!item.hasItemMeta()) return null;
|
if (!item.hasItemMeta()) return null;
|
||||||
ItemMeta itemMeta = item.getItemMeta();
|
ItemMeta itemMeta = item.getItemMeta();
|
||||||
|
Loading…
Reference in New Issue
Block a user