mirror of
https://github.com/kaboomserver/extras.git
synced 2025-01-06 22:51:53 +00:00
Add more configuration options (#314)
* Add option to randomise spawn locations in config (closes #309)
* Add option to configure entity cap per chunk (closes #311)
* Suppress warnings for star imports
* Add missing return value & whitespace
* Explictly specify type of numbers in spawn randomization
* Upgrade to Java 11
* Make teleport centered
* Final configuration
* Remove star import
* Revert "Suppress warnings for star imports"
This reverts commit 2a2232b0da
.
* Let's try 17
This commit is contained in:
parent
3d1f8e5247
commit
23da0661b3
4 changed files with 29 additions and 4 deletions
2
.github/workflows/main.yml
vendored
2
.github/workflows/main.yml
vendored
|
@ -15,7 +15,7 @@ jobs:
|
|||
- uses: actions/setup-java@v2
|
||||
with:
|
||||
distribution: 'temurin'
|
||||
java-version: 8
|
||||
java-version: 18
|
||||
|
||||
- name: Cache maven packages to speed up build
|
||||
uses: actions/cache@v1
|
||||
|
|
4
pom.xml
4
pom.xml
|
@ -5,8 +5,8 @@
|
|||
<version>master</version>
|
||||
|
||||
<properties>
|
||||
<maven.compiler.source>1.8</maven.compiler.source>
|
||||
<maven.compiler.target>1.8</maven.compiler.target>
|
||||
<maven.compiler.source>11</maven.compiler.source>
|
||||
<maven.compiler.target>11</maven.compiler.target>
|
||||
<maven.test.skip>true</maven.test.skip>
|
||||
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
|
||||
</properties>
|
||||
|
|
|
@ -1,11 +1,15 @@
|
|||
package pw.kaboom.extras.modules.entity;
|
||||
|
||||
import java.security.SecureRandom;
|
||||
import java.util.Random;
|
||||
|
||||
import org.bukkit.Chunk;
|
||||
import org.bukkit.Location;
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.World;
|
||||
import org.bukkit.WorldBorder;
|
||||
import org.bukkit.block.CreatureSpawner;
|
||||
import org.bukkit.configuration.file.FileConfiguration;
|
||||
import org.bukkit.entity.AreaEffectCloud;
|
||||
import org.bukkit.entity.EnderDragon;
|
||||
import org.bukkit.entity.Entity;
|
||||
|
@ -29,8 +33,15 @@ import org.bukkit.event.weather.LightningStrikeEvent;
|
|||
import com.destroystokyo.paper.event.block.TNTPrimeEvent;
|
||||
import com.destroystokyo.paper.event.entity.PreCreatureSpawnEvent;
|
||||
import com.destroystokyo.paper.event.entity.PreSpawnerSpawnEvent;
|
||||
import org.bukkit.plugin.java.JavaPlugin;
|
||||
import org.spigotmc.event.player.PlayerSpawnLocationEvent;
|
||||
import pw.kaboom.extras.Main;
|
||||
|
||||
public final class EntitySpawn implements Listener {
|
||||
private static final Main PLUGIN = JavaPlugin.getPlugin(Main.class);
|
||||
private static final FileConfiguration CONFIG = PLUGIN.getConfig();
|
||||
private static final SecureRandom RANDOM = new SecureRandom();
|
||||
|
||||
private void applyEntityChanges(final Entity entity) {
|
||||
switch (entity.getType()) {
|
||||
case AREA_EFFECT_CLOUD:
|
||||
|
@ -85,7 +96,8 @@ public final class EntitySpawn implements Listener {
|
|||
default:
|
||||
if (!EntityType.PLAYER.equals(entityType)) {
|
||||
final int chunkEntityCount = chunk.getEntities().length;
|
||||
final int chunkEntityCountLimit = 30;
|
||||
final int chunkEntityCountLimit = CONFIG.getInt("maxEntitiesPerChunk");
|
||||
|
||||
if (chunkEntityCount >= chunkEntityCountLimit) {
|
||||
return true;
|
||||
}
|
||||
|
@ -168,6 +180,16 @@ public final class EntitySpawn implements Listener {
|
|||
}
|
||||
}
|
||||
|
||||
@EventHandler
|
||||
void onPlayerSpawn(final PlayerSpawnLocationEvent event) {
|
||||
final World world = event.getPlayer().getWorld();
|
||||
final WorldBorder worldBorder = world.getWorldBorder();
|
||||
|
||||
if (CONFIG.getBoolean("randomizeSpawn") && event.getPlayer().getBedSpawnLocation() != event.getSpawnLocation()) {
|
||||
event.setSpawnLocation(new Location(world, RANDOM.nextDouble(-300000000D, 30000000D) + .5, 100D, RANDOM.nextDouble(-300000000D, 30000000D) + .5));
|
||||
}
|
||||
}
|
||||
|
||||
@EventHandler
|
||||
void onEntitySpawn(final EntitySpawnEvent event) {
|
||||
final double x = event.getLocation().getX();
|
||||
|
|
|
@ -3,6 +3,9 @@ allowJoinOnFullServer: true
|
|||
enableKick: false
|
||||
enableJoinRestrictions: false
|
||||
opOnJoin: true
|
||||
randomizeSpawn: false
|
||||
# Set to -1 to disable
|
||||
maxEntitiesPerChunk: 30
|
||||
playerJoinTitle: "§7Welcome to Kaboom!"
|
||||
playerJoinSubtitle: "Free OP • Anarchy • Creative"
|
||||
opTag: "§4§l[§c§lOP§4§l] §c"
|
||||
|
|
Loading…
Reference in a new issue