更新
This commit is contained in:
@@ -4,62 +4,64 @@ import org.bukkit.Sound;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
public class SoundPack {
|
||||
|
||||
private Sound sound;
|
||||
private Float a;
|
||||
private Float b;
|
||||
|
||||
public SoundPack() {
|
||||
this.sound = Sound.valueOf(SoundUtils.getModifiedSound("ENTITY_VILLAGER_NO"));
|
||||
this.a = 1f;
|
||||
this.b = 1f;
|
||||
}
|
||||
|
||||
public SoundPack(Sound sound, Float a, Float b) {
|
||||
this.sound = sound;
|
||||
this.a = a;
|
||||
this.b = b;
|
||||
}
|
||||
|
||||
public SoundPack(String s) {
|
||||
try {
|
||||
sound = Sound.valueOf(SoundUtils.getModifiedSound(s.split("-")[0]));
|
||||
a = Float.valueOf(s.split("-")[1]);
|
||||
b = Float.valueOf(s.split("-")[2]);
|
||||
}
|
||||
catch (Exception e) {
|
||||
this.sound = Sound.valueOf(SoundUtils.getModifiedSound("ENTITY_VILLAGER_NO"));
|
||||
this.a = 1f;
|
||||
this.b = 1f;
|
||||
}
|
||||
}
|
||||
|
||||
public Sound getSound() {
|
||||
return sound;
|
||||
}
|
||||
|
||||
public Float getA() {
|
||||
return a;
|
||||
}
|
||||
|
||||
public Float getB() {
|
||||
return b;
|
||||
}
|
||||
|
||||
public void play(Player p) {
|
||||
p.playSound(p.getLocation(), sound, a, b);
|
||||
}
|
||||
|
||||
public void parse(String s) {
|
||||
try {
|
||||
sound = Sound.valueOf(SoundUtils.getModifiedSound(s.split("-")[0]));
|
||||
a = Float.valueOf(s.split("-")[1]);
|
||||
b = Float.valueOf(s.split("-")[2]);
|
||||
}
|
||||
catch (Exception e) {
|
||||
this.sound = Sound.valueOf(SoundUtils.getModifiedSound("ENTITY_VILLAGER_NO"));
|
||||
this.a = 1f;
|
||||
this.b = 1f;
|
||||
}
|
||||
}
|
||||
|
||||
private Sound sound;
|
||||
private Float a;
|
||||
private Float b;
|
||||
|
||||
public SoundPack() {
|
||||
this.sound = Sound.valueOf(SoundUtils.getModifiedSound("ENTITY_VILLAGER_NO"));
|
||||
this.a = 1f;
|
||||
this.b = 1f;
|
||||
}
|
||||
|
||||
public SoundPack(Sound sound, Float a, Float b) {
|
||||
this.sound = sound;
|
||||
this.a = a;
|
||||
this.b = b;
|
||||
}
|
||||
|
||||
public SoundPack(String s) {
|
||||
try {
|
||||
sound = Sound.valueOf(SoundUtils.getModifiedSound(s.split("-")[0]));
|
||||
a = Float.valueOf(s.split("-")[1]);
|
||||
b = Float.valueOf(s.split("-")[2]);
|
||||
} catch (Exception e) {
|
||||
this.sound = Sound.valueOf(SoundUtils.getModifiedSound("ENTITY_VILLAGER_NO"));
|
||||
this.a = 1f;
|
||||
this.b = 1f;
|
||||
}
|
||||
}
|
||||
|
||||
public Sound getSound() {
|
||||
return sound;
|
||||
}
|
||||
|
||||
public Float getA() {
|
||||
return a;
|
||||
}
|
||||
|
||||
public Float getB() {
|
||||
return b;
|
||||
}
|
||||
|
||||
public void play(Player p) {
|
||||
p.playSound(p.getLocation(), sound, a, b);
|
||||
}
|
||||
|
||||
public void parse(String s) {
|
||||
try {
|
||||
sound = Sound.valueOf(SoundUtils.getModifiedSound(s.split("-")[0]));
|
||||
a = Float.valueOf(s.split("-")[1]);
|
||||
b = Float.valueOf(s.split("-")[2]);
|
||||
} catch (Exception e) {
|
||||
this.sound = Sound.valueOf(SoundUtils.getModifiedSound("ENTITY_VILLAGER_NO"));
|
||||
this.a = 1f;
|
||||
this.b = 1f;
|
||||
}
|
||||
}
|
||||
|
||||
public String toString() {
|
||||
return sound.name() + "-" + a + "-" + b;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,52 +1,43 @@
|
||||
package me.skymc.taboolib.sound;
|
||||
|
||||
import org.bukkit.Location;
|
||||
import org.bukkit.Sound;
|
||||
|
||||
import me.skymc.taboolib.TabooLib;
|
||||
import me.skymc.taboolib.message.MsgUtils;
|
||||
import org.bukkit.Location;
|
||||
import org.bukkit.Sound;
|
||||
|
||||
public class SoundUtils {
|
||||
|
||||
public static void sound(Location paramLocation, String paramString, float paramFloat1, float paramFloat2) {
|
||||
String str = getModifiedSound(paramString);
|
||||
try {
|
||||
paramLocation.getWorld().playSound(paramLocation, Sound.valueOf(str), paramFloat1, paramFloat2);
|
||||
}
|
||||
catch (Exception localException) {
|
||||
MsgUtils.send("§4Bug with " + paramString + ". No such sound found. Please report it to the plugin creator :)");
|
||||
}
|
||||
}
|
||||
|
||||
static String getModifiedSound(String str) {
|
||||
if (TabooLib.getVerint() < 10900) {
|
||||
str = str.replace("BLOCK_FIRE_EXTINGUISH", "FIZZ");
|
||||
str = str.replace("BLOCK_NOTE_HAT", "NOTE_STICKS");
|
||||
str = str.replace("ENTITY_SHEEP_DEATH", "SHEEP_IDLE");
|
||||
str = str.replace("ENTITY_LLAMA_ANGRY", "HORSE_HIT");
|
||||
str = str.replace("BLOCK_BREWING_STAND_BREW", "CREEPER_HISS");
|
||||
str = str.replace("ENTITY_SHULKER_TELEPORT", "ENDERMAN_TELEPORT");
|
||||
str = str.replace("ENTITY_ZOMBIE_ATTACK_IRON_DOOR", "ZOMBIE_METAL");
|
||||
str = str.replace("BLOCK_GRAVEL_BREAK", "DIG_GRAVEL");
|
||||
str = str.replace("BLOCK_SNOW_BREAK", "DIG_SNOW");
|
||||
str = str.replace("BLOCK_GRAVEL_BREAK", "DIG_GRAVEL");
|
||||
str = str.replace("ENTITY_PLAYER_LEVELUP", "LEVEL_UP");
|
||||
str = str.replace("ENTITY_SNOWBALL_THROW", "SHOOT_ARROW");
|
||||
|
||||
str = str.replace("ENTITY_", "");
|
||||
str = str.replace("GENERIC_", "");
|
||||
str = str.replace("BLOCK_", "");
|
||||
str = str.replace("_AMBIENT", "");
|
||||
str = str.replace("_BREAK", "");
|
||||
str = str.replace("PLAYER_ATTACK_CRIT", "ITEM_BREAK");
|
||||
str = str.replace("ENDERMEN", "ENDERMAN");
|
||||
str = str.replace("ARROW_SHOOT", "SHOOT_ARROW");
|
||||
str = str.replace("UI_BUTTON_", "");
|
||||
str = str.replace("ENDERMAN_HURT", "ENDERMAN_HIT");
|
||||
str = str.replace("BLAZE_HURT", "BLAZE_HIT");
|
||||
str = str.replace("_FLAP", "_WINGS");
|
||||
str = str.replace("EXPERIENCE_", "");
|
||||
}
|
||||
return str;
|
||||
}
|
||||
|
||||
public static void sound(Location paramLocation, String paramString, float paramFloat1, float paramFloat2) {
|
||||
String str = getModifiedSound(paramString);
|
||||
try {
|
||||
paramLocation.getWorld().playSound(paramLocation, Sound.valueOf(str), paramFloat1, paramFloat2);
|
||||
} catch (Exception localException) {
|
||||
MsgUtils.send("§4Bug with " + paramString + ". No such sound found. Please report it to the plugin creator :)");
|
||||
}
|
||||
}
|
||||
|
||||
static String getModifiedSound(String str) {
|
||||
if (TabooLib.getVerint() < 10900) {
|
||||
str = str.replace("BLOCK_FIRE_EXTINGUISH", "FIZZ");
|
||||
str = str.replace("BLOCK_NOTE_HAT", "NOTE_STICKS");
|
||||
str = str.replace("ENTITY_SHEEP_DEATH", "SHEEP_IDLE");
|
||||
str = str.replace("ENTITY_LLAMA_ANGRY", "HORSE_HIT");
|
||||
str = str.replace("BLOCK_BREWING_STAND_BREW", "CREEPER_HISS");
|
||||
str = str.replace("ENTITY_SHULKER_TELEPORT", "ENDERMAN_TELEPORT");
|
||||
str = str.replace("ENTITY_ZOMBIE_ATTACK_IRON_DOOR", "ZOMBIE_METAL");
|
||||
str = str.replace("BLOCK_GRAVEL_BREAK", "DIG_GRAVEL");
|
||||
str = str.replace("BLOCK_SNOW_BREAK", "DIG_SNOW");
|
||||
str = str.replace("BLOCK_GRAVEL_BREAK", "DIG_GRAVEL");
|
||||
str = str.replace("ENTITY_PLAYER_LEVELUP", "LEVEL_UP");
|
||||
str = str.replace("ENTITY_SNOWBALL_THROW", "SHOOT_ARROW");
|
||||
str = str.replace("PLAYER_ATTACK_CRIT", "ITEM_BREAK");
|
||||
str = str.replace("ENDERMEN", "ENDERMAN");
|
||||
str = str.replace("ARROW_SHOOT", "SHOOT_ARROW");
|
||||
str = str.replace("ENDERMAN_HURT", "ENDERMAN_HIT");
|
||||
str = str.replace("BLAZE_HURT", "BLAZE_HIT");
|
||||
str = str.replace("_FLAP", "_WINGS");
|
||||
str = str.replaceAll("ENTITY_|GENERIC_|BLOCK_|_AMBIENT|_BREAK|UI_BUTTON_|EXPERIENCE_", "");
|
||||
}
|
||||
return str;
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user