Detect and block prefilled inventories in PersonalKitCreator
Signed-off-by: Lixfel <agga-games@gmx.de>
Dieser Commit ist enthalten in:
Ursprung
da157fef72
Commit
08b483deb4
@ -0,0 +1,30 @@
|
||||
/*
|
||||
This file is a part of the SteamWar software.
|
||||
|
||||
Copyright (C) 2020 SteamWar.de-Serverteam
|
||||
|
||||
This program is free software: you can redistribute it and/or modify
|
||||
it under the terms of the GNU Affero General Public License as published by
|
||||
the Free Software Foundation, either version 3 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU Affero General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU Affero General Public License
|
||||
along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
package de.steamwar.fightsystem.listener;
|
||||
|
||||
import org.bukkit.craftbukkit.v1_10_R1.inventory.CraftItemStack;
|
||||
import org.bukkit.inventory.ItemStack;
|
||||
|
||||
class PersonalKitCreator_10 {
|
||||
|
||||
static boolean hasItems(ItemStack stack){
|
||||
return CraftItemStack.asNMSCopy(stack).getTag().hasKey("Items");
|
||||
}
|
||||
}
|
@ -0,0 +1,30 @@
|
||||
/*
|
||||
This file is a part of the SteamWar software.
|
||||
|
||||
Copyright (C) 2020 SteamWar.de-Serverteam
|
||||
|
||||
This program is free software: you can redistribute it and/or modify
|
||||
it under the terms of the GNU Affero General Public License as published by
|
||||
the Free Software Foundation, either version 3 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU Affero General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU Affero General Public License
|
||||
along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
package de.steamwar.fightsystem.listener;
|
||||
|
||||
import org.bukkit.craftbukkit.v1_12_R1.inventory.CraftItemStack;
|
||||
import org.bukkit.inventory.ItemStack;
|
||||
|
||||
class PersonalKitCreator_12 {
|
||||
|
||||
static boolean hasItems(ItemStack stack){
|
||||
return CraftItemStack.asNMSCopy(stack).getTag().hasKey("Items");
|
||||
}
|
||||
}
|
@ -19,6 +19,7 @@
|
||||
|
||||
package de.steamwar.fightsystem.listener;
|
||||
|
||||
import org.bukkit.craftbukkit.v1_14_R1.inventory.CraftItemStack;
|
||||
import org.bukkit.inventory.ItemStack;
|
||||
|
||||
import java.util.Objects;
|
||||
@ -29,4 +30,8 @@ class PersonalKitCreator_14 {
|
||||
static boolean hasAttributeModifier(ItemStack stack){
|
||||
return stack.hasItemMeta() && Objects.requireNonNull(stack.getItemMeta()).hasAttributeModifiers();
|
||||
}
|
||||
|
||||
static boolean hasItems(ItemStack stack){
|
||||
return CraftItemStack.asNMSCopy(stack).getTag().hasKey("Items");
|
||||
}
|
||||
}
|
||||
|
@ -0,0 +1,30 @@
|
||||
/*
|
||||
This file is a part of the SteamWar software.
|
||||
|
||||
Copyright (C) 2020 SteamWar.de-Serverteam
|
||||
|
||||
This program is free software: you can redistribute it and/or modify
|
||||
it under the terms of the GNU Affero General Public License as published by
|
||||
the Free Software Foundation, either version 3 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU Affero General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU Affero General Public License
|
||||
along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
package de.steamwar.fightsystem.listener;
|
||||
|
||||
import org.bukkit.craftbukkit.v1_15_R1.inventory.CraftItemStack;
|
||||
import org.bukkit.inventory.ItemStack;
|
||||
|
||||
class PersonalKitCreator_15 {
|
||||
|
||||
static boolean hasItems(ItemStack stack){
|
||||
return CraftItemStack.asNMSCopy(stack).getTag().hasKey("Items");
|
||||
}
|
||||
}
|
@ -0,0 +1,30 @@
|
||||
/*
|
||||
This file is a part of the SteamWar software.
|
||||
|
||||
Copyright (C) 2020 SteamWar.de-Serverteam
|
||||
|
||||
This program is free software: you can redistribute it and/or modify
|
||||
it under the terms of the GNU Affero General Public License as published by
|
||||
the Free Software Foundation, either version 3 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU Affero General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU Affero General Public License
|
||||
along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
package de.steamwar.fightsystem.listener;
|
||||
|
||||
import org.bukkit.craftbukkit.v1_8_R3.inventory.CraftItemStack;
|
||||
import org.bukkit.inventory.ItemStack;
|
||||
|
||||
class PersonalKitCreator_8 {
|
||||
|
||||
static boolean hasItems(ItemStack stack){
|
||||
return CraftItemStack.asNMSCopy(stack).getTag().hasKey("Items");
|
||||
}
|
||||
}
|
@ -0,0 +1,30 @@
|
||||
/*
|
||||
This file is a part of the SteamWar software.
|
||||
|
||||
Copyright (C) 2020 SteamWar.de-Serverteam
|
||||
|
||||
This program is free software: you can redistribute it and/or modify
|
||||
it under the terms of the GNU Affero General Public License as published by
|
||||
the Free Software Foundation, either version 3 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU Affero General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU Affero General Public License
|
||||
along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
package de.steamwar.fightsystem.listener;
|
||||
|
||||
import org.bukkit.craftbukkit.v1_9_R2.inventory.CraftItemStack;
|
||||
import org.bukkit.inventory.ItemStack;
|
||||
|
||||
class PersonalKitCreator_9 {
|
||||
|
||||
static boolean hasItems(ItemStack stack){
|
||||
return CraftItemStack.asNMSCopy(stack).getTag().hasKey("Items");
|
||||
}
|
||||
}
|
@ -42,6 +42,8 @@ import org.bukkit.event.player.PlayerMoveEvent;
|
||||
import org.bukkit.event.player.PlayerQuitEvent;
|
||||
import org.bukkit.inventory.ItemStack;
|
||||
import org.bukkit.inventory.PlayerInventory;
|
||||
import org.bukkit.inventory.meta.BlockDataMeta;
|
||||
import org.bukkit.inventory.meta.ItemMeta;
|
||||
|
||||
import java.util.EnumSet;
|
||||
import java.util.HashMap;
|
||||
@ -160,11 +162,38 @@ public class PersonalKitCreator extends BasicListener {
|
||||
return true;
|
||||
}
|
||||
|
||||
if(stack.hasItemMeta()){
|
||||
ItemMeta meta = stack.getItemMeta();
|
||||
if(meta instanceof BlockDataMeta && ((BlockDataMeta)meta).hasBlockData())
|
||||
return true; //Blocks always upwards slabs etc.
|
||||
|
||||
if(hasItems(stack))
|
||||
return true; //Blocks prefilled inventories
|
||||
}
|
||||
|
||||
Kit normal = KitManager.getKitByName(Config.MemberDefault);
|
||||
assert normal != null;
|
||||
return !normal.isEnchantmentInKit(stack) && !stack.getEnchantments().isEmpty();
|
||||
}
|
||||
|
||||
private static boolean hasItems(ItemStack stack){
|
||||
switch(Core.getVersion()){
|
||||
case 8:
|
||||
return PersonalKitCreator_8.hasItems(stack);
|
||||
case 9:
|
||||
return PersonalKitCreator_9.hasItems(stack);
|
||||
case 10:
|
||||
return PersonalKitCreator_10.hasItems(stack);
|
||||
case 12:
|
||||
return PersonalKitCreator_12.hasItems(stack);
|
||||
case 14:
|
||||
return PersonalKitCreator_14.hasItems(stack);
|
||||
case 15:
|
||||
default:
|
||||
return PersonalKitCreator_15.hasItems(stack);
|
||||
}
|
||||
}
|
||||
|
||||
private static class InventoryBackup{
|
||||
private final Player player;
|
||||
private final ItemStack[] contents;
|
||||
|
In neuem Issue referenzieren
Einen Benutzer sperren