Skip to content

Commit 7d30032

Browse files
authored
Add spawn per mobs flag/gamerule
Gamerule spawn mobs
2 parents 5242513 + 4894e80 commit 7d30032

File tree

51 files changed

+2371
-69
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

51 files changed

+2371
-69
lines changed

.idea/gradle.xml

Lines changed: 0 additions & 3 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

.idea/misc.xml

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

api/build.gradle.kts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ plugins {
66
group = "fr.euphyllia.skyllia"
77

88
dependencies {
9-
compileOnly("io.papermc.paper:paper-api:1.21.10-R0.1-SNAPSHOT")
9+
compileOnly("io.papermc.paper:paper-api:1.20.6-R0.1-SNAPSHOT")
1010
compileOnly(project(":database"))
1111
}
1212

api/src/main/java/fr/euphyllia/skyllia/api/SkylliaAPI.java

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@
1111
import fr.euphyllia.skyllia.api.skyblock.model.IslandSettings;
1212
import fr.euphyllia.skyllia.api.skyblock.model.Position;
1313
import fr.euphyllia.skyllia.api.utils.nms.BiomesImpl;
14+
import fr.euphyllia.skyllia.api.utils.nms.MobsSpawnImpl;
1415
import fr.euphyllia.skyllia.api.utils.nms.WorldNMS;
1516
import org.bukkit.Chunk;
1617
import org.bukkit.Location;
@@ -244,6 +245,11 @@ public static WorldNMS getWorldNMS() {
244245
return implementation.getWorldNMS();
245246
}
246247

248+
@ApiStatus.Internal
249+
public static MobsSpawnImpl getMobsSpawnImpl() {
250+
return implementation.getMobsSpawnImpl();
251+
}
252+
247253
/**
248254
* Retrieves the Permissions Manager.
249255
*

api/src/main/java/fr/euphyllia/skyllia/api/SkylliaImplementation.java

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@
1111
import fr.euphyllia.skyllia.api.skyblock.model.IslandSettings;
1212
import fr.euphyllia.skyllia.api.skyblock.model.Position;
1313
import fr.euphyllia.skyllia.api.utils.nms.BiomesImpl;
14+
import fr.euphyllia.skyllia.api.utils.nms.MobsSpawnImpl;
1415
import fr.euphyllia.skyllia.api.utils.nms.WorldNMS;
1516
import org.bukkit.Chunk;
1617
import org.bukkit.Location;
@@ -162,6 +163,12 @@ public interface SkylliaImplementation {
162163
@ApiStatus.Internal
163164
WorldNMS getWorldNMS();
164165

166+
/**
167+
* Do not use. Reserved for Skyllia internal NMS bridges.
168+
*/
169+
@ApiStatus.Internal
170+
MobsSpawnImpl getMobsSpawnImpl();
171+
165172
/**
166173
* Retrieves the Permissions Manager.
167174
*
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,10 @@
11
package fr.euphyllia.skyllia.api.commands;
22

33
import io.papermc.paper.command.brigadier.BasicCommand;
4+
import org.jetbrains.annotations.Nullable;
45

56
@SuppressWarnings("UnstableApiUsage")
67
public interface SkylliaCommandInterface extends BasicCommand {
8+
9+
@Nullable String permission();
710
}
Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
package fr.euphyllia.skyllia.api.utils.nms;
2+
3+
import org.bukkit.entity.EntityType;
4+
import org.bukkit.event.entity.CreatureSpawnEvent;
5+
6+
import java.util.Map;
7+
import java.util.Set;
8+
9+
public interface MobsSpawnImpl {
10+
11+
Set<CreatureSpawnEvent.SpawnReason> ignoredReasons();
12+
13+
Map<EntityType, String> supportedBossMobs();
14+
15+
Map<EntityType, String> supportedHostileAdjacentMobs();
16+
17+
Map<EntityType, String> supportedHostileMobs();
18+
19+
Map<EntityType, String> supportedNeutralMobs();
20+
21+
Map<EntityType, String> supportedOtherMobs();
22+
23+
Map<EntityType, String> supportedPassiveMobs();
24+
}

build.gradle.kts

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -30,9 +30,6 @@ dependencies {
3030
implementation(project(":hook:essentialsx"))
3131

3232
// NMS Version
33-
implementation(project(":nms:v1_20_R1"))
34-
implementation(project(":nms:v1_20_R2"))
35-
implementation(project(":nms:v1_20_R3"))
3633
implementation(project(":nms:v1_20_R4"))
3734
implementation(project(":nms:v1_21_R1"))
3835
implementation(project(":nms:v1_21_R2"))

diagram_skyllia.png

-1.56 MB
Loading
Lines changed: 162 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,162 @@
1+
package fr.euphyllia.skyllia.utils.nms.v1_20_R1;
2+
3+
import fr.euphyllia.skyllia.api.utils.nms.MobsSpawnImpl;
4+
import org.bukkit.entity.EntityType;
5+
import org.bukkit.event.entity.CreatureSpawnEvent;
6+
7+
import java.util.Map;
8+
import java.util.Set;
9+
10+
public class MobSpawnNMS implements MobsSpawnImpl {
11+
12+
private static final Set<CreatureSpawnEvent.SpawnReason> IGNORED_REASONS;
13+
private static final Map<EntityType, String> HOSTILE_MOBS;
14+
private static final Map<EntityType, String> BOSS_MOBS;
15+
private static final Map<EntityType, String> HOSTILE_ADJACENT_MOBS;
16+
private static final Map<EntityType, String> NEUTRAL_MOBS;
17+
private static final Map<EntityType, String> OTHER_MOBS;
18+
private static final Map<EntityType, String> PASSIVE_MOBS;
19+
20+
static {
21+
IGNORED_REASONS = Set.of(
22+
CreatureSpawnEvent.SpawnReason.SPAWNER,
23+
CreatureSpawnEvent.SpawnReason.SPAWNER_EGG,
24+
CreatureSpawnEvent.SpawnReason.CUSTOM,
25+
CreatureSpawnEvent.SpawnReason.COMMAND
26+
);
27+
28+
BOSS_MOBS = Map.of(
29+
EntityType.ENDER_DRAGON, "ender_dragon",
30+
EntityType.WITHER, "wither"
31+
);
32+
33+
HOSTILE_ADJACENT_MOBS = Map.of(
34+
EntityType.SKELETON_HORSE, "skeleton_horse",
35+
EntityType.ZOMBIE_HORSE, "zombie_horse"
36+
);
37+
38+
HOSTILE_MOBS = Map.ofEntries(
39+
Map.entry(EntityType.BLAZE, "blaze"),
40+
Map.entry(EntityType.CREEPER, "creeper"),
41+
Map.entry(EntityType.ELDER_GUARDIAN, "elder_guardian"),
42+
Map.entry(EntityType.ENDERMITE, "endermite"),
43+
Map.entry(EntityType.EVOKER, "evoker"),
44+
Map.entry(EntityType.GHAST, "ghast"),
45+
Map.entry(EntityType.GUARDIAN, "guardian"),
46+
Map.entry(EntityType.HOGLIN, "hoglin"),
47+
Map.entry(EntityType.HUSK, "husk"),
48+
Map.entry(EntityType.MAGMA_CUBE, "magma_cube"),
49+
Map.entry(EntityType.PHANTOM, "phantom"),
50+
Map.entry(EntityType.PIGLIN_BRUTE, "piglin_brute"),
51+
Map.entry(EntityType.PILLAGER, "pillager"),
52+
Map.entry(EntityType.RAVAGER, "ravager"),
53+
Map.entry(EntityType.SHULKER, "shulker"),
54+
Map.entry(EntityType.SILVERFISH, "silverfish"),
55+
Map.entry(EntityType.SKELETON, "skeleton"),
56+
Map.entry(EntityType.SLIME, "slime"),
57+
Map.entry(EntityType.STRAY, "stray"),
58+
Map.entry(EntityType.VEX, "vex"),
59+
Map.entry(EntityType.VINDICATOR, "vindicator"),
60+
Map.entry(EntityType.WARDEN, "warden"),
61+
Map.entry(EntityType.WITCH, "witch"),
62+
Map.entry(EntityType.WITHER_SKELETON, "wither_skeleton"),
63+
Map.entry(EntityType.ZOGLIN, "zoglin"),
64+
Map.entry(EntityType.ZOMBIE, "zombie"),
65+
Map.entry(EntityType.ZOMBIE_VILLAGER, "zombie_villager")
66+
);
67+
68+
NEUTRAL_MOBS = Map.ofEntries(
69+
Map.entry(EntityType.BEE, "bee"),
70+
Map.entry(EntityType.CAVE_SPIDER, "cave_spider"),
71+
Map.entry(EntityType.DOLPHIN, "dolphin"),
72+
Map.entry(EntityType.DROWNED, "drowned"),
73+
Map.entry(EntityType.ENDERMAN, "enderman"),
74+
Map.entry(EntityType.FOX, "fox"),
75+
Map.entry(EntityType.GOAT, "goat"),
76+
Map.entry(EntityType.IRON_GOLEM, "iron_golem"),
77+
Map.entry(EntityType.LLAMA, "llama"),
78+
Map.entry(EntityType.PANDA, "panda"),
79+
Map.entry(EntityType.PIGLIN, "piglin"),
80+
Map.entry(EntityType.POLAR_BEAR, "polar_bear"),
81+
Map.entry(EntityType.PUFFERFISH, "pufferfish"),
82+
Map.entry(EntityType.SPIDER, "spider"),
83+
Map.entry(EntityType.TRADER_LLAMA, "trader_llama"),
84+
Map.entry(EntityType.WOLF, "wolf"),
85+
Map.entry(EntityType.ZOMBIFIED_PIGLIN, "zombified_piglin")
86+
);
87+
88+
OTHER_MOBS = Map.of(
89+
EntityType.GIANT, "giant",
90+
EntityType.ILLUSIONER, "illusioner",
91+
EntityType.ARMOR_STAND, "armor_stand"
92+
);
93+
94+
PASSIVE_MOBS = Map.ofEntries(
95+
Map.entry(EntityType.ALLAY, "allay"),
96+
Map.entry(EntityType.AXOLOTL, "axolotl"),
97+
Map.entry(EntityType.BAT, "bat"),
98+
Map.entry(EntityType.CAT, "cat"),
99+
Map.entry(EntityType.CHICKEN, "chicken"),
100+
Map.entry(EntityType.COD, "cod"),
101+
Map.entry(EntityType.COW, "cow"),
102+
Map.entry(EntityType.DONKEY, "donkey"),
103+
Map.entry(EntityType.FROG, "frog"),
104+
Map.entry(EntityType.GLOW_SQUID, "glow_squid"),
105+
Map.entry(EntityType.HORSE, "horse"),
106+
Map.entry(EntityType.MUSHROOM_COW, "mooshroom"),
107+
Map.entry(EntityType.MULE, "mule"),
108+
Map.entry(EntityType.OCELOT, "ocelot"),
109+
Map.entry(EntityType.PARROT, "parrot"),
110+
Map.entry(EntityType.PIG, "pig"),
111+
Map.entry(EntityType.RABBIT, "rabbit"),
112+
Map.entry(EntityType.SALMON, "salmon"),
113+
Map.entry(EntityType.SHEEP, "sheep"),
114+
Map.entry(EntityType.SNIFFER, "sniffer"),
115+
Map.entry(EntityType.SNOWMAN, "snow_golem"),
116+
Map.entry(EntityType.SQUID, "squid"),
117+
Map.entry(EntityType.STRIDER, "strider"),
118+
Map.entry(EntityType.TADPOLE, "tadpole"),
119+
Map.entry(EntityType.TROPICAL_FISH, "tropical_fish"),
120+
Map.entry(EntityType.TURTLE, "turtle"),
121+
Map.entry(EntityType.VILLAGER, "villager"),
122+
Map.entry(EntityType.WANDERING_TRADER, "wandering_villager"),
123+
Map.entry(EntityType.CAMEL, "camel")
124+
);
125+
}
126+
127+
@Override
128+
public Set<CreatureSpawnEvent.SpawnReason> ignoredReasons() {
129+
return IGNORED_REASONS;
130+
}
131+
132+
@Override
133+
public Map<EntityType, String> supportedBossMobs() {
134+
return BOSS_MOBS;
135+
}
136+
137+
@Override
138+
public Map<EntityType, String> supportedHostileAdjacentMobs() {
139+
return HOSTILE_ADJACENT_MOBS;
140+
}
141+
142+
@Override
143+
public Map<EntityType, String> supportedHostileMobs() {
144+
return HOSTILE_MOBS;
145+
}
146+
147+
148+
@Override
149+
public Map<EntityType, String> supportedNeutralMobs() {
150+
return NEUTRAL_MOBS;
151+
}
152+
153+
@Override
154+
public Map<EntityType, String> supportedOtherMobs() {
155+
return OTHER_MOBS;
156+
}
157+
158+
@Override
159+
public Map<EntityType, String> supportedPassiveMobs() {
160+
return PASSIVE_MOBS;
161+
}
162+
}

0 commit comments

Comments
 (0)