-
-
Notifications
You must be signed in to change notification settings - Fork 104
/
Denizen.java
604 lines (575 loc) · 26.2 KB
/
Denizen.java
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
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
package com.denizenscript.denizen;
import com.denizenscript.denizen.events.ScriptEventRegistry;
import com.denizenscript.denizen.events.bukkit.SavesReloadEvent;
import com.denizenscript.denizen.events.server.ServerPrestartScriptEvent;
import com.denizenscript.denizen.events.server.ServerStartScriptEvent;
import com.denizenscript.denizen.nms.NMSVersion;
import com.denizenscript.denizen.objects.InventoryTag;
import com.denizenscript.denizen.objects.NPCTag;
import com.denizenscript.denizen.objects.PlayerTag;
import com.denizenscript.denizen.objects.properties.PropertyRegistry;
import com.denizenscript.denizen.scripts.commands.BukkitCommandRegistry;
import com.denizenscript.denizen.scripts.commands.player.ClickableCommand;
import com.denizenscript.denizen.scripts.containers.ContainerRegistry;
import com.denizenscript.denizen.scripts.containers.core.*;
import com.denizenscript.denizen.scripts.triggers.TriggerRegistry;
import com.denizenscript.denizen.tags.BukkitTagContext;
import com.denizenscript.denizen.tags.core.NPCTagBase;
import com.denizenscript.denizen.tags.core.ServerTagBase;
import com.denizenscript.denizen.utilities.*;
import com.denizenscript.denizen.utilities.command.*;
import com.denizenscript.denizen.utilities.command.manager.CommandManager;
import com.denizenscript.denizen.utilities.command.manager.Injector;
import com.denizenscript.denizen.utilities.command.manager.messaging.Messaging;
import com.denizenscript.denizen.utilities.debugging.BStatsMetricsLite;
import com.denizenscript.denizen.utilities.debugging.StatsRecord;
import com.denizenscript.denizen.utilities.debugging.Debug;
import com.denizenscript.denizen.utilities.depends.Depends;
import com.denizenscript.denizen.utilities.entity.DenizenEntityType;
import com.denizenscript.denizen.utilities.flags.PlayerFlagHandler;
import com.denizenscript.denizen.utilities.flags.WorldFlagHandler;
import com.denizenscript.denizen.utilities.implementation.DenizenCoreImplementation;
import com.denizenscript.denizen.utilities.maps.DenizenMapManager;
import com.denizenscript.denizen.nms.NMSHandler;
import com.denizenscript.denizen.nms.interfaces.FakeArrow;
import com.denizenscript.denizen.nms.interfaces.FakePlayer;
import com.denizenscript.denizen.nms.interfaces.ItemProjectile;
import com.denizenscript.denizen.npc.TraitRegistry;
import com.denizenscript.denizen.npc.DenizenNPCHelper;
import com.denizenscript.denizen.utilities.packets.NetworkInterceptHelper;
import com.denizenscript.denizen.utilities.world.VoidGenerator;
import com.denizenscript.denizen.utilities.world.VoidGenerator1_17;
import com.denizenscript.denizencore.DenizenCore;
import com.denizenscript.denizencore.objects.ObjectFetcher;
import com.denizenscript.denizencore.objects.core.TimeTag;
import com.denizenscript.denizencore.objects.notable.NoteManager;
import com.denizenscript.denizencore.scripts.ScriptHelper;
import com.denizenscript.denizencore.scripts.ScriptRegistry;
import com.denizenscript.denizencore.scripts.commands.core.AdjustCommand;
import com.denizenscript.denizencore.scripts.commands.queue.RunLaterCommand;
import com.denizenscript.denizencore.tags.TagManager;
import com.denizenscript.denizencore.utilities.CoreConfiguration;
import com.denizenscript.denizencore.utilities.CoreUtilities;
import com.denizenscript.denizencore.utilities.debugging.StrongWarning;
import com.denizenscript.denizencore.utilities.text.ConfigUpdater;
import org.bukkit.*;
import org.bukkit.command.Command;
import org.bukkit.command.CommandSender;
import org.bukkit.configuration.file.FileConfiguration;
import org.bukkit.configuration.file.YamlConfiguration;
import org.bukkit.entity.Player;
import org.bukkit.event.HandlerList;
import org.bukkit.generator.ChunkGenerator;
import org.bukkit.plugin.java.JavaPlugin;
import org.bukkit.scheduler.BukkitRunnable;
import java.io.*;
import java.net.URLDecoder;
import java.util.UUID;
import java.util.logging.Level;
import java.util.logging.Logger;
public class Denizen extends JavaPlugin {
public static Denizen instance;
public static Denizen getInstance() {
return instance;
}
public static boolean hasTickedOnce = false;
public static String versionTag = null;
private boolean startedSuccessful = false;
public static boolean supportsPaper = false;
public CommandManager commandManager;
public TriggerRegistry triggerRegistry;
public DenizenNPCHelper npcHelper;
public BukkitWorldScriptHelper worldScriptHelper;
public ItemScriptHelper itemScriptHelper;
public ExCommandHandler exCommand;
public DenizenCoreImplementation coreImplementation = new DenizenCoreImplementation();
/*
* Sets up Denizen on start of the CraftBukkit server.
*/
@Override
public void onEnable() {
instance = this;
try {
versionTag = this.getDescription().getVersion();
CoreUtilities.noDebugContext = new BukkitTagContext(null, null, null, false, null);
CoreUtilities.basicContext = new BukkitTagContext(null, null, null, true, null);
CoreUtilities.errorButNoDebugContext = new BukkitTagContext(null, null, null, false, null);
CoreUtilities.errorButNoDebugContext.showErrors = true;
// Load Denizen's core
DenizenCore.init(coreImplementation);
}
catch (Exception e) {
e.printStackTrace();
getServer().getPluginManager().disablePlugin(this);
startedSuccessful = false;
return;
}
PlayerFlagHandler.dataFolder = new File(getDataFolder(), "player_flags");
if (!PlayerFlagHandler.dataFolder.exists()) {
PlayerFlagHandler.dataFolder.mkdir();
}
String javaVersion = System.getProperty("java.version");
getLogger().info("Running on java version: " + javaVersion);
if (javaVersion.startsWith("8") || javaVersion.startsWith("1.8")) {
getLogger().info("Running on fully supported Java 8. Updating to Java 17+ is recommended.");
}
else if (javaVersion.startsWith("9") || javaVersion.startsWith("1.9") || javaVersion.startsWith("10") || javaVersion.startsWith("1.10")
|| javaVersion.startsWith("11")
|| javaVersion.startsWith("12") || javaVersion.startsWith("13") || javaVersion.startsWith("14") || javaVersion.startsWith("15")) {
getLogger().warning("Running unreliable Java version. Old Minecraft is built for Java 8, modern Minecraft is built for Java 17. Other Java versions are not guaranteed to function properly.");
}
else if (javaVersion.startsWith("16")) {
getLogger().info("Running on fully supported Java 16.");
}
else if (javaVersion.startsWith("17")) {
getLogger().info("Running on fully supported Java 17.");
}
else {
getLogger().info("Running on unrecognized (future?) Java version. May or may not work.");
}
if (!NMSHandler.initialize(this)) {
getLogger().warning("-------------------------------------");
getLogger().warning("This build of Denizen is not compatible with this Spigot version! Deactivating Denizen!");
getLogger().warning("-------------------------------------");
getServer().getPluginManager().disablePlugin(this);
startedSuccessful = false;
return;
}
if (!NMSHandler.instance.isCorrectMappingsCode()) {
getLogger().warning("-------------------------------------");
getLogger().warning("This build of Denizen was built for a different Spigot revision! This may potentially cause issues."
+ " If you are experiencing trouble, update Denizen and Spigot both to latest builds!"
+ " If this message appears with both Denizen and Spigot fully up-to-date, contact the Denizen team (via GitHub, Spigot, or Discord) to request an update be built.");
getLogger().warning("-------------------------------------");
}
BukkitCommandRegistry commandRegistry = new BukkitCommandRegistry();
triggerRegistry = new TriggerRegistry();
boolean citizensBork = false;
try {
// Activate dependencies
Depends.initialize();
if (Depends.citizens == null) {
if (Bukkit.getPluginManager().getPlugin("Citizens") != null) {
citizensBork = true;
getLogger().warning("Citizens is present but doesn't seem to be activated! You may have an error earlier in your logs, or you may have a broken plugin load order.");
}
else {
getLogger().warning("Citizens does not seem to be available! Denizen will have greatly reduced functionality!");
}
}
startedSuccessful = true;
}
catch (Exception e) {
Debug.echoError(e);
}
try {
// Populate config.yml if it doesn't yet exist.
saveDefaultConfig();
reloadConfig();
// Startup procedure
Debug.log(ChatColor.LIGHT_PURPLE + "+-------------------------+");
Debug.log(ChatColor.YELLOW + " _/_ _ ._ _ _ ");
Debug.log(ChatColor.YELLOW + "(/(-/ )/ /_(-/ ) " + ChatColor.GRAY + " scriptable minecraft");
Debug.log("");
Debug.log(ChatColor.GRAY + "by: " + ChatColor.WHITE + "The DenizenScript team");
Debug.log(ChatColor.GRAY + "Chat with us at: " + ChatColor.WHITE + " https://discord.gg/Q6pZGSR");
Debug.log(ChatColor.GRAY + "Or learn more at: " + ChatColor.WHITE + " https://denizenscript.com");
Debug.log(ChatColor.GRAY + "version: " + ChatColor.WHITE + versionTag);
Debug.log(ChatColor.LIGHT_PURPLE + "+-------------------------+");
}
catch (Exception e) {
Debug.echoError(e);
}
try {
if (Class.forName("com.destroystokyo.paper.PaperConfig") != null) {
supportsPaper = true;
}
}
catch (ClassNotFoundException ex) {
// Ignore.
}
catch (Throwable ex) {
Debug.echoError(ex);
}
// bstats.org
try {
BStatsMetricsLite metrics = new BStatsMetricsLite(this);
}
catch (Throwable e) {
Debug.echoError(e);
}
try {
// If Citizens is enabled, Create the NPC Helper
if (Depends.citizens != null) {
npcHelper = new DenizenNPCHelper();
}
// Create our CommandManager to handle '/denizen' commands
commandManager = new CommandManager();
commandManager.setInjector(new Injector(this));
commandManager.register(DenizenCommandHandler.class);
// If Citizens is enabled, let it handle '/npc' commands
if (Depends.citizens != null) {
Depends.citizens.registerCommandClass(NPCCommandHandler.class);
}
DenizenEntityType.registerEntityType("ITEM_PROJECTILE", ItemProjectile.class);
DenizenEntityType.registerEntityType("FAKE_ARROW", FakeArrow.class);
DenizenEntityType.registerEntityType("FAKE_PLAYER", FakePlayer.class);
// Track all player names for quick PlayerTag matching
for (OfflinePlayer player : Bukkit.getOfflinePlayers()) {
PlayerTag.notePlayer(player);
}
}
catch (Exception e) {
Debug.echoError(e);
}
try {
DenizenCore.commandRegistry = commandRegistry;
commandRegistry.registerCommands();
}
catch (Exception e) {
Debug.echoError(e);
}
try {
// Register script-container types
ScriptRegistry._registerCoreTypes();
}
catch (Exception e) {
Debug.echoError(e);
}
try {
ContainerRegistry.registerMainContainers();
}
catch (Exception e) {
Debug.echoError(e);
}
try {
// Ensure the Scripts and Midi folder exist
new File(getDataFolder() + "/scripts").mkdirs();
new File(getDataFolder() + "/midi").mkdirs();
new File(getDataFolder() + "/schematics").mkdirs();
// Ensure the example Denizen.mid sound file is available
if (!new File(getDataFolder() + "/midi/Denizen.mid").exists()) {
String sourceFile = URLDecoder.decode(Denizen.class.getProtectionDomain().getCodeSource().getLocation().getFile());
Debug.log("Denizen.mid not found, extracting from " + sourceFile);
Utilities.extractFile(new File(sourceFile), "Denizen.mid", getDataFolder() + "/midi/");
}
}
catch (Exception e) {
Debug.echoError(e);
}
try {
// Automatic config file update
InputStream properConfig = Denizen.class.getResourceAsStream("/config.yml");
String properConfigString = ScriptHelper.convertStreamToString(properConfig);
properConfig.close();
FileInputStream currentConfig = new FileInputStream(getDataFolder() + "/config.yml");
String currentConfigString = ScriptHelper.convertStreamToString(currentConfig);
currentConfig.close();
String updated = ConfigUpdater.updateConfig(currentConfigString, properConfigString);
if (updated != null) {
Debug.log("Your config file is outdated. Automatically updating it...");
FileOutputStream configOutput = new FileOutputStream(getDataFolder() + "/config.yml");
OutputStreamWriter writer = new OutputStreamWriter(configOutput);
writer.write(updated);
writer.close();
configOutput.close();
reloadConfig();
}
}
catch (Exception e) {
Debug.echoError(e);
}
try {
worldScriptHelper = new BukkitWorldScriptHelper();
itemScriptHelper = new ItemScriptHelper();
new InventoryScriptHelper();
new EntityScriptHelper();
new CommandScriptHelper();
}
catch (Exception e) {
Debug.echoError(e);
}
try {
if (Depends.citizens != null) {
// Register traits
TraitRegistry.registerMainTraits();
}
}
catch (Exception e) {
Debug.echoError(e);
}
// Register Core Members in the Denizen Registries
try {
if (Depends.citizens != null) {
triggerRegistry.registerCoreMembers();
}
}
catch (Exception e) {
Debug.echoError(e);
}
try {
AdjustCommand.specialAdjustables.put("server", ServerTagBase::adjustServer);
// Register all the modern script events
ScriptEventRegistry.registerMainEvents();
// Register Core ObjectTags with the ObjectFetcher
ObjectFetcher.registerCoreObjects();
CommonRegistries.registerMainObjects();
TagManager.registerCoreTags();
CommonRegistries.registerMainTagHandlers();
}
catch (Exception e) {
Debug.echoError(e);
}
try {
// Initialize all properties
PropertyRegistry.registerMainProperties();
}
catch (Exception e) {
Debug.echoError(e);
}
try {
new CommandEvents();
if (Settings.cache_packetInterceptAutoInit) {
NetworkInterceptHelper.enable();
}
}
catch (Exception e) {
Debug.echoError(e);
}
try {
if (supportsPaper) {
final Class<?> clazz = Class.forName("com.denizenscript.denizen.paper.PaperModule");
clazz.getMethod("init").invoke(null);
}
}
catch (ClassNotFoundException ex) {
supportsPaper = false;
}
catch (Throwable ex) {
supportsPaper = false;
Debug.echoError(ex);
}
Debug.log("Loaded <A>" + commandRegistry.instances.size() + "<W> core commands and <A>" + ObjectFetcher.objectsByPrefix.size() + "<W> core object types.");
exCommand = new ExCommandHandler();
exCommand.enableFor(getCommand("ex"));
ExSustainedCommandHandler exsCommand = new ExSustainedCommandHandler();
exsCommand.enableFor(getCommand("exs"));
// Load script files without processing.
DenizenCore.preloadScripts();
// Load the saves.yml into memory
reloadSaves();
try {
// Fire the 'on Server PreStart' world event
ServerPrestartScriptEvent.instance.specialHackRunEvent();
}
catch (Throwable ex) {
Debug.echoError(ex);
}
final boolean hadCitizensBork = citizensBork;
// Run everything else on the first server tick
Bukkit.getScheduler().scheduleSyncDelayedTask(this, () -> {
hasTickedOnce = true;
try {
if (hadCitizensBork) {
Depends.setupCitizens();
if (Depends.citizens != null) {
getLogger().warning("Citizens was activated late - this means a plugin load order error occurred. You may have plugins with invalid 'plugin.yml' files (eg that use the 'loadbefore' directive, or that have circular dependencies).");
npcHelper = new DenizenNPCHelper();
Depends.citizens.registerCommandClass(NPCCommandHandler.class);
TraitRegistry.registerMainTraits();
triggerRegistry.registerCoreMembers();
commandRegistry.registerCitizensCommands();
ScriptEventRegistry.registerCitizensEvents();
new NPCTagBase();
ObjectFetcher.registerWithObjectFetcher(NPCTag.class, NPCTag.tagProcessor);
}
}
}
catch (Throwable ex) {
Debug.echoError(ex);
}
try {
// Process script files (events, etc).
NoteManager.reload();
DenizenCore.postLoadScripts();
Debug.log(ChatColor.LIGHT_PURPLE + "+-------------------------+");
// Fire the 'on Server Start' world event
ServerStartScriptEvent.instance.fire();
worldScriptHelper.serverStartEvent();
if (Settings.allowStupidx()) {
Debug.echoError("Don't screw with bad config values.");
Bukkit.shutdown();
}
Bukkit.getScheduler().scheduleSyncRepeatingTask(Denizen.this, () -> {
Debug.onTick();
DenizenCore.tick(50); // Sadly, minecraft has no delta timing, so a tick is always 50ms.
}, 1, 1);
InventoryTag.setupInventoryTracker();
if (!CoreConfiguration.skipAllFlagCleanings && !Settings.skipChunkFlagCleaning) {
BukkitWorldScriptHelper.cleanAllWorldChunkFlags();
}
Bukkit.getPluginManager().registerEvents(new PlayerFlagHandler(), this);
Debug.log("Denizen fully loaded at: " + TimeTag.now().format());
}
catch (Throwable ex) {
Debug.echoError(ex);
}
}, 1);
new BukkitRunnable() {
@Override
public void run() {
if (Settings.canRecordStats()) {
StatsRecord.trigger();
}
}
}.runTaskTimer(this, 100, 20 * 60 * 60);
new BukkitRunnable() {
@Override
public void run() {
PlayerFlagHandler.cleanCache();
}
}.runTaskTimer(this, 100, 20 * 60);
new BukkitRunnable() {
@Override
public void run() {
if (!StrongWarning.recentWarnings.isEmpty()) {
StringBuilder warnText = new StringBuilder();
warnText.append(ChatColor.YELLOW).append("[Denizen] ").append(ChatColor.RED).append("Recent strong system warnings, scripters need to address ASAP (check earlier console logs for details):");
for (StrongWarning warning : StrongWarning.recentWarnings) {
warnText.append("\n- ").append(warning.message);
}
StrongWarning.recentWarnings.clear();
Bukkit.getConsoleSender().sendMessage(warnText.toString());
for (Player player : Bukkit.getOnlinePlayers()) {
if (player.isOp()) {
player.sendMessage(warnText.toString());
}
}
}
}
}.runTaskTimer(this, 100, 20 * 60 * 5);
}
public boolean hasDisabled = false;
/*
* Unloads Denizen on shutdown of the server.
*/
@Override
public void onDisable() {
if (!startedSuccessful) {
return;
}
if (hasDisabled) {
return;
}
hasDisabled = true;
DenizenCore.shutdown();
ScoreboardHelper._saveScoreboards();
InventoryScriptHelper._savePlayerInventories();
triggerRegistry.disableCoreMembers();
getLogger().log(Level.INFO, " v" + getDescription().getVersion() + " disabled.");
Bukkit.getServer().getScheduler().cancelTasks(this);
HandlerList.unregisterAll(this);
saveSaves(false);
worldFlags.shutdown();
}
@Override
public void reloadConfig() {
super.reloadConfig();
Settings.refillCache();
if (!CoreConfiguration.defaultDebugMode) {
getLogger().warning("Debug is disabled in the Denizen config. This is almost always a mistake, and should not be done in the majority of cases.");
}
}
private FileConfiguration scoreboardsConfig = null;
private File scoreboardsConfigFile = null;
public WorldFlagHandler worldFlags;
public void reloadSaves() {
if (scoreboardsConfigFile == null) {
scoreboardsConfigFile = new File(getDataFolder(), "scoreboards.yml");
}
scoreboardsConfig = YamlConfiguration.loadConfiguration(scoreboardsConfigFile);
// Reload scoreboards from scoreboards.yml
ScoreboardHelper._recallScoreboards();
// Load maps from maps.yml
DenizenMapManager.reloadMaps();
DenizenCore.reloadSaves();
if (worldFlags == null) {
worldFlags = new WorldFlagHandler();
}
worldFlags.shutdown();
worldFlags.init();
RunLaterCommand.init(new File(getDataFolder(), "run_later.yml").getPath());
if (new File(getDataFolder(), "saves.yml").exists()) {
LegacySavesUpdater.updateLegacySaves();
}
Bukkit.getServer().getPluginManager().callEvent(new SavesReloadEvent());
}
public FileConfiguration getScoreboards() {
if (scoreboardsConfig == null) {
reloadSaves();
}
return scoreboardsConfig;
}
/**
* Immediately saves all non-core save data.
* @param canSleep 'true' if the system should sleep and lock the thread until saves are complete. 'false' is saves can happen in the future.
*/
public void saveSaves(boolean canSleep) {
// Save scoreboards to scoreboards.yml
ScoreboardHelper._saveScoreboards();
// Save maps to maps.yml
DenizenMapManager.saveMaps();
// Save server flags
try {
scoreboardsConfig.save(scoreboardsConfigFile);
}
catch (IOException ex) {
Logger.getLogger(JavaPlugin.class.getName()).log(Level.SEVERE, "Could not save to " + scoreboardsConfigFile, ex);
}
PlayerFlagHandler.saveAllNow(canSleep);
worldFlags.saveAll();
RunLaterCommand.saveToFile(!canSleep);
}
@Override
public boolean onCommand(CommandSender sender, Command cmd, String alias, String[] args) {
if (cmd.getName().equals("denizenclickable")) {
if (args.length != 1 || !(sender instanceof Player)) {
return false;
}
UUID id;
try {
id = UUID.fromString(args[0]);
}
catch (IllegalArgumentException ex) {
return false;
}
ClickableCommand.runClickable(id, (Player) sender);
return true;
}
String modifier = args.length > 0 ? args[0] : "";
if (!commandManager.hasCommand(cmd, modifier) && !modifier.isEmpty()) {
return suggestClosestModifier(sender, cmd.getName(), modifier);
}
Object[] methodArgs = {sender};
return commandManager.executeSafe(cmd, args, sender, methodArgs);
}
private boolean suggestClosestModifier(CommandSender sender, String command, String modifier) {
String closest = commandManager.getClosestCommandModifier(command, modifier);
if (!closest.isEmpty()) {
Messaging.send(sender, "<7>Unknown command. Did you mean:");
Messaging.send(sender, " /" + command + " " + closest);
return true;
}
return false;
}
@Override
public ChunkGenerator getDefaultWorldGenerator(String worldName, String id) {
if (CoreUtilities.toLowerCase(id).equals("void")) {
if (NMSHandler.getVersion().isAtLeast(NMSVersion.v1_17)) {
return new VoidGenerator1_17();
}
return new VoidGenerator();
}
return null;
}
}