fix: resolve all 375 checkstyle violations
This commit is contained in:
parent
bfeecb0866
commit
1d57972038
45 changed files with 286 additions and 107 deletions
|
|
@ -172,9 +172,9 @@ tasks {
|
||||||
checkstyle {
|
checkstyle {
|
||||||
toolVersion = "10.21.4"
|
toolVersion = "10.21.4"
|
||||||
configFile = file("config/checkstyle/checkstyle.xml")
|
configFile = file("config/checkstyle/checkstyle.xml")
|
||||||
isIgnoreFailures = true
|
isIgnoreFailures = false
|
||||||
maxErrors = 0
|
maxErrors = 0
|
||||||
maxWarnings = 200
|
maxWarnings = 0
|
||||||
}
|
}
|
||||||
|
|
||||||
tasks.withType<Checkstyle>().configureEach {
|
tasks.withType<Checkstyle>().configureEach {
|
||||||
|
|
|
||||||
|
|
@ -89,7 +89,7 @@ public final class LoParkour extends LoPlugin {
|
||||||
/** Called from {@link PluginBootstrap} on shutdown. */
|
/** Called from {@link PluginBootstrap} on shutdown. */
|
||||||
public void runShutdownSequence() {
|
public void runShutdownSequence() {
|
||||||
try {
|
try {
|
||||||
new ArrayList<>(Divider.sections.keySet()).forEach(session -> {
|
new ArrayList<>(Divider.SECTIONS.keySet()).forEach(session -> {
|
||||||
try {
|
try {
|
||||||
session.onAllPlayersLeft();
|
session.onAllPlayersLeft();
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
|
|
@ -97,7 +97,7 @@ public final class LoParkour extends LoPlugin {
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
new ArrayList<>(Divider.sections.keySet()).forEach(Divider::remove);
|
new ArrayList<>(Divider.SECTIONS.keySet()).forEach(Divider::remove);
|
||||||
|
|
||||||
for (ParkourUser user : ParkourUser.getUsers()) {
|
for (ParkourUser user : ParkourUser.getUsers()) {
|
||||||
ParkourUser.leave(user);
|
ParkourUser.leave(user);
|
||||||
|
|
|
||||||
|
|
@ -8,6 +8,9 @@ package dev.loki.loparkour.adaptive.core;
|
||||||
*/
|
*/
|
||||||
class DifficultyWeights {
|
class DifficultyWeights {
|
||||||
|
|
||||||
|
private DifficultyWeights() {
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Calculates distance weight distribution for given difficulty.
|
* Calculates distance weight distribution for given difficulty.
|
||||||
*
|
*
|
||||||
|
|
|
||||||
|
|
@ -11,6 +11,9 @@ import java.util.concurrent.ConcurrentHashMap;
|
||||||
*/
|
*/
|
||||||
public class AdaptiveConfig {
|
public class AdaptiveConfig {
|
||||||
|
|
||||||
|
private AdaptiveConfig() {
|
||||||
|
}
|
||||||
|
|
||||||
private static final ConcurrentHashMap<String, Object> CACHE = new ConcurrentHashMap<>();
|
private static final ConcurrentHashMap<String, Object> CACHE = new ConcurrentHashMap<>();
|
||||||
private static volatile boolean initialized = false;
|
private static volatile boolean initialized = false;
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -27,7 +27,6 @@ import org.jetbrains.annotations.NotNull;
|
||||||
import org.jetbrains.annotations.Nullable;
|
import org.jetbrains.annotations.Nullable;
|
||||||
|
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.Arrays;
|
|
||||||
import java.util.Collections;
|
import java.util.Collections;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.logging.Level;
|
import java.util.logging.Level;
|
||||||
|
|
@ -200,15 +199,25 @@ public class LoParkourCommand implements CommandExecutor, TabCompleter {
|
||||||
// ── tab complete ───────────────────────────────────────────────────────────
|
// ── tab complete ───────────────────────────────────────────────────────────
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@SuppressWarnings("checkstyle:CyclomaticComplexity")
|
||||||
public List<String> onTabComplete(@NotNull CommandSender sender, @NotNull Command command,
|
public List<String> onTabComplete(@NotNull CommandSender sender, @NotNull Command command,
|
||||||
@NotNull String alias, @NotNull String[] args) {
|
@NotNull String alias, @NotNull String[] args) {
|
||||||
List<String> completions = new ArrayList<>();
|
List<String> completions = new ArrayList<>();
|
||||||
|
|
||||||
if (args.length == 1) {
|
if (args.length == 1) {
|
||||||
if (ParkourOption.JOIN.mayPerform(sender)) { completions.add("join"); completions.add("leave"); }
|
if (ParkourOption.JOIN.mayPerform(sender)) {
|
||||||
if (ParkourOption.MAIN.mayPerform(sender)) completions.add("menu");
|
completions.add("join");
|
||||||
if (ParkourOption.PLAY.mayPerform(sender)) completions.add("play");
|
completions.add("leave");
|
||||||
if (ParkourOption.LEADERBOARDS.mayPerform(sender)) completions.add("leaderboard");
|
}
|
||||||
|
if (ParkourOption.MAIN.mayPerform(sender)) {
|
||||||
|
completions.add("menu");
|
||||||
|
}
|
||||||
|
if (ParkourOption.PLAY.mayPerform(sender)) {
|
||||||
|
completions.add("play");
|
||||||
|
}
|
||||||
|
if (ParkourOption.LEADERBOARDS.mayPerform(sender)) {
|
||||||
|
completions.add("leaderboard");
|
||||||
|
}
|
||||||
if (sender.hasPermission(ParkourOption.ADMIN.permission)) {
|
if (sender.hasPermission(ParkourOption.ADMIN.permission)) {
|
||||||
completions.addAll(List.of("schematic", "create", "reload", "forcejoin", "forceleave", "reset", "recoverinventory"));
|
completions.addAll(List.of("schematic", "create", "reload", "forcejoin", "forceleave", "reset", "recoverinventory"));
|
||||||
}
|
}
|
||||||
|
|
@ -217,23 +226,25 @@ public class LoParkourCommand implements CommandExecutor, TabCompleter {
|
||||||
|
|
||||||
if (args.length == 2) {
|
if (args.length == 2) {
|
||||||
String a1 = args[0].toLowerCase();
|
String a1 = args[0].toLowerCase();
|
||||||
if (a1.equals("reset") && sender.hasPermission(ParkourOption.ADMIN.permission)) {
|
if ("reset".equals(a1) && sender.hasPermission(ParkourOption.ADMIN.permission)) {
|
||||||
completions.add("everyone");
|
completions.add("everyone");
|
||||||
ParkourPlayer.getPlayers().forEach(pp -> completions.add(pp.getName()));
|
ParkourPlayer.getPlayers().forEach(pp -> completions.add(pp.getName()));
|
||||||
} else if (a1.equals("join") && ParkourOption.JOIN.mayPerform(sender)) {
|
} else if ("join".equals(a1) && ParkourOption.JOIN.mayPerform(sender)) {
|
||||||
Registry.getModes().forEach(m -> completions.add(m.getName()));
|
Registry.getModes().forEach(m -> completions.add(m.getName()));
|
||||||
ParkourPlayer.getPlayers().forEach(pp -> completions.add(pp.getName()));
|
ParkourPlayer.getPlayers().forEach(pp -> completions.add(pp.getName()));
|
||||||
} else if (a1.equals("leaderboard") && ParkourOption.LEADERBOARDS.mayPerform(sender)) {
|
} else if ("leaderboard".equals(a1) && ParkourOption.LEADERBOARDS.mayPerform(sender)) {
|
||||||
Registry.getModes().forEach(m -> completions.add(m.getName()));
|
Registry.getModes().forEach(m -> completions.add(m.getName()));
|
||||||
} else if (a1.equals("schematic") && sender.hasPermission(ParkourOption.ADMIN.permission)) {
|
} else if ("schematic".equals(a1) && sender.hasPermission(ParkourOption.ADMIN.permission)) {
|
||||||
completions.addAll(SCHEMATIC_SUBCOMMANDS);
|
completions.addAll(SCHEMATIC_SUBCOMMANDS);
|
||||||
} else if (a1.equals("create") && sender.hasPermission(ParkourOption.ADMIN.permission)) {
|
} else if ("create".equals(a1) && sender.hasPermission(ParkourOption.ADMIN.permission)) {
|
||||||
completions.addAll(SCHEMATIC_DIFFICULTIES);
|
completions.addAll(SCHEMATIC_DIFFICULTIES);
|
||||||
} else if ((a1.equals("forcejoin") || a1.equals("forceleave")) && sender.hasPermission(ParkourOption.ADMIN.permission)) {
|
} else if (("forcejoin".equals(a1) || "forceleave".equals(a1)) && sender.hasPermission(ParkourOption.ADMIN.permission)) {
|
||||||
completions.add("everyone");
|
completions.add("everyone");
|
||||||
if (a1.equals("forcejoin")) completions.add("nearest");
|
if ("forcejoin".equals(a1)) {
|
||||||
|
completions.add("nearest");
|
||||||
|
}
|
||||||
Bukkit.getOnlinePlayers().forEach(pl -> completions.add(pl.getName()));
|
Bukkit.getOnlinePlayers().forEach(pl -> completions.add(pl.getName()));
|
||||||
} else if (a1.equals("recoverinventory") && sender.hasPermission(ParkourOption.ADMIN.permission)) {
|
} else if ("recoverinventory".equals(a1) && sender.hasPermission(ParkourOption.ADMIN.permission)) {
|
||||||
Bukkit.getOnlinePlayers().forEach(pl -> completions.add(pl.getName()));
|
Bukkit.getOnlinePlayers().forEach(pl -> completions.add(pl.getName()));
|
||||||
}
|
}
|
||||||
return filter(args[1], completions);
|
return filter(args[1], completions);
|
||||||
|
|
@ -242,10 +253,10 @@ public class LoParkourCommand implements CommandExecutor, TabCompleter {
|
||||||
if (args.length == 3 && sender.hasPermission(ParkourOption.ADMIN.permission)) {
|
if (args.length == 3 && sender.hasPermission(ParkourOption.ADMIN.permission)) {
|
||||||
String a1 = args[0].toLowerCase();
|
String a1 = args[0].toLowerCase();
|
||||||
String a2 = args[1].toLowerCase();
|
String a2 = args[1].toLowerCase();
|
||||||
if (a1.equals("schematic")) {
|
if ("schematic".equals(a1)) {
|
||||||
if (a2.equals("paste")) {
|
if ("paste".equals(a2)) {
|
||||||
addLoadedSchematicIds(completions);
|
addLoadedSchematicIds(completions);
|
||||||
} else if (a2.equals("create")) {
|
} else if ("create".equals(a2)) {
|
||||||
completions.addAll(SCHEMATIC_DIFFICULTIES);
|
completions.addAll(SCHEMATIC_DIFFICULTIES);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -255,7 +266,7 @@ public class LoParkourCommand implements CommandExecutor, TabCompleter {
|
||||||
if (args.length == 4 && sender.hasPermission(ParkourOption.ADMIN.permission)) {
|
if (args.length == 4 && sender.hasPermission(ParkourOption.ADMIN.permission)) {
|
||||||
String a1 = args[0].toLowerCase();
|
String a1 = args[0].toLowerCase();
|
||||||
String a2 = args[1].toLowerCase();
|
String a2 = args[1].toLowerCase();
|
||||||
if (a1.equals("schematic") && a2.equals("create")) {
|
if ("schematic".equals(a1) && "create".equals(a2)) {
|
||||||
completions.addAll(SCHEMATIC_DIFFICULTIES);
|
completions.addAll(SCHEMATIC_DIFFICULTIES);
|
||||||
}
|
}
|
||||||
return filter(args[3], completions);
|
return filter(args[3], completions);
|
||||||
|
|
|
||||||
|
|
@ -180,7 +180,9 @@ public class ConfigUpdater {
|
||||||
|
|
||||||
@Nullable
|
@Nullable
|
||||||
private File createBackup(@NotNull File file) {
|
private File createBackup(@NotNull File file) {
|
||||||
if (!file.exists()) return null;
|
if (!file.exists()) {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
try {
|
try {
|
||||||
File bak = new File(file.getParent(), file.getName() + ".bak");
|
File bak = new File(file.getParent(), file.getName() + ".bak");
|
||||||
Files.copy(file.toPath(), bak.toPath(), StandardCopyOption.REPLACE_EXISTING);
|
Files.copy(file.toPath(), bak.toPath(), StandardCopyOption.REPLACE_EXISTING);
|
||||||
|
|
|
||||||
|
|
@ -25,6 +25,9 @@ import java.util.stream.Stream;
|
||||||
*/
|
*/
|
||||||
public class LocaleLoader {
|
public class LocaleLoader {
|
||||||
|
|
||||||
|
private LocaleLoader() {
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Load all locale files from the locales/ folder.
|
* Load all locale files from the locales/ folder.
|
||||||
* Returns a map of locale name → FileConfiguration.
|
* Returns a map of locale name → FileConfiguration.
|
||||||
|
|
@ -68,7 +71,9 @@ public class LocaleLoader {
|
||||||
}
|
}
|
||||||
|
|
||||||
private static void ensureFolder(@NotNull File folder) {
|
private static void ensureFolder(@NotNull File folder) {
|
||||||
if (!folder.exists()) folder.mkdirs();
|
if (!folder.exists()) {
|
||||||
|
folder.mkdirs();
|
||||||
|
}
|
||||||
String[] files = folder.list();
|
String[] files = folder.list();
|
||||||
if (files == null || files.length == 0) {
|
if (files == null || files.length == 0) {
|
||||||
Plugin plugin = LoParkour.getPlugin();
|
Plugin plugin = LoParkour.getPlugin();
|
||||||
|
|
|
||||||
|
|
@ -26,6 +26,9 @@ import java.util.regex.Pattern;
|
||||||
*/
|
*/
|
||||||
public class Locales {
|
public class Locales {
|
||||||
|
|
||||||
|
private Locales() {
|
||||||
|
}
|
||||||
|
|
||||||
private static final LocaleCache CACHE = new LocaleCache();
|
private static final LocaleCache CACHE = new LocaleCache();
|
||||||
private static final Pattern REPLACEMENT_PATTERN = Pattern.compile("%[a-z]");
|
private static final Pattern REPLACEMENT_PATTERN = Pattern.compile("%[a-z]");
|
||||||
|
|
||||||
|
|
@ -144,7 +147,9 @@ public class Locales {
|
||||||
}
|
}
|
||||||
|
|
||||||
Item item = new Item(mat, name);
|
Item item = new Item(mat, name);
|
||||||
if (!lore.isEmpty()) item.lore(lore.split("\\|\\|"));
|
if (!lore.isEmpty()) {
|
||||||
|
item.lore(lore.split("\\|\\|"));
|
||||||
|
}
|
||||||
return item;
|
return item;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -24,6 +24,9 @@ import java.util.function.BiFunction;
|
||||||
*/
|
*/
|
||||||
public class Option {
|
public class Option {
|
||||||
|
|
||||||
|
private Option() {
|
||||||
|
}
|
||||||
|
|
||||||
// ── Initialization ────────────────────────────────────────────────────────
|
// ── Initialization ────────────────────────────────────────────────────────
|
||||||
|
|
||||||
public static void init(boolean firstLoad) {
|
public static void init(boolean firstLoad) {
|
||||||
|
|
|
||||||
|
|
@ -19,6 +19,9 @@ import java.util.Map;
|
||||||
*/
|
*/
|
||||||
public class OptionGeneral {
|
public class OptionGeneral {
|
||||||
|
|
||||||
|
private OptionGeneral() {
|
||||||
|
}
|
||||||
|
|
||||||
public static double BORDER_SIZE;
|
public static double BORDER_SIZE;
|
||||||
public static List<Integer> POSSIBLE_LEADS;
|
public static List<Integer> POSSIBLE_LEADS;
|
||||||
public static BlockFace HEADING;
|
public static BlockFace HEADING;
|
||||||
|
|
|
||||||
|
|
@ -11,6 +11,9 @@ import java.util.Map;
|
||||||
*/
|
*/
|
||||||
public class OptionGeneration {
|
public class OptionGeneration {
|
||||||
|
|
||||||
|
private OptionGeneration() {
|
||||||
|
}
|
||||||
|
|
||||||
// ── Block generation probabilities ────────────────────────────────────────
|
// ── Block generation probabilities ────────────────────────────────────────
|
||||||
public static double TYPE_NORMAL;
|
public static double TYPE_NORMAL;
|
||||||
public static double TYPE_SPECIAL;
|
public static double TYPE_SPECIAL;
|
||||||
|
|
|
||||||
|
|
@ -11,6 +11,9 @@ import org.bukkit.Sound;
|
||||||
*/
|
*/
|
||||||
public class OptionParticles {
|
public class OptionParticles {
|
||||||
|
|
||||||
|
private OptionParticles() {
|
||||||
|
}
|
||||||
|
|
||||||
public static Option.ParticleShape PARTICLE_SHAPE;
|
public static Option.ParticleShape PARTICLE_SHAPE;
|
||||||
public static Sound SOUND_TYPE;
|
public static Sound SOUND_TYPE;
|
||||||
public static int SOUND_PITCH;
|
public static int SOUND_PITCH;
|
||||||
|
|
@ -30,12 +33,16 @@ public class OptionParticles {
|
||||||
|
|
||||||
private static Sound resolveSound(String name) {
|
private static Sound resolveSound(String name) {
|
||||||
if (name != null && !name.isEmpty()) {
|
if (name != null && !name.isEmpty()) {
|
||||||
try { return Sound.valueOf(name.toUpperCase()); }
|
try {
|
||||||
catch (IllegalArgumentException ignored) {}
|
return Sound.valueOf(name.toUpperCase());
|
||||||
|
} catch (IllegalArgumentException ignored) {
|
||||||
|
}
|
||||||
}
|
}
|
||||||
for (String fb : new String[]{"BLOCK_NOTE_BLOCK_GUITAR", "BLOCK_NOTE_BLOCK_PLING", "BLOCK_NOTE_PLING"}) {
|
for (String fb : new String[]{"BLOCK_NOTE_BLOCK_GUITAR", "BLOCK_NOTE_BLOCK_PLING", "BLOCK_NOTE_PLING"}) {
|
||||||
try { return Sound.valueOf(fb); }
|
try {
|
||||||
catch (IllegalArgumentException ignored) {}
|
return Sound.valueOf(fb);
|
||||||
|
} catch (IllegalArgumentException ignored) {
|
||||||
|
}
|
||||||
}
|
}
|
||||||
LoParkour.getPlugin().getLogger().warning("Could not resolve any sound, using first available.");
|
LoParkour.getPlugin().getLogger().warning("Could not resolve any sound, using first available.");
|
||||||
return Sound.values()[0];
|
return Sound.values()[0];
|
||||||
|
|
@ -43,12 +50,16 @@ public class OptionParticles {
|
||||||
|
|
||||||
private static Particle resolveParticle(String name) {
|
private static Particle resolveParticle(String name) {
|
||||||
if (name != null && !name.isEmpty()) {
|
if (name != null && !name.isEmpty()) {
|
||||||
try { return Particle.valueOf(name.toUpperCase()); }
|
try {
|
||||||
catch (IllegalArgumentException ignored) {}
|
return Particle.valueOf(name.toUpperCase());
|
||||||
|
} catch (IllegalArgumentException ignored) {
|
||||||
|
}
|
||||||
}
|
}
|
||||||
for (String fb : new String[]{"INSTANT_EFFECT", "SPELL_INSTANT", "CRIT"}) {
|
for (String fb : new String[]{"INSTANT_EFFECT", "SPELL_INSTANT", "CRIT"}) {
|
||||||
try { return Particle.valueOf(fb); }
|
try {
|
||||||
catch (IllegalArgumentException ignored) {}
|
return Particle.valueOf(fb);
|
||||||
|
} catch (IllegalArgumentException ignored) {
|
||||||
|
}
|
||||||
}
|
}
|
||||||
LoParkour.getPlugin().getLogger().warning("Could not resolve any particle, using first available.");
|
LoParkour.getPlugin().getLogger().warning("Could not resolve any particle, using first available.");
|
||||||
return Particle.values()[0];
|
return Particle.values()[0];
|
||||||
|
|
@ -56,8 +67,10 @@ public class OptionParticles {
|
||||||
|
|
||||||
private static Option.ParticleShape resolveShape(String name) {
|
private static Option.ParticleShape resolveShape(String name) {
|
||||||
if (name != null && !name.isEmpty()) {
|
if (name != null && !name.isEmpty()) {
|
||||||
try { return Option.ParticleShape.valueOf(name.toUpperCase()); }
|
try {
|
||||||
catch (IllegalArgumentException ignored) {}
|
return Option.ParticleShape.valueOf(name.toUpperCase());
|
||||||
|
} catch (IllegalArgumentException ignored) {
|
||||||
|
}
|
||||||
}
|
}
|
||||||
return Option.ParticleShape.BOX;
|
return Option.ParticleShape.BOX;
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -1,6 +1,5 @@
|
||||||
package dev.loki.loparkour.config.options;
|
package dev.loki.loparkour.config.options;
|
||||||
|
|
||||||
import dev.loki.loparkour.LoParkour;
|
|
||||||
import dev.loki.loparkour.config.core.Config;
|
import dev.loki.loparkour.config.core.Config;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
@ -8,6 +7,9 @@ import dev.loki.loparkour.config.core.Config;
|
||||||
*/
|
*/
|
||||||
public class OptionSQL {
|
public class OptionSQL {
|
||||||
|
|
||||||
|
private OptionSQL() {
|
||||||
|
}
|
||||||
|
|
||||||
public static boolean SQL;
|
public static boolean SQL;
|
||||||
public static String SQL_URL;
|
public static String SQL_URL;
|
||||||
public static int SQL_PORT;
|
public static int SQL_PORT;
|
||||||
|
|
|
||||||
|
|
@ -17,6 +17,9 @@ import java.util.function.BiFunction;
|
||||||
*/
|
*/
|
||||||
public class OptionStyles {
|
public class OptionStyles {
|
||||||
|
|
||||||
|
private OptionStyles() {
|
||||||
|
}
|
||||||
|
|
||||||
public static Set<Style> initStyles(String path, FileConfiguration config,
|
public static Set<Style> initStyles(String path, FileConfiguration config,
|
||||||
BiFunction<String, List<Material>, Style> fn) {
|
BiFunction<String, List<Material>, Style> fn) {
|
||||||
var styles = new HashSet<Style>();
|
var styles = new HashSet<Style>();
|
||||||
|
|
|
||||||
|
|
@ -88,7 +88,7 @@ public class GeneratorStatistics {
|
||||||
long elapsed = java.time.Duration.between(generator.state.start, java.time.Instant.now()).toMillis();
|
long elapsed = java.time.Duration.between(generator.state.start, java.time.Instant.now()).toMillis();
|
||||||
Duration d = Duration.ofMillis(elapsed);
|
Duration d = Duration.ofMillis(elapsed);
|
||||||
|
|
||||||
if (format.equals("HH:mm:ss.SSS")) {
|
if ("HH:mm:ss.SSS".equals(format)) {
|
||||||
long hours = d.toHours();
|
long hours = d.toHours();
|
||||||
long minutes = d.toMinutesPart();
|
long minutes = d.toMinutesPart();
|
||||||
long seconds = d.toSecondsPart();
|
long seconds = d.toSecondsPart();
|
||||||
|
|
|
||||||
|
|
@ -70,15 +70,34 @@ public class ParkourGenerator {
|
||||||
|
|
||||||
|
|
||||||
// Core generation methods
|
// Core generation methods
|
||||||
public void generate() { placer.generate(); }
|
public void generate() {
|
||||||
public void generate(int amount) { placer.generate(amount); }
|
placer.generate();
|
||||||
public void generateFirst(Location spawn, Location block) { placer.generateFirst(spawn, block); }
|
}
|
||||||
|
|
||||||
|
public void generate(int amount) {
|
||||||
|
placer.generate(amount);
|
||||||
|
}
|
||||||
|
|
||||||
|
public void generateFirst(Location spawn, Location block) {
|
||||||
|
placer.generateFirst(spawn, block);
|
||||||
|
}
|
||||||
|
|
||||||
// Lifecycle methods
|
// Lifecycle methods
|
||||||
public void startTick() { lifecycle.startTick(); }
|
public void startTick() {
|
||||||
public void tick() { lifecycle.tick(); }
|
lifecycle.startTick();
|
||||||
public void fall() { lifecycle.fall(); }
|
}
|
||||||
protected void score() { lifecycle.score(); }
|
|
||||||
|
public void tick() {
|
||||||
|
lifecycle.tick();
|
||||||
|
}
|
||||||
|
|
||||||
|
public void fall() {
|
||||||
|
lifecycle.fall();
|
||||||
|
}
|
||||||
|
|
||||||
|
protected void score() {
|
||||||
|
lifecycle.score();
|
||||||
|
}
|
||||||
|
|
||||||
public void reset(boolean regenerate) {
|
public void reset(boolean regenerate) {
|
||||||
lifecycle.reset(regenerate);
|
lifecycle.reset(regenerate);
|
||||||
|
|
|
||||||
|
|
@ -105,6 +105,7 @@ public class BlockPlacer {
|
||||||
placeNormalBlock(); // Fallback to normal block
|
placeNormalBlock(); // Fallback to normal block
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
default -> {}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -86,7 +86,15 @@ public class GhostPlayer {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean isActive() { return entity != null && entity.isValid(); }
|
public boolean isActive() {
|
||||||
public String getPlayerName() { return data.getPlayerName(); }
|
return entity != null && entity.isValid();
|
||||||
public int getScore() { return data.getScore(); }
|
}
|
||||||
|
|
||||||
|
public String getPlayerName() {
|
||||||
|
return data.getPlayerName();
|
||||||
|
}
|
||||||
|
|
||||||
|
public int getScore() {
|
||||||
|
return data.getScore();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -62,6 +62,11 @@ public class GhostRecorder {
|
||||||
return new GhostData(playerUuid, playerName, score, frames);
|
return new GhostData(playerUuid, playerName, score, frames);
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean isRecording() { return recording; }
|
public boolean isRecording() {
|
||||||
public int getFrameCount() { return frames.size(); }
|
return recording;
|
||||||
|
}
|
||||||
|
|
||||||
|
public int getFrameCount() {
|
||||||
|
return frames.size();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -47,10 +47,21 @@ public class GhostData {
|
||||||
|
|
||||||
// ── Getters ───────────────────────────────────────────────────────────────
|
// ── Getters ───────────────────────────────────────────────────────────────
|
||||||
|
|
||||||
public UUID getPlayerUuid() { return playerUuid; }
|
public UUID getPlayerUuid() {
|
||||||
public String getPlayerName() { return playerName; }
|
return playerUuid;
|
||||||
public int getScore() { return score; }
|
}
|
||||||
public List<GhostFrame> getFrames() { return frames; }
|
|
||||||
|
public String getPlayerName() {
|
||||||
|
return playerName;
|
||||||
|
}
|
||||||
|
|
||||||
|
public int getScore() {
|
||||||
|
return score;
|
||||||
|
}
|
||||||
|
|
||||||
|
public List<GhostFrame> getFrames() {
|
||||||
|
return frames;
|
||||||
|
}
|
||||||
|
|
||||||
// ── Serialisation ─────────────────────────────────────────────────────────
|
// ── Serialisation ─────────────────────────────────────────────────────────
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -5,6 +5,8 @@ import org.geysermc.floodgate.api.FloodgateApi;
|
||||||
|
|
||||||
public class FloodgateHook {
|
public class FloodgateHook {
|
||||||
|
|
||||||
|
private FloodgateHook() {}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Whether this player is a bedrock player.
|
* Whether this player is a bedrock player.
|
||||||
*
|
*
|
||||||
|
|
|
||||||
|
|
@ -9,6 +9,8 @@ import me.filoghost.holographicdisplays.api.HolographicDisplaysAPI;
|
||||||
|
|
||||||
public class HoloHook {
|
public class HoloHook {
|
||||||
|
|
||||||
|
private HoloHook() {}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Initializes this hook.
|
* Initializes this hook.
|
||||||
*/
|
*/
|
||||||
|
|
|
||||||
|
|
@ -48,6 +48,7 @@ public class PAPIHook extends PlaceholderExpansion {
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@SuppressWarnings({"checkstyle:MethodLength", "checkstyle:CyclomaticComplexity"})
|
||||||
public String onPlaceholderRequest(Player player, @NotNull String params) {
|
public String onPlaceholderRequest(Player player, @NotNull String params) {
|
||||||
// placeholders that don't require a player
|
// placeholders that don't require a player
|
||||||
switch (params) {
|
switch (params) {
|
||||||
|
|
@ -62,6 +63,7 @@ public class PAPIHook extends PlaceholderExpansion {
|
||||||
Score score = Modes.DEFAULT.getLeaderboard().getScoreAtRank(1);
|
Score score = Modes.DEFAULT.getLeaderboard().getScoreAtRank(1);
|
||||||
return score != null ? Integer.toString(score.score()) : "?";
|
return score != null ? Integer.toString(score.score()) : "?";
|
||||||
}
|
}
|
||||||
|
default -> {}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (params.contains("player_rank_")) {
|
if (params.contains("player_rank_")) {
|
||||||
|
|
@ -102,6 +104,7 @@ public class PAPIHook extends PlaceholderExpansion {
|
||||||
case "high_score_time" -> {
|
case "high_score_time" -> {
|
||||||
return Modes.DEFAULT.getLeaderboard().get(player.getUniqueId()).time();
|
return Modes.DEFAULT.getLeaderboard().get(player.getUniqueId()).time();
|
||||||
}
|
}
|
||||||
|
default -> {}
|
||||||
}
|
}
|
||||||
|
|
||||||
ParkourUser user = ParkourUser.getUser(player);
|
ParkourUser user = ParkourUser.getUser(player);
|
||||||
|
|
|
||||||
|
|
@ -8,6 +8,8 @@ import org.bukkit.plugin.RegisteredServiceProvider;
|
||||||
|
|
||||||
public class VaultHook {
|
public class VaultHook {
|
||||||
|
|
||||||
|
private VaultHook() {}
|
||||||
|
|
||||||
private static Economy economy;
|
private static Economy economy;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
||||||
|
|
@ -15,7 +15,11 @@ public class CommunityMenu extends LPMenu {
|
||||||
|
|
||||||
baseGui(title, 3)
|
baseGui(title, 3)
|
||||||
.setItem(13, localeItem(player, "community.leaderboards.item"),
|
.setItem(13, localeItem(player, "community.leaderboards.item"),
|
||||||
e -> { if (ParkourOption.LEADERBOARDS.mayPerform(player)) Menus.LEADERBOARDS.open(player); })
|
e -> {
|
||||||
|
if (ParkourOption.LEADERBOARDS.mayPerform(player)) {
|
||||||
|
Menus.LEADERBOARDS.open(player);
|
||||||
|
}
|
||||||
|
})
|
||||||
.setItem(22, closeButton(player), e -> player.closeInventory())
|
.setItem(22, closeButton(player), e -> player.closeInventory())
|
||||||
.open(player);
|
.open(player);
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -34,9 +34,13 @@ public class LeaderboardsMenu extends LPMenu {
|
||||||
List<ItemStack> items = new ArrayList<>();
|
List<ItemStack> items = new ArrayList<>();
|
||||||
|
|
||||||
for (Mode mode : Registry.getModes()) {
|
for (Mode mode : Registry.getModes()) {
|
||||||
if (mode.getLeaderboard() == null) continue;
|
if (mode.getLeaderboard() == null) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
var item = mode.getItem(locale);
|
var item = mode.getItem(locale);
|
||||||
if (item == null) continue;
|
if (item == null) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
modes.add(mode);
|
modes.add(mode);
|
||||||
items.add(item.build());
|
items.add(item.build());
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -33,7 +33,9 @@ public class SingleLeaderboardMenu extends LPMenu {
|
||||||
public void open(@NotNull Player player, @NotNull Mode mode, @NotNull Leaderboard.Sort sort, int page) {
|
public void open(@NotNull Player player, @NotNull Mode mode, @NotNull Leaderboard.Sort sort, int page) {
|
||||||
this.currentPage = page;
|
this.currentPage = page;
|
||||||
Leaderboard leaderboard = mode.getLeaderboard();
|
Leaderboard leaderboard = mode.getLeaderboard();
|
||||||
if (leaderboard == null) return;
|
if (leaderboard == null) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
String locale = locale(player);
|
String locale = locale(player);
|
||||||
String title = Locales.getString(locale, ParkourOption.LEADERBOARDS.path + ".name");
|
String title = Locales.getString(locale, ParkourOption.LEADERBOARDS.path + ".name");
|
||||||
|
|
@ -44,7 +46,9 @@ public class SingleLeaderboardMenu extends LPMenu {
|
||||||
for (Map.Entry<UUID, Score> entry : leaderboard.sort(sort).entrySet()) {
|
for (Map.Entry<UUID, Score> entry : leaderboard.sort(sort).entrySet()) {
|
||||||
rank++;
|
rank++;
|
||||||
Score score = entry.getValue();
|
Score score = entry.getValue();
|
||||||
if (score == null) continue;
|
if (score == null) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
ItemStack skull = new ItemStack(Material.PLAYER_HEAD);
|
ItemStack skull = new ItemStack(Material.PLAYER_HEAD);
|
||||||
if (rank <= 20 && !ParkourUser.isBedrockPlayer(player)) {
|
if (rank <= 20 && !ParkourUser.isBedrockPlayer(player)) {
|
||||||
|
|
@ -71,7 +75,9 @@ public class SingleLeaderboardMenu extends LPMenu {
|
||||||
.replace("%t", score.time())
|
.replace("%t", score.time())
|
||||||
.replace("%d", score.difficulty()));
|
.replace("%d", score.difficulty()));
|
||||||
ItemMeta built = base.build().getItemMeta();
|
ItemMeta built = base.build().getItemMeta();
|
||||||
if (built != null) skull.setItemMeta(built);
|
if (built != null) {
|
||||||
|
skull.setItemMeta(built);
|
||||||
|
}
|
||||||
|
|
||||||
items.add(skull);
|
items.add(skull);
|
||||||
}
|
}
|
||||||
|
|
@ -104,5 +110,7 @@ public class SingleLeaderboardMenu extends LPMenu {
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void open(@NotNull Player player) { /* use open(player, mode, sort) */ }
|
public void open(@NotNull Player player) {
|
||||||
|
/* use open(player, mode, sort) */
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -5,7 +5,9 @@ import org.bukkit.entity.Player;
|
||||||
import org.jetbrains.annotations.NotNull;
|
import org.jetbrains.annotations.NotNull;
|
||||||
import org.jetbrains.annotations.Nullable;
|
import org.jetbrains.annotations.Nullable;
|
||||||
|
|
||||||
import java.util.*;
|
import java.util.HashMap;
|
||||||
|
import java.util.List;
|
||||||
|
import java.util.Map;
|
||||||
import java.util.function.BiFunction;
|
import java.util.function.BiFunction;
|
||||||
import java.util.function.Predicate;
|
import java.util.function.Predicate;
|
||||||
|
|
||||||
|
|
@ -29,7 +31,10 @@ public abstract class DynamicMenu {
|
||||||
*/
|
*/
|
||||||
// Stub: migrate to LoLib GUI when dynamic rows are wired up.
|
// Stub: migrate to LoLib GUI when dynamic rows are wired up.
|
||||||
/*
|
/*
|
||||||
public void registerMainItem(int row, int id, BiFunction<@NotNull Player, @Nullable ParkourUser, dev.loki.loparkour.util.gui.MenuItem> item, Predicate<Player> shouldDisplay) {
|
public void registerMainItem(
|
||||||
|
int row, int id,
|
||||||
|
BiFunction<@NotNull Player, @Nullable ParkourUser, dev.loki.loparkour.util.gui.MenuItem> item,
|
||||||
|
Predicate<Player> shouldDisplay) {
|
||||||
if (id < 0 || row < 0 || row > 4) {
|
if (id < 0 || row < 0 || row > 4) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
@ -75,6 +80,9 @@ public abstract class DynamicMenu {
|
||||||
/**
|
/**
|
||||||
* Data class for registered items
|
* Data class for registered items
|
||||||
*/
|
*/
|
||||||
protected record ItemContainer(int id, BiFunction<@NotNull Player, @Nullable ParkourUser, dev.loki.loparkour.util.gui.MenuItem> item,
|
protected record ItemContainer(
|
||||||
Predicate<Player> predicate) {}
|
int id,
|
||||||
|
BiFunction<@NotNull Player, @Nullable ParkourUser, dev.loki.loparkour.util.gui.MenuItem> item,
|
||||||
|
Predicate<Player> predicate
|
||||||
|
) {}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -21,7 +21,9 @@ public class LobbyMenu extends LPMenu {
|
||||||
@Override
|
@Override
|
||||||
public void open(@NotNull Player player) {
|
public void open(@NotNull Player player) {
|
||||||
ParkourUser user = ParkourUser.getUser(player);
|
ParkourUser user = ParkourUser.getUser(player);
|
||||||
if (user == null) return;
|
if (user == null) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
String locale = user.locale;
|
String locale = user.locale;
|
||||||
String title = Locales.getString(locale, "lobby.name");
|
String title = Locales.getString(locale, "lobby.name");
|
||||||
|
|
|
||||||
|
|
@ -24,7 +24,9 @@ public class PlayerManagementMenu extends LPMenu {
|
||||||
@Override
|
@Override
|
||||||
public void open(@NotNull Player player) {
|
public void open(@NotNull Player player) {
|
||||||
ParkourPlayer viewer = ParkourPlayer.getPlayer(player);
|
ParkourPlayer viewer = ParkourPlayer.getPlayer(player);
|
||||||
if (viewer == null) return;
|
if (viewer == null) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
var session = viewer.session;
|
var session = viewer.session;
|
||||||
String locale = viewer.locale;
|
String locale = viewer.locale;
|
||||||
|
|
|
||||||
|
|
@ -15,9 +15,17 @@ public class PlayMenu extends LPMenu {
|
||||||
|
|
||||||
baseGui(title, 3)
|
baseGui(title, 3)
|
||||||
.setItem(11, localeItem(player, "play.single.item"),
|
.setItem(11, localeItem(player, "play.single.item"),
|
||||||
e -> { if (ParkourOption.SINGLE.mayPerform(player)) Menus.SINGLE.open(player); })
|
e -> {
|
||||||
|
if (ParkourOption.SINGLE.mayPerform(player)) {
|
||||||
|
Menus.SINGLE.open(player);
|
||||||
|
}
|
||||||
|
})
|
||||||
.setItem(15, localeItem(player, "play.spectator.item"),
|
.setItem(15, localeItem(player, "play.spectator.item"),
|
||||||
e -> { if (ParkourOption.SPECTATOR.mayPerform(player)) Menus.SPECTATOR.open(player); })
|
e -> {
|
||||||
|
if (ParkourOption.SPECTATOR.mayPerform(player)) {
|
||||||
|
Menus.SPECTATOR.open(player);
|
||||||
|
}
|
||||||
|
})
|
||||||
.setItem(22, closeButton(player), e -> player.closeInventory())
|
.setItem(22, closeButton(player), e -> player.closeInventory())
|
||||||
.open(player);
|
.open(player);
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -33,17 +33,25 @@ public class SingleMenu extends LPMenu {
|
||||||
|
|
||||||
for (Mode mode : Registry.getModes()) {
|
for (Mode mode : Registry.getModes()) {
|
||||||
// Skip spectator mode in single menu
|
// Skip spectator mode in single menu
|
||||||
if (mode.getName().equals("spectator")) continue;
|
if ("spectator".equals(mode.getName())) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
// Check if mode is enabled in config
|
// Check if mode is enabled in config
|
||||||
if (!Config.CONFIG.getBoolean("modes." + mode.getName() + ".enabled", true)) continue;
|
if (!Config.CONFIG.getBoolean("modes." + mode.getName() + ".enabled", true)) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
boolean blocked = Config.CONFIG.getBoolean("permissions.enabled")
|
boolean blocked = Config.CONFIG.getBoolean("permissions.enabled")
|
||||||
&& !player.hasPermission("LoParkour.gamemode." + mode.getName());
|
&& !player.hasPermission("LoParkour.gamemode." + mode.getName());
|
||||||
if (blocked) continue;
|
if (blocked) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
var item = mode.getItem(locale);
|
var item = mode.getItem(locale);
|
||||||
if (item == null) continue;
|
if (item == null) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
availableModes.add(mode);
|
availableModes.add(mode);
|
||||||
items.add(item.build());
|
items.add(item.build());
|
||||||
|
|
|
||||||
|
|
@ -35,10 +35,16 @@ public class SpectatorMenu extends LPMenu {
|
||||||
List<Session> sessions = new ArrayList<>();
|
List<Session> sessions = new ArrayList<>();
|
||||||
List<ItemStack> items = new ArrayList<>();
|
List<ItemStack> items = new ArrayList<>();
|
||||||
|
|
||||||
for (Session session : Divider.sections.keySet()) {
|
for (Session session : Divider.SECTIONS.keySet()) {
|
||||||
if (!session.isAcceptingSpectators()) continue;
|
if (!session.isAcceptingSpectators()) {
|
||||||
if (user != null && session == user.session) continue;
|
continue;
|
||||||
if (session.getPlayers().isEmpty()) continue;
|
}
|
||||||
|
if (user != null && session == user.session) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
if (session.getPlayers().isEmpty()) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
var pp = session.getPlayers().get(0);
|
var pp = session.getPlayers().get(0);
|
||||||
ItemStack skull = new ItemStack(Material.PLAYER_HEAD);
|
ItemStack skull = new ItemStack(Material.PLAYER_HEAD);
|
||||||
|
|
|
||||||
|
|
@ -18,14 +18,18 @@ import java.util.List;
|
||||||
public class LangMenu extends LPMenu {
|
public class LangMenu extends LPMenu {
|
||||||
|
|
||||||
public void open(@NotNull ParkourPlayer user) {
|
public void open(@NotNull ParkourPlayer user) {
|
||||||
if (user == null) return;
|
if (user == null) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
open(user.player);
|
open(user.player);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void open(@NotNull Player player) {
|
public void open(@NotNull Player player) {
|
||||||
ParkourPlayer pp = ParkourPlayer.getPlayer(player);
|
ParkourPlayer pp = ParkourPlayer.getPlayer(player);
|
||||||
if (pp == null) return;
|
if (pp == null) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
String locale = pp.locale;
|
String locale = pp.locale;
|
||||||
String title = Locales.getString(locale, "settings.lang.name");
|
String title = Locales.getString(locale, "settings.lang.name");
|
||||||
|
|
@ -44,7 +48,6 @@ public class LangMenu extends LPMenu {
|
||||||
item.setItemMeta(meta);
|
item.setItemMeta(meta);
|
||||||
}
|
}
|
||||||
gui = gui.setItem(10 + i, item, e -> {
|
gui = gui.setItem(10 + i, item, e -> {
|
||||||
pp.locale = lang;
|
|
||||||
pp.locale = lang;
|
pp.locale = lang;
|
||||||
pp.updateHotbar(); // Update hotbar with new language
|
pp.updateHotbar(); // Update hotbar with new language
|
||||||
Menus.SETTINGS.open(player);
|
Menus.SETTINGS.open(player);
|
||||||
|
|
|
||||||
|
|
@ -22,14 +22,18 @@ import java.util.List;
|
||||||
public class ParkourSettingsMenu extends LPMenu {
|
public class ParkourSettingsMenu extends LPMenu {
|
||||||
|
|
||||||
public void open(@NotNull ParkourPlayer user) {
|
public void open(@NotNull ParkourPlayer user) {
|
||||||
if (user == null) return;
|
if (user == null) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
open(user.player);
|
open(user.player);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void open(@NotNull Player player) {
|
public void open(@NotNull Player player) {
|
||||||
ParkourPlayer pp = ParkourPlayer.getPlayer(player);
|
ParkourPlayer pp = ParkourPlayer.getPlayer(player);
|
||||||
if (pp == null) return;
|
if (pp == null) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
String locale = pp.locale;
|
String locale = pp.locale;
|
||||||
String title = Locales.getString(locale, "settings.name");
|
String title = Locales.getString(locale, "settings.name");
|
||||||
|
|
@ -151,10 +155,14 @@ public class ParkourSettingsMenu extends LPMenu {
|
||||||
|
|
||||||
int slot = 10;
|
int slot = 10;
|
||||||
for (Style style : Registry.getStyles()) {
|
for (Style style : Registry.getStyles()) {
|
||||||
if (slot > 16) break;
|
if (slot > 16) {
|
||||||
|
break;
|
||||||
|
}
|
||||||
String name = style.getName();
|
String name = style.getName();
|
||||||
String perm = ParkourOption.STYLES.permission + "." + name.toLowerCase().replace(" ", ".");
|
String perm = ParkourOption.STYLES.permission + "." + name.toLowerCase().replace(" ", ".");
|
||||||
if (Config.CONFIG.getBoolean("permissions.per-style") && !player.hasPermission(perm)) continue;
|
if (Config.CONFIG.getBoolean("permissions.per-style") && !player.hasPermission(perm)) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
ItemStack item = new ItemStack(style.getNext());
|
ItemStack item = new ItemStack(style.getNext());
|
||||||
ItemMeta meta = item.getItemMeta();
|
ItemMeta meta = item.getItemMeta();
|
||||||
|
|
|
||||||
|
|
@ -22,7 +22,9 @@ public class SettingsMenu extends LPMenu {
|
||||||
if (ParkourOption.PARKOUR_SETTINGS.mayPerform(player) && ParkourPlayer.isPlayer(player)) {
|
if (ParkourOption.PARKOUR_SETTINGS.mayPerform(player) && ParkourPlayer.isPlayer(player)) {
|
||||||
gui = gui.setItem(11, localeItem(player, "settings.parkour_settings.item"), e -> {
|
gui = gui.setItem(11, localeItem(player, "settings.parkour_settings.item"), e -> {
|
||||||
ParkourPlayer pp = ParkourPlayer.getPlayer(player);
|
ParkourPlayer pp = ParkourPlayer.getPlayer(player);
|
||||||
if (pp != null) pp.session.generator.menu(pp);
|
if (pp != null) {
|
||||||
|
pp.session.generator.menu(pp);
|
||||||
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -30,7 +32,9 @@ public class SettingsMenu extends LPMenu {
|
||||||
String langName = Locales.getString(locale, "name");
|
String langName = Locales.getString(locale, "name");
|
||||||
gui = gui.setItem(13, localeItem(locale, "settings.lang.item", langName), e -> {
|
gui = gui.setItem(13, localeItem(locale, "settings.lang.item", langName), e -> {
|
||||||
ParkourPlayer pp = ParkourPlayer.getPlayer(player);
|
ParkourPlayer pp = ParkourPlayer.getPlayer(player);
|
||||||
if (pp != null) Menus.LANG.open(pp);
|
if (pp != null) {
|
||||||
|
Menus.LANG.open(pp);
|
||||||
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -114,7 +114,9 @@ public class CoopMode implements MultiMode {
|
||||||
@Override
|
@Override
|
||||||
public void leave(Player player, Session session) {
|
public void leave(Player player, Session session) {
|
||||||
ParkourPlayer pp = ParkourPlayer.getPlayer(player);
|
ParkourPlayer pp = ParkourPlayer.getPlayer(player);
|
||||||
if (pp == null) return;
|
if (pp == null) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
ParkourUser.leave(pp);
|
ParkourUser.leave(pp);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -82,7 +82,7 @@ public class ParkourPlayer extends ParkourUser {
|
||||||
*/
|
*/
|
||||||
public static @Nullable ParkourPlayer getPlayer(@NotNull Player player) {
|
public static @Nullable ParkourPlayer getPlayer(@NotNull Player player) {
|
||||||
// Optimized: search directly in sessions without creating intermediate list
|
// Optimized: search directly in sessions without creating intermediate list
|
||||||
return Divider.sections.keySet().stream()
|
return Divider.SECTIONS.keySet().stream()
|
||||||
.flatMap(session -> session.getPlayers().stream())
|
.flatMap(session -> session.getPlayers().stream())
|
||||||
.filter(other -> other.getUUID().equals(player.getUniqueId()))
|
.filter(other -> other.getUUID().equals(player.getUniqueId()))
|
||||||
.findAny()
|
.findAny()
|
||||||
|
|
@ -93,7 +93,7 @@ public class ParkourPlayer extends ParkourUser {
|
||||||
* @return List with all players.
|
* @return List with all players.
|
||||||
*/
|
*/
|
||||||
public static List<ParkourPlayer> getPlayers() {
|
public static List<ParkourPlayer> getPlayers() {
|
||||||
return Divider.sections.keySet().stream()
|
return Divider.SECTIONS.keySet().stream()
|
||||||
.flatMap(session -> session.getPlayers().stream())
|
.flatMap(session -> session.getPlayers().stream())
|
||||||
.toList();
|
.toList();
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -92,7 +92,7 @@ public final class UserRegistry {
|
||||||
}
|
}
|
||||||
|
|
||||||
public static Set<ParkourUser> getUsers() {
|
public static Set<ParkourUser> getUsers() {
|
||||||
return Divider.sections.keySet().stream()
|
return Divider.SECTIONS.keySet().stream()
|
||||||
.flatMap(session -> session.getUsers().stream())
|
.flatMap(session -> session.getUsers().stream())
|
||||||
.collect(Collectors.toSet());
|
.collect(Collectors.toSet());
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -49,7 +49,7 @@ public final class LPSchematicLegacy {
|
||||||
}
|
}
|
||||||
|
|
||||||
SchematicData data = GSON.fromJson(json.toString(), SchematicData.class);
|
SchematicData data = GSON.fromJson(json.toString(), SchematicData.class);
|
||||||
if (data == null || data.format_version != FORMAT_VERSION) {
|
if (data == null || data.formatVersion != FORMAT_VERSION) {
|
||||||
throw new IOException("Unsupported .lpschem format in " + file.getName());
|
throw new IOException("Unsupported .lpschem format in " + file.getName());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -77,7 +77,7 @@ public final class LPSchematicLegacy {
|
||||||
}
|
}
|
||||||
|
|
||||||
private static class SchematicData {
|
private static class SchematicData {
|
||||||
int format_version;
|
int formatVersion;
|
||||||
SchematicMetadata metadata;
|
SchematicMetadata metadata;
|
||||||
SchematicDimensions dimensions;
|
SchematicDimensions dimensions;
|
||||||
List<String> palette;
|
List<String> palette;
|
||||||
|
|
|
||||||
|
|
@ -6,7 +6,11 @@ import dev.loki.loparkour.player.core.ParkourPlayer;
|
||||||
import dev.loki.loparkour.player.spectator.ParkourSpectator;
|
import dev.loki.loparkour.player.spectator.ParkourSpectator;
|
||||||
import dev.loki.loparkour.player.core.ParkourUser;
|
import dev.loki.loparkour.player.core.ParkourUser;
|
||||||
|
|
||||||
import java.util.*;
|
import java.util.ArrayList;
|
||||||
|
import java.util.HashMap;
|
||||||
|
import java.util.List;
|
||||||
|
import java.util.Map;
|
||||||
|
import java.util.UUID;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Manages users (players and spectators) within a session.
|
* Manages users (players and spectators) within a session.
|
||||||
|
|
@ -19,7 +23,7 @@ class SessionUserManager {
|
||||||
private final List<ParkourUser> muted = new ArrayList<>();
|
private final List<ParkourUser> muted = new ArrayList<>();
|
||||||
private final Session session;
|
private final Session session;
|
||||||
|
|
||||||
public SessionUserManager(Session session) {
|
SessionUserManager(Session session) {
|
||||||
this.session = session;
|
this.session = session;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -6,7 +6,6 @@ import dev.loki.loparkour.LoParkour;
|
||||||
import dev.loki.loparkour.config.options.Option;
|
import dev.loki.loparkour.config.options.Option;
|
||||||
|
|
||||||
import java.sql.Connection;
|
import java.sql.Connection;
|
||||||
import java.sql.PreparedStatement;
|
|
||||||
import java.sql.SQLException;
|
import java.sql.SQLException;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.concurrent.CopyOnWriteArrayList;
|
import java.util.concurrent.CopyOnWriteArrayList;
|
||||||
|
|
|
||||||
|
|
@ -11,7 +11,7 @@ class SQLMigrationManager {
|
||||||
|
|
||||||
private final SQLQueryExecutor queryExecutor;
|
private final SQLQueryExecutor queryExecutor;
|
||||||
|
|
||||||
public SQLMigrationManager(SQLQueryExecutor queryExecutor) {
|
SQLMigrationManager(SQLQueryExecutor queryExecutor) {
|
||||||
this.queryExecutor = queryExecutor;
|
this.queryExecutor = queryExecutor;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -18,7 +18,7 @@ class SQLQueryExecutor {
|
||||||
|
|
||||||
private final SQLConnectionManager connectionManager;
|
private final SQLConnectionManager connectionManager;
|
||||||
|
|
||||||
public SQLQueryExecutor(SQLConnectionManager connectionManager) {
|
SQLQueryExecutor(SQLConnectionManager connectionManager) {
|
||||||
this.connectionManager = connectionManager;
|
this.connectionManager = connectionManager;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -9,7 +9,7 @@ import java.util.Map;
|
||||||
import java.util.stream.IntStream;
|
import java.util.stream.IntStream;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* <p>Divides the parkour world in sections, each with an active session.</p>
|
* <p>Divides the parkour world in SECTIONS, each with an active session.</p>
|
||||||
* <p>Iteration 2.</p>
|
* <p>Iteration 2.</p>
|
||||||
*
|
*
|
||||||
* @author loki
|
* @author loki
|
||||||
|
|
@ -23,7 +23,7 @@ public class Divider {
|
||||||
/**
|
/**
|
||||||
* Map with all session ids map to the session instances.
|
* Map with all session ids map to the session instances.
|
||||||
*/
|
*/
|
||||||
public static final Map<Session, Integer> sections = new HashMap<>();
|
public static final Map<Session, Integer> SECTIONS = new HashMap<>();
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Associates a session to a specific section.
|
* Associates a session to a specific section.
|
||||||
|
|
@ -32,12 +32,12 @@ public class Divider {
|
||||||
*/
|
*/
|
||||||
public static synchronized Location add(Session session) {
|
public static synchronized Location add(Session session) {
|
||||||
// attempts to get the closest available section to the center
|
// attempts to get the closest available section to the center
|
||||||
var missing = IntStream.range(0, sections.size() + 1)
|
var missing = IntStream.range(0, SECTIONS.size() + 1)
|
||||||
.filter(i -> !sections.containsValue(i))
|
.filter(i -> !SECTIONS.containsValue(i))
|
||||||
.findFirst()
|
.findFirst()
|
||||||
.orElseThrow();
|
.orElseThrow();
|
||||||
|
|
||||||
sections.put(session, missing);
|
SECTIONS.put(session, missing);
|
||||||
|
|
||||||
var location = toLocation(session);
|
var location = toLocation(session);
|
||||||
|
|
||||||
|
|
@ -50,7 +50,7 @@ public class Divider {
|
||||||
* @param session The session.
|
* @param session The session.
|
||||||
*/
|
*/
|
||||||
public static void remove(Session session) {
|
public static void remove(Session session) {
|
||||||
sections.remove(session);
|
SECTIONS.remove(session);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
@ -58,7 +58,7 @@ public class Divider {
|
||||||
* @return The location at the center of section n.
|
* @return The location at the center of section n.
|
||||||
*/
|
*/
|
||||||
private static Location toLocation(Session session) {
|
private static Location toLocation(Session session) {
|
||||||
int[] xz = spiralAt(sections.get(session));
|
int[] xz = spiralAt(SECTIONS.get(session));
|
||||||
|
|
||||||
return new Location(World.getWorld(),
|
return new Location(World.getWorld(),
|
||||||
xz[0] * Option.BORDER_SIZE,
|
xz[0] * Option.BORDER_SIZE,
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue