Skip to content

Commit

Permalink
Merge branch 'master' into renovate/com.github.wolfieheart-armorstand…
Browse files Browse the repository at this point in the history
…editor-1.x
  • Loading branch information
Wolfieheart authored Oct 19, 2023
2 parents b1982a5 + 2a9a854 commit 4dbf49a
Show file tree
Hide file tree
Showing 9 changed files with 231 additions and 163 deletions.
10 changes: 5 additions & 5 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
<groupId>io.github.rypofalem.armorstandeditor</groupId>
<artifactId>armorstandeditor</artifactId>
<packaging>jar</packaging>
<version>1.20.2-44</version>
<version>1.20.2-44.1</version>
<name>armorstandeditor</name>
<url>http://maven.apache.org</url>

Expand Down Expand Up @@ -152,7 +152,7 @@
<dependency>
<groupId>com.palmergames.bukkit.towny</groupId>
<artifactId>towny</artifactId>
<version>0.99.6.1</version>
<version>0.99.6.2</version>
<scope>provided</scope>
</dependency>
<!--- UpdateChecker -->
Expand Down Expand Up @@ -180,7 +180,7 @@
<dependency>
<groupId>com.github.angeschossen</groupId>
<artifactId>LandsAPI</artifactId>
<version>6.35.0</version>
<version>6.37.0</version>
<scope>provided</scope>
</dependency>
<!-- Bentobox -->
Expand Down Expand Up @@ -212,7 +212,7 @@
<plugin>
<groupId>org.openrewrite.maven</groupId>
<artifactId>rewrite-maven-plugin</artifactId>
<version>5.4.1</version>
<version>5.8.1</version>
<configuration>
<activeRecipes>
<recipe>org.openrewrite.java.migrate.UpgradeToJava17</recipe>
Expand All @@ -227,7 +227,7 @@
<dependency>
<groupId>org.openrewrite.recipe</groupId>
<artifactId>rewrite-migrate-java</artifactId>
<version>2.0.9</version>
<version>2.1.1</version>
</dependency>
</dependencies>
</plugin>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,10 +26,7 @@
import io.github.rypofalem.armorstandeditor.Metrics.*;
import io.github.rypofalem.armorstandeditor.language.Language;

import org.bukkit.Bukkit;
import org.bukkit.ChatColor;
import org.bukkit.Material;
import org.bukkit.NamespacedKey;
import org.bukkit.*;
import org.bukkit.entity.Player;
import org.bukkit.inventory.ItemStack;
import org.bukkit.inventory.meta.Damageable;
Expand Down Expand Up @@ -59,9 +56,10 @@ public class ArmorStandEditorPlugin extends JavaPlugin {
String warningMCVer = "Minecraft Version: ";
public boolean hasSpigot = false;
public boolean hasPaper = false;
public boolean hasFolia = false;
String nmsVersionNotLatest = null;
PluginDescriptionFile pdfFile = this.getDescription();
static final String SEPARATOR_FIELD = "================================";
public static final String SEPARATOR_FIELD = "================================";

public PlayerEditorManager editorManager;

Expand All @@ -79,6 +77,7 @@ public class ArmorStandEditorPlugin extends JavaPlugin {
String editToolName = null;
boolean requireToolLore = false;
List<?> editToolLore = null;
boolean enablePerWorld = false;
List<?> allowedWorldList = null;
boolean allowCustomModelData = false;
Integer customModelDataInt = Integer.MIN_VALUE;
Expand All @@ -103,6 +102,9 @@ public class ArmorStandEditorPlugin extends JavaPlugin {
public Team team;
String lockedTeam = "ASLocked";

//Debugging Options.... Not Exposed
boolean debugFlag;

private static ArmorStandEditorPlugin plugin;

public ArmorStandEditorPlugin() {
Expand Down Expand Up @@ -143,6 +145,7 @@ public void onEnable() {
//Spigot Check
hasSpigot = getHasSpigot();
hasPaper = getHasPaper();
hasFolia = Scheduler.isFolia();

//If Paper and Spigot are both FALSE - Disable the plugin
if (!hasPaper && !hasSpigot) {
Expand All @@ -159,7 +162,15 @@ public void onEnable() {
}

getServer().getPluginManager().enablePlugin(this);
if (!Scheduler.isFolia()) registerScoreboards(scoreboard);

if (!hasFolia) {
scoreboard = Objects.requireNonNull(this.getServer().getScoreboardManager()).getMainScoreboard();
registerScoreboards(scoreboard);
} else {
getServer().getLogger().warning("Scoreboards currently do not work on Folia. Scoreboard Coloring will not work");
}


getLogger().info(SEPARATOR_FIELD);

//saveResource doesn't accept File.separator on Windows, need to hardcode unix separator "/" instead
Expand Down Expand Up @@ -226,7 +237,13 @@ public void onEnable() {
editToolLore = getConfig().getList("toolLore", null);
}

allowedWorldList = getConfig().getList("allowed-worlds", null);
enablePerWorld = getConfig().getBoolean("enablePerWorldSupport", false);
if(enablePerWorld) {
allowedWorldList = getConfig().getList("allowed-worlds", null);
if (allowedWorldList != null && allowedWorldList.get(0).equals("*")) {
allowedWorldList = getServer().getWorlds().stream().map(World::getName).toList();
}
}

//Require Sneaking - Wolfst0rm/ArmorStandEditor#17
requireSneaking = getConfig().getBoolean("requireSneaking", false);
Expand All @@ -250,8 +267,17 @@ public void onEnable() {

adminOnlyNotifications = getConfig().getBoolean("adminOnlyNotifications", true);

debugFlag = getConfig().getBoolean("debugFlag", false);
if(debugFlag){
getServer().getLogger().warning(ArmorStandEditorPlugin.SEPARATOR_FIELD);
getServer().getLogger().warning(" ArmorStandEditor - Debug Mode ");
getServer().getLogger().warning(" Debug Mode: ENABLED! ");
getServer().getLogger().warning(" USE THIS FOR DEVELOPMENT PURPOSES ONLY! ");
getServer().getLogger().warning(ArmorStandEditorPlugin.SEPARATOR_FIELD);
}

//Run UpdateChecker - Reports out to Console on Startup ONLY!
if (!Scheduler.isFolia() && runTheUpdateChecker) {
if (!hasFolia && runTheUpdateChecker) {

if (opUpdateNotification) {
runUpdateCheckerWithOPNotifyOnJoinEnabled();
Expand Down Expand Up @@ -316,14 +342,14 @@ private void runUpdateCheckerWithOPNotifyOnJoinEnabled() {

//Implement Glow Effects for Wolfstorm/ArmorStandEditor-Issues#5 - Add Disable Slots with Different Glow than Default
private void registerScoreboards(Scoreboard scoreboard) {
getLogger().info("Registering Scoreboards required for Glowing Effects");
getServer().getLogger().info("Registering Scoreboards required for Glowing Effects");

//Fix for Scoreboard Issue reported by Starnos - Wolfst0rm/ArmorStandEditor-Issues/issues/18
if (scoreboard.getTeam(lockedTeam) == null) {
scoreboard.registerNewTeam(lockedTeam);
Objects.requireNonNull(scoreboard.getTeam(lockedTeam)).setColor(ChatColor.RED);
scoreboard.getTeam(lockedTeam).setColor(ChatColor.RED);
} else {
getLogger().info("Scoreboard for ASLocked Already exists. Continuing to load");
getServer().getLogger().info("Scoreboard for ASLocked Already exists. Continuing to load");
}
}

Expand All @@ -350,7 +376,7 @@ public void onDisable() {
if (player.getOpenInventory().getTopInventory().getHolder() == editorManager.getMenuHolder()) player.closeInventory();
}

if (!Scheduler.isFolia()) {
if (!hasFolia) {
scoreboard = Objects.requireNonNull(this.getServer().getScoreboardManager()).getMainScoreboard();
unregisterScoreboards(scoreboard);
}
Expand All @@ -374,14 +400,17 @@ public boolean getHasSpigot() {
public boolean getHasPaper() {
try {
Class.forName("com.destroystokyo.paper.PaperConfig");
nmsVersionNotLatest = "SpigotMC ASAP.";
nmsVersionNotLatest = "PaperMC ASAP.";
return true;
} catch (ClassNotFoundException e) {
nmsVersionNotLatest = "";
return false;
}
}

public boolean getHasFolia() {
return Scheduler.isFolia();
}

public String getArmorStandEditorVersion() {
return getConfig().getString("version");
Expand Down Expand Up @@ -496,12 +525,10 @@ public boolean isEditTool(ItemStack itemStk) {
}
return true;
}


public void performReload() {
public void performReload() {

//Unregister Scoreboard before before performing the reload
if (!Scheduler.isFolia()) {
if (!hasFolia) {
scoreboard = Objects.requireNonNull(this.getServer().getScoreboardManager()).getMainScoreboard();
unregisterScoreboards(scoreboard);
}
Expand All @@ -510,7 +537,7 @@ public void performReload() {
reloadConfig();

//Re-Register Scoreboards
if (!Scheduler.isFolia()) registerScoreboards(scoreboard);
if (!hasFolia) registerScoreboards(scoreboard);

//Reload Config File
reloadConfig();
Expand Down Expand Up @@ -559,7 +586,14 @@ public void performReload() {
editToolLore = getConfig().getList("toolLore", null);
}

allowedWorldList = getConfig().getList("allowed-worlds", null);

enablePerWorld = getConfig().getBoolean("enablePerWorldSupport", false);
if(enablePerWorld) {
allowedWorldList = getConfig().getList("allowed-worlds", null);
if (allowedWorldList != null && allowedWorldList.get(0).equals("*")) {
allowedWorldList = getServer().getWorlds().stream().map(World::getName).toList();
}
}

//Require Sneaking - Wolfst0rm/ArmorStandEditor#17
requireSneaking = getConfig().getBoolean("requireSneaking", false);
Expand All @@ -583,7 +617,7 @@ public void performReload() {
updateCheckerInterval = getConfig().getDouble("updateCheckerInterval", 24);

//Run UpdateChecker - Reports out to Console on Startup ONLY!
if (!Scheduler.isFolia() && runTheUpdateChecker) {
if (!hasFolia && runTheUpdateChecker) {

if (opUpdateNotification) {
runUpdateCheckerWithOPNotifyOnJoinEnabled();
Expand Down Expand Up @@ -671,4 +705,14 @@ public NamespacedKey getIconKey() {
return iconKey;
}

/**
* For debugging ASE - Do not use this outside of Development or stuff
*/
public boolean isDebug() {
return debugFlag;
}

public void debugMsgHandler(String msg){
if(isDebug()) getServer().getLogger().log(Level.WARNING, "[ASE-DEBUG]: {0}", msg);
}
}
Loading

0 comments on commit 4dbf49a

Please sign in to comment.