forked from SteamWar/SteamWar
send help ._.
This commit is contained in:
@@ -232,9 +232,21 @@ public class FlatteningWrapper14 implements FlatteningWrapper.IFlatteningWrapper
|
||||
scoreboardName.set(packet, ChatWrapper.impl.stringToChatComponent(title));
|
||||
}
|
||||
|
||||
private static final Class<?> scoreActionEnum = Reflection.getClass("{nms.server}.ScoreboardServer$Action");
|
||||
private static final Reflection.FieldAccessor<?> scoreAction = Reflection.getField(FlatteningWrapper.scoreboardScore, scoreActionEnum, 0);
|
||||
private static final Object scoreActionChange = scoreActionEnum.getEnumConstants()[0];
|
||||
private static final Class<?> scoreActionEnum;
|
||||
private static final Reflection.FieldAccessor<?> scoreAction;
|
||||
private static final Object scoreActionChange;
|
||||
|
||||
static {
|
||||
if (Core.getVersion() < 21) {
|
||||
scoreActionEnum = Reflection.getClass("{nms.server}.ScoreboardServer$Action");
|
||||
scoreAction = Reflection.getField(FlatteningWrapper.scoreboardScore, scoreActionEnum, 0);
|
||||
scoreActionChange = scoreActionEnum.getEnumConstants()[0];
|
||||
} else {
|
||||
scoreActionEnum = null;
|
||||
scoreAction = null;
|
||||
scoreActionChange = null;
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setScoreAction(Object packet) {
|
||||
|
||||
@@ -30,4 +30,10 @@ dependencies {
|
||||
attribute(TargetJvmVersion.TARGET_JVM_VERSION_ATTRIBUTE, 21)
|
||||
}
|
||||
}
|
||||
compileOnly(libs.nms21) {
|
||||
attributes {
|
||||
// Very Hacky, but it works
|
||||
attribute(TargetJvmVersion.TARGET_JVM_VERSION_ATTRIBUTE, 21)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
+6
-9
@@ -17,22 +17,19 @@
|
||||
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
package de.steamwar.inventory;
|
||||
package de.steamwar.core;
|
||||
|
||||
import org.bukkit.enchantments.Enchantment;
|
||||
import org.bukkit.inventory.ItemFlag;
|
||||
import org.bukkit.entity.EntityType;
|
||||
|
||||
import java.util.Collection;
|
||||
import java.util.EnumSet;
|
||||
|
||||
public class SWItem21 implements SWItem.ISWItem {
|
||||
public class TrickyTrialsWrapper21 implements TrickyTrialsWrapper {
|
||||
@Override
|
||||
public Collection<ItemFlag> getHideFlags() {
|
||||
return EnumSet.allOf(ItemFlag.class);
|
||||
public EntityType getTntEntityType() {
|
||||
return EntityType.TNT;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Enchantment getDurabilityEnchantment() {
|
||||
public Enchantment getUnbreakingEnchantment() {
|
||||
return Enchantment.UNBREAKING;
|
||||
}
|
||||
}
|
||||
@@ -96,7 +96,7 @@ public class FlatteningWrapper8 implements FlatteningWrapper.IFlatteningWrapper
|
||||
private static final Reflection.FieldAccessor<Integer> spawnLivingType = Reflection.getField(ProtocolWrapper.spawnLivingPacket, int.class, 1);
|
||||
private static final Map<EntityType, Object> types = new HashMap<>();
|
||||
static {
|
||||
types.put(EntityType.PRIMED_TNT, 50);
|
||||
types.put(TrickyTrialsWrapper.impl.getTntEntityType(), 50);
|
||||
types.put(EntityType.ARMOR_STAND, 30);
|
||||
types.put(EntityType.ARROW, 60);
|
||||
types.put(EntityType.FIREBALL, 63);
|
||||
|
||||
+6
-16
@@ -17,29 +17,19 @@
|
||||
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
package de.steamwar.inventory;
|
||||
package de.steamwar.core;
|
||||
|
||||
import org.bukkit.enchantments.Enchantment;
|
||||
import org.bukkit.inventory.ItemFlag;
|
||||
import org.bukkit.entity.EntityType;
|
||||
|
||||
import java.util.Collection;
|
||||
import java.util.EnumSet;
|
||||
|
||||
public class SWItem8 implements SWItem.ISWItem {
|
||||
public class TrickyTrialsWrapper8 implements TrickyTrialsWrapper {
|
||||
@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
|
||||
);
|
||||
public EntityType getTntEntityType() {
|
||||
return EntityType.PRIMED_TNT;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Enchantment getDurabilityEnchantment() {
|
||||
public Enchantment getUnbreakingEnchantment() {
|
||||
return Enchantment.DURABILITY;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,31 @@
|
||||
/*
|
||||
* 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.core;
|
||||
|
||||
import org.bukkit.enchantments.Enchantment;
|
||||
import org.bukkit.entity.EntityType;
|
||||
|
||||
public interface TrickyTrialsWrapper {
|
||||
TrickyTrialsWrapper impl = VersionDependent.getVersionImpl(Core.getInstance());
|
||||
|
||||
EntityType getTntEntityType();
|
||||
|
||||
Enchantment getUnbreakingEnchantment();
|
||||
}
|
||||
@@ -23,6 +23,7 @@ import com.google.gson.JsonArray;
|
||||
import com.google.gson.JsonObject;
|
||||
import de.steamwar.core.Core;
|
||||
import de.steamwar.core.FlatteningWrapper;
|
||||
import de.steamwar.core.TrickyTrialsWrapper;
|
||||
import de.steamwar.core.VersionDependent;
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.OfflinePlayer;
|
||||
@@ -33,12 +34,11 @@ import org.bukkit.inventory.meta.ItemMeta;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collection;
|
||||
import java.util.EnumSet;
|
||||
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;
|
||||
@@ -112,7 +112,7 @@ public class SWItem {
|
||||
|
||||
itemMeta.setDisplayName(name);
|
||||
if (lore != null && !lore.isEmpty()) itemMeta.setLore(lore);
|
||||
if (enchanted) itemMeta.addEnchant(impl.getDurabilityEnchantment() , 10, true);
|
||||
if (enchanted) itemMeta.addEnchant(TrickyTrialsWrapper.impl.getUnbreakingEnchantment(), 10, true);
|
||||
itemStack.setItemMeta(itemMeta);
|
||||
}
|
||||
callback = c;
|
||||
@@ -149,7 +149,7 @@ public class SWItem {
|
||||
|
||||
private void hideAttributes() {
|
||||
if (itemMeta == null) return;
|
||||
for (ItemFlag flag : impl.getHideFlags()) {
|
||||
for (ItemFlag flag : EnumSet.allOf(ItemFlag.class)) {
|
||||
itemMeta.addItemFlags(flag);
|
||||
}
|
||||
}
|
||||
@@ -194,16 +194,10 @@ public class SWItem {
|
||||
|
||||
public void setEnchanted(boolean enchanted) {
|
||||
if (enchanted){
|
||||
itemMeta.addEnchant(impl.getDurabilityEnchantment() , 10, true);
|
||||
itemMeta.addEnchant(TrickyTrialsWrapper.impl.getUnbreakingEnchantment() , 10, true);
|
||||
} else {
|
||||
itemMeta.removeEnchant(impl.getDurabilityEnchantment());
|
||||
itemMeta.removeEnchant(TrickyTrialsWrapper.impl.getUnbreakingEnchantment());
|
||||
}
|
||||
itemStack.setItemMeta(itemMeta);
|
||||
}
|
||||
|
||||
public interface ISWItem {
|
||||
Collection<ItemFlag> getHideFlags();
|
||||
|
||||
Enchantment getDurabilityEnchantment();
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user