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