Skip to content

Commit 2433bc7

Browse files
authored
Merge pull request #34 from CyR1en/development
Sync to main
2 parents 17e2f4c + 78cab05 commit 2433bc7

40 files changed

Lines changed: 1083 additions & 445 deletions

.idea/icon.png

40.2 KB
Loading

build.gradle

Lines changed: 5 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@ java {
3939

4040
PluginManifest pluginManifest = [
4141
name : 'CommandPrompter',
42-
version : new Version(major: 2, minor: 6, patch: 0, fix: 0, classifier: 'RELEASE'),
42+
version : new Version(major: 2, minor: 7, patch: 0, fix: 0, classifier: 'SNAPSHOT'),
4343
author : 'CyR1en',
4444
description: 'Perfect companion plugin for inventory UI menu.',
4545
entry : 'com.cyr1en.commandprompter.CommandPrompter'
@@ -63,10 +63,10 @@ repositories {
6363
dependencies {
6464
implementation 'com.cyr1en:kiso-utils:1.8-SNAPSHOT'
6565
implementation 'com.cyr1en:kiso-mc:1.8-SNAPSHOT'
66-
implementation 'net.wesjd:anvilgui:1.9.0-SNAPSHOT'
67-
implementation 'io.github.rapha149.signgui:signgui:2.2.1'
66+
implementation 'net.wesjd:anvilgui:1.9.2-SNAPSHOT'
67+
implementation 'io.github.rapha149.signgui:signgui:2.2.2'
6868
implementation 'org.bstats:bstats-bukkit:3.0.0'
69-
implementation "dev.jorel:commandapi-bukkit-shade:9.2.0"
69+
implementation "dev.jorel:commandapi-bukkit-shade:9.3.0"
7070
implementation group: 'org.fusesource.jansi', name: 'jansi', version: '2.4.0'
7171

7272
// Exclude these
@@ -97,7 +97,7 @@ shadowJar {
9797
}
9898

9999
archiveBaseName.set("$project.name")
100-
archiveClassifier.set(pluginManifest.version.classifier + "-Bundled")
100+
archiveClassifier.set('bundled')
101101
archiveVersion.set(pluginManifest.version.getFullVersion())
102102

103103
relocate 'com.github.stefvanschie.inventoryframework', 'com.cyr1en.inventoryframework'
@@ -115,11 +115,9 @@ shadowJar {
115115
import com.github.jengelman.gradle.plugins.shadow.tasks.ShadowJar
116116

117117
tasks.register("lightJar", ShadowJar) {
118-
archiveClassifier.set(pluginManifest.version.classifier)
119118
from sourceSets.main.output
120119
configurations = [project.configurations.runtimeClasspath]
121120

122-
123121
dependencies {
124122
exclude(dependency('com.mojang:brigadier'))
125123
exclude(dependency('com.github.stefvanschie.inventoryframework:IF'))

src/main/java/com/cyr1en/commandprompter/CommandPrompter.java

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,6 @@
4545
import com.cyr1en.kiso.mc.I18N;
4646
import com.cyr1en.kiso.mc.UpdateChecker;
4747
import com.cyr1en.kiso.utils.SRegex;
48-
4948
import org.bstats.bukkit.Metrics;
5049
import org.bukkit.Bukkit;
5150
import org.bukkit.entity.Player;
@@ -122,9 +121,9 @@ public void onDisable() {
122121
}
123122

124123
private void initPromptSystem() {
124+
Bukkit.getPluginManager().registerEvents(headCache = new HeadCache(this), this);
125125
promptManager = new PromptManager(this);
126126
initCommandListener();
127-
Bukkit.getPluginManager().registerEvents(headCache = new HeadCache(this), this);
128127
}
129128

130129
private boolean loadDeps() {
@@ -137,7 +136,7 @@ private boolean loadDeps() {
137136

138137
var depLoader = new DependencyLoader(this);
139138
if (!depLoader.isClassLoaderAccessSupported())
140-
return depErrAndDisable("No access to URLClassloader, cannot load depedencies!", depLoader);
139+
return depErrAndDisable("No access to URLClassloader, cannot load dependencies!", depLoader);
141140

142141
if (!depLoader.loadCoreDeps())
143142
return depErrAndDisable("Unable to load dependencies!", depLoader);
@@ -190,7 +189,7 @@ private void hackMap() {
190189
logger.warn("sHash: " + sHash + " | pHash: " + pHash);
191190
Bukkit.getPluginManager().registerEvents(commandListener, this);
192191
} catch (NoSuchFieldException | IllegalAccessException e) {
193-
e.printStackTrace();
192+
logger.err("Unable to hack command map!");
194193
}
195194
}
196195

@@ -248,6 +247,7 @@ public void reload(boolean clean) {
248247
messenger.setPrefix(config.promptPrefix());
249248
logger = new PluginLogger(this, "CommandPrompter");
250249
i18n = new I18N(this, "CommandPrompter");
250+
headCache.reBuildCache();
251251
promptManager.getParser().initRegex();
252252
ChatPrompt.DefaultListener.setPriority(this);
253253
setupUpdater();

src/main/java/com/cyr1en/commandprompter/PluginLogger.java

Lines changed: 3 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
package com.cyr1en.commandprompter;
22

33
import org.bukkit.Bukkit;
4-
import org.bukkit.ChatColor;
54
import org.fusesource.jansi.Ansi;
65
import org.fusesource.jansi.AnsiConsole;
76

@@ -17,8 +16,8 @@ public class PluginLogger {
1716
private final ColorGradient normalGrad;
1817
private final ColorGradient debugGrad;
1918

20-
private boolean debugMode = false;
21-
private boolean isFancy = true;
19+
private final boolean debugMode;
20+
private final boolean isFancy;
2221

2322
public PluginLogger(CommandPrompter plugin, String prefix) {
2423
this.isFancy = plugin.getConfiguration().fancyLogger();
@@ -91,20 +90,12 @@ public void debug(String msg, Object... args) {
9190
if (debugMode) {
9291
msg = callerAvailable ? String.format("[%s] - %s", caller.getSimpleName(), msg)
9392
: Objects.isNull(lastDebugClass) ? msg
94-
: String.format("[%s?] - %s", lastDebugClass.getSimpleName(), msg);
93+
: String.format("[%s?] - %s", lastDebugClass.getSimpleName(), msg);
9594
var str = new Ansi().fgRgb(255, 195, 113).a(msg).reset().toString();
9695
log(debugPrefix, Level.INFO, str, args);
9796
}
9897
}
9998

100-
public void setDebugMode(boolean b) {
101-
debugMode = b;
102-
}
103-
104-
public void bukkitWarn(String msg) {
105-
Bukkit.getConsoleSender().sendMessage(ChatColor.GOLD + getPrefix() + msg);
106-
}
107-
10899
private String getPrefix() {
109100
return prefix;
110101
}

src/main/java/com/cyr1en/commandprompter/api/Dispatcher.java

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -90,16 +90,22 @@ public static void dispatchWithAttachment(Plugin plugin, Player sender, String c
9090
var logger = commandPrompter.getPluginLogger();
9191

9292
logger.debug("Dispatching command with permission attachment");
93+
9394
var attachment = sender.addAttachment(plugin, ticks);
9495
if (attachment == null) {
9596
logger.err("Unable to create PermissionAttachment for " + sender.getName());
9697
return;
9798
}
98-
logger.debug("Added PermissionAttachment");
99-
for (String perm : perms)
99+
100+
for (String perm : perms) {
101+
logger.debug("Attached Perm: " + perm);
100102
attachment.setPermission(perm, true);
103+
}
101104
attachment.getPermissible().recalculatePermissions();
102-
dispatchCommand(plugin, (Player) attachment.getPermissible(), command);
105+
final String checked = command.codePointAt(0) == 0x2F ? command.substring(1) : command;
106+
Bukkit.dispatchCommand(sender, checked);
107+
//dispatchCommand(plugin, sender, command);
108+
sender.removeAttachment(attachment);
103109
}
104110

105111
}

src/main/java/com/cyr1en/commandprompter/api/prompt/Prompt.java

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -99,4 +99,18 @@ public interface Prompt {
9999
* @return true if input is valid
100100
*/
101101
boolean isValidInput(String input);
102+
103+
/**
104+
* Returns a boolean value if inputs should be sanitized.
105+
*
106+
* @return true if inputs should be sanitized
107+
*/
108+
boolean sanitizeInput();
109+
110+
/**
111+
* Set whether inputs should be sanitized.
112+
*
113+
* @param sanitize true if inputs should be sanitized
114+
*/
115+
void setInputSanitization(boolean sanitize);
102116
}

src/main/java/com/cyr1en/commandprompter/commands/CommandAPIWrapper.java

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,13 +2,12 @@
22

33
import com.cyr1en.commandprompter.CommandPrompter;
44
import com.cyr1en.commandprompter.util.Util;
5-
65
import dev.jorel.commandapi.CommandAPI;
76
import dev.jorel.commandapi.CommandAPIBukkitConfig;
87

98
/**
109
* Wrapper for CommandAPI.
11-
*
10+
*
1211
* <p>
1312
* Since CommandPrompter loads CommandAPI dynamically, we need a wrapper to
1413
* prevent
@@ -24,6 +23,7 @@ public CommandAPIWrapper(CommandPrompter plugin) {
2423

2524
public void load() {
2625
var config = new CommandAPIBukkitConfig(plugin);
26+
config.useLatestNMSVersion(false);
2727
config = plugin.getConfiguration().debugMode() ? config.silentLogs(false).verboseOutput(true)
2828
: config.silentLogs(true).verboseOutput(false);
2929

@@ -42,6 +42,7 @@ public void onDisable() {
4242

4343
public void registerCommands() {
4444
new MainCommand(plugin).register();
45-
new ConsoleDelegate(plugin).register();
45+
new DelegateCommand.ConsoleDelegate(plugin).register();
46+
new DelegateCommand.PlayerDelegate(plugin).register();
4647
}
4748
}

src/main/java/com/cyr1en/commandprompter/commands/ConsoleDelegate.java

Lines changed: 0 additions & 83 deletions
This file was deleted.

0 commit comments

Comments
 (0)