Skip to content

Commit

Permalink
Merge branch '3.9-dev'
Browse files Browse the repository at this point in the history
  • Loading branch information
lokka30 committed Jan 10, 2023
2 parents d23233c + 04ac4a8 commit 6e97c32
Show file tree
Hide file tree
Showing 21 changed files with 451 additions and 371 deletions.
22 changes: 13 additions & 9 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,12 @@

<groupId>me.lokka30</groupId>
<artifactId>LevelledMobs</artifactId>
<version>3.9.1 b730</version>
<packaging>jar</packaging>
<version>3.9.2 b734</version>

<name>LevelledMobs</name>
<description>The Ultimate RPG Mob Levelling Plugin</description>
<description>The Ultimate RPG Mob Levelling Solution</description>

<packaging>jar</packaging>

<properties>
<java.version>17</java.version>
Expand All @@ -25,28 +27,28 @@
<artifactId>maven-compiler-plugin</artifactId>
<version>3.10.1</version>
<configuration>
<source>16</source>
<target>16</target>
<source>17</source>
<target>17</target>
</configuration>
</plugin>
<plugin>
<groupId>net.md-5</groupId>
<artifactId>specialsource-maven-plugin</artifactId>
<version>1.2.2</version>
<version>1.2.4</version>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-shade-plugin</artifactId>
<version>3.3.0</version>
<version>3.4.1</version>
<configuration>
<relocations>
<relocation>
<pattern>org.bstats</pattern>
<shadedPattern>me.lokka30.levelledmobs.bstats</shadedPattern>
<shadedPattern>me.lokka30.levelledmobs.lib.bstats</shadedPattern>
</relocation>
<relocation>
<pattern>me.lokka30.microlib</pattern>
<shadedPattern>${project.groupId}.microlib</shadedPattern>
<shadedPattern>me.lokka30.levelledmobs.lib.microlib</shadedPattern>
</relocation>
</relocations>
<filters>
Expand Down Expand Up @@ -125,6 +127,7 @@
<url>https://maven.enginehub.org/repo/</url>
</repository>
</repositories>

<dependencies>
<dependency>
<groupId>net.essentialsx</groupId>
Expand All @@ -150,6 +153,7 @@
<version>3.3.39</version>
<scope>provided</scope>
</dependency>
<!--suppress VulnerableLibrariesLocal -->
<dependency>
<groupId>org.spigotmc</groupId>
<artifactId>spigot-api</artifactId>
Expand Down
4 changes: 2 additions & 2 deletions src/main/java/me/lokka30/levelledmobs/Companion.java
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@
import me.lokka30.levelledmobs.misc.FileLoader;
import me.lokka30.levelledmobs.misc.FileMigrator;
import me.lokka30.levelledmobs.misc.VersionInfo;
import me.lokka30.levelledmobs.nms.ServerVersionInfo;
import me.lokka30.levelledmobs.nametag.ServerVersionInfo;
import me.lokka30.levelledmobs.rules.MetricsInfo;
import me.lokka30.levelledmobs.util.Utils;
import me.lokka30.microlib.exceptions.OutdatedServerVersionException;
Expand Down Expand Up @@ -572,7 +572,7 @@ void shutDownAsyncTasks() {
}

private void buildUniversalGroups() {
final ServerVersionInfo versionInfo = main.nametagQueueManager.nmsHandler.versionInfo;
final ServerVersionInfo versionInfo = main.nametagQueueManager.nametagSenderHandler.versionInfo;

// include interfaces: Monster, Boss
hostileMobsGroup = Stream.of(
Expand Down
2 changes: 1 addition & 1 deletion src/main/java/me/lokka30/levelledmobs/LevelledMobs.java
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@
import me.lokka30.levelledmobs.misc.NamespacedKeys;
import me.lokka30.levelledmobs.misc.NametagTimerChecker;
import me.lokka30.levelledmobs.misc.YmlParsingHelper;
import me.lokka30.levelledmobs.nms.Definitions;
import me.lokka30.levelledmobs.nametag.Definitions;
import me.lokka30.levelledmobs.rules.RulesManager;
import me.lokka30.levelledmobs.rules.RulesParsingManager;
import me.lokka30.levelledmobs.util.ConfigUtils;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
import me.lokka30.levelledmobs.managers.ExternalCompatibilityManager;
import me.lokka30.levelledmobs.misc.DebugCreator;
import me.lokka30.levelledmobs.misc.LivingEntityWrapper;
import me.lokka30.levelledmobs.nms.MiscUtils;
import me.lokka30.levelledmobs.nametag.MiscUtils;
import me.lokka30.levelledmobs.util.Utils;
import org.bukkit.Bukkit;
import org.bukkit.Location;
Expand Down Expand Up @@ -54,7 +54,7 @@ public void parseSubcommand(final LevelledMobs main, final @NotNull CommandSende
} else if ("chunk_kill_count".equalsIgnoreCase(args[1])) {
chunkKillCount(sender, args);
} else if ("nbt_dump".equalsIgnoreCase(args[1])) {
if (!main.nametagQueueManager.nmsHandler.versionInfo.isNMSVersionValid()){
if (!main.nametagQueueManager.nametagSenderHandler.versionInfo.isNMSVersionValid()){
sender.sendMessage("Unable to dump, an unknown NMS version was detected");
return;
}
Expand Down Expand Up @@ -127,7 +127,7 @@ private void doNbtDump(final @NotNull CommandSender sender, final String @NotNul
lmEntity.getNameIfBaby(),
lmEntity.getWorldName(),
locationStr,
MiscUtils.getNBTDump(lmEntity.getLivingEntity(), main)
MiscUtils.getNBTDump(lmEntity.getLivingEntity())
);

lmEntity.free();
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 Expand Up @@ -168,7 +175,7 @@ private void updateDeathMessage(final @NotNull PlayerDeathEvent event, final @No
}

private @NotNull Component buildPlayerComponent(final @NotNull Player player){
final Component playerName = main.nametagQueueManager.nmsHandler.versionInfo.getMinecraftVersion() >= 1.18 ?
final Component playerName = main.nametagQueueManager.nametagSenderHandler.versionInfo.getMinecraftVersion() >= 1.18 ?
player.name() : Component.text(player.getName());
final HoverEvent<HoverEvent.ShowEntity> hoverEvent = HoverEvent.showEntity(
Key.key("minecraft"), player.getUniqueId(), playerName);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -878,7 +878,7 @@ public void run() {
}

public void updateNametag(final LivingEntityWrapper lmEntity) {
final boolean preserveMobName = !main.nametagQueueManager.nmsHandler.isUsingProtocolLib;
final boolean preserveMobName = !main.nametagQueueManager.nametagSenderHandler.isUsingProtocolLib;
final NametagResult nametag = getNametag(lmEntity, false, preserveMobName);

final QueueItem queueItem = new QueueItem(
Expand Down Expand Up @@ -1142,7 +1142,7 @@ private void checkLevelledEntity(@NotNull final LivingEntityWrapper lmEntity,
location.getWorld().equals(lmEntity.getWorld()) &&
lmEntity.getLocation().distanceSquared(location) <= maxDistance) {
//if within distance, update nametag.
final boolean preserveMobName = !main.nametagQueueManager.nmsHandler.isUsingProtocolLib;
final boolean preserveMobName = !main.nametagQueueManager.nametagSenderHandler.isUsingProtocolLib;
final NametagResult nametag = main.levelManager.getNametag(lmEntity, false, preserveMobName);
main.nametagQueueManager.addToQueue(
new QueueItem(lmEntity, nametag, List.of(player)));
Expand Down
Loading

0 comments on commit 6e97c32

Please sign in to comment.