-
Notifications
You must be signed in to change notification settings - Fork 4
/
Copy pathpatchs.patch
420 lines (390 loc) · 18.1 KB
/
patchs.patch
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
diff --git a/api/src/main/java/net/luckperms/api/platform/Platform.java b/api/src/main/java/net/luckperms/api/platform/Platform.java
index bc31a34a8..e1e0dc00b 100644
--- a/api/src/main/java/net/luckperms/api/platform/Platform.java
+++ b/api/src/main/java/net/luckperms/api/platform/Platform.java
@@ -71,6 +71,7 @@ public interface Platform {
*/
enum Type {
BUKKIT("Bukkit"),
+ MIRAI_CONSOLE("Mirai Console"),
BUNGEECORD("BungeeCord"),
SPONGE("Sponge"),
NUKKIT("Nukkit"),
diff --git a/common/src/main/java/me/lucko/luckperms/common/api/implementation/ApiPlatform.java b/common/src/main/java/me/lucko/luckperms/common/api/implementation/ApiPlatform.java
index d19884c76..1c5d918c2 100644
--- a/common/src/main/java/me/lucko/luckperms/common/api/implementation/ApiPlatform.java
+++ b/common/src/main/java/me/lucko/luckperms/common/api/implementation/ApiPlatform.java
@@ -52,7 +52,8 @@ public class ApiPlatform implements Platform, PluginMetadata {
@Override
public @NonNull String getApiVersion() {
- String[] version = this.plugin.getBootstrap().getVersion().split("\\.");
+ String[] version = this.plugin.getBootstrap().getVersionLuckPerms().split("\\.");
+ version[1] = version[1].replace("-SNAPSHOT", "");
return version[0] + '.' + version[1];
}
diff --git a/common/src/main/java/me/lucko/luckperms/common/command/CommandManager.java b/common/src/main/java/me/lucko/luckperms/common/command/CommandManager.java
index c5be1966a..ecd1fddf1 100644
--- a/common/src/main/java/me/lucko/luckperms/common/command/CommandManager.java
+++ b/common/src/main/java/me/lucko/luckperms/common/command/CommandManager.java
@@ -89,6 +89,7 @@ import java.util.concurrent.atomic.AtomicBoolean;
import java.util.concurrent.atomic.AtomicReference;
import java.util.function.Function;
import java.util.stream.Collectors;
+import java.util.stream.Stream;
/**
* Root command manager for the '/luckperms' command.
@@ -109,7 +110,7 @@ public class CommandManager {
public CommandManager(LuckPermsPlugin plugin) {
this.plugin = plugin;
this.tabCompletions = new TabCompletions(plugin);
- this.mainCommands = ImmutableList.<Command<?>>builder()
+ this.mainCommands = Stream.concat(ImmutableList.<Command<?>>builder()
.add(new UserParentCommand())
.add(new GroupParentCommand())
.add(new TrackParentCommand())
@@ -136,14 +137,28 @@ public class CommandManager {
.add(new DeleteTrack())
.add(new ListTracks())
.build()
- .stream()
+ .stream(),injectedCommands())
.collect(ImmutableCollectors.toMap(c -> c.getName().toLowerCase(Locale.ROOT), Function.identity()));
}
+ protected Stream<Command<?>> injectedCommands() {
+ return Stream.empty();
+ }
+
public LuckPermsPlugin getPlugin() {
return this.plugin;
}
+ protected Object preExecute(Sender sender, String label, List<String> arguments) {
+ return null;
+ }
+ protected boolean shouldRenderVersion(Sender sender, boolean hasPermAny, boolean isFirstTime) {
+ return true;
+ }
+ protected boolean shouldRendNoPermsForSubCommands(Sender sender) {
+ return true;
+ }
+
public TabCompletions getTabCompletions() {
return this.tabCompletions;
}
@@ -220,10 +235,25 @@ public class CommandManager {
}
private void execute(Sender sender, String label, List<String> arguments) {
+ {
+ Object result = preExecute(sender, label, arguments);
+ if (result != null) return;
+ }
applyConvenienceAliases(arguments, true);
// Handle no arguments
if (arguments.isEmpty() || arguments.size() == 1 && arguments.get(0).trim().isEmpty()) {
+ boolean lpm_hasAnyPermission = hasPermissionForAny(sender);
+ boolean lpm_isFirstTime = false;
+ if (!lpm_hasAnyPermission) {
+ Collection<? extends Group> groups = this.plugin.getGroupManager().getAll().values();
+ if (groups.size() <= 1 && groups.stream().allMatch(g -> g.normalData().isEmpty())) {
+ lpm_isFirstTime = true;
+ }
+ }
+
+ if (shouldRenderVersion(sender, lpm_hasAnyPermission, lpm_isFirstTime)) {
+
sender.sendMessage(Message.prefixed(Component.text()
.color(NamedTextColor.DARK_GREEN)
.append(Component.text("Running "))
@@ -233,16 +263,21 @@ public class CommandManager {
.append(Message.FULL_STOP)
));
- if (hasPermissionForAny(sender)) {
+ }
+
+ if (lpm_hasAnyPermission) {
Message.VIEW_AVAILABLE_COMMANDS_PROMPT.send(sender, label);
return;
}
- Collection<? extends Group> groups = this.plugin.getGroupManager().getAll().values();
- if (groups.size() <= 1 && groups.stream().allMatch(g -> g.normalData().isEmpty())) {
+ if (lpm_isFirstTime) {
Message.FIRST_TIME_SETUP.send(sender, label, sender.getName());
} else {
+ if (shouldRendNoPermsForSubCommands(sender)) {
+
Message.NO_PERMISSION_FOR_SUBCOMMANDS.send(sender);
+
+ }
}
return;
}
@@ -300,14 +335,6 @@ public class CommandManager {
}
private void sendCommandUsage(Sender sender, String label) {
- sender.sendMessage(Message.prefixed(Component.text()
- .color(NamedTextColor.DARK_GREEN)
- .append(Component.text("Running "))
- .append(Component.text(AbstractLuckPermsPlugin.getPluginName(), NamedTextColor.AQUA))
- .append(Component.space())
- .append(Component.text("v" + this.plugin.getBootstrap().getVersion(), NamedTextColor.AQUA))
- .append(Message.FULL_STOP)
- ));
this.mainCommands.values().stream()
.filter(Command::shouldDisplay)
diff --git a/common/src/main/java/me/lucko/luckperms/common/command/access/CommandPermission.java b/common/src/main/java/me/lucko/luckperms/common/command/access/CommandPermission.java
index ed1ed15e3..aac889424 100644
--- a/common/src/main/java/me/lucko/luckperms/common/command/access/CommandPermission.java
+++ b/common/src/main/java/me/lucko/luckperms/common/command/access/CommandPermission.java
@@ -31,6 +31,7 @@ import me.lucko.luckperms.common.sender.Sender;
* An enumeration of the permissions required to execute built in LuckPerms commands.
*/
public enum CommandPermission {
+ LPM_DEBUG("lpmdebug", Type.NONE),
SYNC("sync", Type.NONE),
INFO("info", Type.NONE),
diff --git a/common/src/main/java/me/lucko/luckperms/common/command/spec/CommandSpec.java b/common/src/main/java/me/lucko/luckperms/common/command/spec/CommandSpec.java
index f749a3117..44740004f 100644
--- a/common/src/main/java/me/lucko/luckperms/common/command/spec/CommandSpec.java
+++ b/common/src/main/java/me/lucko/luckperms/common/command/spec/CommandSpec.java
@@ -38,6 +38,7 @@ import java.util.Locale;
*/
@SuppressWarnings("SpellCheckingInspection")
public enum CommandSpec {
+ LPM_DEBUG("/%s lpmdebug"),
USER("/%s user <user>"),
GROUP("/%s group <group>"),
diff --git a/common/src/main/java/me/lucko/luckperms/common/commands/misc/EditorCommand.java b/common/src/main/java/me/lucko/luckperms/common/commands/misc/EditorCommand.java
index 46ac1698d..166e2fbf9 100644
--- a/common/src/main/java/me/lucko/luckperms/common/commands/misc/EditorCommand.java
+++ b/common/src/main/java/me/lucko/luckperms/common/commands/misc/EditorCommand.java
@@ -108,6 +108,8 @@ public class EditorCommand extends SingleCommand {
Message.EDITOR_START.send(sender);
+ sender.flush();
+
WebEditorSession.createAndOpen(holders, tracks, sender, label, plugin);
}
diff --git a/common/src/main/java/me/lucko/luckperms/common/config/ConfigKeys.java b/common/src/main/java/me/lucko/luckperms/common/config/ConfigKeys.java
index 17b2d7b48..8de0a9fec 100644
--- a/common/src/main/java/me/lucko/luckperms/common/config/ConfigKeys.java
+++ b/common/src/main/java/me/lucko/luckperms/common/config/ConfigKeys.java
@@ -735,7 +735,7 @@ public final class ConfigKeys {
/**
* A list of the keys defined in this class.
*/
- private static final List<SimpleConfigKey<?>> KEYS = KeyedConfiguration.initialise(ConfigKeys.class);
+ private static List<SimpleConfigKey<?>> KEYS = KeyedConfiguration.initialise(ConfigKeys.class);
public static List<? extends ConfigKey<?>> getKeys() {
return KEYS;
diff --git a/common/src/main/java/me/lucko/luckperms/common/dependencies/DependencyManager.java b/common/src/main/java/me/lucko/luckperms/common/dependencies/DependencyManager.java
index 710658ef8..17ba4728c 100644
--- a/common/src/main/java/me/lucko/luckperms/common/dependencies/DependencyManager.java
+++ b/common/src/main/java/me/lucko/luckperms/common/dependencies/DependencyManager.java
@@ -32,6 +32,7 @@ import me.lucko.luckperms.common.dependencies.relocation.Relocation;
import me.lucko.luckperms.common.dependencies.relocation.RelocationHandler;
import me.lucko.luckperms.common.plugin.LuckPermsPlugin;
import me.lucko.luckperms.common.plugin.classpath.ClassPathAppender;
+import me.lucko.luckperms.common.plugin.logging.PluginLogger;
import me.lucko.luckperms.common.storage.StorageType;
import me.lucko.luckperms.common.util.MoreFiles;
@@ -72,6 +73,7 @@ public class DependencyManager {
private final EnumMap<Dependency, Path> loaded = new EnumMap<>(Dependency.class);
/** A map of isolated classloaders which have been created. */
private final Map<ImmutableSet<Dependency>, IsolatedClassLoader> loaders = new HashMap<>();
+ private final PluginLogger logger;
/** Cached relocation handler instance. */
private @MonotonicNonNull RelocationHandler relocationHandler = null;
@@ -80,6 +82,7 @@ public class DependencyManager {
this.cacheDirectory = setupCacheDirectory(plugin);
this.classPathAppender = plugin.getBootstrap().getClassPathAppender();
this.loadingExecutor = plugin.getBootstrap().getScheduler().async();
+ this.logger = plugin.getLogger();
}
public DependencyManager(Path cacheDirectory, Executor executor) { // standalone
@@ -87,6 +90,7 @@ public class DependencyManager {
this.cacheDirectory = cacheDirectory;
this.classPathAppender = null;
this.loadingExecutor = executor;
+ this.logger = null;
}
private synchronized RelocationHandler getRelocationHandler() {
@@ -186,6 +190,9 @@ public class DependencyManager {
// attempt to download the dependency from each repo in order.
for (DependencyRepository repo : DependencyRepository.values()) {
try {
+ if (logger != null) {
+ logger.info("Downloading dependency: " + dependency + ", " + file.getFileName() + " from " + repo);
+ }
repo.download(dependency, file);
return file;
} catch (DependencyDownloadException e) {
diff --git a/common/src/main/java/me/lucko/luckperms/common/dependencies/DependencyRepository.java b/common/src/main/java/me/lucko/luckperms/common/dependencies/DependencyRepository.java
index 7dcdd4ea5..8b3d32972 100644
--- a/common/src/main/java/me/lucko/luckperms/common/dependencies/DependencyRepository.java
+++ b/common/src/main/java/me/lucko/luckperms/common/dependencies/DependencyRepository.java
@@ -41,6 +41,16 @@ import java.util.concurrent.TimeUnit;
*/
public enum DependencyRepository {
+ ALIYUN_MIRROR("https://maven.aliyun.com/repository/public") {
+ @Override
+ protected URLConnection openConnection(Dependency dependency) throws IOException {
+ URLConnection connection = super.openConnection(dependency);
+ connection.setConnectTimeout((int) TimeUnit.SECONDS.toMillis(5));
+ connection.setReadTimeout((int) TimeUnit.SECONDS.toMillis(10));
+ return connection;
+ }
+ },
+
/**
* Maven Central mirror repository.
*
diff --git a/common/src/main/java/me/lucko/luckperms/common/locale/Message.java b/common/src/main/java/me/lucko/luckperms/common/locale/Message.java
index 0be4e97e1..bf66ed15d 100644
--- a/common/src/main/java/me/lucko/luckperms/common/locale/Message.java
+++ b/common/src/main/java/me/lucko/luckperms/common/locale/Message.java
@@ -1576,8 +1576,7 @@ public interface Message {
.append(text(':'))),
prefixed(text()
.color(WHITE)
- .append(text(" "))
- .append(text(plugin.getBootstrap().getServerVersion()))),
+ .append(text(plugin.getBootstrap().versionOnCommandRender()))),
prefixed(text()
.color(AQUA)
.append(text("- ", WHITE))
diff --git a/common/src/main/java/me/lucko/luckperms/common/model/manager/user/UserHousekeeper.java b/common/src/main/java/me/lucko/luckperms/common/model/manager/user/UserHousekeeper.java
index f1ae13665..bbbd40edc 100644
--- a/common/src/main/java/me/lucko/luckperms/common/model/manager/user/UserHousekeeper.java
+++ b/common/src/main/java/me/lucko/luckperms/common/model/manager/user/UserHousekeeper.java
@@ -75,7 +75,7 @@ public class UserHousekeeper implements Runnable {
public void cleanup(UUID uuid) {
// unload users which aren't online and who haven't been online (or tried to login) recently
- if (this.recentlyUsed.contains(uuid) || this.recentlyUsedApi.contains(uuid) || this.plugin.getBootstrap().isPlayerOnline(uuid)) {
+ if (this.recentlyUsed.contains(uuid) || this.recentlyUsedApi.contains(uuid) || uuid.getMostSignificantBits() == 0L) {
return;
}
@@ -108,4 +108,14 @@ public class UserHousekeeper implements Runnable {
this.unit = unit;
}
}
+
+ public static class Access {
+ public static ExpiringSet<UUID> recentlyUsed(UserHousekeeper i) {
+ return i.recentlyUsed;
+ }
+
+ public static ExpiringSet<UUID> recentlyUsedApi(UserHousekeeper i) {
+ return i.recentlyUsedApi;
+ }
+ }
}
diff --git a/common/src/main/java/me/lucko/luckperms/common/plugin/bootstrap/LuckPermsBootstrap.java b/common/src/main/java/me/lucko/luckperms/common/plugin/bootstrap/LuckPermsBootstrap.java
index df8fbcb53..d089dd490 100644
--- a/common/src/main/java/me/lucko/luckperms/common/plugin/bootstrap/LuckPermsBootstrap.java
+++ b/common/src/main/java/me/lucko/luckperms/common/plugin/bootstrap/LuckPermsBootstrap.java
@@ -232,4 +232,14 @@ public interface LuckPermsBootstrap {
return null;
}
+
+ // LuckPerms Mirai - Start
+
+ default String versionOnCommandRender() {
+ return null;
+ }
+
+ String getVersionLuckPerms();
+
+ // LuckPerms Mirai - End
}
diff --git a/common/src/main/java/me/lucko/luckperms/common/sender/Sender.java b/common/src/main/java/me/lucko/luckperms/common/sender/Sender.java
index a4287a7d0..df176f333 100644
--- a/common/src/main/java/me/lucko/luckperms/common/sender/Sender.java
+++ b/common/src/main/java/me/lucko/luckperms/common/sender/Sender.java
@@ -160,4 +160,12 @@ public interface Sender {
return true;
}
+ /**
+ * Flush cached message to real sender
+ *
+ * For LuckPerms-Mirai
+ */
+ default void flush() {}
+
+ default boolean isHoverEventSupported() { return false; }
}
diff --git a/common/src/main/java/me/lucko/luckperms/common/util/ExpiringSet.java b/common/src/main/java/me/lucko/luckperms/common/util/ExpiringSet.java
index 8ed2535d9..aef840178 100644
--- a/common/src/main/java/me/lucko/luckperms/common/util/ExpiringSet.java
+++ b/common/src/main/java/me/lucko/luckperms/common/util/ExpiringSet.java
@@ -27,6 +27,9 @@ package me.lucko.luckperms.common.util;
import com.github.benmanes.caffeine.cache.Cache;
+import java.util.ArrayList;
+import java.util.Collection;
+import java.util.Map;
import java.util.concurrent.TimeUnit;
/**
@@ -57,4 +60,17 @@ public class ExpiringSet<E> {
public void remove(E item) {
this.cache.invalidate(item);
}
+
+ public Collection<E> snapshot() {
+ ArrayList<E> rsp = new ArrayList<>();
+ long currentTime = System.currentTimeMillis();
+ for (Map.Entry<E, Long> e : cache.asMap().entrySet()) {
+ E k = e.getKey();
+ Long v = e.getValue();
+ if (v != null && v > currentTime) {
+ rsp.add(k);
+ }
+ }
+ return rsp;
+ }
}
diff --git a/common/src/main/java/me/lucko/luckperms/common/verbose/VerboseListener.java b/common/src/main/java/me/lucko/luckperms/common/verbose/VerboseListener.java
index 22c082368..063585fce 100644
--- a/common/src/main/java/me/lucko/luckperms/common/verbose/VerboseListener.java
+++ b/common/src/main/java/me/lucko/luckperms/common/verbose/VerboseListener.java
@@ -174,7 +174,7 @@ public class VerboseListener {
}
// just send as a raw message
- if (this.notifiedSender.isConsole()) {
+ if (!this.notifiedSender.isHoverEventSupported()) {
this.notifiedSender.sendMessage(component);
return;
}
diff --git a/settings.gradle b/settings.gradle
index b03ef276d..b88ed5914 100644
--- a/settings.gradle
+++ b/settings.gradle
@@ -1,7 +1,6 @@
// Fabric Needs this
pluginManagement {
repositories {
- jcenter()
maven {
url 'https://maven.fabricmc.net/'
}
@@ -14,24 +13,4 @@ include (
'api',
'common',
'common:loader-utils',
- 'bukkit',
- 'bukkit:loader',
- 'bukkit-legacy',
- 'bukkit-legacy:loader',
- 'bungee',
- 'bungee:loader',
- 'fabric',
- 'forge',
- 'forge:loader',
- 'forge:forge-api',
- 'nukkit',
- 'nukkit:loader',
- 'sponge',
- 'sponge:loader',
- 'sponge:sponge-service',
- 'sponge:sponge-service-api8',
- 'velocity',
- 'standalone',
- 'standalone:loader',
- 'standalone:app'
)