diff --git a/pom.xml b/pom.xml
index 1801cda..7dc8be9 100644
--- a/pom.xml
+++ b/pom.xml
@@ -75,7 +75,7 @@
com.io.yutian
PixelLiveAPI
- 1.1.4
+ 1.2.2
provided
diff --git a/src/main/java/com/io/yutian/enderdragonwar/effect/GameGiftEffect.java b/src/main/java/com/io/yutian/enderdragonwar/effect/GameGiftEffect.java
index 5badff0..f9a6271 100644
--- a/src/main/java/com/io/yutian/enderdragonwar/effect/GameGiftEffect.java
+++ b/src/main/java/com/io/yutian/enderdragonwar/effect/GameGiftEffect.java
@@ -3,18 +3,15 @@ package com.io.yutian.enderdragonwar.effect;
import com.io.yutian.enderdragonwar.EnderDragonWar;
import com.io.yutian.enderdragonwar.game.Game;
import com.io.yutian.pixelliveapi.api.effect.GiftEffect;
+import com.io.yutian.pixelliveapi.api.effect.GiftEffectMetadata;
public abstract class GameGiftEffect extends GiftEffect {
- public GameGiftEffect(String audience) {
- super(audience);
- }
-
- public abstract void apply(Game game);
+ public abstract void apply(Game game, GiftEffectMetadata metadata);
@Override
- public void apply() {
- apply(EnderDragonWar.getGame());
+ public void apply(GiftEffectMetadata metadata) {
+ apply(EnderDragonWar.getGame(), metadata);
}
}
diff --git a/src/main/java/com/io/yutian/enderdragonwar/effect/types/AddMaxHealthEffect.java b/src/main/java/com/io/yutian/enderdragonwar/effect/types/AddMaxHealthEffect.java
index bff949a..2931e2e 100644
--- a/src/main/java/com/io/yutian/enderdragonwar/effect/types/AddMaxHealthEffect.java
+++ b/src/main/java/com/io/yutian/enderdragonwar/effect/types/AddMaxHealthEffect.java
@@ -3,6 +3,7 @@ package com.io.yutian.enderdragonwar.effect.types;
import com.io.yutian.enderdragonwar.EnderDragonWar;
import com.io.yutian.enderdragonwar.game.Game;
import com.io.yutian.enderdragonwar.effect.GameGiftEffect;
+import com.io.yutian.pixelliveapi.api.effect.GiftEffectMetadata;
import org.bukkit.Particle;
import org.bukkit.attribute.Attribute;
import org.bukkit.entity.Player;
@@ -14,14 +15,10 @@ public class AddMaxHealthEffect extends GameGiftEffect {
public static UUID uuid = UUID.randomUUID();
- public AddMaxHealthEffect(String audience) {
- super(audience);
- }
-
@Override
- public void apply(Game game) {
+ public void apply(Game game, GiftEffectMetadata metadata) {
Player player = game.getPlayer();
- new BukkitRunnable() {
+ game.addTask(new BukkitRunnable() {
private int count = 0;
@Override
@@ -37,7 +34,7 @@ public class AddMaxHealthEffect extends GameGiftEffect {
}
count++;
}
- }.runTaskTimer(EnderDragonWar.inst(), 0L, 1L);
+ }.runTaskTimer(EnderDragonWar.inst(), 0L, 1L));
}
@Override
diff --git a/src/main/java/com/io/yutian/enderdragonwar/effect/types/BlackHoleEffect.java b/src/main/java/com/io/yutian/enderdragonwar/effect/types/BlackHoleEffect.java
index 8d2b3ef..b6a17cf 100644
--- a/src/main/java/com/io/yutian/enderdragonwar/effect/types/BlackHoleEffect.java
+++ b/src/main/java/com/io/yutian/enderdragonwar/effect/types/BlackHoleEffect.java
@@ -4,6 +4,7 @@ import com.io.yutian.enderdragonwar.EnderDragonWar;
import com.io.yutian.enderdragonwar.game.Game;
import com.io.yutian.enderdragonwar.effect.GameGiftEffect;
import com.io.yutian.enderdragonwar.util.RandomUtil;
+import com.io.yutian.pixelliveapi.api.effect.GiftEffectMetadata;
import org.bukkit.Location;
import org.bukkit.Material;
import org.bukkit.Particle;
@@ -24,15 +25,12 @@ public class BlackHoleEffect extends GameGiftEffect {
private static int seconds = 15;
private boolean stop = false;
- public BlackHoleEffect(String audience) {
- super(audience);
- }
@Override
- public void apply(Game game) {
+ public void apply(Game game, GiftEffectMetadata metadata) {
List fallingBlocks = new ArrayList<>();
Location location = game.getPlayer().getLocation().add(0, 2, 0);
- new BukkitRunnable() {
+ game.addTask(new BukkitRunnable() {
private int i = 0;
@Override
@@ -55,8 +53,8 @@ public class BlackHoleEffect extends GameGiftEffect {
}
i++;
}
- }.runTaskTimer(EnderDragonWar.inst(), 0L, 10L);
- new BukkitRunnable() {
+ }.runTaskTimer(EnderDragonWar.inst(), 0L, 10L));
+ game.addTask(new BukkitRunnable() {
private Set uuids = new HashSet<>();
@Override
@@ -101,8 +99,8 @@ public class BlackHoleEffect extends GameGiftEffect {
}
}
}
- }.runTaskTimer(EnderDragonWar.inst(), 0L, 5L);
- new BukkitRunnable() {
+ }.runTaskTimer(EnderDragonWar.inst(), 0L, 5L));
+ game.addTask(new BukkitRunnable() {
private Set uuids = new HashSet<>();
@Override
@@ -134,7 +132,7 @@ public class BlackHoleEffect extends GameGiftEffect {
}
}
}
- }.runTaskTimer(EnderDragonWar.inst(), 0L, 1L);
+ }.runTaskTimer(EnderDragonWar.inst(), 0L, 1L));
}
@Override
diff --git a/src/main/java/com/io/yutian/enderdragonwar/effect/types/BomBomEffect.java b/src/main/java/com/io/yutian/enderdragonwar/effect/types/BomBomEffect.java
index 647fe29..e155b93 100644
--- a/src/main/java/com/io/yutian/enderdragonwar/effect/types/BomBomEffect.java
+++ b/src/main/java/com/io/yutian/enderdragonwar/effect/types/BomBomEffect.java
@@ -4,6 +4,7 @@ import com.io.yutian.enderdragonwar.EnderDragonWar;
import com.io.yutian.enderdragonwar.effect.GameGiftEffect;
import com.io.yutian.enderdragonwar.game.Game;
import com.io.yutian.enderdragonwar.util.EntityUtil;
+import com.io.yutian.pixelliveapi.api.effect.GiftEffectMetadata;
import net.kyori.adventure.text.Component;
import org.bukkit.*;
import org.bukkit.attribute.Attribute;
@@ -75,12 +76,8 @@ public class BomBomEffect extends GameGiftEffect {
private List fallingBlocks = new ArrayList<>();
private BossBar bossBar;
- public BomBomEffect(String audience) {
- super(audience);
- }
-
@Override
- public void apply(Game game) {
+ public void apply(Game game, GiftEffectMetadata metadata) {
bossBar = Bukkit.createBossBar("§4§l毁天灭地", BarColor.RED, BarStyle.SOLID);
World world = game.getWorld();
Player player = game.getPlayer();
@@ -102,7 +99,7 @@ public class BomBomEffect extends GameGiftEffect {
armorStand1.getEquipment().setItem(EquipmentSlot.FEET, ITEM_4);
armorStand1.getAttribute(Attribute.GENERIC_SCALE).setBaseValue(6.0);
});
- new BukkitRunnable() {
+ game.addTask(new BukkitRunnable() {
private int count = 0;
@Override
@@ -153,8 +150,8 @@ public class BomBomEffect extends GameGiftEffect {
}
count++;
}
- }.runTaskTimer(EnderDragonWar.inst(), 0L, 15L);
- new BukkitRunnable() {
+ }.runTaskTimer(EnderDragonWar.inst(), 0L, 15L));
+ game.addTask(new BukkitRunnable() {
private int count = 0;
@Override
@@ -171,8 +168,8 @@ public class BomBomEffect extends GameGiftEffect {
bossBar.setTitle(flag ? "§4§l毁天灭地" : "§c§l毁天灭地");
count++;
}
- }.runTaskTimer(EnderDragonWar.inst(), 0L, 5L);
- new BukkitRunnable() {
+ }.runTaskTimer(EnderDragonWar.inst(), 0L, 5L));
+ game.addTask(new BukkitRunnable() {
private int count = 0;
@Override
@@ -188,8 +185,8 @@ public class BomBomEffect extends GameGiftEffect {
armorStand.getWorld().spawnParticle(Particle.FLAME, location1, 5, 0.2, 1, 0.2, 0.01);
count++;
}
- }.runTaskTimer(EnderDragonWar.inst(), 0L, 2L);
- new BukkitRunnable() {
+ }.runTaskTimer(EnderDragonWar.inst(), 0L, 2L));
+ game.addTask(new BukkitRunnable() {
@Override
public void run() {
if (fallingBlocks.isEmpty()) {
@@ -211,7 +208,7 @@ public class BomBomEffect extends GameGiftEffect {
}
}
}
- }.runTaskTimer(EnderDragonWar.inst(), 0L, 1L);
+ }.runTaskTimer(EnderDragonWar.inst(), 0L, 1L));
}
}
diff --git a/src/main/java/com/io/yutian/enderdragonwar/effect/types/ClearInventoryEffect.java b/src/main/java/com/io/yutian/enderdragonwar/effect/types/ClearInventoryEffect.java
index b1c4b3e..5907334 100644
--- a/src/main/java/com/io/yutian/enderdragonwar/effect/types/ClearInventoryEffect.java
+++ b/src/main/java/com/io/yutian/enderdragonwar/effect/types/ClearInventoryEffect.java
@@ -4,6 +4,7 @@ import com.io.yutian.enderdragonwar.EnderDragonWar;
import com.io.yutian.enderdragonwar.game.Game;
import com.io.yutian.enderdragonwar.effect.GameGiftEffect;
import com.io.yutian.enderdragonwar.util.RandomUtil;
+import com.io.yutian.pixelliveapi.api.effect.GiftEffectMetadata;
import org.bukkit.Material;
import org.bukkit.Particle;
import org.bukkit.Sound;
@@ -21,16 +22,12 @@ import java.util.List;
public class ClearInventoryEffect extends GameGiftEffect {
- public ClearInventoryEffect(String audience) {
- super(audience);
- }
-
@Override
- public void apply(Game game) {
+ public void apply(Game game, GiftEffectMetadata metadata) {
World world = game.getWorld();
Player player = game.getPlayer();
List allays = new ArrayList<>();
- new BukkitRunnable() {
+ game.addTask(new BukkitRunnable() {
private int totalCount = Math.max(15, getUseableItemCount(player).size());
private int count = 0;
@@ -64,7 +61,7 @@ public class ClearInventoryEffect extends GameGiftEffect {
allays.add(allay);
count++;
}
- }.runTaskTimer(EnderDragonWar.inst(), 10L, 4L);
+ }.runTaskTimer(EnderDragonWar.inst(), 10L, 4L));
}
@Override
diff --git a/src/main/java/com/io/yutian/enderdragonwar/effect/types/FiveLightningEffect.java b/src/main/java/com/io/yutian/enderdragonwar/effect/types/FiveLightningEffect.java
index 010e23a..7c36a85 100644
--- a/src/main/java/com/io/yutian/enderdragonwar/effect/types/FiveLightningEffect.java
+++ b/src/main/java/com/io/yutian/enderdragonwar/effect/types/FiveLightningEffect.java
@@ -3,19 +3,16 @@ package com.io.yutian.enderdragonwar.effect.types;
import com.io.yutian.enderdragonwar.EnderDragonWar;
import com.io.yutian.enderdragonwar.game.Game;
import com.io.yutian.enderdragonwar.effect.GameGiftEffect;
+import com.io.yutian.pixelliveapi.api.effect.GiftEffectMetadata;
import org.bukkit.entity.Player;
import org.bukkit.scheduler.BukkitRunnable;
public class FiveLightningEffect extends GameGiftEffect {
- public FiveLightningEffect(String audience) {
- super(audience);
- }
-
@Override
- public void apply(Game game) {
+ public void apply(Game game, GiftEffectMetadata metadata) {
Player player = game.getPlayer();
- new BukkitRunnable() {
+ game.addTask(new BukkitRunnable() {
private int count = 0;
@Override
@@ -27,7 +24,7 @@ public class FiveLightningEffect extends GameGiftEffect {
player.getWorld().strikeLightning(player.getLocation());
count++;
}
- }.runTaskTimer(EnderDragonWar.inst(), 0, 10L);
+ }.runTaskTimer(EnderDragonWar.inst(), 0, 10L));
}
@Override
diff --git a/src/main/java/com/io/yutian/enderdragonwar/effect/types/GiveTotemEffect.java b/src/main/java/com/io/yutian/enderdragonwar/effect/types/GiveTotemEffect.java
index f2104c3..7f21f3e 100644
--- a/src/main/java/com/io/yutian/enderdragonwar/effect/types/GiveTotemEffect.java
+++ b/src/main/java/com/io/yutian/enderdragonwar/effect/types/GiveTotemEffect.java
@@ -2,18 +2,15 @@ package com.io.yutian.enderdragonwar.effect.types;
import com.io.yutian.enderdragonwar.effect.GameGiftEffect;
import com.io.yutian.enderdragonwar.game.Game;
+import com.io.yutian.pixelliveapi.api.effect.GiftEffectMetadata;
import org.bukkit.Material;
import org.bukkit.entity.Player;
import org.bukkit.inventory.ItemStack;
public class GiveTotemEffect extends GameGiftEffect {
- public GiveTotemEffect(String audience) {
- super(audience);
- }
-
@Override
- public void apply(Game game) {
+ public void apply(Game game, GiftEffectMetadata metadata) {
Player player = game.getPlayer();
player.getInventory().addItem(new ItemStack(Material.TOTEM_OF_UNDYING));
}
diff --git a/src/main/java/com/io/yutian/enderdragonwar/effect/types/LavaPoolEffect.java b/src/main/java/com/io/yutian/enderdragonwar/effect/types/LavaPoolEffect.java
index bcad0d7..2f857fe 100644
--- a/src/main/java/com/io/yutian/enderdragonwar/effect/types/LavaPoolEffect.java
+++ b/src/main/java/com/io/yutian/enderdragonwar/effect/types/LavaPoolEffect.java
@@ -16,10 +16,6 @@ import org.bukkit.potion.PotionEffectType;
public class LavaPoolEffect extends GameGiftEffect {
- public LavaPoolEffect(String audience) {
- super(audience);
- }
-
@Override
public void apply(Game game) {
Player player = game.getPlayer();
diff --git a/src/main/java/com/io/yutian/enderdragonwar/effect/types/LuckyBlockEffect.java b/src/main/java/com/io/yutian/enderdragonwar/effect/types/LuckyBlockEffect.java
index c935b83..17503cb 100644
--- a/src/main/java/com/io/yutian/enderdragonwar/effect/types/LuckyBlockEffect.java
+++ b/src/main/java/com/io/yutian/enderdragonwar/effect/types/LuckyBlockEffect.java
@@ -4,6 +4,7 @@ import com.io.yutian.enderdragonwar.effect.GameGiftEffect;
import com.io.yutian.enderdragonwar.game.Game;
import com.io.yutian.enderdragonwar.util.ItemStackBuilder;
import com.io.yutian.enderdragonwar.util.RandomUtil;
+import com.io.yutian.pixelliveapi.api.effect.GiftEffectMetadata;
import org.bukkit.*;
import org.bukkit.block.Block;
import org.bukkit.enchantments.Enchantment;
@@ -80,10 +81,6 @@ public class LuckyBlockEffect extends GameGiftEffect {
}
- public LuckyBlockEffect(String audience) {
- super(audience);
- }
-
public static void openLuckyBlock(Player player, Block block) {
Location location = block.getLocation().add(0.5, 0.5, 0.5);
location.getWorld().spawnParticle(Particle.FIREWORK, location, 35, 0.55, 0.55, 0.55, 0.05);
@@ -105,7 +102,7 @@ public class LuckyBlockEffect extends GameGiftEffect {
}
@Override
- public void apply(Game game) {
+ public void apply(Game game, GiftEffectMetadata metadata) {
game.getPlayer().getInventory().addItem(new ItemStackBuilder(Material.SPONGE).setDisplayName("§6§l幸运方块").build());
}
diff --git a/src/main/java/com/io/yutian/enderdragonwar/effect/types/PlayerBigEffect.java b/src/main/java/com/io/yutian/enderdragonwar/effect/types/PlayerBigEffect.java
index 99f6c8e..6b27d3b 100644
--- a/src/main/java/com/io/yutian/enderdragonwar/effect/types/PlayerBigEffect.java
+++ b/src/main/java/com/io/yutian/enderdragonwar/effect/types/PlayerBigEffect.java
@@ -2,17 +2,14 @@ package com.io.yutian.enderdragonwar.effect.types;
import com.io.yutian.enderdragonwar.effect.GameGiftEffect;
import com.io.yutian.enderdragonwar.game.Game;
+import com.io.yutian.pixelliveapi.api.effect.GiftEffectMetadata;
import org.bukkit.attribute.Attribute;
import org.bukkit.entity.Player;
public class PlayerBigEffect extends GameGiftEffect {
- public PlayerBigEffect(String audience) {
- super(audience);
- }
-
@Override
- public void apply(Game game) {
+ public void apply(Game game, GiftEffectMetadata metadata) {
Player player = game.getPlayer();
if (player.getAttribute(Attribute.GENERIC_SCALE).getBaseValue() >= 20) {
return;
diff --git a/src/main/java/com/io/yutian/enderdragonwar/effect/types/PlayerGoldAppleEffect.java b/src/main/java/com/io/yutian/enderdragonwar/effect/types/PlayerGoldAppleEffect.java
index 90d647b..ff49be8 100644
--- a/src/main/java/com/io/yutian/enderdragonwar/effect/types/PlayerGoldAppleEffect.java
+++ b/src/main/java/com/io/yutian/enderdragonwar/effect/types/PlayerGoldAppleEffect.java
@@ -2,18 +2,15 @@ package com.io.yutian.enderdragonwar.effect.types;
import com.io.yutian.enderdragonwar.effect.GameGiftEffect;
import com.io.yutian.enderdragonwar.game.Game;
+import com.io.yutian.pixelliveapi.api.effect.GiftEffectMetadata;
import org.bukkit.Material;
import org.bukkit.entity.Player;
import org.bukkit.inventory.ItemStack;
public class PlayerGoldAppleEffect extends GameGiftEffect {
- public PlayerGoldAppleEffect(String audience) {
- super(audience);
- }
-
@Override
- public void apply(Game game) {
+ public void apply(Game game, GiftEffectMetadata metadata) {
Player player = game.getPlayer();
ItemStack goldApple = new ItemStack(Material.ENCHANTED_GOLDEN_APPLE);
goldApple.setAmount(2);
diff --git a/src/main/java/com/io/yutian/enderdragonwar/effect/types/PlayerResetEffect.java b/src/main/java/com/io/yutian/enderdragonwar/effect/types/PlayerResetEffect.java
index 2f58864..5331251 100644
--- a/src/main/java/com/io/yutian/enderdragonwar/effect/types/PlayerResetEffect.java
+++ b/src/main/java/com/io/yutian/enderdragonwar/effect/types/PlayerResetEffect.java
@@ -2,17 +2,14 @@ package com.io.yutian.enderdragonwar.effect.types;
import com.io.yutian.enderdragonwar.effect.GameGiftEffect;
import com.io.yutian.enderdragonwar.game.Game;
+import com.io.yutian.pixelliveapi.api.effect.GiftEffectMetadata;
import org.bukkit.attribute.Attribute;
import org.bukkit.entity.Player;
public class PlayerResetEffect extends GameGiftEffect {
- public PlayerResetEffect(String audience) {
- super(audience);
- }
-
@Override
- public void apply(Game game) {
+ public void apply(Game game, GiftEffectMetadata metadata) {
Player player = game.getPlayer();
player.getAttribute(Attribute.GENERIC_SCALE).setBaseValue(1);
player.getAttribute(Attribute.PLAYER_BLOCK_INTERACTION_RANGE).setBaseValue(4.5);
diff --git a/src/main/java/com/io/yutian/enderdragonwar/effect/types/PlayerSmallEffect.java b/src/main/java/com/io/yutian/enderdragonwar/effect/types/PlayerSmallEffect.java
index d2fec34..1b42bfc 100644
--- a/src/main/java/com/io/yutian/enderdragonwar/effect/types/PlayerSmallEffect.java
+++ b/src/main/java/com/io/yutian/enderdragonwar/effect/types/PlayerSmallEffect.java
@@ -2,17 +2,14 @@ package com.io.yutian.enderdragonwar.effect.types;
import com.io.yutian.enderdragonwar.effect.GameGiftEffect;
import com.io.yutian.enderdragonwar.game.Game;
+import com.io.yutian.pixelliveapi.api.effect.GiftEffectMetadata;
import org.bukkit.attribute.Attribute;
import org.bukkit.entity.Player;
public class PlayerSmallEffect extends GameGiftEffect {
- public PlayerSmallEffect(String audience) {
- super(audience);
- }
-
@Override
- public void apply(Game game) {
+ public void apply(Game game, GiftEffectMetadata metadata) {
Player player = game.getPlayer();
if (player.getAttribute(Attribute.GENERIC_SCALE).getBaseValue() <= 0.1) {
return;
diff --git a/src/main/java/com/io/yutian/enderdragonwar/effect/types/RandomBoxEffect.java b/src/main/java/com/io/yutian/enderdragonwar/effect/types/RandomBoxEffect.java
index 9a8230d..b121c90 100644
--- a/src/main/java/com/io/yutian/enderdragonwar/effect/types/RandomBoxEffect.java
+++ b/src/main/java/com/io/yutian/enderdragonwar/effect/types/RandomBoxEffect.java
@@ -4,7 +4,9 @@ import com.io.yutian.enderdragonwar.EnderDragonWar;
import com.io.yutian.enderdragonwar.effect.GameGiftEffect;
import com.io.yutian.enderdragonwar.game.Game;
import com.io.yutian.pixelliveapi.api.PixelLiveAPI;
+import com.io.yutian.pixelliveapi.api.data.RandomBox;
import com.io.yutian.pixelliveapi.api.data.RandomBoxEntry;
+import com.io.yutian.pixelliveapi.api.effect.GiftEffectMetadata;
import com.io.yutian.pixelliveapi.api.util.RandomBoxHelper;
import org.bukkit.Bukkit;
import org.bukkit.Sound;
@@ -14,35 +16,42 @@ import org.bukkit.scheduler.BukkitTask;
public class RandomBoxEffect extends GameGiftEffect {
- public RandomBoxEffect(String audience) {
- super(audience);
- }
+ private static final String BOX_ID = "随机盲盒";
@Override
- public void apply(Game game) {
+ public void apply(Game game, GiftEffectMetadata metadata) {
Player player = game.getPlayer();
- RandomBoxHelper randomBoxHelper = PixelLiveAPI.getRandomBoxManager().getRandomBoxHelper();
+ RandomBox randomBox = PixelLiveAPI.getRandomBoxManager().getRandomBox(BOX_ID);
+ if (randomBox == null) {
+ EnderDragonWar.inst().getLogger().warning("随机盲盒 "+BOX_ID+" 不存在");
+ }
+ RandomBoxHelper randomBoxHelper = randomBox.getRandomBoxHelper();
BukkitTask task = new BukkitRunnable() {
private int i = 0;
@Override
public void run() {
RandomBoxEntry randomBoxEntry = randomBoxHelper.getRandomEffect();
+ String effect = randomBoxEntry.getEffect().getEffect();
+ int amount = randomBoxEntry.getEffect().getAmount();
+ String showName = randomBoxEntry.getShowName() + (amount > 1 ? "X"+amount : "");
if (i >= 12) {
- player.sendTitle("§6随机盲盒", "§9整蛊效果: §e" + randomBoxEntry.getShowName());
+ player.sendTitle("§6随机盲盒", "§9整蛊效果: §e" + showName);
player.playSound(player.getLocation(), Sound.BLOCK_COMPARATOR_CLICK, 1, 1);
- PixelLiveAPI.getEffectQueueManager().addEffect(getAudience(), randomBoxEntry.getEffect(), 1);
- Bukkit.broadcastMessage("§c[消息]§a随机盲盒抽中了 §e" + randomBoxEntry.getShowName());
+ PixelLiveAPI.getEffectQueueManager().addEffect(metadata.getAnchor(), metadata.getAudience(), effect, amount);
+
+ Bukkit.broadcastMessage("§c[消息]§a随机盲盒抽中了 §e" + showName);
cancel();
return;
}
- player.sendTitle("§6随机盲盒", "§9整蛊效果: §e" + randomBoxHelper.getRandomEffect().getShowName());
+ player.sendTitle("§6随机盲盒", "§9整蛊效果: §e" + showName);
player.playSound(player.getLocation(), Sound.BLOCK_COMPARATOR_CLICK, 1, 1);
i++;
}
}.runTaskTimer(EnderDragonWar.inst(), 0L, 5L);
- EnderDragonWar.getGame().addTasks(task);
+ EnderDragonWar.getGame().addTask(task);
}
+
@Override
public int getQueueTime() {
return 12 * 5;
diff --git a/src/main/java/com/io/yutian/enderdragonwar/effect/types/SpawnBuildEffect.java b/src/main/java/com/io/yutian/enderdragonwar/effect/types/SpawnBuildEffect.java
index 7b793f6..0d5db22 100644
--- a/src/main/java/com/io/yutian/enderdragonwar/effect/types/SpawnBuildEffect.java
+++ b/src/main/java/com/io/yutian/enderdragonwar/effect/types/SpawnBuildEffect.java
@@ -3,17 +3,14 @@ package com.io.yutian.enderdragonwar.effect.types;
import com.io.yutian.enderdragonwar.effect.GameGiftEffect;
import com.io.yutian.enderdragonwar.game.Game;
import com.io.yutian.enderdragonwar.util.WEUtil;
+import com.io.yutian.pixelliveapi.api.effect.GiftEffectMetadata;
import org.bukkit.Location;
import org.bukkit.entity.Player;
public class SpawnBuildEffect extends GameGiftEffect {
- public SpawnBuildEffect(String audience) {
- super(audience);
- }
-
@Override
- public void apply(Game game) {
+ public void apply(Game game, GiftEffectMetadata metadata) {
Player player = game.getPlayer();
Location location = player.getLocation();
WEUtil.loadSchematics(player.getLocation(), "anquanwu");
diff --git a/src/main/java/com/io/yutian/enderdragonwar/effect/types/SpawnEnderPortalEffect.java b/src/main/java/com/io/yutian/enderdragonwar/effect/types/SpawnEnderPortalEffect.java
index f1e0dc2..4c3b186 100644
--- a/src/main/java/com/io/yutian/enderdragonwar/effect/types/SpawnEnderPortalEffect.java
+++ b/src/main/java/com/io/yutian/enderdragonwar/effect/types/SpawnEnderPortalEffect.java
@@ -4,6 +4,7 @@ import com.io.yutian.enderdragonwar.EnderDragonWar;
import com.io.yutian.enderdragonwar.data.Region;
import com.io.yutian.enderdragonwar.game.Game;
import com.io.yutian.enderdragonwar.util.BuildSpawner;
+import com.io.yutian.pixelliveapi.api.effect.GiftEffectMetadata;
import com.sk89q.worldedit.EditSession;
import com.sk89q.worldedit.WorldEdit;
import com.sk89q.worldedit.bukkit.BukkitAdapter;
@@ -27,10 +28,6 @@ public class SpawnEnderPortalEffect extends GameGiftEffect {
public static List enderPortalRegions = new ArrayList<>();
- public SpawnEnderPortalEffect(String audience) {
- super(audience);
- }
-
public static void checkPortalRegion(Location location) {
Iterator iterator = enderPortalRegions.iterator();
while (iterator.hasNext()) {
@@ -51,7 +48,7 @@ public class SpawnEnderPortalEffect extends GameGiftEffect {
}
@Override
- public void apply(Game game) {
+ public void apply(Game game, GiftEffectMetadata metadata) {
int chunkWight = 2;
int chunkLength = 2;
int ladderLength = 3;
diff --git a/src/main/java/com/io/yutian/enderdragonwar/effect/types/SummonIronGolem.java b/src/main/java/com/io/yutian/enderdragonwar/effect/types/SummonIronGolem.java
index 81a4f07..86b5833 100644
--- a/src/main/java/com/io/yutian/enderdragonwar/effect/types/SummonIronGolem.java
+++ b/src/main/java/com/io/yutian/enderdragonwar/effect/types/SummonIronGolem.java
@@ -2,17 +2,14 @@ package com.io.yutian.enderdragonwar.effect.types;
import com.io.yutian.enderdragonwar.effect.GameGiftEffect;
import com.io.yutian.enderdragonwar.game.Game;
+import com.io.yutian.pixelliveapi.api.effect.GiftEffectMetadata;
import org.bukkit.entity.EntityType;
import org.bukkit.entity.Player;
public class SummonIronGolem extends GameGiftEffect {
- public SummonIronGolem(String audience) {
- super(audience);
- }
-
@Override
- public void apply(Game game) {
+ public void apply(Game game, GiftEffectMetadata metadata) {
Player player = game.getPlayer();
player.getWorld().spawnEntity(player.getLocation(), EntityType.IRON_GOLEM);
player.getWorld().spawnEntity(player.getLocation(), EntityType.IRON_GOLEM);
diff --git a/src/main/java/com/io/yutian/enderdragonwar/effect/types/SummonMobsEffect.java b/src/main/java/com/io/yutian/enderdragonwar/effect/types/SummonMobsEffect.java
index 8519a86..ad20872 100644
--- a/src/main/java/com/io/yutian/enderdragonwar/effect/types/SummonMobsEffect.java
+++ b/src/main/java/com/io/yutian/enderdragonwar/effect/types/SummonMobsEffect.java
@@ -3,6 +3,7 @@ package com.io.yutian.enderdragonwar.effect.types;
import com.io.yutian.enderdragonwar.effect.GameGiftEffect;
import com.io.yutian.enderdragonwar.game.Game;
import com.io.yutian.enderdragonwar.util.RandomUtil;
+import com.io.yutian.pixelliveapi.api.effect.GiftEffectMetadata;
import org.bukkit.entity.Creeper;
import org.bukkit.entity.EntityType;
import org.bukkit.entity.Player;
@@ -11,12 +12,8 @@ import org.bukkit.util.Vector;
public class SummonMobsEffect extends GameGiftEffect {
- public SummonMobsEffect(String audience) {
- super(audience);
- }
-
@Override
- public void apply(Game game) {
+ public void apply(Game game, GiftEffectMetadata metadata) {
Player player = game.getPlayer();
for (int i = 0; i < 5; i++) {
Zombie zombie = (Zombie) player.getWorld().spawnEntity(player.getLocation(), EntityType.ZOMBIE);
diff --git a/src/main/java/com/io/yutian/enderdragonwar/effect/types/TakeMaxHealthEffect.java b/src/main/java/com/io/yutian/enderdragonwar/effect/types/TakeMaxHealthEffect.java
index 3c547d3..6946e3c 100644
--- a/src/main/java/com/io/yutian/enderdragonwar/effect/types/TakeMaxHealthEffect.java
+++ b/src/main/java/com/io/yutian/enderdragonwar/effect/types/TakeMaxHealthEffect.java
@@ -2,18 +2,15 @@ package com.io.yutian.enderdragonwar.effect.types;
import com.io.yutian.enderdragonwar.game.Game;
import com.io.yutian.enderdragonwar.effect.GameGiftEffect;
+import com.io.yutian.pixelliveapi.api.effect.GiftEffectMetadata;
import org.bukkit.Particle;
import org.bukkit.attribute.Attribute;
import org.bukkit.entity.Player;
public class TakeMaxHealthEffect extends GameGiftEffect {
- public TakeMaxHealthEffect(String audience) {
- super(audience);
- }
-
@Override
- public void apply(Game game) {
+ public void apply(Game game, GiftEffectMetadata metadata) {
Player player = game.getPlayer();
player.spawnParticle(Particle.SMOKE, player.getLocation().add(0, 1, 0), 30, 0.25, 0.25, 0.25, 0.05);
if (player.getAttribute(Attribute.GENERIC_MAX_HEALTH).getBaseValue() <= 20) {
diff --git a/src/main/java/com/io/yutian/enderdragonwar/effect/types/ToHeavenEffect.java b/src/main/java/com/io/yutian/enderdragonwar/effect/types/ToHeavenEffect.java
index 66d5acd..685d81c 100644
--- a/src/main/java/com/io/yutian/enderdragonwar/effect/types/ToHeavenEffect.java
+++ b/src/main/java/com/io/yutian/enderdragonwar/effect/types/ToHeavenEffect.java
@@ -3,22 +3,19 @@ package com.io.yutian.enderdragonwar.effect.types;
import com.io.yutian.enderdragonwar.EnderDragonWar;
import com.io.yutian.enderdragonwar.effect.GameGiftEffect;
import com.io.yutian.enderdragonwar.game.Game;
+import com.io.yutian.pixelliveapi.api.effect.GiftEffectMetadata;
import org.bukkit.entity.Player;
import org.bukkit.scheduler.BukkitRunnable;
import org.bukkit.util.Vector;
public class ToHeavenEffect extends GameGiftEffect {
- public ToHeavenEffect(String audience) {
- super(audience);
- }
-
@Override
- public void apply(Game game) {
+ public void apply(Game game, GiftEffectMetadata metadata) {
Player player = game.getPlayer();
double radius = 1.5D;
EnderDragonWar.getGame().takeLiveTime(60);
- new BukkitRunnable() {
+ game.addTask(new BukkitRunnable() {
private int count = 0;
private double angle = 0;
private double speed = 1.25;
@@ -41,7 +38,7 @@ public class ToHeavenEffect extends GameGiftEffect {
}
count++;
}
- }.runTaskTimer(EnderDragonWar.inst(), 0L, 1L);
+ }.runTaskTimer(EnderDragonWar.inst(), 0L, 1L));
}
@Override
diff --git a/src/main/java/com/io/yutian/enderdragonwar/effect/types/WorldDestroyEffect.java b/src/main/java/com/io/yutian/enderdragonwar/effect/types/WorldDestroyEffect.java
index 05f474c..c4ff466 100644
--- a/src/main/java/com/io/yutian/enderdragonwar/effect/types/WorldDestroyEffect.java
+++ b/src/main/java/com/io/yutian/enderdragonwar/effect/types/WorldDestroyEffect.java
@@ -4,6 +4,7 @@ import com.io.yutian.enderdragonwar.EnderDragonWar;
import com.io.yutian.enderdragonwar.game.Game;
import com.io.yutian.enderdragonwar.effect.GameGiftEffect;
import com.io.yutian.enderdragonwar.util.EntityUtil;
+import com.io.yutian.pixelliveapi.api.effect.GiftEffectMetadata;
import net.kyori.adventure.text.Component;
import org.bukkit.*;
import org.bukkit.attribute.Attribute;
@@ -75,12 +76,8 @@ public class WorldDestroyEffect extends GameGiftEffect {
private List fallingBlocks = new ArrayList<>();
private BossBar bossBar;
- public WorldDestroyEffect(String audience) {
- super(audience);
- }
-
@Override
- public void apply(Game game) {
+ public void apply(Game game, GiftEffectMetadata metadata) {
bossBar = Bukkit.createBossBar("§4§l世界毁灭", BarColor.RED, BarStyle.SOLID);
World world = game.getWorld();
Player player = game.getPlayer();
@@ -102,7 +99,7 @@ public class WorldDestroyEffect extends GameGiftEffect {
armorStand1.getEquipment().setItem(EquipmentSlot.FEET, ITEM_4);
armorStand1.getAttribute(Attribute.GENERIC_SCALE).setBaseValue(6.0);
});
- new BukkitRunnable() {
+ game.addTask(new BukkitRunnable() {
private int count = 0;
@Override
@@ -153,8 +150,8 @@ public class WorldDestroyEffect extends GameGiftEffect {
}
count++;
}
- }.runTaskTimer(EnderDragonWar.inst(), 0L, 15L);
- new BukkitRunnable() {
+ }.runTaskTimer(EnderDragonWar.inst(), 0L, 15L));
+ game.addTask(new BukkitRunnable() {
private int count = 0;
@Override
@@ -171,8 +168,8 @@ public class WorldDestroyEffect extends GameGiftEffect {
bossBar.setTitle(flag ? "§4§l世界毁灭" : "§c§l世界毁灭");
count++;
}
- }.runTaskTimer(EnderDragonWar.inst(), 0L, 5L);
- new BukkitRunnable() {
+ }.runTaskTimer(EnderDragonWar.inst(), 0L, 5L));
+ game.addTask(new BukkitRunnable() {
private int count = 0;
@Override
@@ -188,8 +185,8 @@ public class WorldDestroyEffect extends GameGiftEffect {
armorStand.getWorld().spawnParticle(Particle.FLAME, location1, 8, 0.2, 1, 0.2, 0.01);
count++;
}
- }.runTaskTimer(EnderDragonWar.inst(), 0L, 2L);
- new BukkitRunnable() {
+ }.runTaskTimer(EnderDragonWar.inst(), 0L, 2L));
+ game.addTask(new BukkitRunnable() {
@Override
public void run() {
if (fallingBlocks.isEmpty()) {
@@ -212,7 +209,7 @@ public class WorldDestroyEffect extends GameGiftEffect {
}
}
}
- }.runTaskTimer(EnderDragonWar.inst(), 0L, 1L);
+ }.runTaskTimer(EnderDragonWar.inst(), 0L, 1L));
}
}
diff --git a/src/main/java/com/io/yutian/enderdragonwar/effect/types/WuHuJumpEffect.java b/src/main/java/com/io/yutian/enderdragonwar/effect/types/WuHuJumpEffect.java
index b45e7f3..c141034 100644
--- a/src/main/java/com/io/yutian/enderdragonwar/effect/types/WuHuJumpEffect.java
+++ b/src/main/java/com/io/yutian/enderdragonwar/effect/types/WuHuJumpEffect.java
@@ -3,6 +3,7 @@ package com.io.yutian.enderdragonwar.effect.types;
import com.io.yutian.enderdragonwar.EnderDragonWar;
import com.io.yutian.enderdragonwar.effect.GameGiftEffect;
import com.io.yutian.enderdragonwar.game.Game;
+import com.io.yutian.pixelliveapi.api.effect.GiftEffectMetadata;
import org.bukkit.Effect;
import org.bukkit.Location;
import org.bukkit.Sound;
@@ -14,12 +15,8 @@ import org.bukkit.scheduler.BukkitTask;
public class WuHuJumpEffect extends GameGiftEffect {
- public WuHuJumpEffect(String audience) {
- super(audience);
- }
-
@Override
- public void apply(Game game) {
+ public void apply(Game game, GiftEffectMetadata metadata) {
Player player = game.getPlayer();
player.setVelocity(player.getLocation().getDirection().multiply(0.5).setY(1.0));
player.playEffect(player.getLocation(), Effect.MOBSPAWNER_FLAMES, 10);
@@ -40,7 +37,7 @@ public class WuHuJumpEffect extends GameGiftEffect {
i++;
}
}.runTaskTimer(EnderDragonWar.inst(), 2L, 1L);
- game.addTasks(task);
+ game.addTask(task);
}
}
diff --git a/src/main/java/com/io/yutian/enderdragonwar/game/Game.java b/src/main/java/com/io/yutian/enderdragonwar/game/Game.java
index b30bab2..6152018 100644
--- a/src/main/java/com/io/yutian/enderdragonwar/game/Game.java
+++ b/src/main/java/com/io/yutian/enderdragonwar/game/Game.java
@@ -154,7 +154,7 @@ public class Game {
return startd;
}
- public void addTasks(BukkitTask task) {
+ public void addTask(BukkitTask task) {
this.tasks.add(task);
}
diff --git a/src/main/java/com/io/yutian/enderdragonwar/listener/PlayerListener.java b/src/main/java/com/io/yutian/enderdragonwar/listener/PlayerListener.java
index be4fa99..81b4ee5 100644
--- a/src/main/java/com/io/yutian/enderdragonwar/listener/PlayerListener.java
+++ b/src/main/java/com/io/yutian/enderdragonwar/listener/PlayerListener.java
@@ -71,9 +71,9 @@ public class PlayerListener implements Listener {
public void onPlayerRespawn(PlayerRespawnEvent event) {
Player player = event.getPlayer();
Location location = event.getRespawnLocation();
- for (int i = -3; i <= 3; i++) {
- for (int j = 0; j <= 3; j++) {
- for (int z = -3; z <= 3; z++) {
+ for (int i = -5; i <= 5; i++) {
+ for (int j = 0; j <= 8; j++) {
+ for (int z = -5; z <= 5; z++) {
Block block = location.clone().add(i, j, z).getBlock();
if (block.getType() == Material.LAVA) {
block.setType(Material.AIR);
diff --git a/src/main/resources/plugin.yml b/src/main/resources/plugin.yml
index 04f4cdc..3ca290e 100644
--- a/src/main/resources/plugin.yml
+++ b/src/main/resources/plugin.yml
@@ -1,5 +1,5 @@
name: EnderDragonWar
-version: 1.0.5
+version: 1.1
api-version: 1.20
main: com.io.yutian.enderdragonwar.EnderDragonWar
depend: [PixelLiveAPI]