mirror of
https://github.com/darksaid98/AlathranWars.git
synced 2026-12-03 14:38:56 +00:00
style: reformat project
This commit is contained in:
28 files changed
+135
-115
No files matched your search
@@ -1,10 +1,10 @@
|
|||||||
package com.github.alathra.AlathranWars.commands;
|
package com.github.alathra.AlathranWars.commands;
|
||||||
|
|
||||||
import com.github.alathra.AlathranWars.AlathranWars;
|
import com.github.alathra.AlathranWars.AlathranWars;
|
||||||
import com.github.alathra.AlathranWars.conflict.war.side.Side;
|
import com.github.alathra.AlathranWars.conflict.battle.siege.Siege;
|
||||||
import com.github.alathra.AlathranWars.conflict.war.War;
|
import com.github.alathra.AlathranWars.conflict.war.War;
|
||||||
import com.github.alathra.AlathranWars.conflict.war.WarController;
|
import com.github.alathra.AlathranWars.conflict.war.WarController;
|
||||||
import com.github.alathra.AlathranWars.conflict.battle.siege.Siege;
|
import com.github.alathra.AlathranWars.conflict.war.side.Side;
|
||||||
import com.github.alathra.AlathranWars.enums.CommandArgsSiege;
|
import com.github.alathra.AlathranWars.enums.CommandArgsSiege;
|
||||||
import com.github.alathra.AlathranWars.enums.CommandArgsWar;
|
import com.github.alathra.AlathranWars.enums.CommandArgsWar;
|
||||||
import com.github.alathra.AlathranWars.hooks.TownyHook;
|
import com.github.alathra.AlathranWars.hooks.TownyHook;
|
||||||
@@ -648,7 +648,8 @@ public class CommandUtil {
|
|||||||
}
|
}
|
||||||
if (AlathranWars.getInstance().getConfig().getInt("minimumPlayTime") > 0) {
|
if (AlathranWars.getInstance().getConfig().getInt("minimumPlayTime") > 0) {
|
||||||
//check playtime, if its less than min its true
|
//check playtime, if its less than min its true
|
||||||
if (playTicks < (AlathranWars.getInstance().getConfig().getInt("minimumPlayTime") * (60 * 60 * 20))) out = 2;
|
if (playTicks < (AlathranWars.getInstance().getConfig().getInt("minimumPlayTime") * (60 * 60 * 20)))
|
||||||
|
out = 2;
|
||||||
}
|
}
|
||||||
|
|
||||||
return out;
|
return out;
|
||||||
|
|||||||
@@ -1,10 +1,10 @@
|
|||||||
package com.github.alathra.AlathranWars.commands;
|
package com.github.alathra.AlathranWars.commands;
|
||||||
|
|
||||||
import com.github.alathra.AlathranWars.AlathranWars;
|
import com.github.alathra.AlathranWars.AlathranWars;
|
||||||
import com.github.alathra.AlathranWars.conflict.war.side.Side;
|
import com.github.alathra.AlathranWars.conflict.battle.siege.Siege;
|
||||||
import com.github.alathra.AlathranWars.conflict.war.War;
|
import com.github.alathra.AlathranWars.conflict.war.War;
|
||||||
import com.github.alathra.AlathranWars.conflict.war.WarController;
|
import com.github.alathra.AlathranWars.conflict.war.WarController;
|
||||||
import com.github.alathra.AlathranWars.conflict.battle.siege.Siege;
|
import com.github.alathra.AlathranWars.conflict.war.side.Side;
|
||||||
import com.github.alathra.AlathranWars.enums.battle.BattleVictoryReason;
|
import com.github.alathra.AlathranWars.enums.battle.BattleVictoryReason;
|
||||||
import com.github.alathra.AlathranWars.utility.UtilsChat;
|
import com.github.alathra.AlathranWars.utility.UtilsChat;
|
||||||
import com.github.milkdrinkers.colorparser.ColorParser;
|
import com.github.milkdrinkers.colorparser.ColorParser;
|
||||||
|
|||||||
@@ -8,15 +8,20 @@ import java.util.UUID;
|
|||||||
|
|
||||||
public interface Battle {
|
public interface Battle {
|
||||||
void start(); // Initiates battle
|
void start(); // Initiates battle
|
||||||
|
|
||||||
void stop(); // Ends battle
|
void stop(); // Ends battle
|
||||||
|
|
||||||
void resume(); // Resume battle after server restart or plugin reload
|
void resume(); // Resume battle after server restart or plugin reload
|
||||||
|
|
||||||
void attackersWin(BattleVictoryReason reason); // A Attacker victory
|
void attackersWin(BattleVictoryReason reason); // A Attacker victory
|
||||||
|
|
||||||
void defendersWin(BattleVictoryReason reason); // A Defender victory
|
void defendersWin(BattleVictoryReason reason); // A Defender victory
|
||||||
|
|
||||||
void equalWin(BattleVictoryReason reason); // A Draw
|
void equalWin(BattleVictoryReason reason); // A Draw
|
||||||
|
|
||||||
|
|
||||||
UUID uuid = null; // Battle UUID
|
UUID uuid = null; // Battle UUID
|
||||||
|
|
||||||
default @NotNull UUID getUUID() {
|
default @NotNull UUID getUUID() {
|
||||||
return uuid;
|
return uuid;
|
||||||
}
|
}
|
||||||
@@ -42,6 +47,7 @@ public interface Battle {
|
|||||||
}
|
}
|
||||||
|
|
||||||
BattleType battleType = null;
|
BattleType battleType = null;
|
||||||
|
|
||||||
default BattleType getBattleType() {
|
default BattleType getBattleType() {
|
||||||
return battleType;
|
return battleType;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -34,7 +34,10 @@ import org.bukkit.scheduler.BukkitRunnable;
|
|||||||
import space.arim.morepaperlib.scheduling.ScheduledTask;
|
import space.arim.morepaperlib.scheduling.ScheduledTask;
|
||||||
|
|
||||||
import java.time.Duration;
|
import java.time.Duration;
|
||||||
import java.util.*;
|
import java.util.ArrayList;
|
||||||
|
import java.util.HashSet;
|
||||||
|
import java.util.List;
|
||||||
|
import java.util.Set;
|
||||||
import java.util.concurrent.ConcurrentHashMap;
|
import java.util.concurrent.ConcurrentHashMap;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -164,7 +167,7 @@ public abstract class Laser {
|
|||||||
/**
|
/**
|
||||||
* Gets laser status.
|
* Gets laser status.
|
||||||
*
|
*
|
||||||
* @return <code>true</code> if the laser is currently running
|
* @return <code>true</code> if the laser is currently running
|
||||||
* (i.e. {@link #start} has been called and the duration is not over)
|
* (i.e. {@link #start} has been called and the duration is not over)
|
||||||
*/
|
*/
|
||||||
public boolean isStarted() {
|
public boolean isStarted() {
|
||||||
|
|||||||
@@ -161,7 +161,7 @@ class Packets {
|
|||||||
ColorParser.of("Laser reflection failed to initialize. The utility is disabled. Please ensure your version (<version>) is supported.")
|
ColorParser.of("Laser reflection failed to initialize. The utility is disabled. Please ensure your version (<version>) is supported.")
|
||||||
.parseMinimessagePlaceholder("version", Bukkit.getServer().getClass().getPackage().getName())
|
.parseMinimessagePlaceholder("version", Bukkit.getServer().getClass().getPackage().getName())
|
||||||
.build()
|
.build()
|
||||||
, e);
|
, e);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -1,9 +1,9 @@
|
|||||||
package com.github.alathra.AlathranWars.conflict.battle.raid;
|
package com.github.alathra.AlathranWars.conflict.battle.raid;
|
||||||
|
|
||||||
import com.github.alathra.AlathranWars.AlathranWars;
|
import com.github.alathra.AlathranWars.AlathranWars;
|
||||||
import com.github.alathra.AlathranWars.conflict.war.side.Side;
|
|
||||||
import com.github.alathra.AlathranWars.conflict.war.War;
|
|
||||||
import com.github.alathra.AlathranWars.conflict.battle.Battle;
|
import com.github.alathra.AlathranWars.conflict.battle.Battle;
|
||||||
|
import com.github.alathra.AlathranWars.conflict.war.War;
|
||||||
|
import com.github.alathra.AlathranWars.conflict.war.side.Side;
|
||||||
import com.github.alathra.AlathranWars.enums.CaptureProgressDirection;
|
import com.github.alathra.AlathranWars.enums.CaptureProgressDirection;
|
||||||
import com.github.alathra.AlathranWars.enums.battle.*;
|
import com.github.alathra.AlathranWars.enums.battle.*;
|
||||||
import com.github.alathra.AlathranWars.events.battle.BattleResultEvent;
|
import com.github.alathra.AlathranWars.events.battle.BattleResultEvent;
|
||||||
|
|||||||
@@ -1,9 +1,9 @@
|
|||||||
package com.github.alathra.AlathranWars.conflict.battle.siege;
|
package com.github.alathra.AlathranWars.conflict.battle.siege;
|
||||||
|
|
||||||
import com.github.alathra.AlathranWars.AlathranWars;
|
import com.github.alathra.AlathranWars.AlathranWars;
|
||||||
import com.github.alathra.AlathranWars.conflict.war.side.Side;
|
|
||||||
import com.github.alathra.AlathranWars.conflict.war.War;
|
|
||||||
import com.github.alathra.AlathranWars.conflict.battle.Battle;
|
import com.github.alathra.AlathranWars.conflict.battle.Battle;
|
||||||
|
import com.github.alathra.AlathranWars.conflict.war.War;
|
||||||
|
import com.github.alathra.AlathranWars.conflict.war.side.Side;
|
||||||
import com.github.alathra.AlathranWars.db.DatabaseQueries;
|
import com.github.alathra.AlathranWars.db.DatabaseQueries;
|
||||||
import com.github.alathra.AlathranWars.enums.CaptureProgressDirection;
|
import com.github.alathra.AlathranWars.enums.CaptureProgressDirection;
|
||||||
import com.github.alathra.AlathranWars.enums.battle.*;
|
import com.github.alathra.AlathranWars.enums.battle.*;
|
||||||
@@ -25,7 +25,9 @@ import org.jetbrains.annotations.Nullable;
|
|||||||
|
|
||||||
import java.time.Duration;
|
import java.time.Duration;
|
||||||
import java.time.Instant;
|
import java.time.Instant;
|
||||||
import java.util.*;
|
import java.util.HashSet;
|
||||||
|
import java.util.Set;
|
||||||
|
import java.util.UUID;
|
||||||
import java.util.stream.Collectors;
|
import java.util.stream.Collectors;
|
||||||
import java.util.stream.Stream;
|
import java.util.stream.Stream;
|
||||||
|
|
||||||
@@ -164,6 +166,7 @@ public class Siege implements Battle {
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* Stop a battle in favor of the attackers
|
* Stop a battle in favor of the attackers
|
||||||
|
*
|
||||||
* @param reason what triggered the end
|
* @param reason what triggered the end
|
||||||
*/
|
*/
|
||||||
public void attackersWin(BattleVictoryReason reason) {
|
public void attackersWin(BattleVictoryReason reason) {
|
||||||
@@ -191,6 +194,7 @@ public class Siege implements Battle {
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* Stop a battle in favor of the defenders
|
* Stop a battle in favor of the defenders
|
||||||
|
*
|
||||||
* @param reason what triggered the end
|
* @param reason what triggered the end
|
||||||
*/
|
*/
|
||||||
public void defendersWin(BattleVictoryReason reason) {
|
public void defendersWin(BattleVictoryReason reason) {
|
||||||
@@ -206,6 +210,7 @@ public class Siege implements Battle {
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* End a battle in favor of no one
|
* End a battle in favor of no one
|
||||||
|
*
|
||||||
* @param reason what triggered the end
|
* @param reason what triggered the end
|
||||||
*/
|
*/
|
||||||
public void equalWin(BattleVictoryReason reason) {
|
public void equalWin(BattleVictoryReason reason) {
|
||||||
@@ -606,38 +611,38 @@ public class Siege implements Battle {
|
|||||||
.filter(p -> p.isConnected() && !attackers.contains(p))
|
.filter(p -> p.isConnected() && !attackers.contains(p))
|
||||||
.collect(Collectors.toSet())
|
.collect(Collectors.toSet())
|
||||||
.forEach(p -> {
|
.forEach(p -> {
|
||||||
// TODO Player left battlefield
|
// TODO Player left battlefield
|
||||||
|
|
||||||
}
|
}
|
||||||
);
|
);
|
||||||
|
|
||||||
// Entering attackers
|
// Entering attackers
|
||||||
attackers.stream()
|
attackers.stream()
|
||||||
.filter(p -> p.isConnected() && !previousAttackersOnBattlefield.contains(p))
|
.filter(p -> p.isConnected() && !previousAttackersOnBattlefield.contains(p))
|
||||||
.collect(Collectors.toSet())
|
.collect(Collectors.toSet())
|
||||||
.forEach(p -> {
|
.forEach(p -> {
|
||||||
// TODO Player entered battlefield
|
// TODO Player entered battlefield
|
||||||
|
|
||||||
}
|
}
|
||||||
);
|
);
|
||||||
|
|
||||||
// Leaving defenders
|
// Leaving defenders
|
||||||
previousDefendersOnBattlefield.stream()
|
previousDefendersOnBattlefield.stream()
|
||||||
.filter(p -> p.isConnected() && !defenders.contains(p))
|
.filter(p -> p.isConnected() && !defenders.contains(p))
|
||||||
.collect(Collectors.toSet())
|
.collect(Collectors.toSet())
|
||||||
.forEach(p -> {
|
.forEach(p -> {
|
||||||
// TODO Player left battlefield
|
// TODO Player left battlefield
|
||||||
|
|
||||||
}
|
}
|
||||||
);
|
);
|
||||||
|
|
||||||
// Entering defenders
|
// Entering defenders
|
||||||
defenders.stream()
|
defenders.stream()
|
||||||
.filter(p -> p.isConnected() && !previousDefendersOnBattlefield.contains(p))
|
.filter(p -> p.isConnected() && !previousDefendersOnBattlefield.contains(p))
|
||||||
.collect(Collectors.toSet())
|
.collect(Collectors.toSet())
|
||||||
.forEach(p -> {
|
.forEach(p -> {
|
||||||
// TODO Player entered battlefield
|
// TODO Player entered battlefield
|
||||||
}
|
}
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
+1
-1
@@ -3,8 +3,8 @@ package com.github.alathra.AlathranWars.conflict.battle.siege;
|
|||||||
import com.github.alathra.AlathranWars.AlathranWars;
|
import com.github.alathra.AlathranWars.AlathranWars;
|
||||||
import com.github.alathra.AlathranWars.conflict.battle.beam.CrystalLaser;
|
import com.github.alathra.AlathranWars.conflict.battle.beam.CrystalLaser;
|
||||||
import com.github.alathra.AlathranWars.conflict.battle.beam.Laser;
|
import com.github.alathra.AlathranWars.conflict.battle.beam.Laser;
|
||||||
import com.github.alathra.AlathranWars.enums.battle.BattleSide;
|
|
||||||
import com.github.alathra.AlathranWars.enums.CaptureProgressDirection;
|
import com.github.alathra.AlathranWars.enums.CaptureProgressDirection;
|
||||||
|
import com.github.alathra.AlathranWars.enums.battle.BattleSide;
|
||||||
import com.github.alathra.AlathranWars.enums.battle.BattleVictoryReason;
|
import com.github.alathra.AlathranWars.enums.battle.BattleVictoryReason;
|
||||||
import com.github.alathra.AlathranWars.utility.UtilsChat;
|
import com.github.alathra.AlathranWars.utility.UtilsChat;
|
||||||
import com.github.milkdrinkers.colorparser.ColorParser;
|
import com.github.milkdrinkers.colorparser.ColorParser;
|
||||||
|
|||||||
@@ -1,6 +1,7 @@
|
|||||||
package com.github.alathra.AlathranWars.conflict.war;
|
package com.github.alathra.AlathranWars.conflict.war;
|
||||||
|
|
||||||
import com.github.alathra.AlathranWars.conflict.*;
|
import com.github.alathra.AlathranWars.conflict.Conflict;
|
||||||
|
import com.github.alathra.AlathranWars.conflict.Occupation;
|
||||||
import com.github.alathra.AlathranWars.conflict.battle.raid.Raid;
|
import com.github.alathra.AlathranWars.conflict.battle.raid.Raid;
|
||||||
import com.github.alathra.AlathranWars.conflict.battle.siege.Siege;
|
import com.github.alathra.AlathranWars.conflict.battle.siege.Siege;
|
||||||
import com.github.alathra.AlathranWars.conflict.war.side.Side;
|
import com.github.alathra.AlathranWars.conflict.war.side.Side;
|
||||||
|
|||||||
@@ -1,9 +1,9 @@
|
|||||||
package com.github.alathra.AlathranWars.conflict.war;
|
package com.github.alathra.AlathranWars.conflict.war;
|
||||||
|
|
||||||
import com.github.alathra.AlathranWars.conflict.war.side.Side;
|
|
||||||
import com.github.alathra.AlathranWars.conflict.war.side.SideCreationException;
|
|
||||||
import com.github.alathra.AlathranWars.conflict.battle.raid.Raid;
|
import com.github.alathra.AlathranWars.conflict.battle.raid.Raid;
|
||||||
import com.github.alathra.AlathranWars.conflict.battle.siege.Siege;
|
import com.github.alathra.AlathranWars.conflict.battle.siege.Siege;
|
||||||
|
import com.github.alathra.AlathranWars.conflict.war.side.Side;
|
||||||
|
import com.github.alathra.AlathranWars.conflict.war.side.SideCreationException;
|
||||||
import com.github.alathra.AlathranWars.enums.ConflictType;
|
import com.github.alathra.AlathranWars.enums.ConflictType;
|
||||||
import com.palmergames.bukkit.towny.object.Government;
|
import com.palmergames.bukkit.towny.object.Government;
|
||||||
import com.palmergames.bukkit.towny.object.Nation;
|
import com.palmergames.bukkit.towny.object.Nation;
|
||||||
@@ -28,17 +28,18 @@ public class WarBuilder {
|
|||||||
private Government aggressor;
|
private Government aggressor;
|
||||||
private Government victim;
|
private Government victim;
|
||||||
|
|
||||||
public WarBuilder() {}
|
public WarBuilder() {
|
||||||
|
}
|
||||||
|
|
||||||
public War resume() {
|
public War resume() {
|
||||||
if (
|
if (
|
||||||
uuid == null ||
|
uuid == null ||
|
||||||
name == null ||
|
name == null ||
|
||||||
label == null ||
|
label == null ||
|
||||||
side1 == null ||
|
side1 == null ||
|
||||||
side2 == null ||
|
side2 == null ||
|
||||||
sieges == null ||
|
sieges == null ||
|
||||||
raids == null
|
raids == null
|
||||||
) {
|
) {
|
||||||
throw new IllegalStateException();
|
throw new IllegalStateException();
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,8 +1,8 @@
|
|||||||
package com.github.alathra.AlathranWars.conflict.war;
|
package com.github.alathra.AlathranWars.conflict.war;
|
||||||
|
|
||||||
import com.github.alathra.AlathranWars.conflict.war.side.Side;
|
|
||||||
import com.github.alathra.AlathranWars.conflict.battle.raid.Raid;
|
import com.github.alathra.AlathranWars.conflict.battle.raid.Raid;
|
||||||
import com.github.alathra.AlathranWars.conflict.battle.siege.Siege;
|
import com.github.alathra.AlathranWars.conflict.battle.siege.Siege;
|
||||||
|
import com.github.alathra.AlathranWars.conflict.war.side.Side;
|
||||||
import com.github.alathra.AlathranWars.db.DatabaseQueries;
|
import com.github.alathra.AlathranWars.db.DatabaseQueries;
|
||||||
import com.palmergames.bukkit.towny.object.Nation;
|
import com.palmergames.bukkit.towny.object.Nation;
|
||||||
import com.palmergames.bukkit.towny.object.Town;
|
import com.palmergames.bukkit.towny.object.Town;
|
||||||
|
|||||||
@@ -28,7 +28,8 @@ public class SideBuilder {
|
|||||||
private Instant siegeGrace;
|
private Instant siegeGrace;
|
||||||
private Instant raidGrace;
|
private Instant raidGrace;
|
||||||
|
|
||||||
public SideBuilder() {}
|
public SideBuilder() {
|
||||||
|
}
|
||||||
|
|
||||||
public Side rebuild() throws SideCreationException {
|
public Side rebuild() throws SideCreationException {
|
||||||
// if (warUUID == null || uuid == null || town == null || side == null || team == null || name == null ||
|
// if (warUUID == null || uuid == null || town == null || side == null || team == null || name == null ||
|
||||||
@@ -45,8 +46,8 @@ public class SideBuilder {
|
|||||||
if (side == null
|
if (side == null
|
||||||
) throw new IllegalStateException("Missing state to create Side 1.1");
|
) throw new IllegalStateException("Missing state to create Side 1.1");
|
||||||
|
|
||||||
if ( team == null || name == null ||
|
if (team == null || name == null ||
|
||||||
towns == null || nations == null
|
towns == null || nations == null
|
||||||
) throw new IllegalStateException("Missing state to create Side 1");
|
) throw new IllegalStateException("Missing state to create Side 1");
|
||||||
|
|
||||||
if (playersIncludingOffline == null ||
|
if (playersIncludingOffline == null ||
|
||||||
|
|||||||
@@ -30,23 +30,23 @@ public enum DatabaseType {
|
|||||||
* MariaDB database type.
|
* MariaDB database type.
|
||||||
*/
|
*/
|
||||||
MARIADB("MariaDB", org.mariadb.jdbc.Driver.class.getName(), MariaDbDataSource.class.getName(), "mariadb", '?', '&'),
|
MARIADB("MariaDB", org.mariadb.jdbc.Driver.class.getName(), MariaDbDataSource.class.getName(), "mariadb", '?', '&'),
|
||||||
;
|
;
|
||||||
|
|
||||||
private final String driverName;
|
private final String driverName;
|
||||||
private final String driverClassName;
|
private final String driverClassName;
|
||||||
private final String dataSourceClassName;
|
private final String dataSourceClassName;
|
||||||
private final String jdbcPrefix;
|
private final String jdbcPrefix;
|
||||||
private final char jdbcPropertyPrefix;
|
private final char jdbcPropertyPrefix;
|
||||||
private final char jdbcPropertySeparator;
|
private final char jdbcPropertySeparator;
|
||||||
|
|
||||||
DatabaseType(String driverName, String driverClassName, String dataSourceClassName, String jdbcPrefix, char jdbcPropertyPrefix, char jdbcPropertySeparator) {
|
DatabaseType(String driverName, String driverClassName, String dataSourceClassName, String jdbcPrefix, char jdbcPropertyPrefix, char jdbcPropertySeparator) {
|
||||||
this.driverName = driverName;
|
this.driverName = driverName;
|
||||||
this.driverClassName = driverClassName;
|
this.driverClassName = driverClassName;
|
||||||
this.dataSourceClassName = dataSourceClassName;
|
this.dataSourceClassName = dataSourceClassName;
|
||||||
this.jdbcPrefix = jdbcPrefix;
|
this.jdbcPrefix = jdbcPrefix;
|
||||||
this.jdbcPropertyPrefix = jdbcPropertyPrefix;
|
this.jdbcPropertyPrefix = jdbcPropertyPrefix;
|
||||||
this.jdbcPropertySeparator = jdbcPropertySeparator;
|
this.jdbcPropertySeparator = jdbcPropertySeparator;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Gets driver name.
|
* Gets driver name.
|
||||||
@@ -109,14 +109,14 @@ public enum DatabaseType {
|
|||||||
* @return the string
|
* @return the string
|
||||||
*/
|
*/
|
||||||
public String formatJdbcConnectionProperties(Map<String, Object> properties) {
|
public String formatJdbcConnectionProperties(Map<String, Object> properties) {
|
||||||
if (properties.isEmpty()) return "";
|
if (properties.isEmpty()) return "";
|
||||||
|
|
||||||
List<String> connectionProperties = properties.entrySet().stream()
|
List<String> connectionProperties = properties.entrySet().stream()
|
||||||
.map(map -> "%s=%s".formatted(map.getKey(), map.getValue()))
|
.map(map -> "%s=%s".formatted(map.getKey(), map.getValue()))
|
||||||
.toList();
|
.toList();
|
||||||
|
|
||||||
return jdbcPropertyPrefix + String.join(Character.toString(jdbcPropertySeparator), connectionProperties);
|
return jdbcPropertyPrefix + String.join(Character.toString(jdbcPropertySeparator), connectionProperties);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -130,7 +130,8 @@ public enum DatabaseType {
|
|||||||
for (DatabaseType type : DatabaseType.values()) {
|
for (DatabaseType type : DatabaseType.values()) {
|
||||||
if (type.equals(prefix.toLowerCase())) {
|
if (type.equals(prefix.toLowerCase())) {
|
||||||
return type;
|
return type;
|
||||||
};
|
}
|
||||||
|
;
|
||||||
}
|
}
|
||||||
|
|
||||||
return null;
|
return null;
|
||||||
|
|||||||
@@ -14,24 +14,24 @@ import java.util.regex.Pattern;
|
|||||||
* Utility class for getting jOOQ Context to use with HikariCP.
|
* Utility class for getting jOOQ Context to use with HikariCP.
|
||||||
*/
|
*/
|
||||||
public final class JooqContext {
|
public final class JooqContext {
|
||||||
static {
|
static {
|
||||||
JooqLogger.globalThreshold(Log.Level.ERROR); // Silence JOOQ warnings
|
JooqLogger.globalThreshold(Log.Level.ERROR); // Silence JOOQ warnings
|
||||||
}
|
}
|
||||||
|
|
||||||
private static final String TABLE_PREFIX = Cfg.get().getOrDefault("db.prefix", "example_"); // The table prefix as grabbed from config
|
private static final String TABLE_PREFIX = Cfg.get().getOrDefault("db.prefix", "example_"); // The table prefix as grabbed from config
|
||||||
private static final Pattern MATCH_ALL_EXCEPT_INFORMATION_SCHEMA = Pattern.compile("^(?!INFORMATION_SCHEMA)(.*?)$");
|
private static final Pattern MATCH_ALL_EXCEPT_INFORMATION_SCHEMA = Pattern.compile("^(?!INFORMATION_SCHEMA)(.*?)$");
|
||||||
private static final Pattern MATCH_ALL = Pattern.compile("^(.*?)$");
|
private static final Pattern MATCH_ALL = Pattern.compile("^(.*?)$");
|
||||||
private static final String REPLACEMENT = "%s$0".formatted(TABLE_PREFIX); //
|
private static final String REPLACEMENT = "%s$0".formatted(TABLE_PREFIX); //
|
||||||
private final SQLDialect dialect;
|
private final SQLDialect dialect;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Instantiates a new Jooq context.
|
* Instantiates a new Jooq context.
|
||||||
*
|
*
|
||||||
* @param dialect the getSQLDialect
|
* @param dialect the getSQLDialect
|
||||||
*/
|
*/
|
||||||
public JooqContext(SQLDialect dialect) {
|
public JooqContext(SQLDialect dialect) {
|
||||||
this.dialect = dialect;
|
this.dialect = dialect;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Create DSL Context.
|
* Create DSL Context.
|
||||||
@@ -40,53 +40,54 @@ public final class JooqContext {
|
|||||||
* @return the dsl context
|
* @return the dsl context
|
||||||
*/
|
*/
|
||||||
public DSLContext createContext(Connection connection) {
|
public DSLContext createContext(Connection connection) {
|
||||||
record SimpleConnectionProvider(Connection connection) implements ConnectionProvider {
|
record SimpleConnectionProvider(Connection connection) implements ConnectionProvider {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Connection acquire() throws DataAccessException {
|
public Connection acquire() throws DataAccessException {
|
||||||
return connection;
|
return connection;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void release(Connection connection) throws DataAccessException {}
|
public void release(Connection connection) throws DataAccessException {
|
||||||
}
|
}
|
||||||
return createWith(new SimpleConnectionProvider(connection));
|
}
|
||||||
}
|
return createWith(new SimpleConnectionProvider(connection));
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Applies default configuration
|
* Applies default configuration
|
||||||
*
|
*
|
||||||
* @param connectionProvider A connection lifecycle handler API.
|
* @param connectionProvider A connection lifecycle handler API.
|
||||||
* @return DSLContext
|
* @return DSLContext
|
||||||
*/
|
*/
|
||||||
private DSLContext createWith(ConnectionProvider connectionProvider) {
|
private DSLContext createWith(ConnectionProvider connectionProvider) {
|
||||||
return new DefaultConfiguration()
|
return new DefaultConfiguration()
|
||||||
.set(connectionProvider)
|
.set(connectionProvider)
|
||||||
.set(dialect)
|
.set(dialect)
|
||||||
.set(createSettings())
|
.set(createSettings())
|
||||||
.set(new ExecuteListenerProvider[0])
|
.set(new ExecuteListenerProvider[0])
|
||||||
.dsl();
|
.dsl();
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Returns base settings for DSL Contexts.
|
* Returns base settings for DSL Contexts.
|
||||||
*
|
*
|
||||||
* @return Settings
|
* @return Settings
|
||||||
*/
|
*/
|
||||||
private Settings createSettings() {
|
private Settings createSettings() {
|
||||||
return new Settings()
|
return new Settings()
|
||||||
.withBackslashEscaping(BackslashEscaping.OFF)
|
.withBackslashEscaping(BackslashEscaping.OFF)
|
||||||
.withRenderSchema(false)
|
.withRenderSchema(false)
|
||||||
.withRenderMapping(new RenderMapping() // Support the tables having custom prefix
|
.withRenderMapping(new RenderMapping() // Support the tables having custom prefix
|
||||||
.withSchemata(new MappedSchema()
|
.withSchemata(new MappedSchema()
|
||||||
.withInputExpression(MATCH_ALL_EXCEPT_INFORMATION_SCHEMA)
|
.withInputExpression(MATCH_ALL_EXCEPT_INFORMATION_SCHEMA)
|
||||||
.withTables(new MappedTable()
|
.withTables(new MappedTable()
|
||||||
.withInputExpression(MATCH_ALL)
|
.withInputExpression(MATCH_ALL)
|
||||||
.withOutput(REPLACEMENT)
|
.withOutput(REPLACEMENT)
|
||||||
)
|
)
|
||||||
)
|
)
|
||||||
)
|
)
|
||||||
.withRenderQuotedNames(RenderQuotedNames.ALWAYS)
|
.withRenderQuotedNames(RenderQuotedNames.ALWAYS)
|
||||||
.withRenderNameCase(RenderNameCase.LOWER);
|
.withRenderNameCase(RenderNameCase.LOWER);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -1,7 +1,7 @@
|
|||||||
package com.github.alathra.AlathranWars.events.battle;
|
package com.github.alathra.AlathranWars.events.battle;
|
||||||
|
|
||||||
import com.github.alathra.AlathranWars.conflict.war.War;
|
|
||||||
import com.github.alathra.AlathranWars.conflict.battle.Battle;
|
import com.github.alathra.AlathranWars.conflict.battle.Battle;
|
||||||
|
import com.github.alathra.AlathranWars.conflict.war.War;
|
||||||
import com.github.alathra.AlathranWars.enums.battle.BattleVictor;
|
import com.github.alathra.AlathranWars.enums.battle.BattleVictor;
|
||||||
import com.github.alathra.AlathranWars.enums.battle.BattleVictoryReason;
|
import com.github.alathra.AlathranWars.enums.battle.BattleVictoryReason;
|
||||||
import org.bukkit.event.Event;
|
import org.bukkit.event.Event;
|
||||||
|
|||||||
@@ -1,7 +1,7 @@
|
|||||||
package com.github.alathra.AlathranWars.events.battle;
|
package com.github.alathra.AlathranWars.events.battle;
|
||||||
|
|
||||||
import com.github.alathra.AlathranWars.conflict.war.War;
|
|
||||||
import com.github.alathra.AlathranWars.conflict.battle.Battle;
|
import com.github.alathra.AlathranWars.conflict.battle.Battle;
|
||||||
|
import com.github.alathra.AlathranWars.conflict.war.War;
|
||||||
import org.bukkit.event.Event;
|
import org.bukkit.event.Event;
|
||||||
import org.bukkit.event.HandlerList;
|
import org.bukkit.event.HandlerList;
|
||||||
import org.jetbrains.annotations.NotNull;
|
import org.jetbrains.annotations.NotNull;
|
||||||
|
|||||||
+1
-1
@@ -1,7 +1,7 @@
|
|||||||
package com.github.alathra.AlathranWars.events.battle;
|
package com.github.alathra.AlathranWars.events.battle;
|
||||||
|
|
||||||
import com.github.alathra.AlathranWars.conflict.war.War;
|
|
||||||
import com.github.alathra.AlathranWars.conflict.battle.Battle;
|
import com.github.alathra.AlathranWars.conflict.battle.Battle;
|
||||||
|
import com.github.alathra.AlathranWars.conflict.war.War;
|
||||||
import com.github.alathra.AlathranWars.enums.battle.BattleType;
|
import com.github.alathra.AlathranWars.enums.battle.BattleType;
|
||||||
import com.github.alathra.AlathranWars.enums.battle.BattleVictor;
|
import com.github.alathra.AlathranWars.enums.battle.BattleVictor;
|
||||||
import com.github.alathra.AlathranWars.enums.battle.BattleVictoryReason;
|
import com.github.alathra.AlathranWars.enums.battle.BattleVictoryReason;
|
||||||
|
|||||||
+1
-1
@@ -1,7 +1,7 @@
|
|||||||
package com.github.alathra.AlathranWars.events.battle;
|
package com.github.alathra.AlathranWars.events.battle;
|
||||||
|
|
||||||
import com.github.alathra.AlathranWars.conflict.war.War;
|
|
||||||
import com.github.alathra.AlathranWars.conflict.battle.Battle;
|
import com.github.alathra.AlathranWars.conflict.battle.Battle;
|
||||||
|
import com.github.alathra.AlathranWars.conflict.war.War;
|
||||||
import com.github.alathra.AlathranWars.enums.battle.BattleType;
|
import com.github.alathra.AlathranWars.enums.battle.BattleType;
|
||||||
import org.bukkit.event.Cancellable;
|
import org.bukkit.event.Cancellable;
|
||||||
import org.bukkit.event.Event;
|
import org.bukkit.event.Event;
|
||||||
|
|||||||
@@ -1,7 +1,7 @@
|
|||||||
package com.github.alathra.AlathranWars.listeners;
|
package com.github.alathra.AlathranWars.listeners;
|
||||||
|
|
||||||
import com.github.alathra.AlathranWars.conflict.war.WarController;
|
|
||||||
import com.github.alathra.AlathranWars.conflict.battle.siege.Siege;
|
import com.github.alathra.AlathranWars.conflict.battle.siege.Siege;
|
||||||
|
import com.github.alathra.AlathranWars.conflict.war.WarController;
|
||||||
import com.github.alathra.AlathranWars.utility.Utils;
|
import com.github.alathra.AlathranWars.utility.Utils;
|
||||||
import com.github.alathra.AlathranWars.utility.UtilsChat;
|
import com.github.alathra.AlathranWars.utility.UtilsChat;
|
||||||
import com.github.milkdrinkers.colorparser.ColorParser;
|
import com.github.milkdrinkers.colorparser.ColorParser;
|
||||||
|
|||||||
+1
-1
@@ -1,8 +1,8 @@
|
|||||||
package com.github.alathra.AlathranWars.listeners.items;
|
package com.github.alathra.AlathranWars.listeners.items;
|
||||||
|
|
||||||
import com.github.alathra.AlathranWars.AlathranWars;
|
import com.github.alathra.AlathranWars.AlathranWars;
|
||||||
import com.github.alathra.AlathranWars.conflict.war.WarController;
|
|
||||||
import com.github.alathra.AlathranWars.conflict.battle.siege.Siege;
|
import com.github.alathra.AlathranWars.conflict.battle.siege.Siege;
|
||||||
|
import com.github.alathra.AlathranWars.conflict.war.WarController;
|
||||||
import com.github.alathra.AlathranWars.items.WarItemRegistry;
|
import com.github.alathra.AlathranWars.items.WarItemRegistry;
|
||||||
import com.github.alathra.AlathranWars.utility.UtilsChat;
|
import com.github.alathra.AlathranWars.utility.UtilsChat;
|
||||||
import com.github.milkdrinkers.colorparser.ColorParser;
|
import com.github.milkdrinkers.colorparser.ColorParser;
|
||||||
|
|||||||
+1
-1
@@ -1,7 +1,7 @@
|
|||||||
package com.github.alathra.AlathranWars.listeners.siege;
|
package com.github.alathra.AlathranWars.listeners.siege;
|
||||||
|
|
||||||
import com.github.alathra.AlathranWars.conflict.war.WarController;
|
|
||||||
import com.github.alathra.AlathranWars.conflict.battle.siege.Siege;
|
import com.github.alathra.AlathranWars.conflict.battle.siege.Siege;
|
||||||
|
import com.github.alathra.AlathranWars.conflict.war.WarController;
|
||||||
import com.github.alathra.AlathranWars.enums.battle.BattleSide;
|
import com.github.alathra.AlathranWars.enums.battle.BattleSide;
|
||||||
import org.bukkit.entity.Player;
|
import org.bukkit.entity.Player;
|
||||||
import org.bukkit.event.EventHandler;
|
import org.bukkit.event.EventHandler;
|
||||||
|
|||||||
+1
-1
@@ -1,7 +1,7 @@
|
|||||||
package com.github.alathra.AlathranWars.listeners.siege;
|
package com.github.alathra.AlathranWars.listeners.siege;
|
||||||
|
|
||||||
import com.github.alathra.AlathranWars.conflict.war.WarController;
|
|
||||||
import com.github.alathra.AlathranWars.conflict.battle.siege.Siege;
|
import com.github.alathra.AlathranWars.conflict.battle.siege.Siege;
|
||||||
|
import com.github.alathra.AlathranWars.conflict.war.WarController;
|
||||||
import com.github.alathra.AlathranWars.enums.battle.BattleSide;
|
import com.github.alathra.AlathranWars.enums.battle.BattleSide;
|
||||||
import org.bukkit.entity.Player;
|
import org.bukkit.entity.Player;
|
||||||
import org.bukkit.event.EventHandler;
|
import org.bukkit.event.EventHandler;
|
||||||
|
|||||||
@@ -1,8 +1,8 @@
|
|||||||
package com.github.alathra.AlathranWars.listeners.siege;
|
package com.github.alathra.AlathranWars.listeners.siege;
|
||||||
|
|
||||||
import com.github.alathra.AlathranWars.conflict.war.side.Side;
|
|
||||||
import com.github.alathra.AlathranWars.conflict.war.War;
|
|
||||||
import com.github.alathra.AlathranWars.conflict.battle.siege.Siege;
|
import com.github.alathra.AlathranWars.conflict.battle.siege.Siege;
|
||||||
|
import com.github.alathra.AlathranWars.conflict.war.War;
|
||||||
|
import com.github.alathra.AlathranWars.conflict.war.side.Side;
|
||||||
import com.github.alathra.AlathranWars.enums.battle.BattleType;
|
import com.github.alathra.AlathranWars.enums.battle.BattleType;
|
||||||
import com.github.alathra.AlathranWars.enums.battle.BattleVictoryReason;
|
import com.github.alathra.AlathranWars.enums.battle.BattleVictoryReason;
|
||||||
import com.github.alathra.AlathranWars.events.battle.BattleResultEvent;
|
import com.github.alathra.AlathranWars.events.battle.BattleResultEvent;
|
||||||
|
|||||||
@@ -1,8 +1,8 @@
|
|||||||
package com.github.alathra.AlathranWars.listeners.war;
|
package com.github.alathra.AlathranWars.listeners.war;
|
||||||
|
|
||||||
import com.github.alathra.AlathranWars.conflict.war.side.Side;
|
|
||||||
import com.github.alathra.AlathranWars.conflict.war.War;
|
import com.github.alathra.AlathranWars.conflict.war.War;
|
||||||
import com.github.alathra.AlathranWars.conflict.war.WarController;
|
import com.github.alathra.AlathranWars.conflict.war.WarController;
|
||||||
|
import com.github.alathra.AlathranWars.conflict.war.side.Side;
|
||||||
import com.github.alathra.AlathranWars.hooks.NameColorHandler;
|
import com.github.alathra.AlathranWars.hooks.NameColorHandler;
|
||||||
import com.palmergames.bukkit.towny.event.NationAddTownEvent;
|
import com.palmergames.bukkit.towny.event.NationAddTownEvent;
|
||||||
import com.palmergames.bukkit.towny.event.NationPreRenameEvent;
|
import com.palmergames.bukkit.towny.event.NationPreRenameEvent;
|
||||||
|
|||||||
@@ -1,8 +1,8 @@
|
|||||||
package com.github.alathra.AlathranWars.listeners.war;
|
package com.github.alathra.AlathranWars.listeners.war;
|
||||||
|
|
||||||
import com.github.alathra.AlathranWars.conflict.war.side.Side;
|
|
||||||
import com.github.alathra.AlathranWars.conflict.war.War;
|
import com.github.alathra.AlathranWars.conflict.war.War;
|
||||||
import com.github.alathra.AlathranWars.conflict.war.WarController;
|
import com.github.alathra.AlathranWars.conflict.war.WarController;
|
||||||
|
import com.github.alathra.AlathranWars.conflict.war.side.Side;
|
||||||
import com.github.alathra.AlathranWars.hooks.NameColorHandler;
|
import com.github.alathra.AlathranWars.hooks.NameColorHandler;
|
||||||
import org.bukkit.entity.Player;
|
import org.bukkit.entity.Player;
|
||||||
import org.bukkit.event.EventHandler;
|
import org.bukkit.event.EventHandler;
|
||||||
|
|||||||
@@ -1,8 +1,8 @@
|
|||||||
package com.github.alathra.AlathranWars.listeners.war;
|
package com.github.alathra.AlathranWars.listeners.war;
|
||||||
|
|
||||||
import com.github.alathra.AlathranWars.conflict.war.side.Side;
|
|
||||||
import com.github.alathra.AlathranWars.conflict.war.War;
|
import com.github.alathra.AlathranWars.conflict.war.War;
|
||||||
import com.github.alathra.AlathranWars.conflict.war.WarController;
|
import com.github.alathra.AlathranWars.conflict.war.WarController;
|
||||||
|
import com.github.alathra.AlathranWars.conflict.war.side.Side;
|
||||||
import com.github.alathra.AlathranWars.hooks.NameColorHandler;
|
import com.github.alathra.AlathranWars.hooks.NameColorHandler;
|
||||||
import org.bukkit.entity.Player;
|
import org.bukkit.entity.Player;
|
||||||
import org.bukkit.event.EventHandler;
|
import org.bukkit.event.EventHandler;
|
||||||
|
|||||||
@@ -1,8 +1,8 @@
|
|||||||
package com.github.alathra.AlathranWars.listeners.war;
|
package com.github.alathra.AlathranWars.listeners.war;
|
||||||
|
|
||||||
import com.github.alathra.AlathranWars.conflict.war.side.Side;
|
|
||||||
import com.github.alathra.AlathranWars.conflict.war.War;
|
import com.github.alathra.AlathranWars.conflict.war.War;
|
||||||
import com.github.alathra.AlathranWars.conflict.war.WarController;
|
import com.github.alathra.AlathranWars.conflict.war.WarController;
|
||||||
|
import com.github.alathra.AlathranWars.conflict.war.side.Side;
|
||||||
import com.github.alathra.AlathranWars.hooks.NameColorHandler;
|
import com.github.alathra.AlathranWars.hooks.NameColorHandler;
|
||||||
import com.github.milkdrinkers.colorparser.ColorParser;
|
import com.github.milkdrinkers.colorparser.ColorParser;
|
||||||
import com.palmergames.bukkit.towny.event.TownAddResidentEvent;
|
import com.palmergames.bukkit.towny.event.TownAddResidentEvent;
|
||||||
|
|||||||
@@ -1,7 +1,7 @@
|
|||||||
package com.github.alathra.AlathranWars.utility;
|
package com.github.alathra.AlathranWars.utility;
|
||||||
|
|
||||||
import com.github.alathra.AlathranWars.conflict.war.WarController;
|
|
||||||
import com.github.alathra.AlathranWars.conflict.battle.siege.Siege;
|
import com.github.alathra.AlathranWars.conflict.battle.siege.Siege;
|
||||||
|
import com.github.alathra.AlathranWars.conflict.war.WarController;
|
||||||
import com.palmergames.bukkit.towny.object.WorldCoord;
|
import com.palmergames.bukkit.towny.object.WorldCoord;
|
||||||
import org.bukkit.Location;
|
import org.bukkit.Location;
|
||||||
import org.bukkit.Material;
|
import org.bukkit.Material;
|
||||||
|
|||||||
Reference in new issue
Block a user