Minor cleanup
This commit is contained in:
42 files changed
+10981
-7559
No files matched your search
-18
@@ -1,18 +0,0 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<classpath>
|
||||
<classpathentry kind="src" output="bin/main" path="src/main/java">
|
||||
<attributes>
|
||||
<attribute name="gradle_scope" value="main"/>
|
||||
<attribute name="gradle_used_by_scope" value="main,test"/>
|
||||
</attributes>
|
||||
</classpathentry>
|
||||
<classpathentry kind="src" output="bin/main" path="src/main/resources">
|
||||
<attributes>
|
||||
<attribute name="gradle_scope" value="main"/>
|
||||
<attribute name="gradle_used_by_scope" value="main,test"/>
|
||||
</attributes>
|
||||
</classpathentry>
|
||||
<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/JavaSE-1.8/"/>
|
||||
<classpathentry kind="con" path="org.eclipse.buildship.core.gradleclasspathcontainer"/>
|
||||
<classpathentry kind="output" path="bin/default"/>
|
||||
</classpath>
|
||||
+1013
File diff suppressed because it is too large.
Load diff
+132
-12
@@ -1,15 +1,135 @@
|
||||
.DS_STORE
|
||||
.gradle/
|
||||
build/
|
||||
*.iml
|
||||
*.idea
|
||||
*/.classpath
|
||||
*/.project
|
||||
*/.settings
|
||||
*/bin
|
||||
*/build
|
||||
*/nbproject
|
||||
### Others ###
|
||||
*.cmd
|
||||
*.sh
|
||||
*.prefs
|
||||
|
||||
### Maven ###
|
||||
/mvn
|
||||
/target/lib
|
||||
/target/maven-archiver
|
||||
/target/classes
|
||||
/target/maven-status
|
||||
pom.xml.tag
|
||||
pom.xml.releaseBackup
|
||||
pom.xml.versionsBackup
|
||||
pom.xml.next
|
||||
release.properties
|
||||
dependency-reduced-pom.xml
|
||||
buildNumber.properties
|
||||
.mvn/timing.properties
|
||||
out/
|
||||
|
||||
### Java ###
|
||||
*.class
|
||||
|
||||
# Mobile Tools for Java (J2ME)
|
||||
.mtj.tmp/
|
||||
|
||||
# Package Files #
|
||||
*.war
|
||||
*.ear
|
||||
|
||||
# virtual machine crash logs, see http://www.java.com/en/download/help/error_hotspot.xml
|
||||
hs_err_pid*
|
||||
|
||||
|
||||
### Intellij ###
|
||||
# Covers JetBrains IDEs: IntelliJ, RubyMine, PhpStorm, AppCode, PyCharm, CLion, Android Studio and Webstorm
|
||||
|
||||
*.iml
|
||||
|
||||
## Directory-based project format:
|
||||
.idea/
|
||||
# if you remove the above rule, at least ignore the following:
|
||||
|
||||
# User-specific stuff:
|
||||
# .idea/workspace.xml
|
||||
# .idea/tasks.xml
|
||||
# .idea/dictionaries
|
||||
# .idea/shelf
|
||||
|
||||
# Sensitive or high-churn files:
|
||||
# .idea/dataSources.ids
|
||||
# .idea/dataSources.xml
|
||||
# .idea/sqlDataSources.xml
|
||||
# .idea/dynamic.xml
|
||||
# .idea/uiDesigner.xml
|
||||
|
||||
# Gradle:
|
||||
# .idea/gradle.xml
|
||||
# .idea/libraries
|
||||
.gradle
|
||||
|
||||
# Mongo Explorer plugin:
|
||||
# .idea/mongoSettings.xml
|
||||
|
||||
## File-based project format:
|
||||
*.ipr
|
||||
*.iws
|
||||
|
||||
## Plugin-specific files:
|
||||
|
||||
# IntelliJ
|
||||
/out/
|
||||
|
||||
# mpeltonen/sbt-idea plugin
|
||||
.idea_modules/
|
||||
|
||||
# JIRA plugin
|
||||
atlassian-ide-plugin.xml
|
||||
|
||||
# Crashlytics plugin (for Android Studio and IntelliJ)
|
||||
com_crashlytics_export_strings.xml
|
||||
crashlytics.properties
|
||||
crashlytics-build.properties
|
||||
fabric.properties
|
||||
|
||||
|
||||
### Eclipse ###
|
||||
*.pydevproject
|
||||
.metadata
|
||||
bin/
|
||||
tmp/
|
||||
*.tmp
|
||||
*.bak
|
||||
*.swp
|
||||
*~.nib
|
||||
local.properties
|
||||
.settings/
|
||||
.loadpath
|
||||
|
||||
# Eclipse Core
|
||||
.project
|
||||
/bin
|
||||
|
||||
# External tool builders
|
||||
.externalToolBuilders/
|
||||
|
||||
# Locally stored "Eclipse launch configurations"
|
||||
*.launch
|
||||
|
||||
# CDT-specific
|
||||
.cproject
|
||||
|
||||
# JDT-specific (Eclipse Java Development Tools)
|
||||
.classpath
|
||||
|
||||
# Java annotation processor (APT)
|
||||
.factorypath
|
||||
|
||||
# PDT-specific
|
||||
.buildpath
|
||||
|
||||
# sbteclipse plugin
|
||||
.target
|
||||
|
||||
# TeXlipse plugin
|
||||
.texlipse
|
||||
|
||||
# STS (Spring Tool Suite)
|
||||
.springBeans
|
||||
/target/
|
||||
checkstyle.xml
|
||||
classes/
|
||||
*.bat
|
||||
docs/
|
||||
build/
|
||||
+10
-8
@@ -1,6 +1,9 @@
|
||||
plugins {
|
||||
java
|
||||
`java-library`
|
||||
|
||||
idea
|
||||
eclipse
|
||||
}
|
||||
|
||||
repositories {
|
||||
@@ -35,20 +38,19 @@ repositories {
|
||||
}
|
||||
|
||||
dependencies {
|
||||
compileOnly("org.spigotmc:spigot-api:1.17-R0.1-SNAPSHOT")
|
||||
compileOnly("org.spigotmc:spigot-api:1.17.1-R0.1-SNAPSHOT")
|
||||
compileOnly("com.comphenix.protocol:ProtocolLib:4.7.0-SNAPSHOT")
|
||||
implementation("com.elmakers.mine.bukkit:MagicAPI:8.6")
|
||||
implementation("de.tr7zw:item-nbt-api-plugin:2.4.1")
|
||||
implementation("de.tr7zw:item-nbt-api-plugin:2.8.0")
|
||||
implementation("com.github.TheBusyBiscuit:Slimefun4:v4.1.15") { isTransitive = false }
|
||||
implementation("io.netty:netty-all:4.0.39.Final")
|
||||
implementation("io.netty:netty-all:4.1.65.Final")
|
||||
implementation("com.gmail.nossr50.mcMMO:mcMMO:2.1.200") { isTransitive = false }
|
||||
implementation("com.github.brcdev-minecraft:shopgui-api:2.2.0")
|
||||
implementation("fr.minuskube.inv:smart-invs:1.2.7")
|
||||
implementation(":DynamicShop-2.11.8")
|
||||
implementation(":CraftingStore-2.6.8")
|
||||
compileOnly("com.github.SaberLLC:Saber-Factions:2.9.1-RC") { isTransitive = false }
|
||||
implementation("com.github.CraftingStore:MinecraftPlugin:master-SNAPSHOT")
|
||||
compileOnly(":JetsMinions")
|
||||
compileOnlyApi("org.apache.logging.log4j:log4j-api:2.8.1")
|
||||
compileOnlyApi("org.apache.logging.log4j:log4j-api:2.0.1")
|
||||
compileOnly("org.jetbrains:annotations:21.0.1")
|
||||
}
|
||||
|
||||
the<JavaPluginExtension>().toolchain {
|
||||
@@ -63,7 +65,7 @@ tasks.compileJava.configure {
|
||||
options.release.set(8)
|
||||
}
|
||||
|
||||
version = "2.3.3"
|
||||
version = "2.4.0"
|
||||
|
||||
tasks.named<Copy>("processResources") {
|
||||
filesMatching("plugin.yml") {
|
||||
|
||||
@@ -0,0 +1,4 @@
|
||||
org.gradle.daemon=true
|
||||
org.gradle.jvmargs=-Xmx2048m -XX:+HeapDumpOnOutOfMemoryError -Dfile.encoding=UTF-8
|
||||
org.gradle.configureondemand=true
|
||||
org.gradle.parallel=true
|
||||
Binary file not shown.
Binary file not shown.
File diff suppressed because it is too large.
Load diff
@@ -1,5 +1,7 @@
|
||||
package me.dniym.actions;
|
||||
|
||||
import me.dniym.enums.Protections;
|
||||
import me.dniym.events.IllegalStackActionEvent;
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.block.Block;
|
||||
import org.bukkit.entity.Entity;
|
||||
@@ -7,52 +9,54 @@ import org.bukkit.entity.Player;
|
||||
import org.bukkit.inventory.Inventory;
|
||||
import org.bukkit.inventory.ItemStack;
|
||||
|
||||
import me.dniym.enums.Protections;
|
||||
import me.dniym.events.IllegalStackActionEvent;
|
||||
|
||||
|
||||
public class IllegalStackAction {
|
||||
|
||||
public static boolean isCompleted(Protections protection, Entity cause, Block block, ItemStack itemInHand, Entity mount,Inventory inventory) {
|
||||
IllegalStackActionEvent event = new IllegalStackActionEvent(protection, cause, block, itemInHand, mount, inventory);
|
||||
Bukkit.getPluginManager().callEvent(event);
|
||||
|
||||
return !event.isCancelled();
|
||||
}
|
||||
|
||||
public static boolean isCompleted(Protections protection,Entity entity, Player player) {
|
||||
return isCompleted(protection,player,null,null,entity,null);
|
||||
}
|
||||
public static boolean isCompleted(
|
||||
Protections protection,
|
||||
Entity cause,
|
||||
Block block,
|
||||
ItemStack itemInHand,
|
||||
Entity mount,
|
||||
Inventory inventory
|
||||
) {
|
||||
IllegalStackActionEvent event = new IllegalStackActionEvent(protection, cause, block, itemInHand, mount, inventory);
|
||||
Bukkit.getPluginManager().callEvent(event);
|
||||
|
||||
public static boolean isCompleted(Protections protection, Player player, Block block) {
|
||||
return isCompleted(protection,player,block,null,null,null);
|
||||
}
|
||||
return !event.isCancelled();
|
||||
}
|
||||
|
||||
public static boolean isCompleted(Protections protection, Player player, Block block, ItemStack itemInHand) {
|
||||
return isCompleted(protection,player,block,itemInHand,null,null);
|
||||
}
|
||||
public static boolean isCompleted(Protections protection, Entity entity, Player player) {
|
||||
return isCompleted(protection, player, null, null, entity, null);
|
||||
}
|
||||
|
||||
public static boolean isCompleted(Protections protection, Player player) {
|
||||
|
||||
return isCompleted(protection,player,null,null,null,null);
|
||||
}
|
||||
public static boolean isCompleted(Protections protection, Player player, Block block) {
|
||||
return isCompleted(protection, player, block, null, null, null);
|
||||
}
|
||||
|
||||
public static boolean isCompleted(Protections protection, Entity entity, Player player, Block block) {
|
||||
return isCompleted(protection,player,block, null, entity,null);
|
||||
}
|
||||
public static boolean isCompleted(Protections protection, Player player, Block block, ItemStack itemInHand) {
|
||||
return isCompleted(protection, player, block, itemInHand, null, null);
|
||||
}
|
||||
|
||||
public static boolean isCompleted(Protections protection, Entity entity, Entity mount) {
|
||||
return isCompleted(protection,entity,null,null,mount,null);
|
||||
}
|
||||
public static boolean isCompleted(Protections protection, Player player) {
|
||||
|
||||
public static boolean isCompleted(Protections protection, ItemStack item, Block block) {
|
||||
return isCompleted(protection,null,block,item,null,null);
|
||||
}
|
||||
return isCompleted(protection, player, null, null, null, null);
|
||||
}
|
||||
|
||||
public static boolean isCompleted(Protections protection, ItemStack item, Inventory inventory) {
|
||||
return isCompleted(protection,null,null,item,null,inventory);
|
||||
}
|
||||
public static boolean isCompleted(Protections protection, Entity entity, Player player, Block block) {
|
||||
return isCompleted(protection, player, block, null, entity, null);
|
||||
}
|
||||
|
||||
public static boolean isCompleted(Protections protection, Entity entity, Entity mount) {
|
||||
return isCompleted(protection, entity, null, null, mount, null);
|
||||
}
|
||||
|
||||
public static boolean isCompleted(Protections protection, ItemStack item, Block block) {
|
||||
return isCompleted(protection, null, block, item, null, null);
|
||||
}
|
||||
|
||||
public static boolean isCompleted(Protections protection, ItemStack item, Inventory inventory) {
|
||||
return isCompleted(protection, null, null, item, null, inventory);
|
||||
}
|
||||
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
@@ -1,7 +1,11 @@
|
||||
package me.dniym.checks;
|
||||
|
||||
import java.util.HashSet;
|
||||
|
||||
import me.dniym.IllegalStack;
|
||||
import me.dniym.enums.Msg;
|
||||
import me.dniym.enums.Protections;
|
||||
import me.dniym.listeners.fListener;
|
||||
import me.dniym.utils.NBTApiStuff;
|
||||
import me.dniym.utils.NBTStuff;
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.attribute.Attribute;
|
||||
import org.bukkit.attribute.AttributeModifier;
|
||||
@@ -11,81 +15,76 @@ import org.bukkit.inventory.ItemFlag;
|
||||
import org.bukkit.inventory.ItemStack;
|
||||
import org.bukkit.inventory.meta.ItemMeta;
|
||||
|
||||
import me.dniym.IllegalStack;
|
||||
import me.dniym.enums.Msg;
|
||||
import me.dniym.enums.Protections;
|
||||
import me.dniym.listeners.fListener;
|
||||
import me.dniym.utils.NBTApiStuff;
|
||||
import me.dniym.utils.NBTStuff;
|
||||
|
||||
import java.util.HashSet;
|
||||
|
||||
public class BadAttributeCheck {
|
||||
|
||||
public static void CheckStorageInventory(CraftingInventory inventory, Player player) {
|
||||
|
||||
public static void CheckStorageInventory(CraftingInventory inventory, Player player) {
|
||||
if (Protections.RemoveCustomAttributes.isEnabled() && IllegalStack.hasStorage()) {
|
||||
|
||||
if (Protections.AllowBypass.isEnabled() && player.hasPermission("illegalstack.enchantbypass"))
|
||||
if (Protections.AllowBypass.isEnabled() && player.hasPermission("illegalstack.enchantbypass")) {
|
||||
return;
|
||||
|
||||
for(ItemStack is:inventory.getStorageContents()) {
|
||||
if(is != null && is.getType() != Material.AIR && NBTStuff.hasBadCustomData(is)) {
|
||||
fListener.getLog().append2(Msg.GenericItemRemoval.getValue(is,Protections.RemoveCustomAttributes,player,"Crafting Inventory"));
|
||||
inventory.removeItem(is);
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
public static boolean hasBadAttributes(ItemStack is, Object obj) {
|
||||
if(!Protections.RemoveCustomAttributes.isEnabled())
|
||||
return false;
|
||||
|
||||
if(is != null && is.getType() != Material.AIR && checkForBadCustomData(is,obj))
|
||||
return true;
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
public static boolean checkForBadCustomData(ItemStack is, Object obj) {
|
||||
for (ItemStack itemStack : inventory.getStorageContents()) {
|
||||
if (itemStack != null && itemStack.getType() != Material.AIR && NBTStuff.hasBadCustomData(itemStack)) {
|
||||
fListener.getLog().append2(Msg.GenericItemRemoval.getValue(
|
||||
itemStack,
|
||||
Protections.RemoveCustomAttributes,
|
||||
player,
|
||||
"Crafting Inventory"
|
||||
));
|
||||
inventory.removeItem(itemStack);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public static boolean hasBadAttributes(ItemStack is, Object obj) {
|
||||
if (!Protections.RemoveCustomAttributes.isEnabled()) {
|
||||
return false;
|
||||
}
|
||||
return is != null && is.getType() != Material.AIR && checkForBadCustomData(is, obj);
|
||||
}
|
||||
|
||||
|
||||
ItemMeta im = is.getItemMeta();
|
||||
|
||||
if (IllegalStack.isHasAttribAPI()) {
|
||||
if(im.hasAttributeModifiers()) {
|
||||
|
||||
StringBuilder attribs = new StringBuilder();
|
||||
HashSet<Attribute> toRemove = new HashSet<Attribute>();
|
||||
for (Attribute a : im.getAttributeModifiers().keySet()) {
|
||||
public static boolean checkForBadCustomData(ItemStack itemStack, Object obj) {
|
||||
ItemMeta itemMeta = itemStack.getItemMeta();
|
||||
if (IllegalStack.isHasAttribAPI()) {
|
||||
if (itemMeta.hasAttributeModifiers()) {
|
||||
StringBuilder attribs = new StringBuilder();
|
||||
HashSet<Attribute> toRemove = new HashSet<>();
|
||||
for (Attribute a : itemMeta.getAttributeModifiers().keySet()) {
|
||||
|
||||
for (AttributeModifier st : im.getAttributeModifiers(a)) {
|
||||
attribs.append(" ").append(st.getName()).append(" value: ").append(st.getAmount());
|
||||
}
|
||||
for (AttributeModifier st : itemMeta.getAttributeModifiers(a)) {
|
||||
attribs.append(" ").append(st.getName()).append(" value: ").append(st.getAmount());
|
||||
}
|
||||
toRemove.add(a);
|
||||
}
|
||||
|
||||
toRemove.add(a);
|
||||
}
|
||||
|
||||
|
||||
fListener.getLog().append(Msg.CustomAttribsRemoved3.getValue(is,obj,attribs),Protections.RemoveCustomAttributes);
|
||||
|
||||
for (Attribute remove : toRemove)
|
||||
im.removeAttributeModifier(remove);
|
||||
fListener.getLog().append(
|
||||
Msg.CustomAttribsRemoved3.getValue(itemStack, obj, attribs),
|
||||
Protections.RemoveCustomAttributes
|
||||
);
|
||||
|
||||
for(ItemFlag iFlag:im.getItemFlags())
|
||||
im.removeItemFlags(iFlag);
|
||||
|
||||
is.setItemMeta(im);
|
||||
return true;
|
||||
}
|
||||
} else if (IllegalStack.isNbtAPI()) {
|
||||
return NBTApiStuff.checkForBadCustomDataLegacy(is, obj);
|
||||
for (Attribute remove : toRemove) {
|
||||
itemMeta.removeAttributeModifier(remove);
|
||||
}
|
||||
|
||||
for (ItemFlag iFlag : itemMeta.getItemFlags()) {
|
||||
itemMeta.removeItemFlags(iFlag);
|
||||
}
|
||||
|
||||
itemStack.setItemMeta(itemMeta);
|
||||
return true;
|
||||
}
|
||||
} else if (IllegalStack.isNbtAPI()) {
|
||||
return NBTApiStuff.checkForBadCustomDataLegacy(itemStack, obj);
|
||||
|
||||
} else {
|
||||
fListener.getLog().append(
|
||||
Msg.StaffNoNBTAPI.getValue(Protections.RemoveCustomAttributes.name()),
|
||||
Protections.RemoveCustomAttributes
|
||||
);
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
} else fListener.getLog().append(Msg.StaffNoNBTAPI.getValue(Protections.RemoveCustomAttributes.name()),Protections.RemoveCustomAttributes);
|
||||
return false;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -1,135 +1,140 @@
|
||||
package me.dniym.checks;
|
||||
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.block.BlockState;
|
||||
import org.bukkit.block.Container;
|
||||
import org.bukkit.block.ShulkerBox;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.inventory.Inventory;
|
||||
import org.bukkit.inventory.ItemStack;
|
||||
import org.bukkit.inventory.meta.BlockStateMeta;
|
||||
import org.bukkit.scheduler.BukkitRunnable;
|
||||
|
||||
import me.dniym.IllegalStack;
|
||||
import me.dniym.actions.IllegalStackAction;
|
||||
import me.dniym.enums.Msg;
|
||||
import me.dniym.enums.Protections;
|
||||
import me.dniym.listeners.fListener;
|
||||
import me.dniym.utils.NBTStuff;
|
||||
|
||||
public class CheckUtils {
|
||||
|
||||
public static boolean CheckEntireContainer(Container c) {
|
||||
boolean added = false;
|
||||
for(ItemStack is:c.getInventory()) {
|
||||
|
||||
if(is != null && IllegalStack.hasShulkers() && is.getType().name().contains("SHULKER_BOX"))
|
||||
{
|
||||
|
||||
int tagSize =NBTStuff.isBadShulker(is);
|
||||
|
||||
if (tagSize > 0 && IllegalStackAction.isCompleted(Protections.DestroyInvalidShulkers,is,c.getInventory())) {
|
||||
fListener.getLog().append(Msg.StaffBadShulkerRemoved.getValue(c.getLocation(), tagSize),Protections.DestroyInvalidShulkers);
|
||||
is.setType(Material.AIR);
|
||||
return true;
|
||||
} else {
|
||||
|
||||
if(is.getItemMeta() instanceof BlockStateMeta){
|
||||
BlockStateMeta im = (BlockStateMeta)is.getItemMeta();
|
||||
Boolean remove = false;
|
||||
if(im.getBlockState() instanceof ShulkerBox)
|
||||
{
|
||||
BlockState shulk = im.getBlockState();
|
||||
ShulkerBox shulker = (ShulkerBox) shulk;
|
||||
Inventory inv = Bukkit.createInventory(null, shulker.getInventory().getSize(), "IScontainerCheck");
|
||||
for(ItemStack is2:shulker.getInventory().getContents())
|
||||
{
|
||||
if(is2 == null)
|
||||
continue;
|
||||
tagSize =NBTStuff.isBadShulker(is2);
|
||||
if (tagSize > 0 && IllegalStackAction.isCompleted(Protections.DestroyInvalidShulkers, is2,shulker.getInventory())) {
|
||||
fListener.getLog().append(Msg.StaffBadShulkerRemoved.getValue(c.getLocation(), tagSize),Protections.DestroyInvalidShulkers);
|
||||
is2.setType(Material.AIR);
|
||||
remove = true;
|
||||
}
|
||||
|
||||
|
||||
if(!remove)
|
||||
remove = OverstackedItemCheck.CheckContainer(is2, c);
|
||||
if(!remove)
|
||||
remove =IllegalEnchantCheck.isIllegallyEnchanted(is2, c);
|
||||
if(!remove)
|
||||
remove =RemoveItemTypesCheck.shouldRemove(is2, c);
|
||||
|
||||
if(remove) {
|
||||
inv.removeItem(is2);
|
||||
added = true;
|
||||
}
|
||||
}
|
||||
if(added) {
|
||||
new BukkitRunnable() {
|
||||
|
||||
@Override
|
||||
public void run() {
|
||||
|
||||
shulker.getInventory().setContents(inv.getContents());
|
||||
im.setBlockState(shulker);
|
||||
is.setItemMeta(im);
|
||||
|
||||
}
|
||||
|
||||
}.runTaskLater(IllegalStack.getPlugin(), 4);
|
||||
|
||||
return true;
|
||||
//shulk.update(true);
|
||||
//shulk.setBlockData(shulker.getBlockData());
|
||||
//im.setBlockState(shulk);
|
||||
|
||||
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
if(OverstackedItemCheck.CheckContainer(is,c))
|
||||
return true;
|
||||
|
||||
if(IllegalEnchantCheck.isIllegallyEnchanted(is, c))
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
public static boolean CheckEntireInventory(Inventory inv) {
|
||||
|
||||
for(int i = 0; i < inv.getContents().length; i++) {
|
||||
ItemStack is = inv.getContents()[i];
|
||||
if(is == null)
|
||||
continue;
|
||||
if(RemoveItemTypesCheck.shouldRemove(is, inv))
|
||||
return true;
|
||||
else if(IllegalEnchantCheck.isIllegallyEnchanted(is, inv))
|
||||
return true;
|
||||
else if(BadAttributeCheck.hasBadAttributes(is,inv))
|
||||
return true;
|
||||
else if(OverstackedItemCheck.CheckContainer(is, inv))
|
||||
return true;
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
||||
if(!fListener.is18() && IllegalStack.hasStorage())
|
||||
for(ItemStack is:inv.getStorageContents())
|
||||
if(OverstackedItemCheck.CheckContainer(is, inv))
|
||||
return true;
|
||||
|
||||
return false;
|
||||
}
|
||||
}
|
||||
package me.dniym.checks;
|
||||
|
||||
import me.dniym.IllegalStack;
|
||||
import me.dniym.actions.IllegalStackAction;
|
||||
import me.dniym.enums.Msg;
|
||||
import me.dniym.enums.Protections;
|
||||
import me.dniym.listeners.fListener;
|
||||
import me.dniym.utils.NBTStuff;
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.block.BlockState;
|
||||
import org.bukkit.block.Container;
|
||||
import org.bukkit.block.ShulkerBox;
|
||||
import org.bukkit.inventory.Inventory;
|
||||
import org.bukkit.inventory.ItemStack;
|
||||
import org.bukkit.inventory.meta.BlockStateMeta;
|
||||
import org.bukkit.scheduler.BukkitRunnable;
|
||||
|
||||
public class CheckUtils {
|
||||
|
||||
public static boolean CheckEntireContainer(Container container) {
|
||||
boolean added = false;
|
||||
for (ItemStack itemStack : container.getInventory()) {
|
||||
if (itemStack != null && IllegalStack.hasShulkers() && itemStack.getType().name().contains("SHULKER_BOX")) {
|
||||
int tagSize = NBTStuff.isBadShulker(itemStack);
|
||||
if (tagSize > 0 && IllegalStackAction.isCompleted(
|
||||
Protections.DestroyInvalidShulkers,
|
||||
itemStack,
|
||||
container.getInventory()
|
||||
)) {
|
||||
fListener.getLog().append(
|
||||
Msg.StaffBadShulkerRemoved.getValue(container.getLocation(), tagSize),
|
||||
Protections.DestroyInvalidShulkers
|
||||
);
|
||||
itemStack.setType(Material.AIR);
|
||||
return true;
|
||||
} else {
|
||||
if (itemStack.getItemMeta() instanceof BlockStateMeta) {
|
||||
BlockStateMeta im = (BlockStateMeta) itemStack.getItemMeta();
|
||||
boolean remove = false;
|
||||
if (im.getBlockState() instanceof ShulkerBox) {
|
||||
BlockState shulk = im.getBlockState();
|
||||
ShulkerBox shulker = (ShulkerBox) shulk;
|
||||
Inventory inv = Bukkit.createInventory(null, shulker.getInventory().getSize(), "IScontainerCheck");
|
||||
for (ItemStack itemStack1 : shulker.getInventory().getContents()) {
|
||||
if (itemStack1 == null) {
|
||||
continue;
|
||||
}
|
||||
tagSize = NBTStuff.isBadShulker(itemStack1);
|
||||
if (tagSize > 0 && IllegalStackAction.isCompleted(
|
||||
Protections.DestroyInvalidShulkers,
|
||||
itemStack1,
|
||||
shulker.getInventory()
|
||||
)) {
|
||||
fListener.getLog().append(
|
||||
Msg.StaffBadShulkerRemoved.getValue(container.getLocation(), tagSize),
|
||||
Protections.DestroyInvalidShulkers
|
||||
);
|
||||
itemStack1.setType(Material.AIR);
|
||||
remove = true;
|
||||
}
|
||||
|
||||
if (!remove) {
|
||||
remove = OverstackedItemCheck.CheckContainer(itemStack1, container);
|
||||
}
|
||||
if (!remove) {
|
||||
remove = IllegalEnchantCheck.isIllegallyEnchanted(itemStack1, container);
|
||||
}
|
||||
if (!remove) {
|
||||
remove = RemoveItemTypesCheck.shouldRemove(itemStack1, container);
|
||||
}
|
||||
|
||||
if (remove) {
|
||||
inv.removeItem(itemStack1);
|
||||
added = true;
|
||||
}
|
||||
}
|
||||
if (added) {
|
||||
new BukkitRunnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
shulker.getInventory().setContents(inv.getContents());
|
||||
im.setBlockState(shulker);
|
||||
itemStack.setItemMeta(im);
|
||||
}
|
||||
}.runTaskLater(IllegalStack.getPlugin(), 4);
|
||||
return true;
|
||||
//shulk.update(true);
|
||||
//shulk.setBlockData(shulker.getBlockData());
|
||||
//im.setBlockState(shulk);
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (OverstackedItemCheck.CheckContainer(itemStack, container)) {
|
||||
return true;
|
||||
}
|
||||
|
||||
if (IllegalEnchantCheck.isIllegallyEnchanted(itemStack, container)) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
public static boolean CheckEntireInventory(Inventory inv) {
|
||||
|
||||
for (int i = 0; i < inv.getContents().length; i++) {
|
||||
ItemStack is = inv.getContents()[i];
|
||||
if (is == null) {
|
||||
continue;
|
||||
}
|
||||
if (RemoveItemTypesCheck.shouldRemove(is, inv)) {
|
||||
return true;
|
||||
} else if (IllegalEnchantCheck.isIllegallyEnchanted(is, inv)) {
|
||||
return true;
|
||||
} else if (BadAttributeCheck.hasBadAttributes(is, inv)) {
|
||||
return true;
|
||||
} else if (OverstackedItemCheck.CheckContainer(is, inv)) {
|
||||
return true;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
if (!fListener.is18() && IllegalStack.hasStorage()) {
|
||||
for (ItemStack is : inv.getStorageContents()) {
|
||||
if (OverstackedItemCheck.CheckContainer(is, inv)) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -1,116 +1,149 @@
|
||||
package me.dniym.checks;
|
||||
|
||||
import me.dniym.IllegalStack;
|
||||
import me.dniym.enums.Msg;
|
||||
import me.dniym.enums.Protections;
|
||||
import me.dniym.listeners.fListener;
|
||||
import me.dniym.utils.SlimefunCompat;
|
||||
|
||||
import org.bukkit.Location;
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.block.Container;
|
||||
import org.bukkit.enchantments.Enchantment;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.inventory.Inventory;
|
||||
import org.bukkit.inventory.ItemStack;
|
||||
import java.util.HashSet;
|
||||
|
||||
|
||||
public class IllegalEnchantCheck {
|
||||
|
||||
public static boolean CheckForIllegalEnchants (ItemStack is, Object obj) {
|
||||
|
||||
if(is != null && (obj instanceof Inventory || obj instanceof Container))
|
||||
return isIllegallyEnchanted(is,obj);
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
public static boolean CheckStorageInventory(Inventory inv,Player plr) {
|
||||
if(!IllegalStack.hasStorage())
|
||||
return false;
|
||||
|
||||
boolean invalid = false;
|
||||
for(ItemStack is:inv.getStorageContents())
|
||||
if(is != null && is.getType() != Material.AIR && (invalid = isIllegallyEnchanted(is,inv,true)))
|
||||
fListener.getLog().append2(Msg.GenericItemRemoval.getValue(is,Protections.FixIllegalEnchantmentLevels, plr, "Crafting Inventory"));
|
||||
|
||||
|
||||
return invalid;
|
||||
}
|
||||
|
||||
public static boolean isIllegallyEnchanted(ItemStack is, Object obj) {
|
||||
return isIllegallyEnchanted(is,obj,false);
|
||||
}
|
||||
public static boolean isIllegallyEnchanted(ItemStack is, Object obj, Boolean silent) {
|
||||
|
||||
if (is == null)
|
||||
return false;
|
||||
|
||||
if (Protections.FixIllegalEnchantmentLevels.isEnabled() && !is.getEnchantments().isEmpty())
|
||||
{
|
||||
if (!Protections.OnlyFunctionInWorlds.getTxtSet().isEmpty()) {//world list isnt empty
|
||||
Location loc = null;
|
||||
|
||||
if(obj instanceof Inventory) {
|
||||
loc = ((Inventory)obj).getLocation();
|
||||
if(loc == null) {
|
||||
|
||||
}
|
||||
} else if (obj instanceof Location)
|
||||
loc = ((Location)obj);
|
||||
else if(obj instanceof Container)
|
||||
loc = ((Container) obj).getLocation();
|
||||
|
||||
if (loc != null && !Protections.OnlyFunctionInWorlds.getTxtSet().contains(loc.getWorld().getName())) //isnt in a checked world
|
||||
return false;
|
||||
}
|
||||
|
||||
HashSet<Enchantment> replace = new HashSet<>();
|
||||
for (Enchantment en : is.getEnchantments().keySet())
|
||||
if (is.getEnchantmentLevel(en) > en.getMaxLevel()) {
|
||||
|
||||
if (SlimefunCompat.isValid(is, en))
|
||||
continue;
|
||||
|
||||
if (IllegalStack.isEpicRename() && ((en == Enchantment.LURE || en == Enchantment.ARROW_INFINITE) && is.getEnchantmentLevel(en) == 4341))
|
||||
continue;
|
||||
if (Protections.EnchantedItemWhitelist.isWhitelisted(is))
|
||||
break;
|
||||
|
||||
if (Protections.CustomEnchantOverride.isAllowedEnchant(en, is.getEnchantmentLevel(en)))
|
||||
continue;
|
||||
|
||||
if (Protections.DestroyIllegallyEnchantedItemsInstead.isEnabled()) {
|
||||
if(!silent) fListener.getLog().append2(Msg.DestroyedEnchantedItem.getValue(obj, is, en));
|
||||
is.setType(Material.AIR);
|
||||
return true;
|
||||
}
|
||||
if (en.canEnchantItem(is)) {
|
||||
if(!silent) fListener.getLog().append2(Msg.IllegalEnchantLevel.getValue(obj, is, en));
|
||||
} else {
|
||||
if(!silent) fListener.getLog().append2(Msg.IllegalEnchantType.getValue(obj, is, en));
|
||||
replace.add(en);
|
||||
}
|
||||
} else {
|
||||
if (!en.canEnchantItem(is)) {
|
||||
if (SlimefunCompat.isValid(is, en))
|
||||
continue;
|
||||
|
||||
replace.add(en);
|
||||
if(!silent) fListener.getLog().append2(Msg.IllegalEnchantType.getValue(obj, is, en));
|
||||
}
|
||||
}
|
||||
|
||||
for (Enchantment en : replace) {
|
||||
is.removeEnchantment(en);
|
||||
if (en.canEnchantItem(is))
|
||||
is.addEnchantment(en, en.getMaxLevel());
|
||||
}
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
package me.dniym.checks;
|
||||
|
||||
import me.dniym.IllegalStack;
|
||||
import me.dniym.enums.Msg;
|
||||
import me.dniym.enums.Protections;
|
||||
import me.dniym.listeners.fListener;
|
||||
import me.dniym.utils.SlimefunCompat;
|
||||
import org.bukkit.Location;
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.block.Container;
|
||||
import org.bukkit.enchantments.Enchantment;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.inventory.Inventory;
|
||||
import org.bukkit.inventory.ItemStack;
|
||||
|
||||
import java.util.HashSet;
|
||||
|
||||
public class IllegalEnchantCheck {
|
||||
|
||||
public static boolean CheckForIllegalEnchants(ItemStack itemStack, Object obj) {
|
||||
|
||||
if (itemStack != null && (obj instanceof Inventory || obj instanceof Container)) {
|
||||
return isIllegallyEnchanted(itemStack, obj);
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
public static boolean CheckStorageInventory(Inventory inv, Player player) {
|
||||
if (!IllegalStack.hasStorage()) {
|
||||
return false;
|
||||
}
|
||||
|
||||
boolean invalid = false;
|
||||
for (ItemStack itemStack : inv.getStorageContents()) {
|
||||
if (itemStack != null && itemStack.getType() != Material.AIR && (invalid = isIllegallyEnchanted(
|
||||
itemStack,
|
||||
inv,
|
||||
true
|
||||
))) {
|
||||
fListener.getLog().append2(Msg.GenericItemRemoval.getValue(
|
||||
itemStack,
|
||||
Protections.FixIllegalEnchantmentLevels,
|
||||
player,
|
||||
"Crafting Inventory"
|
||||
));
|
||||
}
|
||||
}
|
||||
|
||||
return invalid;
|
||||
}
|
||||
|
||||
public static boolean isIllegallyEnchanted(ItemStack itemStack, Object obj) {
|
||||
return isIllegallyEnchanted(itemStack, obj, false);
|
||||
}
|
||||
|
||||
public static boolean isIllegallyEnchanted(ItemStack itemStack, Object obj, boolean silent) {
|
||||
|
||||
if (itemStack == null) {
|
||||
return false;
|
||||
}
|
||||
|
||||
if (Protections.FixIllegalEnchantmentLevels.isEnabled() && !itemStack.getEnchantments().isEmpty()) {
|
||||
if (!Protections.OnlyFunctionInWorlds.getTxtSet().isEmpty()) {//world list isnt empty
|
||||
Location loc = null;
|
||||
|
||||
if (obj instanceof Inventory) {
|
||||
loc = ((Inventory) obj).getLocation();
|
||||
} else if (obj instanceof Location) {
|
||||
loc = ((Location) obj);
|
||||
} else if (obj instanceof Container) {
|
||||
loc = ((Container) obj).getLocation();
|
||||
}
|
||||
|
||||
if (loc != null && !Protections.OnlyFunctionInWorlds.getTxtSet().contains(loc
|
||||
.getWorld()
|
||||
.getName())) //isnt in a checked world
|
||||
{
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
HashSet<Enchantment> replace = new HashSet<>();
|
||||
for (Enchantment enchantment : itemStack.getEnchantments().keySet()) {
|
||||
if (itemStack.getEnchantmentLevel(enchantment) > enchantment.getMaxLevel()) {
|
||||
|
||||
if (SlimefunCompat.isValid(itemStack, enchantment)) {
|
||||
continue;
|
||||
}
|
||||
|
||||
if (IllegalStack.isEpicRename() && ((enchantment == Enchantment.LURE || enchantment == Enchantment.ARROW_INFINITE) && itemStack
|
||||
.getEnchantmentLevel(
|
||||
enchantment) == 4341)) {
|
||||
continue;
|
||||
}
|
||||
if (Protections.EnchantedItemWhitelist.isWhitelisted(itemStack)) {
|
||||
break;
|
||||
}
|
||||
|
||||
if (Protections.CustomEnchantOverride.isAllowedEnchant(
|
||||
enchantment,
|
||||
itemStack.getEnchantmentLevel(enchantment)
|
||||
)) {
|
||||
continue;
|
||||
}
|
||||
|
||||
if (Protections.DestroyIllegallyEnchantedItemsInstead.isEnabled()) {
|
||||
if (!silent) {
|
||||
fListener.getLog().append2(Msg.DestroyedEnchantedItem.getValue(obj, itemStack, enchantment));
|
||||
}
|
||||
itemStack.setType(Material.AIR);
|
||||
return true;
|
||||
}
|
||||
if (enchantment.canEnchantItem(itemStack)) {
|
||||
if (!silent) {
|
||||
fListener.getLog().append2(Msg.IllegalEnchantLevel.getValue(obj, itemStack, enchantment));
|
||||
}
|
||||
} else {
|
||||
if (!silent) {
|
||||
fListener.getLog().append2(Msg.IllegalEnchantType.getValue(obj, itemStack, enchantment));
|
||||
}
|
||||
replace.add(enchantment);
|
||||
}
|
||||
} else {
|
||||
if (!enchantment.canEnchantItem(itemStack)) {
|
||||
if (SlimefunCompat.isValid(itemStack, enchantment)) {
|
||||
continue;
|
||||
}
|
||||
|
||||
replace.add(enchantment);
|
||||
if (!silent) {
|
||||
fListener.getLog().append2(Msg.IllegalEnchantType.getValue(obj, itemStack, enchantment));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
for (Enchantment en : replace) {
|
||||
itemStack.removeEnchantment(en);
|
||||
if (en.canEnchantItem(itemStack)) {
|
||||
itemStack.addEnchantment(en, en.getMaxLevel());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -1,138 +0,0 @@
|
||||
package me.dniym.checks;
|
||||
|
||||
|
||||
|
||||
|
||||
import java.util.HashSet;
|
||||
|
||||
import org.bukkit.Location;
|
||||
import org.bukkit.block.Block;
|
||||
import org.bukkit.block.BlockState;
|
||||
import org.bukkit.block.ShulkerBox;
|
||||
import org.bukkit.enchantments.Enchantment;
|
||||
import org.bukkit.inventory.InventoryHolder;
|
||||
import org.bukkit.inventory.ItemStack;
|
||||
import org.bukkit.inventory.meta.BlockStateMeta;
|
||||
import org.bukkit.scheduler.BukkitRunnable;
|
||||
|
||||
import me.dniym.IllegalStack;
|
||||
import me.dniym.enums.Protections;
|
||||
import me.dniym.utils.SlimefunCompat;
|
||||
|
||||
public class IrritaingLegacyChecks {
|
||||
|
||||
public static boolean isIllegallyEnchanted(ItemStack is) {
|
||||
|
||||
if (is == null)
|
||||
return false;
|
||||
|
||||
if (Protections.FixIllegalEnchantmentLevels.isEnabled() && !is.getEnchantments().isEmpty())
|
||||
{
|
||||
|
||||
HashSet<Enchantment> replace = new HashSet<>();
|
||||
for (Enchantment en : is.getEnchantments().keySet())
|
||||
if (is.getEnchantmentLevel(en) > en.getMaxLevel()) {
|
||||
|
||||
if (SlimefunCompat.isValid(is, en))
|
||||
continue;
|
||||
|
||||
if (IllegalStack.isEpicRename() && ((en == Enchantment.LURE || en == Enchantment.ARROW_INFINITE) && is.getEnchantmentLevel(en) == 4341))
|
||||
continue;
|
||||
if (Protections.EnchantedItemWhitelist.isWhitelisted(is))
|
||||
break;
|
||||
|
||||
if (Protections.CustomEnchantOverride.isAllowedEnchant(en, is.getEnchantmentLevel(en)))
|
||||
continue;
|
||||
return true;
|
||||
} else {
|
||||
if (!en.canEnchantItem(is)) {
|
||||
if (SlimefunCompat.isValid(is, en))
|
||||
continue;
|
||||
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
public static boolean CheckItem(ItemStack item, Location loc) {
|
||||
boolean cancel = false;
|
||||
|
||||
if(item.hasItemMeta() && IllegalStack.hasShulkers()) { //check for shulkers
|
||||
final BlockStateMeta sbm = (BlockStateMeta)item.getItemMeta();
|
||||
if (sbm.getBlockState() instanceof ShulkerBox)
|
||||
{
|
||||
final ShulkerBox shulker = (ShulkerBox)sbm.getBlockState();
|
||||
for(ItemStack is:shulker.getInventory().getContents())
|
||||
{
|
||||
boolean overstacked = false;
|
||||
boolean illegalEnchanted = false;
|
||||
if (Protections.RemoveOverstackedItems.isEnabled()) {
|
||||
overstacked = IrritaingLegacyChecks.CheckContainer(is, sbm, loc);
|
||||
|
||||
}
|
||||
if (Protections.FixIllegalEnchantmentLevels.isEnabled()) {
|
||||
illegalEnchanted = isIllegallyEnchanted(is);
|
||||
|
||||
}
|
||||
if(overstacked || illegalEnchanted)
|
||||
{
|
||||
cancel = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
} else { //should be a single item.
|
||||
cancel = CheckForOverstackedItems(item);
|
||||
|
||||
}
|
||||
return cancel;
|
||||
}
|
||||
private static boolean CheckForOverstackedItems(ItemStack item) {
|
||||
return item.getAmount() > item.getType().getMaxStackSize();
|
||||
|
||||
}
|
||||
public static boolean CheckContainer(ItemStack is, BlockStateMeta sb, Location loc) {
|
||||
|
||||
|
||||
if (is == null)
|
||||
return false;
|
||||
|
||||
if (is.getAmount() > is.getMaxStackSize())
|
||||
{
|
||||
if (Protections.AllowStack.isWhitelisted(is.getType().name(), null))
|
||||
return false;
|
||||
|
||||
return true;
|
||||
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
public static boolean CheckContainer(Block block) {
|
||||
BlockState bs = block.getState();
|
||||
|
||||
Boolean invalid = false;
|
||||
|
||||
if(bs instanceof InventoryHolder)
|
||||
for(ItemStack is:((InventoryHolder)bs).getInventory())
|
||||
if(is != null && CheckItem(is,block.getLocation())) {
|
||||
|
||||
new BukkitRunnable() {
|
||||
|
||||
@Override
|
||||
public void run() {
|
||||
((InventoryHolder)bs).getInventory().removeItem(is);
|
||||
}
|
||||
|
||||
}.runTaskLater(IllegalStack.getPlugin(), 2);
|
||||
invalid = true;
|
||||
}
|
||||
|
||||
|
||||
return invalid;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,134 @@
|
||||
package me.dniym.checks;
|
||||
|
||||
import me.dniym.IllegalStack;
|
||||
import me.dniym.enums.Protections;
|
||||
import me.dniym.utils.SlimefunCompat;
|
||||
import org.bukkit.Location;
|
||||
import org.bukkit.block.Block;
|
||||
import org.bukkit.block.BlockState;
|
||||
import org.bukkit.block.ShulkerBox;
|
||||
import org.bukkit.enchantments.Enchantment;
|
||||
import org.bukkit.inventory.InventoryHolder;
|
||||
import org.bukkit.inventory.ItemStack;
|
||||
import org.bukkit.inventory.meta.BlockStateMeta;
|
||||
import org.bukkit.scheduler.BukkitRunnable;
|
||||
|
||||
public class IrritatingLegacyChecks {
|
||||
|
||||
public static boolean isIllegallyEnchanted(ItemStack itemStack) {
|
||||
if (itemStack == null) {
|
||||
return false;
|
||||
}
|
||||
if (Protections.FixIllegalEnchantmentLevels.isEnabled() && !itemStack.getEnchantments().isEmpty()) {
|
||||
|
||||
for (Enchantment enchantment : itemStack.getEnchantments().keySet()) {
|
||||
if (itemStack.getEnchantmentLevel(enchantment) > enchantment.getMaxLevel()) {
|
||||
|
||||
if (SlimefunCompat.isValid(itemStack, enchantment)) {
|
||||
continue;
|
||||
}
|
||||
|
||||
if (IllegalStack.isEpicRename() && ((enchantment == Enchantment.LURE || enchantment == Enchantment.ARROW_INFINITE) && itemStack
|
||||
.getEnchantmentLevel(
|
||||
enchantment) == 4341)) {
|
||||
continue;
|
||||
}
|
||||
if (Protections.EnchantedItemWhitelist.isWhitelisted(itemStack)) {
|
||||
break;
|
||||
}
|
||||
|
||||
if (Protections.CustomEnchantOverride.isAllowedEnchant(
|
||||
enchantment,
|
||||
itemStack.getEnchantmentLevel(enchantment)
|
||||
)) {
|
||||
continue;
|
||||
}
|
||||
return true;
|
||||
} else {
|
||||
if (!enchantment.canEnchantItem(itemStack)) {
|
||||
if (SlimefunCompat.isValid(itemStack, enchantment)) {
|
||||
continue;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
public static boolean CheckItem(ItemStack item, Location location) {
|
||||
boolean cancel = false;
|
||||
|
||||
if (item.hasItemMeta() && IllegalStack.hasShulkers()) { //check for shulkers
|
||||
final BlockStateMeta blockStateMeta = (BlockStateMeta) item.getItemMeta();
|
||||
if (blockStateMeta.getBlockState() instanceof ShulkerBox) {
|
||||
final ShulkerBox shulker = (ShulkerBox) blockStateMeta.getBlockState();
|
||||
for (ItemStack itemStack : shulker.getInventory().getContents()) {
|
||||
boolean overstacked = false;
|
||||
boolean illegalEnchanted = false;
|
||||
if (Protections.RemoveOverstackedItems.isEnabled()) {
|
||||
overstacked = IrritatingLegacyChecks.CheckContainer(itemStack, location);
|
||||
|
||||
}
|
||||
if (Protections.FixIllegalEnchantmentLevels.isEnabled()) {
|
||||
illegalEnchanted = isIllegallyEnchanted(itemStack);
|
||||
|
||||
}
|
||||
if (overstacked || illegalEnchanted) {
|
||||
cancel = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
} else { //should be a single item.
|
||||
cancel = CheckForOverstackedItems(item);
|
||||
|
||||
}
|
||||
return cancel;
|
||||
}
|
||||
|
||||
private static boolean CheckForOverstackedItems(ItemStack item) {
|
||||
return item.getAmount() > item.getType().getMaxStackSize();
|
||||
|
||||
}
|
||||
|
||||
public static boolean CheckContainer(ItemStack itemStack, Location loc) {
|
||||
if (itemStack == null) {
|
||||
return false;
|
||||
}
|
||||
if (itemStack.getAmount() > itemStack.getMaxStackSize()) {
|
||||
return !Protections.AllowStack.isWhitelisted(itemStack.getType().name(), null);
|
||||
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
public static boolean CheckContainer(Block block) {
|
||||
BlockState blockState = block.getState();
|
||||
boolean invalid = false;
|
||||
|
||||
if (blockState instanceof InventoryHolder) {
|
||||
for (ItemStack itemStack : ((InventoryHolder) blockState).getInventory()) {
|
||||
if (itemStack != null && CheckItem(itemStack, block.getLocation())) {
|
||||
new BukkitRunnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
((InventoryHolder) blockState).getInventory().removeItem(itemStack);
|
||||
}
|
||||
|
||||
}.runTaskLater(IllegalStack.getPlugin(), 2);
|
||||
invalid = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
return invalid;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -1,89 +1,107 @@
|
||||
package me.dniym.checks;
|
||||
|
||||
import me.dniym.IllegalStack;
|
||||
import me.dniym.enums.Msg;
|
||||
import me.dniym.enums.Protections;
|
||||
import me.dniym.listeners.fListener;
|
||||
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.block.Container;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.inventory.Inventory;
|
||||
import org.bukkit.inventory.ItemStack;
|
||||
|
||||
public class OverstackedItemCheck {
|
||||
|
||||
public static boolean CheckForOverstackedItems (ItemStack is, Object obj) {
|
||||
|
||||
if(is != null && (obj instanceof Inventory || obj instanceof Container))
|
||||
return CheckContainer(is,obj);
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
public static boolean CheckStorageInventory(Inventory inv,Player plr) {
|
||||
boolean invalid = false;
|
||||
if(!IllegalStack.hasStorage())
|
||||
return false;
|
||||
|
||||
for(ItemStack is:inv.getStorageContents())
|
||||
if(is != null && is.getType() != Material.AIR && CheckContainer(is,inv,true))
|
||||
fListener.getLog().append2(Msg.GenericItemRemoval.getValue(is,Protections.RemoveOverstackedItems, plr, "Crafting Inventory"));
|
||||
|
||||
|
||||
return invalid;
|
||||
}
|
||||
|
||||
public static boolean CheckContainer(ItemStack is, Object obj) {
|
||||
if(CheckContainer(is,obj,false))
|
||||
return true;
|
||||
|
||||
return false;
|
||||
}
|
||||
public static boolean CheckContainer(ItemStack is, Object obj, Boolean silent) {
|
||||
|
||||
if (is == null)
|
||||
return false;
|
||||
|
||||
|
||||
if (is.getAmount() > is.getMaxStackSize()) {
|
||||
|
||||
if (!Protections.IllegalStackMode.isEnabled()) //in blacklist mode and on the blacklist
|
||||
{
|
||||
if (Protections.FixOverstackedItemInstead.isEnabled()) {
|
||||
if(!silent) fListener.getLog().append(Msg.IllegalStackShorten.getValue(obj, is), Protections.RemoveOverstackedItems);
|
||||
is.setAmount(is.getType().getMaxStackSize());
|
||||
return true;
|
||||
} else {
|
||||
if(!silent) fListener.getLog().append(Msg.IllegalStackItemScan.getValue(obj, is), Protections.RemoveOverstackedItems);
|
||||
if(obj instanceof Inventory)
|
||||
((Inventory)obj).remove(is);
|
||||
else
|
||||
((Container)obj).getInventory().remove(is);
|
||||
return true;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
if (Protections.AllowStack.isWhitelisted(is.getType().name(), null))
|
||||
return false;
|
||||
|
||||
if (Protections.FixOverstackedItemInstead.isEnabled()) {
|
||||
if(!silent) fListener.getLog().append2(Msg.IllegalStackShorten.getValue(obj, is));
|
||||
is.setAmount(is.getType().getMaxStackSize());
|
||||
|
||||
return true;
|
||||
} else {
|
||||
if(!silent) fListener.getLog().append2(Msg.IllegalStackItemScan.getValue(obj, is));
|
||||
if(obj instanceof Inventory)
|
||||
((Inventory)obj).remove(is);
|
||||
else
|
||||
((Container)obj).getInventory().remove(is);
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
}
|
||||
package me.dniym.checks;
|
||||
|
||||
import me.dniym.IllegalStack;
|
||||
import me.dniym.enums.Msg;
|
||||
import me.dniym.enums.Protections;
|
||||
import me.dniym.listeners.fListener;
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.block.Container;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.inventory.Inventory;
|
||||
import org.bukkit.inventory.ItemStack;
|
||||
|
||||
public class OverstackedItemCheck {
|
||||
|
||||
public static boolean CheckForOverstackedItems(ItemStack itemStack, Object obj) {
|
||||
|
||||
if (itemStack != null && (obj instanceof Inventory || obj instanceof Container)) {
|
||||
return CheckContainer(itemStack, obj);
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
public static boolean CheckStorageInventory(Inventory inv, Player player) {
|
||||
if (!IllegalStack.hasStorage()) {
|
||||
return false;
|
||||
}
|
||||
|
||||
for (ItemStack is : inv.getStorageContents()) {
|
||||
if (is != null && is.getType() != Material.AIR && CheckContainer(is, inv, true)) {
|
||||
fListener.getLog().append2(Msg.GenericItemRemoval.getValue(
|
||||
is,
|
||||
Protections.RemoveOverstackedItems,
|
||||
player,
|
||||
"Crafting Inventory"
|
||||
));
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
public static boolean CheckContainer(ItemStack itemStack, Object obj) {
|
||||
return CheckContainer(itemStack, obj, false);
|
||||
}
|
||||
|
||||
public static boolean CheckContainer(ItemStack is, Object obj, Boolean silent) {
|
||||
if (is == null) {
|
||||
return false;
|
||||
}
|
||||
|
||||
if (is.getAmount() > is.getMaxStackSize()) {
|
||||
|
||||
if (!Protections.IllegalStackMode.isEnabled()) { //in blacklist mode and on the blacklist
|
||||
if (Protections.FixOverstackedItemInstead.isEnabled()) {
|
||||
if (!silent) {
|
||||
fListener.getLog().append(
|
||||
Msg.IllegalStackShorten.getValue(obj, is),
|
||||
Protections.RemoveOverstackedItems
|
||||
);
|
||||
}
|
||||
is.setAmount(is.getType().getMaxStackSize());
|
||||
return true;
|
||||
} else {
|
||||
if (!silent) {
|
||||
fListener.getLog().append(
|
||||
Msg.IllegalStackItemScan.getValue(obj, is),
|
||||
Protections.RemoveOverstackedItems
|
||||
);
|
||||
}
|
||||
if (obj instanceof Inventory) {
|
||||
((Inventory) obj).remove(is);
|
||||
} else {
|
||||
((Container) obj).getInventory().remove(is);
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
if (Protections.AllowStack.isWhitelisted(is.getType().name(), null)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
if (Protections.FixOverstackedItemInstead.isEnabled()) {
|
||||
if (!silent) {
|
||||
fListener.getLog().append2(Msg.IllegalStackShorten.getValue(obj, is));
|
||||
}
|
||||
is.setAmount(is.getType().getMaxStackSize());
|
||||
|
||||
return true;
|
||||
} else {
|
||||
if (!silent) {
|
||||
fListener.getLog().append2(Msg.IllegalStackItemScan.getValue(obj, is));
|
||||
}
|
||||
if (obj instanceof Inventory) {
|
||||
((Inventory) obj).remove(is);
|
||||
} else {
|
||||
((Container) obj).getInventory().remove(is);
|
||||
}
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -1,53 +1,53 @@
|
||||
package me.dniym.checks;
|
||||
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.block.Container;
|
||||
import org.bukkit.block.ShulkerBox;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.inventory.Inventory;
|
||||
import org.bukkit.inventory.ItemStack;
|
||||
|
||||
import me.dniym.IllegalStack;
|
||||
import me.dniym.enums.Msg;
|
||||
import me.dniym.enums.Protections;
|
||||
import me.dniym.listeners.fListener;
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.block.Container;
|
||||
import org.bukkit.inventory.Inventory;
|
||||
import org.bukkit.inventory.ItemStack;
|
||||
|
||||
public class RemoveItemTypesCheck {
|
||||
|
||||
public static boolean CheckForIllegalTypes(ItemStack is, Object obj) {
|
||||
public static boolean CheckForIllegalTypes(ItemStack itemStack, Object obj) {
|
||||
|
||||
if(is != null && (obj instanceof Inventory || (IllegalStack.hasContainers() && obj instanceof Container)))
|
||||
if(shouldRemove(is,obj))
|
||||
{
|
||||
if(obj instanceof Inventory)
|
||||
((Inventory)obj).remove(is);
|
||||
else
|
||||
((Container)obj).getInventory().remove(is);
|
||||
}
|
||||
if (itemStack != null && (obj instanceof Inventory || (IllegalStack.hasContainers() && obj instanceof Container))) {
|
||||
if (shouldRemove(itemStack, obj)) {
|
||||
if (obj instanceof Inventory) {
|
||||
((Inventory) obj).remove(itemStack);
|
||||
} else {
|
||||
((Container) obj).getInventory().remove(itemStack);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return false;
|
||||
return false;
|
||||
}
|
||||
|
||||
}
|
||||
public static boolean shouldRemove(Material type) {
|
||||
return Protections.RemoveItemTypes.isWhitelisted(type);
|
||||
}
|
||||
|
||||
public static boolean shouldRemove(Material type, Player player) {
|
||||
return Protections.RemoveItemTypes.isWhitelisted(type);
|
||||
|
||||
|
||||
}
|
||||
|
||||
public static boolean shouldRemove(ItemStack is, Object obj) {
|
||||
public static boolean shouldRemove(ItemStack itemStack, Object obj) {
|
||||
|
||||
|
||||
if (Protections.RemoveItemTypes.isWhitelisted(is)) {
|
||||
|
||||
if (obj != null && Protections.RemoveItemTypes.notifyOnly()) {
|
||||
fListener.getLog().notify(Protections.RemoveItemTypes, " Triggered by: a contianer with item: " + is.getType().name());
|
||||
return false;
|
||||
} else if (obj != null)
|
||||
fListener.getLog().append2(Msg.ItemTypeRemoved.getValue(obj,is,null));
|
||||
return true;
|
||||
|
||||
}
|
||||
return false;
|
||||
}
|
||||
if (Protections.RemoveItemTypes.isWhitelisted(itemStack)) {
|
||||
|
||||
if (obj != null && Protections.RemoveItemTypes.notifyOnly()) {
|
||||
fListener.getLog().notify(
|
||||
Protections.RemoveItemTypes,
|
||||
" Triggered by: a container with item: " + itemStack.getType().name()
|
||||
);
|
||||
return false;
|
||||
} else if (obj != null) {
|
||||
fListener.getLog().append2(Msg.ItemTypeRemoved.getValue(obj, itemStack, null));
|
||||
}
|
||||
return true;
|
||||
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
}
|
||||
+121
-75
@@ -4,7 +4,7 @@ import me.dniym.IllegalStack;
|
||||
import me.dniym.enums.Msg;
|
||||
import me.dniym.enums.Protections;
|
||||
import me.dniym.listeners.fListener;
|
||||
import me.dniym.utils.SpigMethods;
|
||||
import me.dniym.utils.SpigotMethods;
|
||||
import org.apache.commons.lang.StringUtils;
|
||||
import org.bukkit.ChatColor;
|
||||
import org.bukkit.Location;
|
||||
@@ -17,15 +17,16 @@ import org.bukkit.scheduler.BukkitRunnable;
|
||||
|
||||
import java.util.HashSet;
|
||||
|
||||
public class iStackCommand implements CommandExecutor {
|
||||
public class IllegalStackCommand implements CommandExecutor {
|
||||
|
||||
@Override
|
||||
public boolean onCommand(CommandSender sender, Command command, String label, String[] args) {
|
||||
|
||||
if (args.length == 1) {
|
||||
if (args[0].equalsIgnoreCase("reload")) {
|
||||
if (!hasPerm(sender, "illegalstack.admin"))
|
||||
if (!hasPerm(sender, "illegalstack.admin")) {
|
||||
return true;
|
||||
}
|
||||
|
||||
sender.sendMessage(ChatColor.GREEN + "[IllegalStack] - All configuration settings have been reloaded.");
|
||||
IllegalStack.ReloadConfig(true);
|
||||
@@ -35,57 +36,72 @@ public class iStackCommand implements CommandExecutor {
|
||||
|
||||
if (args.length >= 1) {
|
||||
if (args[0].toLowerCase().startsWith("ver")) {
|
||||
if (!hasPerm(sender, "illegalstack.admin"))
|
||||
if (!hasPerm(sender, "illegalstack.admin")) {
|
||||
return true;
|
||||
}
|
||||
|
||||
String ver = IllegalStack.getPlugin().getDescription().getVersion();
|
||||
sender.sendMessage(ChatColor.AQUA + "-----===== Illegal Stack (" + ver + ") =====-----");
|
||||
sender.sendMessage(ChatColor.GOLD + " Detected Server Version: " + IllegalStack.getVersion() + (IllegalStack.isSpigot() ? "" : "Spigot"));
|
||||
sender.sendMessage(ChatColor.GOLD + " Detected Server Version: " + IllegalStack.getVersion() + (IllegalStack.isSpigot()
|
||||
? ""
|
||||
: "Spigot"));
|
||||
return true;
|
||||
|
||||
}
|
||||
|
||||
if (args[0].toLowerCase().startsWith("fix")) {
|
||||
if (sender instanceof Player) {
|
||||
if (sender.hasPermission("IllegalStack.fixCommand"))
|
||||
if (sender.hasPermission("IllegalStack.fixCommand")) {
|
||||
Protections.fixEnchants(((Player) sender));
|
||||
else
|
||||
} else {
|
||||
sender.sendMessage("You don't have permission to force fix enchantment levels on an item.");
|
||||
} else
|
||||
}
|
||||
} else {
|
||||
sender.sendMessage("This command can only be used in game by a player.");
|
||||
}
|
||||
return true;
|
||||
|
||||
}
|
||||
if (args[0].toLowerCase().startsWith("prot")) {
|
||||
if (!hasPerm(sender, "illegalstack.admin"))
|
||||
if (!hasPerm(sender, "illegalstack.admin")) {
|
||||
return true;
|
||||
fListener fl = fListener.getInstance();
|
||||
}
|
||||
sender.sendMessage(ChatColor.AQUA + "-----===== Illegal Stack Protections =====-----");
|
||||
sender.sendMessage(ChatColor.GOLD + " Detected Server Version: " + IllegalStack.getVersion() + (IllegalStack.isSpigot() ? "" : "Spigot"));
|
||||
sender.sendMessage(ChatColor.GOLD + " Detected Server Version: " + IllegalStack.getVersion() + (IllegalStack.isSpigot()
|
||||
? ""
|
||||
: "Spigot"));
|
||||
sender.sendMessage(ChatColor.AQUA + "-" + " Version Specific Protections -");
|
||||
int parentId = 0;
|
||||
int catId = 0;
|
||||
if (args.length >= 2)
|
||||
if (StringUtils.isNumeric(args[1].trim()))
|
||||
if (args.length >= 2) {
|
||||
if (StringUtils.isNumeric(args[1].trim())) {
|
||||
catId = Integer.parseInt(args[1].trim());
|
||||
if (args.length == 3)
|
||||
if (StringUtils.isNumeric(args[1].trim()))
|
||||
}
|
||||
}
|
||||
if (args.length == 3) {
|
||||
if (StringUtils.isNumeric(args[1].trim())) {
|
||||
parentId = Integer.parseInt(args[2].trim());
|
||||
}
|
||||
}
|
||||
for (Protections p : Protections.values()) {
|
||||
if (!p.getCommand().isEmpty())
|
||||
if (!p.getCommand().isEmpty()) {
|
||||
continue;
|
||||
if (p.isVersionSpecific(IllegalStack.getVersion()) && p.isRelevantToVersion(IllegalStack.getVersion()) && p.getCatId() != 2)
|
||||
sendProtection(sender, p, IllegalStack.getVersion(), parentId, catId);
|
||||
}
|
||||
if (p.isVersionSpecific(IllegalStack.getVersion()) && p.isRelevantToVersion(IllegalStack.getVersion()) && p.getCatId() != 2) {
|
||||
sendProtection(sender, p, parentId, catId);
|
||||
}
|
||||
}
|
||||
|
||||
//sender.sendMessage(ChatColor.AQUA + "- Multi-Version Protections -");
|
||||
sendCategory(sender, "Multi-Version Protections", (catId == 1), 1);
|
||||
if (catId == 1) {
|
||||
for (Protections p : Protections.values()) {
|
||||
if (!p.getCommand().isEmpty() || p.getCatId() == 2)
|
||||
if (!p.getCommand().isEmpty() || p.getCatId() == 2) {
|
||||
continue;
|
||||
if (p.isRelevantToVersion(IllegalStack.getVersion()) && !p.isVersionSpecific(IllegalStack.getVersion()))
|
||||
sendProtection(sender, p, IllegalStack.getVersion(), parentId, catId);
|
||||
}
|
||||
if (p.isRelevantToVersion(IllegalStack.getVersion()) && !p.isVersionSpecific(IllegalStack.getVersion())) {
|
||||
sendProtection(sender, p, parentId, catId);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
@@ -94,11 +110,13 @@ public class iStackCommand implements CommandExecutor {
|
||||
//sender.sendMessage(ChatColor.AQUA + "- Misc / User Requested Features -");
|
||||
if (catId == 2) {
|
||||
for (Protections p : Protections.values()) {
|
||||
if (!p.getCommand().isEmpty())
|
||||
if (!p.getCommand().isEmpty()) {
|
||||
continue;
|
||||
}
|
||||
|
||||
if (p.isRelevantToVersion(IllegalStack.getVersion()) && p.getCatId() == catId)
|
||||
sendProtection(sender, p, IllegalStack.getVersion(), parentId, catId);
|
||||
if (p.isRelevantToVersion(IllegalStack.getVersion()) && p.getCatId() == catId) {
|
||||
sendProtection(sender, p, parentId, catId);
|
||||
}
|
||||
}
|
||||
}
|
||||
return true;
|
||||
@@ -124,12 +142,18 @@ public class iStackCommand implements CommandExecutor {
|
||||
|
||||
if (args.length >= 2) {
|
||||
if (args[0].equalsIgnoreCase("teleport")) {
|
||||
if (!hasPerm(sender, "illegalstack.notify"))
|
||||
if (!hasPerm(sender, "illegalstack.notify")) {
|
||||
return true;
|
||||
}
|
||||
if (sender instanceof Player) {
|
||||
if (args.length >= 4) {
|
||||
World w = IllegalStack.getPlugin().getServer().getWorld(args[4]);
|
||||
Location loc = new Location(w, Integer.parseInt(args[1]), Integer.parseInt(args[2]), Integer.parseInt(args[3]));
|
||||
Location loc = new Location(
|
||||
w,
|
||||
Integer.parseInt(args[1]),
|
||||
Integer.parseInt(args[2]),
|
||||
Integer.parseInt(args[3])
|
||||
);
|
||||
((Player) sender).teleport(loc);
|
||||
return true;
|
||||
}
|
||||
@@ -139,14 +163,16 @@ public class iStackCommand implements CommandExecutor {
|
||||
}
|
||||
}
|
||||
if (args[0].equalsIgnoreCase("toggle")) {
|
||||
if (!hasPerm(sender, "illegalstack.admin"))
|
||||
if (!hasPerm(sender, "illegalstack.admin")) {
|
||||
return true;
|
||||
}
|
||||
Protections p = Protections.getProtection(args[1]);
|
||||
if (p != null) {
|
||||
p.toggleProtection();
|
||||
String status = "ON";
|
||||
if (!p.isEnabled())
|
||||
if (!p.isEnabled()) {
|
||||
status = "OFF";
|
||||
}
|
||||
fListener.getLog().append2(Msg.StaffProtectionToggleMsg.getValue(p, sender.getName(), status));
|
||||
refreshCommands(sender);
|
||||
return true;
|
||||
@@ -156,34 +182,38 @@ public class iStackCommand implements CommandExecutor {
|
||||
}
|
||||
|
||||
if (args.length >= 4) {
|
||||
if (!hasPerm(sender, "illegalstack.admin"))
|
||||
if (!hasPerm(sender, "illegalstack.admin")) {
|
||||
return true;
|
||||
}
|
||||
if (args[0].equalsIgnoreCase("value")) {
|
||||
|
||||
Protections pro = Protections.getProtection(args[2]);
|
||||
if (pro == null) {
|
||||
sender.sendMessage(Msg.StaffInvalidProtectionMsg.getValue());
|
||||
String prots = "";
|
||||
for (Protections p : Protections.values())
|
||||
if (p.isList())
|
||||
prots = prots + p.name() + ", ";
|
||||
sender.sendMessage(ChatColor.GRAY + prots);
|
||||
StringBuilder prots = new StringBuilder();
|
||||
for (Protections p : Protections.values()) {
|
||||
if (p.isList()) {
|
||||
prots.append(p.name()).append(", ");
|
||||
}
|
||||
}
|
||||
sender.sendMessage(ChatColor.GRAY + prots.toString());
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
if (args[1].equalsIgnoreCase("remove")) {
|
||||
String val = args[3].trim();
|
||||
StringBuilder val = new StringBuilder(args[3].trim());
|
||||
if (args.length >= 4) {
|
||||
val = "";
|
||||
for (int i = 3; i < args.length; i++)
|
||||
val = val + args[i] + " ";
|
||||
val = new StringBuilder();
|
||||
for (int i = 3; i < args.length; i++) {
|
||||
val.append(args[i]).append(" ");
|
||||
}
|
||||
|
||||
val = val.trim();
|
||||
val = new StringBuilder(val.toString().trim());
|
||||
|
||||
}
|
||||
|
||||
pro.remTxtSet(val, sender);
|
||||
pro.remTxtSet(val.toString(), sender);
|
||||
//refreshCommands(sender);
|
||||
return true;
|
||||
}
|
||||
@@ -200,42 +230,49 @@ public class iStackCommand implements CommandExecutor {
|
||||
}
|
||||
if (args.length > 0) {
|
||||
if (args[0].equalsIgnoreCase("toggle")) {
|
||||
if (!hasPerm(sender, "illegalstack.admin"))
|
||||
if (!hasPerm(sender, "illegalstack.admin")) {
|
||||
return true;
|
||||
}
|
||||
sender.sendMessage(ChatColor.AQUA + "-----===== Available Protection Toggles =====-----");
|
||||
String prots = "";
|
||||
for (Protections p : Protections.values())
|
||||
if (p.getParentId() == 0)
|
||||
prots = prots + p.name() + ", ";
|
||||
StringBuilder prots = new StringBuilder();
|
||||
for (Protections p : Protections.values()) {
|
||||
if (p.getParentId() == 0) {
|
||||
prots.append(p.name()).append(", ");
|
||||
}
|
||||
}
|
||||
|
||||
sender.sendMessage(ChatColor.GRAY + prots);
|
||||
sender.sendMessage(ChatColor.GRAY + prots.toString());
|
||||
sender.sendMessage(ChatColor.GOLD + "/istack toggle <protection>" + ChatColor.GRAY + " - Toggles a protection on/off");
|
||||
return true;
|
||||
}
|
||||
|
||||
if (args[0].equalsIgnoreCase("value")) {
|
||||
if (!hasPerm(sender, "illegalstack.admin"))
|
||||
if (!hasPerm(sender, "illegalstack.admin")) {
|
||||
return true;
|
||||
}
|
||||
if (args.length > 3 && args[1].equalsIgnoreCase("add")) {
|
||||
Protections pro = Protections.getProtection(args[2]);
|
||||
if (pro != Protections.ItemNamesToRemove && pro != Protections.ItemLoresToRemove) {
|
||||
sender.sendMessage(Msg.StaffSingleWordsOnly.getValue());
|
||||
return true;
|
||||
}
|
||||
String text = "";
|
||||
for (int i = 3; i < args.length; i++)
|
||||
text = text + args[i] + " ";
|
||||
if (pro.validate(text.trim(), sender))
|
||||
sender.sendMessage(Msg.StaffStringUpdated.getValue(text));
|
||||
StringBuilder text = new StringBuilder();
|
||||
for (int i = 3; i < args.length; i++) {
|
||||
text.append(args[i]).append(" ");
|
||||
}
|
||||
if (pro.validate(text.toString().trim(), sender)) {
|
||||
sender.sendMessage(Msg.StaffStringUpdated.getValue(text.toString()));
|
||||
}
|
||||
return true;
|
||||
|
||||
}
|
||||
if (args.length > 3 && args[1].equalsIgnoreCase("set")) {
|
||||
Protections pro = Protections.getProtection(args[2]);
|
||||
String text = "";
|
||||
for (int i = 3; i < args.length; i++)
|
||||
text = text + args[i] + " ";
|
||||
if (pro.validate(text, sender)) {
|
||||
StringBuilder text = new StringBuilder();
|
||||
for (int i = 3; i < args.length; i++) {
|
||||
text.append(args[i]).append(" ");
|
||||
}
|
||||
if (pro.validate(text.toString(), sender)) {
|
||||
sender.sendMessage(Msg.StaffOptionUpdated.getValue());
|
||||
//refreshCommands(sender);
|
||||
}
|
||||
@@ -256,8 +293,9 @@ public class iStackCommand implements CommandExecutor {
|
||||
}
|
||||
|
||||
private boolean hasPerm(CommandSender sender, String perm) {
|
||||
if (sender.hasPermission(perm))
|
||||
if (sender.hasPermission(perm)) {
|
||||
return true;
|
||||
}
|
||||
sender.sendMessage(Msg.StaffMsgNoPerm.getValue(perm));
|
||||
|
||||
return false;
|
||||
@@ -265,23 +303,26 @@ public class iStackCommand implements CommandExecutor {
|
||||
|
||||
private void sendCategory(CommandSender sender, String category, Boolean show, int catId) {
|
||||
Player plr = null;
|
||||
if (sender instanceof Player)
|
||||
if (sender instanceof Player) {
|
||||
plr = (Player) sender;
|
||||
}
|
||||
|
||||
if (IllegalStack.isSpigot() && plr != null) {
|
||||
plr.spigot().sendMessage(SpigMethods.makeCategoryText(plr, category, show, catId));
|
||||
plr.spigot().sendMessage(SpigotMethods.makeCategoryText(category, show, catId));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private void sendProtection(CommandSender sender, Protections p, String serverVersion, int parentId, int catId) {
|
||||
private void sendProtection(CommandSender sender, Protections p, int parentId, int catId) {
|
||||
|
||||
boolean line = false;
|
||||
String status = ChatColor.GREEN + " ON";
|
||||
Player plr = null;
|
||||
if (sender instanceof Player)
|
||||
if (sender instanceof Player) {
|
||||
plr = (Player) sender;
|
||||
if (!p.isEnabled())
|
||||
}
|
||||
if (!p.isEnabled()) {
|
||||
status = ChatColor.DARK_RED + "OFF";
|
||||
}
|
||||
if (IllegalStack.isSpigot() && plr != null) {
|
||||
boolean hasKids = false;
|
||||
HashSet<Protections> kids = new HashSet<>();
|
||||
@@ -292,35 +333,40 @@ public class iStackCommand implements CommandExecutor {
|
||||
}
|
||||
}
|
||||
|
||||
plr.spigot().sendMessage(SpigMethods.makeParentText(p, status, hasKids, catId));
|
||||
for (Protections child : kids)
|
||||
if (parentId != 0 && parentId == p.getProtId())
|
||||
plr.spigot().sendMessage(SpigMethods.makeChildText(child, catId));
|
||||
plr.spigot().sendMessage(SpigotMethods.makeParentText(p, status, hasKids, catId));
|
||||
for (Protections child : kids) {
|
||||
if (parentId != 0 && parentId == p.getProtId()) {
|
||||
plr.spigot().sendMessage(SpigotMethods.makeChildText(child, catId));
|
||||
}
|
||||
}
|
||||
|
||||
} else {
|
||||
if (!p.isList())
|
||||
if (!p.isList()) {
|
||||
sender.sendMessage(ChatColor.GOLD + "[" + status + ChatColor.GOLD + "] " + ChatColor.DARK_AQUA + "" + p.getDisplayName() + "");
|
||||
else
|
||||
sender.sendMessage(ChatColor.DARK_GRAY + "[" + " " + ChatColor.DARK_GRAY + "] " + ChatColor.DARK_AQUA + "" + p.getDisplayName() + " " + p.findValue());
|
||||
} else {
|
||||
sender.sendMessage(ChatColor.DARK_GRAY + "[" + " " + ChatColor.DARK_GRAY + "] " + ChatColor.DARK_AQUA + "" + p.getDisplayName() + " " + p
|
||||
.findValue());
|
||||
}
|
||||
for (Protections child : Protections.values()) {
|
||||
if (child.getParentId() == p.getProtId()) {
|
||||
sender.sendMessage(ChatColor.AQUA + "-> " + ChatColor.DARK_AQUA + child.getDisplayName() + " " + ChatColor.GRAY + child.findValue());
|
||||
sender.sendMessage(ChatColor.AQUA + "-> " + ChatColor.DARK_AQUA + child.getDisplayName() + " " + ChatColor.GRAY + child
|
||||
.findValue());
|
||||
line = false;
|
||||
}
|
||||
}
|
||||
}
|
||||
if (line)
|
||||
if (line) {
|
||||
sender.sendMessage(" ");
|
||||
}
|
||||
}
|
||||
|
||||
private void refreshCommands(final CommandSender sender) {
|
||||
new BukkitRunnable() {
|
||||
|
||||
@Override
|
||||
public void run() {
|
||||
IllegalStack.getPlugin().getServer().dispatchCommand(sender, "istack prot");
|
||||
}
|
||||
|
||||
}.runTaskLater(IllegalStack.getPlugin(), 5);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
@@ -1,447 +1,487 @@
|
||||
package me.dniym.enums;
|
||||
|
||||
import me.dniym.IllegalStack;
|
||||
import org.apache.logging.log4j.LogManager;
|
||||
import org.apache.logging.log4j.Logger;
|
||||
import org.bukkit.ChatColor;
|
||||
import org.bukkit.Location;
|
||||
import org.bukkit.block.Block;
|
||||
import org.bukkit.block.BlockState;
|
||||
|
||||
import org.bukkit.block.Container;
|
||||
import org.bukkit.block.DoubleChest;
|
||||
import org.bukkit.enchantments.Enchantment;
|
||||
import org.bukkit.entity.Entity;
|
||||
import org.bukkit.entity.EntityType;
|
||||
import org.bukkit.entity.HumanEntity;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.inventory.Inventory;
|
||||
import org.bukkit.inventory.ItemStack;
|
||||
|
||||
public enum Msg {
|
||||
|
||||
//@ Location of offense
|
||||
//~name~ name of player or entity
|
||||
//~contents~ contents of an item frame
|
||||
//~removedblocks~ blocked removed
|
||||
//~author~ book author
|
||||
//~blockType block type
|
||||
//~item~
|
||||
|
||||
PluginPrefix("[IllegalStack] -"),
|
||||
PluginTeleportText(ChatColor.GOLD + "Click to teleport here"),
|
||||
|
||||
ChestRemoved("removed a chest from a ~entity~ @"),
|
||||
ChestPrevented("prevented ~player~ from putting a chest on a ~entity~ @"),
|
||||
StaffChestPunishment("punished ~player~ for continuing to try to put chests on a creature. A ~entity~ was removed, the player's inventory has been cleared and the player has been kicked from the server. @"),
|
||||
BookRemoved("Found a book with characters that do NOT match the specified character set and removed it.. Author was: ~author~"),
|
||||
TooManyPages("Found a book with too many pages and removed it from the inventory of ~name~"),
|
||||
SignRemoved("Found a sign not matching the allowed character set in the world @"),
|
||||
SignRemovedOnPlace("detected a sign placed by ~name~ that contained characters not in the allowed character set. Possible dupe machine exploit! @"),
|
||||
SignKickPlayerMsg("Placing signs with unicode characters is NOT permitted."),
|
||||
ShulkerClick("Removed a shulker box from inside another shulker box clicked by: ~name~"),
|
||||
ShulkerPlace("Removed a shulker box containing illegally stacked, or enchanted items on player ~player~ @"),
|
||||
|
||||
ItemFrameRemoveOnExtend("removed an item frame containing - ~contents~ on the back of a retracting piston @"),
|
||||
ItemFrameRemoveOnRetract("removed an item frame containing - ~contents~ pulled by a sticky piston"),
|
||||
PistonRetractionDupe("Stopped Rail/Carpet Dupe & Removed Piston @ ~removedblocks~"),
|
||||
NetherPortalBlock("Blocked an entity from entering or leaving the nether: ~name~ @"),
|
||||
EndPortalBlock("Blocked an entity from entering or leaving the end: ~name~ @"),
|
||||
MinecartGlitch1("Located and removed a minecart glitched inside another block : ~blocktype~ @"),
|
||||
MinecartGlitch2("Stopped a minecart from being glitched into a block @"),
|
||||
HeadInsideSolidBlock("Stopped ~player~ 's head from being inside a solid block while in a ~vehicle~ @"),
|
||||
HeadInsideSolidBlock2("Stopped ~player~ 's head from being inside a ~block~ Reason: potential Xray Glitch"),
|
||||
MinecartMount("Prevented a ~entity~ from being able to mount a ~vehicle~ @"),
|
||||
ZeroTickGlitch("Stopped Zero tick crop growth glitch and removed (~removedblocks~) @"),
|
||||
NamedItemRemovalHopper("Found an item named ~item~ in a hopper, it has been removed @"),
|
||||
NamedItemRemovalPlayer("Found an item named: ~item~ in ~name~'s inventory, it has been removed. @"),
|
||||
ItemTypeRemovedPlayer("Found a blacklisted item type: ~item~ in ~name~'s inventory, it has been removed"),
|
||||
ItemTypeRemovedPlayerOnPlace("~name~ attempted to place a blacklisted item type: ~item~, it has been removed"),
|
||||
ItemTypeRemovedPlayerOnDrop("~name~ attempted to drop a blacklisted item type: ~item~, it has been removed"),
|
||||
ItemTypeRemoved("Found a blacklisted item type: ~item~ in ~player~'s inventory, it has been removed"),
|
||||
SilkTouchBookBlocked("Stopped ~name~ from breaking ~block~ using a silk touch book @"),
|
||||
|
||||
PistonHeadRemoval("A piston head was exploded.. removing an orphan piston base @"),
|
||||
IllegalStackLogin("Illegal stack of items removed: ~item~ (~amount~) from player: ~name~ at login."),
|
||||
IllegalStackOffhand("Removed an illegal stack of items from the off hand of ~name~, ~item~ ( ~amount~)"),
|
||||
IllegalStackPlayerBody("Illegal stack of items removed: ~item~ (~amount~) from ~name~'s body during item scan."),
|
||||
IllegalStackItemScan("Illegal stack of items removed: ~item~ (~amount~) from player: ~name~ at item scan."),
|
||||
IllegalStackOnClick("Illegal stack of items removed: ~item~ (~amount~) from player: ~name~ on click in inventory."),
|
||||
IllegalStackShorten("Fixed an illegal stack of: ~item~ (~amount~) triggered by player: ~name~."),
|
||||
IllegalStackDurability("Fixed durability on: ~item~ triggered by player: ~name~."),
|
||||
IllegalStackUnstack("Unstacked an illegal stack of: ~item~ (~amount~) triggered by player: ~name~. ~lost~ items were unable to fit and lost."),
|
||||
InvalidPotionRemoved("Removed invalid potion from ~name~ had the following effects: ~effects~"),
|
||||
UnbreakableItemCleared("Removed Unbreakable flag from ~item~ found on player ~name~"),
|
||||
CustomAttribsRemoved("Removed Custom Attributes on ~item~ held by ~name~ (~attributes~)"),
|
||||
CustomAttribsRemoved2("Removed ~item~ with Custom Attributes worn by ~name~ (~attributes~)"),
|
||||
CustomAttribsRemoved3("Removed ~item~ with Custom attributes found in ~name~'s inventory (~attributes~)"),
|
||||
GlideActivateMaxBuild("Prevented ~name~ from activating an elytra while above the max build height. @"),
|
||||
GlideAboveMaxBuild("Player ~name~ was using an elytra above the max build height, disabling glide. @"),
|
||||
CorrectedPlayerLocation("(possible pearl glitch into block) Corrected an enderpearl teleport location for ~player~ @"),
|
||||
StoppedPushableArmorStand("Prevented an armor stand from being lifted straight up via a piston @"),
|
||||
StoppedPushableEntity("Prevented an entity (armor stand/end crystal) from being pushed into another entity @"),
|
||||
RemovedRenamedItem("Removed a renamed item ~item~ from the inventory of ~name~"),
|
||||
BlockedTripwireDupe("Player ~name~ attempted to place a tripwire hook on a trap door, it has been removed (PreventTripwireDupe = true)"),
|
||||
GenericItemRemoval("~item~ removed by protection ~protection~, found on source ~source~"),
|
||||
PlayerTrappedPortalMsg("&cSorry ~name~ but that portal appears to not have a valid exit! You would be trapped if you went through it!"),
|
||||
PlayerCommandSleepMsg("&cSorry but all commands are disabled while sleeping!"),
|
||||
PlayerDisabledBookMsg("&cSorry but player book editing is disabled on this server!"),
|
||||
PlayerKickMsgFishing("&cAuto Clicker Fishing is not allowed on this server!"),
|
||||
PlayerKickMsgFishMod("&cAttention! it looks like you may be using an Auto Fishing Mod... Please change the spot you're fishing to avoid getting kicked!"),
|
||||
PlayerSwimExploitMsg("&cThat villager is too busy swimming to trade with you right now!"),
|
||||
PlayerCMIShulkerNest("&cSorry you can not put a shulker into another shulker!"),
|
||||
PlayerDisabledHorseChestMsg("&cSorry, chests on horses, llamas, mules etc are disabled!"),
|
||||
PlayerDisabledRidingChestedMsg("&cSorry, taming creatures that can carry chests is disabled!"),
|
||||
PlayerKickForChestMsg("&cYou were warned about chests on mobs, stop trying."),
|
||||
|
||||
PlayerNearbyNotification("a nearby exploit was detected ~prot~"),
|
||||
PlayerNetherBlock("&cSorry ~name~ players are not allowed on top of the nether!"),
|
||||
PlayerEnchantBlocked("&cSorry ~name~ Enchanting this item is not permitted."),
|
||||
PlayerRepairBlocked("&cSorry ~name~ Repairing this item is not permitted."),
|
||||
PlayerSpawnEggBlock("&cSorry you can not use spawn eggs to change spawner types!"),
|
||||
|
||||
StaffMsgChangedSpawnerType("Player ~player~ used ~type~ to change a spawner type @"),
|
||||
StaffMsgEndGatewayVehicleRemoved("player ~name~ attempted to take a ~vehicle~ through an end gateway, it has been removed."),
|
||||
StaffMsgBlockedPortalLogin("broke a trapped nether portal @"),
|
||||
StaffMsgBlockedPortal("~player~ was prevented from going through a blocked/trapped nether portal @"),
|
||||
StaffMsgDropperExploit("Detected a hopper/dropper loop exploit and removed a dispenser/dropper @"),
|
||||
StaffMsgDispenerFlint("Detected a downward facing dispenser from dispensing flint and steel which would crash the server @"),
|
||||
StaffMsgSpawnerReset("A ~type~ spawner was reset to a pig spawner when broken by ~name~ @"),
|
||||
StaffMsgCreativeBlock("~name~ was prevented from loading in an illegal item via the creative saved toolbar."),
|
||||
StaffMsgNetherBlock("~name~ was prevented from accessing the top of the nether @"),
|
||||
StaffMsgNetherFix("~name~ has been teleported down from above the nether ceiling @"),
|
||||
StaffMsgUnderNether("~name~ has been killed for flying under the nether floor @"),
|
||||
StaffMsgNetherCart("Stopped ~name~ riding in a vehicle above the nether ceiling @"),
|
||||
StaffMsgBookRemoved("Removed a writable book from player: ~name~ because player book creation is disabled!"),
|
||||
StaffProtectionToggleMsg("Protection: ~protection~ has been turned ~status~ by ~name~"),
|
||||
StaffInvalidProtectionMsg("&cYou must supply a valid protection name to add values to:"),
|
||||
StaffOptionUpdated("&aOption successfully updated!"),
|
||||
StaffSingleWordsOnly("&cThat protection does not support multiple word arguments!"),
|
||||
StaffStringUpdated("&aValue updated with string value: ~value~"),
|
||||
StaffEnchantBypass("&cPlease left click with the item in hand you wish to add to the EnchantedItemWhitelist, left click with nothing in hand or use /istack cancel to cancel."),
|
||||
StaffEnchantBypassCancel("&cEnchantedItemWhitelist add item mode DISABLED."),
|
||||
StaffEnchantBypassAdded("&aAdded ~itemdata~ to the EnchantedItemWhitelist!"),
|
||||
StaffSpamFishingNotice("&a~player~ is spam fishing! ~casts~ casts without a 2 second break! @"),
|
||||
StaffAutoFishingNotice("&a~player~ appears to be using an autofishing mod.. ~count~ caught within 0.3 blocks of each other @"),
|
||||
StaffBadShulkerRemoved("Removed a hacked shulker box with an excessive amount of items in it (~size~) from ~name~ @"),
|
||||
StaffBadShulkerInWorld("Removed a dropped shulker box with an excessive amount of items in it (~size~) from the world: @"),
|
||||
StaffNoItem("You must be holding an item in your main hand to force fix it's enchantment!"),
|
||||
StaffNoEnchants("This item has no enchants to fix!"),
|
||||
StaffEnchantFixed("Corrected ~amount~ enchants on ~item~"),
|
||||
StaffNoNBTAPI("NBT-Api was not found on your server and is needed for ~prot~ since it is enabled! Please download and install it from: https://www.spigotmc.org/resources/nbt-api.7939/"),
|
||||
StaffEnchantNotFixed("IllegalStack did not detect any invalid enchantments on this item."),
|
||||
StaffEndPortalProtected("Prevented the end portal from being broken using a dispenser @"),
|
||||
StaffMsgNoPerm("You do not have permission to use that IllegalStack feature, node required: ~perm~"),
|
||||
StaffMsgBedExplosion("Prevented a bed from being used as an explosive @"),
|
||||
DestroyedEnchantedItem("Destroyed an Illegally Enchanted Item ~item~ ~enchant~.(~lvl) found on player: ~player~"),
|
||||
IllegalEnchantLevel("&aFixed Enchantment Level ~enchant~.(~lvl~) on ~item~ found on player: ~player~"),
|
||||
IllegalEnchantType("&aCould not fix Enchantment ~enchant~.(~lvl~) on ~item~ found on player: ~player~ this enchantment is not valid for this item type!");
|
||||
|
||||
private static final Logger LOGGER = LogManager.getLogger("IllegalStack/" + Msg.class.getSimpleName());
|
||||
|
||||
private String value;
|
||||
|
||||
Msg(String val) {
|
||||
this.setValue(val);
|
||||
}
|
||||
|
||||
public String getValue(String variable) {
|
||||
String val = value;
|
||||
val = val.replace("~perm~", variable);
|
||||
val = val.replace("~prot~", variable);
|
||||
val = val.replace("~author~", variable);
|
||||
val = val.replace("~name~", variable);
|
||||
val = val.replace("~contents~", variable);
|
||||
val = val.replace("~removedblocks~", variable);
|
||||
val = val.replace("@", "@" + variable);
|
||||
val = val.replace("~value~", variable);
|
||||
return ChatColor.translateAlternateColorCodes('&', val);
|
||||
}
|
||||
|
||||
public String getValue(Location location, String types) {
|
||||
String val = value;
|
||||
val = val.replace("@", "@ " + location.toString());
|
||||
val = val.replace("~removedblocks~", types);
|
||||
val = val.replace("~contents~", types);
|
||||
val = val.replace("~item~", types);
|
||||
val = val.replace("~name~", types);
|
||||
return ChatColor.translateAlternateColorCodes('&', val);
|
||||
}
|
||||
|
||||
public String getValue(ItemStack is, Protections prot, Player plr, String source) {
|
||||
String val = value;
|
||||
|
||||
val = val.replace("~item~", is.getType().name());
|
||||
val = val.replace("~protection~", prot.getDisplayName());
|
||||
val = val.replace("~source~", source);
|
||||
if(plr != null)
|
||||
val = plr.getName() + " - " + val;
|
||||
|
||||
return ChatColor.translateAlternateColorCodes('&', val);
|
||||
}
|
||||
public String getValue(Player player, String displayName) {
|
||||
String val = value;
|
||||
val = val.replace("@", "@ " + player.getLocation().toString());
|
||||
val = val.replace("~item~", displayName);
|
||||
val = val.replace("~name~", player.getName());
|
||||
val = val.replace("~player~", player.getName());
|
||||
val = val.replace("~type~", displayName);
|
||||
val = val.replace("~block~", displayName);
|
||||
val = val.replace("~effects~", displayName);
|
||||
return ChatColor.translateAlternateColorCodes('&', val);
|
||||
}
|
||||
|
||||
public String getValue(HumanEntity le, String value) {
|
||||
String val = value;
|
||||
|
||||
val = val.replace("~author~", value);
|
||||
val = val.replace("~name~", le.getName());
|
||||
return val;
|
||||
}
|
||||
|
||||
public String getValue(Player p, Location loc) {
|
||||
String val = value;
|
||||
|
||||
val = val.replace("~player~", p.getName());
|
||||
val = val.replace("@", "@ " + loc.toString());
|
||||
return val;
|
||||
}
|
||||
public String getValue(String source, Location loc) {
|
||||
String val = value;
|
||||
|
||||
val = val.replace("~player~", source);
|
||||
val = val.replace("@", "@ " + loc.toString());
|
||||
return val;
|
||||
}
|
||||
public String getValue(Player p, Integer count, Location loc) {
|
||||
String val = value;
|
||||
|
||||
val = val.replace("~player~", p.getName());
|
||||
val = val.replace("@", "@ " + loc.toString());
|
||||
val = val.replace("~count~", count.toString());
|
||||
return val;
|
||||
}
|
||||
|
||||
public String getValue(Player p, Entity ent) {
|
||||
String val = value;
|
||||
|
||||
val = val.replace("~name~", p.getName());
|
||||
val = val.replace("~player~", p.getName());
|
||||
val = val.replace("~entity~", ent.getName());
|
||||
val = val.replace("~vehicle~", ent.getType().name());
|
||||
val = val.replace("@", "@ " + ent.getLocation().toString());
|
||||
return val;
|
||||
}
|
||||
|
||||
public String getValue(Entity ent1, Entity ent2) {
|
||||
String val = value;
|
||||
|
||||
if(ent1 instanceof Player)
|
||||
val = val.replace("~entity~", ((Player)ent1).getName());
|
||||
else
|
||||
val = val.replace("~entity~", ent1.getType().name());
|
||||
|
||||
val = val.replace("~vehicle~", ent2.getType().name());
|
||||
val = val.replace("@", "@ " + ent1.getLocation().toString());
|
||||
return val;
|
||||
}
|
||||
public String getValue(Location loc, ItemStack is) {
|
||||
String val = value;
|
||||
|
||||
|
||||
val = val.replace("@", "@ " + loc.toString());
|
||||
val = val.replace("~item~", is.getType().name());
|
||||
val = val.replace("~amount~", "" + is.getAmount());
|
||||
return ChatColor.translateAlternateColorCodes('&', val);
|
||||
}
|
||||
public String getValue(Object obj, ItemStack is, Enchantment en) {
|
||||
|
||||
|
||||
String val = value;
|
||||
|
||||
val = val.replace("~item~", is.getType().name());
|
||||
if(en == null)
|
||||
val = val.replace("~enchant~", "");
|
||||
else {
|
||||
val = val.replace("~enchant~", en.getName());
|
||||
val = val.replace("~lvl~", is.getEnchantmentLevel(en) + "");
|
||||
}
|
||||
if(obj instanceof BlockState)
|
||||
val = val.replace("~player~", "a " + ((BlockState)obj).getBlock().getType().name() + "'s inventory");
|
||||
else if(obj instanceof Player)
|
||||
val = val.replace("~player~", ((Player)obj).getName());
|
||||
else if(obj instanceof Inventory)
|
||||
val = val.replace("~player~", ((Inventory)obj).getType().name() + " - ");
|
||||
else if(obj instanceof Location)
|
||||
val = val.replace("~player~", "a shulker box");
|
||||
else if(obj instanceof Container)
|
||||
val = val.replace("~player~", ((Container)obj).getType().name());
|
||||
|
||||
Location loc = null;
|
||||
|
||||
if(obj instanceof BlockState)
|
||||
loc = ((BlockState)obj).getLocation();
|
||||
if(obj instanceof Player)
|
||||
loc = ((Player)obj).getLocation();
|
||||
else if (obj instanceof Block)
|
||||
loc = ((Block)obj).getLocation();
|
||||
else if (obj instanceof Inventory)
|
||||
loc = ((Inventory)obj).getLocation();
|
||||
else if (obj instanceof Location)
|
||||
loc = ((Location)obj);
|
||||
else if(obj instanceof Container)
|
||||
loc = ((Container)obj).getLocation();
|
||||
|
||||
if(loc != null)
|
||||
val = val.replace("@", "@ " + loc.toString());
|
||||
else
|
||||
val = val.replace("@", "@ UNKNOWN ");
|
||||
return val;
|
||||
|
||||
}
|
||||
|
||||
public String getValue(Player p, ItemStack is, Enchantment en) {
|
||||
String val = value;
|
||||
|
||||
val = val.replace("~item~", is.getType().name());
|
||||
val = val.replace("~enchant~", en.getName());
|
||||
val = val.replace("~lvl~", is.getEnchantmentLevel(en) + "");
|
||||
val = val.replace("~player~", p.getName());
|
||||
val = val.replace("@", "@ " + p.getLocation().toString());
|
||||
return val;
|
||||
|
||||
}
|
||||
|
||||
public String getValue(Player p, EntityType et) {
|
||||
String val = value;
|
||||
|
||||
val = val.replace("@", "@ " + p.getLocation().toString());
|
||||
val = val.replace("~type~", et.name());
|
||||
val = val.replace("~name~", p.getName());
|
||||
return ChatColor.translateAlternateColorCodes('&', val);
|
||||
}
|
||||
|
||||
|
||||
public String getValue(Object obj, ItemStack is) {
|
||||
if(obj instanceof Inventory) {
|
||||
if(((Inventory)obj).getHolder() instanceof Player) {
|
||||
Inventory inv = (Inventory)obj;
|
||||
return getValue((Player)inv.getHolder(),is);
|
||||
} else
|
||||
return getValue(((Inventory)obj).getLocation(), is);
|
||||
} else if(obj instanceof Container)
|
||||
return getValue(((Container)obj),is);
|
||||
LOGGER.error("An unknown object {} was passed to IllegalStack during a logging operation please report this to dNiym at the spigot forums or on the IllegalStack Discord.", obj.toString());
|
||||
return "???";
|
||||
}
|
||||
|
||||
public String getValue(Container c, ItemStack is) {
|
||||
String val = value;
|
||||
|
||||
val = val.replace("@", "@ " + c.getLocation().toString());
|
||||
val = val.replace("~item~", is.getType().name());
|
||||
val = val.replace("~name~", c.getType().name());
|
||||
val = val.replace("~amount~", "" + is.getAmount());
|
||||
return ChatColor.translateAlternateColorCodes('&', val);
|
||||
}
|
||||
|
||||
public String getValue(Player p, ItemStack is) {
|
||||
String val = value;
|
||||
|
||||
val = val.replace("@", "@ " + p.getLocation().toString());
|
||||
val = val.replace("~item~", is.getType().name());
|
||||
val = val.replace("~name~", p.getName());
|
||||
val = val.replace("~amount~", "" + is.getAmount());
|
||||
|
||||
return ChatColor.translateAlternateColorCodes('&', val);
|
||||
}
|
||||
|
||||
public String getValue(ItemStack is, Object obj, StringBuilder list) {
|
||||
String val = value;
|
||||
|
||||
if(obj instanceof Player) {
|
||||
val = val.replace("@", "@ " + ((Player)obj).getLocation().toString());
|
||||
val = val.replace("~name~", ((Player)obj).getName());
|
||||
} else if(obj instanceof Inventory) {
|
||||
Inventory inv = null;
|
||||
inv = (Inventory) obj;
|
||||
if(inv.getHolder() instanceof Container)
|
||||
val = val.replace("~name~", ((Container)inv.getHolder()).getLocation().getBlock().getType().name() + " @" + ((Container)inv.getHolder()).getLocation().toString());
|
||||
else if(inv.getHolder() instanceof DoubleChest)
|
||||
val = val.replace("~name~", ((DoubleChest)inv.getHolder()).getLocation().getBlock().getType().name() + " @" + inv.getLocation().toString());
|
||||
else if(inv.getHolder() instanceof Player)
|
||||
val = val.replace("~name~", ((Player)inv.getHolder()).getName() + " @" + inv.getLocation().toString());
|
||||
else
|
||||
LOGGER.error("IllegalStack was supposed to send a message detailing an inventory but could not determine its type! Please contact dNiym at the IllegalStack discord or on Spigot with this message: {} ", obj.toString());
|
||||
}
|
||||
|
||||
|
||||
val = val.replace("~item~", is.getType().name());
|
||||
val = val.replace("~amount~", "" + is.getAmount());
|
||||
val = val.replace("~attributes~", list);
|
||||
|
||||
return ChatColor.translateAlternateColorCodes('&', val);
|
||||
}
|
||||
public String getValue(Player p, ItemStack is, String list) {
|
||||
String val = value;
|
||||
|
||||
val = val.replace("@", "@ " + p.getLocation().toString());
|
||||
val = val.replace("~item~", is.getType().name());
|
||||
val = val.replace("~name~", p.getName());
|
||||
val = val.replace("~amount~", "" + is.getAmount());
|
||||
val = val.replace("~attributes~", list);
|
||||
return ChatColor.translateAlternateColorCodes('&', val);
|
||||
}
|
||||
|
||||
public String getConfigVal() {
|
||||
return ChatColor.translateAlternateColorCodes('&', value);
|
||||
}
|
||||
|
||||
public String getValue() {
|
||||
return value;
|
||||
}
|
||||
|
||||
public void setValue(String value) {
|
||||
this.value = value;
|
||||
}
|
||||
|
||||
public String getValue(Protections p, String name, String status) {
|
||||
String val = value;
|
||||
|
||||
val = val.replace("~protection~", p.name());
|
||||
val = val.replace("~name~", name);
|
||||
val = val.replace("~status~", "" + status);
|
||||
return ChatColor.translateAlternateColorCodes('&', val);
|
||||
}
|
||||
|
||||
public String getValue(Player p, int size) {
|
||||
String val = value;
|
||||
|
||||
val = val.replace("@", "@ " + p.getLocation().toString());
|
||||
val = val.replace("~size~", "" + size);
|
||||
val = val.replace("~name~", p.getName());
|
||||
|
||||
|
||||
return ChatColor.translateAlternateColorCodes('&', val);
|
||||
}
|
||||
|
||||
public String getValue(Location loc, int size) {
|
||||
String val = value;
|
||||
|
||||
val = val.replace("@", "@ " + loc.toString());
|
||||
val = val.replace("~size~", "" + size);
|
||||
return ChatColor.translateAlternateColorCodes('&', val);
|
||||
}
|
||||
|
||||
public String getValue(Player p, ItemStack is, int lostItems) {
|
||||
String val = value;
|
||||
|
||||
val = val.replace("@", "@ " + p.getLocation().toString());
|
||||
val = val.replace("~item~", is.getType().name());
|
||||
val = val.replace("~name~", p.getName());
|
||||
val = val.replace("~amount~", "" + is.getAmount());
|
||||
val = val.replace("~lost~", "" + lostItems);
|
||||
return ChatColor.translateAlternateColorCodes('&', val);
|
||||
}
|
||||
|
||||
}
|
||||
package me.dniym.enums;
|
||||
|
||||
import org.apache.logging.log4j.LogManager;
|
||||
import org.apache.logging.log4j.Logger;
|
||||
import org.bukkit.ChatColor;
|
||||
import org.bukkit.Location;
|
||||
import org.bukkit.block.Block;
|
||||
import org.bukkit.block.BlockState;
|
||||
import org.bukkit.block.Container;
|
||||
import org.bukkit.block.DoubleChest;
|
||||
import org.bukkit.enchantments.Enchantment;
|
||||
import org.bukkit.entity.Entity;
|
||||
import org.bukkit.entity.EntityType;
|
||||
import org.bukkit.entity.HumanEntity;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.inventory.Inventory;
|
||||
import org.bukkit.inventory.ItemStack;
|
||||
|
||||
public enum Msg {
|
||||
|
||||
//@ Location of offense
|
||||
//~name~ name of player or entity
|
||||
//~contents~ contents of an item frame
|
||||
//~removedblocks~ blocked removed
|
||||
//~author~ book author
|
||||
//~blockType block type
|
||||
//~item~
|
||||
|
||||
PluginPrefix("[IllegalStack] -"),
|
||||
PluginTeleportText(ChatColor.GOLD + "Click to teleport here"),
|
||||
|
||||
ChestRemoved("removed a chest from a ~entity~ @"),
|
||||
ChestPrevented("prevented ~player~ from putting a chest on a ~entity~ @"),
|
||||
StaffChestPunishment(
|
||||
"punished ~player~ for continuing to try to put chests on a creature. A ~entity~ was removed, the player's inventory has been cleared and the player has been kicked from the server. @"),
|
||||
BookRemoved("Found a book with characters that do NOT match the specified character set and removed it.. Author was: ~author~"),
|
||||
TooManyPages("Found a book with too many pages and removed it from the inventory of ~name~"),
|
||||
SignRemoved("Found a sign not matching the allowed character set in the world @"),
|
||||
SignRemovedOnPlace(
|
||||
"detected a sign placed by ~name~ that contained characters not in the allowed character set. Possible dupe machine exploit! @"),
|
||||
SignKickPlayerMsg("Placing signs with unicode characters is NOT permitted."),
|
||||
ShulkerClick("Removed a shulker box from inside another shulker box clicked by: ~name~"),
|
||||
ShulkerPlace("Removed a shulker box containing illegally stacked, or enchanted items on player ~player~ @"),
|
||||
|
||||
ItemFrameRemoveOnExtend("removed an item frame containing - ~contents~ on the back of a retracting piston @"),
|
||||
ItemFrameRemoveOnRetract("removed an item frame containing - ~contents~ pulled by a sticky piston"),
|
||||
PistonRetractionDupe("Stopped Rail/Carpet Dupe & Removed Piston @ ~removedblocks~"),
|
||||
NetherPortalBlock("Blocked an entity from entering or leaving the nether: ~name~ @"),
|
||||
EndPortalBlock("Blocked an entity from entering or leaving the end: ~name~ @"),
|
||||
MinecartGlitch1("Located and removed a minecart glitched inside another block : ~blocktype~ @"),
|
||||
MinecartGlitch2("Stopped a minecart from being glitched into a block @"),
|
||||
HeadInsideSolidBlock("Stopped ~player~ 's head from being inside a solid block while in a ~vehicle~ @"),
|
||||
HeadInsideSolidBlock2("Stopped ~player~ 's head from being inside a ~block~ Reason: potential Xray Glitch"),
|
||||
MinecartMount("Prevented a ~entity~ from being able to mount a ~vehicle~ @"),
|
||||
ZeroTickGlitch("Stopped Zero tick crop growth glitch and removed (~removedblocks~) @"),
|
||||
NamedItemRemovalHopper("Found an item named ~item~ in a hopper, it has been removed @"),
|
||||
NamedItemRemovalPlayer("Found an item named: ~item~ in ~name~'s inventory, it has been removed. @"),
|
||||
ItemTypeRemovedPlayer("Found a blacklisted item type: ~item~ in ~name~'s inventory, it has been removed"),
|
||||
ItemTypeRemovedPlayerOnPlace("~name~ attempted to place a blacklisted item type: ~item~, it has been removed"),
|
||||
ItemTypeRemovedPlayerOnDrop("~name~ attempted to drop a blacklisted item type: ~item~, it has been removed"),
|
||||
ItemTypeRemoved("Found a blacklisted item type: ~item~ in ~player~'s inventory, it has been removed"),
|
||||
SilkTouchBookBlocked("Stopped ~name~ from breaking ~block~ using a silk touch book @"),
|
||||
|
||||
PistonHeadRemoval("A piston head was exploded.. removing an orphan piston base @"),
|
||||
IllegalStackLogin("Illegal stack of items removed: ~item~ (~amount~) from player: ~name~ at login."),
|
||||
IllegalStackOffhand("Removed an illegal stack of items from the off hand of ~name~, ~item~ ( ~amount~)"),
|
||||
IllegalStackPlayerBody("Illegal stack of items removed: ~item~ (~amount~) from ~name~'s body during item scan."),
|
||||
IllegalStackItemScan("Illegal stack of items removed: ~item~ (~amount~) from player: ~name~ at item scan."),
|
||||
IllegalStackOnClick("Illegal stack of items removed: ~item~ (~amount~) from player: ~name~ on click in inventory."),
|
||||
IllegalStackShorten("Fixed an illegal stack of: ~item~ (~amount~) triggered by player: ~name~."),
|
||||
IllegalStackDurability("Fixed durability on: ~item~ triggered by player: ~name~."),
|
||||
IllegalStackUnstack(
|
||||
"Unstacked an illegal stack of: ~item~ (~amount~) triggered by player: ~name~. ~lost~ items were unable to fit and lost."),
|
||||
InvalidPotionRemoved("Removed invalid potion from ~name~ had the following effects: ~effects~"),
|
||||
UnbreakableItemCleared("Removed Unbreakable flag from ~item~ found on player ~name~"),
|
||||
CustomAttribsRemoved("Removed Custom Attributes on ~item~ held by ~name~ (~attributes~)"),
|
||||
CustomAttribsRemoved2("Removed ~item~ with Custom Attributes worn by ~name~ (~attributes~)"),
|
||||
CustomAttribsRemoved3("Removed ~item~ with Custom attributes found in ~name~'s inventory (~attributes~)"),
|
||||
GlideActivateMaxBuild("Prevented ~name~ from activating an elytra while above the max build height. @"),
|
||||
GlideAboveMaxBuild("Player ~name~ was using an elytra above the max build height, disabling glide. @"),
|
||||
CorrectedPlayerLocation("(possible pearl glitch into block) Corrected an enderpearl teleport location for ~player~ @"),
|
||||
StoppedPushableArmorStand("Prevented an armor stand from being lifted straight up via a piston @"),
|
||||
StoppedPushableEntity("Prevented an entity (armor stand/end crystal) from being pushed into another entity @"),
|
||||
RemovedRenamedItem("Removed a renamed item ~item~ from the inventory of ~name~"),
|
||||
BlockedTripwireDupe(
|
||||
"Player ~name~ attempted to place a tripwire hook on a trap door, it has been removed (PreventTripwireDupe = true)"),
|
||||
GenericItemRemoval("~item~ removed by protection ~protection~, found on source ~source~"),
|
||||
PlayerTrappedPortalMsg(
|
||||
"&cSorry ~name~ but that portal appears to not have a valid exit! You would be trapped if you went through it!"),
|
||||
PlayerCommandSleepMsg("&cSorry but all commands are disabled while sleeping!"),
|
||||
PlayerDisabledBookMsg("&cSorry but player book editing is disabled on this server!"),
|
||||
PlayerKickMsgFishing("&cAuto Clicker Fishing is not allowed on this server!"),
|
||||
PlayerKickMsgFishMod(
|
||||
"&cAttention! it looks like you may be using an Auto Fishing Mod... Please change the spot you're fishing to avoid getting kicked!"),
|
||||
PlayerSwimExploitMsg("&cThat villager is too busy swimming to trade with you right now!"),
|
||||
PlayerCMIShulkerNest("&cSorry you can not put a shulker into another shulker!"),
|
||||
PlayerDisabledHorseChestMsg("&cSorry, chests on horses, llamas, mules etc are disabled!"),
|
||||
PlayerDisabledRidingChestedMsg("&cSorry, taming creatures that can carry chests is disabled!"),
|
||||
PlayerKickForChestMsg("&cYou were warned about chests on mobs, stop trying."),
|
||||
|
||||
PlayerNearbyNotification("a nearby exploit was detected ~prot~"),
|
||||
PlayerNetherBlock("&cSorry ~name~ players are not allowed on top of the nether!"),
|
||||
PlayerEnchantBlocked("&cSorry ~name~ Enchanting this item is not permitted."),
|
||||
PlayerRepairBlocked("&cSorry ~name~ Repairing this item is not permitted."),
|
||||
PlayerSpawnEggBlock("&cSorry you can not use spawn eggs to change spawner types!"),
|
||||
|
||||
StaffMsgChangedSpawnerType("Player ~player~ used ~type~ to change a spawner type @"),
|
||||
StaffMsgEndGatewayVehicleRemoved("player ~name~ attempted to take a ~vehicle~ through an end gateway, it has been removed."),
|
||||
StaffMsgBlockedPortalLogin("broke a trapped nether portal @"),
|
||||
StaffMsgBlockedPortal("~player~ was prevented from going through a blocked/trapped nether portal @"),
|
||||
StaffMsgDropperExploit("Detected a hopper/dropper loop exploit and removed a dispenser/dropper @"),
|
||||
StaffMsgDispenerFlint("Detected a downward facing dispenser from dispensing flint and steel which would crash the server @"),
|
||||
StaffMsgSpawnerReset("A ~type~ spawner was reset to a pig spawner when broken by ~name~ @"),
|
||||
StaffMsgCreativeBlock("~name~ was prevented from loading in an illegal item via the creative saved toolbar."),
|
||||
StaffMsgNetherBlock("~name~ was prevented from accessing the top of the nether @"),
|
||||
StaffMsgNetherFix("~name~ has been teleported down from above the nether ceiling @"),
|
||||
StaffMsgUnderNether("~name~ has been killed for flying under the nether floor @"),
|
||||
StaffMsgNetherCart("Stopped ~name~ riding in a vehicle above the nether ceiling @"),
|
||||
StaffMsgBookRemoved("Removed a writable book from player: ~name~ because player book creation is disabled!"),
|
||||
StaffProtectionToggleMsg("Protection: ~protection~ has been turned ~status~ by ~name~"),
|
||||
StaffInvalidProtectionMsg("&cYou must supply a valid protection name to add values to:"),
|
||||
StaffOptionUpdated("&aOption successfully updated!"),
|
||||
StaffSingleWordsOnly("&cThat protection does not support multiple word arguments!"),
|
||||
StaffStringUpdated("&aValue updated with string value: ~value~"),
|
||||
StaffEnchantBypass(
|
||||
"&cPlease left click with the item in hand you wish to add to the EnchantedItemWhitelist, left click with nothing in hand or use /istack cancel to cancel."),
|
||||
StaffEnchantBypassCancel("&cEnchantedItemWhitelist add item mode DISABLED."),
|
||||
StaffEnchantBypassAdded("&aAdded ~itemdata~ to the EnchantedItemWhitelist!"),
|
||||
StaffSpamFishingNotice("&a~player~ is spam fishing! ~casts~ casts without a 2 second break! @"),
|
||||
StaffAutoFishingNotice("&a~player~ appears to be using an autofishing mod.. ~count~ caught within 0.3 blocks of each other @"),
|
||||
StaffBadShulkerRemoved("Removed a hacked shulker box with an excessive amount of items in it (~size~) from ~name~ @"),
|
||||
StaffBadShulkerInWorld("Removed a dropped shulker box with an excessive amount of items in it (~size~) from the world: @"),
|
||||
StaffNoItem("You must be holding an item in your main hand to force fix it's enchantment!"),
|
||||
StaffNoEnchants("This item has no enchants to fix!"),
|
||||
StaffEnchantFixed("Corrected ~amount~ enchants on ~item~"),
|
||||
StaffNoNBTAPI(
|
||||
"NBT-Api was not found on your server and is needed for ~prot~ since it is enabled! Please download and install it from: https://www.spigotmc.org/resources/nbt-api.7939/"),
|
||||
StaffEnchantNotFixed("IllegalStack did not detect any invalid enchantments on this item."),
|
||||
StaffEndPortalProtected("Prevented the end portal from being broken using a dispenser @"),
|
||||
StaffMsgNoPerm("You do not have permission to use that IllegalStack feature, node required: ~perm~"),
|
||||
StaffMsgBedExplosion("Prevented a bed from being used as an explosive @"),
|
||||
DestroyedEnchantedItem("Destroyed an Illegally Enchanted Item ~item~ ~enchant~.(~lvl) found on player: ~player~"),
|
||||
IllegalEnchantLevel("&aFixed Enchantment Level ~enchant~.(~lvl~) on ~item~ found on player: ~player~"),
|
||||
IllegalEnchantType(
|
||||
"&aCould not fix Enchantment ~enchant~.(~lvl~) on ~item~ found on player: ~player~ this enchantment is not valid for this item type!");
|
||||
|
||||
private static final Logger LOGGER = LogManager.getLogger("IllegalStack/" + Msg.class.getSimpleName());
|
||||
|
||||
private String value;
|
||||
|
||||
Msg(String val) {
|
||||
this.setValue(val);
|
||||
}
|
||||
|
||||
public String getValue(String variable) {
|
||||
String val = value;
|
||||
val = val.replace("~perm~", variable);
|
||||
val = val.replace("~prot~", variable);
|
||||
val = val.replace("~author~", variable);
|
||||
val = val.replace("~name~", variable);
|
||||
val = val.replace("~contents~", variable);
|
||||
val = val.replace("~removedblocks~", variable);
|
||||
val = val.replace("@", "@" + variable);
|
||||
val = val.replace("~value~", variable);
|
||||
return ChatColor.translateAlternateColorCodes('&', val);
|
||||
}
|
||||
|
||||
public String getValue(Location location, String types) {
|
||||
String val = value;
|
||||
val = val.replace("@", "@ " + location.toString());
|
||||
val = val.replace("~removedblocks~", types);
|
||||
val = val.replace("~contents~", types);
|
||||
val = val.replace("~item~", types);
|
||||
val = val.replace("~name~", types);
|
||||
return ChatColor.translateAlternateColorCodes('&', val);
|
||||
}
|
||||
|
||||
public String getValue(ItemStack is, Protections prot, Player plr, String source) {
|
||||
String val = value;
|
||||
|
||||
val = val.replace("~item~", is.getType().name());
|
||||
val = val.replace("~protection~", prot.getDisplayName());
|
||||
val = val.replace("~source~", source);
|
||||
if (plr != null) {
|
||||
val = plr.getName() + " - " + val;
|
||||
}
|
||||
|
||||
return ChatColor.translateAlternateColorCodes('&', val);
|
||||
}
|
||||
|
||||
public String getValue(Player player, String displayName) {
|
||||
String val = value;
|
||||
val = val.replace("@", "@ " + player.getLocation());
|
||||
val = val.replace("~item~", displayName);
|
||||
val = val.replace("~name~", player.getName());
|
||||
val = val.replace("~player~", player.getName());
|
||||
val = val.replace("~type~", displayName);
|
||||
val = val.replace("~block~", displayName);
|
||||
val = val.replace("~effects~", displayName);
|
||||
return ChatColor.translateAlternateColorCodes('&', val);
|
||||
}
|
||||
|
||||
public String getValue(HumanEntity le, String value) {
|
||||
String val = value;
|
||||
|
||||
val = val.replace("~author~", value);
|
||||
val = val.replace("~name~", le.getName());
|
||||
return val;
|
||||
}
|
||||
|
||||
public String getValue(Player p, Location loc) {
|
||||
String val = value;
|
||||
|
||||
val = val.replace("~player~", p.getName());
|
||||
val = val.replace("@", "@ " + loc.toString());
|
||||
return val;
|
||||
}
|
||||
|
||||
public String getValue(String source, Location loc) {
|
||||
String val = value;
|
||||
|
||||
val = val.replace("~player~", source);
|
||||
val = val.replace("@", "@ " + loc.toString());
|
||||
return val;
|
||||
}
|
||||
|
||||
public String getValue(Player p, Integer count, Location loc) {
|
||||
String val = value;
|
||||
|
||||
val = val.replace("~player~", p.getName());
|
||||
val = val.replace("@", "@ " + loc.toString());
|
||||
val = val.replace("~count~", count.toString());
|
||||
return val;
|
||||
}
|
||||
|
||||
public String getValue(Player p, Entity ent) {
|
||||
String val = value;
|
||||
|
||||
val = val.replace("~name~", p.getName());
|
||||
val = val.replace("~player~", p.getName());
|
||||
val = val.replace("~entity~", ent.getName());
|
||||
val = val.replace("~vehicle~", ent.getType().name());
|
||||
val = val.replace("@", "@ " + ent.getLocation());
|
||||
return val;
|
||||
}
|
||||
|
||||
public String getValue(Entity ent1, Entity ent2) {
|
||||
String val = value;
|
||||
|
||||
if (ent1 instanceof Player) {
|
||||
val = val.replace("~entity~", ent1.getName());
|
||||
} else {
|
||||
val = val.replace("~entity~", ent1.getType().name());
|
||||
}
|
||||
|
||||
val = val.replace("~vehicle~", ent2.getType().name());
|
||||
val = val.replace("@", "@ " + ent1.getLocation());
|
||||
return val;
|
||||
}
|
||||
|
||||
public String getValue(Location loc, ItemStack is) {
|
||||
String val = value;
|
||||
|
||||
|
||||
val = val.replace("@", "@ " + loc.toString());
|
||||
val = val.replace("~item~", is.getType().name());
|
||||
val = val.replace("~amount~", "" + is.getAmount());
|
||||
return ChatColor.translateAlternateColorCodes('&', val);
|
||||
}
|
||||
|
||||
public String getValue(Object obj, ItemStack is, Enchantment en) {
|
||||
|
||||
|
||||
String val = value;
|
||||
|
||||
val = val.replace("~item~", is.getType().name());
|
||||
if (en == null) {
|
||||
val = val.replace("~enchant~", "");
|
||||
} else {
|
||||
val = val.replace("~enchant~", en.getName());
|
||||
val = val.replace("~lvl~", is.getEnchantmentLevel(en) + "");
|
||||
}
|
||||
if (obj instanceof BlockState) {
|
||||
val = val.replace("~player~", "a " + ((BlockState) obj).getBlock().getType().name() + "'s inventory");
|
||||
} else if (obj instanceof Player) {
|
||||
val = val.replace("~player~", ((Player) obj).getName());
|
||||
} else if (obj instanceof Inventory) {
|
||||
val = val.replace("~player~", ((Inventory) obj).getType().name() + " - ");
|
||||
} else if (obj instanceof Location) {
|
||||
val = val.replace("~player~", "a shulker box");
|
||||
} else if (obj instanceof Container) {
|
||||
val = val.replace("~player~", ((Container) obj).getType().name());
|
||||
}
|
||||
|
||||
Location loc = null;
|
||||
|
||||
if (obj instanceof BlockState) {
|
||||
loc = ((BlockState) obj).getLocation();
|
||||
}
|
||||
if (obj instanceof Player) {
|
||||
loc = ((Player) obj).getLocation();
|
||||
} else if (obj instanceof Block) {
|
||||
loc = ((Block) obj).getLocation();
|
||||
} else if (obj instanceof Inventory) {
|
||||
loc = ((Inventory) obj).getLocation();
|
||||
} else if (obj instanceof Location) {
|
||||
loc = ((Location) obj);
|
||||
} else if (obj instanceof Container) {
|
||||
loc = ((Container) obj).getLocation();
|
||||
}
|
||||
|
||||
if (loc != null) {
|
||||
val = val.replace("@", "@ " + loc);
|
||||
} else {
|
||||
val = val.replace("@", "@ UNKNOWN ");
|
||||
}
|
||||
return val;
|
||||
|
||||
}
|
||||
|
||||
public String getValue(Player p, ItemStack is, Enchantment en) {
|
||||
String val = value;
|
||||
|
||||
val = val.replace("~item~", is.getType().name());
|
||||
val = val.replace("~enchant~", en.getName());
|
||||
val = val.replace("~lvl~", is.getEnchantmentLevel(en) + "");
|
||||
val = val.replace("~player~", p.getName());
|
||||
val = val.replace("@", "@ " + p.getLocation());
|
||||
return val;
|
||||
|
||||
}
|
||||
|
||||
public String getValue(Player p, EntityType et) {
|
||||
String val = value;
|
||||
|
||||
val = val.replace("@", "@ " + p.getLocation());
|
||||
val = val.replace("~type~", et.name());
|
||||
val = val.replace("~name~", p.getName());
|
||||
return ChatColor.translateAlternateColorCodes('&', val);
|
||||
}
|
||||
|
||||
|
||||
public String getValue(Object obj, ItemStack is) {
|
||||
if (obj instanceof Inventory) {
|
||||
if (((Inventory) obj).getHolder() instanceof Player) {
|
||||
Inventory inv = (Inventory) obj;
|
||||
return getValue((Player) inv.getHolder(), is);
|
||||
} else {
|
||||
return getValue(((Inventory) obj).getLocation(), is);
|
||||
}
|
||||
} else if (obj instanceof Container) {
|
||||
return getValue(((Container) obj), is);
|
||||
}
|
||||
LOGGER.error(
|
||||
"An unknown object {} was passed to IllegalStack during a logging operation please report this to dNiym at the spigot forums or on the IllegalStack Discord.",
|
||||
obj.toString()
|
||||
);
|
||||
return "???";
|
||||
}
|
||||
|
||||
public String getValue(Container c, ItemStack is) {
|
||||
String val = value;
|
||||
|
||||
val = val.replace("@", "@ " + c.getLocation());
|
||||
val = val.replace("~item~", is.getType().name());
|
||||
val = val.replace("~name~", c.getType().name());
|
||||
val = val.replace("~amount~", "" + is.getAmount());
|
||||
return ChatColor.translateAlternateColorCodes('&', val);
|
||||
}
|
||||
|
||||
public String getValue(Player p, ItemStack is) {
|
||||
String val = value;
|
||||
|
||||
val = val.replace("@", "@ " + p.getLocation());
|
||||
val = val.replace("~item~", is.getType().name());
|
||||
val = val.replace("~name~", p.getName());
|
||||
val = val.replace("~amount~", "" + is.getAmount());
|
||||
|
||||
return ChatColor.translateAlternateColorCodes('&', val);
|
||||
}
|
||||
|
||||
public String getValue(ItemStack is, Object obj, StringBuilder list) {
|
||||
String val = value;
|
||||
|
||||
if (obj instanceof Player) {
|
||||
val = val.replace("@", "@ " + ((Player) obj).getLocation());
|
||||
val = val.replace("~name~", ((Player) obj).getName());
|
||||
} else if (obj instanceof Inventory) {
|
||||
Inventory inv = null;
|
||||
inv = (Inventory) obj;
|
||||
if (inv.getHolder() instanceof Container) {
|
||||
val = val.replace(
|
||||
"~name~",
|
||||
((Container) inv.getHolder())
|
||||
.getLocation()
|
||||
.getBlock()
|
||||
.getType()
|
||||
.name() + " @" + ((Container) inv.getHolder()).getLocation()
|
||||
);
|
||||
} else if (inv.getHolder() instanceof DoubleChest) {
|
||||
val = val.replace(
|
||||
"~name~",
|
||||
((DoubleChest) inv.getHolder()).getLocation().getBlock().getType().name() + " @" + inv
|
||||
.getLocation()
|
||||
.toString()
|
||||
);
|
||||
} else if (inv.getHolder() instanceof Player) {
|
||||
val = val.replace("~name~", ((Player) inv.getHolder()).getName() + " @" + inv.getLocation().toString());
|
||||
} else {
|
||||
LOGGER.error(
|
||||
"IllegalStack was supposed to send a message detailing an inventory but could not determine its type! Please contact dNiym at the IllegalStack discord or on Spigot with this message: {} ",
|
||||
obj.toString()
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
val = val.replace("~item~", is.getType().name());
|
||||
val = val.replace("~amount~", "" + is.getAmount());
|
||||
val = val.replace("~attributes~", list);
|
||||
|
||||
return ChatColor.translateAlternateColorCodes('&', val);
|
||||
}
|
||||
|
||||
public String getValue(Player p, ItemStack is, String list) {
|
||||
String val = value;
|
||||
|
||||
val = val.replace("@", "@ " + p.getLocation());
|
||||
val = val.replace("~item~", is.getType().name());
|
||||
val = val.replace("~name~", p.getName());
|
||||
val = val.replace("~amount~", "" + is.getAmount());
|
||||
val = val.replace("~attributes~", list);
|
||||
return ChatColor.translateAlternateColorCodes('&', val);
|
||||
}
|
||||
|
||||
public String getConfigVal() {
|
||||
return ChatColor.translateAlternateColorCodes('&', value);
|
||||
}
|
||||
|
||||
public String getValue() {
|
||||
return value;
|
||||
}
|
||||
|
||||
public void setValue(String value) {
|
||||
this.value = value;
|
||||
}
|
||||
|
||||
public String getValue(Protections p, String name, String status) {
|
||||
String val = value;
|
||||
|
||||
val = val.replace("~protection~", p.name());
|
||||
val = val.replace("~name~", name);
|
||||
val = val.replace("~status~", "" + status);
|
||||
return ChatColor.translateAlternateColorCodes('&', val);
|
||||
}
|
||||
|
||||
public String getValue(Player p, int size) {
|
||||
String val = value;
|
||||
|
||||
val = val.replace("@", "@ " + p.getLocation());
|
||||
val = val.replace("~size~", "" + size);
|
||||
val = val.replace("~name~", p.getName());
|
||||
|
||||
|
||||
return ChatColor.translateAlternateColorCodes('&', val);
|
||||
}
|
||||
|
||||
public String getValue(Location loc, int size) {
|
||||
String val = value;
|
||||
|
||||
val = val.replace("@", "@ " + loc.toString());
|
||||
val = val.replace("~size~", "" + size);
|
||||
return ChatColor.translateAlternateColorCodes('&', val);
|
||||
}
|
||||
|
||||
public String getValue(Player p, ItemStack is, int lostItems) {
|
||||
String val = value;
|
||||
|
||||
val = val.replace("@", "@ " + p.getLocation());
|
||||
val = val.replace("~item~", is.getType().name());
|
||||
val = val.replace("~name~", p.getName());
|
||||
val = val.replace("~amount~", "" + is.getAmount());
|
||||
val = val.replace("~lost~", "" + lostItems);
|
||||
return ChatColor.translateAlternateColorCodes('&', val);
|
||||
}
|
||||
|
||||
}
|
||||
File diff suppressed because it is too large.
Load diff
@@ -1,5 +1,6 @@
|
||||
package me.dniym.events;
|
||||
|
||||
import me.dniym.enums.Protections;
|
||||
import org.bukkit.block.Block;
|
||||
import org.bukkit.entity.Entity;
|
||||
import org.bukkit.event.Cancellable;
|
||||
@@ -8,107 +9,105 @@ import org.bukkit.event.HandlerList;
|
||||
import org.bukkit.inventory.Inventory;
|
||||
import org.bukkit.inventory.ItemStack;
|
||||
|
||||
import me.dniym.enums.Protections;
|
||||
|
||||
public class IllegalStackActionEvent extends Event implements Cancellable {
|
||||
private boolean cancelled = false;
|
||||
private static final HandlerList handlers = new HandlerList();
|
||||
private Protections protection = null;
|
||||
private Entity cause;
|
||||
private Block block;
|
||||
private ItemStack item;
|
||||
|
||||
private static final HandlerList handlers = new HandlerList();
|
||||
private boolean cancelled = false;
|
||||
private Protections protection;
|
||||
private Entity cause;
|
||||
private Block block;
|
||||
private ItemStack item;
|
||||
private Entity mount;
|
||||
private Inventory affectedInventory;
|
||||
|
||||
public IllegalStackActionEvent(Protections prot, Entity src, Block blk, ItemStack itm, Entity mnt, Inventory inventory) {
|
||||
this.protection = prot;
|
||||
this.setCause(src);
|
||||
this.block = blk;
|
||||
this.item = itm;
|
||||
this.setMount(mnt);
|
||||
this.affectedInventory = inventory;
|
||||
|
||||
}
|
||||
private Inventory affectedInventory;
|
||||
|
||||
|
||||
public IllegalStackActionEvent(
|
||||
Protections protections,
|
||||
Entity entity,
|
||||
Block block,
|
||||
ItemStack itemStack,
|
||||
Entity entity1,
|
||||
Inventory inventory
|
||||
) {
|
||||
this.protection = protections;
|
||||
this.setCause(entity);
|
||||
this.block = block;
|
||||
this.item = itemStack;
|
||||
this.setMount(entity1);
|
||||
this.affectedInventory = inventory;
|
||||
|
||||
@Override
|
||||
public boolean isCancelled() {
|
||||
return cancelled;
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setCancelled(boolean cancel) {
|
||||
cancelled = cancel;
|
||||
}
|
||||
public static HandlerList getHandlerList() {
|
||||
return handlers;
|
||||
}
|
||||
|
||||
@Override
|
||||
public HandlerList getHandlers() {
|
||||
return handlers;
|
||||
}
|
||||
|
||||
public static HandlerList getHandlerList() {
|
||||
return handlers;
|
||||
}
|
||||
@Override
|
||||
public boolean isCancelled() {
|
||||
return cancelled;
|
||||
}
|
||||
|
||||
public Protections getProtection() {
|
||||
return protection;
|
||||
}
|
||||
@Override
|
||||
public void setCancelled(boolean cancel) {
|
||||
cancelled = cancel;
|
||||
}
|
||||
|
||||
public void setProtection(Protections protection) {
|
||||
this.protection = protection;
|
||||
}
|
||||
@Override
|
||||
public HandlerList getHandlers() {
|
||||
return handlers;
|
||||
}
|
||||
|
||||
public Block getBlock() {
|
||||
return block;
|
||||
}
|
||||
public Protections getProtection() {
|
||||
return protection;
|
||||
}
|
||||
|
||||
public void setBlock(Block block) {
|
||||
this.block = block;
|
||||
}
|
||||
public void setProtection(Protections protection) {
|
||||
this.protection = protection;
|
||||
}
|
||||
|
||||
public ItemStack getItem() {
|
||||
return item;
|
||||
}
|
||||
public Block getBlock() {
|
||||
return block;
|
||||
}
|
||||
|
||||
public void setItem(ItemStack item) {
|
||||
this.item = item;
|
||||
}
|
||||
public void setBlock(Block block) {
|
||||
this.block = block;
|
||||
}
|
||||
|
||||
public ItemStack getItem() {
|
||||
return item;
|
||||
}
|
||||
|
||||
public void setItem(ItemStack item) {
|
||||
this.item = item;
|
||||
}
|
||||
|
||||
|
||||
|
||||
public Entity getMount() {
|
||||
return mount;
|
||||
}
|
||||
public Entity getMount() {
|
||||
return mount;
|
||||
}
|
||||
|
||||
|
||||
|
||||
public void setMount(Entity mount) {
|
||||
this.mount = mount;
|
||||
}
|
||||
public void setMount(Entity mount) {
|
||||
this.mount = mount;
|
||||
}
|
||||
|
||||
|
||||
|
||||
public Entity getCause() {
|
||||
return cause;
|
||||
}
|
||||
public Entity getCause() {
|
||||
return cause;
|
||||
}
|
||||
|
||||
|
||||
|
||||
public void setCause(Entity cause) {
|
||||
this.cause = cause;
|
||||
}
|
||||
public void setCause(Entity cause) {
|
||||
this.cause = cause;
|
||||
}
|
||||
|
||||
|
||||
|
||||
public Inventory getAffectedInventory() {
|
||||
return affectedInventory;
|
||||
}
|
||||
public Inventory getAffectedInventory() {
|
||||
return affectedInventory;
|
||||
}
|
||||
|
||||
|
||||
|
||||
public void setAffectedInventory(Inventory affectedInventory) {
|
||||
this.affectedInventory = affectedInventory;
|
||||
}
|
||||
public void setAffectedInventory(Inventory affectedInventory) {
|
||||
this.affectedInventory = affectedInventory;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -1,56 +1,56 @@
|
||||
package me.dniym.events;
|
||||
|
||||
import me.dniym.enums.Protections;
|
||||
import org.bukkit.event.Cancellable;
|
||||
import org.bukkit.event.Event;
|
||||
import org.bukkit.event.HandlerList;
|
||||
|
||||
import me.dniym.enums.Protections;
|
||||
|
||||
public class IllegalStackLogEvent extends Event implements Cancellable {
|
||||
|
||||
private boolean cancelled = false;
|
||||
private static final HandlerList handlers = new HandlerList();
|
||||
private String message = "";
|
||||
private Protections protection = null;
|
||||
|
||||
public IllegalStackLogEvent(String message, Protections prot) {
|
||||
this.setMessage(message);
|
||||
this.setProtection(prot);
|
||||
|
||||
}
|
||||
private static final HandlerList handlers = new HandlerList();
|
||||
private boolean cancelled = false;
|
||||
private String message = "";
|
||||
private Protections protection = null;
|
||||
|
||||
@Override
|
||||
public boolean isCancelled() {
|
||||
return cancelled;
|
||||
}
|
||||
public IllegalStackLogEvent(String message, Protections prot) {
|
||||
this.setMessage(message);
|
||||
this.setProtection(prot);
|
||||
|
||||
@Override
|
||||
public void setCancelled(boolean cancel) {
|
||||
cancelled = cancel;
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public HandlerList getHandlers() {
|
||||
return handlers;
|
||||
}
|
||||
|
||||
public static HandlerList getHandlerList() {
|
||||
return handlers;
|
||||
}
|
||||
public static HandlerList getHandlerList() {
|
||||
return handlers;
|
||||
}
|
||||
|
||||
public String getMessage() {
|
||||
return message;
|
||||
}
|
||||
@Override
|
||||
public boolean isCancelled() {
|
||||
return cancelled;
|
||||
}
|
||||
|
||||
public void setMessage(String message) {
|
||||
this.message = message;
|
||||
}
|
||||
@Override
|
||||
public void setCancelled(boolean cancel) {
|
||||
cancelled = cancel;
|
||||
}
|
||||
|
||||
public Protections getProtection() {
|
||||
return protection;
|
||||
}
|
||||
@Override
|
||||
public HandlerList getHandlers() {
|
||||
return handlers;
|
||||
}
|
||||
|
||||
public void setProtection(Protections protection) {
|
||||
this.protection = protection;
|
||||
}
|
||||
public String getMessage() {
|
||||
return message;
|
||||
}
|
||||
|
||||
}
|
||||
public void setMessage(String message) {
|
||||
this.message = message;
|
||||
}
|
||||
|
||||
public Protections getProtection() {
|
||||
return protection;
|
||||
}
|
||||
|
||||
public void setProtection(Protections protection) {
|
||||
this.protection = protection;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -10,6 +10,7 @@ import java.util.List;
|
||||
import java.util.UUID;
|
||||
|
||||
public class FishAttempt {
|
||||
|
||||
static HashMap<UUID, FishAttempt> attempts = new HashMap<>();
|
||||
|
||||
Long lastFish = 0L;
|
||||
@@ -18,45 +19,51 @@ public class FishAttempt {
|
||||
double range = 0.3;
|
||||
private int count = 0;
|
||||
private int sameSpotCount = 0;
|
||||
private List<Location> BLACKLIST = new ArrayList<>();
|
||||
private final List<Location> BLACKLIST = new ArrayList<>();
|
||||
|
||||
public FishAttempt(Player p) {
|
||||
attempts.put(p.getUniqueId(), this);
|
||||
}
|
||||
|
||||
public static FishAttempt findPlayer(Player p) {
|
||||
if (attempts.containsKey(p.getUniqueId()))
|
||||
if (attempts.containsKey(p.getUniqueId())) {
|
||||
return attempts.get(p.getUniqueId());
|
||||
}
|
||||
return new FishAttempt(p);
|
||||
}
|
||||
|
||||
public static FishHook findHook(Player player) {
|
||||
for (FishHook fh : player.getWorld().getEntitiesByClass(FishHook.class))
|
||||
if (fh.getShooter() instanceof Player)
|
||||
if (fh.getShooter() == player)
|
||||
for (FishHook fh : player.getWorld().getEntitiesByClass(FishHook.class)) {
|
||||
if (fh.getShooter() instanceof Player) {
|
||||
if (fh.getShooter() == player) {
|
||||
return fh;
|
||||
}
|
||||
}
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
public void fishCaught(Location hookLoc) {
|
||||
if (lastLocation == null || lastLocation.getWorld() != hookLoc.getWorld())
|
||||
if (lastLocation == null || lastLocation.getWorld() != hookLoc.getWorld()) {
|
||||
lastLocation = hookLoc;
|
||||
}
|
||||
Location testLoc = hookLoc.clone();
|
||||
testLoc.setY(lastLocation.getY());
|
||||
|
||||
if (lastLocation.getWorld() == testLoc.getWorld() && lastLocation.distance(testLoc) <= range)
|
||||
if (lastLocation.getWorld() == testLoc.getWorld() && lastLocation.distance(testLoc) <= range) {
|
||||
setSameSpotCount(getSameSpotCount() + 1);
|
||||
else {
|
||||
} else {
|
||||
setSameSpotCount(1);
|
||||
lastLocation = hookLoc;
|
||||
}
|
||||
}
|
||||
|
||||
public void addAttempt() {
|
||||
if (System.currentTimeMillis() >= lastFish)
|
||||
if (System.currentTimeMillis() >= lastFish) {
|
||||
count = 1;
|
||||
else
|
||||
} else {
|
||||
count++;
|
||||
}
|
||||
lastFish = System.currentTimeMillis() + spamThreshold;
|
||||
}
|
||||
|
||||
@@ -82,8 +89,9 @@ public class FishAttempt {
|
||||
}
|
||||
|
||||
public void blackList(Location location) {
|
||||
if (getBLACKLIST().size() > 3)
|
||||
if (getBLACKLIST().size() > 3) {
|
||||
getBLACKLIST().remove(0);
|
||||
}
|
||||
getBLACKLIST().add(location);
|
||||
}
|
||||
|
||||
@@ -95,12 +103,15 @@ public class FishAttempt {
|
||||
for (Location l : BLACKLIST) {
|
||||
Location testLoc = l.clone();
|
||||
testLoc.setY(location.getY());
|
||||
if (location.getWorld() != testLoc.getWorld())
|
||||
if (location.getWorld() != testLoc.getWorld()) {
|
||||
continue;
|
||||
}
|
||||
|
||||
if (testLoc.distance(location) <= range)
|
||||
if (testLoc.distance(location) <= range) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -1,6 +1,8 @@
|
||||
package me.dniym.listeners;
|
||||
|
||||
import me.dniym.logging.Logg;
|
||||
import me.dniym.IllegalStack;
|
||||
import me.dniym.enums.Msg;
|
||||
import me.dniym.enums.Protections;
|
||||
import org.apache.logging.log4j.LogManager;
|
||||
import org.apache.logging.log4j.Logger;
|
||||
import org.bukkit.Material;
|
||||
@@ -12,49 +14,48 @@ import org.bukkit.event.block.Action;
|
||||
import org.bukkit.event.player.PlayerInteractEvent;
|
||||
import org.bukkit.inventory.ItemStack;
|
||||
|
||||
import me.dniym.IllegalStack;
|
||||
import me.dniym.enums.Msg;
|
||||
import me.dniym.enums.Protections;
|
||||
|
||||
public class Listener113 implements Listener {
|
||||
|
||||
IllegalStack plugin;
|
||||
private static final Logger LOGGER = LogManager.getLogger("IllegalStack/" + Listener113.class.getSimpleName());
|
||||
IllegalStack plugin;
|
||||
|
||||
public Listener113(IllegalStack illegalStack) {
|
||||
plugin = illegalStack;
|
||||
plugin.getServer().getPluginManager().registerEvents(this, plugin);
|
||||
LOGGER.info("Enabling 1.13+ Checks");
|
||||
public Listener113(IllegalStack illegalStack) {
|
||||
plugin = illegalStack;
|
||||
plugin.getServer().getPluginManager().registerEvents(this, plugin);
|
||||
LOGGER.info("Enabling 1.13+ Checks");
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
private static final Logger LOGGER = LogManager.getLogger("IllegalStack/" + Listener113.class.getSimpleName());
|
||||
@EventHandler
|
||||
public void spawnerChangeCheck(PlayerInteractEvent event) {
|
||||
if (Protections.PreventSpawnEggsOnSpawners.isEnabled()) {
|
||||
|
||||
@EventHandler
|
||||
public void spawnerChangeCheck(PlayerInteractEvent event) {
|
||||
if(Protections.PreventSpawnEggsOnSpawners.isEnabled()) {
|
||||
Player plr = event.getPlayer();
|
||||
ItemStack is = plr.getInventory().getItemInMainHand();
|
||||
|
||||
Player plr = event.getPlayer();
|
||||
ItemStack is = plr.getInventory().getItemInMainHand();
|
||||
|
||||
if(is == null)
|
||||
is = plr.getInventory().getItemInOffHand();
|
||||
|
||||
if(is != null && is.getType().name().toLowerCase().contains("spawn_egg")) {
|
||||
if(event.getAction() == Action.RIGHT_CLICK_BLOCK) {
|
||||
if (is == null) {
|
||||
is = plr.getInventory().getItemInOffHand();
|
||||
}
|
||||
|
||||
Block blk = event.getClickedBlock();
|
||||
if(blk.getType() == Material.SPAWNER && !event.getPlayer().isOp())
|
||||
{
|
||||
plr.sendMessage(Msg.PlayerSpawnEggBlock.getValue());
|
||||
event.setCancelled(true);
|
||||
if (is != null && is.getType().name().toLowerCase().contains("spawn_egg")) {
|
||||
if (event.getAction() == Action.RIGHT_CLICK_BLOCK) {
|
||||
|
||||
} else if (blk.getType() == Material.SPAWNER)
|
||||
fListener.getLog().append(Msg.StaffMsgChangedSpawnerType.getValue(plr,is.getType().name()),Protections.PreventSpawnEggsOnSpawners);
|
||||
Block blk = event.getClickedBlock();
|
||||
if (blk.getType() == Material.SPAWNER && !event.getPlayer().isOp()) {
|
||||
plr.sendMessage(Msg.PlayerSpawnEggBlock.getValue());
|
||||
event.setCancelled(true);
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
} else if (blk.getType() == Material.SPAWNER) {
|
||||
fListener.getLog().append(
|
||||
Msg.StaffMsgChangedSpawnerType.getValue(plr, is.getType().name()),
|
||||
Protections.PreventSpawnEggsOnSpawners
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
@@ -1,303 +1,329 @@
|
||||
package me.dniym.listeners;
|
||||
|
||||
import io.netty.util.internal.ThreadLocalRandom;
|
||||
import me.dniym.IllegalStack;
|
||||
import me.dniym.enums.Msg;
|
||||
import me.dniym.enums.Protections;
|
||||
import me.dniym.timers.fTimer;
|
||||
import org.bukkit.Location;
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.block.Block;
|
||||
import org.bukkit.block.BlockFace;
|
||||
import org.bukkit.block.data.Waterlogged;
|
||||
import org.bukkit.enchantments.Enchantment;
|
||||
|
||||
import org.bukkit.event.EventHandler;
|
||||
import org.bukkit.event.Listener;
|
||||
import org.bukkit.event.block.BlockBreakEvent;
|
||||
import org.bukkit.event.block.BlockDispenseArmorEvent;
|
||||
import org.bukkit.entity.EnderPearl;
|
||||
import org.bukkit.entity.Entity;
|
||||
import org.bukkit.entity.FallingBlock;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.entity.Projectile;
|
||||
import org.bukkit.entity.Villager;
|
||||
import org.bukkit.entity.WanderingTrader;
|
||||
import org.bukkit.entity.ZombieVillager;
|
||||
import org.bukkit.event.entity.EntitySpawnEvent;
|
||||
import org.bukkit.event.entity.EntityTransformEvent;
|
||||
import org.bukkit.event.entity.ProjectileHitEvent;
|
||||
import org.bukkit.event.entity.ProjectileLaunchEvent;
|
||||
import org.bukkit.event.entity.VillagerReplenishTradeEvent;
|
||||
import org.bukkit.event.inventory.InventoryOpenEvent;
|
||||
import org.bukkit.event.player.PlayerInteractEntityEvent;
|
||||
import org.bukkit.event.player.PlayerItemHeldEvent;
|
||||
import org.bukkit.event.player.PlayerSwapHandItemsEvent;
|
||||
import org.bukkit.inventory.ItemStack;
|
||||
import org.bukkit.inventory.Merchant;
|
||||
import org.bukkit.inventory.MerchantInventory;
|
||||
import org.bukkit.inventory.meta.EnchantmentStorageMeta;
|
||||
import org.bukkit.scheduler.BukkitRunnable;
|
||||
|
||||
import java.util.Arrays;
|
||||
import java.util.HashMap;
|
||||
import java.util.HashSet;
|
||||
import java.util.UUID;
|
||||
|
||||
|
||||
public class Listener114 implements Listener {
|
||||
|
||||
private static final BlockFace[] faces = {BlockFace.EAST, BlockFace.WEST, BlockFace.SOUTH, BlockFace.NORTH};
|
||||
HashMap<UUID, Long> lastTrade = new HashMap<>();
|
||||
HashSet<Material> consumables = new HashSet<>();
|
||||
IllegalStack plugin;
|
||||
|
||||
public Listener114(IllegalStack illegalStack) {
|
||||
plugin = illegalStack;
|
||||
|
||||
Material[] consume = new Material[]{Material.APPLE, Material.BAKED_POTATO, Material.BEETROOT, Material.BEETROOT_SOUP, Material.BREAD, Material.CARROT,
|
||||
Material.CHORUS_FRUIT, Material.COOKED_CHICKEN, Material.COOKED_COD, Material.COOKED_MUTTON, Material.COOKED_PORKCHOP, Material.COOKED_SALMON,
|
||||
Material.COOKED_RABBIT, Material.COOKIE, Material.DRIED_KELP, Material.GOLDEN_APPLE, Material.ENCHANTED_GOLDEN_APPLE, Material.GOLDEN_CARROT,
|
||||
Material.MELON_SLICE, Material.MUSHROOM_STEW, Material.POISONOUS_POTATO, Material.POTATO, Material.PUFFERFISH, Material.PUMPKIN_PIE, Material.RABBIT_STEW,
|
||||
Material.BEEF, Material.CHICKEN, Material.COD, Material.MUTTON, Material.PORKCHOP, Material.RABBIT, Material.SALMON, Material.ROTTEN_FLESH,
|
||||
Material.SPIDER_EYE, Material.COOKED_BEEF, Material.SUSPICIOUS_STEW, Material.SWEET_BERRIES, Material.TROPICAL_FISH, Material.MILK_BUCKET,
|
||||
Material.POTION};
|
||||
consumables.addAll(Arrays.asList(consume));
|
||||
|
||||
plugin.getServer().getPluginManager().registerEvents(this,plugin);
|
||||
}
|
||||
|
||||
@EventHandler
|
||||
public void onChestDispense(BlockDispenseArmorEvent e) {
|
||||
if (Protections.DisableChestsOnMobs.isEnabled()) {
|
||||
|
||||
if(e.getItem().getType() == Material.CHEST) {
|
||||
e.setCancelled(true);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@EventHandler
|
||||
public void OnVillagerTransform(EntityTransformEvent e) {
|
||||
|
||||
if (Protections.ZombieVillagerTransformChance.getIntValue() < 100) {
|
||||
for (Entity ent : e.getTransformedEntities()) {
|
||||
|
||||
if (ent instanceof ZombieVillager) {
|
||||
if (Protections.ZombieVillagerTransformChance.getIntValue() <= 0) {
|
||||
e.setCancelled(true);
|
||||
return;
|
||||
}
|
||||
|
||||
int roll = ThreadLocalRandom.current().nextInt(1, 100);
|
||||
|
||||
if (roll > Protections.ZombieVillagerTransformChance.getIntValue()) {
|
||||
e.setCancelled(true);
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@EventHandler
|
||||
public void OnVillagerInteract(PlayerInteractEntityEvent e) {
|
||||
if (Protections.DisableInWorlds.getTxtSet().contains(e.getPlayer().getWorld().getName()))
|
||||
return;
|
||||
if (Protections.PreventVillagerSwimExploit.isEnabled()) {
|
||||
if (e.getRightClicked() != null && e.getRightClicked() instanceof Villager && e.getRightClicked() instanceof Merchant) {
|
||||
boolean cancel = false;
|
||||
|
||||
Villager v = (Villager) e.getRightClicked();
|
||||
|
||||
if (v.getLocation().getBlock().getType() == Material.WATER) {
|
||||
cancel = true;
|
||||
}
|
||||
Block down = v.getLocation().getBlock();
|
||||
if (down.getBlockData() instanceof Waterlogged) {
|
||||
Waterlogged wl = (Waterlogged) down.getBlockData();
|
||||
if (wl.isWaterlogged()) {
|
||||
cancel = true;
|
||||
}
|
||||
}
|
||||
if (cancel) {
|
||||
e.setCancelled(cancel);
|
||||
e.getPlayer().sendMessage(Msg.PlayerSwimExploitMsg.getValue());
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@EventHandler
|
||||
public void onBlockBreak(BlockBreakEvent e) {
|
||||
|
||||
|
||||
if (Protections.SilkTouchBookExploit.isEnabled()) {
|
||||
Player p = e.getPlayer();
|
||||
if (p != null && p.getInventory().getItemInMainHand() != null) {
|
||||
ItemStack is = p.getInventory().getItemInMainHand();
|
||||
if (is.getType() == Material.ENCHANTED_BOOK) {
|
||||
EnchantmentStorageMeta bm = (EnchantmentStorageMeta) is.getItemMeta();
|
||||
for (Enchantment en : bm.getStoredEnchants().keySet())
|
||||
if (en.equals(Enchantment.SILK_TOUCH)) {
|
||||
if (e.getBlock().getType() == Material.CHEST || e.getBlock().getType() == Material.TRAPPED_CHEST)
|
||||
return;
|
||||
|
||||
e.setCancelled(true);
|
||||
fListener.getLog().append2(Msg.SilkTouchBookBlocked.getValue(p, e.getBlock().getType().name()));
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@EventHandler
|
||||
public void LockMerchantTrades(InventoryOpenEvent e) {
|
||||
|
||||
|
||||
if (Protections.DisableInWorlds.getTxtSet().contains(e.getPlayer().getWorld().getName()))
|
||||
return;
|
||||
if (Protections.PreventCommandsInBed.isEnabled() && e.getPlayer().isSleeping()) {
|
||||
e.setCancelled(true);
|
||||
return;
|
||||
}
|
||||
if (!Protections.VillagerTradeCheesing.isEnabled())
|
||||
return;
|
||||
if (e.getInventory() instanceof MerchantInventory) {
|
||||
|
||||
MerchantInventory mi = (MerchantInventory) e.getInventory();
|
||||
if (mi.getHolder() instanceof WanderingTrader)
|
||||
return;
|
||||
if (mi.getHolder() instanceof Villager) {
|
||||
Villager v = (Villager) mi.getHolder();
|
||||
|
||||
if (v.getVillagerExperience() == 0)
|
||||
v.setVillagerExperience(1);
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@EventHandler
|
||||
public void PreventVillagerRestock(VillagerReplenishTradeEvent e) {
|
||||
if (Protections.DisableInWorlds.getTxtSet().contains(e.getEntity().getWorld().getName()))
|
||||
return;
|
||||
if (!Protections.VillagerTradeCheesing.isEnabled())
|
||||
return;
|
||||
if (Protections.VillagerRestockTime.getIntValue() <= 0 || !fListener.getIs114())
|
||||
return;
|
||||
//if the villager is not in the list, add them with a new empty timestamp.
|
||||
if (!lastTrade.containsKey(e.getEntity().getUniqueId()))
|
||||
lastTrade.put(e.getEntity().getUniqueId(), 0l);
|
||||
if (System.currentTimeMillis() >= lastTrade.get(e.getEntity().getUniqueId())) {
|
||||
//timestamp is either empty or has expired, allow a restock.
|
||||
lastTrade.put(e.getEntity().getUniqueId(), System.currentTimeMillis() + 60000 * Protections.VillagerRestockTime.getIntValue());
|
||||
} else {
|
||||
//timestamp has not expired do not allow restocking.
|
||||
e.setCancelled(true);
|
||||
}
|
||||
}
|
||||
|
||||
@EventHandler
|
||||
public void onHandSwap(PlayerSwapHandItemsEvent e) {
|
||||
if (!Protections.PreventFoodDupe.isEnabled())
|
||||
return;
|
||||
ItemStack itm1 = e.getMainHandItem();
|
||||
ItemStack itm2 = e.getOffHandItem();
|
||||
if (itm1 == null || itm2 == null)
|
||||
return;
|
||||
if (consumables.contains(itm1.getType()) && consumables.contains(itm2.getType()) && itm1.getType() == itm2.getType()) {
|
||||
if (itm1.getAmount() == 1 && itm2.getAmount() == 1)
|
||||
return;
|
||||
e.getPlayer().getInventory().setItemInMainHand(new ItemStack(Material.AIR));
|
||||
e.getPlayer().getInventory().setItemInOffHand(new ItemStack(Material.AIR));
|
||||
e.setCancelled(true);
|
||||
new BukkitRunnable() {
|
||||
|
||||
@Override
|
||||
public void run() {
|
||||
e.getPlayer().getInventory().setItemInMainHand(itm1);
|
||||
e.getPlayer().getInventory().setItemInOffHand(itm2);
|
||||
}
|
||||
|
||||
}.runTaskLater(IllegalStack.getPlugin(), 3);
|
||||
}
|
||||
}
|
||||
|
||||
@EventHandler
|
||||
public void onPearlHit(ProjectileHitEvent e) {
|
||||
|
||||
if (Protections.PreventPearlGlassPhasing.isEnabled()) {
|
||||
if (!(e.getEntity() instanceof EnderPearl) || e.getHitBlock() == null || !(e.getEntity().getShooter() instanceof Player) || e.getHitBlockFace() != BlockFace.UP)
|
||||
return;
|
||||
for (BlockFace face : faces) {
|
||||
Block next = e.getHitBlock().getRelative(face);
|
||||
Block above = next.getRelative(BlockFace.UP);
|
||||
Player p = ((Player) e.getEntity().getShooter());
|
||||
if (!fListener.getAirBlocks().contains(above.getType())) {
|
||||
if (!fListener.getInstance().getGlassBlocks().contains(above.getType()))
|
||||
continue;
|
||||
Location l = e.getHitBlock().getRelative(e.getHitBlockFace()).getLocation().add(0.5, 0.5, 0.5);
|
||||
fListener.getInstance().getTeleGlitch().put(p.getUniqueId(), l);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@EventHandler
|
||||
public void onItemSwitch(PlayerItemHeldEvent e) {
|
||||
if (!Protections.PreventFoodDupe.isEnabled())
|
||||
return;
|
||||
ItemStack itm1 = e.getPlayer().getInventory().getItem(e.getPreviousSlot());
|
||||
ItemStack itm2 = e.getPlayer().getInventory().getItem(e.getNewSlot());
|
||||
if (itm1 == null || itm2 == null)
|
||||
return;
|
||||
|
||||
if (consumables.contains(itm1.getType()) && consumables.contains(itm2.getType()) && itm1.getType() == itm2.getType()) {
|
||||
if (itm1.getAmount() == 1 && itm2.getAmount() == 1)
|
||||
return;
|
||||
int tSlot = e.getNewSlot();
|
||||
ItemStack tFood = e.getPlayer().getInventory().getItem(tSlot);
|
||||
if (tFood == null) {
|
||||
tSlot = e.getPreviousSlot();
|
||||
tFood = e.getPlayer().getInventory().getItem(tSlot);
|
||||
}
|
||||
final int slot = tSlot;
|
||||
final ItemStack food = tFood;
|
||||
e.getPlayer().getInventory().setItem(slot, new ItemStack(Material.AIR));
|
||||
new BukkitRunnable() {
|
||||
|
||||
@Override
|
||||
public void run() {
|
||||
e.getPlayer().getInventory().setItem(slot, food);
|
||||
}
|
||||
}.runTaskLater(IllegalStack.getPlugin(), 3);
|
||||
}
|
||||
}
|
||||
|
||||
@EventHandler
|
||||
public void onProjectileLaunch(ProjectileLaunchEvent e) {
|
||||
if (Protections.PreventProjectileExploit.isEnabled())
|
||||
fTimer.trackProjectile(e.getEntity());
|
||||
}
|
||||
|
||||
@EventHandler// (ignoreCancelled = false, priority=EventPriority.LOWEST)
|
||||
public void onFallingBlockSpawn(EntitySpawnEvent e) {
|
||||
if (e.getEntity() instanceof Projectile && Protections.PreventProjectileExploit.isEnabled())
|
||||
fTimer.trackProjectile((Projectile) e.getEntity());
|
||||
|
||||
if (!(e.getEntity() instanceof FallingBlock) || !Protections.PreventVibratingBlocks.isEnabled())
|
||||
return;
|
||||
|
||||
if (Protections.DisableInWorlds.isWhitelisted(e.getEntity().getWorld().getName()))
|
||||
return;
|
||||
|
||||
fTimer.trackBlock((FallingBlock) e.getEntity());
|
||||
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
package me.dniym.listeners;
|
||||
|
||||
import io.netty.util.internal.ThreadLocalRandom;
|
||||
import me.dniym.IllegalStack;
|
||||
import me.dniym.enums.Msg;
|
||||
import me.dniym.enums.Protections;
|
||||
import me.dniym.timers.fTimer;
|
||||
import org.bukkit.Location;
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.block.Block;
|
||||
import org.bukkit.block.BlockFace;
|
||||
import org.bukkit.block.data.Waterlogged;
|
||||
import org.bukkit.enchantments.Enchantment;
|
||||
import org.bukkit.entity.EnderPearl;
|
||||
import org.bukkit.entity.Entity;
|
||||
import org.bukkit.entity.FallingBlock;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.entity.Projectile;
|
||||
import org.bukkit.entity.Villager;
|
||||
import org.bukkit.entity.WanderingTrader;
|
||||
import org.bukkit.entity.ZombieVillager;
|
||||
import org.bukkit.event.EventHandler;
|
||||
import org.bukkit.event.Listener;
|
||||
import org.bukkit.event.block.BlockBreakEvent;
|
||||
import org.bukkit.event.block.BlockDispenseArmorEvent;
|
||||
import org.bukkit.event.entity.EntitySpawnEvent;
|
||||
import org.bukkit.event.entity.EntityTransformEvent;
|
||||
import org.bukkit.event.entity.ProjectileHitEvent;
|
||||
import org.bukkit.event.entity.ProjectileLaunchEvent;
|
||||
import org.bukkit.event.entity.VillagerReplenishTradeEvent;
|
||||
import org.bukkit.event.inventory.InventoryOpenEvent;
|
||||
import org.bukkit.event.player.PlayerInteractEntityEvent;
|
||||
import org.bukkit.event.player.PlayerItemHeldEvent;
|
||||
import org.bukkit.event.player.PlayerSwapHandItemsEvent;
|
||||
import org.bukkit.inventory.ItemStack;
|
||||
import org.bukkit.inventory.Merchant;
|
||||
import org.bukkit.inventory.MerchantInventory;
|
||||
import org.bukkit.inventory.meta.EnchantmentStorageMeta;
|
||||
import org.bukkit.scheduler.BukkitRunnable;
|
||||
|
||||
import java.util.Arrays;
|
||||
import java.util.HashMap;
|
||||
import java.util.HashSet;
|
||||
import java.util.UUID;
|
||||
|
||||
public class Listener114 implements Listener {
|
||||
|
||||
private static final BlockFace[] faces = {BlockFace.EAST, BlockFace.WEST, BlockFace.SOUTH, BlockFace.NORTH};
|
||||
HashMap<UUID, Long> lastTrade = new HashMap<>();
|
||||
HashSet<Material> consumables = new HashSet<>();
|
||||
IllegalStack plugin;
|
||||
|
||||
public Listener114(IllegalStack illegalStack) {
|
||||
plugin = illegalStack;
|
||||
|
||||
Material[] consume = new Material[]{Material.APPLE, Material.BAKED_POTATO, Material.BEETROOT, Material.BEETROOT_SOUP, Material.BREAD, Material.CARROT,
|
||||
Material.CHORUS_FRUIT, Material.COOKED_CHICKEN, Material.COOKED_COD, Material.COOKED_MUTTON, Material.COOKED_PORKCHOP, Material.COOKED_SALMON,
|
||||
Material.COOKED_RABBIT, Material.COOKIE, Material.DRIED_KELP, Material.GOLDEN_APPLE, Material.ENCHANTED_GOLDEN_APPLE, Material.GOLDEN_CARROT,
|
||||
Material.MELON_SLICE, Material.MUSHROOM_STEW, Material.POISONOUS_POTATO, Material.POTATO, Material.PUFFERFISH, Material.PUMPKIN_PIE, Material.RABBIT_STEW,
|
||||
Material.BEEF, Material.CHICKEN, Material.COD, Material.MUTTON, Material.PORKCHOP, Material.RABBIT, Material.SALMON, Material.ROTTEN_FLESH,
|
||||
Material.SPIDER_EYE, Material.COOKED_BEEF, Material.SUSPICIOUS_STEW, Material.SWEET_BERRIES, Material.TROPICAL_FISH, Material.MILK_BUCKET,
|
||||
Material.POTION};
|
||||
consumables.addAll(Arrays.asList(consume));
|
||||
|
||||
plugin.getServer().getPluginManager().registerEvents(this, plugin);
|
||||
}
|
||||
|
||||
@EventHandler
|
||||
public void onChestDispense(BlockDispenseArmorEvent e) {
|
||||
if (Protections.DisableChestsOnMobs.isEnabled()) {
|
||||
|
||||
if (e.getItem().getType() == Material.CHEST) {
|
||||
e.setCancelled(true);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@EventHandler
|
||||
public void OnVillagerTransform(EntityTransformEvent e) {
|
||||
|
||||
if (Protections.ZombieVillagerTransformChance.getIntValue() < 100) {
|
||||
for (Entity ent : e.getTransformedEntities()) {
|
||||
|
||||
if (ent instanceof ZombieVillager) {
|
||||
if (Protections.ZombieVillagerTransformChance.getIntValue() <= 0) {
|
||||
e.setCancelled(true);
|
||||
return;
|
||||
}
|
||||
|
||||
int roll = ThreadLocalRandom.current().nextInt(1, 100);
|
||||
|
||||
if (roll > Protections.ZombieVillagerTransformChance.getIntValue()) {
|
||||
e.setCancelled(true);
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@EventHandler
|
||||
public void OnVillagerInteract(PlayerInteractEntityEvent e) {
|
||||
if (Protections.DisableInWorlds.getTxtSet().contains(e.getPlayer().getWorld().getName())) {
|
||||
return;
|
||||
}
|
||||
if (Protections.PreventVillagerSwimExploit.isEnabled()) {
|
||||
if (e.getRightClicked() != null && e.getRightClicked() instanceof Villager && e.getRightClicked() instanceof Merchant) {
|
||||
boolean cancel = false;
|
||||
|
||||
Villager v = (Villager) e.getRightClicked();
|
||||
|
||||
if (v.getLocation().getBlock().getType() == Material.WATER) {
|
||||
cancel = true;
|
||||
}
|
||||
Block down = v.getLocation().getBlock();
|
||||
if (down.getBlockData() instanceof Waterlogged) {
|
||||
Waterlogged wl = (Waterlogged) down.getBlockData();
|
||||
if (wl.isWaterlogged()) {
|
||||
cancel = true;
|
||||
}
|
||||
}
|
||||
if (cancel) {
|
||||
e.setCancelled(true);
|
||||
e.getPlayer().sendMessage(Msg.PlayerSwimExploitMsg.getValue());
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@EventHandler
|
||||
public void onBlockBreak(BlockBreakEvent e) {
|
||||
|
||||
|
||||
if (Protections.SilkTouchBookExploit.isEnabled()) {
|
||||
Player p = e.getPlayer();
|
||||
if (p != null && p.getInventory().getItemInMainHand() != null) {
|
||||
ItemStack is = p.getInventory().getItemInMainHand();
|
||||
if (is.getType() == Material.ENCHANTED_BOOK) {
|
||||
EnchantmentStorageMeta enchantmentStorageMeta = (EnchantmentStorageMeta) is.getItemMeta();
|
||||
for (Enchantment enchantment : enchantmentStorageMeta.getStoredEnchants().keySet()) {
|
||||
if (enchantment.equals(Enchantment.SILK_TOUCH)) {
|
||||
if (e.getBlock().getType() == Material.CHEST || e.getBlock().getType() == Material.TRAPPED_CHEST) {
|
||||
return;
|
||||
}
|
||||
|
||||
e.setCancelled(true);
|
||||
fListener.getLog().append2(Msg.SilkTouchBookBlocked.getValue(p, e.getBlock().getType().name()));
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@EventHandler
|
||||
public void LockMerchantTrades(InventoryOpenEvent e) {
|
||||
|
||||
|
||||
if (Protections.DisableInWorlds.getTxtSet().contains(e.getPlayer().getWorld().getName())) {
|
||||
return;
|
||||
}
|
||||
if (Protections.PreventCommandsInBed.isEnabled() && e.getPlayer().isSleeping()) {
|
||||
e.setCancelled(true);
|
||||
return;
|
||||
}
|
||||
if (!Protections.VillagerTradeCheesing.isEnabled()) {
|
||||
return;
|
||||
}
|
||||
if (e.getInventory() instanceof MerchantInventory) {
|
||||
|
||||
MerchantInventory mi = (MerchantInventory) e.getInventory();
|
||||
if (mi.getHolder() instanceof WanderingTrader) {
|
||||
return;
|
||||
}
|
||||
if (mi.getHolder() instanceof Villager) {
|
||||
Villager v = (Villager) mi.getHolder();
|
||||
|
||||
if (v.getVillagerExperience() == 0) {
|
||||
v.setVillagerExperience(1);
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@EventHandler
|
||||
public void PreventVillagerRestock(VillagerReplenishTradeEvent e) {
|
||||
if (Protections.DisableInWorlds.getTxtSet().contains(e.getEntity().getWorld().getName())) {
|
||||
return;
|
||||
}
|
||||
if (!Protections.VillagerTradeCheesing.isEnabled()) {
|
||||
return;
|
||||
}
|
||||
if (Protections.VillagerRestockTime.getIntValue() <= 0 || !fListener.getIs114()) {
|
||||
return;
|
||||
}
|
||||
//if the villager is not in the list, add them with a new empty timestamp.
|
||||
if (!lastTrade.containsKey(e.getEntity().getUniqueId())) {
|
||||
lastTrade.put(e.getEntity().getUniqueId(), 0L);
|
||||
}
|
||||
if (System.currentTimeMillis() >= lastTrade.get(e.getEntity().getUniqueId())) {
|
||||
//timestamp is either empty or has expired, allow a restock.
|
||||
lastTrade.put(
|
||||
e.getEntity().getUniqueId(),
|
||||
System.currentTimeMillis() + 60000L * Protections.VillagerRestockTime.getIntValue()
|
||||
);
|
||||
} else {
|
||||
//timestamp has not expired do not allow restocking.
|
||||
e.setCancelled(true);
|
||||
}
|
||||
}
|
||||
|
||||
@EventHandler
|
||||
public void onHandSwap(PlayerSwapHandItemsEvent e) {
|
||||
if (!Protections.PreventFoodDupe.isEnabled()) {
|
||||
return;
|
||||
}
|
||||
ItemStack item1 = e.getMainHandItem();
|
||||
ItemStack item2 = e.getOffHandItem();
|
||||
if (item1 == null || item2 == null) {
|
||||
return;
|
||||
}
|
||||
if (consumables.contains(item1.getType()) && consumables.contains(item2.getType()) && item1.getType() == item2.getType()) {
|
||||
if (item1.getAmount() == 1 && item2.getAmount() == 1) {
|
||||
return;
|
||||
}
|
||||
e.getPlayer().getInventory().setItemInMainHand(new ItemStack(Material.AIR));
|
||||
e.getPlayer().getInventory().setItemInOffHand(new ItemStack(Material.AIR));
|
||||
e.setCancelled(true);
|
||||
new BukkitRunnable() {
|
||||
|
||||
@Override
|
||||
public void run() {
|
||||
e.getPlayer().getInventory().setItemInMainHand(item1);
|
||||
e.getPlayer().getInventory().setItemInOffHand(item2);
|
||||
}
|
||||
|
||||
}.runTaskLater(IllegalStack.getPlugin(), 3);
|
||||
}
|
||||
}
|
||||
|
||||
@EventHandler
|
||||
public void onPearlHit(ProjectileHitEvent e) {
|
||||
|
||||
if (Protections.PreventPearlGlassPhasing.isEnabled()) {
|
||||
if (!(e.getEntity() instanceof EnderPearl) || e.getHitBlock() == null || !(e
|
||||
.getEntity()
|
||||
.getShooter() instanceof Player) || e.getHitBlockFace() != BlockFace.UP) {
|
||||
return;
|
||||
}
|
||||
for (BlockFace face : faces) {
|
||||
Block next = e.getHitBlock().getRelative(face);
|
||||
Block above = next.getRelative(BlockFace.UP);
|
||||
Player p = ((Player) e.getEntity().getShooter());
|
||||
if (!fListener.getAirBlocks().contains(above.getType())) {
|
||||
if (!fListener.getInstance().getGlassBlocks().contains(above.getType())) {
|
||||
continue;
|
||||
}
|
||||
Location l = e.getHitBlock().getRelative(e.getHitBlockFace()).getLocation().add(0.5, 0.5, 0.5);
|
||||
fListener.getInstance().getTeleGlitch().put(p.getUniqueId(), l);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@EventHandler
|
||||
public void onItemSwitch(PlayerItemHeldEvent e) {
|
||||
if (!Protections.PreventFoodDupe.isEnabled()) {
|
||||
return;
|
||||
}
|
||||
ItemStack item1 = e.getPlayer().getInventory().getItem(e.getPreviousSlot());
|
||||
ItemStack item2 = e.getPlayer().getInventory().getItem(e.getNewSlot());
|
||||
if (item1 == null || item2 == null) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (consumables.contains(item1.getType()) && consumables.contains(item2.getType()) && item1.getType() == item2.getType()) {
|
||||
if (item1.getAmount() == 1 && item2.getAmount() == 1) {
|
||||
return;
|
||||
}
|
||||
int tSlot = e.getNewSlot();
|
||||
ItemStack tFood = e.getPlayer().getInventory().getItem(tSlot);
|
||||
if (tFood == null) {
|
||||
tSlot = e.getPreviousSlot();
|
||||
tFood = e.getPlayer().getInventory().getItem(tSlot);
|
||||
}
|
||||
final int slot = tSlot;
|
||||
final ItemStack food = tFood;
|
||||
e.getPlayer().getInventory().setItem(slot, new ItemStack(Material.AIR));
|
||||
new BukkitRunnable() {
|
||||
|
||||
@Override
|
||||
public void run() {
|
||||
e.getPlayer().getInventory().setItem(slot, food);
|
||||
}
|
||||
}.runTaskLater(IllegalStack.getPlugin(), 3);
|
||||
}
|
||||
}
|
||||
|
||||
@EventHandler
|
||||
public void onProjectileLaunch(ProjectileLaunchEvent e) {
|
||||
if (Protections.PreventProjectileExploit.isEnabled()) {
|
||||
fTimer.trackProjectile(e.getEntity());
|
||||
}
|
||||
}
|
||||
|
||||
@EventHandler// (ignoreCancelled = false, priority=EventPriority.LOWEST)
|
||||
public void onFallingBlockSpawn(EntitySpawnEvent e) {
|
||||
if (e.getEntity() instanceof Projectile && Protections.PreventProjectileExploit.isEnabled()) {
|
||||
fTimer.trackProjectile((Projectile) e.getEntity());
|
||||
}
|
||||
|
||||
if (!(e.getEntity() instanceof FallingBlock) || !Protections.PreventVibratingBlocks.isEnabled()) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (Protections.DisableInWorlds.isWhitelisted(e.getEntity().getWorld().getName())) {
|
||||
return;
|
||||
}
|
||||
|
||||
fTimer.trackBlock((FallingBlock) e.getEntity());
|
||||
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
@@ -1,47 +1,45 @@
|
||||
package me.dniym.listeners;
|
||||
|
||||
import me.dniym.IllegalStack;
|
||||
import me.dniym.enums.Protections;
|
||||
import org.bukkit.entity.Piglin;
|
||||
import org.bukkit.event.EventHandler;
|
||||
import org.bukkit.event.Listener;
|
||||
import org.bukkit.event.entity.EntityDeathEvent;
|
||||
import org.bukkit.event.entity.EntityPickupItemEvent;
|
||||
import org.bukkit.event.entity.EntitySpawnEvent;
|
||||
import me.dniym.IllegalStack;
|
||||
import me.dniym.enums.Protections;
|
||||
|
||||
public class Listener116 implements Listener {
|
||||
|
||||
public Listener116(IllegalStack plugin) {
|
||||
|
||||
plugin.getServer().getPluginManager().registerEvents(this, plugin);
|
||||
|
||||
}
|
||||
public Listener116(IllegalStack plugin) {
|
||||
|
||||
@EventHandler
|
||||
public void onEntitySpawn(EntitySpawnEvent e) {
|
||||
if(Protections.PreventPiglinDupe.isEnabled() && e.getEntity() instanceof Piglin)
|
||||
{
|
||||
Piglin p = (Piglin) e.getEntity();
|
||||
p.setCanPickupItems(false);
|
||||
}
|
||||
}
|
||||
plugin.getServer().getPluginManager().registerEvents(this, plugin);
|
||||
|
||||
}
|
||||
|
||||
@EventHandler
|
||||
public void onEntitySpawn(EntitySpawnEvent e) {
|
||||
if (Protections.PreventPiglinDupe.isEnabled() && e.getEntity() instanceof Piglin) {
|
||||
Piglin p = (Piglin) e.getEntity();
|
||||
p.setCanPickupItems(false);
|
||||
}
|
||||
}
|
||||
|
||||
@EventHandler
|
||||
public void onEntityPickup(EntityPickupItemEvent e) {
|
||||
if (Protections.PreventPiglinDupe.isEnabled() && e.getEntity() instanceof Piglin) {
|
||||
e.setCancelled(true);
|
||||
Piglin pig = (Piglin) e.getEntity();
|
||||
pig.setCanPickupItems(false);
|
||||
}
|
||||
}
|
||||
|
||||
@EventHandler
|
||||
public void onEntityDeath(EntityDeathEvent e) {
|
||||
if (Protections.PreventPiglinDupe.isEnabled() && e.getEntity() instanceof Piglin) {
|
||||
e.getDrops().clear();
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
@EventHandler
|
||||
public void onEntityPickup(EntityPickupItemEvent e) {
|
||||
if(Protections.PreventPiglinDupe.isEnabled() && e.getEntity() instanceof Piglin)
|
||||
{
|
||||
e.setCancelled(true);
|
||||
Piglin pig = (Piglin)e.getEntity();
|
||||
pig.setCanPickupItems(false);
|
||||
}
|
||||
}
|
||||
|
||||
@EventHandler
|
||||
public void onEntityDeath(EntityDeathEvent e) {
|
||||
if(Protections.PreventPiglinDupe.isEnabled() && e.getEntity() instanceof Piglin) {
|
||||
e.getDrops().clear();
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
+16
-10
@@ -16,25 +16,28 @@ import org.bukkit.inventory.ItemStack;
|
||||
import org.bukkit.inventory.meta.ItemMeta;
|
||||
import org.bukkit.scheduler.BukkitRunnable;
|
||||
|
||||
public class protListener implements Listener {
|
||||
public class ProtectionListener implements Listener {
|
||||
|
||||
IllegalStack plugin;
|
||||
|
||||
public protListener(IllegalStack illegalStack) {
|
||||
public ProtectionListener(IllegalStack illegalStack) {
|
||||
this.plugin = illegalStack;
|
||||
}
|
||||
|
||||
@EventHandler
|
||||
@EventHandler
|
||||
public void onPlayerSwapHandItemsEvent(PlayerSwapHandItemsEvent e) {
|
||||
|
||||
if (!Protections.PreventItemSwapLagExploit.isEnabled())
|
||||
if (!Protections.PreventItemSwapLagExploit.isEnabled()) {
|
||||
return;
|
||||
if (!fListener.getInstance().getSwapDelay().containsKey(e.getPlayer()))
|
||||
fListener.getInstance().getSwapDelay().put(e.getPlayer(), 0l);
|
||||
if (System.currentTimeMillis() < fListener.getInstance().getSwapDelay().get(e.getPlayer()))
|
||||
}
|
||||
if (!fListener.getInstance().getSwapDelay().containsKey(e.getPlayer())) {
|
||||
fListener.getInstance().getSwapDelay().put(e.getPlayer(), 0L);
|
||||
}
|
||||
if (System.currentTimeMillis() < fListener.getInstance().getSwapDelay().get(e.getPlayer())) {
|
||||
e.setCancelled(true);
|
||||
else
|
||||
fListener.getInstance().getSwapDelay().put(e.getPlayer(), System.currentTimeMillis() + 750l);
|
||||
} else {
|
||||
fListener.getInstance().getSwapDelay().put(e.getPlayer(), System.currentTimeMillis() + 750L);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -49,6 +52,7 @@ public class protListener implements Listener {
|
||||
}
|
||||
new BukkitRunnable() {
|
||||
final Player player = p;
|
||||
|
||||
@Override
|
||||
public void run() {
|
||||
if (player.getLocation().getBlockY() > 255 && player.isGliding()) {
|
||||
@@ -63,8 +67,9 @@ public class protListener implements Listener {
|
||||
|
||||
@EventHandler
|
||||
public void onBlockForm(BlockFormEvent e) {
|
||||
if (!Protections.PreventCobbleGenerators.isEnabled())
|
||||
if (!Protections.PreventCobbleGenerators.isEnabled()) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (e.getNewState().getType() == Material.COBBLESTONE) {
|
||||
e.setCancelled(true);
|
||||
@@ -92,4 +97,5 @@ public class protListener implements Listener {
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
File diff suppressed because it is too large.
Load diff
@@ -19,10 +19,11 @@ public class mcMMOListener implements Listener {
|
||||
this.plugin = illegalStack;
|
||||
}
|
||||
|
||||
public static boolean ismcMMOActive(Player p) {
|
||||
if (mcMMOactive == null)
|
||||
public static boolean ismcMMOActive(Player player) {
|
||||
if (mcMMOactive == null) {
|
||||
return false;
|
||||
return mcMMOactive.contains(p.getUniqueId());
|
||||
}
|
||||
return mcMMOactive.contains(player.getUniqueId());
|
||||
}
|
||||
|
||||
/*
|
||||
@@ -65,4 +66,5 @@ public class mcMMOListener implements Listener {
|
||||
public void onAbilDeactivate(McMMOPlayerAbilityDeactivateEvent e) {
|
||||
mcMMOactive.remove(e.getPlayer().getUniqueId());
|
||||
}
|
||||
|
||||
}
|
||||
@@ -2,16 +2,12 @@ package me.dniym.listeners;
|
||||
|
||||
import com.comphenix.protocol.PacketType;
|
||||
import com.comphenix.protocol.ProtocolLibrary;
|
||||
import com.comphenix.protocol.ProtocolManager;
|
||||
import com.comphenix.protocol.events.PacketAdapter;
|
||||
import com.comphenix.protocol.events.PacketContainer;
|
||||
import com.comphenix.protocol.events.PacketEvent;
|
||||
import com.comphenix.protocol.reflect.FieldAccessException;
|
||||
import me.dniym.IllegalStack;
|
||||
import me.dniym.enums.Msg;
|
||||
import me.dniym.enums.Protections;
|
||||
import me.dniym.timers.fTimer;
|
||||
|
||||
import org.apache.logging.log4j.LogManager;
|
||||
import org.apache.logging.log4j.Logger;
|
||||
import org.bukkit.Material;
|
||||
@@ -35,7 +31,7 @@ public class pLisbListener {
|
||||
HashMap<UUID, Long> messageDelay = new HashMap<>();
|
||||
|
||||
|
||||
public pLisbListener(IllegalStack illegalStack, String version) {
|
||||
public pLisbListener(IllegalStack illegalStack) {
|
||||
plugin = illegalStack;
|
||||
|
||||
//ProtocolLibrary.getProtocolManager().addPacketListener(new BookCrashExploitCheck(plugin));
|
||||
@@ -44,8 +40,11 @@ public class pLisbListener {
|
||||
new PacketAdapter(plugin, PacketType.Play.Client.SET_CREATIVE_SLOT) {
|
||||
@Override
|
||||
public void onPacketReceiving(PacketEvent event) {
|
||||
if (!Protections.BlockBadItemsFromCreativeTab.isEnabled() || event.getPlayer().isOp() || event.getPlayer().hasPermission("illegalstack.admin"))
|
||||
if (!Protections.BlockBadItemsFromCreativeTab.isEnabled() || event.getPlayer().isOp() || event
|
||||
.getPlayer()
|
||||
.hasPermission("illegalstack.admin")) {
|
||||
return;
|
||||
}
|
||||
try {
|
||||
ItemStack stack = event.getPacket().getItemModifier().readSafely(0);
|
||||
if (stack != null && stack.hasItemMeta()) {
|
||||
@@ -56,111 +55,123 @@ public class pLisbListener {
|
||||
Msg.StaffMsgCreativeBlock.getValue(event.getPlayer().getName());
|
||||
}
|
||||
} catch (IndexOutOfBoundsException ex) {
|
||||
LOGGER.error("An error receiving a SET_CREATIVE_SLOT packet has occurred, you are probably using paper and have BlockBadItemsFromCreativeTab turned on. This setting is needed very rarely, and ONLY if you have regular non-op players with access to /gmc.");
|
||||
LOGGER.error(
|
||||
"An error receiving a SET_CREATIVE_SLOT packet has occurred, you are probably using paper and have BlockBadItemsFromCreativeTab turned on. This setting is needed very rarely, and ONLY if you have regular non-op players with access to /gmc.");
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
if (Protections.DisableChestsOnMobs.isEnabled()) {
|
||||
|
||||
|
||||
ProtocolLibrary.getProtocolManager().addPacketListener(
|
||||
new PacketAdapter(plugin, PacketType.Play.Client.USE_ENTITY) {
|
||||
|
||||
|
||||
@Override
|
||||
public void onPacketReceiving(PacketEvent event) {
|
||||
|
||||
if(event.getPacket().getIntegers().read(0) <= 0) {
|
||||
LOGGER.info("{} tried to interact with entity with an invalid id: {} if this happens often please investigate what the player is doing and message dNiym on spigot or the IllegalStack discord.", event.getPlayer().getName(), event.getPacket().getIntegers().read(0));
|
||||
event.setCancelled(true);
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
if (event.getPacket().getIntegers().read(0) <= 0) {
|
||||
LOGGER.info(
|
||||
"{} tried to interact with entity with an invalid id: {} if this happens often please investigate what the player is doing and message dNiym on spigot or the IllegalStack discord.",
|
||||
event.getPlayer().getName(),
|
||||
event.getPacket().getIntegers().read(0)
|
||||
);
|
||||
event.setCancelled(true);
|
||||
return;
|
||||
}
|
||||
|
||||
if (IllegalStack.hasChestedAnimals()) {
|
||||
|
||||
if(event.isAsync()) {
|
||||
//event.setCancelled(true);
|
||||
new BukkitRunnable() {
|
||||
|
||||
@Override
|
||||
public void run() {
|
||||
Entity entity=null;
|
||||
try {
|
||||
entity=event.getPacket().getEntityModifier(event.getPlayer().getWorld()).read(0);
|
||||
} catch (RuntimeException ex) {
|
||||
LOGGER.error("Async Packet - Couldn't get an entity from id: ", ex);
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
if (event.isAsync()) {
|
||||
//event.setCancelled(true);
|
||||
new BukkitRunnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
Entity entity;
|
||||
try {
|
||||
entity = event
|
||||
.getPacket()
|
||||
.getEntityModifier(event.getPlayer().getWorld())
|
||||
.read(0);
|
||||
} catch (RuntimeException ex) {
|
||||
LOGGER.error("Async Packet - Couldn't get an entity from id: ", ex);
|
||||
return;
|
||||
}
|
||||
if (entity instanceof Horse && ((Horse) entity).isTamed()) {
|
||||
ItemStack is = event.getPlayer().getInventory().getItemInHand();
|
||||
if (!fListener.is18() && (is == null || is.getType() != Material.CHEST))
|
||||
if (!fListener.is18() && (is == null || is.getType() != Material.CHEST)) {
|
||||
is = event.getPlayer().getInventory().getItemInOffHand();
|
||||
if (is == null || is.getType() != Material.CHEST)
|
||||
}
|
||||
if (is == null || is.getType() != Material.CHEST) {
|
||||
return;
|
||||
}
|
||||
exploitMessage(event.getPlayer(), entity);
|
||||
event.setCancelled(true);
|
||||
fTimer.getPunish().put(event.getPlayer(), entity);
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
if (entity instanceof ChestedHorse && ((ChestedHorse) entity).isTamed()) {
|
||||
ItemStack is = event.getPlayer().getInventory().getItemInMainHand();
|
||||
if (is == null || is.getType() != Material.CHEST)
|
||||
if (is == null || is.getType() != Material.CHEST) {
|
||||
is = event.getPlayer().getInventory().getItemInOffHand();
|
||||
if (is == null || is.getType() != Material.CHEST)
|
||||
}
|
||||
if (is == null || is.getType() != Material.CHEST) {
|
||||
return;
|
||||
}
|
||||
exploitMessage(event.getPlayer(), entity);
|
||||
event.setCancelled(true);
|
||||
|
||||
((ChestedHorse) entity).setCarryingChest(true);
|
||||
((ChestedHorse) entity).setCarryingChest(false);
|
||||
fTimer.getPunish().put(event.getPlayer(), entity);
|
||||
return;
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}.runTaskLater(this.plugin, 1);
|
||||
} else {
|
||||
|
||||
}.runTaskLater(this.plugin, 1);
|
||||
}
|
||||
else {
|
||||
|
||||
try {
|
||||
Entity entity = null;
|
||||
try {
|
||||
event.getPacket().getEntityModifier(event.getPlayer().getWorld()).read(0);
|
||||
} catch (RuntimeException ex) {
|
||||
LOGGER.info("No entity available from id. ", ex);
|
||||
return;
|
||||
}
|
||||
if (entity instanceof ChestedHorse && ((ChestedHorse) entity).isTamed()) {
|
||||
ItemStack is = event.getPlayer().getInventory().getItemInMainHand();
|
||||
if (is == null || is.getType() != Material.CHEST)
|
||||
is = event.getPlayer().getInventory().getItemInOffHand();
|
||||
if (is == null || is.getType() != Material.CHEST)
|
||||
Entity entity = null;
|
||||
try {
|
||||
event.getPacket().getEntityModifier(event.getPlayer().getWorld()).read(0);
|
||||
} catch (RuntimeException ex) {
|
||||
LOGGER.info("No entity available from id. ", ex);
|
||||
return;
|
||||
exploitMessage(event.getPlayer(), entity);
|
||||
|
||||
event.setCancelled(true);
|
||||
}
|
||||
if (entity instanceof ChestedHorse && ((ChestedHorse) entity).isTamed()) {
|
||||
ItemStack is = event.getPlayer().getInventory().getItemInMainHand();
|
||||
if (is == null || is.getType() != Material.CHEST) {
|
||||
is = event.getPlayer().getInventory().getItemInOffHand();
|
||||
}
|
||||
if (is == null || is.getType() != Material.CHEST) {
|
||||
return;
|
||||
}
|
||||
exploitMessage(event.getPlayer(), entity);
|
||||
|
||||
event.setCancelled(true);
|
||||
// event.setPacket(new PacketContainer(Packet));
|
||||
((ChestedHorse) entity).setCarryingChest(true);
|
||||
((ChestedHorse) entity).setCarryingChest(false);
|
||||
fTimer.getPunish().put(event.getPlayer(), entity);
|
||||
((ChestedHorse) entity).setCarryingChest(true);
|
||||
((ChestedHorse) entity).setCarryingChest(false);
|
||||
fTimer.getPunish().put(event.getPlayer(), entity);
|
||||
}
|
||||
} catch (IndexOutOfBoundsException ex) {
|
||||
LOGGER.error("An error receiving a USE_ENTITY packet has occurred.", ex);
|
||||
}
|
||||
} catch (IndexOutOfBoundsException ex) {
|
||||
LOGGER.error("An error receiving a USE_ENTITY packet has occurred.", ex);
|
||||
}
|
||||
}
|
||||
} else {
|
||||
try {
|
||||
|
||||
|
||||
Entity entity = event.getPacket().getEntityModifier(event.getPlayer().getWorld()).read(0);
|
||||
if (entity instanceof Horse && ((Horse) entity).isTamed()) {
|
||||
ItemStack is = event.getPlayer().getInventory().getItemInHand();
|
||||
if (!fListener.getInstance().is18() && (is == null || is.getType() != Material.CHEST))
|
||||
if (!fListener.is18() && (is == null || is.getType() != Material.CHEST)) {
|
||||
is = event.getPlayer().getInventory().getItemInOffHand();
|
||||
if (is == null || is.getType() != Material.CHEST)
|
||||
}
|
||||
if (is == null || is.getType() != Material.CHEST) {
|
||||
return;
|
||||
}
|
||||
exploitMessage(event.getPlayer(), entity);
|
||||
event.setCancelled(true);
|
||||
|
||||
@@ -177,8 +188,9 @@ public class pLisbListener {
|
||||
}
|
||||
|
||||
private void exploitMessage(Player p, Entity ent) {
|
||||
if (!messageDelay.containsKey(p.getUniqueId()))
|
||||
if (!messageDelay.containsKey(p.getUniqueId())) {
|
||||
messageDelay.put(p.getUniqueId(), 0L);
|
||||
}
|
||||
|
||||
if (System.currentTimeMillis() > messageDelay.get(p.getUniqueId())) {
|
||||
p.sendMessage(Msg.PlayerDisabledHorseChestMsg.getValue());
|
||||
@@ -186,4 +198,5 @@ public class pLisbListener {
|
||||
messageDelay.put(p.getUniqueId(), System.currentTimeMillis() + 2000L);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
+43
-30
@@ -9,7 +9,6 @@ import net.md_5.bungee.api.chat.ClickEvent.Action;
|
||||
import net.md_5.bungee.api.chat.ComponentBuilder;
|
||||
import net.md_5.bungee.api.chat.HoverEvent;
|
||||
import net.md_5.bungee.api.chat.TextComponent;
|
||||
|
||||
import org.apache.logging.log4j.LogManager;
|
||||
import org.apache.logging.log4j.Logger;
|
||||
import org.bukkit.Bukkit;
|
||||
@@ -24,35 +23,38 @@ import java.io.FileWriter;
|
||||
import java.io.IOException;
|
||||
import java.util.Calendar;
|
||||
|
||||
public class Logg {
|
||||
public class Log {
|
||||
|
||||
private static final Logger LOGGER = LogManager.getLogger("IllegalStack/" + Log.class.getSimpleName());
|
||||
IllegalStack plugin;
|
||||
File file;
|
||||
Calendar date;
|
||||
|
||||
private static final Logger LOGGER = LogManager.getLogger("IllegalStack/" + Logg.class.getSimpleName());
|
||||
|
||||
public Logg(IllegalStack plugin) {
|
||||
public Log(IllegalStack plugin) {
|
||||
this.plugin = plugin;
|
||||
if (Protections.LogOffensesInSeparateFile.isEnabled())
|
||||
if (Protections.LogOffensesInSeparateFile.isEnabled()) {
|
||||
file = new File(plugin.getDataFolder() + "/OffenseLog.txt");
|
||||
}
|
||||
date = Calendar.getInstance();
|
||||
}
|
||||
|
||||
|
||||
@Deprecated
|
||||
public void append2(String message) {
|
||||
this.append(message, null);
|
||||
|
||||
}
|
||||
public void append(String message,Protections prot) {
|
||||
this.append(message, null);
|
||||
|
||||
}
|
||||
|
||||
public void append(String message, Protections prot) {
|
||||
|
||||
if (prot != null) {
|
||||
IllegalStackLogEvent event = new IllegalStackLogEvent(message, prot);
|
||||
Bukkit.getPluginManager().callEvent(event);
|
||||
|
||||
if (event.isCancelled()) {
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
if(prot != null) {
|
||||
IllegalStackLogEvent event = new IllegalStackLogEvent(message,prot);
|
||||
Bukkit.getPluginManager().callEvent(event);
|
||||
|
||||
if (event.isCancelled())
|
||||
return;
|
||||
}
|
||||
|
||||
if (Protections.LogOffensesInSeparateFile.isEnabled()) {
|
||||
try {
|
||||
LOGGER.info(message);
|
||||
@@ -67,22 +69,26 @@ public class Logg {
|
||||
}
|
||||
|
||||
if (Protections.InGameNotifications.isEnabled()) {
|
||||
for (Player p : IllegalStack.getPlugin().getServer().getOnlinePlayers())
|
||||
for (Player p : IllegalStack.getPlugin().getServer().getOnlinePlayers()) {
|
||||
if (p.hasPermission("illegalstack.notify")) {
|
||||
message = cleanMessage(message);
|
||||
|
||||
if (IllegalStack.isSpigot() && message.contains("@")) {
|
||||
TextComponent msg = new TextComponent(message);
|
||||
msg.setHoverEvent(new HoverEvent(HoverEvent.Action.SHOW_TEXT, new ComponentBuilder(Msg.PluginTeleportText.getValue()).create()));
|
||||
msg.setHoverEvent(new HoverEvent(
|
||||
HoverEvent.Action.SHOW_TEXT,
|
||||
new ComponentBuilder(Msg.PluginTeleportText.getValue()).create()
|
||||
));
|
||||
msg.setClickEvent(new ClickEvent(Action.RUN_COMMAND, getTeleportLoc(message)));
|
||||
p.spigot().sendMessage(msg);
|
||||
} else {
|
||||
p.sendMessage(Msg.PluginPrefix.getValue() + ChatColor.RESET + message);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
private String getTeleportLoc(String message) {
|
||||
String[] words = message.split("@");
|
||||
String[] coords = words[1].split(" ");
|
||||
@@ -95,8 +101,9 @@ public class Logg {
|
||||
position = "/istack teleport " + x + " " + y + " " + z + " " + ChatColor.stripColor(coords[1]);
|
||||
} catch (NumberFormatException ex) {
|
||||
LOGGER.error("Failed to get position");
|
||||
for (int i = 0; i < coords.length; i++)
|
||||
for (int i = 0; i < coords.length; i++) {
|
||||
LOGGER.error("Coord: {} {}", i, coords[i]);
|
||||
}
|
||||
}
|
||||
return position;
|
||||
}
|
||||
@@ -122,13 +129,14 @@ public class Logg {
|
||||
if (Protections.PlayerOffenseNotifications.isEnabled()) {
|
||||
World w = IllegalStack.getPlugin().getServer().getWorld(world);
|
||||
Location offense = new Location(w, x, y, z);
|
||||
for (Player p : w.getPlayers())
|
||||
for (Player p : w.getPlayers()) {
|
||||
if (p.getLocation().distance(offense) <= 10) {
|
||||
//[IllegalStack] -Stopped Retraction Dupe Glitch & Removed Piston @ Location{world=CraftWorld{name=event},x=-266.0,y=81.0,z=-238.0,pitch=0.0,yaw=0.0}
|
||||
String mNear = message.substring(0, message.indexOf('@'));
|
||||
mNear = Msg.PluginPrefix.getValue() + " " + Msg.PlayerNearbyNotification.getValue(mNear);
|
||||
p.sendMessage(mNear);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
String coords = "@ " + ChatColor.AQUA + world + " " + x + " " + y + " " + z;
|
||||
@@ -141,7 +149,8 @@ public class Logg {
|
||||
public String dateStamp() {
|
||||
String now;
|
||||
|
||||
now = monthFromNumber(date.get(Calendar.MONTH)) + " " + date.get(Calendar.DAY_OF_MONTH) + " " + date.get(Calendar.YEAR) + " (" + date.get(Calendar.HOUR) + ":" +
|
||||
now = monthFromNumber(date.get(Calendar.MONTH)) + " " + date.get(Calendar.DAY_OF_MONTH) + " " + date.get(Calendar.YEAR) + " (" + date
|
||||
.get(Calendar.HOUR) + ":" +
|
||||
date.get(Calendar.MINUTE) + ":" + date.get(Calendar.SECOND) + ") - ";
|
||||
return now;
|
||||
}
|
||||
@@ -181,7 +190,7 @@ public class Logg {
|
||||
|
||||
if (Protections.LogOffensesInSeparateFile.isEnabled()) {
|
||||
try {
|
||||
LOGGER.info("(Notification Only) {} {}", prot.name(), message);
|
||||
LOGGER.info("(Notification Only) {} {}", prot.name(), message);
|
||||
BufferedWriter bw = new BufferedWriter(new FileWriter(file, true));
|
||||
bw.append(dateStamp()).append(message).append("\r\n");
|
||||
bw.close();
|
||||
@@ -193,21 +202,25 @@ public class Logg {
|
||||
}
|
||||
|
||||
if (Protections.LogOffensesInSeparateFile.isEnabled()) {
|
||||
for (Player p : IllegalStack.getPlugin().getServer().getOnlinePlayers())
|
||||
for (Player p : IllegalStack.getPlugin().getServer().getOnlinePlayers()) {
|
||||
if (p.hasPermission("illegalstack.notify")) {
|
||||
message = cleanMessage(message);
|
||||
|
||||
if (IllegalStack.isSpigot() && message.contains("@")) {
|
||||
|
||||
TextComponent msg = new TextComponent(ChatColor.GREEN + "(Notification Only) " + message);
|
||||
msg.setHoverEvent(new HoverEvent(HoverEvent.Action.SHOW_TEXT, new ComponentBuilder(Msg.PluginTeleportText.getValue()).create()));
|
||||
msg.setHoverEvent(new HoverEvent(
|
||||
HoverEvent.Action.SHOW_TEXT,
|
||||
new ComponentBuilder(Msg.PluginTeleportText.getValue()).create()
|
||||
));
|
||||
msg.setClickEvent(new ClickEvent(Action.RUN_COMMAND, getTeleportLoc(message)));
|
||||
p.spigot().sendMessage(msg);
|
||||
} else {
|
||||
p.sendMessage(ChatColor.RED + "[IllegalStack] - (Notification Only)" + ChatColor.RESET + message);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
@@ -5,13 +5,11 @@ import me.dniym.IllegalStack;
|
||||
import me.dniym.checks.BadAttributeCheck;
|
||||
import me.dniym.enums.Msg;
|
||||
import me.dniym.enums.Protections;
|
||||
import me.dniym.listeners.Listener113;
|
||||
import me.dniym.listeners.fListener;
|
||||
import me.dniym.listeners.mcMMOListener;
|
||||
import me.dniym.utils.NBTStuff;
|
||||
import me.dniym.utils.SlimefunCompat;
|
||||
import me.dniym.utils.SpigMethods;
|
||||
|
||||
import me.dniym.utils.SpigotMethods;
|
||||
import org.apache.logging.log4j.LogManager;
|
||||
import org.apache.logging.log4j.Logger;
|
||||
import org.bukkit.Bukkit;
|
||||
@@ -45,17 +43,16 @@ public class fTimer implements Runnable {
|
||||
|
||||
private static final HashMap<FallingBlock, Long> fbTracker = new HashMap<>();
|
||||
private static final HashMap<Projectile, Long> projTracker = new HashMap<>();
|
||||
private static final Logger LOGGER = LogManager.getLogger("IllegalStack/" + fTimer.class.getSimpleName());
|
||||
private static long endScanFinish = 0L;
|
||||
private static World dragon = null;
|
||||
private static HashMap<Player, Entity> punish = new HashMap<>();
|
||||
private final long scanDelay = 1;
|
||||
private final IllegalStack plugin;
|
||||
private final boolean is1_8;
|
||||
private long nextScan;
|
||||
private long longScan;
|
||||
private long endScan = 0L;
|
||||
private final boolean is1_8;
|
||||
|
||||
private static final Logger LOGGER = LogManager.getLogger("IllegalStack/" + fTimer.class.getSimpleName());
|
||||
|
||||
public fTimer(IllegalStack illegalStack) {
|
||||
this.plugin = illegalStack;
|
||||
@@ -66,8 +63,9 @@ public class fTimer implements Runnable {
|
||||
.split(",")[3];
|
||||
is1_8 = version.equalsIgnoreCase("v1_8_R3") || version.contains("v1_8");
|
||||
|
||||
if (is1_8)
|
||||
if (is1_8) {
|
||||
LOGGER.info("Minecraft 1.8 detected not checking offhand slot for overstacked items.");
|
||||
}
|
||||
if (is1_8 || version.equalsIgnoreCase("v1_9_R4") || version.equalsIgnoreCase("v1_10_R2")) {
|
||||
LOGGER.info("Version < 1.11 found, not checking for shulker boxes");
|
||||
}
|
||||
@@ -101,11 +99,12 @@ public class fTimer implements Runnable {
|
||||
@Override
|
||||
public void run() {
|
||||
|
||||
for (Player p : punish.keySet())
|
||||
for (Player p : punish.keySet()) {
|
||||
fListener.punishPlayer(p, punish.get(p));
|
||||
}
|
||||
punish.clear();
|
||||
|
||||
|
||||
|
||||
if (Protections.BlockNonPlayersInEndPortal.isEnabled() && getDragon() != null && System.currentTimeMillis() > endScan) {
|
||||
endScan = System.currentTimeMillis() + 500L;
|
||||
if (getDragon().getEnvironment() == Environment.THE_END) {
|
||||
@@ -115,8 +114,9 @@ public class fTimer implements Runnable {
|
||||
if (l.getBlock().getType() == Material.BEDROCK) //found bottom of portal
|
||||
{
|
||||
for (Entity ent : l.getWorld().getNearbyEntities(l, 3, 2, 3)) {
|
||||
if (ent instanceof Player)
|
||||
if (ent instanceof Player) {
|
||||
continue;
|
||||
}
|
||||
|
||||
Vector v = ent.getVelocity();
|
||||
v.setY(4);
|
||||
@@ -130,21 +130,24 @@ public class fTimer implements Runnable {
|
||||
}
|
||||
}
|
||||
|
||||
if (System.currentTimeMillis() >= getEndScanFinish())
|
||||
if (System.currentTimeMillis() >= getEndScanFinish()) {
|
||||
setDragon(null);
|
||||
}
|
||||
|
||||
if (Protections.PreventPortalTraps.isEnabled() && System.currentTimeMillis() >= this.longScan) {
|
||||
this.longScan = System.currentTimeMillis() + 10000L;
|
||||
for (Player p : Bukkit.getOnlinePlayers()) {
|
||||
Block exit = p.getLocation().getBlock();
|
||||
|
||||
if (exit.getType() != fListener.getPortal())
|
||||
if (exit.getType() != fListener.getPortal()) {
|
||||
continue;
|
||||
}
|
||||
String invalid = "";
|
||||
for (BlockFace face : fListener.getFaces()) {
|
||||
exit = exit.getRelative(face);
|
||||
if (exit.getType() == fListener.getPortal())
|
||||
if (exit.getType() == fListener.getPortal()) {
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
boolean valid = false;
|
||||
@@ -175,16 +178,18 @@ public class fTimer implements Runnable {
|
||||
if (Protections.PreventProjectileExploit.isEnabled()) {
|
||||
HashSet<Projectile> removed = new HashSet<>();
|
||||
for (Projectile p : projTracker.keySet()) {
|
||||
if (p == null || projTracker.get(p) >= System.currentTimeMillis())
|
||||
if (p == null || projTracker.get(p) >= System.currentTimeMillis()) {
|
||||
removed.add(p);
|
||||
}
|
||||
|
||||
if (p != null && p.getLocation().getBlock().getType() == Material.BUBBLE_COLUMN) {
|
||||
removed.add(p);
|
||||
p.remove();
|
||||
}
|
||||
}
|
||||
for (Projectile p : removed)
|
||||
for (Projectile p : removed) {
|
||||
projTracker.remove(p);
|
||||
}
|
||||
}
|
||||
|
||||
if (Protections.PreventVibratingBlocks.isEnabled()) {
|
||||
@@ -194,37 +199,48 @@ public class fTimer implements Runnable {
|
||||
removed.add(fb);
|
||||
}
|
||||
|
||||
for (Entity ent : fb.getNearbyEntities(1, 1, 1))
|
||||
for (Entity ent : fb.getNearbyEntities(1, 1, 1)) {
|
||||
if (ent instanceof Minecart || ent instanceof Boat) {
|
||||
removed.add(fb);
|
||||
fb.remove();
|
||||
ent.remove();
|
||||
}
|
||||
}
|
||||
}
|
||||
for (FallingBlock fb : removed)
|
||||
for (FallingBlock fb : removed) {
|
||||
fbTracker.remove(fb);
|
||||
}
|
||||
}
|
||||
|
||||
for (Player p : plugin.getServer().getOnlinePlayers()) {
|
||||
if (SpigMethods.isNPC(p)) continue;
|
||||
if (SpigotMethods.isNPC(p)) {
|
||||
continue;
|
||||
}
|
||||
|
||||
if (Protections.PreventHeadInsideBlock.isEnabled() && p.getGameMode() == GameMode.SURVIVAL) {
|
||||
Material type = p.getEyeLocation().getBlock().getType();
|
||||
if(Protections.AlsoPreventHeadInside.isWhitelisted(type)) {
|
||||
fListener.getLog().append(Msg.HeadInsideSolidBlock2.getValue(p,p.getEyeLocation().getBlock().getType().name()), Protections.PreventHeadInsideBlock);
|
||||
p.getEyeLocation().getBlock().breakNaturally();
|
||||
|
||||
}
|
||||
Material type = p.getEyeLocation().getBlock().getType();
|
||||
if (Protections.AlsoPreventHeadInside.isWhitelisted(type)) {
|
||||
fListener.getLog().append(Msg.HeadInsideSolidBlock2.getValue(
|
||||
p,
|
||||
p.getEyeLocation().getBlock().getType().name()
|
||||
), Protections.PreventHeadInsideBlock);
|
||||
p.getEyeLocation().getBlock().breakNaturally();
|
||||
|
||||
}
|
||||
}
|
||||
for (ItemStack is : p.getInventory().getContents()) {
|
||||
if (Protections.FixNegativeDurability.isEnabled())
|
||||
NBTStuff.checkForNegativeDurability(is, p);
|
||||
if (Protections.FixNegativeDurability.isEnabled()) {
|
||||
NBTStuff.checkForNegativeDurability(is, p);
|
||||
}
|
||||
|
||||
if (is != null && !p.isOp()) {
|
||||
if (Protections.RemoveItemTypes.isWhitelisted(is)) {
|
||||
if (Protections.RemoveItemTypes.notifyOnly())
|
||||
fListener.getLog().notify(Protections.RemoveItemTypes, " Triggered by: " + p.getName() + " with item: " + is.getType().name());
|
||||
else {
|
||||
if (Protections.RemoveItemTypes.notifyOnly()) {
|
||||
fListener.getLog().notify(
|
||||
Protections.RemoveItemTypes,
|
||||
" Triggered by: " + p.getName() + " with item: " + is.getType().name()
|
||||
);
|
||||
} else {
|
||||
fListener.getLog().append2(Msg.ItemTypeRemovedPlayer.getValue(p, is));
|
||||
p.getInventory().remove(is);
|
||||
}
|
||||
@@ -240,7 +256,8 @@ public class fTimer implements Runnable {
|
||||
}
|
||||
}
|
||||
|
||||
if (Protections.RemoveItemsMatchingName.isEnabled() && (!Protections.BlockEnchantingInstead.isEnabled() && !Protections.BlockRepairsInstead.isEnabled())) {
|
||||
if (Protections.RemoveItemsMatchingName.isEnabled() && (!Protections.BlockEnchantingInstead.isEnabled() && !Protections.BlockRepairsInstead
|
||||
.isEnabled())) {
|
||||
if (is != null && is.hasItemMeta()) {
|
||||
ItemMeta im = is.getItemMeta();
|
||||
for (String ignored : Protections.ItemNamesToRemove.getTxtSet()) {
|
||||
@@ -264,17 +281,20 @@ public class fTimer implements Runnable {
|
||||
for (Player p : plugin.getServer().getOnlinePlayers()) {
|
||||
if (!is1_8) {
|
||||
p.getInventory().getItemInOffHand();
|
||||
if (Protections.DisableInWorlds.getTxtSet().contains(p.getWorld().getName()))
|
||||
if (Protections.DisableInWorlds.getTxtSet().contains(p.getWorld().getName())) {
|
||||
continue;
|
||||
}
|
||||
ItemStack is = p.getInventory().getItemInOffHand();
|
||||
if (Protections.FixNegativeDurability.isEnabled())
|
||||
NBTStuff.checkForNegativeDurability(is, p);
|
||||
if (Protections.FixNegativeDurability.isEnabled()) {
|
||||
NBTStuff.checkForNegativeDurability(is, p);
|
||||
}
|
||||
if (is.getAmount() > is.getMaxStackSize()) {
|
||||
|
||||
if (!Protections.IllegalStackMode.isEnabled()) //in blacklist mode and on the blacklist
|
||||
{
|
||||
if (!Protections.AllowStack.isWhitelisted(is.getType().name(), p))
|
||||
if (!Protections.AllowStack.isWhitelisted(is.getType().name(), p)) {
|
||||
continue;
|
||||
}
|
||||
|
||||
if (Protections.FixOverstackedItemInstead.isEnabled()) {
|
||||
is.setAmount(is.getType().getMaxStackSize());
|
||||
@@ -286,66 +306,87 @@ public class fTimer implements Runnable {
|
||||
continue;
|
||||
}
|
||||
|
||||
if (Protections.AllowStack.isWhitelisted(is.getType().name(), p))
|
||||
if (Protections.AllowStack.isWhitelisted(is.getType().name(), p)) {
|
||||
continue;
|
||||
}
|
||||
|
||||
if (Protections.AllowStackForGroup.isWhitelisted(is.getType().name()) && p.hasPermission("illegalstack.overstack"))
|
||||
if (Protections.AllowStackForGroup.isWhitelisted(is.getType().name()) && p.hasPermission(
|
||||
"illegalstack.overstack")) {
|
||||
continue;
|
||||
}
|
||||
|
||||
if (Protections.RemoveOverstackedItems.notifyOnly())
|
||||
if (Protections.RemoveOverstackedItems.notifyOnly()) {
|
||||
continue;
|
||||
}
|
||||
|
||||
if (Protections.FixIllegalEnchantmentLevels.isEnabled() && !mcMMOListener.ismcMMOActive(p)) {
|
||||
if (!Protections.OnlyFunctionInWorlds.getTxtSet().isEmpty()) //world list isn't empty
|
||||
if (!Protections.OnlyFunctionInWorlds.getTxtSet().contains(p.getWorld().getName())) //isn't in a checked world
|
||||
{
|
||||
if (!Protections.OnlyFunctionInWorlds.getTxtSet().contains(p
|
||||
.getWorld()
|
||||
.getName())) //isn't in a checked world
|
||||
{
|
||||
continue;
|
||||
if (Protections.AllowBypass.isEnabled() && p.hasPermission("illegalstack.enchantbypass"))
|
||||
}
|
||||
}
|
||||
if (Protections.AllowBypass.isEnabled() && p.hasPermission("illegalstack.enchantbypass")) {
|
||||
continue;
|
||||
}
|
||||
if (is != null && is.getEnchantments().isEmpty()) {
|
||||
|
||||
HashSet<Enchantment> replace = new HashSet<>();
|
||||
for (Enchantment en : is.getEnchantments().keySet())
|
||||
for (Enchantment en : is.getEnchantments().keySet()) {
|
||||
if (is.getEnchantmentLevel(en) > en.getMaxLevel()) {
|
||||
|
||||
if (SlimefunCompat.isValid(is, en))
|
||||
if (SlimefunCompat.isValid(is, en)) {
|
||||
continue;
|
||||
if (IllegalStack.isClueScrolls() && en == Enchantment.DURABILITY && is.getType() == Material.PAPER)
|
||||
}
|
||||
if (IllegalStack.isClueScrolls() && en == Enchantment.DURABILITY && is.getType() == Material.PAPER) {
|
||||
continue;
|
||||
if (IllegalStack.isEpicRename() && ((en == Enchantment.LURE || en == Enchantment.ARROW_INFINITE) && is.getEnchantmentLevel(en) == 4341))
|
||||
}
|
||||
if (IllegalStack.isEpicRename() && ((en == Enchantment.LURE || en == Enchantment.ARROW_INFINITE) && is
|
||||
.getEnchantmentLevel(en) == 4341)) {
|
||||
continue;
|
||||
if (Protections.EnchantedItemWhitelist.isWhitelisted(is))
|
||||
}
|
||||
if (Protections.EnchantedItemWhitelist.isWhitelisted(is)) {
|
||||
break;
|
||||
if (Protections.CustomEnchantOverride.isAllowedEnchant(en, is.getEnchantmentLevel(en)))
|
||||
}
|
||||
if (Protections.CustomEnchantOverride.isAllowedEnchant(en, is.getEnchantmentLevel(en))) {
|
||||
continue;
|
||||
}
|
||||
fListener.getLog().append2(Msg.IllegalEnchantLevel.getValue(p, is, en));
|
||||
replace.add(en);
|
||||
|
||||
} else {
|
||||
if (!en.canEnchantItem(is)) {
|
||||
if (Protections.EnchantedItemWhitelist.isWhitelisted(is))
|
||||
if (Protections.EnchantedItemWhitelist.isWhitelisted(is)) {
|
||||
continue;
|
||||
if (SlimefunCompat.isValid(is, en))
|
||||
}
|
||||
if (SlimefunCompat.isValid(is, en)) {
|
||||
continue;
|
||||
}
|
||||
|
||||
replace.add(en);
|
||||
fListener.getLog().append2(Msg.IllegalEnchantType.getValue(p, is, en));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
for (Enchantment en : replace) {
|
||||
is.removeEnchantment(en);
|
||||
p.updateInventory();
|
||||
LOGGER.info("Debug 1");
|
||||
if (en.canEnchantItem(is))
|
||||
new BukkitRunnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
is.addEnchantment(en, en.getMaxLevel());
|
||||
}
|
||||
if (en.canEnchantItem(is)) {
|
||||
new BukkitRunnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
is.addEnchantment(en, en.getMaxLevel());
|
||||
}
|
||||
|
||||
}.runTaskLater(this.plugin, 1);
|
||||
}
|
||||
|
||||
}.runTaskLater(this.plugin, 1);
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
@@ -361,14 +402,16 @@ public class fTimer implements Runnable {
|
||||
}
|
||||
}
|
||||
|
||||
for (ItemStack is : p.getInventory().getArmorContents())
|
||||
for (ItemStack is : p.getInventory().getArmorContents()) {
|
||||
if (is != null && is.getAmount() > is.getMaxStackSize()) {
|
||||
if (Protections.DisableInWorlds.getTxtSet().contains(p.getWorld().getName()))
|
||||
if (Protections.DisableInWorlds.getTxtSet().contains(p.getWorld().getName())) {
|
||||
continue;
|
||||
}
|
||||
if (!Protections.IllegalStackMode.isEnabled()) //in blacklist mode and on the blacklist
|
||||
{
|
||||
if (!Protections.AllowStack.isWhitelisted(is.getType().name(), p))
|
||||
if (!Protections.AllowStack.isWhitelisted(is.getType().name(), p)) {
|
||||
continue;
|
||||
}
|
||||
if (Protections.FixOverstackedItemInstead.isEnabled()) {
|
||||
is.setAmount(is.getType().getMaxStackSize());
|
||||
fListener.getLog().append2(Msg.IllegalStackShorten.getValue(p, is));
|
||||
@@ -379,62 +422,81 @@ public class fTimer implements Runnable {
|
||||
continue;
|
||||
}
|
||||
|
||||
if (Protections.AllowStack.isWhitelisted(is.getType().name(), p))
|
||||
if (Protections.AllowStack.isWhitelisted(is.getType().name(), p)) {
|
||||
continue;
|
||||
}
|
||||
|
||||
if (Protections.RemoveOverstackedItems.notifyOnly())
|
||||
if (Protections.RemoveOverstackedItems.notifyOnly()) {
|
||||
continue;
|
||||
}
|
||||
|
||||
if (Protections.FixIllegalEnchantmentLevels.isEnabled() && !mcMMOListener.ismcMMOActive(p)) {
|
||||
if (!Protections.OnlyFunctionInWorlds.getTxtSet().isEmpty()) //world list isn't empty
|
||||
if (!Protections.OnlyFunctionInWorlds.getTxtSet().contains(p.getWorld().getName())) //isn't in a checked world
|
||||
{
|
||||
if (!Protections.OnlyFunctionInWorlds.getTxtSet().contains(p
|
||||
.getWorld()
|
||||
.getName())) //isn't in a checked world
|
||||
{
|
||||
continue;
|
||||
}
|
||||
}
|
||||
|
||||
if (Protections.AllowBypass.isEnabled() && p.hasPermission("illegalstack.enchantbypass"))
|
||||
if (Protections.AllowBypass.isEnabled() && p.hasPermission("illegalstack.enchantbypass")) {
|
||||
continue;
|
||||
}
|
||||
|
||||
if (is != null && is.getEnchantments().isEmpty()) {
|
||||
HashSet<Enchantment> replace = new HashSet<>();
|
||||
for (Enchantment en : is.getEnchantments().keySet())
|
||||
for (Enchantment en : is.getEnchantments().keySet()) {
|
||||
if (is.getEnchantmentLevel(en) > en.getMaxLevel()) {
|
||||
|
||||
if (SlimefunCompat.isValid(is, en))
|
||||
if (SlimefunCompat.isValid(is, en)) {
|
||||
continue;
|
||||
if (IllegalStack.isClueScrolls() && en == Enchantment.DURABILITY && is.getType() == Material.PAPER)
|
||||
}
|
||||
if (IllegalStack.isClueScrolls() && en == Enchantment.DURABILITY && is.getType() == Material.PAPER) {
|
||||
continue;
|
||||
if (IllegalStack.isEpicRename() && ((en == Enchantment.LURE || en == Enchantment.ARROW_INFINITE) && is.getEnchantmentLevel(en) == 4341))
|
||||
}
|
||||
if (IllegalStack.isEpicRename() && ((en == Enchantment.LURE || en == Enchantment.ARROW_INFINITE) && is
|
||||
.getEnchantmentLevel(en) == 4341)) {
|
||||
continue;
|
||||
if (Protections.EnchantedItemWhitelist.isWhitelisted(is))
|
||||
}
|
||||
if (Protections.EnchantedItemWhitelist.isWhitelisted(is)) {
|
||||
break;
|
||||
if (Protections.CustomEnchantOverride.isAllowedEnchant(en, is.getEnchantmentLevel(en)))
|
||||
}
|
||||
if (Protections.CustomEnchantOverride.isAllowedEnchant(en, is.getEnchantmentLevel(en))) {
|
||||
continue;
|
||||
}
|
||||
fListener.getLog().append2(Msg.IllegalEnchantLevel.getValue(p, is, en));
|
||||
replace.add(en);
|
||||
} else {
|
||||
if (!en.canEnchantItem(is)) {
|
||||
if (Protections.EnchantedItemWhitelist.isWhitelisted(is))
|
||||
if (Protections.EnchantedItemWhitelist.isWhitelisted(is)) {
|
||||
continue;
|
||||
if (SlimefunCompat.isValid(is, en))
|
||||
}
|
||||
if (SlimefunCompat.isValid(is, en)) {
|
||||
continue;
|
||||
}
|
||||
|
||||
replace.add(en);
|
||||
fListener.getLog().append2(Msg.IllegalEnchantType.getValue(p, is, en));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
for (Enchantment en : replace) {
|
||||
is.removeEnchantment(en);
|
||||
LOGGER.info("Debug 3");
|
||||
p.updateInventory();
|
||||
if (en.canEnchantItem(is))
|
||||
new BukkitRunnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
is.addEnchantment(en, en.getMaxLevel());
|
||||
}
|
||||
if (en.canEnchantItem(is)) {
|
||||
new BukkitRunnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
is.addEnchantment(en, en.getMaxLevel());
|
||||
}
|
||||
|
||||
}.runTaskLater(this.plugin, 1);
|
||||
}
|
||||
|
||||
}.runTaskLater(this.plugin, 1);
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -448,13 +510,15 @@ public class fTimer implements Runnable {
|
||||
p.getInventory().remove(is);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
for (ItemStack is : p.getInventory().getContents()) {
|
||||
|
||||
if (is == null || Protections.DisableInWorlds.getTxtSet().contains(p.getWorld().getName()))
|
||||
if (is == null || Protections.DisableInWorlds.getTxtSet().contains(p.getWorld().getName())) {
|
||||
continue;
|
||||
}
|
||||
if (Protections.FixNegativeDurability.isEnabled()) {
|
||||
NBTStuff.checkForNegativeDurability(is, p);
|
||||
NBTStuff.checkForNegativeDurability(is, p);
|
||||
}
|
||||
if (is.hasItemMeta()) {
|
||||
ItemMeta im = is.getItemMeta();
|
||||
@@ -462,8 +526,9 @@ public class fTimer implements Runnable {
|
||||
if (Protections.RemoveUnbreakableFlag.isEnabled() && IllegalStack.hasUnbreakable()) {
|
||||
|
||||
if (im.isUnbreakable()) {
|
||||
if (Protections.AllowBypass.isEnabled() && p.hasPermission("illegalstack.enchantbypass"))
|
||||
if (Protections.AllowBypass.isEnabled() && p.hasPermission("illegalstack.enchantbypass")) {
|
||||
continue;
|
||||
}
|
||||
fListener.getLog().append2(Msg.UnbreakableItemCleared.getValue(p, is));
|
||||
im.setUnbreakable(false);
|
||||
is.setItemMeta(im);
|
||||
@@ -471,18 +536,20 @@ public class fTimer implements Runnable {
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
if (Protections.RemoveCustomAttributes.isEnabled()) {
|
||||
|
||||
if (Protections.AllowBypass.isEnabled() && p.hasPermission("illegalstack.enchantbypass"))
|
||||
if (Protections.AllowBypass.isEnabled() && p.hasPermission("illegalstack.enchantbypass")) {
|
||||
continue;
|
||||
}
|
||||
//NBTStuff.checkForBadCustomData(is, p, false);
|
||||
BadAttributeCheck.checkForBadCustomData(is, p);
|
||||
}
|
||||
|
||||
if (Protections.PreventInvalidPotions.isEnabled() && im instanceof PotionMeta) {
|
||||
if (Protections.AllowBypass.isEnabled() && p.hasPermission("illegalstack.enchantbypass"))
|
||||
if (Protections.AllowBypass.isEnabled() && p.hasPermission("illegalstack.enchantbypass")) {
|
||||
continue;
|
||||
}
|
||||
|
||||
if (IllegalStack.isHasMCMMO()) {
|
||||
if (NBTStuff.hasNbtTag("IllegalStack", is, "mcmmoitem", Protections.PreventInvalidPotions)) {
|
||||
@@ -491,15 +558,20 @@ public class fTimer implements Runnable {
|
||||
}
|
||||
PotionMeta potion = (PotionMeta) is.getItemMeta();
|
||||
PotionData pd = potion.getBasePotionData();
|
||||
if (pd.getType() == PotionType.UNCRAFTABLE || (potion.hasCustomEffects() && !potion.getCustomEffects().isEmpty())) {
|
||||
if (pd.getType() == PotionType.UNCRAFTABLE || (potion.hasCustomEffects() && !potion
|
||||
.getCustomEffects()
|
||||
.isEmpty())) {
|
||||
|
||||
if (pd.getType() == PotionType.UNCRAFTABLE && potion.getCustomEffects().isEmpty())
|
||||
if (pd.getType() == PotionType.UNCRAFTABLE && potion.getCustomEffects().isEmpty()) {
|
||||
continue;
|
||||
}
|
||||
|
||||
p.getInventory().remove(is);
|
||||
StringBuilder efx = new StringBuilder();
|
||||
for (PotionEffect ce : potion.getCustomEffects())
|
||||
efx.append(ce.getType().getName()).append(" amplifier: ").append(ce.getAmplifier()).append(" duration: ").append(ce.getDuration()).append(",");
|
||||
for (PotionEffect ce : potion.getCustomEffects()) {
|
||||
efx.append(ce.getType().getName()).append(" amplifier: ").append(ce.getAmplifier()).append(
|
||||
" duration: ").append(ce.getDuration()).append(",");
|
||||
}
|
||||
|
||||
fListener.getLog().append2(Msg.InvalidPotionRemoved.getValue(p, efx.toString()));
|
||||
}
|
||||
@@ -509,58 +581,75 @@ public class fTimer implements Runnable {
|
||||
|
||||
if (Protections.FixIllegalEnchantmentLevels.isEnabled() && !mcMMOListener.ismcMMOActive(p)) {
|
||||
if (!Protections.OnlyFunctionInWorlds.getTxtSet().isEmpty()) //world list isn't empty
|
||||
if (!Protections.OnlyFunctionInWorlds.getTxtSet().contains(p.getWorld().getName())) //isn't in a checked world
|
||||
{
|
||||
if (!Protections.OnlyFunctionInWorlds.getTxtSet().contains(p
|
||||
.getWorld()
|
||||
.getName())) //isn't in a checked world
|
||||
{
|
||||
continue;
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
if (is != null && is.getEnchantments() != null && !is.getEnchantments().isEmpty()) {
|
||||
if (Protections.AllowBypass.isEnabled() && p.hasPermission("illegalstack.enchantbypass"))
|
||||
if (Protections.AllowBypass.isEnabled() && p.hasPermission("illegalstack.enchantbypass")) {
|
||||
continue;
|
||||
}
|
||||
|
||||
|
||||
HashSet<Enchantment> replace = new HashSet<>();
|
||||
for (Enchantment en : is.getEnchantments().keySet())
|
||||
for (Enchantment en : is.getEnchantments().keySet()) {
|
||||
if (is.getEnchantmentLevel(en) > en.getMaxLevel()) {
|
||||
|
||||
if (SlimefunCompat.isValid(is, en))
|
||||
if (SlimefunCompat.isValid(is, en)) {
|
||||
continue;
|
||||
if (IllegalStack.isClueScrolls() && en == Enchantment.DURABILITY && is.getType() == Material.PAPER)
|
||||
}
|
||||
if (IllegalStack.isClueScrolls() && en == Enchantment.DURABILITY && is.getType() == Material.PAPER) {
|
||||
continue;
|
||||
if (IllegalStack.isEpicRename() && ((en == Enchantment.LURE || en == Enchantment.ARROW_INFINITE) && is.getEnchantmentLevel(en) == 4341))
|
||||
}
|
||||
if (IllegalStack.isEpicRename() && ((en == Enchantment.LURE || en == Enchantment.ARROW_INFINITE) && is
|
||||
.getEnchantmentLevel(en) == 4341)) {
|
||||
continue;
|
||||
if (Protections.EnchantedItemWhitelist.isWhitelisted(is))
|
||||
}
|
||||
if (Protections.EnchantedItemWhitelist.isWhitelisted(is)) {
|
||||
break;
|
||||
if (Protections.CustomEnchantOverride.isAllowedEnchant(en, is.getEnchantmentLevel(en)))
|
||||
}
|
||||
if (Protections.CustomEnchantOverride.isAllowedEnchant(en, is.getEnchantmentLevel(en))) {
|
||||
continue;
|
||||
}
|
||||
fListener.getLog().append2(Msg.IllegalEnchantLevel.getValue(p, is, en));
|
||||
replace.add(en);
|
||||
|
||||
} else {
|
||||
if (!en.canEnchantItem(is)) {
|
||||
if (Protections.EnchantedItemWhitelist.isWhitelisted(is))
|
||||
if (Protections.EnchantedItemWhitelist.isWhitelisted(is)) {
|
||||
continue;
|
||||
if (SlimefunCompat.isValid(is, en))
|
||||
}
|
||||
if (SlimefunCompat.isValid(is, en)) {
|
||||
continue;
|
||||
}
|
||||
replace.add(en);
|
||||
fListener.getLog().append2(Msg.IllegalEnchantType.getValue(p, is, en));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
for (Enchantment en : replace) {
|
||||
is.removeEnchantment(en);
|
||||
}
|
||||
|
||||
|
||||
p.updateInventory();
|
||||
new BukkitRunnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
for(Enchantment en: replace) {
|
||||
if (en.canEnchantItem(is))
|
||||
is.addEnchantment(en, en.getMaxLevel());
|
||||
|
||||
}
|
||||
}
|
||||
@Override
|
||||
public void run() {
|
||||
for (Enchantment en : replace) {
|
||||
if (en.canEnchantItem(is)) {
|
||||
is.addEnchantment(en, en.getMaxLevel());
|
||||
}
|
||||
|
||||
}.runTaskLater(this.plugin, 4);
|
||||
}
|
||||
}
|
||||
|
||||
}.runTaskLater(this.plugin, 4);
|
||||
|
||||
}
|
||||
}
|
||||
@@ -568,8 +657,9 @@ public class fTimer implements Runnable {
|
||||
if (is != null && is.getAmount() > is.getMaxStackSize()) {
|
||||
if (!Protections.IllegalStackMode.isEnabled()) //in blacklist mode and on the blacklist
|
||||
{
|
||||
if (!Protections.AllowStack.isWhitelisted(is.getType().name(), p))
|
||||
if (!Protections.AllowStack.isWhitelisted(is.getType().name(), p)) {
|
||||
continue;
|
||||
}
|
||||
|
||||
if (Protections.FixOverstackedItemInstead.isEnabled()) {
|
||||
is.setAmount(is.getType().getMaxStackSize());
|
||||
@@ -582,14 +672,18 @@ public class fTimer implements Runnable {
|
||||
}
|
||||
|
||||
}
|
||||
if (Protections.AllowStack.isWhitelisted(is.getType().name(), p))
|
||||
if (Protections.AllowStack.isWhitelisted(is.getType().name(), p)) {
|
||||
continue;
|
||||
}
|
||||
|
||||
if (Protections.AllowStackForGroup.isWhitelisted(is.getType().name()) && p.hasPermission("illegalstack.overstack"))
|
||||
if (Protections.AllowStackForGroup.isWhitelisted(is.getType().name()) && p.hasPermission(
|
||||
"illegalstack.overstack")) {
|
||||
continue;
|
||||
}
|
||||
|
||||
if (Protections.RemoveOverstackedItems.notifyOnly())
|
||||
if (Protections.RemoveOverstackedItems.notifyOnly()) {
|
||||
continue;
|
||||
}
|
||||
|
||||
if (Protections.FixOverstackedItemInstead.isEnabled()) {
|
||||
fListener.getLog().append2(Msg.IllegalStackShorten.getValue(p, is));
|
||||
@@ -603,12 +697,13 @@ public class fTimer implements Runnable {
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public World getDragon() {
|
||||
|
||||
public World getDragon() {
|
||||
return dragon;
|
||||
}
|
||||
|
||||
public static void setDragon(World world) {
|
||||
fTimer.dragon = world;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -2,7 +2,6 @@ package me.dniym.timers;
|
||||
|
||||
import me.dniym.enums.Msg;
|
||||
import me.dniym.enums.Protections;
|
||||
import me.dniym.listeners.Listener113;
|
||||
import me.dniym.listeners.fListener;
|
||||
import net.md_5.bungee.api.ChatColor;
|
||||
import org.apache.logging.log4j.LogManager;
|
||||
@@ -19,18 +18,18 @@ import java.util.HashSet;
|
||||
|
||||
public class sTimer implements Runnable {
|
||||
|
||||
private static long signCheck = 0L;
|
||||
private static long chunkScan = 0L;
|
||||
private static boolean scanChunks = false;
|
||||
private static final HashMap<Block, Player> signBlock = new HashMap<>();
|
||||
private static final HashSet<BlockState[]> entList = new HashSet<>();
|
||||
private static final HashSet<String> checkedChunks = new HashSet<>();
|
||||
|
||||
private static final Logger LOGGER = LogManager.getLogger("IllegalStack/" + sTimer.class.getSimpleName());
|
||||
private static long signCheck = 0L;
|
||||
private static long chunkScan = 0L;
|
||||
private static boolean scanChunks = false;
|
||||
|
||||
public sTimer() {
|
||||
if (Protections.DestroyBadSignsonChunkLoad.isEnabled())
|
||||
if (Protections.DestroyBadSignsonChunkLoad.isEnabled()) {
|
||||
scanChunks = true;
|
||||
}
|
||||
}
|
||||
|
||||
public static long getSignCheck() {
|
||||
@@ -44,8 +43,9 @@ public class sTimer implements Runnable {
|
||||
public static void checkSign(Block block, Player player) {
|
||||
|
||||
signBlock.put(block, player);
|
||||
if (signCheck == -1L)
|
||||
if (signCheck == -1L) {
|
||||
signCheck = System.currentTimeMillis() + 4000L;
|
||||
}
|
||||
}
|
||||
|
||||
public static void checkChunk(String chunkID, BlockState[] tileEntities) {
|
||||
@@ -59,24 +59,35 @@ public class sTimer implements Runnable {
|
||||
@Override
|
||||
public void run() {
|
||||
|
||||
if (!Protections.DestroyBadSignsonChunkLoad.isEnabled() || Protections.DestroyBadSignsonChunkLoad.notifyOnly())
|
||||
if (!Protections.DestroyBadSignsonChunkLoad.isEnabled() || Protections.DestroyBadSignsonChunkLoad.notifyOnly()) {
|
||||
return;
|
||||
}
|
||||
if (getSignCheck() != -1L && System.currentTimeMillis() >= getSignCheck()) {
|
||||
for (Block b : signBlock.keySet()) {
|
||||
BlockState st = b.getState();
|
||||
if (st instanceof Sign) {
|
||||
Sign sign = (Sign) st;
|
||||
boolean illegal = false;
|
||||
for (String line : sign.getLines())
|
||||
if (!Charset.forName(Protections.ValidCharset.getTxtValue()).newEncoder().canEncode(ChatColor.stripColor(line))) {
|
||||
for (String line : sign.getLines()) {
|
||||
if (!Charset.forName(Protections.ValidCharset.getTxtValue()).newEncoder().canEncode(ChatColor.stripColor(
|
||||
line))) {
|
||||
illegal = true;
|
||||
LOGGER.info("[IllegalStack Debug]: - Found a sign with illegal chars: line with invalid text was: {} @ {}", line, sign.getLocation().toString());
|
||||
LOGGER.info(
|
||||
"[IllegalStack Debug]: - Found a sign with illegal chars: line with invalid text was: {} @ {}",
|
||||
line,
|
||||
sign.getLocation().toString()
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
Player p = signBlock.get(sign.getBlock());
|
||||
if (illegal) {
|
||||
if (p != null)
|
||||
fListener.getLog().append2(Msg.SignRemovedOnPlace.getValue(sign.getLocation(), signBlock.get(b).getName()));
|
||||
if (p != null) {
|
||||
fListener.getLog().append2(Msg.SignRemovedOnPlace.getValue(
|
||||
sign.getLocation(),
|
||||
signBlock.get(b).getName()
|
||||
));
|
||||
}
|
||||
sign.getBlock().setType(Material.AIR);
|
||||
p.kickPlayer(Msg.SignKickPlayerMsg.getValue());
|
||||
}
|
||||
@@ -88,21 +99,30 @@ public class sTimer implements Runnable {
|
||||
|
||||
if (System.currentTimeMillis() >= chunkScan && scanChunks) {
|
||||
HashSet<Block> found = new HashSet<>();
|
||||
for (BlockState[] bs : entList)
|
||||
for (BlockState st : bs)
|
||||
for (BlockState[] bs : entList) {
|
||||
for (BlockState st : bs) {
|
||||
if (st instanceof Sign) {
|
||||
Sign sign = (Sign) st;
|
||||
for (String line : sign.getLines())
|
||||
if (!Charset.forName(Protections.ValidCharset.getTxtValue()).newEncoder().canEncode(ChatColor.stripColor(line))) {
|
||||
for (String line : sign.getLines()) {
|
||||
if (!Charset
|
||||
.forName(Protections.ValidCharset.getTxtValue())
|
||||
.newEncoder()
|
||||
.canEncode(ChatColor.stripColor(line))) {
|
||||
sign.getBlock().setType(Material.AIR);
|
||||
found.add(sign.getBlock());
|
||||
}
|
||||
}
|
||||
}
|
||||
if (!found.isEmpty())
|
||||
for (Block b : found)
|
||||
}
|
||||
}
|
||||
if (!found.isEmpty()) {
|
||||
for (Block b : found) {
|
||||
fListener.getLog().append2(Msg.SignRemoved.getValue(b.getLocation(), ""));
|
||||
}
|
||||
}
|
||||
chunkScan = System.currentTimeMillis() + 5000L;
|
||||
entList.clear();
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
@@ -1,18 +0,0 @@
|
||||
package me.dniym.utils;
|
||||
|
||||
public enum AttribLimit {
|
||||
|
||||
InstantHealth("HEAL", 6, 124),
|
||||
Leaping("Jump", 8, 3);
|
||||
|
||||
private String name;
|
||||
private int oldId;
|
||||
private int maxValue;
|
||||
private int defaultValue;
|
||||
|
||||
AttribLimit(String name, int oldId, int maxValue) { }
|
||||
|
||||
public static AttribLimit get(String name) {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
@@ -26,10 +26,11 @@ public class BookCrashExploitCheck extends PacketAdapter {
|
||||
final int slot = integers.read(1) - 3;
|
||||
final int maxSlots = inventoryView.countSlots();
|
||||
PacketAttack pa = PacketAttack.findPlayer(player.getUniqueId());
|
||||
if (slot > maxSlots || slot < 0)
|
||||
if (slot > maxSlots || slot < 0) {
|
||||
event.setCancelled(pa.addAttempt(event, "WINDOW_INVALID_CLICK"));
|
||||
else
|
||||
} else {
|
||||
event.setCancelled(pa.addAttempt(event, "WINDOW_CLICK_SPAM"));
|
||||
}
|
||||
}
|
||||
} //else
|
||||
//event.setCancelled(true);
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
/*
|
||||
package me.dniym.utils;
|
||||
|
||||
public class DropExploit {
|
||||
/*
|
||||
private static final HashSet<DropExploit> trackedBlocks = new HashSet<>();
|
||||
private final Block block;
|
||||
private final HashMap<ItemStack, Long> items = new HashMap<>();
|
||||
@@ -67,5 +67,6 @@ public class DropExploit {
|
||||
item.setItemMeta(meta);
|
||||
|
||||
}
|
||||
*/
|
||||
|
||||
}
|
||||
*/
|
||||
@@ -6,8 +6,6 @@
|
||||
* The great thing about this is you can easily identify YOUR gui and handle events for YOUR gui rather than trying to identify it in a regular listener
|
||||
* class by name.
|
||||
*/
|
||||
|
||||
|
||||
package me.dniym.utils;
|
||||
|
||||
import org.bukkit.Bukkit;
|
||||
@@ -25,6 +23,7 @@ import org.bukkit.inventory.meta.ItemMeta;
|
||||
import java.util.Arrays;
|
||||
|
||||
public class GuiObject implements InventoryHolder, Listener {
|
||||
|
||||
private final Inventory inv;
|
||||
|
||||
public GuiObject() {
|
||||
@@ -42,8 +41,18 @@ public class GuiObject implements InventoryHolder, Listener {
|
||||
|
||||
// You can call this whenever you want to put the items in or use your existing gui code
|
||||
public void initializeItems() {
|
||||
inv.addItem(createGuiItem(Material.DIAMOND_SWORD, "Example Sword", "�aFirst line of the lore", "�bSecond line of the lore"));
|
||||
inv.addItem(createGuiItem(Material.IRON_HELMET, "�bExample Helmet", "�aFirst line of the lore", "�bSecond line of the lore"));
|
||||
inv.addItem(createGuiItem(
|
||||
Material.DIAMOND_SWORD,
|
||||
"Example Sword",
|
||||
"�aFirst line of the lore",
|
||||
"�bSecond line of the lore"
|
||||
));
|
||||
inv.addItem(createGuiItem(
|
||||
Material.IRON_HELMET,
|
||||
"�bExample Helmet",
|
||||
"�aFirst line of the lore",
|
||||
"�bSecond line of the lore"
|
||||
));
|
||||
}
|
||||
|
||||
// Nice little method to create a gui item with a custom name, and description
|
||||
@@ -71,13 +80,18 @@ public class GuiObject implements InventoryHolder, Listener {
|
||||
|
||||
@EventHandler
|
||||
public void onInventoryClick(final InventoryClickEvent e) {
|
||||
if (e.getInventory().getHolder() != this) return;
|
||||
if (e.getInventory().getHolder() != this) {
|
||||
return;
|
||||
}
|
||||
e.setCancelled(true);
|
||||
final ItemStack clickedItem = e.getCurrentItem();
|
||||
// verify current item is not null
|
||||
if (clickedItem == null || clickedItem.getType() == Material.AIR) return;
|
||||
if (clickedItem == null || clickedItem.getType() == Material.AIR) {
|
||||
return;
|
||||
}
|
||||
final Player p = (Player) e.getWhoClicked();
|
||||
// Using slots click is a best option for your inventory click's
|
||||
p.sendMessage("You clicked at slot " + e.getRawSlot());
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
@@ -11,8 +11,9 @@ public class MagicHook {
|
||||
|
||||
public static boolean isMagicItem(ItemStack is) {
|
||||
|
||||
if (magicApi == null)
|
||||
if (magicApi == null) {
|
||||
getApi();
|
||||
}
|
||||
|
||||
return magicApi.isBrush(is) || magicApi.isSpell(is) || magicApi.isUpgrade(is) || magicApi.isWand(is);
|
||||
}
|
||||
@@ -26,4 +27,5 @@ public class MagicHook {
|
||||
magicApi = ((MagicAPI) magicPlugin);
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
@@ -1,14 +1,14 @@
|
||||
package me.dniym.utils;
|
||||
|
||||
|
||||
import de.tr7zw.nbtapi.NBTCompound;
|
||||
import de.tr7zw.nbtapi.NBTCompoundList;
|
||||
import de.tr7zw.nbtapi.NBTEntity;
|
||||
import de.tr7zw.nbtapi.NBTItem;
|
||||
import de.tr7zw.nbtapi.NBTListCompound;
|
||||
import me.dniym.enums.Msg;
|
||||
import me.dniym.enums.Protections;
|
||||
import me.dniym.listeners.fListener;
|
||||
|
||||
|
||||
import java.util.ArrayList;
|
||||
|
||||
import me.dniym.timers.sTimer;
|
||||
import org.apache.logging.log4j.LogManager;
|
||||
import org.apache.logging.log4j.Logger;
|
||||
import org.bukkit.Material;
|
||||
@@ -18,13 +18,6 @@ import org.bukkit.entity.Player;
|
||||
import org.bukkit.inventory.ItemStack;
|
||||
import org.bukkit.persistence.PersistentDataContainer;
|
||||
|
||||
import de.tr7zw.nbtapi.NBTCompound;
|
||||
import de.tr7zw.nbtapi.NBTCompoundList;
|
||||
import de.tr7zw.nbtapi.NBTEntity;
|
||||
import de.tr7zw.nbtapi.NBTItem;
|
||||
import de.tr7zw.nbtapi.NBTListCompound;
|
||||
import java.util.List;
|
||||
|
||||
public class NBTApiStuff {
|
||||
|
||||
private static final Logger LOGGER = LogManager.getLogger("IllegalStack/" + NBTApiStuff.class.getSimpleName());
|
||||
@@ -65,12 +58,10 @@ public class NBTApiStuff {
|
||||
public static void getEntityTags(Entity ent) {
|
||||
|
||||
NBTEntity nbtent = new NBTEntity(ent);
|
||||
|
||||
|
||||
NamespacedKey key = new NamespacedKey(NamespacedKey.MINECRAFT, "gossips");
|
||||
PersistentDataContainer data = ent.getPersistentDataContainer();
|
||||
|
||||
|
||||
NBTCompound tag = nbtent.getCompound("Offers");
|
||||
LOGGER.info("offers-> {} - {}", tag.asNBTString(), tag.getType("Recipes"));
|
||||
for (NBTListCompound s : nbtent.getCompound("Offers").getCompoundList("Recipes")) {
|
||||
@@ -114,105 +105,110 @@ public class NBTApiStuff {
|
||||
if (is.getType().name().contains("SHULKER_BOX")) {
|
||||
NBTItem nbti = new NBTItem(is);
|
||||
NBTCompound tag = nbti.getCompound("BlockEntityTag");
|
||||
if (tag == null)
|
||||
if (tag == null) {
|
||||
return 0;
|
||||
}
|
||||
NBTCompoundList itemTag = tag.getCompoundList("Items");
|
||||
if (itemTag == null)
|
||||
if (itemTag == null) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
if (itemTag.size() > 27)
|
||||
if (itemTag.size() > 27) {
|
||||
return itemTag.size();
|
||||
}
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
public static void hasBadCustomDataOnArmorLegacy(Player p) {
|
||||
ItemStack is = p.getInventory().getHelmet();
|
||||
String slot = "";
|
||||
if(hasBadCustomDataLegacy(p.getInventory().getBoots())) {
|
||||
slot = "boots";
|
||||
p.getInventory().setBoots(new ItemStack(Material.AIR));
|
||||
} else if(hasBadCustomDataLegacy(p.getInventory().getChestplate())) {
|
||||
slot = "chestplate";
|
||||
p.getInventory().setChestplate(new ItemStack(Material.AIR));
|
||||
} else if(hasBadCustomDataLegacy(p.getInventory().getHelmet())) {
|
||||
p.getInventory().setHelmet(new ItemStack(Material.AIR));
|
||||
slot = "helmet";
|
||||
} else if(hasBadCustomDataLegacy(p.getInventory().getLeggings())) {
|
||||
p.getInventory().setLeggings(new ItemStack(Material.AIR));
|
||||
slot = "leggings";
|
||||
}
|
||||
|
||||
|
||||
if(!slot.isEmpty())
|
||||
{
|
||||
fListener.getLog().append2(Msg.CustomAttribsRemoved2.getValue(p,is, slot));
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
ItemStack is = p.getInventory().getHelmet();
|
||||
String slot = "";
|
||||
if (hasBadCustomDataLegacy(p.getInventory().getBoots())) {
|
||||
slot = "boots";
|
||||
p.getInventory().setBoots(new ItemStack(Material.AIR));
|
||||
} else if (hasBadCustomDataLegacy(p.getInventory().getChestplate())) {
|
||||
slot = "chestplate";
|
||||
p.getInventory().setChestplate(new ItemStack(Material.AIR));
|
||||
} else if (hasBadCustomDataLegacy(p.getInventory().getHelmet())) {
|
||||
p.getInventory().setHelmet(new ItemStack(Material.AIR));
|
||||
slot = "helmet";
|
||||
} else if (hasBadCustomDataLegacy(p.getInventory().getLeggings())) {
|
||||
p.getInventory().setLeggings(new ItemStack(Material.AIR));
|
||||
slot = "leggings";
|
||||
}
|
||||
|
||||
|
||||
if (!slot.isEmpty()) {
|
||||
fListener.getLog().append2(Msg.CustomAttribsRemoved2.getValue(p, is, slot));
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
public static boolean hasBadCustomDataLegacy(ItemStack is) {
|
||||
if(is == null)
|
||||
return false;
|
||||
|
||||
if (is == null) {
|
||||
return false;
|
||||
}
|
||||
|
||||
NBTItem nbti = new NBTItem(is);
|
||||
NBTCompoundList itemTag = nbti.getCompoundList("AttributeModifiers");
|
||||
|
||||
|
||||
return (itemTag != null && itemTag.size() > 0);
|
||||
|
||||
|
||||
}
|
||||
|
||||
public static boolean checkForBadCustomDataLegacy(ItemStack is, Object obj) {
|
||||
boolean helmet = false;
|
||||
NBTItem nbti = new NBTItem(is);
|
||||
NBTCompoundList itemTag = nbti.getCompoundList("AttributeModifiers");
|
||||
if (itemTag == null) {
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
if (itemTag.size() > 0) {
|
||||
itemTag.clear();
|
||||
nbti.setObject("AttributeModifiers", itemTag);
|
||||
|
||||
|
||||
|
||||
|
||||
StringBuilder attribs = new StringBuilder();
|
||||
attribs.append("Custom Attribute Data");
|
||||
fListener.getLog().append(Msg.CustomAttribsRemoved3.getValue(is,obj,attribs),Protections.RemoveCustomAttributes);
|
||||
|
||||
if(obj instanceof Player)
|
||||
((Player)obj).getInventory().remove(is);
|
||||
else
|
||||
LOGGER.info("The object type: {} is not accounted for in the legacy NBT Api check.. Please report this to dNiym at the IllegalStack discord or via spigot!", obj.toString() );
|
||||
|
||||
fListener.getLog().append(Msg.CustomAttribsRemoved3.getValue(is, obj, attribs), Protections.RemoveCustomAttributes);
|
||||
|
||||
if (obj instanceof Player) {
|
||||
((Player) obj).getInventory().remove(is);
|
||||
} else {
|
||||
LOGGER.info(
|
||||
"The object type: {} is not accounted for in the legacy NBT Api check.. Please report this to dNiym at the IllegalStack discord or via spigot!",
|
||||
obj.toString()
|
||||
);
|
||||
}
|
||||
|
||||
return true;
|
||||
|
||||
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
public static void checkForBadCustomDataLegacy(ItemStack is, Player p, boolean sendToPlayer) {
|
||||
boolean helmet = false;
|
||||
boolean helmet = false;
|
||||
NBTItem nbti = new NBTItem(is);
|
||||
NBTCompoundList itemTag = nbti.getCompoundList("AttributeModifiers");
|
||||
if (itemTag == null) {
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
if (itemTag.size() > 0) {
|
||||
itemTag.clear();
|
||||
nbti.setObject("AttributeModifiers", itemTag);
|
||||
|
||||
if (sendToPlayer)
|
||||
|
||||
if (sendToPlayer) {
|
||||
p.sendMessage(Msg.CustomAttribsRemoved.getValue(p, is, "Custom Attribute Data"));
|
||||
else
|
||||
} else {
|
||||
fListener.getLog().append2(Msg.CustomAttribsRemoved.getValue(p, is, "Custom Attribute Data"));
|
||||
|
||||
}
|
||||
|
||||
p.getInventory().remove(is);
|
||||
|
||||
// p.getInventory().addItem(nbti.getItem());
|
||||
|
||||
// p.getInventory().addItem(nbti.getItem());
|
||||
}
|
||||
}
|
||||
|
||||
@@ -223,4 +219,4 @@ public class NBTApiStuff {
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
@@ -1,18 +1,15 @@
|
||||
package me.dniym.utils;
|
||||
|
||||
import com.massivecraft.factions.shade.me.lucko.helper.nbt.NBT;
|
||||
import me.dniym.IllegalStack;
|
||||
import me.dniym.enums.Msg;
|
||||
import me.dniym.enums.Protections;
|
||||
import me.dniym.listeners.fListener;
|
||||
import me.dniym.timers.fTimer;
|
||||
import org.apache.logging.log4j.LogManager;
|
||||
import org.apache.logging.log4j.Logger;
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.NamespacedKey;
|
||||
import org.bukkit.attribute.Attribute;
|
||||
import org.bukkit.attribute.AttributeModifier;
|
||||
|
||||
import org.bukkit.entity.Entity;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.inventory.ItemFlag;
|
||||
@@ -40,10 +37,11 @@ public class NBTStuff {
|
||||
|
||||
item.setItemMeta(im);
|
||||
|
||||
} else if (IllegalStack.isNbtAPI())
|
||||
} else if (IllegalStack.isNbtAPI()) {
|
||||
item = NBTApiStuff.addNBTTagLegacy(item, value);
|
||||
else
|
||||
} else {
|
||||
Msg.StaffNoNBTAPI.getValue(prot.name());
|
||||
}
|
||||
return item;
|
||||
}
|
||||
|
||||
@@ -55,16 +53,18 @@ public class NBTStuff {
|
||||
|
||||
PersistentDataContainer data = im.getPersistentDataContainer();
|
||||
NamespacedKey key = new NamespacedKey(IllegalStack.getPlugin(), "timestamp");
|
||||
if (data.has(key, PersistentDataType.LONG))
|
||||
if (data.has(key, PersistentDataType.LONG)) {
|
||||
return null;
|
||||
}
|
||||
|
||||
data.set(key, PersistentDataType.LONG, (System.currentTimeMillis() + 4500L));
|
||||
item.setItemMeta(im);
|
||||
|
||||
} else if (IllegalStack.isNbtAPI())
|
||||
} else if (IllegalStack.isNbtAPI()) {
|
||||
item = NBTApiStuff.updateTimeStampLegacy(item);
|
||||
|
||||
else Msg.StaffNoNBTAPI.getValue(prot.name());
|
||||
} else {
|
||||
Msg.StaffNoNBTAPI.getValue(prot.name());
|
||||
}
|
||||
return item;
|
||||
}
|
||||
|
||||
@@ -90,32 +90,38 @@ public class NBTStuff {
|
||||
}
|
||||
} else if (IllegalStack.isNbtAPI()) {
|
||||
item = NBTApiStuff.checkTimestampLegacy(item);
|
||||
} else Msg.StaffNoNBTAPI.getValue(prot.name());
|
||||
} else {
|
||||
Msg.StaffNoNBTAPI.getValue(prot.name());
|
||||
}
|
||||
|
||||
return item;
|
||||
}
|
||||
|
||||
public static boolean hasSpigotNBT() {
|
||||
return fListener.getInstance().is115() || fListener.getInstance().is114();
|
||||
return fListener.getInstance().is115() || fListener.getInstance().is114();
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
public static boolean isProCosmetics(ItemStack is, Protections prot) {
|
||||
if (IllegalStack.getProCosmetics() != null) {
|
||||
if (IllegalStack.isNbtAPI())
|
||||
if (IllegalStack.isNbtAPI()) {
|
||||
NBTApiStuff.isProCosmeticsLegacy(is);
|
||||
else Msg.StaffNoNBTAPI.getValue(prot.name());
|
||||
} else {
|
||||
Msg.StaffNoNBTAPI.getValue(prot.name());
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
public static Boolean hasNbtTag(String pluginName, ItemStack item, String tag, Protections prot) {
|
||||
if (item == null)
|
||||
if (item == null) {
|
||||
return false;
|
||||
}
|
||||
|
||||
Plugin plugin = Bukkit.getServer().getPluginManager().getPlugin(pluginName);
|
||||
if (plugin == null)
|
||||
if (plugin == null) {
|
||||
return false;
|
||||
}
|
||||
|
||||
if (hasSpigotNBT()) {
|
||||
if (item.hasItemMeta()) {
|
||||
@@ -127,7 +133,9 @@ public class NBTStuff {
|
||||
}
|
||||
} else if (IllegalStack.isNbtAPI()) {
|
||||
return NBTApiStuff.hasNbtTagLegacy(item, tag);
|
||||
} else Msg.StaffNoNBTAPI.getValue(prot.name());
|
||||
} else {
|
||||
Msg.StaffNoNBTAPI.getValue(prot.name());
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
@@ -135,57 +143,60 @@ public class NBTStuff {
|
||||
|
||||
if (!IllegalStack.isNbtAPI() && Protections.DestroyInvalidShulkers.isEnabled()) {
|
||||
Protections.DestroyInvalidShulkers.setEnabled(false);
|
||||
LOGGER.warn("Protection DestroyInvalidShulkers was enabled, however NBTAPI 2.0+ was not loaded on this server, this protection will only work if NBTAPI is present and running. This protection has automatically been disabled. ");
|
||||
LOGGER.warn(
|
||||
"Protection DestroyInvalidShulkers was enabled, however NBTAPI 2.0+ was not loaded on this server, this protection will only work if NBTAPI is present and running. This protection has automatically been disabled. ");
|
||||
return 0;
|
||||
}
|
||||
|
||||
if (!Protections.DestroyInvalidShulkers.isEnabled())
|
||||
if (!Protections.DestroyInvalidShulkers.isEnabled()) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
return NBTApiStuff.isBadShulkerLegacy(is);
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
public static boolean hasBadCustomData(ItemStack is) {
|
||||
|
||||
ItemMeta im = is.getItemMeta();
|
||||
|
||||
|
||||
if (IllegalStack.isHasAttribAPI() && im.hasAttributeModifiers()) {
|
||||
|
||||
|
||||
return true;
|
||||
} else if (IllegalStack.isNbtAPI())
|
||||
return NBTApiStuff.hasBadCustomDataLegacy(is);
|
||||
|
||||
|
||||
|
||||
} else if (IllegalStack.isNbtAPI()) {
|
||||
return NBTApiStuff.hasBadCustomDataLegacy(is);
|
||||
}
|
||||
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
public static void checkForNegativeDurability(ItemStack is, Player p) {
|
||||
if(is == null)
|
||||
return;
|
||||
|
||||
if (IllegalStack.isHasAttribAPI())
|
||||
{
|
||||
if(is.getItemMeta() instanceof Damageable) {
|
||||
Damageable dmg = (Damageable)is.getItemMeta();
|
||||
if(dmg.getDamage() > is.getType().getMaxDurability()) {
|
||||
fListener.getLog().append(Msg.IllegalStackDurability.getValue(p, is), Protections.FixNegativeDurability);
|
||||
dmg.setDamage(is.getType().getMaxDurability());
|
||||
is.setItemMeta((ItemMeta)dmg);
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
if (is == null) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (IllegalStack.isHasAttribAPI()) {
|
||||
if (is.getItemMeta() instanceof Damageable) {
|
||||
Damageable dmg = (Damageable) is.getItemMeta();
|
||||
if (dmg.getDamage() > is.getType().getMaxDurability()) {
|
||||
fListener.getLog().append(Msg.IllegalStackDurability.getValue(p, is), Protections.FixNegativeDurability);
|
||||
dmg.setDamage(is.getType().getMaxDurability());
|
||||
is.setItemMeta((ItemMeta) dmg);
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public static void checkForBadCustomData(ItemStack is, Player p, boolean sendToPlayer) {
|
||||
|
||||
ItemMeta im = is.getItemMeta();
|
||||
|
||||
|
||||
if (IllegalStack.isHasAttribAPI() && im.hasAttributeModifiers()) {
|
||||
StringBuilder attribs = new StringBuilder();
|
||||
HashSet<Attribute> toRemove = new HashSet<Attribute>();
|
||||
HashSet<Attribute> toRemove = new HashSet<>();
|
||||
for (Attribute a : im.getAttributeModifiers().keySet()) {
|
||||
for (AttributeModifier st : im.getAttributeModifiers(a)) {
|
||||
attribs.append(" ").append(st.getName()).append(" value: ").append(st.getAmount());
|
||||
@@ -193,23 +204,31 @@ public class NBTStuff {
|
||||
|
||||
toRemove.add(a);
|
||||
}
|
||||
if (sendToPlayer)
|
||||
if (sendToPlayer) {
|
||||
p.sendMessage(Msg.CustomAttribsRemoved.getValue(p, is, attribs.toString()));
|
||||
else
|
||||
fListener.getLog().append(Msg.CustomAttribsRemoved.getValue(p, is, attribs.toString()),Protections.RemoveCustomAttributes);
|
||||
for (Attribute remove : toRemove)
|
||||
} else {
|
||||
fListener.getLog().append(
|
||||
Msg.CustomAttribsRemoved.getValue(p, is, attribs.toString()),
|
||||
Protections.RemoveCustomAttributes
|
||||
);
|
||||
}
|
||||
for (Attribute remove : toRemove) {
|
||||
im.removeAttributeModifier(remove);
|
||||
}
|
||||
|
||||
for (ItemFlag iFlag : im.getItemFlags()) {
|
||||
im.removeItemFlags(iFlag);
|
||||
}
|
||||
|
||||
for(ItemFlag iFlag:im.getItemFlags())
|
||||
im.removeItemFlags(iFlag);
|
||||
|
||||
is.setItemMeta(im);
|
||||
|
||||
} else if (IllegalStack.isNbtAPI()) {
|
||||
NBTApiStuff.hasBadCustomDataOnArmorLegacy(p);
|
||||
NBTApiStuff.hasBadCustomDataOnArmorLegacy(p);
|
||||
NBTApiStuff.checkForBadCustomDataLegacy(is, p, sendToPlayer);
|
||||
|
||||
} else Msg.StaffNoNBTAPI.getValue(Protections.RemoveCustomAttributes.name());
|
||||
} else {
|
||||
Msg.StaffNoNBTAPI.getValue(Protections.RemoveCustomAttributes.name());
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -226,8 +245,9 @@ public class NBTStuff {
|
||||
|
||||
//should only ever be used on 1.15+ servers no need for legacy
|
||||
public static boolean hasNbtTag(Entity entity, String tag) {
|
||||
if (entity == null)
|
||||
if (entity == null) {
|
||||
return false;
|
||||
}
|
||||
|
||||
PersistentDataContainer data = entity.getPersistentDataContainer();
|
||||
NamespacedKey key = new NamespacedKey(IllegalStack.getPlugin(), tag);
|
||||
|
||||
@@ -28,25 +28,30 @@ public class PacketAttack {
|
||||
|
||||
public static PacketAttack findPlayer(UUID uniqueId) {
|
||||
|
||||
for (PacketAttack pa : attacks)
|
||||
if (pa.playerid.equals(uniqueId))
|
||||
for (PacketAttack pa : attacks) {
|
||||
if (pa.playerid.equals(uniqueId)) {
|
||||
return pa;
|
||||
}
|
||||
}
|
||||
|
||||
return new PacketAttack(uniqueId);
|
||||
}
|
||||
|
||||
public boolean addAttempt(Object packetEvent, String attackType) {
|
||||
|
||||
if (!this.pAttack.containsKey(attackType))
|
||||
if (!this.pAttack.containsKey(attackType)) {
|
||||
this.pAttack.put(attackType, 0);
|
||||
}
|
||||
|
||||
this.pAttack.put(attackType, this.pAttack.get(attackType) + 1);
|
||||
int maxAttempts = 250;
|
||||
|
||||
if (attackType.equalsIgnoreCase("WINDOW_INVALID_CLICK"))
|
||||
if (attackType.equalsIgnoreCase("WINDOW_INVALID_CLICK")) {
|
||||
maxAttempts = 5;
|
||||
if (attackType.equalsIgnoreCase("WINDOW_CLICK_SPAM"))
|
||||
}
|
||||
if (attackType.equalsIgnoreCase("WINDOW_CLICK_SPAM")) {
|
||||
maxAttempts = 80;
|
||||
}
|
||||
|
||||
return shouldCancelPacket(packetEvent, maxAttempts, attackType);
|
||||
|
||||
@@ -60,7 +65,8 @@ public class PacketAttack {
|
||||
int size = event.getPacket().getBytes().toString().length();
|
||||
|
||||
if (size > 2700) { //sending too large of a packet, cancel it regardless
|
||||
fListener.getLog().append2("Player sent a packet too large for the server to handle! Probably a packet attack!");
|
||||
fListener.getLog().append2(
|
||||
"Player sent a packet too large for the server to handle! Probably a packet attack!");
|
||||
event.getPlayer().kickPlayer("Invalid Packet Detected (packet too large)");
|
||||
return true;
|
||||
} else if (maxAttempts > 0) {
|
||||
@@ -76,4 +82,5 @@ public class PacketAttack {
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -10,14 +10,16 @@ import org.bukkit.inventory.ItemStack;
|
||||
|
||||
public class SlimefunCompat {
|
||||
|
||||
public static boolean isValid(Inventory inv) {
|
||||
return true;
|
||||
}
|
||||
public static boolean isValid(Inventory inv) {
|
||||
return true;
|
||||
}
|
||||
|
||||
public static boolean isValid(ItemStack is, Enchantment en) {
|
||||
|
||||
if(is == null)
|
||||
return false;
|
||||
|
||||
if (is == null) {
|
||||
return false;
|
||||
}
|
||||
|
||||
if (IllegalStack.isSlimeFun()) {
|
||||
SlimefunItem sfi = SlimefunItem.getByItem(is);
|
||||
if (sfi != null) {
|
||||
@@ -31,11 +33,14 @@ public class SlimefunCompat {
|
||||
if (IllegalStack.isClueScrolls() && IllegalStack.isNbtAPI()) {
|
||||
if (is.hasItemMeta()) {
|
||||
NBTItem nbti = new NBTItem(is);
|
||||
for (String key : nbti.getKeys())
|
||||
if (key.contains("ClueScrolls"))
|
||||
for (String key : nbti.getKeys()) {
|
||||
if (key.contains("ClueScrolls")) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
}
|
||||
+87
-43
@@ -7,50 +7,61 @@ import net.md_5.bungee.api.chat.ClickEvent;
|
||||
import net.md_5.bungee.api.chat.ComponentBuilder;
|
||||
import net.md_5.bungee.api.chat.HoverEvent;
|
||||
import net.md_5.bungee.api.chat.TextComponent;
|
||||
|
||||
import org.bukkit.entity.LivingEntity;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
public class SpigMethods {
|
||||
public class SpigotMethods {
|
||||
|
||||
public static BaseComponent makeParentText(Protections p, String status, boolean children, int catId) {
|
||||
public static BaseComponent makeParentText(Protections protections, String status, boolean children, int catId) {
|
||||
|
||||
String sTag = " ";
|
||||
if (!p.isList())
|
||||
if (!protections.isList()) {
|
||||
sTag = ChatColor.DARK_AQUA + "[" + status + ChatColor.DARK_AQUA + "]";
|
||||
}
|
||||
|
||||
TextComponent cLink = new TextComponent(sTag);
|
||||
if (!p.isList()) {
|
||||
cLink.setClickEvent(new ClickEvent(ClickEvent.Action.RUN_COMMAND, "/istack toggle " + p.name()));
|
||||
cLink.setHoverEvent(new HoverEvent(HoverEvent.Action.SHOW_TEXT, new ComponentBuilder("Toggle This Protection On/Off").create()));
|
||||
if (!protections.isList()) {
|
||||
cLink.setClickEvent(new ClickEvent(ClickEvent.Action.RUN_COMMAND, "/istack toggle " + protections.name()));
|
||||
cLink.setHoverEvent(new HoverEvent(
|
||||
HoverEvent.Action.SHOW_TEXT,
|
||||
new ComponentBuilder("Toggle This Protection On/Off").create()
|
||||
));
|
||||
} else {
|
||||
cLink = new TextComponent(ChatColor.GRAY + "[" + ChatColor.GREEN + "A");
|
||||
String cmd = "/istack value add " + p.name();
|
||||
String cmd = "/istack value add " + protections.name();
|
||||
cLink.setClickEvent(new ClickEvent(ClickEvent.Action.SUGGEST_COMMAND, cmd));
|
||||
cLink.setHoverEvent(new HoverEvent(HoverEvent.Action.SHOW_TEXT, new ComponentBuilder("Add a value to this list").create()));
|
||||
TextComponent opt = null;
|
||||
cLink.setHoverEvent(new HoverEvent(
|
||||
HoverEvent.Action.SHOW_TEXT,
|
||||
new ComponentBuilder("Add a value to this list").create()
|
||||
));
|
||||
TextComponent opt;
|
||||
|
||||
if (!p.getTxtSet().isEmpty()) {
|
||||
if (!protections.getTxtSet().isEmpty()) {
|
||||
opt = new TextComponent(ChatColor.RED + "R");
|
||||
cmd = "/istack value remove " + p.name();
|
||||
cmd = "/istack value remove " + protections.name();
|
||||
opt.setClickEvent(new ClickEvent(ClickEvent.Action.SUGGEST_COMMAND, cmd));
|
||||
opt.setHoverEvent(new HoverEvent(HoverEvent.Action.SHOW_TEXT, new ComponentBuilder("Remove a value from this list").create()));
|
||||
opt.setHoverEvent(new HoverEvent(
|
||||
HoverEvent.Action.SHOW_TEXT,
|
||||
new ComponentBuilder("Remove a value from this list").create()
|
||||
));
|
||||
|
||||
cLink.addExtra(opt);
|
||||
} else {
|
||||
cLink.addExtra(" ");
|
||||
}
|
||||
opt = new TextComponent(ChatColor.AQUA + "L");
|
||||
opt.setHoverEvent(new HoverEvent(HoverEvent.Action.SHOW_TEXT, new ComponentBuilder(ChatColor.AQUA + p.findValue()).create()));
|
||||
opt.setHoverEvent(new HoverEvent(
|
||||
HoverEvent.Action.SHOW_TEXT,
|
||||
new ComponentBuilder(ChatColor.AQUA + protections.findValue()).create()
|
||||
));
|
||||
|
||||
cLink.addExtra(opt);
|
||||
cLink.addExtra(ChatColor.GRAY + "] ");
|
||||
}
|
||||
|
||||
cLink.addExtra(ChatColor.GOLD + " " + p.getDisplayName());
|
||||
cLink.addExtra(ChatColor.GOLD + " " + protections.getDisplayName());
|
||||
TextComponent info = new TextComponent(ChatColor.GREEN + " *");
|
||||
if (!p.getDescription().equalsIgnoreCase("")) {
|
||||
String desc = p.getDescription() + ChatColor.AQUA + " " + p.getVersion() + ChatColor.RESET;
|
||||
if (!protections.getDescription().equalsIgnoreCase("")) {
|
||||
String desc = protections.getDescription() + ChatColor.AQUA + " " + protections.getVersion() + ChatColor.RESET;
|
||||
info.setHoverEvent(new HoverEvent(HoverEvent.Action.SHOW_TEXT, new ComponentBuilder(desc).create()));
|
||||
}
|
||||
cLink.addExtra(info);
|
||||
@@ -58,8 +69,14 @@ public class SpigMethods {
|
||||
//kids
|
||||
if (children) {
|
||||
TextComponent opt = new TextComponent(ChatColor.YELLOW + "(more options)");
|
||||
opt.setClickEvent(new ClickEvent(ClickEvent.Action.RUN_COMMAND, "/istack prot " + catId + " " + p.getProtId()));
|
||||
opt.setHoverEvent(new HoverEvent(HoverEvent.Action.SHOW_TEXT, new ComponentBuilder("Click to show/hide more options").create()));
|
||||
opt.setClickEvent(new ClickEvent(
|
||||
ClickEvent.Action.RUN_COMMAND,
|
||||
"/istack prot " + catId + " " + protections.getProtId()
|
||||
));
|
||||
opt.setHoverEvent(new HoverEvent(
|
||||
HoverEvent.Action.SHOW_TEXT,
|
||||
new ComponentBuilder("Click to show/hide more options").create()
|
||||
));
|
||||
cLink.addExtra(opt);
|
||||
}
|
||||
|
||||
@@ -67,23 +84,29 @@ public class SpigMethods {
|
||||
}
|
||||
|
||||
|
||||
public static BaseComponent makeCategoryText(Player plr, String category, Boolean show, int catID) {
|
||||
public static BaseComponent makeCategoryText(String category, Boolean show, int catID) {
|
||||
|
||||
TextComponent cLink = new TextComponent(ChatColor.AQUA + "- " + category + " -");
|
||||
String sText = ChatColor.GRAY + " (" + ChatColor.GREEN + "SHOW" + ChatColor.GRAY + ")";
|
||||
|
||||
if (show)
|
||||
if (show) {
|
||||
sText = ChatColor.GRAY + " (" + ChatColor.RED + "HIDE" + ChatColor.GRAY + ")";
|
||||
}
|
||||
|
||||
TextComponent option = new TextComponent(sText);
|
||||
option.setHoverEvent(new HoverEvent(HoverEvent.Action.SHOW_TEXT, new ComponentBuilder(ChatColor.GRAY + "Click to activate").create()));
|
||||
option.setHoverEvent(new HoverEvent(
|
||||
HoverEvent.Action.SHOW_TEXT,
|
||||
new ComponentBuilder(ChatColor.GRAY + "Click to activate").create()
|
||||
));
|
||||
|
||||
String command = "/istack prot ";
|
||||
if (!show) {
|
||||
if (catID == 1)
|
||||
if (catID == 1) {
|
||||
command = command + 1;
|
||||
if (catID == 2)
|
||||
}
|
||||
if (catID == 2) {
|
||||
command = command + 2;
|
||||
}
|
||||
}
|
||||
|
||||
option.setClickEvent(new ClickEvent(ClickEvent.Action.RUN_COMMAND, command));
|
||||
@@ -101,17 +124,26 @@ public class SpigMethods {
|
||||
TextComponent option = new TextComponent(ChatColor.GOLD + " [" + ChatColor.GREEN + "A");
|
||||
if (p == Protections.EnchantedItemWhitelist) {
|
||||
option.setClickEvent(new ClickEvent(ClickEvent.Action.RUN_COMMAND, "/istack enchantwhitelistmode"));
|
||||
option.setHoverEvent(new HoverEvent(HoverEvent.Action.SHOW_TEXT, new ComponentBuilder("Click to toggle adding EnchantedItemWhitelist add mode on/off").create()));
|
||||
option.setHoverEvent(new HoverEvent(
|
||||
HoverEvent.Action.SHOW_TEXT,
|
||||
new ComponentBuilder("Click to toggle adding EnchantedItemWhitelist add mode on/off").create()
|
||||
));
|
||||
} else {
|
||||
option.setClickEvent(new ClickEvent(ClickEvent.Action.SUGGEST_COMMAND, "/istack value add " + p.name()));
|
||||
option.setHoverEvent(new HoverEvent(HoverEvent.Action.SHOW_TEXT, new ComponentBuilder("Click to add a value to this list.").create()));
|
||||
option.setHoverEvent(new HoverEvent(
|
||||
HoverEvent.Action.SHOW_TEXT,
|
||||
new ComponentBuilder("Click to add a value to this list.").create()
|
||||
));
|
||||
}
|
||||
|
||||
cLink.addExtra(option);
|
||||
if (!p.getTxtSet().isEmpty()) {
|
||||
option = new TextComponent(ChatColor.RED + "R");
|
||||
option.setClickEvent(new ClickEvent(ClickEvent.Action.SUGGEST_COMMAND, "/istack value remove " + p.name()));
|
||||
option.setHoverEvent(new HoverEvent(HoverEvent.Action.SHOW_TEXT, new ComponentBuilder("Click to remove a value from this list.").create()));
|
||||
option.setHoverEvent(new HoverEvent(
|
||||
HoverEvent.Action.SHOW_TEXT,
|
||||
new ComponentBuilder("Click to remove a value from this list.").create()
|
||||
));
|
||||
cLink.addExtra(option);
|
||||
} else {
|
||||
cLink.addExtra(" ");
|
||||
@@ -124,19 +156,24 @@ public class SpigMethods {
|
||||
} else if (p.getIntValue() >= 0) {
|
||||
|
||||
int val = 0;
|
||||
if (p.getConfigValue() instanceof Integer)
|
||||
if (p.getConfigValue() instanceof Integer) {
|
||||
val = (Integer) p.getConfigValue();
|
||||
}
|
||||
|
||||
String pad = "";
|
||||
if (val <= 9)
|
||||
if (val <= 9) {
|
||||
pad = " ";
|
||||
else if (val <= 99)
|
||||
} else if (val <= 99) {
|
||||
pad = " ";
|
||||
}
|
||||
|
||||
|
||||
TextComponent option = new TextComponent(ChatColor.GRAY + " [" + p.findValue() + pad + "] ");
|
||||
option.setHoverEvent(new HoverEvent(HoverEvent.Action.SHOW_TEXT, new ComponentBuilder(p.findValue()).create()));
|
||||
option.setHoverEvent(new HoverEvent(HoverEvent.Action.SHOW_TEXT, new ComponentBuilder(ChatColor.GREEN + "(Click to change)").create()));
|
||||
option.setHoverEvent(new HoverEvent(
|
||||
HoverEvent.Action.SHOW_TEXT,
|
||||
new ComponentBuilder(ChatColor.GREEN + "(Click to change)").create()
|
||||
));
|
||||
String command = "/istack value set " + p.name();
|
||||
option.setClickEvent(new ClickEvent(ClickEvent.Action.SUGGEST_COMMAND, command));
|
||||
|
||||
@@ -144,14 +181,18 @@ public class SpigMethods {
|
||||
} else if (!p.getTxtValue().isEmpty()) {
|
||||
TextComponent option = new TextComponent(ChatColor.GRAY + " [" + ChatColor.GREEN + "TXT" + ChatColor.GRAY + "] ");
|
||||
option.setHoverEvent(new HoverEvent(HoverEvent.Action.SHOW_TEXT, new ComponentBuilder(p.findValue()).create()));
|
||||
option.setHoverEvent(new HoverEvent(HoverEvent.Action.SHOW_TEXT, new ComponentBuilder(ChatColor.GRAY + p.findValue() + ChatColor.GREEN + " (Click to change)").create()));
|
||||
option.setHoverEvent(new HoverEvent(
|
||||
HoverEvent.Action.SHOW_TEXT,
|
||||
new ComponentBuilder(ChatColor.GRAY + p.findValue() + ChatColor.GREEN + " (Click to change)").create()
|
||||
));
|
||||
String command = "/istack value set " + p.name() + " " + p.getConfigValue();
|
||||
option.setClickEvent(new ClickEvent(ClickEvent.Action.SUGGEST_COMMAND, command));
|
||||
cLink.addExtra(option);
|
||||
} else {
|
||||
String status = ChatColor.GREEN + " ON";
|
||||
if (!p.isEnabled())
|
||||
if (!p.isEnabled()) {
|
||||
status = ChatColor.DARK_RED + "OFF";
|
||||
}
|
||||
|
||||
TextComponent option = new TextComponent(ChatColor.GOLD + " [" + status + ChatColor.GOLD + "] ");
|
||||
option.setHoverEvent(new HoverEvent(HoverEvent.Action.SHOW_TEXT, new ComponentBuilder("Click to toggle").create()));
|
||||
@@ -191,10 +232,11 @@ public class SpigMethods {
|
||||
newString.append("\n").append(temp1);
|
||||
temp1 = word;
|
||||
} else {
|
||||
if (!temp1.equalsIgnoreCase(""))
|
||||
if (!temp1.equalsIgnoreCase("")) {
|
||||
temp1 = temp1 + " " + word;
|
||||
else
|
||||
} else {
|
||||
temp1 = word;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
@@ -209,26 +251,27 @@ public class SpigMethods {
|
||||
public static String longWord(String text, int length) {
|
||||
String[] words = text.split(" ");
|
||||
int counter = 0;
|
||||
String newString = "";
|
||||
StringBuilder newString = new StringBuilder();
|
||||
for (int i = 0; i < words[0].length(); i++) {
|
||||
if (counter == length - 2) {
|
||||
newString = newString + words[0].charAt(i) + "-\n";
|
||||
newString.append(words[0].charAt(i)).append("-\n");
|
||||
counter = 0;
|
||||
} else {
|
||||
newString = newString + words[0].charAt(i);
|
||||
newString.append(words[0].charAt(i));
|
||||
counter++;
|
||||
}
|
||||
}
|
||||
return newString;
|
||||
return newString.toString();
|
||||
}
|
||||
|
||||
public static boolean isNPC(LivingEntity ent) {
|
||||
|
||||
|
||||
return ent.hasMetadata("shopkeeper");
|
||||
}
|
||||
return ent.hasMetadata("shopkeeper");
|
||||
}
|
||||
|
||||
private static final class FlagFontInfo {
|
||||
|
||||
static int getPxLength(char c) {
|
||||
switch (c) {
|
||||
case 'i':
|
||||
@@ -250,6 +293,7 @@ public class SpigMethods {
|
||||
static int getPxLength(String string) {
|
||||
return string.chars().reduce(0, (p, i) -> p + getPxLength((char) i) + 1);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user