Skip to content

Commit

Permalink
CommunicateManager and improvement
Browse files Browse the repository at this point in the history
  • Loading branch information
Mehran1022mm committed Feb 14, 2024
1 parent 359df10 commit b437880
Show file tree
Hide file tree
Showing 15 changed files with 521 additions and 484 deletions.
121 changes: 113 additions & 8 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,8 +1,113 @@
# Default ignored files
/shelf/
/workspace.xml
# Editor-based HTTP Client requests
/httpRequests/
# Datasource local storage ignored files
/dataSources/
/dataSources.local.xml
# User-specific stuff
.idea/

*.iml
*.ipr
*.iws

# IntelliJ
out/

# Compiled class file
*.class

# Log file
*.log

# BlueJ files
*.ctxt

# Package Files #
*.jar
*.war
*.nar
*.ear
*.zip
*.tar.gz
*.rar

# virtual machine crash logs, see http://www.java.com/en/download/help/error_hotspot.xml
hs_err_pid*

*~

# temporary files which can be created if a process still has a handle open of a deleted file
.fuse_hidden*

# KDE directory preferences
.directory

# Linux trash folder which might appear on any partition or disk
.Trash-*

# .nfs files are created when an open file is removed but is still being accessed
.nfs*

# General
.DS_Store
.AppleDouble
.LSOverride

# Icon must end with two \r
Icon

# Thumbnails
._*

# Files that might appear in the root of a volume
.DocumentRevisions-V100
.fseventsd
.Spotlight-V100
.TemporaryItems
.Trashes
.VolumeIcon.icns
.com.apple.timemachine.donotpresent

# Directories potentially created on remote AFP share
.AppleDB
.AppleDesktop
Network Trash Folder
Temporary Items
.apdisk

# Windows thumbnail cache files
Thumbs.db
Thumbs.db:encryptable
ehthumbs.db
ehthumbs_vista.db

# Dump file
*.stackdump

# Folder config file
[Dd]esktop.ini

# Recycle Bin used on file shares
$RECYCLE.BIN/

# Windows Installer files
*.cab
*.msi
*.msix
*.msm
*.msp

# Windows shortcuts
*.lnk

target/

pom.xml.tag
pom.xml.releaseBackup
pom.xml.versionsBackup
pom.xml.next

release.properties
dependency-reduced-pom.xml
buildNumber.properties
.mvn/timing.properties
.mvn/wrapper/maven-wrapper.jar
.flattened-pom.xml

# Common working directory
run/
1 change: 1 addition & 0 deletions Event-Core.iml
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
<configuration>
<autoDetectTypes>
<platformType>SPIGOT</platformType>
<platformType>BUKKIT</platformType>
</autoDetectTypes>
</configuration>
</facet>
Expand Down
6 changes: 3 additions & 3 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -23,8 +23,8 @@
<artifactId>maven-compiler-plugin</artifactId>
<version>3.8.1</version>
<configuration>
<source>9</source>
<target>9</target>
<source>14</source>
<target>14</target>
</configuration>
</plugin>
<plugin>
Expand Down Expand Up @@ -112,4 +112,4 @@
<scope>compile</scope>
</dependency>
</dependencies>
</project>
</project>
82 changes: 33 additions & 49 deletions src/main/java/ir/Mehran1022/EventCore/Main.java
Original file line number Diff line number Diff line change
@@ -1,11 +1,13 @@
package ir.mehran1022.eventcore;

import ir.mehran1022.eventcore.Commands.EventCommand;
import ir.mehran1022.eventcore.Listeners.PlayerJoinEvent;
import ir.mehran1022.eventcore.Managers.ConfigManager;
import ir.mehran1022.eventcore.Managers.InventoryManager;
import ir.mehran1022.eventcore.Managers.UpdateManager;
import ir.mehran1022.eventcore.Utils.Common;
import ir.mehran1022.eventcore.command.EventCommand;
import ir.mehran1022.eventcore.listener.PlayerJoinEvent;
import ir.mehran1022.eventcore.manager.CommunicationManager;
import ir.mehran1022.eventcore.manager.ConfigManager;
import ir.mehran1022.eventcore.manager.InventoryManager;
import ir.mehran1022.eventcore.manager.UpdateManager;
import ir.mehran1022.eventcore.util.Common;
import lombok.val;
import net.milkbowl.vault.economy.Economy;
import org.bukkit.Bukkit;
import org.bukkit.configuration.file.FileConfiguration;
Expand All @@ -29,84 +31,66 @@ public void onEnable() {
saveDefaultConfig();
ConfigManager.loadConfig();
loadPlayersData();
if (!economyPluginFound) {
if (Bukkit.getPluginManager().getPlugin("Vault") == null) {
Common.log("&cCan't Use Cost Feature. Vault Not Found.");
val vaultPlugin = Bukkit.getPluginManager().getPlugin("Vault");
if (!economyPluginFound && vaultPlugin != null) {
Common.debug("[Debug] use cost feature. I couldn't find Vault.");
} else {
Common.log("&cCan't Use Cost Feature. Failed To Get Economy Plugin.");
getConfig().set("Cost.Enabled", false);
}
Common.debug("[Debug] Can't use cost feature. Failed to get economy plugin.");
getConfig().set("Cost.Enabled", false);
}
loadThings();
Common.log("&eBungeecord addon is disabled in this version because of major bugs. We recommend to remove it from your bungeecord server until we fix it!");
}

private void loadThings() {
Common.registerEvent(new InventoryManager(), this);
Common.registerEvent(new PlayerJoinEvent(), this);
if (ConfigManager.DEBUG) {
Common.log("[Debug] Registered events");
}
Common.debug("[Debug] Registered events");
Common.registerCommand("event", new EventCommand());
if (ConfigManager.DEBUG) {
Common.log("[Debug] Registered commands");
}
Common.debug("[Debug] Registered commands");
Common.registerTabCompleter(new EventCommand(), "event");
if (ConfigManager.DEBUG) {
Common.log("[Debug] Registered tab completer");
}
/*
try {
getServer().getMessenger().registerOutgoingPluginChannel(this, "event-core:eventcore");
getServer().getMessenger().registerOutgoingPluginChannel(this, "event-core:message");
} catch (Exception e) {
Common.log("&cCannot register out-going channels: " + e.getMessage());
}
*/
Common.debug("[Debug] Registered tab completer");
economyPluginFound = setupEconomy();
if (ConfigManager.CHECKUPDATE) {
UpdateManager.start();
if (ConfigManager.DEBUG) {
Common.log("[Debug] Started update-checker worker");
}
Common.debug("[Debug] Started update-checker worker");
}
if (ConfigManager.BUNGEECORD) {
setupChannel();
Common.debug("[Debug] Setup channel successful");
}
new Metrics(this, 18612);
}

public void setupChannel() {
getServer().getMessenger().registerOutgoingPluginChannel(this, "Event-Core");
getServer().getMessenger().registerIncomingPluginChannel(this, "Event-Core", new CommunicationManager());
CommunicationManager.sendSyncRequest();
}

@Override
public void onDisable() {
UpdateManager.stop();
if (ConfigManager.DEBUG) {
Common.log("[Debug] Stopped update-check worker");
}
Common.debug("[Debug] Stopped update-check worker");
}

private void loadPlayersData() {
file = new File(getDataFolder(), "playersData.yml");
if (!file.exists()) {
saveResource("playersData.yml", false);
if (ConfigManager.DEBUG) {
Common.log("[Debug] Created playersData.yml");
}
Common.debug("[Debug] Created playersData.yml");
}
playersData = YamlConfiguration.loadConfiguration(file);
if (ConfigManager.DEBUG) {
Common.log("[Debug] Assigned players data");
}
Common.debug("[Debug] Assigned players data");
}

private boolean setupEconomy() {
if (Bukkit.getPluginManager().getPlugin("Vault") == null) {
if (ConfigManager.DEBUG) {
Common.log("[Debug] Vault not found");
}
Common.debug("[Debug] Vault not found.");
return false;
}
RegisteredServiceProvider<Economy> rsp = Bukkit.getServicesManager().getRegistration(Economy.class);
final RegisteredServiceProvider<Economy> rsp = Bukkit.getServicesManager().getRegistration(Economy.class);
if (rsp == null) {
if (ConfigManager.DEBUG) {
Common.log("[Debug] Economy provider not found");
}
Common.debug("[Debug] Economy provider not found.");
return false;
}
econ = rsp.getProvider();
Expand Down
Loading

0 comments on commit b437880

Please sign in to comment.