Skip to content

Commit

Permalink
v3.9.2 b733
Browse files Browse the repository at this point in the history
* if `creature-death-nametag` in rules.yml doesn't contain `%displayname%` it will no longer display strange death nametags
  • Loading branch information
stumper66 committed Jan 5, 2023
1 parent cb7ca5c commit 19ee538
Show file tree
Hide file tree
Showing 5 changed files with 57 additions and 80 deletions.
2 changes: 1 addition & 1 deletion pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@

<groupId>me.lokka30</groupId>
<artifactId>LevelledMobs</artifactId>
<version>3.9.2 b732</version>
<version>3.9.2 b733</version>

<name>LevelledMobs</name>
<description>The Ultimate RPG Mob Levelling Solution</description>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -97,30 +97,20 @@ private void parseEggCommand(final String[] args) {
}

switch (command) {
case "/name":
info.customName = foundValue;
break;
case "/customdropid":
info.customDropId = foundValue;
break;
case "/lore":
info.customLore = foundValue;
break;
case "/entity":
case "/name" -> info.customName = foundValue;
case "/customdropid" -> info.customDropId = foundValue;
case "/lore" -> info.customLore = foundValue;
case "/entity" -> {
try {
info.spawnType = EntityType.valueOf(foundValue.toUpperCase());
} catch (final Exception ignored) {
commandSender.sendMessage("Invalid spawn type: " + foundValue);
return;
}
break;
case "/minlevel":
info.minLevel = Integer.parseInt(foundValue);
break;
case "/maxlevel":
info.maxLevel = Integer.parseInt(foundValue);
break;
case "/giveplayer":
}
case "/minlevel" -> info.minLevel = Integer.parseInt(foundValue);
case "/maxlevel" -> info.maxLevel = Integer.parseInt(foundValue);
case "/giveplayer" -> {
if (Utils.isNullOrEmpty(foundValue)) {
showMessage("command.levelledmobs.spawn_egg.no-player-specified");
return;
Expand All @@ -135,7 +125,7 @@ private void parseEggCommand(final String[] args) {
showMessage("common.player-offline", "%player%", foundValue);
return;
}
break;
}
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -181,51 +181,27 @@ private void parseCreateCommand(final String[] args) {
}

switch (command) {
case "/name":
info.customName = foundValue;
break;
case "/customdropid":
info.customDropId = foundValue;
break;
case "/lore":
info.customLore = foundValue;
break;
case "/spawntype":
case "/name" -> info.customName = foundValue;
case "/customdropid" -> info.customDropId = foundValue;
case "/lore" -> info.customLore = foundValue;
case "/spawntype" -> {
try {
info.spawnType = EntityType.valueOf(foundValue.toUpperCase());
} catch (final Exception ignored) {
commandSender.sendMessage("Invalid spawn type: " + foundValue);
return;
}
break;
case "/minlevel":
info.minLevel = Integer.parseInt(foundValue);
break;
case "/maxlevel":
info.maxLevel = Integer.parseInt(foundValue);
break;
case "/delay":
info.delay = Integer.parseInt(foundValue);
break;
case "/maxnearbyentities":
info.maxNearbyEntities = Integer.parseInt(foundValue);
break;
case "/minspawndelay":
info.minSpawnDelay = Integer.parseInt(foundValue);
break;
case "/maxspawndelay":
info.maxSpawnDelay = Integer.parseInt(foundValue);
break;
case "/requiredplayerrange":
info.requiredPlayerRange = Integer.parseInt(foundValue);
break;
case "/spawncount":
info.spawnCount = Integer.parseInt(foundValue);
break;
case "/spawnrange":
info.spawnRange = Integer.parseInt(foundValue);
break;
case "/giveplayer":
}
case "/minlevel" -> info.minLevel = Integer.parseInt(foundValue);
case "/maxlevel" -> info.maxLevel = Integer.parseInt(foundValue);
case "/delay" -> info.delay = Integer.parseInt(foundValue);
case "/maxnearbyentities" -> info.maxNearbyEntities = Integer.parseInt(foundValue);
case "/minspawndelay" -> info.minSpawnDelay = Integer.parseInt(foundValue);
case "/maxspawndelay" -> info.maxSpawnDelay = Integer.parseInt(foundValue);
case "/requiredplayerrange" -> info.requiredPlayerRange = Integer.parseInt(foundValue);
case "/spawncount" -> info.spawnCount = Integer.parseInt(foundValue);
case "/spawnrange" -> info.spawnRange = Integer.parseInt(foundValue);
case "/giveplayer" -> {
if (Utils.isNullOrEmpty(foundValue)) {
showMessage("command.levelledmobs.spawner.no-player-specified");
return;
Expand All @@ -240,7 +216,7 @@ private void parseCreateCommand(final String[] args) {
showMessage("common.player-offline", "%player%", foundValue);
return;
}
break;
}
}
}

Expand Down Expand Up @@ -380,7 +356,7 @@ public List<String> parseTabCompletions(final LevelledMobs main,
if ("create".equalsIgnoreCase(args[1])) {
return tabCompletions_Create(args);
} else if (("info".equalsIgnoreCase(args[1]) || "copy".equalsIgnoreCase(args[1]))
&& args.length <= 3) {
&& args.length == 3) {
return Arrays.asList("on", "off");
}

Expand All @@ -390,32 +366,36 @@ public List<String> parseTabCompletions(final LevelledMobs main,
@NotNull private List<String> tabCompletions_Create(@NotNull final String @NotNull [] args) {
if (!Utils.isNullOrEmpty(args[args.length - 2])) {
switch (args[args.length - 2].toLowerCase()) {
case "/spawntype":
case "/spawntype" -> {
final List<String> entityNames = new LinkedList<>();
for (final EntityType entityType : EntityType.values()) {
entityNames.add(entityType.toString().toLowerCase());
}

return entityNames;
case "/delay":
}
case "/delay" -> {
return Collections.singletonList("0");
case "/minspawndelay":
}
case "/minspawndelay" -> {
return Collections.singletonList("200");
case "/maxspawndelay":
}
case "/maxspawndelay" -> {
return Collections.singletonList("800");
case "/maxnearbyentities":
case "/requiredplayerrange":
}
case "/maxnearbyentities", "/requiredplayerrange" -> {
return Collections.singletonList("16");
case "/spawncount":
case "/spawnrange":
}
case "/spawncount", "/spawnrange" -> {
return Collections.singletonList("4");
case "/giveplayer":
}
case "/giveplayer" -> {
final List<String> players = new LinkedList<>();
for (final Player player : Bukkit.getOnlinePlayers()) {
players.add(player.getName());
}
players.sort(String.CASE_INSENSITIVE_ORDER);
return players;
}
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -339,7 +339,7 @@ public List<String> parseTabCompletions(final LevelledMobs main,
// these are for atPlayer and atLocation
if (args.length > 5) {
switch (args[4].toLowerCase()) {
case "atplayer":
case "atplayer" -> {
if (args.length == 6) {
final List<String> suggestions = new LinkedList<>();
for (final Player onlinePlayer : Bukkit.getOnlinePlayers()) {
Expand All @@ -359,9 +359,8 @@ public List<String> parseTabCompletions(final LevelledMobs main,
return List.of();
}
}
break;

case "atlocation":
}
case "atlocation" -> {
if (args.length < 9) { // args 6, 7 and 8 = x, y and z
return List.of("~");
} else if (args.length == 9) {
Expand All @@ -375,16 +374,17 @@ public List<String> parseTabCompletions(final LevelledMobs main,
return List.of();
}
}

break;
case "here":
}
case "here" -> {
if (!skipOverride) {
return List.of("/override");
} else {
return List.of();
}
default:
}
default -> {
return List.of();
}
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -124,6 +124,7 @@ private void updateDeathMessage(final @NotNull PlayerDeathEvent event, final @No
return;
}
final String mobName = nametagResult.getNametagNonNull();
final int displayNameIndex = mobName.indexOf("{DisplayName}");

Component newCom;
if (nametagResult.hadCustomDeathMessage){
Expand All @@ -132,8 +133,14 @@ private void updateDeathMessage(final @NotNull PlayerDeathEvent event, final @No
newCom = LegacyComponentSerializer.legacyAmpersand().deserialize(mobName)
.replaceText(replacementConfig);
}
else if (displayNameIndex < 0){
// creature-death-nametag in rules.yml doesn't contain %displayname%
// so we'll just send the whole thing as text
newCom = Component.translatable(tc.key(),
buildPlayerComponent(event.getEntity()),
LegacyComponentSerializer.legacyAmpersand().deserialize(mobName));
}
else {
final int displayNameIndex = mobName.indexOf("{DisplayName}");
final Component leftComp = displayNameIndex > 0 ?
LegacyComponentSerializer.legacyAmpersand().deserialize(mobName.substring(0, displayNameIndex)) :
Component.empty();
Expand Down

0 comments on commit 19ee538

Please sign in to comment.