diff --git a/.idea/.name b/.idea/.name
new file mode 100644
index 0000000..d1b40fa
--- /dev/null
+++ b/.idea/.name
@@ -0,0 +1 @@
+VulnerabilityPatcher
\ No newline at end of file
diff --git a/.idea/compiler.xml b/.idea/compiler.xml
index 615b71c..d7bd2a1 100644
--- a/.idea/compiler.xml
+++ b/.idea/compiler.xml
@@ -2,8 +2,10 @@
-
-
+
+
+
+
\ No newline at end of file
diff --git a/.idea/gradle.xml b/.idea/gradle.xml
index c0e46b1..1aa6d66 100644
--- a/.idea/gradle.xml
+++ b/.idea/gradle.xml
@@ -1,5 +1,6 @@
+
-
+
-
+
@@ -240,7 +119,7 @@
-
+
true
@@ -259,525 +138,17 @@
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
- Minecraft
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
- 1.8
-
-
-
-
-
-
-
-
-
-
-
- me.cooljwb.vulnerabilitypatcher.VulnerabilityPatcher-Paper
-
-
-
-
-
-
-
-
-
-
-
- 1.8
-
-
-
-
-
-
-
-
-
-
-
- Gradle: com.destroystokyo.paper:paper-api:1.13.2-R0.1-SNAPSHOT
-
-
-
-
-
-
-
-
-
-
+
+
+
+
\ No newline at end of file
diff --git a/README.md b/README.md
index 9865806..90bc1b4 100644
--- a/README.md
+++ b/README.md
@@ -1,10 +1,7 @@
# VulnerabilityPatcher
**Info:**
-VulnerabilityPatcher is a light weight Paper plugin that runs on 1.13.2 servers.
-Its task is to prevent bugs in Spigot to cause issues for both the server and the players.
+VulnerabilityPatcher is a plugin that runs on 1.13 and 1.14 servers.
+Its task is to prevent bugs in Minecraft servers that causes issues/lag for the server or players.
**Patches:**
-It currently prevents 20+ vulnerabilities from being executed.
-
-**Planned:**
-- Spigot and Paper support.
+It currently prevents 20+ vulnerabilities from being executed on the server.
diff --git a/build.gradle b/build.gradle
index 7806a71..cf67a40 100644
--- a/build.gradle
+++ b/build.gradle
@@ -23,6 +23,7 @@ dependencies {
compile 'com.destroystokyo.paper:paper-api:1.13-R0.1-SNAPSHOT'
compile 'com.destroystokyo.paper:paper-api:1.14-R0.1-SNAPSHOT'
compile files('libs/Spigot-1.13.jar')
+ compile files('libs/Spigot-1.13.2.jar')
compile files('libs/Spigot-1.14.jar')
}
diff --git a/gradle.properties b/gradle.properties
index e3f35d4..85bebc1 100644
--- a/gradle.properties
+++ b/gradle.properties
@@ -1,2 +1,2 @@
pluginGroup=me.cooljwb.vulnerabilitypatcher
-pluginVersion=v0.5.1
\ No newline at end of file
+pluginVersion=v1.0-BETA
\ No newline at end of file
diff --git a/src/main/java/me/cooljwb/vulnerabilitypatcher/SMG.java b/src/main/java/me/cooljwb/vulnerabilitypatcher/SMG.java
index 99f29b8..c7b552a 100644
--- a/src/main/java/me/cooljwb/vulnerabilitypatcher/SMG.java
+++ b/src/main/java/me/cooljwb/vulnerabilitypatcher/SMG.java
@@ -45,6 +45,8 @@ public enum SMG {
BLOCK(SMG.VULNERABILITYPATCHER.msg + "&cThis block is not allowed."),
+ SWITCH(SMG.VULNERABILITYPATCHER.msg + "&cDo not switch items repeatedly."),
+
VERSION(SMG.VULNERABILITYPATCHER.msg + "&7This server utilizes %s-%s made by %s"),
NO_PERMISSION(SMG.VULNERABILITYPATCHER.msg + "&cYou do not have permission to do this."),
NOT_PLAYER(SMG.VULNERABILITYPATCHER.msg + "&cThis command can only be done in game."),
diff --git a/src/main/java/me/cooljwb/vulnerabilitypatcher/Variables.java b/src/main/java/me/cooljwb/vulnerabilitypatcher/Variables.java
index 09b3586..2e27111 100644
--- a/src/main/java/me/cooljwb/vulnerabilitypatcher/Variables.java
+++ b/src/main/java/me/cooljwb/vulnerabilitypatcher/Variables.java
@@ -3,6 +3,26 @@ package me.cooljwb.vulnerabilitypatcher;
import java.util.Arrays;
import java.util.List;
+/*
+ * Copyright 2019 CoolJWB
+ *
+ * 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.
+ */
+
+/**
+ * @author CoolJWB
+ */
+
public enum Variables {
Attributes(Arrays.asList("generic.maxhealth", "generic.followrange", "generic.knockbackresistance",
"generic.movementspeed", "generic.attackdamage", "generic.armor", "generic.armortoughness",
diff --git a/src/main/java/me/cooljwb/vulnerabilitypatcher/VulnerabilityPatcher.java b/src/main/java/me/cooljwb/vulnerabilitypatcher/VulnerabilityPatcher.java
index 917ea42..3cc63f4 100644
--- a/src/main/java/me/cooljwb/vulnerabilitypatcher/VulnerabilityPatcher.java
+++ b/src/main/java/me/cooljwb/vulnerabilitypatcher/VulnerabilityPatcher.java
@@ -1,11 +1,17 @@
package me.cooljwb.vulnerabilitypatcher;
+import me.cooljwb.vulnerabilitypatcher.commands.CommandGetLag;
import me.cooljwb.vulnerabilitypatcher.commands.CommandGetNBT;
import me.cooljwb.vulnerabilitypatcher.commands.CommandVulnerabilityPatcher;
import me.cooljwb.vulnerabilitypatcher.patches.*;
import org.bukkit.Bukkit;
+import org.bukkit.entity.Item;
import org.bukkit.event.Listener;
+import org.bukkit.inventory.ItemStack;
import org.bukkit.plugin.java.JavaPlugin;
+import org.bukkit.potion.Potion;
+
+import java.lang.reflect.Field;
import java.util.ArrayList;
import java.util.List;
import java.util.logging.Level;
@@ -38,6 +44,7 @@ public final class VulnerabilityPatcher extends JavaPlugin {
public static VulnerabilityPatcher main;
private Logger log = Logger.getLogger("Minecraft"); // Get the server logger.
private final String version = Bukkit.getVersion().substring((Bukkit.getVersion().indexOf(":") + 1), Bukkit.getVersion().indexOf(")")).trim();
+ public boolean paper = Bukkit.getVersion().contains("Paper");
public static String pluginName, pluginVersion;
public static List pluginAuthors;
@@ -45,8 +52,9 @@ public final class VulnerabilityPatcher extends JavaPlugin {
private ArrayList listeners = new ArrayList<>();
private Patches patches;
- private CommandVulnerabilityPatcher commandvulnerabilitypatcher = new CommandVulnerabilityPatcher(this);
- private CommandGetNBT commandgetnbt = new CommandGetNBT(this);
+ private CommandVulnerabilityPatcher commandvulnerabilitypatcher = new CommandVulnerabilityPatcher();
+ private CommandGetNBT commandgetnbt = new CommandGetNBT();
+ private CommandGetLag commandgetlag = new CommandGetLag();
public final Death_Items death_items = new Death_Items();
public final Disconnect_Items disconnect_items = new Disconnect_Items();
@@ -63,6 +71,7 @@ public final class VulnerabilityPatcher extends JavaPlugin {
Bukkit.getServer().getPluginCommand(CommandVulnerabilityPatcher.vulnerabilitypatcher).setExecutor(commandvulnerabilitypatcher);
Bukkit.getServer().getPluginCommand(CommandGetNBT.getnbt).setExecutor(commandgetnbt);
+ //Bukkit.getServer().getPluginCommand(CommandGetLag.getlag).setExecutor(commandgetlag);
hand_switch.runnable();
@@ -71,6 +80,15 @@ public final class VulnerabilityPatcher extends JavaPlugin {
}
}
+ public static Class> getCraftClass(String name) {
+ try {
+ return Class.forName("org.bukkit.craftbukkit.v1_14_R1." + name);
+ } catch(ClassNotFoundException e) {
+ e.printStackTrace();
+ return null;
+ }
+ }
+
private boolean version() {
switch(version) {
case "1.13":
@@ -88,7 +106,6 @@ public final class VulnerabilityPatcher extends JavaPlugin {
}
return false;
}
-
private boolean initialize() {
pluginName = this.getName();
pluginVersion = this.getDescription().getVersion();
@@ -107,13 +124,6 @@ public final class VulnerabilityPatcher extends JavaPlugin {
getConfig().options().copyDefaults(true);
saveDefaultConfig();
}
-
- public void reloadPlugin() {
- reloadConfig();
- initialize();
- patches.initialize();
- }
-
private void registerEvents() {
for(String patch : getConfig().getStringList("Patches")) {
if(Patches.devmode)
@@ -123,13 +133,13 @@ public final class VulnerabilityPatcher extends JavaPlugin {
case "DeathItems": listeners.add(new Death_Items()); break;
case "CrashItems": listeners.add(new Crash_Items()); break;
case "Books": listeners.add(new Books()); break;
- case "RougeEntity": listeners.add(new Rouge_Entity()); break;
+ case "RougeEntity": registerServerTypeEvent(); break;
case "Arrows": listeners.add(new Arrows()); break;
case "Riptide": listeners.add(new Trident_Riptide()); break;
case "FollowRange": listeners.add(new Follow_Range()); break;
case "DisconnectItems": listeners.add(new Disconnect_Items()); break;
case "EntityTag": listeners.add(new Entity_Tag()); break;
- case "Blocks": listeners.add(new Blocks()); break;
+ case "Spawner": listeners.add(new Spawner()); break;
case "StructureBlocks": listeners.add(new Structure_Blocks()); break;
case "Chunks": listeners.add(new Chunks()); break;
case "ItemFrames": listeners.add(new Item_Frames()); break;
@@ -139,4 +149,16 @@ public final class VulnerabilityPatcher extends JavaPlugin {
}
listeners.forEach(listener -> Bukkit.getPluginManager().registerEvents(listener, this)); // Register the events.
}
+ private void registerServerTypeEvent() {
+ if(paper)
+ listeners.add(new Rouge_Entity_Paper());
+ else
+ listeners.add(new Rouge_Entity_Spigot());
+ }
+
+ public void reloadPlugin() {
+ reloadConfig();
+ initialize();
+ patches.initialize();
+ }
}
diff --git a/src/main/java/me/cooljwb/vulnerabilitypatcher/commands/CommandGetLag.java b/src/main/java/me/cooljwb/vulnerabilitypatcher/commands/CommandGetLag.java
new file mode 100644
index 0000000..ec8e502
--- /dev/null
+++ b/src/main/java/me/cooljwb/vulnerabilitypatcher/commands/CommandGetLag.java
@@ -0,0 +1,47 @@
+package me.cooljwb.vulnerabilitypatcher.commands;
+
+import me.cooljwb.vulnerabilitypatcher.patches.Patches;
+import org.bukkit.Bukkit;
+import org.bukkit.Chunk;
+import org.bukkit.World;
+import org.bukkit.command.Command;
+import org.bukkit.command.CommandExecutor;
+import org.bukkit.command.CommandSender;
+
+import java.util.ArrayList;
+import java.util.Arrays;
+import java.util.HashMap;
+import java.util.Map;
+
+public class CommandGetLag extends Patches implements CommandExecutor {
+
+ public static String getlag = "getlag";
+
+ @Override
+ public boolean onCommand(CommandSender sender, Command cmd, String label, String[] args) {
+ if(cmd.getName().equalsIgnoreCase("getlag")) {
+ HashMap chunks = getChunkEntities();
+ for(Map.Entry entry : chunks.entrySet()) {
+ if((Integer)entry.getValue() > 10)
+ System.out.println(((Chunk)entry.getKey()).getWorld() + " " + ((Chunk)entry.getKey()).getX() + " " + ((Chunk)entry.getKey()).getZ());
+ }
+ }
+ return false;
+ }
+
+ public HashMap getChunkEntities() {
+ HashMap chunks = new HashMap<>();
+ for(Chunk chunk : getLoadedChunks()) {
+ chunks.put(chunk, (chunk.getEntities().length + chunk.getTileEntities().length));
+ }
+ return chunks;
+ }
+ private ArrayList getLoadedChunks() {
+ ArrayList chunks = new ArrayList<>();
+ for(World world : Bukkit.getWorlds()) {
+ chunks.addAll(Arrays.asList(world.getLoadedChunks()));
+ }
+ return chunks;
+ }
+
+}
diff --git a/src/main/java/me/cooljwb/vulnerabilitypatcher/commands/CommandGetNBT.java b/src/main/java/me/cooljwb/vulnerabilitypatcher/commands/CommandGetNBT.java
index 06cfa3d..ac2c7c3 100644
--- a/src/main/java/me/cooljwb/vulnerabilitypatcher/commands/CommandGetNBT.java
+++ b/src/main/java/me/cooljwb/vulnerabilitypatcher/commands/CommandGetNBT.java
@@ -15,11 +15,6 @@ import org.bukkit.inventory.ItemStack;
public class CommandGetNBT extends Patches implements CommandExecutor {
public static String getnbt = "getnbt";
- private VulnerabilityPatcher main;
-
- public CommandGetNBT(VulnerabilityPatcher main) {
- this.main = main;
- }
@Override
public boolean onCommand(CommandSender sender, Command cmd, String label, String[] args) {
diff --git a/src/main/java/me/cooljwb/vulnerabilitypatcher/commands/CommandVulnerabilityPatcher.java b/src/main/java/me/cooljwb/vulnerabilitypatcher/commands/CommandVulnerabilityPatcher.java
index 0631c9f..1ecfd1e 100644
--- a/src/main/java/me/cooljwb/vulnerabilitypatcher/commands/CommandVulnerabilityPatcher.java
+++ b/src/main/java/me/cooljwb/vulnerabilitypatcher/commands/CommandVulnerabilityPatcher.java
@@ -35,13 +35,8 @@ import org.bukkit.command.CommandSender;
public class CommandVulnerabilityPatcher extends Patches implements CommandExecutor {
public static String vulnerabilitypatcher = "vulnerabilitypatcher";
- private VulnerabilityPatcher main;
private Logger log = Logger.getLogger("Minecraft");
- public CommandVulnerabilityPatcher(VulnerabilityPatcher main) {
- this.main = main;
- }
-
@Override
public boolean onCommand(CommandSender sender, Command cmd, String label, String[] args) {
if(cmd.getName().equalsIgnoreCase(vulnerabilitypatcher)) {
@@ -89,7 +84,7 @@ public class CommandVulnerabilityPatcher extends Patches implements CommandExecu
main.getConfig().set("BlockedEntityTags", stringList);
main.saveConfig();
- msg(sender, SMG.BLOCKED_TAGS.msg);
+ msg(sender, String.format(SMG.BLOCKED_TAGS.msg, args[1]));
}
else
diff --git a/src/main/java/me/cooljwb/vulnerabilitypatcher/modifiers/NBTModifier.java b/src/main/java/me/cooljwb/vulnerabilitypatcher/modifiers/NBTModifier.java
index 4affbe3..e2fdac3 100644
--- a/src/main/java/me/cooljwb/vulnerabilitypatcher/modifiers/NBTModifier.java
+++ b/src/main/java/me/cooljwb/vulnerabilitypatcher/modifiers/NBTModifier.java
@@ -2,6 +2,7 @@ package me.cooljwb.vulnerabilitypatcher.modifiers;
import org.bukkit.Bukkit;
import org.bukkit.entity.Arrow;
+import org.bukkit.entity.Entity;
import org.bukkit.entity.Firework;
import org.bukkit.entity.Player;
import org.bukkit.inventory.ItemStack;
@@ -9,17 +10,39 @@ import org.bukkit.projectiles.ProjectileSource;
import java.util.logging.Logger;
+/*
+ * Copyright 2019 CoolJWB
+ *
+ * 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.
+ */
+
+/**
+ * @author CoolJWB
+ */
+
public class NBTModifier {
private Logger log = Logger.getLogger("Minecraft"); // Get the server logger.
private NBTModifier_1_13 nbt_1_13 = new NBTModifier_1_13();
+ private NBTModifier_1_13_2 nbt_1_13_2 = new NBTModifier_1_13_2();
private NBTModifier_1_14 nbt_1_14 = new NBTModifier_1_14();
public static String getVersion() {
switch(Bukkit.getVersion().substring((Bukkit.getVersion().indexOf(":") + 1), Bukkit.getVersion().indexOf(")")).trim()) {
case "1.13":
case "1.13.1":
- case "1.13.2":
return "1.13";
+ case "1.13.2":
+ return "1.13.2";
case "1.14":
case "1.14.1":
case "1.14.2":
@@ -31,10 +54,12 @@ public class NBTModifier {
}
}
- public String itemToString(ItemStack item) {
+ protected String itemToString(ItemStack item) {
switch(getVersion()) {
case "1.13":
return nbt_1_13.itemToString(item);
+ case "1.13.2":
+ return nbt_1_13_2.itemToString(item);
case "1.14":
return nbt_1_14.itemToString(item);
default:
@@ -42,69 +67,85 @@ public class NBTModifier {
}
}
- public boolean removePlayerdata(String player) {
+ protected boolean removePlayerdata(String player) {
switch(getVersion()) {
case "1.13":
return nbt_1_13.removePlayerdata(player);
+ case "1.13.2":
+ return nbt_1_13_2.removePlayerdata(player);
case "1.14":
return nbt_1_14.removePlayerdata(player);
}
return false;
}
- public void resetMeta(Player player, ItemStack item, boolean mainhand) {
+ protected void resetMeta(Player player, ItemStack item, boolean mainhand) {
switch(getVersion()) {
case "1.13":
nbt_1_13.resetMeta(player, item, mainhand);
break;
+ case "1.13.2":
+ nbt_1_13_2.resetMeta(player, item, mainhand);
+ break;
case "1.14":
nbt_1_14.resetMeta(player, item, mainhand);
break;
}
}
- public boolean isPlayer(ProjectileSource source) {
+ protected boolean isPlayer(ProjectileSource source) {
switch(getVersion()) {
case "1.13":
return nbt_1_13.isPlayer(source);
+ case "1.13.2":
+ return nbt_1_13_2.isPlayer(source);
case "1.14":
return nbt_1_14.isPlayer(source);
default:
return false;
}
}
- public double getArrowDamage(Arrow arrow) {
+ protected double getArrowDamage(Arrow arrow) {
switch(getVersion()) {
case "1.13":
return nbt_1_13.getArrowDamage(arrow);
+ case "1.13.2":
+ return nbt_1_13_2.getArrowDamage(arrow);
case "1.14":
return nbt_1_14.getArrowDamage(arrow);
default:
return 0;
}
}
- public void setArrowDamage(Arrow arrow, double amount) {
+ protected void setArrowDamage(Arrow arrow, double amount) {
switch(getVersion()) {
case "1.13":
nbt_1_13.setArrowDamage(arrow, amount);
break;
+ case "1.13.2":
+ nbt_1_13_2.setArrowDamage(arrow, amount);
+ break;
case "1.14":
nbt_1_14.setArrowDamage(arrow, amount);
break;
}
}
- public int getFireworkEffectSize(Firework firework) {
+ protected int getFireworkEffectSize(Firework firework) {
switch(getVersion()) {
case "1.13":
return nbt_1_13.getFireworkEffectSize(firework);
+ case "1.13.2":
+ return nbt_1_13_2.getFireworkEffectSize(firework);
case "1.14":
return nbt_1_14.getFireworkEffectSize(firework);
default:
return 0;
}
}
- public boolean hasFireworkLargeEffect(Firework firework) {
+ protected boolean hasFireworkLargeEffect(Firework firework) {
switch(getVersion()) {
case "1.13":
return nbt_1_13.hasFireworkLargeEffect(firework);
+ case "1.13.2":
+ return nbt_1_13_2.hasFireworkLargeEffect(firework);
case "1.14":
return nbt_1_14.hasFireworkLargeEffect(firework);
default:
@@ -116,6 +157,8 @@ public class NBTModifier {
switch(getVersion()) {
case "1.13":
return nbt_1_13.isCrashItem(item);
+ case "1.13.2":
+ return nbt_1_13_2.isCrashItem(item);
case "1.14":
return nbt_1_14.isCrashItem(item);
default:
@@ -126,6 +169,8 @@ public class NBTModifier {
switch(getVersion()) {
case "1.13":
return nbt_1_13.containsCrashItem(item);
+ case "1.13.2":
+ return nbt_1_13_2.containsCrashItem(item);
case "1.14":
return nbt_1_14.containsCrashItem(item);
default:
@@ -137,16 +182,20 @@ public class NBTModifier {
switch(getVersion()) {
case "1.13":
return nbt_1_13.isDeathItem(item);
+ case "1.13.2":
+ return nbt_1_13_2.isDeathItem(item);
case "1.14":
return nbt_1_14.isDeathItem(item);
default:
return false;
}
}
- public boolean containsDeathItem(ItemStack item) {
+ protected boolean containsDeathItem(ItemStack item) {
switch(getVersion()) {
case "1.13":
return nbt_1_13.containsDeathItem(item);
+ case "1.13.2":
+ return nbt_1_13_2.containsDeathItem(item);
case "1.14":
return nbt_1_14.containsDeathItem(item);
default:
@@ -158,6 +207,8 @@ public class NBTModifier {
switch(getVersion()) {
case "1.13":
return nbt_1_13.isDisconnectItem(item);
+ case "1.13.2":
+ return nbt_1_13_2.isDisconnectItem(item);
case "1.14":
return nbt_1_14.isDisconnectItem(item);
default:
@@ -168,14 +219,29 @@ public class NBTModifier {
switch(getVersion()) {
case "1.13":
return nbt_1_13.containsDisconnectItem(item);
+ case "1.13.2":
+ return nbt_1_13_2.containsDisconnectItem(item);
case "1.14":
return nbt_1_14.containsDisconnectItem(item);
default:
return false;
}
}
+ public void removeInvalidValues(Entity entity) {
+ switch(getVersion()) {
+ case "1.13":
+ nbt_1_13.removeInvalidValues(entity);
+ break;
+ case "1.13.2":
+ nbt_1_13_2.removeInvalidValues(entity);
+ break;
+ case "1.14":
+ nbt_1_14.removeInvalidValues(entity);
+ break;
+ }
+ }
- public boolean isDangerousEgg(ItemStack item) {
+ protected boolean isDangerousEgg(ItemStack item) {
switch(getVersion()) {
case "1.13":
return nbt_1_13.isDangerousEgg(item);
diff --git a/src/main/java/me/cooljwb/vulnerabilitypatcher/modifiers/NBTModifier_1_13.java b/src/main/java/me/cooljwb/vulnerabilitypatcher/modifiers/NBTModifier_1_13.java
index e6331b4..e1439d9 100644
--- a/src/main/java/me/cooljwb/vulnerabilitypatcher/modifiers/NBTModifier_1_13.java
+++ b/src/main/java/me/cooljwb/vulnerabilitypatcher/modifiers/NBTModifier_1_13.java
@@ -1,8 +1,10 @@
package me.cooljwb.vulnerabilitypatcher.modifiers;
+import com.mojang.brigadier.exceptions.CommandSyntaxException;
import me.cooljwb.vulnerabilitypatcher.Variables;
import me.cooljwb.vulnerabilitypatcher.VulnerabilityPatcher;
import me.cooljwb.vulnerabilitypatcher.patches.Patches;
+import net.minecraft.server.v1_13_R1.MojangsonParser;
import net.minecraft.server.v1_13_R1.NBTBase;
import net.minecraft.server.v1_13_R1.NBTTagCompound;
import net.minecraft.server.v1_13_R1.NBTTagList;
@@ -23,6 +25,26 @@ import java.io.File;
import java.util.HashMap;
import java.util.logging.*;
+/*
+ * Copyright 2019 CoolJWB
+ *
+ * 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.
+ */
+
+/**
+ * @author CoolJWB
+ */
+
public class NBTModifier_1_13 {
private Logger log = Logger.getLogger("Minecraft");
@@ -317,6 +339,16 @@ public class NBTModifier_1_13 {
}
return false;
}
+ void removeInvalidValues(Entity entity) {
+ NBTTagCompound tag = getEntityNBT(entity);
+ if(tag.toString().contains("Color:-")) {
+ try {
+ MojangsonParser.parse(tag.toString().replaceAll("Color:-", ""));
+ } catch (CommandSyntaxException e) {
+ e.printStackTrace();
+ }
+ }
+ }
boolean isDangerousEgg(ItemStack item) {
if(item != null && item.getType().name().equalsIgnoreCase("spawn_egg")) {
diff --git a/src/main/java/me/cooljwb/vulnerabilitypatcher/modifiers/NBTModifier_1_13_2.java b/src/main/java/me/cooljwb/vulnerabilitypatcher/modifiers/NBTModifier_1_13_2.java
new file mode 100644
index 0000000..15521c6
--- /dev/null
+++ b/src/main/java/me/cooljwb/vulnerabilitypatcher/modifiers/NBTModifier_1_13_2.java
@@ -0,0 +1,342 @@
+package me.cooljwb.vulnerabilitypatcher.modifiers;
+
+import com.mojang.brigadier.exceptions.CommandSyntaxException;
+import me.cooljwb.vulnerabilitypatcher.Variables;
+import me.cooljwb.vulnerabilitypatcher.VulnerabilityPatcher;
+import me.cooljwb.vulnerabilitypatcher.patches.Patches;
+import net.minecraft.server.v1_13_R2.MojangsonParser;
+import net.minecraft.server.v1_13_R2.NBTBase;
+import net.minecraft.server.v1_13_R2.NBTTagCompound;
+import net.minecraft.server.v1_13_R2.NBTTagList;
+import org.bukkit.Bukkit;
+import org.bukkit.Material;
+import org.bukkit.craftbukkit.v1_13_R2.entity.CraftEntity;
+import org.bukkit.craftbukkit.v1_13_R2.entity.CraftPlayer;
+import org.bukkit.craftbukkit.v1_13_R2.inventory.CraftItemStack;
+import org.bukkit.entity.Arrow;
+import org.bukkit.entity.Entity;
+import org.bukkit.entity.Firework;
+import org.bukkit.entity.Player;
+import org.bukkit.inventory.ItemStack;
+import org.bukkit.inventory.meta.BookMeta;
+import org.bukkit.projectiles.ProjectileSource;
+
+import java.io.File;
+import java.util.HashMap;
+import java.util.logging.Level;
+import java.util.logging.Logger;
+
+public class NBTModifier_1_13_2 {
+
+ private Logger log = Logger.getLogger("Minecraft");
+
+ /* Misc */
+ public void log(Level level, String message) {
+ log.log(level, String.format("[%s] %s", VulnerabilityPatcher.pluginName, message));
+ }
+ private void fired_countermeasure(String reason) {
+ if (Patches.devmode)
+ log(Level.INFO, String.format("Fired countermeasure in %s reason: %s", getClass().getName(), reason));
+ }
+
+ private NBTTagCompound getItemNBT(ItemStack item) {
+ if(item != null) {
+ net.minecraft.server.v1_13_R2.ItemStack nmsItemStack = CraftItemStack.asNMSCopy(item);
+ if(nmsItemStack != null)
+ return nmsItemStack.getTag();
+ }
+ return null;
+ }
+ private NBTTagCompound getEntityNBT(Entity entity) {
+ net.minecraft.server.v1_13_R2.Entity nmsEntity = ((CraftEntity)entity).getHandle();
+ NBTTagCompound tag = new NBTTagCompound();
+ nmsEntity.save(tag);
+ return tag;
+ }
+ private void setEntityNBT(Entity entity, NBTTagCompound nbtTagCompound) {
+ net.minecraft.server.v1_13_R2.Entity nmsEntity = ((CraftEntity)entity).getHandle();
+ nmsEntity.f(nbtTagCompound);
+ }
+ public NBTTagList getAttributeList(ItemStack item) {
+ NBTTagCompound itemtag = getItemNBT(item);
+
+ if(item != null && itemtag != null && itemtag.hasKey("AttributeModifiers"))
+ return getItemNBT(item).getList("AttributeModifiers", 10);
+ return null;
+ }
+ String itemToString(ItemStack item) {
+ if(item != null) {
+ net.minecraft.server.v1_13_R2.ItemStack nmsItemStack = CraftItemStack.asNMSCopy(item);
+
+ if(nmsItemStack.hasTag())
+ return nmsItemStack.getTag().toString();
+ }
+ return "";
+ }
+
+ boolean removePlayerdata(String player) {
+ if(Bukkit.getPlayer(player) != null) {
+ ((CraftEntity) Bukkit.getPlayer(player)).getHandle().f(new NBTTagCompound());
+ return true;
+ }
+ else if(Bukkit.getOfflinePlayer(player) != null) {
+ File file = new File(Bukkit.getServer().getWorldContainer() + "/world/playerdata/" + Bukkit.getOfflinePlayer(player).getUniqueId().toString() + ".dat");
+ return file.delete();
+ }
+ return false;
+ }
+ void resetMeta(Player player, ItemStack item, boolean mainhand) {
+ net.minecraft.server.v1_13_R2.ItemStack nmsItemStack = CraftItemStack.asNMSCopy(item);
+
+ if(nmsItemStack.hasTag() && nmsItemStack.getTag().hasKey("pages")) {
+ if (nmsItemStack.getTag().getList("pages", 8).toString().contains("run_command")) {
+ BookMeta meta = (BookMeta) item.getItemMeta();
+ ItemStack book = new ItemStack(Material.WRITTEN_BOOK);
+
+ meta.setPages(meta.getPages());
+ book.setItemMeta(meta);
+
+ if (mainhand)
+ player.getInventory().setItemInMainHand(book);
+ else
+ player.getInventory().setItemInOffHand(book);
+ }
+ }
+ }
+ boolean isPlayer(ProjectileSource source) {
+ return source instanceof CraftPlayer;
+ }
+ double getArrowDamage(Arrow arrow) {
+ return getEntityNBT(arrow).hasKey("damage") ? getEntityNBT(arrow).getDouble("damage") : 0;
+ }
+ void setArrowDamage(Arrow arrow, double amount) {
+ NBTTagCompound tag = getEntityNBT(arrow);
+ if(tag.hasKey("damage")) {
+ tag.setDouble("damage", amount);
+ setEntityNBT(arrow, tag);
+ }
+ }
+ int getFireworkEffectSize(Firework firework) {
+ NBTTagCompound tag = getEntityNBT(firework);
+ if(tag.hasKey("FireworksItem") && tag.getCompound("FireworksItem").hasKey("tag") && tag.getCompound("FireworksItem").getCompound("tag").hasKey("Fireworks") && tag.getCompound("FireworksItem").getCompound("tag").getCompound("Fireworks").hasKey("Explosions"))
+ return tag.getCompound("FireworksItem").getCompound("tag").getCompound("Fireworks").getList("Explosions", 10).size();
+ return 0;
+ }
+ boolean hasFireworkLargeEffect(Firework firework) {
+ NBTTagCompound tag = getEntityNBT(firework);
+ if(tag.hasKey("FireworksItem") && tag.getCompound("FireworksItem").hasKey("tag") && tag.getCompound("FireworksItem").getCompound("tag").hasKey("Fireworks") && tag.getCompound("FireworksItem").getCompound("tag").getCompound("Fireworks").hasKey("Explosions")) {
+ NBTTagList explosions = tag.getCompound("FireworksItem").getCompound("tag").getCompound("Fireworks").getList("Explosions", 10);
+ for(int x = 0; x <= (explosions.size() - 1); x++) {
+ if(explosions.getCompound(x).getInt("Type") == 1 || explosions.getCompound(x).getInt("Type") == 3)
+ return true;
+ }
+ }
+ return false;
+ }
+
+ boolean isCrashItem(ItemStack item) {
+ if(item != null) {
+ net.minecraft.server.v1_13_R2.ItemStack nmsItemStack = CraftItemStack.asNMSCopy(item);
+
+ if(nmsItemStack.getTag() != null) {
+ NBTTagCompound itemtag = nmsItemStack.getTag();
+
+ if(itemtag.toString().contains("translation.test.invalid")) {
+ fired_countermeasure("isCrashItem");
+ return true;
+ }
+ }
+ }
+ return false;
+ }
+ boolean containsCrashItem(ItemStack item) {
+ if(item != null) {
+ net.minecraft.server.v1_13_R2.ItemStack nmsItemStack = CraftItemStack.asNMSCopy(item);
+
+ if(nmsItemStack.getTag() != null) {
+ NBTTagCompound blockentitytag = nmsItemStack.getTag().getCompound("BlockEntityTag");
+ NBTTagList itemlist = blockentitytag.getList("Items", 10);
+
+ for(int a = 0; a <= itemlist.size(); a++) {
+ NBTTagCompound itemtag = itemlist.getCompound(a).getCompound("tag");
+
+ if(itemtag.toString().contains("translation.test.invalid")) {
+ fired_countermeasure("containsCrashItem");
+ return true;
+ }
+ }
+ }
+ }
+ return false;
+ }
+
+ boolean isDeathItem(ItemStack item) {
+ net.minecraft.server.v1_13_R2.ItemStack nmsItemStack = CraftItemStack.asNMSCopy(item);
+
+ if(nmsItemStack != null && nmsItemStack.hasTag())
+ return isDeathItem(nmsItemStack.getTag());
+ return false;
+ }
+ private boolean isDeathItem(NBTTagCompound item) {
+ if(item != null) {
+ NBTTagList attrlist = item.getList("AttributeModifiers", 10);
+
+ if(attrlist != null) {
+ for(int i = 0; i < attrlist.size(); i++) {
+ NBTTagCompound compound = (NBTTagCompound)attrlist.get(i);
+ if((compound.getString("Name").equalsIgnoreCase("MAX_HEALTH") || compound.getString("AttributeName").equalsIgnoreCase("generic.maxHealth")) && compound.getDouble("Amount") <= 0) {
+ fired_countermeasure("isDeathItem");
+ return true;
+ }
+ }
+ }
+ }
+ return false;
+ }
+ boolean containsDeathItem(ItemStack item) {
+ if(item != null) {
+ net.minecraft.server.v1_13_R2.ItemStack nmsItemStack = CraftItemStack.asNMSCopy(item);
+
+ if(nmsItemStack.getTag() != null) {
+ NBTTagCompound blockentitytag = nmsItemStack.getTag().getCompound("BlockEntityTag");
+ NBTTagList itemlist = blockentitytag.getList("Items", 10);
+
+ for(int a = 0; a <= itemlist.size(); a++) {
+ NBTTagList attrlist = itemlist.getCompound(a).getCompound("tag").getList("AttributeModifiers", 10);
+
+ for(int b = 0; b <= attrlist.size(); b++) {
+ String attribute_name = attrlist.getCompound(b).getString("AttributeName");
+ String name = attrlist.getCompound(b).getString("Name");
+ Double amount = attrlist.getCompound(b).getDouble("Amount");
+
+ if((name.equalsIgnoreCase("MAX_HEALTH") || attribute_name.equalsIgnoreCase("generic.maxHealth")) && amount <= 0) {
+ fired_countermeasure("containsDeathItem");
+ return true;
+ }
+ }
+ }
+ }
+ }
+ return false;
+ }
+
+ boolean isDisconnectItem(ItemStack item) {
+ net.minecraft.server.v1_13_R2.ItemStack nmsItemStack = CraftItemStack.asNMSCopy(item);
+
+ if(nmsItemStack != null && nmsItemStack.hasTag())
+ return isDisconnectItem(nmsItemStack.getTag());
+ return false;
+ }
+ private boolean isDisconnectItem(NBTTagCompound item) {
+ if(item != null) {
+ if(item.hasKey("CustomPotionColor") && item.getInt("CustomPotionColor") < 0) {
+ fired_countermeasure("isCustomPotionColorDisconnectItem");
+ return true;
+ }
+
+
+ else if((item.getCompound("display").hasKey("color") && item.getCompound("display").getInt("color") < 0)) {
+ fired_countermeasure("isDisplayColorDisconnectItem");
+ return true;
+ }
+
+ else if(item.getCompound("BlockEntityTag").hasKey("Patterns")) {
+ NBTTagList patterns = item.getCompound("BlockEntityTag").getList("Patterns", 10);
+ for(int x = 0; x <= (patterns.size() - 1); x++) {
+ if(patterns.get(x).getTypeId() == 10) {
+ if(patterns.getCompound(x).hasKey("Color") && patterns.getCompound(x).getInt("Color") < 0)
+ return true;
+ }
+ }
+
+ for(NBTBase base : item.getCompound("BlockEntityTag").getList("Patterns", 10)) {
+ if(base.asString().contains("Color:-1")) {
+ fired_countermeasure("isDisplayBannedColorDisconnectItem");
+ return true;
+ }
+ }
+ }
+
+ else if(item.toString().length() > 60000 || isMovementDisconnectItem(item) || isInvalidAttributeName(item)) {
+ fired_countermeasure("isLargeNBTDisconnectItem");
+ return true;
+ }
+ }
+ return false;
+ }
+ boolean containsDisconnectItem(ItemStack item) {
+ if(item != null) {
+ net.minecraft.server.v1_13_R2.ItemStack nmsItemStack = CraftItemStack.asNMSCopy(item);
+
+ if(nmsItemStack != null && nmsItemStack.getTag() != null) {
+ NBTTagList items = nmsItemStack.getTag().getCompound("BlockEntityTag").getList("Items", 10);
+
+ if(items != null) {
+ for (int a = 0; a <= items.size(); a++) {
+ NBTTagCompound nmsitem = items.getCompound(a);
+ return isDisconnectItem(nmsitem.getCompound("tag"));
+ }
+ }
+ }
+ }
+ return false;
+ }
+ private boolean isMovementDisconnectItem(NBTTagCompound tag) {
+ if(tag != null) {
+ NBTTagList attrlist = tag.getList("AttributeModifiers", 10);
+ if(attrlist != null) {
+ HashMap attributes = new HashMap<>();
+
+ for(int a = 0; a <= attrlist.size(); a++) {
+ NBTTagCompound attribute = attrlist.getCompound(a);
+
+ if(attribute.getString("AttributeName").equalsIgnoreCase("generic.movementspeed") && attributes.containsKey(attribute.getString("AttributeName").toLowerCase()) && !Float.isFinite(attribute.getFloat("Amount"))) {
+ fired_countermeasure("isMovementDisconnectItem");
+ return true;
+ }
+
+ attributes.put(attribute.getString("AttributeName").toLowerCase(), attribute.getFloat("Amount"));
+ }
+ }
+ }
+ return false;
+ }
+ private boolean isInvalidAttributeName(NBTTagCompound tag) {
+ if(tag != null) {
+ NBTTagList attrlist = tag.getList("AttributeModifiers", 10);
+
+ if(attrlist != null) {
+ for(int a = 0; a <= attrlist.size(); a++) {
+ NBTTagCompound attribute = attrlist.getCompound(a);
+
+ if(attribute != null && attribute.getString("AttributeName").toLowerCase() != "") {
+ if(!Variables.Attributes.liststr.contains(attribute.getString("AttributeName").toLowerCase())) {
+ fired_countermeasure("isInvalidAttributeNameDisconnectItem");
+ return true;
+ }
+ }
+ }
+ }
+ }
+ return false;
+ }
+ void removeInvalidValues(Entity entity) {
+ NBTTagCompound tag = getEntityNBT(entity);
+ if(tag.toString().contains("Color:-")) {
+ try {
+ MojangsonParser.parse(tag.toString().replaceAll("Color:-", ""));
+ } catch (CommandSyntaxException e) {
+ e.printStackTrace();
+ }
+ }
+ }
+
+ boolean isDangerousEgg(ItemStack item) {
+ if(item != null && item.getType().name().equalsIgnoreCase("spawn_egg")) {
+ net.minecraft.server.v1_13_R2.ItemStack nmsItemStack = CraftItemStack.asNMSCopy(item);
+
+ return nmsItemStack.hasTag() && VulnerabilityPatcher.main.getConfig().getStringList("BlockedEntityTags").contains(nmsItemStack.getTag().getCompound("EntityTag").getString("id").replaceAll("minecraft:", ""));
+ }
+ return false;
+ }
+}
diff --git a/src/main/java/me/cooljwb/vulnerabilitypatcher/modifiers/NBTModifier_1_14.java b/src/main/java/me/cooljwb/vulnerabilitypatcher/modifiers/NBTModifier_1_14.java
index d776504..b7c778f 100644
--- a/src/main/java/me/cooljwb/vulnerabilitypatcher/modifiers/NBTModifier_1_14.java
+++ b/src/main/java/me/cooljwb/vulnerabilitypatcher/modifiers/NBTModifier_1_14.java
@@ -1,8 +1,10 @@
package me.cooljwb.vulnerabilitypatcher.modifiers;
+import com.mojang.brigadier.exceptions.CommandSyntaxException;
import me.cooljwb.vulnerabilitypatcher.Variables;
import me.cooljwb.vulnerabilitypatcher.VulnerabilityPatcher;
import me.cooljwb.vulnerabilitypatcher.patches.Patches;
+import net.minecraft.server.v1_14_R1.MojangsonParser;
import net.minecraft.server.v1_14_R1.NBTBase;
import net.minecraft.server.v1_14_R1.NBTTagCompound;
import net.minecraft.server.v1_14_R1.NBTTagList;
@@ -24,6 +26,26 @@ import java.io.File;
import java.util.HashMap;
import java.util.logging.*;
+/*
+ * Copyright 2019 CoolJWB
+ *
+ * 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.
+ */
+
+/**
+ * @author CoolJWB
+ */
+
public class NBTModifier_1_14 {
private Logger log = Logger.getLogger("Minecraft");
@@ -318,6 +340,16 @@ public class NBTModifier_1_14 {
}
return false;
}
+ void removeInvalidValues(Entity entity) {
+ NBTTagCompound tag = getEntityNBT(entity);
+ if(tag.asString().contains("Color:-")) {
+ try {
+ setEntityNBT(entity, MojangsonParser.parse(tag.asString().replaceAll("Color:-", "")));
+ } catch (CommandSyntaxException e) {
+ e.printStackTrace();
+ }
+ }
+ }
boolean isDangerousEgg(ItemStack item) {
if(item != null && item.getItemMeta() instanceof SpawnEggMeta) {
diff --git a/src/main/java/me/cooljwb/vulnerabilitypatcher/patches/Arrows.java b/src/main/java/me/cooljwb/vulnerabilitypatcher/patches/Arrows.java
index 6cec80a..082939b 100644
--- a/src/main/java/me/cooljwb/vulnerabilitypatcher/patches/Arrows.java
+++ b/src/main/java/me/cooljwb/vulnerabilitypatcher/patches/Arrows.java
@@ -10,7 +10,6 @@ import org.bukkit.event.player.PlayerVelocityEvent;
import java.util.ArrayList;
import java.util.Arrays;
-import java.util.logging.Logger;
/*
* Copyright 2019 CoolJWB
@@ -34,7 +33,7 @@ import java.util.logging.Logger;
public class Arrows extends Patches implements Listener {
- private ArrayList blockedEntityTypes = new ArrayList<>(Arrays.asList(EntityType.ARROW, EntityType.SPECTRAL_ARROW)); // Tipped arrow?
+ private ArrayList blockedEntityTypes = new ArrayList<>(Arrays.asList(EntityType.ARROW, EntityType.SPECTRAL_ARROW));
@EventHandler(priority = EventPriority.HIGHEST)
public void onPlayerVelocityEvent(PlayerVelocityEvent event) {
diff --git a/src/main/java/me/cooljwb/vulnerabilitypatcher/patches/Blocks.java b/src/main/java/me/cooljwb/vulnerabilitypatcher/patches/Blocks.java
deleted file mode 100644
index d68845c..0000000
--- a/src/main/java/me/cooljwb/vulnerabilitypatcher/patches/Blocks.java
+++ /dev/null
@@ -1,15 +0,0 @@
-package me.cooljwb.vulnerabilitypatcher.patches;
-
-import org.bukkit.Material;
-import org.bukkit.event.EventHandler;
-import org.bukkit.event.block.BlockPlaceEvent;
-
-public class Blocks extends Patches {
-
- @EventHandler
- public void onBlockPlaceEvent(BlockPlaceEvent event) {
- if(event.getBlockPlaced().getType().equals(Material.SPAWNER)) {
- event.getBlockPlaced().getState().setBlockData(Material.SPAWNER.createBlockData());
- }
- }
-}
diff --git a/src/main/java/me/cooljwb/vulnerabilitypatcher/patches/Books.java b/src/main/java/me/cooljwb/vulnerabilitypatcher/patches/Books.java
index d30e594..0241768 100644
--- a/src/main/java/me/cooljwb/vulnerabilitypatcher/patches/Books.java
+++ b/src/main/java/me/cooljwb/vulnerabilitypatcher/patches/Books.java
@@ -32,9 +32,6 @@ import java.util.logging.Logger;
*/
public class Books extends Patches implements Listener {
-
- private Logger log = Logger.getLogger("Minecraft");
-
@EventHandler(priority = EventPriority.HIGHEST)
public void onPlayerInteractEvent(PlayerInteractEvent event) {
if (event.getItem() != null && (event.getAction() == Action.RIGHT_CLICK_AIR || event.getAction() == Action.RIGHT_CLICK_BLOCK)) {
@@ -56,7 +53,7 @@ public class Books extends Patches implements Listener {
debug(event);
}
- public void writtenBook(Player player, EquipmentSlot hand) {
+ private void writtenBook(Player player, EquipmentSlot hand) {
if(hand.name().equals("OFF_HAND")) {
ItemStack hand_item = player.getInventory().getItemInOffHand();
resetMeta(player, hand_item, false);
@@ -67,8 +64,7 @@ public class Books extends Patches implements Listener {
resetMeta(player, hand_item, true);
}
}
-
- public void knowledgeBook(Player player, EquipmentSlot hand) {
+ private void knowledgeBook(Player player, EquipmentSlot hand) {
if(hand.name().equals("OFF_HAND")) {
ItemStack hand_item = player.getInventory().getItemInOffHand();
if(itemToString(hand_item).length() > 100)
@@ -81,6 +77,4 @@ public class Books extends Patches implements Listener {
hand_item.setItemMeta(null);
}
}
-
-
}
diff --git a/src/main/java/me/cooljwb/vulnerabilitypatcher/patches/Chunks.java b/src/main/java/me/cooljwb/vulnerabilitypatcher/patches/Chunks.java
index 2ae6b16..d08343e 100644
--- a/src/main/java/me/cooljwb/vulnerabilitypatcher/patches/Chunks.java
+++ b/src/main/java/me/cooljwb/vulnerabilitypatcher/patches/Chunks.java
@@ -5,6 +5,26 @@ import org.bukkit.event.Listener;
import org.bukkit.event.entity.EntitySpawnEvent;
import org.bukkit.event.weather.LightningStrikeEvent;
+/*
+ * Copyright 2019 CoolJWB
+ *
+ * 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.
+ */
+
+/**
+ * @author CoolJWB
+ */
+
public class Chunks extends Patches implements Listener {
@EventHandler
@@ -19,7 +39,7 @@ public class Chunks extends Patches implements Listener {
event.setCancelled(true);
}
- public boolean outOfRange(int value) {
+ private boolean outOfRange(int value) {
return value > 29999999 || value < -29999999;
}
}
diff --git a/src/main/java/me/cooljwb/vulnerabilitypatcher/patches/Crash_Items.java b/src/main/java/me/cooljwb/vulnerabilitypatcher/patches/Crash_Items.java
index 9d1cc3c..a941103 100644
--- a/src/main/java/me/cooljwb/vulnerabilitypatcher/patches/Crash_Items.java
+++ b/src/main/java/me/cooljwb/vulnerabilitypatcher/patches/Crash_Items.java
@@ -40,8 +40,6 @@ import java.util.logging.Logger;
public class Crash_Items extends Patches implements Listener {
- private Logger log = Logger.getLogger("Minecraft");
-
@EventHandler(priority = EventPriority.HIGHEST)
public void onBlockDispenseEvent(BlockDispenseEvent event) {
ItemStack item = event.getItem();
diff --git a/src/main/java/me/cooljwb/vulnerabilitypatcher/patches/Death_Items.java b/src/main/java/me/cooljwb/vulnerabilitypatcher/patches/Death_Items.java
index f38fdc9..afa4702 100644
--- a/src/main/java/me/cooljwb/vulnerabilitypatcher/patches/Death_Items.java
+++ b/src/main/java/me/cooljwb/vulnerabilitypatcher/patches/Death_Items.java
@@ -39,8 +39,6 @@ import java.util.logging.Logger;
public class Death_Items extends Patches implements Listener {
- private Logger log = Logger.getLogger("Minecraft");
-
/* When a dispenser dispenses a death item cancel the event and null the item. */
@EventHandler(priority = EventPriority.HIGHEST)
public void onBlockDispenseEvent(BlockDispenseEvent event) {
diff --git a/src/main/java/me/cooljwb/vulnerabilitypatcher/patches/Death_Potions.java b/src/main/java/me/cooljwb/vulnerabilitypatcher/patches/Death_Potions.java
index 01489fe..c516347 100644
--- a/src/main/java/me/cooljwb/vulnerabilitypatcher/patches/Death_Potions.java
+++ b/src/main/java/me/cooljwb/vulnerabilitypatcher/patches/Death_Potions.java
@@ -100,7 +100,6 @@ public class Death_Potions extends Patches implements Listener {
}
return false;
}
-
private boolean isDeathPotion(Collection effects) {
for(PotionEffect effect : effects) {
if (effect.getType().getName().equalsIgnoreCase("HEAL") && (effect.getAmplifier() == 125 || effect.getAmplifier() == 93 || effect.getAmplifier() == 61 || effect.getAmplifier() == 29)) {
diff --git a/src/main/java/me/cooljwb/vulnerabilitypatcher/patches/Disconnect_Items.java b/src/main/java/me/cooljwb/vulnerabilitypatcher/patches/Disconnect_Items.java
index f05dd64..041abe4 100644
--- a/src/main/java/me/cooljwb/vulnerabilitypatcher/patches/Disconnect_Items.java
+++ b/src/main/java/me/cooljwb/vulnerabilitypatcher/patches/Disconnect_Items.java
@@ -2,10 +2,12 @@ package me.cooljwb.vulnerabilitypatcher.patches;
import me.cooljwb.vulnerabilitypatcher.SMG;
import org.bukkit.Bukkit;
+import org.bukkit.Material;
import org.bukkit.block.Block;
import org.bukkit.block.Container;
import org.bukkit.block.Jukebox;
-import org.bukkit.entity.ArmorStand;
+import org.bukkit.entity.Entity;
+import org.bukkit.entity.LivingEntity;
import org.bukkit.entity.Player;
import org.bukkit.event.EventHandler;
import org.bukkit.event.EventPriority;
@@ -17,7 +19,10 @@ import org.bukkit.event.inventory.InventoryClickEvent;
import org.bukkit.event.inventory.InventoryType;
import org.bukkit.event.player.PlayerDropItemEvent;
import org.bukkit.event.player.PlayerInteractEvent;
+import org.bukkit.inventory.EntityEquipment;
import org.bukkit.inventory.ItemStack;
+import org.bukkit.inventory.meta.ItemMeta;
+import org.bukkit.material.MaterialData;
import org.bukkit.potion.Potion;
import org.bukkit.scheduler.BukkitScheduler;
@@ -45,7 +50,6 @@ import java.util.logging.Logger;
public class Disconnect_Items extends Patches implements Listener {
- // TODO: Possibly fix disconnect items once for all, otherwise add more patches.
// TODO: Add /give disconnect items.
@EventHandler(priority = EventPriority.HIGHEST)
@@ -100,9 +104,7 @@ public class Disconnect_Items extends Patches implements Listener {
Jukebox box = (Jukebox) event.getBlockPlaced().getState();
boolean violation = false;
- try {
- box.getPlaying();
- } catch(IllegalArgumentException ignored) {
+ if(box.getPlaying() != Material.AIR && !box.getPlaying().isRecord()) {
event.setCancelled(true);
violation = true;
}
@@ -110,7 +112,7 @@ public class Disconnect_Items extends Patches implements Listener {
if(violation) {
Player player = event.getPlayer();
msg(player, SMG.ITEM_IN_CONTAINER.msg);
- notifyViolation(player, "place", event.getBlock().getType() + " with disconnect item in it", event.getPlayer().getLocation());
+ notifyViolation(player, "place", event.getBlock().getType() + " with non record item in it", event.getPlayer().getLocation());
}
}
@@ -119,20 +121,21 @@ public class Disconnect_Items extends Patches implements Listener {
@EventHandler(priority = EventPriority.HIGHEST)
public void onEntitySpawnEvent(EntitySpawnEvent event) {
- if(event.getEntity() instanceof ArmorStand) {
- ArmorStand armorStand = (ArmorStand) event.getEntity();
+ removeInvalidValues(event.getEntity()); // Experimental.
+
+ if(event.getEntity() instanceof LivingEntity) {
+ Entity entity = event.getEntity();
boolean violation = false;
try {
- armorStand.getBoots(); armorStand.getLeggings(); armorStand.getChestplate(); armorStand.getHelmet(); armorStand.getItemInHand();
- } catch(IllegalArgumentException ignored) {
+ hasDisconnectItem(entity);
+ } catch(NullPointerException e) {
event.setCancelled(true);
violation = true;
}
- if(violation) {
- notifyViolation("Unknown", "place", " with a disconnect item", event.getEntity().getLocation());
- }
+ if (violation)
+ notifyViolation("Unknown", "summon", event.getEntity().getName() + " with a disconnect item", event.getEntity().getLocation());
}
}
@@ -202,4 +205,10 @@ public class Disconnect_Items extends Patches implements Listener {
debug(event);
}
+
+ private boolean hasDisconnectItem(Entity entity) {
+ if(entity instanceof LivingEntity)
+ return isDisconnectItem(((LivingEntity) entity).getEquipment().getChestplate()) || isDisconnectItem(((LivingEntity) entity).getEquipment().getLeggings()) || isDisconnectItem(((LivingEntity) entity).getEquipment().getChestplate()) || isDisconnectItem(((LivingEntity) entity).getEquipment().getHelmet()) || isDisconnectItem(((LivingEntity) entity).getEquipment().getItemInHand());
+ return false;
+ }
}
\ No newline at end of file
diff --git a/src/main/java/me/cooljwb/vulnerabilitypatcher/patches/Entity_Tag.java b/src/main/java/me/cooljwb/vulnerabilitypatcher/patches/Entity_Tag.java
index 25ac0a9..50adcd9 100644
--- a/src/main/java/me/cooljwb/vulnerabilitypatcher/patches/Entity_Tag.java
+++ b/src/main/java/me/cooljwb/vulnerabilitypatcher/patches/Entity_Tag.java
@@ -10,6 +10,26 @@ import org.bukkit.inventory.ItemStack;
import java.util.logging.Logger;
+/*
+ * Copyright 2019 CoolJWB
+ *
+ * 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.
+ */
+
+/**
+ * @author CoolJWB
+ */
+
public class Entity_Tag extends Patches implements Listener {
private Logger log = Logger.getLogger("Minecraft");
@@ -18,11 +38,13 @@ public class Entity_Tag extends Patches implements Listener {
public void onPlayerInteractEvent(PlayerInteractEvent event) {
ItemStack item = event.getItem();
- if(isDangerousEgg(item))
+ if(isDangerousEgg(item)) {
clearItemMeta(event.getItem());
+ notifyViolation(event.getPlayer().getName(), "use", event.getItem().getType() + " with", event.getPlayer().getLocation());
+ }
debug(event);
- }
+ } // Checks modified Spawn Eggs.
@EventHandler(priority = EventPriority.HIGHEST)
public void onBlockDispenseEvent(BlockDispenseEvent event) {
@@ -45,5 +67,5 @@ public class Entity_Tag extends Patches implements Listener {
}
debug(event);
- }
+ } // Checks if a block tried to dispense a modified Spawn Egg.
}
diff --git a/src/main/java/me/cooljwb/vulnerabilitypatcher/patches/Fireworks.java b/src/main/java/me/cooljwb/vulnerabilitypatcher/patches/Fireworks.java
index 52162e2..0dbda95 100644
--- a/src/main/java/me/cooljwb/vulnerabilitypatcher/patches/Fireworks.java
+++ b/src/main/java/me/cooljwb/vulnerabilitypatcher/patches/Fireworks.java
@@ -4,6 +4,26 @@ import org.bukkit.entity.Firework;
import org.bukkit.event.EventHandler;
import org.bukkit.event.entity.EntitySpawnEvent;
+/*
+ * Copyright 2019 CoolJWB
+ *
+ * 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.
+ */
+
+/**
+ * @author CoolJWB
+ */
+
public class Fireworks extends Patches {
@EventHandler
diff --git a/src/main/java/me/cooljwb/vulnerabilitypatcher/patches/Follow_Range.java b/src/main/java/me/cooljwb/vulnerabilitypatcher/patches/Follow_Range.java
index 13de2db..873e31d 100644
--- a/src/main/java/me/cooljwb/vulnerabilitypatcher/patches/Follow_Range.java
+++ b/src/main/java/me/cooljwb/vulnerabilitypatcher/patches/Follow_Range.java
@@ -31,8 +31,6 @@ import java.util.logging.Logger;
public class Follow_Range extends Patches implements Listener {
- private Logger log = Logger.getLogger("Minecraft");
-
@EventHandler(priority = EventPriority.HIGHEST)
public void onEntitySpawnEvent(EntitySpawnEvent event) {
if (event.getEntity() != null && event.getEntity() instanceof LivingEntity) {
diff --git a/src/main/java/me/cooljwb/vulnerabilitypatcher/patches/Handswitch.java b/src/main/java/me/cooljwb/vulnerabilitypatcher/patches/Handswitch.java
index c31cbe7..5cc11e5 100644
--- a/src/main/java/me/cooljwb/vulnerabilitypatcher/patches/Handswitch.java
+++ b/src/main/java/me/cooljwb/vulnerabilitypatcher/patches/Handswitch.java
@@ -1,9 +1,11 @@
package me.cooljwb.vulnerabilitypatcher.patches;
+import me.cooljwb.vulnerabilitypatcher.SMG;
import org.bukkit.Bukkit;
import org.bukkit.ChatColor;
import org.bukkit.entity.Player;
import org.bukkit.event.EventHandler;
+import org.bukkit.event.EventPriority;
import org.bukkit.event.Listener;
import org.bukkit.event.player.PlayerSwapHandItemsEvent;
import org.bukkit.scheduler.BukkitScheduler;
@@ -11,13 +13,31 @@ import org.bukkit.scheduler.BukkitScheduler;
import java.util.ArrayList;
import java.util.HashMap;
-public class Handswitch extends Patches implements Listener {
+/*
+ * Copyright 2019 CoolJWB
+ *
+ * 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.
+ */
- // TODO: Improve this.
+/**
+ * @author CoolJWB
+ */
+
+public class Handswitch extends Patches implements Listener {
private static HashMap switches = new HashMap<>();
private static ArrayList cooldown = new ArrayList<>();
- int its = 0;
+ private int its = 0;
public void runnable() {
BukkitScheduler scheduler = Bukkit.getServer().getScheduler();
@@ -28,16 +48,16 @@ public class Handswitch extends Patches implements Listener {
its++;
if(its >= 30) {
for(Player player : cooldown)
- msg(player, ChatColor.RED + "Please do not switch items repeatedly.");
+ msg(player, SMG.SWITCH.msg);
cooldown = new ArrayList<>();
its = 0;
}
}
}, 20L, 0);
- }
+ } // Cooldown notification.
- @EventHandler
+ @EventHandler(priority = EventPriority.HIGHEST)
public void PlayerSwapHandItems(PlayerSwapHandItemsEvent event) {
if(cooldown.contains(event.getPlayer())) {
event.setCancelled(true);
@@ -55,5 +75,5 @@ public class Handswitch extends Patches implements Listener {
else
switches.put(event.getPlayer(), playerSwitches + 1);
}
- }
+ } // Item hand swap counter.
}
diff --git a/src/main/java/me/cooljwb/vulnerabilitypatcher/patches/Item_Frames.java b/src/main/java/me/cooljwb/vulnerabilitypatcher/patches/Item_Frames.java
index 0dc0b49..7040844 100644
--- a/src/main/java/me/cooljwb/vulnerabilitypatcher/patches/Item_Frames.java
+++ b/src/main/java/me/cooljwb/vulnerabilitypatcher/patches/Item_Frames.java
@@ -8,8 +8,27 @@ import org.bukkit.event.hanging.HangingPlaceEvent;
import java.util.ArrayList;
-public class Item_Frames extends Patches implements Listener {
+/*
+ * Copyright 2019 CoolJWB
+ *
+ * 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.
+ */
+/**
+ * @author CoolJWB
+ */
+
+public class Item_Frames extends Patches implements Listener {
private ArrayList entities = new ArrayList<>();
@EventHandler
@@ -25,7 +44,7 @@ public class Item_Frames extends Patches implements Listener {
@EventHandler
public void onEntitySpawn(EntitySpawnEvent event) {
- if(entities.contains(event.getEntity())) {
+ if(!entities.contains(event.getEntity()) && event.getEntity().getType().name().equalsIgnoreCase("ITEM_FRAME")) {
event.setCancelled(true); // Cancels any item frame that hasn't been placed.
fired_countermeasure("ItemFrameEntity");
}
diff --git a/src/main/java/me/cooljwb/vulnerabilitypatcher/patches/Patches.java b/src/main/java/me/cooljwb/vulnerabilitypatcher/patches/Patches.java
index e8bb5e5..b9793b1 100644
--- a/src/main/java/me/cooljwb/vulnerabilitypatcher/patches/Patches.java
+++ b/src/main/java/me/cooljwb/vulnerabilitypatcher/patches/Patches.java
@@ -5,12 +5,12 @@ import me.cooljwb.vulnerabilitypatcher.VulnerabilityPatcher;
import me.cooljwb.vulnerabilitypatcher.modifiers.NBTModifier;
import net.md_5.bungee.api.ChatColor;
import net.md_5.bungee.api.chat.*;
-//import net.minecraft.server.v1_14_R1.ChatMessageException;
import org.apache.commons.lang.builder.ReflectionToStringBuilder;
import org.bukkit.Bukkit;
import org.bukkit.Location;
import org.bukkit.World;
import org.bukkit.command.CommandSender;
+import org.bukkit.enchantments.Enchantment;
import org.bukkit.entity.Entity;
import org.bukkit.entity.Player;
import org.bukkit.event.Event;
@@ -21,6 +21,7 @@ import org.bukkit.scheduler.BukkitScheduler;
import java.util.HashMap;
import java.util.List;
+import java.util.Map;
import java.util.logging.Level;
import java.util.logging.Logger;
@@ -56,10 +57,12 @@ public class Patches extends NBTModifier implements Listener {
private Death_Items death_items;
private Disconnect_Items disconnect_items;
private Crash_Items crash_items;
- private Rouge_Entity rouge_entity;
+ private Rouge_Entity_Spigot rouge_entity;
private Logger log = Logger.getLogger("Minecraft");
+
private HashMap active_attributes = new HashMap<>();
+ protected HashMap player_speed = new HashMap<>();
protected byte mode = 0;
@@ -81,42 +84,33 @@ public class Patches extends NBTModifier implements Listener {
this.disconnect_items = main.disconnect_items;
this.crash_items = main.crash_items;
}
-
public void runnable() {
BukkitScheduler scheduler = Bukkit.getServer().getScheduler();
scheduler.scheduleSyncRepeatingTask(main, new Runnable() {
@Override
public void run() {
for(Player player : Bukkit.getOnlinePlayers()) {
- if(player.getLocation().getY() <= -29999999) // Fixes invalid movement disconnection.
- player.getLocation().setY(-29999999);
- else if(player.getLocation().getY() >= 29999999) // Fixes invalid movement disconnection.
- player.getLocation().setY(29999999);
+ if(player.getWalkSpeed() > 0.3F)
+ player.setWalkSpeed(0.3F);
+ if(player.getFlySpeed() > 0.15F)
+ player.setFlySpeed(0.15F);
+
+ if(player.getLocation().getY() <= -29999990) // Fixes invalid movement disconnection.
+ player.getLocation().setY(-29999990);
+ else if(player.getLocation().getY() >= 29999990) // Fixes invalid movement disconnection.
+ player.getLocation().setY(29999990);
for(ItemStack item : player.getInventory()) {
- /*if(listeners.contains("DisconnectItems") && itemInVisibleSlot(player.getInventory(), item)) {
+ if(mode == 2) {
+ if(item != null && item.getItemMeta() != null) {
+ for (Map.Entry entry : item.getItemMeta().getEnchants().entrySet()) {
+ if (((Integer) entry.getValue()) > 5) {
+ clearItemMeta(item);
+ }
+ }
+ }
+ }
- NBTTagList item_attributes = getNBTAttributeList(item);
-
- if(item_attributes != null) {
- for(int a = 0; a <= item_attributes.size(); a++) {
- NBTTagCompound attribute = item_attributes.getCompound(a);
-
- if(attribute != null && !attribute.isEmpty()) {
- String attr_name = attribute.getString("AttributeName").toLowerCase();
- float attr_amount = attribute.getFloat("Amount");
-
- if((active_attributes.containsKey("generic.movementspeed") && attr_name.equalsIgnoreCase("generic.movementspeed")) && (Float.isFinite(active_attributes.get("generic.movementspeed")) || Float.isInfinite(active_attributes.get("generic.movementspeed")) || active_attributes.get("generic.movementspeed") == Float.NEGATIVE_INFINITY) && (Float.isFinite(attr_amount) || Float.isInfinite(attr_amount) || attr_amount == Float.NEGATIVE_INFINITY)) {
- msg(player, SMG.ITEMS.msg);
- clearItemMeta(item);
- }
-
- active_attributes.put(attr_name, attr_amount);
- }
- }
- }
- }*/
-
for(String listener : listeners) {
switch(listener) {
case "DeathItems":
@@ -147,9 +141,24 @@ public class Patches extends NBTModifier implements Listener {
for(World world : Bukkit.getWorlds()) {
for(Entity entity : world.getEntities()) {
+ if(entity == null)
+ continue;
+
if(entity.getName().equalsIgnoreCase("Minecart with Spawner")) {
- entity.remove();
- }
+ entity.remove(); // TODO: Make this configurable.
+ } // Remove Minecart Spawners.
+ if((entity.getVelocity().getX() > 10.0D || entity.getVelocity().getY() > 10.0D || entity.getVelocity().getZ() > 10.0D || entity.getVelocity().getX() < -6.0D || entity.getVelocity().getY() < -6.0D || entity.getVelocity().getZ() < -6.0D)) {
+ if(entity.getName().equals("Firework Rocket"))
+ entity.remove();
+ else {
+ if(entity.getVelocity().getX() > 10.0D)
+ entity.getVelocity().setX(10);
+ else if(entity.getVelocity().getY() > 10.0D)
+ entity.getVelocity().setY(10);
+ else if(entity.getVelocity().getZ() > 10.0D)
+ entity.getVelocity().setZ(10);
+ }
+ } // Remove crazy fireworks.
}
} // Remove Spawner Minecarts.
}
diff --git a/src/main/java/me/cooljwb/vulnerabilitypatcher/patches/Rouge_Entity.java b/src/main/java/me/cooljwb/vulnerabilitypatcher/patches/Rouge_Entity.java
deleted file mode 100644
index e846db3..0000000
--- a/src/main/java/me/cooljwb/vulnerabilitypatcher/patches/Rouge_Entity.java
+++ /dev/null
@@ -1,73 +0,0 @@
-package me.cooljwb.vulnerabilitypatcher.patches;
-
-import com.destroystokyo.paper.event.entity.EntityKnockbackByEntityEvent;
-import org.bukkit.*;
-import org.bukkit.entity.Entity;
-import org.bukkit.event.EventHandler;
-import org.bukkit.event.Listener;
-import org.bukkit.scheduler.BukkitScheduler;
-
-import java.util.logging.Logger;
-
-/*
- * Copyright 2019 CoolJWB
- *
- * 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.
- */
-
-/**
- * @author CoolJWB
- */
-
-
-public class Rouge_Entity extends Patches implements Listener {
-
- private Logger log = Logger.getLogger("Minecraft");
-
- public Rouge_Entity() { checkRougeEntities(); }
-
- public void checkRougeEntities() {
- BukkitScheduler scheduler = Bukkit.getScheduler();
- scheduler.scheduleSyncRepeatingTask(main, new Runnable() {
- @Override
- public void run() {
- for(World world : Bukkit.getWorlds()) {
- if(world.getEntities() != null) {
- for(Entity entity : world.getEntities()) {
- if(entity != null && (entity.getVelocity().getX() > 10.0D || entity.getVelocity().getY() > 10.0D || entity.getVelocity().getZ() > 10.0D || entity.getVelocity().getX() < -6.0D || entity.getVelocity().getY() < -6.0D || entity.getVelocity().getZ() < -6.0D)) {
- if(entity.getName().equals("Firework Rocket"))
- entity.remove();
- else {
- if(entity.getVelocity().getX() > 10.0D)
- entity.getVelocity().setX(10);
- else if(entity.getVelocity().getY() > 10.0D)
- entity.getVelocity().setY(10);
- else if(entity.getVelocity().getZ() > 10.0D)
- entity.getVelocity().setZ(10);
- }
- }
- }
- }
- }
- }
- }, 0L, 0);
- }
-
- @EventHandler
- public void onEntityKnockback(EntityKnockbackByEntityEvent event) { // Add Spigot support?
- if(event.getKnockbackStrength() > 50) {
- event.getAcceleration().multiply(50/event.getKnockbackStrength());
- }
- debug(event);
- }
-}
diff --git a/src/main/java/me/cooljwb/vulnerabilitypatcher/patches/Rouge_Entity_Paper.java b/src/main/java/me/cooljwb/vulnerabilitypatcher/patches/Rouge_Entity_Paper.java
new file mode 100644
index 0000000..dd61c38
--- /dev/null
+++ b/src/main/java/me/cooljwb/vulnerabilitypatcher/patches/Rouge_Entity_Paper.java
@@ -0,0 +1,36 @@
+package me.cooljwb.vulnerabilitypatcher.patches;
+
+import com.destroystokyo.paper.event.entity.EntityKnockbackByEntityEvent;
+import org.bukkit.event.EventHandler;
+import org.bukkit.event.EventPriority;
+import org.bukkit.event.Listener;
+
+/*
+ * Copyright 2019 CoolJWB
+ *
+ * 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.
+ */
+
+/**
+ * @author CoolJWB
+ */
+
+public class Rouge_Entity_Paper extends Patches implements Listener {
+ @EventHandler(priority = EventPriority.HIGHEST)
+ public void onEntityKnockback(EntityKnockbackByEntityEvent event) {
+ if(event.getKnockbackStrength() > 50) {
+ event.getAcceleration().multiply(50/event.getKnockbackStrength());
+ }
+ debug(event);
+ }
+}
diff --git a/src/main/java/me/cooljwb/vulnerabilitypatcher/patches/Rouge_Entity_Spigot.java b/src/main/java/me/cooljwb/vulnerabilitypatcher/patches/Rouge_Entity_Spigot.java
new file mode 100644
index 0000000..c29f75a
--- /dev/null
+++ b/src/main/java/me/cooljwb/vulnerabilitypatcher/patches/Rouge_Entity_Spigot.java
@@ -0,0 +1,73 @@
+package me.cooljwb.vulnerabilitypatcher.patches;
+
+import org.bukkit.*;
+import org.bukkit.enchantments.Enchantment;
+import org.bukkit.entity.LivingEntity;
+import org.bukkit.event.EventHandler;
+import org.bukkit.event.EventPriority;
+import org.bukkit.event.Listener;
+import org.bukkit.event.entity.EntityDamageByEntityEvent;
+import org.bukkit.inventory.ItemStack;
+import org.bukkit.util.Vector;
+
+/*
+ * Copyright 2019 CoolJWB
+ *
+ * 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.
+ */
+
+/**
+ * @author CoolJWB
+ */
+
+public class Rouge_Entity_Spigot extends Patches implements Listener {
+ long timediff = 0;
+ @EventHandler(priority = EventPriority.HIGHEST)
+ public void onEntityDamage(EntityDamageByEntityEvent event) {
+ if(!event.getDamager().getName().equalsIgnoreCase("Arrow") && event.getEntity() instanceof LivingEntity && event.getDamager() instanceof LivingEntity) {
+
+ LivingEntity entity = (LivingEntity) event.getEntity();
+ LivingEntity damager = (LivingEntity) event.getDamager();
+
+ Location damager_location = event.getDamager().getLocation();
+ Location entity_location = event.getEntity().getLocation();
+
+ Vector vector = damager_location.toVector().subtract(entity_location.toVector()).normalize();
+ ItemStack item = damager.getEquipment().getItemInMainHand();
+
+ if(item.getEnchantments().containsKey(Enchantment.KNOCKBACK) && item.getEnchantmentLevel(Enchantment.KNOCKBACK) >= 10) {
+ event.setCancelled(true);
+
+ vector.setY(0);
+ vector.multiply(-0.5);
+
+ if (entity.getFallDistance() > 0) {
+ vector.setY(-0.5);
+ }
+
+ else {
+ if((System.currentTimeMillis() - timediff) > 1000) {
+ vector.setY(0.4);
+ timediff = System.currentTimeMillis();
+ }
+
+ else
+ vector.setY(0);
+ }
+
+ event.getEntity().setVelocity(vector);
+ entity.damage(event.getDamage());
+ } // If too much knockback cancel event and add normal knockback.
+ }
+ }
+}
diff --git a/src/main/java/me/cooljwb/vulnerabilitypatcher/patches/Spawner.java b/src/main/java/me/cooljwb/vulnerabilitypatcher/patches/Spawner.java
new file mode 100644
index 0000000..f070fca
--- /dev/null
+++ b/src/main/java/me/cooljwb/vulnerabilitypatcher/patches/Spawner.java
@@ -0,0 +1,35 @@
+package me.cooljwb.vulnerabilitypatcher.patches;
+
+import org.bukkit.Material;
+import org.bukkit.event.EventHandler;
+import org.bukkit.event.block.BlockPlaceEvent;
+
+/*
+ * Copyright 2019 CoolJWB
+ *
+ * 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.
+ */
+
+/**
+ * @author CoolJWB
+ */
+
+public class Spawner extends Patches {
+
+ @EventHandler
+ public void onBlockPlaceEvent(BlockPlaceEvent event) {
+ if(event.getBlockPlaced().getType().equals(Material.SPAWNER)) {
+ event.getBlockPlaced().getState().setBlockData(Material.SPAWNER.createBlockData());
+ }
+ }
+}
diff --git a/src/main/java/me/cooljwb/vulnerabilitypatcher/patches/Structure_Blocks.java b/src/main/java/me/cooljwb/vulnerabilitypatcher/patches/Structure_Blocks.java
index f983636..58a444c 100644
--- a/src/main/java/me/cooljwb/vulnerabilitypatcher/patches/Structure_Blocks.java
+++ b/src/main/java/me/cooljwb/vulnerabilitypatcher/patches/Structure_Blocks.java
@@ -6,6 +6,26 @@ import org.bukkit.event.EventPriority;
import org.bukkit.event.Listener;
import org.bukkit.event.player.PlayerInteractEvent;
+/*
+ * Copyright 2019 CoolJWB
+ *
+ * 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.
+ */
+
+/**
+ * @author CoolJWB
+ */
+
public class Structure_Blocks extends Patches implements Listener {
@EventHandler(priority = EventPriority.HIGHEST)
@@ -17,5 +37,5 @@ public class Structure_Blocks extends Patches implements Listener {
event.setCancelled(true);
}
}
- }
+ } // Disables Strucure Blocks completely.
}
diff --git a/src/main/java/me/cooljwb/vulnerabilitypatcher/patches/Trident_Riptide.java b/src/main/java/me/cooljwb/vulnerabilitypatcher/patches/Trident_Riptide.java
index 6585c4c..5144822 100644
--- a/src/main/java/me/cooljwb/vulnerabilitypatcher/patches/Trident_Riptide.java
+++ b/src/main/java/me/cooljwb/vulnerabilitypatcher/patches/Trident_Riptide.java
@@ -1,9 +1,5 @@
package me.cooljwb.vulnerabilitypatcher.patches;
-import me.cooljwb.vulnerabilitypatcher.SMG;
-import org.apache.commons.lang.builder.ReflectionToStringBuilder;
-import org.bukkit.Bukkit;
-import org.bukkit.ChatColor;
import org.bukkit.Material;
import org.bukkit.enchantments.Enchantment;
import org.bukkit.entity.Player;
@@ -11,10 +7,8 @@ import org.bukkit.event.EventHandler;
import org.bukkit.event.EventPriority;
import org.bukkit.event.Listener;
import org.bukkit.event.player.PlayerInteractEvent;
-import org.bukkit.event.player.PlayerMoveEvent;
import org.bukkit.event.player.PlayerRiptideEvent;
import org.bukkit.inventory.ItemStack;
-import org.bukkit.scheduler.BukkitScheduler;
import java.util.HashMap;
diff --git a/src/main/resources/config.yml b/src/main/resources/config.yml
index 7cd7878..dd2ec03 100644
--- a/src/main/resources/config.yml
+++ b/src/main/resources/config.yml
@@ -13,7 +13,7 @@ Patches:
- FollowRange
- DisconnectItems
- EntityTag
- - Blocks
+ - Spawner
- StructureBlocks
- Chunks
- ItemFrames
@@ -51,7 +51,13 @@ Notify:
Permission: vulnerability.notify
# Security Mode (EASY : MEDIUM : STRICT)
+# EASY: Blocks dangerous items loosely (should still be secure).
+# MEDIUM: Blocks dangerous items strictly (more secure by checking all items in containers).
+# STRICT: Blocks all items that have any potential issue (fully secure but removes enchants over level 5 and removes all attributes, custom potions, ect).
SecurityMode: "EASY"
# DevMode should be set to false, unless you're a developer of this plugin.
-DevMode: false
\ No newline at end of file
+DevMode: false
+
+# Do not modify this value, used to define the configurations version for future versions.
+ConfVersion: 0
\ No newline at end of file
diff --git a/src/main/resources/plugin.yml b/src/main/resources/plugin.yml
index ff4e069..04a7cc0 100644
--- a/src/main/resources/plugin.yml
+++ b/src/main/resources/plugin.yml
@@ -1,5 +1,5 @@
name: VulnerabilityPatcher
-version: 0.5.1
+version: 1.0-BETA
main: me.cooljwb.vulnerabilitypatcher.VulnerabilityPatcher
api-version: 1.13
authors: [CoolJWB]