This commit is contained in:
YuTian 2024-08-19 20:31:41 +08:00
parent 291aea4ba5
commit b036dabb42
26 changed files with 98 additions and 152 deletions

View File

@ -75,7 +75,7 @@
<dependency>
<groupId>com.io.yutian</groupId>
<artifactId>PixelLiveAPI</artifactId>
<version>1.1.4</version>
<version>1.2.2</version>
<scope>provided</scope>
</dependency>
<dependency>

View File

@ -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);
}
}

View File

@ -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

View File

@ -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<FallingBlock> 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<UUID> 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<UUID> uuids = new HashSet<>();
@Override
@ -134,7 +132,7 @@ public class BlackHoleEffect extends GameGiftEffect {
}
}
}
}.runTaskTimer(EnderDragonWar.inst(), 0L, 1L);
}.runTaskTimer(EnderDragonWar.inst(), 0L, 1L));
}
@Override

View File

@ -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<FallingBlock> 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));
}
}

View File

@ -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<Allay> 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

View File

@ -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

View File

@ -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));
}

View File

@ -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();

View File

@ -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());
}

View File

@ -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;

View File

@ -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);

View File

@ -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);

View File

@ -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;

View File

@ -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;

View File

@ -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");

View File

@ -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<Region> enderPortalRegions = new ArrayList<>();
public SpawnEnderPortalEffect(String audience) {
super(audience);
}
public static void checkPortalRegion(Location location) {
Iterator<Region> 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;

View File

@ -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);

View File

@ -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);

View File

@ -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) {

View File

@ -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

View File

@ -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<FallingBlock> 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));
}
}

View File

@ -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);
}
}

View File

@ -154,7 +154,7 @@ public class Game {
return startd;
}
public void addTasks(BukkitTask task) {
public void addTask(BukkitTask task) {
this.tasks.add(task);
}

View File

@ -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);

View File

@ -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]