Skip to content

Commit 18fa049

Browse files
committed
Build against Paper 1.21.4
Spigot servers are still supported.
1 parent 28d1787 commit 18fa049

File tree

8 files changed

+51
-51
lines changed

8 files changed

+51
-51
lines changed

pom.xml

+1-11
Original file line numberDiff line numberDiff line change
@@ -143,10 +143,6 @@
143143
</repository>
144144

145145
<!-- Repository for Bukkit -->
146-
<repository>
147-
<id>spigot-repo</id>
148-
<url>https://hub.spigotmc.org/nexus/content/groups/public/</url>
149-
</repository>
150146
<repository>
151147
<id>papermc-repo</id>
152148
<url>https://repo.papermc.io/repository/maven-public/</url>
@@ -174,16 +170,10 @@
174170
-->
175171

176172
<!-- Bukkit -->
177-
<dependency>
178-
<!-- GPL -->
179-
<groupId>org.spigotmc</groupId>
180-
<artifactId>spigot-api</artifactId>
181-
<version>1.21.3-R0.1-SNAPSHOT</version>
182-
</dependency>
183173
<dependency>
184174
<groupId>io.papermc.paper</groupId>
185175
<artifactId>paper-api</artifactId>
186-
<version>1.21.3-R0.1-SNAPSHOT</version>
176+
<version>1.21.4-R0.1-SNAPSHOT</version>
187177
</dependency>
188178

189179
<!-- Used for storing and retreiving Constructs in a storage transparent medium: JSONs -->

src/main/java/com/laytonsmith/abstraction/bukkit/BukkitMCInventory.java

+7-4
Original file line numberDiff line numberDiff line change
@@ -162,10 +162,13 @@ public MCInventoryHolder getHolder() {
162162

163163
@Override
164164
public String getTitle() {
165-
Nameable n = ((Nameable) i.getHolder());
166-
if(n == null) {
167-
return null;
165+
InventoryHolder h = i.getHolder();
166+
if(h instanceof Nameable) {
167+
return ((Nameable) h).getCustomName();
168+
}
169+
if(h instanceof BukkitMCVirtualInventoryHolder.VirtualHolder) {
170+
return ((BukkitMCVirtualInventoryHolder.VirtualHolder) h).getTitle();
168171
}
169-
return n.getCustomName();
172+
return null;
170173
}
171174
}

src/main/java/com/laytonsmith/abstraction/bukkit/BukkitMCSkullMeta.java

+3-3
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
package com.laytonsmith.abstraction.bukkit;
22

3-
import com.laytonsmith.PureUtilities.Common.ReflectionUtils;
3+
import com.destroystokyo.paper.profile.PlayerProfile;
44
import com.laytonsmith.abstraction.AbstractionObject;
55
import com.laytonsmith.abstraction.MCOfflinePlayer;
66
import com.laytonsmith.abstraction.MCPlayerProfile;
@@ -58,7 +58,7 @@ public void setOwningPlayer(MCOfflinePlayer player) {
5858
@Override
5959
public MCPlayerProfile getProfile() {
6060
if(((BukkitMCServer) Static.getServer()).isPaper()) {
61-
Object profile = ReflectionUtils.invokeMethod(SkullMeta.class, sm, "getPlayerProfile");
61+
PlayerProfile profile = this.sm.getPlayerProfile();
6262
if(profile != null) {
6363
return new BukkitMCPlayerProfile(profile);
6464
}
@@ -69,6 +69,6 @@ public MCPlayerProfile getProfile() {
6969
@Override
7070
public void setProfile(MCPlayerProfile profile) {
7171
// Completes the profile from user cache.
72-
ReflectionUtils.invokeMethod(sm, "setPlayerProfile", profile.getHandle());
72+
this.sm.setPlayerProfile((PlayerProfile) profile.getHandle());
7373
}
7474
}

src/main/java/com/laytonsmith/abstraction/bukkit/BukkitMCVirtualInventoryHolder.java

+9-15
Original file line numberDiff line numberDiff line change
@@ -3,13 +3,13 @@
33
import com.laytonsmith.abstraction.MCInventory;
44
import com.laytonsmith.abstraction.MCVirtualInventoryHolder;
55
import com.laytonsmith.core.functions.InventoryManagement;
6-
import org.bukkit.Nameable;
76
import org.bukkit.inventory.Inventory;
87
import org.bukkit.inventory.InventoryHolder;
8+
import org.jetbrains.annotations.NotNull;
99

1010
public class BukkitMCVirtualInventoryHolder implements MCVirtualInventoryHolder {
1111

12-
private VirtualHolder vholder;
12+
private final VirtualHolder vholder;
1313

1414
public BukkitMCVirtualInventoryHolder(String id, String title) {
1515
this.vholder = new VirtualHolder(id, title);
@@ -21,20 +21,20 @@ public BukkitMCVirtualInventoryHolder(InventoryHolder ih) {
2121

2222
@Override
2323
public MCInventory getInventory() {
24-
return new BukkitMCInventory(vholder.getInventory());
24+
return new BukkitMCInventory(this.vholder.getInventory());
2525
}
2626

2727
@Override
2828
public String getID() {
29-
return vholder.id;
29+
return this.vholder.id;
3030
}
3131

3232
@Override
33-
public Object getHandle() {
33+
public VirtualHolder getHandle() {
3434
return this.vholder;
3535
}
3636

37-
public class VirtualHolder implements InventoryHolder, Nameable {
37+
public static class VirtualHolder implements InventoryHolder {
3838
private final String id;
3939
private final String title;
4040

@@ -44,18 +44,12 @@ public class VirtualHolder implements InventoryHolder, Nameable {
4444
}
4545

4646
@Override
47-
public Inventory getInventory() {
47+
public @NotNull Inventory getInventory() {
4848
return (Inventory) InventoryManagement.VIRTUAL_INVENTORIES.get(this.id).getHandle();
4949
}
5050

51-
@Override
52-
public String getCustomName() {
53-
return title;
54-
}
55-
56-
@Override
57-
public void setCustomName(String name) {
58-
// not modifiable at this time
51+
public String getTitle() {
52+
return this.title;
5953
}
6054
}
6155
}

src/main/java/com/laytonsmith/abstraction/bukkit/events/BukkitPlayerEvents.java

+14-3
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
package com.laytonsmith.abstraction.bukkit.events;
22

3+
import com.laytonsmith.PureUtilities.Common.ReflectionUtils;
34
import com.laytonsmith.PureUtilities.Vector3D;
45
import com.laytonsmith.abstraction.Implementation;
56
import com.laytonsmith.abstraction.MCBookMeta;
@@ -18,6 +19,7 @@
1819
import com.laytonsmith.abstraction.bukkit.BukkitMCItemStack;
1920
import com.laytonsmith.abstraction.bukkit.BukkitMCLocation;
2021
import com.laytonsmith.abstraction.bukkit.BukkitMCNamespacedKey;
22+
import com.laytonsmith.abstraction.bukkit.BukkitMCServer;
2123
import com.laytonsmith.abstraction.bukkit.BukkitMCWorld;
2224
import com.laytonsmith.abstraction.bukkit.blocks.BukkitMCBlock;
2325
import com.laytonsmith.abstraction.bukkit.blocks.BukkitMCMaterial;
@@ -72,10 +74,11 @@
7274
import com.laytonsmith.abstraction.events.MCWorldChangedEvent;
7375
import com.laytonsmith.annotations.abstraction;
7476
import com.laytonsmith.core.Static;
77+
import io.papermc.paper.advancement.AdvancementDisplay;
78+
import net.kyori.adventure.text.serializer.plain.PlainTextComponentSerializer;
7579
import org.bukkit.Bukkit;
7680
import org.bukkit.Location;
7781
import org.bukkit.World;
78-
import org.bukkit.advancement.AdvancementDisplay;
7982
import org.bukkit.block.BlockFace;
8083
import org.bukkit.damage.DamageSource;
8184
import org.bukkit.damage.DamageType;
@@ -1172,8 +1175,16 @@ public MCNamespacedKey getAdvancementKey() {
11721175

11731176
@Override
11741177
public String getTitle() {
1175-
if(Static.getServer().getMinecraftVersion().gte(MCVersion.MC1_18_X)) {
1176-
AdvancementDisplay display = e.getAdvancement().getDisplay();
1178+
if(((BukkitMCServer) Static.getServer()).isPaper()) {
1179+
if(Static.getServer().getMinecraftVersion().gte(MCVersion.MC1_17_X)) {
1180+
AdvancementDisplay display = e.getAdvancement().getDisplay();
1181+
if(display != null) {
1182+
return PlainTextComponentSerializer.plainText().serialize(display.title());
1183+
}
1184+
}
1185+
} else if(Static.getServer().getMinecraftVersion().gte(MCVersion.MC1_18_X)) {
1186+
org.bukkit.advancement.AdvancementDisplay display = ReflectionUtils.invokeMethod(e.getAdvancement(),
1187+
"getDisplay");
11771188
if(display != null) {
11781189
return display.getTitle();
11791190
}

src/main/java/com/laytonsmith/abstraction/enums/bukkit/BukkitMCParticle.java

+14-13
Original file line numberDiff line numberDiff line change
@@ -142,27 +142,28 @@ public Object getParticleData(MCLocation l, Object data) {
142142
}
143143
case TRAIL:
144144
if(Static.getServer().getMinecraftVersion().gte(MCVersion.MC1_21_4)) {
145+
if(data instanceof MCParticleData.Trail trail) {
146+
return new Particle.Trail((Location) trail.location().getHandle(),
147+
BukkitMCColor.GetColor(trail.color()), trail.duration());
148+
} else {
149+
return new Particle.Trail((Location) l.getHandle(), Color.fromRGB(252, 120, 18),
150+
new Random().nextInt(40) + 10);
151+
}
152+
} else {
153+
// 1.21.3 only
154+
Class clazz = null;
145155
try {
146-
Class clazz = Class.forName("org.bukkit.Particle$Trail");
147-
Constructor constructor = clazz.getConstructor(Location.class, Color.class, int.class);
156+
clazz = Class.forName("org.bukkit.Particle$TargetColor");
157+
Constructor constructor = clazz.getConstructor(Location.class, Color.class);
148158
constructor.setAccessible(true);
149159
if(data instanceof MCParticleData.Trail trail) {
150160
return constructor.newInstance((Location) trail.location().getHandle(),
151-
BukkitMCColor.GetColor(trail.color()), trail.duration());
161+
BukkitMCColor.GetColor(trail.color()));
152162
} else {
153-
return constructor.newInstance((Location) l.getHandle(), Color.fromRGB(252, 120, 18),
154-
new Random().nextInt(40) + 10);
163+
return constructor.newInstance((Location) l.getHandle(), Color.fromRGB(252, 120, 18));
155164
}
156165
} catch (ClassNotFoundException | NoSuchMethodException | InstantiationException
157166
| IllegalAccessException | InvocationTargetException ignore) {}
158-
} else {
159-
// 1.21.3 only
160-
if(data instanceof MCParticleData.Trail trail) {
161-
return new Particle.TargetColor((Location) trail.location().getHandle(),
162-
BukkitMCColor.GetColor(trail.color()));
163-
} else {
164-
return new Particle.TargetColor((Location) l.getHandle(), Color.fromRGB(252, 120, 18));
165-
}
166167
}
167168
}
168169
return null;

src/main/java/com/laytonsmith/core/events/drivers/PlayerEvents.java

+2-1
Original file line numberDiff line numberDiff line change
@@ -2913,7 +2913,8 @@ public Driver driver() {
29132913
public String docs() {
29142914
return "{}"
29152915
+ " Fires when a player completes all criteria to unlock an advancement or recipe."
2916-
+ " {player | advancement | title: The advancement display title, if one exists (MC 1.18.2+)}"
2916+
+ " {player | advancement | title: The advancement display title, if one exists (MC 1.17.1+ on"
2917+
+ " Paper, 1.18.2+ on Spigot)}"
29172918
+ " {}"
29182919
+ " {}";
29192920
}

src/main/java/com/laytonsmith/core/functions/InventoryManagement.java

+1-1
Original file line numberDiff line numberDiff line change
@@ -2916,7 +2916,7 @@ public MSVersion since() {
29162916
* @param t
29172917
* @return
29182918
*/
2919-
private static MCInventory GetInventory(Mixed specifier, MCWorld w, Target t) {
2919+
static MCInventory GetInventory(Mixed specifier, MCWorld w, Target t) {
29202920
MCInventory inv = GetInventoryOrNull(specifier, w, t);
29212921
if(inv == null) {
29222922
if(specifier.isInstanceOf(CArray.TYPE)) {

0 commit comments

Comments
 (0)