Skip to content

Commit b3032a5

Browse files
committed
Build against Spigot 1.20.2
1 parent 5fade91 commit b3032a5

File tree

8 files changed

+69
-35
lines changed

8 files changed

+69
-35
lines changed

pom.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -175,7 +175,7 @@
175175
<!-- GPL -->
176176
<groupId>org.spigotmc</groupId>
177177
<artifactId>spigot-api</artifactId>
178-
<version>1.20.1-R0.1-SNAPSHOT</version>
178+
<version>1.20.2-R0.1-SNAPSHOT</version>
179179
</dependency>
180180

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

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

Lines changed: 31 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,7 @@
3535
import com.laytonsmith.abstraction.enums.MCSound;
3636
import com.laytonsmith.abstraction.enums.MCSoundCategory;
3737
import com.laytonsmith.abstraction.enums.MCTreeType;
38+
import com.laytonsmith.abstraction.enums.MCVersion;
3839
import com.laytonsmith.abstraction.enums.MCWorldEnvironment;
3940
import com.laytonsmith.abstraction.enums.MCWorldType;
4041
import com.laytonsmith.abstraction.enums.bukkit.BukkitMCBiomeType;
@@ -50,6 +51,7 @@
5051
import com.laytonsmith.core.constructs.CClosure;
5152
import com.laytonsmith.core.constructs.CString;
5253
import com.laytonsmith.core.constructs.Target;
54+
import com.laytonsmith.core.exceptions.CRE.CREPluginInternalException;
5355
import org.bukkit.Chunk;
5456
import org.bukkit.Effect;
5557
import org.bukkit.FireworkEffect;
@@ -69,6 +71,8 @@
6971
import org.bukkit.inventory.meta.FireworkMeta;
7072
import org.bukkit.util.Consumer;
7173

74+
import java.lang.reflect.InvocationTargetException;
75+
import java.lang.reflect.Method;
7276
import java.util.ArrayList;
7377
import java.util.List;
7478

@@ -237,32 +241,39 @@ public MCEntity spawn(MCLocation l, MCEntityType entType) {
237241
((BukkitMCEntityType) entType).getConcrete()));
238242
}
239243

244+
@Override
245+
public MCEntity spawn(MCLocation l, MCEntityType.MCVanillaEntityType entityType) {
246+
return BukkitConvertor.BukkitGetCorrectEntity(w.spawnEntity(
247+
((BukkitMCLocation) l).asLocation(),
248+
(EntityType) MCEntityType.valueOfVanillaType(entityType).getConcrete()));
249+
}
250+
240251
@Override
241252
public MCEntity spawn(MCLocation l, MCEntityType entType, final CClosure closure) {
242-
EntityType type = (EntityType) entType.getConcrete();
243-
Consumer<? extends Entity> consumer = (Consumer<Entity>) entity -> {
244-
MCEntity temp = BukkitConvertor.BukkitGetCorrectEntity(entity);
245-
Static.InjectEntity(temp);
253+
Location location = (Location) l.getHandle();
254+
Class<? extends Entity> entityClass = ((EntityType) entType.getConcrete()).getEntityClass();
255+
Entity entity;
256+
if(Static.getServer().getMinecraftVersion().gte(MCVersion.MC1_20_2)) {
257+
entity = w.spawn(location, entityClass, e -> beforeSpawn(e, closure));
258+
} else {
246259
try {
247-
closure.executeCallable(null, Target.UNKNOWN, new CString(entity.getUniqueId().toString(), Target.UNKNOWN));
248-
} finally {
249-
Static.UninjectEntity(temp);
260+
Method m = w.getClass().getMethod("spawn", Location.class, Class.class, Consumer.class);
261+
entity = (Entity) m.invoke(w, location, entityClass, (Consumer<Entity>) e -> beforeSpawn(e, closure));
262+
} catch (NoSuchMethodException | IllegalAccessException | InvocationTargetException e) {
263+
throw new CREPluginInternalException(e.getMessage(), Target.UNKNOWN, e);
250264
}
251-
};
252-
Entity ent = this.spawn((Location) l.getHandle(), type.getEntityClass(), consumer);
253-
return BukkitConvertor.BukkitGetCorrectEntity(ent);
254-
}
255-
256-
@SuppressWarnings("unchecked")
257-
private <T extends Entity> Entity spawn(Location location, Class<T> clazz, Consumer<? extends Entity> consumer) {
258-
return w.spawn(location, clazz, (Consumer<T>) consumer);
265+
}
266+
return BukkitConvertor.BukkitGetCorrectEntity(entity);
259267
}
260268

261-
@Override
262-
public MCEntity spawn(MCLocation l, MCEntityType.MCVanillaEntityType entityType) {
263-
return BukkitConvertor.BukkitGetCorrectEntity(w.spawnEntity(
264-
((BukkitMCLocation) l).asLocation(),
265-
(EntityType) MCEntityType.valueOfVanillaType(entityType).getConcrete()));
269+
private void beforeSpawn(Entity entity, CClosure closure) {
270+
MCEntity temp = BukkitConvertor.BukkitGetCorrectEntity(entity);
271+
Static.InjectEntity(temp);
272+
try {
273+
closure.executeCallable(new CString(entity.getUniqueId().toString(), Target.UNKNOWN));
274+
} finally {
275+
Static.UninjectEntity(temp);
276+
}
266277
}
267278

268279
@Override

src/main/java/com/laytonsmith/abstraction/bukkit/entities/BukkitMCDisplay.java

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -102,6 +102,16 @@ public void setInterpolationDelayTicks(int ticks) {
102102
this.d.setInterpolationDuration(ticks);
103103
}
104104

105+
@Override
106+
public int getTeleportDuration() {
107+
return this.d.getTeleportDuration();
108+
}
109+
110+
@Override
111+
public void setTeleportDuration(int ticks) {
112+
this.d.setTeleportDuration(ticks);
113+
}
114+
105115
@Override
106116
public float getShadowRadius() {
107117
return this.d.getShadowRadius();

src/main/java/com/laytonsmith/abstraction/bukkit/entities/BukkitMCPlayer.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -412,7 +412,7 @@ public void setTempOp(Boolean value) throws ClassNotFoundException, NoSuchFieldE
412412
String ops = "p";
413413
String getPlayerList = "ac";
414414
MCVersion mcversion = Static.getServer().getMinecraftVersion();
415-
if(mcversion.lt(MCVersion.MC1_20_X)) {
415+
if(mcversion.lt(MCVersion.MC1_20_2)) {
416416
ops = "o";
417417
if(mcversion.equals(MCVersion.MC1_19_3)) {
418418
getPlayerList = "ab";

src/main/java/com/laytonsmith/abstraction/entities/MCDisplay.java

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,18 @@ public interface MCDisplay extends MCEntity {
3333

3434
void setInterpolationDelayTicks(int ticks);
3535

36+
/**
37+
* Added in MC 1.20.2
38+
* @return ticks
39+
*/
40+
int getTeleportDuration();
41+
42+
/**
43+
* Added in MC 1.20.2
44+
* @param ticks
45+
*/
46+
void setTeleportDuration(int ticks);
47+
3648
float getShadowRadius();
3749

3850
void setShadowRadius(float radius);

src/main/java/com/laytonsmith/abstraction/enums/MCSound.java

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1569,17 +1569,17 @@ public enum MCVanillaSound {
15691569
MUSIC_OVERWORLD_SPARSE_JUNGLE(MCVersion.MC1_20),
15701570

15711571
// 1.20.2 additions
1572-
BLOCK_SPONGE_ABSORB(MCVersion.MC1_20_X),
1573-
BLOCK_SPONGE_BREAK(MCVersion.MC1_20_X),
1574-
BLOCK_SPONGE_FALL(MCVersion.MC1_20_X),
1575-
BLOCK_SPONGE_HIT(MCVersion.MC1_20_X),
1576-
BLOCK_SPONGE_PLACE(MCVersion.MC1_20_X),
1577-
BLOCK_SPONGE_STEP(MCVersion.MC1_20_X),
1578-
BLOCK_WET_SPONGE_BREAK(MCVersion.MC1_20_X),
1579-
BLOCK_WET_SPONGE_FALL(MCVersion.MC1_20_X),
1580-
BLOCK_WET_SPONGE_HIT(MCVersion.MC1_20_X),
1581-
BLOCK_WET_SPONGE_PLACE(MCVersion.MC1_20_X),
1582-
BLOCK_WET_SPONGE_STEP(MCVersion.MC1_20_X),
1572+
BLOCK_SPONGE_ABSORB(MCVersion.MC1_20_2),
1573+
BLOCK_SPONGE_BREAK(MCVersion.MC1_20_2),
1574+
BLOCK_SPONGE_FALL(MCVersion.MC1_20_2),
1575+
BLOCK_SPONGE_HIT(MCVersion.MC1_20_2),
1576+
BLOCK_SPONGE_PLACE(MCVersion.MC1_20_2),
1577+
BLOCK_SPONGE_STEP(MCVersion.MC1_20_2),
1578+
BLOCK_WET_SPONGE_BREAK(MCVersion.MC1_20_2),
1579+
BLOCK_WET_SPONGE_FALL(MCVersion.MC1_20_2),
1580+
BLOCK_WET_SPONGE_HIT(MCVersion.MC1_20_2),
1581+
BLOCK_WET_SPONGE_PLACE(MCVersion.MC1_20_2),
1582+
BLOCK_WET_SPONGE_STEP(MCVersion.MC1_20_2),
15831583

15841584
UNKNOWN(MCVersion.NEVER);
15851585

src/main/java/com/laytonsmith/abstraction/enums/MCVersion.java

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -66,6 +66,7 @@ public enum MCVersion implements Version {
6666
MC1_19_X,
6767
MC1_20,
6868
MC1_20_1,
69+
MC1_20_2,
6970
MC1_20_X,
7071
MC1_X,
7172
MC2_X,

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

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4100,7 +4100,7 @@ public String getName() {
41004100

41014101
@Override
41024102
public String docs() {
4103-
return "boolean {entityUUID} Returns if the given projectile should bounce when it hits something.";
4103+
return "boolean {entityUUID} Returns if the given projectile should bounce when it hits something. (deprecated)";
41044104
}
41054105

41064106
@Override
@@ -4129,7 +4129,7 @@ public String getName() {
41294129

41304130
@Override
41314131
public String docs() {
4132-
return "void {entityUUID, boolean} Sets if the given projectile should bounce when it hits something.";
4132+
return "void {entityUUID, boolean} Sets if the given projectile should bounce when it hits something. (deprecated)";
41334133
}
41344134

41354135
@Override

0 commit comments

Comments
 (0)