Skip to content

Commit

Permalink
Drop 1.18.2 support (#711)
Browse files Browse the repository at this point in the history
* Remove v1_18 module

* Fix build

* Remove unneeded API

* Refactor SupportUtils

* Further clean up of SupportUtils

* Move SupportUtils

* Update SupportUtils.java

* Update SupportUtils.java
  • Loading branch information
TylerS1066 authored Sep 11, 2024
1 parent 45e1261 commit 936a87a
Show file tree
Hide file tree
Showing 23 changed files with 68 additions and 774 deletions.
6 changes: 2 additions & 4 deletions Movecraft/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,9 @@ plugins {
id("io.papermc.hangar-publish-plugin") version "0.1.2"
}

java.toolchain.languageVersion = JavaLanguageVersion.of(17)
java.toolchain.languageVersion = JavaLanguageVersion.of(21)

dependencies {
runtimeOnly(project(":movecraft-v1_18", "reobf"))
runtimeOnly(project(":movecraft-v1_20", "reobf"))
runtimeOnly(project(":movecraft-v1_21", "reobf"))
implementation(project(":movecraft-api"))
Expand All @@ -22,7 +21,6 @@ tasks.shadowJar {

dependencies {
include(project(":movecraft-api"))
include(project(":movecraft-v1_18"))
include(project(":movecraft-v1_20"))
include(project(":movecraft-v1_21"))
}
Expand Down Expand Up @@ -68,7 +66,7 @@ hangarPublish {
platforms {
register(io.papermc.hangarpublishplugin.model.Platforms.PAPER) {
jar.set(tasks.shadowJar.flatMap { it.archiveFile })
platformVersions.set(listOf("1.18.2", "1.20.6", "1.21.1"))
platformVersions.set(listOf("1.20.6", "1.21.1"))
}
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,6 @@
package net.countercraft.movecraft.async.rotation;

import net.countercraft.movecraft.CruiseDirection;
import net.countercraft.movecraft.Movecraft;
import net.countercraft.movecraft.MovecraftLocation;
import net.countercraft.movecraft.MovecraftRotation;
import net.countercraft.movecraft.TrackedLocation;
Expand All @@ -32,7 +31,6 @@
import net.countercraft.movecraft.events.CraftRotateEvent;
import net.countercraft.movecraft.events.CraftTeleportEntityEvent;
import net.countercraft.movecraft.localisation.I18nSupport;
import net.countercraft.movecraft.mapUpdater.update.AccessLocationUpdateCommand;
import net.countercraft.movecraft.mapUpdater.update.CraftRotateCommand;
import net.countercraft.movecraft.mapUpdater.update.EntityUpdateCommand;
import net.countercraft.movecraft.mapUpdater.update.UpdateCommand;
Expand All @@ -47,9 +45,6 @@
import org.bukkit.World;
import org.bukkit.entity.Entity;
import org.bukkit.entity.EntityType;
import org.bukkit.entity.HumanEntity;
import org.bukkit.event.inventory.InventoryType;
import org.bukkit.inventory.InventoryView;

import java.util.HashSet;
import java.util.List;
Expand Down Expand Up @@ -270,14 +265,12 @@ private void rotateEntitiesOnCraft(Location tOP) {
(oldHitBox.getMaxY() + oldHitBox.getMinY())/2.0,
(oldHitBox.getMaxZ() + oldHitBox.getMinZ())/2.0);

List<EntityType> entityList = List.of(EntityType.PLAYER, EntityType.PRIMED_TNT);
List<EntityType> entityList = List.of(EntityType.PLAYER, EntityType.TNT);
for(Entity entity : craft.getWorld().getNearbyEntities(midpoint,
oldHitBox.getXLength() / 2.0 + 1,
oldHitBox.getYLength() / 2.0 + 2,
oldHitBox.getZLength() / 2.0 + 1)) {

rotateHumanEntity(entity);

if (craft.getType().getBoolProperty(CraftType.ONLY_MOVE_PLAYERS)
&& (!entityList.contains(entity.getType())
|| craft instanceof SinkingCraft)) {
Expand Down Expand Up @@ -308,30 +301,6 @@ private void rotateEntitiesOnCraft(Location tOP) {
}
}

private void rotateHumanEntity(Entity entity) {
if (!(entity instanceof HumanEntity)) {
return;
}

InventoryView inventoryView = ((HumanEntity) entity).getOpenInventory();
if (inventoryView.getType() == InventoryType.CRAFTING) {
return;
}

Location l = Movecraft.getInstance().getWorldHandler().getAccessLocation(inventoryView);
if (l == null) {
return;
}

MovecraftLocation location = new MovecraftLocation(l.getBlockX(), l.getBlockY(), l.getBlockZ());
if (!oldHitBox.contains(location)) {
return;
}

location = MathUtils.rotateVec(rotation, location.subtract(originPoint)).add(originPoint);
updates.add(new AccessLocationUpdateCommand(inventoryView, location.toBukkit(w)));
}

public MovecraftLocation getOriginPoint() {
return originPoint;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,6 @@
import net.countercraft.movecraft.events.CraftTranslateEvent;
import net.countercraft.movecraft.events.ItemHarvestEvent;
import net.countercraft.movecraft.localisation.I18nSupport;
import net.countercraft.movecraft.mapUpdater.update.AccessLocationUpdateCommand;
import net.countercraft.movecraft.mapUpdater.update.BlockCreateCommand;
import net.countercraft.movecraft.mapUpdater.update.CraftTranslateCommand;
import net.countercraft.movecraft.mapUpdater.update.EntityUpdateCommand;
Expand All @@ -41,11 +40,8 @@
import org.bukkit.enchantments.Enchantment;
import org.bukkit.entity.Entity;
import org.bukkit.entity.EntityType;
import org.bukkit.entity.HumanEntity;
import org.bukkit.event.inventory.InventoryType;
import org.bukkit.inventory.Inventory;
import org.bukkit.inventory.InventoryHolder;
import org.bukkit.inventory.InventoryView;
import org.bukkit.inventory.ItemStack;
import org.jetbrains.annotations.NotNull;

Expand Down Expand Up @@ -365,9 +361,6 @@ private void preventsTorpedoRocketsPilots() {
oldHitBox.getYLength() / 2.0 + 2,
oldHitBox.getZLength() / 2.0 + 1
)) {

processHumanEntity(entity);

if ((entity.getType() == EntityType.PLAYER && !(craft instanceof SinkingCraft))) {
CraftTeleportEntityEvent e = new CraftTeleportEntityEvent(craft, entity);
Bukkit.getServer().getPluginManager().callEvent(e);
Expand All @@ -381,7 +374,7 @@ private void preventsTorpedoRocketsPilots() {
}

if (craft.getType().getBoolProperty(CraftType.ONLY_MOVE_PLAYERS)
&& entity.getType() != EntityType.PRIMED_TNT) {
&& entity.getType() != EntityType.TNT) {
continue;
}

Expand All @@ -395,30 +388,6 @@ private void preventsTorpedoRocketsPilots() {
}
}

//this part looks similar to rotationTask
//maybe can be thrown in a util class?
private void processHumanEntity(Entity entity) {
if (!(entity instanceof HumanEntity)) {
return;
}

InventoryView inventoryView = ((HumanEntity) entity).getOpenInventory();
if (inventoryView.getType() == InventoryType.CRAFTING) {
return;
}

Location l = Movecraft.getInstance().getWorldHandler().getAccessLocation(inventoryView);
if (l == null) {
return;
}

MovecraftLocation location = new MovecraftLocation(l.getBlockX(), l.getBlockY(), l.getBlockZ());
if (oldHitBox.contains(location)) {
location = location.translate(dx, dy, dz);
updates.add(new AccessLocationUpdateCommand(inventoryView, location.toBukkit(world)));
}
}

/**
*
* @return True if failed, false otherwise
Expand Down

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ private boolean sendSilhouetteToPlayers() {
for (Player p : location.getWorld().getPlayers()) { // this is necessary because signs do not get updated client side correctly without refreshing the chunks, which causes a memory leak in the clients
double distSquared = location.distanceSquared(p.getLocation());
if ((distSquared < Settings.SilhouetteViewDistance * Settings.SilhouetteViewDistance) && (distSquared > 32 * 32)) {
p.spawnParticle(Particle.VILLAGER_HAPPY, location, 9);
p.spawnParticle(Particle.HAPPY_VILLAGER, location, 9);
}
}
return true;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@
import net.countercraft.movecraft.processing.tasks.detection.validators.WaterContactValidator;
import net.countercraft.movecraft.util.AtomicLocationSet;
import net.countercraft.movecraft.util.CollectionUtils;
import net.countercraft.movecraft.util.SupportUtils;
import net.countercraft.movecraft.util.Tags;
import net.countercraft.movecraft.util.hitboxes.BitmapHitBox;
import net.countercraft.movecraft.util.hitboxes.HitBox;
Expand All @@ -54,7 +55,6 @@
import java.util.HashSet;
import java.util.List;
import java.util.Map;
import java.util.Optional;
import java.util.Queue;
import java.util.Set;
import java.util.concurrent.ConcurrentHashMap;
Expand Down Expand Up @@ -356,13 +356,14 @@ public void run() {
BlockData blockData = movecraftWorld.getData(probe);
Material material = blockData.getMaterial();

Optional<BlockFace> blockDataOptional = SupportUtils.getSupportFace(blockData, directionalDependent);
if (blockDataOptional.isPresent()) {
BlockFace facing = blockDataOptional.get();
MovecraftLocation relativeLoc = probe.getRelative(facing);
if (directionalDependent.contains(material)) {
BlockFace supportFace = SupportUtils.getSupportFace(blockData);
if (supportFace != null) {
MovecraftLocation relativeLoc = probe.getRelative(supportFace);

if (!legal.contains(relativeLoc))
continue;
if (!legal.contains(relativeLoc))
continue;
}
}

if(!visited.add(probe))
Expand Down

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ public void run() {
eUp.doUpdate();
}
else if (!craft.getType().getBoolProperty(CraftType.ONLY_MOVE_PLAYERS)
|| entity.getType() == EntityType.PRIMED_TNT) {
|| entity.getType() == EntityType.TNT) {
CraftTeleportEntityEvent e = new CraftTeleportEntityEvent(craft, entity);
Bukkit.getServer().getPluginManager().callEvent(e);
if (e.isCancelled())
Expand Down
2 changes: 1 addition & 1 deletion api/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ plugins {
id("buildlogic.java-conventions")
}

java.toolchain.languageVersion = JavaLanguageVersion.of(17)
java.toolchain.languageVersion = JavaLanguageVersion.of(21)

dependencies {
api(libs.io.papermc.paper.paper.api)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,10 +15,6 @@ public abstract class WorldHandler {
public abstract void translateCraft(@NotNull Craft craft, @NotNull MovecraftLocation newLocation, @NotNull World world);
public abstract void setBlockFast(@NotNull Location location, @NotNull BlockData data);
public abstract void setBlockFast(@NotNull Location location, @NotNull MovecraftRotation rotation, @NotNull BlockData data);
@Deprecated(forRemoval = true)
public abstract @Nullable Location getAccessLocation(@NotNull InventoryView inventoryView); // Not needed for 1.20+, remove when dropping support for 1.18.2
@Deprecated(forRemoval = true)
public abstract void setAccessLocation(@NotNull InventoryView inventoryView, @NotNull Location location); // Not needed for 1.20+, remove when dropping support for 1.18.2

public static @NotNull String getPackageName(@NotNull String minecraftVersion) {
String[] parts = minecraftVersion.split("\\.");
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ public abstract class AsyncChunk<T extends Chunk> {
static {
Constructor<?> temp = null;
try {
Class.forName("net.countercraft.movecraft.support.v1_18.IAsyncChunk");
Class.forName("net.countercraft.movecraft.support.v1_20.IAsyncChunk");
final Class<?> clazz = Class.forName("net.countercraft.movecraft.support." + WorldHandler.getPackageName(Bukkit.getServer().getMinecraftVersion()) + ".IAsyncChunk");
if (AsyncChunk.class.isAssignableFrom(clazz)) {
temp = clazz.getConstructor(Chunk.class);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,12 +8,16 @@
import org.bukkit.block.Block;
import org.bukkit.block.BlockState;
import org.bukkit.block.data.BlockData;
import org.bukkit.entity.Entity;
import org.bukkit.inventory.ItemStack;
import org.bukkit.material.MaterialData;
import org.bukkit.metadata.MetadataValue;
import org.bukkit.plugin.Plugin;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
import org.jetbrains.annotations.Unmodifiable;

import java.util.Collection;
import java.util.List;

public class MovecraftState implements BlockState {
Expand Down Expand Up @@ -48,6 +52,16 @@ public BlockData getBlockData() {
return data;
}

@Override
public @NotNull BlockState copy() {
throw new UnsupportedOperationException();
}

@Override
public @NotNull BlockState copy(@NotNull Location location) {
throw new UnsupportedOperationException();
}

@NotNull
@Override
public Material getType() {
Expand Down Expand Up @@ -156,6 +170,11 @@ public boolean isCollidable() {
throw new UnsupportedOperationException();
}

@Override
public @Unmodifiable @NotNull Collection<ItemStack> getDrops(@Nullable ItemStack tool, @Nullable Entity entity) {
throw new UnsupportedOperationException();
}

@Override
public void setMetadata(@NotNull String s, @NotNull MetadataValue metadataValue) {
throw new UnsupportedOperationException();
Expand Down
Loading

0 comments on commit 936a87a

Please sign in to comment.