Skip to content

Commit 01217b0

Browse files
authored
Merge branch 'gecolay:main' into main
2 parents 26f4e8b + 61e13ab commit 01217b0

File tree

34 files changed

+72
-70
lines changed

34 files changed

+72
-70
lines changed

build.gradle.kts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
plugins {
22
`java-library`
33
`maven-publish`
4-
id("com.gradleup.shadow") version "9.0.0-beta17"
5-
id("io.papermc.paperweight.userdev") version "2.0.0-beta.17" apply false
4+
id("com.gradleup.shadow") version "9.0.0-rc1"
5+
id("io.papermc.paperweight.userdev") version "2.0.0-beta.18" apply false
66
}
77

88
allprojects {

core/build.gradle.kts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,15 +3,15 @@ plugins {
33
}
44

55
dependencies {
6-
compileOnly("io.papermc.paper:paper-api:1.21.7-R0.1-SNAPSHOT")
7-
compileOnly("com.sk89q.worldguard:worldguard-bukkit:7.0.13") {
6+
compileOnly("io.papermc.paper:paper-api:1.21.8-R0.1-SNAPSHOT")
7+
compileOnly("com.sk89q.worldguard:worldguard-bukkit:7.0.14") {
88
exclude("com.google.guava", "guava")
99
exclude("com.google.code.gson", "gson")
1010
exclude("it.unimi.dsi", "fastutil")
1111
}
1212
compileOnly("me.clip:placeholderapi:2.11.6")
1313
compileOnly("com.github.GriefPrevention:GriefPrevention:16.18.4")
14-
compileOnly("com.intellectualsites.plotsquared:plotsquared-core:7.5.3")
14+
compileOnly("com.intellectualsites.plotsquared:plotsquared-core:7.5.4")
1515
}
1616

1717
java {

core/src/main/java/dev/geco/gsit/GSitMain.java

Lines changed: 13 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -75,9 +75,9 @@ public class GSitMain extends JavaPlugin {
7575
private PlaceholderAPILink placeholderAPILink;
7676
private PlotSquaredLink plotSquaredLink;
7777
private WorldGuardLink worldGuardLink;
78-
private boolean supportsPaperFeature = false;
7978
private boolean supportsTaskFeature = false;
80-
private boolean supportsFoliaFeature = false;
79+
private boolean isPaperServer = false;
80+
private boolean isFoliaServer = false;
8181

8282
public static GSitMain getInstance() { return gSitMain; }
8383

@@ -121,11 +121,11 @@ public class GSitMain extends JavaPlugin {
121121

122122
public WorldGuardLink getWorldGuardLink() { return worldGuardLink; }
123123

124-
public boolean supportsPaperFeature() { return supportsPaperFeature; }
125-
126124
public boolean supportsTaskFeature() { return supportsTaskFeature; }
127125

128-
public boolean supportsFoliaFeature() { return supportsFoliaFeature; }
126+
public boolean isPaperServer() { return isPaperServer; }
127+
128+
public boolean isFoliaServer() { return isFoliaServer; }
129129

130130
public void onLoad() {
131131
gSitMain = this;
@@ -150,7 +150,7 @@ public void onLoad() {
150150

151151
loadFeatures();
152152

153-
messageService = supportsPaperFeature && versionService.isNewerOrVersion(18, 2) ? new PaperMessageService(this) : new SpigotMessageService(this);
153+
messageService = isPaperServer && versionService.isNewerOrVersion(18, 2) ? new PaperMessageService(this) : new SpigotMessageService(this);
154154
}
155155

156156
public void onEnable() {
@@ -261,20 +261,20 @@ private boolean connectDatabase(CommandSender sender) {
261261
}
262262

263263
private void loadFeatures() {
264-
try {
265-
Class.forName("io.papermc.paper.event.entity.EntityMoveEvent");
266-
supportsPaperFeature = true;
267-
} catch(ClassNotFoundException e) { supportsPaperFeature = false; }
268-
269264
try {
270265
Class.forName("io.papermc.paper.threadedregions.scheduler.GlobalRegionScheduler");
271266
supportsTaskFeature = true;
272267
} catch(ClassNotFoundException e) { supportsTaskFeature = false; }
273268

269+
try {
270+
Class.forName("io.papermc.paper.event.entity.EntityMoveEvent");
271+
isPaperServer = true;
272+
} catch(ClassNotFoundException e) { isPaperServer = false; }
273+
274274
try {
275275
Class.forName("io.papermc.paper.threadedregions.RegionizedServerInitEvent");
276-
supportsFoliaFeature = true;
277-
} catch(ClassNotFoundException e) { supportsFoliaFeature = false; }
276+
isFoliaServer = true;
277+
} catch(ClassNotFoundException e) { isFoliaServer = false; }
278278

279279
if(Bukkit.getPluginManager().getPlugin("WorldGuard") != null) {
280280
worldGuardLink = new WorldGuardLink();

core/src/main/java/dev/geco/gsit/event/EntityEventHandler.java

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -50,11 +50,7 @@ public void handleEntityDismountEvent(Cancellable event, Entity entity, Entity d
5050
}, 2);
5151

5252
Entity bottom = gSitMain.getPassengerUtil().getBottomEntityVehicle(dismounted);
53-
if(gSitMain.getConfigService().PS_BOTTOM_RETURN) {
54-
gSitMain.getTaskService().runDelayed(() -> {
55-
if(player.isValid()) gSitMain.getEntityUtil().setEntityLocation(player, bottom.getLocation());
56-
}, player, 1);
57-
}
53+
if(gSitMain.getConfigService().PS_BOTTOM_RETURN && player.isValid()) gSitMain.getEntityUtil().setEntityLocation(player, bottom.getLocation());
5854

5955
gSitMain.getPlayerSitService().stopPlayerSit(player, GStopReason.GET_UP, false, true, false);
6056
}

core/src/main/java/dev/geco/gsit/service/PlayerSitService.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -88,7 +88,7 @@ public boolean stopPlayerSit(Player source, GStopReason stopReason, boolean remo
8888
for(UUID passenger : passengers.getValue()) {
8989
Entity passengerEntity = Bukkit.getEntity(passenger);
9090
if(passengerEntity == null) continue;
91-
if(gSitMain.supportsFoliaFeature()) gSitMain.getTaskService().run(passengerEntity::remove, passengerEntity);
91+
if(gSitMain.isFoliaServer()) gSitMain.getTaskService().run(passengerEntity::remove, passengerEntity);
9292
else passengerEntity.remove();
9393
}
9494
String key = source.getUniqueId().toString() + passengers.getKey();
@@ -105,7 +105,7 @@ public boolean stopPlayerSit(Player source, GStopReason stopReason, boolean remo
105105
for(UUID vehicle : vehicles.getValue()) {
106106
Entity vehicleEntity = Bukkit.getEntity(vehicle);
107107
if(vehicleEntity == null) continue;
108-
if(gSitMain.supportsFoliaFeature()) gSitMain.getTaskService().run(vehicleEntity::remove, vehicleEntity);
108+
if(gSitMain.isFoliaServer()) gSitMain.getTaskService().run(vehicleEntity::remove, vehicleEntity);
109109
else vehicleEntity.remove();
110110
}
111111
String key = vehicles.getKey().toString() + source.getUniqueId();

core/src/main/java/dev/geco/gsit/service/SitService.java

Lines changed: 14 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@
2626
import java.util.HashSet;
2727
import java.util.Set;
2828
import java.util.UUID;
29+
import java.util.logging.Level;
2930

3031
public class SitService {
3132

@@ -154,18 +155,23 @@ public boolean removeSeat(GSeat seat, GStopReason stopReason, boolean useSafeDis
154155
public void handleSafeSeatDismount(GSeat seat) {
155156
Entity entity = seat.getEntity();
156157

157-
Material blockType = seat.getBlock().getType();
158-
Location upLocation = seat.getLocation().add(0d, baseOffset + (Tag.STAIRS.isTagged(blockType) ? STAIR_Y_OFFSET : 0d) - gSitMain.getConfigService().S_SITMATERIALS.getOrDefault(blockType, 0d), 0d);
158+
try {
159+
Material blockType = seat.getBlock().getType();
160+
Location upLocation = seat.getLocation().add(0d, baseOffset + (Tag.STAIRS.isTagged(blockType) ? STAIR_Y_OFFSET : 0d) - gSitMain.getConfigService().S_SITMATERIALS.getOrDefault(blockType, 0d), 0d);
159161

160-
Location returnLocation = gSitMain.getConfigService().GET_UP_RETURN ? seat.getReturnLocation() : upLocation;
162+
Location returnLocation = gSitMain.getConfigService().GET_UP_RETURN ? seat.getReturnLocation() : upLocation;
161163

162-
Location entityLocation = entity.getLocation();
164+
Location entityLocation = entity.getLocation();
163165

164-
returnLocation.setYaw(entityLocation.getYaw());
165-
returnLocation.setPitch(entityLocation.getPitch());
166+
returnLocation.setYaw(entityLocation.getYaw());
167+
returnLocation.setPitch(entityLocation.getPitch());
166168

167-
gSitMain.getEntityUtil().setEntityLocation(entity, returnLocation);
168-
if(!gSitMain.getVersionManager().isNewerOrVersion(17, 0)) gSitMain.getEntityUtil().setEntityLocation(seat.getSeatEntity(), returnLocation);
169+
if(entity.isValid()) gSitMain.getEntityUtil().setEntityLocation(entity, returnLocation);
170+
if(seat.getSeatEntity().isValid() && !gSitMain.getVersionManager().isNewerOrVersion(17, 0)) gSitMain.getEntityUtil().setEntityLocation(seat.getSeatEntity(), returnLocation);
171+
} catch(Throwable e) {
172+
// If we can't access the block, entity or seat entity data in a Folia server environment we ignore this error
173+
if(!gSitMain.isFoliaServer()) gSitMain.getLogger().log(Level.SEVERE, "Could not safely dismount the entity!", e);
174+
}
169175
}
170176

171177
public GSeat createStairSeatForEntity(Block block, LivingEntity entity) {

gradle.properties

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
version=2.4.1
1+
version=2.4.3
22
group=dev.geco.gsit
33
description=Relax with other players on nice seats!
44

mcv/v1_18/src/main/java/dev/geco/gsit/mcv/v1_18/object/GCrawl.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -131,7 +131,7 @@ private void tick(Location location) {
131131
serverPlayer.connection.send(new ClientboundSetEntityDataPacket(boxEntity.getId(), boxEntity.getEntityData(), true));
132132
} else {
133133
serverPlayer.connection.send(new ClientboundSetEntityDataPacket(boxEntity.getId(), boxEntity.getEntityData(), true));
134-
boxEntity.teleportToWithTicket(playerLocation.getX(), playerLocation.getY(), playerLocation.getZ());
134+
boxEntity.setPosRaw(playerLocation.getX(), playerLocation.getY(), playerLocation.getZ(), true);
135135
serverPlayer.connection.send(new ClientboundTeleportEntityPacket(boxEntity));
136136
}
137137
}, true, playerLocation);

mcv/v1_18_2/src/main/java/dev/geco/gsit/mcv/v1_18_2/object/GCrawl.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -131,7 +131,7 @@ private void tick(Location location) {
131131
serverPlayer.connection.send(new ClientboundSetEntityDataPacket(boxEntity.getId(), boxEntity.getEntityData(), true));
132132
} else {
133133
serverPlayer.connection.send(new ClientboundSetEntityDataPacket(boxEntity.getId(), boxEntity.getEntityData(), true));
134-
boxEntity.teleportToWithTicket(playerLocation.getX(), playerLocation.getY(), playerLocation.getZ());
134+
boxEntity.setPosRaw(playerLocation.getX(), playerLocation.getY(), playerLocation.getZ(), true);
135135
serverPlayer.connection.send(new ClientboundTeleportEntityPacket(boxEntity));
136136
}
137137
}, true, playerLocation);

mcv/v1_19/src/main/java/dev/geco/gsit/mcv/v1_19/object/GCrawl.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -131,7 +131,7 @@ private void tick(Location location) {
131131
serverPlayer.connection.send(new ClientboundSetEntityDataPacket(boxEntity.getId(), boxEntity.getEntityData(), true));
132132
} else {
133133
serverPlayer.connection.send(new ClientboundSetEntityDataPacket(boxEntity.getId(), boxEntity.getEntityData(), true));
134-
boxEntity.teleportToWithTicket(playerLocation.getX(), playerLocation.getY(), playerLocation.getZ());
134+
boxEntity.setPosRaw(playerLocation.getX(), playerLocation.getY(), playerLocation.getZ(), true);
135135
serverPlayer.connection.send(new ClientboundTeleportEntityPacket(boxEntity));
136136
}
137137
}, true, playerLocation);

0 commit comments

Comments
 (0)