测试版1.0.5

This commit is contained in:
yaohunya 2024-08-11 13:59:20 +08:00
parent 7ce09606ba
commit 832e93a2ef
6 changed files with 156 additions and 0 deletions

View File

@ -0,0 +1,71 @@
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.entity.Player;
import org.bukkit.entity.TNTPrimed;
import org.bukkit.scheduler.BukkitRunnable;
import org.bukkit.scheduler.BukkitTask;
import java.util.ArrayList;
import java.util.Collections;
import java.util.List;
import java.util.Random;
public class RandomBox extends GiftEffect {
public RandomBox(String audience) {
super(audience);
}
@Override
public void apply(Game game) {
Player player = game.getPlayer();
List<String> stringList = new ArrayList<>();
stringList.add("清理背包");
stringList.add("火山喷发");
stringList.add("幸运方块");
stringList.add("黑洞");
stringList.add("五雷轰顶");
stringList.add("装备清空");
stringList.add("岩浆泡澡");
stringList.add("钢铁保安");
stringList.add("6倍血量");
stringList.add("原地复活");
stringList.add("魔豆天梯");
stringList.add("世界毁灭");
stringList.add("变大");
stringList.add("变小");
stringList.add("安全庇护所");
stringList.add("螺旋升天");
stringList.add("怪物军团");
Collections.shuffle(stringList);
Random random = new Random();
String eventName = stringList.get(random.nextInt(stringList.size()));
BukkitTask task = new BukkitRunnable() {
private int i = 0;
@Override
public void run() {
if (i >= 12) {
player.sendTitle("§6随机盲盒","§9整蛊效果: §e"+eventName);
player.playSound(player.getLocation(),Sound.BLOCK_COMPARATOR_CLICK,1,1);
GiftEffectManager.addGiftEffect(getAudience(),eventName);
Bukkit.broadcastMessage("§c[消息]§a随机盲盒抽中了 §e"+eventName);
cancel();
return;
}
player.sendTitle("§6随机盲盒","§9整蛊效果: §e"+stringList.get(random.nextInt(stringList.size())));
player.playSound(player.getLocation(),Sound.BLOCK_COMPARATOR_CLICK,1,1);
i++;
}
}.runTaskTimer(Main.plugin, 0L, 5L);
Main.game.addTasks(task);
}
}

View File

@ -15,6 +15,8 @@ public class SummonIronGolem extends GiftEffect {
public void apply(Game game) { public void apply(Game game) {
Player player = game.getPlayer(); Player player = game.getPlayer();
player.getWorld().spawnEntity(player.getLocation(), EntityType.IRON_GOLEM); player.getWorld().spawnEntity(player.getLocation(), EntityType.IRON_GOLEM);
player.getWorld().spawnEntity(player.getLocation(), EntityType.IRON_GOLEM);
player.getWorld().spawnEntity(player.getLocation(), EntityType.IRON_GOLEM);
} }
} }

View File

@ -0,0 +1,32 @@
package com.yaohun.enderdragonwars.effect.types;
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;
import org.bukkit.util.Vector;
public class SummonMobs extends GiftEffect {
public SummonMobs(String audience) {
super(audience);
}
@Override
public void apply(Game game) {
Player player = game.getPlayer();
for (int i = 0; i < 5;i++){
Zombie zombie = (Zombie) player.getWorld().spawnEntity(player.getLocation(), EntityType.ZOMBIE);
zombie.setVelocity(new Vector(RandomUtil.getRandomDouble(-1,1,1),RandomUtil.getRandomDouble(-1,1,1),RandomUtil.getRandomDouble(-1,1,1)));
}
for (int i = 0; i < 5;i++){
Creeper creeper = (Creeper) player.getWorld().spawnEntity(player.getLocation(), EntityType.CREEPER);
creeper.setVelocity(new Vector(RandomUtil.getRandomDouble(-1,1,1),RandomUtil.getRandomDouble(-1,1,1),RandomUtil.getRandomDouble(-1,1,1)));
}
}
}

View File

@ -0,0 +1,46 @@
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.Location;
import org.bukkit.entity.Creeper;
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 {
public WuHuJump(String audience) {
super(audience);
}
@Override
public void apply(Game game) {
Player player = game.getPlayer();
player.setVelocity(player.getLocation().getDirection().multiply(0.5).setY(1.0));
player.playEffect(player.getLocation(), Effect.MOBSPAWNER_FLAMES, 10);
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();}
Location location = player.getLocation();
TNTPrimed tntPrimed = (TNTPrimed) location.getWorld().spawnEntity(location.clone().add(0,-0.5,0), EntityType.PRIMED_TNT);
tntPrimed.setFuseTicks(5);
tntPrimed.setYield(0.0F);
location.getWorld().playSound(location, Sound.ENTITY_CREEPER_PRIMED, 1.0f, 1.0f);
i++;
}
}.runTaskTimer(Main.plugin, 2L,1L);
game.addTasks(task);
}
}

View File

@ -119,6 +119,9 @@ public class Game {
return startd; return startd;
} }
public void addTasks(BukkitTask task){
this.tasks.add(task);
}
public long getLiveTime() { public long getLiveTime() {
return liveTime; return liveTime;
} }

View File

@ -56,6 +56,8 @@ public class GiftEffectManager {
registerGiftEffect("变小", PlayerSmallEffect::new); registerGiftEffect("变小", PlayerSmallEffect::new);
registerGiftEffect("安全庇护所", SpawnBuildEffect::new); registerGiftEffect("安全庇护所", SpawnBuildEffect::new);
registerGiftEffect("螺旋升天", ToHeavenEffect::new); registerGiftEffect("螺旋升天", ToHeavenEffect::new);
registerGiftEffect("怪物军团", SummonMobs::new);
registerGiftEffect("芜湖起飞", WuHuJump::new);
} }
private static void registerGiftEffect(String id, Function<String, GiftEffect> giftEffectGetter) { private static void registerGiftEffect(String id, Function<String, GiftEffect> giftEffectGetter) {