Skip to content

Commit

Permalink
1.0-beta.3 (Changelog below)
Browse files Browse the repository at this point in the history
Changes:
- Fixed MySQL support
- Changed how player data loads
- Changed MySQL driver to `org.mariadb.jdbc.Driver`
- Added support for MariaDB (Untested)
- Added /reload support for Profiles as before it would spam console with a lot of errors, although I recommend restarting your server instead when possible. (This is also a warning in-game that will be sent to the player using /reload)
  • Loading branch information
Refrac committed Sep 16, 2023
1 parent efb69d3 commit 887445c
Show file tree
Hide file tree
Showing 38 changed files with 217 additions and 130 deletions.
37 changes: 35 additions & 2 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@

<groupId>me.refracdevelopment</groupId>
<artifactId>SimpleTags</artifactId>
<version>1.0-beta.2</version>
<version>1.0-beta.3</version>
<packaging>jar</packaging>

<name>SimpleTags</name>
Expand Down Expand Up @@ -79,6 +79,10 @@
<id>jitpack.io</id>
<url>https://jitpack.io</url>
</repository>
<repository>
<id>AlessioDP</id>
<url>https://repo.alessiodp.com/releases/</url>
</repository>
<repository>
<id>codemc-repo</id>
<url>https://repo.codemc.org/repository/maven-public/</url>
Expand All @@ -90,7 +94,13 @@
<dependency>
<groupId>org.spigotmc</groupId>
<artifactId>spigot-api</artifactId>
<version>1.16.5-R0.1-SNAPSHOT</version>
<version>1.8.8-R0.1-SNAPSHOT</version>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>org.spigotmc</groupId>
<artifactId>spigot-api</artifactId>
<version>1.20-R0.1-SNAPSHOT</version>
<scope>provided</scope>
</dependency>
<dependency>
Expand Down Expand Up @@ -120,18 +130,41 @@
<artifactId>HeadDatabase-API</artifactId>
<version>1.3.1</version>
<scope>provided</scope>
<exclusions>
<exclusion>
<groupId>io.papermc.paper</groupId>
<artifactId>paper-api</artifactId>
</exclusion>
</exclusions>
</dependency>
<dependency>
<groupId>com.github.Tweetzy</groupId>
<artifactId>Skulls</artifactId>
<version>3.10.0</version>
<scope>provided</scope>
<exclusions>
<exclusion>
<groupId>me.TechsCode</groupId>
<artifactId>UltraEconomyAPI</artifactId>
</exclusion>
</exclusions>
</dependency>
<dependency>
<groupId>de.tr7zw</groupId>
<artifactId>item-nbt-api-plugin</artifactId>
<version>2.11.3</version>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>net.byteflux</groupId>
<artifactId>libby-bukkit</artifactId>
<version>1.3.0</version>
</dependency>
<dependency>
<groupId>org.mariadb.jdbc</groupId>
<artifactId>mariadb-java-client</artifactId>
<version>3.1.4</version>
<scope>provided</scope>
</dependency>
</dependencies>
</project>
59 changes: 41 additions & 18 deletions src/main/java/me/refracdevelopment/simpletags/SimpleTags.java
Original file line number Diff line number Diff line change
Expand Up @@ -6,14 +6,23 @@
import dev.rosewood.rosegarden.manager.Manager;
import dev.rosewood.rosegarden.utils.NMSUtil;
import lombok.Getter;
import me.refracdevelopment.simpletags.config.*;
import me.refracdevelopment.simpletags.data.ProfileManager;
import me.refracdevelopment.simpletags.database.DataType;
import me.refracdevelopment.simpletags.database.MySQLManager;
import me.refracdevelopment.simpletags.listeners.ChatListener;
import me.refracdevelopment.simpletags.listeners.MenuListener;
import me.refracdevelopment.simpletags.listeners.PlayerListener;
import me.refracdevelopment.simpletags.manager.*;
import me.refracdevelopment.simpletags.manager.CommandManager;
import me.refracdevelopment.simpletags.manager.MenuManager;
import me.refracdevelopment.simpletags.manager.TagManager;
import me.refracdevelopment.simpletags.manager.configuration.ConfigurationManager;
import me.refracdevelopment.simpletags.manager.configuration.LocaleManager;
import me.refracdevelopment.simpletags.manager.configuration.cache.Config;
import me.refracdevelopment.simpletags.manager.configuration.cache.ConfigFile;
import me.refracdevelopment.simpletags.manager.configuration.cache.Menus;
import me.refracdevelopment.simpletags.manager.configuration.cache.Tags;
import me.refracdevelopment.simpletags.manager.data.DataType;
import me.refracdevelopment.simpletags.manager.data.MySQLManager;
import me.refracdevelopment.simpletags.manager.data.PlayerMapper;
import me.refracdevelopment.simpletags.player.data.ProfileManager;
import me.refracdevelopment.simpletags.utilities.DownloadUtil;
import me.refracdevelopment.simpletags.utilities.Tasks;
import me.refracdevelopment.simpletags.utilities.chat.Color;
import me.refracdevelopment.simpletags.utilities.chat.PAPIExpansion;
Expand Down Expand Up @@ -56,13 +65,22 @@ public void enable() {
long startTiming = System.currentTimeMillis();
PluginManager pluginManager = this.getServer().getPluginManager();

DownloadUtil.downloadAndEnable();

// Check if the server is on 1.7
if (NMSUtil.getVersionNumber() <= 7) {
Color.log("&cSimpleTags 1.7 is in legacy mode, please update to 1.8+");
pluginManager.disablePlugin(this);
return;
}

// Make sure the server has PlaceholderAPI
if (pluginManager.getPlugin("PlaceholderAPI") == null) {
Color.log("&cPlease install PlaceholderAPI onto your server to use this plugin.");
pluginManager.disablePlugin(this);
return;
}

// Make sure the server has NBTAPI
if (pluginManager.getPlugin("NBTAPI") == null) {
Color.log("&cPlease install NBTAPI onto your server to use this plugin.");
Expand Down Expand Up @@ -101,7 +119,11 @@ public void enable() {

@Override
public void disable() {
// unused
// Plugin shutdown logic
if (dataType == DataType.MYSQL) {
mySQLManager.shutdown();
}
this.getServer().getScheduler().cancelTasks(this);
}

@Override
Expand All @@ -112,24 +134,25 @@ protected List<Class<? extends Manager>> getManagerLoadPriority() {
public void loadFiles() {
tagsFile = new ConfigFile(this, "tags.yml");
menusFile = new ConfigFile(this, "menus.yml");
tagsFile.load();
menusFile.load();
Config.loadConfig();
Tags.loadConfig();
Menus.loadConfig();
}

private void loadManagers() {
if (Config.DATA_TYPE.equalsIgnoreCase("MYSQL")) {
dataType = DataType.MYSQL;
mySQLManager = new MySQLManager(this);
getMySQLManager().connect();
getMySQLManager().createT();
Color.log("&aEnabled MySQL support!");
} else {
dataType = DataType.FLAT_FILE;
playerMapper = new PlayerMapper(getDataFolder().getAbsolutePath() + File.separator + "playerdata");
Color.log("&aEnabled Flat File support!");
switch (Config.DATA_TYPE.toUpperCase()) {
case "MYSQL":
dataType = DataType.MYSQL;
mySQLManager = new MySQLManager(this);
getMySQLManager().connect();
getMySQLManager().createT();
Color.log("&aEnabled MySQL support!");
break;
case "FLAT_FILE":
dataType = DataType.FLAT_FILE;
playerMapper = new PlayerMapper(getDataFolder().getAbsolutePath() + File.separator + "playerdata");
Color.log("&aEnabled Flat File support!");
break;
}

profileManager = new ProfileManager();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,10 +7,10 @@
import dev.rosewood.rosegarden.command.framework.annotation.RoseExecutable;
import dev.rosewood.rosegarden.utils.StringPlaceholders;
import me.refracdevelopment.simpletags.SimpleTags;
import me.refracdevelopment.simpletags.config.ConfigFile;
import me.refracdevelopment.simpletags.config.Tags;
import me.refracdevelopment.simpletags.data.Tag;
import me.refracdevelopment.simpletags.manager.LocaleManager;
import me.refracdevelopment.simpletags.manager.configuration.LocaleManager;
import me.refracdevelopment.simpletags.manager.configuration.cache.ConfigFile;
import me.refracdevelopment.simpletags.manager.configuration.cache.Tags;
import me.refracdevelopment.simpletags.utilities.Permissions;
import me.refracdevelopment.simpletags.utilities.chat.Placeholders;
import org.bukkit.entity.Player;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,9 @@
import dev.rosewood.rosegarden.command.framework.annotation.RoseExecutable;
import dev.rosewood.rosegarden.utils.StringPlaceholders;
import me.refracdevelopment.simpletags.SimpleTags;
import me.refracdevelopment.simpletags.config.ConfigFile;
import me.refracdevelopment.simpletags.config.Tags;
import me.refracdevelopment.simpletags.manager.LocaleManager;
import me.refracdevelopment.simpletags.manager.configuration.LocaleManager;
import me.refracdevelopment.simpletags.manager.configuration.cache.ConfigFile;
import me.refracdevelopment.simpletags.manager.configuration.cache.Tags;
import me.refracdevelopment.simpletags.utilities.Permissions;
import me.refracdevelopment.simpletags.utilities.chat.Placeholders;
import org.bukkit.entity.Player;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,9 @@
import dev.rosewood.rosegarden.command.framework.annotation.RoseExecutable;
import dev.rosewood.rosegarden.utils.StringPlaceholders;
import me.refracdevelopment.simpletags.SimpleTags;
import me.refracdevelopment.simpletags.config.ConfigFile;
import me.refracdevelopment.simpletags.config.Tags;
import me.refracdevelopment.simpletags.manager.LocaleManager;
import me.refracdevelopment.simpletags.manager.configuration.LocaleManager;
import me.refracdevelopment.simpletags.manager.configuration.cache.ConfigFile;
import me.refracdevelopment.simpletags.manager.configuration.cache.Tags;
import me.refracdevelopment.simpletags.utilities.Permissions;
import me.refracdevelopment.simpletags.utilities.chat.Placeholders;
import org.bukkit.entity.Player;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
import dev.rosewood.rosegarden.command.framework.RoseCommandWrapper;
import dev.rosewood.rosegarden.command.framework.annotation.RoseExecutable;
import me.refracdevelopment.simpletags.SimpleTags;
import me.refracdevelopment.simpletags.manager.LocaleManager;
import me.refracdevelopment.simpletags.manager.configuration.LocaleManager;
import me.refracdevelopment.simpletags.utilities.Permissions;
import org.bukkit.entity.Player;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
import dev.rosewood.rosegarden.command.framework.RoseCommandWrapper;
import dev.rosewood.rosegarden.command.framework.annotation.RoseExecutable;
import me.refracdevelopment.simpletags.SimpleTags;
import me.refracdevelopment.simpletags.manager.LocaleManager;
import me.refracdevelopment.simpletags.manager.configuration.LocaleManager;
import me.refracdevelopment.simpletags.utilities.Permissions;
import me.refracdevelopment.simpletags.utilities.Tasks;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,9 @@
import dev.rosewood.rosegarden.command.framework.annotation.RoseExecutable;
import dev.rosewood.rosegarden.utils.StringPlaceholders;
import me.refracdevelopment.simpletags.SimpleTags;
import me.refracdevelopment.simpletags.data.ProfileData;
import me.refracdevelopment.simpletags.data.Tag;
import me.refracdevelopment.simpletags.manager.LocaleManager;
import me.refracdevelopment.simpletags.manager.configuration.LocaleManager;
import me.refracdevelopment.simpletags.player.data.ProfileData;
import me.refracdevelopment.simpletags.utilities.Permissions;
import me.refracdevelopment.simpletags.utilities.Tasks;
import me.refracdevelopment.simpletags.utilities.Utilities;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
import dev.rosewood.rosegarden.command.framework.RoseCommandWrapper;
import dev.rosewood.rosegarden.command.framework.annotation.RoseExecutable;
import me.refracdevelopment.simpletags.SimpleTags;
import me.refracdevelopment.simpletags.manager.LocaleManager;
import me.refracdevelopment.simpletags.manager.configuration.LocaleManager;
import me.refracdevelopment.simpletags.menu.TagsMenu;
import org.bukkit.entity.Player;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
import dev.rosewood.rosegarden.command.framework.RoseCommandWrapper;
import dev.rosewood.rosegarden.command.framework.annotation.RoseExecutable;
import dev.rosewood.rosegarden.utils.StringPlaceholders;
import me.refracdevelopment.simpletags.manager.LocaleManager;
import me.refracdevelopment.simpletags.manager.configuration.LocaleManager;
import me.refracdevelopment.simpletags.utilities.Permissions;

public class VersionCommand extends RoseCommand {
Expand Down

This file was deleted.

Original file line number Diff line number Diff line change
@@ -1,12 +1,14 @@
package me.refracdevelopment.simpletags.listeners;

import me.refracdevelopment.simpletags.SimpleTags;
import me.refracdevelopment.simpletags.config.Config;
import me.refracdevelopment.simpletags.data.ProfileData;
import me.refracdevelopment.simpletags.manager.configuration.cache.Config;
import me.refracdevelopment.simpletags.player.data.ProfileData;
import me.refracdevelopment.simpletags.utilities.chat.Color;
import org.bukkit.entity.Player;
import org.bukkit.event.EventHandler;
import org.bukkit.event.Listener;
import org.bukkit.event.player.AsyncPlayerChatEvent;
import org.bukkit.event.player.PlayerCommandPreprocessEvent;

public class ChatListener implements Listener {

Expand All @@ -19,4 +21,14 @@ public void onChat(AsyncPlayerChatEvent event) {
event.setFormat(profile.getTagPrefix() + event.getFormat());
}
}

@EventHandler
public void onReload(PlayerCommandPreprocessEvent event) {
Player player = event.getPlayer();

if (event.getMessage().equalsIgnoreCase("/reload") ||
event.getMessage().equalsIgnoreCase("/reload confirm")) {
Color.sendMessage(player, "%prefix% Use of /reload is not recommended as it can cause issues often cases. Please restart your server when possible.");
}
}
}
Original file line number Diff line number Diff line change
@@ -1,42 +1,38 @@
package me.refracdevelopment.simpletags.listeners;

import me.refracdevelopment.simpletags.SimpleTags;
import me.refracdevelopment.simpletags.data.Profile;
import me.refracdevelopment.simpletags.manager.configuration.cache.Config;
import me.refracdevelopment.simpletags.player.Profile;
import me.refracdevelopment.simpletags.utilities.Tasks;
import me.refracdevelopment.simpletags.utilities.Utilities;
import me.refracdevelopment.simpletags.utilities.chat.Color;
import org.bukkit.ChatColor;
import org.bukkit.entity.Player;
import org.bukkit.event.EventHandler;
import org.bukkit.event.Listener;
import org.bukkit.event.player.AsyncPlayerPreLoginEvent;
import org.bukkit.event.player.PlayerJoinEvent;
import org.bukkit.event.player.PlayerLoginEvent;
import org.bukkit.event.player.PlayerQuitEvent;

public class PlayerListener implements Listener {

@EventHandler
public void onLogin(AsyncPlayerPreLoginEvent event) {
try {
SimpleTags.getInstance().getProfileManager().handleProfileCreation(event.getUniqueId(), event.getName());
} catch (NullPointerException exception) {
event.disallow(AsyncPlayerPreLoginEvent.Result.KICK_FULL, "&cERROR: Could not create profile!");
}
public void onLogin(PlayerLoginEvent event) {
Player player = event.getPlayer();

SimpleTags.getInstance().getProfileManager().handleProfileCreation(player.getUniqueId(), player.getName());

Profile profile = SimpleTags.getInstance().getProfileManager().getProfile(player.getUniqueId());
Tasks.runAsync(SimpleTags.getInstance(), () -> profile.getData().load());
}

@EventHandler
public void onJoin(PlayerJoinEvent event) {
Player player = event.getPlayer();
Profile profile = SimpleTags.getInstance().getProfileManager().getProfile(player.getUniqueId());

try {
Tasks.runAsync(SimpleTags.getInstance(), () -> profile.getData().load());
} catch (NullPointerException exception) {
player.kickPlayer(ChatColor.RED + "ERROR: Profile returned null.");
return;
}

if (profile == null || profile.getData() == null) {
player.kickPlayer(ChatColor.RED + "ERROR: Profile returned null.");
player.kickPlayer(Color.translate(Config.KICK_MESSAGES_ERROR));
return;
}

Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
package me.refracdevelopment.simpletags.manager;

import lombok.Getter;
import me.refracdevelopment.simpletags.SimpleTags;
import me.refracdevelopment.simpletags.data.Tag;
import me.refracdevelopment.simpletags.utilities.chat.Color;
Expand All @@ -8,6 +9,7 @@
import java.util.List;
import java.util.Optional;

@Getter
public class TagManager {

private final List<Tag> loadedTags = new ArrayList<>();
Expand Down Expand Up @@ -39,10 +41,6 @@ public Tag getCachedTag(String name) {
return null;
}

public List<Tag> getLoadedTags() {
return loadedTags;
}

public void updateTags() {
SimpleTags.getInstance().getProfileManager().getProfiles().values().forEach(profile -> {
if (getCachedTag(profile.getData().getTag()) == null) {
Expand Down
Loading

0 comments on commit 887445c

Please sign in to comment.