Skip to content

Commit 02e480e

Browse files
committed
Just some small updates
1 parent d5e01a4 commit 02e480e

File tree

1 file changed

+12
-20
lines changed

1 file changed

+12
-20
lines changed

src/main/java/ch/njol/skript/expressions/ExprEntitySound.java

Lines changed: 12 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -121,13 +121,9 @@ public Sound getSound(LivingEntity entity, int height, ItemStack item, boolean b
121121
}
122122

123123
private boolean bigOrSpeedy;
124-
@SuppressWarnings("NotNullFieldNotInitialized")
125124
private SoundType soundType;
126-
@SuppressWarnings("NotNullFieldNotInitialized")
127125
private Expression<Number> height;
128-
@SuppressWarnings("NotNullFieldNotInitialized")
129126
private Expression<LivingEntity> entities;
130-
@SuppressWarnings("NotNullFieldNotInitialized")
131127
private Expression<ItemType> item;
132128

133129
@Override
@@ -145,12 +141,10 @@ public boolean init(Expression<?>[] exprs, int matchedPattern, Kleenean isDelaye
145141

146142
@Override
147143
protected String @Nullable [] get(Event event) {
148-
//noinspection ConstantValue
149-
int height = this.height == null ? -1 : this.height.getOptionalSingle(event).orElse(-1).intValue();
144+
int height = this.height == null ? -1 : this.height.getOptionalSingle(event).orElse(-1).intValue();
150145

151146
ItemStack defaultItem = new ItemStack(soundType == SoundType.EAT ? Material.COOKED_BEEF : Material.POTION);
152-
//noinspection ConstantValue
153-
ItemStack item = this.item == null ? defaultItem : this.item.getOptionalSingle(event).map(ItemType::getRandom).orElse(defaultItem);
147+
ItemStack item = this.item == null ? defaultItem : this.item.getOptionalSingle(event).map(ItemType::getRandom).orElse(defaultItem);
154148

155149
return entities.stream(event)
156150
.map(entity -> soundType.getSound(entity, height, item, bigOrSpeedy))
@@ -172,29 +166,27 @@ public Class<? extends String> getReturnType() {
172166

173167
@Override
174168
public String toString(@Nullable Event event, boolean debug) {
175-
String soundDescription = "unknown";
169+
String sound = "unknown";
176170
switch (soundType) {
177-
case DAMAGE, DEATH, SWIM, AMBIENT -> soundDescription = soundType.name().toLowerCase();
171+
case DAMAGE, DEATH, SWIM, AMBIENT -> sound = soundType.name().toLowerCase();
178172
case FALL -> {
179-
//noinspection ConstantValue
180-
if (this.height == null) {
181-
soundDescription = bigOrSpeedy ? "high fall damage" : "normal fall damage";
173+
if (this.height == null) {
174+
sound = bigOrSpeedy ? "high fall damage" : "normal fall damage";
182175
} else {
183-
soundDescription = "fall damage from a height of " + this.height.toString(event, debug);
176+
sound = "fall damage from a height of " + this.height.toString(event, debug);
184177
}
185178
}
186-
case SPLASH -> soundDescription = bigOrSpeedy ? "speedy splash" : "splash";
179+
case SPLASH -> sound = bigOrSpeedy ? "speedy splash" : "splash";
187180
case EAT, DRINK -> {
188181
String action = soundType == SoundType.EAT ? "eating" : "drinking";
189-
//noinspection ConstantValue
190-
if (this.item == null) {
191-
soundDescription = action;
182+
if (this.item == null) {
183+
sound = action;
192184
} else {
193-
soundDescription = action + " " + this.item.toString(event, debug);
185+
sound = action + " " + this.item.toString(event, debug);
194186
}
195187
}
196188
}
197-
return soundDescription + " sound of " + entities.toString(event, debug);
189+
return sound + " sound of " + entities.toString(event, debug);
198190
}
199191

200192
}

0 commit comments

Comments
 (0)