fix-1
This commit is contained in:
parent
832e93a2ef
commit
4bd35b9292
|
@ -1,11 +1,11 @@
|
|||
package com.yaohun.enderdragonwars;
|
||||
|
||||
import com.yaohun.enderdragonwars.listener.RepairGiftGui;
|
||||
import com.yaohun.enderdragonwars.effect.types.*;
|
||||
import com.yaohun.enderdragonwars.game.Game;
|
||||
import com.yaohun.enderdragonwars.listener.GameListener;
|
||||
import com.yaohun.enderdragonwars.listener.LiveListener;
|
||||
import com.yaohun.enderdragonwars.listener.PlayerListener;
|
||||
import com.yaohun.enderdragonwars.listener.RepairGiftGui;
|
||||
import com.yaohun.enderdragonwars.manager.GameManager;
|
||||
import com.yaohun.enderdragonwars.manager.GiftEffectManager;
|
||||
import org.bukkit.Bukkit;
|
||||
|
|
|
@ -27,10 +27,22 @@ public class DirectionPoint extends Point {
|
|||
this.pitch = pitch;
|
||||
}
|
||||
|
||||
public static DirectionPoint of(Location location) {
|
||||
return new DirectionPoint(location.getX(), location.getY(), location.getZ(), location.getYaw(), location.getPitch());
|
||||
}
|
||||
|
||||
public static DirectionPoint deserialize(ConfigurationSection section) {
|
||||
return new DirectionPoint(section.getDouble("x"), section.getDouble("y"), section.getDouble("z"), (float) section.getDouble("yaw"), (float) section.getDouble("pitch"));
|
||||
}
|
||||
|
||||
public float getPitch() {
|
||||
return pitch;
|
||||
}
|
||||
|
||||
public void setPitch(float pitch) {
|
||||
this.pitch = pitch;
|
||||
}
|
||||
|
||||
public float getYaw() {
|
||||
return yaw;
|
||||
}
|
||||
|
@ -39,19 +51,11 @@ public class DirectionPoint extends Point {
|
|||
this.yaw = yaw;
|
||||
}
|
||||
|
||||
public void setPitch(float pitch) {
|
||||
this.pitch = pitch;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Location toLocation(World world) {
|
||||
return new Location(world, getX(), getY(), getZ(), yaw, pitch);
|
||||
}
|
||||
|
||||
public static DirectionPoint of(Location location) {
|
||||
return new DirectionPoint(location.getX(), location.getY(), location.getZ(), location.getYaw(), location.getPitch());
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return "DirectionPoint{" +
|
||||
|
@ -77,8 +81,4 @@ public class DirectionPoint extends Point {
|
|||
return Objects.hash(super.hashCode(), yaw, pitch);
|
||||
}
|
||||
|
||||
public static DirectionPoint deserialize(ConfigurationSection section) {
|
||||
return new DirectionPoint(section.getDouble("x"), section.getDouble("y"), section.getDouble("z"), (float) section.getDouble("yaw"), (float) section.getDouble("pitch"));
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -24,6 +24,14 @@ public class Point {
|
|||
this.z = z;
|
||||
}
|
||||
|
||||
public static Point of(Location location) {
|
||||
return new Point(location.getX(), location.getY(), location.getZ());
|
||||
}
|
||||
|
||||
public static Point deserialize(ConfigurationSection section) {
|
||||
return new Point(section.getDouble("x"), section.getDouble("y"), section.getDouble("z"));
|
||||
}
|
||||
|
||||
public int getBlockX() {
|
||||
return (int) Math.floor(x);
|
||||
}
|
||||
|
@ -40,22 +48,22 @@ public class Point {
|
|||
return x;
|
||||
}
|
||||
|
||||
public double getY() {
|
||||
return y;
|
||||
}
|
||||
|
||||
public double getZ() {
|
||||
return z;
|
||||
}
|
||||
|
||||
public void setX(double x) {
|
||||
this.x = x;
|
||||
}
|
||||
|
||||
public double getY() {
|
||||
return y;
|
||||
}
|
||||
|
||||
public void setY(double y) {
|
||||
this.y = y;
|
||||
}
|
||||
|
||||
public double getZ() {
|
||||
return z;
|
||||
}
|
||||
|
||||
public void setZ(double z) {
|
||||
this.z = z;
|
||||
}
|
||||
|
@ -68,14 +76,6 @@ public class Point {
|
|||
return new Location(world, x, y, z, 0, 0);
|
||||
}
|
||||
|
||||
public static Point of(Location location) {
|
||||
return new Point(location.getX(), location.getY(), location.getZ());
|
||||
}
|
||||
|
||||
public static Point deserialize(ConfigurationSection section) {
|
||||
return new Point(section.getDouble("x"), section.getDouble("y"), section.getDouble("z"));
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return "Point{" +
|
||||
|
|
|
@ -17,6 +17,13 @@ public class Region {
|
|||
this.max = max;
|
||||
}
|
||||
|
||||
public static Region deserialize(ConfigurationSection section) {
|
||||
World world1 = Bukkit.getWorld(section.getString("world"));
|
||||
Point point1 = Point.deserialize(section.getConfigurationSection("min"));
|
||||
Point point2 = Point.deserialize(section.getConfigurationSection("max"));
|
||||
return new Region(world1, point1, point2);
|
||||
}
|
||||
|
||||
public World getWorld() {
|
||||
return world;
|
||||
}
|
||||
|
@ -29,13 +36,6 @@ public class Region {
|
|||
return max;
|
||||
}
|
||||
|
||||
public static Region deserialize(ConfigurationSection section) {
|
||||
World world1 = Bukkit.getWorld(section.getString("world"));
|
||||
Point point1 = Point.deserialize(section.getConfigurationSection("min"));
|
||||
Point point2 = Point.deserialize(section.getConfigurationSection("max"));
|
||||
return new Region(world1, point1, point2);
|
||||
}
|
||||
|
||||
public boolean isInRegion(Location location) {
|
||||
if (!location.getWorld().getName().equalsIgnoreCase(world.getName())) {
|
||||
return false;
|
||||
|
|
|
@ -23,6 +23,7 @@ public class AddMaxHealthEffect extends GiftEffect {
|
|||
Player player = game.getPlayer();
|
||||
new BukkitRunnable() {
|
||||
private int count = 0;
|
||||
|
||||
@Override
|
||||
public void run() {
|
||||
if (count >= 50) {
|
||||
|
|
|
@ -34,6 +34,7 @@ public class BlackHoleEffect extends GiftEffect {
|
|||
Location location = game.getPlayer().getLocation().add(0, 2, 0);
|
||||
new BukkitRunnable() {
|
||||
private int i = 0;
|
||||
|
||||
@Override
|
||||
public void run() {
|
||||
if (i >= seconds * 2) {
|
||||
|
@ -57,6 +58,7 @@ public class BlackHoleEffect extends GiftEffect {
|
|||
}.runTaskTimer(Main.plugin, 0L, 10L);
|
||||
new BukkitRunnable() {
|
||||
private Set<UUID> uuids = new HashSet<>();
|
||||
|
||||
@Override
|
||||
public void run() {
|
||||
if (stop) {
|
||||
|
@ -103,6 +105,7 @@ public class BlackHoleEffect extends GiftEffect {
|
|||
}.runTaskTimer(Main.plugin, 0L, 5L);
|
||||
new BukkitRunnable() {
|
||||
private Set<UUID> uuids = new HashSet<>();
|
||||
|
||||
@Override
|
||||
public void run() {
|
||||
if (stop) {
|
||||
|
|
|
@ -34,10 +34,46 @@ public class BomBomEffect extends GiftEffect {
|
|||
private static final ItemStack ITEM_6;
|
||||
private static final ItemStack ITEM_7;
|
||||
|
||||
private List<FallingBlock> fallingBlocks = new ArrayList<>();
|
||||
private BossBar bossBar;
|
||||
static {
|
||||
ITEM_1 = new ItemStack(Material.TNT);
|
||||
ITEM_2 = new ItemStack(Material.LEATHER_CHESTPLATE);
|
||||
ITEM_3 = new ItemStack(Material.LEATHER_LEGGINGS);
|
||||
ITEM_4 = new ItemStack(Material.LEATHER_BOOTS);
|
||||
ITEM_5 = new ItemStack(Material.LEATHER_CHESTPLATE);
|
||||
ITEM_6 = new ItemStack(Material.LEATHER_LEGGINGS);
|
||||
ITEM_7 = new ItemStack(Material.LEATHER_BOOTS);
|
||||
Color color1 = Color.fromRGB(214, 41, 0);
|
||||
Color color2 = Color.fromRGB(255, 133, 102);
|
||||
ItemMeta itemMeta2 = ITEM_2.getItemMeta();
|
||||
ColorableArmorMeta colorableArmorMeta2 = (ColorableArmorMeta) itemMeta2;
|
||||
colorableArmorMeta2.setColor(color1);
|
||||
ITEM_2.setItemMeta(colorableArmorMeta2);
|
||||
ItemMeta itemMeta3 = ITEM_3.getItemMeta();
|
||||
ColorableArmorMeta colorableArmorMeta3 = (ColorableArmorMeta) itemMeta3;
|
||||
colorableArmorMeta3.setColor(color1);
|
||||
ITEM_3.setItemMeta(colorableArmorMeta3);
|
||||
ItemMeta itemMeta4 = ITEM_4.getItemMeta();
|
||||
ColorableArmorMeta colorableArmorMeta4 = (ColorableArmorMeta) itemMeta4;
|
||||
colorableArmorMeta4.setColor(color1);
|
||||
ITEM_4.setItemMeta(colorableArmorMeta4);
|
||||
ItemMeta itemMeta5 = ITEM_5.getItemMeta();
|
||||
ColorableArmorMeta colorableArmorMeta5 = (ColorableArmorMeta) itemMeta5;
|
||||
colorableArmorMeta5.setColor(color2);
|
||||
ITEM_5.setItemMeta(colorableArmorMeta5);
|
||||
ItemMeta itemMeta6 = ITEM_6.getItemMeta();
|
||||
ColorableArmorMeta colorableArmorMeta6 = (ColorableArmorMeta) itemMeta6;
|
||||
colorableArmorMeta6.setColor(color2);
|
||||
ITEM_6.setItemMeta(colorableArmorMeta6);
|
||||
ItemMeta itemMeta7 = ITEM_7.getItemMeta();
|
||||
ColorableArmorMeta colorableArmorMeta7 = (ColorableArmorMeta) itemMeta7;
|
||||
colorableArmorMeta7.setColor(color2);
|
||||
ITEM_7.setItemMeta(colorableArmorMeta7);
|
||||
|
||||
}
|
||||
|
||||
protected boolean stop = false;
|
||||
private List<FallingBlock> fallingBlocks = new ArrayList<>();
|
||||
private BossBar bossBar;
|
||||
|
||||
public BomBomEffect(String audience) {
|
||||
super(audience);
|
||||
|
@ -68,6 +104,7 @@ public class BomBomEffect extends GiftEffect {
|
|||
});
|
||||
new BukkitRunnable() {
|
||||
private int count = 0;
|
||||
|
||||
@Override
|
||||
public void run() {
|
||||
Location loc = armorStand.getLocation().clone().add(0, 8, 0);
|
||||
|
@ -119,6 +156,7 @@ public class BomBomEffect extends GiftEffect {
|
|||
}.runTaskTimer(Main.plugin, 0L, 15L);
|
||||
new BukkitRunnable() {
|
||||
private int count = 0;
|
||||
|
||||
@Override
|
||||
public void run() {
|
||||
if (stop) {
|
||||
|
@ -136,6 +174,7 @@ public class BomBomEffect extends GiftEffect {
|
|||
}.runTaskTimer(Main.plugin, 0L, 5L);
|
||||
new BukkitRunnable() {
|
||||
private int count = 0;
|
||||
|
||||
@Override
|
||||
public void run() {
|
||||
if (stop) {
|
||||
|
@ -175,41 +214,4 @@ public class BomBomEffect extends GiftEffect {
|
|||
}.runTaskTimer(Main.plugin, 0L, 1L);
|
||||
}
|
||||
|
||||
static {
|
||||
ITEM_1 = new ItemStack(Material.TNT);
|
||||
ITEM_2 = new ItemStack(Material.LEATHER_CHESTPLATE);
|
||||
ITEM_3 = new ItemStack(Material.LEATHER_LEGGINGS);
|
||||
ITEM_4 = new ItemStack(Material.LEATHER_BOOTS);
|
||||
ITEM_5 = new ItemStack(Material.LEATHER_CHESTPLATE);
|
||||
ITEM_6 = new ItemStack(Material.LEATHER_LEGGINGS);
|
||||
ITEM_7 = new ItemStack(Material.LEATHER_BOOTS);
|
||||
Color color1 = Color.fromRGB(214, 41, 0);
|
||||
Color color2 = Color.fromRGB(255, 133, 102);
|
||||
ItemMeta itemMeta2 = ITEM_2.getItemMeta();
|
||||
ColorableArmorMeta colorableArmorMeta2 = (ColorableArmorMeta) itemMeta2;
|
||||
colorableArmorMeta2.setColor(color1);
|
||||
ITEM_2.setItemMeta(colorableArmorMeta2);
|
||||
ItemMeta itemMeta3 = ITEM_3.getItemMeta();
|
||||
ColorableArmorMeta colorableArmorMeta3 = (ColorableArmorMeta) itemMeta3;
|
||||
colorableArmorMeta3.setColor(color1);
|
||||
ITEM_3.setItemMeta(colorableArmorMeta3);
|
||||
ItemMeta itemMeta4 = ITEM_4.getItemMeta();
|
||||
ColorableArmorMeta colorableArmorMeta4 = (ColorableArmorMeta) itemMeta4;
|
||||
colorableArmorMeta4.setColor(color1);
|
||||
ITEM_4.setItemMeta(colorableArmorMeta4);
|
||||
ItemMeta itemMeta5 = ITEM_5.getItemMeta();
|
||||
ColorableArmorMeta colorableArmorMeta5 = (ColorableArmorMeta) itemMeta5;
|
||||
colorableArmorMeta5.setColor(color2);
|
||||
ITEM_5.setItemMeta(colorableArmorMeta5);
|
||||
ItemMeta itemMeta6 = ITEM_6.getItemMeta();
|
||||
ColorableArmorMeta colorableArmorMeta6 = (ColorableArmorMeta) itemMeta6;
|
||||
colorableArmorMeta6.setColor(color2);
|
||||
ITEM_6.setItemMeta(colorableArmorMeta6);
|
||||
ItemMeta itemMeta7 = ITEM_7.getItemMeta();
|
||||
ColorableArmorMeta colorableArmorMeta7 = (ColorableArmorMeta) itemMeta7;
|
||||
colorableArmorMeta7.setColor(color2);
|
||||
ITEM_7.setItemMeta(colorableArmorMeta7);
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -33,6 +33,7 @@ public class ClearInventoryEffect extends GiftEffect {
|
|||
new BukkitRunnable() {
|
||||
private int totalCount = Math.max(15, getUseableItemCount(player).size());
|
||||
private int count = 0;
|
||||
|
||||
@Override
|
||||
public void run() {
|
||||
if (count > totalCount) {
|
||||
|
|
|
@ -17,6 +17,7 @@ public class FiveLightningEffect extends GiftEffect {
|
|||
Player player = game.getPlayer();
|
||||
new BukkitRunnable() {
|
||||
private int count = 0;
|
||||
|
||||
@Override
|
||||
public void run() {
|
||||
if (count > 5) {
|
||||
|
|
|
@ -4,11 +4,7 @@ import com.yaohun.enderdragonwars.effect.GiftEffect;
|
|||
import com.yaohun.enderdragonwars.game.Game;
|
||||
import com.yaohun.enderdragonwars.util.ItemStackBuilder;
|
||||
import com.yaohun.enderdragonwars.util.RandomUtil;
|
||||
import net.kyori.adventure.text.Component;
|
||||
import org.bukkit.Location;
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.Particle;
|
||||
import org.bukkit.Sound;
|
||||
import org.bukkit.*;
|
||||
import org.bukkit.block.Block;
|
||||
import org.bukkit.enchantments.Enchantment;
|
||||
import org.bukkit.entity.Item;
|
||||
|
@ -22,13 +18,56 @@ public class LuckyBlockEffect extends GiftEffect {
|
|||
|
||||
private static List<ItemStack> itemStacks = new ArrayList<>();
|
||||
|
||||
public LuckyBlockEffect(String audience) {
|
||||
super(audience);
|
||||
static {
|
||||
itemStacks.add(new ItemStackBuilder(Material.ENDER_PEARL).setAmount(16).build());
|
||||
itemStacks.add(new ItemStackBuilder(Material.ENDER_EYE).setAmount(16).build());
|
||||
itemStacks.add(new ItemStackBuilder(Material.DIAMOND_BLOCK).setAmount(16).build());
|
||||
itemStacks.add(new ItemStackBuilder(Material.DIAMOND).setAmount(64).build());
|
||||
|
||||
itemStacks.add(new ItemStackBuilder(Material.GOLDEN_APPLE).setAmount(16).build());
|
||||
itemStacks.add(new ItemStackBuilder(Material.ENCHANTED_GOLDEN_APPLE).setAmount(4).build());
|
||||
|
||||
itemStacks.add(new ItemStackBuilder(Material.CARROT).setAmount(64).build());
|
||||
itemStacks.add(new ItemStackBuilder(Material.GOLDEN_CARROT).setAmount(64).build());
|
||||
itemStacks.add(new ItemStackBuilder(Material.BAKED_POTATO).setAmount(64).build());
|
||||
itemStacks.add(new ItemStackBuilder(Material.COOKED_BEEF).setAmount(64).build());
|
||||
itemStacks.add(new ItemStackBuilder(Material.COOKED_CHICKEN).setAmount(64).build());
|
||||
itemStacks.add(new ItemStackBuilder(Material.COOKED_COD).setAmount(64).build());
|
||||
itemStacks.add(new ItemStackBuilder(Material.COOKED_MUTTON).setAmount(64).build());
|
||||
itemStacks.add(new ItemStackBuilder(Material.COOKED_SALMON).setAmount(64).build());
|
||||
itemStacks.add(new ItemStackBuilder(Material.COOKED_PORKCHOP).setAmount(64).build());
|
||||
|
||||
Tag.LOGS.getValues().forEach(material -> itemStacks.add(new ItemStackBuilder(material).setAmount(64).build()));
|
||||
|
||||
Tag.ITEMS_AXES.getValues().forEach(material -> itemStacks.add(new ItemStackBuilder(material).build()));
|
||||
Tag.ITEMS_PICKAXES.getValues().forEach(material -> itemStacks.add(new ItemStackBuilder(material).build()));
|
||||
Tag.ITEMS_SHOVELS.getValues().forEach(material -> itemStacks.add(new ItemStackBuilder(material).build()));
|
||||
|
||||
itemStacks.add(new ItemStackBuilder(Material.DIAMOND_HELMET).build());
|
||||
itemStacks.add(new ItemStackBuilder(Material.DIAMOND_CHESTPLATE).build());
|
||||
itemStacks.add(new ItemStackBuilder(Material.DIAMOND_LEGGINGS).build());
|
||||
itemStacks.add(new ItemStackBuilder(Material.DIAMOND_BOOTS).build());
|
||||
itemStacks.add(new ItemStackBuilder(Material.DIAMOND_SWORD).build());
|
||||
itemStacks.add(new ItemStackBuilder(Material.DIAMOND_HELMET).addEnchant(Enchantment.PROTECTION, 1).build());
|
||||
itemStacks.add(new ItemStackBuilder(Material.DIAMOND_CHESTPLATE).addEnchant(Enchantment.PROTECTION, 1).build());
|
||||
itemStacks.add(new ItemStackBuilder(Material.DIAMOND_LEGGINGS).addEnchant(Enchantment.PROTECTION, 1).build());
|
||||
itemStacks.add(new ItemStackBuilder(Material.DIAMOND_BOOTS).addEnchant(Enchantment.PROTECTION, 1).build());
|
||||
itemStacks.add(new ItemStackBuilder(Material.DIAMOND_SWORD).addEnchant(Enchantment.SHARPNESS, 1).build());
|
||||
itemStacks.add(new ItemStackBuilder(Material.NETHERITE_HELMET).build());
|
||||
itemStacks.add(new ItemStackBuilder(Material.NETHERITE_CHESTPLATE).build());
|
||||
itemStacks.add(new ItemStackBuilder(Material.NETHERITE_LEGGINGS).build());
|
||||
itemStacks.add(new ItemStackBuilder(Material.NETHERITE_BOOTS).build());
|
||||
itemStacks.add(new ItemStackBuilder(Material.NETHERITE_SWORD).build());
|
||||
itemStacks.add(new ItemStackBuilder(Material.NETHERITE_HELMET).addEnchant(Enchantment.PROTECTION, 1).build());
|
||||
itemStacks.add(new ItemStackBuilder(Material.NETHERITE_CHESTPLATE).addEnchant(Enchantment.PROTECTION, 1).build());
|
||||
itemStacks.add(new ItemStackBuilder(Material.NETHERITE_LEGGINGS).addEnchant(Enchantment.PROTECTION, 1).build());
|
||||
itemStacks.add(new ItemStackBuilder(Material.NETHERITE_BOOTS).addEnchant(Enchantment.PROTECTION, 1).build());
|
||||
itemStacks.add(new ItemStackBuilder(Material.NETHERITE_SWORD).addEnchant(Enchantment.SHARPNESS, 1).build());
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void apply(Game game) {
|
||||
game.getPlayer().getInventory().addItem(new ItemStackBuilder(Material.SPONGE).setDisplayName("§6§l幸运方块").build());
|
||||
public LuckyBlockEffect(String audience) {
|
||||
super(audience);
|
||||
}
|
||||
|
||||
public static void openLuckyBlock(Player player, Block block) {
|
||||
|
@ -45,11 +84,9 @@ public class LuckyBlockEffect extends GiftEffect {
|
|||
item.setGlowing(true);
|
||||
}
|
||||
|
||||
static {
|
||||
itemStacks.add(new ItemStackBuilder(Material.IRON_SWORD).addEnchant(Enchantment.SHARPNESS, 3).build());
|
||||
itemStacks.add(new ItemStackBuilder(Material.IRON_SWORD).addEnchant(Enchantment.SHARPNESS, 3).setDisplayName("§6§l幸运铁剑").build());
|
||||
itemStacks.add(new ItemStackBuilder(Material.GOLDEN_SWORD).addEnchant(Enchantment.SHARPNESS, 5).addEnchant(Enchantment.FIRE_ASPECT, 2).setDisplayName("§6§l幸运金剑").build());
|
||||
itemStacks.add(new ItemStackBuilder(Material.DIAMOND_CHESTPLATE).addEnchant(Enchantment.PROTECTION, 3).setDisplayName("§6§l幸运钻石胸甲").build());
|
||||
@Override
|
||||
public void apply(Game game) {
|
||||
game.getPlayer().getInventory().addItem(new ItemStackBuilder(Material.SPONGE).setDisplayName("§6§l幸运方块").build());
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -1,15 +1,12 @@
|
|||
package com.yaohun.enderdragonwars.effect.types;
|
||||
|
||||
import com.sk89q.worldedit.world.entity.EntityType;
|
||||
import com.yaohun.enderdragonwars.Main;
|
||||
import com.yaohun.enderdragonwars.effect.GiftEffect;
|
||||
import com.yaohun.enderdragonwars.game.Game;
|
||||
import com.yaohun.enderdragonwars.manager.GiftEffectManager;
|
||||
import net.kyori.adventure.sound.Sound;
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.Location;
|
||||
import org.bukkit.Sound;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.entity.TNTPrimed;
|
||||
import org.bukkit.scheduler.BukkitRunnable;
|
||||
import org.bukkit.scheduler.BukkitTask;
|
||||
|
||||
|
@ -50,6 +47,7 @@ public class RandomBox extends GiftEffect {
|
|||
String eventName = stringList.get(random.nextInt(stringList.size()));
|
||||
BukkitTask task = new BukkitRunnable() {
|
||||
private int i = 0;
|
||||
|
||||
@Override
|
||||
public void run() {
|
||||
if (i >= 12) {
|
||||
|
|
|
@ -1,5 +1,6 @@
|
|||
package com.yaohun.enderdragonwars.effect.types;
|
||||
|
||||
import com.yaohun.enderdragonwars.Main;
|
||||
import com.yaohun.enderdragonwars.data.Region;
|
||||
import com.yaohun.enderdragonwars.effect.GiftEffect;
|
||||
import com.yaohun.enderdragonwars.game.Game;
|
||||
|
@ -30,6 +31,7 @@ public class SpawnEnderPortalEffect extends GiftEffect {
|
|||
int platformWidth = 3;
|
||||
int platformLength = 7;
|
||||
int levelAmount = 15;
|
||||
Main.game.takeLiveTime(60 * 6);
|
||||
World world = game.getWorld();
|
||||
Player player = game.getPlayer();
|
||||
Location location = player.getLocation();
|
||||
|
|
|
@ -4,7 +4,6 @@ import com.yaohun.enderdragonwars.effect.GiftEffect;
|
|||
import com.yaohun.enderdragonwars.game.Game;
|
||||
import com.yaohun.enderdragonwars.util.RandomUtil;
|
||||
import org.bukkit.entity.Creeper;
|
||||
import org.bukkit.entity.Entity;
|
||||
import org.bukkit.entity.EntityType;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.entity.Zombie;
|
||||
|
|
|
@ -17,11 +17,13 @@ public class ToHeavenEffect extends GiftEffect {
|
|||
public void apply(Game game) {
|
||||
Player player = game.getPlayer();
|
||||
double radius = 1.5D;
|
||||
Main.game.takeLiveTime(60);
|
||||
new BukkitRunnable() {
|
||||
private int count = 0;
|
||||
private double angle = 0;
|
||||
private double speed = 1.25;
|
||||
private int skyTnt = 0;
|
||||
|
||||
@Override
|
||||
public void run() {
|
||||
if (count >= 200) {
|
||||
|
|
|
@ -1,19 +1,16 @@
|
|||
package com.yaohun.enderdragonwars.effect.types;
|
||||
|
||||
import com.sk89q.worldedit.world.entity.EntityType;
|
||||
import com.yaohun.enderdragonwars.Main;
|
||||
import com.yaohun.enderdragonwars.effect.GiftEffect;
|
||||
import com.yaohun.enderdragonwars.game.Game;
|
||||
import com.yaohun.enderdragonwars.util.RandomUtil;
|
||||
import net.kyori.adventure.sound.Sound;
|
||||
import org.bukkit.Effect;
|
||||
import org.bukkit.Location;
|
||||
import org.bukkit.entity.Creeper;
|
||||
import org.bukkit.Sound;
|
||||
import org.bukkit.entity.EntityType;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.entity.TNTPrimed;
|
||||
import org.bukkit.entity.Zombie;
|
||||
import org.bukkit.scheduler.BukkitRunnable;
|
||||
import org.bukkit.scheduler.BukkitTask;
|
||||
import org.bukkit.util.Vector;
|
||||
|
||||
public class WuHuJump extends GiftEffect {
|
||||
|
||||
|
@ -29,11 +26,14 @@ public class WuHuJump extends GiftEffect {
|
|||
player.playSound(player.getLocation(), Sound.ENTITY_BAT_TAKEOFF, 1.0F, 1.0F);
|
||||
BukkitTask task = new BukkitRunnable() {
|
||||
private int i = 0;
|
||||
|
||||
@Override
|
||||
public void run() {
|
||||
if(i >= 4){cancel();}
|
||||
if (i >= 4) {
|
||||
cancel();
|
||||
}
|
||||
Location location = player.getLocation();
|
||||
TNTPrimed tntPrimed = (TNTPrimed) location.getWorld().spawnEntity(location.clone().add(0,-0.5,0), EntityType.PRIMED_TNT);
|
||||
TNTPrimed tntPrimed = (TNTPrimed) location.getWorld().spawnEntity(location.clone().add(0, -0.5, 0), EntityType.TNT);
|
||||
tntPrimed.setFuseTicks(5);
|
||||
tntPrimed.setYield(0.0F);
|
||||
location.getWorld().playSound(location, Sound.ENTITY_CREEPER_PRIMED, 1.0f, 1.0f);
|
||||
|
|
|
@ -26,6 +26,8 @@ public class Game {
|
|||
private boolean startd;
|
||||
private long liveTime;
|
||||
private List<BukkitTask> tasks = new ArrayList<>();
|
||||
private int tragetCueI = 0;
|
||||
|
||||
public Game() {
|
||||
bossBar1 = Bukkit.createBossBar("下播时间", BarColor.WHITE, BarStyle.SEGMENTED_20);
|
||||
bossBar2 = Bukkit.createBossBar("挑战目标", BarColor.WHITE, BarStyle.SOLID);
|
||||
|
@ -55,7 +57,6 @@ public class Game {
|
|||
BossBarUtil.setBarColor(bossBar1, d);
|
||||
}
|
||||
|
||||
private int tragetCueI = 0;
|
||||
public void targetCueBossBar() {
|
||||
tragetCueI--;
|
||||
if (tragetCueI <= 0) {
|
||||
|
@ -78,7 +79,9 @@ public class Game {
|
|||
}
|
||||
|
||||
public void startGame(Player player) {
|
||||
if(startd){return;}
|
||||
if (startd) {
|
||||
return;
|
||||
}
|
||||
this.player = player;
|
||||
this.startd = true;
|
||||
this.world = player.getWorld();
|
||||
|
@ -101,6 +104,7 @@ public class Game {
|
|||
public World getWorld() {
|
||||
return world;
|
||||
}
|
||||
|
||||
public void updataPlayerData(Player player) {
|
||||
player.setFoodLevel(20);
|
||||
player.setGameMode(GameMode.SURVIVAL);
|
||||
|
@ -122,9 +126,11 @@ public class Game {
|
|||
public void addTasks(BukkitTask task) {
|
||||
this.tasks.add(task);
|
||||
}
|
||||
|
||||
public long getLiveTime() {
|
||||
return liveTime;
|
||||
}
|
||||
|
||||
public void setLiveTime(long liveTime) {
|
||||
this.liveTime = liveTime;
|
||||
}
|
||||
|
|
|
@ -65,6 +65,7 @@ public class GameListener implements Listener {
|
|||
Player p = e.getEntity();
|
||||
new BukkitRunnable() {
|
||||
private int i = 0;
|
||||
|
||||
public void run() {
|
||||
if (i == 1) {
|
||||
p.spigot().respawn();
|
||||
|
|
|
@ -1,9 +1,7 @@
|
|||
package com.yaohun.enderdragonwars.listener;
|
||||
|
||||
import com.yaohun.enderdragonwars.effect.types.LuckyBlockEffect;
|
||||
import org.bukkit.Location;
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.Particle;
|
||||
import org.bukkit.block.Block;
|
||||
import org.bukkit.entity.Entity;
|
||||
import org.bukkit.entity.IronGolem;
|
||||
|
@ -13,7 +11,6 @@ import org.bukkit.event.Listener;
|
|||
import org.bukkit.event.block.BlockBreakEvent;
|
||||
import org.bukkit.event.entity.EntityDamageEvent;
|
||||
import org.bukkit.event.player.PlayerInteractEntityEvent;
|
||||
import org.bukkit.event.player.PlayerInteractEvent;
|
||||
import org.bukkit.inventory.ItemStack;
|
||||
import org.bukkit.inventory.PlayerInventory;
|
||||
|
||||
|
|
|
@ -2,7 +2,6 @@ package com.yaohun.enderdragonwars.listener;
|
|||
|
||||
import com.yaohun.enderdragonwars.Main;
|
||||
import com.yaohun.enderdragonwars.data.GiftData;
|
||||
import com.yaohun.enderdragonwars.liveevent.GiftEventHandler;
|
||||
import com.yaohun.enderdragonwars.manager.GiftEffectManager;
|
||||
import com.yaohun.enderdragonwars.util.GameUtil;
|
||||
import com.yaohun.enderdragonwars.util.RandomUtil;
|
||||
|
@ -27,63 +26,6 @@ public class RepairGiftGui implements Listener {
|
|||
|
||||
public static String invTitle = "我的世界整蛊 - 礼物触发管理";
|
||||
|
||||
@EventHandler
|
||||
public void onClick(InventoryClickEvent e){
|
||||
int rawSlot = e.getRawSlot();
|
||||
Player zhubo = (Player) e.getWhoClicked();
|
||||
Inventory inv = e.getInventory();
|
||||
if(e.getView().getTitle().equalsIgnoreCase(invTitle)){
|
||||
if(rawSlot >= 0) {
|
||||
e.setCancelled(true);
|
||||
zhubo.closeInventory();
|
||||
ItemStack stack = e.getCurrentItem();
|
||||
if (stack != null && stack.getType() != Material.AIR) {
|
||||
NBTItem nbti = new NBTItem(stack);
|
||||
if (nbti.hasKey("giftName")) {
|
||||
String giftName = nbti.getString("giftName");
|
||||
String userName = "抖音"+ RandomUtil.getRandomInt(1,100);
|
||||
int amount = 1;
|
||||
if (e.getClick() == ClickType.RIGHT) {
|
||||
amount = 10;
|
||||
} else if (e.getClick() == ClickType.SHIFT_LEFT) {
|
||||
amount = 66;
|
||||
}else if (e.getClick() == ClickType.SHIFT_RIGHT) {
|
||||
amount = 188;
|
||||
}
|
||||
if(Main.gameManager.getGiftData(giftName) == null){
|
||||
zhubo.sendTitle("§r", "§c未设置效果",10, 30, 10);
|
||||
return;
|
||||
}
|
||||
GiftData giftData = Main.gameManager.getGiftData(giftName);
|
||||
String hide_userName = GameUtil.hideName(userName);
|
||||
String eventName = giftData.getEvent();
|
||||
String eventName_Show = eventName;
|
||||
if(amount >= 2) {
|
||||
String title = "§c" + eventName_Show + " x" + amount;
|
||||
String subtitle = "§9" + hide_userName;
|
||||
zhubo.sendTitle(title, subtitle,0, 30, 10);
|
||||
}else{
|
||||
String title = "§c" + eventName_Show;
|
||||
String subtitle = "§9" + hide_userName;
|
||||
zhubo.sendTitle(title, subtitle,0, 30, 10);
|
||||
}
|
||||
if (amount <= 1) {
|
||||
giftData.playSoundEvent();
|
||||
GiftEffectManager.addGiftEffect(hide_userName, eventName);
|
||||
} else {
|
||||
for (int i = 0; i < amount; i++) {
|
||||
Bukkit.getScheduler().runTaskLater(Main.plugin, () -> {
|
||||
giftData.playSoundEvent();
|
||||
GiftEffectManager.addGiftEffect(hide_userName, eventName);
|
||||
}, (long) i * 5);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public static void OpenGui(Player p) {
|
||||
Inventory inv = Bukkit.createInventory(null, 27, invTitle);
|
||||
HashMap<String, ItemStack> hashMap = new HashMap<>();
|
||||
|
@ -183,4 +125,61 @@ public class RepairGiftGui implements Listener {
|
|||
item = nbti.getItem();
|
||||
return item;
|
||||
}
|
||||
|
||||
@EventHandler
|
||||
public void onClick(InventoryClickEvent e) {
|
||||
int rawSlot = e.getRawSlot();
|
||||
Player zhubo = (Player) e.getWhoClicked();
|
||||
Inventory inv = e.getInventory();
|
||||
if (e.getView().getTitle().equalsIgnoreCase(invTitle)) {
|
||||
if (rawSlot >= 0) {
|
||||
e.setCancelled(true);
|
||||
zhubo.closeInventory();
|
||||
ItemStack stack = e.getCurrentItem();
|
||||
if (stack != null && stack.getType() != Material.AIR) {
|
||||
NBTItem nbti = new NBTItem(stack);
|
||||
if (nbti.hasKey("giftName")) {
|
||||
String giftName = nbti.getString("giftName");
|
||||
String userName = "抖音" + RandomUtil.getRandomInt(1, 100);
|
||||
int amount = 1;
|
||||
if (e.getClick() == ClickType.RIGHT) {
|
||||
amount = 10;
|
||||
} else if (e.getClick() == ClickType.SHIFT_LEFT) {
|
||||
amount = 66;
|
||||
} else if (e.getClick() == ClickType.SHIFT_RIGHT) {
|
||||
amount = 188;
|
||||
}
|
||||
if (Main.gameManager.getGiftData(giftName) == null) {
|
||||
zhubo.sendTitle("§r", "§c未设置效果", 10, 30, 10);
|
||||
return;
|
||||
}
|
||||
GiftData giftData = Main.gameManager.getGiftData(giftName);
|
||||
String hide_userName = GameUtil.hideName(userName);
|
||||
String eventName = giftData.getEvent();
|
||||
String eventName_Show = eventName;
|
||||
if (amount >= 2) {
|
||||
String title = "§c" + eventName_Show + " x" + amount;
|
||||
String subtitle = "§9" + hide_userName;
|
||||
zhubo.sendTitle(title, subtitle, 0, 30, 10);
|
||||
} else {
|
||||
String title = "§c" + eventName_Show;
|
||||
String subtitle = "§9" + hide_userName;
|
||||
zhubo.sendTitle(title, subtitle, 0, 30, 10);
|
||||
}
|
||||
if (amount <= 1) {
|
||||
giftData.playSoundEvent();
|
||||
GiftEffectManager.addGiftEffect(hide_userName, eventName);
|
||||
} else {
|
||||
for (int i = 0; i < amount; i++) {
|
||||
Bukkit.getScheduler().runTaskLater(Main.plugin, () -> {
|
||||
giftData.playSoundEvent();
|
||||
GiftEffectManager.addGiftEffect(hide_userName, eventName);
|
||||
}, (long) i * 5);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -62,13 +62,16 @@ public class GameManager {
|
|||
public String getDianzan_event() {
|
||||
return this.eventName;
|
||||
}
|
||||
|
||||
public int getDianzan_amount() {
|
||||
return dianzan;
|
||||
}
|
||||
public void addDianzan_amount(int add_amount){
|
||||
setDianzan_amount(getDianzan_amount()+add_amount);
|
||||
}
|
||||
|
||||
public void setDianzan_amount(int dianzan_amount) {
|
||||
this.dianzan = dianzan_amount;
|
||||
}
|
||||
|
||||
public void addDianzan_amount(int add_amount) {
|
||||
setDianzan_amount(getDianzan_amount() + add_amount);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -32,6 +32,7 @@ public class BossBarUtil {
|
|||
bossBar.setColor(BarColor.GREEN);
|
||||
}
|
||||
}
|
||||
|
||||
public static void setBarProgress(BossBar bossBar, double percent) {
|
||||
if (percent <= 0) {
|
||||
percent = 0;
|
||||
|
|
|
@ -11,11 +11,11 @@ import org.bukkit.block.data.type.EndPortalFrame;
|
|||
import org.bukkit.scheduler.BukkitRunnable;
|
||||
import org.bukkit.util.Vector;
|
||||
|
||||
import java.util.Arrays;
|
||||
import java.util.List;
|
||||
|
||||
public class BuildSpawner {
|
||||
|
||||
protected ISpawnModeHander spawnModeHander;
|
||||
private World world;
|
||||
private Direction initialDirection;
|
||||
private int originX;
|
||||
|
@ -29,16 +29,12 @@ public class BuildSpawner {
|
|||
private int platformLength;
|
||||
private int levelAmount;
|
||||
private SpawnMode spawnMode;
|
||||
|
||||
private int nowX;
|
||||
private int nowY;
|
||||
private int nowZ;
|
||||
private Direction nowDirection;
|
||||
|
||||
private List<Material> materials;
|
||||
|
||||
protected ISpawnModeHander spawnModeHander;
|
||||
|
||||
public BuildSpawner(World world, Direction initialDirection, int originX, int originY, int originZ, int chunkWight, int chunkLength, int ladderLength, int ladderAmount, int platformWidth, int platformLength, int levelAmount, SpawnMode spawnMode, List<Material> materials) {
|
||||
this.world = world;
|
||||
this.initialDirection = initialDirection;
|
||||
|
@ -176,6 +172,22 @@ public class BuildSpawner {
|
|||
nowDirection = nowDirection.getRightDirection();
|
||||
}
|
||||
|
||||
public Region getEffectiveRegion(World world) {
|
||||
return spawnModeHander.getEffectiveRegion(world);
|
||||
}
|
||||
|
||||
public int getHeight() {
|
||||
return spawnModeHander.getHeight();
|
||||
}
|
||||
|
||||
public void setInitialDirection(Direction initialDirection) {
|
||||
this.initialDirection = initialDirection;
|
||||
}
|
||||
|
||||
public Material getRandomMaterial() {
|
||||
return materials.get(RandomUtil.getRandomInt(0, materials.size() - 1));
|
||||
}
|
||||
|
||||
private enum TransformType {
|
||||
PLATFORM,
|
||||
LADDER
|
||||
|
@ -226,14 +238,6 @@ public class BuildSpawner {
|
|||
|
||||
}
|
||||
|
||||
public Region getEffectiveRegion(World world) {
|
||||
return spawnModeHander.getEffectiveRegion(world);
|
||||
}
|
||||
|
||||
public int getHeight() {
|
||||
return spawnModeHander.getHeight();
|
||||
}
|
||||
|
||||
public enum SpawnMode {
|
||||
|
||||
MODE_1,
|
||||
|
@ -241,11 +245,20 @@ public class BuildSpawner {
|
|||
|
||||
}
|
||||
|
||||
private interface ISpawnModeHander {
|
||||
void spawn();
|
||||
|
||||
Region getEffectiveRegion(World world);
|
||||
|
||||
int getHeight();
|
||||
}
|
||||
|
||||
private class SpawnModeHandler_1 implements ISpawnModeHander {
|
||||
@Override
|
||||
public void spawn() {
|
||||
new BukkitRunnable() {
|
||||
private int count = 0;
|
||||
|
||||
@Override
|
||||
public void run() {
|
||||
if (count >= levelAmount) {
|
||||
|
@ -329,6 +342,7 @@ public class BuildSpawner {
|
|||
public void spawn() {
|
||||
new BukkitRunnable() {
|
||||
private int count = 0;
|
||||
|
||||
@Override
|
||||
public void run() {
|
||||
if (count >= levelAmount) {
|
||||
|
@ -443,20 +457,4 @@ public class BuildSpawner {
|
|||
|
||||
}
|
||||
|
||||
public void setInitialDirection(Direction initialDirection) {
|
||||
this.initialDirection = initialDirection;
|
||||
}
|
||||
|
||||
private interface ISpawnModeHander {
|
||||
void spawn();
|
||||
|
||||
Region getEffectiveRegion(World world);
|
||||
|
||||
int getHeight();
|
||||
}
|
||||
|
||||
public Material getRandomMaterial() {
|
||||
return materials.get(RandomUtil.getRandomInt(0, materials.size() - 1));
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -25,6 +25,7 @@ public class GameUtil {
|
|||
}
|
||||
}
|
||||
}
|
||||
|
||||
public static boolean specialGiftEffectTriggers(Player player, String eventName, String show_userName, int amount) {
|
||||
if (eventName.contains("盲盒")) {
|
||||
if (eventName.contains("#")) {
|
||||
|
|
|
@ -1,6 +1,8 @@
|
|||
package com.yaohun.enderdragonwars.util;
|
||||
|
||||
import org.bukkit.*;
|
||||
import org.bukkit.ChatColor;
|
||||
import org.bukkit.FireworkEffect;
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.attribute.Attribute;
|
||||
import org.bukkit.attribute.AttributeModifier;
|
||||
import org.bukkit.block.banner.Pattern;
|
||||
|
@ -11,7 +13,6 @@ import org.bukkit.inventory.ItemStack;
|
|||
import org.bukkit.inventory.meta.EnchantmentStorageMeta;
|
||||
import org.bukkit.inventory.meta.FireworkMeta;
|
||||
import org.bukkit.inventory.meta.ItemMeta;
|
||||
import org.bukkit.inventory.meta.SkullMeta;
|
||||
import org.bukkit.potion.PotionEffect;
|
||||
|
||||
import java.lang.reflect.Field;
|
||||
|
@ -75,6 +76,29 @@ public class ItemStackBuilder {
|
|||
this.fireworkEffects = new ArrayList<>();
|
||||
}
|
||||
|
||||
protected static ItemStack setEnchants(ItemStack stack, List<String> enchants) {
|
||||
if (enchants == null) {
|
||||
return stack;
|
||||
}
|
||||
for (String s : enchants) {
|
||||
if (s.contains(":")) {
|
||||
String[] part = s.split(":");
|
||||
Enchantment en = Enchantment.getByName(part[0]);
|
||||
if (en == null) {
|
||||
continue;
|
||||
}
|
||||
if (stack.getType() != Material.ENCHANTED_BOOK) {
|
||||
stack.addUnsafeEnchantment(en, Integer.parseInt(part[1]));
|
||||
} else {
|
||||
EnchantmentStorageMeta esm = (EnchantmentStorageMeta) stack.getItemMeta();
|
||||
esm.addStoredEnchant(en, Integer.parseInt(part[1]), true);
|
||||
stack.setItemMeta((ItemMeta) esm);
|
||||
}
|
||||
}
|
||||
}
|
||||
return stack;
|
||||
}
|
||||
|
||||
public ItemStack build() {
|
||||
ItemStack item = new ItemStack(type, amount);
|
||||
item.setType(type);
|
||||
|
@ -115,26 +139,66 @@ public class ItemStackBuilder {
|
|||
return amount;
|
||||
}
|
||||
|
||||
public ItemStackBuilder setAmount(int amount) {
|
||||
this.amount = amount;
|
||||
return this;
|
||||
}
|
||||
|
||||
public Material getType() {
|
||||
return type;
|
||||
}
|
||||
|
||||
public ItemStackBuilder setType(Material type) {
|
||||
this.type = type;
|
||||
return this;
|
||||
}
|
||||
|
||||
public List<String> getLore() {
|
||||
return lore;
|
||||
}
|
||||
|
||||
public ItemStackBuilder setLore(List<String> loreList) {
|
||||
this.lore = loreList;
|
||||
return this;
|
||||
}
|
||||
|
||||
public ItemStackBuilder setLore(String... lores) {
|
||||
this.lore = new ArrayList<>(Arrays.asList(lores));
|
||||
return this;
|
||||
}
|
||||
|
||||
public int getCustomModelData() {
|
||||
return customModelData;
|
||||
}
|
||||
|
||||
public ItemStackBuilder setCustomModelData(int customModelData) {
|
||||
this.customModelData = customModelData;
|
||||
return this;
|
||||
}
|
||||
|
||||
public Map<Enchantment, Integer> getEnchants() {
|
||||
return enchants;
|
||||
}
|
||||
|
||||
public ItemStackBuilder setEnchants(Map<Enchantment, Integer> enchants) {
|
||||
this.enchants = enchants;
|
||||
return this;
|
||||
}
|
||||
|
||||
public ItemStackBuilder setEnchants(List<String> enchants) {
|
||||
this.enchants = getEnchantsFromList(enchants);
|
||||
return this;
|
||||
}
|
||||
|
||||
public Set<ItemFlag> getItemFlags() {
|
||||
return itemFlags;
|
||||
}
|
||||
|
||||
public ItemStackBuilder setItemFlags(Set<ItemFlag> itemFlags) {
|
||||
this.itemFlags = itemFlags;
|
||||
return this;
|
||||
}
|
||||
|
||||
public List<PotionEffect> getPotionEffects() {
|
||||
return potionEffects;
|
||||
}
|
||||
|
@ -151,30 +215,15 @@ public class ItemStackBuilder {
|
|||
return displayName;
|
||||
}
|
||||
|
||||
public ItemStackBuilder setDisplayName(String name) {
|
||||
this.displayName = name;
|
||||
return this;
|
||||
}
|
||||
|
||||
public short getData() {
|
||||
return data;
|
||||
}
|
||||
|
||||
public ItemStackBuilder setItemStack(ItemStack item) {
|
||||
this.itemStack = item;
|
||||
return this;
|
||||
}
|
||||
|
||||
public ItemStackBuilder setType(Material type) {
|
||||
this.type = type;
|
||||
return this;
|
||||
}
|
||||
|
||||
public ItemStackBuilder setCustomModelData(int customModelData) {
|
||||
this.customModelData = customModelData;
|
||||
return this;
|
||||
}
|
||||
|
||||
public ItemStackBuilder setAmount(int amount) {
|
||||
this.amount = amount;
|
||||
return this;
|
||||
}
|
||||
|
||||
public ItemStackBuilder setData(int data) {
|
||||
if (data > 255) {
|
||||
data = 255;
|
||||
|
@ -188,26 +237,16 @@ public class ItemStackBuilder {
|
|||
return this;
|
||||
}
|
||||
|
||||
public ItemStackBuilder setItemStack(ItemStack item) {
|
||||
this.itemStack = item;
|
||||
return this;
|
||||
}
|
||||
|
||||
public ItemStackBuilder setItemMeta(ItemMeta meta) {
|
||||
this.meta = meta;
|
||||
return this;
|
||||
}
|
||||
|
||||
public ItemStackBuilder setDisplayName(String name) {
|
||||
this.displayName = name;
|
||||
return this;
|
||||
}
|
||||
|
||||
public ItemStackBuilder setLore(List<String> loreList) {
|
||||
this.lore = loreList;
|
||||
return this;
|
||||
}
|
||||
|
||||
public ItemStackBuilder setLore(String... lores) {
|
||||
this.lore = new ArrayList<>(Arrays.asList(lores));
|
||||
return this;
|
||||
}
|
||||
|
||||
public ItemStackBuilder addLore(String lore) {
|
||||
this.lore.add(lore);
|
||||
return this;
|
||||
|
@ -255,21 +294,6 @@ public class ItemStackBuilder {
|
|||
return this;
|
||||
}
|
||||
|
||||
public ItemStackBuilder setEnchants(Map<Enchantment, Integer> enchants) {
|
||||
this.enchants = enchants;
|
||||
return this;
|
||||
}
|
||||
|
||||
public ItemStackBuilder setEnchants(List<String> enchants) {
|
||||
this.enchants = getEnchantsFromList(enchants);
|
||||
return this;
|
||||
}
|
||||
|
||||
public ItemStackBuilder setItemFlags(Set<ItemFlag> itemFlags) {
|
||||
this.itemFlags = itemFlags;
|
||||
return this;
|
||||
}
|
||||
|
||||
public ItemStackBuilder addItemFlags(ItemFlag[] itemFlags) {
|
||||
this.itemFlags.addAll(Arrays.asList(itemFlags));
|
||||
return this;
|
||||
|
@ -313,29 +337,6 @@ public class ItemStackBuilder {
|
|||
return map;
|
||||
}
|
||||
|
||||
protected static ItemStack setEnchants(ItemStack stack, List<String> enchants) {
|
||||
if (enchants == null) {
|
||||
return stack;
|
||||
}
|
||||
for (String s : enchants) {
|
||||
if (s.contains(":")) {
|
||||
String[] part = s.split(":");
|
||||
Enchantment en = Enchantment.getByName(part[0]);
|
||||
if (en == null) {
|
||||
continue;
|
||||
}
|
||||
if (stack.getType() != Material.ENCHANTED_BOOK) {
|
||||
stack.addUnsafeEnchantment(en, Integer.parseInt(part[1]));
|
||||
} else {
|
||||
EnchantmentStorageMeta esm = (EnchantmentStorageMeta) stack.getItemMeta();
|
||||
esm.addStoredEnchant(en, Integer.parseInt(part[1]), true);
|
||||
stack.setItemMeta((ItemMeta) esm);
|
||||
}
|
||||
}
|
||||
}
|
||||
return stack;
|
||||
}
|
||||
|
||||
private void setField(Object instance, String name, Object value) throws ReflectiveOperationException {
|
||||
Field field = instance.getClass().getDeclaredField(name);
|
||||
field.setAccessible(true);
|
||||
|
|
Loading…
Reference in New Issue
Block a user