mirror of
https://github.com/plexusorg/Module-FalseOp.git
synced 2026-06-03 22:56:54 +00:00
Update for Plex 2.0
This commit is contained in:
@@ -7,12 +7,12 @@ jobs:
|
||||
runs-on: ubuntu-latest
|
||||
|
||||
steps:
|
||||
- uses: actions/checkout@v4
|
||||
- name: Set up JDK 21
|
||||
uses: actions/setup-java@v4
|
||||
- uses: actions/checkout@v6
|
||||
- name: Set up JDK 25
|
||||
uses: actions/setup-java@v5
|
||||
with:
|
||||
distribution: temurin
|
||||
java-version: 21
|
||||
java-version: 25
|
||||
cache: gradle
|
||||
- name: Build with Gradle
|
||||
run: chmod a+x gradlew && ./gradlew build --no-daemon
|
||||
+10
-6
@@ -12,21 +12,25 @@ repositories {
|
||||
url = uri("https://nexus.telesphoreo.me/repository/plex/")
|
||||
}
|
||||
|
||||
maven {
|
||||
url = uri("https://repo.codemc.io/repository/maven-releases/")
|
||||
}
|
||||
|
||||
mavenCentral()
|
||||
}
|
||||
|
||||
dependencies {
|
||||
compileOnly("io.papermc.paper:paper-api:1.21.11-R0.1-SNAPSHOT")
|
||||
compileOnly("dev.plex:server:1.6")
|
||||
implementation("net.dmulloy2:ProtocolLib:5.4.0")
|
||||
compileOnly("io.papermc.paper:paper-api:26.1.2.build.+")
|
||||
compileOnly("dev.plex:api:2.0-SNAPSHOT")
|
||||
compileOnly("com.github.retrooper:packetevents-spigot:2.12.1")
|
||||
}
|
||||
|
||||
group = "dev.plex"
|
||||
version = "1.6"
|
||||
version = "2.0-SNAPSHOT"
|
||||
description = "Module-FalseOp"
|
||||
|
||||
java {
|
||||
toolchain.languageVersion.set(JavaLanguageVersion.of(21))
|
||||
toolchain.languageVersion.set(JavaLanguageVersion.of(25))
|
||||
}
|
||||
|
||||
publishing {
|
||||
@@ -37,7 +41,7 @@ publishing {
|
||||
}
|
||||
}
|
||||
|
||||
tasks.getByName < Jar > ("jar") {
|
||||
tasks.getByName<Jar>("jar") {
|
||||
archiveBaseName.set("Module-FalseOp")
|
||||
archiveVersion.set("")
|
||||
}
|
||||
|
||||
Vendored
BIN
Binary file not shown.
+3
-1
@@ -1,7 +1,9 @@
|
||||
distributionBase=GRADLE_USER_HOME
|
||||
distributionPath=wrapper/dists
|
||||
distributionUrl=https\://services.gradle.org/distributions/gradle-9.2.1-bin.zip
|
||||
distributionUrl=https\://services.gradle.org/distributions/gradle-9.5.1-bin.zip
|
||||
networkTimeout=10000
|
||||
retries=0
|
||||
retryBackOffMs=500
|
||||
validateDistributionUrl=true
|
||||
zipStoreBase=GRADLE_USER_HOME
|
||||
zipStorePath=wrapper/dists
|
||||
|
||||
@@ -57,7 +57,7 @@
|
||||
# Darwin, MinGW, and NonStop.
|
||||
#
|
||||
# (3) This script is generated from the Groovy template
|
||||
# https://github.com/gradle/gradle/blob/HEAD/platforms/jvm/plugins-application/src/main/resources/org/gradle/api/internal/plugins/unixStartScript.txt
|
||||
# https://github.com/gradle/gradle/blob/3d91ce3b8caaf77ad09f381f43615b715b53f72c/platforms/jvm/plugins-application/src/main/resources/org/gradle/api/internal/plugins/unixStartScript.txt
|
||||
# within the Gradle project.
|
||||
#
|
||||
# You can find Gradle at https://github.com/gradle/gradle/.
|
||||
|
||||
Vendored
+10
-21
@@ -23,8 +23,8 @@
|
||||
@rem
|
||||
@rem ##########################################################################
|
||||
|
||||
@rem Set local scope for the variables with windows NT shell
|
||||
if "%OS%"=="Windows_NT" setlocal
|
||||
@rem Set local scope for the variables, and ensure extensions are enabled
|
||||
setlocal EnableExtensions
|
||||
|
||||
set DIRNAME=%~dp0
|
||||
if "%DIRNAME%"=="" set DIRNAME=.
|
||||
@@ -51,7 +51,7 @@ echo. 1>&2
|
||||
echo Please set the JAVA_HOME variable in your environment to match the 1>&2
|
||||
echo location of your Java installation. 1>&2
|
||||
|
||||
goto fail
|
||||
"%COMSPEC%" /c exit 1
|
||||
|
||||
:findJavaFromJavaHome
|
||||
set JAVA_HOME=%JAVA_HOME:"=%
|
||||
@@ -65,7 +65,7 @@ echo. 1>&2
|
||||
echo Please set the JAVA_HOME variable in your environment to match the 1>&2
|
||||
echo location of your Java installation. 1>&2
|
||||
|
||||
goto fail
|
||||
"%COMSPEC%" /c exit 1
|
||||
|
||||
:execute
|
||||
@rem Setup the command line
|
||||
@@ -73,21 +73,10 @@ goto fail
|
||||
|
||||
|
||||
@rem Execute Gradle
|
||||
"%JAVA_EXE%" %DEFAULT_JVM_OPTS% %JAVA_OPTS% %GRADLE_OPTS% "-Dorg.gradle.appname=%APP_BASE_NAME%" -jar "%APP_HOME%\gradle\wrapper\gradle-wrapper.jar" %*
|
||||
@rem endlocal doesn't take effect until after the line is parsed and variables are expanded
|
||||
@rem which allows us to clear the local environment before executing the java command
|
||||
endlocal & "%JAVA_EXE%" %DEFAULT_JVM_OPTS% %JAVA_OPTS% %GRADLE_OPTS% "-Dorg.gradle.appname=%APP_BASE_NAME%" -jar "%APP_HOME%\gradle\wrapper\gradle-wrapper.jar" %* & call :exitWithErrorLevel
|
||||
|
||||
:end
|
||||
@rem End local scope for the variables with windows NT shell
|
||||
if %ERRORLEVEL% equ 0 goto mainEnd
|
||||
|
||||
:fail
|
||||
rem Set variable GRADLE_EXIT_CONSOLE if you need the _script_ return code instead of
|
||||
rem the _cmd.exe /c_ return code!
|
||||
set EXIT_CODE=%ERRORLEVEL%
|
||||
if %EXIT_CODE% equ 0 set EXIT_CODE=1
|
||||
if not ""=="%GRADLE_EXIT_CONSOLE%" exit %EXIT_CODE%
|
||||
exit /b %EXIT_CODE%
|
||||
|
||||
:mainEnd
|
||||
if "%OS%"=="Windows_NT" endlocal
|
||||
|
||||
:omega
|
||||
:exitWithErrorLevel
|
||||
@rem Use "%COMSPEC%" /c exit to allow operators to work properly in scripts
|
||||
"%COMSPEC%" /c exit %ERRORLEVEL%
|
||||
|
||||
@@ -2,7 +2,6 @@ package dev.plex;
|
||||
|
||||
import dev.plex.listener.PlayerListener;
|
||||
import dev.plex.module.PlexModule;
|
||||
import dev.plex.util.PlexLog;
|
||||
import org.bukkit.Bukkit;
|
||||
|
||||
public class FalseOp extends PlexModule
|
||||
@@ -12,9 +11,9 @@ public class FalseOp extends PlexModule
|
||||
@Override
|
||||
public void enable()
|
||||
{
|
||||
if (!Bukkit.getPluginManager().isPluginEnabled("ProtocolLib"))
|
||||
if (!Bukkit.getPluginManager().isPluginEnabled("packetevents"))
|
||||
{
|
||||
PlexLog.error("The Plex-FalseOp module requires the ProtocolLib plugin to work.");
|
||||
api().logging().error("The FalseOp module requires the PacketEvents plugin to work.");
|
||||
return;
|
||||
}
|
||||
playerListener = new PlayerListener();
|
||||
|
||||
@@ -1,11 +1,15 @@
|
||||
package dev.plex.listener;
|
||||
|
||||
import com.comphenix.protocol.PacketType;
|
||||
import com.comphenix.protocol.ProtocolLibrary;
|
||||
import com.comphenix.protocol.ProtocolManager;
|
||||
import com.comphenix.protocol.events.*;
|
||||
import com.github.retrooper.packetevents.PacketEvents;
|
||||
import com.github.retrooper.packetevents.event.PacketListener;
|
||||
import com.github.retrooper.packetevents.event.PacketListenerCommon;
|
||||
import com.github.retrooper.packetevents.event.PacketListenerPriority;
|
||||
import com.github.retrooper.packetevents.event.PacketSendEvent;
|
||||
import com.github.retrooper.packetevents.protocol.packettype.PacketType;
|
||||
import com.github.retrooper.packetevents.wrapper.play.server.WrapperPlayServerEntityStatus;
|
||||
import io.papermc.paper.datacomponent.DataComponentTypes;
|
||||
import io.papermc.paper.registry.TypedKey;
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.GameMode;
|
||||
import org.bukkit.Location;
|
||||
import org.bukkit.Material;
|
||||
@@ -15,6 +19,7 @@ import org.bukkit.block.BlockFace;
|
||||
import org.bukkit.block.BlockType;
|
||||
import org.bukkit.block.data.BlockData;
|
||||
import org.bukkit.block.data.Directional;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.event.Event;
|
||||
import org.bukkit.event.EventHandler;
|
||||
import org.bukkit.event.block.Action;
|
||||
@@ -27,35 +32,40 @@ import org.bukkit.util.Vector;
|
||||
@SuppressWarnings("UnstableApiUsage")
|
||||
public class PlayerListener extends PlexListener
|
||||
{
|
||||
private final ProtocolManager protocolManager;
|
||||
private final PacketListener packetListener;
|
||||
private final PacketListenerCommon packetListener;
|
||||
|
||||
public PlayerListener()
|
||||
{
|
||||
protocolManager = ProtocolLibrary.getProtocolManager();
|
||||
packetListener = new PacketAdapter(plugin, ListenerPriority.NORMAL, PacketType.Play.Server.ENTITY_STATUS)
|
||||
packetListener = PacketEvents.getAPI().getEventManager().registerListener(new PacketListener()
|
||||
{
|
||||
@Override
|
||||
public void onPacketSending(PacketEvent event)
|
||||
public void onPacketSend(PacketSendEvent event)
|
||||
{
|
||||
if (event.isPlayerTemporary())
|
||||
if (event.getPacketType() != PacketType.Play.Server.ENTITY_STATUS)
|
||||
{
|
||||
return;
|
||||
}
|
||||
PacketContainer packet = event.getPacket();
|
||||
byte b;
|
||||
if (packet.getIntegers().getValues().getFirst() == event.getPlayer().getEntityId() && (b = packet.getBytes().getValues().getFirst()) >= (byte) 24 && b <= (byte) 27)
|
||||
|
||||
WrapperPlayServerEntityStatus packet = new WrapperPlayServerEntityStatus(event);
|
||||
Player player = event.getPlayer();
|
||||
if (player == null)
|
||||
{
|
||||
packet.getBytes().write(0, (byte) 28);
|
||||
return;
|
||||
}
|
||||
|
||||
int status = packet.getStatus();
|
||||
if (packet.getEntityId() == player.getEntityId() && status >= 24 && status <= 27)
|
||||
{
|
||||
packet.setStatus(28);
|
||||
event.markForReEncode(true);
|
||||
}
|
||||
}
|
||||
};
|
||||
protocolManager.addPacketListener(packetListener);
|
||||
}, PacketListenerPriority.NORMAL);
|
||||
}
|
||||
|
||||
public void cleanUp()
|
||||
{
|
||||
protocolManager.removePacketListener(packetListener);
|
||||
PacketEvents.getAPI().getEventManager().unregisterListener(packetListener);
|
||||
}
|
||||
|
||||
@EventHandler
|
||||
@@ -79,10 +89,14 @@ public class PlayerListener extends PlexListener
|
||||
ItemStack item = event.getItem();
|
||||
if (item != null)
|
||||
{
|
||||
if (item.hasData(DataComponentTypes.CAN_PLACE_ON)) {
|
||||
canPlace = item.getData(DataComponentTypes.CAN_PLACE_ON).predicates().stream().anyMatch(blockPredicate -> {
|
||||
for (TypedKey<BlockType> key : blockPredicate.blocks()) {
|
||||
if (key.key().equals(clicked.getType().asBlockType().key())) {
|
||||
if (item.hasData(DataComponentTypes.CAN_PLACE_ON))
|
||||
{
|
||||
canPlace = item.getData(DataComponentTypes.CAN_PLACE_ON).predicates().stream().anyMatch(blockPredicate ->
|
||||
{
|
||||
for (TypedKey<BlockType> key : blockPredicate.blocks())
|
||||
{
|
||||
if (key.key().equals(clicked.getType().asBlockType().key()))
|
||||
{
|
||||
return true;
|
||||
}
|
||||
}
|
||||
@@ -90,10 +104,14 @@ public class PlayerListener extends PlexListener
|
||||
});
|
||||
}
|
||||
|
||||
if (item.hasData(DataComponentTypes.CAN_BREAK)) {
|
||||
canBreak = item.getData(DataComponentTypes.CAN_BREAK).predicates().stream().anyMatch(blockPredicate -> {
|
||||
for (TypedKey<BlockType> key : blockPredicate.blocks()) {
|
||||
if (key.key().equals(clicked.getType().asBlockType().key())) {
|
||||
if (item.hasData(DataComponentTypes.CAN_BREAK))
|
||||
{
|
||||
canBreak = item.getData(DataComponentTypes.CAN_BREAK).predicates().stream().anyMatch(blockPredicate ->
|
||||
{
|
||||
for (TypedKey<BlockType> key : blockPredicate.blocks())
|
||||
{
|
||||
if (key.key().equals(clicked.getType().asBlockType().key()))
|
||||
{
|
||||
return true;
|
||||
}
|
||||
}
|
||||
@@ -133,7 +151,7 @@ public class PlayerListener extends PlexListener
|
||||
block.setBlockData(directional);
|
||||
}
|
||||
BlockPlaceEvent placeEvent = new BlockPlaceEvent(block, block.getState(), clicked, event.getItem(), player, true, player.getHandRaised());
|
||||
plugin.getServer().getPluginManager().callEvent(placeEvent);
|
||||
Bukkit.getPluginManager().callEvent(placeEvent);
|
||||
if (placeEvent.isCancelled())
|
||||
{
|
||||
block.setType(oldType);
|
||||
@@ -157,7 +175,7 @@ public class PlayerListener extends PlexListener
|
||||
return;
|
||||
}
|
||||
BlockBreakEvent breakEvent = new BlockBreakEvent(clicked, player);
|
||||
plugin.getServer().getPluginManager().callEvent(breakEvent);
|
||||
Bukkit.getPluginManager().callEvent(breakEvent);
|
||||
if (breakEvent.isCancelled())
|
||||
{
|
||||
return;
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
name: Module-FalseOp
|
||||
main: dev.plex.FalseOp
|
||||
description: Make clients think they have OP!
|
||||
version: 1.6
|
||||
version: 2.0-SNAPSHOT
|
||||
apiCompatibility: 1
|
||||
Reference in New Issue
Block a user