First 1.21.3 drafts

This commit is contained in:
2024-11-26 16:30:24 +01:00
parent df37fa1564
commit d6202f9596
5 changed files with 107 additions and 11 deletions
@@ -146,7 +146,7 @@ public class EventListener implements Listener {
@EventHandler(priority = EventPriority.HIGH)
public void onEntitySpawn(EntitySpawnEvent event) {
if (event.getEntityType() != EntityType.PRIMED_TNT) {
if (event.getEntityType().name().equals("tnt")) {
return;
}
Region tntRegion = Region.getRegion(event.getLocation());
@@ -0,0 +1,38 @@
/*
* This file is a part of the SteamWar software.
*
* Copyright (C) 2024 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.inventory;
import org.bukkit.enchantments.Enchantment;
import org.bukkit.inventory.ItemFlag;
import java.util.Collection;
import java.util.EnumSet;
public class SWItem21 implements SWItem.ISWItem {
@Override
public Collection<ItemFlag> getHideFlags() {
return EnumSet.allOf(ItemFlag.class);
}
@Override
public Enchantment getDurabilityEnchantment() {
return Enchantment.UNBREAKING;
}
}
@@ -0,0 +1,45 @@
/*
* This file is a part of the SteamWar software.
*
* Copyright (C) 2024 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.inventory;
import org.bukkit.enchantments.Enchantment;
import org.bukkit.inventory.ItemFlag;
import java.util.Collection;
import java.util.EnumSet;
public class SWItem8 implements SWItem.ISWItem {
@Override
public Collection<ItemFlag> getHideFlags() {
return EnumSet.of(
ItemFlag.HIDE_ATTRIBUTES,
ItemFlag.HIDE_DESTROYS,
ItemFlag.HIDE_UNBREAKABLE,
ItemFlag.HIDE_ENCHANTS,
ItemFlag.HIDE_PLACED_ON,
ItemFlag.HIDE_POTION_EFFECTS
);
}
@Override
public Enchantment getDurabilityEnchantment() {
return Enchantment.DURABILITY;
}
}
+6 -1
View File
@@ -32,7 +32,12 @@ dependencies {
compileOnly(libs.worldedit12)
compileOnly(libs.spigotapi)
compileOnly(libs.paperapi21) {
attributes {
// Very Hacky, but it works
attribute(TargetJvmVersion.TARGET_JVM_VERSION_ATTRIBUTE, 21)
}
}
compileOnly(libs.netty)
compileOnly(libs.authlib)
compileOnly(libs.viaapi)
@@ -21,7 +21,9 @@ package de.steamwar.inventory;
import com.google.gson.JsonArray;
import com.google.gson.JsonObject;
import de.steamwar.core.Core;
import de.steamwar.core.FlatteningWrapper;
import de.steamwar.core.VersionDependent;
import org.bukkit.Material;
import org.bukkit.OfflinePlayer;
import org.bukkit.enchantments.Enchantment;
@@ -30,10 +32,13 @@ import org.bukkit.inventory.ItemStack;
import org.bukkit.inventory.meta.ItemMeta;
import java.util.ArrayList;
import java.util.Collection;
import java.util.List;
public class SWItem {
private static final ISWItem impl = VersionDependent.getVersionImpl(Core.getInstance());
private ItemStack itemStack;
private ItemMeta itemMeta;
private InvCallback callback;
@@ -107,7 +112,7 @@ public class SWItem {
itemMeta.setDisplayName(name);
if (lore != null && !lore.isEmpty()) itemMeta.setLore(lore);
if (enchanted) itemMeta.addEnchant(Enchantment.DURABILITY , 10, true);
if (enchanted) itemMeta.addEnchant(impl.getDurabilityEnchantment() , 10, true);
itemStack.setItemMeta(itemMeta);
}
callback = c;
@@ -144,12 +149,9 @@ public class SWItem {
private void hideAttributes() {
if (itemMeta == null) return;
itemMeta.addItemFlags(ItemFlag.HIDE_ATTRIBUTES);
itemMeta.addItemFlags(ItemFlag.HIDE_DESTROYS);
itemMeta.addItemFlags(ItemFlag.HIDE_UNBREAKABLE);
itemMeta.addItemFlags(ItemFlag.HIDE_ENCHANTS);
itemMeta.addItemFlags(ItemFlag.HIDE_PLACED_ON);
itemMeta.addItemFlags(ItemFlag.HIDE_POTION_EFFECTS);
for (ItemFlag flag : impl.getHideFlags()) {
itemMeta.addItemFlags(flag);
}
}
public ItemStack getItemStack() {
@@ -192,10 +194,16 @@ public class SWItem {
public void setEnchanted(boolean enchanted) {
if (enchanted){
itemMeta.addEnchant(Enchantment.DURABILITY , 10, true);
itemMeta.addEnchant(impl.getDurabilityEnchantment() , 10, true);
} else {
itemMeta.removeEnchant(Enchantment.DURABILITY);
itemMeta.removeEnchant(impl.getDurabilityEnchantment());
}
itemStack.setItemMeta(itemMeta);
}
public interface ISWItem {
Collection<ItemFlag> getHideFlags();
Enchantment getDurabilityEnchantment();
}
}