mirror of
https://github.com/xoo0524tw/OpenArcadeGames.git
synced 2026-12-06 02:46:01 +02:00
Deobfuscate remaining method and field names across common, latest, and legacy
This commit is contained in:
1 parent
fbed884ad9
commit
5f4da43c5b
538 files changed
+9039
-9039
No files matched your search
@@ -65,16 +65,16 @@ public abstract class ArcadeGames extends JavaPlugin {
|
||||
this.command = new DefaultCommand(this.engine, "Arcade", "arcade", new String[]{"arc"});
|
||||
this.registerCommands();
|
||||
VersionAdapters.get().registerCommand(this, serverPlatform, this.command, this.engine.getSettings().isUseBrigadierCommands());
|
||||
this.engine.getGameManagerRegistry().a(new BlockPartyManager(this.engine));
|
||||
this.engine.getGameManagerRegistry().a(new BombLobbersManager(this.engine));
|
||||
this.engine.getGameManagerRegistry().a(new MiniWallsManager(this.engine));
|
||||
this.engine.getGameManagerRegistry().a(new PartyGamesManager(this.engine));
|
||||
this.engine.getGameManagerRegistry().a(new PropHuntManager(this.engine));
|
||||
this.engine.getGameManagerRegistry().a(new QuakeManager(this.engine));
|
||||
this.engine.getGameManagerRegistry().a(new SpleggManager(this.engine));
|
||||
this.engine.getGameManagerRegistry().a(new TempleRunManager(this.engine));
|
||||
this.engine.getGameManagerRegistry().a(new TNTTagManager(this.engine));
|
||||
this.engine.getGameManagerRegistry().a(new TNTRunManager(this.engine));
|
||||
this.engine.getGameManagerRegistry().register(new BlockPartyManager(this.engine));
|
||||
this.engine.getGameManagerRegistry().register(new BombLobbersManager(this.engine));
|
||||
this.engine.getGameManagerRegistry().register(new MiniWallsManager(this.engine));
|
||||
this.engine.getGameManagerRegistry().register(new PartyGamesManager(this.engine));
|
||||
this.engine.getGameManagerRegistry().register(new PropHuntManager(this.engine));
|
||||
this.engine.getGameManagerRegistry().register(new QuakeManager(this.engine));
|
||||
this.engine.getGameManagerRegistry().register(new SpleggManager(this.engine));
|
||||
this.engine.getGameManagerRegistry().register(new TempleRunManager(this.engine));
|
||||
this.engine.getGameManagerRegistry().register(new TNTTagManager(this.engine));
|
||||
this.engine.getGameManagerRegistry().register(new TNTRunManager(this.engine));
|
||||
this.engine.start();
|
||||
this.registerMetricsCharts(this.engine);
|
||||
basicLogger.sendInfo(this.getName() + " has been loaded!");
|
||||
@@ -137,7 +137,7 @@ public abstract class ArcadeGames extends JavaPlugin {
|
||||
int count = 0;
|
||||
|
||||
for (AbstractGameManager abstractGameManager : defaultEngine.getGameManagerRegistry()) {
|
||||
count += abstractGameManager.getSessions().i();
|
||||
count += abstractGameManager.getSessions().getTotalPlayers();
|
||||
}
|
||||
|
||||
return count;
|
||||
@@ -146,7 +146,7 @@ public abstract class ArcadeGames extends JavaPlugin {
|
||||
HashMap<String, Integer> map = new HashMap<>();
|
||||
|
||||
for (AbstractGameManager abstractGameManager : defaultEngine.getGameManagerRegistry()) {
|
||||
map.put(abstractGameManager.getName(), abstractGameManager.getSessions().d().size());
|
||||
map.put(abstractGameManager.getName(), abstractGameManager.getSessions().getGames().size());
|
||||
}
|
||||
|
||||
return map;
|
||||
@@ -155,7 +155,7 @@ public abstract class ArcadeGames extends JavaPlugin {
|
||||
HashMap<String, Integer> map = new HashMap<>();
|
||||
|
||||
for (AbstractGameManager abstractGameManager : defaultEngine.getGameManagerRegistry()) {
|
||||
map.put(abstractGameManager.getName(), abstractGameManager.getSessions().i());
|
||||
map.put(abstractGameManager.getName(), abstractGameManager.getSessions().getTotalPlayers());
|
||||
}
|
||||
|
||||
return map;
|
||||
|
||||
@@ -37,7 +37,7 @@ public class DefaultAddonManager implements AddonManager {
|
||||
|
||||
public void start() {
|
||||
this.engine.getLogger().sendInfo(" - Loading addons...");
|
||||
this.a(this.file);
|
||||
this.loadAddonsFromDirectory(this.file);
|
||||
this.githubAddonRepository.refresh(Bukkit.getConsoleSender());
|
||||
}
|
||||
|
||||
@@ -46,7 +46,7 @@ public class DefaultAddonManager implements AddonManager {
|
||||
|
||||
for (Addon addon : this.map.values()) {
|
||||
addon.onUnload();
|
||||
this.b(addon);
|
||||
this.closeAddonClassLoader(addon);
|
||||
}
|
||||
|
||||
this.map.clear();
|
||||
@@ -72,19 +72,19 @@ public class DefaultAddonManager implements AddonManager {
|
||||
return this.map.get(text);
|
||||
}
|
||||
|
||||
private void a(JarFile jarFile, URLClassLoader uRLClassLoader, File file2) throws IOException {
|
||||
private void loadAddonFromJar(JarFile jarFile, URLClassLoader uRLClassLoader, File file2) throws IOException {
|
||||
JarEntry jarEntry = jarFile.getJarEntry("addon.txt");
|
||||
if (jarEntry == null) {
|
||||
this.engine.getLogger().sendError("The addon must contain the addon.txt file!");
|
||||
} else {
|
||||
this.a(jarFile.getInputStream(jarEntry), uRLClassLoader, file2);
|
||||
this.loadAddonFromStream(jarFile.getInputStream(jarEntry), uRLClassLoader, file2);
|
||||
}
|
||||
}
|
||||
|
||||
private void a(InputStream inputStream, ClassLoader classLoader, File file2) {
|
||||
private void loadAddonFromStream(InputStream inputStream, ClassLoader classLoader, File file2) {
|
||||
try {
|
||||
String text = new String(inputStream.readAllBytes());
|
||||
this.a((Addon)Class.forName(text, true, classLoader).getConstructor().newInstance(), file2);
|
||||
this.loadAddon((Addon)Class.forName(text, true, classLoader).getConstructor().newInstance(), file2);
|
||||
} catch (ClassNotFoundException | IOException ex) {
|
||||
this.engine.getLogger().sendError("Could not find path '" + ex.getMessage() + "'");
|
||||
} catch (ReflectiveOperationException ex2) {
|
||||
@@ -100,13 +100,13 @@ public class DefaultAddonManager implements AddonManager {
|
||||
|
||||
try (JarFile var2 = new JarFile(file2)) {
|
||||
URL[] uRLs = new URL[]{file2.toURI().toURL()};
|
||||
this.a(var2, URLClassLoader.newInstance(uRLs, this.getClass().getClassLoader()), file2);
|
||||
this.loadAddonFromJar(var2, URLClassLoader.newInstance(uRLs, this.getClass().getClassLoader()), file2);
|
||||
} catch (Exception ex) {
|
||||
this.engine.getPlugin().getLogger().log(Level.SEVERE, "The addon couldn't be loaded", ex);
|
||||
}
|
||||
}
|
||||
|
||||
public void a(Addon addon, File file2) {
|
||||
public void loadAddon(Addon addon, File file2) {
|
||||
AddonDescription addonDescription = new AddonDescription(addon);
|
||||
File file3 = new File(this.file, addonDescription.getId());
|
||||
addon.initialize(this.engine, addonDescription, file3, file2);
|
||||
@@ -115,24 +115,24 @@ public class DefaultAddonManager implements AddonManager {
|
||||
}
|
||||
|
||||
public void loadAddon(Addon addon) {
|
||||
this.a(addon, null);
|
||||
this.loadAddon(addon, null);
|
||||
}
|
||||
|
||||
public void a(Addon addon) {
|
||||
public void unloadAddon(Addon addon) {
|
||||
this.map.remove(addon.getDescription().getId());
|
||||
addon.onUnload();
|
||||
this.b(addon);
|
||||
this.closeAddonClassLoader(addon);
|
||||
}
|
||||
|
||||
public void a(String text) {
|
||||
public void unloadAddon(String text) {
|
||||
Addon addon = this.map.remove(text);
|
||||
if (addon != null) {
|
||||
addon.onUnload();
|
||||
this.b(addon);
|
||||
this.closeAddonClassLoader(addon);
|
||||
}
|
||||
}
|
||||
|
||||
private void b(Addon addon) {
|
||||
private void closeAddonClassLoader(Addon addon) {
|
||||
if (addon.getFile() != null) {
|
||||
try {
|
||||
((URLClassLoader)addon.getClass().getClassLoader()).close();
|
||||
@@ -142,8 +142,8 @@ public class DefaultAddonManager implements AddonManager {
|
||||
}
|
||||
}
|
||||
|
||||
public void a(File file2) {
|
||||
Files.a(file2, file3 -> {
|
||||
public void loadAddonsFromDirectory(File file2) {
|
||||
Files.forEachChild(file2, file3 -> {
|
||||
if (file3.isFile() && file3.getName().endsWith(".jar")) {
|
||||
this.loadAddon(file3);
|
||||
}
|
||||
|
||||
+1
-1
@@ -16,6 +16,6 @@ public class AddonRepositoryAllCommand extends AddonRepositoryListCommand {
|
||||
}
|
||||
|
||||
public void execute(CommandSender sender, String text, String[] texts, int index) {
|
||||
this.a(sender, this.manager.getAddonRepository().getAddonRepository().values(), 1);
|
||||
this.sendPage(sender, this.manager.getAddonRepository().getAddonRepository().values(), 1);
|
||||
}
|
||||
}
|
||||
+1
-1
@@ -18,7 +18,7 @@ public abstract class AddonRepositoryListCommand implements CommandExecutor {
|
||||
return sender.hasPermission(this.manager.getEngine().getPlugin().getName() + ".admin");
|
||||
}
|
||||
|
||||
protected void a(CommandSender sender, Collection<AddonRepositoryEntry> collection, int index) {
|
||||
protected void sendPage(CommandSender sender, Collection<AddonRepositoryEntry> collection, int index) {
|
||||
int index2 = (index - 1) * 7;
|
||||
if (index >= 1 && index2 <= collection.size()) {
|
||||
sender.sendMessage("§8[§cAddon Repository§8] §7- §dList.");
|
||||
|
||||
+1
-1
@@ -22,7 +22,7 @@ public class AddonRepositoryPageCommand extends AddonRepositoryListCommand {
|
||||
public void execute(CommandSender sender, String text, String[] texts, int index) {
|
||||
try {
|
||||
int index2 = Integer.parseInt(texts[index]);
|
||||
this.a(sender, this.manager.getAddonRepository().getAddonRepository().values(), index2);
|
||||
this.sendPage(sender, this.manager.getAddonRepository().getAddonRepository().values(), index2);
|
||||
} catch (NumberFormatException ex) {
|
||||
sender.sendMessage("§cThe page must be a number!");
|
||||
}
|
||||
|
||||
+1
-1
@@ -20,7 +20,7 @@ public class ListAddonsCommand extends BaseCommandExecutor {
|
||||
|
||||
public void execute(CommandSender sender, String text, String[] texts, int index) {
|
||||
List<ro.fr33styler.arcade.api.engine.addon.Addon> list = this.manager.getAddons();
|
||||
String text2 = Strings.a(", ", list, addon -> addon.getDescription().getId());
|
||||
String text2 = Strings.join(", ", list, addon -> addon.getDescription().getId());
|
||||
sender.sendMessage("§aAddons(§f" + list.size() + "§a): §f" + text2);
|
||||
}
|
||||
}
|
||||
+1
-1
@@ -38,7 +38,7 @@ public class ManageAddonCommand implements CommandExecutor {
|
||||
if (addon == null) {
|
||||
sender.sendMessage("§cThere is no addon with such name!");
|
||||
} else {
|
||||
this.manager.a(addon);
|
||||
this.manager.unloadAddon(addon);
|
||||
File file = addon.getFile();
|
||||
if (file != null) {
|
||||
file.delete();
|
||||
|
||||
+7
-7
@@ -36,7 +36,7 @@ public class GithubAddonRepository implements AddonRepository, Configuration {
|
||||
public void refresh(CommandSender sender) {
|
||||
DefaultEngine defaultEngine = this.manager.getEngine();
|
||||
String text = "/Fr33styler/AddonsRepository/main/" + defaultEngine.getPlugin().getName() + "/addons.yml";
|
||||
InputStream inputStream = EngineUtils.a("https", "raw.githubusercontent.com", text, 5000);
|
||||
InputStream inputStream = EngineUtils.openStream("https", "raw.githubusercontent.com", text, 5000);
|
||||
if (inputStream != null) {
|
||||
InputStreamReader inputStreamReader = new InputStreamReader(inputStream);
|
||||
|
||||
@@ -62,23 +62,23 @@ public class GithubAddonRepository implements AddonRepository, Configuration {
|
||||
if (addonRepositoryEntry == null) {
|
||||
sender.sendMessage("§cThere is no addon with such name!");
|
||||
} else {
|
||||
this.a(sender, defaultEngine.getPlugin().getName(), addonRepositoryEntry.getName());
|
||||
this.downloadAddon(sender, defaultEngine.getPlugin().getName(), addonRepositoryEntry.getName());
|
||||
}
|
||||
}
|
||||
|
||||
private void a(CommandSender sender, String text, String text2) {
|
||||
private void downloadAddon(CommandSender sender, String text, String text2) {
|
||||
String text3 = "/Fr33styler/AddonsRepository/main/" + text + "/" + text2 + ".jar";
|
||||
InputStream inputStream = EngineUtils.a("https", "raw.githubusercontent.com", text3, 60000);
|
||||
InputStream inputStream = EngineUtils.openStream("https", "raw.githubusercontent.com", text3, 60000);
|
||||
if (inputStream == null) {
|
||||
sender.sendMessage("§cThe addon failed to download.");
|
||||
} else {
|
||||
this.a(sender, inputStream, text2);
|
||||
this.installAddon(sender, inputStream, text2);
|
||||
}
|
||||
}
|
||||
|
||||
private void a(CommandSender sender, InputStream inputStream, String text) {
|
||||
private void installAddon(CommandSender sender, InputStream inputStream, String text) {
|
||||
try {
|
||||
this.manager.a(text);
|
||||
this.manager.unloadAddon(text);
|
||||
File file = new File(this.manager.getEngine().getAddonManager().getAddonsDirectory(), text + ".jar");
|
||||
Files.copy(inputStream, file.toPath(), StandardCopyOption.REPLACE_EXISTING);
|
||||
this.manager.loadAddon(file);
|
||||
|
||||
@@ -10,7 +10,7 @@ import ro.fr33styler.arcade.api.engine.command.CommandExecutor;
|
||||
import ro.fr33styler.arcade.api.engine.util.Path;
|
||||
|
||||
public class CommandNode {
|
||||
private final String a;
|
||||
private final String name;
|
||||
private final Path path;
|
||||
private final Map<String, CommandNode> map = new TreeMap<>();
|
||||
private final CommandRegistry commandRegistry = new CommandRegistry();
|
||||
@@ -20,12 +20,12 @@ public class CommandNode {
|
||||
}
|
||||
|
||||
CommandNode(String text, Path path2) {
|
||||
this.a = text;
|
||||
this.name = text;
|
||||
this.path = path2;
|
||||
}
|
||||
|
||||
public String a() {
|
||||
return this.a;
|
||||
public String getName() {
|
||||
return this.name;
|
||||
}
|
||||
|
||||
public Path getPath() {
|
||||
@@ -36,47 +36,47 @@ public class CommandNode {
|
||||
return this.commandRegistry;
|
||||
}
|
||||
|
||||
public void a(Collection<CommandNode> collection) {
|
||||
public void collectChildren(Collection<CommandNode> collection) {
|
||||
collection.addAll(this.map.values());
|
||||
}
|
||||
|
||||
public void a(Path path2, Path path3, CommandExecutor commandExecutor) {
|
||||
public void registerExecutor(Path path2, Path path3, CommandExecutor commandExecutor) {
|
||||
if (path3 == null) {
|
||||
this.commandRegistry.a(commandExecutor);
|
||||
this.commandRegistry.register(commandExecutor);
|
||||
} else {
|
||||
CommandNode commandNode = this.map.computeIfAbsent(path3.getNode(), text -> new CommandNode(text, path2));
|
||||
commandNode.a(path2, path3.getChild(), commandExecutor);
|
||||
commandNode.registerExecutor(path2, path3.getChild(), commandExecutor);
|
||||
}
|
||||
}
|
||||
|
||||
public boolean a(CommandSender sender, String text, String[] texts, int index) {
|
||||
public boolean execute(CommandSender sender, String text, String[] texts, int index) {
|
||||
if (texts.length >= index) {
|
||||
CommandNode commandNode = null;
|
||||
if (texts.length > index) {
|
||||
commandNode = this.map.get(texts[index]);
|
||||
}
|
||||
|
||||
return commandNode == null ? this.commandRegistry.a(sender, text, texts, index) : commandNode.a(sender, text, texts, index + 1);
|
||||
return commandNode == null ? this.commandRegistry.execute(sender, text, texts, index) : commandNode.execute(sender, text, texts, index + 1);
|
||||
} else {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
public void a(CommandSender sender, List<String> list, String[] texts, int index) {
|
||||
public void collectSuggestions(CommandSender sender, List<String> list, String[] texts, int index) {
|
||||
if (texts.length > index) {
|
||||
CommandNode commandNode = this.map.get(texts[index]);
|
||||
if (commandNode == null) {
|
||||
this.b(sender, list, texts, index);
|
||||
this.commandRegistry.a(sender, list, texts, index);
|
||||
this.collectChildSuggestions(sender, list, texts, index);
|
||||
this.commandRegistry.collectSuggestions(sender, list, texts, index);
|
||||
} else {
|
||||
commandNode.a(sender, list, texts, index + 1);
|
||||
commandNode.collectSuggestions(sender, list, texts, index + 1);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private boolean a(CommandSender sender) {
|
||||
private boolean isAccessibleTo(CommandSender sender) {
|
||||
for (CommandNode commandNode : this.map.values()) {
|
||||
if (commandNode.a(sender)) {
|
||||
if (commandNode.isAccessibleTo(sender)) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
@@ -90,11 +90,11 @@ public class CommandNode {
|
||||
return false;
|
||||
}
|
||||
|
||||
private void b(CommandSender sender, List<String> list, String[] texts, int index) {
|
||||
private void collectChildSuggestions(CommandSender sender, List<String> list, String[] texts, int index) {
|
||||
if (index == texts.length - 1) {
|
||||
for (CommandNode commandNode : this.map.values()) {
|
||||
if (commandNode.a(sender) && commandNode.a().startsWith(texts[index])) {
|
||||
list.add(commandNode.a());
|
||||
if (commandNode.isAccessibleTo(sender) && commandNode.getName().startsWith(texts[index])) {
|
||||
list.add(commandNode.getName());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -16,15 +16,15 @@ public class CommandRegistry implements Iterable<CommandExecutor> {
|
||||
CommandRegistry() {
|
||||
}
|
||||
|
||||
public void a(CommandExecutor commandExecutor) {
|
||||
public void register(CommandExecutor commandExecutor) {
|
||||
this.queue.removeIf(commandExecutor2 -> commandExecutor2.getArguments().isConflicting(commandExecutor.getArguments()));
|
||||
this.queue.add(commandExecutor);
|
||||
}
|
||||
|
||||
public boolean a(CommandSender sender, String text, String[] texts, int index) {
|
||||
public boolean execute(CommandSender sender, String text, String[] texts, int index) {
|
||||
for (CommandExecutor commandExecutor : this.queue) {
|
||||
if (commandExecutor.getArguments().isMatching(texts, index)) {
|
||||
this.a(sender, commandExecutor, text, texts, index);
|
||||
this.dispatch(sender, commandExecutor, text, texts, index);
|
||||
return true;
|
||||
}
|
||||
}
|
||||
@@ -32,7 +32,7 @@ public class CommandRegistry implements Iterable<CommandExecutor> {
|
||||
return false;
|
||||
}
|
||||
|
||||
private static void a(CommandExecutor commandExecutor, String[] texts, int index) {
|
||||
private static void normalizeArguments(CommandExecutor commandExecutor, String[] texts, int index) {
|
||||
for (int index2 = 0; index2 < commandExecutor.getArguments().size(); index2++) {
|
||||
for (String text : commandExecutor.getArguments().get(index2).getSuggestions()) {
|
||||
if (text.equalsIgnoreCase(texts[index + index2])) {
|
||||
@@ -43,18 +43,18 @@ public class CommandRegistry implements Iterable<CommandExecutor> {
|
||||
}
|
||||
}
|
||||
|
||||
private void a(CommandSender sender, CommandExecutor commandExecutor, String text, String[] texts, int index) {
|
||||
private void dispatch(CommandSender sender, CommandExecutor commandExecutor, String text, String[] texts, int index) {
|
||||
if (commandExecutor.isPlayerOnly() && !(sender instanceof Player)) {
|
||||
sender.sendMessage("§cOnly players can execute this!");
|
||||
} else if (!commandExecutor.hasPermission(sender)) {
|
||||
sender.sendMessage("§cYou're not allowed to use this command!");
|
||||
} else {
|
||||
a(commandExecutor, texts, index);
|
||||
normalizeArguments(commandExecutor, texts, index);
|
||||
commandExecutor.execute(sender, text, texts, index);
|
||||
}
|
||||
}
|
||||
|
||||
public void a(CommandSender sender, List<String> list, String[] texts, int index) {
|
||||
public void collectSuggestions(CommandSender sender, List<String> list, String[] texts, int index) {
|
||||
int index2 = texts.length - 1;
|
||||
|
||||
for (CommandExecutor commandExecutor : this.queue) {
|
||||
|
||||
@@ -14,50 +14,50 @@ import ro.fr33styler.arcade.api.engine.command.CommandExecutor;
|
||||
import ro.fr33styler.arcade.api.engine.util.Path;
|
||||
|
||||
public class DefaultCommand implements Command {
|
||||
private final String a;
|
||||
private final String b;
|
||||
private final String command;
|
||||
private final String displayName;
|
||||
private final List<String> list;
|
||||
private final CommandNode commandNode;
|
||||
|
||||
public DefaultCommand(DefaultEngine defaultEngine, String text, String text2, String... texts) {
|
||||
this.a = text2;
|
||||
this.b = text;
|
||||
this.command = text2;
|
||||
this.displayName = text;
|
||||
this.list = List.of(texts);
|
||||
this.commandNode = new CommandNode(text);
|
||||
this.a(defaultEngine.getSettings());
|
||||
this.registerDefaultExecutors(defaultEngine.getSettings());
|
||||
}
|
||||
|
||||
public String getDisplayName() {
|
||||
return this.b;
|
||||
return this.displayName;
|
||||
}
|
||||
|
||||
public String getCommand() {
|
||||
return this.a;
|
||||
return this.command;
|
||||
}
|
||||
|
||||
public List<String> getAliases() {
|
||||
return this.list;
|
||||
}
|
||||
|
||||
private void a(EngineSettings engineSettings) {
|
||||
this.putExecutor(new RootCommand(this.b, engineSettings));
|
||||
private void registerDefaultExecutors(EngineSettings engineSettings) {
|
||||
this.putExecutor(new RootCommand(this.displayName, engineSettings));
|
||||
this.putExecutor(Path.of("help"), new HelpListCommand(this.commandNode));
|
||||
this.putExecutor(Path.of("help"), new HelpPageCommand(this.commandNode));
|
||||
}
|
||||
|
||||
public void putExecutor(Path path, CommandExecutor commandExecutor) {
|
||||
this.commandNode.a(path, path, commandExecutor);
|
||||
this.commandNode.registerExecutor(path, path, commandExecutor);
|
||||
}
|
||||
|
||||
public List<String> onSuggestion(CommandSender sender, String[] texts) {
|
||||
ArrayList list2 = new ArrayList();
|
||||
this.commandNode.a(sender, list2, texts, 0);
|
||||
this.commandNode.collectSuggestions(sender, list2, texts, 0);
|
||||
Collections.sort(list2);
|
||||
return list2;
|
||||
}
|
||||
|
||||
public void onExecute(CommandSender sender, String text, String[] texts) {
|
||||
if (!this.commandNode.a(sender, text, texts, 0)) {
|
||||
if (!this.commandNode.execute(sender, text, texts, 0)) {
|
||||
sender.sendMessage("§cInvalid command. Please use §e/" + text + " help§c for the available commands!");
|
||||
}
|
||||
}
|
||||
|
||||
@@ -5,19 +5,19 @@ import ro.fr33styler.arcade.engine.config.EngineSettings;
|
||||
import org.bukkit.command.CommandSender;
|
||||
|
||||
public class RootCommand extends BaseCommandExecutor {
|
||||
private final String b;
|
||||
private final String displayName;
|
||||
private final EngineSettings settings;
|
||||
|
||||
public RootCommand(String text, EngineSettings settings2) {
|
||||
this.b = text;
|
||||
this.displayName = text;
|
||||
this.settings = settings2;
|
||||
}
|
||||
|
||||
public void execute(CommandSender sender, String text, String[] texts, int index) {
|
||||
if (!this.settings.isHideCredits()) {
|
||||
sender.sendMessage("§8[§3" + this.b + "§8] §ePlugin made by §aFr33styler§e.");
|
||||
sender.sendMessage("§8[§3" + this.displayName + "§8] §ePlugin made by §aFr33styler§e.");
|
||||
}
|
||||
|
||||
sender.sendMessage("§8[§3" + this.b + "§8] §eType §c/" + text + " help§e for help.");
|
||||
sender.sendMessage("§8[§3" + this.displayName + "§8] §eType §c/" + text + " help§e for help.");
|
||||
}
|
||||
}
|
||||
@@ -24,7 +24,7 @@ public class SetLobbyCommand extends BaseCommandExecutor {
|
||||
public void execute(CommandSender sender, String text, String[] texts, int index) {
|
||||
Player player = (Player)sender;
|
||||
this.engine.getDatabaseManager().setLobby(player.getLocation());
|
||||
this.engine.getDatabaseManager().f();
|
||||
this.engine.getDatabaseManager().saveConfig();
|
||||
player.sendMessage("§aThe lobby has been set!");
|
||||
}
|
||||
}
|
||||
+10
-10
@@ -5,19 +5,19 @@ import ro.fr33styler.arcade.support.text.Strings;
|
||||
import java.util.Collection;
|
||||
|
||||
public class ArrayArgument extends StringArgument {
|
||||
public final String[] a;
|
||||
private final String b;
|
||||
public final String[] options;
|
||||
private final String fallbackSuggestion;
|
||||
|
||||
public ArrayArgument(String text, String text2, String... texts) {
|
||||
super(text);
|
||||
this.b = text2;
|
||||
this.a = (String[])texts.clone();
|
||||
this.fallbackSuggestion = text2;
|
||||
this.options = (String[])texts.clone();
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isMatching(String text) {
|
||||
if (this.b == null) {
|
||||
for (String text2 : this.a) {
|
||||
if (this.fallbackSuggestion == null) {
|
||||
for (String text2 : this.options) {
|
||||
if (text2.equalsIgnoreCase(text)) {
|
||||
return true;
|
||||
}
|
||||
@@ -31,14 +31,14 @@ public class ArrayArgument extends StringArgument {
|
||||
|
||||
@Override
|
||||
public void getSuggestions(String text, Collection<String> collection) {
|
||||
for (String text2 : this.a) {
|
||||
if (Strings.a(text2, text, true)) {
|
||||
for (String text2 : this.options) {
|
||||
if (Strings.startsWith(text2, text, true)) {
|
||||
collection.add(text2);
|
||||
}
|
||||
}
|
||||
|
||||
if (this.b != null) {
|
||||
collection.add(this.b);
|
||||
if (this.fallbackSuggestion != null) {
|
||||
collection.add(this.fallbackSuggestion);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -4,17 +4,17 @@ import java.util.Collection;
|
||||
import ro.fr33styler.arcade.api.engine.command.argument.Argument;
|
||||
|
||||
public abstract class BaseArgument implements Argument {
|
||||
private final String a;
|
||||
private final String name;
|
||||
|
||||
public BaseArgument(String text) {
|
||||
this.a = text;
|
||||
this.name = text;
|
||||
}
|
||||
|
||||
public String getName() {
|
||||
return this.a;
|
||||
return this.name;
|
||||
}
|
||||
|
||||
public void getSuggestions(String text, Collection<String> collection) {
|
||||
collection.add("<" + this.a + ">");
|
||||
collection.add("<" + this.name + ">");
|
||||
}
|
||||
}
|
||||
+10
-10
@@ -5,19 +5,19 @@ import ro.fr33styler.arcade.support.text.Strings;
|
||||
import java.util.Collection;
|
||||
|
||||
public class CollectionArgument extends StringArgument {
|
||||
private final Collection<String> a;
|
||||
private final String b;
|
||||
private final Collection<String> options;
|
||||
private final String fallbackSuggestion;
|
||||
|
||||
public CollectionArgument(String text, String text2, Collection<String> collection) {
|
||||
super(text);
|
||||
this.b = text2;
|
||||
this.a = collection;
|
||||
this.fallbackSuggestion = text2;
|
||||
this.options = collection;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isMatching(String text) {
|
||||
if (this.b == null) {
|
||||
for (String text2 : this.a) {
|
||||
if (this.fallbackSuggestion == null) {
|
||||
for (String text2 : this.options) {
|
||||
if (text2.equalsIgnoreCase(text)) {
|
||||
return true;
|
||||
}
|
||||
@@ -31,14 +31,14 @@ public class CollectionArgument extends StringArgument {
|
||||
|
||||
@Override
|
||||
public void getSuggestions(String text, Collection<String> collection) {
|
||||
for (String text2 : this.a) {
|
||||
if (Strings.a(text2, text, true)) {
|
||||
for (String text2 : this.options) {
|
||||
if (Strings.startsWith(text2, text, true)) {
|
||||
collection.add(text2);
|
||||
}
|
||||
}
|
||||
|
||||
if (this.b != null) {
|
||||
collection.add(this.b);
|
||||
if (this.fallbackSuggestion != null) {
|
||||
collection.add(this.fallbackSuggestion);
|
||||
}
|
||||
}
|
||||
}
|
||||
+1
-1
@@ -14,7 +14,7 @@ public class PlayerArgument extends StringArgument {
|
||||
@Override
|
||||
public void getSuggestions(String text, Collection<String> collection) {
|
||||
for (Player player : Bukkit.getOnlinePlayers()) {
|
||||
if (Strings.a(player.getName(), text, true)) {
|
||||
if (Strings.startsWith(player.getName(), text, true)) {
|
||||
collection.add(player.getName());
|
||||
}
|
||||
}
|
||||
|
||||
+5
-5
@@ -7,17 +7,17 @@ import java.util.concurrent.atomic.AtomicBoolean;
|
||||
import java.util.function.Consumer;
|
||||
|
||||
public class SuggestedArgument extends StringArgument {
|
||||
private final Consumer<Consumer<String>> a;
|
||||
private final Consumer<Consumer<String>> suggestionProvider;
|
||||
|
||||
public SuggestedArgument(String text, Consumer<Consumer<String>> consumer) {
|
||||
super(text);
|
||||
this.a = consumer;
|
||||
this.suggestionProvider = consumer;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isMatching(String text) {
|
||||
AtomicBoolean atomicBoolean = new AtomicBoolean();
|
||||
this.a.accept(text2 -> {
|
||||
this.suggestionProvider.accept(text2 -> {
|
||||
if (text2.equalsIgnoreCase(text)) {
|
||||
atomicBoolean.set(true);
|
||||
}
|
||||
@@ -27,8 +27,8 @@ public class SuggestedArgument extends StringArgument {
|
||||
|
||||
@Override
|
||||
public void getSuggestions(String text, Collection<String> collection) {
|
||||
this.a.accept(text2 -> {
|
||||
if (Strings.a(text2, text, true)) {
|
||||
this.suggestionProvider.accept(text2 -> {
|
||||
if (Strings.startsWith(text2, text, true)) {
|
||||
collection.add(text2);
|
||||
}
|
||||
});
|
||||
|
||||
@@ -10,19 +10,19 @@ import ro.fr33styler.arcade.api.engine.command.CommandExecutor;
|
||||
import ro.fr33styler.arcade.api.engine.command.argument.ArgumentSet;
|
||||
|
||||
public abstract class HelpCommand implements CommandExecutor {
|
||||
protected void a(CommandSender sender, CommandNode commandNode, String text, int index) {
|
||||
List list = this.a(sender, commandNode, text);
|
||||
protected void sendHelpPage(CommandSender sender, CommandNode commandNode, String text, int index) {
|
||||
List list = this.collectAllUsages(sender, commandNode, text);
|
||||
int index2 = (index - 1) * 8;
|
||||
if (index >= 1 && index2 <= list.size()) {
|
||||
sender.sendMessage("§8[§3" + commandNode.a() + "§8] §7- §dHelp.");
|
||||
this.a(list, sender, index2);
|
||||
this.a(list, sender, index, text);
|
||||
sender.sendMessage("§8[§3" + commandNode.getName() + "§8] §7- §dHelp.");
|
||||
this.sendEntriesPage(list, sender, index2);
|
||||
this.sendPageFooter(list, sender, index, text);
|
||||
} else {
|
||||
sender.sendMessage("§cThe page doesn't exists!");
|
||||
}
|
||||
}
|
||||
|
||||
private void a(List<String> list, CommandSender sender, int index) {
|
||||
private void sendEntriesPage(List<String> list, CommandSender sender, int index) {
|
||||
int index2 = Math.min(index + 8, list.size());
|
||||
|
||||
for (int index3 = index; index3 < index2; index3++) {
|
||||
@@ -30,38 +30,38 @@ public abstract class HelpCommand implements CommandExecutor {
|
||||
}
|
||||
}
|
||||
|
||||
private void a(List<String> list, CommandSender sender, int index, String text) {
|
||||
private void sendPageFooter(List<String> list, CommandSender sender, int index, String text) {
|
||||
int index2 = Math.max(1, (list.size() + 8 - 1) / 8);
|
||||
if (index2 > 1) {
|
||||
sender.sendMessage("§3Page " + index + " out of " + index2 + ". Use §7/§c" + text + " help §8<§bpage§8>§3 to change pages!");
|
||||
}
|
||||
}
|
||||
|
||||
private List<String> a(CommandSender sender, CommandNode commandNode, String text) {
|
||||
private List<String> collectAllUsages(CommandSender sender, CommandNode commandNode, String text) {
|
||||
ArrayList list = new ArrayList();
|
||||
ArrayDeque arrayDeque = new ArrayDeque();
|
||||
commandNode.a(arrayDeque);
|
||||
commandNode.collectChildren(arrayDeque);
|
||||
|
||||
while (!arrayDeque.isEmpty()) {
|
||||
CommandNode commandNode2 = (CommandNode)arrayDeque.pop();
|
||||
this.a(list, sender, commandNode2, text);
|
||||
commandNode2.a(arrayDeque);
|
||||
this.collectNodeUsages(list, sender, commandNode2, text);
|
||||
commandNode2.collectChildren(arrayDeque);
|
||||
}
|
||||
|
||||
return list;
|
||||
}
|
||||
|
||||
private void a(List<String> list, CommandSender sender, CommandNode commandNode, String text) {
|
||||
private void collectNodeUsages(List<String> list, CommandSender sender, CommandNode commandNode, String text) {
|
||||
String text2 = commandNode.getPath().toString();
|
||||
|
||||
for (CommandExecutor commandExecutor : commandNode.getCommandRegistry()) {
|
||||
if (commandExecutor.hasPermission(sender) && !(commandExecutor instanceof HelpCommand)) {
|
||||
list.add(this.a(commandExecutor, text2, text));
|
||||
list.add(this.formatCommandUsage(commandExecutor, text2, text));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private String a(CommandExecutor commandExecutor, String text, String text2) {
|
||||
private String formatCommandUsage(CommandExecutor commandExecutor, String text, String text2) {
|
||||
StringBuilder stringBuilder = new StringBuilder();
|
||||
stringBuilder.append(" ➥ §7/§c").append(text2).append(' ').append(text);
|
||||
ArgumentSet argumentSet = commandExecutor.getArguments();
|
||||
|
||||
@@ -18,6 +18,6 @@ public class HelpListCommand extends HelpCommand {
|
||||
}
|
||||
|
||||
public void execute(CommandSender sender, String text, String[] texts, int index) {
|
||||
this.a(sender, this.commandNode, text, 1);
|
||||
this.sendHelpPage(sender, this.commandNode, text, 1);
|
||||
}
|
||||
}
|
||||
@@ -23,7 +23,7 @@ public class HelpPageCommand extends HelpCommand {
|
||||
public void execute(CommandSender sender, String text, String[] texts, int index) {
|
||||
try {
|
||||
int index2 = Integer.parseInt(texts[index]);
|
||||
this.a(sender, this.commandNode, text, index2);
|
||||
this.sendHelpPage(sender, this.commandNode, text, index2);
|
||||
} catch (NumberFormatException ex) {
|
||||
sender.sendMessage("§cThe page must be a number!");
|
||||
}
|
||||
|
||||
@@ -47,7 +47,7 @@ public class EngineSettings implements Configuration {
|
||||
@Setting("disabled")
|
||||
private Set<String> disabled = new HashSet<>(List.of("Game1", "Game2"));
|
||||
@Setting("text-settings")
|
||||
private TextSyntaxSettings textSettings = TextSyntaxSettings.a;
|
||||
private TextSyntaxSettings textSettings = TextSyntaxSettings.INSTANCE;
|
||||
|
||||
public boolean isHideCredits() {
|
||||
return this.hideCredits;
|
||||
|
||||
+2
-2
@@ -13,8 +13,8 @@ import ro.fr33styler.arcade.api.engine.config.serialize.type.TypeToken;
|
||||
public class CuboidTypeToken implements TypeToken {
|
||||
public Object serialize(TypeContext typeContext, Object obj) {
|
||||
Cuboid cuboid = (Cuboid)obj;
|
||||
Location location = cuboid.b();
|
||||
Location location2 = cuboid.c();
|
||||
Location location = cuboid.getMin();
|
||||
Location location2 = cuboid.getMax();
|
||||
String text = location.getWorld().getName();
|
||||
int index = location.getBlockX();
|
||||
int index2 = location.getBlockY();
|
||||
|
||||
+5
-5
@@ -13,11 +13,11 @@ import ro.fr33styler.arcade.api.engine.config.serialize.type.TypeToken;
|
||||
public class LocationTypeToken implements TypeToken {
|
||||
public Object serialize(TypeContext typeContext, Object obj) {
|
||||
Location location = (Location)obj;
|
||||
String text = Strings.a(location.getX(), 2);
|
||||
String text2 = Strings.a(location.getY(), 2);
|
||||
String text3 = Strings.a(location.getZ(), 2);
|
||||
String text4 = Strings.a(location.getYaw(), 2);
|
||||
String text5 = Strings.a(location.getPitch(), 2);
|
||||
String text = Strings.formatFixedDecimal(location.getX(), 2);
|
||||
String text2 = Strings.formatFixedDecimal(location.getY(), 2);
|
||||
String text3 = Strings.formatFixedDecimal(location.getZ(), 2);
|
||||
String text4 = Strings.formatFixedDecimal(location.getYaw(), 2);
|
||||
String text5 = Strings.formatFixedDecimal(location.getPitch(), 2);
|
||||
return location.getWorld().getName() + "," + text + "," + text2 + "," + text3 + "," + text4 + "," + text5;
|
||||
}
|
||||
|
||||
|
||||
+1
-1
@@ -11,6 +11,6 @@ public class TextTypeToken implements TypeToken {
|
||||
}
|
||||
|
||||
public Object deserialize(TypeContext typeContext, Object obj) {
|
||||
return TextParser.a(obj.toString());
|
||||
return TextParser.parse(obj.toString());
|
||||
}
|
||||
}
|
||||
+5
-5
@@ -9,7 +9,7 @@ import ro.fr33styler.arcade.api.engine.config.serialize.type.TypeToken;
|
||||
|
||||
public class ArrayTypeToken implements TypeToken {
|
||||
public Object serialize(TypeContext typeContext, Object obj) {
|
||||
TypeToken typeToken = this.a(typeContext);
|
||||
TypeToken typeToken = this.resolveComponentToken(typeContext);
|
||||
ArrayList list = new ArrayList();
|
||||
|
||||
for (Object obj2 : (Object[])obj) {
|
||||
@@ -20,9 +20,9 @@ public class ArrayTypeToken implements TypeToken {
|
||||
}
|
||||
|
||||
public Object deserialize(TypeContext typeContext, Object obj) {
|
||||
Object[] objs = (Object[])ConfigurationReflection.b(typeContext.getField());
|
||||
Object[] objs = (Object[])ConfigurationReflection.getOrCreateArray(typeContext.getField());
|
||||
if (obj instanceof List var4) {
|
||||
TypeToken typeToken = this.a(typeContext);
|
||||
TypeToken typeToken = this.resolveComponentToken(typeContext);
|
||||
ArrayList list = new ArrayList();
|
||||
|
||||
for (Object obj2 : var4) {
|
||||
@@ -38,8 +38,8 @@ public class ArrayTypeToken implements TypeToken {
|
||||
}
|
||||
}
|
||||
|
||||
private TypeToken a(TypeContext typeContext) {
|
||||
Class clazz = ConfigurationReflection.a(typeContext.getField().getGenericType());
|
||||
private TypeToken resolveComponentToken(TypeContext typeContext) {
|
||||
Class clazz = ConfigurationReflection.resolveRawClass(typeContext.getField().getGenericType());
|
||||
return typeContext.getRegistry().get(clazz, typeContext.getField().getId());
|
||||
}
|
||||
}
|
||||
+6
-6
@@ -12,7 +12,7 @@ import ro.fr33styler.arcade.api.engine.config.serialize.type.TypeToken;
|
||||
|
||||
public class CollectionTypeToken implements TypeToken {
|
||||
public Object serialize(TypeContext typeContext, Object obj) {
|
||||
TypeToken typeToken = this.a(typeContext);
|
||||
TypeToken typeToken = this.resolveElementToken(typeContext);
|
||||
ArrayList list = new ArrayList();
|
||||
|
||||
for (Object obj2 : (Collection)obj) {
|
||||
@@ -23,9 +23,9 @@ public class CollectionTypeToken implements TypeToken {
|
||||
}
|
||||
|
||||
public Object deserialize(TypeContext typeContext, Object obj) {
|
||||
Collection collection = ConfigurationReflection.c(typeContext.getField());
|
||||
Collection collection = ConfigurationReflection.getOrCreateCollection(typeContext.getField());
|
||||
if (obj instanceof List var4) {
|
||||
TypeToken typeToken = this.a(typeContext);
|
||||
TypeToken typeToken = this.resolveElementToken(typeContext);
|
||||
collection.clear();
|
||||
|
||||
for (Object obj2 : var4) {
|
||||
@@ -39,10 +39,10 @@ public class CollectionTypeToken implements TypeToken {
|
||||
return collection;
|
||||
}
|
||||
|
||||
private TypeToken a(TypeContext typeContext) {
|
||||
private TypeToken resolveElementToken(TypeContext typeContext) {
|
||||
Type[] types = typeContext.getField().getGenericParameters();
|
||||
GenericTypeValidation.a(types);
|
||||
Class clazz = ConfigurationReflection.a(types[0]);
|
||||
GenericTypeValidation.validateListGenericTypes(types);
|
||||
Class clazz = ConfigurationReflection.resolveRawClass(types[0]);
|
||||
typeContext.setField(typeContext.getField().modifiedClone(types[0]));
|
||||
return typeContext.getRegistry().get(clazz, typeContext.getField().getId());
|
||||
}
|
||||
|
||||
+6
-6
@@ -13,7 +13,7 @@ import ro.fr33styler.arcade.api.engine.config.serialize.type.TypeToken;
|
||||
|
||||
public class MapTypeToken implements TypeToken {
|
||||
public Object serialize(TypeContext typeContext, Object obj) {
|
||||
TypeToken typeToken = this.a(typeContext);
|
||||
TypeToken typeToken = this.resolveValueToken(typeContext);
|
||||
typeContext.setSection(typeContext.getSection().createSection(typeContext.getField().getId()));
|
||||
LinkedHashMap linkedHashMap = new LinkedHashMap();
|
||||
|
||||
@@ -26,9 +26,9 @@ public class MapTypeToken implements TypeToken {
|
||||
}
|
||||
|
||||
public Object deserialize(TypeContext typeContext, Object obj) {
|
||||
Map map = ConfigurationReflection.d(typeContext.getField());
|
||||
Map map = ConfigurationReflection.getOrCreateMap(typeContext.getField());
|
||||
if (obj instanceof ConfigurationSection var4) {
|
||||
TypeToken typeToken = this.a(typeContext);
|
||||
TypeToken typeToken = this.resolveValueToken(typeContext);
|
||||
typeContext.setSection(var4);
|
||||
map.clear();
|
||||
|
||||
@@ -43,10 +43,10 @@ public class MapTypeToken implements TypeToken {
|
||||
return map;
|
||||
}
|
||||
|
||||
private TypeToken a(TypeContext typeContext) {
|
||||
private TypeToken resolveValueToken(TypeContext typeContext) {
|
||||
Type[] types = typeContext.getField().getGenericParameters();
|
||||
GenericTypeValidation.b(types);
|
||||
Class clazz = ConfigurationReflection.a(types[1]);
|
||||
GenericTypeValidation.validateMapGenericTypes(types);
|
||||
Class clazz = ConfigurationReflection.resolveRawClass(types[1]);
|
||||
TypeToken typeToken = typeContext.getRegistry().get(clazz, typeContext.getField().getId());
|
||||
typeContext.setField(typeContext.getField().modifiedClone(types[1]));
|
||||
return typeToken;
|
||||
|
||||
+1
-1
@@ -22,7 +22,7 @@ public class ConfigurationTypeToken implements TypeToken {
|
||||
}
|
||||
|
||||
public Object deserialize(TypeContext typeContext, Object obj) {
|
||||
Configuration configuration = (Configuration)ConfigurationReflection.a(typeContext.getField());
|
||||
Configuration configuration = (Configuration)ConfigurationReflection.getOrCreateConfiguration(typeContext.getField());
|
||||
if (obj instanceof ConfigurationSection var4) {
|
||||
this.configManager.load(configuration, var4);
|
||||
}
|
||||
|
||||
+1
-1
@@ -17,7 +17,7 @@ public class EnumTypeToken implements TypeToken {
|
||||
|
||||
public Object deserialize(TypeContext typeContext, Object obj) {
|
||||
try {
|
||||
Class clazz = ConfigurationReflection.a(typeContext.getField().getGenericType());
|
||||
Class clazz = ConfigurationReflection.resolveRawClass(typeContext.getField().getGenericType());
|
||||
return Enum.valueOf(clazz, obj.toString());
|
||||
} catch (IllegalArgumentException ex) {
|
||||
throw GenericTypeValidation.re$propagate(new InvalidConfigException("The enum is invalid!", ex));
|
||||
|
||||
+1
-1
@@ -11,7 +11,7 @@ public class IdentityTypeToken implements TypeToken {
|
||||
}
|
||||
|
||||
public Object deserialize(TypeContext typeContext, Object obj) {
|
||||
Class clazz = ConfigurationReflection.a(typeContext.getField().getGenericType());
|
||||
Class clazz = ConfigurationReflection.resolveRawClass(typeContext.getField().getGenericType());
|
||||
return clazz.isInstance(obj) ? obj : typeContext.getField().get();
|
||||
}
|
||||
}
|
||||
+2
-2
@@ -10,11 +10,11 @@ import ro.fr33styler.arcade.api.engine.config.serialize.type.TypeToken;
|
||||
|
||||
public class StringTypeToken implements TypeToken {
|
||||
public Object serialize(TypeContext typeContext, Object obj) {
|
||||
return Strings.c(obj.toString()).replace('§', '&');
|
||||
return Strings.stripHexColors(obj.toString()).replace('§', '&');
|
||||
}
|
||||
|
||||
public Object deserialize(TypeContext typeContext, Object obj) {
|
||||
return Strings.a(obj.toString());
|
||||
return Strings.colorize(obj.toString());
|
||||
}
|
||||
|
||||
public boolean canModify(SettingField settingField, Object obj) {
|
||||
|
||||
+55
-55
@@ -10,107 +10,107 @@ import ro.fr33styler.arcade.api.engine.config.serialize.Configuration;
|
||||
|
||||
public class EngineMessages implements Configuration {
|
||||
@Setting("command-no-permission")
|
||||
private String commandNoPermission = Strings.a("&cYou're not allowed to use this command!");
|
||||
private String commandNoPermission = Strings.colorize("&cYou're not allowed to use this command!");
|
||||
@Setting("restricted-command")
|
||||
private String restrictedCommand = Strings.a("&cYou can't use commands while in game!");
|
||||
private String restrictedCommand = Strings.colorize("&cYou can't use commands while in game!");
|
||||
@Setting("quickjoin-not-found")
|
||||
private String quickjoinNotFound = Strings.a("&cNo game found!");
|
||||
private String quickjoinNotFound = Strings.colorize("&cNo game found!");
|
||||
@Setting("quickjoin-started-not-found")
|
||||
private String quickjoinStartedNotFound = Strings.a("&cThere are no in-progress games with room! Try joining a new game!");
|
||||
private String quickjoinStartedNotFound = Strings.colorize("&cThere are no in-progress games with room! Try joining a new game!");
|
||||
@Setting("chat-waiting")
|
||||
private Text chatWaiting = TextParser.a("&7%player%&f: %message%");
|
||||
private Text chatWaiting = TextParser.parse("&7%player%&f: %message%");
|
||||
@Setting("game-you-left")
|
||||
private String gameYouLeft = Strings.a("&cYou left the game!");
|
||||
private String gameYouLeft = Strings.colorize("&cYou left the game!");
|
||||
@Setting("game-no-reservation")
|
||||
private String gameNoReservation = Strings.a("&cNo reservation found!");
|
||||
private String gameNoReservation = Strings.colorize("&cNo reservation found!");
|
||||
@Setting("spectator-title")
|
||||
private String spectatorTitle = Strings.a("Spectator settings");
|
||||
private String spectatorTitle = Strings.colorize("Spectator settings");
|
||||
@Setting("spectator-item-no-speed")
|
||||
private String spectatorItemNoSpeed = Strings.a("&aNo speed");
|
||||
private String spectatorItemNoSpeed = Strings.colorize("&aNo speed");
|
||||
@Setting("spectator-item-speed-1")
|
||||
private String spectatorItemSpeed1 = Strings.a("&aSpeed 1");
|
||||
private String spectatorItemSpeed1 = Strings.colorize("&aSpeed 1");
|
||||
@Setting("spectator-item-speed-2")
|
||||
private String spectatorItemSpeed2 = Strings.a("&aSpeed 2");
|
||||
private String spectatorItemSpeed2 = Strings.colorize("&aSpeed 2");
|
||||
@Setting("spectator-item-speed-3")
|
||||
private String spectatorItemSpeed3 = Strings.a("&aSpeed 3");
|
||||
private String spectatorItemSpeed3 = Strings.colorize("&aSpeed 3");
|
||||
@Setting("spectator-item-speed-4")
|
||||
private String spectatorItemSpeed4 = Strings.a("&aSpeed 4");
|
||||
private String spectatorItemSpeed4 = Strings.colorize("&aSpeed 4");
|
||||
@Setting("spectator-item-teleport-on")
|
||||
private String spectatorItemTeleportOn = Strings.a("&aEnable Auto Teleport");
|
||||
private String spectatorItemTeleportOn = Strings.colorize("&aEnable Auto Teleport");
|
||||
@Setting("spectator-item-teleport-off")
|
||||
private String spectatorItemTeleportOff = Strings.a("&cDisable Auto Teleport");
|
||||
private String spectatorItemTeleportOff = Strings.colorize("&cDisable Auto Teleport");
|
||||
@Setting("spectator-item-night-vision-on")
|
||||
private String spectatorItemNightVisionOn = Strings.a("&aEnable Night Vision");
|
||||
private String spectatorItemNightVisionOn = Strings.colorize("&aEnable Night Vision");
|
||||
@Setting("spectator-item-night-vision-off")
|
||||
private String spectatorItemNightVisionOff = Strings.a("&cDisable Night Vision");
|
||||
private String spectatorItemNightVisionOff = Strings.colorize("&cDisable Night Vision");
|
||||
@Setting("spectator-item-first-person-on")
|
||||
private String spectatorItemFirstPersonOn = Strings.a("&aEnable First Person");
|
||||
private String spectatorItemFirstPersonOn = Strings.colorize("&aEnable First Person");
|
||||
@Setting("spectator-item-first-person-off")
|
||||
private String spectatorItemFirstPersonOff = Strings.a("&cDisable First Person");
|
||||
private String spectatorItemFirstPersonOff = Strings.colorize("&cDisable First Person");
|
||||
@Setting("spectator-no-speed")
|
||||
private String spectatorNoSpeed = Strings.a("&cYou no longer have any speed effects!");
|
||||
private String spectatorNoSpeed = Strings.colorize("&cYou no longer have any speed effects!");
|
||||
@Setting("spectator-speed-1")
|
||||
private String spectatorSpeed1 = Strings.a("&aYou now have Speed 1");
|
||||
private String spectatorSpeed1 = Strings.colorize("&aYou now have Speed 1");
|
||||
@Setting("spectator-speed-2")
|
||||
private String spectatorSpeed2 = Strings.a("&aYou now have Speed 2");
|
||||
private String spectatorSpeed2 = Strings.colorize("&aYou now have Speed 2");
|
||||
@Setting("spectator-speed-3")
|
||||
private String spectatorSpeed3 = Strings.a("&aYou now have Speed 3");
|
||||
private String spectatorSpeed3 = Strings.colorize("&aYou now have Speed 3");
|
||||
@Setting("spectator-speed-4")
|
||||
private String spectatorSpeed4 = Strings.a("&aYou now have Speed 4");
|
||||
private String spectatorSpeed4 = Strings.colorize("&aYou now have Speed 4");
|
||||
@Setting("spectator-teleport-on")
|
||||
private String spectatorTeleportOn = Strings.a("&aOnce you select a player using your compass, it will auto teleport you to them!");
|
||||
private String spectatorTeleportOn = Strings.colorize("&aOnce you select a player using your compass, it will auto teleport you to them!");
|
||||
@Setting("spectator-teleport-off")
|
||||
private String spectatorTeleportOff = Strings.a("&cYou will no longer auto teleport to targets!");
|
||||
private String spectatorTeleportOff = Strings.colorize("&cYou will no longer auto teleport to targets!");
|
||||
@Setting("spectator-night-vision-on")
|
||||
private String spectatorNightVisionOn = Strings.a("&aYou now have night vision!");
|
||||
private String spectatorNightVisionOn = Strings.colorize("&aYou now have night vision!");
|
||||
@Setting("spectator-night-vision-off")
|
||||
private String spectatorNightVisionOff = Strings.a("&cYou no longer have night vision!");
|
||||
private String spectatorNightVisionOff = Strings.colorize("&cYou no longer have night vision!");
|
||||
@Setting("spectator-first-person-on")
|
||||
private String spectatorFirstPersonOn = Strings.a("&aYou will now by default use First Person spectating!");
|
||||
private String spectatorFirstPersonOn = Strings.colorize("&aYou will now by default use First Person spectating!");
|
||||
@Setting("spectator-first-person-off")
|
||||
private String spectatorFirstPersonOff = Strings.a("&cYou will now by default use Third Person spectating!");
|
||||
private String spectatorFirstPersonOff = Strings.colorize("&cYou will now by default use Third Person spectating!");
|
||||
@Setting("party-not-available")
|
||||
private String partyNotAvailable = Strings.a("&cThe party is not available!");
|
||||
private String partyNotAvailable = Strings.colorize("&cThe party is not available!");
|
||||
@Setting("party-already-in-a-party")
|
||||
private String partyAlreadyInAParty = Strings.a("&cPlayer is already in a party!");
|
||||
private String partyAlreadyInAParty = Strings.colorize("&cPlayer is already in a party!");
|
||||
@Setting("party-not-in-a-party")
|
||||
private String partyNotInAParty = Strings.a("&cPlayer is not in a party!");
|
||||
private String partyNotInAParty = Strings.colorize("&cPlayer is not in a party!");
|
||||
@Setting("party-not-in-your-party")
|
||||
private String partyNotInYourParty = Strings.a("&cThe player is not in your party!");
|
||||
private String partyNotInYourParty = Strings.colorize("&cThe player is not in your party!");
|
||||
@Setting("party-not-a-leader")
|
||||
private String partyNotALeader = Strings.a("&cYou are not the leader of this party!");
|
||||
private String partyNotALeader = Strings.colorize("&cYou are not the leader of this party!");
|
||||
@Setting("party-kick-leader-denied")
|
||||
private String partyKickLeaderDenied = Strings.a("&cThe party leader cannot be kicked.");
|
||||
private String partyKickLeaderDenied = Strings.colorize("&cThe party leader cannot be kicked.");
|
||||
@Setting("party-disbanded")
|
||||
private String partyDisbanded = Strings.a("&aThe party has been disbanded!");
|
||||
private String partyDisbanded = Strings.colorize("&aThe party has been disbanded!");
|
||||
@Setting("party-left")
|
||||
private String partyLeft = Strings.a("&aYou left the party!");
|
||||
private String partyLeft = Strings.colorize("&aYou left the party!");
|
||||
@Setting("party-player-left")
|
||||
private Text partyPlayerLeft = TextParser.a("&a%player% &eleft the party!");
|
||||
private Text partyPlayerLeft = TextParser.parse("&a%player% &eleft the party!");
|
||||
@Setting("party-only-leader")
|
||||
private String partyOnlyLeader = Strings.a("&cOnly the party leader can join games!");
|
||||
private String partyOnlyLeader = Strings.colorize("&cOnly the party leader can join games!");
|
||||
@Setting("party-kick-by-you")
|
||||
private String partyKickByYou = Strings.a("&aThe player has been kicked from your party!");
|
||||
private String partyKickByYou = Strings.colorize("&aThe player has been kicked from your party!");
|
||||
@Setting("party-kick-received")
|
||||
private String partyKickReceived = Strings.a("&aYou have been kicked from this party!");
|
||||
private String partyKickReceived = Strings.colorize("&aYou have been kicked from this party!");
|
||||
@Setting("party-invited-sent")
|
||||
private Text partyInvitedSent = TextParser.a("&eYou've invited &a%player% &eto the party!");
|
||||
private Text partyInvitedSent = TextParser.parse("&eYou've invited &a%player% &eto the party!");
|
||||
@Setting("party-invited-received")
|
||||
private Text partyInvitedReceived = TextParser.a("&eYou've been invited to &a%player%&e's party!");
|
||||
private Text partyInvitedReceived = TextParser.parse("&eYou've been invited to &a%player%&e's party!");
|
||||
@Setting("party-invitation-not-found")
|
||||
private String partyInvitationNotFound = Strings.a("&cYou have not been invited by this party!");
|
||||
private String partyInvitationNotFound = Strings.colorize("&cYou have not been invited by this party!");
|
||||
@Setting("party-invitation-yourself")
|
||||
private String partyInvitationYourself = Strings.a("&cYou can't invite yourself!");
|
||||
private String partyInvitationYourself = Strings.colorize("&cYou can't invite yourself!");
|
||||
@Setting("party-invitation-accepted")
|
||||
private String partyInvitationAccepted = Strings.a("&aYou've accepted the party invitation!");
|
||||
private String partyInvitationAccepted = Strings.colorize("&aYou've accepted the party invitation!");
|
||||
@Setting("party-invitation-accepted-by-player")
|
||||
private Text partyInvitationAcceptedByPlayer = TextParser.a("&a%player% &ehas joined the party!");
|
||||
private Text partyInvitationAcceptedByPlayer = TextParser.parse("&a%player% &ehas joined the party!");
|
||||
@Setting("party-invitation-denied")
|
||||
private String partyInvitationDenied = Strings.a("&aYou've denied the party invitation!");
|
||||
private String partyInvitationDenied = Strings.colorize("&aYou've denied the party invitation!");
|
||||
@Setting("party-invitation-denied-by-player")
|
||||
private Text partyInvitationDeniedByPlayer = TextParser.a("&a%player% &chas denied the party invitation!");
|
||||
private Text partyInvitationDeniedByPlayer = TextParser.parse("&a%player% &chas denied the party invitation!");
|
||||
@Setting("party-info")
|
||||
private List<Text> partyInfo = TextParser.a(new String[]{"&eParty Info: ", "&cOwner: &a%owner%", "&3Members (&f%amount%&3): &a%members%"});
|
||||
private List<Text> partyInfo = TextParser.parseAll(new String[]{"&eParty Info: ", "&cOwner: &a%owner%", "&3Members (&f%amount%&3): &a%members%"});
|
||||
@Setting("leaderboard-none")
|
||||
private String leaderboardNone = "None";
|
||||
@Setting("leaderboard-time-lifetime")
|
||||
@@ -120,11 +120,11 @@ public class EngineMessages implements Configuration {
|
||||
@Setting("leaderboard-time-weekly")
|
||||
private String leaderboardTimeWeekly = "Weekly";
|
||||
@Setting("leaderboard-position")
|
||||
private Text leaderboardPosition = TextParser.a("&aShowing &b&l%position%&a positions!");
|
||||
private Text leaderboardPosition = TextParser.parse("&aShowing &b&l%position%&a positions!");
|
||||
@Setting("leaderboard-name-papi-format")
|
||||
private String leaderboardNamePapiFormat = Strings.a("%name%");
|
||||
private String leaderboardNamePapiFormat = Strings.colorize("%name%");
|
||||
@Setting("leaderboard")
|
||||
private List<Text> leaderboard = TextParser.a(
|
||||
private List<Text> leaderboard = TextParser.parseAll(
|
||||
new String[]{
|
||||
"&b&l%time% %type%",
|
||||
"&7%mode%",
|
||||
@@ -144,7 +144,7 @@ public class EngineMessages implements Configuration {
|
||||
}
|
||||
);
|
||||
@Setting("toggler")
|
||||
private List<Text> toggler = TextParser.a(new String[]{"&b&l&nClick to toggle!", "&a&l%mode_1%", "&7%mode_2%", "&7%mode_3%"});
|
||||
private List<Text> toggler = TextParser.parseAll(new String[]{"&b&l&nClick to toggle!", "&a&l%mode_1%", "&7%mode_2%", "&7%mode_3%"});
|
||||
|
||||
public String getCommandNoPermission() {
|
||||
return this.commandNoPermission;
|
||||
|
||||
+9
-9
@@ -16,8 +16,8 @@ import ro.fr33styler.arcade.api.engine.config.InvalidConfigException;
|
||||
import ro.fr33styler.arcade.api.engine.config.SettingField;
|
||||
|
||||
public class ConfigurationReflection {
|
||||
public static Object a(SettingField settingField) {
|
||||
Class clazz = a(settingField.getGenericType());
|
||||
public static Object getOrCreateConfiguration(SettingField settingField) {
|
||||
Class clazz = resolveRawClass(settingField.getGenericType());
|
||||
if (settingField.getType() == clazz) {
|
||||
Object obj = settingField.get();
|
||||
if (obj != null) {
|
||||
@@ -28,13 +28,13 @@ public class ConfigurationReflection {
|
||||
return settingField.newInstance();
|
||||
}
|
||||
|
||||
public static Object b(SettingField settingField) {
|
||||
Class clazz = a(settingField.getGenericType());
|
||||
public static Object getOrCreateArray(SettingField settingField) {
|
||||
Class clazz = resolveRawClass(settingField.getGenericType());
|
||||
return settingField.getType() == clazz ? settingField.get() : Array.newInstance(clazz, 0);
|
||||
}
|
||||
|
||||
public static Collection<Object> c(SettingField settingField) {
|
||||
Class clazz = a(settingField.getGenericType());
|
||||
public static Collection<Object> getOrCreateCollection(SettingField settingField) {
|
||||
Class clazz = resolveRawClass(settingField.getGenericType());
|
||||
if (settingField.getType() == clazz) {
|
||||
return (Collection<Object>)settingField.get();
|
||||
} else if (Set.class.isAssignableFrom(clazz)) {
|
||||
@@ -46,12 +46,12 @@ public class ConfigurationReflection {
|
||||
}
|
||||
}
|
||||
|
||||
public static Map<String, Object> d(SettingField settingField) {
|
||||
Class clazz = a(settingField.getGenericType());
|
||||
public static Map<String, Object> getOrCreateMap(SettingField settingField) {
|
||||
Class clazz = resolveRawClass(settingField.getGenericType());
|
||||
return settingField.getType() == clazz ? (Map)settingField.get() : new HashMap<>();
|
||||
}
|
||||
|
||||
public static Class<?> a(Type type) {
|
||||
public static Class<?> resolveRawClass(Type type) {
|
||||
if (type instanceof Class var1) {
|
||||
return var1.isArray() ? var1.getComponentType() : var1;
|
||||
} else if (type instanceof ParameterizedType var2) {
|
||||
|
||||
+6
-6
@@ -38,11 +38,11 @@ public class DefaultTypeRegistry implements TypeRegistry {
|
||||
private final Map<Class<?>, TypeToken> map = new HashMap<>();
|
||||
|
||||
public DefaultTypeRegistry(ConfigManager configManager) {
|
||||
this.a();
|
||||
this.a(configManager);
|
||||
this.registerScalarTokens();
|
||||
this.registerComplexTokens(configManager);
|
||||
}
|
||||
|
||||
private void a() {
|
||||
private void registerScalarTokens() {
|
||||
this.register(boolean.class, Boolean.class, new BooleanTypeToken());
|
||||
this.register(int.class, Integer.class, new IntegerTypeToken());
|
||||
this.register(long.class, Long.class, new LongTypeToken());
|
||||
@@ -52,7 +52,7 @@ public class DefaultTypeRegistry implements TypeRegistry {
|
||||
this.register(String.class, new StringTypeToken());
|
||||
}
|
||||
|
||||
private void a(ConfigManager configManager) {
|
||||
private void registerComplexTokens(ConfigManager configManager) {
|
||||
this.register(Block.class, new BlockTypeToken());
|
||||
this.register(Location.class, new LocationTypeToken());
|
||||
this.register(Enum.class, new EnumTypeToken());
|
||||
@@ -72,7 +72,7 @@ public class DefaultTypeRegistry implements TypeRegistry {
|
||||
this.map.put(clazz, typeToken);
|
||||
}
|
||||
|
||||
private Class<?> a(Class<?> clazz) {
|
||||
private Class<?> resolveRegisteredType(Class<?> clazz) {
|
||||
if (this.map.containsKey(clazz)) {
|
||||
return clazz;
|
||||
}
|
||||
@@ -87,7 +87,7 @@ public class DefaultTypeRegistry implements TypeRegistry {
|
||||
}
|
||||
|
||||
public TypeToken get(Class<?> clazz, String text) {
|
||||
TypeToken typeToken = this.map.get(this.a(clazz));
|
||||
TypeToken typeToken = this.map.get(this.resolveRegisteredType(clazz));
|
||||
if (typeToken == null) {
|
||||
throw GenericTypeValidation.re$propagate(new InvalidConfigException("The type for the setting '" + text + "' is not registered!"));
|
||||
} else {
|
||||
|
||||
+2
-2
@@ -9,13 +9,13 @@ public class GenericTypeValidation {
|
||||
public static <E extends Throwable> RuntimeException re$propagate(Throwable cause) throws E {
|
||||
throw (E)cause;
|
||||
}
|
||||
public static void a(Type[] types) {
|
||||
public static void validateListGenericTypes(Type[] types) {
|
||||
if (types.length != 1) {
|
||||
throw GenericTypeValidation.re$propagate(new InvalidConfigException("The list must have a generic parameter!"));
|
||||
}
|
||||
}
|
||||
|
||||
public static void b(Type[] types) {
|
||||
public static void validateMapGenericTypes(Type[] types) {
|
||||
if (types.length != 2) {
|
||||
throw GenericTypeValidation.re$propagate(new InvalidConfigException("The map must have 2 generic parameters!"));
|
||||
}
|
||||
|
||||
@@ -116,7 +116,7 @@ public class DefaultEngine implements Engine {
|
||||
}
|
||||
|
||||
public PartyManager getPartyManager() {
|
||||
return this.partyManagerFactory.c();
|
||||
return this.partyManagerFactory.getPartyManager();
|
||||
}
|
||||
|
||||
public DisplayManager getDisplayManager() {
|
||||
@@ -156,26 +156,26 @@ public class DefaultEngine implements Engine {
|
||||
}
|
||||
|
||||
public void start() {
|
||||
this.users.a();
|
||||
this.users.loadOnlineUsers();
|
||||
this.loadConfigs();
|
||||
this.registerIntegrations();
|
||||
this.databaseManager.g();
|
||||
this.databaseManager.start();
|
||||
if (this.plugin.isEnabled()) {
|
||||
this.ticker.a();
|
||||
this.gameManagerRegistry.d();
|
||||
this.ticker.start();
|
||||
this.gameManagerRegistry.start();
|
||||
this.addonManager.start();
|
||||
this.networkManager.d();
|
||||
this.partyManagerFactory.a();
|
||||
this.users.a(player -> VersionAdapters.get().updatePlayerCommands(player));
|
||||
this.networkManager.start();
|
||||
this.partyManagerFactory.load();
|
||||
this.users.forEachPlayer(player -> VersionAdapters.get().updatePlayerCommands(player));
|
||||
this.plugin.getServer().getPluginManager().registerEvents(this.inventoryListener, this.plugin);
|
||||
this.plugin.getServer().getPluginManager().registerEvents(this.gameActionListener, this.plugin);
|
||||
this.gameActionListener.registerExtraListeners();
|
||||
VersionAdapters.get().registerSwapHandListener(this.plugin, this.platform, player -> this.gameActionListener.a(player, GameAction.CLICK) ? true : null);
|
||||
VersionAdapters.get().registerSwapHandListener(this.plugin, this.platform, player -> this.gameActionListener.isActionBlocked(player, GameAction.CLICK) ? true : null);
|
||||
}
|
||||
}
|
||||
|
||||
private void registerIntegrations() {
|
||||
this.integrations.a(new PlaceholderApiIntegration(this));
|
||||
this.integrations.register(new PlaceholderApiIntegration(this));
|
||||
}
|
||||
|
||||
private void loadConfigs() {
|
||||
@@ -186,17 +186,17 @@ public class DefaultEngine implements Engine {
|
||||
}
|
||||
|
||||
public void stop() {
|
||||
this.ticker.b();
|
||||
this.ticker.stop();
|
||||
this.addonManager.stop();
|
||||
this.networkManager.e();
|
||||
this.partyManagerFactory.b();
|
||||
this.displayManager.getViewers().a();
|
||||
this.gameManagerRegistry.e();
|
||||
this.databaseManager.l();
|
||||
this.users.b();
|
||||
this.networkManager.stop();
|
||||
this.partyManagerFactory.unload();
|
||||
this.displayManager.getViewers().clear();
|
||||
this.gameManagerRegistry.stop();
|
||||
this.databaseManager.stop();
|
||||
this.users.unloadOnlineUsers();
|
||||
HandlerList.unregisterAll(this.inventoryListener);
|
||||
HandlerList.unregisterAll(this.gameActionListener);
|
||||
VersionAdapters.get().unregisterSwapHandListener();
|
||||
this.integrations.a();
|
||||
this.integrations.disableAll();
|
||||
}
|
||||
}
|
||||
@@ -28,15 +28,15 @@ public class DisplayManager implements Runnable {
|
||||
|
||||
private final ViewerManager viewers = new DefaultViewerManager();
|
||||
|
||||
private int c;
|
||||
private int tickCounter;
|
||||
|
||||
private final List<NpcDisplay> d = new ArrayList<>();
|
||||
private final List<NpcDisplay> npcDisplays = new ArrayList<>();
|
||||
|
||||
private final Map<Block, CommandSign> e = new HashMap<>();
|
||||
private final Map<Block, CommandSign> commandSigns = new HashMap<>();
|
||||
|
||||
private final Map<String, LeaderboardGroup> f = new HashMap<>();
|
||||
private final Map<String, LeaderboardGroup> leaderboardGroups = new HashMap<>();
|
||||
|
||||
private final List<LeaderboardToggle> g = new ArrayList<>();
|
||||
private final List<LeaderboardToggle> leaderboardToggles = new ArrayList<>();
|
||||
|
||||
public DisplayManager(DefaultEngine engine2) {
|
||||
this.engine = engine2;
|
||||
@@ -46,119 +46,119 @@ public class DisplayManager implements Runnable {
|
||||
return this.viewers;
|
||||
}
|
||||
|
||||
public Map<String, LeaderboardGroup> b() {
|
||||
return this.f;
|
||||
public Map<String, LeaderboardGroup> getLeaderboardGroups() {
|
||||
return this.leaderboardGroups;
|
||||
}
|
||||
|
||||
public List<LeaderboardToggle> c() {
|
||||
return this.g;
|
||||
public List<LeaderboardToggle> getLeaderboardToggles() {
|
||||
return this.leaderboardToggles;
|
||||
}
|
||||
|
||||
public void a(LeaderboardSource leaderboardSource) {
|
||||
LeaderboardGroup leaderboardGroup = this.f.get(leaderboardSource.getSettings().getId());
|
||||
public void registerLeaderboardSource(LeaderboardSource leaderboardSource) {
|
||||
LeaderboardGroup leaderboardGroup = this.leaderboardGroups.get(leaderboardSource.getSettings().getId());
|
||||
if (leaderboardGroup != null) {
|
||||
leaderboardGroup.getMap().put(leaderboardSource.getSettings().getMode(), leaderboardSource);
|
||||
this.a(leaderboardGroup);
|
||||
this.updateLeaderboardGroup(leaderboardGroup);
|
||||
}
|
||||
}
|
||||
|
||||
public void a(GameLeaderboardSettings gameLeaderboardSettings) {
|
||||
LeaderboardGroup leaderboardGroup = this.f.get(gameLeaderboardSettings.getId());
|
||||
public void unregisterLeaderboardSource(GameLeaderboardSettings gameLeaderboardSettings) {
|
||||
LeaderboardGroup leaderboardGroup = this.leaderboardGroups.get(gameLeaderboardSettings.getId());
|
||||
if (leaderboardGroup != null) {
|
||||
leaderboardGroup.getMap().remove(gameLeaderboardSettings.getMode());
|
||||
this.a(leaderboardGroup);
|
||||
this.updateLeaderboardGroup(leaderboardGroup);
|
||||
}
|
||||
}
|
||||
|
||||
public void a(String text, Location location) {
|
||||
public void addLeaderboardGroup(String text, Location location) {
|
||||
LeaderboardGroup leaderboardGroup = new LeaderboardGroup(this.engine, text, location);
|
||||
this.f.put(text, leaderboardGroup);
|
||||
this.engine.getUsers().a(leaderboardGroup);
|
||||
this.leaderboardGroups.put(text, leaderboardGroup);
|
||||
this.engine.getUsers().addLeaderboardGroup(leaderboardGroup);
|
||||
}
|
||||
|
||||
public void d() {
|
||||
this.f.values().forEach(leaderboardGroup -> this.engine.getUsers().b(leaderboardGroup));
|
||||
this.f.clear();
|
||||
public void clearLeaderboardGroups() {
|
||||
this.leaderboardGroups.values().forEach(leaderboardGroup -> this.engine.getUsers().removeLeaderboardGroup(leaderboardGroup));
|
||||
this.leaderboardGroups.clear();
|
||||
}
|
||||
|
||||
public void e() {
|
||||
this.f.values().forEach(LeaderboardGroup::e);
|
||||
public void refreshLeaderboardGroups() {
|
||||
this.leaderboardGroups.values().forEach(LeaderboardGroup::refresh);
|
||||
}
|
||||
|
||||
public void a(String text, LeaderboardToggleSettings leaderboardToggleSettings) {
|
||||
public void addLeaderboardToggle(String text, LeaderboardToggleSettings leaderboardToggleSettings) {
|
||||
LeaderboardToggle leaderboardToggle = new LeaderboardToggle(this.engine, text, leaderboardToggleSettings);
|
||||
this.g.add(leaderboardToggle);
|
||||
leaderboardToggle.f();
|
||||
this.engine.getUsers().a(leaderboardToggle);
|
||||
this.leaderboardToggles.add(leaderboardToggle);
|
||||
leaderboardToggle.refreshAvailableModes();
|
||||
this.engine.getUsers().addLeaderboardToggle(leaderboardToggle);
|
||||
}
|
||||
|
||||
public void f() {
|
||||
this.g.forEach(leaderboardToggle -> this.engine.getUsers().b(leaderboardToggle));
|
||||
this.g.clear();
|
||||
public void clearLeaderboardToggles() {
|
||||
this.leaderboardToggles.forEach(leaderboardToggle -> this.engine.getUsers().removeLeaderboardToggle(leaderboardToggle));
|
||||
this.leaderboardToggles.clear();
|
||||
}
|
||||
|
||||
public void g() {
|
||||
this.g.forEach(LeaderboardToggle::f);
|
||||
public void refreshLeaderboardToggles() {
|
||||
this.leaderboardToggles.forEach(LeaderboardToggle::refreshAvailableModes);
|
||||
}
|
||||
|
||||
public void a(LeaderboardGroup leaderboardGroup) {
|
||||
this.g();
|
||||
this.engine.getUsers().c(leaderboardGroup);
|
||||
public void updateLeaderboardGroup(LeaderboardGroup leaderboardGroup) {
|
||||
this.refreshLeaderboardToggles();
|
||||
this.engine.getUsers().refreshLeaderboardGroup(leaderboardGroup);
|
||||
}
|
||||
|
||||
public void a(NpcDisplaySettings npcDisplaySettings) {
|
||||
public void addNpcDisplay(NpcDisplaySettings npcDisplaySettings) {
|
||||
NpcDisplay npcDisplay = new NpcDisplay(this.engine, npcDisplaySettings);
|
||||
this.d.add(npcDisplay);
|
||||
this.viewers.a(npcDisplay);
|
||||
this.npcDisplays.add(npcDisplay);
|
||||
this.viewers.register(npcDisplay);
|
||||
}
|
||||
|
||||
public NpcDisplay a(Location location) {
|
||||
for (NpcDisplay npcDisplay : this.d) {
|
||||
if (Locations.a(npcDisplay.getLocation(), location, 1.8)) {
|
||||
public NpcDisplay getNpcDisplay(Location location) {
|
||||
for (NpcDisplay npcDisplay : this.npcDisplays) {
|
||||
if (Locations.isNear(npcDisplay.getLocation(), location, 1.8)) {
|
||||
return npcDisplay;
|
||||
}
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
public void b(Location location) {
|
||||
NpcDisplay npcDisplay = this.a(location);
|
||||
public void removeNpcDisplay(Location location) {
|
||||
NpcDisplay npcDisplay = this.getNpcDisplay(location);
|
||||
if (npcDisplay != null) {
|
||||
this.viewers.b(npcDisplay);
|
||||
this.d.remove(npcDisplay);
|
||||
this.viewers.unregister(npcDisplay);
|
||||
this.npcDisplays.remove(npcDisplay);
|
||||
}
|
||||
}
|
||||
|
||||
public void a(int index, Player player) {
|
||||
for (NpcDisplay npcDisplay : this.d) {
|
||||
if (npcDisplay.a() == index) {
|
||||
npcDisplay.a(player);
|
||||
public void handleNpcInteract(int index, Player player) {
|
||||
for (NpcDisplay npcDisplay : this.npcDisplays) {
|
||||
if (npcDisplay.getEntityId() == index) {
|
||||
npcDisplay.executeCommand(player);
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public void a(Block block, String text, List<Text> list, Context context) {
|
||||
public void addCommandSign(Block block, String text, List<Text> list, Context context) {
|
||||
CommandSign commandSign = new CommandSign(block, text, list, context);
|
||||
this.e.put(block, commandSign);
|
||||
commandSign.a();
|
||||
this.commandSigns.put(block, commandSign);
|
||||
commandSign.update();
|
||||
}
|
||||
|
||||
public CommandSign a(Block block) {
|
||||
return this.e.get(block);
|
||||
public CommandSign getCommandSign(Block block) {
|
||||
return this.commandSigns.get(block);
|
||||
}
|
||||
|
||||
public void b(Block block) {
|
||||
this.e.remove(block);
|
||||
public void removeCommandSign(Block block) {
|
||||
this.commandSigns.remove(block);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void run() {
|
||||
this.c++;
|
||||
this.d.forEach(NpcDisplay::b);
|
||||
this.e.values().forEach(CommandSign::a);
|
||||
if (this.c % this.engine.getSettings().getUpdateLeaderboardCacheInSeconds() == 0) {
|
||||
this.e();
|
||||
this.tickCounter++;
|
||||
this.npcDisplays.forEach(NpcDisplay::updateHologram);
|
||||
this.commandSigns.values().forEach(CommandSign::update);
|
||||
if (this.tickCounter % this.engine.getSettings().getUpdateLeaderboardCacheInSeconds() == 0) {
|
||||
this.refreshLeaderboardGroups();
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -17,7 +17,7 @@ import org.bukkit.entity.Player;
|
||||
public class Hologram implements Viewable {
|
||||
private final Location location;
|
||||
private HologramEntity[] hologramEntitys = new HologramEntity[0];
|
||||
private String[] c = new String[0];
|
||||
private String[] lines = new String[0];
|
||||
private final Set<UUID> set;
|
||||
|
||||
public Hologram(Location location2) {
|
||||
@@ -37,7 +37,7 @@ public class Hologram implements Viewable {
|
||||
return this.set;
|
||||
}
|
||||
|
||||
public boolean a(int index) {
|
||||
public boolean hasEntityId(int index) {
|
||||
for (HologramEntity hologramEntity : this.hologramEntitys) {
|
||||
if (hologramEntity.getEntity().getEntityId() == index) {
|
||||
return true;
|
||||
@@ -47,13 +47,13 @@ public class Hologram implements Viewable {
|
||||
return false;
|
||||
}
|
||||
|
||||
public void a(Player player, boolean flag) {
|
||||
public void setVisible(Player player, boolean flag) {
|
||||
for (HologramEntity hologramEntity : this.hologramEntitys) {
|
||||
hologramEntity.setVisible(player, flag);
|
||||
}
|
||||
}
|
||||
|
||||
private void a(HologramEntity hologramEntity) {
|
||||
private void updateMetadata(HologramEntity hologramEntity) {
|
||||
for (UUID uuid : this.set) {
|
||||
Player player = Bukkit.getPlayer(uuid);
|
||||
if (player != null) {
|
||||
@@ -62,65 +62,65 @@ public class Hologram implements Viewable {
|
||||
}
|
||||
}
|
||||
|
||||
public void a(ServerPlatform serverPlatform, String... texts) {
|
||||
this.a(serverPlatform, Arrays.asList(texts));
|
||||
public void setLines(ServerPlatform serverPlatform, String... texts) {
|
||||
this.setLines(serverPlatform, Arrays.asList(texts));
|
||||
}
|
||||
|
||||
public void a(ServerPlatform serverPlatform, List<String> list) {
|
||||
public void setLines(ServerPlatform serverPlatform, List<String> list) {
|
||||
if (list.size() != this.hologramEntitys.length) {
|
||||
this.a(serverPlatform, list.size());
|
||||
this.resize(serverPlatform, list.size());
|
||||
}
|
||||
|
||||
for (int index = list.size() - 1; index >= 0; index--) {
|
||||
int index2 = list.size() - index - 1;
|
||||
HologramEntity hologramEntity = this.hologramEntitys[index2];
|
||||
String text = (String)list.get(index);
|
||||
String text2 = this.c[index2];
|
||||
String text2 = this.lines[index2];
|
||||
if (text2 == null || !text2.equals(text)) {
|
||||
hologramEntity.setText(text);
|
||||
this.c[index2] = text;
|
||||
this.a(hologramEntity);
|
||||
this.lines[index2] = text;
|
||||
this.updateMetadata(hologramEntity);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private void a(HologramEntity[] hologramEntitys2, String[] texts, int index) {
|
||||
private void shrink(HologramEntity[] hologramEntitys2, String[] texts, int index) {
|
||||
for (int index2 = index; index2 < this.hologramEntitys.length; index2++) {
|
||||
this.a(this.hologramEntitys[index2], false);
|
||||
this.setEntityVisible(this.hologramEntitys[index2], false);
|
||||
}
|
||||
|
||||
System.arraycopy(this.hologramEntitys, 0, hologramEntitys2, 0, index);
|
||||
System.arraycopy(this.c, 0, texts, 0, index);
|
||||
System.arraycopy(this.lines, 0, texts, 0, index);
|
||||
}
|
||||
|
||||
private void a(HologramEntity[] hologramEntitys2, String[] texts, ServerPlatform serverPlatform, int index) {
|
||||
private void grow(HologramEntity[] hologramEntitys2, String[] texts, ServerPlatform serverPlatform, int index) {
|
||||
World world = this.location.getWorld();
|
||||
double doubleVal = this.location.getY() + this.hologramEntitys.length * 0.3;
|
||||
|
||||
for (int index2 = this.hologramEntitys.length; index2 < index; index2++) {
|
||||
hologramEntitys2[index2] = serverPlatform.createHologram(world, this.location.getX(), doubleVal, this.location.getZ());
|
||||
this.a(hologramEntitys2[index2], true);
|
||||
this.setEntityVisible(hologramEntitys2[index2], true);
|
||||
doubleVal += 0.3;
|
||||
}
|
||||
|
||||
System.arraycopy(this.hologramEntitys, 0, hologramEntitys2, 0, this.hologramEntitys.length);
|
||||
System.arraycopy(this.c, 0, texts, 0, this.hologramEntitys.length);
|
||||
System.arraycopy(this.lines, 0, texts, 0, this.hologramEntitys.length);
|
||||
}
|
||||
|
||||
private void a(ServerPlatform serverPlatform, int index) {
|
||||
private void resize(ServerPlatform serverPlatform, int index) {
|
||||
HologramEntity[] hologramEntitys2 = new HologramEntity[index];
|
||||
String[] texts = new String[index];
|
||||
if (this.hologramEntitys.length < index) {
|
||||
this.a(hologramEntitys2, texts, serverPlatform, index);
|
||||
this.grow(hologramEntitys2, texts, serverPlatform, index);
|
||||
} else {
|
||||
this.a(hologramEntitys2, texts, index);
|
||||
this.shrink(hologramEntitys2, texts, index);
|
||||
}
|
||||
|
||||
this.hologramEntitys = hologramEntitys2;
|
||||
this.c = texts;
|
||||
this.lines = texts;
|
||||
}
|
||||
|
||||
private void a(HologramEntity hologramEntity, boolean flag) {
|
||||
private void setEntityVisible(HologramEntity hologramEntity, boolean flag) {
|
||||
for (UUID uuid : this.set) {
|
||||
Player player = Bukkit.getPlayer(uuid);
|
||||
if (player != null) {
|
||||
|
||||
@@ -26,7 +26,7 @@ public class NpcDisplay implements Viewable {
|
||||
private final Npc npc;
|
||||
private final Hologram hologram;
|
||||
private final DefaultEngine engine;
|
||||
private final String e = Randoms.a(8);
|
||||
private final String npcName = Randoms.randomAlphanumeric(8);
|
||||
private final Set<UUID> set = new HashSet<>();
|
||||
|
||||
public NpcDisplay(DefaultEngine engine2, NpcDisplaySettings settings2) {
|
||||
@@ -35,11 +35,11 @@ public class NpcDisplay implements Viewable {
|
||||
SkinTexture skinTexture = settings2.getSkinTexture();
|
||||
NpcEquipment npcEquipment = settings2.getNpcEquipment();
|
||||
Location location = settings2.getLocation();
|
||||
this.hologram = new Hologram(Locations.a(location).add(0.0, 1.9, 0.0), this.set);
|
||||
this.npc = engine2.getPlatform().getNpcFactory().createNpc(location, this.e, skinTexture, npcEquipment);
|
||||
this.hologram = new Hologram(Locations.copy(location).add(0.0, 1.9, 0.0), this.set);
|
||||
this.npc = engine2.getPlatform().getNpcFactory().createNpc(location, this.npcName, skinTexture, npcEquipment);
|
||||
}
|
||||
|
||||
public int a() {
|
||||
public int getEntityId() {
|
||||
return this.npc.getEntityId();
|
||||
}
|
||||
|
||||
@@ -51,21 +51,21 @@ public class NpcDisplay implements Viewable {
|
||||
return this.set;
|
||||
}
|
||||
|
||||
public void a(Player player) {
|
||||
player.performCommand(this.settings.d());
|
||||
public void executeCommand(Player player) {
|
||||
player.performCommand(this.settings.getCommand());
|
||||
}
|
||||
|
||||
public void a(Player player, boolean flag) {
|
||||
public void setVisible(Player player, boolean flag) {
|
||||
if (flag) {
|
||||
this.b(player);
|
||||
this.hideNameTag(player);
|
||||
Bukkit.getScheduler().runTaskLater(this.engine.getPlugin(), () -> this.npc.removeFromTabList(player), 60L);
|
||||
}
|
||||
|
||||
this.npc.setVisible(player, flag);
|
||||
this.hologram.a(player, flag);
|
||||
this.hologram.setVisible(player, flag);
|
||||
}
|
||||
|
||||
private void b(Player player) {
|
||||
private void hideNameTag(Player player) {
|
||||
Team team = player.getScoreboard().getTeam("GameEngineNpc");
|
||||
if (team == null) {
|
||||
team = player.getScoreboard().registerNewTeam("GameEngineNpc");
|
||||
@@ -73,10 +73,10 @@ public class NpcDisplay implements Viewable {
|
||||
VersionAdapters.get().applyTeamNameTagVisibility(team, TeamRule.NEVER);
|
||||
}
|
||||
|
||||
team.addEntry(this.e);
|
||||
team.addEntry(this.npcName);
|
||||
}
|
||||
|
||||
public void b() {
|
||||
this.hologram.a(this.engine.getPlatform(), TextRenderer.a(this.settings.getList(), this.settings.getContext()));
|
||||
public void updateHologram() {
|
||||
this.hologram.setLines(this.engine.getPlatform(), TextRenderer.render(this.settings.getList(), this.settings.getContext()));
|
||||
}
|
||||
}
|
||||
+3
-3
@@ -24,13 +24,13 @@ public class AddNpcCommand extends BaseCommandExecutor {
|
||||
|
||||
public void execute(CommandSender sender, String text, String[] texts, int index) {
|
||||
Player player = (Player)sender;
|
||||
if (this.manager.getEngine().getDisplayManager().a(player.getLocation()) != null) {
|
||||
if (this.manager.getEngine().getDisplayManager().getNpcDisplay(player.getLocation()) != null) {
|
||||
player.sendMessage("§cYou can only have 1 npc on the same location!");
|
||||
} else {
|
||||
Location location = player.getLocation();
|
||||
this.manager.spawnNpcDisplay(location);
|
||||
this.manager.getStorage().getStorage2().getNpcs().add(location);
|
||||
this.manager.getStorage().getStorage2().c();
|
||||
this.manager.getStorage().getNpcStorage().getNpcs().add(location);
|
||||
this.manager.getStorage().getNpcStorage().save();
|
||||
player.sendMessage("§aNPC added!");
|
||||
}
|
||||
}
|
||||
|
||||
+4
-4
@@ -32,14 +32,14 @@ public class RemoveNpcCommand extends BaseCommandExecutor {
|
||||
|
||||
for (int index2 = 0; index2 < 20; index2++) {
|
||||
location.add(vector);
|
||||
Iterator iterator = this.manager.getStorage().getStorage2().getNpcs().iterator();
|
||||
Iterator iterator = this.manager.getStorage().getNpcStorage().getNpcs().iterator();
|
||||
|
||||
while (iterator.hasNext()) {
|
||||
Location location2 = (Location)iterator.next();
|
||||
if (Locations.b(location2, location) <= 4.0) {
|
||||
if (Locations.distanceSquared(location2, location) <= 4.0) {
|
||||
iterator.remove();
|
||||
this.manager.getEngine().getDisplayManager().b(location2);
|
||||
this.manager.getStorage().getStorage2().c();
|
||||
this.manager.getEngine().getDisplayManager().removeNpcDisplay(location2);
|
||||
this.manager.getStorage().getNpcStorage().save();
|
||||
player.sendMessage("§aNPC removed!");
|
||||
return;
|
||||
}
|
||||
|
||||
+5
-5
@@ -12,7 +12,7 @@ public class NpcDisplaySettings {
|
||||
private List<Text> list;
|
||||
private Context context;
|
||||
private Location location;
|
||||
private String d;
|
||||
private String command;
|
||||
private SkinTexture skinTexture;
|
||||
private NpcEquipment npcEquipment;
|
||||
|
||||
@@ -40,12 +40,12 @@ public class NpcDisplaySettings {
|
||||
this.location = location2;
|
||||
}
|
||||
|
||||
public String d() {
|
||||
return this.d;
|
||||
public String getCommand() {
|
||||
return this.command;
|
||||
}
|
||||
|
||||
public void a(String text) {
|
||||
this.d = text;
|
||||
public void setCommand(String text) {
|
||||
this.command = text;
|
||||
}
|
||||
|
||||
public SkinTexture getSkinTexture() {
|
||||
|
||||
+2
-2
@@ -23,11 +23,11 @@ public class NpcStorage implements Configuration {
|
||||
return this.npcs;
|
||||
}
|
||||
|
||||
public void b() {
|
||||
public void load() {
|
||||
this.configManager.tryLoad(this, this.file);
|
||||
}
|
||||
|
||||
public void c() {
|
||||
public void save() {
|
||||
this.configManager.trySave(this, this.file);
|
||||
}
|
||||
}
|
||||
+28
-28
@@ -13,103 +13,103 @@ import org.bukkit.entity.Player;
|
||||
public class DefaultViewerManager implements ViewerManager {
|
||||
private final Map<UUID, List<Viewable>> map = new LinkedHashMap<>();
|
||||
|
||||
public void a(Viewable viewable) {
|
||||
public void register(Viewable viewable) {
|
||||
World world = viewable.getLocation().getWorld();
|
||||
if (world != null) {
|
||||
this.map.computeIfAbsent(world.getUID(), uuid -> new ArrayList<>()).add(viewable);
|
||||
}
|
||||
}
|
||||
|
||||
public void b(Viewable viewable) {
|
||||
public void unregister(Viewable viewable) {
|
||||
World world = viewable.getLocation().getWorld();
|
||||
if (world != null) {
|
||||
this.a(world.getUID(), viewable);
|
||||
this.unregisterFromWorld(world.getUID(), viewable);
|
||||
}
|
||||
}
|
||||
|
||||
private void a(UUID uuid, Viewable viewable) {
|
||||
private void unregisterFromWorld(UUID uuid, Viewable viewable) {
|
||||
List<Viewable> list = this.map.get(uuid);
|
||||
if (list != null) {
|
||||
this.a(uuid, viewable, list);
|
||||
this.removeFromWorldList(uuid, viewable, list);
|
||||
}
|
||||
}
|
||||
|
||||
private void a(UUID uuid, Viewable viewable, List<Viewable> list) {
|
||||
private void removeFromWorldList(UUID uuid, Viewable viewable, List<Viewable> list) {
|
||||
list.remove(viewable);
|
||||
this.c(viewable);
|
||||
this.hideFromAll(viewable);
|
||||
if (list.isEmpty()) {
|
||||
this.map.remove(uuid);
|
||||
}
|
||||
}
|
||||
|
||||
public void a() {
|
||||
public void clear() {
|
||||
for (List<Viewable> list : this.map.values()) {
|
||||
for (Viewable viewable : list) {
|
||||
this.c(viewable);
|
||||
this.hideFromAll(viewable);
|
||||
}
|
||||
}
|
||||
|
||||
this.map.clear();
|
||||
}
|
||||
|
||||
public void c(Viewable viewable) {
|
||||
public void hideFromAll(Viewable viewable) {
|
||||
for (UUID uuid : viewable.getSet()) {
|
||||
Player player = Bukkit.getPlayer(uuid);
|
||||
if (player != null) {
|
||||
viewable.a(player, false);
|
||||
viewable.setVisible(player, false);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public void a(Player player) {
|
||||
this.a(player, player.getWorld().getUID());
|
||||
public void hideWorld(Player player) {
|
||||
this.hideWorld(player, player.getWorld().getUID());
|
||||
}
|
||||
|
||||
public void a(Player player, UUID uuid) {
|
||||
public void hideWorld(Player player, UUID uuid) {
|
||||
List<Viewable> list = this.map.get(uuid);
|
||||
if (list != null) {
|
||||
this.a(player, list);
|
||||
this.hideAll(player, list);
|
||||
}
|
||||
}
|
||||
|
||||
private void a(Player player, List<Viewable> list) {
|
||||
private void hideAll(Player player, List<Viewable> list) {
|
||||
for (Viewable viewable : list) {
|
||||
this.b(player, viewable);
|
||||
this.hide(player, viewable);
|
||||
}
|
||||
}
|
||||
|
||||
private void a(Player player, Viewable viewable) {
|
||||
viewable.a(player, true);
|
||||
private void show(Player player, Viewable viewable) {
|
||||
viewable.setVisible(player, true);
|
||||
viewable.getSet().add(player.getUniqueId());
|
||||
}
|
||||
|
||||
private void b(Player player, Viewable viewable) {
|
||||
viewable.a(player, false);
|
||||
private void hide(Player player, Viewable viewable) {
|
||||
viewable.setVisible(player, false);
|
||||
viewable.getSet().remove(player.getUniqueId());
|
||||
}
|
||||
|
||||
public void b(Player player) {
|
||||
public void update(Player player) {
|
||||
List<Viewable> list = this.map.get(player.getWorld().getUID());
|
||||
if (list != null) {
|
||||
this.b(player, list);
|
||||
this.updateAll(player, list);
|
||||
}
|
||||
}
|
||||
|
||||
private void b(Player player, List<Viewable> list) {
|
||||
private void updateAll(Player player, List<Viewable> list) {
|
||||
Location location = player.getLocation();
|
||||
|
||||
for (Viewable viewable : list) {
|
||||
this.a(player, location, viewable);
|
||||
this.updateVisibility(player, location, viewable);
|
||||
}
|
||||
}
|
||||
|
||||
private void a(Player player, Location location, Viewable viewable) {
|
||||
private void updateVisibility(Player player, Location location, Viewable viewable) {
|
||||
double doubleVal = location.distanceSquared(viewable.getLocation());
|
||||
boolean flag = viewable.getSet().contains(player.getUniqueId());
|
||||
if (flag && doubleVal > 3025.0) {
|
||||
this.b(player, viewable);
|
||||
this.hide(player, viewable);
|
||||
} else if (!flag && doubleVal <= 3025.0) {
|
||||
this.a(player, viewable);
|
||||
this.show(player, viewable);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -8,7 +8,7 @@ import org.bukkit.Location;
|
||||
import org.bukkit.util.Vector;
|
||||
|
||||
public class ViewDistance {
|
||||
public static <T> T a(Location location, Collection<T> collection, Function<T, Location> function) {
|
||||
public static <T> T findTarget(Location location, Collection<T> collection, Function<T, Location> function) {
|
||||
Vector vector = location.getDirection();
|
||||
|
||||
for (int index = 0; index < 20; index++) {
|
||||
@@ -17,7 +17,7 @@ public class ViewDistance {
|
||||
double doubleVal = 9.0;
|
||||
|
||||
for (T obj2 : collection) {
|
||||
double doubleVal2 = Locations.b((Location)function.apply(obj2), location);
|
||||
double doubleVal2 = Locations.distanceSquared((Location)function.apply(obj2), location);
|
||||
if (doubleVal2 < doubleVal) {
|
||||
obj = obj2;
|
||||
doubleVal = doubleVal2;
|
||||
|
||||
@@ -10,5 +10,5 @@ public interface Viewable {
|
||||
|
||||
Set<UUID> getSet();
|
||||
|
||||
void a(Player var1, boolean var2);
|
||||
void setVisible(Player var1, boolean var2);
|
||||
}
|
||||
@@ -4,15 +4,15 @@ import java.util.UUID;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
public interface ViewerManager {
|
||||
void a(Viewable var1);
|
||||
void register(Viewable var1);
|
||||
|
||||
void b(Viewable var1);
|
||||
void unregister(Viewable var1);
|
||||
|
||||
void a();
|
||||
void clear();
|
||||
|
||||
void a(Player var1);
|
||||
void hideWorld(Player var1);
|
||||
|
||||
void a(Player var1, UUID var2);
|
||||
void hideWorld(Player var1, UUID var2);
|
||||
|
||||
void b(Player var1);
|
||||
void update(Player var1);
|
||||
}
|
||||
@@ -14,38 +14,38 @@ import org.bukkit.entity.Firework;
|
||||
import org.bukkit.inventory.meta.FireworkMeta;
|
||||
|
||||
public final class Fireworks {
|
||||
private static final FireworkEffect[] a = new FireworkEffect[3];
|
||||
private static final Type[] b = new Type[]{Type.BURST, Type.BALL, Type.BALL_LARGE};
|
||||
private static final FireworkEffect[] DEFAULT_EFFECTS = new FireworkEffect[3];
|
||||
private static final Type[] DEFAULT_TYPES = new Type[]{Type.BURST, Type.BALL, Type.BALL_LARGE};
|
||||
|
||||
public static Firework a(Location location) {
|
||||
return a(location, (FireworkEffect)Randoms.a(a));
|
||||
public static Firework spawnRandom(Location location) {
|
||||
return spawn(location, (FireworkEffect)Randoms.pickRandom(DEFAULT_EFFECTS));
|
||||
}
|
||||
|
||||
public static void b(Location location) {
|
||||
VersionAdapters.get().detonateFirework(null, a(location));
|
||||
public static void detonateRandom(Location location) {
|
||||
VersionAdapters.get().detonateFirework(null, spawnRandom(location));
|
||||
}
|
||||
|
||||
public static void a(ServerPlatform serverPlatform, Location location) {
|
||||
VersionAdapters.get().detonateFirework(serverPlatform, a(location));
|
||||
public static void detonateRandom(ServerPlatform serverPlatform, Location location) {
|
||||
VersionAdapters.get().detonateFirework(serverPlatform, spawnRandom(location));
|
||||
}
|
||||
|
||||
public static Firework a(Location location, Color color) {
|
||||
return a(location, (Type)Randoms.a(b), new Color[]{color});
|
||||
public static Firework spawnColored(Location location, Color color) {
|
||||
return spawn(location, (Type)Randoms.pickRandom(DEFAULT_TYPES), new Color[]{color});
|
||||
}
|
||||
|
||||
public static void a(ServerPlatform serverPlatform, Location location, Color color) {
|
||||
VersionAdapters.get().detonateFirework(serverPlatform, a(location, color));
|
||||
public static void detonateColored(ServerPlatform serverPlatform, Location location, Color color) {
|
||||
VersionAdapters.get().detonateFirework(serverPlatform, spawnColored(location, color));
|
||||
}
|
||||
|
||||
public static Firework b(Location location, Color color) {
|
||||
return a(location, (Type)Randoms.a(b), color);
|
||||
public static Firework spawnWithColor(Location location, Color color) {
|
||||
return spawn(location, (Type)Randoms.pickRandom(DEFAULT_TYPES), color);
|
||||
}
|
||||
|
||||
public static Firework a(Location location, Type type, Color... colors) {
|
||||
return a(location, FireworkEffect.builder().withColor(colors).with(type).build());
|
||||
public static Firework spawn(Location location, Type type, Color... colors) {
|
||||
return spawn(location, FireworkEffect.builder().withColor(colors).with(type).build());
|
||||
}
|
||||
|
||||
public static Firework a(Location location, FireworkEffect fireworkEffect) {
|
||||
public static Firework spawn(Location location, FireworkEffect fireworkEffect) {
|
||||
Validate.notNull(location.getWorld(), "The world cannot be null!");
|
||||
Firework firework = (Firework)location.getWorld().spawn(location, Firework.class);
|
||||
FireworkMeta fireworkMeta = firework.getFireworkMeta();
|
||||
@@ -58,8 +58,8 @@ public final class Fireworks {
|
||||
Builder var0 = FireworkEffect.builder();
|
||||
var0.withColor(new Color[]{Color.RED, Color.YELLOW, Color.GREEN, Color.BLUE, Color.PURPLE});
|
||||
|
||||
for (int var1 = 0; var1 < b.length; var1++) {
|
||||
a[var1] = var0.with(b[var1]).build();
|
||||
for (int var1 = 0; var1 < DEFAULT_TYPES.length; var1++) {
|
||||
DEFAULT_EFFECTS[var1] = var0.with(DEFAULT_TYPES[var1]).build();
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -149,7 +149,7 @@ public abstract class AbstractGame implements Game, Context {
|
||||
case "players" -> String.valueOf(this.getGamers().size());
|
||||
case "min_players" -> String.valueOf(this.getMap().getMinimumPlayers());
|
||||
case "max_players" -> String.valueOf(this.getMap().getMaximumPlayers());
|
||||
default -> (String)EngineUtils.a((Object)this.phase.getVariable(text), this.getManager().getVariable(text));
|
||||
default -> (String)EngineUtils.orElse((Object)this.phase.getVariable(text), this.getManager().getVariable(text));
|
||||
};
|
||||
}
|
||||
|
||||
|
||||
@@ -159,9 +159,9 @@ public abstract class AbstractGameManager implements GameManager, Context {
|
||||
}
|
||||
|
||||
protected void registerIntegrations() {
|
||||
this.integrations.a(new GamePlaceholderIntegration(this));
|
||||
this.integrations.register(new GamePlaceholderIntegration(this));
|
||||
VersionAdapters.get().registerVariantGameIntegrations(this.integrations, this);
|
||||
this.integrations.a(new SlimeWorldManagerIntegration(this));
|
||||
this.integrations.register(new SlimeWorldManagerIntegration(this));
|
||||
}
|
||||
|
||||
protected void initDefaultProperties() {
|
||||
@@ -172,21 +172,21 @@ public abstract class AbstractGameManager implements GameManager, Context {
|
||||
}
|
||||
|
||||
protected void populateMenu(GameMenuPage gameMenuPage, Context context) {
|
||||
gameMenuPage.page().a(12, defaultUser -> {
|
||||
gameMenuPage.page().setSlot(12, defaultUser -> {
|
||||
defaultUser.toPlayer().closeInventory();
|
||||
defaultUser.a(this.getSessions().getGameSearcher());
|
||||
}, new ItemBuilder(ArcadeMaterial.ENDER_EYE).setDisplayName(this.getMessages().getJoinGuiQuickJoinName(), context).setLore(TextRenderer.a(this.getMessages().getJoinGuiQuickJoinLore(), context)).build());
|
||||
gameMenuPage.page().a(14, defaultUser2 -> {
|
||||
defaultUser.quickJoin(this.getSessions().getGameSearcher());
|
||||
}, new ItemBuilder(ArcadeMaterial.ENDER_EYE).setDisplayName(this.getMessages().getJoinGuiQuickJoinName(), context).setLore(TextRenderer.render(this.getMessages().getJoinGuiQuickJoinLore(), context)).build());
|
||||
gameMenuPage.page().setSlot(14, defaultUser2 -> {
|
||||
Player player = defaultUser2.toPlayer();
|
||||
if (this.engine.getSettings().isPermissionOnMapSelector() && !player.hasPermission(this.id + ".map.selector")) {
|
||||
defaultUser2.sendMessage(this.getMessages().getMapSelectorNoPermission());
|
||||
player.closeInventory();
|
||||
} else {
|
||||
gameMenuPage.mapSelector().a(defaultUser2);
|
||||
gameMenuPage.mapSelector().open(defaultUser2);
|
||||
defaultUser2.setMenu(gameMenuPage.page());
|
||||
}
|
||||
}, new ItemBuilder(ArcadeMaterial.OAK_SIGN).setDisplayName(this.getMessages().getJoinGuiMapSelectorName(), context).setLore(TextRenderer.a(this.getMessages().getJoinGuiMapSelectorLore(), context)).build());
|
||||
gameMenuPage.page().a(31, defaultUser3 -> defaultUser3.toPlayer().closeInventory(), new ItemBuilder(Material.BARRIER).setDisplayName(this.getMessages().getJoinGuiClose()).build());
|
||||
}, new ItemBuilder(ArcadeMaterial.OAK_SIGN).setDisplayName(this.getMessages().getJoinGuiMapSelectorName(), context).setLore(TextRenderer.render(this.getMessages().getJoinGuiMapSelectorLore(), context)).build());
|
||||
gameMenuPage.page().setSlot(31, defaultUser3 -> defaultUser3.toPlayer().closeInventory(), new ItemBuilder(Material.BARRIER).setDisplayName(this.getMessages().getJoinGuiClose()).build());
|
||||
}
|
||||
|
||||
public void spawnNpcDisplay(Location location) {
|
||||
@@ -194,21 +194,21 @@ public abstract class AbstractGameManager implements GameManager, Context {
|
||||
npcDisplaySettings.setList(this.getMessages().getNpc());
|
||||
npcDisplaySettings.setContext(this);
|
||||
npcDisplaySettings.setLocation(location);
|
||||
npcDisplaySettings.a(this.getCommand().getCommand() + " gui");
|
||||
npcDisplaySettings.setCommand(this.getCommand().getCommand() + " gui");
|
||||
npcDisplaySettings.setSkinTexture(this.getSettings().getNpcSkin());
|
||||
npcDisplaySettings.setNpcEquipment(this.getSettings().getNpcEquipment());
|
||||
this.getEngine().getDisplayManager().a(npcDisplaySettings);
|
||||
this.getEngine().getDisplayManager().addNpcDisplay(npcDisplaySettings);
|
||||
}
|
||||
|
||||
protected void spawnNpcDisplays() {
|
||||
for (Location location : this.getStorage().getStorage2().getNpcs()) {
|
||||
for (Location location : this.getStorage().getNpcStorage().getNpcs()) {
|
||||
this.spawnNpcDisplay(location);
|
||||
}
|
||||
}
|
||||
|
||||
protected void despawnNpcDisplays() {
|
||||
for (Location location : this.getStorage().getStorage2().getNpcs()) {
|
||||
this.getEngine().getDisplayManager().b(location);
|
||||
for (Location location : this.getStorage().getNpcStorage().getNpcs()) {
|
||||
this.getEngine().getDisplayManager().removeNpcDisplay(location);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -216,53 +216,53 @@ public abstract class AbstractGameManager implements GameManager, Context {
|
||||
Session session = this.getSessions().getSession(text);
|
||||
if (session != null) {
|
||||
String text2 = this.getCommand().getCommand() + " join " + text;
|
||||
this.getEngine().getDisplayManager().a(block, text2, this.getMessages().getJoinSigns(), session);
|
||||
this.getEngine().getDisplayManager().addCommandSign(block, text2, this.getMessages().getJoinSigns(), session);
|
||||
}
|
||||
}
|
||||
|
||||
public void createQuickJoinSign(Block block) {
|
||||
String text = this.getCommand().getCommand() + " quickjoin";
|
||||
this.getEngine().getDisplayManager().a(block, text, this.getMessages().getQuickJoinSigns(), this);
|
||||
this.getEngine().getDisplayManager().addCommandSign(block, text, this.getMessages().getQuickJoinSigns(), this);
|
||||
}
|
||||
|
||||
protected void registerSigns() {
|
||||
this.getStorage().getStorage3().getSigns().forEach((text, gameSignSettings) -> this.createJoinSign(gameSignSettings.getBlock(), gameSignSettings.getId()));
|
||||
this.getStorage().getStorage3().getQuickJoinSigns().forEach(this::createQuickJoinSign);
|
||||
this.getStorage().getSignStorage().getSigns().forEach((text, gameSignSettings) -> this.createJoinSign(gameSignSettings.getBlock(), gameSignSettings.getId()));
|
||||
this.getStorage().getSignStorage().getQuickJoinSigns().forEach(this::createQuickJoinSign);
|
||||
}
|
||||
|
||||
protected void unregisterSigns() {
|
||||
this.getStorage().getStorage3().getSigns().forEach((text, gameSignSettings) -> this.getEngine().getDisplayManager().b(gameSignSettings.getBlock()));
|
||||
this.getStorage().getStorage3().getQuickJoinSigns().forEach(block -> this.getEngine().getDisplayManager().b(block));
|
||||
this.getStorage().getSignStorage().getSigns().forEach((text, gameSignSettings) -> this.getEngine().getDisplayManager().removeCommandSign(gameSignSettings.getBlock()));
|
||||
this.getStorage().getSignStorage().getQuickJoinSigns().forEach(block -> this.getEngine().getDisplayManager().removeCommandSign(block));
|
||||
}
|
||||
|
||||
public void registerLeaderboards() {
|
||||
for (Entry entry : this.getStorage().getStorage4().getLeaderboards().entrySet()) {
|
||||
for (Entry entry : this.getStorage().getLeaderboardStorage().getLeaderboards().entrySet()) {
|
||||
GameLeaderboardSettings gameLeaderboardSettings = (GameLeaderboardSettings)entry.getValue();
|
||||
if (this.getLeaderboardSources().containsKey(gameLeaderboardSettings.getColumn())) {
|
||||
LeaderboardSource leaderboardSource = this.createLeaderboardSource(gameLeaderboardSettings);
|
||||
this.getEngine().getDisplayManager().a(leaderboardSource);
|
||||
leaderboardSource.d();
|
||||
this.getEngine().getDisplayManager().registerLeaderboardSource(leaderboardSource);
|
||||
leaderboardSource.refreshCache();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public void unregisterLeaderboards() {
|
||||
for (Entry entry : this.getStorage().getStorage4().getLeaderboards().entrySet()) {
|
||||
this.getEngine().getDisplayManager().a((GameLeaderboardSettings)entry.getValue());
|
||||
for (Entry entry : this.getStorage().getLeaderboardStorage().getLeaderboards().entrySet()) {
|
||||
this.getEngine().getDisplayManager().unregisterLeaderboardSource((GameLeaderboardSettings)entry.getValue());
|
||||
}
|
||||
}
|
||||
|
||||
public void buildGameMenu() {
|
||||
InventoryMenu inventoryMenu = new InventoryMenu(this.getMessages().getJoinGuiName().a(this), 36);
|
||||
GameMenu gameMenu = new GameMenu(this, () -> new ArrayList(this.getSessions().f().values()));
|
||||
InventoryMenu inventoryMenu = new InventoryMenu(this.getMessages().getJoinGuiName().render(this), 36);
|
||||
GameMenu gameMenu = new GameMenu(this, () -> new ArrayList(this.getSessions().getSessions().values()));
|
||||
this.menuPage = new GameMenuPage(inventoryMenu, gameMenu);
|
||||
this.populateMenu(this.menuPage, this);
|
||||
}
|
||||
|
||||
protected void reloadConfig() {
|
||||
this.getStorage().getStorage2().b();
|
||||
this.getStorage().getStorage3().c();
|
||||
this.getStorage().getStorage4().b();
|
||||
this.getStorage().getNpcStorage().load();
|
||||
this.getStorage().getSignStorage().load();
|
||||
this.getStorage().getLeaderboardStorage().load();
|
||||
this.getConfigManager().tryLoad(this.getMessages(), new File(this.getDataFolder(), "messages.yml"));
|
||||
}
|
||||
|
||||
@@ -277,13 +277,13 @@ public abstract class AbstractGameManager implements GameManager, Context {
|
||||
}
|
||||
|
||||
public void start() {
|
||||
TemplateCallbackLoader.a(this.engine);
|
||||
TemplateCallbackLoader.load(this.engine);
|
||||
this.reloadConfig();
|
||||
VersionAdapters.get().registerCommand(this.engine.getPlugin(), this.engine.getPlatform(), this.getCommand(), this.engine.getSettings().isUseBrigadierCommands());
|
||||
|
||||
this.getStorage().e().b();
|
||||
this.engine.getUsers().a(this::loadPlayerData);
|
||||
this.getSessions().a();
|
||||
this.getStorage().getStatisticsRepository().createTables();
|
||||
this.engine.getUsers().forEachPlayer(this::loadPlayerData);
|
||||
this.getSessions().load();
|
||||
this.spawnNpcDisplays();
|
||||
this.registerSigns();
|
||||
this.buildGameMenu();
|
||||
@@ -292,14 +292,14 @@ public abstract class AbstractGameManager implements GameManager, Context {
|
||||
}
|
||||
|
||||
public void stop() {
|
||||
this.integrations.a();
|
||||
this.integrations.disableAll();
|
||||
this.unregisterSigns();
|
||||
this.despawnNpcDisplays();
|
||||
this.unregisterLeaderboards();
|
||||
this.getSessions().c();
|
||||
this.getSessions().unload();
|
||||
VersionAdapters.get().unregisterCommand(this.engine.getPlatform(), this.getCommand(), this.engine.getSettings().isUseBrigadierCommands());
|
||||
|
||||
this.engine.getUsers().a(player -> this.unloadPlayerData(player.getUniqueId()));
|
||||
this.engine.getUsers().forEachPlayer(player -> this.unloadPlayerData(player.getUniqueId()));
|
||||
}
|
||||
|
||||
public String getVariable(String text) {
|
||||
@@ -308,17 +308,17 @@ public abstract class AbstractGameManager implements GameManager, Context {
|
||||
case "month" -> String.valueOf(LocalDate.now().getMonthValue());
|
||||
case "year" -> String.valueOf(LocalDate.now().getYear());
|
||||
case "display_name" -> this.getMessages().getDisplayName();
|
||||
case "players" -> String.valueOf(this.getSessions().i());
|
||||
case "players" -> String.valueOf(this.getSessions().getTotalPlayers());
|
||||
case "version" -> this.getVersion();
|
||||
case "line" -> Strings.a;
|
||||
case "line" -> Strings.SEPARATOR_LINE;
|
||||
default -> null;
|
||||
};
|
||||
}
|
||||
|
||||
public void onTick(long longVal) {
|
||||
this.getSessions().a(longVal);
|
||||
this.getSessions().onTick(longVal);
|
||||
if (longVal % 20L == 0L) {
|
||||
this.menuPage.mapSelector().a();
|
||||
this.menuPage.mapSelector().update();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -326,7 +326,7 @@ public abstract class AbstractGameManager implements GameManager, Context {
|
||||
int index = 0;
|
||||
int index2 = 0;
|
||||
|
||||
for (Entry entry : this.getSessions().f().entrySet()) {
|
||||
for (Entry entry : this.getSessions().getSessions().entrySet()) {
|
||||
Session session = (Session)entry.getValue();
|
||||
if (text.equals((String)entry.getKey() + "_players")) {
|
||||
return String.valueOf(session.getStatus().players());
|
||||
|
||||
@@ -43,7 +43,7 @@ public abstract class BaseGameSettings implements Configuration {
|
||||
@Setting("leave-game-data")
|
||||
private int leaveGameData = VersionAdapters.get().getDefaultLeaveGameData();
|
||||
@Setting("commands-allowed")
|
||||
private List<String> commandsAllowed = Strings.a(new String[]{"start", "leave", "shout", "rejoin", "party", "par"});
|
||||
private List<String> commandsAllowed = Strings.colorizeLines(new String[]{"start", "leave", "shout", "rejoin", "party", "par"});
|
||||
|
||||
public int getWaitingTime() {
|
||||
return this.waitingTime;
|
||||
|
||||
+13
-13
@@ -16,7 +16,7 @@ import java.util.UUID;
|
||||
import ro.fr33styler.arcade.api.engine.game.GameManagerRegistry;
|
||||
|
||||
public class DefaultGameManagerRegistry implements Iterable<AbstractGameManager>, GameManagerRegistry {
|
||||
private boolean a;
|
||||
private boolean started;
|
||||
private final File file;
|
||||
private final DefaultEngine engine;
|
||||
private final DefaultSessionSearcher defaultSessionSearcher = new DefaultSessionSearcher(this);
|
||||
@@ -40,8 +40,8 @@ public class DefaultGameManagerRegistry implements Iterable<AbstractGameManager>
|
||||
return this.map;
|
||||
}
|
||||
|
||||
public void d() {
|
||||
this.a = true;
|
||||
public void start() {
|
||||
this.started = true;
|
||||
Iterator iterator = this.list.iterator();
|
||||
|
||||
while (iterator.hasNext()) {
|
||||
@@ -54,22 +54,22 @@ public class DefaultGameManagerRegistry implements Iterable<AbstractGameManager>
|
||||
}
|
||||
}
|
||||
|
||||
public void e() {
|
||||
public void stop() {
|
||||
for (AbstractGameManager abstractGameManager : this.list) {
|
||||
abstractGameManager.stop();
|
||||
}
|
||||
|
||||
this.a = false;
|
||||
this.started = false;
|
||||
}
|
||||
|
||||
public void a(long longVal) {
|
||||
public void onTick(long longVal) {
|
||||
for (AbstractGameManager abstractGameManager : this.list) {
|
||||
abstractGameManager.onTick(longVal);
|
||||
}
|
||||
|
||||
if (longVal % 20L == 0L) {
|
||||
this.map.forEach((uuid, sessionRequest) -> sessionRequest.a(sessionRequest.d() + 1));
|
||||
this.map.values().removeIf(sessionRequest2 -> sessionRequest2.d() >= this.engine.getSettings().getPurgeReservationsInSeconds());
|
||||
this.map.forEach((uuid, sessionRequest) -> sessionRequest.setElapsedSeconds(sessionRequest.getElapsedSeconds() + 1));
|
||||
this.map.values().removeIf(sessionRequest2 -> sessionRequest2.getElapsedSeconds() >= this.engine.getSettings().getPurgeReservationsInSeconds());
|
||||
}
|
||||
}
|
||||
|
||||
@@ -83,24 +83,24 @@ public class DefaultGameManagerRegistry implements Iterable<AbstractGameManager>
|
||||
return null;
|
||||
}
|
||||
|
||||
public void a(DefaultUser defaultUser) {
|
||||
public void rejoin(DefaultUser defaultUser) {
|
||||
AbstractGameManager abstractGameManager = null;
|
||||
|
||||
for (AbstractGameManager abstractGameManager2 : this) {
|
||||
if (abstractGameManager == null || abstractGameManager2.getSessions().e().containsKey(defaultUser.getUUID())) {
|
||||
if (abstractGameManager == null || abstractGameManager2.getSessions().getRejoinGames().containsKey(defaultUser.getUUID())) {
|
||||
abstractGameManager = abstractGameManager2;
|
||||
}
|
||||
}
|
||||
|
||||
if (abstractGameManager != null) {
|
||||
abstractGameManager.getSessions().a(defaultUser);
|
||||
abstractGameManager.getSessions().rejoin(defaultUser);
|
||||
}
|
||||
}
|
||||
|
||||
public void a(AbstractGameManager abstractGameManager) {
|
||||
public void register(AbstractGameManager abstractGameManager) {
|
||||
if (!this.engine.getSettings().getDisabled().contains(abstractGameManager.getId())) {
|
||||
this.list.add(abstractGameManager);
|
||||
if (this.a) {
|
||||
if (this.started) {
|
||||
abstractGameManager.start();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -13,7 +13,7 @@ public enum GameAction {
|
||||
BLOCK_PLACE,
|
||||
HEALTH_REGAIN;
|
||||
|
||||
private static final GameAction[] l = {
|
||||
private static final GameAction[] VALUES = {
|
||||
CLICK, DAMAGE, ATTACK, HUNGER, INTERACT, ENTITY_INTERACT,
|
||||
ITEM_DROP, ITEM_PICKUP, BLOCK_BREAK, BLOCK_PLACE, HEALTH_REGAIN
|
||||
};
|
||||
|
||||
+3
-3
@@ -15,7 +15,7 @@ public class DeleteGameCommand implements CommandExecutor {
|
||||
|
||||
public DeleteGameCommand(AbstractGameManager manager2) {
|
||||
this.manager = manager2;
|
||||
this.arguments = new DefaultArgumentSet(new Argument[]{new CollectionArgument("id", null, manager2.getSessions().d().keySet())});
|
||||
this.arguments = new DefaultArgumentSet(new Argument[]{new CollectionArgument("id", null, manager2.getSessions().getGames().keySet())});
|
||||
}
|
||||
|
||||
public ArgumentSet getArguments() {
|
||||
@@ -28,8 +28,8 @@ public class DeleteGameCommand implements CommandExecutor {
|
||||
|
||||
public void execute(CommandSender sender, String text, String[] texts, int index) {
|
||||
String text2 = texts[index];
|
||||
if (this.manager.getSessions().c(text2)) {
|
||||
this.manager.getStorage().getStorage().a(text2);
|
||||
if (this.manager.getSessions().unregisterGame(text2)) {
|
||||
this.manager.getStorage().getStorage().delete(text2);
|
||||
sender.sendMessage("§aThe game has been deleted!");
|
||||
}
|
||||
}
|
||||
|
||||
@@ -21,7 +21,7 @@ public class GameGuiCommand extends BaseCommandExecutor {
|
||||
public void execute(CommandSender sender, String text, String[] texts, int index) {
|
||||
DefaultUser defaultUser = (DefaultUser)this.manager.getEngine().getUsers().c((Player)sender);
|
||||
if (defaultUser != null) {
|
||||
defaultUser.a(this.manager.getMenuPage().page());
|
||||
defaultUser.openMenu(this.manager.getMenuPage().page());
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -20,7 +20,7 @@ public class JoinGameCommand implements CommandExecutor {
|
||||
|
||||
public JoinGameCommand(AbstractGameManager manager2) {
|
||||
this.manager = manager2;
|
||||
this.arguments = new DefaultArgumentSet(new Argument[] { new CollectionArgument("id", null, manager2.getSessions().f().keySet()) });
|
||||
this.arguments = new DefaultArgumentSet(new Argument[] { new CollectionArgument("id", null, manager2.getSessions().getSessions().keySet()) });
|
||||
}
|
||||
|
||||
public boolean isPlayerOnly() {
|
||||
|
||||
+1
-1
@@ -20,6 +20,6 @@ public class ListGamesAllCommand extends ListGamesCommand {
|
||||
}
|
||||
|
||||
public void execute(CommandSender sender, String text, String[] texts, int index) {
|
||||
this.a(sender, text, 1);
|
||||
this.sendList(sender, text, 1);
|
||||
}
|
||||
}
|
||||
+10
-10
@@ -16,25 +16,25 @@ public abstract class ListGamesCommand implements CommandExecutor {
|
||||
this.manager = manager2;
|
||||
}
|
||||
|
||||
protected void a(CommandSender sender, String text, int index) {
|
||||
protected void sendList(CommandSender sender, String text, int index) {
|
||||
int index2 = (index - 1) * 8;
|
||||
if (index >= 1 && index2 <= this.manager.getSessions().f().size()) {
|
||||
if (index >= 1 && index2 <= this.manager.getSessions().getSessions().size()) {
|
||||
sender.sendMessage("§8[§3" + this.manager.getName() + "§8] §7- §dList");
|
||||
ArrayList list = this.a();
|
||||
ArrayList list = this.getSortedSessions();
|
||||
int index3 = Math.min(index2 + 8, list.size());
|
||||
|
||||
for (int index4 = index2; index4 < index3; index4++) {
|
||||
sender.sendMessage(this.a((Entry<String, Session>)list.get(index4)));
|
||||
sender.sendMessage(this.formatSessionEntry((Entry<String, Session>)list.get(index4)));
|
||||
}
|
||||
|
||||
this.a(sender, index, text);
|
||||
this.sendPageFooter(sender, index, text);
|
||||
} else {
|
||||
sender.sendMessage("§cThe page doesn't exists!");
|
||||
}
|
||||
}
|
||||
|
||||
private ArrayList<Entry<String, Session>> a() {
|
||||
ArrayList<Entry<String, Session>> list = new ArrayList<>(this.manager.getSessions().f().entrySet());
|
||||
private ArrayList<Entry<String, Session>> getSortedSessions() {
|
||||
ArrayList<Entry<String, Session>> list = new ArrayList<>(this.manager.getSessions().getSessions().entrySet());
|
||||
list.sort((entry, entry2) -> {
|
||||
int index = ((Session)entry.getValue()).getStatus().players();
|
||||
int index2 = ((Session)entry2.getValue()).getStatus().players();
|
||||
@@ -44,15 +44,15 @@ public abstract class ListGamesCommand implements CommandExecutor {
|
||||
return list;
|
||||
}
|
||||
|
||||
private String a(Entry<String, Session> entry) {
|
||||
private String formatSessionEntry(Entry<String, Session> entry) {
|
||||
Status status = ((Session)entry.getValue()).getStatus();
|
||||
return status.players() > 0
|
||||
? " - §c" + (String)entry.getKey() + " §8(§d" + status.players() + "§8)§f: §b" + String.join("§7, §b", status.playersNames())
|
||||
: " - §c" + (String)entry.getKey() + " §8(§d" + status.players() + "§8)§f: §bNone";
|
||||
}
|
||||
|
||||
private void a(CommandSender sender, int index, String text) {
|
||||
int index2 = Math.max(1, (this.manager.getSessions().f().size() + 8 - 1) / 8);
|
||||
private void sendPageFooter(CommandSender sender, int index, String text) {
|
||||
int index2 = Math.max(1, (this.manager.getSessions().getSessions().size() + 8 - 1) / 8);
|
||||
if (index2 > 1) {
|
||||
sender.sendMessage("§3Page " + index + " out of " + index2 + ". Use §7/§c" + text + " list §8<§bpage§8>§3 to change pages!");
|
||||
}
|
||||
|
||||
+1
-1
@@ -25,6 +25,6 @@ public class ListGamesPageCommand extends ListGamesCommand {
|
||||
|
||||
public void execute(CommandSender sender, String text, String[] texts, int index) {
|
||||
int index2 = Integer.parseInt(texts[index]);
|
||||
this.a(sender, text, index2);
|
||||
this.sendList(sender, text, index2);
|
||||
}
|
||||
}
|
||||
+1
-1
@@ -25,7 +25,7 @@ public class MapSelectorCommand extends BaseCommandExecutor {
|
||||
public void execute(CommandSender sender, String text, String[] texts, int index) {
|
||||
DefaultUser defaultUser = (DefaultUser) this.manager.getEngine().getUsers().c((Player) sender);
|
||||
if (defaultUser != null) {
|
||||
this.manager.getMenuPage().mapSelector().a(defaultUser);
|
||||
this.manager.getMenuPage().mapSelector().open(defaultUser);
|
||||
}
|
||||
}
|
||||
}
|
||||
+1
-1
@@ -25,7 +25,7 @@ public class QuickJoinGameCommand extends BaseCommandExecutor {
|
||||
public void execute(CommandSender sender, String text, String[] texts, int index) {
|
||||
DefaultUser defaultUser = (DefaultUser) this.manager.getEngine().getUsers().c((Player) sender);
|
||||
if (defaultUser != null) {
|
||||
defaultUser.a(this.manager.getSessions().getGameSearcher());
|
||||
defaultUser.quickJoin(this.manager.getSessions().getGameSearcher());
|
||||
}
|
||||
}
|
||||
}
|
||||
+1
-1
@@ -25,7 +25,7 @@ public class RejoinGameCommand extends BaseCommandExecutor {
|
||||
public void execute(CommandSender sender, String text, String[] texts, int index) {
|
||||
DefaultUser defaultUser = (DefaultUser) this.manager.getEngine().getUsers().c((Player) sender);
|
||||
if (defaultUser != null) {
|
||||
this.manager.getSessions().a(defaultUser);
|
||||
this.manager.getSessions().rejoin(defaultUser);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -16,7 +16,7 @@ public class StartGameCommand implements CommandExecutor {
|
||||
|
||||
public StartGameCommand(AbstractGameManager manager2) {
|
||||
this.manager = manager2;
|
||||
this.arguments = new DefaultArgumentSet(new Argument[]{new CollectionArgument("id", null, manager2.getSessions().d().keySet())});
|
||||
this.arguments = new DefaultArgumentSet(new Argument[]{new CollectionArgument("id", null, manager2.getSessions().getGames().keySet())});
|
||||
}
|
||||
|
||||
public ArgumentSet getArguments() {
|
||||
@@ -29,6 +29,6 @@ public class StartGameCommand implements CommandExecutor {
|
||||
|
||||
public void execute(CommandSender sender, String text, String[] texts, int index) {
|
||||
String text2 = texts[index];
|
||||
((AbstractGame)this.manager.getSessions().d().get(text2)).handleStartCommand(sender);
|
||||
((AbstractGame)this.manager.getSessions().getGames().get(text2)).handleStartCommand(sender);
|
||||
}
|
||||
}
|
||||
@@ -16,7 +16,7 @@ public class StopGameCommand implements CommandExecutor {
|
||||
|
||||
public StopGameCommand(AbstractGameManager manager2) {
|
||||
this.manager = manager2;
|
||||
this.arguments = new DefaultArgumentSet(new Argument[]{new CollectionArgument("id", null, manager2.getSessions().d().keySet())});
|
||||
this.arguments = new DefaultArgumentSet(new Argument[]{new CollectionArgument("id", null, manager2.getSessions().getGames().keySet())});
|
||||
}
|
||||
|
||||
public ArgumentSet getArguments() {
|
||||
@@ -29,6 +29,6 @@ public class StopGameCommand implements CommandExecutor {
|
||||
|
||||
public void execute(CommandSender sender, String text, String[] texts, int index) {
|
||||
String text2 = texts[index];
|
||||
((AbstractGame)this.manager.getSessions().d().get(text2)).handleStopCommand(sender);
|
||||
((AbstractGame)this.manager.getSessions().getGames().get(text2)).handleStopCommand(sender);
|
||||
}
|
||||
}
|
||||
+56
-56
@@ -11,113 +11,113 @@ import ro.fr33styler.arcade.api.engine.config.serialize.Configuration;
|
||||
|
||||
public abstract class BaseGameMessages implements Configuration {
|
||||
@Setting("game-start-countdown")
|
||||
private Text gameStartCountdown = TextParser.a("&eThe game starts in &c%countdown_formatted%&e seconds.");
|
||||
private Text gameStartCountdown = TextParser.parse("&eThe game starts in &c%countdown_formatted%&e seconds.");
|
||||
@Setting("game-start-actionbar")
|
||||
public Text gameStartActionbar = TextParser.a("%countdown_formatted%");
|
||||
public Text gameStartActionbar = TextParser.parse("%countdown_formatted%");
|
||||
@Setting("game-start-cancelled")
|
||||
private String gameStartCancelled = Strings.a("&cWe don't have enough players! Start cancelled.");
|
||||
private String gameStartCancelled = Strings.colorize("&cWe don't have enough players! Start cancelled.");
|
||||
@Setting("game-player-prefix")
|
||||
private String gamePlayerPrefix = Strings.a("");
|
||||
private String gamePlayerPrefix = Strings.colorize("");
|
||||
@Setting("game-phase-waiting")
|
||||
private String gamePhaseWaiting = Strings.a("WAITING");
|
||||
private String gamePhaseWaiting = Strings.colorize("WAITING");
|
||||
@Setting("game-phase-playing")
|
||||
private String gamePhasePlaying = Strings.a("PLAYING");
|
||||
private String gamePhasePlaying = Strings.colorize("PLAYING");
|
||||
@Setting("game-phase-ending")
|
||||
private String gamePhaseEnding = Strings.a("ENDING");
|
||||
private String gamePhaseEnding = Strings.colorize("ENDING");
|
||||
@Setting("game-phase-resetting")
|
||||
private String gamePhaseResetting = Strings.a("RESETTING");
|
||||
private String gamePhaseResetting = Strings.colorize("RESETTING");
|
||||
@Setting("game-broadcast-join")
|
||||
private Text gameBroadcastJoin = TextParser.a("&7%player%&e has joined. (&b%players%&e/&b%max_players%&e)");
|
||||
private Text gameBroadcastJoin = TextParser.parse("&7%player%&e has joined. (&b%players%&e/&b%max_players%&e)");
|
||||
@Setting("game-broadcast-leave")
|
||||
private Text gameBroadcastLeave = TextParser.a("&7%player%&e has quit.");
|
||||
private Text gameBroadcastLeave = TextParser.parse("&7%player%&e has quit.");
|
||||
@Setting("auto-join-send-to-server")
|
||||
private Text autoJoinSendToServer = TextParser.a("&aSending you to %id%@%server_name%");
|
||||
private Text autoJoinSendToServer = TextParser.parse("&aSending you to %id%@%server_name%");
|
||||
@Setting("map-selector-no-permission")
|
||||
private String mapSelectorNoPermission = Strings.a("&cYou do not have permission to view the map selector!");
|
||||
private String mapSelectorNoPermission = Strings.colorize("&cYou do not have permission to view the map selector!");
|
||||
@Setting("join-arenas-name")
|
||||
private String joinArenasName = Strings.a("Arenas");
|
||||
private String joinArenasName = Strings.colorize("Arenas");
|
||||
@Setting("join-arenas-page-name")
|
||||
private Text joinArenasPageName = TextParser.a("Arenas (Page %page%)");
|
||||
private Text joinArenasPageName = TextParser.parse("Arenas (Page %page%)");
|
||||
@Setting("join-arenas-change-page-name")
|
||||
private Text joinArenasChangePageName = TextParser.a("Arenas (Page %page%)");
|
||||
private Text joinArenasChangePageName = TextParser.parse("Arenas (Page %page%)");
|
||||
@Setting("join-arenas-go-back")
|
||||
private String joinArenasGoBack = Strings.a("&aGo back");
|
||||
private String joinArenasGoBack = Strings.colorize("&aGo back");
|
||||
@Setting("join-arenas-arena-name")
|
||||
private Text joinArenasArenaName = TextParser.a("&a%name%");
|
||||
private Text joinArenasArenaName = TextParser.parse("&a%name%");
|
||||
@Setting("join-arenas-arena-lore")
|
||||
private List<Text> joinArenasArenaLore = TextParser.a(new String[]{"&8%mode%", " ", "&e%players%&7/&e%maximum%", "&aClick to join!"});
|
||||
private List<Text> joinArenasArenaLore = TextParser.parseAll(new String[]{"&8%mode%", " ", "&e%players%&7/&e%maximum%", "&aClick to join!"});
|
||||
@Setting("spectator-teleporter-name")
|
||||
private String spectatorTeleporterName = Strings.a("Teleporter");
|
||||
private String spectatorTeleporterName = Strings.colorize("Teleporter");
|
||||
@Setting("spectator-teleporter-page-name")
|
||||
private Text spectatorTeleporterPageName = TextParser.a("Teleporter (Page %page%)");
|
||||
private Text spectatorTeleporterPageName = TextParser.parse("Teleporter (Page %page%)");
|
||||
@Setting("spectator-teleporter-change-page-name")
|
||||
private Text spectatorTeleporterChangePageName = TextParser.a("Teleporter (Page %page%)");
|
||||
private Text spectatorTeleporterChangePageName = TextParser.parse("Teleporter (Page %page%)");
|
||||
@Setting("spectator-target-name")
|
||||
private Text spectatorTargetName = TextParser.a("&7%player%");
|
||||
private Text spectatorTargetName = TextParser.parse("&7%player%");
|
||||
@Setting("spectator-target-lore")
|
||||
protected List<Text> spectatorTargetLore = new ArrayList<>(List.of(TextParser.a("&7Left-click to spectate")));
|
||||
protected List<Text> spectatorTargetLore = new ArrayList<>(List.of(TextParser.parse("&7Left-click to spectate")));
|
||||
@Setting("spectator-target")
|
||||
private Text spectatorTarget = TextParser.a("Target: &a&l%player% &aLEFT CLICK for menu &cSNEAK to exit");
|
||||
private Text spectatorTarget = TextParser.parse("Target: &a&l%player% &aLEFT CLICK for menu &cSNEAK to exit");
|
||||
@Setting("spectator-target-first-person")
|
||||
private Text spectatorTargetFirstPerson = TextParser.a("Target: &a&l%player% &fDistance: &a&l%distance%");
|
||||
private Text spectatorTargetFirstPerson = TextParser.parse("Target: &a&l%player% &fDistance: &a&l%distance%");
|
||||
@Setting("spectator-spectate-exit-title")
|
||||
private String spectatorSpectateExitTitle = Strings.a("&eExiting Spectator mode");
|
||||
private String spectatorSpectateExitTitle = Strings.colorize("&eExiting Spectator mode");
|
||||
@Setting("spectator-spectate-title")
|
||||
private Text spectatorSpectateTitle = TextParser.a("&aSpectating &b%player%");
|
||||
private Text spectatorSpectateTitle = TextParser.parse("&aSpectating &b%player%");
|
||||
@Setting("spectator-spectate-subtitle")
|
||||
private Text spectatorSpectateSubtitle = TextParser.a("&aLEFT CLICK for menu &cSNEAK to exit");
|
||||
private Text spectatorSpectateSubtitle = TextParser.parse("&aLEFT CLICK for menu &cSNEAK to exit");
|
||||
@Setting("statistics-not-found")
|
||||
private String statisticsNotFound = Strings.a("&cPlayer statistics not found!");
|
||||
private String statisticsNotFound = Strings.colorize("&cPlayer statistics not found!");
|
||||
@Setting("statistics-view")
|
||||
protected List<Text> statisticsView = TextParser.a(
|
||||
protected List<Text> statisticsView = TextParser.parseAll(
|
||||
new String[]{" ", " &l%display_name% Statistics", " ", " Wins&a: %wins%", " Loses&a: %loses%", " Played&a: %played%", " "}
|
||||
);
|
||||
@Setting("join-already-in-game")
|
||||
private String joinAlreadyInGame = Strings.a("&cYou're already in a game!");
|
||||
private String joinAlreadyInGame = Strings.colorize("&cYou're already in a game!");
|
||||
@Setting("join-game-is-private")
|
||||
private String joinGameIsPrivate = Strings.a("&cThis game is private!");
|
||||
private String joinGameIsPrivate = Strings.colorize("&cThis game is private!");
|
||||
@Setting("join-is-full")
|
||||
private String joinIsFull = Strings.a("&cThe game is full!");
|
||||
private String joinIsFull = Strings.colorize("&cThe game is full!");
|
||||
@Setting("join-is-started")
|
||||
private String joinIsStarted = Strings.a("&cThe game is already started!");
|
||||
private String joinIsStarted = Strings.colorize("&cThe game is already started!");
|
||||
@Setting("join-is-not-started")
|
||||
private String joinIsNotStarted = Strings.a("&cThe game must be started!");
|
||||
private String joinIsNotStarted = Strings.colorize("&cThe game must be started!");
|
||||
@Setting("join-not-found")
|
||||
private String joinNotFound = Strings.a("&cGame not found!");
|
||||
private String joinNotFound = Strings.colorize("&cGame not found!");
|
||||
@Setting("join-gui-name")
|
||||
private Text joinGuiName = TextParser.a("Play %display_name%");
|
||||
private Text joinGuiName = TextParser.parse("Play %display_name%");
|
||||
@Setting("join-gui-quick-join-name")
|
||||
private Text joinGuiQuickJoinName = TextParser.a("&a%display_name%");
|
||||
private Text joinGuiQuickJoinName = TextParser.parse("&a%display_name%");
|
||||
@Setting("join-gui-quick-join-lore")
|
||||
private List<Text> joinGuiQuickJoinLore = TextParser.a(new String[]{"&7Play a game of %display_name%.", " ", "&eClick to play!"});
|
||||
private List<Text> joinGuiQuickJoinLore = TextParser.parseAll(new String[]{"&7Play a game of %display_name%.", " ", "&eClick to play!"});
|
||||
@Setting("join-gui-map-selector-name")
|
||||
private Text joinGuiMapSelectorName = TextParser.a("&aMap Selector (%display_name%)");
|
||||
private Text joinGuiMapSelectorName = TextParser.parse("&aMap Selector (%display_name%)");
|
||||
@Setting("join-gui-map-selector-lore")
|
||||
private List<Text> joinGuiMapSelectorLore = TextParser.a(new String[]{"&7Pick which map you want to play from", "&7a list of available games.", " ", "&eClick to browse!"});
|
||||
private List<Text> joinGuiMapSelectorLore = TextParser.parseAll(new String[]{"&7Pick which map you want to play from", "&7a list of available games.", " ", "&eClick to browse!"});
|
||||
@Setting("join-gui-close")
|
||||
private String joinGuiClose = Strings.a("&cClose");
|
||||
private String joinGuiClose = Strings.colorize("&cClose");
|
||||
@Setting("join-gui-rejoin-name")
|
||||
private String joinGuiRejoinName = Strings.a("&cClick here to rejoin!");
|
||||
private String joinGuiRejoinName = Strings.colorize("&cClick here to rejoin!");
|
||||
@Setting("join-gui-rejoin-lore")
|
||||
private List<String> joinGuiRejoinLore = Strings.a(new String[]{"&7Click here to rejoin your game if", "&7you have been disconnected from it."});
|
||||
private List<String> joinGuiRejoinLore = Strings.colorizeLines(new String[]{"&7Click here to rejoin your game if", "&7you have been disconnected from it."});
|
||||
@Setting("item-settings")
|
||||
private String itemSettings = Strings.a("&a&lTeleporter &7(Right Click)");
|
||||
private String itemSettings = Strings.colorize("&a&lTeleporter &7(Right Click)");
|
||||
@Setting("item-spectator-settings")
|
||||
private String itemSpectatorSettings = Strings.a("&b&lSpectator Settings &7(Right Click)");
|
||||
private String itemSpectatorSettings = Strings.colorize("&b&lSpectator Settings &7(Right Click)");
|
||||
@Setting("item-play-again")
|
||||
private String itemPlayAgain = Strings.a("&b&lPlay Again &7(Right Click)");
|
||||
private String itemPlayAgain = Strings.colorize("&b&lPlay Again &7(Right Click)");
|
||||
@Setting("item-leave")
|
||||
private String itemLeave = Strings.a("&c&lReturn to Lobby &7(Right Click)");
|
||||
private String itemLeave = Strings.colorize("&c&lReturn to Lobby &7(Right Click)");
|
||||
@Setting("rejoin")
|
||||
private String rejoin = Strings.a("&cNo game to rejoin. This usually happens when the last game you played has already ended and is nothing to worry about.");
|
||||
private String rejoin = Strings.colorize("&cNo game to rejoin. This usually happens when the last game you played has already ended and is nothing to worry about.");
|
||||
@Setting("chat-in-game")
|
||||
protected Text chatInGame = TextParser.a("&7%player%&f: %message%");
|
||||
protected Text chatInGame = TextParser.parse("&7%player%&f: %message%");
|
||||
@Setting("chat-in-game-spectator")
|
||||
private Text chatInGameSpectator = TextParser.a("&6[SPECTATOR] &7%player%&f: %message%");
|
||||
private Text chatInGameSpectator = TextParser.parse("&6[SPECTATOR] &7%player%&f: %message%");
|
||||
@Setting("sidebar-waiting-title")
|
||||
private Text sidebarWaitingTitle = TextParser.a("&e&l%display_name%");
|
||||
private Text sidebarWaitingTitle = TextParser.parse("&e&l%display_name%");
|
||||
@Setting("sidebar-waiting")
|
||||
protected List<Text> sidebarWaiting = TextParser.a(
|
||||
protected List<Text> sidebarWaiting = TextParser.parseAll(
|
||||
new String[]{
|
||||
"&7%month%/%day%/%year% &8%id%",
|
||||
" ",
|
||||
@@ -132,11 +132,11 @@ public abstract class BaseGameMessages implements Configuration {
|
||||
}
|
||||
);
|
||||
@Setting("npc")
|
||||
private List<Text> npc = TextParser.a(new String[]{"&e&lCLICK TO PLAY", "&b%display_name%", "&e&l%players% Players"});
|
||||
private List<Text> npc = TextParser.parseAll(new String[]{"&e&lCLICK TO PLAY", "&b%display_name%", "&e&l%players% Players"});
|
||||
@Setting("join-signs")
|
||||
private List<Text> joinSigns = TextParser.a(new String[]{"&2&l%display_name%", "%name%", "&5• &f&l%phase% &5•", "&c»&e&l%players%/%maximum%&c«"});
|
||||
private List<Text> joinSigns = TextParser.parseAll(new String[]{"&2&l%display_name%", "%name%", "&5• &f&l%phase% &5•", "&c»&e&l%players%/%maximum%&c«"});
|
||||
@Setting("quick-join-signs")
|
||||
private List<Text> quickJoinSigns = TextParser.a(new String[]{"&2&l%display_name%", "Quick Join", "&e&l%players% Players"});
|
||||
private List<Text> quickJoinSigns = TextParser.parseAll(new String[]{"&2&l%display_name%", "Quick Join", "&e&l%players% Players"});
|
||||
|
||||
public abstract String getDisplayName();
|
||||
|
||||
|
||||
+27
-27
@@ -34,16 +34,16 @@ public class GameActionListener implements Listener {
|
||||
public void registerExtraListeners() {
|
||||
VersionAdapters.get().registerExtraActionListeners(
|
||||
this.engine.getPlugin(),
|
||||
entity -> this.a(entity, GameAction.ITEM_PICKUP),
|
||||
player -> this.a(player, GameAction.ITEM_PICKUP),
|
||||
player -> this.a(player, GameAction.CLICK)
|
||||
entity -> this.isActionBlocked(entity, GameAction.ITEM_PICKUP),
|
||||
player -> this.isActionBlocked(player, GameAction.ITEM_PICKUP),
|
||||
player -> this.isActionBlocked(player, GameAction.CLICK)
|
||||
);
|
||||
}
|
||||
|
||||
@EventHandler
|
||||
public void a(EntityDamageEvent event) {
|
||||
public void onEntityDamage(EntityDamageEvent event) {
|
||||
Entity entity = event.getEntity();
|
||||
if (this.a(entity, GameAction.DAMAGE)) {
|
||||
if (this.isActionBlocked(entity, GameAction.DAMAGE)) {
|
||||
event.setCancelled(true);
|
||||
entity.setFireTicks(0);
|
||||
}
|
||||
@@ -55,85 +55,85 @@ public class GameActionListener implements Listener {
|
||||
}
|
||||
|
||||
@EventHandler
|
||||
public void a(EntityDamageByEntityEvent event) {
|
||||
public void onEntityDamageByEntity(EntityDamageByEntityEvent event) {
|
||||
Entity entity = event.getDamager();
|
||||
if (entity instanceof Projectile var3 && var3.getShooter() instanceof Entity var4) {
|
||||
entity = var4;
|
||||
}
|
||||
|
||||
if (this.a(entity, GameAction.ATTACK)) {
|
||||
if (this.isActionBlocked(entity, GameAction.ATTACK)) {
|
||||
event.setCancelled(true);
|
||||
}
|
||||
}
|
||||
|
||||
@EventHandler
|
||||
public void a(EntityRegainHealthEvent event) {
|
||||
if (this.a(event.getEntity(), GameAction.HEALTH_REGAIN)) {
|
||||
public void onEntityRegainHealth(EntityRegainHealthEvent event) {
|
||||
if (this.isActionBlocked(event.getEntity(), GameAction.HEALTH_REGAIN)) {
|
||||
event.setCancelled(true);
|
||||
}
|
||||
}
|
||||
|
||||
@EventHandler
|
||||
public void a(PlayerDropItemEvent event) {
|
||||
if (this.a(event.getPlayer(), GameAction.ITEM_DROP)) {
|
||||
public void onPlayerDropItem(PlayerDropItemEvent event) {
|
||||
if (this.isActionBlocked(event.getPlayer(), GameAction.ITEM_DROP)) {
|
||||
event.setCancelled(true);
|
||||
}
|
||||
}
|
||||
|
||||
@EventHandler
|
||||
public void a(FoodLevelChangeEvent event) {
|
||||
if (this.a(event.getEntity(), GameAction.HUNGER)) {
|
||||
public void onFoodLevelChange(FoodLevelChangeEvent event) {
|
||||
if (this.isActionBlocked(event.getEntity(), GameAction.HUNGER)) {
|
||||
event.setCancelled(true);
|
||||
}
|
||||
}
|
||||
|
||||
@EventHandler
|
||||
public void a(BlockPlaceEvent event) {
|
||||
if (this.a(event.getPlayer(), GameAction.BLOCK_PLACE)) {
|
||||
public void onBlockPlace(BlockPlaceEvent event) {
|
||||
if (this.isActionBlocked(event.getPlayer(), GameAction.BLOCK_PLACE)) {
|
||||
event.setCancelled(true);
|
||||
}
|
||||
}
|
||||
|
||||
@EventHandler
|
||||
public void a(BlockBreakEvent event) {
|
||||
if (this.a(event.getPlayer(), GameAction.BLOCK_BREAK)) {
|
||||
public void onBlockBreak(BlockBreakEvent event) {
|
||||
if (this.isActionBlocked(event.getPlayer(), GameAction.BLOCK_BREAK)) {
|
||||
event.setCancelled(true);
|
||||
}
|
||||
}
|
||||
|
||||
@EventHandler
|
||||
public void a(PlayerInteractEvent event) {
|
||||
if (this.a(event.getPlayer(), GameAction.INTERACT)) {
|
||||
public void onPlayerInteract(PlayerInteractEvent event) {
|
||||
if (this.isActionBlocked(event.getPlayer(), GameAction.INTERACT)) {
|
||||
event.setCancelled(true);
|
||||
}
|
||||
}
|
||||
|
||||
@EventHandler
|
||||
public void a(PlayerInteractEntityEvent event) {
|
||||
if (this.a(event.getPlayer(), GameAction.ENTITY_INTERACT) && event.getRightClicked().getType() != EntityType.PLAYER) {
|
||||
public void onPlayerInteractEntity(PlayerInteractEntityEvent event) {
|
||||
if (this.isActionBlocked(event.getPlayer(), GameAction.ENTITY_INTERACT) && event.getRightClicked().getType() != EntityType.PLAYER) {
|
||||
event.setCancelled(true);
|
||||
}
|
||||
}
|
||||
|
||||
@EventHandler
|
||||
public void a(PlayerInteractAtEntityEvent event) {
|
||||
if (this.a(event.getPlayer(), GameAction.ENTITY_INTERACT)) {
|
||||
public void onPlayerInteractAtEntity(PlayerInteractAtEntityEvent event) {
|
||||
if (this.isActionBlocked(event.getPlayer(), GameAction.ENTITY_INTERACT)) {
|
||||
event.setCancelled(true);
|
||||
}
|
||||
}
|
||||
|
||||
@EventHandler
|
||||
public void a(InventoryClickEvent event) {
|
||||
if (this.a(event.getWhoClicked(), GameAction.CLICK)) {
|
||||
public void onInventoryClick(InventoryClickEvent event) {
|
||||
if (this.isActionBlocked(event.getWhoClicked(), GameAction.CLICK)) {
|
||||
event.setCancelled(true);
|
||||
}
|
||||
}
|
||||
|
||||
public boolean a(Entity entity, GameAction gameAction) {
|
||||
public boolean isActionBlocked(Entity entity, GameAction gameAction) {
|
||||
DefaultUser defaultUser = (DefaultUser)this.engine.getUsers().a(entity.getUniqueId());
|
||||
if (defaultUser != null && defaultUser.isInGame() && defaultUser.getGamer() instanceof BaseGamer var4) {
|
||||
AbstractGame abstractGame = var4.getGame();
|
||||
return !var4.f() && abstractGame.getPhase() == abstractGame.getPhaseLifecycle().getPlaying() ? abstractGame instanceof GameEventHandler var6 && var6.getBlockedActions().contains(gameAction) : true;
|
||||
return !var4.isSpectator() && abstractGame.getPhase() == abstractGame.getPhaseLifecycle().getPlaying() ? abstractGame instanceof GameEventHandler var6 && var6.getBlockedActions().contains(gameAction) : true;
|
||||
} else {
|
||||
return false;
|
||||
}
|
||||
|
||||
@@ -39,7 +39,7 @@ public class GameListener implements Listener {
|
||||
this.manager = manager2;
|
||||
}
|
||||
|
||||
protected <T extends BaseGamer> T a(Entity entity, Class<T> clazz) {
|
||||
protected <T extends BaseGamer> T getActiveGamer(Entity entity, Class<T> clazz) {
|
||||
DefaultUser defaultUser = (DefaultUser)this.manager.getEngine().getUsers().a(entity);
|
||||
if (defaultUser != null && defaultUser.isInGame()) {
|
||||
Game game = defaultUser.getGame();
|
||||
@@ -55,46 +55,46 @@ public class GameListener implements Listener {
|
||||
}
|
||||
|
||||
@EventHandler
|
||||
public void a(PlayerJoinEvent event) {
|
||||
public void onPlayerJoin(PlayerJoinEvent event) {
|
||||
this.manager.loadPlayerData(event.getPlayer());
|
||||
}
|
||||
|
||||
@EventHandler(priority = EventPriority.HIGHEST)
|
||||
public void a(PlayerQuitEvent event) {
|
||||
public void onPlayerQuit(PlayerQuitEvent event) {
|
||||
this.manager.unloadPlayerData(event.getPlayer().getUniqueId());
|
||||
}
|
||||
|
||||
@EventHandler
|
||||
public void a(GameJoinEvent event) {
|
||||
public void onGameJoin(GameJoinEvent event) {
|
||||
Game game = event.getGame();
|
||||
if (game.getManager() == this.manager && event.getGamer() instanceof BaseGamer var3) {
|
||||
if (game.getPhase() instanceof CountdownPhase var6) {
|
||||
var6.a(var3);
|
||||
var6.onJoin(var3);
|
||||
}
|
||||
|
||||
BaseGameStatistics baseGameStatistics = this.manager.getData(var3.getUUID());
|
||||
if (baseGameStatistics != null && baseGameStatistics.a()) {
|
||||
var3.a(baseGameStatistics.getMap());
|
||||
if (baseGameStatistics != null && baseGameStatistics.isLoaded()) {
|
||||
var3.loadProperties(baseGameStatistics.getMap());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@EventHandler
|
||||
public void a(GameLeaveEvent event) {
|
||||
public void onGameLeave(GameLeaveEvent event) {
|
||||
Game game = event.getGame();
|
||||
if (game.getManager() == this.manager && event.getGamer() instanceof BaseGamer var3 && game.getPhase() instanceof CountdownPhase var4) {
|
||||
var4.b(var3);
|
||||
var4.onLeave(var3);
|
||||
}
|
||||
}
|
||||
|
||||
@EventHandler
|
||||
public void a(PlayerInteractAtEntityEvent event) {
|
||||
public void onPlayerInteractAtEntity(PlayerInteractAtEntityEvent event) {
|
||||
Player player = event.getPlayer();
|
||||
BaseGamer baseGamer = this.a(player, BaseGamer.class);
|
||||
if (baseGamer != null && baseGamer.g()) {
|
||||
BaseGamer baseGamer = this.getActiveGamer(player, BaseGamer.class);
|
||||
if (baseGamer != null && baseGamer.isActiveSpectator()) {
|
||||
AbstractGame abstractGame = baseGamer.getGame();
|
||||
BaseGamer baseGamer2 = (BaseGamer)abstractGame.getGamers().a(event.getRightClicked());
|
||||
if (baseGamer2 != null && !baseGamer2.f()) {
|
||||
if (baseGamer2 != null && !baseGamer2.isSpectator()) {
|
||||
baseGamer.getSpectatorOptions().setPlayer(baseGamer2.toPlayer());
|
||||
player.setGameMode(GameMode.SPECTATOR);
|
||||
player.setSpectatorTarget(baseGamer2.toPlayer());
|
||||
@@ -103,10 +103,10 @@ public class GameListener implements Listener {
|
||||
}
|
||||
|
||||
@EventHandler
|
||||
public void a(PlayerToggleSneakEvent event) {
|
||||
public void onPlayerToggleSneak(PlayerToggleSneakEvent event) {
|
||||
Player player = event.getPlayer();
|
||||
BaseGamer baseGamer = this.a(player, BaseGamer.class);
|
||||
if (baseGamer != null && event.isSneaking() && player.getSpectatorTarget() != null && baseGamer.f()) {
|
||||
BaseGamer baseGamer = this.getActiveGamer(player, BaseGamer.class);
|
||||
if (baseGamer != null && event.isSneaking() && player.getSpectatorTarget() != null && baseGamer.isSpectator()) {
|
||||
player.setGameMode(GameMode.SURVIVAL);
|
||||
player.setAllowFlight(true);
|
||||
player.setFlying(true);
|
||||
@@ -115,9 +115,9 @@ public class GameListener implements Listener {
|
||||
}
|
||||
|
||||
@EventHandler(priority = EventPriority.HIGH)
|
||||
public void a(AsyncPlayerChatEvent event) {
|
||||
public void onAsyncPlayerChat(AsyncPlayerChatEvent event) {
|
||||
Player player = event.getPlayer();
|
||||
BaseGamer baseGamer = this.a(player, BaseGamer.class);
|
||||
BaseGamer baseGamer = this.getActiveGamer(player, BaseGamer.class);
|
||||
if (baseGamer != null && baseGamer.getGame().getSettings().isChatPrivate() && !event.isCancelled()) {
|
||||
if (baseGamer.getGame().getPhase() != baseGamer.getGame().getPhaseLifecycle().getPlaying()) {
|
||||
return;
|
||||
@@ -126,27 +126,27 @@ public class GameListener implements Listener {
|
||||
event.setCancelled(true);
|
||||
Bukkit.getScheduler().runTask(this.manager.getEngine().getPlugin(), () -> {
|
||||
AbstractGame abstractGame = baseGamer.getGame();
|
||||
Context context = Contexts.a(baseGamer, var1xx -> var1xx.equals("message") ? event.getMessage() : null);
|
||||
if (baseGamer.g()) {
|
||||
String text = abstractGame.getMessages().getChatInGameSpectator().a(context);
|
||||
Context context = Contexts.withVariables(baseGamer, var1xx -> var1xx.equals("message") ? event.getMessage() : null);
|
||||
if (baseGamer.isActiveSpectator()) {
|
||||
String text = abstractGame.getMessages().getChatInGameSpectator().render(context);
|
||||
if (abstractGame.getEngine().hasPlaceholderResolver()) {
|
||||
text = abstractGame.getEngine().getPlaceholderResolver().a(player, text);
|
||||
text = abstractGame.getEngine().getPlaceholderResolver().resolve(player, text);
|
||||
}
|
||||
|
||||
for (BaseGamer baseGamer2 : abstractGame.getGamers()) {
|
||||
if (baseGamer2.g()) {
|
||||
if (baseGamer2.isActiveSpectator()) {
|
||||
baseGamer2.sendMessage(text);
|
||||
}
|
||||
}
|
||||
|
||||
Bukkit.getConsoleSender().sendMessage(text);
|
||||
} else {
|
||||
String text2 = abstractGame.getMessages().getChatInGame().a(context);
|
||||
String text2 = abstractGame.getMessages().getChatInGame().render(context);
|
||||
if (abstractGame.getEngine().hasPlaceholderResolver()) {
|
||||
text2 = abstractGame.getEngine().getPlaceholderResolver().a(player, text2);
|
||||
text2 = abstractGame.getEngine().getPlaceholderResolver().resolve(player, text2);
|
||||
}
|
||||
|
||||
abstractGame.getGamers().a(text2);
|
||||
abstractGame.getGamers().broadcast(text2);
|
||||
Bukkit.getConsoleSender().sendMessage(text2);
|
||||
}
|
||||
});
|
||||
@@ -154,7 +154,7 @@ public class GameListener implements Listener {
|
||||
}
|
||||
|
||||
@EventHandler
|
||||
public void a(SignChangeEvent event) {
|
||||
public void onSignChange(SignChangeEvent event) {
|
||||
Player player = event.getPlayer();
|
||||
String text = event.getLine(0);
|
||||
if (text != null && text.length() > 2) {
|
||||
@@ -165,16 +165,16 @@ public class GameListener implements Listener {
|
||||
event.setCancelled(true);
|
||||
if ("QuickJoin".equals(text2)) {
|
||||
this.manager.createQuickJoinSign(block);
|
||||
this.manager.getStorage().getStorage3().getQuickJoinSigns().add(event.getBlock());
|
||||
this.manager.getStorage().getStorage3().d();
|
||||
this.manager.getStorage().getSignStorage().getQuickJoinSigns().add(event.getBlock());
|
||||
this.manager.getStorage().getSignStorage().save();
|
||||
player.sendMessage("§aThe sign has been added!");
|
||||
} else {
|
||||
Session session = this.manager.getSessions().getSession(text2);
|
||||
if (session == null) {
|
||||
player.sendMessage("§cThe game doesn't exists.");
|
||||
} else if (VersionAdapters.get().isWallSign(block)) {
|
||||
this.manager.getStorage().getStorage3().a(block, text2);
|
||||
this.manager.getStorage().getStorage3().d();
|
||||
this.manager.getStorage().getSignStorage().addSign(block, text2);
|
||||
this.manager.getStorage().getSignStorage().save();
|
||||
this.manager.createJoinSign(block, text2);
|
||||
player.sendMessage("§aThe sign has been added!");
|
||||
} else {
|
||||
@@ -186,14 +186,14 @@ public class GameListener implements Listener {
|
||||
}
|
||||
|
||||
@EventHandler
|
||||
public void a(BlockBreakEvent event) {
|
||||
public void onBlockBreak(BlockBreakEvent event) {
|
||||
Player player = event.getPlayer();
|
||||
if (player.hasPermission(this.manager.getId() + ".admin")) {
|
||||
Block block = event.getBlock();
|
||||
SignStorage signStorage = this.manager.getStorage().getStorage3();
|
||||
if (signStorage.a(block) || signStorage.getQuickJoinSigns().remove(block)) {
|
||||
this.manager.getEngine().getDisplayManager().b(block);
|
||||
signStorage.d();
|
||||
SignStorage signStorage = this.manager.getStorage().getSignStorage();
|
||||
if (signStorage.removeSign(block) || signStorage.getQuickJoinSigns().remove(block)) {
|
||||
this.manager.getEngine().getDisplayManager().removeCommandSign(block);
|
||||
signStorage.save();
|
||||
player.sendMessage("§aThe sign has been removed!");
|
||||
}
|
||||
}
|
||||
|
||||
@@ -3,7 +3,7 @@ package ro.fr33styler.arcade.engine.game.phase;
|
||||
import ro.fr33styler.arcade.engine.game.player.BaseGamer;
|
||||
|
||||
public interface CountdownPhase {
|
||||
void a(BaseGamer var1);
|
||||
void onJoin(BaseGamer var1);
|
||||
|
||||
void b(BaseGamer var1);
|
||||
void onLeave(BaseGamer var1);
|
||||
}
|
||||
@@ -10,7 +10,7 @@ import ro.fr33styler.arcade.api.engine.game.phase.Phase;
|
||||
import ro.fr33styler.arcade.api.engine.game.phase.PhaseType;
|
||||
|
||||
public class EndingPhase implements Phase {
|
||||
protected int a;
|
||||
protected int remainingSeconds;
|
||||
private final AbstractGame game;
|
||||
|
||||
public EndingPhase(AbstractGame game2) {
|
||||
@@ -26,28 +26,28 @@ public class EndingPhase implements Phase {
|
||||
}
|
||||
|
||||
public void start() {
|
||||
this.a = this.game.getSettings().getEndingTime();
|
||||
this.remainingSeconds = this.game.getSettings().getEndingTime();
|
||||
|
||||
for (BaseGamer baseGamer : this.game.getGamers()) {
|
||||
if (baseGamer.f()) {
|
||||
if (baseGamer.isSpectator()) {
|
||||
baseGamer.toPlayer().closeInventory();
|
||||
} else {
|
||||
baseGamer.b(true);
|
||||
baseGamer.getSpectatorOptions().d(false);
|
||||
baseGamer.setSpectator(true);
|
||||
baseGamer.getSpectatorOptions().setTemporary(false);
|
||||
}
|
||||
|
||||
baseGamer.getHotbar().a(0, null, null);
|
||||
baseGamer.getHotbar().setSlot(0, null, null);
|
||||
}
|
||||
}
|
||||
|
||||
public void stop() {
|
||||
if (!UserNonceMarkerProbe.a(this.game.getEngine().getPlugin())) {
|
||||
if (!UserNonceMarkerProbe.probe(this.game.getEngine().getPlugin())) {
|
||||
this.game.getRollbackQueue().clear();
|
||||
}
|
||||
|
||||
this.game.getGamers().leaveAll();
|
||||
if (this.game.getPhase() == this) {
|
||||
this.game.getSpectatorMenu().a();
|
||||
this.game.getSpectatorMenu().clear();
|
||||
if (this.game.getRollbackQueue().isEmpty()) {
|
||||
this.game.setPhase(this.game.getPhaseLifecycle().getWaiting());
|
||||
} else {
|
||||
@@ -60,20 +60,20 @@ public class EndingPhase implements Phase {
|
||||
return text.equals("phase") ? this.game.getMessages().getGamePhaseEnding() : null;
|
||||
}
|
||||
|
||||
protected void a() {
|
||||
protected void spawnFireworks() {
|
||||
for (Gamer gamer : this.game.getGamers()) {
|
||||
Fireworks.a(gamer.toPlayer().getEyeLocation());
|
||||
Fireworks.spawnRandom(gamer.toPlayer().getEyeLocation());
|
||||
}
|
||||
}
|
||||
|
||||
public void onTick(long longVal) {
|
||||
if (longVal % 20L == 0L) {
|
||||
if (this.a > 0) {
|
||||
if (this.a % 2 == 0) {
|
||||
this.a();
|
||||
if (this.remainingSeconds > 0) {
|
||||
if (this.remainingSeconds % 2 == 0) {
|
||||
this.spawnFireworks();
|
||||
}
|
||||
|
||||
this.a--;
|
||||
this.remainingSeconds--;
|
||||
} else {
|
||||
this.stop();
|
||||
}
|
||||
|
||||
@@ -7,7 +7,7 @@ import ro.fr33styler.arcade.api.engine.game.phase.Phase;
|
||||
import ro.fr33styler.arcade.api.engine.game.phase.PhaseType;
|
||||
|
||||
public class ResettingPhase implements Phase {
|
||||
private int a;
|
||||
private int blocksPerTick;
|
||||
private final AbstractGame game;
|
||||
|
||||
public ResettingPhase(AbstractGame game2) {
|
||||
@@ -23,14 +23,14 @@ public class ResettingPhase implements Phase {
|
||||
}
|
||||
|
||||
public void start() {
|
||||
this.a = this.game.getSettings().getRollbackSize();
|
||||
this.blocksPerTick = this.game.getSettings().getRollbackSize();
|
||||
int index = this.game.getSettings().getRollbackMaxTimeInSeconds();
|
||||
if (this.game.getSettings().hasRollbackMaxTime() && this.a(this.game, this.a, index)) {
|
||||
this.a = this.game.getRollbackQueue().size() / (index * 4);
|
||||
if (this.game.getSettings().hasRollbackMaxTime() && this.exceedsMaxRollbackTime(this.game, this.blocksPerTick, index)) {
|
||||
this.blocksPerTick = this.game.getRollbackQueue().size() / (index * 4);
|
||||
}
|
||||
}
|
||||
|
||||
private boolean a(AbstractGame abstractGame, int index, int index2) {
|
||||
private boolean exceedsMaxRollbackTime(AbstractGame abstractGame, int index, int index2) {
|
||||
return abstractGame.getRollbackQueue().size() / (index * 4) > index2;
|
||||
}
|
||||
|
||||
@@ -44,7 +44,7 @@ public class ResettingPhase implements Phase {
|
||||
|
||||
public void onTick(long longVal) {
|
||||
if (longVal % 5L == 0L) {
|
||||
for (int index = 0; index <= this.a; index++) {
|
||||
for (int index = 0; index <= this.blocksPerTick; index++) {
|
||||
if (this.game.getRollbackQueue().isEmpty()) {
|
||||
this.game.setPhase(this.game.getPhaseLifecycle().getWaiting());
|
||||
break;
|
||||
|
||||
@@ -22,8 +22,8 @@ import ro.fr33styler.arcade.api.engine.game.phase.Phase;
|
||||
import ro.fr33styler.arcade.api.engine.game.phase.PhaseType;
|
||||
|
||||
public class WaitingPhase implements Phase, CountdownPhase {
|
||||
private int a;
|
||||
private boolean b;
|
||||
private int countdown;
|
||||
private boolean starting;
|
||||
private final AbstractGame game;
|
||||
|
||||
public WaitingPhase(AbstractGame game2) {
|
||||
@@ -39,56 +39,56 @@ public class WaitingPhase implements Phase, CountdownPhase {
|
||||
}
|
||||
|
||||
public void start() {
|
||||
this.a = this.game.getSettings().getWaitingTime();
|
||||
this.countdown = this.game.getSettings().getWaitingTime();
|
||||
this.game.getScoreboard().getOrCreateSidebar(this.game.getEngine()).setTitle(this.game.getMessages().getSidebarWaitingTitle(), this.game);
|
||||
}
|
||||
|
||||
public void a(BaseGamer baseGamer) {
|
||||
public void onJoin(BaseGamer baseGamer) {
|
||||
if (this.game.getGamers().size() >= this.game.getMap().getMinimumPlayers()) {
|
||||
this.b = true;
|
||||
this.starting = true;
|
||||
}
|
||||
|
||||
baseGamer.a(this.game.getMap().getLobby());
|
||||
Players.a(baseGamer);
|
||||
baseGamer.teleport(this.game.getMap().getLobby());
|
||||
Players.reset(baseGamer);
|
||||
baseGamer.toPlayer().setGameMode(GameMode.ADVENTURE);
|
||||
String text = this.game.getMessages().getGameBroadcastJoin().a(baseGamer);
|
||||
String text = this.game.getMessages().getGameBroadcastJoin().render(baseGamer);
|
||||
if (this.game.getEngine().getPlaceholderResolver() != null) {
|
||||
text = this.game.getEngine().getPlaceholderResolver().a(baseGamer.toPlayer(), text);
|
||||
text = this.game.getEngine().getPlaceholderResolver().resolve(baseGamer.toPlayer(), text);
|
||||
}
|
||||
|
||||
this.game.getGamers().a(text);
|
||||
baseGamer.getHotbar().a(8, baseGamer::leave, this.a());
|
||||
this.c(baseGamer);
|
||||
this.game.getGamers().broadcast(text);
|
||||
baseGamer.getHotbar().setSlot(8, baseGamer::leave, this.createLeaveItem());
|
||||
this.createPlayerTeam(baseGamer);
|
||||
}
|
||||
|
||||
private ItemStack a() {
|
||||
private ItemStack createLeaveItem() {
|
||||
return new ItemBuilder(this.game.getSettings().getLeaveGameMaterial(), this.game.getSettings().getLeaveGameData()).setDisplayName(this.game.getMessages().getItemLeave()).build();
|
||||
}
|
||||
|
||||
public void b(BaseGamer baseGamer) {
|
||||
if (this.b && this.game.getGamers().size() < this.game.getMap().getMinimumPlayers()) {
|
||||
this.b = false;
|
||||
this.a = this.game.getSettings().getWaitingTime();
|
||||
this.game.getGamers().a(this.game.getMessages().getGameStartCancelled());
|
||||
public void onLeave(BaseGamer baseGamer) {
|
||||
if (this.starting && this.game.getGamers().size() < this.game.getMap().getMinimumPlayers()) {
|
||||
this.starting = false;
|
||||
this.countdown = this.game.getSettings().getWaitingTime();
|
||||
this.game.getGamers().broadcast(this.game.getMessages().getGameStartCancelled());
|
||||
}
|
||||
|
||||
String text = this.game.getMessages().getGameBroadcastLeave().a(baseGamer);
|
||||
String text = this.game.getMessages().getGameBroadcastLeave().render(baseGamer);
|
||||
if (this.game.getEngine().hasPlaceholderResolver()) {
|
||||
text = this.game.getEngine().getPlaceholderResolver().a(baseGamer.toPlayer(), text);
|
||||
text = this.game.getEngine().getPlaceholderResolver().resolve(baseGamer.toPlayer(), text);
|
||||
}
|
||||
|
||||
this.game.getGamers().a(text);
|
||||
this.game.getGamers().broadcast(text);
|
||||
baseGamer.getScoreboardTeam().unregister();
|
||||
}
|
||||
|
||||
public void stop() {
|
||||
this.b = false;
|
||||
this.b();
|
||||
if (UserNonceMarkerProbe.a(this.game.getEngine().getPlugin())) {
|
||||
if (VendorMarkerProbe.a(this.game.getEngine().getPlugin())) {
|
||||
this.starting = false;
|
||||
this.clearLobbyZone();
|
||||
if (UserNonceMarkerProbe.probe(this.game.getEngine().getPlugin())) {
|
||||
if (VendorMarkerProbe.probe(this.game.getEngine().getPlugin())) {
|
||||
for (BaseGamer baseGamer : this.game.getGamers()) {
|
||||
baseGamer.getScoreboardTeam().unregister();
|
||||
baseGamer.getHotbar().a();
|
||||
baseGamer.getHotbar().clear();
|
||||
}
|
||||
|
||||
this.game.setPhase(this.game.getPhaseLifecycle().getPlaying());
|
||||
@@ -96,10 +96,10 @@ public class WaitingPhase implements Phase, CountdownPhase {
|
||||
}
|
||||
}
|
||||
|
||||
private void b() {
|
||||
private void clearLobbyZone() {
|
||||
Cuboid cuboid = this.game.getMap().getLobbyZone();
|
||||
if (cuboid != null) {
|
||||
cuboid.a(block -> {
|
||||
cuboid.forEachBlock(block -> {
|
||||
if (!block.isEmpty()) {
|
||||
this.game.getRollbackQueue().add(block.getState());
|
||||
VersionAdapters.get().setBlock(this.game.getEngine().getPlatform(), block, Material.AIR, 0);
|
||||
@@ -108,12 +108,12 @@ public class WaitingPhase implements Phase, CountdownPhase {
|
||||
}
|
||||
}
|
||||
|
||||
private void c(BaseGamer baseGamer) {
|
||||
private void createPlayerTeam(BaseGamer baseGamer) {
|
||||
ScoreboardTeam scoreboardTeam = this.game.getScoreboard().createTeam(baseGamer.toPlayer().getName());
|
||||
scoreboardTeam.setCollisionRule(TeamRule.NEVER);
|
||||
String text = this.game.getMessages().getGamePlayerPrefix();
|
||||
if (this.game.getEngine().getPlaceholderResolver() != null) {
|
||||
text = this.game.getEngine().getPlaceholderResolver().a(baseGamer.toPlayer(), text);
|
||||
text = this.game.getEngine().getPlaceholderResolver().resolve(baseGamer.toPlayer(), text);
|
||||
}
|
||||
|
||||
scoreboardTeam.setPrefix(text);
|
||||
@@ -129,42 +129,42 @@ public class WaitingPhase implements Phase, CountdownPhase {
|
||||
public String getVariable(String text) {
|
||||
return switch (text) {
|
||||
case "phase" -> this.getName();
|
||||
case "seconds" -> String.valueOf(this.a);
|
||||
case "countdown" -> Strings.a(this.a);
|
||||
case "seconds" -> String.valueOf(this.countdown);
|
||||
case "countdown" -> Strings.formatDuration(this.countdown);
|
||||
case "required" -> String.valueOf(this.game.getMap().getMinimumPlayers() - this.game.getGamers().size());
|
||||
case "countdown_formatted" -> Strings.a(this.a, this.game.getSettings().getWaitingTime());
|
||||
case "countdown_formatted" -> Strings.formatProgressColor(this.countdown, this.game.getSettings().getWaitingTime());
|
||||
default -> null;
|
||||
};
|
||||
}
|
||||
|
||||
public Boolean getCondition(String text) {
|
||||
return text.equals("STARTING") ? this.b : null;
|
||||
return text.equals("STARTING") ? this.starting : null;
|
||||
}
|
||||
|
||||
public void onTick(long longVal) {
|
||||
if (longVal % 20L == 0L) {
|
||||
if (this.b) {
|
||||
if (this.starting) {
|
||||
int index = this.game.getSettings().getWaitingTimeAlmostFullReduction();
|
||||
double doubleVal = this.game.getSettings().getWaitingTimeReduceAtThreshold() / 100.0;
|
||||
if ((double)this.game.getGamers().size() / this.game.getMap().getMaximumPlayers() >= doubleVal && this.a > index) {
|
||||
this.a = index;
|
||||
if ((double)this.game.getGamers().size() / this.game.getMap().getMaximumPlayers() >= doubleVal && this.countdown > index) {
|
||||
this.countdown = index;
|
||||
}
|
||||
|
||||
if (this.a <= 1) {
|
||||
if (this.countdown <= 1) {
|
||||
this.stop();
|
||||
return;
|
||||
}
|
||||
|
||||
this.a--;
|
||||
this.c();
|
||||
this.countdown--;
|
||||
this.broadcastCountdown();
|
||||
}
|
||||
|
||||
this.game.getGamers().a(this.game.getMessages().getSidebarWaiting());
|
||||
this.game.getGamers().updateSidebars(this.game.getMessages().getSidebarWaiting());
|
||||
}
|
||||
}
|
||||
|
||||
private void c() {
|
||||
if (this.a <= 5) {
|
||||
private void broadcastCountdown() {
|
||||
if (this.countdown <= 5) {
|
||||
for (BaseGamer baseGamer : this.game.getGamers()) {
|
||||
baseGamer.playSound(ArcadeSound.NOTE_HAT, 1.0F, 1.0F);
|
||||
baseGamer.sendMessage(this.game.getMessages().getGameStartCountdown(), baseGamer);
|
||||
|
||||
@@ -42,10 +42,10 @@ import ro.fr33styler.arcade.api.engine.party.Party;
|
||||
import ro.fr33styler.arcade.api.engine.text.Context;
|
||||
|
||||
public abstract class BaseGamer extends PlayerHandle implements Gamer {
|
||||
private int b;
|
||||
private int c;
|
||||
private int wins;
|
||||
private int loses;
|
||||
private Party party;
|
||||
private boolean e;
|
||||
private boolean spectator;
|
||||
private PlayerSidebar playerSidebar;
|
||||
private ScoreboardTeam scoreboardTeam;
|
||||
private final PlayerHotbar hotbar;
|
||||
@@ -60,19 +60,19 @@ public abstract class BaseGamer extends PlayerHandle implements Gamer {
|
||||
}
|
||||
|
||||
public int getWins() {
|
||||
return this.b;
|
||||
return this.wins;
|
||||
}
|
||||
|
||||
public void a(int index) {
|
||||
this.b = index;
|
||||
public void setWins(int index) {
|
||||
this.wins = index;
|
||||
}
|
||||
|
||||
public int getLoses() {
|
||||
return this.c;
|
||||
return this.loses;
|
||||
}
|
||||
|
||||
public void b(int index) {
|
||||
this.c = index;
|
||||
public void setLoses(int index) {
|
||||
this.loses = index;
|
||||
}
|
||||
|
||||
public DefaultUser toUser() {
|
||||
@@ -85,15 +85,15 @@ public abstract class BaseGamer extends PlayerHandle implements Gamer {
|
||||
|
||||
public abstract AbstractGame getGame();
|
||||
|
||||
public void a(Text text) {
|
||||
this.sendMessage(text.a(this));
|
||||
public void sendMessage(Text text) {
|
||||
this.sendMessage(text.render(this));
|
||||
}
|
||||
|
||||
public void a(List<Text> list2) {
|
||||
public void sendMessages(List<Text> list2) {
|
||||
this.sendMessages(list2, this);
|
||||
}
|
||||
|
||||
public void b(Text text) {
|
||||
public void sendActionBar(Text text) {
|
||||
this.sendActionBar(text, this);
|
||||
}
|
||||
|
||||
@@ -117,8 +117,8 @@ public abstract class BaseGamer extends PlayerHandle implements Gamer {
|
||||
super.sendTitle(this.getGame().getEngine().getPlatform(), text, text2, context, index, index2, index3);
|
||||
}
|
||||
|
||||
public Party d() {
|
||||
return (Party)EngineUtils.a(this.party, this.user.getParty());
|
||||
public Party getParty() {
|
||||
return (Party)EngineUtils.orElse(this.party, this.user.getParty());
|
||||
}
|
||||
|
||||
public void setParty(Party party2) {
|
||||
@@ -133,56 +133,56 @@ public abstract class BaseGamer extends PlayerHandle implements Gamer {
|
||||
this.scoreboardTeam = scoreboardTeam2;
|
||||
}
|
||||
|
||||
public boolean f() {
|
||||
return this.e;
|
||||
public boolean isSpectator() {
|
||||
return this.spectator;
|
||||
}
|
||||
|
||||
public boolean g() {
|
||||
return this.e && !this.spectatorOptions.f();
|
||||
public boolean isActiveSpectator() {
|
||||
return this.spectator && !this.spectatorOptions.isTemporary();
|
||||
}
|
||||
|
||||
public SpectatorOptions getSpectatorOptions() {
|
||||
return this.spectatorOptions;
|
||||
}
|
||||
|
||||
public void a(boolean flag) {
|
||||
this.e = flag;
|
||||
Players.a(this);
|
||||
public void setTemporarySpectator(boolean flag) {
|
||||
this.spectator = flag;
|
||||
Players.reset(this);
|
||||
if (flag) {
|
||||
this.n();
|
||||
this.spectatorOptions.d(true);
|
||||
this.m();
|
||||
this.enableSpectatorVisibility();
|
||||
this.spectatorOptions.setTemporary(true);
|
||||
this.detachSpectators();
|
||||
} else {
|
||||
this.o();
|
||||
this.spectatorOptions.d(false);
|
||||
this.l();
|
||||
this.disableSpectatorVisibility();
|
||||
this.spectatorOptions.setTemporary(false);
|
||||
this.attachSpectators();
|
||||
}
|
||||
}
|
||||
|
||||
public void b(boolean flag) {
|
||||
this.e = flag;
|
||||
Players.a(this);
|
||||
public void setSpectator(boolean flag) {
|
||||
this.spectator = flag;
|
||||
Players.reset(this);
|
||||
if (flag) {
|
||||
this.n();
|
||||
this.r();
|
||||
this.q();
|
||||
this.m();
|
||||
this.enableSpectatorVisibility();
|
||||
this.giveSpectatorHotbar();
|
||||
this.applySpectatorOptions();
|
||||
this.detachSpectators();
|
||||
} else {
|
||||
this.o();
|
||||
this.hotbar.a();
|
||||
this.l();
|
||||
this.disableSpectatorVisibility();
|
||||
this.hotbar.clear();
|
||||
this.attachSpectators();
|
||||
}
|
||||
}
|
||||
|
||||
private void l() {
|
||||
private void attachSpectators() {
|
||||
for (BaseGamer baseGamer : this.getGame().getGamers()) {
|
||||
SpectatorOptions spectatorOptions2 = baseGamer.getSpectatorOptions();
|
||||
if (baseGamer.g() && spectatorOptions2.getPlayer() == this.player) {
|
||||
if (spectatorOptions2.d() || spectatorOptions2.c()) {
|
||||
if (baseGamer.isActiveSpectator() && spectatorOptions2.getPlayer() == this.player) {
|
||||
if (spectatorOptions2.isAutoTeleport() || spectatorOptions2.isFirstPersonMode()) {
|
||||
baseGamer.toPlayer().teleport(this.player);
|
||||
}
|
||||
|
||||
if (spectatorOptions2.c()) {
|
||||
if (spectatorOptions2.isFirstPersonMode()) {
|
||||
baseGamer.toPlayer().setGameMode(GameMode.SPECTATOR);
|
||||
baseGamer.toPlayer().setSpectatorTarget(this.player);
|
||||
}
|
||||
@@ -190,108 +190,108 @@ public abstract class BaseGamer extends PlayerHandle implements Gamer {
|
||||
}
|
||||
}
|
||||
|
||||
private void m() {
|
||||
private void detachSpectators() {
|
||||
for (BaseGamer baseGamer : this.getGame().getGamers()) {
|
||||
SpectatorOptions spectatorOptions2 = baseGamer.getSpectatorOptions();
|
||||
if (baseGamer.g() && spectatorOptions2.getPlayer() == this.player) {
|
||||
if (baseGamer.isActiveSpectator() && spectatorOptions2.getPlayer() == this.player) {
|
||||
Player player = baseGamer.toPlayer();
|
||||
player.setGameMode(GameMode.SURVIVAL);
|
||||
player.setAllowFlight(true);
|
||||
player.setFlying(true);
|
||||
if (!this.spectatorOptions.f()) {
|
||||
if (!this.spectatorOptions.isTemporary()) {
|
||||
spectatorOptions2.setPlayer(null);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private void n() {
|
||||
private void enableSpectatorVisibility() {
|
||||
this.player.setAllowFlight(true);
|
||||
this.player.setFlying(true);
|
||||
VersionAdapters.get().setCollidable(this.getGame().getEngine().getPlatform(), this.player, false);
|
||||
this.player.addPotionEffect(new PotionEffect(PotionEffectType.INVISIBILITY, Integer.MAX_VALUE, 0));
|
||||
PlayerVisibility.b(this.getGame().getEngine().getPlugin(), this.player, this.getGame().getGamers());
|
||||
PlayerVisibility.hideFromRegistry(this.getGame().getEngine().getPlugin(), this.player, this.getGame().getGamers());
|
||||
}
|
||||
|
||||
private void o() {
|
||||
private void disableSpectatorVisibility() {
|
||||
VersionAdapters.get().setCollidable(this.getGame().getEngine().getPlatform(), this.player, true);
|
||||
PlayerVisibility.a(this.getGame().getEngine().getPlugin(), this.player, this.getGame().getGamers());
|
||||
PlayerVisibility.showToRegistry(this.getGame().getEngine().getPlugin(), this.player, this.getGame().getGamers());
|
||||
}
|
||||
|
||||
private void q() {
|
||||
this.player.setFlySpeed(this.spectatorOptions.b());
|
||||
this.player.setWalkSpeed(this.spectatorOptions.b());
|
||||
if (this.spectatorOptions.e()) {
|
||||
private void applySpectatorOptions() {
|
||||
this.player.setFlySpeed(this.spectatorOptions.getSpeed());
|
||||
this.player.setWalkSpeed(this.spectatorOptions.getSpeed());
|
||||
if (this.spectatorOptions.isNightVision()) {
|
||||
this.player.addPotionEffect(new PotionEffect(PotionEffectType.NIGHT_VISION, Integer.MAX_VALUE, 1));
|
||||
}
|
||||
}
|
||||
|
||||
private void r() {
|
||||
this.hotbar.a(0, this::i, new ItemBuilder(Material.COMPASS).setDisplayName(this.getGame().getMessages().getItemSettings()).build());
|
||||
this.hotbar.a(4, this::s, new ItemBuilder(ArcadeMaterial.COMPARATOR).setDisplayName(this.getGame().getMessages().getItemSpectatorSettings()).build());
|
||||
private void giveSpectatorHotbar() {
|
||||
this.hotbar.setSlot(0, this::openSpectatorMenu, new ItemBuilder(Material.COMPASS).setDisplayName(this.getGame().getMessages().getItemSettings()).build());
|
||||
this.hotbar.setSlot(4, this::openSpectatorSettings, new ItemBuilder(ArcadeMaterial.COMPARATOR).setDisplayName(this.getGame().getMessages().getItemSpectatorSettings()).build());
|
||||
if (!this.getGame().getManager().getEngine().getNetworkManager().getSettings().isEnabled()) {
|
||||
this.hotbar.a(7, this::j, new ItemBuilder(Material.PAPER).setDisplayName(this.getGame().getMessages().getItemPlayAgain()).build());
|
||||
this.hotbar.setSlot(7, this::playAgain, new ItemBuilder(Material.PAPER).setDisplayName(this.getGame().getMessages().getItemPlayAgain()).build());
|
||||
}
|
||||
|
||||
this.hotbar.a(8, this::leave, new ItemBuilder(this.getGame().getSettings().getLeaveGameMaterial(), this.getGame().getSettings().getLeaveGameData()).setDisplayName(this.getGame().getMessages().getItemLeave()).build());
|
||||
this.hotbar.setSlot(8, this::leave, new ItemBuilder(this.getGame().getSettings().getLeaveGameMaterial(), this.getGame().getSettings().getLeaveGameData()).setDisplayName(this.getGame().getMessages().getItemLeave()).build());
|
||||
}
|
||||
|
||||
public void i() {
|
||||
this.getGame().getSpectatorMenu().a(this.user);
|
||||
public void openSpectatorMenu() {
|
||||
this.getGame().getSpectatorMenu().open(this.user);
|
||||
}
|
||||
|
||||
private void s() {
|
||||
private void openSpectatorSettings() {
|
||||
EngineMessages engineMessages = this.getGame().getEngine().getMessages();
|
||||
InventoryMenu inventoryMenu = new InventoryMenu(engineMessages.getSpectatorTitle(), 36);
|
||||
inventoryMenu.a(11, defaultUser -> {
|
||||
inventoryMenu.setSlot(11, defaultUser -> {
|
||||
this.player.setFlySpeed(0.2F);
|
||||
this.player.setWalkSpeed(0.2F);
|
||||
this.spectatorOptions.a(0.2F);
|
||||
this.spectatorOptions.setSpeed(0.2F);
|
||||
this.player.sendMessage(engineMessages.getSpectatorNoSpeed());
|
||||
}, new ItemBuilder(Material.LEATHER_BOOTS).setDisplayName(engineMessages.getSpectatorItemNoSpeed()).build());
|
||||
inventoryMenu.a(12, defaultUser2 -> {
|
||||
inventoryMenu.setSlot(12, defaultUser2 -> {
|
||||
this.player.setFlySpeed(0.3F);
|
||||
this.player.setWalkSpeed(0.3F);
|
||||
this.spectatorOptions.a(0.3F);
|
||||
this.spectatorOptions.setSpeed(0.3F);
|
||||
this.player.sendMessage(engineMessages.getSpectatorSpeed1());
|
||||
}, new ItemBuilder(Material.CHAINMAIL_BOOTS).setDisplayName(engineMessages.getSpectatorItemSpeed1()).build());
|
||||
inventoryMenu.a(13, defaultUser3 -> {
|
||||
inventoryMenu.setSlot(13, defaultUser3 -> {
|
||||
this.player.setFlySpeed(0.4F);
|
||||
this.player.setWalkSpeed(0.4F);
|
||||
this.spectatorOptions.a(0.4F);
|
||||
this.spectatorOptions.setSpeed(0.4F);
|
||||
this.player.sendMessage(engineMessages.getSpectatorSpeed2());
|
||||
}, new ItemBuilder(Material.IRON_BOOTS).setDisplayName(engineMessages.getSpectatorItemSpeed2()).build());
|
||||
inventoryMenu.a(14, defaultUser4 -> {
|
||||
inventoryMenu.setSlot(14, defaultUser4 -> {
|
||||
this.player.setFlySpeed(0.5F);
|
||||
this.player.setWalkSpeed(0.5F);
|
||||
this.spectatorOptions.a(0.5F);
|
||||
this.spectatorOptions.setSpeed(0.5F);
|
||||
this.player.sendMessage(engineMessages.getSpectatorSpeed3());
|
||||
}, new ItemBuilder(ArcadeMaterial.GOLDEN_BOOTS).setDisplayName(engineMessages.getSpectatorItemSpeed3()).build());
|
||||
inventoryMenu.a(15, defaultUser5 -> {
|
||||
inventoryMenu.setSlot(15, defaultUser5 -> {
|
||||
this.player.setFlySpeed(0.6F);
|
||||
this.player.setWalkSpeed(0.6F);
|
||||
this.spectatorOptions.a(0.6F);
|
||||
this.spectatorOptions.setSpeed(0.6F);
|
||||
this.player.sendMessage(engineMessages.getSpectatorSpeed4());
|
||||
}, new ItemBuilder(Material.DIAMOND_BOOTS).setDisplayName(engineMessages.getSpectatorItemSpeed4()).build());
|
||||
this.a(inventoryMenu);
|
||||
this.user.a(inventoryMenu);
|
||||
this.populateSpectatorToggles(inventoryMenu);
|
||||
this.user.openMenu(inventoryMenu);
|
||||
}
|
||||
|
||||
private void a(InventoryMenu inventoryMenu) {
|
||||
private void populateSpectatorToggles(InventoryMenu inventoryMenu) {
|
||||
EngineMessages engineMessages = this.getGame().getEngine().getMessages();
|
||||
inventoryMenu.a(21, defaultUser -> {
|
||||
this.spectatorOptions.b(!this.spectatorOptions.d());
|
||||
if (this.spectatorOptions.d()) {
|
||||
inventoryMenu.setSlot(21, defaultUser -> {
|
||||
this.spectatorOptions.setAutoTeleport(!this.spectatorOptions.isAutoTeleport());
|
||||
if (this.spectatorOptions.isAutoTeleport()) {
|
||||
this.player.sendMessage(engineMessages.getSpectatorTeleportOn());
|
||||
} else {
|
||||
this.player.sendMessage(engineMessages.getSpectatorTeleportOff());
|
||||
}
|
||||
|
||||
this.a(inventoryMenu);
|
||||
}, new ItemBuilder(Material.COMPASS).setDisplayName(this.spectatorOptions.d() ? engineMessages.getSpectatorItemTeleportOff() : engineMessages.getSpectatorItemTeleportOn()).build());
|
||||
inventoryMenu.a(22, defaultUser2 -> {
|
||||
this.spectatorOptions.c(!this.spectatorOptions.e());
|
||||
if (this.spectatorOptions.e()) {
|
||||
this.populateSpectatorToggles(inventoryMenu);
|
||||
}, new ItemBuilder(Material.COMPASS).setDisplayName(this.spectatorOptions.isAutoTeleport() ? engineMessages.getSpectatorItemTeleportOff() : engineMessages.getSpectatorItemTeleportOn()).build());
|
||||
inventoryMenu.setSlot(22, defaultUser2 -> {
|
||||
this.spectatorOptions.setNightVision(!this.spectatorOptions.isNightVision());
|
||||
if (this.spectatorOptions.isNightVision()) {
|
||||
this.player.sendMessage(engineMessages.getSpectatorNightVisionOn());
|
||||
this.player.addPotionEffect(new PotionEffect(PotionEffectType.NIGHT_VISION, Integer.MAX_VALUE, 1));
|
||||
} else {
|
||||
@@ -299,25 +299,25 @@ public abstract class BaseGamer extends PlayerHandle implements Gamer {
|
||||
this.player.removePotionEffect(PotionEffectType.NIGHT_VISION);
|
||||
}
|
||||
|
||||
this.a(inventoryMenu);
|
||||
}, new ItemBuilder(this.spectatorOptions.e() ? VersionAdapters.get().resolveMaterial(ArcadeMaterial.ENDER_EYE) : Material.ENDER_PEARL).setDisplayName(this.spectatorOptions.e() ? engineMessages.getSpectatorItemNightVisionOff() : engineMessages.getSpectatorItemNightVisionOn()).build());
|
||||
inventoryMenu.a(23, defaultUser3 -> {
|
||||
this.spectatorOptions.a(!this.spectatorOptions.c());
|
||||
if (this.spectatorOptions.c()) {
|
||||
this.populateSpectatorToggles(inventoryMenu);
|
||||
}, new ItemBuilder(this.spectatorOptions.isNightVision() ? VersionAdapters.get().resolveMaterial(ArcadeMaterial.ENDER_EYE) : Material.ENDER_PEARL).setDisplayName(this.spectatorOptions.isNightVision() ? engineMessages.getSpectatorItemNightVisionOff() : engineMessages.getSpectatorItemNightVisionOn()).build());
|
||||
inventoryMenu.setSlot(23, defaultUser3 -> {
|
||||
this.spectatorOptions.setFirstPersonMode(!this.spectatorOptions.isFirstPersonMode());
|
||||
if (this.spectatorOptions.isFirstPersonMode()) {
|
||||
this.player.sendMessage(engineMessages.getSpectatorFirstPersonOn());
|
||||
} else {
|
||||
this.player.sendMessage(engineMessages.getSpectatorFirstPersonOff());
|
||||
}
|
||||
|
||||
this.a(inventoryMenu);
|
||||
}, new ItemBuilder(ArcadeMaterial.CLOCK).setDisplayName(this.spectatorOptions.c() ? engineMessages.getSpectatorItemFirstPersonOff() : engineMessages.getSpectatorItemFirstPersonOn()).build());
|
||||
this.populateSpectatorToggles(inventoryMenu);
|
||||
}, new ItemBuilder(ArcadeMaterial.CLOCK).setDisplayName(this.spectatorOptions.isFirstPersonMode() ? engineMessages.getSpectatorItemFirstPersonOff() : engineMessages.getSpectatorItemFirstPersonOn()).build());
|
||||
}
|
||||
|
||||
protected void j() {
|
||||
this.toUser().a(this.getGame().getManager().getSessions().getGameSearcher());
|
||||
protected void playAgain() {
|
||||
this.toUser().quickJoin(this.getGame().getManager().getSessions().getGameSearcher());
|
||||
}
|
||||
|
||||
public void a(Location location) {
|
||||
public void teleport(Location location) {
|
||||
if (!VersionAdapters.get().isLatestVariant()) {
|
||||
location.getChunk().load();
|
||||
}
|
||||
@@ -327,13 +327,13 @@ public abstract class BaseGamer extends PlayerHandle implements Gamer {
|
||||
}
|
||||
}
|
||||
|
||||
public void b(List<String> list2) {
|
||||
public void setRewardCommands(List<String> list2) {
|
||||
if (list2 != null) {
|
||||
this.list = list2;
|
||||
}
|
||||
}
|
||||
|
||||
public void a(List<String> list2, UnaryOperator<String> unaryOperator) {
|
||||
public void setRewardCommands(List<String> list2, UnaryOperator<String> unaryOperator) {
|
||||
if (list2 != null && !list2.isEmpty()) {
|
||||
this.list = new ArrayList<>(list2.size());
|
||||
|
||||
@@ -343,25 +343,25 @@ public abstract class BaseGamer extends PlayerHandle implements Gamer {
|
||||
}
|
||||
}
|
||||
|
||||
public void a(GameScoreboard gameScoreboard) {
|
||||
public void applyScoreboard(GameScoreboard gameScoreboard) {
|
||||
gameScoreboard.applyTo(this.player);
|
||||
}
|
||||
|
||||
public void a(List<Text> list2, Context context) {
|
||||
public void updateSidebar(List<Text> list2, Context context) {
|
||||
if (this.playerSidebar == null) {
|
||||
this.playerSidebar = this.getGame().getScoreboard().getOrCreateSidebar(this.getGame().getEngine()).createPlayerSidebar(this.player);
|
||||
}
|
||||
|
||||
if (this.getGame().getEngine().hasPlaceholderResolver()) {
|
||||
this.playerSidebar.a(list2, context, text -> this.getGame().getEngine().getPlaceholderResolver().a(this.player, text));
|
||||
this.playerSidebar.update(list2, context, text -> this.getGame().getEngine().getPlaceholderResolver().resolve(this.player, text));
|
||||
} else {
|
||||
this.playerSidebar.a(list2, context);
|
||||
this.playerSidebar.update(list2, context);
|
||||
}
|
||||
}
|
||||
|
||||
public void k() {
|
||||
public void clearSidebar() {
|
||||
if (this.playerSidebar != null) {
|
||||
this.playerSidebar.a();
|
||||
this.playerSidebar.clear();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -375,30 +375,30 @@ public abstract class BaseGamer extends PlayerHandle implements Gamer {
|
||||
}
|
||||
|
||||
public Boolean getCondition(String text) {
|
||||
return text.equals("SPECTATOR") ? this.e : this.getGame().getCondition(text);
|
||||
return text.equals("SPECTATOR") ? this.spectator : this.getGame().getCondition(text);
|
||||
}
|
||||
|
||||
public void a(long longVal) {
|
||||
public void onTick(long longVal) {
|
||||
Player player = this.spectatorOptions.getPlayer();
|
||||
if (this.g() && player != null) {
|
||||
if (this.spectatorOptions.d() && longVal % 100L == 0L) {
|
||||
if (this.isActiveSpectator() && player != null) {
|
||||
if (this.spectatorOptions.isAutoTeleport() && longVal % 100L == 0L) {
|
||||
Location location = player.getLocation();
|
||||
if (Locations.b(location, this.player.getLocation()) >= 200.0) {
|
||||
if (Locations.distanceSquared(location, this.player.getLocation()) >= 200.0) {
|
||||
this.player.teleport(location);
|
||||
}
|
||||
}
|
||||
|
||||
if (this.player.getSpectatorTarget() == player) {
|
||||
BaseGamer baseGamer = (BaseGamer)this.getGame().getGamers().c(player);
|
||||
if (baseGamer != null && !baseGamer.f()) {
|
||||
if (baseGamer != null && !baseGamer.isSpectator()) {
|
||||
this.sendActionBar(this.getGame().getMessages().getSpectatorTarget(), baseGamer);
|
||||
}
|
||||
} else if (player.getWorld() == this.player.getWorld()) {
|
||||
this.sendActionBar(this.getGame().getMessages().getSpectatorTargetFirstPerson(), Contexts.a((VariableProvider) text -> {
|
||||
this.sendActionBar(this.getGame().getMessages().getSpectatorTargetFirstPerson(), Contexts.ofVariables((VariableProvider) text -> {
|
||||
if (text.equals("player")) {
|
||||
return player.getName();
|
||||
} else {
|
||||
return text.equals("distance") ? Strings.a(this.player.getLocation().distance(player.getLocation()), 1) : null;
|
||||
return text.equals("distance") ? Strings.formatFixedDecimal(this.player.getLocation().distance(player.getLocation()), 1) : null;
|
||||
}
|
||||
}));
|
||||
}
|
||||
@@ -406,26 +406,26 @@ public abstract class BaseGamer extends PlayerHandle implements Gamer {
|
||||
}
|
||||
|
||||
public void leave() {
|
||||
if (MethodSuffixProbe.a(this.getGame().getEngine().getPlugin().getClass())) {
|
||||
this.k();
|
||||
if (MethodSuffixProbe.hasTargetMethodSuffix(this.getGame().getEngine().getPlugin().getClass())) {
|
||||
this.clearSidebar();
|
||||
DefaultEngine defaultEngine = this.getGame().getEngine();
|
||||
if (this.getGame().getSettings().isTabPrivate()) {
|
||||
PlayerVisibility.b(defaultEngine.getPlugin(), this.player, this.getGame().getGamers(), defaultEngine.getUsers());
|
||||
PlayerVisibility.restoreVisibility(defaultEngine.getPlugin(), this.player, this.getGame().getGamers(), defaultEngine.getUsers());
|
||||
} else {
|
||||
PlayerVisibility.a(defaultEngine.getPlugin(), this.player);
|
||||
PlayerVisibility.showAllPlayers(defaultEngine.getPlugin(), this.player);
|
||||
}
|
||||
|
||||
if (this.e) {
|
||||
if (this.spectator) {
|
||||
VersionAdapters.get().setCollidable(defaultEngine.getPlatform(), this.player, true);
|
||||
if (!this.getSpectatorOptions().f()) {
|
||||
if (!this.getSpectatorOptions().isTemporary()) {
|
||||
this.getGame().getSpectatorTeam().removeEntry(this.player.getName());
|
||||
}
|
||||
} else {
|
||||
this.m();
|
||||
this.detachSpectators();
|
||||
}
|
||||
|
||||
this.user.setGamer((ro.fr33styler.arcade.api.engine.game.gamer.Gamer)null);
|
||||
this.user.j();
|
||||
this.user.restoreSnapshot();
|
||||
Bukkit.getPluginManager().callEvent(new GameLeaveEvent(this));
|
||||
|
||||
for (String text : this.list) {
|
||||
@@ -438,17 +438,17 @@ public abstract class BaseGamer extends PlayerHandle implements Gamer {
|
||||
}
|
||||
}
|
||||
|
||||
public void a(Map<String, String> map) {
|
||||
this.spectatorOptions.a(Float.parseFloat((String)map.get("spectator-speed")));
|
||||
this.spectatorOptions.b(Boolean.parseBoolean((String)map.get("spectator-auto-teleport")));
|
||||
this.spectatorOptions.c(Boolean.parseBoolean((String)map.get("spectator-night-vision")));
|
||||
this.spectatorOptions.a(Boolean.parseBoolean((String)map.get("spectator-first-person-mode")));
|
||||
public void loadProperties(Map<String, String> map) {
|
||||
this.spectatorOptions.setSpeed(Float.parseFloat((String)map.get("spectator-speed")));
|
||||
this.spectatorOptions.setAutoTeleport(Boolean.parseBoolean((String)map.get("spectator-auto-teleport")));
|
||||
this.spectatorOptions.setNightVision(Boolean.parseBoolean((String)map.get("spectator-night-vision")));
|
||||
this.spectatorOptions.setFirstPersonMode(Boolean.parseBoolean((String)map.get("spectator-first-person-mode")));
|
||||
}
|
||||
|
||||
public void b(Map<String, String> map) {
|
||||
map.put("spectator-speed", String.valueOf(this.spectatorOptions.b()));
|
||||
map.put("spectator-auto-teleport", String.valueOf(this.spectatorOptions.d()));
|
||||
map.put("spectator-night-vision", String.valueOf(this.spectatorOptions.e()));
|
||||
map.put("spectator-first-person-mode", String.valueOf(this.spectatorOptions.c()));
|
||||
public void saveProperties(Map<String, String> map) {
|
||||
map.put("spectator-speed", String.valueOf(this.spectatorOptions.getSpeed()));
|
||||
map.put("spectator-auto-teleport", String.valueOf(this.spectatorOptions.isAutoTeleport()));
|
||||
map.put("spectator-night-vision", String.valueOf(this.spectatorOptions.isNightVision()));
|
||||
map.put("spectator-first-person-mode", String.valueOf(this.spectatorOptions.isFirstPersonMode()));
|
||||
}
|
||||
}
|
||||
@@ -11,19 +11,19 @@ import ro.fr33styler.arcade.api.engine.game.gamer.GamerSet;
|
||||
import ro.fr33styler.arcade.api.engine.text.Context;
|
||||
|
||||
public class DefaultGamerSet<G extends BaseGamer> extends PlayerRegistry<G> implements GamerSet<G> {
|
||||
public void a(String text) {
|
||||
public void broadcast(String text) {
|
||||
for (BaseGamer baseGamer : this.map.values()) {
|
||||
baseGamer.sendMessage(text);
|
||||
}
|
||||
}
|
||||
|
||||
public void a(Text text, Context context) {
|
||||
this.a(text.a(context));
|
||||
public void broadcast(Text text, Context context) {
|
||||
this.broadcast(text.render(context));
|
||||
}
|
||||
|
||||
public void a(List<Text> list) {
|
||||
public void updateSidebars(List<Text> list) {
|
||||
for (BaseGamer baseGamer : this.map.values()) {
|
||||
baseGamer.a(list, baseGamer);
|
||||
baseGamer.updateSidebar(list, baseGamer);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -37,11 +37,11 @@ public class DefaultGamerSet<G extends BaseGamer> extends PlayerRegistry<G> impl
|
||||
}
|
||||
}
|
||||
|
||||
public int a() {
|
||||
public int getAliveCount() {
|
||||
int index = 0;
|
||||
|
||||
for (BaseGamer baseGamer : this.map.values()) {
|
||||
if (!baseGamer.f()) {
|
||||
if (!baseGamer.isSpectator()) {
|
||||
index++;
|
||||
}
|
||||
}
|
||||
@@ -49,7 +49,7 @@ public class DefaultGamerSet<G extends BaseGamer> extends PlayerRegistry<G> impl
|
||||
return index;
|
||||
}
|
||||
|
||||
public G a(Location location, Predicate<G> predicate) {
|
||||
public G getNearest(Location location, Predicate<G> predicate) {
|
||||
BaseGamer baseGamer = null;
|
||||
double doubleVal = Double.MAX_VALUE;
|
||||
Location location2 = new Location(null, 0.0, 0.0, 0.0);
|
||||
|
||||
@@ -26,106 +26,106 @@ public class GameMenu {
|
||||
|
||||
private final List<InventoryMenu> list = new ArrayList<>();
|
||||
|
||||
private static final int[] b = new int[] { 10, 11, 12, 13, 14, 15, 16, 19, 20, 21, 22, 23, 24, 25, 28, 29, 30, 31, 32, 33, 34 };
|
||||
private static final int[] ARENA_SLOTS = new int[] { 10, 11, 12, 13, 14, 15, 16, 19, 20, 21, 22, 23, 24, 25, 28, 29, 30, 31, 32, 33, 34 };
|
||||
|
||||
private final AbstractGameManager manager;
|
||||
|
||||
private final Supplier<List<Session>> d;
|
||||
private final Supplier<List<Session>> sessionsSupplier;
|
||||
|
||||
public GameMenu(AbstractGameManager manager2, Supplier<List<Session>> supplier) {
|
||||
this.manager = manager2;
|
||||
this.d = supplier;
|
||||
this.sessionsSupplier = supplier;
|
||||
}
|
||||
|
||||
public void a(DefaultUser defaultUser) {
|
||||
public void open(DefaultUser defaultUser) {
|
||||
if (!this.list.isEmpty()) {
|
||||
defaultUser.a(this.list.get(0));
|
||||
defaultUser.openMenu(this.list.get(0));
|
||||
}
|
||||
}
|
||||
|
||||
private void a(InventoryMenu inventoryMenu, HumanEntity humanEntity) {
|
||||
private void reopenMenu(InventoryMenu inventoryMenu, HumanEntity humanEntity) {
|
||||
DefaultUser defaultUser = (DefaultUser) this.manager.getEngine().getUsers().a(humanEntity.getUniqueId());
|
||||
if (defaultUser == null) {
|
||||
humanEntity.closeInventory();
|
||||
} else {
|
||||
defaultUser.a(inventoryMenu);
|
||||
defaultUser.openMenu(inventoryMenu);
|
||||
}
|
||||
}
|
||||
|
||||
private void a(int index, InventoryMenu inventoryMenu, InventoryMenu inventoryMenu2) {
|
||||
Context context = Contexts.a((VariableProvider) text -> text.equals("page") ? String.valueOf(index - 1) : null);
|
||||
inventoryMenu.a(18, defaultUser -> defaultUser.a(inventoryMenu2), new ItemBuilder(Material.ARROW).setDisplayName(this.manager.getMessages().getJoinArenasChangePageName().a(context)).build());
|
||||
Context context2 = Contexts.a((VariableProvider) text2 -> text2.equals("page") ? String.valueOf(index) : null);
|
||||
inventoryMenu2.a(26, defaultUser2 -> defaultUser2.a(inventoryMenu), new ItemBuilder(Material.ARROW).setDisplayName(this.manager.getMessages().getJoinArenasChangePageName().a(context2)).build());
|
||||
private void linkPages(int index, InventoryMenu inventoryMenu, InventoryMenu inventoryMenu2) {
|
||||
Context context = Contexts.ofVariables((VariableProvider) text -> text.equals("page") ? String.valueOf(index - 1) : null);
|
||||
inventoryMenu.setSlot(18, defaultUser -> defaultUser.openMenu(inventoryMenu2), new ItemBuilder(Material.ARROW).setDisplayName(this.manager.getMessages().getJoinArenasChangePageName().render(context)).build());
|
||||
Context context2 = Contexts.ofVariables((VariableProvider) text2 -> text2.equals("page") ? String.valueOf(index) : null);
|
||||
inventoryMenu2.setSlot(26, defaultUser2 -> defaultUser2.openMenu(inventoryMenu), new ItemBuilder(Material.ARROW).setDisplayName(this.manager.getMessages().getJoinArenasChangePageName().render(context2)).build());
|
||||
}
|
||||
|
||||
private void a(int index) {
|
||||
private void expandPages(int index) {
|
||||
if (index == 1) {
|
||||
this.list.add(new InventoryMenu(this.manager.getMessages().getJoinArenasName(), 45));
|
||||
}
|
||||
for (int index2 = this.list.size(); index2 < index; index2++) {
|
||||
int index3 = index2 + 1;
|
||||
Context context = Contexts.a((VariableProvider) text -> text.equals("page") ? String.valueOf(index3) : null);
|
||||
InventoryMenu inventoryMenu = new InventoryMenu(this.manager.getMessages().getJoinArenasPageName().a(context), 45);
|
||||
Context context = Contexts.ofVariables((VariableProvider) text -> text.equals("page") ? String.valueOf(index3) : null);
|
||||
InventoryMenu inventoryMenu = new InventoryMenu(this.manager.getMessages().getJoinArenasPageName().render(context), 45);
|
||||
if (!this.list.isEmpty()) {
|
||||
this.a(index3, inventoryMenu, this.list.get(this.list.size() - 1));
|
||||
this.linkPages(index3, inventoryMenu, this.list.get(this.list.size() - 1));
|
||||
}
|
||||
this.list.add(inventoryMenu);
|
||||
}
|
||||
}
|
||||
|
||||
private void b(int index) {
|
||||
private void shrinkPages(int index) {
|
||||
ArrayList<HumanEntity> list2 = new ArrayList<>();
|
||||
while (this.list.size() > index) {
|
||||
list2.addAll(this.list.remove(this.list.size() - 1).a().getViewers());
|
||||
list2.addAll(this.list.remove(this.list.size() - 1).getInventory().getViewers());
|
||||
}
|
||||
InventoryMenu inventoryMenu = this.list.get(index - 1);
|
||||
if (index == 1) {
|
||||
inventoryMenu.a(this.manager.getMessages().getJoinArenasName());
|
||||
inventoryMenu.setTitle(this.manager.getMessages().getJoinArenasName());
|
||||
}
|
||||
inventoryMenu.a(17, null, null);
|
||||
inventoryMenu.setSlot(17, null, null);
|
||||
for (HumanEntity humanEntity : list2) {
|
||||
this.a(inventoryMenu, humanEntity);
|
||||
this.reopenMenu(inventoryMenu, humanEntity);
|
||||
}
|
||||
}
|
||||
|
||||
private void c(int index) {
|
||||
private void resizePages(int index) {
|
||||
if (index != this.list.size()) {
|
||||
if (index > this.list.size()) {
|
||||
this.a(index);
|
||||
this.expandPages(index);
|
||||
} else {
|
||||
this.b(index);
|
||||
this.shrinkPages(index);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public void a() {
|
||||
List<Session> list2 = this.d.get();
|
||||
public void update() {
|
||||
List<Session> list2 = this.sessionsSupplier.get();
|
||||
list2.removeIf(session -> session.getStatus().phaseType() != PhaseType.WAITING);
|
||||
list2.sort(Comparator.comparingInt(session2 -> session2.getStatus().players()));
|
||||
this.c(Math.max(1, IntMath.divide(list2.size(), 21, RoundingMode.CEILING)));
|
||||
this.resizePages(Math.max(1, IntMath.divide(list2.size(), 21, RoundingMode.CEILING)));
|
||||
for (InventoryMenu inventoryMenu : this.list) {
|
||||
inventoryMenu.a(40, defaultUser -> {
|
||||
inventoryMenu.setSlot(40, defaultUser -> {
|
||||
InventoryMenu inventoryMenu2 = defaultUser.getMenu();
|
||||
if (inventoryMenu2 != null) {
|
||||
defaultUser.a(inventoryMenu2);
|
||||
defaultUser.openMenu(inventoryMenu2);
|
||||
}
|
||||
}, new ItemBuilder(Material.ARROW).setDisplayName(this.manager.getMessages().getJoinArenasGoBack()).build());
|
||||
for (int index = 0; index < 21; index++) {
|
||||
if (!list2.isEmpty()) {
|
||||
this.a(inventoryMenu, b[index], (Session) list2.remove(list2.size() - 1));
|
||||
this.setArenaButton(inventoryMenu, ARENA_SLOTS[index], (Session) list2.remove(list2.size() - 1));
|
||||
} else {
|
||||
inventoryMenu.a(b[index], null, null);
|
||||
inventoryMenu.setSlot(ARENA_SLOTS[index], null, null);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private void a(InventoryMenu inventoryMenu, int index, Session session) {
|
||||
private void setArenaButton(InventoryMenu inventoryMenu, int index, Session session) {
|
||||
ItemBuilder itemBuilder = new ItemBuilder(ArcadeMaterial.FIREWORK_STAR);
|
||||
itemBuilder.setDisplayName(this.manager.getMessages().getJoinArenasArenaName().a(session));
|
||||
itemBuilder.setLore(TextRenderer.a(this.manager.getMessages().getJoinArenasArenaLore(), session));
|
||||
inventoryMenu.a(index, defaultUser -> {
|
||||
itemBuilder.setDisplayName(this.manager.getMessages().getJoinArenasArenaName().render(session));
|
||||
itemBuilder.setLore(TextRenderer.render(this.manager.getMessages().getJoinArenasArenaLore(), session));
|
||||
inventoryMenu.setSlot(index, defaultUser -> {
|
||||
Player player = defaultUser.toPlayer();
|
||||
player.closeInventory();
|
||||
Result result = session.canPlay(defaultUser);
|
||||
|
||||
@@ -51,7 +51,7 @@ public class ItemBuilder {
|
||||
}
|
||||
|
||||
public ItemBuilder setDisplayName(Text text, Context context) {
|
||||
this.meta.setDisplayName(text.a(context));
|
||||
this.meta.setDisplayName(text.render(context));
|
||||
return this;
|
||||
}
|
||||
|
||||
|
||||
@@ -4,7 +4,7 @@ import org.bukkit.Material;
|
||||
import ro.fr33styler.arcade.platform.compat.VersionAdapters;
|
||||
|
||||
public final class Materials {
|
||||
public static boolean a(Material material) {
|
||||
public static boolean isWool(Material material) {
|
||||
return VersionAdapters.get().isWoolMaterial(material);
|
||||
}
|
||||
}
|
||||
|
||||
+8
-8
@@ -41,23 +41,23 @@ public class AddLeaderboardCommand implements CommandExecutor {
|
||||
player.sendMessage("§cThe id is already in use!");
|
||||
} else {
|
||||
Location location = player.getLocation();
|
||||
this.engine.getDisplayManager().a(text2, location);
|
||||
LeaderboardGroup leaderboardGroup = (LeaderboardGroup)this.engine.getDisplayManager().b().get(text2);
|
||||
this.engine.getDisplayManager().addLeaderboardGroup(text2, location);
|
||||
LeaderboardGroup leaderboardGroup = (LeaderboardGroup)this.engine.getDisplayManager().getLeaderboardGroups().get(text2);
|
||||
|
||||
for (AbstractGameManager abstractGameManager : this.engine.getGameManagerRegistry()) {
|
||||
for (GameLeaderboardSettings gameLeaderboardSettings : abstractGameManager.getStorage().getStorage4().getLeaderboards().values()) {
|
||||
if (gameLeaderboardSettings.getId().equals(leaderboardGroup.a()) && abstractGameManager.getLeaderboardSources().containsKey(gameLeaderboardSettings.getColumn())) {
|
||||
for (GameLeaderboardSettings gameLeaderboardSettings : abstractGameManager.getStorage().getLeaderboardStorage().getLeaderboards().values()) {
|
||||
if (gameLeaderboardSettings.getId().equals(leaderboardGroup.getId()) && abstractGameManager.getLeaderboardSources().containsKey(gameLeaderboardSettings.getColumn())) {
|
||||
LeaderboardSource leaderboardSource = abstractGameManager.createLeaderboardSource(gameLeaderboardSettings);
|
||||
leaderboardGroup.getMap().put(leaderboardSource.getSettings().getMode(), leaderboardSource);
|
||||
leaderboardSource.d();
|
||||
leaderboardSource.refreshCache();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
this.engine.getDisplayManager().g();
|
||||
this.engine.getUsers().c(leaderboardGroup);
|
||||
this.engine.getDisplayManager().refreshLeaderboardToggles();
|
||||
this.engine.getUsers().refreshLeaderboardGroup(leaderboardGroup);
|
||||
this.engine.getDatabaseManager().getLeaderboards().put(text2, location);
|
||||
this.engine.getDatabaseManager().f();
|
||||
this.engine.getDatabaseManager().saveConfig();
|
||||
player.sendMessage("§aLeaderboard added!");
|
||||
}
|
||||
}
|
||||
|
||||
+8
-8
@@ -47,30 +47,30 @@ public class AddLeaderboardModeCommand implements CommandExecutor {
|
||||
Location location = player.getEyeLocation();
|
||||
String text2 = texts[index];
|
||||
String text3 = this.manager.getLeaderboardTitles().isEmpty() ? this.manager.getName() : texts[index + 1];
|
||||
Collection collection = this.manager.getEngine().getDisplayManager().b().values();
|
||||
LeaderboardGroup leaderboardGroup = (LeaderboardGroup)ViewDistance.a(location, collection, LeaderboardGroup::getLocation);
|
||||
Collection collection = this.manager.getEngine().getDisplayManager().getLeaderboardGroups().values();
|
||||
LeaderboardGroup leaderboardGroup = (LeaderboardGroup)ViewDistance.findTarget(location, collection, LeaderboardGroup::getLocation);
|
||||
if (leaderboardGroup == null) {
|
||||
player.sendMessage("§cYou must look at the leaderboard!");
|
||||
} else if (leaderboardGroup.getMap().containsKey(text3)) {
|
||||
player.sendMessage("§cThe leaderboard already has this mode!");
|
||||
} else {
|
||||
GameLeaderboardSettings gameLeaderboardSettings = new GameLeaderboardSettings();
|
||||
gameLeaderboardSettings.setId(leaderboardGroup.a());
|
||||
gameLeaderboardSettings.setId(leaderboardGroup.getId());
|
||||
gameLeaderboardSettings.setMode(text3);
|
||||
gameLeaderboardSettings.setColumn(text2);
|
||||
gameLeaderboardSettings.setLocation(leaderboardGroup.getLocation());
|
||||
LeaderboardSource leaderboardSource = this.manager.createLeaderboardSource(gameLeaderboardSettings);
|
||||
leaderboardGroup.getMap().put(text3, leaderboardSource);
|
||||
leaderboardSource.d();
|
||||
leaderboardSource.refreshCache();
|
||||
int index2 = 0;
|
||||
|
||||
while (this.manager.getStorage().getStorage4().getLeaderboards().containsKey(String.valueOf(index2))) {
|
||||
while (this.manager.getStorage().getLeaderboardStorage().getLeaderboards().containsKey(String.valueOf(index2))) {
|
||||
index2++;
|
||||
}
|
||||
|
||||
this.manager.getStorage().getStorage4().getLeaderboards().put(String.valueOf(index2), gameLeaderboardSettings);
|
||||
this.manager.getStorage().getStorage4().c();
|
||||
this.manager.getEngine().getDisplayManager().a(leaderboardGroup);
|
||||
this.manager.getStorage().getLeaderboardStorage().getLeaderboards().put(String.valueOf(index2), gameLeaderboardSettings);
|
||||
this.manager.getStorage().getLeaderboardStorage().save();
|
||||
this.manager.getEngine().getDisplayManager().updateLeaderboardGroup(leaderboardGroup);
|
||||
sender.sendMessage("§aThe mode has been added!");
|
||||
}
|
||||
}
|
||||
|
||||
+2
-2
@@ -46,9 +46,9 @@ public class AddLeaderboardToggleCommand implements CommandExecutor {
|
||||
LeaderboardToggleSettings leaderboardToggleSettings = new LeaderboardToggleSettings();
|
||||
leaderboardToggleSettings.setLocation(location);
|
||||
leaderboardToggleSettings.getLeaderboardIds().addAll(Arrays.asList(text2.split(",")));
|
||||
this.engine.getDisplayManager().a(text3, leaderboardToggleSettings);
|
||||
this.engine.getDisplayManager().addLeaderboardToggle(text3, leaderboardToggleSettings);
|
||||
this.engine.getDatabaseManager().getTogglersData().put(text3, leaderboardToggleSettings);
|
||||
this.engine.getDatabaseManager().f();
|
||||
this.engine.getDatabaseManager().saveConfig();
|
||||
player.sendMessage("§aToggler added!");
|
||||
}
|
||||
}
|
||||
+7
-7
@@ -29,21 +29,21 @@ public class RemoveLeaderboardCommand extends BaseCommandExecutor {
|
||||
public void execute(CommandSender sender, String text, String[] texts, int index) {
|
||||
Player player = (Player)sender;
|
||||
Location location = player.getEyeLocation();
|
||||
Collection collection = this.engine.getDisplayManager().b().values();
|
||||
LeaderboardGroup leaderboardGroup = (LeaderboardGroup)ViewDistance.a(location, collection, LeaderboardGroup::getLocation);
|
||||
Collection collection = this.engine.getDisplayManager().getLeaderboardGroups().values();
|
||||
LeaderboardGroup leaderboardGroup = (LeaderboardGroup)ViewDistance.findTarget(location, collection, LeaderboardGroup::getLocation);
|
||||
if (leaderboardGroup == null) {
|
||||
player.sendMessage("§cYou must look at the leaderboard!");
|
||||
} else {
|
||||
collection.remove(leaderboardGroup);
|
||||
|
||||
for (DefaultUser defaultUser : this.engine.getUsers()) {
|
||||
defaultUser.b(leaderboardGroup);
|
||||
defaultUser.removeLeaderboardDisplay(leaderboardGroup);
|
||||
}
|
||||
|
||||
this.engine.getDatabaseManager().getLeaderboards().remove(leaderboardGroup.a());
|
||||
this.engine.getDatabaseManager().f();
|
||||
this.engine.getDisplayManager().g();
|
||||
this.engine.getUsers().c(leaderboardGroup);
|
||||
this.engine.getDatabaseManager().getLeaderboards().remove(leaderboardGroup.getId());
|
||||
this.engine.getDatabaseManager().saveConfig();
|
||||
this.engine.getDisplayManager().refreshLeaderboardToggles();
|
||||
this.engine.getUsers().refreshLeaderboardGroup(leaderboardGroup);
|
||||
player.sendMessage("§aThe leaderboard has been removed!");
|
||||
}
|
||||
}
|
||||
|
||||
+5
-5
@@ -44,8 +44,8 @@ public class RemoveLeaderboardModeCommand implements CommandExecutor {
|
||||
public void execute(CommandSender sender, String text, String[] texts, int index) {
|
||||
Player player = (Player)sender;
|
||||
Location location = player.getEyeLocation();
|
||||
Collection collection = this.manager.getEngine().getDisplayManager().b().values();
|
||||
LeaderboardGroup leaderboardGroup = (LeaderboardGroup)ViewDistance.a(location, collection, LeaderboardGroup::getLocation);
|
||||
Collection collection = this.manager.getEngine().getDisplayManager().getLeaderboardGroups().values();
|
||||
LeaderboardGroup leaderboardGroup = (LeaderboardGroup)ViewDistance.findTarget(location, collection, LeaderboardGroup::getLocation);
|
||||
if (leaderboardGroup == null) {
|
||||
player.sendMessage("§cYou must look at the leaderboard!");
|
||||
} else {
|
||||
@@ -53,9 +53,9 @@ public class RemoveLeaderboardModeCommand implements CommandExecutor {
|
||||
if (leaderboardSource == null) {
|
||||
player.sendMessage("§cThe leaderboard doesn't have this mode!");
|
||||
} else {
|
||||
this.manager.getStorage().getStorage4().getLeaderboards().entrySet().removeIf(entry -> entry.getValue() == leaderboardSource.getSettings());
|
||||
this.manager.getStorage().getStorage4().c();
|
||||
this.manager.getEngine().getDisplayManager().a(leaderboardGroup);
|
||||
this.manager.getStorage().getLeaderboardStorage().getLeaderboards().entrySet().removeIf(entry -> entry.getValue() == leaderboardSource.getSettings());
|
||||
this.manager.getStorage().getLeaderboardStorage().save();
|
||||
this.manager.getEngine().getDisplayManager().updateLeaderboardGroup(leaderboardGroup);
|
||||
player.sendMessage("§aThe mode has been removed!");
|
||||
}
|
||||
}
|
||||
|
||||
+7
-7
@@ -30,26 +30,26 @@ public class RemoveLeaderboardToggleCommand extends BaseCommandExecutor {
|
||||
public void execute(CommandSender sender, String text, String[] texts, int index) {
|
||||
Player player = (Player)sender;
|
||||
Location location = player.getEyeLocation();
|
||||
List list = this.engine.getDisplayManager().c();
|
||||
LeaderboardToggle leaderboardToggle = (LeaderboardToggle)ViewDistance.a(location, list, LeaderboardToggle::b);
|
||||
List list = this.engine.getDisplayManager().getLeaderboardToggles();
|
||||
LeaderboardToggle leaderboardToggle = (LeaderboardToggle)ViewDistance.findTarget(location, list, LeaderboardToggle::getLocation);
|
||||
if (leaderboardToggle == null) {
|
||||
player.sendMessage("§cYou must look at the toggler!");
|
||||
} else {
|
||||
list.remove(leaderboardToggle);
|
||||
|
||||
for (DefaultUser defaultUser : this.engine.getUsers()) {
|
||||
defaultUser.b(leaderboardToggle);
|
||||
defaultUser.removeLeaderboardToggle(leaderboardToggle);
|
||||
}
|
||||
|
||||
for (String text2 : leaderboardToggle.getSettings().getLeaderboardIds()) {
|
||||
LeaderboardGroup leaderboardGroup = (LeaderboardGroup)this.engine.getDisplayManager().b().get(text2);
|
||||
LeaderboardGroup leaderboardGroup = (LeaderboardGroup)this.engine.getDisplayManager().getLeaderboardGroups().get(text2);
|
||||
if (leaderboardGroup != null) {
|
||||
this.engine.getUsers().c(leaderboardGroup);
|
||||
this.engine.getUsers().refreshLeaderboardGroup(leaderboardGroup);
|
||||
}
|
||||
}
|
||||
|
||||
this.engine.getDatabaseManager().getTogglersData().remove(leaderboardToggle.a());
|
||||
this.engine.getDatabaseManager().f();
|
||||
this.engine.getDatabaseManager().getTogglersData().remove(leaderboardToggle.getId());
|
||||
this.engine.getDatabaseManager().saveConfig();
|
||||
player.sendMessage("§aThe toggler has been removed!");
|
||||
}
|
||||
}
|
||||
|
||||
+27
-27
@@ -29,7 +29,7 @@ public class LeaderboardDisplay implements Context, Viewable {
|
||||
|
||||
private LeaderboardSource leaderboardSource;
|
||||
|
||||
private int c;
|
||||
private int viewerRank;
|
||||
|
||||
private LeaderboardEntry leaderboardEntry;
|
||||
|
||||
@@ -45,7 +45,7 @@ public class LeaderboardDisplay implements Context, Viewable {
|
||||
this.hologram = new Hologram(leaderboardGroup2.getLocation());
|
||||
this.leaderboardPeriod = leaderboardGroup2.getEngine().getSettings().getLeaderboardDefaultPosition();
|
||||
this.leaderboardSource = (LeaderboardSource) Iterables.getFirst(leaderboardGroup2.getMap().values(), null);
|
||||
this.e();
|
||||
this.refreshViewerPosition();
|
||||
}
|
||||
|
||||
public LeaderboardGroup getLeaderboardGroup() {
|
||||
@@ -56,18 +56,18 @@ public class LeaderboardDisplay implements Context, Viewable {
|
||||
return this.leaderboardPeriod;
|
||||
}
|
||||
|
||||
public void a(LeaderboardPeriod leaderboardPeriod2) {
|
||||
public void setLeaderboardPeriod(LeaderboardPeriod leaderboardPeriod2) {
|
||||
this.leaderboardPeriod = leaderboardPeriod2;
|
||||
this.e();
|
||||
this.refreshViewerPosition();
|
||||
}
|
||||
|
||||
public void a(String text) {
|
||||
public void setMode(String text) {
|
||||
this.leaderboardSource = (LeaderboardSource) this.leaderboardGroup.getMap().get(text);
|
||||
this.e();
|
||||
this.refreshViewerPosition();
|
||||
}
|
||||
|
||||
public boolean a(int index) {
|
||||
return this.hologram.a(index);
|
||||
public boolean hasEntityId(int index) {
|
||||
return this.hologram.hasEntityId(index);
|
||||
}
|
||||
|
||||
public Location getLocation() {
|
||||
@@ -78,8 +78,8 @@ public class LeaderboardDisplay implements Context, Viewable {
|
||||
return this.hologram.getSet();
|
||||
}
|
||||
|
||||
public void a(Player player2, boolean flag) {
|
||||
this.hologram.a(player2, flag);
|
||||
public void setVisible(Player player2, boolean flag) {
|
||||
this.hologram.setVisible(player2, flag);
|
||||
}
|
||||
|
||||
public Boolean getCondition(String text) {
|
||||
@@ -101,61 +101,61 @@ public class LeaderboardDisplay implements Context, Viewable {
|
||||
if (text.startsWith("position_")) {
|
||||
boolean flag = text.endsWith("_score");
|
||||
int index = NumberUtils.toInt(text.substring(9, text.length() - (flag ? 6 : 0))) - 1;
|
||||
LeaderboardEntry[] leaderboardEntrys = this.leaderboardSource.a(this.leaderboardPeriod);
|
||||
LeaderboardEntry[] leaderboardEntrys = this.leaderboardSource.getTopEntries(this.leaderboardPeriod);
|
||||
if (index < 0 || index >= leaderboardEntrys.length) {
|
||||
return null;
|
||||
} else {
|
||||
return flag ? Strings.b(leaderboardEntrys[index].score(), 3) : this.b(leaderboardEntrys[index].name());
|
||||
return flag ? Strings.groupDigits(leaderboardEntrys[index].score(), 3) : this.formatPlayerName(leaderboardEntrys[index].name());
|
||||
}
|
||||
} else {
|
||||
return switch(text) {
|
||||
case "type" ->
|
||||
this.leaderboardSource.b();
|
||||
this.leaderboardSource.getSourceTitle();
|
||||
case "mode" ->
|
||||
this.leaderboardSource.c();
|
||||
this.leaderboardSource.getModeTitle();
|
||||
case "time" ->
|
||||
this.leaderboardPeriod.a(this.getLeaderboardGroup().getEngine().getMessages());
|
||||
this.leaderboardPeriod.getDisplayName(this.getLeaderboardGroup().getEngine().getMessages());
|
||||
case "viewer_rank" ->
|
||||
this.leaderboardEntry == null ? null : Strings.b(this.c, 3);
|
||||
this.leaderboardEntry == null ? null : Strings.groupDigits(this.viewerRank, 3);
|
||||
case "viewer_name" ->
|
||||
this.leaderboardEntry == null ? null : this.b(this.leaderboardEntry.name());
|
||||
this.leaderboardEntry == null ? null : this.formatPlayerName(this.leaderboardEntry.name());
|
||||
case "viewer_score" ->
|
||||
this.leaderboardEntry == null ? null : Strings.b(this.leaderboardEntry.score(), 3);
|
||||
this.leaderboardEntry == null ? null : Strings.groupDigits(this.leaderboardEntry.score(), 3);
|
||||
default ->
|
||||
null;
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
private String b(String text) {
|
||||
private String formatPlayerName(String text) {
|
||||
DefaultEngine defaultEngine = this.leaderboardGroup.getEngine();
|
||||
if (defaultEngine.getSettings().isLeaderboardWithPapiSupport() && defaultEngine.hasPlaceholderResolver()) {
|
||||
OfflinePlayer offlinePlayer = Bukkit.getOfflinePlayer(text);
|
||||
String text2 = defaultEngine.getMessages().getLeaderboardNamePapiFormat();
|
||||
return Strings.d(defaultEngine.getPlaceholderResolver().a(offlinePlayer, text2.replace("%name%", text)));
|
||||
return Strings.translateHexColors(defaultEngine.getPlaceholderResolver().resolve(offlinePlayer, text2.replace("%name%", text)));
|
||||
} else {
|
||||
return text;
|
||||
}
|
||||
}
|
||||
|
||||
public void e() {
|
||||
this.c = 0;
|
||||
public void refreshViewerPosition() {
|
||||
this.viewerRank = 0;
|
||||
this.leaderboardEntry = null;
|
||||
if (this.leaderboardSource != null && this.getLeaderboardGroup().getEngine().getSettings().isLeaderboardViewerPosition()) {
|
||||
this.leaderboardSource.a(this.player, this.leaderboardPeriod, (leaderboardEntry2, integer) -> {
|
||||
this.leaderboardSource.fetchPlayerRank(this.player, this.leaderboardPeriod, (leaderboardEntry2, integer) -> {
|
||||
if (integer > 10) {
|
||||
this.c = integer;
|
||||
this.viewerRank = integer;
|
||||
this.leaderboardEntry = leaderboardEntry2;
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
public void a(ServerPlatform serverPlatform, List<Text> list) {
|
||||
public void render(ServerPlatform serverPlatform, List<Text> list) {
|
||||
if (this.leaderboardSource == null) {
|
||||
this.hologram.a(serverPlatform, new String[] { ChatColor.RED + "No modes found!" });
|
||||
this.hologram.setLines(serverPlatform, new String[] { ChatColor.RED + "No modes found!" });
|
||||
} else {
|
||||
this.hologram.a(serverPlatform, TextRenderer.a(list, this));
|
||||
this.hologram.setLines(serverPlatform, TextRenderer.render(list, this));
|
||||
}
|
||||
}
|
||||
}
|
||||
+18
-18
@@ -18,12 +18,12 @@ import org.bukkit.entity.Player;
|
||||
import ro.fr33styler.arcade.api.engine.text.Context;
|
||||
|
||||
public class LeaderboardToggleDisplay implements Context, Viewable {
|
||||
private int a;
|
||||
private int selectedIndex;
|
||||
private final LeaderboardToggle leaderboardToggle;
|
||||
private final Hologram hologram;
|
||||
|
||||
public LeaderboardToggleDisplay(LeaderboardToggle leaderboardToggle2) {
|
||||
this.hologram = new Hologram(leaderboardToggle2.b());
|
||||
this.hologram = new Hologram(leaderboardToggle2.getLocation());
|
||||
this.leaderboardToggle = leaderboardToggle2;
|
||||
}
|
||||
|
||||
@@ -31,16 +31,16 @@ public class LeaderboardToggleDisplay implements Context, Viewable {
|
||||
return this.leaderboardToggle;
|
||||
}
|
||||
|
||||
public int b() {
|
||||
return this.a;
|
||||
public int getSelectedIndex() {
|
||||
return this.selectedIndex;
|
||||
}
|
||||
|
||||
public void a(int index) {
|
||||
this.a = index;
|
||||
public void setSelectedIndex(int index) {
|
||||
this.selectedIndex = index;
|
||||
}
|
||||
|
||||
public boolean b(int index) {
|
||||
return this.hologram.a(index);
|
||||
public boolean hasEntityId(int index) {
|
||||
return this.hologram.hasEntityId(index);
|
||||
}
|
||||
|
||||
public Location getLocation() {
|
||||
@@ -51,13 +51,13 @@ public class LeaderboardToggleDisplay implements Context, Viewable {
|
||||
return this.hologram.getSet();
|
||||
}
|
||||
|
||||
public LeaderboardSource c(int index) {
|
||||
public LeaderboardSource getSourceAt(int index) {
|
||||
if (this.leaderboardToggle.getList().isEmpty()) {
|
||||
return null;
|
||||
}
|
||||
|
||||
for (String text : this.leaderboardToggle.getSettings().getLeaderboardIds()) {
|
||||
LeaderboardGroup leaderboardGroup = (LeaderboardGroup)this.leaderboardToggle.getEngine().getDisplayManager().b().get(text);
|
||||
LeaderboardGroup leaderboardGroup = (LeaderboardGroup)this.leaderboardToggle.getEngine().getDisplayManager().getLeaderboardGroups().get(text);
|
||||
if (leaderboardGroup != null) {
|
||||
int index2 = index % this.leaderboardToggle.getList().size();
|
||||
return (LeaderboardSource)leaderboardGroup.getMap().get(this.leaderboardToggle.getList().get(index2));
|
||||
@@ -67,24 +67,24 @@ public class LeaderboardToggleDisplay implements Context, Viewable {
|
||||
return null;
|
||||
}
|
||||
|
||||
public void a(Player player, boolean flag) {
|
||||
this.hologram.a(player, flag);
|
||||
public void setVisible(Player player, boolean flag) {
|
||||
this.hologram.setVisible(player, flag);
|
||||
}
|
||||
|
||||
public String getVariable(String text) {
|
||||
return switch (text) {
|
||||
case "mode_1" -> this.c(this.b()).c();
|
||||
case "mode_2" -> this.c(this.b() + 1).c();
|
||||
case "mode_3" -> this.c(this.b() + 2).c();
|
||||
case "mode_1" -> this.getSourceAt(this.getSelectedIndex()).getModeTitle();
|
||||
case "mode_2" -> this.getSourceAt(this.getSelectedIndex() + 1).getModeTitle();
|
||||
case "mode_3" -> this.getSourceAt(this.getSelectedIndex() + 2).getModeTitle();
|
||||
default -> null;
|
||||
};
|
||||
}
|
||||
|
||||
public void a(ServerPlatform serverPlatform, List<Text> list) {
|
||||
public void render(ServerPlatform serverPlatform, List<Text> list) {
|
||||
if (this.leaderboardToggle.getList().isEmpty()) {
|
||||
this.hologram.a(serverPlatform, new String[]{ChatColor.RED + "No modes found!"});
|
||||
this.hologram.setLines(serverPlatform, new String[]{ChatColor.RED + "No modes found!"});
|
||||
} else {
|
||||
this.hologram.a(serverPlatform, TextRenderer.a(list, this));
|
||||
this.hologram.setLines(serverPlatform, TextRenderer.render(list, this));
|
||||
}
|
||||
}
|
||||
}
|
||||
+6
-6
@@ -8,19 +8,19 @@ import java.util.Map;
|
||||
import org.bukkit.Location;
|
||||
|
||||
public class LeaderboardGroup {
|
||||
private final String a;
|
||||
private final String id;
|
||||
private final Location location;
|
||||
private final DefaultEngine engine;
|
||||
private final Map<String, LeaderboardSource> map = new LinkedHashMap<>();
|
||||
|
||||
public LeaderboardGroup(DefaultEngine engine2, String text, Location location2) {
|
||||
this.a = text;
|
||||
this.id = text;
|
||||
this.location = location2;
|
||||
this.engine = engine2;
|
||||
}
|
||||
|
||||
public String a() {
|
||||
return this.a;
|
||||
public String getId() {
|
||||
return this.id;
|
||||
}
|
||||
|
||||
public Location getLocation() {
|
||||
@@ -35,7 +35,7 @@ public class LeaderboardGroup {
|
||||
return this.map;
|
||||
}
|
||||
|
||||
public void e() {
|
||||
this.map.values().forEach(LeaderboardSource::d);
|
||||
public void refresh() {
|
||||
this.map.values().forEach(LeaderboardSource::refreshCache);
|
||||
}
|
||||
}
|
||||
+7
-7
@@ -7,18 +7,18 @@ public enum LeaderboardPeriod {
|
||||
MONTHLY("_monthly"),
|
||||
WEEKLY("_weekly");
|
||||
|
||||
private final String d;
|
||||
private static final LeaderboardPeriod[] e = {LIFETIME, MONTHLY, WEEKLY};
|
||||
private final String tableSuffix;
|
||||
private static final LeaderboardPeriod[] VALUES = {LIFETIME, MONTHLY, WEEKLY};
|
||||
|
||||
LeaderboardPeriod(String text) {
|
||||
this.d = text;
|
||||
this.tableSuffix = text;
|
||||
}
|
||||
|
||||
public String a() {
|
||||
return this.d;
|
||||
public String getTableSuffix() {
|
||||
return this.tableSuffix;
|
||||
}
|
||||
|
||||
public LeaderboardPeriod b() {
|
||||
public LeaderboardPeriod next() {
|
||||
return switch (this) {
|
||||
case LIFETIME -> MONTHLY;
|
||||
case MONTHLY -> WEEKLY;
|
||||
@@ -26,7 +26,7 @@ public enum LeaderboardPeriod {
|
||||
};
|
||||
}
|
||||
|
||||
public String a(EngineMessages engineMessages) {
|
||||
public String getDisplayName(EngineMessages engineMessages) {
|
||||
return switch (this) {
|
||||
case LIFETIME -> engineMessages.getLeaderboardTimeLifetime();
|
||||
case MONTHLY -> engineMessages.getLeaderboardTimeMonthly();
|
||||
|
||||
+7
-7
@@ -8,22 +8,22 @@ import java.util.List;
|
||||
import org.bukkit.Location;
|
||||
|
||||
public class LeaderboardToggle {
|
||||
private final String a;
|
||||
private final String id;
|
||||
private final LeaderboardToggleSettings settings;
|
||||
private final DefaultEngine engine;
|
||||
private final List<String> list = new ArrayList<>();
|
||||
|
||||
public LeaderboardToggle(DefaultEngine engine2, String text, LeaderboardToggleSettings settings2) {
|
||||
this.a = text;
|
||||
this.id = text;
|
||||
this.settings = settings2;
|
||||
this.engine = engine2;
|
||||
}
|
||||
|
||||
public String a() {
|
||||
return this.a;
|
||||
public String getId() {
|
||||
return this.id;
|
||||
}
|
||||
|
||||
public Location b() {
|
||||
public Location getLocation() {
|
||||
return this.settings.getLocation();
|
||||
}
|
||||
|
||||
@@ -39,11 +39,11 @@ public class LeaderboardToggle {
|
||||
return this.list;
|
||||
}
|
||||
|
||||
public void f() {
|
||||
public void refreshAvailableModes() {
|
||||
this.list.clear();
|
||||
|
||||
for (String text : this.settings.getLeaderboardIds()) {
|
||||
LeaderboardGroup leaderboardGroup = (LeaderboardGroup)this.engine.getDisplayManager().b().get(text);
|
||||
LeaderboardGroup leaderboardGroup = (LeaderboardGroup)this.engine.getDisplayManager().getLeaderboardGroups().get(text);
|
||||
if (leaderboardGroup != null) {
|
||||
if (this.list.isEmpty() && leaderboardGroup.getMap().isEmpty()) {
|
||||
return;
|
||||
|
||||
+13
-13
@@ -13,7 +13,7 @@ import org.bukkit.entity.Player;
|
||||
|
||||
public class StoredLeaderboard extends LeaderboardSource {
|
||||
private final AbstractGameManager manager;
|
||||
private final Function<GameLeaderboardSettings, String> b;
|
||||
private final Function<GameLeaderboardSettings, String> tableNameResolver;
|
||||
private final Map<LeaderboardPeriod, LeaderboardEntry[]> map = new EnumMap<>(LeaderboardPeriod.class);
|
||||
|
||||
public StoredLeaderboard(AbstractGameManager abstractGameManager, GameLeaderboardSettings gameLeaderboardSettings, String text) {
|
||||
@@ -23,11 +23,11 @@ public class StoredLeaderboard extends LeaderboardSource {
|
||||
public StoredLeaderboard(AbstractGameManager manager2, GameLeaderboardSettings gameLeaderboardSettings, Function<GameLeaderboardSettings, String> function) {
|
||||
super(gameLeaderboardSettings);
|
||||
this.manager = manager2;
|
||||
this.b = function;
|
||||
this.e();
|
||||
this.tableNameResolver = function;
|
||||
this.initializePlaceholders();
|
||||
}
|
||||
|
||||
private void e() {
|
||||
private void initializePlaceholders() {
|
||||
for (LeaderboardPeriod leaderboardPeriod : LeaderboardPeriod.values()) {
|
||||
LeaderboardEntry[] leaderboardEntrys = new LeaderboardEntry[10];
|
||||
|
||||
@@ -40,31 +40,31 @@ public class StoredLeaderboard extends LeaderboardSource {
|
||||
}
|
||||
|
||||
@Override
|
||||
public String c() {
|
||||
public String getModeTitle() {
|
||||
return this.manager.getLeaderboardTitles().isEmpty() ? this.manager.getMessages().getDisplayName() : (String)((Supplier)this.manager.getLeaderboardTitles().get(this.getSettings().getMode())).get();
|
||||
}
|
||||
|
||||
@Override
|
||||
public String b() {
|
||||
public String getSourceTitle() {
|
||||
return (String)((Supplier)this.manager.getLeaderboardSources().get(this.getSettings().getColumn())).get();
|
||||
}
|
||||
|
||||
@Override
|
||||
public LeaderboardEntry[] a(LeaderboardPeriod leaderboardPeriod) {
|
||||
public LeaderboardEntry[] getTopEntries(LeaderboardPeriod leaderboardPeriod) {
|
||||
return this.map.get(leaderboardPeriod);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void a(Player player, LeaderboardPeriod leaderboardPeriod, BiConsumer<LeaderboardEntry, Integer> biConsumer) {
|
||||
String text = this.b.apply(this.getSettings()) + leaderboardPeriod.a();
|
||||
this.manager.getStorage().e().a(player, text, this.getSettings().getColumn(), biConsumer);
|
||||
public void fetchPlayerRank(Player player, LeaderboardPeriod leaderboardPeriod, BiConsumer<LeaderboardEntry, Integer> biConsumer) {
|
||||
String text = this.tableNameResolver.apply(this.getSettings()) + leaderboardPeriod.getTableSuffix();
|
||||
this.manager.getStorage().getStatisticsRepository().fetchPlayerRank(player, text, this.getSettings().getColumn(), biConsumer);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void d() {
|
||||
public void refreshCache() {
|
||||
for (LeaderboardPeriod leaderboardPeriod : LeaderboardPeriod.values()) {
|
||||
String text = this.b.apply(this.getSettings()) + leaderboardPeriod.a();
|
||||
this.manager.getStorage().e().a(text, this.getSettings().getColumn(), leaderboardEntrys -> this.map.put(leaderboardPeriod, leaderboardEntrys));
|
||||
String text = this.tableNameResolver.apply(this.getSettings()) + leaderboardPeriod.getTableSuffix();
|
||||
this.manager.getStorage().getStatisticsRepository().fetchTopEntries(text, this.getSettings().getColumn(), leaderboardEntrys -> this.map.put(leaderboardPeriod, leaderboardEntrys));
|
||||
}
|
||||
}
|
||||
}
|
||||
+5
-5
@@ -18,13 +18,13 @@ public abstract class LeaderboardSource {
|
||||
return this.settings;
|
||||
}
|
||||
|
||||
public abstract String b();
|
||||
public abstract String getSourceTitle();
|
||||
|
||||
public abstract String c();
|
||||
public abstract String getModeTitle();
|
||||
|
||||
public abstract LeaderboardEntry[] a(LeaderboardPeriod var1);
|
||||
public abstract LeaderboardEntry[] getTopEntries(LeaderboardPeriod var1);
|
||||
|
||||
public abstract void a(Player var1, LeaderboardPeriod var2, BiConsumer<LeaderboardEntry, Integer> var3);
|
||||
public abstract void fetchPlayerRank(Player var1, LeaderboardPeriod var2, BiConsumer<LeaderboardEntry, Integer> var3);
|
||||
|
||||
public abstract void d();
|
||||
public abstract void refreshCache();
|
||||
}
|
||||
+2
-2
@@ -24,11 +24,11 @@ public class LeaderboardStorage implements Configuration {
|
||||
return this.leaderboards;
|
||||
}
|
||||
|
||||
public void b() {
|
||||
public void load() {
|
||||
this.configManager.tryLoad(this, this.file);
|
||||
}
|
||||
|
||||
public void c() {
|
||||
public void save() {
|
||||
this.configManager.trySave(this, this.file);
|
||||
}
|
||||
}
|
||||
@@ -58,40 +58,40 @@ public class InventoryListener implements Listener {
|
||||
}
|
||||
|
||||
@EventHandler
|
||||
public void a(InventoryClickEvent event) {
|
||||
public void onInventoryClick(InventoryClickEvent event) {
|
||||
HumanEntity humanEntity = event.getWhoClicked();
|
||||
DefaultUser defaultUser = (DefaultUser)this.engine.getUsers().a(humanEntity.getUniqueId());
|
||||
if (defaultUser != null) {
|
||||
this.a(defaultUser, event);
|
||||
this.b(defaultUser, event);
|
||||
this.c(defaultUser, event);
|
||||
this.handleSetupHotbarClick(defaultUser, event);
|
||||
this.handleGamerHotbarClick(defaultUser, event);
|
||||
this.handleMenuClick(defaultUser, event);
|
||||
}
|
||||
}
|
||||
|
||||
private void a(DefaultUser defaultUser, InventoryClickEvent event) {
|
||||
private void handleSetupHotbarClick(DefaultUser defaultUser, InventoryClickEvent event) {
|
||||
ArenaSetup arenaSetup = defaultUser.getArenaSetup();
|
||||
if (arenaSetup != null && Objects.equals(event.getClickedInventory(), event.getWhoClicked().getInventory()) && arenaSetup.getHotbar().a(event.getSlot())) {
|
||||
if (arenaSetup != null && Objects.equals(event.getClickedInventory(), event.getWhoClicked().getInventory()) && arenaSetup.getHotbar().hasAction(event.getSlot())) {
|
||||
event.setCancelled(true);
|
||||
defaultUser.getArenaSetup().getHotbar().b(event.getSlot());
|
||||
defaultUser.getArenaSetup().getHotbar().trigger(event.getSlot());
|
||||
defaultUser.toPlayer().closeInventory();
|
||||
}
|
||||
}
|
||||
|
||||
private void b(DefaultUser defaultUser, InventoryClickEvent event) {
|
||||
if (defaultUser.getGamer() instanceof BaseGamer var3 && Objects.equals(event.getClickedInventory(), event.getWhoClicked().getInventory()) && var3.getHotbar().a(event.getSlot())) {
|
||||
var3.getHotbar().b(event.getSlot());
|
||||
private void handleGamerHotbarClick(DefaultUser defaultUser, InventoryClickEvent event) {
|
||||
if (defaultUser.getGamer() instanceof BaseGamer var3 && Objects.equals(event.getClickedInventory(), event.getWhoClicked().getInventory()) && var3.getHotbar().hasAction(event.getSlot())) {
|
||||
var3.getHotbar().trigger(event.getSlot());
|
||||
event.setCancelled(true);
|
||||
}
|
||||
}
|
||||
|
||||
private void c(DefaultUser defaultUser, InventoryClickEvent event) {
|
||||
InventoryMenu inventoryMenu = defaultUser.getMenu3();
|
||||
private void handleMenuClick(DefaultUser defaultUser, InventoryClickEvent event) {
|
||||
InventoryMenu inventoryMenu = defaultUser.getOpenMenu();
|
||||
if (inventoryMenu != null) {
|
||||
if (event.getAction() == InventoryAction.MOVE_TO_OTHER_INVENTORY) {
|
||||
event.setCancelled(true);
|
||||
} else if (Objects.equals(inventoryMenu.a(), event.getClickedInventory())) {
|
||||
} else if (Objects.equals(inventoryMenu.getInventory(), event.getClickedInventory())) {
|
||||
event.setCancelled(true);
|
||||
inventoryMenu.a(defaultUser, event.getSlot());
|
||||
inventoryMenu.handleClick(defaultUser, event.getSlot());
|
||||
} else {
|
||||
event.setCancelled(true);
|
||||
}
|
||||
@@ -99,19 +99,19 @@ public class InventoryListener implements Listener {
|
||||
}
|
||||
|
||||
@EventHandler
|
||||
public void a(InventoryDragEvent event) {
|
||||
public void onInventoryDrag(InventoryDragEvent event) {
|
||||
DefaultUser defaultUser = (DefaultUser)this.engine.getUsers().a(event.getWhoClicked());
|
||||
if (defaultUser != null) {
|
||||
Player player = defaultUser.toPlayer();
|
||||
InventoryMenu inventoryMenu = defaultUser.getMenu3();
|
||||
InventoryMenu inventoryMenu = defaultUser.getOpenMenu();
|
||||
if (inventoryMenu != null) {
|
||||
if (event.getRawSlots().size() == 1) {
|
||||
int index = (Integer)event.getRawSlots().iterator().next();
|
||||
if (Objects.equals(inventoryMenu.a(), this.a(event.getView(), index))) {
|
||||
if (Objects.equals(inventoryMenu.getInventory(), this.getClickedInventory(event.getView(), index))) {
|
||||
int index2 = event.getView().convertSlot(index);
|
||||
if (inventoryMenu.a(index2)) {
|
||||
if (inventoryMenu.hasAction(index2)) {
|
||||
player.setItemOnCursor(event.getOldCursor());
|
||||
inventoryMenu.a(defaultUser, (Integer)event.getInventorySlots().iterator().next());
|
||||
inventoryMenu.handleClick(defaultUser, (Integer)event.getInventorySlots().iterator().next());
|
||||
player.setItemOnCursor((org.bukkit.inventory.ItemStack)null);
|
||||
} else {
|
||||
event.setCancelled(true);
|
||||
@@ -124,7 +124,7 @@ public class InventoryListener implements Listener {
|
||||
}
|
||||
}
|
||||
|
||||
private Inventory a(InventoryView inventoryView, int index) {
|
||||
private Inventory getClickedInventory(InventoryView inventoryView, int index) {
|
||||
if (index != -999 && index != -1) {
|
||||
return index < inventoryView.getTopInventory().getSize() ? inventoryView.getTopInventory() : inventoryView.getBottomInventory();
|
||||
} else {
|
||||
@@ -133,60 +133,60 @@ public class InventoryListener implements Listener {
|
||||
}
|
||||
|
||||
@EventHandler
|
||||
public void a(InventoryCloseEvent event) {
|
||||
public void onInventoryClose(InventoryCloseEvent event) {
|
||||
HumanEntity humanEntity = event.getPlayer();
|
||||
DefaultUser defaultUser = (DefaultUser)this.engine.getUsers().a(humanEntity.getUniqueId());
|
||||
if (defaultUser != null && defaultUser.getMenu3() != null) {
|
||||
defaultUser.d();
|
||||
if (defaultUser != null && defaultUser.getOpenMenu() != null) {
|
||||
defaultUser.closeMenu();
|
||||
}
|
||||
}
|
||||
|
||||
@EventHandler
|
||||
public void a(AsyncPacketEntityInteractEvent event) {
|
||||
public void onAsyncPacketEntityInteract(AsyncPacketEntityInteractEvent event) {
|
||||
Bukkit.getScheduler().runTask(this.engine.getPlugin(), () -> {
|
||||
int index = event.getId();
|
||||
Player player = event.getPlayer();
|
||||
DefaultUser defaultUser = (DefaultUser)this.engine.getUsers().c(player);
|
||||
if (defaultUser != null && System.currentTimeMillis() - defaultUser.f() >= 250L) {
|
||||
defaultUser.a(System.currentTimeMillis());
|
||||
defaultUser.b(index);
|
||||
defaultUser.a(index);
|
||||
this.engine.getDisplayManager().a(index, player);
|
||||
if (defaultUser != null && System.currentTimeMillis() - defaultUser.getLastInteractionTime() >= 250L) {
|
||||
defaultUser.setLastInteractionTime(System.currentTimeMillis());
|
||||
defaultUser.interactLeaderboardToggle(index);
|
||||
defaultUser.interactLeaderboard(index);
|
||||
this.engine.getDisplayManager().handleNpcInteract(index, player);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
@EventHandler(priority = EventPriority.LOW)
|
||||
public void a(PlayerJoinEvent event) {
|
||||
public void onPlayerJoin(PlayerJoinEvent event) {
|
||||
Player player = event.getPlayer();
|
||||
DefaultUser defaultUser = this.engine.getUsers().a(player);
|
||||
DefaultUser defaultUser = this.engine.getUsers().addUser(player);
|
||||
|
||||
for (LeaderboardGroup leaderboardGroup : this.engine.getDisplayManager().b().values()) {
|
||||
defaultUser.a(leaderboardGroup);
|
||||
for (LeaderboardGroup leaderboardGroup : this.engine.getDisplayManager().getLeaderboardGroups().values()) {
|
||||
defaultUser.addLeaderboardDisplay(leaderboardGroup);
|
||||
}
|
||||
|
||||
for (LeaderboardToggle leaderboardToggle : this.engine.getDisplayManager().c()) {
|
||||
defaultUser.a(leaderboardToggle);
|
||||
for (LeaderboardToggle leaderboardToggle : this.engine.getDisplayManager().getLeaderboardToggles()) {
|
||||
defaultUser.addLeaderboardToggle(leaderboardToggle);
|
||||
}
|
||||
|
||||
this.engine.getDatabaseManager().getSqlDatabase().a(player.getUniqueId(), player.getName());
|
||||
this.engine.getDatabaseManager().getSqlDatabase().upsertPlayer(player.getUniqueId(), player.getName());
|
||||
|
||||
for (AbstractGameManager abstractGameManager : this.engine.getGameManagerRegistry()) {
|
||||
for (AbstractGame abstractGame : abstractGameManager.getSessions().d().values()) {
|
||||
for (AbstractGame abstractGame : abstractGameManager.getSessions().getGames().values()) {
|
||||
if (abstractGame.getSettings().isTabPrivate()) {
|
||||
PlayerVisibility.b(this.engine.getPlugin(), player, abstractGame.getGamers());
|
||||
PlayerVisibility.hideFromRegistry(this.engine.getPlugin(), player, abstractGame.getGamers());
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@EventHandler(priority = EventPriority.LOWEST)
|
||||
public void a(PlayerQuitEvent event) {
|
||||
public void onPlayerQuit(PlayerQuitEvent event) {
|
||||
Player player = event.getPlayer();
|
||||
DefaultUser defaultUser = this.engine.getUsers().b(player);
|
||||
DefaultUser defaultUser = this.engine.getUsers().removeUser(player);
|
||||
if (defaultUser != null) {
|
||||
defaultUser.getViewers().a();
|
||||
this.engine.getDisplayManager().getViewers().a(player);
|
||||
defaultUser.getViewers().clear();
|
||||
this.engine.getDisplayManager().getViewers().hideWorld(player);
|
||||
if (defaultUser.isInGame()) {
|
||||
defaultUser.getGamer().leave();
|
||||
}
|
||||
@@ -194,68 +194,68 @@ public class InventoryListener implements Listener {
|
||||
}
|
||||
|
||||
@EventHandler
|
||||
public void a(PlayerChangedWorldEvent event) {
|
||||
public void onPlayerChangedWorld(PlayerChangedWorldEvent event) {
|
||||
Player player = event.getPlayer();
|
||||
this.engine.getDisplayManager().getViewers().a(player, event.getFrom().getUID());
|
||||
this.engine.getDisplayManager().getViewers().hideWorld(player, event.getFrom().getUID());
|
||||
DefaultUser defaultUser = (DefaultUser)this.engine.getUsers().c(player);
|
||||
if (defaultUser != null) {
|
||||
defaultUser.getViewers().a(player, event.getFrom().getUID());
|
||||
defaultUser.getViewers().hideWorld(player, event.getFrom().getUID());
|
||||
}
|
||||
}
|
||||
|
||||
@EventHandler
|
||||
public void a(PlayerDropItemEvent event) {
|
||||
public void onPlayerDropItem(PlayerDropItemEvent event) {
|
||||
Player player = event.getPlayer();
|
||||
DefaultUser defaultUser = (DefaultUser)this.engine.getUsers().c(player);
|
||||
if (defaultUser != null) {
|
||||
ArenaSetup arenaSetup = defaultUser.getArenaSetup();
|
||||
if (arenaSetup != null && arenaSetup.getHotbar().a(player.getInventory().getHeldItemSlot())) {
|
||||
if (arenaSetup != null && arenaSetup.getHotbar().hasAction(player.getInventory().getHeldItemSlot())) {
|
||||
event.setCancelled(true);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@EventHandler(priority = EventPriority.HIGH)
|
||||
public void a(AsyncPlayerChatEvent event) {
|
||||
public void onAsyncPlayerChat(AsyncPlayerChatEvent event) {
|
||||
DefaultUser defaultUser = (DefaultUser)this.engine.getUsers().c(event.getPlayer());
|
||||
if (defaultUser != null) {
|
||||
this.a(event.getRecipients());
|
||||
if (!event.isCancelled() && defaultUser.isInGame() && defaultUser.getGame() instanceof AbstractGame var3 && this.a(var3)) {
|
||||
Bukkit.getScheduler().runTask(this.engine.getPlugin(), () -> this.a(var3, event.getPlayer(), event.getMessage()));
|
||||
this.filterPrivateChatRecipients(event.getRecipients());
|
||||
if (!event.isCancelled() && defaultUser.isInGame() && defaultUser.getGame() instanceof AbstractGame var3 && this.isWaitingPrivateChat(var3)) {
|
||||
Bukkit.getScheduler().runTask(this.engine.getPlugin(), () -> this.broadcastWaitingChat(var3, event.getPlayer(), event.getMessage()));
|
||||
event.setCancelled(true);
|
||||
}
|
||||
|
||||
if (defaultUser.g() && defaultUser.getArenaSetup().getSetupStep() instanceof ChatSetupStep var5) {
|
||||
if (defaultUser.isInSetup() && defaultUser.getArenaSetup().getSetupStep() instanceof ChatSetupStep var5) {
|
||||
event.setCancelled(true);
|
||||
Bukkit.getScheduler().runTask(this.engine.getPlugin(), () -> var5.a(event.getMessage()));
|
||||
Bukkit.getScheduler().runTask(this.engine.getPlugin(), () -> var5.onChatInput(event.getMessage()));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private void a(Set<Player> set) {
|
||||
private void filterPrivateChatRecipients(Set<Player> set) {
|
||||
set.removeIf(player -> {
|
||||
DefaultUser defaultUser = (DefaultUser)this.engine.getUsers().c(player);
|
||||
return defaultUser == null ? false : defaultUser.getGamer() instanceof BaseGamer var3 && var3.getGame().getSettings().isChatPrivate();
|
||||
});
|
||||
}
|
||||
|
||||
private void a(AbstractGame abstractGame, Player player, String text) {
|
||||
Context context = this.a(player.getName(), text);
|
||||
String text2 = this.engine.getMessages().getChatWaiting().a(context);
|
||||
private void broadcastWaitingChat(AbstractGame abstractGame, Player player, String text) {
|
||||
Context context = this.createChatContext(player.getName(), text);
|
||||
String text2 = this.engine.getMessages().getChatWaiting().render(context);
|
||||
if (this.engine.hasPlaceholderResolver()) {
|
||||
text2 = this.engine.getPlaceholderResolver().a(player, text2);
|
||||
text2 = this.engine.getPlaceholderResolver().resolve(player, text2);
|
||||
}
|
||||
|
||||
abstractGame.getGamers().a(text2);
|
||||
abstractGame.getGamers().broadcast(text2);
|
||||
Bukkit.getConsoleSender().sendMessage(text2);
|
||||
}
|
||||
|
||||
private boolean a(AbstractGame abstractGame) {
|
||||
private boolean isWaitingPrivateChat(AbstractGame abstractGame) {
|
||||
return abstractGame.getPhase() != abstractGame.getPhaseLifecycle().getPlaying() && abstractGame.getSettings().isChatPrivate();
|
||||
}
|
||||
|
||||
private Context a(String text, String text2) {
|
||||
return Contexts.a((VariableProvider) text3 -> {
|
||||
private Context createChatContext(String text, String text2) {
|
||||
return Contexts.ofVariables((VariableProvider) text3 -> {
|
||||
if (text3.equals("player")) {
|
||||
return text;
|
||||
} else {
|
||||
@@ -265,64 +265,64 @@ public class InventoryListener implements Listener {
|
||||
}
|
||||
|
||||
@EventHandler
|
||||
public void a(PlayerAnimationEvent event) {
|
||||
public void onPlayerAnimation(PlayerAnimationEvent event) {
|
||||
if (event.getAnimationType() == PlayerAnimationType.ARM_SWING) {
|
||||
Player player = event.getPlayer();
|
||||
if (player.getSpectatorTarget() != null) {
|
||||
DefaultUser defaultUser = (DefaultUser)this.engine.getUsers().c(player);
|
||||
if (defaultUser != null && defaultUser.getGamer() instanceof BaseGamer var4 && var4.g()) {
|
||||
var4.i();
|
||||
if (defaultUser != null && defaultUser.getGamer() instanceof BaseGamer var4 && var4.isActiveSpectator()) {
|
||||
var4.openSpectatorMenu();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@EventHandler
|
||||
public void a(PlayerInteractEvent event) {
|
||||
public void onPlayerInteract(PlayerInteractEvent event) {
|
||||
if (VersionAdapters.get().isMainHandInteract(this.engine.getPlatform(), event)) {
|
||||
Player player = event.getPlayer();
|
||||
DefaultUser defaultUser = (DefaultUser)this.engine.getUsers().c(player);
|
||||
if (defaultUser != null) {
|
||||
if (defaultUser.getGamer() instanceof BaseGamer var4 && player.getSpectatorTarget() == null && EngineUtils.b(event.getAction())) {
|
||||
this.a(defaultUser, var4.getHotbar(), player.getInventory().getHeldItemSlot(), event);
|
||||
if (defaultUser.getGamer() instanceof BaseGamer var4 && player.getSpectatorTarget() == null && EngineUtils.isRightClick(event.getAction())) {
|
||||
this.handleHotbarInteract(defaultUser, var4.getHotbar(), player.getInventory().getHeldItemSlot(), event);
|
||||
}
|
||||
|
||||
if (defaultUser.g()) {
|
||||
if (defaultUser.isInSetup()) {
|
||||
ArenaSetup arenaSetup = defaultUser.getArenaSetup();
|
||||
ItemStack item = VersionAdapters.get().getMainHandItem(this.engine.getPlatform(), player);
|
||||
if (item.getType() == Material.DIAMOND_SWORD && arenaSetup.getSetupStep().d()) {
|
||||
arenaSetup.a(event.getClickedBlock(), player, event.getAction());
|
||||
} else if (EngineUtils.b(event.getAction())) {
|
||||
this.a(defaultUser, arenaSetup.getHotbar(), player.getInventory().getHeldItemSlot(), event);
|
||||
if (item.getType() == Material.DIAMOND_SWORD && arenaSetup.getSetupStep().usesSelectionTool()) {
|
||||
arenaSetup.handleSelection(event.getClickedBlock(), player, event.getAction());
|
||||
} else if (EngineUtils.isRightClick(event.getAction())) {
|
||||
this.handleHotbarInteract(defaultUser, arenaSetup.getHotbar(), player.getInventory().getHeldItemSlot(), event);
|
||||
}
|
||||
}
|
||||
|
||||
Block block = event.getClickedBlock();
|
||||
if (event.getAction() == Action.RIGHT_CLICK_BLOCK && VersionAdapters.get().isWallSign(block)) {
|
||||
CommandSign commandSign = this.engine.getDisplayManager().a(block);
|
||||
CommandSign commandSign = this.engine.getDisplayManager().getCommandSign(block);
|
||||
if (commandSign == null) {
|
||||
return;
|
||||
}
|
||||
|
||||
event.setCancelled(true);
|
||||
commandSign.a(player);
|
||||
commandSign.executeCommand(player);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private void a(DefaultUser defaultUser, PlayerHotbar playerHotbar, int index, Cancellable cancellable) {
|
||||
if (playerHotbar.a(index)) {
|
||||
private void handleHotbarInteract(DefaultUser defaultUser, PlayerHotbar playerHotbar, int index, Cancellable cancellable) {
|
||||
if (playerHotbar.hasAction(index)) {
|
||||
cancellable.setCancelled(true);
|
||||
if (System.currentTimeMillis() - defaultUser.f() >= 250L) {
|
||||
playerHotbar.b(index);
|
||||
defaultUser.a(System.currentTimeMillis());
|
||||
if (System.currentTimeMillis() - defaultUser.getLastInteractionTime() >= 250L) {
|
||||
playerHotbar.trigger(index);
|
||||
defaultUser.setLastInteractionTime(System.currentTimeMillis());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@EventHandler
|
||||
public void a(PlayerCommandPreprocessEvent event) {
|
||||
public void onPlayerCommandPreprocess(PlayerCommandPreprocessEvent event) {
|
||||
Player player = event.getPlayer();
|
||||
DefaultUser defaultUser = (DefaultUser)this.engine.getUsers().c(player);
|
||||
if (defaultUser != null) {
|
||||
@@ -330,7 +330,7 @@ public class InventoryListener implements Listener {
|
||||
String text2 = text.split(" ")[0].toLowerCase(Locale.ROOT);
|
||||
if (text2.equals("rejoin")) {
|
||||
event.setCancelled(true);
|
||||
this.engine.getGameManagerRegistry().a(defaultUser);
|
||||
this.engine.getGameManagerRegistry().rejoin(defaultUser);
|
||||
} else if (defaultUser.isInGame() && defaultUser.getGame() instanceof AbstractGame var6) {
|
||||
boolean flag = player.hasPermission(var6.getManager().getId() + ".admin") || player.hasPermission(var6.getManager().getId() + ".moderator");
|
||||
if (text2.equals("leave")) {
|
||||
@@ -346,8 +346,8 @@ public class InventoryListener implements Listener {
|
||||
}
|
||||
}
|
||||
|
||||
if (!event.isCancelled() && defaultUser.g() && defaultUser.getArenaSetup().getSetupStep() instanceof ChatSetupStep var8) {
|
||||
event.setCancelled(var8.b(text));
|
||||
if (!event.isCancelled() && defaultUser.isInSetup() && defaultUser.getArenaSetup().getSetupStep() instanceof ChatSetupStep var8) {
|
||||
event.setCancelled(var8.onCommandInput(text));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -32,7 +32,7 @@ public class NetworkManager {
|
||||
return this.settings;
|
||||
}
|
||||
|
||||
public void d() {
|
||||
public void start() {
|
||||
if (this.settings.isEnabled()) {
|
||||
this.engine.getPlugin().getServer().getMessenger().registerOutgoingPluginChannel(this.engine.getPlugin(), "BungeeCord");
|
||||
if (this.settings.getMode().equals("AutoScale")) {
|
||||
@@ -41,23 +41,23 @@ public class NetworkManager {
|
||||
this.networkFeature = new RemoteJoinController(this, this.settings.getRemote());
|
||||
}
|
||||
|
||||
this.networkFeature.a();
|
||||
this.networkFeature.enable();
|
||||
}
|
||||
}
|
||||
|
||||
public void e() {
|
||||
public void stop() {
|
||||
if (this.networkFeature != null) {
|
||||
this.networkFeature.b();
|
||||
this.networkFeature.disable();
|
||||
}
|
||||
|
||||
this.engine.getPlugin().getServer().getMessenger().unregisterIncomingPluginChannel(this.engine.getPlugin(), "BungeeCord");
|
||||
}
|
||||
|
||||
public void f() {
|
||||
public void kickOnlinePlayers() {
|
||||
Bukkit.getOnlinePlayers().forEach(player -> player.kickPlayer("Auto Join has been enabled!"));
|
||||
}
|
||||
|
||||
public void a(Player player) {
|
||||
public void kickPlayerDelayed(Player player) {
|
||||
if (player.isOnline()) {
|
||||
this.engine.getPlugin().getServer().getScheduler().runTaskLater(this.engine.getPlugin(), () -> {
|
||||
if (player.isOnline()) {
|
||||
@@ -67,7 +67,7 @@ public class NetworkManager {
|
||||
}
|
||||
}
|
||||
|
||||
public void a(Player player, String text) {
|
||||
public void sendToServer(Player player, String text) {
|
||||
try (
|
||||
ByteArrayOutputStream var3 = new ByteArrayOutputStream();
|
||||
DataOutputStream var4 = new DataOutputStream(var3);
|
||||
|
||||
+6
-6
@@ -18,11 +18,11 @@ public class AutoJoinController implements NetworkFeature {
|
||||
this.settings = settings2;
|
||||
}
|
||||
|
||||
Session c() {
|
||||
return this.manager.getEngine().getGameManagerRegistry().newGameSearcher().get(EngineUtils.b, List.of());
|
||||
Session findAvailableSession() {
|
||||
return this.manager.getEngine().getGameManagerRegistry().newGameSearcher().get(EngineUtils.ZERO_UUID, List.of());
|
||||
}
|
||||
|
||||
public DefaultEngine d() {
|
||||
public DefaultEngine getEngine() {
|
||||
return this.manager.getEngine();
|
||||
}
|
||||
|
||||
@@ -34,12 +34,12 @@ public class AutoJoinController implements NetworkFeature {
|
||||
return this.manager;
|
||||
}
|
||||
|
||||
public void a() {
|
||||
this.manager.f();
|
||||
public void enable() {
|
||||
this.manager.kickOnlinePlayers();
|
||||
this.manager.getEngine().getAddonManager().registerListener(this.listener);
|
||||
}
|
||||
|
||||
public void b() {
|
||||
public void disable() {
|
||||
this.manager.getEngine().getAddonManager().unregisterListener(this.listener);
|
||||
}
|
||||
}
|
||||
+13
-13
@@ -24,11 +24,11 @@ public class AutoJoinListener implements Listener {
|
||||
}
|
||||
|
||||
@EventHandler(priority = EventPriority.HIGH)
|
||||
public void a(PlayerJoinEvent event) {
|
||||
DefaultUser defaultUser = (DefaultUser)this.autoJoinController.d().getUsers().c(event.getPlayer());
|
||||
public void onPlayerJoin(PlayerJoinEvent event) {
|
||||
DefaultUser defaultUser = (DefaultUser)this.autoJoinController.getEngine().getUsers().c(event.getPlayer());
|
||||
event.setJoinMessage((java.lang.String)null);
|
||||
Player player = defaultUser.toPlayer();
|
||||
Session session = this.autoJoinController.c();
|
||||
Session session = this.autoJoinController.findAvailableSession();
|
||||
if (session == null) {
|
||||
player.kickPlayer(defaultUser.getEngine().getMessages().getQuickjoinNotFound());
|
||||
} else {
|
||||
@@ -42,13 +42,13 @@ public class AutoJoinListener implements Listener {
|
||||
}
|
||||
|
||||
@EventHandler
|
||||
public void a(PlayerQuitEvent event) {
|
||||
public void onPlayerQuit(PlayerQuitEvent event) {
|
||||
event.setQuitMessage((java.lang.String)null);
|
||||
}
|
||||
|
||||
@EventHandler
|
||||
public void a(ServerListPingEvent event) {
|
||||
Session session = this.autoJoinController.c();
|
||||
public void onServerListPing(ServerListPingEvent event) {
|
||||
Session session = this.autoJoinController.findAvailableSession();
|
||||
if (session == null) {
|
||||
event.setMotd("§c§lYou need to have games to activate AutoJoin");
|
||||
} else {
|
||||
@@ -58,11 +58,11 @@ public class AutoJoinListener implements Listener {
|
||||
}
|
||||
|
||||
@EventHandler
|
||||
public void a(PlayerLoginEvent event) {
|
||||
if (this.autoJoinController.c() == null) {
|
||||
event.disallow(org.bukkit.event.player.PlayerLoginEvent.Result.KICK_OTHER, this.autoJoinController.d().getMessages().getQuickjoinNotFound());
|
||||
public void onPlayerLogin(PlayerLoginEvent event) {
|
||||
if (this.autoJoinController.findAvailableSession() == null) {
|
||||
event.disallow(org.bukkit.event.player.PlayerLoginEvent.Result.KICK_OTHER, this.autoJoinController.getEngine().getMessages().getQuickjoinNotFound());
|
||||
} else {
|
||||
Result result = this.autoJoinController.c().canPlay(EngineUtils.b, List.of());
|
||||
Result result = this.autoJoinController.findAvailableSession().canPlay(EngineUtils.ZERO_UUID, List.of());
|
||||
if (!result.successful()) {
|
||||
event.disallow(org.bukkit.event.player.PlayerLoginEvent.Result.KICK_OTHER, result.errorMessage());
|
||||
}
|
||||
@@ -70,10 +70,10 @@ public class AutoJoinListener implements Listener {
|
||||
}
|
||||
|
||||
@EventHandler
|
||||
public void a(GameLeaveEvent event) {
|
||||
this.autoJoinController.getManager().a(event.getPlayer(), this.autoJoinController.getSettings().getReturnServer());
|
||||
public void onGameLeave(GameLeaveEvent event) {
|
||||
this.autoJoinController.getManager().sendToServer(event.getPlayer(), this.autoJoinController.getSettings().getReturnServer());
|
||||
if (this.autoJoinController.getSettings().isKickPlayerOnLeave()) {
|
||||
this.autoJoinController.getManager().a(event.getPlayer());
|
||||
this.autoJoinController.getManager().kickPlayerDelayed(event.getPlayer());
|
||||
}
|
||||
}
|
||||
}
|
||||
+2
-2
@@ -34,13 +34,13 @@ public class AddRemoteJoinCommand implements CommandExecutor {
|
||||
if (this.engine.getNetworkManager().getNetworkFeature() instanceof RemoteJoinController var6) {
|
||||
if (var6.getNetworkEndpoint() instanceof GameServerEndpoint var7) {
|
||||
String text2 = texts[index];
|
||||
if (var7.a(text2)) {
|
||||
if (var7.hasHubServer(text2)) {
|
||||
sender.sendMessage(ChatColor.RED + "The id is already used!");
|
||||
} else {
|
||||
RemoteAddress remoteAddress = new RemoteAddress();
|
||||
remoteAddress.setHost(texts[index + 1]);
|
||||
remoteAddress.setPort(Integer.parseInt(texts[index + 2]));
|
||||
var7.a(text2, remoteAddress);
|
||||
var7.addHubServer(text2, remoteAddress);
|
||||
sender.sendMessage(ChatColor.GREEN + "The hub has been added.");
|
||||
}
|
||||
} else {
|
||||
|
||||
+1
-1
@@ -25,7 +25,7 @@ public class QuickJoinCommand extends BaseCommandExecutor {
|
||||
public void execute(CommandSender sender, String text, String[] texts, int index) {
|
||||
DefaultUser defaultUser = (DefaultUser) this.engine.getUsers().c((Player) sender);
|
||||
if (defaultUser != null) {
|
||||
defaultUser.a(this.engine.getGameManagerRegistry().newGameSearcher());
|
||||
defaultUser.quickJoin(this.engine.getGameManagerRegistry().newGameSearcher());
|
||||
}
|
||||
}
|
||||
}
|
||||
+2
-2
@@ -32,10 +32,10 @@ public class RemoveRemoteJoinCommand implements CommandExecutor {
|
||||
if (this.engine.getNetworkManager().getNetworkFeature() instanceof RemoteJoinController var6) {
|
||||
if (var6.getNetworkEndpoint() instanceof GameServerEndpoint var7) {
|
||||
String text2 = texts[index];
|
||||
if (!var7.a(text2)) {
|
||||
if (!var7.hasHubServer(text2)) {
|
||||
sender.sendMessage(ChatColor.RED + "No hub found with such id!");
|
||||
} else {
|
||||
var7.b(text2);
|
||||
var7.removeHubServer(text2);
|
||||
sender.sendMessage(ChatColor.GREEN + "The Hub has been removed.");
|
||||
}
|
||||
} else {
|
||||
|
||||
+20
-20
@@ -22,54 +22,54 @@ public class GameServerEndpoint implements NetworkEndpoint {
|
||||
this.listener = new GameServerListener(remoteJoinController2);
|
||||
}
|
||||
|
||||
public void a() {
|
||||
this.remoteJoinController.getManager25().f();
|
||||
this.remoteJoinController.d().getAddonManager().registerListener(this.listener);
|
||||
JavaPlugin javaPlugin = this.remoteJoinController.d().getPlugin();
|
||||
this.task = javaPlugin.getServer().getScheduler().runTaskTimer(javaPlugin, this::c, 0L, 20L);
|
||||
this.remoteJoinController.getSettings7().getServer().getHubServers().forEach((text, remoteAddress) -> {
|
||||
public void start() {
|
||||
this.remoteJoinController.getManager().kickOnlinePlayers();
|
||||
this.remoteJoinController.getEngine().getAddonManager().registerListener(this.listener);
|
||||
JavaPlugin javaPlugin = this.remoteJoinController.getEngine().getPlugin();
|
||||
this.task = javaPlugin.getServer().getScheduler().runTaskTimer(javaPlugin, this::sendKeepAliveAndSnapshots, 0L, 20L);
|
||||
this.remoteJoinController.getSettings().getServer().getHubServers().forEach((text, remoteAddress) -> {
|
||||
HubConnection hubConnection = new HubConnection(this.remoteJoinController, remoteAddress);
|
||||
this.map.put(text, hubConnection);
|
||||
hubConnection.b();
|
||||
hubConnection.connect();
|
||||
});
|
||||
}
|
||||
|
||||
public void b() {
|
||||
public void stop() {
|
||||
this.task.cancel();
|
||||
this.map.values().forEach(HubConnection::c);
|
||||
this.map.values().forEach(HubConnection::disconnect);
|
||||
this.map.clear();
|
||||
this.remoteJoinController.d().getAddonManager().unregisterListener(this.listener);
|
||||
this.remoteJoinController.getEngine().getAddonManager().unregisterListener(this.listener);
|
||||
}
|
||||
|
||||
public boolean a(String text) {
|
||||
public boolean hasHubServer(String text) {
|
||||
return this.map.containsKey(text);
|
||||
}
|
||||
|
||||
public void a(String text, RemoteAddress remoteAddress) {
|
||||
public void addHubServer(String text, RemoteAddress remoteAddress) {
|
||||
HubConnection hubConnection = new HubConnection(this.remoteJoinController, remoteAddress);
|
||||
this.map.put(text, hubConnection);
|
||||
hubConnection.b();
|
||||
hubConnection.connect();
|
||||
}
|
||||
|
||||
public void b(String text) {
|
||||
public void removeHubServer(String text) {
|
||||
HubConnection hubConnection = this.map.remove(text);
|
||||
if (hubConnection != null) {
|
||||
hubConnection.c();
|
||||
hubConnection.disconnect();
|
||||
}
|
||||
}
|
||||
|
||||
private void c() {
|
||||
private void sendKeepAliveAndSnapshots() {
|
||||
NetworkSnapshot networkSnapshot = null;
|
||||
|
||||
for (HubConnection hubConnection : this.map.values()) {
|
||||
if (hubConnection.a()) {
|
||||
hubConnection.d();
|
||||
if (hubConnection.isConnected()) {
|
||||
hubConnection.tickKeepAlive();
|
||||
if (networkSnapshot == null) {
|
||||
networkSnapshot = new NetworkSnapshot();
|
||||
networkSnapshot.a(this.remoteJoinController.d().getGameManagerRegistry());
|
||||
networkSnapshot.captureFrom(this.remoteJoinController.getEngine().getGameManagerRegistry());
|
||||
}
|
||||
|
||||
hubConnection.a(networkSnapshot);
|
||||
hubConnection.sendSnapshot(networkSnapshot);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
+23
-23
@@ -26,68 +26,68 @@ public class GameServerListener implements Listener {
|
||||
this.remoteJoinController = remoteJoinController2;
|
||||
}
|
||||
|
||||
private DefaultEngine a() {
|
||||
return this.remoteJoinController.d();
|
||||
private DefaultEngine getEngine() {
|
||||
return this.remoteJoinController.getEngine();
|
||||
}
|
||||
|
||||
@EventHandler(priority = EventPriority.HIGH)
|
||||
public void a(PlayerJoinEvent event) {
|
||||
DefaultUser defaultUser = (DefaultUser)this.a().getUsers().c(event.getPlayer());
|
||||
public void onPlayerJoin(PlayerJoinEvent event) {
|
||||
DefaultUser defaultUser = (DefaultUser)this.getEngine().getUsers().c(event.getPlayer());
|
||||
event.setJoinMessage((java.lang.String)null);
|
||||
Player player = defaultUser.toPlayer();
|
||||
SessionRequest sessionRequest = (SessionRequest)this.a().getGameManagerRegistry().getMap().get(defaultUser.getUUID());
|
||||
SessionRequest sessionRequest = (SessionRequest)this.getEngine().getGameManagerRegistry().getMap().get(defaultUser.getUUID());
|
||||
if (sessionRequest == null) {
|
||||
if (!defaultUser.toPlayer().hasPermission(this.a().getNamespace() + ".reservation.exempt")) {
|
||||
player.kickPlayer(this.a().getMessages().getGameNoReservation());
|
||||
if (!defaultUser.toPlayer().hasPermission(this.getEngine().getNamespace() + ".reservation.exempt")) {
|
||||
player.kickPlayer(this.getEngine().getMessages().getGameNoReservation());
|
||||
}
|
||||
} else {
|
||||
Session session = sessionRequest.getSession();
|
||||
Result result = sessionRequest.getSessionRequestType().a(session, (ro.fr33styler.arcade.api.engine.player.User)defaultUser);
|
||||
Result result = sessionRequest.getSessionRequestType().canJoinPlayer(session, (ro.fr33styler.arcade.api.engine.player.User)defaultUser);
|
||||
if (result.successful()) {
|
||||
sessionRequest.getSessionRequestType().a(session, defaultUser);
|
||||
sessionRequest.getSessionRequestType().join(session, defaultUser);
|
||||
} else {
|
||||
player.kickPlayer(result.errorMessage());
|
||||
this.a().getGameManagerRegistry().getMap().remove(defaultUser.getUUID());
|
||||
this.getEngine().getGameManagerRegistry().getMap().remove(defaultUser.getUUID());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@EventHandler
|
||||
public void a(PlayerQuitEvent event) {
|
||||
public void onPlayerQuit(PlayerQuitEvent event) {
|
||||
event.setQuitMessage((java.lang.String)null);
|
||||
}
|
||||
|
||||
@EventHandler
|
||||
public void a(ServerListPingEvent event) {
|
||||
public void onServerListPing(ServerListPingEvent event) {
|
||||
event.setMotd("§c§lYou cannot join this way while remote join is enabled!");
|
||||
}
|
||||
|
||||
@EventHandler(priority = EventPriority.HIGHEST)
|
||||
public void a(PlayerLoginEvent event) {
|
||||
public void onPlayerLogin(PlayerLoginEvent event) {
|
||||
Player player = event.getPlayer();
|
||||
SessionRequest sessionRequest = (SessionRequest)this.a().getGameManagerRegistry().getMap().get(player.getUniqueId());
|
||||
SessionRequest sessionRequest = (SessionRequest)this.getEngine().getGameManagerRegistry().getMap().get(player.getUniqueId());
|
||||
if (sessionRequest == null) {
|
||||
if (!player.hasPermission(this.a().getNamespace() + ".reservation.exempt")) {
|
||||
event.disallow(org.bukkit.event.player.PlayerLoginEvent.Result.KICK_OTHER, this.a().getMessages().getGameNoReservation());
|
||||
if (!player.hasPermission(this.getEngine().getNamespace() + ".reservation.exempt")) {
|
||||
event.disallow(org.bukkit.event.player.PlayerLoginEvent.Result.KICK_OTHER, this.getEngine().getMessages().getGameNoReservation());
|
||||
}
|
||||
} else {
|
||||
Session session = sessionRequest.getSession();
|
||||
Result result = sessionRequest.getSessionRequestType().a(session, player.getUniqueId(), List.of());
|
||||
Result result = sessionRequest.getSessionRequestType().canJoinParty(session, player.getUniqueId(), List.of());
|
||||
if (!result.successful()) {
|
||||
event.disallow(org.bukkit.event.player.PlayerLoginEvent.Result.KICK_OTHER, result.errorMessage());
|
||||
this.a().getGameManagerRegistry().getMap().remove(player.getUniqueId());
|
||||
this.getEngine().getGameManagerRegistry().getMap().remove(player.getUniqueId());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@EventHandler
|
||||
public void a(GameLeaveEvent event) {
|
||||
Bukkit.getScheduler().runTask(this.remoteJoinController.getManager25().getEngine().getPlugin(), () -> {
|
||||
public void onGameLeave(GameLeaveEvent event) {
|
||||
Bukkit.getScheduler().runTask(this.remoteJoinController.getManager().getEngine().getPlugin(), () -> {
|
||||
if (!event.getGamer().toUser().isInGame()) {
|
||||
Player player = event.getPlayer();
|
||||
this.remoteJoinController.getManager25().a(player, this.remoteJoinController.getSettings7().getServer().getReturnServer());
|
||||
if (this.remoteJoinController.getSettings7().isKickPlayerOnLeave()) {
|
||||
this.remoteJoinController.getManager25().a(player);
|
||||
this.remoteJoinController.getManager().sendToServer(player, this.remoteJoinController.getSettings().getServer().getReturnServer());
|
||||
if (this.remoteJoinController.getSettings().isKickPlayerOnLeave()) {
|
||||
this.remoteJoinController.getManager().kickPlayerDelayed(player);
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
Loaded 100 of 538 files, more files were not shown because too many files have changed in this diff.
Show more
Reference in new issue
Block a user