Skip to content

Commit

Permalink
Merge branch 'gecolay:main' into main
Browse files Browse the repository at this point in the history
  • Loading branch information
Dreeam-qwq authored Jun 25, 2024
2 parents 83673ff + 3fc8702 commit 7373cb9
Show file tree
Hide file tree
Showing 32 changed files with 249 additions and 31 deletions.
2 changes: 1 addition & 1 deletion core/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
<parent>
<groupId>dev.geco.gsit</groupId>
<artifactId>GSit</artifactId>
<version>1.9.3</version>
<version>1.9.5</version>
</parent>

<properties>
Expand Down
2 changes: 0 additions & 2 deletions core/src/main/java/dev/geco/gsit/events/PlayerSitEvents.java
Original file line number Diff line number Diff line change
Expand Up @@ -64,8 +64,6 @@ public void PIntAEE(PlayerInteractAtEntityEvent Event) {

if(GPM.getCManager().FEATUREFLAGS.contains("DISABLE_PLAYERSIT_ELYTRA") && player.isGliding()) return;

if((player.getGameMode() == GameMode.CREATIVE && player.getOpenInventory().getType() != InventoryType.CREATIVE) || (player.getGameMode() != GameMode.CREATIVE && player.getOpenInventory().getType() != InventoryType.CRAFTING)) return;

if(GPM.getCrawlManager().isCrawling(player)) return;

double distance = GPM.getCManager().PS_MAX_DISTANCE;
Expand Down
2 changes: 2 additions & 0 deletions core/src/main/java/dev/geco/gsit/manager/CrawlManager.java
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,8 @@ public IGCrawl startCrawl(Player Player) {

if(preEvent.isCancelled()) return null;

if(GPM.getCManager().CUSTOM_MESSAGE) GPM.getMManager().sendActionBarMessage(Player, "Messages.action-crawl-info");

IGCrawl crawl = GPM.getEntityUtil().createCrawlObject(Player);

crawl.start();
Expand Down
2 changes: 1 addition & 1 deletion dist/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
<parent>
<groupId>dev.geco.gsit</groupId>
<artifactId>GSit</artifactId>
<version>1.9.3</version>
<version>1.9.5</version>
</parent>

<build>
Expand Down
2 changes: 1 addition & 1 deletion mcv1_17/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
<parent>
<groupId>dev.geco.gsit</groupId>
<artifactId>GSit</artifactId>
<version>1.9.3</version>
<version>1.9.5</version>
</parent>

<properties>
Expand Down
2 changes: 1 addition & 1 deletion mcv1_17_1/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
<parent>
<groupId>dev.geco.gsit</groupId>
<artifactId>GSit</artifactId>
<version>1.9.3</version>
<version>1.9.5</version>
</parent>

<properties>
Expand Down
2 changes: 1 addition & 1 deletion mcv1_18/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
<parent>
<groupId>dev.geco.gsit</groupId>
<artifactId>GSit</artifactId>
<version>1.9.3</version>
<version>1.9.5</version>
</parent>

<properties>
Expand Down
2 changes: 1 addition & 1 deletion mcv1_18_2/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
<parent>
<groupId>dev.geco.gsit</groupId>
<artifactId>GSit</artifactId>
<version>1.9.3</version>
<version>1.9.5</version>
</parent>

<properties>
Expand Down
2 changes: 1 addition & 1 deletion mcv1_19/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
<parent>
<groupId>dev.geco.gsit</groupId>
<artifactId>GSit</artifactId>
<version>1.9.3</version>
<version>1.9.5</version>
</parent>

<properties>
Expand Down
2 changes: 1 addition & 1 deletion mcv1_19_1/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
<parent>
<groupId>dev.geco.gsit</groupId>
<artifactId>GSit</artifactId>
<version>1.9.3</version>
<version>1.9.5</version>
</parent>

<properties>
Expand Down
2 changes: 1 addition & 1 deletion mcv1_19_3/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
<parent>
<groupId>dev.geco.gsit</groupId>
<artifactId>GSit</artifactId>
<version>1.9.3</version>
<version>1.9.5</version>
</parent>

<properties>
Expand Down
2 changes: 1 addition & 1 deletion mcv1_19_4/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
<parent>
<groupId>dev.geco.gsit</groupId>
<artifactId>GSit</artifactId>
<version>1.9.3</version>
<version>1.9.5</version>
</parent>

<properties>
Expand Down
2 changes: 1 addition & 1 deletion mcv1_20/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
<parent>
<groupId>dev.geco.gsit</groupId>
<artifactId>GSit</artifactId>
<version>1.9.3</version>
<version>1.9.5</version>
</parent>

<properties>
Expand Down
2 changes: 1 addition & 1 deletion mcv1_20_2/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
<parent>
<groupId>dev.geco.gsit</groupId>
<artifactId>GSit</artifactId>
<version>1.9.3</version>
<version>1.9.5</version>
</parent>

<properties>
Expand Down
2 changes: 1 addition & 1 deletion mcv1_20_3/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
<parent>
<groupId>dev.geco.gsit</groupId>
<artifactId>GSit</artifactId>
<version>1.9.3</version>
<version>1.9.5</version>
</parent>

<properties>
Expand Down
2 changes: 1 addition & 1 deletion mcv1_20_5/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
<parent>
<groupId>dev.geco.gsit</groupId>
<artifactId>GSit</artifactId>
<version>1.9.3</version>
<version>1.9.5</version>
</parent>

<properties>
Expand Down
2 changes: 1 addition & 1 deletion mcv1_21/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
<parent>
<groupId>dev.geco.gsit</groupId>
<artifactId>GSit</artifactId>
<version>1.9.3</version>
<version>1.9.5</version>
</parent>

<properties>
Expand Down
218 changes: 218 additions & 0 deletions mcv1_21/src/main/java/dev/geco/gsit/mcv/x/objects/GCrawl.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,218 @@
package dev.geco.gsit.mcv.x.objects;

import org.bukkit.*;
import org.bukkit.block.*;
import org.bukkit.block.data.*;
import org.bukkit.event.*;
import org.bukkit.event.entity.*;
import org.bukkit.event.player.*;
import org.bukkit.entity.*;
import org.bukkit.inventory.*;
import org.bukkit.craftbukkit.v1_21_R1.entity.*;

import net.minecraft.network.protocol.game.*;
import net.minecraft.server.level.*;

import dev.geco.gsit.GSitMain;
import dev.geco.gsit.objects.*;

public class GCrawl implements IGCrawl {

private final GSitMain GPM = GSitMain.getInstance();

private final Player player;

private final ServerPlayer serverPlayer;

protected final BoxEntity boxEntity;

private Location blockLocation;

private boolean boxPresent;

protected final BlockData blockData = Material.BARRIER.createBlockData();

private final Listener listener;
private final Listener moveListener;
private final Listener stopListener;

private final long spawnTime = System.nanoTime();

public GCrawl(Player Player) {

player = Player;

serverPlayer = ((CraftPlayer) player).getHandle();

boxEntity = new BoxEntity(player.getLocation());

listener = new Listener() {

@EventHandler(priority = EventPriority.LOWEST, ignoreCancelled = true)
public void ETogSE(EntityToggleSwimEvent Event) { if(Event.getEntity() == player) Event.setCancelled(true); }

@EventHandler(priority = EventPriority.LOWEST, ignoreCancelled = true)
public void PIntE(PlayerInteractEvent Event) {

if(!Event.isAsynchronous() && Event.getPlayer() == player && blockLocation != null && Event.getClickedBlock().equals(blockLocation.getBlock()) && Event.getHand() == EquipmentSlot.HAND) {

Event.setCancelled(true);

GPM.getTManager().run(() -> {

buildBlock(blockLocation);
}, false, player);
}
}
};

moveListener = new Listener() {

@EventHandler(priority = EventPriority.HIGHEST, ignoreCancelled = true)
public void PMovE(PlayerMoveEvent Event) {

if(!Event.isAsynchronous() && Event.getPlayer() == player) {

Location locationFrom = Event.getFrom(), locationTo = Event.getTo();

if(locationFrom.getX() != locationTo.getX() || locationFrom.getZ() != locationTo.getZ() || locationFrom.getY() != locationTo.getY()) tick(locationFrom);
}
}
};

stopListener = new Listener() {

@EventHandler(priority = EventPriority.HIGHEST, ignoreCancelled = true)
public void PTogSE(PlayerToggleSneakEvent Event) { if(!Event.isAsynchronous() && Event.getPlayer() == player && Event.isSneaking()) GPM.getCrawlManager().stopCrawl(player, GetUpReason.GET_UP); }
};
}

public void start() {

player.setSwimming(true);

Bukkit.getPluginManager().registerEvents(listener, GPM);

GPM.getTManager().runDelayed(() -> {

Bukkit.getPluginManager().registerEvents(moveListener, GPM);

if(GPM.getCManager().C_GET_UP_SNEAK) Bukkit.getPluginManager().registerEvents(stopListener, GPM);

tick(player.getLocation());
}, false, player, 1);
}

private void tick(Location Location) {

if(!checkCrawlValid()) return;

Location location = Location.clone();

Block locationBlock = location.getBlock();

int blockSize = (int) ((location.getY() - location.getBlockY()) * 100);

location.setY(location.getBlockY() + (blockSize >= 40 ? 2.49 : 1.49));

Block aboveBlock = location.getBlock();

boolean aboveBlockSolid = aboveBlock.getBoundingBox().contains(location.toVector()) && !aboveBlock.getCollisionShape().getBoundingBoxes().isEmpty();
boolean canPlaceBlock = isValidArea(locationBlock.getRelative(BlockFace.UP), aboveBlock, blockLocation != null ? blockLocation.getBlock() : null);
boolean canSetBarrier = canPlaceBlock && (aboveBlock.getType().isAir() || aboveBlockSolid);

if(blockLocation == null || !aboveBlock.equals(blockLocation.getBlock())) {

destoryBlock();

if(canSetBarrier && !aboveBlockSolid) buildBlock(location);
}

if(!canSetBarrier && !aboveBlockSolid) {

Location playerLocation = Location.clone();

GPM.getTManager().run(() -> {

int height = locationBlock.getBoundingBox().getHeight() >= 0.4 || playerLocation.getY() % 0.015625 == 0.0 ? (player.getFallDistance() > 0.7 ? 0 : blockSize) : 0;

playerLocation.setY(playerLocation.getY() + (height >= 40 ? 1.5 : 0.5));

boxEntity.setRawPeekAmount(height >= 40 ? 100 - height : 0);

if(boxPresent) {

serverPlayer.connection.send(new ClientboundSetEntityDataPacket(boxEntity.getId(), boxEntity.getEntityData().getNonDefaultValues()));
boxEntity.teleportTo(playerLocation.getX(), playerLocation.getY(), playerLocation.getZ());
serverPlayer.connection.send(new ClientboundTeleportEntityPacket(boxEntity));
} else {

boxEntity.setPos(playerLocation.getX(), playerLocation.getY(), playerLocation.getZ());
serverPlayer.connection.send(new ClientboundAddEntityPacket(boxEntity.getId(), boxEntity.getUUID(), boxEntity.getX(), boxEntity.getY(), boxEntity.getZ(), boxEntity.getXRot(), boxEntity.getYRot(), boxEntity.getType(), 0, boxEntity.getDeltaMovement(), boxEntity.getYHeadRot()));
boxPresent = true;
serverPlayer.connection.send(new ClientboundSetEntityDataPacket(boxEntity.getId(), boxEntity.getEntityData().getNonDefaultValues()));
}
}, true, playerLocation);
} else destoryEntity();
}

public void stop() {

HandlerList.unregisterAll(listener);
HandlerList.unregisterAll(moveListener);
HandlerList.unregisterAll(stopListener);

player.setSwimming(false);

if(blockLocation != null) player.sendBlockChange(blockLocation, blockLocation.getBlock().getBlockData());

serverPlayer.connection.send(new ClientboundRemoveEntitiesPacket(boxEntity.getId()));
}

private void buildBlock(Location Location) {

blockLocation = Location;

player.sendBlockChange(blockLocation, blockData);
}

private void destoryBlock() {

if(blockLocation != null) player.sendBlockChange(blockLocation, blockLocation.getBlock().getBlockData());

blockLocation = null;
}

private void destoryEntity() {

if(!boxPresent) return;

serverPlayer.connection.send(new ClientboundRemoveEntitiesPacket(boxEntity.getId()));

boxPresent = false;
}

private boolean checkCrawlValid() {

if(serverPlayer.isInWater() || player.isFlying()) {

GPM.getTManager().run(() -> {

GPM.getCrawlManager().stopCrawl(player, GetUpReason.ACTION);
}, true, blockLocation != null ? blockLocation : player.getLocation());

return false;
}

return true;
}

private boolean isValidArea(Block BlockUp, Block AboveBlock, Block LocationBlock) { return BlockUp.equals(AboveBlock) || BlockUp.equals(LocationBlock); }

public Player getPlayer() { return player; }

public long getNano() { return System.nanoTime() - spawnTime; }

public String toString() { return boxEntity.getUUID().toString(); }

}
2 changes: 1 addition & 1 deletion pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
<groupId>dev.geco.gsit</groupId>
<artifactId>GSit</artifactId>
<name>GSit</name>
<version>1.9.3</version>
<version>1.9.5</version>
<description>Relax with other players on nice seats!</description>
<url>https://www.spigotmc.org/resources/62325</url>
<inceptionYear>2018</inceptionYear>
Expand Down
2 changes: 1 addition & 1 deletion v1_17/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
<parent>
<groupId>dev.geco.gsit</groupId>
<artifactId>GSit</artifactId>
<version>1.9.3</version>
<version>1.9.5</version>
</parent>

<properties>
Expand Down
2 changes: 1 addition & 1 deletion v1_17_1/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
<parent>
<groupId>dev.geco.gsit</groupId>
<artifactId>GSit</artifactId>
<version>1.9.3</version>
<version>1.9.5</version>
</parent>

<properties>
Expand Down
Loading

0 comments on commit 7373cb9

Please sign in to comment.