Skip to content

Commit

Permalink
Merge branch '3.2-dev'
Browse files Browse the repository at this point in the history
  • Loading branch information
lokka30 committed Oct 12, 2021
2 parents 5ce959d + 87da972 commit 7bee0d5
Show file tree
Hide file tree
Showing 74 changed files with 2,774 additions and 1,023 deletions.
3 changes: 2 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -12,4 +12,5 @@ LevelledMobs.iml
# Why? Different developers use different IDE settings.
.classpath
.project
/.settings
/.settings
.idea/jarRepositories.xml
8 changes: 1 addition & 7 deletions .idea/LevelledMobs.iml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

5 changes: 5 additions & 0 deletions .idea/jarRepositories.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

16 changes: 13 additions & 3 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@

<groupId>me.lokka30</groupId>
<artifactId>LevelledMobs</artifactId>
<version>3.1.8 b517</version>
<version>3.2.0 b531</version>
<packaging>jar</packaging>

<name>LevelledMobs</name>
Expand Down Expand Up @@ -45,7 +45,7 @@
</relocation>
<relocation>
<pattern>me.lokka30.microlib</pattern>
<shadedPattern>me.lokka30.levelledmobs.microlib</shadedPattern>
<shadedPattern>${project.groupId}.microlib</shadedPattern>
</relocation>
</relocations>
<filters>
Expand Down Expand Up @@ -113,6 +113,10 @@
<id>sk89q-repo</id>
<url>https://maven.enginehub.org/repo/</url>
</repository>
<repository>
<id>bs-repo</id>
<url>https://ci.pluginwiki.us/plugin/repository/everything/</url>
</repository>
</repositories>

<dependencies>
Expand Down Expand Up @@ -143,7 +147,7 @@
<dependency>
<groupId>com.sk89q.worldguard</groupId>
<artifactId>worldguard-bukkit</artifactId>
<version>7.0.4</version>
<version>7.0.5</version>
<scope>provided</scope>
</dependency>
<dependency>
Expand All @@ -163,5 +167,11 @@
<version>2.8.0</version>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>simplepets.brainsynder</groupId>
<artifactId>API</artifactId>
<version>5.0-BUILD-89</version>
<scope>provided</scope>
</dependency>
</dependencies>
</project>
3 changes: 2 additions & 1 deletion src/main/java/me/lokka30/levelledmobs/Companion.java
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ public class Companion {
final private MetricsInfo metricsInfo;

void checkWorldGuard() {
// Hook into WorldGuard, register LM's flags.
// Hook into WorldGuard
// This cannot be moved to onEnable (stated in WorldGuard's documentation). It MUST be ran in onLoad.
if (ExternalCompatibilityManager.hasWorldGuardInstalled()) {
main.worldGuardIntegration = new WorldGuardIntegration();
Expand Down Expand Up @@ -261,6 +261,7 @@ void setupMetrics() {
metrics.addCustomChart(new SimplePie("custom-entity-names", metricsInfo::customEntityNamesCount));
metrics.addCustomChart(new SimplePie("utilizes-nbtdata", metricsInfo::usesNbtData));
metrics.addCustomChart(new SimplePie("utilizes_player_levelling", metricsInfo::usesPlayerLevelling));
metrics.addCustomChart(new SimplePie("nametag_visibility", metricsInfo::nametagVisibility));
metrics.addCustomChart(new SimpleBarChart("enabled-compatibility", metricsInfo::enabledCompats));
}

Expand Down
14 changes: 10 additions & 4 deletions src/main/java/me/lokka30/levelledmobs/LevelledMobs.java
Original file line number Diff line number Diff line change
Expand Up @@ -10,9 +10,7 @@
import me.lokka30.levelledmobs.listeners.EntityDamageDebugListener;
import me.lokka30.levelledmobs.listeners.PlayerInteractEventListener;
import me.lokka30.levelledmobs.managers.*;
import me.lokka30.levelledmobs.misc.ConfigUtils;
import me.lokka30.levelledmobs.misc.Utils;
import me.lokka30.levelledmobs.misc.YmlParsingHelper;
import me.lokka30.levelledmobs.misc.*;
import me.lokka30.levelledmobs.rules.RulesManager;
import me.lokka30.levelledmobs.rules.RulesParsingManager;
import me.lokka30.microlib.QuickTimer;
Expand Down Expand Up @@ -43,18 +41,21 @@ public class LevelledMobs extends JavaPlugin {
public ChunkLoadListener chunkLoadListener;
public BlockPlaceListener blockPlaceListener;
public PlayerInteractEventListener playerInteractEventListener;
public Namespaced_Keys namespaced_keys;
public final Companion companion = new Companion(this);
public final MobHeadManager mobHeadManager = new MobHeadManager(this);
public final RulesParsingManager rulesParsingManager = new RulesParsingManager(this);
public final RulesManager rulesManager = new RulesManager(this);
public final MobsQueueManager _mobsQueueManager = new MobsQueueManager(this);
public final NametagQueueManager nametagQueueManager_ = new NametagQueueManager(this);
public final NametagTimerChecker nametagTimerChecker = new NametagTimerChecker(this);
public final Object attributeSyncObject = new Object();
public Random random;
public PlaceholderApiIntegration placeholderApiIntegration;
public boolean migratedFromPre30;
public YmlParsingHelper helperSettings;
public int playerLevellingMinRelevelTime;
public int maxPlayersRecorded;

// Configuration
public YamlConfiguration settingsCfg;
Expand All @@ -69,6 +70,7 @@ public class LevelledMobs extends JavaPlugin {
public int incompatibilitiesAmount;
private long loadTime;
public WeakHashMap<LivingEntity, Instant> playerLevellingEntities;
public Stack<LivingEntityWrapper> cacheCheck;

@Override
public void onLoad() {
Expand All @@ -84,6 +86,7 @@ public void onLoad() {
public void onEnable() {
final QuickTimer timer = new QuickTimer();

this.namespaced_keys = new Namespaced_Keys(this);
this.playerLevellingEntities = new WeakHashMap<>();
this.helperSettings = new YmlParsingHelper();
this.random = new Random();
Expand All @@ -100,7 +103,10 @@ public void onEnable() {
companion.loadSpigotConfig();

Utils.logger.info("&fStart-up: &7Running misc procedures...");
if (ExternalCompatibilityManager.hasProtocolLibInstalled()) levelManager.startNametagAutoUpdateTask();
if (ExternalCompatibilityManager.hasProtocolLibInstalled()) {
levelManager.startNametagAutoUpdateTask();
levelManager.startNametagTimer();
}
companion.setupMetrics();
companion.checkUpdates();

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -38,4 +38,12 @@ public interface LivingEntityInterface {
LevelledMobs getMainInstance();

double getDistanceFromSpawn();

int getSpawnedTimeOfDay();

void setSpawnedTimeOfDay(final int ticks);

void clearEntityData();

void free();
}
Original file line number Diff line number Diff line change
Expand Up @@ -13,9 +13,7 @@
import org.bukkit.command.TabCompleter;
import org.jetbrains.annotations.NotNull;

import java.util.Arrays;
import java.util.LinkedList;
import java.util.List;
import java.util.*;

/**
* This class handles the command execution of '/levelledmobs'.
Expand All @@ -33,47 +31,57 @@ public LevelledMobsCommand(final LevelledMobs main) {
rulesSubcommand = new RulesSubcommand(main);
}

// Retain alphabetical order please.
private final CompatibilitySubcommand compatibilitySubcommand = new CompatibilitySubcommand();
private final GenerateMobDataSubcommand generateMobDataSubcommand = new GenerateMobDataSubcommand();
private final InfoSubcommand infoSubcommand = new InfoSubcommand();
private final KillSubcommand killSubcommand = new KillSubcommand();
private final ReloadSubcommand reloadSubcommand = new ReloadSubcommand();
private final SummonSubcommand summonSubcommand = new SummonSubcommand();
private final CompatibilitySubcommand compatibilitySubcommand = new CompatibilitySubcommand();
private final GenerateMobDataSubcommand generateMobDataSubcommand = new GenerateMobDataSubcommand();
private final SpawnerSubCommand spawnerSubCommand;
private final RulesSubcommand rulesSubcommand;
private final SpawnerSubCommand spawnerSubCommand;
private final SummonSubcommand summonSubcommand = new SummonSubcommand();
private final DebugSubcommand debugSubcommand = new DebugSubcommand();

public boolean onCommand(@NotNull final CommandSender sender, final Command command, final String label, final String[] args) {
if (sender.hasPermission("levelledmobs.command")) {
if (args.length == 0) {
sendMainUsage(sender, label);
} else {
switch (args[0].toLowerCase()) {
case "kill":
killSubcommand.parseSubcommand(main, sender, label, args);
// Retain alphabetical order please.
case "compatibility":
compatibilitySubcommand.parseSubcommand(main, sender, label, args);
break;
case "reload":
reloadSubcommand.parseSubcommand(main, sender, label, args);
case "debug":
debugSubcommand.parseSubcommand(main, sender, label, args);
break;
case "summon":
summonSubcommand.parseSubcommand(main, sender, label, args);
case "generatemobdata":
generateMobDataSubcommand.parseSubcommand(main, sender, label, args);
break;
case "info":
infoSubcommand.parseSubcommand(main, sender, label, args);
break;
case "compatibility":
compatibilitySubcommand.parseSubcommand(main, sender, label, args);
case "kill":
killSubcommand.parseSubcommand(main, sender, label, args);
break;
case "generatemobdata":
generateMobDataSubcommand.parseSubcommand(main, sender, label, args);
case "reload":
reloadSubcommand.parseSubcommand(main, sender, label, args);
break;
case "rules":
rulesSubcommand.parseSubcommand(main, sender, label, args);
break;
case "spawner":
spawnerSubCommand.parseSubcommand(main, sender, label, args);
break;
case "rules":
rulesSubcommand.parseSubcommand(main, sender, label, args);
case "summon":
summonSubcommand.parseSubcommand(main, sender, label, args);
break;
case "test":
test(sender, args);
break;
default:
sendMainUsage(sender, label);
break;
}
}
} else {
Expand All @@ -82,23 +90,26 @@ public boolean onCommand(@NotNull final CommandSender sender, final Command comm
return true;
}

private void test(@NotNull final CommandSender sender, final String @NotNull [] args) {

}

private void sendMainUsage(@NotNull final CommandSender sender, final String label) {
List<String> mainUsage = main.messagesCfg.getStringList("command.levelledmobs.main-usage");

mainUsage = Utils.replaceAllInList(mainUsage, "%prefix%", main.configUtils.getPrefix());
mainUsage = Utils.replaceAllInList(mainUsage, "%label%", label);
mainUsage = Utils.colorizeAllInList(mainUsage);

mainUsage.forEach(sender::sendMessage);
}

// Retain alphabetical order please.
private final List<String> commandsToCheck = Arrays.asList("debug", "summon", "kill", "reload", "info", "compatibility", "spawner", "rules");

@Override
public List<String> onTabComplete(final CommandSender sender, final Command cmd, final String alias, @NotNull final String[] args) {
public List<String> onTabComplete(final CommandSender sender, final Command cmd, final String alias, @NotNull final String @NotNull [] args) {
if (args.length == 1) {
List<String> suggestions = new LinkedList<>();

List<String> commandsToCheck = Arrays.asList("summon", "kill", "reload", "info", "compatibility", "spawner", "rules");

commandsToCheck.forEach(command -> {
if (sender.hasPermission("levelledmobs.command." + command)) {
suggestions.add(command);
Expand All @@ -108,19 +119,20 @@ public List<String> onTabComplete(final CommandSender sender, final Command cmd,
return suggestions;
} else {
switch (args[0].toLowerCase()) {
case "summon":
return summonSubcommand.parseTabCompletions(main, sender, args);
case "kill":
return killSubcommand.parseTabCompletions(main, sender, args);
// Retain alphabetical order please.
case "generatemobdata":
return generateMobDataSubcommand.parseTabCompletions(main, sender, args);
case "spawner":
return spawnerSubCommand.parseTabCompletions(main, sender, args);
case "kill":
return killSubcommand.parseTabCompletions(main, sender, args);
case "rules":
return rulesSubcommand.parseTabCompletions(main, sender, args);
// missing subcommands don't have tab completions.
case "spawner":
return spawnerSubCommand.parseTabCompletions(main, sender, args);
case "summon":
return summonSubcommand.parseTabCompletions(main, sender, args);
// the missing subcommands don't have tab completions, don't bother including them.
default:
return null;
return Collections.emptyList();
}
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
import org.bukkit.command.CommandSender;
import org.jetbrains.annotations.NotNull;

import java.util.Collections;
import java.util.List;

/**
Expand Down Expand Up @@ -43,6 +44,6 @@ public void parseSubcommand(final LevelledMobs main, @NotNull final CommandSende
@Override
public List<String> parseTabCompletions(final LevelledMobs main, final CommandSender sender, final String[] args) {
// This subcommand has no tab completions.
return null;
return Collections.emptyList();
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
package me.lokka30.levelledmobs.commands.subcommands;

import me.lokka30.levelledmobs.LevelledMobs;
import me.lokka30.levelledmobs.misc.DebugCreator;
import me.lokka30.microlib.MessageUtils;
import org.bukkit.command.CommandSender;
import org.jetbrains.annotations.NotNull;

import java.util.Collections;
import java.util.List;

public class DebugSubcommand implements Subcommand {

@Override
public void parseSubcommand(final LevelledMobs main, final @NotNull CommandSender sender, final String label, final String[] args) {
if (!sender.hasPermission("levelledmobs.command.debug")) {
main.configUtils.sendNoPermissionMsg(sender);
return;
}

if (args.length < 3 || !"create".equalsIgnoreCase(args[1]) && !"confirm".equalsIgnoreCase(args[2])){
sender.sendMessage(MessageUtils.colorizeAll("&fBuild Debug Files&r\n" +
"If you're running this command, that means a LM Developer asked you to.\n" +
"We need copies of your LevelledMobs files, as well as a list of your current plugins, your current server build and version, " +
"and your current and maximum player count. Confirming this command will create a .ZIP file containing the above mentioned information, " +
"to be shared with a LM Developer. &fAbsolutely NOTHING&r within the .ZIP would contain private or personal information, and you can verify " +
"the contents of the .ZIP file prior to sending.\n" +
"If you are satisfied, please confirm by typing &b/lm debug create confirm"));

return;
}

DebugCreator.createDebug(main, sender);
}

@Override
public List<String> parseTabCompletions(final LevelledMobs main, final CommandSender sender, final String[] args) {
// This subcommand has no tab completions.
return Collections.emptyList();
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,7 @@ public List<String> parseTabCompletions(final LevelledMobs main, final CommandSe
if (args.length == 2 && sender instanceof ConsoleCommandSender)
return Collections.singletonList("(password?)");

return null;
return Collections.emptyList();
}

YamlConfiguration dropsConfig;
Expand Down
Loading

0 comments on commit 7bee0d5

Please sign in to comment.