Skip to content

Commit

Permalink
Merge pull request #451 from ArcanePlugins/3.9-dev
Browse files Browse the repository at this point in the history
3.9 dev
  • Loading branch information
lokka30 authored Apr 19, 2023
2 parents d48206b + 48dfd11 commit 1429bf8
Show file tree
Hide file tree
Showing 24 changed files with 286 additions and 883 deletions.
109 changes: 51 additions & 58 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -6,36 +6,35 @@

<groupId>me.lokka30</groupId>
<artifactId>LevelledMobs</artifactId>
<version>3.9.5 b743</version>
<version>3.10.0 b752</version>

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

<packaging>jar</packaging>

<properties>
<java.version>17</java.version>
<maven.compiler.source>17</maven.compiler.source>
<maven.compiler.target>17</maven.compiler.target>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>

<bstats.version>3.0.1</bstats.version>
<microlib.version>3.2.0</microlib.version>

<paper.version>1.19.4-R0.1-SNAPSHOT</paper.version>
<essentialsx.version>2.19.7</essentialsx.version>
<placeholderapi.version>2.11.2</placeholderapi.version>
<authlib.version>3.3.39</authlib.version>
<worldguard.version>7.0.7</worldguard.version>
<protocollib.version>4.8.0</protocollib.version>
<item-nbt.version>2.11.1</item-nbt.version>
<lm-items.version>1.1.0</lm-items.version>
</properties>

<build>
<defaultGoal>clean package</defaultGoal>
<finalName>${project.name}-${project.version}</finalName>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<version>3.10.1</version>
<configuration>
<source>17</source>
<target>17</target>
</configuration>
</plugin>
<plugin>
<groupId>net.md-5</groupId>
<artifactId>specialsource-maven-plugin</artifactId>
<version>1.2.4</version>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-shade-plugin</artifactId>
Expand Down Expand Up @@ -75,11 +74,6 @@
</goals>
<configuration>
<createDependencyReducedPom>false</createDependencyReducedPom>
<artifactSet>
<includes>
<include>*:*</include>
</includes>
</artifactSet>
</configuration>
</execution>
</executions>
Expand All @@ -94,6 +88,10 @@
</build>

<repositories>
<repository>
<id>papermc</id>
<url>https://repo.papermc.io/repository/maven-public/</url>
</repository>
<repository>
<id>essentials-releases</id>
<url>https://repo.essentialsx.net/releases/</url>
Expand All @@ -102,10 +100,6 @@
<id>placeholderapi</id>
<url>https://repo.extendedclip.com/content/repositories/placeholderapi/</url>
</repository>
<repository>
<id>spigotmc-repo</id>
<url>https://hub.spigotmc.org/nexus/content/groups/public/</url>
</repository>
<repository>
<id>sonatype</id>
<url>https://oss.sonatype.org/content/groups/public/</url>
Expand All @@ -125,77 +119,76 @@
</repositories>

<dependencies>
<!-- Dependencies which are shaded in LM -->
<dependency>
<groupId>com.github.lokka30</groupId>
<artifactId>MicroLib</artifactId>
<version>${microlib.version}</version>
<scope>compile</scope>
</dependency>
<dependency>
<groupId>org.bstats</groupId>
<artifactId>bstats-bukkit</artifactId>
<version>${bstats.version}</version>
<scope>compile</scope>
</dependency>

<!-- Compile-only dependencies -->
<dependency>
<groupId>net.essentialsx</groupId>
<artifactId>EssentialsX</artifactId>
<version>2.19.7</version>
<version>${essentialsx.version}</version>
<scope>provided</scope>
<!-- For some weird ass reason the essentials dependency, even though provided,
provides us spigot as a transitive dependency, which makes maven go wild! Even though
we do not compile essentials, we have to exclude it -->
<exclusions>
<exclusion>
<groupId>org.spigotmc</groupId>
<artifactId>spigot-api</artifactId>
</exclusion>
</exclusions>
</dependency>
<dependency>
<groupId>io.papermc.paper</groupId>
<artifactId>paper-api</artifactId>
<version>1.19.3-R0.1-SNAPSHOT</version>
<version>${paper.version}</version>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>me.clip</groupId>
<artifactId>placeholderapi</artifactId>
<version>2.11.2</version>
<version>${placeholderapi.version}</version>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>com.mojang</groupId>
<artifactId>authlib</artifactId>
<version>3.3.39</version>
<scope>provided</scope>
</dependency>
<!--suppress VulnerableLibrariesLocal -->
<dependency>
<groupId>org.spigotmc</groupId>
<artifactId>spigot-api</artifactId>
<version>1.19.3-R0.1-SNAPSHOT</version>
<version>${authlib.version}</version>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>org.bstats</groupId>
<artifactId>bstats-bukkit</artifactId>
<version>3.0.0</version>
<scope>compile</scope>
</dependency>
<dependency>
<groupId>com.sk89q.worldguard</groupId>
<artifactId>worldguard-bukkit</artifactId>
<version>7.0.7</version>
<version>${worldguard.version}</version>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>com.github.lokka30</groupId>
<artifactId>MicroLib</artifactId>
<version>3.2.0</version>
<scope>compile</scope>
</dependency>
<dependency>
<groupId>com.github.dmulloy2</groupId>
<artifactId>ProtocolLib</artifactId>
<version>4.8.0</version>
<version>${protocollib.version}</version>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>de.tr7zw</groupId>
<artifactId>item-nbt-api-plugin</artifactId>
<version>2.11.1</version>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>com.google.code.gson</groupId>
<artifactId>gson</artifactId>
<version>2.10.1</version>
<version>${item-nbt.version}</version>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>io.github.stumper66</groupId>
<artifactId>LM_Items</artifactId>
<version>1.1.0</version>
<version>${lm-items.version}</version>
<scope>provided</scope>
</dependency>
</dependencies>
Expand Down
1 change: 0 additions & 1 deletion src/main/java/me/lokka30/levelledmobs/Companion.java
Original file line number Diff line number Diff line change
Expand Up @@ -167,7 +167,6 @@ boolean loadFiles(final boolean isReload) {
main.customDropsHandler = new CustomDropsHandler(main);

if (!isReload) {
main.attributesCfg = loadEmbeddedResource("defaultAttributes.yml");
main.dropsCfg = loadEmbeddedResource("defaultDrops.yml");
main.mobHeadManager.loadTextures(
Objects.requireNonNull(loadEmbeddedResource("textures.yml")));
Expand Down
1 change: 0 additions & 1 deletion src/main/java/me/lokka30/levelledmobs/LevelledMobs.java
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,6 @@ public final class LevelledMobs extends JavaPlugin {
// Configuration
public YamlConfiguration settingsCfg;
public YamlConfiguration messagesCfg;
public YamlConfiguration attributesCfg;
public YamlConfiguration dropsCfg;
public final ConfigUtils configUtils = new ConfigUtils(this);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ public void parseSubcommand(final LevelledMobs main, final @NotNull CommandSende
}

if (args.length <= 1) {
sender.sendMessage("Options: create / chunk_kill_count / nbt_dump / mylocation");
sender.sendMessage("Options: create / chunk_kill_count / nbt_dump / mylocation / spawn_distance");
return;
}

Expand All @@ -64,12 +64,66 @@ public void parseSubcommand(final LevelledMobs main, final @NotNull CommandSende
}
} else if ("mylocation".equalsIgnoreCase(args[1])){
showPlayerLocation(sender);
}
else {
} else if ("spawn_distance".equalsIgnoreCase(args[1])) {
showSpawnDistance(sender, args);
} else {
showMessage("other.create-debug");
}
}

private void showSpawnDistance(final @NotNull CommandSender sender, final String @NotNull [] args){
Player player = null;
if (!(sender instanceof Player) && args.length < 3) {
sender.sendMessage("Must specify a player when running this command from console");
return;
}
if (args.length >= 3) {
player = Bukkit.getPlayer(args[2]);
if (player == null) {
sender.sendMessage("Invalid playername: " + args[2]);
return;
}
}

if (player == null) {
player = (Player) sender;
}

final LivingEntityWrapper lmEntity = main.levelledMobsCommand.rulesSubcommand.getMobBeingLookedAt(
player, true, sender);

if (lmEntity == null){
sender.sendMessage("Could not locate any mobs near player: " + player.getName());
return;
}

final double distance = lmEntity.getDistanceFromSpawn();

final String locationStr = String.format("%s, %s, %s",
lmEntity.getLivingEntity().getLocation().getBlockX(),
lmEntity.getLivingEntity().getLocation().getBlockY(),
lmEntity.getLivingEntity().getLocation().getBlockZ());
final String mobLevel = lmEntity.isLevelled() ? String.valueOf(lmEntity.getMobLevel()) : "0";

String entityName = lmEntity.getTypeName();
if (ExternalCompatibilityManager.hasMythicMobsInstalled()
&& ExternalCompatibilityManager.isMythicMob(lmEntity)) {
entityName = ExternalCompatibilityManager.getMythicMobInternalName(lmEntity);
}

final String message = String.format(
"Spawn distance is %s for: %s (lvl %s %s) in %s, %s",
Utils.round(distance, 1),
entityName,
mobLevel,
lmEntity.getNameIfBaby(),
lmEntity.getWorldName(),
locationStr);

lmEntity.free();
sender.sendMessage(message);
}

private void showPlayerLocation(final @NotNull CommandSender sender){
if (!(sender instanceof final Player player)){
sender.sendMessage("The command must be run by a player");
Expand Down Expand Up @@ -118,7 +172,7 @@ private void doNbtDump(final @NotNull CommandSender sender, final String @NotNul
lmEntity.getLivingEntity().getLocation().getBlockX(),
lmEntity.getLivingEntity().getLocation().getBlockY(),
lmEntity.getLivingEntity().getLocation().getBlockZ());
final String mobLevel = lmEntity.isLevelled() ? lmEntity.getMobLevel() + "" : "0";
final String mobLevel = lmEntity.isLevelled() ? String.valueOf(lmEntity.getMobLevel()) : "0";

final String message = String.format(
"Showing nbt dump for: %s (lvl %s %s) in %s, %s\n%s",
Expand Down Expand Up @@ -154,7 +208,7 @@ public List<String> parseTabCompletions(final LevelledMobs main, final CommandSe
final String @NotNull [] args) {

if (args.length <= 2) {
return List.of("create", "chunk_kill_count", "mylocation", "nbt_dump");
return List.of("create", "chunk_kill_count", "mylocation", "nbt_dump", "spawn_distance");
}
if ("chunk_kill_count".equalsIgnoreCase(args[1])) {
return List.of("reset");
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -361,7 +361,7 @@ private void showEffectiveRules(@NotNull final Player player, final boolean show
lmEntity.getLivingEntity().getLocation().getBlockX(),
lmEntity.getLivingEntity().getLocation().getBlockY(),
lmEntity.getLivingEntity().getLocation().getBlockZ());
final String mobLevel = lmEntity.isLevelled() ? lmEntity.getMobLevel() + "" : "0";
final String mobLevel = lmEntity.isLevelled() ? String.valueOf(lmEntity.getMobLevel()) : "0";
final List<String> messages = getMessage("command.levelledmobs.rules.effective-rules",
new String[]{"%mobname%", "%entitytype%", "%location%", "%world%", "%level%"},
new String[]{entityName, lmEntity.getNameIfBaby(), locationStr, lmEntity.getWorldName(),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,15 +28,15 @@ public CustomDropInstance(final @Nullable EntityType associatedMob) {
this.isBabyMob = false;
}

CustomDropInstance(final @NotNull EntityType associatedMob, final boolean isBabyMob) {
public CustomDropInstance(final @NotNull EntityType associatedMob, final boolean isBabyMob) {
this.associatedMob = associatedMob;
this.entityGroup = null;
this.customItems = new LinkedList<>();
this.overallPermissions = new LinkedList<>();
this.isBabyMob = isBabyMob;
}

CustomDropInstance(final @NotNull CustomUniversalGroups entityGroup) {
public CustomDropInstance(final @NotNull CustomUniversalGroups entityGroup) {
this.associatedMob = null;
this.entityGroup = entityGroup;
this.customItems = new LinkedList<>();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -533,6 +533,7 @@ && isCustomDropsDebuggingEnabled()) {
return;
}

final boolean runOnSpawn = dropBase instanceof CustomCommand cc && cc.runOnSpawn;
boolean didNotMakeChance = false;
float chanceRole = 0.0F;

Expand All @@ -553,14 +554,14 @@ && hasReachedChunkKillLimit(info.lmEntity)) {
return;
}

if (!info.equippedOnly && dropBase.chance < 1.0) {
if ((!info.equippedOnly || runOnSpawn) && dropBase.chance < 1.0) {
chanceRole = (float) ThreadLocalRandom.current().nextInt(0, 100001) * 0.00001F;
if (1.0F - chanceRole >= dropBase.chance) {
didNotMakeChance = true;
}
}

if (didNotMakeChance && !info.equippedOnly && isCustomDropsDebuggingEnabled()) {
if (didNotMakeChance && (!info.equippedOnly || runOnSpawn) && isCustomDropsDebuggingEnabled()) {
if (dropBase instanceof final CustomDropItem dropItem) {
final ItemStack itemStack =
info.deathByFire ? getCookedVariantOfMeat(dropItem.getItemStack())
Expand All @@ -574,8 +575,14 @@ && hasReachedChunkKillLimit(info.lmEntity)) {
);
}
}
else if (isCustomDropsDebuggingEnabled()){
info.addDebugMessage(String.format(
"&8 - &7Custom command&7, chance: &b%s&7, chanceRole: &b%s&7, executed: &bfalse&7.",
dropBase.chance, Utils.round(chanceRole, 4))
);
}
}
if (!info.equippedOnly && didNotMakeChance) {
if ((!info.equippedOnly || runOnSpawn) && didNotMakeChance) {
return;
}

Expand Down Expand Up @@ -987,7 +994,7 @@ private boolean madePlayerLevelRequirement(final @NotNull CustomDropProcessingIn
} else {
//levelToUse = main.levelManager.getPlayerLevelSourceNumber(info.mobKiller, variableToUse);
final PlayerLevelSourceResult result = main.levelManager.getPlayerLevelSourceNumber(
info.mobKiller, variableToUse);
info.mobKiller, info.lmEntity, variableToUse);
levelToUse = result.isNumericResult ? result.numericResult : 1;
info.playerLevelVariableCache.put(variableToUse, levelToUse);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1077,8 +1077,9 @@ private void showCustomDropsDebugInfo(final StringBuilder sbMain) {
item.getMaterial() != null ? item.getMaterial().toString() : "(unknown)";
sb.append(String.format(" &b%s&r, amount: &b%s&r, chance: &b%s&r", itemMaterial,
item.getAmountAsString(), baseItem.chance));
} else {
sb.append(String.format(" COMMAND, chance: &b%s&r", baseItem.chance));
} else if (baseItem instanceof final CustomCommand cc) {
sb.append(String.format(" COMMAND, chance: &b%s&r, run-on-spawn: %s, run-on-death: %s",
baseItem.chance, cc.runOnSpawn, cc.runOnDeath));
}

if (baseItem.minLevel > -1) {
Expand Down
Loading

0 comments on commit 1429bf8

Please sign in to comment.