Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions .github/workflows/gradle.yml
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ jobs:
java-version: '17'
distribution: 'temurin'
- name: Cache Gradle
uses: actions/cache@v4.0.2
uses: actions/cache@v4
with:
path: ~/.gradle/caches
key: >-
Expand All @@ -36,7 +36,7 @@ jobs:
with:
arguments: shadowJar
- name: Upload a Build Artifact
uses: actions/upload-artifact@v4.3.6
uses: actions/upload-artifact@v4
with:
name: 'Successfully build EternalCombat'
path: eternalcombat-plugin/build/libs/*.jar
2 changes: 2 additions & 0 deletions buildSrc/src/main/kotlin/Versions.kt
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ object Versions {

const val ETERNALCODE_COMMONS = "1.1.3"
const val MULTIFICATION = "1.1.4"
const val PACKETS_EVENTS = "2.7.0"

const val ADVENTURE_PLATFORM_BUKKIT = "4.3.4"
const val ADVENTURE_API = "4.17.0"
Expand All @@ -29,6 +30,7 @@ object Versions {
const val WORLD_GUARD_BUKKIT = "7.0.9"

const val PLACEHOLDER_API = "2.11.6"
const val PAPERLIB = "1.0.8"

}

Expand Down
21 changes: 0 additions & 21 deletions buildSrc/src/main/kotlin/eternalcombat-java.gradle.kts
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
plugins {
`java-library`
checkstyle
}

group = "com.eternalcode"
Expand All @@ -11,26 +10,6 @@ java {
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.compilerArgs = listOf("-Xlint:deprecation", "-parameters")
options.encoding = "UTF-8"
Expand Down
15 changes: 8 additions & 7 deletions buildSrc/src/main/kotlin/eternalcombat-repositories.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -5,11 +5,12 @@ plugins {
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/") }
maven { url = uri("https://repo.extendedclip.com/content/repositories/placeholderapi/")}
maven("https://hub.spigotmc.org/nexus/content/repositories/snapshots/")
maven("https://papermc.io/repo/repository/maven-public/")
maven("https://repo.eternalcode.pl/releases")
maven("https://storehouse.okaeri.eu/repository/maven-public/")
maven("https://repo.panda-lang.org/releases")
maven("https://maven.enginehub.org/repo/")
maven("https://repo.extendedclip.com/content/repositories/placeholderapi/")
maven("https://repo.codemc.io/repository/maven-releases/")
}
Original file line number Diff line number Diff line change
Expand Up @@ -6,4 +6,20 @@ public interface Region {

Location getCenter();

Location getMin();

Location getMax();

default boolean contains(Location location) {
return this.contains(location.getX(), location.getY(), location.getZ());
}

default boolean contains(double x, double y, double z) {
Location min = this.getMin();
Location max = this.getMax();
return x >= min.getX() && x < max.getX()
&& y >= min.getY() && y < max.getY()
&& z >= min.getZ() && z < max.getZ();
}

}
Original file line number Diff line number Diff line change
@@ -1,7 +1,9 @@
package com.eternalcode.combat.region;

import java.util.Collection;
import java.util.Optional;
import org.bukkit.Location;
import org.bukkit.World;

public interface RegionProvider {

Expand All @@ -11,4 +13,6 @@ default boolean isInRegion(Location location) {
return this.getRegion(location).isPresent();
}

Collection<Region> getRegions(World world);

}
6 changes: 3 additions & 3 deletions eternalcombat-plugin/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,8 @@ dependencies {
// Multification
implementation("com.eternalcode:multification-bukkit:${Versions.MULTIFICATION}")
implementation("com.eternalcode:multification-okaeri:${Versions.MULTIFICATION}")
implementation("com.github.retrooper:packetevents-spigot:${Versions.PACKETS_EVENTS}")
implementation("io.papermc:paperlib:${Versions.PAPERLIB}")
}

bukkit {
Expand All @@ -68,15 +70,13 @@ bukkit {

tasks {
runServer {
minecraftVersion("1.21.1")
minecraftVersion("1.21.4")
}
}

tasks.shadowJar {
archiveFileName.set("EternalCombat v${project.version}.jar")

dependsOn("checkstyleMain")
dependsOn("checkstyleTest")
dependsOn("test")

exclude(
Expand Down
Original file line number Diff line number Diff line change
@@ -1,10 +1,16 @@
package com.eternalcode.combat;

import com.eternalcode.combat.border.BorderTriggerController;
import com.eternalcode.combat.border.BorderService;
import com.eternalcode.combat.border.BorderServiceImpl;
import com.eternalcode.combat.border.animation.block.BorderBlockController;
import com.eternalcode.combat.border.animation.particle.ParticleController;
import com.eternalcode.combat.bridge.BridgeService;
import com.eternalcode.combat.fight.drop.DropKeepInventoryService;
import com.eternalcode.combat.fight.FightManager;
import com.eternalcode.combat.fight.drop.DropService;
import com.eternalcode.combat.fight.effect.FightEffectService;
import com.eternalcode.combat.fight.knockback.KnockbackService;
import com.eternalcode.combat.fight.tagout.FightTagOutService;
import com.eternalcode.combat.fight.pearl.FightPearlService;
import com.eternalcode.combat.handler.InvalidUsageHandlerImpl;
Expand Down Expand Up @@ -34,17 +40,21 @@
import com.eternalcode.combat.fight.tagout.FightTagOutServiceImpl;
import com.eternalcode.combat.fight.tagout.FightTagOutCommand;
import com.eternalcode.combat.notification.NotificationAnnouncer;
import com.eternalcode.combat.region.RegionController;
import com.eternalcode.combat.fight.knockback.KnockbackRegionController;
import com.eternalcode.combat.region.RegionProvider;
import com.eternalcode.combat.updater.UpdaterNotificationController;
import com.eternalcode.combat.updater.UpdaterService;
import com.eternalcode.commons.adventure.AdventureLegacyColorPostProcessor;
import com.eternalcode.commons.adventure.AdventureLegacyColorPreProcessor;
import com.eternalcode.commons.bukkit.scheduler.BukkitSchedulerImpl;
import com.eternalcode.commons.scheduler.Scheduler;
import com.eternalcode.multification.notice.Notice;
import com.github.retrooper.packetevents.PacketEvents;
import com.google.common.base.Stopwatch;
import dev.rollczi.litecommands.LiteCommands;
import dev.rollczi.litecommands.bukkit.LiteBukkitFactory;
import dev.rollczi.litecommands.bukkit.LiteBukkitMessages;
import io.github.retrooper.packetevents.factory.spigot.SpigotPacketEventsBuilder;
import net.kyori.adventure.platform.AudienceProvider;
import net.kyori.adventure.platform.bukkit.BukkitAudiences;
import net.kyori.adventure.text.minimessage.MiniMessage;
Expand Down Expand Up @@ -79,6 +89,12 @@ public final class CombatPlugin extends JavaPlugin implements EternalCombatApi {
private AudienceProvider audienceProvider;
private LiteCommands<CommandSender> liteCommands;

@Override
public void onLoad() {
PacketEvents.setAPI(SpigotPacketEventsBuilder.build(this));
PacketEvents.getAPI().load();
}

@Override
public void onEnable() {
Stopwatch started = Stopwatch.createStarted();
Expand All @@ -89,6 +105,7 @@ public void onEnable() {
ConfigService configService = new ConfigService();

EventCaller eventCaller = new EventCaller(server);
Scheduler scheduler = new BukkitSchedulerImpl(this);

this.pluginConfig = configService.create(PluginConfig.class, new File(dataFolder, "config.yml"));

Expand All @@ -111,7 +128,8 @@ public void onEnable() {
BridgeService bridgeService = new BridgeService(this.pluginConfig, server.getPluginManager(), this.getLogger(), this);
bridgeService.init(this.fightManager, server);
this.regionProvider = bridgeService.getRegionProvider();

BorderService borderService = new BorderServiceImpl(scheduler, server, regionProvider, eventCaller, pluginConfig.border);
KnockbackService knockbackService = new KnockbackService(this.pluginConfig, scheduler);

NotificationAnnouncer notificationAnnouncer = new NotificationAnnouncer(this.audienceProvider, this.pluginConfig, miniMessage);

Expand Down Expand Up @@ -141,23 +159,26 @@ public void onEnable() {
new Metrics(this, BSTATS_METRICS_ID);

Stream.of(
new PercentDropModifier(this.pluginConfig.dropSettings),
new PlayersHealthDropModifier(this.pluginConfig.dropSettings, this.logoutService)
new PercentDropModifier(this.pluginConfig.drop),
new PlayersHealthDropModifier(this.pluginConfig.drop, this.logoutService)
).forEach(this.dropService::registerModifier);


Stream.of(
new DropController(this.dropService, this.dropKeepInventoryService, this.pluginConfig.dropSettings, this.fightManager),
new DropController(this.dropService, this.dropKeepInventoryService, this.pluginConfig.drop, this.fightManager),
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, server),
new FightPearlController(this.pluginConfig.pearl, notificationAnnouncer, this.fightManager, this.fightPearlService),
new UpdaterNotificationController(updaterService, this.pluginConfig, this.audienceProvider, miniMessage),
new RegionController(notificationAnnouncer, this.regionProvider, this.fightManager, this.pluginConfig),
new KnockbackRegionController(notificationAnnouncer, this.regionProvider, this.fightManager, knockbackService, server),
new FightEffectController(this.pluginConfig.effect, this.fightEffectService, this.fightManager, this.getServer()),
new FightTagOutController(this.fightTagOutService),
new FightMessageController(this.fightManager, notificationAnnouncer, this.pluginConfig, this.getServer())
new FightMessageController(this.fightManager, notificationAnnouncer, this.pluginConfig, this.getServer()),
new BorderTriggerController(borderService, pluginConfig.border, fightManager, server),
new ParticleController(borderService, pluginConfig.border.particle, scheduler, server),
new BorderBlockController(borderService, pluginConfig.border.block, scheduler, server)
).forEach(listener -> this.getServer().getPluginManager().registerEvents(listener, this));

EternalCombatProvider.initialize(this);
Expand All @@ -179,6 +200,8 @@ public void onDisable() {
}

this.fightManager.untagAll();

PacketEvents.getAPI().terminate();
}

@Override
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,66 @@
package com.eternalcode.combat.border;

import java.util.Collections;
import java.util.HashSet;
import java.util.Map;
import java.util.Set;
import java.util.UUID;
import java.util.concurrent.ConcurrentHashMap;

class BorderActivePointsIndex {

private final Map<String, Map<UUID, Set<BorderPoint>>> registry = new ConcurrentHashMap<>();

boolean hasPoints(String world, UUID player) {
Map<UUID, Set<BorderPoint>> worldRegistry = this.registry.get(world);
if (worldRegistry == null) {
return false;
}

return worldRegistry.containsKey(player);
}

Set<BorderPoint> putPoints(String world, UUID player, Set<BorderPoint> points) {
Map<UUID, Set<BorderPoint>> worldRegistry = this.registry.computeIfAbsent(world, k -> new ConcurrentHashMap<>());
Set<BorderPoint> oldPoints = worldRegistry.put(player, points);
if (oldPoints != null) {
return calculateRemovedPoints(points, oldPoints);
}

return Set.of();
}

private static Set<BorderPoint> calculateRemovedPoints(Set<BorderPoint> points, Set<BorderPoint> oldPoints) {
Set<BorderPoint> removed = new HashSet<>();
for (BorderPoint oldPoint : oldPoints) {
if (!points.contains(oldPoint)) {
removed.add(oldPoint);
}
}
return Collections.unmodifiableSet(removed);
}

Set<BorderPoint> getPoints(String world, UUID player) {
Map<UUID, Set<BorderPoint>> worldRegistry = this.registry.get(world);
if (worldRegistry == null) {
return Set.of();
}

return worldRegistry.getOrDefault(player, Set.of());
}

Set<BorderPoint> removePoints(String world, UUID player) {
Map<UUID, Set<BorderPoint>> worldRegistry = this.registry.get(world);
if (worldRegistry == null) {
return Set.of();
}

Set<BorderPoint> remove = worldRegistry.remove(player);
if (remove == null) {
return Set.of();
}

return remove;
}

}
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
package com.eternalcode.combat.border;

import dev.rollczi.litecommands.shared.Lazy;
import java.util.ArrayList;
import java.util.List;
import java.util.Set;
import java.util.stream.Collectors;

class BorderLazyResult implements BorderResult {

private final List<Lazy<List<BorderPoint>>> borderPoints = new ArrayList<>();

void addLazyBorderPoints(Lazy<List<BorderPoint>> supplier) {
borderPoints.add(supplier);
}

@Override
public Set<BorderPoint> collect() {
return borderPoints.stream()
.flatMap(result -> result.get().stream())
.collect(Collectors.toUnmodifiableSet());
}

}
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
package com.eternalcode.combat.border;

import org.jetbrains.annotations.Nullable;

public record BorderPoint(int x, int y, int z, @Nullable BorderPoint inclusive) {

public BorderPoint(int x, int y, int z) {
this(x, y, z, null);
}

public BorderPoint toInclusive() {
if (inclusive == null) {
return this;
}

return inclusive;
}

}
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
package com.eternalcode.combat.border;

import java.util.Set;

public interface BorderResult {

Set<BorderPoint> collect();

}
Loading
Loading