Skip to content

Commit cdbedb7

Browse files
authored
Merge branch 'gecolay:main' into main
2 parents 2deffde + e9ff642 commit cdbedb7

File tree

50 files changed

+1054
-89
lines changed

Some content is hidden

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

50 files changed

+1054
-89
lines changed

build.gradle.kts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
plugins {
22
`java-library`
33
`maven-publish`
4-
id("com.gradleup.shadow") version "9.0.0-beta11"
4+
id("com.gradleup.shadow") version "9.0.0-beta12"
55
id("io.papermc.paperweight.userdev") version "2.0.0-beta.16" apply false
66
}
77

@@ -43,6 +43,7 @@ dependencies {
4343
api(project(":v1_21", configuration = "reobf"))
4444
api(project(":v1_21_2", configuration = "reobf"))
4545
api(project(":v1_21_4", configuration = "reobf"))
46+
api(project(":v1_21_5", configuration = "reobf"))
4647
}
4748

4849
tasks {

core/build.gradle.kts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ plugins {
33
}
44

55
dependencies {
6-
compileOnly("io.papermc.paper:paper-api:1.21.4-R0.1-SNAPSHOT")
6+
compileOnly("io.papermc.paper:paper-api:1.21.5-R0.1-SNAPSHOT")
77
compileOnly("com.sk89q.worldguard:worldguard-bukkit:7.0.13") {
88
exclude("com.google.guava", "guava")
99
exclude("com.google.code.gson", "gson")

core/src/main/java/dev/geco/gsit/cmd/GBellyFlopCommand.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,7 @@ public boolean onCommand(@NotNull CommandSender sender, @NotNull Command command
4545
return true;
4646
}
4747

48-
if(!player.isValid() || player.isSneaking() || !player.isOnGround() || player.getVehicle() != null || player.isSleeping()) {
48+
if(!player.isValid() || player.isSneaking() || !player.isOnGround() || player.getVehicle() != null || player.isSleeping() || gSitMain.getSitService().isEntityBlocked(player)) {
4949
gSitMain.getMessageService().sendMessage(sender, "Messages.action-pose-now-error");
5050
return true;
5151
}

core/src/main/java/dev/geco/gsit/cmd/GLayCommand.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,7 @@ public boolean onCommand(@NotNull CommandSender sender, @NotNull Command command
4545
return true;
4646
}
4747

48-
if(!player.isValid() || player.isSneaking() || !player.isOnGround() || player.getVehicle() != null || player.isSleeping()) {
48+
if(!player.isValid() || player.isSneaking() || !player.isOnGround() || player.getVehicle() != null || player.isSleeping() || gSitMain.getSitService().isEntityBlocked(player)) {
4949
gSitMain.getMessageService().sendMessage(sender, "Messages.action-pose-now-error");
5050
return true;
5151
}

core/src/main/java/dev/geco/gsit/cmd/GSitCommand.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@ public boolean onCommand(@NotNull CommandSender sender, @NotNull Command command
4242
return true;
4343
}
4444

45-
if(!player.isValid() || player.isSneaking() || !player.isOnGround() || player.getVehicle() != null || player.isSleeping()) {
45+
if(!player.isValid() || player.isSneaking() || !player.isOnGround() || player.getVehicle() != null || player.isSleeping() || gSitMain.getSitService().isEntityBlocked(player)) {
4646
gSitMain.getMessageService().sendMessage(sender, "Messages.action-sit-now-error");
4747
return true;
4848
}

core/src/main/java/dev/geco/gsit/cmd/GSpinCommand.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,7 @@ public boolean onCommand(@NotNull CommandSender sender, @NotNull Command command
4545
return true;
4646
}
4747

48-
if(!player.isValid() || player.isSneaking() || !player.isOnGround() || player.getVehicle() != null || player.isSleeping()) {
48+
if(!player.isValid() || player.isSneaking() || !player.isOnGround() || player.getVehicle() != null || player.isSleeping() || gSitMain.getSitService().isEntityBlocked(player)) {
4949
gSitMain.getMessageService().sendMessage(sender, "Messages.action-pose-now-error");
5050
return true;
5151
}

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

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,11 @@ 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 && player.isValid()) gSitMain.getEntityUtil().setEntityLocation(player, bottom.getLocation());
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+
}
5458

5559
gSitMain.getPlayerSitService().stopPlayerSit(player, GStopReason.GET_UP, false, true, false);
5660
}

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

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -53,6 +53,8 @@ public void playerInteractEvent(PlayerInteractEvent event) {
5353

5454
if(!player.isValid() || player.isSneaking()) return;
5555

56+
if(gSitMain.getSitService().isEntityBlocked(player)) return;
57+
5658
if(gSitMain.getSitService().isEntitySitting(player) || gSitMain.getPoseService().isPlayerPosing(player) || gSitMain.getCrawlService().isPlayerCrawling(player)) return;
5759

5860
double distance = gSitMain.getConfigService().S_MAX_DISTANCE;

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

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -87,7 +87,11 @@ public boolean stopPlayerSit(Player source, GStopReason stopReason, boolean remo
8787
topToBottomStacks.remove(passengers.getKey());
8888
for(UUID passenger : passengers.getValue()) {
8989
Entity passengerEntity = Bukkit.getEntity(passenger);
90-
if(passengerEntity != null) passengerEntity.remove();
90+
if(passengerEntity != null) {
91+
gSitMain.getTaskService().run(() -> {
92+
if(passengerEntity.isValid()) passengerEntity.remove();
93+
}, passengerEntity.getLocation());
94+
}
9195
}
9296
String key = source.getUniqueId().toString() + passengers.getKey();
9397
Long spawnTime = spawnTimes.get(key);
@@ -102,7 +106,11 @@ public boolean stopPlayerSit(Player source, GStopReason stopReason, boolean remo
102106
bottomToTopStacks.remove(vehicles.getKey());
103107
for(UUID vehicle : vehicles.getValue()) {
104108
Entity vehicleEntity = Bukkit.getEntity(vehicle);
105-
if(vehicleEntity != null) vehicleEntity.remove();
109+
if(vehicleEntity != null) {
110+
gSitMain.getTaskService().run(() -> {
111+
if(vehicleEntity.isValid()) vehicleEntity.remove();
112+
}, vehicleEntity.getLocation());
113+
}
106114
}
107115
String key = vehicles.getKey().toString() + source.getUniqueId();
108116
Long spawnTime = spawnTimes.get(key);

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

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,7 @@ public class SitService {
3636
private final double baseOffset;
3737
private final HashMap<UUID, GSeat> seats = new HashMap<>();
3838
private final HashMap<Block, Set<GSeat>> blockSeats = new HashMap<>();
39+
private final HashSet<UUID> entityBlocked = new HashSet<>();
3940
private int sitUsageCount = 0;
4041
private long sitUsageNanoTime = 0;
4142

@@ -56,18 +57,22 @@ public SitService(GSitMain gSitMain) {
5657

5758
public boolean isBlockWithSeat(Block block) { return blockSeats.containsKey(block); }
5859

60+
public boolean isEntityBlocked(Entity entity) { return entityBlocked.contains(entity.getUniqueId()); }
61+
5962
public Set<GSeat> getSeatsByBlock(Block block) { return blockSeats.getOrDefault(block, Collections.emptySet()); }
6063

6164
public boolean kickSeatEntitiesFromBlock(Block block, LivingEntity entity) {
6265
if(!isBlockWithSeat(block)) return true;
63-
if(!gSitMain.getPermissionService().hasPermission(entity, "Kick.Sit")) return false;
66+
if(!gSitMain.getPermissionService().hasPermission(entity, "Kick.Sit", "Kick.*")) return false;
6467
for(GSeat seat : getSeatsByBlock(block)) if(!removeSeat(seat, GStopReason.KICKED)) return false;
6568
return true;
6669
}
6770

6871
public GSeat createSeat(Block block, LivingEntity entity) { return createSeat(block, entity, true, 0d, 0d, 0d, entity.getLocation().getYaw(), gSitMain.getConfigService().CENTER_BLOCK); }
6972

7073
public GSeat createSeat(Block block, LivingEntity entity, boolean canRotate, double xOffset, double yOffset, double zOffset, float seatRotation, boolean sitInBlockCenter) {
74+
if(entityBlocked.contains(entity.getUniqueId())) return null;
75+
7176
Location returnLocation = entity.getLocation();
7277
Location seatLocation = getSeatLocation(block, returnLocation, xOffset, yOffset, zOffset, sitInBlockCenter);
7378
if(!gSitMain.getEntityUtil().isSitLocationValid(seatLocation)) return null;
@@ -148,6 +153,8 @@ public void handleSafeSeatDismount(GSeat seat) {
148153

149154
Location returnLocation = gSitMain.getConfigService().GET_UP_RETURN ? seat.getReturnLocation() : upLocation;
150155

156+
if(entity.isValid()) entityBlocked.add(entity.getUniqueId());
157+
151158
gSitMain.getTaskService().runDelayed(() -> {
152159
Location entityLocation = entity.getLocation();
153160

@@ -156,7 +163,9 @@ public void handleSafeSeatDismount(GSeat seat) {
156163

157164
if(seat.getSeatEntity().isValid()) gSitMain.getEntityUtil().setEntityLocation(seat.getSeatEntity(), returnLocation);
158165
if(entity.isValid()) gSitMain.getEntityUtil().setEntityLocation(entity, returnLocation);
159-
}, 0);
166+
167+
entityBlocked.remove(entity.getUniqueId());
168+
}, returnLocation, 1);
160169
}
161170

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

0 commit comments

Comments
 (0)