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 */ /* Fill lists */
Collections.addAll( Collections.addAll(
consoleCommandBlacklist, consoleCommandBlacklist,
"bukkit:about",
"bukkit:ver",
"bukkit:version",
"about",
"icanhasbukkit",
"ver",
"version",
"essentials:action", "essentials:action",
"essentials:adventure", "essentials:adventure",
"essentials:adventuremode", "essentials:adventuremode",
@ -49,6 +57,126 @@ public class Main extends JavaPlugin {
"essentials:creative", "essentials:creative",
"essentials:creativemode", "essentials:creativemode",
"essentials:describe", "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:eaction",
"essentials:eadventure", "essentials:eadventure",
"essentials:eadventuremode", "essentials:eadventuremode",
@ -124,97 +252,6 @@ public class Main extends JavaPlugin {
"essentials:ewarp", "essentials:ewarp",
"essentials:ewarps", "essentials:ewarps",
"essentials:ewhisper", "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", "eaction",
"eadventure", "eadventure",
"eadventuremode", "eadventuremode",
@ -245,7 +282,6 @@ public class Main extends JavaPlugin {
"eecreative", "eecreative",
"eemail", "eemail",
"efeed", "efeed",
"effect",
"egamemode", "egamemode",
"egm", "egm",
"egma", "egma",
@ -291,66 +327,58 @@ public class Main extends JavaPlugin {
"ewarp", "ewarp",
"ewarps", "ewarps",
"ewhisper", "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", "execute",
"feed",
"gamemode", "gamemode",
"gamerule", "gamerule",
"gm",
"gma",
"gmc",
"gms",
"gmsp",
"gmt",
"heal",
"helpop",
"jail",
"kill",
"m",
"mail",
"me", "me",
"memo",
"mute",
"msg", "msg",
"nuke", "say",
"spreadplayers",
"tell",
"title",
"tp",
"worldborder",
"paper:paper", "paper:paper",
"paper", "paper",
"pardon",
"pardonip",
"pm",
"shoutworld",
"say",
"silence",
"sp",
"spec",
"spectator",
"spigot:spigot", "spigot:spigot",
"spigot", "spigot",
"spreadplayers",
"sudo", "viaversion:viaver",
"survival", "viaversion:viaversion",
"survivalmode", "viaversion:vvbukkit",
"t", "viaver",
"tele", "viaversion",
"teleport", "vvbukkit"
"tell",
"tempban",
"title",
"tjail",
"togglejail",
"tp",
"tp2p",
"tpaall",
"tpall",
"tppos",
"tptoggle",
"unban",
"unbanip",
"v",
"vanish",
"w",
"warp",
"warps",
"whisper"
); );
Collections.addAll( Collections.addAll(

View file

@ -94,14 +94,17 @@ class EntitySpawn implements Listener {
try { try {
for (ItemStack item : mob.getEquipment().getArmorContents()) { for (ItemStack item : mob.getEquipment().getArmorContents()) {
if (item.getItemMeta() instanceof BannerMeta) { if (item != null &&
final BannerMeta banner = (BannerMeta) item.getItemMeta(); item.hasItemMeta()) {
if (item.getItemMeta() instanceof BannerMeta) {
final BannerMeta banner = (BannerMeta) item.getItemMeta();
for (Pattern pattern : banner.getPatterns()) { for (Pattern pattern : banner.getPatterns()) {
if (pattern.getColor() == null) { if (pattern.getColor() == null) {
mob.getEquipment().setArmorContents( mob.getEquipment().setArmorContents(
new ItemStack[] {null, null, null, null} new ItemStack[] {null, null, null, null}
); );
}
} }
} }
} }
@ -113,12 +116,17 @@ class EntitySpawn implements Listener {
} }
try { try {
if (mob.getEquipment().getItemInMainHand().getItemMeta() instanceof BannerMeta) { ItemStack item = mob.getEquipment().getItemInMainHand();
final BannerMeta banner = (BannerMeta) mob.getEquipment().getItemInMainHand().getItemMeta();
for (Pattern pattern : banner.getPatterns()) { if (item != null &&
if (pattern.getColor() == null) { item.hasItemMeta()) {
mob.getEquipment().setItemInMainHand(null); 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 { try {
if (mob.getEquipment().getItemInOffHand().getItemMeta() instanceof BannerMeta) { ItemStack item = mob.getEquipment().getItemInMainHand();
final BannerMeta banner = (BannerMeta) mob.getEquipment().getItemInOffHand().getItemMeta();
for (Pattern pattern : banner.getPatterns()) { if (item != null &&
if (pattern.getColor() == null) { item.hasItemMeta()) {
mob.getEquipment().setItemInOffHand(null); 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 { try {
for (ItemStack item : mob.getEquipment().getArmorContents()) { for (ItemStack item : mob.getEquipment().getArmorContents()) {
if (item.getItemMeta() instanceof BannerMeta) { if (item != null &&
final BannerMeta banner = (BannerMeta) item.getItemMeta(); item.hasItemMeta()) {
if (item.getItemMeta() instanceof BannerMeta) {
final BannerMeta banner = (BannerMeta) item.getItemMeta();
for (Pattern pattern : banner.getPatterns()) { for (Pattern pattern : banner.getPatterns()) {
if (pattern.getColor() == null) { if (pattern.getColor() == null) {
mob.getEquipment().setArmorContents( mob.getEquipment().setArmorContents(
new ItemStack[] {null, null, null, null} new ItemStack[] {null, null, null, null}
); );
}
} }
} }
} }
@ -207,12 +223,17 @@ class EntitySpawn implements Listener {
} }
try { try {
if (mob.getEquipment().getItemInMainHand().getItemMeta() instanceof BannerMeta) { ItemStack item = mob.getEquipment().getItemInMainHand();
final BannerMeta banner = (BannerMeta) mob.getEquipment().getItemInMainHand().getItemMeta();
for (Pattern pattern : banner.getPatterns()) { if (item != null &&
if (pattern.getColor() == null) { item.hasItemMeta()) {
mob.getEquipment().setItemInMainHand(null); if (item.getItemMeta() instanceof BannerMeta) {
final BannerMeta banner = (BannerMeta) item.getItemMeta();
for (Pattern pattern : banner.getPatterns()) {
if (pattern.getColor() == null) {
mob.getEquipment().setItemInMainHand(null);
}
} }
} }
} }
@ -221,12 +242,17 @@ class EntitySpawn implements Listener {
} }
try { try {
if (mob.getEquipment().getItemInOffHand().getItemMeta() instanceof BannerMeta) { ItemStack item = mob.getEquipment().getItemInMainHand();
final BannerMeta banner = (BannerMeta) mob.getEquipment().getItemInOffHand().getItemMeta();
for (Pattern pattern : banner.getPatterns()) { if (item != null &&
if (pattern.getColor() == null) { item.hasItemMeta()) {
mob.getEquipment().setItemInOffHand(null); 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()) { if (player.hasPlayedBefore()) {
try { try {
for (ItemStack item : player.getInventory().getContents()) { for (ItemStack item : player.getInventory().getContents()) {
if (item.getItemMeta() instanceof BannerMeta) { if (item != null &&
final BannerMeta banner = (BannerMeta) item.getItemMeta(); item.hasItemMeta()) {
if (item.getItemMeta() instanceof BannerMeta) {
final BannerMeta banner = (BannerMeta) item.getItemMeta();
for (Pattern pattern : banner.getPatterns()) { for (Pattern pattern : banner.getPatterns()) {
if (pattern.getColor() == null) { if (pattern.getColor() == null) {
player.getInventory().clear(); player.getInventory().clear();
}
} }
} }
} }