Skip to content

Commit

Permalink
v1.16.20.3
Browse files Browse the repository at this point in the history
  • Loading branch information
CryptoMorin committed Jan 17, 2024
1 parent 3458d13 commit 5d5566c
Show file tree
Hide file tree
Showing 97 changed files with 844 additions and 355 deletions.
3 changes: 2 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,8 @@ Kingdomsx is heavily optimized and easy to use.
### Links:

- [SpigotMC](https://www.spigotmc.org/resources/77670/): The first original page of KingdomsX plugin.
- [Modrinth](https://modrinth.com/plugin/kingdomsx/): The official modrinth page of KingdomsX plugin. It's easier to keep track of plugin versions for people who still wish to use outdated server patches here.
- [Modrinth](https://modrinth.com/plugin/kingdomsx/): The official modrinth page of KingdomsX plugin. It's easier to
keep track of plugin versions for people who still wish to use outdated server patches here.
- [Discord](https://discord.gg/cKsSwtt): Official Kingdoms Discord server. Ask questions, suggest features and report
bugs.
- [Wiki](https://github.com/CryptoMorin/KingdomsX/wiki): Learn how Kingdoms works.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ class ServiceProjectKorra(val handler: (player: Player, location: Location) -> B
location: Location,
ability: CoreAbility?,
isIgnite: Boolean,
isExplosive: Boolean
isExplosive: Boolean,
): Boolean {
// https://github.com/ProjectKorra/ProjectKorra/blob/3ee5c834f96d860be1792b38b2ded2d140dd62bf/src/com/projectkorra/projectkorra/region/Kingdoms.java
return handler(player, location)
Expand Down
6 changes: 2 additions & 4 deletions core/service/src/main/java/org/kingdoms/services/Service.java
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,7 @@ default boolean isAvailable() {
return true;
}

default void enable() {
}
default void enable() {}

default void disable() {
}
default void disable() {}
}
5 changes: 3 additions & 2 deletions core/src/main/resources/map.yml
Original file line number Diff line number Diff line change
Expand Up @@ -64,11 +64,12 @@ elements:
action: "/k claim clipboard remove %X% %Z%"
hover:
- "&6Location&8: &2%X%&7, &2%Z%"
- ""
- "&7Failed to claim this land."
- "It's not necessary to remove it"
- "from the clipboard."
- "&cReason&8: &e"
- "%reason%"
- ""
- "&c%reason%"
item:
material: RED_WOOL
wilderness:
Expand Down
2 changes: 1 addition & 1 deletion core/src/main/resources/misc-upgrades.yml
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ invasion-teleportation:
# Makes "invasions" upgrade to be a requirement to be maxxed to upgrade this upgrade.
# The "miscupgrades.required.invasions" refers to a custom language entry inside your language files. (e.g. en.yml)
# %kingdoms_kingdom_upgrade% is a functional placeholder: https://github.com/CryptoMorin/KingdomsX/wiki/Placeholders#placeholder-functions
#"{kingdoms_kingdom_upgrade:level type=misc, of=INVASIONS} < 5": "miscupgrades.required.invasions"
#"{kingdoms_kingdom_upgrade:level type=misc, of=INVASIONS} < 5": "miscupgrades.required.invasions"

# If anti-explosion upgrade is upgraded, you won't be able to upgrade this and any other upgrade that depends on this.
# You could block anti-explosion from being upgraded if this option is upgraded by doing the same thing.
Expand Down
1 change: 1 addition & 0 deletions core/src/main/resources/schemas/claims.yml
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ biomes:

claim-on-create:
(type): int
(min): -1
(max): 100
starter-free: int
confirmation: str
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -116,7 +116,7 @@ class PeaceTreaties {
fun <T> initializeMeta(
kingdom: Kingdom,
metadataHandler: KingdomMetadataHandler,
default: Supplier<KingdomMetadata>
default: Supplier<KingdomMetadata>,
): T {
var metadata: KingdomMetadata? = kingdom.metadata[metadataHandler]
if (metadata == null) {
Expand Down Expand Up @@ -166,7 +166,7 @@ class PeaceTreatyReceiverMetaHandler private constructor() :
@Suppress("LABEL_NAME_CLASH")
override fun deserialize(
container: KingdomsObject<*>,
context: DeserializationContext<SectionableDataGetter>
context: DeserializationContext<SectionableDataGetter>,
): KingdomMetadata {
return PeaceTreatyReceiverMeta(context.dataProvider.asMap(hashMapOf()) { map, key, value ->
val proposerID = key.asUUID()
Expand Down Expand Up @@ -206,7 +206,7 @@ class PeaceTreatyProposerMetaHandler private constructor() :
KingdomMetadataHandler(Namespace("PeaceTreaties", "PROPOSED")) {
override fun deserialize(
container: KingdomsObject<*>,
context: DeserializationContext<SectionableDataGetter>
context: DeserializationContext<SectionableDataGetter>,
): PeaceTreatyProposedMeta {
return PeaceTreatyProposedMeta(context.dataProvider.asCollection(hashSetOf()) { c, x -> c.add(x.asUUID()!!) })
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,7 @@ class WarPoint {
class WarPointsMetaHandler private constructor() : KingdomMetadataHandler(Namespace("PeaceTreaties", "WAR_POINTS")) {
override fun deserialize(
container: KingdomsObject<*>,
context: DeserializationContext<SectionableDataGetter>
context: DeserializationContext<SectionableDataGetter>,
): KingdomMetadata {
return WarPointsMeta(context.dataProvider.asMap(hashMapOf()) { map, key, value ->
map[key.asUUID()!!] = value.asDouble()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ open class StandardTermProvider(
@JvmStatic
fun standardAmountPrompt(
provider: TermProvider, options: TermGroupingOptions, editor: StandardPeaceTreatyEditor,
handler: (Number) -> Term?
handler: (Number) -> Term?,
): CompletionStage<Term> {
val config = options.getConfigOf(provider)
val ctx = editor.peaceTreaty.placeholderContextProvider
Expand Down
5 changes: 2 additions & 3 deletions platform/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -3,12 +3,11 @@ import org.kingdoms.main.KingdomsGradleCommons.relocateLibs

plugins {
commons
kotlin
shadowed
}

group "org.kingdoms.platform"
version "unspecified"
group = "org.kingdoms.platform"
version = "unspecified"

tasks.shadowJar {
excludeKotlin()
Expand Down
2 changes: 0 additions & 2 deletions platform/bukkit/build.gradle.kts
Original file line number Diff line number Diff line change
@@ -1,6 +1,4 @@
plugins {
java
kotlin
commons
spigot
}
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
package org.kingdoms.platform.bukkit.core;

import org.kingdoms.platform.bukkit.events.BukkitEventHandler;
import org.kingdoms.server.core.Server;
import org.kingdoms.server.events.EventHandler;

public class BukkitServer implements Server {
private final EventHandler eventHandler;

public BukkitServer() {
this.eventHandler = new BukkitEventHandler();
}

@Override
public EventHandler getEventHandler() {
return eventHandler;
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
package org.kingdoms.platform.bukkit.events;

import org.bukkit.Bukkit;
import org.bukkit.event.Event;
import org.kingdoms.server.events.EventHandler;

public final class BukkitEventHandler implements EventHandler {
@Override
public void callEvent(Object event) {
Bukkit.getPluginManager().callEvent((Event) event);
}
}
1 change: 0 additions & 1 deletion platform/folia/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@ import org.kingdoms.main.KingdomsGradleCommons.relocateLibs

plugins {
commons
kotlin
shadowed
}

Expand Down
25 changes: 25 additions & 0 deletions platform/geyser/build.gradle.kts
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
plugins {
commons
sublibs
}

group = "org.kingdoms.platform.geyser"
version = "unspecified"

repositories {
// https://github.com/GeyserMC/Cumulus
// https://wiki.geysermc.org/geyser/using-geyser-or-floodgate-as-a-dependency/
maven {
name = "opencollab-snapshot"
url = uri("https://repo.opencollab.dev/maven-snapshots/")
}
}

dependencies {
compileOnly(project(":shared"))

// Idk this gives an error
// compileOnly("org.geysermc.geyser:api:2.1.0-SNAPSHOT")
// https://wiki.geysermc.org/floodgate/api/
compileOnly("org.geysermc.floodgate:api:2.2.0-SNAPSHOT")
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
package org.kingdoms.platform.geyser.core;

import org.geysermc.floodgate.api.FloodgateApi;

import java.util.UUID;

public final class FloodgateHandler {
public static boolean isFloodgatePlayer(UUID player) {
return FloodgateApi.getInstance().isFloodgatePlayer(player);
}
}
33 changes: 33 additions & 0 deletions platform/paper/build.gradle.kts
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
plugins {
java
kotlin
sublibs
}

group = "org.kingdoms.utils.paper"
description = "Used for defining unique optimization techniques from Paper."
version = "1.0.0"

repositories {
maven {
url = uri("https://repo.papermc.io/repository/maven-public/")
}
}

dependencies {
// https://papermc.io/using-the-api#gradle
compileOnly("io.papermc.paper:paper-api:1.19.4-R0.1-SNAPSHOT")
}

// Paper is compiled with the latest LTS, so we "trick" gradle into using the latest Java version,
// but we compile with Java 8
java {
toolchain {
languageVersion.set(JavaLanguageVersion.of(17))
}
disableAutoTargetJvm()
}
tasks.compileJava {
options.encoding = Charsets.UTF_8.name()
options.release.set(8)
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
package org.kingdoms.utils.paper;

import org.kingdoms.utils.paper.asyncchunks.AsyncChunks;

import java.util.function.Function;

public final class PaperLib {
private static AsyncChunks asyncChunks;

public static void init(Function<Integer, Boolean> versionChecker) {
asyncChunks = AsyncChunks.generateInstance(versionChecker);
}

public static AsyncChunks getAsyncChunks() {
return asyncChunks;
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
package org.kingdoms.utils.paper.asyncchunks;

import org.bukkit.Chunk;
import org.bukkit.World;

import java.util.concurrent.CompletableFuture;
import java.util.function.Function;

public abstract class AsyncChunks {
public static AsyncChunks generateInstance(Function<Integer, Boolean> versionChecker) {
if (versionChecker.apply(15)) {
return new AsyncChunksPaper_15();
} else if (versionChecker.apply(13)) {
return new AsyncChunksPaper_13();
} else if (versionChecker.apply(9) && !versionChecker.apply(13)) {
return new AsyncChunksPaper_9_12();
} else {
//noinspection StaticInitializerReferencesSubClass
return new AsyncChunksSync();
}
}

public final CompletableFuture<Chunk> getChunkAtAsync(World world, int x, int z) {
return getChunkAtAsync(world, x, z, true, false);
}

public final CompletableFuture<Chunk> getChunkAtAsync(World world, int x, int z, boolean generate) {
return getChunkAtAsync(world, x, z, generate, false);
}

public abstract CompletableFuture<Chunk> getChunkAtAsync(World world, int x, int z, boolean generate, boolean isUrgent);
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
package org.kingdoms.utils.paper.asyncchunks;

import org.bukkit.Chunk;
import org.bukkit.World;

import java.util.concurrent.CompletableFuture;

final class AsyncChunksPaper_13 extends AsyncChunks {
@Override
public CompletableFuture<Chunk> getChunkAtAsync(World world, int x, int z, boolean gen, boolean isUrgent) {
return world.getChunkAtAsync(x, z, gen);
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
package org.kingdoms.utils.paper.asyncchunks;

import org.bukkit.Chunk;
import org.bukkit.World;

import java.util.concurrent.CompletableFuture;

final class AsyncChunksPaper_15 extends AsyncChunks {
@Override
public CompletableFuture<Chunk> getChunkAtAsync(World world, int x, int z, boolean gen, boolean isUrgent) {
return world.getChunkAtAsync(x, z, gen, isUrgent);
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
package org.kingdoms.utils.paper.asyncchunks;

import org.bukkit.Chunk;
import org.bukkit.World;

import java.util.concurrent.CompletableFuture;

/**
* Async Chunk Loading for Paper version 1.9 to 1.12
*/
final class AsyncChunksPaper_9_12 extends AsyncChunks {
private static final boolean SUPPORTS_IS_CHUNK_GENERATED;

static {
boolean isChunkGenerated = false;

try {
World.class.getMethod("isChunkGenerated", int.class, int.class);
isChunkGenerated = true;
} catch (NoSuchMethodException ignored) {
}

SUPPORTS_IS_CHUNK_GENERATED = isChunkGenerated;
}

@SuppressWarnings("deprecation")
@Override
public CompletableFuture<Chunk> getChunkAtAsync(World world, int x, int z, boolean gen, boolean isUrgent) {
CompletableFuture<Chunk> future = new CompletableFuture<>();
if (!gen && SUPPORTS_IS_CHUNK_GENERATED && !world.isChunkGenerated(x, z)) {
future.complete(null);
} else {
World.ChunkLoadCallback chunkLoadCallback = future::complete;
world.getChunkAtAsync(x, z, chunkLoadCallback);
}
return future;
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
package org.kingdoms.utils.paper.asyncchunks;

import org.bukkit.Chunk;
import org.bukkit.World;

import java.util.concurrent.CompletableFuture;

final class AsyncChunksSync extends AsyncChunks {
@Override
public CompletableFuture<Chunk> getChunkAtAsync(World world, int x, int z, boolean gen, boolean isUrgent) {
return CompletableFuture.completedFuture(world.getChunkAt(x, z));
}
}
Loading

0 comments on commit 5d5566c

Please sign in to comment.