├── .github
├── FUNDING.yml
└── workflows
│ └── gradle-publish.yml
├── .gitignore
├── LICENSE
├── README.md
├── build.gradle
├── cmd.bat
├── gradle
└── wrapper
│ ├── gradle-wrapper.jar
│ └── gradle-wrapper.properties
├── gradlew
├── gradlew.bat
├── settings.gradle.kts
└── src
└── main
├── java
└── fr
│ └── anarchick
│ └── skriptpacket
│ ├── Logging.java
│ ├── Metrics.java
│ ├── SkriptPacket.java
│ ├── elements
│ ├── CustomComparators.java
│ ├── CustomConverters.java
│ ├── Types.java
│ ├── conditions
│ │ ├── IsBukkitMaterial.java
│ │ ├── IsFromClient.java
│ │ ├── IsFromServer.java
│ │ ├── IsJavaList.java
│ │ └── IsNMS.java
│ ├── deprecated
│ │ ├── ExprArrayList.java
│ │ ├── ExprBaseComponent.java
│ │ ├── ExprBukkitChatComponent.java
│ │ ├── ExprBukkitChunk.java
│ │ ├── ExprBukkitEntity.java
│ │ ├── ExprBukkitItemStack.java
│ │ ├── ExprBukkitMaterial.java
│ │ ├── ExprBukkitWorld.java
│ │ ├── ExprJavaUUID.java
│ │ ├── ExprLocationFromNMS.java
│ │ ├── ExprNMSBiomeID.java
│ │ ├── ExprNMSBlockPosition.java
│ │ ├── ExprNMSText.java
│ │ ├── ExprNewPJSON.java
│ │ ├── ExprNewWatchableObject.java
│ │ ├── ExprPJSON.java
│ │ ├── ExprReadableJson.java
│ │ ├── ExprWatchableObjectIndex.java
│ │ ├── ExprWatchableObjectValue.java
│ │ └── PJSON.java
│ ├── effects
│ │ ├── EffReceivePacket.java
│ │ ├── EffSendPacket.java
│ │ └── EffUpdateEntity.java
│ ├── events
│ │ └── EvtPacket.java
│ └── expressions
│ │ ├── datawatcher
│ │ ├── DataWatcher.java
│ │ ├── ExprDataWatcherIndex.java
│ │ ├── ExprDataWatcherIndexes.java
│ │ └── ExprNewDataWatcher.java
│ │ ├── nms
│ │ ├── ExprNMS.java
│ │ └── ExprPair.java
│ │ ├── packet
│ │ ├── ExprNewPacket.java
│ │ ├── ExprPacketClone.java
│ │ ├── ExprPacketField.java
│ │ ├── ExprPacketFields.java
│ │ ├── ExprPacketFieldsClasses.java
│ │ ├── ExprPacketMeta.java
│ │ └── ExprPacketType.java
│ │ └── utility
│ │ ├── ExprBukkitMaterial.java
│ │ ├── ExprEntityFromID.java
│ │ ├── ExprEntityID.java
│ │ ├── ExprEnum.java
│ │ ├── ExprItemFromMaterial.java
│ │ ├── ExprNumberAs.java
│ │ └── ExprNumbersAsArray.java
│ ├── packets
│ ├── BukkitPacketEvent.java
│ ├── PacketManager.java
│ ├── SPPacketAdapter.java
│ └── SkriptPacketEventListener.java
│ ├── sections
│ └── DoSection.java
│ └── util
│ ├── ArrayUtils.java
│ ├── ClassUtils.java
│ ├── NumberEnums.java
│ ├── NumberUtils.java
│ ├── Scheduling.java
│ ├── Utils.java
│ └── converters
│ ├── Converter.java
│ ├── ConverterLogic.java
│ ├── ConverterToBukkit.java
│ ├── ConverterToNMS.java
│ ├── ConverterToUtility.java
│ └── ConverterType.java
└── resources
├── config.yml
├── packet.sk
└── plugin.yml
/.github/FUNDING.yml:
--------------------------------------------------------------------------------
1 | ko_fi: Anarchick
--------------------------------------------------------------------------------
/.github/workflows/gradle-publish.yml:
--------------------------------------------------------------------------------
1 | # This workflow uses actions that are not certified by GitHub.
2 | # They are provided by a third-party and are governed by
3 | # separate terms of service, privacy policy, and support
4 | # documentation.
5 | # This workflow will build a package using Gradle and then publish it to GitHub packages when a release is created
6 | # For more information see: https://github.com/actions/setup-java/blob/main/docs/advanced-usage.md#Publishing-using-gradle
7 |
8 | name: Gradle Package
9 |
10 | on:
11 | release:
12 | types: [created]
13 |
14 | jobs:
15 | build:
16 |
17 | runs-on: ubuntu-latest
18 | permissions:
19 | contents: read
20 | packages: write
21 |
22 | steps:
23 | - uses: actions/checkout@v4
24 | - name: Set up JDK 17
25 | uses: actions/setup-java@v4
26 | with:
27 | java-version: '17'
28 | distribution: 'temurin'
29 | server-id: github # Value of the distributionManagement/repository/id field of the pom.xml
30 | settings-path: ${{ github.workspace }} # location for the settings.xml file
31 |
32 | - name: Setup Gradle
33 | uses: gradle/actions/setup-gradle@417ae3ccd767c252f5661f1ace9f835f9654f2b5 # v3.1.0
34 |
35 | - name: Build with Gradle
36 | run: ./gradlew build
37 |
38 | # The USERNAME and TOKEN need to correspond to the credentials environment variables used in
39 | # the publishing section of your build.gradle
40 | - name: Publish to GitHub Packages
41 | run: ./gradlew publish
42 | env:
43 | USERNAME: ${{ github.actor }}
44 | TOKEN: ${{ secrets.GITHUB_TOKEN }}
45 |
--------------------------------------------------------------------------------
/.gitignore:
--------------------------------------------------------------------------------
1 | # Compiled class file
2 | *.class
3 |
4 | # Log file
5 | *.log
6 |
7 | # BlueJ files
8 | *.ctxt
9 |
10 | # Mobile Tools for Java (J2ME)
11 | .mtj.tmp/
12 |
13 | # Package Files #
14 | *.jar
15 | *.war
16 | *.nar
17 | *.ear
18 | *.zip
19 | *.tar.gz
20 | *.rar
21 |
22 | # virtual machine crash logs, see http://www.java.com/en/download/help/error_hotspot.xml
23 | hs_err_pid*
24 | /bin/
25 | /target/
26 | /.gradle/
27 |
28 | # Ignore Gradle project-specific cache directory
29 | gradle/
30 | .gradle
31 | .bat
32 | settings.gradle
33 | gradlew
34 |
35 | # Ignore Gradle build output directory
36 | build
37 |
38 |
39 | # Ignore Eclipse specific
40 | .project
41 | .settings/
42 | .classpath
43 |
--------------------------------------------------------------------------------
/LICENSE:
--------------------------------------------------------------------------------
1 | MIT License
2 |
3 | Copyright (c) 2020 Anarchick
4 |
5 | Permission is hereby granted, free of charge, to any person obtaining a copy
6 | of this software and associated documentation files (the "Software"), to deal
7 | in the Software without restriction, including without limitation the rights
8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9 | copies of the Software, and to permit persons to whom the Software is
10 | furnished to do so, subject to the following conditions:
11 |
12 | The above copyright notice and this permission notice shall be included in all
13 | copies or substantial portions of the Software.
14 |
15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21 | SOFTWARE.
22 |
--------------------------------------------------------------------------------
/README.md:
--------------------------------------------------------------------------------
1 | [](http://skripthub.net/docs/?addon=skript-packet)
2 | [](https://discord.com/channels/138464183946575874/860221632852393996)
3 | [](https://ko-fi.com/R6R3VYU8L)
4 |
5 | # Skript-Packet
6 | A Skript packet addon to replace ThatPacketAddon (which is not updated) with Skript 2.5.2+
7 |
8 | # CAUTIONS
9 |
10 | ⚠️ Skript-Packet **is not** a fork of TPA, syntaxes may change ⚠️
11 | ⚠️ This plugin **is not** for beginners ⚠️
12 | ⚠️ You may have to use java NMS which is not an API ⚠️
13 | ⚠️ You **should not** use packet for the first solution if possible, do not try to use this plugin to do ScoreBoard, BossBars, Particles, or existing things ⚠️
14 |
15 | # Requirements
16 | - Recent version of Skript 2.10.0+
17 | - Stable [ProtocolLib dev build](https://ci.dmulloy2.net/job/ProtocolLib/) (does not work with v-5.1.0)
18 | - Java21+
19 | - It's highly recommended to use skript-reflect
20 | - I have only tested mc 1.20.1 and 1.21.4 **but** should work in a lot of mc versions
21 |
22 | # What is a packet
23 | The Minecraft server and your Minecraft client share information called "packets".
24 | Example of a packet:
25 | - Any movement made by an entity
26 | - Opening a gui to a player
27 | - When the player use an item
28 |
29 | The interest of manipulation of packets is to send fake information to a specific group of players, like display a fake diamond block (client side) instead of a tnt (server side).
30 | You can do a lot of things with packets, but it's really hard to understand how to use them ...
31 |
32 | - This link can help you to identify the content of a packet: https://wiki.vg/Protocol
33 | - This link can help you to identify the arguments of a packet: https://minidigger.github.io/MiniMappingViewer/
34 | - The wiki is a good start : https://github.com/Anarchick/skript-packet/wiki/Examples
35 |
36 | # Example of code using skript-packet
37 |
38 | ```applescript
39 | packet event play_client_held_item_slot:
40 | broadcast "slot changed"
41 |
42 | on packet event play_server_chat:
43 | cancel event if "%field 0 of event-packet%" contain "block.minecraft.set_spawn"
44 | ```
45 |
46 |
47 | Example of 1.16.X high level coding (does not work in other versions)
48 |
49 | ```applescript
50 | function BiomeStorage(biome: biome) :: object:
51 | set {_id} to nms biome id of {_biome}
52 | if {BiomeStorage::%{_id}%} is not set:
53 | loop 1024 times:
54 | set {_biomeId::%loop-value%} to {_id}
55 | set {BiomeStorage::%{_id}%} to {_biomeId::*} as primitive int array
56 | return {BiomeStorage::%{_id}%}
57 |
58 | import:
59 | net.minecraft.server.v1_16_R3.PacketPlayOutMapChunk
60 |
61 | effect change client side biome of [chunk] %chunk% to %biome% for %players% :
62 | trigger:
63 | await 0.toString() # Async
64 | set {_chunk} to expression-1
65 | set {_MapChunk} to new PacketPlayOutMapChunk(nms chunk of {_chunk}, 65535)
66 | set {_packet} to new play_server_map_chunk packet
67 | set field 0 of {_packet} to {_chunk}.getX()
68 | set field 1 of {_packet} to {_chunk}.getZ()
69 | set field 2 of {_packet} to {_MapChunk}.c # int
70 | set field 3 of {_packet} to {_MapChunk}.d # NBTTagCompound
71 | set field 4 of {_packet} to BiomeStorage(expression-2)
72 | set {_byte::*} to ...{_MapChunk}.f
73 | set field 5 of {_packet} to {_byte::*} # Primitive byte array
74 | set field 6 of {_packet} to {_MapChunk}.g # Represent all Tiles Entities
75 | set field 7 of {_packet} to true # Represent a full chunk, biomes are store only if true
76 | set field 8 of {_packet} to true
77 | set field 9 of {_packet} to {_} # Empty ArrayList
78 | send packet {_packet} to expression-3 without calling event
79 |
80 | command /biome [] []:
81 | permission: fakebiome.cmd
82 | trigger:
83 | delete {biome}
84 | if arg-1 is set:
85 | set {biome} to arg-1
86 | BiomeStorage({biome})
87 | send "Fake biome set to %{biome}%" to sender
88 |
89 | on async packet event play_server_map_chunk:
90 | {biome} is set
91 | field 7 of event-packet is true # Represent a full chunk, biomes are store only if true
92 | set field 4 of event-packet to BiomeStorage({biome})
93 | ```
94 |
95 |
96 | **More examples on the [wiki](https://github.com/Anarchick/skript-packet/wiki/Examples)**
97 |
--------------------------------------------------------------------------------
/build.gradle:
--------------------------------------------------------------------------------
1 | plugins {
2 | id("com.gradleup.shadow") version "8.3.3"
3 | id ("base")
4 | id("java-library")
5 | id("maven-publish")
6 | id("io.papermc.paperweight.userdev") version "2.0.0-beta.14"
7 | }
8 |
9 | repositories {
10 | maven { url 'https://hub.spigotmc.org/nexus/content/repositories/snapshots' } // Spigot
11 | maven { url 'https://repo.dmulloy2.net/nexus/repository/public/' } // ProtocolLib
12 | maven { url 'https://mvnrepository.com/artifact/org.json/json' } // DataWatcher
13 |
14 | maven { url 'https://repo.skriptlang.org/releases' } // Skript
15 | maven { url 'https://jitpack.io' }
16 |
17 | maven { url 'https://oss.sonatype.org/content/repositories/snapshots' }
18 | maven { url 'https://oss.sonatype.org/content/repositories/central' }
19 | maven {
20 | name = "jeffMediaPublic"
21 | url = uri("https://repo.jeff-media.com/public")
22 | }
23 | mavenCentral()
24 | maven { url 'https://libraries.minecraft.net' } // must be last to avoid conflicts
25 | }
26 |
27 | base {
28 | archivesName = "Skript-Packet"
29 | setVersion("3.0.1")
30 | setGroup("fr.anarchick.skriptpacket")
31 | }
32 |
33 | //version = '3.0.0'
34 | //group = 'fr.anarchick.skriptpacket'
35 |
36 | def mcVersion = '1.21'
37 | def mcSubVersion = '.4'
38 | def skriptVersion = '2.10.0'
39 | def protocolLibVersion = '5.3.0'
40 | def skriptReflectVersion = '2.4-dev1'
41 |
42 | dependencies {
43 | compileOnly (group: 'com.github.SkriptLang', name: 'Skript', version: skriptVersion) {
44 | exclude group: 'com.sk89q.worldguard', module: 'worldguard-legacy'
45 | exclude group: 'net.milkbowl.vault', module: 'Vault'
46 | }
47 | compileOnly group: 'net.md-5', name: 'bungeecord-api', version: mcVersion + '-R0.1-SNAPSHOT'
48 | compileOnly group: 'com.github.SkriptLang', name: 'skript-reflect', version: skriptReflectVersion
49 | compileOnly group: 'org.eclipse.jdt', name: 'org.eclipse.jdt.annotation', version: '2.2.600'
50 | compileOnly group: 'com.mojang', name: 'datafixerupper', version: '1.0.20' // ExprPair
51 | compileOnly group: "com.comphenix.protocol", name: "ProtocolLib", version: protocolLibVersion
52 | compileOnly group: 'org.json', name: 'json', version: '20231013'
53 | implementation("com.jeff_media:SpigotUpdateChecker:3.0.3")
54 | paperweight.paperDevBundle(mcVersion + mcSubVersion +'-R0.1-SNAPSHOT')
55 | }
56 |
57 | java {
58 | toolchain.languageVersion = JavaLanguageVersion.of(21)
59 | }
60 |
61 | tasks {
62 | compileJava {
63 | // Set the release flag. This configures what version bytecode the compiler will emit, as well as what JDK APIs are usable.
64 | // See https://openjdk.java.net/jeps/247 for more information.
65 | options.release = 21
66 | }
67 | }
68 |
69 | tasks.named('shadowJar', com.github.jengelman.gradle.plugins.shadow.tasks.ShadowJar) {
70 | relocate 'com.jeff_media.updatechecker', 'fr.anarchick.skriptpacket.updatechecker'
71 | }
72 |
73 | sourceSets {
74 | main {
75 | java {
76 | exclude 'fr/anarchick/skriptpacket/elements/deprecated/**'
77 | }
78 | }
79 | }
80 |
81 | processResources {
82 | def props = [version: version]
83 | inputs.properties props
84 | filteringCharset 'UTF-8'
85 | filesMatching('plugin.yml') {
86 | expand props
87 | }
88 | // Ensure filtering is applied correctly
89 | filter(org.apache.tools.ant.filters.ReplaceTokens, tokens: props)
90 | }
91 |
92 | [compileJava, compileTestJava]*.options*.encoding = 'UTF-8'
93 |
94 | publishing {
95 | publications {
96 | mavenJava(MavenPublication) {
97 | from components.java
98 | }
99 | }
100 | }
101 |
102 | tasks.register('export') {
103 | group = "other"
104 | description = "build gradle into external folder"
105 | def userHome = System.getenv('USERPROFILE').replace('\\', '/')
106 | def fromFile = 'build/libs/' + base.archivesName.get() + '-' + version + '-all.jar'
107 | // List of version folder to export the jar
108 | def versions = ['1.20.1', '1.21.1', '1.21.4']
109 | doLast {
110 | versions.each { ver ->
111 | def destDir = file(userHome + '/Documents/minecraft/SkriptPacket/' + ver + '/plugins')
112 | if (destDir.exists()) {
113 | copy {
114 | from fromFile
115 | into destDir
116 | rename { String fileName ->
117 | fileName.replace('-all.jar', '.jar')
118 | }
119 | }
120 | } else {
121 | println "The folder '" + destDir + "' does not exist"
122 | }
123 | }
124 | }
125 | }
126 |
127 | tasks.build.finalizedBy(tasks.export)
128 | tasks.shadowJar.finalizedBy(tasks.export)
--------------------------------------------------------------------------------
/cmd.bat:
--------------------------------------------------------------------------------
1 | @echo off
2 | cmd.exe
3 | gradle build && xcopy C:\Users\aeim\git\skript-packet\build\libs\Skript-Packet-2.1.0.jar C:\Users\aeim\Documents\minecraft\eclipse1.17\plugins\skript-packet.jar
4 | pause
--------------------------------------------------------------------------------
/gradle/wrapper/gradle-wrapper.jar:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Anarchick/skript-packet/157b5284c2d901395a079c99e2567d054366a8c6/gradle/wrapper/gradle-wrapper.jar
--------------------------------------------------------------------------------
/gradle/wrapper/gradle-wrapper.properties:
--------------------------------------------------------------------------------
1 | #Fri Oct 11 16:25:39 CEST 2024
2 | distributionBase=GRADLE_USER_HOME
3 | distributionPath=wrapper/dists
4 | distributionUrl=https\://services.gradle.org/distributions/gradle-8.12-bin.zip
5 | zipStoreBase=GRADLE_USER_HOME
6 | zipStorePath=wrapper/dists
7 |
--------------------------------------------------------------------------------
/gradlew:
--------------------------------------------------------------------------------
1 | #!/bin/sh
2 |
3 | #
4 | # Copyright © 2015-2021 the original authors.
5 | #
6 | # Licensed under the Apache License, Version 2.0 (the "License");
7 | # you may not use this file except in compliance with the License.
8 | # You may obtain a copy of the License at
9 | #
10 | # https://www.apache.org/licenses/LICENSE-2.0
11 | #
12 | # Unless required by applicable law or agreed to in writing, software
13 | # distributed under the License is distributed on an "AS IS" BASIS,
14 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15 | # See the License for the specific language governing permissions and
16 | # limitations under the License.
17 | #
18 |
19 | ##############################################################################
20 | #
21 | # Gradle start up script for POSIX generated by Gradle.
22 | #
23 | # Important for running:
24 | #
25 | # (1) You need a POSIX-compliant shell to run this script. If your /bin/sh is
26 | # noncompliant, but you have some other compliant shell such as ksh or
27 | # bash, then to run this script, type that shell name before the whole
28 | # command line, like:
29 | #
30 | # ksh Gradle
31 | #
32 | # Busybox and similar reduced shells will NOT work, because this script
33 | # requires all of these POSIX shell features:
34 | # * functions;
35 | # * expansions «$var», «${var}», «${var:-default}», «${var+SET}»,
36 | # «${var#prefix}», «${var%suffix}», and «$( cmd )»;
37 | # * compound commands having a testable exit status, especially «case»;
38 | # * various built-in commands including «command», «set», and «ulimit».
39 | #
40 | # Important for patching:
41 | #
42 | # (2) This script targets any POSIX shell, so it avoids extensions provided
43 | # by Bash, Ksh, etc; in particular arrays are avoided.
44 | #
45 | # The "traditional" practice of packing multiple parameters into a
46 | # space-separated string is a well documented source of bugs and security
47 | # problems, so this is (mostly) avoided, by progressively accumulating
48 | # options in "$@", and eventually passing that to Java.
49 | #
50 | # Where the inherited environment variables (DEFAULT_JVM_OPTS, JAVA_OPTS,
51 | # and GRADLE_OPTS) rely on word-splitting, this is performed explicitly;
52 | # see the in-line comments for details.
53 | #
54 | # There are tweaks for specific operating systems such as AIX, CygWin,
55 | # Darwin, MinGW, and NonStop.
56 | #
57 | # (3) This script is generated from the Groovy template
58 | # https://github.com/gradle/gradle/blob/master/subprojects/plugins/src/main/resources/org/gradle/api/internal/plugins/unixStartScript.txt
59 | # within the Gradle project.
60 | #
61 | # You can find Gradle at https://github.com/gradle/gradle/.
62 | #
63 | ##############################################################################
64 |
65 | # Attempt to set APP_HOME
66 |
67 | # Resolve links: $0 may be a link
68 | app_path=$0
69 |
70 | # Need this for daisy-chained symlinks.
71 | while
72 | APP_HOME=${app_path%"${app_path##*/}"} # leaves a trailing /; empty if no leading path
73 | [ -h "$app_path" ]
74 | do
75 | ls=$( ls -ld "$app_path" )
76 | link=${ls#*' -> '}
77 | case $link in #(
78 | /*) app_path=$link ;; #(
79 | *) app_path=$APP_HOME$link ;;
80 | esac
81 | done
82 |
83 | APP_HOME=$( cd "${APP_HOME:-./}" && pwd -P ) || exit
84 |
85 | APP_NAME="Gradle"
86 | APP_BASE_NAME=${0##*/}
87 |
88 | # Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script.
89 | DEFAULT_JVM_OPTS='"-Xmx64m" "-Xms64m"'
90 |
91 | # Use the maximum available, or set MAX_FD != -1 to use that value.
92 | MAX_FD=maximum
93 |
94 | warn () {
95 | echo "$*"
96 | } >&2
97 |
98 | die () {
99 | echo
100 | echo "$*"
101 | echo
102 | exit 1
103 | } >&2
104 |
105 | # OS specific support (must be 'true' or 'false').
106 | cygwin=false
107 | msys=false
108 | darwin=false
109 | nonstop=false
110 | case "$( uname )" in #(
111 | CYGWIN* ) cygwin=true ;; #(
112 | Darwin* ) darwin=true ;; #(
113 | MSYS* | MINGW* ) msys=true ;; #(
114 | NONSTOP* ) nonstop=true ;;
115 | esac
116 |
117 | CLASSPATH=$APP_HOME/gradle/wrapper/gradle-wrapper.jar
118 |
119 |
120 | # Determine the Java command to use to start the JVM.
121 | if [ -n "$JAVA_HOME" ] ; then
122 | if [ -x "$JAVA_HOME/jre/sh/java" ] ; then
123 | # IBM's JDK on AIX uses strange locations for the executables
124 | JAVACMD=$JAVA_HOME/jre/sh/java
125 | else
126 | JAVACMD=$JAVA_HOME/bin/java
127 | fi
128 | if [ ! -x "$JAVACMD" ] ; then
129 | die "ERROR: JAVA_HOME is set to an invalid directory: $JAVA_HOME
130 |
131 | Please set the JAVA_HOME variable in your environment to match the
132 | location of your Java installation."
133 | fi
134 | else
135 | JAVACMD=java
136 | which java >/dev/null 2>&1 || die "ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH.
137 |
138 | Please set the JAVA_HOME variable in your environment to match the
139 | location of your Java installation."
140 | fi
141 |
142 | # Increase the maximum file descriptors if we can.
143 | if ! "$cygwin" && ! "$darwin" && ! "$nonstop" ; then
144 | case $MAX_FD in #(
145 | max*)
146 | MAX_FD=$( ulimit -H -n ) ||
147 | warn "Could not query maximum file descriptor limit"
148 | esac
149 | case $MAX_FD in #(
150 | '' | soft) :;; #(
151 | *)
152 | ulimit -n "$MAX_FD" ||
153 | warn "Could not set maximum file descriptor limit to $MAX_FD"
154 | esac
155 | fi
156 |
157 | # Collect all arguments for the java command, stacking in reverse order:
158 | # * args from the command line
159 | # * the main class name
160 | # * -classpath
161 | # * -D...appname settings
162 | # * --module-path (only if needed)
163 | # * DEFAULT_JVM_OPTS, JAVA_OPTS, and GRADLE_OPTS environment variables.
164 |
165 | # For Cygwin or MSYS, switch paths to Windows format before running java
166 | if "$cygwin" || "$msys" ; then
167 | APP_HOME=$( cygpath --path --mixed "$APP_HOME" )
168 | CLASSPATH=$( cygpath --path --mixed "$CLASSPATH" )
169 |
170 | JAVACMD=$( cygpath --unix "$JAVACMD" )
171 |
172 | # Now convert the arguments - kludge to limit ourselves to /bin/sh
173 | for arg do
174 | if
175 | case $arg in #(
176 | -*) false ;; # don't mess with options #(
177 | /?*) t=${arg#/} t=/${t%%/*} # looks like a POSIX filepath
178 | [ -e "$t" ] ;; #(
179 | *) false ;;
180 | esac
181 | then
182 | arg=$( cygpath --path --ignore --mixed "$arg" )
183 | fi
184 | # Roll the args list around exactly as many times as the number of
185 | # args, so each arg winds up back in the position where it started, but
186 | # possibly modified.
187 | #
188 | # NB: a `for` loop captures its iteration list before it begins, so
189 | # changing the positional parameters here affects neither the number of
190 | # iterations, nor the values presented in `arg`.
191 | shift # remove old arg
192 | set -- "$@" "$arg" # push replacement arg
193 | done
194 | fi
195 |
196 | # Collect all arguments for the java command;
197 | # * $DEFAULT_JVM_OPTS, $JAVA_OPTS, and $GRADLE_OPTS can contain fragments of
198 | # shell script including quotes and variable substitutions, so put them in
199 | # double quotes to make sure that they get re-expanded; and
200 | # * put everything else in single quotes, so that it's not re-expanded.
201 |
202 | set -- \
203 | "-Dorg.gradle.appname=$APP_BASE_NAME" \
204 | -classpath "$CLASSPATH" \
205 | org.gradle.wrapper.GradleWrapperMain \
206 | "$@"
207 |
208 | # Use "xargs" to parse quoted args.
209 | #
210 | # With -n1 it outputs one arg per line, with the quotes and backslashes removed.
211 | #
212 | # In Bash we could simply go:
213 | #
214 | # readarray ARGS < <( xargs -n1 <<<"$var" ) &&
215 | # set -- "${ARGS[@]}" "$@"
216 | #
217 | # but POSIX shell has neither arrays nor command substitution, so instead we
218 | # post-process each arg (as a line of input to sed) to backslash-escape any
219 | # character that might be a shell metacharacter, then use eval to reverse
220 | # that process (while maintaining the separation between arguments), and wrap
221 | # the whole thing up as a single "set" statement.
222 | #
223 | # This will of course break if any of these variables contains a newline or
224 | # an unmatched quote.
225 | #
226 |
227 | eval "set -- $(
228 | printf '%s\n' "$DEFAULT_JVM_OPTS $JAVA_OPTS $GRADLE_OPTS" |
229 | xargs -n1 |
230 | sed ' s~[^-[:alnum:]+,./:=@_]~\\&~g; ' |
231 | tr '\n' ' '
232 | )" '"$@"'
233 |
234 | exec "$JAVACMD" "$@"
235 |
--------------------------------------------------------------------------------
/gradlew.bat:
--------------------------------------------------------------------------------
1 | @rem
2 | @rem Copyright 2015 the original author or authors.
3 | @rem
4 | @rem Licensed under the Apache License, Version 2.0 (the "License");
5 | @rem you may not use this file except in compliance with the License.
6 | @rem You may obtain a copy of the License at
7 | @rem
8 | @rem https://www.apache.org/licenses/LICENSE-2.0
9 | @rem
10 | @rem Unless required by applicable law or agreed to in writing, software
11 | @rem distributed under the License is distributed on an "AS IS" BASIS,
12 | @rem WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | @rem See the License for the specific language governing permissions and
14 | @rem limitations under the License.
15 | @rem
16 |
17 | @if "%DEBUG%" == "" @echo off
18 | @rem ##########################################################################
19 | @rem
20 | @rem Gradle startup script for Windows
21 | @rem
22 | @rem ##########################################################################
23 |
24 | @rem Set local scope for the variables with windows NT shell
25 | if "%OS%"=="Windows_NT" setlocal
26 |
27 | set DIRNAME=%~dp0
28 | if "%DIRNAME%" == "" set DIRNAME=.
29 | set APP_BASE_NAME=%~n0
30 | set APP_HOME=%DIRNAME%
31 |
32 | @rem Resolve any "." and ".." in APP_HOME to make it shorter.
33 | for %%i in ("%APP_HOME%") do set APP_HOME=%%~fi
34 |
35 | @rem Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script.
36 | set DEFAULT_JVM_OPTS="-Xmx64m" "-Xms64m"
37 |
38 | @rem Find java.exe
39 | if defined JAVA_HOME goto findJavaFromJavaHome
40 |
41 | set JAVA_EXE=java.exe
42 | %JAVA_EXE% -version >NUL 2>&1
43 | if "%ERRORLEVEL%" == "0" goto execute
44 |
45 | echo.
46 | echo ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH.
47 | echo.
48 | echo Please set the JAVA_HOME variable in your environment to match the
49 | echo location of your Java installation.
50 |
51 | goto fail
52 |
53 | :findJavaFromJavaHome
54 | set JAVA_HOME=%JAVA_HOME:"=%
55 | set JAVA_EXE=%JAVA_HOME%/bin/java.exe
56 |
57 | if exist "%JAVA_EXE%" goto execute
58 |
59 | echo.
60 | echo ERROR: JAVA_HOME is set to an invalid directory: %JAVA_HOME%
61 | echo.
62 | echo Please set the JAVA_HOME variable in your environment to match the
63 | echo location of your Java installation.
64 |
65 | goto fail
66 |
67 | :execute
68 | @rem Setup the command line
69 |
70 | set CLASSPATH=%APP_HOME%\gradle\wrapper\gradle-wrapper.jar
71 |
72 |
73 | @rem Execute Gradle
74 | "%JAVA_EXE%" %DEFAULT_JVM_OPTS% %JAVA_OPTS% %GRADLE_OPTS% "-Dorg.gradle.appname=%APP_BASE_NAME%" -classpath "%CLASSPATH%" org.gradle.wrapper.GradleWrapperMain %*
75 |
76 | :end
77 | @rem End local scope for the variables with windows NT shell
78 | if "%ERRORLEVEL%"=="0" goto mainEnd
79 |
80 | :fail
81 | rem Set variable GRADLE_EXIT_CONSOLE if you need the _script_ return code instead of
82 | rem the _cmd.exe /c_ return code!
83 | if not "" == "%GRADLE_EXIT_CONSOLE%" exit 1
84 | exit /b 1
85 |
86 | :mainEnd
87 | if "%OS%"=="Windows_NT" endlocal
88 |
89 | :omega
90 |
--------------------------------------------------------------------------------
/settings.gradle.kts:
--------------------------------------------------------------------------------
1 | rootProject.name = "Skript-Packet"
2 |
3 | pluginManagement {
4 | repositories {
5 | gradlePluginPortal()
6 | maven("https://repo.papermc.io/repository/maven-public/")
7 | }
8 | }
--------------------------------------------------------------------------------
/src/main/java/fr/anarchick/skriptpacket/Logging.java:
--------------------------------------------------------------------------------
1 | package fr.anarchick.skriptpacket;
2 |
3 | import java.util.logging.Logger;
4 |
5 | import org.bukkit.Bukkit;
6 |
7 | import net.md_5.bungee.api.ChatColor;
8 | import org.bukkit.command.ConsoleCommandSender;
9 |
10 | public class Logging {
11 |
12 | private static final String name = "&7[&bSkript-Packet&7] ";
13 | private static final ConsoleCommandSender LOGGER = Bukkit.getConsoleSender(); // Allow colored messages
14 |
15 | public static void info(String msg) {
16 | LOGGER.sendMessage(colored(name + "&7" + msg));
17 | }
18 |
19 | public static void warn(String msg) {
20 | LOGGER.sendMessage(colored(name + "&e" + msg));
21 | }
22 |
23 | public static void severe(String msg) {
24 | LOGGER.sendMessage(colored(name + "&c" + msg));
25 | }
26 |
27 | private static String colored(String input) {
28 | return ChatColor.translateAlternateColorCodes('&', input);
29 | }
30 |
31 | }
32 |
--------------------------------------------------------------------------------
/src/main/java/fr/anarchick/skriptpacket/SkriptPacket.java:
--------------------------------------------------------------------------------
1 | package fr.anarchick.skriptpacket;
2 |
3 | import ch.njol.skript.ScriptLoader;
4 | import ch.njol.skript.Skript;
5 | import ch.njol.skript.SkriptAddon;
6 | import ch.njol.skript.lang.Expression;
7 | import ch.njol.skript.util.Version;
8 | import com.jeff_media.updatechecker.UpdateCheckSource;
9 | import com.jeff_media.updatechecker.UpdateChecker;
10 | import fr.anarchick.skriptpacket.elements.Types;
11 | import fr.anarchick.skriptpacket.packets.PacketManager;
12 | import fr.anarchick.skriptpacket.packets.SkriptPacketEventListener;
13 | import fr.anarchick.skriptpacket.util.Utils;
14 | import fr.anarchick.skriptpacket.util.converters.ConverterLogic;
15 | import org.bukkit.Bukkit;
16 | import org.bukkit.event.Event;
17 | import org.bukkit.plugin.PluginManager;
18 | import org.bukkit.plugin.java.JavaPlugin;
19 |
20 | public class SkriptPacket extends JavaPlugin {
21 |
22 | private static SkriptPacket INSTANCE;
23 |
24 | public static boolean isReflectAddon = false;
25 |
26 | public static final PluginManager pluginManager = Bukkit.getServer().getPluginManager();
27 |
28 | public static final Version MINIMUM_PROTOCOLLIB_VERSION = new Version(5, 0, 0);
29 | public static final Version PROTOCOLLIB_VERSION =
30 | new Version(pluginManager.getPlugin("ProtocolLib").getDescription().getVersion());
31 |
32 | public static final Version MINIMUM_SKRIPT_VERSION = new Version(2, 7, 0);
33 | public static Version SKRIPT_VERSION;
34 | public static Version VERSION;
35 |
36 | // You have to fork Skript-Packet to enable this !!
37 | public static boolean enableDeprecated = false;
38 |
39 | @Override
40 | public void onEnable() {
41 | INSTANCE = this;
42 | VERSION = new Version(getDescription().getVersion());
43 |
44 | final PluginManager pluginManager = Bukkit.getPluginManager();
45 | isReflectAddon = pluginManager.isPluginEnabled("skript-reflect");
46 |
47 | if (isReflectAddon) {
48 | Logging.info("Support of skript-reflect wrapper enabled");
49 | }
50 |
51 | SKRIPT_VERSION = Skript.getVersion();
52 |
53 | if (SKRIPT_VERSION.isSmallerThan(MINIMUM_SKRIPT_VERSION)) {
54 | Logging.info("Your version of Skript is " + SKRIPT_VERSION);
55 | Logging.info("Skript-Packet requires that you run at least version " + MINIMUM_SKRIPT_VERSION + " of Skript");
56 | // Does not disable the plugin, cause some syntaxes can still works
57 | }
58 |
59 | if (PROTOCOLLIB_VERSION.isSmallerThan(MINIMUM_PROTOCOLLIB_VERSION)) {
60 | Logging.info("Your version of ProtocolLib is " + PROTOCOLLIB_VERSION);
61 | Logging.info("Skript-Packet requires that you run at least version " + MINIMUM_PROTOCOLLIB_VERSION + " of ProtocolLib");
62 | // Does not disable the plugin, cause some syntaxes can still works
63 | }
64 |
65 | try {
66 |
67 | if (Skript.isAcceptRegistrations()) {
68 | final SkriptAddon ADDON = Skript.registerAddon(this);
69 | Class.forName(Types.class.getName()); // Load first
70 | ADDON.loadClasses("fr.anarchick.skriptpacket", "elements");
71 | //ADDON.loadClasses("fr.anarchick.skriptpacket", "sections");
72 | }
73 |
74 | } catch ( Exception e ) {
75 | e.printStackTrace();
76 | pluginManager.disablePlugin(this);
77 | return;
78 | }
79 |
80 | ConverterLogic.loadBiomeID();
81 |
82 | // New Script Event API since https://github.com/SkriptLang/Skript/commit/751c1027d5770079a9242475a86c1bec904f0c33
83 | ScriptLoader.eventRegistry().register(ScriptLoader.ScriptPreInitEvent.class, SkriptPacketEventListener::beforeReload);
84 |
85 | int pluginId = 10270;
86 | Metrics metrics = new Metrics(this, pluginId);
87 | metrics.addCustomChart(new Metrics.SimplePie("skript_version", () ->
88 | SKRIPT_VERSION.toString()));
89 | metrics.addCustomChart(new Metrics.SimplePie("protocollib_version",
90 | () -> Utils.regexGroup("^((\\d+\\.?)+(-\\w+)?)", PROTOCOLLIB_VERSION.toString(), 1)));
91 | metrics.addCustomChart(new Metrics.SimplePie("skript-reflect_support", () ->
92 | String.valueOf(isReflectAddon)));
93 |
94 | Logging.info("is enable! Enjoy packets :D");
95 | checkUpdate();
96 | }
97 |
98 | @Override
99 | public void onDisable() {
100 | PacketManager.removeListeners();
101 | PacketManager.removeAsyncListeners();
102 | }
103 |
104 | public static SkriptPacket getInstance() {
105 | return INSTANCE;
106 | }
107 |
108 | private void checkUpdate() {
109 | new UpdateChecker(this, UpdateCheckSource.GITHUB_RELEASE_TAG, "Anarchick/skript-packet")
110 | .setDownloadLink("https://github.com/Anarchick/skript-packet/releases")
111 | .checkNow();
112 | }
113 |
114 | @SuppressWarnings({"unchecked" })
115 | public static boolean isCurrentEvent(Expression> expr, String error, Class extends Event>... clazz) {
116 | boolean result = expr.getParser().isCurrentEvent(clazz);
117 |
118 | if (!result) {
119 | Skript.error(error);
120 | }
121 |
122 | return result;
123 | }
124 |
125 | }
126 |
--------------------------------------------------------------------------------
/src/main/java/fr/anarchick/skriptpacket/elements/CustomComparators.java:
--------------------------------------------------------------------------------
1 | package fr.anarchick.skriptpacket.elements;
2 |
3 | import ch.njol.skript.aliases.ItemType;
4 | import ch.njol.skript.util.slot.Slot;
5 | import fr.anarchick.skriptpacket.Logging;
6 | import org.bukkit.Material;
7 | import org.bukkit.block.Block;
8 | import org.bukkit.inventory.ItemStack;
9 | import org.skriptlang.skript.lang.comparator.Comparators;
10 | import org.skriptlang.skript.lang.comparator.Relation;
11 |
12 | public class CustomComparators {
13 |
14 | static {
15 |
16 | Logging.info("Register Skript comparators");
17 |
18 | Comparators.registerComparator(Block.class, Material.class,
19 | (o1, o2) -> Relation.get(o1.getType().equals(o2)));
20 |
21 | Comparators.registerComparator(ItemStack.class, Material.class,
22 | (o1, o2) -> Relation.get(o1.getType().equals(o2)));
23 |
24 | Comparators.registerComparator(ItemType.class, Material.class,
25 | (o1, o2) -> Relation.get(o1.getMaterial().equals(o2)));
26 |
27 | Comparators.registerComparator(Slot.class, Material.class,
28 | (o1, o2) -> {
29 |
30 | if (o1.getItem() == null) {
31 | return Relation.get(Material.AIR.equals(o2));
32 | } else {
33 | return Relation.get(o1.getItem().getType().equals(o2));
34 | }
35 |
36 | });
37 |
38 | }
39 |
40 | }
41 |
--------------------------------------------------------------------------------
/src/main/java/fr/anarchick/skriptpacket/elements/CustomConverters.java:
--------------------------------------------------------------------------------
1 | package fr.anarchick.skriptpacket.elements;
2 |
3 | import fr.anarchick.skriptpacket.Logging;
4 |
5 | public class CustomConverters {
6 |
7 | static {
8 |
9 | Logging.info("Register Skript converters");
10 | /*
11 | Converters.registerConverter(ItemStack.class, Material.class, ItemStack::getType);
12 | */
13 | }
14 |
15 | }
16 |
--------------------------------------------------------------------------------
/src/main/java/fr/anarchick/skriptpacket/elements/Types.java:
--------------------------------------------------------------------------------
1 | package fr.anarchick.skriptpacket.elements;
2 |
3 | import ch.njol.skript.classes.ClassInfo;
4 | import ch.njol.skript.classes.Parser;
5 | import ch.njol.skript.classes.Serializer;
6 | import ch.njol.skript.expressions.base.EventValueExpression;
7 | import ch.njol.skript.lang.ParseContext;
8 | import ch.njol.skript.registrations.Classes;
9 | import ch.njol.yggdrasil.Fields;
10 | import com.comphenix.protocol.PacketType;
11 | import com.comphenix.protocol.events.PacketContainer;
12 | import fr.anarchick.skriptpacket.Logging;
13 | import fr.anarchick.skriptpacket.elements.expressions.datawatcher.DataWatcher;
14 | import fr.anarchick.skriptpacket.packets.PacketManager;
15 | import org.eclipse.jdt.annotation.Nullable;
16 | import org.jetbrains.annotations.NotNull;
17 |
18 | import java.io.StreamCorruptedException;
19 |
20 | public class Types {
21 |
22 | static {
23 |
24 | Logging.info("Register Skript types");
25 |
26 | if (Classes.getClassInfoNoError("packettype") == null) {
27 | Classes.registerClass(new ClassInfo<>(PacketType.class, "packettype")
28 | .user("packet ?types?")
29 | .name("PacketType")
30 | .since("1.0")
31 | .description("Represents the type of a packet from ProtocolLib")
32 | .usage(PacketManager.getAllPacketTypeNames())
33 | .examples("broadcast all packettypes")
34 | .defaultExpression(new EventValueExpression<>(PacketType.class))
35 | .supplier(PacketManager.PACKET_TYPES)
36 | .parser(new Parser<>() {
37 |
38 | @Override
39 | public boolean canParse(final @NotNull ParseContext context) {
40 | return true;
41 | }
42 |
43 | @Override
44 | @Nullable
45 | public PacketType parse(final @NotNull String name, final @NotNull ParseContext context) {
46 | return PacketManager.getPacketType(name);
47 | }
48 |
49 | @Override
50 | public @NotNull String toVariableNameString(PacketType packetType) {
51 | return PacketManager.getPacketName(packetType);
52 | }
53 |
54 | @Override
55 | public @NotNull String toString(PacketType packetType, int flags) {
56 | return PacketManager.getPacketName(packetType);
57 | }
58 |
59 | })
60 | .serializer(new Serializer<>() {
61 |
62 | @Override
63 | public @NotNull Fields serialize(PacketType packetType) {
64 | final Fields f = new Fields();
65 | f.putObject("packetType", PacketManager.getPacketName(packetType));
66 | return f;
67 | }
68 |
69 | @Override
70 | public void deserialize(PacketType packetType, @NotNull Fields f) {
71 | assert false;
72 | }
73 |
74 | @Override
75 | public PacketType deserialize(@NotNull Fields f) throws StreamCorruptedException {
76 | final String name = (String) f.getObject("packetType");
77 |
78 | if (name != null) {
79 | return PacketManager.getPacketType(name);
80 | }
81 |
82 | return null;
83 | }
84 |
85 | @Override
86 | @Nullable
87 | public PacketType deserialize(final @NotNull String s) {
88 | return PacketManager.getPacketType(s);
89 | }
90 |
91 | @Override
92 | public boolean mustSyncDeserialization() {
93 | return false;
94 | }
95 |
96 | @Override
97 | protected boolean canBeInstantiated() {
98 | return false;
99 | }
100 |
101 | })
102 | );
103 | }
104 |
105 | if (Classes.getClassInfoNoError("packet") == null) {
106 | Classes.registerClass(new ClassInfo<>(PacketContainer.class, "packet")
107 | .user("packets?")
108 | .name("Packet")
109 | .since("1.0")
110 | .description("Represents a packet from ProtocolLib")
111 | .usage("")
112 | .examples("")
113 | .defaultExpression(new EventValueExpression<>(PacketContainer.class))
114 | .parser(new Parser<>() {
115 |
116 | @Override
117 | public boolean canParse(final @NotNull ParseContext context) {
118 | return false;
119 | }
120 |
121 | @Override
122 | @Nullable
123 | public PacketContainer parse(final @NotNull String packet, final @NotNull ParseContext context) {
124 | return null;
125 | }
126 |
127 | @Override
128 | public @NotNull String toVariableNameString(PacketContainer packet) {
129 | return packet.toString();
130 | }
131 |
132 | @Override
133 | public @NotNull String toString(PacketContainer packet, int flags) {
134 | String str;
135 |
136 | try {
137 | str = packet.toString();
138 | } catch (Exception e) {
139 | str = "PacketContainer[type=" + packet.getType() + ", structureModifier=INVALID_DATA]";
140 | }
141 |
142 | return str;
143 | }
144 |
145 | })
146 | );
147 | }
148 |
149 | if (Classes.getClassInfoNoError("datawatcher") == null) {
150 | Classes.registerClass(new ClassInfo<>(DataWatcher.class, "datawatcher")
151 | .user("datawatchers?")
152 | .name("Datawatcher")
153 | .since("2.0")
154 | .description("A data watcher is a list of index (=integer) associate with a value (=object)")
155 | .usage("")
156 | .examples("")
157 | .parser(new Parser<>() {
158 |
159 | @Override
160 | public boolean canParse(final @NotNull ParseContext context) {
161 | return false;
162 | }
163 |
164 | @Override
165 | @Nullable
166 | public DataWatcher parse(final @NotNull String data, final @NotNull ParseContext context) {
167 | return null;
168 | }
169 |
170 | @Override
171 | public @NotNull String toVariableNameString(DataWatcher data) {
172 | return data.toJSON().toString();
173 | }
174 |
175 | @Override
176 | public @NotNull String toString(DataWatcher data, int flags) {
177 | return data.toJSON().toString();
178 | }
179 |
180 | })
181 | );
182 | }
183 |
184 | }
185 |
186 | }
187 |
--------------------------------------------------------------------------------
/src/main/java/fr/anarchick/skriptpacket/elements/conditions/IsBukkitMaterial.java:
--------------------------------------------------------------------------------
1 | package fr.anarchick.skriptpacket.elements.conditions;
2 |
3 | import ch.njol.skript.conditions.base.PropertyCondition;
4 | import ch.njol.skript.doc.Description;
5 | import ch.njol.skript.doc.Examples;
6 | import ch.njol.skript.doc.Name;
7 | import ch.njol.skript.doc.Since;
8 | import org.bukkit.Material;
9 | import org.jetbrains.annotations.NotNull;
10 |
11 | @Name("Is Bukkit Material")
12 | @Description("Check if a given object is an instance of org.bukkit.Material")
13 | @Examples("if {_something} is Bukkit Material:")
14 | @Since("2.2.0")
15 |
16 | public class IsBukkitMaterial extends PropertyCondition