Fix errors in inventory checker

This commit is contained in:
mathiascode 2019-09-22 17:35:38 +03:00
parent 6b22761698
commit a08c19f850
3 changed files with 246 additions and 189 deletions

View file

@ -27,6 +27,14 @@ public class Main extends JavaPlugin {
/* Fill lists */
Collections.addAll(
consoleCommandBlacklist,
"bukkit:about",
"bukkit:ver",
"bukkit:version",
"about",
"icanhasbukkit",
"ver",
"version",
"essentials:action",
"essentials:adventure",
"essentials:adventuremode",
@ -49,6 +57,126 @@ public class Main extends JavaPlugin {
"essentials:creative",
"essentials:creativemode",
"essentials:describe",
"essentials:feed",
"essentials:gamemode",
"essentials:gm",
"essentials:gma",
"essentials:gmc",
"essentials:gms",
"essentials:gmsp",
"essentials:gmt",
"essentials:heal",
"essentials:helpop",
"essentials:jail",
"essentials:kick",
"essentials:kill",
"essentials:m",
"essentials:mail",
"essentials:me",
"essentials:memo",
"essentials:mute",
"essentials:msg",
"essentials:nuke",
"essentials:pardon",
"essentials:pardonip",
"essentials:pm",
"essentials:shoutworld",
"essentials:silence",
"essentials:sp",
"essentials:spec",
"essentials:spectator",
"essentials:sudo",
"essentials:survival",
"essentials:survivalmode",
"essentials:t",
"essentials:tele",
"essentials:teleport",
"essentials:tell",
"essentials:tempban",
"essentials:tjail",
"essentials:togglejail",
"essentials:tp",
"essentials:tp2p",
"essentials:tpaall",
"essentials:tpall",
"essentials:tppos",
"essentials:tptoggle",
"essentials:unban",
"essentials:unbanip",
"essentials:v",
"essentials:vanish",
"essentials:w",
"essentials:warp",
"essentials:warps",
"essentials:whisper",
"action",
"adventure",
"adventuremode",
"afk",
"amsg",
"away",
"ban",
"banip",
"bc",
"bcast",
"bcastw",
"bcw",
"broadcast",
"broadcastworld",
"ci",
"clean",
"clearinvent",
"clearinventory",
"creative",
"creativemode",
"describe",
"feed",
"gm",
"gma",
"gmc",
"gms",
"gmsp",
"gmt",
"heal",
"helpop",
"jail",
"kill",
"m",
"mail",
"memo",
"mute",
"nuke",
"pardon",
"pardonip",
"pm",
"shoutworld",
"silence",
"sp",
"spec",
"spectator",
"sudo",
"survival",
"survivalmode",
"t",
"tele",
"teleport",
"tempban",
"tjail",
"togglejail",
"tp2p",
"tpaall",
"tpall",
"tppos",
"tptoggle",
"unban",
"unbanip",
"v",
"vanish",
"w",
"warp",
"warps",
"whisper",
"essentials:eaction",
"essentials:eadventure",
"essentials:eadventuremode",
@ -124,97 +252,6 @@ public class Main extends JavaPlugin {
"essentials:ewarp",
"essentials:ewarps",
"essentials:ewhisper",
"essentials:feed",
"essentials:gamemode",
"essentials:gm",
"essentials:gma",
"essentials:gmc",
"essentials:gms",
"essentials:gmsp",
"essentials:gmt",
"essentials:heal",
"essentials:helpop",
"essentials:jail",
"essentials:kick",
"essentials:kill",
"essentials:m",
"essentials:mail",
"essentials:me",
"essentials:memo",
"essentials:mute",
"essentials:msg",
"essentials:nuke",
"essentials:pardon",
"essentials:pardonip",
"essentials:pm",
"essentials:shoutworld",
"essentials:silence",
"essentials:sp",
"essentials:spec",
"essentials:spectator",
"essentials:sudo",
"essentials:survival",
"essentials:survivalmode",
"essentials:t",
"essentials:tele",
"essentials:teleport",
"essentials:tell",
"essentials:tempban",
"essentials:tjail",
"essentials:togglejail",
"essentials:tp",
"essentials:tp2p",
"essentials:tpaall",
"essentials:tpall",
"essentials:tppos",
"essentials:tptoggle",
"essentials:unban",
"essentials:unbanip",
"essentials:v",
"essentials:vanish",
"essentials:w",
"essentials:warp",
"essentials:warps",
"essentials:whisper",
"extras:cc",
"extras:clearchat",
"minecraft:clear",
"minecraft:effect",
"minecraft:execute",
"minecraft:gamemode",
"minecraft:gamerule",
"minecraft:kill",
"minecraft:me",
"minecraft:say",
"minecraft:spreadplayers",
"minecraft:tell",
"minecraft:tellraw",
"minecraft:title",
"minecraft:tp",
"action",
"adventure",
"adventuremode",
"afk",
"amsg",
"away",
"ban",
"banip",
"bc",
"bcast",
"bcastw",
"bcw",
"broadcast",
"broadcastworld",
"cc",
"ci",
"clean",
"clear",
"clearchat",
"clearinvent",
"clearinventory",
"creative",
"creativemode",
"describe",
"eaction",
"eadventure",
"eadventuremode",
@ -245,7 +282,6 @@ public class Main extends JavaPlugin {
"eecreative",
"eemail",
"efeed",
"effect",
"egamemode",
"egm",
"egma",
@ -291,66 +327,58 @@ public class Main extends JavaPlugin {
"ewarp",
"ewarps",
"ewhisper",
"extras:cc",
"extras:clearchat",
"extras:console",
"extras:tellraw",
"cc",
"clearchat",
"console",
"tellraw",
"minecraft:clear",
"minecraft:datapack",
"minecraft:effect",
"minecraft:execute",
"minecraft:gamemode",
"minecraft:gamerule",
"minecraft:me",
"minecraft:msg",
"minecraft:say",
"minecraft:spreadplayers",
"minecraft:tell",
"minecraft:tellraw",
"minecraft:title",
"minecraft:tp",
"minecraft:worldborder",
"clear",
"datapack",
"effect",
"execute",
"feed",
"gamemode",
"gamerule",
"gm",
"gma",
"gmc",
"gms",
"gmsp",
"gmt",
"heal",
"helpop",
"jail",
"kill",
"m",
"mail",
"me",
"memo",
"mute",
"msg",
"nuke",
"say",
"spreadplayers",
"tell",
"title",
"tp",
"worldborder",
"paper:paper",
"paper",
"pardon",
"pardonip",
"pm",
"shoutworld",
"say",
"silence",
"sp",
"spec",
"spectator",
"spigot:spigot",
"spigot",
"spreadplayers",
"sudo",
"survival",
"survivalmode",
"t",
"tele",
"teleport",
"tell",
"tempban",
"title",
"tjail",
"togglejail",
"tp",
"tp2p",
"tpaall",
"tpall",
"tppos",
"tptoggle",
"unban",
"unbanip",
"v",
"vanish",
"w",
"warp",
"warps",
"whisper"
"viaversion:viaver",
"viaversion:viaversion",
"viaversion:vvbukkit",
"viaver",
"viaversion",
"vvbukkit"
);
Collections.addAll(

View file

@ -94,14 +94,17 @@ class EntitySpawn implements Listener {
try {
for (ItemStack item : mob.getEquipment().getArmorContents()) {
if (item.getItemMeta() instanceof BannerMeta) {
final BannerMeta banner = (BannerMeta) item.getItemMeta();
for (Pattern pattern : banner.getPatterns()) {
if (pattern.getColor() == null) {
mob.getEquipment().setArmorContents(
new ItemStack[] {null, null, null, null}
);
if (item != null &&
item.hasItemMeta()) {
if (item.getItemMeta() instanceof BannerMeta) {
final BannerMeta banner = (BannerMeta) item.getItemMeta();
for (Pattern pattern : banner.getPatterns()) {
if (pattern.getColor() == null) {
mob.getEquipment().setArmorContents(
new ItemStack[] {null, null, null, null}
);
}
}
}
}
@ -113,12 +116,17 @@ class EntitySpawn implements Listener {
}
try {
if (mob.getEquipment().getItemInMainHand().getItemMeta() instanceof BannerMeta) {
final BannerMeta banner = (BannerMeta) mob.getEquipment().getItemInMainHand().getItemMeta();
ItemStack item = mob.getEquipment().getItemInMainHand();
for (Pattern pattern : banner.getPatterns()) {
if (pattern.getColor() == null) {
mob.getEquipment().setItemInMainHand(null);
if (item != null &&
item.hasItemMeta()) {
if (item.getItemMeta() instanceof BannerMeta) {
final BannerMeta banner = (BannerMeta) item.getItemMeta();
for (Pattern pattern : banner.getPatterns()) {
if (pattern.getColor() == null) {
mob.getEquipment().setItemInMainHand(null);
}
}
}
}
@ -127,12 +135,17 @@ class EntitySpawn implements Listener {
}
try {
if (mob.getEquipment().getItemInOffHand().getItemMeta() instanceof BannerMeta) {
final BannerMeta banner = (BannerMeta) mob.getEquipment().getItemInOffHand().getItemMeta();
ItemStack item = mob.getEquipment().getItemInMainHand();
for (Pattern pattern : banner.getPatterns()) {
if (pattern.getColor() == null) {
mob.getEquipment().setItemInOffHand(null);
if (item != null &&
item.hasItemMeta()) {
if (mob.getEquipment().getItemInOffHand().getItemMeta() instanceof BannerMeta) {
final BannerMeta banner = (BannerMeta) mob.getEquipment().getItemInOffHand().getItemMeta();
for (Pattern pattern : banner.getPatterns()) {
if (pattern.getColor() == null) {
mob.getEquipment().setItemInOffHand(null);
}
}
}
}
@ -188,14 +201,17 @@ class EntitySpawn implements Listener {
try {
for (ItemStack item : mob.getEquipment().getArmorContents()) {
if (item.getItemMeta() instanceof BannerMeta) {
final BannerMeta banner = (BannerMeta) item.getItemMeta();
for (Pattern pattern : banner.getPatterns()) {
if (pattern.getColor() == null) {
mob.getEquipment().setArmorContents(
new ItemStack[] {null, null, null, null}
);
if (item != null &&
item.hasItemMeta()) {
if (item.getItemMeta() instanceof BannerMeta) {
final BannerMeta banner = (BannerMeta) item.getItemMeta();
for (Pattern pattern : banner.getPatterns()) {
if (pattern.getColor() == null) {
mob.getEquipment().setArmorContents(
new ItemStack[] {null, null, null, null}
);
}
}
}
}
@ -205,28 +221,38 @@ class EntitySpawn implements Listener {
new ItemStack[] {null, null, null, null}
);
}
try {
if (mob.getEquipment().getItemInMainHand().getItemMeta() instanceof BannerMeta) {
final BannerMeta banner = (BannerMeta) mob.getEquipment().getItemInMainHand().getItemMeta();
for (Pattern pattern : banner.getPatterns()) {
if (pattern.getColor() == null) {
mob.getEquipment().setItemInMainHand(null);
ItemStack item = mob.getEquipment().getItemInMainHand();
if (item != null &&
item.hasItemMeta()) {
if (item.getItemMeta() instanceof BannerMeta) {
final BannerMeta banner = (BannerMeta) item.getItemMeta();
for (Pattern pattern : banner.getPatterns()) {
if (pattern.getColor() == null) {
mob.getEquipment().setItemInMainHand(null);
}
}
}
}
} catch (Exception exception) {
mob.getEquipment().setItemInMainHand(null);
}
try {
if (mob.getEquipment().getItemInOffHand().getItemMeta() instanceof BannerMeta) {
final BannerMeta banner = (BannerMeta) mob.getEquipment().getItemInOffHand().getItemMeta();
for (Pattern pattern : banner.getPatterns()) {
if (pattern.getColor() == null) {
mob.getEquipment().setItemInOffHand(null);
ItemStack item = mob.getEquipment().getItemInMainHand();
if (item != null &&
item.hasItemMeta()) {
if (mob.getEquipment().getItemInOffHand().getItemMeta() instanceof BannerMeta) {
final BannerMeta banner = (BannerMeta) mob.getEquipment().getItemInOffHand().getItemMeta();
for (Pattern pattern : banner.getPatterns()) {
if (pattern.getColor() == null) {
mob.getEquipment().setItemInOffHand(null);
}
}
}
}

View file

@ -81,12 +81,15 @@ class PlayerConnection implements Listener {
if (player.hasPlayedBefore()) {
try {
for (ItemStack item : player.getInventory().getContents()) {
if (item.getItemMeta() instanceof BannerMeta) {
final BannerMeta banner = (BannerMeta) item.getItemMeta();
for (Pattern pattern : banner.getPatterns()) {
if (pattern.getColor() == null) {
player.getInventory().clear();
if (item != null &&
item.hasItemMeta()) {
if (item.getItemMeta() instanceof BannerMeta) {
final BannerMeta banner = (BannerMeta) item.getItemMeta();
for (Pattern pattern : banner.getPatterns()) {
if (pattern.getColor() == null) {
player.getInventory().clear();
}
}
}
}