mirror of
https://github.com/ViaVersion/ViaVersion.git
synced 2025-01-12 02:30:38 +01:00
Merge pull request #265 from HugoDaBosss/apiv2
Optimise SoundEffect searching
This commit is contained in:
commit
ad53c1ed7f
@ -2,6 +2,8 @@ package us.myles.ViaVersion.protocols.protocol1_9to1_8.sounds;
|
|||||||
|
|
||||||
import lombok.Getter;
|
import lombok.Getter;
|
||||||
|
|
||||||
|
import java.util.HashMap;
|
||||||
|
|
||||||
@Getter
|
@Getter
|
||||||
public enum SoundEffect {
|
public enum SoundEffect {
|
||||||
|
|
||||||
@ -257,6 +259,14 @@ public enum SoundEffect {
|
|||||||
private final SoundCategory category;
|
private final SoundCategory category;
|
||||||
private final boolean breaksound;
|
private final boolean breaksound;
|
||||||
|
|
||||||
|
private static HashMap<String, SoundEffect> effects;
|
||||||
|
static {
|
||||||
|
effects = new HashMap<String, SoundEffect>();
|
||||||
|
for(SoundEffect e : SoundEffect.values()) {
|
||||||
|
effects.put(e.getName(), e);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
SoundEffect(String name, String newname, SoundCategory cat) {
|
SoundEffect(String name, String newname, SoundCategory cat) {
|
||||||
this.category = cat;
|
this.category = cat;
|
||||||
this.newName = newname;
|
this.newName = newname;
|
||||||
@ -273,10 +283,8 @@ public enum SoundEffect {
|
|||||||
|
|
||||||
public static SoundEffect getByName(String name) {
|
public static SoundEffect getByName(String name) {
|
||||||
name = name.toLowerCase();
|
name = name.toLowerCase();
|
||||||
for (SoundEffect e : SoundEffect.values()) {
|
if(effects.containsKey(name))
|
||||||
if (e.getName().equals(name))
|
return effects.get(name);
|
||||||
return e;
|
|
||||||
}
|
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user