diff --git a/.gitignore b/.gitignore
index 224a273..5e08fc0 100644
--- a/.gitignore
+++ b/.gitignore
@@ -23,6 +23,7 @@ dependency-reduced-pom.xml
# various other potential build files
build/
bin/
+out/
dist/
manifest.mf
diff --git a/api/pom.xml b/api/pom.xml
deleted file mode 100644
index 6f209bf..0000000
--- a/api/pom.xml
+++ /dev/null
@@ -1,24 +0,0 @@
-
- 4.0.0
-
-
- com.ruinscraft
- panilla
- 1.2.3
-
-
- panilla-api
-
-
-
-
- io.netty
- netty-all
- 4.1.24.Final
- provided
-
-
-
-
diff --git a/bukkit/out/production/resources/config.yml b/bukkit/out/production/resources/config.yml
new file mode 100644
index 0000000..5a6555e
--- /dev/null
+++ b/bukkit/out/production/resources/config.yml
@@ -0,0 +1,31 @@
+# Panilla configuration
+
+# Do not change
+configuration-version: 1.0
+
+locale-file: en_US.yml
+
+# Logging options
+logging:
+ console: false
+ chat: false
+
+# Strictness of how much you wish to enforce
+# lenient - Only prevent game-breaking things or crashes
+# average - Prevent most abusive things
+# strict - Prevent anything non-vanilla
+strictness: average
+
+# Whitelist NBT tags from being checked
+nbt-whitelist:
+# - Enchantments # 1.13+ format
+# - ench # 1.12 format
+
+# You shouldn't have to touch this.
+#
+# If you have plugins which use an excessive amount of
+# custom NBT keys, then you can raise it as high as you like.
+#
+# This is to prevent crash items which have an excessive
+# amount of NBT keys.
+max-non-minecraft-nbt-keys: 16
diff --git a/bukkit/out/production/resources/en_US.yml b/bukkit/out/production/resources/en_US.yml
new file mode 100644
index 0000000..fb664e9
--- /dev/null
+++ b/bukkit/out/production/resources/en_US.yml
@@ -0,0 +1,5 @@
+prefix: "&c"
+packet-from-dropped: Packet from %s (%s) was dropped
+packet-to-dropped: Packet to %s (%s) was dropped
+packet-dropped-reason-too-large: because it was too large (%d bytes out of protocol maximum of %d bytes)
+packet-dropped-reason-invalid-nbt: because NBT tag %s failed checks
diff --git a/bukkit/out/production/resources/es_MX.yml b/bukkit/out/production/resources/es_MX.yml
new file mode 100644
index 0000000..123866c
--- /dev/null
+++ b/bukkit/out/production/resources/es_MX.yml
@@ -0,0 +1,5 @@
+prefix: "&c"
+packet-from-dropped: Packet de %s (%s) estaba ignorado
+packet-to-dropped: Packet a %s (%s) estaba ignorado
+packet-dropped-reason-too-large: Porque es demasiado grande (%d bytes de un máximo de of %d bytes)
+packet-dropped-reason-invalid-nbt: Porque NBT etiqueta %s cheques fallidos
diff --git a/bukkit/out/production/resources/plugin.yml b/bukkit/out/production/resources/plugin.yml
new file mode 100644
index 0000000..854baff
--- /dev/null
+++ b/bukkit/out/production/resources/plugin.yml
@@ -0,0 +1,17 @@
+name: Panilla
+version: ${version}
+main: ${mainClass}
+api-version: 1.13
+description: Prevent abusive NBT and harmful packets
+authors: [royalkingkb]
+website: https://github.com/Ruinscraft/Panilla
+permissions:
+ panilla.log.chat:
+ description: View warning logs in chat if enabled in the config
+ default: op
+ panilla.bypass:
+ description: Bypass packet checks
+ default: op
+commands:
+ panilla:
+ description: Information about your Panilla instance
diff --git a/bukkit/out/production/resources/ru_RU.yml b/bukkit/out/production/resources/ru_RU.yml
new file mode 100644
index 0000000..ad6f2c9
--- /dev/null
+++ b/bukkit/out/production/resources/ru_RU.yml
@@ -0,0 +1,5 @@
+prefix: "&c"
+packet-from-dropped: Пакет от %s (%s) был удален
+packet-to-dropped: Пакет до %s (%s) был удален
+packet-dropped-reason-too-large: потому что слишком большой (%d байтов из максимальных %d байтов)
+packet-dropped-reason-invalid-nbt: потому что NBT тег %s не прошел проверку
diff --git a/bukkit/pom.xml b/bukkit/pom.xml
deleted file mode 100644
index 34068e8..0000000
--- a/bukkit/pom.xml
+++ /dev/null
@@ -1,93 +0,0 @@
-
- 4.0.0
-
-
- com.ruinscraft
- panilla
- 1.2.3
-
-
- panilla-bukkit
-
-
- com.ruinscraft.panilla.bukkit.PanillaPlugin
-
-
-
-
- org.bukkit
- bukkit
- 1.12.2-R0.1-SNAPSHOT
- provided
-
-
- com.ruinscraft
- panilla-api
- 1.2.3
- compile
-
-
- com.ruinscraft
- panilla-craftbukkit-v1_8_R3
- 1.2.3
- compile
-
-
- com.ruinscraft
- panilla-craftbukkit-v1_12_R1
- 1.2.3
- compile
-
-
- com.ruinscraft
- panilla-craftbukkit-v1_13_R2
- 1.2.3
- compile
-
-
- com.ruinscraft
- panilla-craftbukkit-v1_14_R1
- 1.2.3
- compile
-
-
-
-
-
-
- org.apache.maven.plugins
- maven-shade-plugin
- 3.1.1
-
-
- package
-
- shade
-
-
-
-
-
-
-
- src/main/resources
- true
-
- plugin.yml
-
-
-
- src/main/resources
- false
-
- **/*.java
- plugin.yml
-
-
-
- Panilla
-
-
-
diff --git a/craftbukkit-v1_12_R1/pom.xml b/craftbukkit-v1_12_R1/pom.xml
deleted file mode 100644
index 9e16fd2..0000000
--- a/craftbukkit-v1_12_R1/pom.xml
+++ /dev/null
@@ -1,29 +0,0 @@
-
- 4.0.0
-
-
- com.ruinscraft
- panilla
- 1.2.3
-
-
- panilla-craftbukkit-v1_12_R1
-
-
-
- com.ruinscraft
- panilla-api
- 1.2.3
- provided
-
-
- org.bukkit
- craftbukkit
- 1.12.2-R0.1-SNAPSHOT
- provided
-
-
-
-
diff --git a/craftbukkit-v1_13_R2/pom.xml b/craftbukkit-v1_13_R2/pom.xml
deleted file mode 100644
index 141daec..0000000
--- a/craftbukkit-v1_13_R2/pom.xml
+++ /dev/null
@@ -1,29 +0,0 @@
-
- 4.0.0
-
-
- com.ruinscraft
- panilla
- 1.2.3
-
-
- panilla-craftbukkit-v1_13_R2
-
-
-
- com.ruinscraft
- panilla-api
- 1.2.3
- provided
-
-
- org.bukkit
- craftbukkit
- 1.13.2-R0.1-SNAPSHOT
- provided
-
-
-
-
diff --git a/craftbukkit-v1_14_R1/pom.xml b/craftbukkit-v1_14_R1/pom.xml
deleted file mode 100644
index b3d3f73..0000000
--- a/craftbukkit-v1_14_R1/pom.xml
+++ /dev/null
@@ -1,29 +0,0 @@
-
- 4.0.0
-
-
- com.ruinscraft
- panilla
- 1.2.3
-
-
- panilla-craftbukkit-v1_14_R1
-
-
-
- com.ruinscraft
- panilla-api
- 1.2.3
- provided
-
-
- org.bukkit
- craftbukkit
- 1.14-R0.1-SNAPSHOT
- provided
-
-
-
-
\ No newline at end of file
diff --git a/craftbukkit-v1_8_R3/pom.xml b/craftbukkit-v1_8_R3/pom.xml
deleted file mode 100644
index 044955e..0000000
--- a/craftbukkit-v1_8_R3/pom.xml
+++ /dev/null
@@ -1,30 +0,0 @@
-
-
- 4.0.0
-
-
- panilla
- com.ruinscraft
- 1.2.3
-
-
- panilla-craftbukkit-v1_8_R3
-
-
-
- com.ruinscraft
- panilla-api
- 1.2.3
- provided
-
-
- org.bukkit
- craftbukkit
- 1.8.8-R0.1-SNAPSHOT
- provided
-
-
-
-
\ No newline at end of file
diff --git a/forge112/build.gradle b/forge112/build.gradle
new file mode 100644
index 0000000..c1f5d58
--- /dev/null
+++ b/forge112/build.gradle
@@ -0,0 +1,27 @@
+// https://docs.spongepowered.org/stable/en/plugin/internals/mcp-setup.html
+
+buildscript {
+ repositories {
+ maven {
+ name = 'forge'
+ url = 'https://files.minecraftforge.net/maven'
+ }
+ }
+
+ dependencies {
+ classpath 'net.minecraftforge.gradle:ForgeGradle:2.3-SNAPSHOT'
+ }
+}
+
+plugins {
+ id 'net.minecrell.vanillagradle.server' version '2.2-6'
+}
+
+dependencies {
+ compileOnly project(":panilla-api")
+}
+
+minecraft {
+ version = '1.12.2'
+ mappings = 'stable_39'
+}
diff --git a/forge112/src/main/java/com/ruinscraft/panilla/sponge72/ContainerCleaner.java b/forge112/src/main/java/com/ruinscraft/panilla/sponge72/ContainerCleaner.java
new file mode 100644
index 0000000..251a044
--- /dev/null
+++ b/forge112/src/main/java/com/ruinscraft/panilla/sponge72/ContainerCleaner.java
@@ -0,0 +1,43 @@
+package com.ruinscraft.panilla.sponge72;
+
+import com.ruinscraft.panilla.api.IContainerCleaner;
+import com.ruinscraft.panilla.api.IPanilla;
+import com.ruinscraft.panilla.api.IPanillaPlayer;
+import com.ruinscraft.panilla.api.nbt.checks.NbtChecks;
+import com.ruinscraft.panilla.sponge72.nbt.NbtTagCompound;
+import net.minecraft.entity.player.EntityPlayerMP;
+import net.minecraft.inventory.Container;
+import net.minecraft.item.ItemStack;
+import net.minecraft.nbt.NBTTagCompound;
+
+public class ContainerCleaner implements IContainerCleaner {
+
+ private final IPanilla panilla;
+
+ public ContainerCleaner(IPanilla panilla) {
+ this.panilla = panilla;
+ }
+
+ @Override
+ public void clean(IPanillaPlayer player) {
+ EntityPlayerMP entityPlayerMP = (EntityPlayerMP) player.getHandle();
+ Container container = entityPlayerMP.inventoryContainer;
+
+ for (int slot = 0; slot < container.inventorySlots.size(); slot++) {
+ ItemStack itemStack = container.getSlot(slot).getStack();
+
+ if (itemStack == null || !itemStack.hasTagCompound()) continue;
+
+ NBTTagCompound tag = itemStack.getTagCompound();
+
+ String failedNbt = NbtChecks.checkAll(
+ new NbtTagCompound(tag), itemStack.getItem().getClass().getSimpleName(), panilla);
+
+ if (failedNbt != null) {
+ tag.removeTag(failedNbt);
+ container.getSlot(slot).getStack().setTagCompound(tag);
+ }
+ }
+ }
+
+}
diff --git a/forge112/src/main/java/com/ruinscraft/panilla/sponge72/ProtocolConstants.java b/forge112/src/main/java/com/ruinscraft/panilla/sponge72/ProtocolConstants.java
new file mode 100644
index 0000000..011862c
--- /dev/null
+++ b/forge112/src/main/java/com/ruinscraft/panilla/sponge72/ProtocolConstants.java
@@ -0,0 +1,12 @@
+package com.ruinscraft.panilla.sponge72;
+
+import com.ruinscraft.panilla.api.IProtocolConstants;
+
+public class ProtocolConstants implements IProtocolConstants {
+
+ @Override
+ public int maxPacketSizeBytes() {
+ return 2097152; // net.minecraft.server.PacketDecompressor L33
+ }
+
+}
diff --git a/forge112/src/main/java/com/ruinscraft/panilla/sponge72/io/PacketInspector.java b/forge112/src/main/java/com/ruinscraft/panilla/sponge72/io/PacketInspector.java
new file mode 100644
index 0000000..2c82c0e
--- /dev/null
+++ b/forge112/src/main/java/com/ruinscraft/panilla/sponge72/io/PacketInspector.java
@@ -0,0 +1,113 @@
+package com.ruinscraft.panilla.sponge72.io;
+
+import com.ruinscraft.panilla.api.IPanilla;
+import com.ruinscraft.panilla.api.IPanillaPlayer;
+import com.ruinscraft.panilla.api.exception.NbtNotPermittedException;
+import com.ruinscraft.panilla.api.exception.OversizedPacketException;
+import com.ruinscraft.panilla.api.io.IPacketInspector;
+import com.ruinscraft.panilla.api.nbt.checks.NbtChecks;
+import com.ruinscraft.panilla.sponge72.nbt.NbtTagCompound;
+import io.netty.buffer.UnpooledByteBufAllocator;
+import net.minecraft.block.Block;
+import net.minecraft.entity.player.EntityPlayerMP;
+import net.minecraft.item.ItemStack;
+import net.minecraft.network.Packet;
+import net.minecraft.network.PacketBuffer;
+import net.minecraft.network.play.client.CPacketCreativeInventoryAction;
+import net.minecraft.network.play.client.CPacketCustomPayload;
+import net.minecraft.network.play.server.SPacketCustomPayload;
+import net.minecraft.network.play.server.SPacketSetSlot;
+
+import java.io.IOException;
+import java.lang.reflect.Field;
+
+public class PacketInspector implements IPacketInspector {
+
+ private final IPanilla panilla;
+
+ public PacketInspector(IPanilla panilla) {
+ this.panilla = panilla;
+ }
+
+ @Override
+ public void checkSize(Object _packet, boolean from) throws OversizedPacketException {
+ if (_packet instanceof Packet>) {
+ Packet> packet = (Packet>) _packet;
+ PacketBuffer dataSerializer = new PacketBuffer(UnpooledByteBufAllocator.DEFAULT.buffer());
+
+ int sizeBytes = 0;
+
+ try {
+ packet.readPacketData(dataSerializer);
+
+ sizeBytes = dataSerializer.readableBytes();
+
+ // https://github.com/aadnk/ProtocolLib/commit/5ec87c9d7650ae21faca9b7b3cc7ac1629870d24
+ if (packet instanceof CPacketCustomPayload || packet instanceof SPacketCustomPayload) {
+ packet.writePacketData(dataSerializer);
+ }
+ } catch (IOException e) {
+ e.printStackTrace();
+ } finally {
+ dataSerializer.release();
+ }
+
+ if (sizeBytes > panilla.getProtocolConstants().maxPacketSizeBytes()) {
+ throw new OversizedPacketException(packet.getClass().getSimpleName(), from, sizeBytes);
+ }
+ }
+ }
+
+ @Override
+ public void checkPacketPlayInSetCreativeSlot(Object _packet) throws NbtNotPermittedException {
+ if (_packet instanceof CPacketCreativeInventoryAction) {
+ CPacketCreativeInventoryAction packet = (CPacketCreativeInventoryAction) _packet;
+
+ int slot = packet.getSlotId();
+ ItemStack itemStack = packet.getStack();
+
+ if (itemStack == null || !itemStack.hasTagCompound()) return;
+
+ NbtChecks.checkPacketPlayIn(slot, new NbtTagCompound(
+ itemStack.getTagCompound()), itemStack.getItem().getClass().getSimpleName(),
+ packet.getClass().getSimpleName(), panilla);
+ }
+ }
+
+ @Override
+ public void checkPacketPlayOutSetSlot(Object _packet) throws NbtNotPermittedException {
+ if (_packet instanceof SPacketSetSlot) {
+ SPacketSetSlot packet = (SPacketSetSlot) _packet;
+
+ try {
+ Field slotField = SPacketSetSlot.class.getDeclaredField("slot");
+ Field itemStackField = SPacketSetSlot.class.getDeclaredField("item");
+
+ slotField.setAccessible(true);
+ itemStackField.setAccessible(true);
+
+ int slot = (int) slotField.get(packet);
+ ItemStack itemStack = (ItemStack) itemStackField.get(packet);
+
+ if (itemStack == null || !itemStack.hasTagCompound()) return;
+
+ NbtChecks.checkPacketPlayOut(slot, new NbtTagCompound(
+ itemStack.getTagCompound()), itemStack.getItem().getClass().getSimpleName(),
+ packet.getClass().getSimpleName(), panilla);
+ } catch (NoSuchFieldException | SecurityException | IllegalArgumentException | IllegalAccessException e) {
+ e.printStackTrace();
+ }
+ }
+ }
+
+ @Override
+ public void sendPacketPlayOutSetSlotAir(IPanillaPlayer player, int slot) {
+ // int windowId (0 for player)
+ // int slotId
+ // ItemStack item
+ SPacketSetSlot packet = new SPacketSetSlot(0, slot, new ItemStack(Block.getBlockById(0)));
+ EntityPlayerMP entityPlayerMP = (EntityPlayerMP) player.getHandle();
+ entityPlayerMP.connection.sendPacket(packet);
+ }
+
+}
diff --git a/forge112/src/main/java/com/ruinscraft/panilla/sponge72/io/PlayerInjector.java b/forge112/src/main/java/com/ruinscraft/panilla/sponge72/io/PlayerInjector.java
new file mode 100644
index 0000000..e2e5c6b
--- /dev/null
+++ b/forge112/src/main/java/com/ruinscraft/panilla/sponge72/io/PlayerInjector.java
@@ -0,0 +1,72 @@
+package com.ruinscraft.panilla.sponge72.io;
+
+import com.ruinscraft.panilla.api.IPanilla;
+import com.ruinscraft.panilla.api.IPanillaPlayer;
+import com.ruinscraft.panilla.api.PanillaLogger;
+import com.ruinscraft.panilla.api.io.IPlayerInjector;
+import com.ruinscraft.panilla.api.io.PlayerInbound;
+import com.ruinscraft.panilla.api.io.PlayerOutbound;
+import io.netty.channel.Channel;
+import net.minecraft.entity.player.EntityPlayerMP;
+import net.minecraft.network.NetworkManager;
+
+import java.lang.reflect.Field;
+
+public class PlayerInjector implements IPlayerInjector {
+
+ private final IPanilla panilla;
+ private final PanillaLogger panillaLogger;
+
+ public PlayerInjector(IPanilla panilla, PanillaLogger panillaLogger) {
+ this.panilla = panilla;
+ this.panillaLogger = panillaLogger;
+ }
+
+ private static Channel getPlayerChannel(IPanillaPlayer player) throws IllegalArgumentException {
+ EntityPlayerMP entityPlayerMP = (EntityPlayerMP) player.getHandle();
+ try {
+ Field channelField = NetworkManager.class.getField("connection");
+ channelField.setAccessible(true);
+ Channel channel = (Channel) channelField.get(entityPlayerMP.connection.netManager);
+ return channel;
+ } catch (NoSuchFieldException e) {
+ e.printStackTrace();
+ } catch (IllegalAccessException e) {
+ e.printStackTrace();
+ }
+ return null;
+ }
+
+ @Override
+ public void register(final IPanillaPlayer player) {
+ Channel channel = getPlayerChannel(player);
+
+ /* Register inbound */
+ if (channel.pipeline().get(PANILLA_CHANNEL_IN) == null) {
+ PlayerInbound inbound = new PlayerInbound(player, panilla, panillaLogger);
+ channel.pipeline().addBefore(MINECRAFT_CHANNEL_DPLX, PANILLA_CHANNEL_IN, inbound);
+ }
+
+ /* Register outbound */
+ if (channel.pipeline().get(PANILLA_CHANNEL_OUT) == null) {
+ PlayerOutbound outbound = new PlayerOutbound(player, panilla, panillaLogger);
+ channel.pipeline().addBefore(MINECRAFT_CHANNEL_DPLX, PANILLA_CHANNEL_OUT, outbound);
+ }
+ }
+
+ @Override
+ public void unregister(final IPanillaPlayer player) {
+ Channel channel = getPlayerChannel(player);
+
+ /* Unregister inbound */
+ if (channel.pipeline().get(PANILLA_CHANNEL_IN) != null) {
+ channel.pipeline().remove(PANILLA_CHANNEL_IN);
+ }
+
+ /* Unregister outbound */
+ if (channel.pipeline().get(PANILLA_CHANNEL_OUT) != null) {
+ channel.pipeline().remove(PANILLA_CHANNEL_OUT);
+ }
+ }
+
+}
diff --git a/forge112/src/main/java/com/ruinscraft/panilla/sponge72/nbt/NbtTagCompound.java b/forge112/src/main/java/com/ruinscraft/panilla/sponge72/nbt/NbtTagCompound.java
new file mode 100644
index 0000000..afb02f7
--- /dev/null
+++ b/forge112/src/main/java/com/ruinscraft/panilla/sponge72/nbt/NbtTagCompound.java
@@ -0,0 +1,58 @@
+package com.ruinscraft.panilla.sponge72.nbt;
+
+import com.ruinscraft.panilla.api.nbt.INbtTagCompound;
+import com.ruinscraft.panilla.api.nbt.INbtTagList;
+import com.ruinscraft.panilla.api.nbt.NbtDataType;
+import net.minecraft.nbt.NBTTagCompound;
+
+import java.util.Set;
+
+public class NbtTagCompound implements INbtTagCompound {
+
+ private final NBTTagCompound handle;
+
+ public NbtTagCompound(NBTTagCompound handle) {
+ this.handle = handle;
+ }
+
+ @Override
+ public boolean hasKey(String key) {
+ return handle.hasKey(key);
+ }
+
+ @Override
+ public boolean hasKeyOfType(String key, NbtDataType nbtDataType) {
+ return handle.hasKey(key, nbtDataType.id);
+ }
+
+ @Override
+ public Set getKeys() {
+ return handle.getKeySet();
+ }
+
+ @Override
+ public int getInt(String key) {
+ return handle.getInteger(key);
+ }
+
+ @Override
+ public short getShort(String key) {
+ return handle.getShort(key);
+ }
+
+ @Override
+ public String getString(String key) {
+ return handle.getString(key);
+ }
+
+ @Override
+ public INbtTagList getList(String key, NbtDataType nbtDataType) {
+ return new NbtTagList(handle.getTagList(key, nbtDataType.id));
+ }
+
+ @Override
+ public INbtTagCompound getCompound(String key) {
+ return new NbtTagCompound(handle.getCompoundTag(key));
+ }
+
+}
diff --git a/forge112/src/main/java/com/ruinscraft/panilla/sponge72/nbt/NbtTagList.java b/forge112/src/main/java/com/ruinscraft/panilla/sponge72/nbt/NbtTagList.java
new file mode 100644
index 0000000..6f3569a
--- /dev/null
+++ b/forge112/src/main/java/com/ruinscraft/panilla/sponge72/nbt/NbtTagList.java
@@ -0,0 +1,30 @@
+package com.ruinscraft.panilla.sponge72.nbt;
+
+import com.ruinscraft.panilla.api.nbt.INbtTagCompound;
+import com.ruinscraft.panilla.api.nbt.INbtTagList;
+import net.minecraft.nbt.NBTTagList;
+
+public class NbtTagList implements INbtTagList {
+
+ private final NBTTagList handle;
+
+ public NbtTagList(NBTTagList handle) {
+ this.handle = handle;
+ }
+
+ @Override
+ public INbtTagCompound getCompound(int index) {
+ return new NbtTagCompound(handle.getCompoundTagAt(index));
+ }
+
+ @Override
+ public String getString(int index) {
+ return handle.getStringTagAt(index);
+ }
+
+ @Override
+ public int size() {
+ return handle.tagCount();
+ }
+
+}
diff --git a/sponge80/build.gradle b/forge113/build.gradle
similarity index 100%
rename from sponge80/build.gradle
rename to forge113/build.gradle
diff --git a/gradle.properties b/gradle.properties
new file mode 100644
index 0000000..e9b9fd5
--- /dev/null
+++ b/gradle.properties
@@ -0,0 +1,3 @@
+# Sets default memory used for gradle commands. Can be overridden by user or command line properties.
+# This is required to provide enough memory for the Minecraft decompilation process.
+org.gradle.jvmargs=-Xmx3G
diff --git a/gradle/wrapper/gradle-wrapper.jar b/gradle/wrapper/gradle-wrapper.jar
index 5c2d1cf..30d399d 100644
Binary files a/gradle/wrapper/gradle-wrapper.jar and b/gradle/wrapper/gradle-wrapper.jar differ
diff --git a/gradle/wrapper/gradle-wrapper.properties b/gradle/wrapper/gradle-wrapper.properties
index f4d7b2b..b4f50c1 100644
--- a/gradle/wrapper/gradle-wrapper.properties
+++ b/gradle/wrapper/gradle-wrapper.properties
@@ -1,5 +1,6 @@
+#Tue May 07 19:14:41 CDT 2019
distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
-distributionUrl=https\://services.gradle.org/distributions/gradle-5.4.1-bin.zip
zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists
+distributionUrl=https\://services.gradle.org/distributions/gradle-2.14-all.zip
diff --git a/gradlew b/gradlew
index b0d6d0a..91a7e26 100644
--- a/gradlew
+++ b/gradlew
@@ -1,20 +1,4 @@
-#!/usr/bin/env sh
-
-#
-# Copyright 2015 the original author or authors.
-#
-# Licensed under the Apache License, Version 2.0 (the "License");
-# you may not use this file except in compliance with the License.
-# You may obtain a copy of the License at
-#
-# http://www.apache.org/licenses/LICENSE-2.0
-#
-# Unless required by applicable law or agreed to in writing, software
-# distributed under the License is distributed on an "AS IS" BASIS,
-# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-# See the License for the specific language governing permissions and
-# limitations under the License.
-#
+#!/usr/bin/env bash
##############################################################################
##
@@ -22,6 +6,47 @@
##
##############################################################################
+# Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script.
+DEFAULT_JVM_OPTS=""
+
+APP_NAME="Gradle"
+APP_BASE_NAME=`basename "$0"`
+
+# Use the maximum available, or set MAX_FD != -1 to use that value.
+MAX_FD="maximum"
+
+warn ( ) {
+ echo "$*"
+}
+
+die ( ) {
+ echo
+ echo "$*"
+ echo
+ exit 1
+}
+
+# OS specific support (must be 'true' or 'false').
+cygwin=false
+msys=false
+darwin=false
+case "`uname`" in
+ CYGWIN* )
+ cygwin=true
+ ;;
+ Darwin* )
+ darwin=true
+ ;;
+ MINGW* )
+ msys=true
+ ;;
+esac
+
+# For Cygwin, ensure paths are in UNIX format before anything is touched.
+if $cygwin ; then
+ [ -n "$JAVA_HOME" ] && JAVA_HOME=`cygpath --unix "$JAVA_HOME"`
+fi
+
# Attempt to set APP_HOME
# Resolve links: $0 may be a link
PRG="$0"
@@ -36,49 +61,9 @@ while [ -h "$PRG" ] ; do
fi
done
SAVED="`pwd`"
-cd "`dirname \"$PRG\"`/" >/dev/null
+cd "`dirname \"$PRG\"`/" >&-
APP_HOME="`pwd -P`"
-cd "$SAVED" >/dev/null
-
-APP_NAME="Gradle"
-APP_BASE_NAME=`basename "$0"`
-
-# Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script.
-DEFAULT_JVM_OPTS='"-Xmx64m" "-Xms64m"'
-
-# Use the maximum available, or set MAX_FD != -1 to use that value.
-MAX_FD="maximum"
-
-warn () {
- echo "$*"
-}
-
-die () {
- echo
- echo "$*"
- echo
- exit 1
-}
-
-# OS specific support (must be 'true' or 'false').
-cygwin=false
-msys=false
-darwin=false
-nonstop=false
-case "`uname`" in
- CYGWIN* )
- cygwin=true
- ;;
- Darwin* )
- darwin=true
- ;;
- MINGW* )
- msys=true
- ;;
- NONSTOP* )
- nonstop=true
- ;;
-esac
+cd "$SAVED" >&-
CLASSPATH=$APP_HOME/gradle/wrapper/gradle-wrapper.jar
@@ -105,7 +90,7 @@ location of your Java installation."
fi
# Increase the maximum file descriptors if we can.
-if [ "$cygwin" = "false" -a "$darwin" = "false" -a "$nonstop" = "false" ] ; then
+if [ "$cygwin" = "false" -a "$darwin" = "false" ] ; then
MAX_FD_LIMIT=`ulimit -H -n`
if [ $? -eq 0 ] ; then
if [ "$MAX_FD" = "maximum" -o "$MAX_FD" = "max" ] ; then
@@ -129,7 +114,6 @@ fi
if $cygwin ; then
APP_HOME=`cygpath --path --mixed "$APP_HOME"`
CLASSPATH=`cygpath --path --mixed "$CLASSPATH"`
- JAVACMD=`cygpath --unix "$JAVACMD"`
# We build the pattern for arguments to be converted via cygpath
ROOTDIRSRAW=`find -L / -maxdepth 1 -mindepth 1 -type d 2>/dev/null`
@@ -170,19 +154,11 @@ if $cygwin ; then
esac
fi
-# Escape application args
-save () {
- for i do printf %s\\n "$i" | sed "s/'/'\\\\''/g;1s/^/'/;\$s/\$/' \\\\/" ; done
- echo " "
+# Split up the JVM_OPTS And GRADLE_OPTS values into an array, following the shell quoting and substitution rules
+function splitJvmOpts() {
+ JVM_OPTS=("$@")
}
-APP_ARGS=$(save "$@")
+eval splitJvmOpts $DEFAULT_JVM_OPTS $JAVA_OPTS $GRADLE_OPTS
+JVM_OPTS[${#JVM_OPTS[*]}]="-Dorg.gradle.appname=$APP_BASE_NAME"
-# Collect all arguments for the java command, following the shell quoting and substitution rules
-eval set -- $DEFAULT_JVM_OPTS $JAVA_OPTS $GRADLE_OPTS "\"-Dorg.gradle.appname=$APP_BASE_NAME\"" -classpath "\"$CLASSPATH\"" org.gradle.wrapper.GradleWrapperMain "$APP_ARGS"
-
-# by default we should be in the correct project dir, but when run from Finder on Mac, the cwd is wrong
-if [ "$(uname)" = "Darwin" ] && [ "$HOME" = "$PWD" ]; then
- cd "$(dirname "$0")"
-fi
-
-exec "$JAVACMD" "$@"
+exec "$JAVACMD" "${JVM_OPTS[@]}" -classpath "$CLASSPATH" org.gradle.wrapper.GradleWrapperMain "$@"
diff --git a/gradlew.bat b/gradlew.bat
index 9991c50..8a0b282 100644
--- a/gradlew.bat
+++ b/gradlew.bat
@@ -1,19 +1,3 @@
-@rem
-@rem Copyright 2015 the original author or authors.
-@rem
-@rem Licensed under the Apache License, Version 2.0 (the "License");
-@rem you may not use this file except in compliance with the License.
-@rem You may obtain a copy of the License at
-@rem
-@rem http://www.apache.org/licenses/LICENSE-2.0
-@rem
-@rem Unless required by applicable law or agreed to in writing, software
-@rem distributed under the License is distributed on an "AS IS" BASIS,
-@rem WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-@rem See the License for the specific language governing permissions and
-@rem limitations under the License.
-@rem
-
@if "%DEBUG%" == "" @echo off
@rem ##########################################################################
@rem
@@ -24,14 +8,14 @@
@rem Set local scope for the variables with windows NT shell
if "%OS%"=="Windows_NT" setlocal
+@rem Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script.
+set DEFAULT_JVM_OPTS=
+
set DIRNAME=%~dp0
if "%DIRNAME%" == "" set DIRNAME=.
set APP_BASE_NAME=%~n0
set APP_HOME=%DIRNAME%
-@rem Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script.
-set DEFAULT_JVM_OPTS="-Xmx64m" "-Xms64m"
-
@rem Find java.exe
if defined JAVA_HOME goto findJavaFromJavaHome
@@ -62,9 +46,10 @@ echo location of your Java installation.
goto fail
:init
-@rem Get command-line arguments, handling Windows variants
+@rem Get command-line arguments, handling Windowz variants
if not "%OS%" == "Windows_NT" goto win9xME_args
+if "%@eval[2+2]" == "4" goto 4NT_args
:win9xME_args
@rem Slurp the command line arguments.
@@ -75,6 +60,11 @@ set _SKIP=2
if "x%~1" == "x" goto execute
set CMD_LINE_ARGS=%*
+goto execute
+
+:4NT_args
+@rem Get arguments from the 4NT Shell from JP Software
+set CMD_LINE_ARGS=%$
:execute
@rem Setup the command line
diff --git a/pom.xml b/pom.xml
deleted file mode 100644
index 2cf768f..0000000
--- a/pom.xml
+++ /dev/null
@@ -1,28 +0,0 @@
-
- 4.0.0
-
- com.ruinscraft
- panilla
- 1.2.3
- pom
-
-
- api
- bukkit
- craftbukkit-v1_12_R1
- craftbukkit-v1_13_R2
- craftbukkit-v1_14_R1
- sponge
- sponge72
- sponge80
- craftbukkit-v1_8_R3
-
-
-
- 1.8
- 1.8
-
-
-
diff --git a/settings.gradle b/settings.gradle
index c69b5c8..fba0c48 100644
--- a/settings.gradle
+++ b/settings.gradle
@@ -1,23 +1,31 @@
-/*
- * This file was generated by the Gradle 'init' task.
- */
-
rootProject.name = 'panilla'
+
+// api
include(':panilla-api')
-include(':panilla-bukkit')
+
+// bukkit
+include(':panilla-craftbukkit-v1_8_R3')
include(':panilla-craftbukkit-v1_12_R1')
include(':panilla-craftbukkit-v1_13_R2')
include(':panilla-craftbukkit-v1_14_R1')
+include(':panilla-bukkit')
+
+// sponge
+include(':panilla-forge112')
+include(':panilla-forge113')
include(':panilla-sponge')
-include(':panilla-sponge72')
-include(':panilla-sponge80')
-include(':panilla-craftbukkit-v1_8_R3')
+
+// api
project(':panilla-api').projectDir = file('api')
-project(':panilla-bukkit').projectDir = file('bukkit')
+
+// bukkit
+project(':panilla-craftbukkit-v1_8_R3').projectDir = file('craftbukkit-v1_8_R3')
project(':panilla-craftbukkit-v1_12_R1').projectDir = file('craftbukkit-v1_12_R1')
project(':panilla-craftbukkit-v1_13_R2').projectDir = file('craftbukkit-v1_13_R2')
project(':panilla-craftbukkit-v1_14_R1').projectDir = file('craftbukkit-v1_14_R1')
+project(':panilla-bukkit').projectDir = file('bukkit')
+
+// sponge
+project(':panilla-forge112').projectDir = file('forge112')
+project(':panilla-forge113').projectDir = file('forge113')
project(':panilla-sponge').projectDir = file('sponge')
-project(':panilla-sponge72').projectDir = file('sponge72')
-project(':panilla-sponge80').projectDir = file('sponge80')
-project(':panilla-craftbukkit-v1_8_R3').projectDir = file('craftbukkit-v1_8_R3')
diff --git a/sponge/build.gradle b/sponge/build.gradle
index e69de29..9c0a41a 100644
--- a/sponge/build.gradle
+++ b/sponge/build.gradle
@@ -0,0 +1,12 @@
+repositories {
+ maven {
+ name = 'sponge-repo'
+ url = 'https://repo.spongepowered.org/maven'
+ }
+}
+
+dependencies {
+ compile 'org.spongepowered:spongeapi:7.1.0'
+ compile project(":panilla-api")
+ compile project(":panilla-forge112")
+}
diff --git a/sponge/pom.xml b/sponge/pom.xml
deleted file mode 100644
index 39ac6bd..0000000
--- a/sponge/pom.xml
+++ /dev/null
@@ -1,17 +0,0 @@
-
-
- 4.0.0
-
-
- panilla
- com.ruinscraft
- 1.2.3
-
-
- panilla-sponge
-
-
-
-
\ No newline at end of file
diff --git a/sponge/src/main/java/com/ruinscraft/panilla/sponge/PanillaPlugin.java b/sponge/src/main/java/com/ruinscraft/panilla/sponge/PanillaPlugin.java
new file mode 100644
index 0000000..327d4aa
--- /dev/null
+++ b/sponge/src/main/java/com/ruinscraft/panilla/sponge/PanillaPlugin.java
@@ -0,0 +1,117 @@
+package com.ruinscraft.panilla.sponge;
+
+import com.google.inject.Inject;
+import com.ruinscraft.panilla.api.*;
+import com.ruinscraft.panilla.api.config.PConfig;
+import com.ruinscraft.panilla.api.config.PLocale;
+import com.ruinscraft.panilla.api.io.IPacketInspector;
+import com.ruinscraft.panilla.api.io.IPlayerInjector;
+import org.spongepowered.api.Game;
+import org.spongepowered.api.entity.living.player.Player;
+import org.spongepowered.api.event.Listener;
+import org.spongepowered.api.event.game.state.GameStartedServerEvent;
+import org.spongepowered.api.plugin.Plugin;
+import org.spongepowered.api.text.serializer.TextSerializers;
+import org.spongepowered.api.util.Color;
+
+import java.util.Collection;
+import java.util.Collections;
+import java.util.logging.Logger;
+
+@Plugin(id = "panilla", name = "Panilla")
+public class PanillaPlugin implements IPanilla, IPanillaPlatform {
+
+ @Inject
+ private Game game;
+ @Inject
+ private Logger logger;
+
+ private PConfig pConfig;
+ private PLocale pLocale;
+ private IProtocolConstants protocolConstants;
+ private IPlayerInjector playerInjector;
+ private IPacketInspector packetInspector;
+ private IContainerCleaner containerCleaner;
+ private IEnchantments enchantments;
+
+ @Override
+ public PConfig getPanillaConfig() {
+ return pConfig;
+ }
+
+ @Override
+ public PLocale getPanillaLocale() {
+ return pLocale;
+ }
+
+ @Override
+ public IPanillaPlatform getPlatform() {
+ return this;
+ }
+
+ @Override
+ public IProtocolConstants getProtocolConstants() {
+ return protocolConstants;
+ }
+
+ @Override
+ public IPlayerInjector getPlayerInjector() {
+ return playerInjector;
+ }
+
+ @Override
+ public IPacketInspector getPacketInspector() {
+ return packetInspector;
+ }
+
+ @Override
+ public IContainerCleaner getContainerCleaner() {
+ return containerCleaner;
+ }
+
+ @Override
+ public IEnchantments getEnchantments() {
+ return enchantments;
+ }
+
+ @Override
+ public String translateColorCodes(String string) {
+ return TextSerializers.formattingCode('&').replaceCodes(string, TextSerializers.LEGACY_FORMATTING_CODE);
+ }
+
+ @Override
+ public boolean isValidPotionColor(int bgr) {
+ int r = (bgr >> 0) & 0xFF;
+ int g = (bgr >> 8) & 0xFF;
+ int b = (bgr >> 16) & 0xFF;
+ int rgb = (r << 16) | (g << 8) | (b << 0);
+
+ Color.ofRgb(rgb); // TODO:
+
+ return true;
+ }
+
+ @Override
+ public Collection getOnlinePlayers() {
+ Collection panillaPlayers = Collections.EMPTY_SET;
+
+ for (Player player : game.getServer().getOnlinePlayers()) {
+
+ }
+
+ return panillaPlayers;
+ }
+
+ @Override
+ public Logger getLogger() {
+ return logger;
+ }
+
+ @Listener
+ public void onServerStart(GameStartedServerEvent event) {
+
+
+
+ }
+
+}
diff --git a/sponge72/build.gradle b/sponge72/build.gradle
deleted file mode 100644
index 721a12b..0000000
--- a/sponge72/build.gradle
+++ /dev/null
@@ -1,3 +0,0 @@
-dependencies {
- compileOnly 'org.spongepowered:spongeapi:7.2.0-SNAPSHOT'
-}
diff --git a/sponge72/pom.xml b/sponge72/pom.xml
deleted file mode 100644
index 47bee10..0000000
--- a/sponge72/pom.xml
+++ /dev/null
@@ -1,35 +0,0 @@
-
-
- 4.0.0
-
-
- panilla
- com.ruinscraft
- 1.2.3
-
-
- panilla-sponge72
-
-
-
- sponge-repo
- http://repo.spongepowered.org/maven
-
-
- forge-repo
- http://files.minecraftforge.net/maven
-
-
-
-
-
- org.spongepowered
- spongeapi
- 7.2.0-SNAPSHOT
- provided
-
-
-
-
\ No newline at end of file
diff --git a/sponge80/pom.xml b/sponge80/pom.xml
deleted file mode 100644
index 1d60ffd..0000000
--- a/sponge80/pom.xml
+++ /dev/null
@@ -1,15 +0,0 @@
-
-
- 4.0.0
-
-
- panilla
- com.ruinscraft
- 1.2.3
-
-
- panilla-sponge80
-
-
\ No newline at end of file