Skip to content

Commit

Permalink
[CORE] ArmorStandEditor 1.20.2-44.1 - QoL Hotfixes (#349)
Browse files Browse the repository at this point in the history
* [CORE] Bump to 1.20.2-44.1

* [CORE] Allow easy way to allow all worlds by default. Fixes #348

* [CORE] Forgot to change the call for the check to see if a user can RMB to activate the UI. Fixes #348

* [CORE] Update Folia Check and Fix Scoreboard is Null Errors

* [CORE] Stricter Check for `/ase stats` usage

* [CORE] Better Implementation for the Per World Support Fix

* [CORE] Make Per World Support a toggleable thing instead of having a default

* [CORE] Merge if Statements when checking PerWorld

Signed-off-by: Wolfieheart <[email protected]>

* [CORE] Fix Folia Leftoever, Fix P2 Protection and add Debug in a few places.

Signed-off-by: Wolfieheart <[email protected]>

* [CORE] Move glowing Item to a better slot

Signed-off-by: Wolfieheart <[email protected]>

* [CORE] Update Config.yml comments to better explain the ASE Per World Implementation

Signed-off-by: Wolfieheart <[email protected]>

---------

Signed-off-by: Wolfieheart <[email protected]>
  • Loading branch information
Wolfieheart authored Oct 19, 2023
1 parent 150107a commit 5cfac1d
Show file tree
Hide file tree
Showing 9 changed files with 227 additions and 159 deletions.
2 changes: 1 addition & 1 deletion 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
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 5cfac1d

Please sign in to comment.