Skip to content

Plugin Rewrite #8

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 40 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
40 commits
Select commit Hold shift + click to select a range
53cdb92
SQLite connection added
RhythmicSys May 2, 2025
ab37313
fix a couple issues.
RhythmicSys May 2, 2025
75e801a
.
RhythmicSys May 4, 2025
b31012e
add another table for active nicks
RhythmicSys May 6, 2025
25a3b99
compiles but doesn't work
RhythmicSys May 6, 2025
1c7ed1f
now using /nick works, save doesn't
RhythmicSys May 6, 2025
667cbb9
genuinely not sure what's wrong here
RhythmicSys May 7, 2025
aa09760
it was a syntax error. Anyways, it works, autocomplete is still broken
RhythmicSys May 7, 2025
3163713
aaaaaaaaa
RhythmicSys May 7, 2025
b766fae
It fixed,,, and I ,, don't know why
RhythmicSys May 8, 2025
f828b4f
Work on commands, but not much has been done
RhythmicSys May 8, 2025
871e04a
Work on processing nicknames, Cache, SqlHandler
RhythmicSys May 10, 2025
5ebaa2e
this is taking so long
RhythmicSys May 10, 2025
098c48c
committing basic changes
RhythmicSys May 11, 2025
5a9319d
Brig save and set commands
Peashooter101 May 11, 2025
c9dafd3
Abstract SubCommand, Brig reset and delete commands
Peashooter101 May 12, 2025
7072f29
Add leave listener, fix delete subcommand
RhythmicSys May 12, 2025
6ce4e38
Implement more feedback messages
RhythmicSys May 12, 2025
41cd10e
Fix nicknames requiring quotes
RhythmicSys May 12, 2025
bf9cbcf
Fix SQL issue and allow saving nicknames that are not currently on yo…
RhythmicSys May 14, 2025
839aca2
Brig admin and admin-set commands.
Peashooter101 May 15, 2025
59ef4fd
Attempt at extracting nickname checks, it's broken now.
RhythmicSys May 16, 2025
d9d8ccb
idk why it keeps saying regex error
RhythmicSys May 17, 2025
80022a3
regex error is fixed, slight work on username check
RhythmicSys May 18, 2025
b26ba6c
Change Nickname from a record to a class (needed to be able to set) -…
RhythmicSys May 20, 2025
392257d
Added nick lookup command, incomplete
RhythmicSys May 20, 2025
455694e
rename lookup to who, fix formatting of message, idk what else I did
RhythmicSys May 21, 2025
f416817
start on admin lookup command
RhythmicSys May 27, 2025
b391a2d
Admin lookup command works now, refactor Message class to be called L…
RhythmicSys Jun 10, 2025
e2b82e6
Admin delete command works
RhythmicSys Jul 26, 2025
41451e0
I don't understand
RhythmicSys Jul 28, 2025
1171fd7
This didn't fix it but I needed to move it anyways
RhythmicSys Jul 28, 2025
2570134
No longer deletes the data lets go
RhythmicSys Jul 29, 2025
f7acfaa
Adjust SQL, move things to be properly async.
RhythmicSys Aug 8, 2025
3e3f1d1
Stop migration from preventing the server from starting properly (mov…
RhythmicSys Aug 10, 2025
e789957
More migration changes - also renamed 'refreshNickname' to 'refreshDi…
RhythmicSys Aug 10, 2025
90c8e99
Alter save migrator to use a batching system
RhythmicSys Aug 12, 2025
b0a9ef0
Change permission registration
RhythmicSys Aug 12, 2025
f9e0dd2
Changed API version
RhythmicSys Aug 12, 2025
7b608ea
Reorganize Locale
RhythmicSys Aug 13, 2025
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 8 additions & 3 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -6,13 +6,13 @@

<groupId>simplexity</groupId>
<artifactId>SimpleNicks</artifactId>
<version>2.1.0</version>
<version>3.0.0</version>
<packaging>jar</packaging>

<name>SimpleNicks</name>

<properties>
<java.version>1.8</java.version>
<java.version>21</java.version>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
</properties>

Expand Down Expand Up @@ -79,7 +79,7 @@
<dependency>
<groupId>io.papermc.paper</groupId>
<artifactId>paper-api</artifactId>
<version>1.21-R0.1-SNAPSHOT</version>
<version>1.21.5-R0.1-SNAPSHOT</version>
<scope>provided</scope>
</dependency>
<dependency>
Expand All @@ -88,5 +88,10 @@
<version>2.11.5</version>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>com.zaxxer</groupId>
<artifactId>HikariCP</artifactId>
<version>6.3.0</version>
</dependency>
</dependencies>
</project>
97 changes: 56 additions & 41 deletions src/main/java/simplexity/simplenicks/SimpleNicks.java
Original file line number Diff line number Diff line change
@@ -1,58 +1,74 @@
package simplexity.simplenicks;

import io.papermc.paper.plugin.lifecycle.event.types.LifecycleEvents;
import net.kyori.adventure.text.minimessage.MiniMessage;
import net.kyori.adventure.text.minimessage.tag.resolver.TagResolver;
import org.bukkit.plugin.Plugin;
import org.bukkit.plugin.java.JavaPlugin;
import simplexity.simplenicks.commands.CommandHandler;
import simplexity.simplenicks.commands.Delete;
import simplexity.simplenicks.commands.Help;
import simplexity.simplenicks.commands.Reset;
import simplexity.simplenicks.commands.Save;
import simplexity.simplenicks.commands.Set;
import simplexity.simplenicks.commands.SNReload;
import simplexity.simplenicks.commands.SubCommand;
import simplexity.simplenicks.commands.NicknameCommand;
import simplexity.simplenicks.config.ConfigHandler;
import simplexity.simplenicks.config.LocaleHandler;
import simplexity.simplenicks.hooks.SNExpansion;
import simplexity.simplenicks.listener.LeaveListener;
import simplexity.simplenicks.listener.LoginListener;
import simplexity.simplenicks.util.Constants;
import simplexity.simplenicks.util.NickHandler;
import simplexity.simplenicks.util.SNExpansion;
import simplexity.simplenicks.saving.SaveMigrator;
import simplexity.simplenicks.saving.SqlHandler;
import simplexity.simplenicks.util.ColorTag;
import simplexity.simplenicks.util.FormatTag;
import simplexity.simplenicks.util.NickPermission;

import java.util.Collections;
import java.util.HashMap;
import java.util.Map;
import java.util.logging.Logger;

/*command based
[/nick [nickname] or /nick <player> [nickname]]
need to check if it's a valid name
[Alphanumeric, tho a bypass permission would be nice]
need to check if the minimessage formats are allowed- i,e, not allowing hover/click event tag
[assuming I'd make a set of blacklisted tag types, check for those]
need to check length after parsing
PlaceholderAPI placeholder for before parsing, and after
*/

@SuppressWarnings("UnstableApiUsage")
public final class SimpleNicks extends JavaPlugin {

private static final MiniMessage miniMessage = MiniMessage.miniMessage();
private static Plugin instance;
private static final HashMap<String, SubCommand> subCommands = new HashMap<>();
private static MiniMessage defaultResolver;

@Override
public void onEnable() {
instance = this;
registerSubCommands();
this.saveDefaultConfig();
getConfig().options().copyDefaults(true);
saveConfig();
this.getCommand("nick").setExecutor(new CommandHandler());
this.getCommand("snreload").setExecutor(new SNReload());
if (this.getServer().getPluginManager().isPluginEnabled("PlaceholderAPI")) {
new SNExpansion().register();
}
instance.getServer().getPluginManager().registerEvents(new LoginListener(), this);
getServer().getPluginManager().registerEvents(new LoginListener(), this);
getServer().getPluginManager().registerEvents(new LeaveListener(), this);
configReload();
SqlHandler.getInstance().init();
SaveMigrator.migrateFromYml();
this.getLifecycleManager().registerEventHandler(LifecycleEvents.COMMANDS, commands -> {
commands.registrar().register(NicknameCommand.createCommand().build());
});
setUpResolver();
registerPermissions();
}

private void registerPermissions() {
for (NickPermission perm : NickPermission.values()) {
getServer().getPluginManager().addPermission(perm.getPermission());
}
for (ColorTag perm : ColorTag.values()) {
getServer().getPluginManager().addPermission(perm.getPermission());
}
}

private void setUpResolver() {
TagResolver.Builder tagResolver = TagResolver.builder();
for (ColorTag colorTag : ColorTag.values()) {
tagResolver.resolver(colorTag.getTagResolver());
}
for (FormatTag formatTag : FormatTag.values()) {
tagResolver.resolver(formatTag.getTagResolver());
}
TagResolver resolver = tagResolver.build();
defaultResolver = MiniMessage.builder()
.strict(false)
.tags(resolver)
.build();
}

public static MiniMessage getMiniMessage() {
Expand All @@ -63,25 +79,24 @@ public static Plugin getInstance() {
return instance;
}

public static Map<String, SubCommand> getSubCommands() {
return Collections.unmodifiableMap(subCommands);
}

public static Logger getSimpleNicksLogger() {
return instance.getLogger();
}

private void registerSubCommands() {
subCommands.put("reset", new Reset("reset", Constants.NICK_RESET, Constants.NICK_RESET_OTHERS, false));
subCommands.put("help", new Help("help", Constants.NICK_COMMAND, Constants.NICK_OTHERS_COMMAND, true));
subCommands.put("set", new Set("set", Constants.NICK_COMMAND, Constants.NICK_OTHERS_RESTRICTIVE, false));
subCommands.put("save", new Save("save", Constants.NICK_SAVE, Constants.NICK_OTHERS_SAVE, false));
subCommands.put("delete", new Delete("delete", Constants.NICK_DELETE, Constants.NICK_OTHERS_DELETE, false));
public static MiniMessage getDefaultParser() {
return defaultResolver;

}


public static void configReload() {
LocaleHandler.getInstance().loadLocale();
ConfigHandler.getInstance().reloadConfig();
NickHandler.getInstance().loadSavingType();
}

@Override
public void onDisable() {
SqlHandler.getInstance().closeDatabase();
}


}
137 changes: 0 additions & 137 deletions src/main/java/simplexity/simplenicks/commands/CommandHandler.java

This file was deleted.

59 changes: 0 additions & 59 deletions src/main/java/simplexity/simplenicks/commands/Delete.java

This file was deleted.

Loading