Compare commits
50
Commits
test
...
renovate/all
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
f077d55a9f | ||
|
|
e732bdf842 | ||
|
|
6b6329c4a6 | ||
|
|
7a6707b20e | ||
|
|
7a10e268bb | ||
|
|
adce4729f0 | ||
|
|
8560f17bac | ||
|
|
d2d7a4f02c | ||
|
|
cf33b23720 | ||
|
|
e261e06635 | ||
|
|
2856ababff | ||
|
|
f061e1738e | ||
|
|
4118983479 | ||
|
|
988859ddbe | ||
|
|
305ab9e299 | ||
|
|
5aaf8a4f08 | ||
|
|
153657c554 | ||
|
|
5123176cb3 | ||
|
|
1665f39151 | ||
|
|
94113ea326 | ||
|
|
7f581dbaac | ||
|
|
2dd25cc27e | ||
|
|
3ca562f515 | ||
|
|
383c405198 | ||
|
|
c522f7c078 | ||
|
|
fb6efa0646 | ||
|
|
ad7899f10e | ||
|
|
ab5e6a7cf3 | ||
|
|
42ae17bf8d | ||
|
|
20d342d0ca | ||
|
|
c4adeb1aed | ||
|
|
d2d0c5b608 | ||
|
|
eb1febab85 | ||
|
|
8153ba55ab | ||
|
|
89784f3412 | ||
|
|
49e82385d4 | ||
|
|
190034f5aa | ||
|
|
1db744c4ec | ||
|
|
94d7baf791 | ||
|
|
c25af3f6d3 | ||
|
|
3b38c82b47 | ||
|
|
526f831fcb | ||
|
|
e4151cbbe0 | ||
|
|
47d9fed823 | ||
|
|
0890b2abbd | ||
|
|
be99a8646d | ||
|
|
b58266c868 | ||
|
|
eaa02a4166 | ||
|
|
08e99ded13 | ||
|
|
e867e7e697 |
No files matched your search
@@ -16,14 +16,14 @@ jobs:
|
||||
|
||||
steps:
|
||||
- name: Checkout
|
||||
uses: actions/checkout@v3
|
||||
uses: actions/checkout@v4
|
||||
- name: Set up JDK 17
|
||||
uses: actions/setup-java@v3
|
||||
uses: actions/setup-java@v4
|
||||
with:
|
||||
java-version: '17'
|
||||
distribution: 'temurin'
|
||||
- name: Cache Gradle
|
||||
uses: actions/cache@v3.3.1
|
||||
uses: actions/cache@v4.0.2
|
||||
with:
|
||||
path: ~/.gradle/caches
|
||||
key: >-
|
||||
@@ -33,11 +33,11 @@ jobs:
|
||||
- name: Make gradlew executable
|
||||
run: chmod +x gradlew
|
||||
- name: Build with Gradle
|
||||
uses: gradle/gradle-build-action@e3426b1f20c7262e0fed7b855aae1325633af3b4
|
||||
uses: gradle/gradle-build-action@66535aaf56f831b35e3a8481c9c99b665b84dd45
|
||||
with:
|
||||
arguments: shadowJar
|
||||
- name: Upload a Build Artifact
|
||||
uses: actions/upload-artifact@v3.1.2
|
||||
uses: actions/upload-artifact@v4.3.3
|
||||
with:
|
||||
name: 'Successfully build EternalCombat'
|
||||
path: build/libs/*.jar
|
||||
path: eternalcombat-plugin/build/libs/*.jar
|
||||
@@ -12,7 +12,7 @@ jobs:
|
||||
uses: actions/checkout@v4
|
||||
|
||||
- name: Set up JDK
|
||||
uses: actions/setup-java@v3
|
||||
uses: actions/setup-java@v4
|
||||
with:
|
||||
distribution: 'temurin'
|
||||
java-version: 17
|
||||
|
||||
@@ -15,7 +15,7 @@
|
||||
|
||||
### Information
|
||||
|
||||
EternalCombat has been tested on Minecraft versions 1.17.1 to 1.20.1, but it should work on most other versions. If you
|
||||
EternalCombat has been tested on Minecraft versions 1.17.1 to 1.20.6, but it should work on most other versions. If you
|
||||
encounter any compatibility issues, please report them in the
|
||||
[Issues tab](https://github.com/EternalCodeTeam/EternalCombat/issues). The plugin requires Java 17 or later, so please
|
||||
make sure it is installed on your server.
|
||||
@@ -35,6 +35,43 @@ Build EternalCombat using:
|
||||
- `eternalcombat.receiveupdates` - Allows you to receive notifications about the new version of the plugin when
|
||||
attaching
|
||||
|
||||
### Developer API
|
||||
|
||||
#### 1. Add repository:
|
||||
|
||||
with Gradle:
|
||||
```kts
|
||||
maven {
|
||||
url = uri("https://repo.eternalcode.pl/releases")
|
||||
}
|
||||
```
|
||||
|
||||
with Maven:
|
||||
```xml
|
||||
<repository>
|
||||
<id>eternalcode-reposilite-releases</id>
|
||||
<name>EternalCode Repository</name>
|
||||
<url>https://repo.eternalcode.pl/releases</url>
|
||||
</repository>
|
||||
```
|
||||
|
||||
#### 2. Add dependency:
|
||||
|
||||
with Gradle:
|
||||
```kts
|
||||
compileOnly("com.eternalcode:eternalcombat-api:1.2.2")
|
||||
```
|
||||
|
||||
with Maven:
|
||||
```xml
|
||||
<dependency>
|
||||
<groupId>com.eternalcode</groupId>
|
||||
<artifactId>eternalcombat-api</artifactId>
|
||||
<version>1.2.2</version>
|
||||
<scope>provided</scope>
|
||||
</dependency>
|
||||
```
|
||||
|
||||
### Contributing
|
||||
|
||||
We welcome all contributions to the EternalCombat project! Please check out [contributing](.github/CONTRIBUTING.md) for
|
||||
|
||||
Binary file not shown.
|
Before Width: | Height: | Size: 60 KiB After Width: | Height: | Size: 86 KiB |
@@ -0,0 +1,29 @@
|
||||
plugins {
|
||||
`kotlin-dsl`
|
||||
}
|
||||
|
||||
repositories {
|
||||
mavenCentral()
|
||||
gradlePluginPortal()
|
||||
}
|
||||
|
||||
dependencies {
|
||||
implementation("org.jetbrains.kotlin:kotlin-stdlib-jdk8:1.9.24")
|
||||
implementation("com.github.johnrengelman:shadow:8.1.1")
|
||||
implementation("net.minecrell:plugin-yml:0.6.0")
|
||||
implementation("xyz.jpenilla:run-task:2.3.0")
|
||||
}
|
||||
|
||||
sourceSets {
|
||||
main {
|
||||
java.setSrcDirs(emptyList<String>())
|
||||
groovy.setSrcDirs(emptyList<String>())
|
||||
resources.setSrcDirs(emptyList<String>())
|
||||
}
|
||||
test {
|
||||
java.setSrcDirs(emptyList<String>())
|
||||
kotlin.setSrcDirs(emptyList<String>())
|
||||
groovy.setSrcDirs(emptyList<String>())
|
||||
resources.setSrcDirs(emptyList<String>())
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,34 @@
|
||||
object Versions {
|
||||
|
||||
const val SPIGOT_API = "1.17.1-R0.1-SNAPSHOT"
|
||||
|
||||
const val JUNIT_JUPITER_API = "5.10.2"
|
||||
const val JUNIT_JUPITER_PARAMS = "5.10.2"
|
||||
const val JUNIT_JUPITER_ENGINE = "5.10.2"
|
||||
|
||||
const val ETERNALCODE_COMMONS = "1.1.3"
|
||||
// TODO: Multification.
|
||||
|
||||
const val ADVENTURE_PLATFORM_BUKKIT = "4.3.3"
|
||||
const val ADVENTURE_TEXT_MINIMESSAGE = "4.17.0"
|
||||
|
||||
const val LITE_COMMANDS = "2.8.9"
|
||||
const val OKAERI_CONFIGS_YAML_BUKKIT = "5.0.2"
|
||||
const val OKAERI_CONFIGS_SERDES_COMMONS = "5.0.2"
|
||||
const val OKAERI_CONFIGS_SERDES_BUKKIT = "5.0.2"
|
||||
|
||||
const val PANDA_UTILITIES = "0.5.2-alpha"
|
||||
const val GIT_CHECK = "1.0.0"
|
||||
const val APACHE_COMMONS = "2.16.1"
|
||||
|
||||
const val CAFFEINE = "3.1.8"
|
||||
|
||||
const val B_STATS_BUKKIT = "3.0.2"
|
||||
const val WORLD_GUARD_BUKKIT = "7.0.10"
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
@@ -0,0 +1,19 @@
|
||||
plugins {
|
||||
`java-library`
|
||||
}
|
||||
|
||||
dependencies {
|
||||
testImplementation("org.spigotmc:spigot-api:${Versions.SPIGOT_API}")
|
||||
testImplementation("org.junit.jupiter:junit-jupiter-api:${Versions.JUNIT_JUPITER_API}")
|
||||
testImplementation("org.junit.jupiter:junit-jupiter-params:${Versions.JUNIT_JUPITER_PARAMS}")
|
||||
testRuntimeOnly("org.junit.jupiter:junit-jupiter-engine:${Versions.JUNIT_JUPITER_ENGINE}")
|
||||
}
|
||||
|
||||
tasks.test {
|
||||
useJUnitPlatform()
|
||||
}
|
||||
|
||||
sourceSets.test {
|
||||
java.setSrcDirs(listOf("test"))
|
||||
resources.setSrcDirs(emptyList<String>())
|
||||
}
|
||||
@@ -0,0 +1,36 @@
|
||||
plugins {
|
||||
`java-library`
|
||||
checkstyle
|
||||
}
|
||||
|
||||
group = "com.eternalcode"
|
||||
version = "1.2.2"
|
||||
|
||||
java {
|
||||
sourceCompatibility = JavaVersion.VERSION_17
|
||||
targetCompatibility = JavaVersion.VERSION_17
|
||||
}
|
||||
|
||||
checkstyle {
|
||||
toolVersion = "10.17.0"
|
||||
|
||||
configFile = file("${rootDir}/config/checkstyle/checkstyle.xml")
|
||||
|
||||
maxErrors = 0
|
||||
maxWarnings = 0
|
||||
}
|
||||
|
||||
// https://github.com/JabRef/jabref/pull/10812/files#diff-49a96e7eea8a94af862798a45174e6ac43eb4f8b4bd40759b5da63ba31ec3ef7R267
|
||||
configurations.named("checkstyle") {
|
||||
resolutionStrategy {
|
||||
capabilitiesResolution {
|
||||
withCapability("com.google.collections:google-collections") {
|
||||
select("com.google.guava:guava:33.2.1-jre")
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
tasks.compileJava {
|
||||
options.encoding = "UTF-8"
|
||||
}
|
||||
@@ -0,0 +1,34 @@
|
||||
plugins {
|
||||
`java-library`
|
||||
`maven-publish`
|
||||
}
|
||||
|
||||
group = "com.eternalcode"
|
||||
version = "1.2.2"
|
||||
|
||||
java {
|
||||
withSourcesJar()
|
||||
withJavadocJar()
|
||||
}
|
||||
|
||||
publishing {
|
||||
publications {
|
||||
create<MavenPublication>("maven") {
|
||||
artifactId = "eternalcombat-api"
|
||||
from(project.components["java"])
|
||||
}
|
||||
}
|
||||
|
||||
repositories {
|
||||
mavenLocal()
|
||||
maven {
|
||||
name = "eternalcodeReleases"
|
||||
url = uri("https://repo.eternalcode.pl/releases")
|
||||
credentials {
|
||||
username = System.getenv("ETERNAL_CODE_MAVEN_USERNAME")
|
||||
password = System.getenv("ETERNAL_CODE_MAVEN_PASSWORD")
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,14 @@
|
||||
plugins {
|
||||
`java-library`
|
||||
}
|
||||
|
||||
repositories {
|
||||
mavenCentral()
|
||||
|
||||
maven { url = uri("https://hub.spigotmc.org/nexus/content/repositories/snapshots/") }
|
||||
maven { url = uri("https://papermc.io/repo/repository/maven-public/") }
|
||||
maven { url = uri("https://repo.eternalcode.pl/releases") }
|
||||
maven { url = uri("https://storehouse.okaeri.eu/repository/maven-public/") }
|
||||
maven { url = uri("https://repo.panda-lang.org/releases") }
|
||||
maven { url = uri("https://maven.enginehub.org/repo/") }
|
||||
}
|
||||
@@ -1,109 +1,45 @@
|
||||
plugins {
|
||||
`java-library`
|
||||
checkstyle
|
||||
|
||||
id("maven-publish")
|
||||
}
|
||||
|
||||
group = "com.eternalcode"
|
||||
version = "1.1.1"
|
||||
|
||||
checkstyle {
|
||||
toolVersion = "10.12.2"
|
||||
|
||||
configFile = file("${rootDir}/config/checkstyle/checkstyle.xml")
|
||||
|
||||
maxErrors = 0
|
||||
maxWarnings = 0
|
||||
}
|
||||
|
||||
repositories {
|
||||
mavenCentral()
|
||||
|
||||
maven { url = uri("https://hub.spigotmc.org/nexus/content/repositories/snapshots/") }
|
||||
maven { url = uri("https://papermc.io/repo/repository/maven-public/") }
|
||||
maven { url = uri("https://repo.eternalcode.pl/releases") }
|
||||
maven { url = uri("https://storehouse.okaeri.eu/repository/maven-public/") }
|
||||
maven { url = uri("https://repo.panda-lang.org/releases") }
|
||||
maven { url = uri("https://maven.enginehub.org/repo/") }
|
||||
`eternalcombat-java`
|
||||
`eternalcombat-repositories`
|
||||
`eternalcombat-publish`
|
||||
`eternalcombat-java-unit-test`
|
||||
}
|
||||
|
||||
dependencies {
|
||||
// Spigot api
|
||||
compileOnlyApi("org.spigotmc:spigot-api:1.19.3-R0.1-SNAPSHOT")
|
||||
compileOnlyApi("org.spigotmc:spigot-api:${Versions.SPIGOT_API}")
|
||||
|
||||
// kyori
|
||||
api("net.kyori:adventure-platform-bukkit:4.3.0")
|
||||
api("net.kyori:adventure-text-minimessage:4.14.0")
|
||||
api("net.kyori:adventure-platform-bukkit:${Versions.ADVENTURE_PLATFORM_BUKKIT}")
|
||||
api("net.kyori:adventure-text-minimessage:${Versions.ADVENTURE_TEXT_MINIMESSAGE}")
|
||||
|
||||
// litecommands
|
||||
api("dev.rollczi.litecommands:bukkit-adventure:2.8.9")
|
||||
api("dev.rollczi.litecommands:bukkit-adventure:${Versions.LITE_COMMANDS}")
|
||||
|
||||
// Okaeri configs
|
||||
api("eu.okaeri:okaeri-configs-yaml-bukkit:5.0.0-beta.5")
|
||||
api("eu.okaeri:okaeri-configs-serdes-commons:5.0.0-beta.5")
|
||||
api("eu.okaeri:okaeri-configs-serdes-bukkit:5.0.0-beta.5")
|
||||
api("eu.okaeri:okaeri-configs-yaml-bukkit:${Versions.OKAERI_CONFIGS_YAML_BUKKIT}")
|
||||
api("eu.okaeri:okaeri-configs-serdes-commons:${Versions.OKAERI_CONFIGS_SERDES_COMMONS}")
|
||||
api("eu.okaeri:okaeri-configs-serdes-bukkit:${Versions.OKAERI_CONFIGS_SERDES_BUKKIT}")
|
||||
|
||||
// Panda utilities
|
||||
api("org.panda-lang:panda-utilities:0.5.2-alpha")
|
||||
api("org.panda-lang:panda-utilities:${Versions.PANDA_UTILITIES}")
|
||||
|
||||
// GitCheck
|
||||
api("com.eternalcode:gitcheck:1.0.0")
|
||||
api("com.eternalcode:gitcheck:${Versions.GIT_CHECK}")
|
||||
|
||||
// commons
|
||||
api("commons-io:commons-io:2.13.0")
|
||||
api("commons-io:commons-io:${Versions.APACHE_COMMONS}")
|
||||
|
||||
// bstats
|
||||
api("org.bstats:bstats-bukkit:3.0.2")
|
||||
api("org.bstats:bstats-bukkit:${Versions.B_STATS_BUKKIT}")
|
||||
|
||||
// caffeine
|
||||
api("com.github.ben-manes.caffeine:caffeine:${Versions.CAFFEINE}")
|
||||
|
||||
api("com.eternalcode:eternalcode-commons-bukkit:${Versions.ETERNALCODE_COMMONS}")
|
||||
api("com.eternalcode:eternalcode-commons-adventure:${Versions.ETERNALCODE_COMMONS}")
|
||||
|
||||
// worldguard
|
||||
compileOnly("com.sk89q.worldguard:worldguard-bukkit:7.0.9")
|
||||
compileOnly("com.sk89q.worldguard:worldguard-bukkit:${Versions.WORLD_GUARD_BUKKIT}")
|
||||
|
||||
// tests
|
||||
testImplementation("org.spigotmc:spigot-api:1.19.3-R0.1-SNAPSHOT")
|
||||
testImplementation("org.junit.jupiter:junit-jupiter-api:5.10.0")
|
||||
testImplementation("org.junit.jupiter:junit-jupiter-params:5.10.0")
|
||||
testRuntimeOnly("org.junit.jupiter:junit-jupiter-engine:5.10.0")
|
||||
}
|
||||
|
||||
java {
|
||||
sourceCompatibility = JavaVersion.VERSION_17
|
||||
targetCompatibility = JavaVersion.VERSION_17
|
||||
}
|
||||
|
||||
tasks.getByName<Test>("test") {
|
||||
useJUnitPlatform()
|
||||
}
|
||||
|
||||
// Publish
|
||||
|
||||
java {
|
||||
withSourcesJar()
|
||||
withJavadocJar()
|
||||
}
|
||||
|
||||
publishing {
|
||||
publications {
|
||||
create<MavenPublication>("maven") {
|
||||
artifactId = "eternalcombat-api"
|
||||
from(project.components["java"])
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
publishing {
|
||||
repositories {
|
||||
mavenLocal()
|
||||
|
||||
maven {
|
||||
name = "eternalcodeReleases"
|
||||
url = uri("https://repo.eternalcode.pl/releases")
|
||||
|
||||
credentials {
|
||||
username = System.getenv("ETERNAL_CODE_MAVEN_USERNAME")
|
||||
password = System.getenv("ETERNAL_CODE_MAVEN_PASSWORD")
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
-119
@@ -1,119 +0,0 @@
|
||||
package com.eternalcode.combat.config;
|
||||
|
||||
import org.apache.commons.io.FileUtils;
|
||||
|
||||
import java.io.File;
|
||||
import java.io.IOException;
|
||||
import java.nio.file.Files;
|
||||
import java.nio.file.StandardCopyOption;
|
||||
import java.time.LocalDate;
|
||||
import java.time.LocalDateTime;
|
||||
import java.time.LocalTime;
|
||||
import java.time.format.DateTimeFormatter;
|
||||
import java.time.format.DateTimeParseException;
|
||||
import java.time.temporal.ChronoUnit;
|
||||
|
||||
public class ConfigBackupService {
|
||||
|
||||
private static final String BACKUP_FOLDER_NAME = "backup";
|
||||
private static final String BACKUP_FILE_EXTENSION = ".bak";
|
||||
private final File dataFolder;
|
||||
|
||||
public ConfigBackupService(File dataFolder) {
|
||||
this.dataFolder = dataFolder;
|
||||
}
|
||||
|
||||
public void createBackup() {
|
||||
File backupFolder = new File(this.dataFolder, BACKUP_FOLDER_NAME);
|
||||
|
||||
if (!backupFolder.exists()) {
|
||||
backupFolder.mkdirs();
|
||||
}
|
||||
|
||||
LocalDateTime currentDateTime = LocalDateTime.now();
|
||||
String backupFolderName = BACKUP_FOLDER_NAME + "_" + currentDateTime.format(DateTimeFormatter.ofPattern("yyyy-MM-dd_HH-mm"));
|
||||
File currentBackupFolder = new File(backupFolder, backupFolderName);
|
||||
if (!currentBackupFolder.exists()) {
|
||||
currentBackupFolder.mkdirs();
|
||||
}
|
||||
|
||||
this.copyFolderContents(this.dataFolder, currentBackupFolder);
|
||||
this.deleteIfOlderDirectory(backupFolder);
|
||||
}
|
||||
|
||||
private void copyFolderContents(File sourceFolder, File targetFolder) {
|
||||
if (!sourceFolder.exists() || !sourceFolder.isDirectory()) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (!targetFolder.exists()) {
|
||||
boolean targetFolderCreated = targetFolder.mkdirs();
|
||||
|
||||
if (!targetFolderCreated) {
|
||||
return;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
File[] filesToBackup = sourceFolder.listFiles();
|
||||
if (filesToBackup == null) {
|
||||
return;
|
||||
}
|
||||
|
||||
for (File file : filesToBackup) {
|
||||
if (file.isDirectory() && !file.getName().equals(BACKUP_FOLDER_NAME)) {
|
||||
File subFolder = new File(targetFolder, file.getName());
|
||||
this.copyFolderContents(file, subFolder);
|
||||
|
||||
continue;
|
||||
}
|
||||
|
||||
if (file.isFile() && !file.getName().endsWith(BACKUP_FILE_EXTENSION)) {
|
||||
File backupFile = new File(targetFolder, file.getName() + BACKUP_FILE_EXTENSION);
|
||||
|
||||
this.copyToBackupFile(file, backupFile);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private void copyToBackupFile(File targetFolder, File path) {
|
||||
try {
|
||||
Files.copy(targetFolder.toPath(), path.toPath(), StandardCopyOption.REPLACE_EXISTING);
|
||||
}
|
||||
catch (IOException exception) {
|
||||
exception.printStackTrace();
|
||||
}
|
||||
}
|
||||
|
||||
// delete backup folders older than X days
|
||||
private void deleteIfOlderDirectory(File backupFolder) {
|
||||
File[] backupFolders = backupFolder.listFiles(File::isDirectory);
|
||||
|
||||
if (backupFolders == null) {
|
||||
return;
|
||||
}
|
||||
|
||||
for (File folder : backupFolders) {
|
||||
String folderName = folder.getName();
|
||||
if (!folderName.startsWith(BACKUP_FOLDER_NAME)) {
|
||||
continue;
|
||||
}
|
||||
|
||||
try {
|
||||
LocalDate folderDate = LocalDate.parse(folderName.substring(BACKUP_FOLDER_NAME.length() + 1, folderName.lastIndexOf("_")));
|
||||
LocalTime folderTime = LocalTime.parse(folderName.substring(folderName.lastIndexOf("_") + 1).replace("-", ":"));
|
||||
LocalDateTime folderDateTime = LocalDateTime.of(folderDate, folderTime);
|
||||
LocalDateTime currentDateTime = LocalDateTime.now();
|
||||
|
||||
long hours = ChronoUnit.HOURS.between(folderDateTime, currentDateTime);
|
||||
|
||||
if (hours > 72) {
|
||||
FileUtils.deleteDirectory(folder);
|
||||
}
|
||||
}
|
||||
catch (DateTimeParseException | IOException exception) {
|
||||
exception.printStackTrace();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -13,17 +13,9 @@ import java.util.Set;
|
||||
|
||||
public class ConfigService {
|
||||
|
||||
private final ConfigBackupService backupService;
|
||||
|
||||
private final Set<OkaeriConfig> configs = new HashSet<>();
|
||||
|
||||
public ConfigService(ConfigBackupService backupService) {
|
||||
this.backupService = backupService;
|
||||
}
|
||||
|
||||
public <T extends OkaeriConfig> T create(Class<T> config, File file) {
|
||||
this.backupService.createBackup();
|
||||
|
||||
T configFile = ConfigManager.create(config);
|
||||
|
||||
configFile.withConfigurer(new YamlBukkitConfigurer(), new SerdesCommons(), new SerdesBukkit());
|
||||
|
||||
+6
@@ -55,6 +55,9 @@ public class PluginConfig extends OkaeriConfig {
|
||||
@Comment("# Release attacker after victim dies?")
|
||||
public boolean shouldReleaseAttacker = true;
|
||||
|
||||
@Comment("# If you want to exclude admins from combat, set this to true")
|
||||
public boolean excludeAdminFromCombat = false;
|
||||
|
||||
@Comment("# Command blocking mode, available modes: WHITELIST, BLACKLIST")
|
||||
public WhitelistBlacklistMode commandBlockingMode = WhitelistBlacklistMode.BLACKLIST;
|
||||
|
||||
@@ -72,6 +75,9 @@ public class PluginConfig extends OkaeriConfig {
|
||||
@Comment("# Block the use of elytra?")
|
||||
public boolean shouldPreventElytraUsage = true;
|
||||
|
||||
@Comment("# Block flying? (flying players will fall to the ground)")
|
||||
public boolean shouldPreventFlying = true;
|
||||
|
||||
@Comment("# Disable the use of elytra on damage?")
|
||||
public boolean shouldElytraDisableOnDamage = true;
|
||||
|
||||
|
||||
@@ -1,7 +1,5 @@
|
||||
package com.eternalcode.combat.drop;
|
||||
|
||||
import com.eternalcode.combat.fight.FightDeathCause;
|
||||
import com.eternalcode.combat.fight.FightTag;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.inventory.ItemStack;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
@@ -15,18 +13,13 @@ public class Drop {
|
||||
|
||||
private final Player player;
|
||||
private final Player killer;
|
||||
private final FightTag fightTag;
|
||||
private final FightDeathCause deathCause;
|
||||
|
||||
private final List<ItemStack> droppedItems;
|
||||
private final int droppedExp;
|
||||
|
||||
private Drop(Player player, Player killer, FightTag fightTag, FightDeathCause deathCause, List<ItemStack> droppedItems, int droppedExp) {
|
||||
private Drop(Player player, Player killer, List<ItemStack> droppedItems, int droppedExp) {
|
||||
this.player = player;
|
||||
this.killer = killer;
|
||||
this.fightTag = fightTag;
|
||||
this.deathCause = deathCause;
|
||||
|
||||
this.droppedItems = droppedItems;
|
||||
this.droppedExp = droppedExp;
|
||||
}
|
||||
@@ -43,14 +36,6 @@ public class Drop {
|
||||
return this.killer;
|
||||
}
|
||||
|
||||
public FightTag getFightTag() {
|
||||
return this.fightTag;
|
||||
}
|
||||
|
||||
public FightDeathCause getDeathCause() {
|
||||
return this.deathCause;
|
||||
}
|
||||
|
||||
public boolean hasKiller() {
|
||||
return this.killer != null;
|
||||
}
|
||||
@@ -67,8 +52,6 @@ public class Drop {
|
||||
|
||||
private Player player;
|
||||
private Player killer;
|
||||
private FightTag fightTag;
|
||||
private FightDeathCause deathCause;
|
||||
private List<ItemStack> droppedItems;
|
||||
private int droppedExp;
|
||||
|
||||
@@ -82,16 +65,6 @@ public class Drop {
|
||||
return this;
|
||||
}
|
||||
|
||||
public Builder fightTag(@NotNull FightTag fightTag) {
|
||||
this.fightTag = fightTag;
|
||||
return this;
|
||||
}
|
||||
|
||||
public Builder deathCause(@NotNull FightDeathCause deathCause) {
|
||||
this.deathCause = deathCause;
|
||||
return this;
|
||||
}
|
||||
|
||||
public Builder droppedItems(@NotNull List<ItemStack> droppedItems) {
|
||||
this.droppedItems = new ArrayList<>(droppedItems);
|
||||
return this;
|
||||
@@ -106,8 +79,6 @@ public class Drop {
|
||||
return new Drop(
|
||||
this.player,
|
||||
this.killer,
|
||||
this.fightTag,
|
||||
this.deathCause,
|
||||
this.droppedItems,
|
||||
this.droppedExp
|
||||
);
|
||||
|
||||
@@ -1,9 +1,9 @@
|
||||
package com.eternalcode.combat.drop;
|
||||
|
||||
import com.eternalcode.combat.fight.FightManager;
|
||||
import com.eternalcode.combat.fight.FightTag;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.event.EventHandler;
|
||||
import org.bukkit.event.EventPriority;
|
||||
import org.bukkit.event.Listener;
|
||||
import org.bukkit.event.entity.PlayerDeathEvent;
|
||||
import org.bukkit.event.player.PlayerRespawnEvent;
|
||||
@@ -27,7 +27,7 @@ public class DropController implements Listener {
|
||||
this.fightManager = fightManager;
|
||||
}
|
||||
|
||||
@EventHandler
|
||||
@EventHandler(priority = EventPriority.LOW)
|
||||
void onPlayerDeath(PlayerDeathEvent event) {
|
||||
Player player = event.getEntity();
|
||||
|
||||
@@ -36,22 +36,21 @@ public class DropController implements Listener {
|
||||
if (dropType == DropType.UNCHANGED || !this.fightManager.isInCombat(player.getUniqueId())) {
|
||||
return;
|
||||
}
|
||||
|
||||
FightTag fightTag = this.fightManager.getTag(player.getUniqueId());
|
||||
|
||||
List<ItemStack> drops = event.getDrops();
|
||||
|
||||
Drop drop = Drop.builder()
|
||||
.player(player)
|
||||
.killer(player.getKiller())
|
||||
.fightTag(fightTag)
|
||||
.deathCause(fightTag.getDeathCause())
|
||||
.droppedItems(drops)
|
||||
.droppedExp(player.getTotalExperience())
|
||||
.build();
|
||||
|
||||
DropResult result = this.dropManager.modify(dropType, drop);
|
||||
|
||||
if (result == null) {
|
||||
return;
|
||||
}
|
||||
|
||||
drops.clear();
|
||||
drops.addAll(result.droppedItems());
|
||||
|
||||
|
||||
+12
-6
@@ -5,8 +5,8 @@ import com.eternalcode.combat.drop.DropModifier;
|
||||
import com.eternalcode.combat.drop.DropResult;
|
||||
import com.eternalcode.combat.drop.DropSettings;
|
||||
import com.eternalcode.combat.drop.DropType;
|
||||
import com.eternalcode.combat.fight.FightDeathCause;
|
||||
import com.eternalcode.combat.fight.FightTag;
|
||||
import com.eternalcode.combat.fight.logout.Logout;
|
||||
import com.eternalcode.combat.fight.logout.LogoutService;
|
||||
import com.eternalcode.combat.util.InventoryUtil;
|
||||
import com.eternalcode.combat.util.MathUtil;
|
||||
import com.eternalcode.combat.util.RemoveItemResult;
|
||||
@@ -15,13 +15,16 @@ import org.bukkit.entity.Player;
|
||||
import org.bukkit.inventory.ItemStack;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Optional;
|
||||
|
||||
public class PlayersHealthDropModifier implements DropModifier {
|
||||
|
||||
private final DropSettings settings;
|
||||
private final LogoutService logoutService;
|
||||
|
||||
public PlayersHealthDropModifier(DropSettings settings) {
|
||||
public PlayersHealthDropModifier(DropSettings settings, LogoutService logoutService) {
|
||||
this.settings = settings;
|
||||
this.logoutService = logoutService;
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -31,17 +34,20 @@ public class PlayersHealthDropModifier implements DropModifier {
|
||||
|
||||
@Override
|
||||
public DropResult modifyDrop(Drop drop) {
|
||||
if (drop.getDeathCause() != FightDeathCause.ESCAPE) {
|
||||
Optional<Logout> logoutOptional = this.logoutService.nextLogoutFor(drop.getPlayer().getUniqueId());
|
||||
|
||||
if (logoutOptional.isEmpty()) {
|
||||
return null;
|
||||
}
|
||||
|
||||
|
||||
Logout logout = logoutOptional.get();
|
||||
Player player = drop.getPlayer();
|
||||
FightTag fightTag = drop.getFightTag();
|
||||
|
||||
List<ItemStack> droppedItems = drop.getDroppedItems();
|
||||
|
||||
double maxHealth = player.getAttribute(Attribute.GENERIC_MAX_HEALTH).getBaseValue();
|
||||
double health = fightTag.getHealthBeforeDeath();
|
||||
double health = logout.health();
|
||||
|
||||
int percentHealth = MathUtil.getRoundedCountPercentage(health, maxHealth);
|
||||
int reversedPercent = MathUtil.clamp(100 - percentHealth, this.settings.playersHealthPercentClamp, 100);
|
||||
|
||||
@@ -1,10 +0,0 @@
|
||||
package com.eternalcode.combat.fight;
|
||||
|
||||
public enum FightDeathCause {
|
||||
|
||||
UNKNOWN,
|
||||
ESCAPE,
|
||||
KILLED_BY_PLAYER,
|
||||
KILLED_BY_ENTITY
|
||||
|
||||
}
|
||||
@@ -9,15 +9,10 @@ public class FightTag {
|
||||
private final UUID taggedPlayer;
|
||||
private final Instant endOfCombatLog;
|
||||
|
||||
private double healthBeforeDeath;
|
||||
private FightDeathCause deathCause;
|
||||
|
||||
FightTag(UUID personToAddCombat, Instant endOfCombatLog) {
|
||||
this.taggedPlayer = personToAddCombat;
|
||||
this.endOfCombatLog = endOfCombatLog;
|
||||
|
||||
this.healthBeforeDeath = 0;
|
||||
this.deathCause = FightDeathCause.UNKNOWN;
|
||||
}
|
||||
|
||||
public UUID getTaggedPlayer() {
|
||||
@@ -42,19 +37,4 @@ public class FightTag {
|
||||
return between;
|
||||
}
|
||||
|
||||
public double getHealthBeforeDeath() {
|
||||
return this.healthBeforeDeath;
|
||||
}
|
||||
|
||||
public void setHealthBeforeDeath(double health) {
|
||||
this.healthBeforeDeath = health;
|
||||
}
|
||||
|
||||
public FightDeathCause getDeathCause() {
|
||||
return this.deathCause;
|
||||
}
|
||||
|
||||
public void setDeathCause(FightDeathCause deathCause) {
|
||||
this.deathCause = deathCause;
|
||||
}
|
||||
}
|
||||
+24
-3
@@ -14,6 +14,7 @@ import org.bukkit.event.entity.EntityDamageEvent;
|
||||
import org.bukkit.event.entity.EntityToggleGlideEvent;
|
||||
import org.bukkit.event.inventory.InventoryOpenEvent;
|
||||
import org.bukkit.event.player.PlayerCommandPreprocessEvent;
|
||||
import org.bukkit.event.player.PlayerToggleFlightEvent;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.UUID;
|
||||
@@ -63,7 +64,7 @@ public class FightActionBlockerController implements Listener {
|
||||
}
|
||||
|
||||
@EventHandler
|
||||
public void onToggleGlide(EntityToggleGlideEvent event) {
|
||||
void onToggleGlide(EntityToggleGlideEvent event) {
|
||||
if (!this.config.settings.shouldPreventElytraUsage) {
|
||||
return;
|
||||
}
|
||||
@@ -83,7 +84,27 @@ public class FightActionBlockerController implements Listener {
|
||||
}
|
||||
|
||||
@EventHandler
|
||||
public void onDamage(EntityDamageEvent event) {
|
||||
void onFly(PlayerToggleFlightEvent event) {
|
||||
if (!this.config.settings.shouldPreventFlying) {
|
||||
return;
|
||||
}
|
||||
|
||||
Player player = event.getPlayer();
|
||||
UUID uniqueId = player.getUniqueId();
|
||||
|
||||
if (!this.fightManager.isInCombat(uniqueId)) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (event.isFlying()) {
|
||||
player.setAllowFlight(false);
|
||||
|
||||
event.setCancelled(true);
|
||||
}
|
||||
}
|
||||
|
||||
@EventHandler
|
||||
void onDamage(EntityDamageEvent event) {
|
||||
if (!this.config.settings.shouldElytraDisableOnDamage) {
|
||||
return;
|
||||
}
|
||||
@@ -117,7 +138,7 @@ public class FightActionBlockerController implements Listener {
|
||||
}
|
||||
|
||||
@EventHandler
|
||||
public void onPlayerCommandPreprocess(PlayerCommandPreprocessEvent event) {
|
||||
void onPlayerCommandPreprocess(PlayerCommandPreprocessEvent event) {
|
||||
Player player = event.getPlayer();
|
||||
UUID playerUniqueId = player.getUniqueId();
|
||||
|
||||
|
||||
-59
@@ -1,59 +0,0 @@
|
||||
package com.eternalcode.combat.fight.controller;
|
||||
|
||||
import com.eternalcode.combat.fight.FightDeathCause;
|
||||
import com.eternalcode.combat.fight.FightManager;
|
||||
import com.eternalcode.combat.fight.FightTag;
|
||||
import org.bukkit.entity.Entity;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.event.EventHandler;
|
||||
import org.bukkit.event.Listener;
|
||||
import org.bukkit.event.entity.EntityDamageByEntityEvent;
|
||||
import org.bukkit.event.player.PlayerQuitEvent;
|
||||
|
||||
public class FightDeathCauseController implements Listener {
|
||||
|
||||
private final FightManager fightManager;
|
||||
|
||||
public FightDeathCauseController(FightManager fightManager) {
|
||||
this.fightManager = fightManager;
|
||||
}
|
||||
|
||||
@EventHandler
|
||||
public void onEntityDamage(EntityDamageByEntityEvent event) {
|
||||
Entity victimEntity = event.getEntity();
|
||||
Entity damagerEntity = event.getDamager();
|
||||
|
||||
if (!(victimEntity instanceof Player victim)) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (!this.fightManager.isInCombat(victim.getUniqueId())) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (victim.getHealth() > event.getFinalDamage()) {
|
||||
return;
|
||||
}
|
||||
|
||||
FightTag fightTag = this.fightManager.getTag(damagerEntity.getUniqueId());
|
||||
|
||||
if (damagerEntity instanceof Player) {
|
||||
fightTag.setDeathCause(FightDeathCause.KILLED_BY_PLAYER);
|
||||
return;
|
||||
}
|
||||
|
||||
fightTag.setDeathCause(FightDeathCause.KILLED_BY_ENTITY);
|
||||
}
|
||||
|
||||
@EventHandler
|
||||
public void onQuit(PlayerQuitEvent event) {
|
||||
Player player = event.getPlayer();
|
||||
|
||||
if (!this.fightManager.isInCombat(player.getUniqueId())) {
|
||||
return;
|
||||
}
|
||||
|
||||
FightTag fightTag = this.fightManager.getTag(player.getUniqueId());
|
||||
fightTag.setDeathCause(FightDeathCause.ESCAPE);
|
||||
}
|
||||
}
|
||||
+4
-2
@@ -3,13 +3,16 @@ package com.eternalcode.combat.fight.controller;
|
||||
import com.eternalcode.combat.config.implementation.PluginConfig;
|
||||
import com.eternalcode.combat.fight.FightManager;
|
||||
import com.eternalcode.combat.fight.bossbar.FightBossBarService;
|
||||
import com.eternalcode.combat.fight.event.CauseOfUnTag;
|
||||
import com.eternalcode.combat.fight.event.FightTagEvent;
|
||||
import com.eternalcode.combat.fight.event.FightUntagEvent;
|
||||
import com.eternalcode.combat.notification.NotificationAnnouncer;
|
||||
import org.bukkit.Server;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.event.EventHandler;
|
||||
import org.bukkit.event.EventPriority;
|
||||
import org.bukkit.event.Listener;
|
||||
import panda.utilities.text.Formatter;
|
||||
|
||||
public class FightMessageController implements Listener {
|
||||
|
||||
@@ -43,7 +46,7 @@ public class FightMessageController implements Listener {
|
||||
}
|
||||
|
||||
@EventHandler(priority = EventPriority.MONITOR, ignoreCancelled = true)
|
||||
void onUnTag(FightTagEvent event) {
|
||||
void onUnTag(FightUntagEvent event) {
|
||||
Player player = this.server.getPlayer(event.getPlayer());
|
||||
|
||||
if (player == null) {
|
||||
@@ -57,5 +60,4 @@ public class FightMessageController implements Listener {
|
||||
this.announcer.sendMessage(player, this.config.messages.playerUntagged);
|
||||
this.bossBarService.hide(event.getPlayer());
|
||||
}
|
||||
|
||||
}
|
||||
+27
-11
@@ -1,10 +1,9 @@
|
||||
package com.eternalcode.combat.fight.controller;
|
||||
|
||||
import com.eternalcode.combat.WhitelistBlacklistMode;
|
||||
import com.eternalcode.combat.fight.event.CauseOfTag;
|
||||
import com.eternalcode.combat.config.implementation.PluginConfig;
|
||||
import com.eternalcode.combat.fight.FightManager;
|
||||
import com.eternalcode.combat.notification.NotificationAnnouncer;
|
||||
import com.eternalcode.combat.fight.event.CauseOfTag;
|
||||
import org.bukkit.entity.EntityType;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.entity.Projectile;
|
||||
@@ -23,12 +22,10 @@ public class FightTagController implements Listener {
|
||||
|
||||
private final FightManager fightManager;
|
||||
private final PluginConfig config;
|
||||
private final NotificationAnnouncer announcer;
|
||||
|
||||
public FightTagController(FightManager fightManager, PluginConfig config, NotificationAnnouncer announcer) {
|
||||
public FightTagController(FightManager fightManager, PluginConfig config) {
|
||||
this.fightManager = fightManager;
|
||||
this.config = config;
|
||||
this.announcer = announcer;
|
||||
}
|
||||
|
||||
@EventHandler(priority = EventPriority.MONITOR, ignoreCancelled = true)
|
||||
@@ -38,7 +35,7 @@ public class FightTagController implements Listener {
|
||||
}
|
||||
|
||||
List<EntityType> disabledProjectileEntities = this.config.settings.disabledProjectileEntities;
|
||||
|
||||
|
||||
if (event.getDamager() instanceof Projectile projectile && disabledProjectileEntities.contains(projectile.getType())) {
|
||||
return;
|
||||
}
|
||||
@@ -47,19 +44,38 @@ public class FightTagController implements Listener {
|
||||
return;
|
||||
}
|
||||
|
||||
Player personToAddCombatTime = this.getDamager(event);
|
||||
Player attacker = this.getDamager(event);
|
||||
|
||||
if (personToAddCombatTime == null) {
|
||||
if (attacker == null) {
|
||||
return;
|
||||
}
|
||||
|
||||
Duration combatTime = this.config.settings.combatDuration;
|
||||
|
||||
UUID attackedUniqueId = attackedPlayerByPerson.getUniqueId();
|
||||
UUID personToAddCombatTimeUniqueId = personToAddCombatTime.getUniqueId();
|
||||
UUID attackerUniqueId = attacker.getUniqueId();
|
||||
|
||||
if (attacker.isOp()) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (attackedPlayerByPerson.isOp() && this.config.settings.excludeAdminFromCombat) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (this.config.settings.shouldPreventFlying) {
|
||||
if (attackedPlayerByPerson.isFlying()) {
|
||||
attackedPlayerByPerson.setFlying(false);
|
||||
attackedPlayerByPerson.setAllowFlight(false);
|
||||
}
|
||||
|
||||
if (attacker.isFlying()) {
|
||||
attacker.setFlying(false);
|
||||
attacker.setAllowFlight(false);
|
||||
}
|
||||
}
|
||||
|
||||
this.fightManager.tag(attackedUniqueId, combatTime, CauseOfTag.PLAYER);
|
||||
this.fightManager.tag(personToAddCombatTimeUniqueId, combatTime, CauseOfTag.PLAYER);
|
||||
this.fightManager.tag(attackerUniqueId, combatTime, CauseOfTag.PLAYER);
|
||||
}
|
||||
|
||||
@EventHandler(priority = EventPriority.MONITOR, ignoreCancelled = true)
|
||||
|
||||
+23
-3
@@ -3,6 +3,7 @@ package com.eternalcode.combat.fight.controller;
|
||||
import com.eternalcode.combat.fight.event.CauseOfUnTag;
|
||||
import com.eternalcode.combat.config.implementation.PluginConfig;
|
||||
import com.eternalcode.combat.fight.FightManager;
|
||||
import com.eternalcode.combat.fight.logout.LogoutService;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.event.EventHandler;
|
||||
import org.bukkit.event.Listener;
|
||||
@@ -12,10 +13,12 @@ public class FightUnTagController implements Listener {
|
||||
|
||||
private final FightManager fightManager;
|
||||
private final PluginConfig config;
|
||||
private final LogoutService logoutService;
|
||||
|
||||
public FightUnTagController(FightManager fightManager, PluginConfig config) {
|
||||
public FightUnTagController(FightManager fightManager, PluginConfig config, LogoutService logoutService) {
|
||||
this.fightManager = fightManager;
|
||||
this.config = config;
|
||||
this.logoutService = logoutService;
|
||||
}
|
||||
|
||||
@EventHandler
|
||||
@@ -27,12 +30,29 @@ public class FightUnTagController implements Listener {
|
||||
return;
|
||||
}
|
||||
|
||||
CauseOfUnTag causeOfUnTag = (killer == null ? CauseOfUnTag.DEATH_BY_PLAYER : CauseOfUnTag.DEATH);
|
||||
CauseOfUnTag cause = this.getDeathCause(player, killer);
|
||||
|
||||
this.fightManager.untag(player.getUniqueId(), causeOfUnTag);
|
||||
this.fightManager.untag(player.getUniqueId(), cause);
|
||||
|
||||
if (killer != null && this.config.settings.shouldReleaseAttacker) {
|
||||
this.fightManager.untag(killer.getUniqueId(), CauseOfUnTag.ATTACKER_RELEASE);
|
||||
}
|
||||
}
|
||||
|
||||
private CauseOfUnTag getDeathCause(Player player, Player killer) {
|
||||
if (this.logoutService.hasLoggedOut(player.getUniqueId())) {
|
||||
return CauseOfUnTag.LOGOUT;
|
||||
}
|
||||
|
||||
if (killer == null) {
|
||||
return CauseOfUnTag.DEATH;
|
||||
}
|
||||
|
||||
if (this.fightManager.isInCombat(killer.getUniqueId())) {
|
||||
return CauseOfUnTag.DEATH_BY_PLAYER;
|
||||
}
|
||||
|
||||
return CauseOfUnTag.DEATH;
|
||||
}
|
||||
|
||||
}
|
||||
+1
-1
@@ -10,7 +10,7 @@ import java.util.Map;
|
||||
public class FightEffectSettings extends OkaeriConfig {
|
||||
|
||||
@Comment({"# Do you want to add effects to players in combat?"})
|
||||
public boolean customEffectsEnabled = true;
|
||||
public boolean customEffectsEnabled = false;
|
||||
|
||||
@Comment({
|
||||
"# If the option above is set to true, you can add effects to players in combat below",
|
||||
|
||||
@@ -3,5 +3,6 @@ package com.eternalcode.combat.fight.event;
|
||||
public enum CauseOfTag {
|
||||
PLAYER,
|
||||
NON_PLAYER,
|
||||
COMMAND
|
||||
COMMAND,
|
||||
CUSTOM
|
||||
}
|
||||
+2
-1
@@ -6,5 +6,6 @@ public enum CauseOfUnTag {
|
||||
DEATH_BY_PLAYER,
|
||||
LOGOUT,
|
||||
COMMAND,
|
||||
ATTACKER_RELEASE
|
||||
ATTACKER_RELEASE,
|
||||
CUSTOM
|
||||
}
|
||||
@@ -0,0 +1,6 @@
|
||||
package com.eternalcode.combat.fight.logout;
|
||||
|
||||
import java.util.UUID;
|
||||
|
||||
public record Logout(UUID player, double health) {
|
||||
}
|
||||
+16
-14
@@ -1,45 +1,47 @@
|
||||
package com.eternalcode.combat.fight.controller;
|
||||
package com.eternalcode.combat.fight.logout;
|
||||
|
||||
import com.eternalcode.combat.config.implementation.PluginConfig;
|
||||
import com.eternalcode.combat.fight.FightManager;
|
||||
import com.eternalcode.combat.fight.FightTag;
|
||||
import com.eternalcode.combat.notification.NotificationAnnouncer;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.event.EventHandler;
|
||||
import org.bukkit.event.EventPriority;
|
||||
import org.bukkit.event.Listener;
|
||||
import org.bukkit.event.player.PlayerQuitEvent;
|
||||
import panda.utilities.text.Formatter;
|
||||
|
||||
public class FightEscapeController implements Listener {
|
||||
public class LogoutController implements Listener {
|
||||
|
||||
private final FightManager fightManager;
|
||||
private final PluginConfig config;
|
||||
private final LogoutService logoutService;
|
||||
private final NotificationAnnouncer announcer;
|
||||
private final PluginConfig config;
|
||||
|
||||
public FightEscapeController(FightManager fightManager, PluginConfig config, NotificationAnnouncer announcer) {
|
||||
|
||||
public LogoutController(FightManager fightManager, LogoutService logoutService, NotificationAnnouncer announcer, PluginConfig config) {
|
||||
this.fightManager = fightManager;
|
||||
this.config = config;
|
||||
this.logoutService = logoutService;
|
||||
this.announcer = announcer;
|
||||
this.config = config;
|
||||
}
|
||||
|
||||
@EventHandler
|
||||
void onPlayerQuit(PlayerQuitEvent event) {
|
||||
@EventHandler(priority = EventPriority.HIGH)
|
||||
void onQuit(PlayerQuitEvent event) {
|
||||
Player player = event.getPlayer();
|
||||
|
||||
if (!this.fightManager.isInCombat(player.getUniqueId())) {
|
||||
return;
|
||||
}
|
||||
|
||||
this.logoutService.punishForLogout(player);
|
||||
player.setHealth(0.0);
|
||||
|
||||
Formatter formatter = new Formatter()
|
||||
.register("{PLAYER}", player.getName());
|
||||
.register("{PLAYER}", player.getName());
|
||||
|
||||
String format = formatter.format(this.config.messages.playerLoggedOutDuringCombat);
|
||||
|
||||
this.announcer.broadcast(format);
|
||||
|
||||
FightTag fightTag = this.fightManager.getTag(player.getUniqueId());
|
||||
fightTag.setHealthBeforeDeath(player.getHealth());
|
||||
|
||||
player.setHealth(0.0); // Untagged in PlayerDeathEvent
|
||||
}
|
||||
|
||||
}
|
||||
+37
@@ -0,0 +1,37 @@
|
||||
package com.eternalcode.combat.fight.logout;
|
||||
|
||||
import com.google.common.cache.Cache;
|
||||
import com.google.common.cache.CacheBuilder;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
import java.util.Optional;
|
||||
import java.util.UUID;
|
||||
import java.util.concurrent.TimeUnit;
|
||||
|
||||
public class LogoutService {
|
||||
|
||||
private final Cache<UUID, Logout> logouts = CacheBuilder.newBuilder()
|
||||
.expireAfterWrite(1, TimeUnit.MINUTES)
|
||||
.build();
|
||||
|
||||
public void punishForLogout(Player player) {
|
||||
UUID uniqueId = player.getUniqueId();
|
||||
|
||||
this.logouts.put(uniqueId, new Logout(uniqueId, player.getHealth()));
|
||||
}
|
||||
|
||||
public Optional<Logout> nextLogoutFor(UUID player) {
|
||||
Logout logout = this.logouts.getIfPresent(player);
|
||||
|
||||
if (logout == null) {
|
||||
return Optional.empty();
|
||||
}
|
||||
|
||||
this.logouts.invalidate(player);
|
||||
return Optional.of(logout);
|
||||
}
|
||||
|
||||
public boolean hasLoggedOut(UUID player) {
|
||||
return this.logouts.asMap().containsKey(player);
|
||||
}
|
||||
}
|
||||
+3
-3
@@ -1,7 +1,7 @@
|
||||
package com.eternalcode.combat.fight.pearl;
|
||||
|
||||
import com.google.common.cache.Cache;
|
||||
import com.google.common.cache.CacheBuilder;
|
||||
import com.github.benmanes.caffeine.cache.Cache;
|
||||
import com.github.benmanes.caffeine.cache.Caffeine;
|
||||
|
||||
import java.time.Duration;
|
||||
import java.time.Instant;
|
||||
@@ -14,7 +14,7 @@ public class FightPearlManager {
|
||||
|
||||
public FightPearlManager(FightPearlSettings pearlSettings) {
|
||||
this.pearlSettings = pearlSettings;
|
||||
this.pearlDelays = CacheBuilder.newBuilder()
|
||||
this.pearlDelays = Caffeine.newBuilder()
|
||||
.expireAfterWrite(pearlSettings.pearlThrowDelay)
|
||||
.build();
|
||||
}
|
||||
|
||||
+9
@@ -22,6 +22,15 @@ public class DefaultRegionProvider implements RegionProvider {
|
||||
return this.contains(min, max, location.getX(), location.getZ());
|
||||
}
|
||||
|
||||
@Override
|
||||
public Location getRegionCenter(Location location) {
|
||||
Location spawnLocation = location.getWorld().getSpawnLocation();
|
||||
double x = spawnLocation.getX();
|
||||
double z = spawnLocation.getZ();
|
||||
|
||||
return new Location(location.getWorld(), x, location.getY(), z);
|
||||
}
|
||||
|
||||
public boolean contains(Point min, Point max, double x, double z) {
|
||||
return x >= min.x() && x < max.x()
|
||||
&& z >= min.z() && z < max.z();
|
||||
|
||||
+20
-2
@@ -8,6 +8,7 @@ import org.bukkit.entity.Player;
|
||||
import org.bukkit.event.EventHandler;
|
||||
import org.bukkit.event.Listener;
|
||||
import org.bukkit.event.player.PlayerMoveEvent;
|
||||
import org.bukkit.event.player.PlayerTeleportEvent;
|
||||
import org.bukkit.util.Vector;
|
||||
|
||||
public class RegionController implements Listener {
|
||||
@@ -47,8 +48,9 @@ public class RegionController implements Listener {
|
||||
return;
|
||||
}
|
||||
|
||||
Location playerLocation = player.getLocation().subtract(player.getWorld().getSpawnLocation());
|
||||
double distance = playerLocation.distance(player.getWorld().getSpawnLocation());
|
||||
Location spawnLocation = this.regionProvider.getRegionCenter(locationTo);
|
||||
Location playerLocation = player.getLocation().subtract(spawnLocation);
|
||||
double distance = playerLocation.distance(spawnLocation);
|
||||
Vector knockback = new Vector(0, 3, 0).multiply(this.pluginConfig.settings.blockedRegionKnockMultiplier / distance);
|
||||
Vector vector = playerLocation.toVector().add(knockback);
|
||||
|
||||
@@ -57,4 +59,20 @@ public class RegionController implements Listener {
|
||||
this.announcer.sendMessage(player, this.pluginConfig.messages.cantEnterOnRegion);
|
||||
}
|
||||
}
|
||||
|
||||
@EventHandler
|
||||
public void onPlayerTeleport(PlayerTeleportEvent event) {
|
||||
Player player = event.getPlayer();
|
||||
|
||||
if (!this.fightManager.isInCombat(player.getUniqueId())) {
|
||||
return;
|
||||
}
|
||||
|
||||
Location targetLocation = event.getTo();
|
||||
|
||||
if (this.regionProvider.isInRegion(targetLocation)) {
|
||||
event.setCancelled(true);
|
||||
this.announcer.sendMessage(player, this.pluginConfig.messages.cantEnterOnRegion);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -2,9 +2,10 @@ package com.eternalcode.combat.region;
|
||||
|
||||
import org.bukkit.Location;
|
||||
|
||||
@FunctionalInterface
|
||||
public interface RegionProvider {
|
||||
|
||||
boolean isInRegion(Location location);
|
||||
|
||||
Location getRegionCenter(Location location);
|
||||
|
||||
}
|
||||
+37
@@ -1,8 +1,10 @@
|
||||
package com.eternalcode.combat.region;
|
||||
|
||||
import com.sk89q.worldedit.bukkit.BukkitAdapter;
|
||||
import com.sk89q.worldedit.math.BlockVector3;
|
||||
import com.sk89q.worldguard.WorldGuard;
|
||||
import com.sk89q.worldguard.protection.ApplicableRegionSet;
|
||||
import com.sk89q.worldguard.protection.regions.ProtectedRegion;
|
||||
import com.sk89q.worldguard.protection.regions.RegionContainer;
|
||||
import com.sk89q.worldguard.protection.regions.RegionQuery;
|
||||
import org.bukkit.Location;
|
||||
@@ -22,6 +24,41 @@ public class WorldGuardRegionProvider implements RegionProvider {
|
||||
return this.regions.stream().anyMatch(region -> this.isInCombatRegion(location, region));
|
||||
}
|
||||
|
||||
@Override
|
||||
public Location getRegionCenter(Location location) {
|
||||
RegionContainer regionContainer = WorldGuard.getInstance().getPlatform().getRegionContainer();
|
||||
RegionQuery regionQuery = regionContainer.createQuery();
|
||||
ApplicableRegionSet applicableRegions = regionQuery.getApplicableRegions(BukkitAdapter.adapt(location));
|
||||
|
||||
double minX = 0;
|
||||
double maxX = 0;
|
||||
double minZ = 0;
|
||||
double maxZ = 0;
|
||||
|
||||
for (ProtectedRegion region : applicableRegions.getRegions()) {
|
||||
BlockVector3 min = region.getMinimumPoint();
|
||||
BlockVector3 max = region.getMaximumPoint();
|
||||
|
||||
if (min.getX() < minX) {
|
||||
minX = min.getX();
|
||||
}
|
||||
if (max.getX() > maxX) {
|
||||
maxX = max.getX();
|
||||
}
|
||||
if (min.getZ() < minZ) {
|
||||
minZ = min.getZ();
|
||||
}
|
||||
if (max.getZ() > maxZ) {
|
||||
maxZ = max.getZ();
|
||||
}
|
||||
}
|
||||
|
||||
double x = (maxX - minX) / 2 + minX;
|
||||
double z = (maxZ - minZ) / 2 + minZ;
|
||||
|
||||
return new Location(location.getWorld(), x, location.getY(), z);
|
||||
}
|
||||
|
||||
private boolean isInCombatRegion(Location location, String regionName) {
|
||||
RegionContainer regionContainer = WorldGuard.getInstance().getPlatform().getRegionContainer();
|
||||
RegionQuery regionQuery = regionContainer.createQuery();
|
||||
|
||||
+2
-1
@@ -14,6 +14,7 @@ import java.util.concurrent.CompletableFuture;
|
||||
public class UpdaterNotificationController implements Listener {
|
||||
|
||||
private static final String NEW_VERSION_AVAILABLE = "<b><gradient:#8a1212:#fc6b03>EternalCombat:</gradient></b> <color:#fce303>New version of EternalCombat is available, please update!";
|
||||
private static final String RECEIVE_UPDATES_PERMISSION = "eternalcombat.receiveupdates";
|
||||
|
||||
private final UpdaterService updaterService;
|
||||
private final PluginConfig pluginConfig;
|
||||
@@ -32,7 +33,7 @@ public class UpdaterNotificationController implements Listener {
|
||||
Player player = event.getPlayer();
|
||||
Audience audience = this.audienceProvider.player(player.getUniqueId());
|
||||
|
||||
if (!player.hasPermission("eternalcombat.receiveupdates") || !this.pluginConfig.settings.shouldReceivePluginUpdates) {
|
||||
if (!player.hasPermission(RECEIVE_UPDATES_PERMISSION) || !this.pluginConfig.settings.shouldReceivePluginUpdates) {
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
@@ -1,25 +1,24 @@
|
||||
package com.eternalcode.combat.util;
|
||||
|
||||
import com.eternalcode.commons.time.DurationParser;
|
||||
import com.eternalcode.commons.time.TemporalAmountParser;
|
||||
import java.time.Duration;
|
||||
import java.time.temporal.ChronoUnit;
|
||||
|
||||
public final class DurationUtil {
|
||||
|
||||
private DurationUtil() {
|
||||
throw new UnsupportedOperationException("This is a utility class and cannot be instantiated");
|
||||
private static final TemporalAmountParser<Duration> WITHOUT_MILLS = new DurationParser()
|
||||
.withUnit("s", ChronoUnit.SECONDS)
|
||||
.withUnit("m", ChronoUnit.MINUTES)
|
||||
.withUnit("h", ChronoUnit.HOURS)
|
||||
.withUnit("d", ChronoUnit.DAYS)
|
||||
.roundOff(ChronoUnit.MILLIS);
|
||||
|
||||
public DurationUtil() {
|
||||
throw new UnsupportedOperationException("This class cannot be instantiated");
|
||||
}
|
||||
|
||||
public static String format(Duration duration) {
|
||||
return format(duration, true);
|
||||
}
|
||||
|
||||
public static String format(Duration duration, boolean removeMillis) {
|
||||
if (removeMillis) {
|
||||
duration = Duration.ofSeconds(duration.toSeconds());
|
||||
}
|
||||
|
||||
return duration.toString()
|
||||
.substring(2)
|
||||
.replaceAll("(\\d[HMS])(?!$)", "$1 ")
|
||||
.toLowerCase();
|
||||
return WITHOUT_MILLS.format(duration);
|
||||
}
|
||||
}
|
||||
@@ -4,9 +4,7 @@ import org.bukkit.inventory.ItemStack;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collection;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Random;
|
||||
import java.util.function.ToIntFunction;
|
||||
|
||||
@@ -23,49 +21,31 @@ public class InventoryUtil {
|
||||
}
|
||||
|
||||
public static RemoveItemResult removeRandomItems(List<ItemStack> list, int itemsToDelete) {
|
||||
List<ItemStack> restItems = new ArrayList<>(list);
|
||||
Map<Integer, ItemStack> removedItems = new HashMap<>();
|
||||
List<ItemStack> currentItems = new ArrayList<>(list);
|
||||
List<ItemStack> removedItems = new ArrayList<>();
|
||||
|
||||
for (int i = 0; i < itemsToDelete; i++) {
|
||||
if (restItems.isEmpty()) {
|
||||
break;
|
||||
}
|
||||
int currentItemsToDelete = itemsToDelete;
|
||||
while (currentItemsToDelete > 0) {
|
||||
int randomIndex = RANDOM.nextInt(list.size());
|
||||
ItemStack currentItem = currentItems.get(randomIndex);
|
||||
|
||||
int randomIndex = RANDOM.nextInt(restItems.size());
|
||||
int amount = currentItem.getAmount();
|
||||
int randomAmount = RANDOM.nextInt(0, Math.min(currentItemsToDelete, amount) + 1);
|
||||
|
||||
ItemStack item = restItems.get(randomIndex);
|
||||
int newAmount = item.getAmount() - 1;
|
||||
|
||||
if (newAmount <= 0) {
|
||||
restItems.remove(randomIndex);
|
||||
incrementItem(removedItems, randomIndex, item);
|
||||
if (amount <= 0 || randomAmount <= 0) {
|
||||
continue;
|
||||
}
|
||||
|
||||
item.setAmount(newAmount);
|
||||
incrementItem(removedItems, randomIndex, item);
|
||||
ItemStack removedItem = currentItem.clone();
|
||||
removedItem.setAmount(randomAmount);
|
||||
removedItems.add(removedItem);
|
||||
|
||||
currentItem.setAmount(amount - randomAmount);
|
||||
|
||||
currentItemsToDelete -= randomAmount;
|
||||
}
|
||||
|
||||
return new RemoveItemResult(restItems, new ArrayList<>(removedItems.values()));
|
||||
}
|
||||
|
||||
// TODO: kinda shitty, but no time for a proper solution now
|
||||
private static void incrementItem(Map<Integer, ItemStack> items, int index, ItemStack itemStack) {
|
||||
ItemStack itemInList = items.get(index);
|
||||
|
||||
if (itemInList == null) {
|
||||
ItemStack cloned = itemStack.clone();
|
||||
|
||||
cloned.setAmount(1);
|
||||
items.put(index, cloned);
|
||||
return;
|
||||
}
|
||||
|
||||
if (!itemInList.isSimilar(itemStack)) {
|
||||
throw new IllegalStateException("Items are not similar!");
|
||||
}
|
||||
|
||||
itemInList.setAmount(itemInList.getAmount() + 1);
|
||||
return new RemoveItemResult(currentItems, removedItems);
|
||||
}
|
||||
|
||||
}
|
||||
@@ -1,18 +0,0 @@
|
||||
package com.eternalcode.combat.util.legacy;
|
||||
|
||||
import net.kyori.adventure.text.Component;
|
||||
import net.kyori.adventure.text.serializer.legacy.LegacyComponentSerializer;
|
||||
|
||||
public final class Legacy {
|
||||
|
||||
private static final LegacyComponentSerializer AMPERSAND_SERIALIZER = LegacyComponentSerializer.builder()
|
||||
.character('&')
|
||||
.hexColors()
|
||||
.useUnusualXRepeatedCharacterHexFormat()
|
||||
.build();
|
||||
|
||||
public static Component component(String text) {
|
||||
return AMPERSAND_SERIALIZER.deserialize(text);
|
||||
}
|
||||
|
||||
}
|
||||
-15
@@ -1,15 +0,0 @@
|
||||
package com.eternalcode.combat.util.legacy;
|
||||
|
||||
import net.kyori.adventure.text.Component;
|
||||
|
||||
import java.util.function.UnaryOperator;
|
||||
import java.util.regex.Pattern;
|
||||
|
||||
public final class LegacyColorProcessor implements UnaryOperator<Component> {
|
||||
|
||||
@Override
|
||||
public Component apply(Component component) {
|
||||
return component.replaceText(builder -> builder.match(Pattern.compile(".*"))
|
||||
.replacement((matchResult, builder1) -> Legacy.component(matchResult.group())));
|
||||
}
|
||||
}
|
||||
@@ -1,53 +0,0 @@
|
||||
package com.eternalcode.combat.util;
|
||||
|
||||
import static org.junit.jupiter.api.Assertions.assertEquals;
|
||||
|
||||
import java.time.Duration;
|
||||
import java.util.Arrays;
|
||||
import java.util.Collection;
|
||||
|
||||
import org.junit.jupiter.params.ParameterizedTest;
|
||||
import org.junit.jupiter.params.provider.MethodSource;
|
||||
|
||||
class DurationUtilTest {
|
||||
|
||||
private static Collection<Object[]> data() {
|
||||
return Arrays.asList(new Object[][]{
|
||||
{ "3m 30s", true, Duration.ofMinutes(3).plusSeconds(30).plusMillis(500) },
|
||||
{ "3m 30.5s", false, Duration.ofMinutes(3).plusSeconds(30).plusMillis(500) },
|
||||
|
||||
{ "59m 59s", true, Duration.ofMinutes(59).plusSeconds(59) },
|
||||
{ "1h 1m", true, Duration.ofHours(1).plusMinutes(1).plusMillis(1) },
|
||||
|
||||
|
||||
{ "0s", true, Duration.ofMillis(500) },
|
||||
{ "0.5s", false, Duration.ofMillis(500) },
|
||||
{ "0s", true, Duration.ofMillis(500) },
|
||||
{ "0s", false, Duration.ZERO },
|
||||
|
||||
|
||||
{ "30s", true, Duration.ofSeconds(30) },
|
||||
{ "30s", false, Duration.ofSeconds(30) },
|
||||
{ "30s", true, Duration.ofSeconds(30).plusMillis(500) },
|
||||
{ "30.5s", false, Duration.ofSeconds(30).plusMillis(500) },
|
||||
|
||||
{ "1h 30m 30s", true, Duration.ofHours(1).plusMinutes(30).plusSeconds(30).plusMillis(500) },
|
||||
{ "1h 30m 30.5s", false, Duration.ofHours(1).plusMinutes(30).plusSeconds(30).plusMillis(500) },
|
||||
{ "1h 1m 1s", true, Duration.ofHours(1).plusMinutes(1).plusSeconds(1) },
|
||||
{ "23h 59m 59s", true, Duration.ofHours(23).plusMinutes(59).plusSeconds(59) },
|
||||
{ "23h 59m 59s", true, Duration.ofHours(23).plusMinutes(59).plusSeconds(59).plusMillis(999) },
|
||||
{ "26h 3m 4s", true, Duration.ofDays(1).plusHours(2).plusMinutes(3).plusSeconds(4).plusMillis(500) },
|
||||
{ "1h 1m 1s", true, Duration.ofHours(1).plusMinutes(1).plusSeconds(1).plusMillis(1) },
|
||||
|
||||
{ "1h 1s", true, Duration.ofHours(1).plusSeconds(1) },
|
||||
{ "1m", true, Duration.ofMinutes(1).plusMillis(1) },
|
||||
});
|
||||
}
|
||||
|
||||
@ParameterizedTest
|
||||
@MethodSource("data")
|
||||
void testFormat(String expected, boolean removeMillis, Duration duration) {
|
||||
String actual = DurationUtil.format(duration, removeMillis);
|
||||
assertEquals(expected, actual);
|
||||
}
|
||||
}
|
||||
@@ -1,32 +1,10 @@
|
||||
import com.github.jengelman.gradle.plugins.shadow.tasks.ShadowJar
|
||||
|
||||
plugins {
|
||||
`java-library`
|
||||
checkstyle
|
||||
`eternalcombat-java`
|
||||
`eternalcombat-repositories`
|
||||
|
||||
id("net.minecrell.plugin-yml.bukkit") version "0.6.0"
|
||||
id("com.github.johnrengelman.shadow") version "8.1.1"
|
||||
id("xyz.jpenilla.run-paper") version "2.1.0"
|
||||
}
|
||||
|
||||
checkstyle {
|
||||
toolVersion = "10.12.2"
|
||||
|
||||
configFile = file("${rootDir}/config/checkstyle/checkstyle.xml")
|
||||
|
||||
maxErrors = 0
|
||||
maxWarnings = 0
|
||||
}
|
||||
|
||||
repositories {
|
||||
mavenCentral()
|
||||
|
||||
maven { url = uri("https://hub.spigotmc.org/nexus/content/repositories/snapshots/") }
|
||||
maven { url = uri("https://papermc.io/repo/repository/maven-public/") }
|
||||
maven { url = uri("https://repo.eternalcode.pl/releases") }
|
||||
maven { url = uri("https://storehouse.okaeri.eu/repository/maven-public/") }
|
||||
maven { url = uri("https://repo.panda-lang.org/releases") }
|
||||
maven { url = uri("https://maven.enginehub.org/repo/") }
|
||||
id("net.minecrell.plugin-yml.bukkit")
|
||||
id("com.github.johnrengelman.shadow")
|
||||
id("xyz.jpenilla.run-paper")
|
||||
}
|
||||
|
||||
dependencies {
|
||||
@@ -43,23 +21,13 @@ bukkit {
|
||||
version = "${project.version}"
|
||||
}
|
||||
|
||||
java {
|
||||
sourceCompatibility = JavaVersion.VERSION_17
|
||||
targetCompatibility = JavaVersion.VERSION_17
|
||||
}
|
||||
|
||||
tasks.withType<JavaCompile> {
|
||||
options.compilerArgs = listOf("-Xlint:deprecation", "-parameters")
|
||||
options.encoding = "UTF-8"
|
||||
}
|
||||
|
||||
tasks {
|
||||
runServer {
|
||||
minecraftVersion("1.19.4")
|
||||
}
|
||||
}
|
||||
|
||||
tasks.withType<ShadowJar> {
|
||||
tasks.shadowJar {
|
||||
archiveFileName.set("EternalCombat v${project.version}.jar")
|
||||
|
||||
dependsOn("checkstyleMain")
|
||||
@@ -86,7 +54,9 @@ tasks.withType<ShadowJar> {
|
||||
"com.eternalcode.gitcheck",
|
||||
"org.json.simple",
|
||||
"org.apache.commons",
|
||||
"javassist"
|
||||
"javassist",
|
||||
"com.github.benmanes.caffeine",
|
||||
"com.eternalcode.commons"
|
||||
).forEach { pack ->
|
||||
relocate(pack, "$prefix.$pack")
|
||||
}
|
||||
|
||||
@@ -3,7 +3,6 @@ package com.eternalcode.combat;
|
||||
import com.eternalcode.combat.bridge.BridgeService;
|
||||
import com.eternalcode.combat.command.InvalidUsage;
|
||||
import com.eternalcode.combat.command.PermissionMessage;
|
||||
import com.eternalcode.combat.config.ConfigBackupService;
|
||||
import com.eternalcode.combat.config.ConfigService;
|
||||
import com.eternalcode.combat.config.implementation.PluginConfig;
|
||||
import com.eternalcode.combat.drop.DropController;
|
||||
@@ -12,8 +11,6 @@ import com.eternalcode.combat.drop.DropManager;
|
||||
import com.eternalcode.combat.drop.impl.PercentDropModifier;
|
||||
import com.eternalcode.combat.drop.impl.PlayersHealthDropModifier;
|
||||
import com.eternalcode.combat.fight.controller.FightActionBlockerController;
|
||||
import com.eternalcode.combat.fight.controller.FightDeathCauseController;
|
||||
import com.eternalcode.combat.fight.controller.FightEscapeController;
|
||||
import com.eternalcode.combat.fight.controller.FightMessageController;
|
||||
import com.eternalcode.combat.fight.controller.FightTagController;
|
||||
import com.eternalcode.combat.fight.controller.FightUnTagController;
|
||||
@@ -23,6 +20,8 @@ import com.eternalcode.combat.fight.FightManager;
|
||||
import com.eternalcode.combat.fight.FightTask;
|
||||
import com.eternalcode.combat.fight.bossbar.FightBossBarService;
|
||||
import com.eternalcode.combat.fight.effect.FightEffectService;
|
||||
import com.eternalcode.combat.fight.logout.LogoutController;
|
||||
import com.eternalcode.combat.fight.logout.LogoutService;
|
||||
import com.eternalcode.combat.fight.pearl.FightPearlController;
|
||||
import com.eternalcode.combat.fight.pearl.FightPearlManager;
|
||||
import com.eternalcode.combat.fight.tagout.FightTagOutController;
|
||||
@@ -33,7 +32,8 @@ import com.eternalcode.combat.region.RegionController;
|
||||
import com.eternalcode.combat.region.RegionProvider;
|
||||
import com.eternalcode.combat.updater.UpdaterNotificationController;
|
||||
import com.eternalcode.combat.updater.UpdaterService;
|
||||
import com.eternalcode.combat.util.legacy.LegacyColorProcessor;
|
||||
import com.eternalcode.commons.adventure.AdventureLegacyColorPostProcessor;
|
||||
import com.eternalcode.commons.adventure.AdventureLegacyColorPreProcessor;
|
||||
import com.google.common.base.Stopwatch;
|
||||
import dev.rollczi.litecommands.LiteCommands;
|
||||
import dev.rollczi.litecommands.bukkit.adventure.platform.LiteBukkitAdventurePlatformFactory;
|
||||
@@ -54,12 +54,19 @@ import java.util.stream.Stream;
|
||||
|
||||
public final class CombatPlugin extends JavaPlugin implements EternalCombatApi {
|
||||
|
||||
private static final String FALLBACK_PREFIX = "eternalcombat";
|
||||
private static final int BSTATS_METRICS_ID = 17803;
|
||||
|
||||
private FightManager fightManager;
|
||||
private FightPearlManager fightPearlManager;
|
||||
private FightTagOutService fightTagOutService;
|
||||
private FightEffectService fightEffectService;
|
||||
|
||||
private LogoutService logoutService;
|
||||
|
||||
private DropManager dropManager;
|
||||
private DropKeepInventoryManager dropKeepInventoryManager;
|
||||
|
||||
private RegionProvider regionProvider;
|
||||
|
||||
private PluginConfig pluginConfig;
|
||||
@@ -74,8 +81,7 @@ public final class CombatPlugin extends JavaPlugin implements EternalCombatApi {
|
||||
|
||||
File dataFolder = this.getDataFolder();
|
||||
|
||||
ConfigBackupService backupService = new ConfigBackupService(dataFolder);
|
||||
ConfigService configService = new ConfigService(backupService);
|
||||
ConfigService configService = new ConfigService();
|
||||
|
||||
EventCaller eventCaller = new EventCaller(server);
|
||||
|
||||
@@ -85,6 +91,7 @@ public final class CombatPlugin extends JavaPlugin implements EternalCombatApi {
|
||||
this.fightPearlManager = new FightPearlManager(this.pluginConfig.pearl);
|
||||
this.fightTagOutService = new FightTagOutService();
|
||||
this.fightEffectService = new FightEffectService();
|
||||
this.logoutService = new LogoutService();
|
||||
this.dropManager = new DropManager();
|
||||
this.dropKeepInventoryManager = new DropKeepInventoryManager();
|
||||
|
||||
@@ -92,7 +99,8 @@ public final class CombatPlugin extends JavaPlugin implements EternalCombatApi {
|
||||
|
||||
this.audienceProvider = BukkitAudiences.create(this);
|
||||
MiniMessage miniMessage = MiniMessage.builder()
|
||||
.postProcessor(new LegacyColorProcessor())
|
||||
.postProcessor(new AdventureLegacyColorPostProcessor())
|
||||
.preProcessor(new AdventureLegacyColorPreProcessor())
|
||||
.build();
|
||||
|
||||
FightBossBarService fightBossBarService = new FightBossBarService(this.pluginConfig, this.audienceProvider, miniMessage);
|
||||
@@ -103,7 +111,7 @@ public final class CombatPlugin extends JavaPlugin implements EternalCombatApi {
|
||||
|
||||
NotificationAnnouncer notificationAnnouncer = new NotificationAnnouncer(this.audienceProvider, miniMessage);
|
||||
|
||||
this.liteCommands = LiteBukkitAdventurePlatformFactory.builder(server, "eternalcombat", this.audienceProvider)
|
||||
this.liteCommands = LiteBukkitAdventurePlatformFactory.builder(server, FALLBACK_PREFIX, this.audienceProvider)
|
||||
.argument(Player.class, new BukkitPlayerArgument<>(this.getServer(), this.pluginConfig.messages.playerNotFound))
|
||||
.contextualBind(Player.class, new BukkitOnlyPlayerContextual<>(this.pluginConfig.messages.admin.onlyForPlayers))
|
||||
|
||||
@@ -118,19 +126,18 @@ public final class CombatPlugin extends JavaPlugin implements EternalCombatApi {
|
||||
FightTask fightTask = new FightTask(server, this.pluginConfig, this.fightManager, fightBossBarService, notificationAnnouncer);
|
||||
this.getServer().getScheduler().runTaskTimer(this, fightTask, 20L, 20L);
|
||||
|
||||
new Metrics(this, 17803);
|
||||
new Metrics(this, BSTATS_METRICS_ID);
|
||||
|
||||
Stream.of(
|
||||
new PercentDropModifier(this.pluginConfig.dropSettings),
|
||||
new PlayersHealthDropModifier(this.pluginConfig.dropSettings)
|
||||
new PlayersHealthDropModifier(this.pluginConfig.dropSettings, this.logoutService)
|
||||
).forEach(this.dropManager::registerModifier);
|
||||
|
||||
Stream.of(
|
||||
new FightDeathCauseController(this.fightManager),
|
||||
new DropController(this.dropManager, this.dropKeepInventoryManager, this.pluginConfig.dropSettings, this.fightManager),
|
||||
new FightTagController(this.fightManager, this.pluginConfig, notificationAnnouncer),
|
||||
new FightUnTagController(this.fightManager, this.pluginConfig),
|
||||
new FightEscapeController(this.fightManager, this.pluginConfig, notificationAnnouncer),
|
||||
new FightTagController(this.fightManager, this.pluginConfig),
|
||||
new LogoutController(this.fightManager, this.logoutService, notificationAnnouncer, this.pluginConfig),
|
||||
new FightUnTagController(this.fightManager, this.pluginConfig, this.logoutService),
|
||||
new FightActionBlockerController(this.fightManager, notificationAnnouncer, this.pluginConfig),
|
||||
new FightPearlController(this.pluginConfig.pearl, notificationAnnouncer, this.fightManager, this.fightPearlManager),
|
||||
new UpdaterNotificationController(updaterService, this.pluginConfig, this.audienceProvider, miniMessage),
|
||||
|
||||
Vendored
BIN
Binary file not shown.
+1
-1
@@ -1,6 +1,6 @@
|
||||
distributionBase=GRADLE_USER_HOME
|
||||
distributionPath=wrapper/dists
|
||||
distributionUrl=https\://services.gradle.org/distributions/gradle-8.3-bin.zip
|
||||
distributionUrl=https\://services.gradle.org/distributions/gradle-8.8-bin.zip
|
||||
networkTimeout=10000
|
||||
validateDistributionUrl=true
|
||||
zipStoreBase=GRADLE_USER_HOME
|
||||
|
||||
@@ -55,7 +55,7 @@
|
||||
# Darwin, MinGW, and NonStop.
|
||||
#
|
||||
# (3) This script is generated from the Groovy template
|
||||
# https://github.com/gradle/gradle/blob/HEAD/subprojects/plugins/src/main/resources/org/gradle/api/internal/plugins/unixStartScript.txt
|
||||
# https://github.com/gradle/gradle/blob/HEAD/platforms/jvm/plugins-application/src/main/resources/org/gradle/api/internal/plugins/unixStartScript.txt
|
||||
# within the Gradle project.
|
||||
#
|
||||
# You can find Gradle at https://github.com/gradle/gradle/.
|
||||
@@ -145,7 +145,7 @@ if ! "$cygwin" && ! "$darwin" && ! "$nonstop" ; then
|
||||
case $MAX_FD in #(
|
||||
max*)
|
||||
# In POSIX sh, ulimit -H is undefined. That's why the result is checked to see if it worked.
|
||||
# shellcheck disable=SC3045
|
||||
# shellcheck disable=SC2039,SC3045
|
||||
MAX_FD=$( ulimit -H -n ) ||
|
||||
warn "Could not query maximum file descriptor limit"
|
||||
esac
|
||||
@@ -153,7 +153,7 @@ if ! "$cygwin" && ! "$darwin" && ! "$nonstop" ; then
|
||||
'' | soft) :;; #(
|
||||
*)
|
||||
# In POSIX sh, ulimit -n is undefined. That's why the result is checked to see if it worked.
|
||||
# shellcheck disable=SC3045
|
||||
# shellcheck disable=SC2039,SC3045
|
||||
ulimit -n "$MAX_FD" ||
|
||||
warn "Could not set maximum file descriptor limit to $MAX_FD"
|
||||
esac
|
||||
@@ -202,11 +202,11 @@ fi
|
||||
# Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script.
|
||||
DEFAULT_JVM_OPTS='"-Xmx64m" "-Xms64m"'
|
||||
|
||||
# Collect all arguments for the java command;
|
||||
# * $DEFAULT_JVM_OPTS, $JAVA_OPTS, and $GRADLE_OPTS can contain fragments of
|
||||
# shell script including quotes and variable substitutions, so put them in
|
||||
# double quotes to make sure that they get re-expanded; and
|
||||
# * put everything else in single quotes, so that it's not re-expanded.
|
||||
# Collect all arguments for the java command:
|
||||
# * DEFAULT_JVM_OPTS, JAVA_OPTS, JAVA_OPTS, and optsEnvironmentVar are not allowed to contain shell fragments,
|
||||
# and any embedded shellness will be escaped.
|
||||
# * For example: A user cannot expect ${Hostname} to be expanded, as it is an environment variable and will be
|
||||
# treated as '${Hostname}' itself on the command line.
|
||||
|
||||
set -- \
|
||||
"-Dorg.gradle.appname=$APP_BASE_NAME" \
|
||||
|
||||
Vendored
+10
-10
@@ -43,11 +43,11 @@ set JAVA_EXE=java.exe
|
||||
%JAVA_EXE% -version >NUL 2>&1
|
||||
if %ERRORLEVEL% equ 0 goto execute
|
||||
|
||||
echo.
|
||||
echo ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH.
|
||||
echo.
|
||||
echo Please set the JAVA_HOME variable in your environment to match the
|
||||
echo location of your Java installation.
|
||||
echo. 1>&2
|
||||
echo ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH. 1>&2
|
||||
echo. 1>&2
|
||||
echo Please set the JAVA_HOME variable in your environment to match the 1>&2
|
||||
echo location of your Java installation. 1>&2
|
||||
|
||||
goto fail
|
||||
|
||||
@@ -57,11 +57,11 @@ set JAVA_EXE=%JAVA_HOME%/bin/java.exe
|
||||
|
||||
if exist "%JAVA_EXE%" goto execute
|
||||
|
||||
echo.
|
||||
echo ERROR: JAVA_HOME is set to an invalid directory: %JAVA_HOME%
|
||||
echo.
|
||||
echo Please set the JAVA_HOME variable in your environment to match the
|
||||
echo location of your Java installation.
|
||||
echo. 1>&2
|
||||
echo ERROR: JAVA_HOME is set to an invalid directory: %JAVA_HOME% 1>&2
|
||||
echo. 1>&2
|
||||
echo Please set the JAVA_HOME variable in your environment to match the 1>&2
|
||||
echo location of your Java installation. 1>&2
|
||||
|
||||
goto fail
|
||||
|
||||
|
||||
+10
-2
@@ -15,7 +15,15 @@
|
||||
"matchPackagePatterns": [
|
||||
"*"
|
||||
]
|
||||
},
|
||||
{
|
||||
"groupName": "spigot dependencies",
|
||||
"groupSlug": "spigotmc",
|
||||
"matchPackagePatterns": [
|
||||
"org.spigotmc*"
|
||||
]
|
||||
}
|
||||
],
|
||||
"separateMajorMinor": false
|
||||
}
|
||||
"separateMajorMinor": true,
|
||||
"pruneStaleBranches": true
|
||||
}
|
||||
Reference in new issue
Block a user