Skip to content

Commit

Permalink
Greater Event-Core
Browse files Browse the repository at this point in the history
Complete re-writing of methods and fixing all existing bugs. Complete optimization. Independence of InvUI external library (Own inventory management system)
  • Loading branch information
Mehran1022mm committed Dec 31, 2023
1 parent ed0d86c commit 5060218
Show file tree
Hide file tree
Showing 23 changed files with 2,378 additions and 664 deletions.
12 changes: 8 additions & 4 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,4 +1,8 @@
.idea/
*.iml
*.ipr
*.iws
# Default ignored files
/shelf/
/workspace.xml
# Editor-based HTTP Client requests
/httpRequests/
# Datasource local storage ignored files
/dataSources/
/dataSources.local.xml
30 changes: 14 additions & 16 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@

<groupId>ir</groupId>
<artifactId>Event-Core</artifactId>
<version>1.0.6-DEV</version>
<version>1.1.0</version>
<packaging>jar</packaging>

<name>Event-Core</name>
Expand Down Expand Up @@ -61,10 +61,6 @@
<id>sonatype</id>
<url>https://oss.sonatype.org/content/groups/public/</url>
</repository>
<repository>
<id>xenondevs</id>
<url>https://repo.xenondevs.xyz/releases</url>
</repository>
<repository>
<id>jitpack.io</id>
<url>https://jitpack.io</url>
Expand All @@ -79,19 +75,9 @@
<dependency>
<groupId>org.spigotmc</groupId>
<artifactId>spigot-api</artifactId>
<version>1.20-R0.1-SNAPSHOT</version>
<version>1.20.4-R0.1-SNAPSHOT</version>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>xyz.xenondevs.invui</groupId>
<artifactId>invui-core</artifactId>
<version>1.8</version>
</dependency>
<dependency>
<groupId>xyz.xenondevs.invui</groupId>
<artifactId>inventory-access-r5</artifactId>
<version>1.8</version>
</dependency>
<dependency>
<groupId>com.github.MilkBowl</groupId>
<artifactId>VaultAPI</artifactId>
Expand All @@ -113,5 +99,17 @@
<artifactId>commons-io</artifactId>
<version>2.11.0</version>
</dependency>
<dependency>
<groupId>org.projectlombok</groupId>
<artifactId>lombok</artifactId>
<version>1.18.30</version>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>org.jetbrains</groupId>
<artifactId>annotations</artifactId>
<version>24.1.0</version>
<scope>compile</scope>
</dependency>
</dependencies>
</project>
460 changes: 208 additions & 252 deletions src/main/java/ir/Mehran1022/EventCore/Commands/EventCommand.java

Large diffs are not rendered by default.

Original file line number Diff line number Diff line change
@@ -1,60 +1,35 @@
/*
MIT License
package ir.mehran1022.eventcore.Listeners;

Copyright (c) 2023 Mehran1022
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
*/

package ir.Mehran1022.EventCore.Listeners;

import ir.Mehran1022.EventCore.Main;
import ir.Mehran1022.EventCore.Managers.ConfigManager;
import ir.Mehran1022.EventCore.Utils.Common;
import ir.mehran1022.eventcore.Main;
import ir.mehran1022.eventcore.Managers.ConfigManager;
import ir.mehran1022.eventcore.Utils.Common;
import ir.mehran1022.eventcore.Commands.EventCommand;
import org.bukkit.entity.Player;
import org.bukkit.event.EventHandler;
import org.bukkit.event.Listener;

import java.io.IOException;
import java.util.UUID;

import static ir.Mehran1022.EventCore.Commands.EventCommand.Active;
import static ir.Mehran1022.EventCore.Commands.EventCommand.EventDesc;

public class PlayerJoinEvent implements Listener {
public final class PlayerJoinEvent implements Listener {
@EventHandler
public void EventNotification (org.bukkit.event.player.PlayerJoinEvent event) {
Player player = event.getPlayer();
if (Active) {
Common.SendMessage(player, ConfigManager.PREFIX + EventDesc);
}
}
@EventHandler
public void DataSave (org.bukkit.event.player.PlayerJoinEvent event) {
public void onPlayerJoin(org.bukkit.event.player.PlayerJoinEvent event) {
Player player = event.getPlayer();
UUID uuid = player.getUniqueId();
Main.PlayersData.set(uuid.toString() + ".NAME", player.getName());
Main.PlayersData.set(uuid.toString() + ".BANNED", false);
String uuidString = uuid.toString();

if (EventCommand.Active) {
Common.sendMessage(player, ConfigManager.PREFIX + EventCommand.EventDesc);
}

Main.playersData.set(uuidString + ".NAME", player.getName());
Main.playersData.set(uuidString + ".BANNED", false);

try {
Main.PlayersData.save(Main.File);
Main.playersData.save(Main.file);
} catch (IOException e) {
e.printStackTrace();
}
}
}

125 changes: 55 additions & 70 deletions src/main/java/ir/Mehran1022/EventCore/Main.java
Original file line number Diff line number Diff line change
@@ -1,36 +1,13 @@
/*
MIT License
Copyright (c) 2023 Mehran1022
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
*/
package ir.mehran1022.eventcore;

package ir.Mehran1022.EventCore;

import ir.Mehran1022.EventCore.Commands.EventCommand;
import ir.Mehran1022.EventCore.Listeners.InventoryClickListener;
import ir.Mehran1022.EventCore.Listeners.PlayerJoinEvent;
import ir.Mehran1022.EventCore.Managers.ConfigManager;
import ir.Mehran1022.EventCore.Managers.UpdateManager;
import ir.Mehran1022.EventCore.Utils.Common;
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 net.milkbowl.vault.economy.Economy;
import org.bukkit.Bukkit;
import org.bukkit.configuration.file.FileConfiguration;
import org.bukkit.configuration.file.YamlConfiguration;
import org.bukkit.plugin.RegisteredServiceProvider;
Expand All @@ -40,70 +17,78 @@ of this software and associated documentation files (the "Software"), to deal

public final class Main extends JavaPlugin {

public static Main instance;

private static Main instance;
private static Economy econ = null;

public static boolean EconomyPluginFound = true;

public static FileConfiguration PlayersData;

public static java.io.File File;
public static boolean economyPluginFound = true;
public static FileConfiguration playersData;
public static File file;

@Override
public void onEnable () {
public void onEnable() {
instance = this;
saveDefaultConfig();
ConfigManager.loadConfig();
PlayersData();
if (!EconomyPluginFound) {
if (getServer().getPluginManager().getPlugin("Vault") == null) {
Common.Log("&c[Event-Core] Can't Use Cost Feature. Vault Not Found.");
loadPlayersData();
if (!economyPluginFound) {
if (Bukkit.getPluginManager().getPlugin("Vault") == null) {
Common.log("&cCan't Use Cost Feature. Vault Not Found.");
} else {
Common.Log("&c[Event-Core] Can't Use Cost Feature. Failed To Get Economy Plugin.");
Common.log("&cCan't Use Cost Feature. Failed To Get Economy Plugin.");
getConfig().set("Cost.Enabled", false);
}
}
LoadThings();
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!");
}
/**
* @Override
* public void onDisable () { }
*/
private void LoadThings () {
Common.RegisterEvent(new PlayerJoinEvent(), this);
Common.RegisterCommand("event", new EventCommand());
Common.RegisterEvent(new InventoryClickListener(), this);
Common.RegisterTabCompleter(new EventCommand(), "event");
getServer().getMessenger().registerOutgoingPluginChannel(this, "event-core:eventcore");
getServer().getMessenger().registerOutgoingPluginChannel(this, "event-core:message");
EconomyPluginFound = setupEconomy();
UpdateManager UM = new UpdateManager(); UM.Start();

private void loadThings() {
Common.registerEvent(new PlayerJoinEvent(), this);
Common.registerCommand("event", new EventCommand());
Common.registerEvent(new InventoryManager(), this);
Common.registerTabCompleter(new EventCommand(), "event");
/*
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());
}
*/
economyPluginFound = setupEconomy();
UpdateManager.start();
new Metrics(this, 18612);
}
private void PlayersData () {
File = new File(getDataFolder(), "PlayersData.yml");
if (!File.exists()) {
saveResource("PlayersData.yml", false);

@Override
public void onDisable() {
UpdateManager.stop();
}

private void loadPlayersData() {
file = new File(getDataFolder(), "playersData.yml");
if (!file.exists()) {
saveResource("playersData.yml", false);
}
PlayersData = YamlConfiguration.loadConfiguration(File);
playersData = YamlConfiguration.loadConfiguration(file);
}

private boolean setupEconomy() {
if (getServer().getPluginManager().getPlugin("Vault") == null) {
System.out.println("Vault Is Null.");
if (Bukkit.getPluginManager().getPlugin("Vault") == null) {
return false;
}
RegisteredServiceProvider<Economy> rsp = getServer().getServicesManager().getRegistration(Economy.class);
RegisteredServiceProvider<Economy> rsp = Bukkit.getServicesManager().getRegistration(Economy.class);
if (rsp == null) {
System.out.println("RegisteredServiceProvider IS Null.");
return false;
}
econ = rsp.getProvider();
return true;
}
public static Economy getEconomy () {

public static Economy getEconomy() {
return econ;
}
public static Main getInstance () {

public static Main getInstance() {
return instance;
}
}
58 changes: 17 additions & 41 deletions src/main/java/ir/Mehran1022/EventCore/Managers/ConfigManager.java
Original file line number Diff line number Diff line change
@@ -1,31 +1,7 @@
/*
MIT License
Copyright (c) 2023 Mehran1022
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
*/

package ir.Mehran1022.EventCore.Managers;

import ir.Mehran1022.EventCore.Main;
import ir.Mehran1022.EventCore.Utils.Common;
package ir.mehran1022.eventcore.Managers;

import ir.mehran1022.eventcore.Main;
import ir.mehran1022.eventcore.Utils.Common;
import org.bukkit.configuration.file.FileConfiguration;

public final class ConfigManager {
Expand Down Expand Up @@ -79,26 +55,26 @@ public static void loadConfig() {
instance.reloadConfig();
FileConfiguration config = instance.getConfig();

PREFIX = Common.Color(config.getString("Prefix") + " ");
ALREADY_STARTED = Common.Color(config.getString("Messages.AlreadyStarted"));
NO_PERMISSION = Common.Color(config.getString("Messages.NoPermission"));
NO_DESC = Common.Color(config.getString("Messages.NoDescription"));
END = Common.Color(config.getString("Messages.EventEnd"));
NO_EVENT = Common.Color(config.getString("Messages.NoActiveEvent"));
PREFIX = Common.color(config.getString("Prefix") + " ");
ALREADY_STARTED = Common.color(config.getString("Messages.AlreadyStarted"));
NO_PERMISSION = Common.color(config.getString("Messages.NoPermission"));
NO_DESC = Common.color(config.getString("Messages.NoDescription"));
END = Common.color(config.getString("Messages.EventEnd"));
NO_EVENT = Common.color(config.getString("Messages.NoActiveEvent"));
SERVER_NAME = config.getString("EventServer");
DURATION = config.getInt("Duration");
BOSSBAR = Common.Color(config.getString("Messages.Bossbar"));
TITLE = Common.Color(config.getString("Titles.Title"));
SUBTITLE = Common.Color(config.getString("Titles.Subtitle"));
BOSSBAR = Common.color(config.getString("Messages.Bossbar"));
TITLE = Common.color(config.getString("Titles.Title"));
SUBTITLE = Common.color(config.getString("Titles.Subtitle"));
FADEIN = config.getInt("Titles.FadeIn");
STAY = config.getInt("Titles.Stay");
FADEOUT = config.getInt("Titles.FadeOut");
ENABLE_COST = config.getBoolean("Cost.Enabled");
COST = config.getDouble("Cost.Cost");
OFFLINE = Common.Color(config.getString("Messages.Offline"));
BLOCK = Common.Color(config.getString("Messages.Block"));
UNBLOCK = Common.Color(config.getString("Messages.Unblock"));
BLOCKED = Common.Color(config.getString("Messages.Blocked"));
OFFLINE = Common.color(config.getString("Messages.Offline"));
BLOCK = Common.color(config.getString("Messages.Block"));
UNBLOCK = Common.color(config.getString("Messages.Unblock"));
BLOCKED = Common.color(config.getString("Messages.Blocked"));
AUTOUPDATE = config.getBoolean("Auto-Update");
CHECKUPDATE = config.getBoolean("Check-Update");

Expand Down
Loading

0 comments on commit 5060218

Please sign in to comment.