diff --git a/.github/ISSUE_TEMPLATE/bug_report.md b/.github/ISSUE_TEMPLATE/bug_report.md deleted file mode 100644 index bf64440..0000000 --- a/.github/ISSUE_TEMPLATE/bug_report.md +++ /dev/null @@ -1,33 +0,0 @@ ---- -name: Bug report -about: Create a report to help us improve -title: '' -labels: bug report -assignees: '' - ---- - -**Describe the bug** -A clear and concise description of what the bug is. - -**To Reproduce** -Steps to reproduce the behavior: -1. Go to '...' -2. Click on '....' -3. Scroll down to '....' -4. See error - -**Expected behavior** -A clear and concise description of what you expected to happen. - -**Screenshots** -If applicable, add screenshots to help explain your problem. - -**System Info (please complete the following information):** - - OS: [e.g. Windows/Linux] - - Server Host [e.g. Apex/Custom] - - MC Version [e.g. 1.17/1.18] - - Plugin Version [e.g. 1.3.0/1.3.1 BETA] - -**Additional context** -Add any other context about the problem here. diff --git a/.github/ISSUE_TEMPLATE/feature_request.md b/.github/ISSUE_TEMPLATE/feature_request.md deleted file mode 100644 index 4aea407..0000000 --- a/.github/ISSUE_TEMPLATE/feature_request.md +++ /dev/null @@ -1,20 +0,0 @@ ---- -name: Feature request -about: Suggest an idea for this project -title: '' -labels: new plugin feature -assignees: '' - ---- - -**Is your feature request related to a problem? Please describe.** -A clear and concise description of what the problem is. Ex. I'm always frustrated when [...] - -**Describe the solution you'd like** -A clear and concise description of what you want to happen. - -**Describe alternatives you've considered** -A clear and concise description of any alternative solutions or features you've considered. - -**Additional context** -Add any other context or screenshots about the feature request here. diff --git a/.github/PULL_REQUEST_TEMPLATE.md b/.github/PULL_REQUEST_TEMPLATE.md deleted file mode 100644 index 977e3be..0000000 --- a/.github/PULL_REQUEST_TEMPLATE.md +++ /dev/null @@ -1,11 +0,0 @@ -**Describe the change** -A clear and concise description of what the changes are. - -**Expected behavior** -A clear and concise description of what your changes are going to do. - -**Screenshots** -If applicable, add screenshots to help explain your changes. - -**Additional context** -Add any other context about the pull request here. diff --git a/.github/workflows/beta.yml b/.github/workflows/beta.yml deleted file mode 100644 index 7adde3f..0000000 --- a/.github/workflows/beta.yml +++ /dev/null @@ -1,37 +0,0 @@ -name: Beta - -on: - push: - branches-ignore: [ main ] - -jobs: - build: - - runs-on: ubuntu-latest - - steps: - - name: Checkout branch - uses: actions/checkout@v2 - - - name: Set up JDK 1.8 - uses: actions/setup-java@v1 - with: - java-version: 1.8 - - - name: Build with Maven - run: | - mvn -B package --file pom.xml - mkdir staging && cp target/*.jar staging - - - name: Set up a cache for maven - uses: actions/cache@v2 - with: - path: ~/.m2 - key: ${{ runner.os }}-m2-${{ hashFiles('**/pom.xml') }} - restore-keys: ${{ runner.os }}-m2 - - - name: Upload artifacts - uses: actions/upload-artifact@v2 - with: - name: artifacts-beta - path: staging diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml deleted file mode 100644 index 722d1c6..0000000 --- a/.github/workflows/release.yml +++ /dev/null @@ -1,37 +0,0 @@ -name: Release - -on: - push: - branches: [ main ] - -jobs: - build: - - runs-on: ubuntu-latest - - steps: - - name: Checkout branch - uses: actions/checkout@v2 - - - name: Set up JDK 1.8 - uses: actions/setup-java@v1 - with: - java-version: 1.8 - - - name: Build with Maven - run: | - mvn -B package --file pom.xml - mkdir staging && cp target/*.jar staging - - - name: Set up a cache for maven - uses: actions/cache@v2 - with: - path: ~/.m2 - key: ${{ runner.os }}-m2-${{ hashFiles('**/pom.xml') }} - restore-keys: ${{ runner.os }}-m2 - - - name: Upload artificats - uses: actions/upload-artifact@v2 - with: - name: artifacts-release - path: staging diff --git a/lib/ProtocolLib.jar b/lib/ProtocolLib.jar new file mode 100644 index 0000000..47b952f Binary files /dev/null and b/lib/ProtocolLib.jar differ diff --git a/pom.xml b/pom.xml index 8b2a39d..df2ab1b 100644 --- a/pom.xml +++ b/pom.xml @@ -80,10 +80,10 @@ spigot-repo https://hub.spigotmc.org/nexus/content/repositories/public/ - - dmulloy2-repo - https://repo.dmulloy2.net/repository/public/ - + + + + placeholderapi https://repo.extendedclip.com/content/repositories/placeholderapi/ @@ -106,9 +106,9 @@ com.comphenix.protocol ProtocolLib - 4.4.0 - - + 4.8.0 + system + ${project.basedir}/lib/ProtocolLib.jar org.xerial diff --git a/src/main/java/net/tylermurphy/hideAndSeek/game/Disguiser.java b/src/main/java/net/tylermurphy/hideAndSeek/game/Disguiser.java index 5fce7d3..351ba10 100644 --- a/src/main/java/net/tylermurphy/hideAndSeek/game/Disguiser.java +++ b/src/main/java/net/tylermurphy/hideAndSeek/game/Disguiser.java @@ -17,6 +17,7 @@ public class Disguiser { public Disguiser(){ this.disguises = new HashMap<>(); + } public Disguise getDisguise(Player player){ diff --git a/src/main/java/net/tylermurphy/hideAndSeek/game/EntityHider.java b/src/main/java/net/tylermurphy/hideAndSeek/game/EntityHider.java index 8274655..3892f6f 100644 --- a/src/main/java/net/tylermurphy/hideAndSeek/game/EntityHider.java +++ b/src/main/java/net/tylermurphy/hideAndSeek/game/EntityHider.java @@ -235,11 +235,7 @@ public class EntityHider implements Listener { destroyEntity.getIntegerArrays().write(0, new int[]{entity.getEntityId()}); } catch (Exception e){ return false; } // Make the entity disappear - try { - manager.sendServerPacket(observer, destroyEntity); - } catch (InvocationTargetException e) { - throw new RuntimeException("Cannot send server packet.", e); - } + manager.sendServerPacket(observer, destroyEntity); } return visibleBefore; } diff --git a/src/main/java/net/tylermurphy/hideAndSeek/game/events/Glow.java b/src/main/java/net/tylermurphy/hideAndSeek/game/events/Glow.java index 8631ef5..dec23d7 100644 --- a/src/main/java/net/tylermurphy/hideAndSeek/game/events/Glow.java +++ b/src/main/java/net/tylermurphy/hideAndSeek/game/events/Glow.java @@ -6,6 +6,7 @@ import com.comphenix.protocol.ProtocolManager; import com.comphenix.protocol.events.PacketContainer; import com.comphenix.protocol.wrappers.WrappedDataWatcher; import net.tylermurphy.hideAndSeek.Main; +import net.tylermurphy.hideAndSeek.util.packet.EntityMetadataPacket; import org.bukkit.entity.Player; import java.lang.reflect.InvocationTargetException; @@ -64,22 +65,13 @@ public class Glow { } public void setGlow(Player player, Player target, boolean glowing) { - PacketContainer packet = protocolManager.createPacket(PacketType.Play.Server.ENTITY_METADATA); - packet.getIntegers().write(0, target.getEntityId()); - WrappedDataWatcher watcher = new WrappedDataWatcher(); - WrappedDataWatcher.Serializer serializer = WrappedDataWatcher.Registry.get(Byte.class); - watcher.setEntity(target); - if (glowing) { - watcher.setObject(0, serializer, (byte) (0x40)); - } else { - watcher.setObject(0, serializer, (byte) (0x0)); - } - packet.getWatchableCollectionModifier().write(0, watcher.getWatchableObjects()); - try { - protocolManager.sendServerPacket(player, packet); - } catch (InvocationTargetException e) { - e.printStackTrace(); - } + + EntityMetadataPacket packet = new EntityMetadataPacket(); + packet.setEntity(target); + packet.setGlow(glowing); + packet.writeMetadata(); + packet.send(player); + } } diff --git a/src/main/java/net/tylermurphy/hideAndSeek/util/packet/AbstractPacket.java b/src/main/java/net/tylermurphy/hideAndSeek/util/packet/AbstractPacket.java index 9293beb..4e3fc3b 100644 --- a/src/main/java/net/tylermurphy/hideAndSeek/util/packet/AbstractPacket.java +++ b/src/main/java/net/tylermurphy/hideAndSeek/util/packet/AbstractPacket.java @@ -23,9 +23,7 @@ public class AbstractPacket { } public void send(Player player){ - try { - protocolManager.sendServerPacket(player, packet); - } catch (InvocationTargetException ignored) {} + protocolManager.sendServerPacket(player, packet); } } diff --git a/src/main/java/net/tylermurphy/hideAndSeek/util/packet/EntityMetadataPacket.java b/src/main/java/net/tylermurphy/hideAndSeek/util/packet/EntityMetadataPacket.java new file mode 100644 index 0000000..d77a227 --- /dev/null +++ b/src/main/java/net/tylermurphy/hideAndSeek/util/packet/EntityMetadataPacket.java @@ -0,0 +1,70 @@ +package net.tylermurphy.hideAndSeek.util.packet; + +import com.comphenix.protocol.PacketType; +import com.comphenix.protocol.wrappers.WrappedDataValue; +import com.comphenix.protocol.wrappers.WrappedDataWatcher; +import com.comphenix.protocol.wrappers.WrappedWatchableObject; +import org.bukkit.entity.Entity; +import org.jetbrains.annotations.NotNull; + +import java.util.ArrayList; +import java.util.List; + +public class EntityMetadataPacket extends AbstractPacket { + + private final WrappedDataWatcher watcher; + private final WrappedDataWatcher.Serializer serializer; + + public EntityMetadataPacket(){ + super(PacketType.Play.Server.ENTITY_METADATA); + watcher = new WrappedDataWatcher(); + serializer = WrappedDataWatcher.Registry.get(Byte.class); + } + + public void setEntity(@NotNull Entity target){ + super.packet.getIntegers().write(0, target.getEntityId()); + watcher.setEntity(target); + } + + public void setGlow(boolean glowing){ + if (glowing) { + watcher.setObject(0, serializer, (byte) (0x40)); + } else { + watcher.setObject(0, serializer, (byte) (0x0)); + } + } + + public void writeMetadata() { + + // thank you to + // https://www.spigotmc.org/threads/unable-to-modify-entity-metadata-packet-using-protocollib-1-19-3.582442/ + + try { + // 1.19.3 And Up + Class.forName("com.comphenix.protocol.wrappers.WrappedDataValue"); + + final List wrappedDataValueList = new ArrayList<>(); + + for(final WrappedWatchableObject entry : watcher.getWatchableObjects()) { + if(entry == null) continue; + + final WrappedDataWatcher.WrappedDataWatcherObject watcherObject = entry.getWatcherObject(); + wrappedDataValueList.add( + new WrappedDataValue( + watcherObject.getIndex(), + watcherObject.getSerializer(), + entry.getRawValue() + ) + ); + } + + packet.getDataValueCollectionModifier().write(0, wrappedDataValueList); + + } catch (ClassCastException | ClassNotFoundException ignored) { + // 1.9 to 1.19.2 And Up + packet.getWatchableCollectionModifier().write(0, watcher.getWatchableObjects()); + } + + } + +} \ No newline at end of file