Skip to content

Commit

Permalink
Updated GitHub repository. Updated FoliaLib to 0.3.1. Added `Mojang…
Browse files Browse the repository at this point in the history
…APIRequestUtils` class. Added checks for offline/cracked servers. Added default fallbacks for null config strings. Added `EpicHomesAPI` class. Added multiple static API methods for developers. Refactored API events to new `me.loving11ish.epichomes.api.events` package. Added firing of `AsyncHomeTeleportEvent in sync mode when not running on Folia. Changed plugin version to `1.0.5`.
  • Loading branch information
Loving11ish committed Nov 29, 2023
1 parent 141f9e4 commit a857d9e
Show file tree
Hide file tree
Showing 36 changed files with 507 additions and 159 deletions.
17 changes: 15 additions & 2 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@

<groupId>me.loving11ish</groupId>
<artifactId>EpicHomes</artifactId>
<version>1.0.4</version>
<version>1.0.5</version>
<packaging>jar</packaging>

<name>EpicHomes</name>
Expand Down Expand Up @@ -44,6 +44,10 @@
<pattern>com.tcoded.folialib</pattern>
<shadedPattern>me.loving11ish.epichomes.folialib</shadedPattern>
</relocation>
<relocation>
<pattern>com.github.lightlibs</pattern>
<shadedPattern>me.loving11ish.epichomes.lightlibs</shadedPattern>
</relocation>
</relocations>
</configuration>
<executions>
Expand Down Expand Up @@ -90,6 +94,10 @@
<id>placeholderapi</id>
<url>https://repo.extendedclip.com/content/repositories/placeholderapi/</url>
</repository>
<repository>
<id>jitpack.io</id>
<url>https://jitpack.io</url>
</repository>
</repositories>

<dependencies>
Expand All @@ -115,9 +123,14 @@
<dependency>
<groupId>com.tcoded</groupId>
<artifactId>FoliaLib</artifactId>
<version>0.3.0</version>
<version>0.3.1</version>
<scope>compile</scope>
</dependency>
<dependency>
<groupId>com.github.lightlibs</groupId>
<artifactId>simplehttpwrapper</artifactId>
<version>0.0.3-alpha</version>
</dependency>
<dependency>
<groupId>com.rylinaux</groupId>
<artifactId>PlugMan</artifactId>
Expand Down
59 changes: 40 additions & 19 deletions src/main/java/me/loving11ish/epichomes/EpicHomes.java
Original file line number Diff line number Diff line change
Expand Up @@ -31,14 +31,19 @@

public final class EpicHomes extends JavaPlugin {

ConsoleCommandSender console = Bukkit.getConsoleSender();

private final PluginDescriptionFile pluginInfo = getDescription();
private final String pluginVersion = pluginInfo.getVersion();
ConsoleCommandSender console = Bukkit.getConsoleSender();

private static EpicHomes plugin;
private static FoliaLib foliaLib;
private static VersionCheckerUtils versionCheckerUtils;
private static boolean GUIEnabled = false;
private static boolean onlineMode = false;

private boolean updateAvailable;

public MessagesFileManager messagesFileManager;
public UsermapFileManager usermapFileManager;
public UsermapStorageUtil usermapStorageUtil;
Expand All @@ -51,7 +56,7 @@ public final class EpicHomes extends JavaPlugin {
public void onEnable() {
// Plugin startup logic
plugin = this;
foliaLib = new FoliaLib(plugin);
foliaLib = new FoliaLib(this);
versionCheckerUtils = new VersionCheckerUtils();
versionCheckerUtils.setVersion();

Expand Down Expand Up @@ -86,7 +91,7 @@ public void onEnable() {
}

//Check if PlugManX is enabled
if (Bukkit.getPluginManager().isPluginEnabled("PlugManX")|| PlugManXAPI.isPlugManXEnabled()){
if (Bukkit.getPluginManager().isPluginEnabled("PlugManX")||PlugManXAPI.isPlugManXEnabled()){
if (!PlugManAPI.iDoNotWantToBeUnOrReloaded("EpicHomes")){
console.sendMessage(ColorUtils.translateColorCodes("&c-------------------------------------------"));
console.sendMessage(ColorUtils.translateColorCodes("&c-------------------------------------------"));
Expand Down Expand Up @@ -153,7 +158,7 @@ public void onEnable() {

//Check for PersistentDataContainers for GUI system
if (versionCheckerUtils.getVersion() >= 14) {
GUIEnabled = getConfig().getBoolean("gui-system.use-global-gui.enabled");
GUIEnabled = getConfig().getBoolean("gui-system.use-global-gui.enabled", true);
if (GUIEnabled){
console.sendMessage(ColorUtils.translateColorCodes("&6EpicHomes: &3Global GUI system enabled!"));
}else {
Expand Down Expand Up @@ -181,19 +186,20 @@ public void onEnable() {
pluginCommands.add("/delhome");
pluginCommands.add("/homes");
pluginCommands.add("/epichomes");
getServer().getPluginManager().registerEvents(new PlayerConnectionEvent(), this);
getServer().getPluginManager().registerEvents(new PlayerDisconnectionEvent(), this);
getServer().getPluginManager().registerEvents(new PlayerMovementEvent(), this);
getServer().getPluginManager().registerEvents(new MenuEvent(), this);
getServer().getPluginManager().registerEvents(new JoinEvent(), this);
getServer().getPluginManager().registerEvents(new PlayerMovementEvent(), this);
getServer().getPluginManager().registerEvents(new PlayerConnectionEvent(), this);
getServer().getPluginManager().registerEvents(new PlayerPreConnectionEvent(), this);
getServer().getPluginManager().registerEvents(new PlayerDisconnectionEvent(), this);
getServer().getPluginManager().registerEvents(new PlayerCommandSendEvent(pluginCommands), this);

//Update banned names lists
HomeCommand.updateBannedNamesList();
SetHomeCommand.updateBannedNamesList();

//Register PlaceHolderAPI hooks
if (Bukkit.getServer().getPluginManager().isPluginEnabled("PlaceholderAPI")|| PlaceholderAPI.isPlaceholderAPIEnabled()){
if (Bukkit.getServer().getPluginManager().isPluginEnabled("PlaceholderAPI")||PlaceholderAPI.isPlaceholderAPIEnabled()){
new PlaceholderAPIHook().register();
console.sendMessage(ColorUtils.translateColorCodes("-------------------------------------------"));
console.sendMessage(ColorUtils.translateColorCodes("&6EpicHomes: &3PlaceholderAPI found!"));
Expand All @@ -213,7 +219,7 @@ public void onEnable() {
console.sendMessage(ColorUtils.translateColorCodes("&6EpicHomes: &3Plugin by: &b&lLoving11ish"));
console.sendMessage(ColorUtils.translateColorCodes("&6EpicHomes: &3has been loaded successfully"));
console.sendMessage(ColorUtils.translateColorCodes("&6EpicHomes: &3Plugin Version: &d&l" + pluginVersion));
if (getConfig().getBoolean("general.developer-debug-mode.enabled")){
if (getConfig().getBoolean("general.developer-debug-mode.enabled", false)){
console.sendMessage(ColorUtils.translateColorCodes("&6EpicHomes-Debug: &aDeveloper debug mode enabled!"));
console.sendMessage(ColorUtils.translateColorCodes("&6EpicHomes-Debug: &aThis WILL fill the console"));
console.sendMessage(ColorUtils.translateColorCodes("&6EpicHomes-Debug: &awith additional EpicHomes information!"));
Expand All @@ -224,34 +230,33 @@ public void onEnable() {

//Check for available updates
new UpdateChecker(109590).getVersion(version -> {
String prefix = messagesFileManager.getMessagesConfig().getString("global-prefix");
String prefix = messagesFileManager.getMessagesConfig().getString("global-prefix", "&f[&6Epic&bHomes&f]&r");
String PREFIX_PLACEHOLDER = "%PREFIX%";
if (this.getDescription().getVersion().equalsIgnoreCase(version)) {
console.sendMessage(ColorUtils.translateColorCodes(messagesFileManager.getMessagesConfig().getString("no-update-available.1").replace(PREFIX_PLACEHOLDER, prefix)));
console.sendMessage(ColorUtils.translateColorCodes(messagesFileManager.getMessagesConfig().getString("no-update-available.2").replace(PREFIX_PLACEHOLDER, prefix)));
console.sendMessage(ColorUtils.translateColorCodes(messagesFileManager.getMessagesConfig().getString("no-update-available.3").replace(PREFIX_PLACEHOLDER, prefix)));
this.updateAvailable = false;
}else {
console.sendMessage(ColorUtils.translateColorCodes(messagesFileManager.getMessagesConfig().getString("update-available.1").replace(PREFIX_PLACEHOLDER, prefix)));
console.sendMessage(ColorUtils.translateColorCodes(messagesFileManager.getMessagesConfig().getString("update-available.2").replace(PREFIX_PLACEHOLDER, prefix)));
console.sendMessage(ColorUtils.translateColorCodes(messagesFileManager.getMessagesConfig().getString("update-available.3").replace(PREFIX_PLACEHOLDER, prefix)));
this.updateAvailable = true;
}
});

//Start auto save task
foliaLib.getImpl().runLaterAsync(new Runnable() {
@Override
public void run() {
AutoSaveTaskUtils.runAutoSaveTask();
String PREFIX_PLACEHOLDER = "%PREFIX%";
String prefix = messagesFileManager.getMessagesConfig().getString("global-prefix");
console.sendMessage(ColorUtils.translateColorCodes(messagesFileManager.getMessagesConfig().getString("auto-save-started").replace(PREFIX_PLACEHOLDER, prefix)));
}
foliaLib.getImpl().runLaterAsync(() -> {
AutoSaveTaskUtils.runAutoSaveTask();
String PREFIX_PLACEHOLDER = "%PREFIX%";
String prefix = messagesFileManager.getMessagesConfig().getString("global-prefix", "&f[&6Epic&bHomes&f]&r");
console.sendMessage(ColorUtils.translateColorCodes(messagesFileManager.getMessagesConfig().getString("auto-save-started").replace(PREFIX_PLACEHOLDER, prefix)));
}, 5L, TimeUnit.SECONDS);
}

@Override
public void onDisable() {
// Plugin shutdown logic
//Plugin shutdown logic

//Unregister event listeners
HandlerList.unregisterAll(this);
Expand Down Expand Up @@ -346,4 +351,20 @@ public static VersionCheckerUtils getVersionCheckerUtils() {
public static boolean isGUIEnabled() {
return GUIEnabled;
}

public static void setGUIEnabled(boolean GUIEnabled) {
EpicHomes.GUIEnabled = GUIEnabled;
}

public static boolean isOnlineMode() {
return onlineMode;
}

public static void setOnlineMode(boolean onlineMode) {
EpicHomes.onlineMode = onlineMode;
}

public boolean isUpdateAvailable() {
return updateAvailable;
}
}
Loading

0 comments on commit a857d9e

Please sign in to comment.