1.0
This commit is contained in:
commit
63146da5d5
3
.gitignore
vendored
Normal file
3
.gitignore
vendored
Normal file
|
@ -0,0 +1,3 @@
|
|||
/.idea/
|
||||
/EnderDragonWar.iml
|
||||
/target/
|
BIN
lib/FastAsyncWorldEdit.jar
Normal file
BIN
lib/FastAsyncWorldEdit.jar
Normal file
Binary file not shown.
BIN
lib/NBTAPI.jar
Normal file
BIN
lib/NBTAPI.jar
Normal file
Binary file not shown.
BIN
lib/PixelLiveAPI-1.0.jar
Normal file
BIN
lib/PixelLiveAPI-1.0.jar
Normal file
Binary file not shown.
76
pom.xml
Normal file
76
pom.xml
Normal file
|
@ -0,0 +1,76 @@
|
|||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<project xmlns="http://maven.apache.org/POM/4.0.0"
|
||||
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
||||
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
|
||||
<modelVersion>4.0.0</modelVersion>
|
||||
|
||||
<groupId>com.io.yutian</groupId>
|
||||
<artifactId>EnderDragonWar</artifactId>
|
||||
<version>1.0</version>
|
||||
<packaging>jar</packaging>
|
||||
|
||||
<name>EnderDragonWar</name>
|
||||
|
||||
<properties>
|
||||
<java.version>21</java.version>
|
||||
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
|
||||
</properties>
|
||||
|
||||
<build>
|
||||
<defaultGoal>clean package</defaultGoal>
|
||||
<plugins>
|
||||
<plugin>
|
||||
<groupId>org.apache.maven.plugins</groupId>
|
||||
<artifactId>maven-compiler-plugin</artifactId>
|
||||
<version>3.13.0</version>
|
||||
<configuration>
|
||||
<source>${java.version}</source>
|
||||
<target>${java.version}</target>
|
||||
</configuration>
|
||||
</plugin>
|
||||
<plugin>
|
||||
<groupId>org.apache.maven.plugins</groupId>
|
||||
<artifactId>maven-shade-plugin</artifactId>
|
||||
<version>3.5.3</version>
|
||||
<executions>
|
||||
<execution>
|
||||
<phase>package</phase>
|
||||
<goals>
|
||||
<goal>shade</goal>
|
||||
</goals>
|
||||
</execution>
|
||||
</executions>
|
||||
</plugin>
|
||||
</plugins>
|
||||
<resources>
|
||||
<resource>
|
||||
<directory>src/main/resources</directory>
|
||||
<filtering>true</filtering>
|
||||
</resource>
|
||||
</resources>
|
||||
</build>
|
||||
|
||||
<repositories>
|
||||
<repository>
|
||||
<id>papermc-repo</id>
|
||||
<url>https://repo.papermc.io/repository/maven-public/</url>
|
||||
</repository>
|
||||
<repository>
|
||||
<id>sonatype</id>
|
||||
<url>https://oss.sonatype.org/content/groups/public/</url>
|
||||
</repository>
|
||||
<repository>
|
||||
<id>public-rpg</id>
|
||||
<url>https://repo.aurora-pixels.com/repository/public-rpg/</url>
|
||||
</repository>
|
||||
</repositories>
|
||||
|
||||
<dependencies>
|
||||
<dependency>
|
||||
<groupId>io.papermc.paper</groupId>
|
||||
<artifactId>paper-api</artifactId>
|
||||
<version>1.20.6-R0.1-SNAPSHOT</version>
|
||||
<scope>provided</scope>
|
||||
</dependency>
|
||||
</dependencies>
|
||||
</project>
|
42
src/main/java/com/yaohun/enderdragonwars/Main.java
Normal file
42
src/main/java/com/yaohun/enderdragonwars/Main.java
Normal file
|
@ -0,0 +1,42 @@
|
|||
package com.yaohun.enderdragonwars;
|
||||
|
||||
import com.yaohun.enderdragonwars.game.Game;
|
||||
import com.yaohun.enderdragonwars.game.GameSetting;
|
||||
import com.yaohun.enderdragonwars.listener.GameListener;
|
||||
import com.yaohun.enderdragonwars.listener.LiveListener;
|
||||
import com.yaohun.enderdragonwars.listener.PlayerListener;
|
||||
import com.yaohun.enderdragonwars.manager.GiftEffectManager;
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.command.Command;
|
||||
import org.bukkit.command.CommandSender;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.plugin.java.JavaPlugin;
|
||||
|
||||
public class Main extends JavaPlugin {
|
||||
|
||||
public static Main plugin;
|
||||
public static Game game;
|
||||
|
||||
@Override
|
||||
public void onEnable() {
|
||||
plugin = this;
|
||||
GiftEffectManager.registerAll();
|
||||
GameSetting.load();
|
||||
game = new Game();
|
||||
|
||||
Bukkit.getPluginManager().registerEvents(new PlayerListener(), this);
|
||||
Bukkit.getPluginManager().registerEvents(new GameListener(), this);
|
||||
Bukkit.getPluginManager().registerEvents(new LiveListener(), this);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean onCommand(CommandSender sender, Command command, String Command, String[] args) {
|
||||
if (args.length == 1 && args[0].equalsIgnoreCase("start")) {
|
||||
Player player = (Player) sender;
|
||||
game.startGame(player);
|
||||
return true;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
}
|
|
@ -0,0 +1,84 @@
|
|||
package com.yaohun.enderdragonwars.data;
|
||||
|
||||
import org.bukkit.Location;
|
||||
import org.bukkit.World;
|
||||
import org.bukkit.configuration.ConfigurationSection;
|
||||
|
||||
import java.util.Objects;
|
||||
|
||||
public class DirectionPoint extends Point {
|
||||
|
||||
private float yaw;
|
||||
private float pitch;
|
||||
|
||||
public DirectionPoint(int x, int y, int z, float yaw, float pitch) {
|
||||
super(x, y, z);
|
||||
this.yaw = yaw;
|
||||
this.pitch = pitch;
|
||||
}
|
||||
|
||||
public DirectionPoint(double x, double y, double z) {
|
||||
this(x, y, z, 0f, 0f);
|
||||
}
|
||||
|
||||
public DirectionPoint(double x, double y, double z, float yaw, float pitch) {
|
||||
super(x, y, z);
|
||||
this.yaw = yaw;
|
||||
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;
|
||||
}
|
||||
|
||||
public void setYaw(float yaw) {
|
||||
this.yaw = yaw;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Location toLocation(World world) {
|
||||
return new Location(world, getX(), getY(), getZ(), yaw, pitch);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return "DirectionPoint{" +
|
||||
"x=" + getX() +
|
||||
", y=" + getY() +
|
||||
", z=" + getZ() +
|
||||
", yaw=" + yaw +
|
||||
", pitch=" + pitch +
|
||||
'}';
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean equals(Object o) {
|
||||
if (this == o) return true;
|
||||
if (o == null || getClass() != o.getClass()) return false;
|
||||
if (!super.equals(o)) return false;
|
||||
DirectionPoint that = (DirectionPoint) o;
|
||||
return super.equals(o) && Float.compare(that.yaw, yaw) == 0 && Float.compare(that.pitch, pitch) == 0;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int hashCode() {
|
||||
return Objects.hash(super.hashCode(), yaw, pitch);
|
||||
}
|
||||
|
||||
}
|
101
src/main/java/com/yaohun/enderdragonwars/data/Point.java
Normal file
101
src/main/java/com/yaohun/enderdragonwars/data/Point.java
Normal file
|
@ -0,0 +1,101 @@
|
|||
package com.yaohun.enderdragonwars.data;
|
||||
|
||||
import org.bukkit.Location;
|
||||
import org.bukkit.World;
|
||||
import org.bukkit.configuration.ConfigurationSection;
|
||||
|
||||
import java.util.Objects;
|
||||
|
||||
public class Point {
|
||||
|
||||
private double x;
|
||||
private double y;
|
||||
private double z;
|
||||
|
||||
public Point(int x, int y, int z) {
|
||||
this.x = x;
|
||||
this.y = y;
|
||||
this.z = z;
|
||||
}
|
||||
|
||||
public Point(double x, double y, double z) {
|
||||
this.x = x;
|
||||
this.y = y;
|
||||
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);
|
||||
}
|
||||
|
||||
public int getBlockY() {
|
||||
return (int) Math.floor(y);
|
||||
}
|
||||
|
||||
public int getBlockZ() {
|
||||
return (int) Math.floor(z);
|
||||
}
|
||||
|
||||
public double getX() {
|
||||
return x;
|
||||
}
|
||||
|
||||
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;
|
||||
}
|
||||
|
||||
public Point clone() {
|
||||
return new Point(x, y, z);
|
||||
}
|
||||
|
||||
public Location toLocation(World world) {
|
||||
return new Location(world, x, y, z, 0, 0);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return "Point{" +
|
||||
"x=" + x +
|
||||
", y=" + y +
|
||||
", z=" + z +
|
||||
'}';
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean equals(Object o) {
|
||||
if (this == o) return true;
|
||||
if (o == null || getClass() != o.getClass()) return false;
|
||||
Point point = (Point) o;
|
||||
return Double.compare(point.x, x) == 0 && Double.compare(point.y, y) == 0 && Double.compare(point.z, z) == 0;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int hashCode() {
|
||||
return Objects.hash(x, y, z);
|
||||
}
|
||||
|
||||
}
|
51
src/main/java/com/yaohun/enderdragonwars/data/Region.java
Normal file
51
src/main/java/com/yaohun/enderdragonwars/data/Region.java
Normal file
|
@ -0,0 +1,51 @@
|
|||
package com.yaohun.enderdragonwars.data;
|
||||
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.Location;
|
||||
import org.bukkit.World;
|
||||
import org.bukkit.configuration.ConfigurationSection;
|
||||
|
||||
public class Region {
|
||||
|
||||
private World world;
|
||||
private Point min;
|
||||
private Point max;
|
||||
|
||||
public Region(World world, Point min, Point max) {
|
||||
this.world = world;
|
||||
this.min = min;
|
||||
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;
|
||||
}
|
||||
|
||||
public Point getMin() {
|
||||
return min;
|
||||
}
|
||||
|
||||
public Point getMax() {
|
||||
return max;
|
||||
}
|
||||
|
||||
public boolean isInRegion(Location location) {
|
||||
if (!location.getWorld().getName().equalsIgnoreCase(world.getName())) {
|
||||
return false;
|
||||
}
|
||||
return (location.getBlockX() >= this.min.getX()
|
||||
&& location.getBlockX() <= this.max.getX()
|
||||
&& location.getBlockY() >= this.min.getY()
|
||||
&& location.getBlockY() <= this.max.getY()
|
||||
&& location.getBlockZ() >= this.min.getZ()
|
||||
&& location.getBlockZ() <= this.max.getZ());
|
||||
}
|
||||
|
||||
}
|
|
@ -0,0 +1,20 @@
|
|||
package com.yaohun.enderdragonwars.effect;
|
||||
|
||||
import com.io.yutian.pixelliveapi.effect.GiftEffect;
|
||||
import com.yaohun.enderdragonwars.Main;
|
||||
import com.yaohun.enderdragonwars.game.Game;
|
||||
|
||||
public abstract class GameGiftEffect extends GiftEffect {
|
||||
|
||||
public GameGiftEffect(String audience) {
|
||||
super(audience);
|
||||
}
|
||||
|
||||
public abstract void apply(Game game);
|
||||
|
||||
@Override
|
||||
public void apply() {
|
||||
apply(Main.game);
|
||||
}
|
||||
|
||||
}
|
|
@ -0,0 +1,48 @@
|
|||
package com.yaohun.enderdragonwars.effect.types;
|
||||
|
||||
import com.yaohun.enderdragonwars.Main;
|
||||
import com.yaohun.enderdragonwars.effect.GameGiftEffect;
|
||||
import com.yaohun.enderdragonwars.game.Game;
|
||||
import org.bukkit.Particle;
|
||||
import org.bukkit.attribute.Attribute;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.scheduler.BukkitRunnable;
|
||||
|
||||
import java.util.UUID;
|
||||
|
||||
public class AddMaxHealthEffect extends GameGiftEffect {
|
||||
|
||||
public static UUID uuid = UUID.randomUUID();
|
||||
|
||||
public AddMaxHealthEffect(String audience) {
|
||||
super(audience);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void apply(Game game) {
|
||||
Player player = game.getPlayer();
|
||||
new BukkitRunnable() {
|
||||
private int count = 0;
|
||||
|
||||
@Override
|
||||
public void run() {
|
||||
if (count >= 50) {
|
||||
cancel();
|
||||
return;
|
||||
}
|
||||
player.spawnParticle(Particle.HEART, player.getLocation().add(0, 0.5, 0), 1, 0.25, 0.25, 0.25, 0.1);
|
||||
if (player.getAttribute(Attribute.GENERIC_MAX_HEALTH).getValue() < 120) {
|
||||
player.getAttribute(Attribute.GENERIC_MAX_HEALTH).setBaseValue(player.getAttribute(Attribute.GENERIC_MAX_HEALTH).getBaseValue() + 2);
|
||||
player.setHealth(Math.min(player.getHealth() + 2, player.getMaxHealth()));
|
||||
}
|
||||
count++;
|
||||
}
|
||||
}.runTaskTimer(Main.plugin, 0L, 1L);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getQueueTime() {
|
||||
return 55;
|
||||
}
|
||||
|
||||
}
|
|
@ -0,0 +1,171 @@
|
|||
package com.yaohun.enderdragonwars.effect.types;
|
||||
|
||||
import com.yaohun.enderdragonwars.Main;
|
||||
import com.yaohun.enderdragonwars.effect.GameGiftEffect;
|
||||
import com.yaohun.enderdragonwars.game.Game;
|
||||
import com.yaohun.enderdragonwars.util.RandomUtil;
|
||||
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.FallingBlock;
|
||||
import org.bukkit.entity.LivingEntity;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.potion.PotionEffect;
|
||||
import org.bukkit.potion.PotionEffectType;
|
||||
import org.bukkit.scheduler.BukkitRunnable;
|
||||
import org.bukkit.util.Vector;
|
||||
|
||||
import java.util.*;
|
||||
|
||||
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) {
|
||||
List<FallingBlock> fallingBlocks = new ArrayList<>();
|
||||
Location location = game.getPlayer().getLocation().add(0, 2, 0);
|
||||
new BukkitRunnable() {
|
||||
private int i = 0;
|
||||
|
||||
@Override
|
||||
public void run() {
|
||||
if (i >= seconds * 2) {
|
||||
stop = true;
|
||||
fallingBlocks.forEach(fallingBlock -> fallingBlock.setGravity(true));
|
||||
location.getWorld().createExplosion(location, 3.0F, false, false);
|
||||
cancel();
|
||||
return;
|
||||
}
|
||||
Set<Block> blocks = getRandomUpBlocks(location, 6, 10);
|
||||
for (Block block : blocks) {
|
||||
FallingBlock fallingBlock = location.getWorld().spawnFallingBlock(block.getLocation().add(0.5, 0, 0.5), block.getBlockData());
|
||||
fallingBlock.setDropItem(false);
|
||||
fallingBlock.setHurtEntities(false);
|
||||
fallingBlock.setGravity(false);
|
||||
block.setType(Material.AIR);
|
||||
fallingBlocks.add(fallingBlock);
|
||||
}
|
||||
i++;
|
||||
}
|
||||
}.runTaskTimer(Main.plugin, 0L, 10L);
|
||||
new BukkitRunnable() {
|
||||
private Set<UUID> uuids = new HashSet<>();
|
||||
|
||||
@Override
|
||||
public void run() {
|
||||
if (stop) {
|
||||
cancel();
|
||||
return;
|
||||
}
|
||||
double r = 16;
|
||||
for (Entity entity : location.getWorld().getNearbyEntities(location, r, r, r)) {
|
||||
if (entity instanceof FallingBlock) {
|
||||
continue;
|
||||
}
|
||||
Location location1 = entity.getLocation();
|
||||
Vector vector = location.toVector().subtract(location1.toVector());
|
||||
vector.normalize();
|
||||
vector.multiply(0.25);
|
||||
entity.setVelocity(vector);
|
||||
if (entity instanceof LivingEntity livingEntity) {
|
||||
livingEntity.damage(1);
|
||||
}
|
||||
if (entity instanceof Player player) {
|
||||
player.addPotionEffect(new PotionEffect(PotionEffectType.SLOWNESS, 20 * 3, 0, true, true, true));
|
||||
}
|
||||
}
|
||||
Iterator<FallingBlock> iterator = fallingBlocks.iterator();
|
||||
while (iterator.hasNext()) {
|
||||
FallingBlock fallingBlock = iterator.next();
|
||||
org.bukkit.util.Vector vector = fallingBlock.getLocation().toVector();
|
||||
org.bukkit.util.Vector vector1 = location.toVector();
|
||||
Vector vector2 = vector1.subtract(vector);
|
||||
vector2.normalize();
|
||||
vector2.multiply(0.65);
|
||||
fallingBlock.setVelocity(vector2);
|
||||
if (!uuids.contains(fallingBlock.getUniqueId())) {
|
||||
if (RandomUtil.random(0.5)) {
|
||||
uuids.add(fallingBlock.getUniqueId());
|
||||
} else {
|
||||
fallingBlock.remove();
|
||||
iterator.remove();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}.runTaskTimer(Main.plugin, 0L, 5L);
|
||||
new BukkitRunnable() {
|
||||
private Set<UUID> uuids = new HashSet<>();
|
||||
|
||||
@Override
|
||||
public void run() {
|
||||
if (stop) {
|
||||
cancel();
|
||||
return;
|
||||
}
|
||||
location.getWorld().spawnParticle(Particle.CLOUD, location, 10, 1.5, 1.5, 1.5, 0.01);
|
||||
location.getWorld().spawnParticle(Particle.INFESTED, location, 10, 1.5, 1.5, 1.5, 0.01);
|
||||
location.getWorld().spawnParticle(Particle.LARGE_SMOKE, location, 10, 1.5, 1.5, 1.5, 0.01);
|
||||
location.getWorld().spawnParticle(Particle.SQUID_INK, location, 10, 1.5, 1.5, 1.5, 0.01);
|
||||
Iterator<FallingBlock> iterator = fallingBlocks.iterator();
|
||||
while (iterator.hasNext()) {
|
||||
FallingBlock fallingBlock = iterator.next();
|
||||
org.bukkit.util.Vector vector = fallingBlock.getLocation().toVector();
|
||||
org.bukkit.util.Vector vector1 = location.toVector();
|
||||
Vector vector2 = vector1.subtract(vector);
|
||||
vector2.normalize();
|
||||
vector2.multiply(0.65);
|
||||
fallingBlock.setVelocity(vector2);
|
||||
if (!uuids.contains(fallingBlock.getUniqueId())) {
|
||||
if (RandomUtil.random(0.5)) {
|
||||
uuids.add(fallingBlock.getUniqueId());
|
||||
} else {
|
||||
fallingBlock.remove();
|
||||
iterator.remove();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}.runTaskTimer(Main.plugin, 0L, 1L);
|
||||
}
|
||||
|
||||
private Set<Block> getRandomUpBlocks(Location location, int size, int amount) {
|
||||
List<Block> blocks = new ArrayList<>();
|
||||
int minX = location.getBlockX() - size;
|
||||
int minY = location.getBlockY() - size * 2;
|
||||
int minZ = location.getBlockZ() - size;
|
||||
int maxX = location.getBlockX() + size;
|
||||
int maxY = location.getBlockY() + size;
|
||||
int maxZ = location.getBlockZ() + size;
|
||||
for (int x = minX; x <= maxX; x++) {
|
||||
for (int z = minZ; z <= maxZ; z++) {
|
||||
for (int y = maxY; y >= minY; y--) {
|
||||
Block block = location.getWorld().getBlockAt(x, y, z);
|
||||
if (!block.getType().equals(Material.AIR)) {
|
||||
blocks.add(block);
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
Set<Block> blocks1 = new HashSet<>();
|
||||
if (blocks.isEmpty()) {
|
||||
return blocks1;
|
||||
}
|
||||
for (int i = 0; i < amount; i++) {
|
||||
int k = RandomUtil.getRandomInt(0, blocks.size() - 1);
|
||||
Block block = blocks.remove(k);
|
||||
blocks1.add(block);
|
||||
}
|
||||
return blocks1;
|
||||
}
|
||||
|
||||
}
|
|
@ -0,0 +1,217 @@
|
|||
package com.yaohun.enderdragonwars.effect.types;
|
||||
|
||||
import com.yaohun.enderdragonwars.Main;
|
||||
import com.yaohun.enderdragonwars.effect.GameGiftEffect;
|
||||
import com.yaohun.enderdragonwars.game.Game;
|
||||
import com.yaohun.enderdragonwars.util.EntityUtil;
|
||||
import net.kyori.adventure.text.Component;
|
||||
import org.bukkit.*;
|
||||
import org.bukkit.attribute.Attribute;
|
||||
import org.bukkit.boss.BarColor;
|
||||
import org.bukkit.boss.BarStyle;
|
||||
import org.bukkit.boss.BossBar;
|
||||
import org.bukkit.entity.*;
|
||||
import org.bukkit.event.entity.CreatureSpawnEvent;
|
||||
import org.bukkit.inventory.EquipmentSlot;
|
||||
import org.bukkit.inventory.ItemStack;
|
||||
import org.bukkit.inventory.meta.ColorableArmorMeta;
|
||||
import org.bukkit.inventory.meta.ItemMeta;
|
||||
import org.bukkit.scheduler.BukkitRunnable;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Iterator;
|
||||
import java.util.List;
|
||||
import java.util.Random;
|
||||
|
||||
public class BomBomEffect extends GameGiftEffect {
|
||||
|
||||
private static final ItemStack ITEM_1;
|
||||
private static final ItemStack ITEM_2;
|
||||
private static final ItemStack ITEM_3;
|
||||
private static final ItemStack ITEM_4;
|
||||
|
||||
private static final ItemStack ITEM_5;
|
||||
private static final ItemStack ITEM_6;
|
||||
private static final ItemStack ITEM_7;
|
||||
|
||||
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);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void apply(Game game) {
|
||||
bossBar = Bukkit.createBossBar("§4§l毁天灭地", BarColor.RED, BarStyle.SOLID);
|
||||
World world = game.getWorld();
|
||||
Player player = game.getPlayer();
|
||||
bossBar.addPlayer(player);
|
||||
ArmorStand armorStand = (ArmorStand) world.spawnEntity(player.getLocation(), EntityType.ARMOR_STAND, CreatureSpawnEvent.SpawnReason.CUSTOM, (entity) -> {
|
||||
ArmorStand armorStand1 = (ArmorStand) entity;
|
||||
armorStand1.setArms(true);
|
||||
armorStand1.setBasePlate(false);
|
||||
armorStand1.customName(Component.text("§4§l毁天灭地"));
|
||||
armorStand1.setCustomNameVisible(true);
|
||||
armorStand1.setDisabledSlots(EquipmentSlot.values());
|
||||
armorStand1.setInvulnerable(true);
|
||||
armorStand1.setGravity(false);
|
||||
armorStand1.getEquipment().setItemInMainHand(ITEM_1);
|
||||
armorStand1.getEquipment().setItemInOffHand(ITEM_1);
|
||||
armorStand1.getEquipment().setItem(EquipmentSlot.HEAD, ITEM_1);
|
||||
armorStand1.getEquipment().setItem(EquipmentSlot.CHEST, ITEM_2);
|
||||
armorStand1.getEquipment().setItem(EquipmentSlot.LEGS, ITEM_3);
|
||||
armorStand1.getEquipment().setItem(EquipmentSlot.FEET, ITEM_4);
|
||||
armorStand1.getAttribute(Attribute.GENERIC_SCALE).setBaseValue(6.0);
|
||||
});
|
||||
new BukkitRunnable() {
|
||||
private int count = 0;
|
||||
|
||||
@Override
|
||||
public void run() {
|
||||
Location loc = armorStand.getLocation().clone().add(0, 8, 0);
|
||||
if (count > 35) {
|
||||
armorStand.remove();
|
||||
for (int i = 0; i < 3; i++) {
|
||||
armorStand.getWorld().createExplosion(armorStand.getLocation(), 5f, true, true);
|
||||
}
|
||||
Random random = new Random();
|
||||
for (int i = 0; i < 500; i++) {
|
||||
FallingBlock fallingBlock = (FallingBlock) world.spawnEntity(loc, EntityType.FALLING_BLOCK, CreatureSpawnEvent.SpawnReason.CUSTOM, (fallingBlockEntity) -> {
|
||||
FallingBlock fallingBlock1 = (FallingBlock) fallingBlockEntity;
|
||||
fallingBlock1.setBlockData(Bukkit.createBlockData(Material.MAGMA_BLOCK));
|
||||
fallingBlock1.setDropItem(false);
|
||||
fallingBlock1.setCancelDrop(true);
|
||||
});
|
||||
fallingBlocks.add(fallingBlock);
|
||||
EntityUtil.shoot(fallingBlock, (Math.random() * 1.8D - 1.5D) * 0.1f, 0.2f + Math.random() * 0.1f, (Math.random() * 1.8D - 1.5D) * 0.1f, 3f + random.nextFloat() * 1.5f, 0f);
|
||||
player.getWorld().playSound(fallingBlock.getLocation(), Sound.ENTITY_GENERIC_EXPLODE, 1f, 1f);
|
||||
}
|
||||
bossBar.removeAll();
|
||||
stop = true;
|
||||
cancel();
|
||||
return;
|
||||
}
|
||||
Random random = new Random();
|
||||
for (int i = 0; i < 35; i++) {
|
||||
FallingBlock fallingBlock = (FallingBlock) world.spawnEntity(loc, EntityType.FALLING_BLOCK, CreatureSpawnEvent.SpawnReason.CUSTOM, (fallingBlockEntity) -> {
|
||||
FallingBlock fallingBlock1 = (FallingBlock) fallingBlockEntity;
|
||||
fallingBlock1.setBlockData(Bukkit.createBlockData(Material.MAGMA_BLOCK));
|
||||
fallingBlock1.setDropItem(false);
|
||||
fallingBlock1.setCancelDrop(true);
|
||||
fallingBlock1.setFireTicks(200);
|
||||
});
|
||||
fallingBlocks.add(fallingBlock);
|
||||
EntityUtil.shoot(fallingBlock, (Math.random() * 2.5D - 1.5D) * 0.1f, 0.4f + Math.random() * 0.15f, (Math.random() * 2.5D - 1.5D) * 0.1f, 3f + random.nextFloat() * 1.5f, 0f);
|
||||
player.getWorld().playSound(fallingBlock.getLocation(), Sound.ENTITY_GENERIC_EXPLODE, 1f, 1f);
|
||||
}
|
||||
for (int i = 0; i < 15; i++) {
|
||||
TNTPrimed tntPrimed = (TNTPrimed) world.spawnEntity(loc, EntityType.TNT, CreatureSpawnEvent.SpawnReason.CUSTOM, (tntEntity) -> {
|
||||
TNTPrimed tntPrimed1 = (TNTPrimed) tntEntity;
|
||||
tntPrimed1.setFuseTicks(80);
|
||||
tntPrimed1.setYield(4);
|
||||
});
|
||||
EntityUtil.shoot(tntPrimed, (Math.random() * 2D - 1.5D) * 0.08f, 0.1f + Math.random() * 0.025f, (Math.random() * 2D - 1.5D) * 0.08f, 3f + random.nextFloat() * 1.5f, 0f);
|
||||
}
|
||||
count++;
|
||||
}
|
||||
}.runTaskTimer(Main.plugin, 0L, 15L);
|
||||
new BukkitRunnable() {
|
||||
private int count = 0;
|
||||
|
||||
@Override
|
||||
public void run() {
|
||||
if (stop) {
|
||||
cancel();
|
||||
return;
|
||||
}
|
||||
boolean flag = count % 2 == 0;
|
||||
armorStand.customName(Component.text(flag ? "§4§l毁天灭地" : "§c§l毁天灭地"));
|
||||
armorStand.getEquipment().setItem(EquipmentSlot.CHEST, flag ? ITEM_2 : ITEM_5);
|
||||
armorStand.getEquipment().setItem(EquipmentSlot.LEGS, flag ? ITEM_3 : ITEM_6);
|
||||
armorStand.getEquipment().setItem(EquipmentSlot.FEET, flag ? ITEM_4 : ITEM_7);
|
||||
bossBar.setTitle(flag ? "§4§l毁天灭地" : "§c§l毁天灭地");
|
||||
count++;
|
||||
}
|
||||
}.runTaskTimer(Main.plugin, 0L, 5L);
|
||||
new BukkitRunnable() {
|
||||
private int count = 0;
|
||||
|
||||
@Override
|
||||
public void run() {
|
||||
if (stop) {
|
||||
cancel();
|
||||
return;
|
||||
}
|
||||
float f = count * 25F;
|
||||
armorStand.setRotation(f, 0);
|
||||
Location location1 = armorStand.getLocation().clone().add(0, 0.35, 0);
|
||||
armorStand.getWorld().spawnParticle(Particle.LAVA, location1, 5, 0.2, 0.6, 0.2, 0.05);
|
||||
armorStand.getWorld().spawnParticle(Particle.FLAME, location1, 5, 0.2, 1, 0.2, 0.01);
|
||||
count++;
|
||||
}
|
||||
}.runTaskTimer(Main.plugin, 0L, 2L);
|
||||
new BukkitRunnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
if (fallingBlocks.isEmpty()) {
|
||||
cancel();
|
||||
return;
|
||||
}
|
||||
Iterator<FallingBlock> iterator = fallingBlocks.iterator();
|
||||
while (iterator.hasNext()) {
|
||||
FallingBlock fallingBlock = iterator.next();
|
||||
Location location = fallingBlock.getLocation();
|
||||
if (fallingBlock.isOnGround() || fallingBlock.isDead()) {
|
||||
location.getWorld().createExplosion(location, 5f, true, true);
|
||||
armorStand.getWorld().spawnParticle(Particle.LAVA, fallingBlock.getLocation(), 35, 1.5, 1.5, 1.5, 0.05);
|
||||
armorStand.getWorld().spawnParticle(Particle.FLAME, fallingBlock.getLocation(), 35, 1.5, 1.5, 1.5, 0.01);
|
||||
location.add(0, 1, 0).getBlock().setType(Material.LAVA);
|
||||
fallingBlock.remove();
|
||||
iterator.remove();
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
}.runTaskTimer(Main.plugin, 0L, 1L);
|
||||
}
|
||||
|
||||
}
|
|
@ -0,0 +1,93 @@
|
|||
package com.yaohun.enderdragonwars.effect.types;
|
||||
|
||||
import com.io.yutian.pixelliveapi.effect.GiftEffect;
|
||||
import com.yaohun.enderdragonwars.Main;
|
||||
import com.yaohun.enderdragonwars.effect.GameGiftEffect;
|
||||
import com.yaohun.enderdragonwars.game.Game;
|
||||
import com.yaohun.enderdragonwars.util.RandomUtil;
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.Particle;
|
||||
import org.bukkit.Sound;
|
||||
import org.bukkit.World;
|
||||
import org.bukkit.entity.Allay;
|
||||
import org.bukkit.entity.EntityType;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.event.entity.CreatureSpawnEvent;
|
||||
import org.bukkit.inventory.ItemStack;
|
||||
import org.bukkit.scheduler.BukkitRunnable;
|
||||
import org.bukkit.util.Vector;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
public class ClearInventoryEffect extends GameGiftEffect {
|
||||
|
||||
public ClearInventoryEffect(String audience) {
|
||||
super(audience);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void apply(Game game) {
|
||||
World world = game.getWorld();
|
||||
Player player = game.getPlayer();
|
||||
List<Allay> allays = new ArrayList<>();
|
||||
new BukkitRunnable() {
|
||||
private int totalCount = Math.max(15, getUseableItemCount(player).size());
|
||||
private int count = 0;
|
||||
|
||||
@Override
|
||||
public void run() {
|
||||
if (count > totalCount) {
|
||||
for (Allay allay : allays) {
|
||||
allay.getWorld().spawnParticle(Particle.WAX_OFF, allay.getLocation(), 30, 0.5, 0.5, 0.5, 0.1);
|
||||
allay.remove();
|
||||
}
|
||||
player.getInventory().clear();
|
||||
cancel();
|
||||
return;
|
||||
}
|
||||
Allay allay = (Allay) world.spawnEntity(player.getLocation().add(0, 1, 0), EntityType.ALLAY, CreatureSpawnEvent.SpawnReason.CUSTOM, (entity) -> {
|
||||
Allay allay1 = (Allay) entity;
|
||||
Vector vector = player.getEyeLocation().getDirection();
|
||||
vector.normalize();
|
||||
vector.multiply(0.5);
|
||||
allay1.setVelocity(vector);
|
||||
allay1.setGlowing(true);
|
||||
allay1.setCollidable(false);
|
||||
allay1.setInvulnerable(true);
|
||||
ItemStack item = takeRandomItem(player);
|
||||
if (item == null) {
|
||||
item = new ItemStack(Material.DIAMOND);
|
||||
}
|
||||
allay1.getEquipment().setItemInMainHand(item);
|
||||
});
|
||||
player.playSound(player.getLocation(), Sound.ENTITY_ITEM_PICKUP, 1, 1);
|
||||
allays.add(allay);
|
||||
count++;
|
||||
}
|
||||
}.runTaskTimer(Main.plugin, 10L, 4L);
|
||||
}
|
||||
|
||||
private List<Integer> getUseableItemCount(Player player) {
|
||||
List<Integer> useableSlots = new ArrayList<>();
|
||||
for (int i = 0; i < 36; i++) {
|
||||
ItemStack item = player.getInventory().getItem(i);
|
||||
if (item != null && item.getType() != Material.AIR) {
|
||||
useableSlots.add(i);
|
||||
}
|
||||
}
|
||||
return useableSlots;
|
||||
}
|
||||
|
||||
private ItemStack takeRandomItem(Player player) {
|
||||
List<Integer> useableSlots = getUseableItemCount(player);
|
||||
if (useableSlots.isEmpty()) {
|
||||
return null;
|
||||
}
|
||||
int i = RandomUtil.getRandomInt(0, useableSlots.size() - 1);
|
||||
ItemStack item = player.getInventory().getItem(useableSlots.get(i));
|
||||
player.getInventory().setItem(useableSlots.get(i), null);
|
||||
return item;
|
||||
}
|
||||
|
||||
}
|
|
@ -0,0 +1,33 @@
|
|||
package com.yaohun.enderdragonwars.effect.types;
|
||||
|
||||
import com.yaohun.enderdragonwars.Main;
|
||||
import com.yaohun.enderdragonwars.effect.GameGiftEffect;
|
||||
import com.yaohun.enderdragonwars.game.Game;
|
||||
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) {
|
||||
Player player = game.getPlayer();
|
||||
new BukkitRunnable() {
|
||||
private int count = 0;
|
||||
|
||||
@Override
|
||||
public void run() {
|
||||
if (count > 5) {
|
||||
cancel();
|
||||
return;
|
||||
}
|
||||
player.getWorld().strikeLightning(player.getLocation());
|
||||
count++;
|
||||
}
|
||||
}.runTaskTimer(Main.plugin, 0, 10L);
|
||||
}
|
||||
|
||||
}
|
|
@ -0,0 +1,21 @@
|
|||
package com.yaohun.enderdragonwars.effect.types;
|
||||
|
||||
import com.yaohun.enderdragonwars.effect.GameGiftEffect;
|
||||
import com.yaohun.enderdragonwars.game.Game;
|
||||
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) {
|
||||
Player player = game.getPlayer();
|
||||
player.getInventory().addItem(new ItemStack(Material.TOTEM_OF_UNDYING));
|
||||
}
|
||||
|
||||
}
|
|
@ -0,0 +1,71 @@
|
|||
package com.yaohun.enderdragonwars.effect.types;
|
||||
|
||||
import com.yaohun.enderdragonwars.effect.GameGiftEffect;
|
||||
import com.yaohun.enderdragonwars.game.Game;
|
||||
import com.yaohun.enderdragonwars.util.RandomUtil;
|
||||
import net.kyori.adventure.text.Component;
|
||||
import org.bukkit.Location;
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.block.Block;
|
||||
import org.bukkit.entity.Blaze;
|
||||
import org.bukkit.entity.EntityType;
|
||||
import org.bukkit.entity.MagmaCube;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.potion.PotionEffect;
|
||||
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();
|
||||
Location location = player.getLocation();
|
||||
|
||||
int size = 20;
|
||||
|
||||
int minX = location.getBlockX() - size / 2;
|
||||
int minY = location.getBlockY() - 3;
|
||||
int minZ = location.getBlockZ() - size / 2;
|
||||
int maxX = location.getBlockX() + size / 2;
|
||||
int maxY = location.getBlockY();
|
||||
int maxZ = location.getBlockZ() + size / 2;
|
||||
|
||||
for (int i = 0; i < 6; i++) {
|
||||
Location location1 = getRandomLocation(location.add(0, 3, 0), size - 3, 3, size - 3);
|
||||
Blaze blaze = (Blaze) location1.getWorld().spawnEntity(location1, EntityType.BLAZE);
|
||||
blaze.setTarget(player);
|
||||
blaze.customName(Component.text("§4§l烈焰人"));
|
||||
blaze.setCustomNameVisible(true);
|
||||
}
|
||||
for (int i = 0; i < 6; i++) {
|
||||
Location location1 = getRandomLocation(location, size - 3, 0, size - 3);
|
||||
MagmaCube magmaCube = (MagmaCube) location1.getWorld().spawnEntity(location1, EntityType.MAGMA_CUBE);
|
||||
magmaCube.setTarget(player);
|
||||
magmaCube.customName(Component.text("§4§l岩浆怪"));
|
||||
magmaCube.setCustomNameVisible(true);
|
||||
}
|
||||
player.addPotionEffect(new PotionEffect(PotionEffectType.FIRE_RESISTANCE, 20 * 60, 1, true, true, true));
|
||||
|
||||
for (int x = minX; x <= maxX; x++) {
|
||||
for (int y = minY; y <= maxY; y++) {
|
||||
for (int z = minZ; z <= maxZ; z++) {
|
||||
Block block = location.getWorld().getBlockAt(x, y, z);
|
||||
block.setType(Material.LAVA);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
private Location getRandomLocation(Location location, double xRange, double yRange, double zRange) {
|
||||
return new Location(location.getWorld(),
|
||||
RandomUtil.getRandomDouble(location.getX() - xRange, location.getX() + xRange, 1),
|
||||
RandomUtil.getRandomDouble(location.getY() - yRange, location.getY() + yRange, 1),
|
||||
RandomUtil.getRandomDouble(location.getZ() - zRange, location.getZ() + zRange, 1));
|
||||
}
|
||||
|
||||
}
|
|
@ -0,0 +1,92 @@
|
|||
package com.yaohun.enderdragonwars.effect.types;
|
||||
|
||||
import com.yaohun.enderdragonwars.effect.GameGiftEffect;
|
||||
import com.yaohun.enderdragonwars.game.Game;
|
||||
import com.yaohun.enderdragonwars.util.ItemStackBuilder;
|
||||
import com.yaohun.enderdragonwars.util.RandomUtil;
|
||||
import org.bukkit.*;
|
||||
import org.bukkit.block.Block;
|
||||
import org.bukkit.enchantments.Enchantment;
|
||||
import org.bukkit.entity.Item;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.inventory.ItemStack;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
public class LuckyBlockEffect extends GameGiftEffect {
|
||||
|
||||
private static List<ItemStack> itemStacks = new ArrayList<>();
|
||||
|
||||
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());
|
||||
|
||||
}
|
||||
|
||||
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);
|
||||
player.playSound(player.getLocation(), Sound.ENTITY_PLAYER_LEVELUP, 1, 1);
|
||||
ItemStack itemStack = itemStacks.get(RandomUtil.getRandomInt(0, itemStacks.size() - 1));
|
||||
Item item = location.getWorld().dropItemNaturally(location, itemStack);
|
||||
item.setOwner(player.getUniqueId());
|
||||
if (itemStack.getItemMeta().hasDisplayName()) {
|
||||
item.customName(itemStack.getItemMeta().displayName());
|
||||
item.setCustomNameVisible(true);
|
||||
}
|
||||
item.setGlowing(true);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void apply(Game game) {
|
||||
game.getPlayer().getInventory().addItem(new ItemStackBuilder(Material.SPONGE).setDisplayName("§6§l幸运方块").build());
|
||||
}
|
||||
|
||||
}
|
|
@ -0,0 +1,26 @@
|
|||
package com.yaohun.enderdragonwars.effect.types;
|
||||
|
||||
import com.yaohun.enderdragonwars.effect.GameGiftEffect;
|
||||
import com.yaohun.enderdragonwars.game.Game;
|
||||
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) {
|
||||
Player player = game.getPlayer();
|
||||
if (player.getAttribute(Attribute.GENERIC_SCALE).getBaseValue() >= 20) {
|
||||
return;
|
||||
}
|
||||
player.getAttribute(Attribute.GENERIC_SCALE).setBaseValue(player.getAttribute(Attribute.GENERIC_SCALE).getBaseValue() + 0.5);
|
||||
player.getAttribute(Attribute.PLAYER_BLOCK_INTERACTION_RANGE).setBaseValue(player.getAttribute(Attribute.PLAYER_BLOCK_INTERACTION_RANGE).getBaseValue() + 1);
|
||||
player.getAttribute(Attribute.GENERIC_STEP_HEIGHT).setBaseValue(player.getAttribute(Attribute.GENERIC_STEP_HEIGHT).getBaseValue() + 1);
|
||||
player.getAttribute(Attribute.GENERIC_MOVEMENT_SPEED).setBaseValue(player.getAttribute(Attribute.GENERIC_MOVEMENT_SPEED).getBaseValue() + 0.03);
|
||||
}
|
||||
|
||||
}
|
|
@ -0,0 +1,22 @@
|
|||
package com.yaohun.enderdragonwars.effect.types;
|
||||
|
||||
import com.yaohun.enderdragonwars.effect.GameGiftEffect;
|
||||
import com.yaohun.enderdragonwars.game.Game;
|
||||
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) {
|
||||
Player player = game.getPlayer();
|
||||
player.getAttribute(Attribute.GENERIC_SCALE).setBaseValue(1);
|
||||
player.getAttribute(Attribute.PLAYER_BLOCK_INTERACTION_RANGE).setBaseValue(4.5);
|
||||
player.getAttribute(Attribute.GENERIC_STEP_HEIGHT).setBaseValue(0.6);
|
||||
}
|
||||
|
||||
}
|
|
@ -0,0 +1,26 @@
|
|||
package com.yaohun.enderdragonwars.effect.types;
|
||||
|
||||
import com.yaohun.enderdragonwars.effect.GameGiftEffect;
|
||||
import com.yaohun.enderdragonwars.game.Game;
|
||||
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) {
|
||||
Player player = game.getPlayer();
|
||||
if (player.getAttribute(Attribute.GENERIC_SCALE).getBaseValue() <= 0.1) {
|
||||
return;
|
||||
}
|
||||
player.getAttribute(Attribute.GENERIC_SCALE).setBaseValue(player.getAttribute(Attribute.GENERIC_SCALE).getBaseValue() - 0.5);
|
||||
player.getAttribute(Attribute.PLAYER_BLOCK_INTERACTION_RANGE).setBaseValue(player.getAttribute(Attribute.PLAYER_BLOCK_INTERACTION_RANGE).getBaseValue() - 0.5);
|
||||
player.getAttribute(Attribute.GENERIC_STEP_HEIGHT).setBaseValue(player.getAttribute(Attribute.GENERIC_STEP_HEIGHT).getBaseValue() - 1);
|
||||
player.getAttribute(Attribute.GENERIC_MOVEMENT_SPEED).setBaseValue(player.getAttribute(Attribute.GENERIC_MOVEMENT_SPEED).getBaseValue() - 0.03);
|
||||
}
|
||||
|
||||
}
|
|
@ -0,0 +1,77 @@
|
|||
package com.yaohun.enderdragonwars.effect.types;
|
||||
|
||||
import com.io.yutian.pixelliveapi.api.Anchor;
|
||||
import com.io.yutian.pixelliveapi.effect.GiftEffect;
|
||||
import com.io.yutian.pixelliveapi.effect.GiftEffectData;
|
||||
import com.io.yutian.pixelliveapi.manager.*;
|
||||
import com.io.yutian.pixelliveapi.util.ToolUtil;
|
||||
import com.yaohun.enderdragonwars.Main;
|
||||
import com.yaohun.enderdragonwars.effect.GameGiftEffect;
|
||||
import com.yaohun.enderdragonwars.game.Game;
|
||||
import com.yaohun.enderdragonwars.manager.GiftEffectManager;
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.Sound;
|
||||
import org.bukkit.entity.Player;
|
||||
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 RandomBoxEffect extends GameGiftEffect {
|
||||
|
||||
public RandomBoxEffect(String audience) {
|
||||
super(audience);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void apply(Game game) {
|
||||
Player player = game.getPlayer();
|
||||
List<String> list = getEffects();
|
||||
Collections.shuffle(list);
|
||||
Random random = new Random();
|
||||
String eventName = list.get(random.nextInt(list.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);
|
||||
EffectQueueManager.addGiftEffect(getAudience(), eventName, 1);
|
||||
Bukkit.broadcastMessage("§c[消息]§a随机盲盒抽中了 §e" + eventName);
|
||||
cancel();
|
||||
return;
|
||||
}
|
||||
player.sendTitle("§6随机盲盒", "§9整蛊效果: §e" + list.get(random.nextInt(list.size())));
|
||||
player.playSound(player.getLocation(), Sound.BLOCK_COMPARATOR_CLICK, 1, 1);
|
||||
i++;
|
||||
}
|
||||
}.runTaskTimer(Main.plugin, 0L, 5L);
|
||||
Main.game.addTasks(task);
|
||||
}
|
||||
|
||||
private List<String> getEffects() {
|
||||
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("怪物军团");
|
||||
return stringList;
|
||||
}
|
||||
|
||||
}
|
|
@ -0,0 +1,20 @@
|
|||
package com.yaohun.enderdragonwars.effect.types;
|
||||
|
||||
import com.yaohun.enderdragonwars.effect.GameGiftEffect;
|
||||
import com.yaohun.enderdragonwars.game.Game;
|
||||
import com.yaohun.enderdragonwars.util.WEUtil;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
public class SpawnBuildEffect extends GameGiftEffect {
|
||||
|
||||
public SpawnBuildEffect(String audience) {
|
||||
super(audience);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void apply(Game game) {
|
||||
Player player = game.getPlayer();
|
||||
WEUtil.loadSchematics(player.getLocation(), "anquanwu");
|
||||
}
|
||||
|
||||
}
|
|
@ -0,0 +1,81 @@
|
|||
package com.yaohun.enderdragonwars.effect.types;
|
||||
|
||||
import com.sk89q.worldedit.EditSession;
|
||||
import com.sk89q.worldedit.WorldEdit;
|
||||
import com.sk89q.worldedit.bukkit.BukkitAdapter;
|
||||
import com.sk89q.worldedit.function.operation.Operations;
|
||||
import com.sk89q.worldedit.math.BlockVector3;
|
||||
import com.sk89q.worldedit.regions.CuboidRegion;
|
||||
import com.yaohun.enderdragonwars.Main;
|
||||
import com.yaohun.enderdragonwars.data.Region;
|
||||
import com.yaohun.enderdragonwars.effect.GameGiftEffect;
|
||||
import com.yaohun.enderdragonwars.game.Game;
|
||||
import com.yaohun.enderdragonwars.util.BuildSpawner;
|
||||
import org.bukkit.Location;
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.World;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
import java.util.Iterator;
|
||||
import java.util.List;
|
||||
|
||||
public class SpawnEnderPortalEffect extends GameGiftEffect {
|
||||
|
||||
private static final List<Material> MATERIAL_LIST = Arrays.asList(Material.WHITE_WOOL, Material.BLACK_WOOL, Material.BROWN_WOOL, Material.BLUE_WOOL, Material.GREEN_WOOL, Material.RED_WOOL, Material.YELLOW_WOOL, Material.PURPLE_WOOL, Material.ORANGE_WOOL, Material.PINK_WOOL, Material.LIGHT_BLUE_WOOL, Material.LIME_WOOL);
|
||||
|
||||
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()) {
|
||||
Region region = iterator.next();
|
||||
if (region.isInRegion(location)) {
|
||||
com.sk89q.worldedit.world.World weWorld = BukkitAdapter.adapt(region.getWorld());
|
||||
BlockVector3 vector0 = BlockVector3.at(region.getMin().getBlockX(), region.getMin().getBlockY(), region.getMin().getBlockZ());
|
||||
BlockVector3 vector1 = BlockVector3.at(region.getMax().getBlockX(), region.getMax().getBlockY(), region.getMax().getBlockZ());
|
||||
CuboidRegion cuboidRegion0 = new CuboidRegion(weWorld, vector0, vector1);
|
||||
try (EditSession editSession = WorldEdit.getInstance().newEditSession(BukkitAdapter.adapt(region.getWorld()))) {
|
||||
editSession.setBlocks((com.sk89q.worldedit.regions.Region) cuboidRegion0, BukkitAdapter.asBlockType(Material.AIR));
|
||||
Operations.complete(editSession.commit());
|
||||
} catch (Exception e) {
|
||||
}
|
||||
iterator.remove();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void apply(Game game) {
|
||||
int chunkWight = 2;
|
||||
int chunkLength = 2;
|
||||
int ladderLength = 3;
|
||||
int ladderAmount = 5;
|
||||
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();
|
||||
BuildSpawner buildSpawner = new BuildSpawner(world, BuildSpawner.Direction.NORTH, location.getBlockX(), location.getBlockY() - 1, location.getBlockZ(), chunkWight, chunkLength, ladderLength, ladderAmount, platformWidth, platformLength, levelAmount, BuildSpawner.SpawnMode.MODE_2, MATERIAL_LIST);
|
||||
Region region = buildSpawner.getEffectiveRegion(world);
|
||||
for (int x = region.getMin().getBlockX(); x <= region.getMax().getBlockX(); x++) {
|
||||
for (int y = region.getMin().getBlockY(); y <= region.getMax().getBlockY(); y++) {
|
||||
for (int z = region.getMin().getBlockZ(); z <= region.getMax().getBlockZ(); z++) {
|
||||
if (world.getBlockAt(x, y, z).getType() != Material.AIR) {
|
||||
world.getBlockAt(x, y, z).setType(Material.AIR);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
enderPortalRegions.add(region);
|
||||
buildSpawner.spawn();
|
||||
}
|
||||
|
||||
}
|
|
@ -0,0 +1,22 @@
|
|||
package com.yaohun.enderdragonwars.effect.types;
|
||||
|
||||
import com.yaohun.enderdragonwars.effect.GameGiftEffect;
|
||||
import com.yaohun.enderdragonwars.game.Game;
|
||||
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) {
|
||||
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);
|
||||
}
|
||||
|
||||
}
|
|
@ -0,0 +1,31 @@
|
|||
package com.yaohun.enderdragonwars.effect.types;
|
||||
|
||||
import com.yaohun.enderdragonwars.effect.GameGiftEffect;
|
||||
import com.yaohun.enderdragonwars.game.Game;
|
||||
import com.yaohun.enderdragonwars.util.RandomUtil;
|
||||
import org.bukkit.entity.Creeper;
|
||||
import org.bukkit.entity.EntityType;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.entity.Zombie;
|
||||
import org.bukkit.util.Vector;
|
||||
|
||||
public class SummonMobsEffect extends GameGiftEffect {
|
||||
|
||||
public SummonMobsEffect(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)));
|
||||
}
|
||||
}
|
||||
|
||||
}
|
|
@ -0,0 +1,26 @@
|
|||
package com.yaohun.enderdragonwars.effect.types;
|
||||
|
||||
import com.yaohun.enderdragonwars.effect.GameGiftEffect;
|
||||
import com.yaohun.enderdragonwars.game.Game;
|
||||
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) {
|
||||
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) {
|
||||
return;
|
||||
}
|
||||
player.getAttribute(Attribute.GENERIC_MAX_HEALTH).setBaseValue(20);
|
||||
}
|
||||
|
||||
|
||||
}
|
|
@ -0,0 +1,47 @@
|
|||
package com.yaohun.enderdragonwars.effect.types;
|
||||
|
||||
import com.yaohun.enderdragonwars.Main;
|
||||
import com.yaohun.enderdragonwars.effect.GameGiftEffect;
|
||||
import com.yaohun.enderdragonwars.game.Game;
|
||||
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) {
|
||||
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) {
|
||||
cancel();
|
||||
return;
|
||||
}
|
||||
double radius = 1.5;
|
||||
double angleStep = Math.PI / 4;
|
||||
double angle = skyTnt * angleStep;
|
||||
Vector vector = new Vector(radius * Math.cos(angle), 0.5, radius * Math.sin(angle));
|
||||
player.setVelocity(vector);
|
||||
skyTnt++;
|
||||
if (skyTnt >= 8) {
|
||||
skyTnt = 0;
|
||||
}
|
||||
count++;
|
||||
}
|
||||
}.runTaskTimer(Main.plugin, 0L, 1L);
|
||||
}
|
||||
|
||||
}
|
|
@ -0,0 +1,17 @@
|
|||
package com.yaohun.enderdragonwars.effect.types;
|
||||
|
||||
import com.yaohun.enderdragonwars.effect.GameGiftEffect;
|
||||
import com.yaohun.enderdragonwars.game.Game;
|
||||
|
||||
public class WorldDestroyEffect extends GameGiftEffect {
|
||||
|
||||
public WorldDestroyEffect(String audience) {
|
||||
super(audience);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void apply(Game game) {
|
||||
|
||||
}
|
||||
|
||||
}
|
|
@ -0,0 +1,46 @@
|
|||
package com.yaohun.enderdragonwars.effect.types;
|
||||
|
||||
import com.yaohun.enderdragonwars.Main;
|
||||
import com.yaohun.enderdragonwars.effect.GameGiftEffect;
|
||||
import com.yaohun.enderdragonwars.game.Game;
|
||||
import org.bukkit.Effect;
|
||||
import org.bukkit.Location;
|
||||
import org.bukkit.Sound;
|
||||
import org.bukkit.entity.EntityType;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.entity.TNTPrimed;
|
||||
import org.bukkit.scheduler.BukkitRunnable;
|
||||
import org.bukkit.scheduler.BukkitTask;
|
||||
|
||||
public class WuHuJumpEffect extends GameGiftEffect {
|
||||
|
||||
public WuHuJumpEffect(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.TNT);
|
||||
tntPrimed.setFuseTicks(5);
|
||||
tntPrimed.setYield(0.5F);
|
||||
location.getWorld().playSound(location, Sound.ENTITY_CREEPER_PRIMED, 1.0f, 1.0f);
|
||||
i++;
|
||||
}
|
||||
}.runTaskTimer(Main.plugin, 2L, 1L);
|
||||
game.addTasks(task);
|
||||
}
|
||||
|
||||
}
|
194
src/main/java/com/yaohun/enderdragonwars/game/Game.java
Normal file
194
src/main/java/com/yaohun/enderdragonwars/game/Game.java
Normal file
|
@ -0,0 +1,194 @@
|
|||
package com.yaohun.enderdragonwars.game;
|
||||
|
||||
import com.yaohun.enderdragonwars.Main;
|
||||
import com.yaohun.enderdragonwars.util.BossBarUtil;
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.GameMode;
|
||||
import org.bukkit.World;
|
||||
import org.bukkit.attribute.Attribute;
|
||||
import org.bukkit.boss.BarColor;
|
||||
import org.bukkit.boss.BarStyle;
|
||||
import org.bukkit.boss.BossBar;
|
||||
import org.bukkit.entity.Player;
|
||||
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 Game {
|
||||
|
||||
private Player player;
|
||||
private BossBar bossBar1;
|
||||
private BossBar bossBar2;
|
||||
private boolean startd;
|
||||
private long liveTime;
|
||||
private List<BukkitTask> tasks = new ArrayList<>();
|
||||
private int tragetCueI = 0;
|
||||
|
||||
private int dianzan;
|
||||
|
||||
public Game() {
|
||||
bossBar1 = Bukkit.createBossBar("下播时间", BarColor.WHITE, BarStyle.SEGMENTED_20);
|
||||
bossBar2 = Bukkit.createBossBar("挑战目标", BarColor.WHITE, BarStyle.SOLID);
|
||||
}
|
||||
|
||||
public void updateBossBar() {
|
||||
if (player == null) {
|
||||
return;
|
||||
}
|
||||
// 击败末影龙提示
|
||||
targetCueBossBar();
|
||||
// 获取最大时间
|
||||
long maxLiveTime = 1000 * 60 * 60 * 6;
|
||||
double d = (double) getLiveTime() / (double) maxLiveTime;
|
||||
d = Math.max(0, Math.min(d, 1));
|
||||
long liveTimeInSeconds = getLiveTime() / 1000;
|
||||
long hours = liveTimeInSeconds / 3600;
|
||||
long minutes = (liveTimeInSeconds % 3600) / 60;
|
||||
long seconds = liveTimeInSeconds % 60;
|
||||
if (hours >= 1) {
|
||||
bossBar1.setTitle("§6§l距离下播还有§f§l: §a" + hours + "小时" + minutes + "分" + seconds + "秒");
|
||||
} else if (minutes >= 1) {
|
||||
bossBar1.setTitle("§6§l距离下播还有§f§l: §a" + minutes + "分" + seconds + "秒");
|
||||
} else if (seconds >= 1) {
|
||||
bossBar1.setTitle("§6§l距离下播还有§f§l: §a" + seconds + "秒");
|
||||
} else {
|
||||
bossBar1.setTitle("§a§l恭喜您完成挑战!下播吧!");
|
||||
}
|
||||
BossBarUtil.setBarProgress(bossBar1, d);
|
||||
BossBarUtil.setBarColor(bossBar1, d);
|
||||
}
|
||||
|
||||
public void targetCueBossBar() {
|
||||
tragetCueI--;
|
||||
if (tragetCueI <= 0) {
|
||||
bossBar2.addPlayer(player);
|
||||
List<String> stringList = new ArrayList<>();
|
||||
stringList.add("§c§l击败末影龙 §b§l减播1小时!");
|
||||
Collections.shuffle(stringList);
|
||||
Random random = new Random();
|
||||
String titleShow = stringList.get(random.nextInt(stringList.size()));
|
||||
bossBar2.setTitle(titleShow);
|
||||
BossBarUtil.setBarColor(bossBar2);
|
||||
tragetCueI = 20;
|
||||
} else {
|
||||
if (tragetCueI == 16) {
|
||||
if (bossBar2.getPlayers().contains(player)) {
|
||||
bossBar2.removePlayer(player);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public void startGame(Player player) {
|
||||
if (startd) {
|
||||
rejoinGame(player);
|
||||
return;
|
||||
}
|
||||
this.player = player;
|
||||
this.startd = true;
|
||||
this.liveTime = 1000 * 60 * 60 * 3;
|
||||
initPlayerData(player);
|
||||
tasks.add(new BukkitRunnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
liveTime = liveTime - 500;
|
||||
updateBossBar();
|
||||
}
|
||||
}.runTaskTimer(Main.plugin, 0L, 10L));
|
||||
}
|
||||
|
||||
public void rejoinGame(Player player) {
|
||||
this.player = player;
|
||||
initPlayerData(player);
|
||||
}
|
||||
|
||||
public void quitGame(Player player) {
|
||||
this.player = null;
|
||||
}
|
||||
|
||||
public void stop() {
|
||||
this.player = null;
|
||||
this.startd = false;
|
||||
tasks.forEach(BukkitTask::cancel);
|
||||
removeBossBar();
|
||||
}
|
||||
|
||||
public Player getPlayer() {
|
||||
return player;
|
||||
}
|
||||
|
||||
public World getWorld() {
|
||||
return player.getWorld();
|
||||
}
|
||||
|
||||
public void initPlayerData(Player player) {
|
||||
player.setFoodLevel(20);
|
||||
player.setGameMode(GameMode.SURVIVAL);
|
||||
Attribute[] attributes = new Attribute[]{Attribute.GENERIC_MAX_HEALTH, Attribute.GENERIC_MOVEMENT_SPEED, Attribute.GENERIC_SCALE, Attribute.GENERIC_STEP_HEIGHT};
|
||||
double[] attributeValues = new double[]{20, 0.1, 1, 0.6};
|
||||
for (int i = 0; i < attributes.length; i++) {
|
||||
player.getAttribute(attributes[i]).setBaseValue(attributeValues[i]);
|
||||
}
|
||||
bossBar1.addPlayer(player);
|
||||
bossBar2.addPlayer(player);
|
||||
}
|
||||
|
||||
public void removeBossBar() {
|
||||
bossBar1.removeAll();
|
||||
bossBar2.removeAll();
|
||||
bossBar1 = Bukkit.createBossBar("下播时间", BarColor.WHITE, BarStyle.SEGMENTED_20);
|
||||
bossBar2 = Bukkit.createBossBar("挑战目标", BarColor.WHITE, BarStyle.SOLID);
|
||||
}
|
||||
|
||||
public boolean isStartd() {
|
||||
return startd;
|
||||
}
|
||||
|
||||
public void addTasks(BukkitTask task) {
|
||||
this.tasks.add(task);
|
||||
}
|
||||
|
||||
public void addDianZan(int count) {
|
||||
this.dianzan += count;
|
||||
}
|
||||
|
||||
public int getDianzan() {
|
||||
return dianzan;
|
||||
}
|
||||
|
||||
public void setDianzan(int dianzan) {
|
||||
this.dianzan = dianzan;
|
||||
}
|
||||
|
||||
public long getLiveTime() {
|
||||
return liveTime;
|
||||
}
|
||||
|
||||
public void setLiveTime(long liveTime) {
|
||||
this.liveTime = liveTime;
|
||||
}
|
||||
|
||||
public void takeLiveTime(long minutes) {
|
||||
long minutesTime = 1000 * 60 * minutes;
|
||||
long newTime = getLiveTime() - minutesTime;
|
||||
if (newTime < 0) {
|
||||
newTime = 0;
|
||||
}
|
||||
setLiveTime(newTime);
|
||||
}
|
||||
|
||||
public void addLiveTime(long minutes) {
|
||||
long minutesTime = 1000 * 60 * minutes;
|
||||
long newTime = getLiveTime() + minutesTime;
|
||||
if (newTime < 0) {
|
||||
newTime = 0;
|
||||
}
|
||||
setLiveTime(newTime);
|
||||
}
|
||||
|
||||
|
||||
}
|
|
@ -0,0 +1,23 @@
|
|||
package com.yaohun.enderdragonwars.game;
|
||||
|
||||
import com.io.yutian.pixelliveapi.manager.ExtraDataManager;
|
||||
|
||||
public class GameSetting {
|
||||
|
||||
private static int dianzanAmount;
|
||||
private static String dianzanEffect;
|
||||
|
||||
public static void load() {
|
||||
dianzanAmount = Integer.parseInt(String.valueOf(ExtraDataManager.getConfigValues().getOrDefault("点赞数量", 100)));
|
||||
dianzanEffect = String.valueOf(ExtraDataManager.getConfigValues().getOrDefault("点赞效果", "幸运方块"));
|
||||
}
|
||||
|
||||
public static int getDianzanAmount() {
|
||||
return dianzanAmount;
|
||||
}
|
||||
|
||||
public static String getDianzanEffect() {
|
||||
return dianzanEffect;
|
||||
}
|
||||
|
||||
}
|
|
@ -0,0 +1,67 @@
|
|||
package com.yaohun.enderdragonwars.listener;
|
||||
|
||||
import com.yaohun.enderdragonwars.Main;
|
||||
import org.bukkit.entity.EnderDragon;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.event.EventHandler;
|
||||
import org.bukkit.event.Listener;
|
||||
import org.bukkit.event.entity.EntityDeathEvent;
|
||||
import org.bukkit.event.entity.PlayerDeathEvent;
|
||||
import org.bukkit.event.player.PlayerDropItemEvent;
|
||||
import org.bukkit.event.player.PlayerJoinEvent;
|
||||
import org.bukkit.event.player.PlayerKickEvent;
|
||||
import org.bukkit.event.player.PlayerQuitEvent;
|
||||
import org.bukkit.event.server.ServerListPingEvent;
|
||||
import org.bukkit.scheduler.BukkitRunnable;
|
||||
|
||||
public class GameListener implements Listener {
|
||||
|
||||
@EventHandler
|
||||
public void onPing(ServerListPingEvent event) {
|
||||
event.setMotd("§a整蛊模式: §6生存挑战 §a当前版本: §6常规版 §b运行中");
|
||||
}
|
||||
|
||||
@EventHandler
|
||||
public void onPlayerJoin(PlayerJoinEvent event) {
|
||||
Player player = event.getPlayer();
|
||||
Main.game.startGame(player);
|
||||
}
|
||||
|
||||
@EventHandler
|
||||
public void onPlayerQuit(PlayerQuitEvent event) {
|
||||
Main.game.quitGame(event.getPlayer());
|
||||
}
|
||||
|
||||
/*
|
||||
* 死亡后游戏时间 +5分钟
|
||||
* */
|
||||
@EventHandler
|
||||
public void onDeath(PlayerDeathEvent event) {
|
||||
event.setDeathMessage(null);
|
||||
Player p = event.getEntity();
|
||||
new BukkitRunnable() {
|
||||
private int i = 0;
|
||||
|
||||
public void run() {
|
||||
if (i == 1) {
|
||||
p.spigot().respawn();
|
||||
}
|
||||
// 增加游戏时间5分钟
|
||||
if (i == 3) {
|
||||
Main.game.addLiveTime(5);
|
||||
p.sendTitle("§4你嘎了", "§e加播5分钟!");
|
||||
cancel();
|
||||
}
|
||||
i++;
|
||||
}
|
||||
}.runTaskTimer(Main.plugin, 0L, 2L);
|
||||
}
|
||||
|
||||
@EventHandler
|
||||
public void onEntityDeath(EntityDeathEvent event) {
|
||||
if (event.getEntity() instanceof EnderDragon) {
|
||||
Main.game.takeLiveTime(60);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
|
@ -0,0 +1,77 @@
|
|||
package com.yaohun.enderdragonwars.listener;
|
||||
|
||||
import com.io.yutian.pixelliveapi.api.Anchor;
|
||||
import com.io.yutian.pixelliveapi.api.Audience;
|
||||
import com.io.yutian.pixelliveapi.api.Gift;
|
||||
import com.io.yutian.pixelliveapi.api.event.AnchorInitializedEvent;
|
||||
import com.io.yutian.pixelliveapi.api.event.LiveGiftEvent;
|
||||
import com.io.yutian.pixelliveapi.api.event.LiveLikeEvent;
|
||||
import com.io.yutian.pixelliveapi.effect.GiftEffectData;
|
||||
import com.io.yutian.pixelliveapi.manager.*;
|
||||
import com.yaohun.enderdragonwars.Main;
|
||||
import com.yaohun.enderdragonwars.game.GameSetting;
|
||||
import com.yaohun.enderdragonwars.util.GameUtil;
|
||||
import com.yaohun.enderdragonwars.util.RandomUtil;
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.event.EventHandler;
|
||||
import org.bukkit.event.Listener;
|
||||
|
||||
public class LiveListener implements Listener {
|
||||
|
||||
@EventHandler
|
||||
public void onInit(AnchorInitializedEvent event) {
|
||||
Anchor anchor = event.getAnchor();
|
||||
anchor.getClient().connect();
|
||||
}
|
||||
|
||||
@EventHandler
|
||||
public void onDianZan(LiveLikeEvent event) {
|
||||
Player zhubo = event.getPlayer();
|
||||
String userName = "" + RandomUtil.getRandomInt(999, 10000);
|
||||
Audience audience = event.getAudience();
|
||||
if (audience.getNickName() != null) {
|
||||
userName = audience.getNickName();
|
||||
}
|
||||
int count = event.getClickCount();
|
||||
Main.game.addDianZan(count);
|
||||
if (Main.game.getDianzan() >= GameSetting.getDianzanAmount()) {
|
||||
String event1 = GameSetting.getDianzanEffect();
|
||||
String title = "§c" + event1;
|
||||
String subtitle = "§9双击屏幕x" + GameSetting.getDianzanAmount();
|
||||
zhubo.sendTitle(title, subtitle, 10, 30, 10);
|
||||
EffectQueueManager.addGiftEffect(userName, event1, 1);
|
||||
Main.game.setDianzan(0);
|
||||
}
|
||||
}
|
||||
|
||||
@EventHandler
|
||||
public void onLive(LiveGiftEvent event) {
|
||||
Player zhubo = event.getPlayer();
|
||||
Audience audience = event.getAudience();
|
||||
String userName = audience.getNickName();
|
||||
boolean butt = userName != null;
|
||||
Gift gift = event.getGift();
|
||||
String giftName = gift.getName();
|
||||
int giftAmount = event.getCount();
|
||||
String hideUserName = GameUtil.hideName(userName);
|
||||
if (!GiftManager.hasGiftData(giftName)) {
|
||||
return;
|
||||
}
|
||||
GiftEffectData giftEffectData = GiftManager.getGiftData(giftName);
|
||||
String effect = giftEffectData.getEffect();
|
||||
String title = "§c" + effect;
|
||||
if (giftAmount >= 2) {
|
||||
title = "§c" + effect + " x" + giftAmount;
|
||||
}
|
||||
String subtitle = "§9" + giftName;
|
||||
if (butt) {
|
||||
subtitle = "§9" + hideUserName;
|
||||
}
|
||||
zhubo.sendTitle(title, subtitle, 0, 30, 10);
|
||||
for (Player player : Bukkit.getOnlinePlayers()) {
|
||||
player.sendMessage("§a礼物: §e" + hideUserName + " §d送来了 §e" + giftName + "x" + giftAmount);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
|
@ -0,0 +1,135 @@
|
|||
package com.yaohun.enderdragonwars.listener;
|
||||
|
||||
import com.yaohun.enderdragonwars.effect.types.LuckyBlockEffect;
|
||||
import com.yaohun.enderdragonwars.effect.types.SpawnEnderPortalEffect;
|
||||
import org.bukkit.*;
|
||||
import org.bukkit.block.Block;
|
||||
import org.bukkit.entity.*;
|
||||
import org.bukkit.event.EventHandler;
|
||||
import org.bukkit.event.Listener;
|
||||
import org.bukkit.event.block.BlockBreakEvent;
|
||||
import org.bukkit.event.entity.EntityDamageByEntityEvent;
|
||||
import org.bukkit.event.entity.EntityDamageEvent;
|
||||
import org.bukkit.event.player.PlayerChangedWorldEvent;
|
||||
import org.bukkit.event.player.PlayerInteractEntityEvent;
|
||||
import org.bukkit.event.player.PlayerPortalEvent;
|
||||
import org.bukkit.event.player.PlayerRespawnEvent;
|
||||
import org.bukkit.inventory.ItemStack;
|
||||
import org.bukkit.inventory.PlayerInventory;
|
||||
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
|
||||
public class PlayerListener implements Listener {
|
||||
|
||||
private static Map<Player, ItemStack> totem = new HashMap<>();
|
||||
|
||||
@EventHandler
|
||||
public void onEntityDamage(EntityDamageEvent event) {
|
||||
if (event.getEntity() instanceof Player player) {
|
||||
PlayerInventory inventory = player.getInventory();
|
||||
Material item = Material.TOTEM_OF_UNDYING;
|
||||
ItemStack mainhand = inventory.getItemInMainHand();
|
||||
ItemStack offhand = inventory.getItemInOffHand();
|
||||
if (player.getHealth() - event.getFinalDamage() <= 0.0d && inventory.contains(item)) {
|
||||
if (mainhand != null && mainhand.getType() == item) {
|
||||
return;
|
||||
}
|
||||
if ((offhand == null || offhand.getType() != item)) {
|
||||
this.totem.put(player, inventory.getItemInOffHand());
|
||||
ItemStack[] contents = inventory.getContents();
|
||||
int length = contents.length;
|
||||
int i = 0;
|
||||
while (true) {
|
||||
if (i >= length) {
|
||||
break;
|
||||
}
|
||||
ItemStack totem = contents[i];
|
||||
if (totem != null && totem.getType().equals(item)) {
|
||||
totem.setAmount(totem.getAmount() - 1);
|
||||
break;
|
||||
}
|
||||
i++;
|
||||
}
|
||||
inventory.setItemInOffHand(new ItemStack(Material.TOTEM_OF_UNDYING));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@EventHandler
|
||||
public void onDamage(EntityDamageByEntityEvent event) {
|
||||
if (event.getEntity() instanceof Player) {
|
||||
if (event.getDamager() instanceof LightningStrike) {
|
||||
event.setDamage(1.0);
|
||||
} else if (event.getDamager() instanceof Creeper creeper) {
|
||||
event.setDamage(creeper.isPowered() ? 4 : 2.0);
|
||||
}
|
||||
} else if (event.getEntity() instanceof LightningStrike) {
|
||||
if (!(event.getDamager() instanceof Player player)) {
|
||||
event.setDamage(2.0);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@EventHandler
|
||||
public void onPlayerBreakBlock(BlockBreakEvent event) {
|
||||
Player player = event.getPlayer();
|
||||
Block block = event.getBlock();
|
||||
if (block.getType() == Material.SPONGE) {
|
||||
event.setCancelled(true);
|
||||
block.setType(Material.AIR);
|
||||
LuckyBlockEffect.openLuckyBlock(player, block);
|
||||
}
|
||||
}
|
||||
|
||||
@EventHandler
|
||||
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++) {
|
||||
Block block = location.clone().add(i, j, z).getBlock();
|
||||
block.setType(Material.AIR);
|
||||
}
|
||||
}
|
||||
}
|
||||
for (int i = -2; i <= 2; i++) {
|
||||
for (int j = -2; j <= 2; j++) {
|
||||
Block block = location.clone().add(i, -1, j).getBlock();
|
||||
block.setType(Material.BEDROCK);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@EventHandler
|
||||
public void onPlayerPortal(PlayerPortalEvent event) {
|
||||
Player player = event.getPlayer();
|
||||
Location location = player.getLocation();
|
||||
SpawnEnderPortalEffect.checkPortalRegion(location);
|
||||
}
|
||||
|
||||
@EventHandler
|
||||
public void onPlayerChangeWorld(PlayerChangedWorldEvent event) {
|
||||
World from = event.getFrom();
|
||||
if (from.getEnvironment() == World.Environment.THE_END) {
|
||||
if (from.getEnderDragonBattle().hasBeenPreviouslyKilled()) {
|
||||
Bukkit.unloadWorld(from, false);
|
||||
Bukkit.createWorld(new WorldCreator(from.getName()).environment(World.Environment.THE_END));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@EventHandler
|
||||
public void onPlayerInteractEntity(PlayerInteractEntityEvent event) {
|
||||
Player player = event.getPlayer();
|
||||
Entity entity = event.getRightClicked();
|
||||
if (entity instanceof IronGolem) {
|
||||
entity.addPassenger(player);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
}
|
|
@ -0,0 +1,30 @@
|
|||
package com.yaohun.enderdragonwars.manager;
|
||||
|
||||
import com.io.yutian.pixelliveapi.manager.EffectManager;
|
||||
import com.yaohun.enderdragonwars.effect.types.*;
|
||||
|
||||
public class GiftEffectManager {
|
||||
|
||||
public static void registerAll() {
|
||||
EffectManager.registerGiftEffect("清理背包", ClearInventoryEffect::new);
|
||||
EffectManager.registerGiftEffect("火山喷发", BomBomEffect::new);
|
||||
EffectManager.registerGiftEffect("幸运方块", LuckyBlockEffect::new);
|
||||
EffectManager.registerGiftEffect("黑洞", BlackHoleEffect::new);
|
||||
EffectManager.registerGiftEffect("五雷轰顶", FiveLightningEffect::new);
|
||||
EffectManager.registerGiftEffect("装备清空", ClearInventoryEffect::new);
|
||||
EffectManager.registerGiftEffect("岩浆泡澡", LavaPoolEffect::new);
|
||||
EffectManager.registerGiftEffect("钢铁保安", SummonIronGolem::new);
|
||||
EffectManager.registerGiftEffect("6倍血量", AddMaxHealthEffect::new);
|
||||
EffectManager.registerGiftEffect("原地复活", GiveTotemEffect::new);
|
||||
EffectManager.registerGiftEffect("魔豆天梯", SpawnEnderPortalEffect::new);
|
||||
EffectManager.registerGiftEffect("世界毁灭", WorldDestroyEffect::new);
|
||||
EffectManager.registerGiftEffect("变大", PlayerBigEffect::new);
|
||||
EffectManager.registerGiftEffect("变小", PlayerSmallEffect::new);
|
||||
EffectManager.registerGiftEffect("安全庇护所", SpawnBuildEffect::new);
|
||||
EffectManager.registerGiftEffect("螺旋升天", ToHeavenEffect::new);
|
||||
EffectManager.registerGiftEffect("怪物军团", SummonMobsEffect::new);
|
||||
EffectManager.registerGiftEffect("芜湖起飞", WuHuJumpEffect::new);
|
||||
EffectManager.registerGiftEffect("随机盲盒", RandomBoxEffect::new);
|
||||
}
|
||||
|
||||
}
|
|
@ -0,0 +1,56 @@
|
|||
package com.yaohun.enderdragonwars.util;
|
||||
|
||||
import org.bukkit.boss.BarColor;
|
||||
import org.bukkit.boss.BossBar;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
public class BossBarUtil {
|
||||
|
||||
public static void setBarColor(BossBar bossBar) {
|
||||
double random = RandomUtil.getRandomDouble(0, 1, 1);
|
||||
if (random >= 0 && random <= 0.2) {
|
||||
bossBar.setColor(BarColor.RED);
|
||||
} else if (random <= 0.4) {
|
||||
bossBar.setColor(BarColor.YELLOW);
|
||||
} else if (random <= 0.6) {
|
||||
bossBar.setColor(BarColor.GREEN);
|
||||
} else if (random <= 0.8) {
|
||||
bossBar.setColor(BarColor.BLUE);
|
||||
} else {
|
||||
bossBar.setColor(BarColor.PURPLE);
|
||||
}
|
||||
}
|
||||
|
||||
public static void setBarColor(BossBar bossBar, double percent) {
|
||||
if (percent >= 0 && percent <= 0.3333) {
|
||||
bossBar.setColor(BarColor.RED);
|
||||
} else if (percent <= 0.6666) {
|
||||
bossBar.setColor(BarColor.YELLOW);
|
||||
} else {
|
||||
bossBar.setColor(BarColor.GREEN);
|
||||
}
|
||||
}
|
||||
|
||||
public static void setBarProgress(BossBar bossBar, double percent) {
|
||||
if (percent <= 0) {
|
||||
percent = 0;
|
||||
} else if (percent >= 1) {
|
||||
percent = 1;
|
||||
}
|
||||
bossBar.setProgress(percent);
|
||||
}
|
||||
|
||||
public static void addBossBar(Player player, List<BossBar> bossBarList) {
|
||||
for (BossBar bossBar : bossBarList) {
|
||||
bossBar.addPlayer(player);
|
||||
}
|
||||
}
|
||||
|
||||
public static void removeBossBar(Player player, List<BossBar> bossBarList) {
|
||||
for (BossBar bossBar : bossBarList) {
|
||||
bossBar.removePlayer(player);
|
||||
}
|
||||
}
|
||||
}
|
460
src/main/java/com/yaohun/enderdragonwars/util/BuildSpawner.java
Normal file
460
src/main/java/com/yaohun/enderdragonwars/util/BuildSpawner.java
Normal file
|
@ -0,0 +1,460 @@
|
|||
package com.yaohun.enderdragonwars.util;
|
||||
|
||||
import com.yaohun.enderdragonwars.Main;
|
||||
import com.yaohun.enderdragonwars.data.Point;
|
||||
import com.yaohun.enderdragonwars.data.Region;
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.Sound;
|
||||
import org.bukkit.World;
|
||||
import org.bukkit.block.Block;
|
||||
import org.bukkit.block.data.type.EndPortalFrame;
|
||||
import org.bukkit.scheduler.BukkitRunnable;
|
||||
import org.bukkit.util.Vector;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
public class BuildSpawner {
|
||||
|
||||
protected ISpawnModeHander spawnModeHander;
|
||||
private World world;
|
||||
private Direction initialDirection;
|
||||
private int originX;
|
||||
private int originY;
|
||||
private int originZ;
|
||||
private int chunkWight;
|
||||
private int chunkLength;
|
||||
private int ladderLength;
|
||||
private int ladderAmount;
|
||||
private int platformWidth;
|
||||
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;
|
||||
|
||||
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;
|
||||
this.originX = originX;
|
||||
this.originY = originY;
|
||||
this.originZ = originZ;
|
||||
this.chunkWight = chunkWight;
|
||||
this.chunkLength = chunkLength;
|
||||
this.ladderLength = ladderLength;
|
||||
this.ladderAmount = ladderAmount;
|
||||
this.platformWidth = platformWidth;
|
||||
this.platformLength = platformLength;
|
||||
this.levelAmount = levelAmount;
|
||||
this.spawnMode = spawnMode;
|
||||
this.materials = materials;
|
||||
|
||||
nowX = originX;
|
||||
nowY = originY;
|
||||
nowZ = originZ;
|
||||
nowDirection = initialDirection;
|
||||
if (spawnMode == SpawnMode.MODE_1) {
|
||||
spawnModeHander = new SpawnModeHandler_1();
|
||||
} else if (spawnMode == SpawnMode.MODE_2) {
|
||||
spawnModeHander = new SpawnModeHandler_2();
|
||||
}
|
||||
}
|
||||
|
||||
public void spawn() {
|
||||
nowX = originX;
|
||||
nowY = originY;
|
||||
nowZ = originZ;
|
||||
nowDirection = initialDirection;
|
||||
if (spawnModeHander != null) {
|
||||
spawnModeHander.spawn();
|
||||
}
|
||||
}
|
||||
|
||||
private void spawnPlatform(int x, int y, int z, Direction direction) {
|
||||
if (direction == Direction.EAST || direction == Direction.WEST) {
|
||||
for (int i = 0; i < platformLength; i++) {
|
||||
for (int j = 0; j < platformWidth; j++) {
|
||||
int x1 = x + (i * chunkWight) * direction.getPlatformVector().getBlockX();
|
||||
int z1 = z + (j * chunkLength) * direction.getPlatformVector().getBlockZ();
|
||||
spawnPlatformChunk(x1, y, z1, direction);
|
||||
}
|
||||
}
|
||||
} else if (direction == Direction.NORTH || direction == Direction.SOUTH) {
|
||||
for (int i = 0; i < platformLength; i++) {
|
||||
for (int j = 0; j < platformWidth; j++) {
|
||||
int x1 = x + (j * chunkLength) * direction.getPlatformVector().getBlockX();
|
||||
int z1 = z + (i * chunkWight) * direction.getPlatformVector().getBlockZ();
|
||||
spawnPlatformChunk(x1, y, z1, direction);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private void spawnLadder(int x, int y, int z, Direction direction) {
|
||||
for (int i = 0; i < ladderAmount; i++) {
|
||||
for (int j = 0; j < ladderLength; j++) {
|
||||
int x1 = getLadderX(i, j, x, z, direction);
|
||||
int z1 = getLadderZ(i, j, x, z, direction);
|
||||
spawnLadderChunk(x1, y + i + 1, z1, direction);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private int getLadderX(int i, int j, int x, int z, Direction direction) {
|
||||
switch (direction) {
|
||||
case EAST:
|
||||
case WEST:
|
||||
return x + (i * chunkWight) * direction.getLadderVector().getBlockX();
|
||||
case SOUTH:
|
||||
case NORTH:
|
||||
return x + (j * chunkLength) * direction.getLadderVector().getBlockX();
|
||||
}
|
||||
return x;
|
||||
}
|
||||
|
||||
private int getLadderZ(int i, int j, int x, int z, Direction direction) {
|
||||
switch (direction) {
|
||||
case EAST:
|
||||
case WEST:
|
||||
return z + (j * chunkLength) * direction.getLadderVector().getBlockZ();
|
||||
case SOUTH:
|
||||
case NORTH:
|
||||
return z + (i * chunkWight) * direction.getLadderVector().getBlockZ();
|
||||
}
|
||||
return z;
|
||||
}
|
||||
|
||||
private void spawnPlatformChunk(int x, int y, int z, Direction direction) {
|
||||
Material material = getRandomMaterial();
|
||||
if (direction == Direction.EAST || direction == Direction.WEST) {
|
||||
for (int i = 0; i < chunkWight; i++) {
|
||||
for (int j = 0; j < chunkLength; j++) {
|
||||
int x1 = x + i * direction.getPlatformVector().getBlockX();
|
||||
int z1 = z + j * direction.getPlatformVector().getBlockZ();
|
||||
world.getBlockAt(x1, y, z1).setType(material);
|
||||
}
|
||||
}
|
||||
} else if (direction == Direction.NORTH || direction == Direction.SOUTH) {
|
||||
for (int i = 0; i < chunkWight; i++) {
|
||||
for (int j = 0; j < chunkLength; j++) {
|
||||
int x1 = x + j * direction.getPlatformVector().getBlockX();
|
||||
int z1 = z + i * direction.getPlatformVector().getBlockZ();
|
||||
world.getBlockAt(x1, y, z1).setType(material);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private void spawnLadderChunk(int x, int y, int z, Direction direction) {
|
||||
Material material = getRandomMaterial();
|
||||
if (direction == Direction.EAST || direction == Direction.WEST) {
|
||||
for (int i = 0; i < chunkWight; i++) {
|
||||
for (int j = 0; j < chunkLength; j++) {
|
||||
int x1 = x + i * direction.getLadderVector().getBlockX();
|
||||
int z1 = z + j * direction.getLadderVector().getBlockZ();
|
||||
world.getBlockAt(x1, y, z1).setType(material);
|
||||
}
|
||||
}
|
||||
} else if (direction == Direction.NORTH || direction == Direction.SOUTH) {
|
||||
for (int i = 0; i < chunkLength; i++) {
|
||||
for (int j = 0; j < chunkWight; j++) {
|
||||
int x1 = x + i * direction.getLadderVector().getBlockX();
|
||||
int z1 = z + j * direction.getLadderVector().getBlockZ();
|
||||
world.getBlockAt(x1, y, z1).setType(material);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private void transformDirection() {
|
||||
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
|
||||
}
|
||||
|
||||
public enum Direction {
|
||||
|
||||
NORTH(new Vector(1.0, 1.0, -1.0), new Vector(-1.0, 1.0, -1.0), new Vector(1.0, 1.0, -1.0)),
|
||||
EAST(new Vector(1.0, 1.0, 1.0), new Vector(1.0, 1.0, -1.0), new Vector(1.0, 1.0, 1.0)),
|
||||
SOUTH(new Vector(-1.0, 1.0, 1.0), new Vector(1.0, 1.0, 1.0), new Vector(-1.0, 1.0, 1.0)),
|
||||
WEST(new Vector(-1.0, 1.0, -1.0), new Vector(-1.0, 1.0, 1.0), new Vector(-1.0, 1.0, -1.0));
|
||||
|
||||
private final Vector vector;
|
||||
private final Vector platformVector;
|
||||
private final Vector ladderVector;
|
||||
|
||||
Direction(Vector vector, Vector platformVector, Vector ladderVector) {
|
||||
this.vector = vector;
|
||||
this.platformVector = platformVector;
|
||||
this.ladderVector = ladderVector;
|
||||
}
|
||||
|
||||
public Vector getVector() {
|
||||
return vector;
|
||||
}
|
||||
|
||||
public Vector getPlatformVector() {
|
||||
return platformVector;
|
||||
}
|
||||
|
||||
public Vector getLadderVector() {
|
||||
return ladderVector;
|
||||
}
|
||||
|
||||
public Direction getRightDirection() {
|
||||
switch (this) {
|
||||
case NORTH:
|
||||
return EAST;
|
||||
case EAST:
|
||||
return SOUTH;
|
||||
case SOUTH:
|
||||
return WEST;
|
||||
case WEST:
|
||||
return NORTH;
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
public enum SpawnMode {
|
||||
|
||||
MODE_1,
|
||||
MODE_2
|
||||
|
||||
}
|
||||
|
||||
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) {
|
||||
spawnPlatform(nowX, nowY, nowZ, nowDirection);
|
||||
cancel();
|
||||
return;
|
||||
}
|
||||
spawnPlatform(nowX, nowY, nowZ, nowDirection);
|
||||
transformXYZ(TransformType.PLATFORM, nowDirection);
|
||||
transformDirection();
|
||||
spawnLadder(nowX, nowY, nowZ, nowDirection);
|
||||
transformXYZ(TransformType.LADDER, nowDirection);
|
||||
transformDirection();
|
||||
count++;
|
||||
}
|
||||
}.runTaskTimer(Main.plugin, 0L, 3L);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Region getEffectiveRegion(World world) {
|
||||
if (initialDirection == Direction.NORTH || initialDirection == Direction.SOUTH) {
|
||||
int minX = originX + (platformWidth * chunkWight) * initialDirection.getPlatformVector().getBlockX();
|
||||
int minY = originY;
|
||||
int minZ = originZ;
|
||||
int maxX = originX + ladderAmount * ladderLength * chunkLength * initialDirection.getLadderVector().getBlockX() + (platformWidth * chunkWight) * initialDirection.getPlatformVector().getBlockX() + 1;
|
||||
int maxY = originY + levelAmount * 5 + 1;
|
||||
int maxZ = originZ + (platformLength * chunkLength) * initialDirection.getPlatformVector().getBlockZ() + 1;
|
||||
return new Region(world, new Point(minX, minY, minZ), new Point(maxX, maxY, maxZ));
|
||||
} else if (initialDirection == Direction.EAST || initialDirection == Direction.WEST) {
|
||||
int minX = originX;
|
||||
int minY = originY;
|
||||
int minZ = originZ + (platformWidth * chunkWight) * initialDirection.getPlatformVector().getBlockZ();
|
||||
int maxX = originX + (platformLength * chunkLength) * initialDirection.getPlatformVector().getBlockX() + 1;
|
||||
int maxY = originY + levelAmount * 5 + 1;
|
||||
int maxZ = originZ + ladderAmount * ladderLength * chunkLength * initialDirection.getLadderVector().getBlockX() + (platformWidth * chunkWight) * initialDirection.getPlatformVector().getBlockZ() + 1;
|
||||
return new Region(world, new Point(minX, minY, minZ), new Point(maxX, maxY, maxZ));
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getHeight() {
|
||||
return levelAmount * 5;
|
||||
}
|
||||
|
||||
private void transformXYZ(TransformType transformType, Direction direction) {
|
||||
if (transformType == TransformType.PLATFORM) {
|
||||
if (direction == Direction.EAST || direction == Direction.WEST) {
|
||||
nowX += (platformLength * chunkWight - 1) * direction.getPlatformVector().getX();
|
||||
} else if (direction == Direction.NORTH || direction == Direction.SOUTH) {
|
||||
nowZ += (platformLength * chunkWight - 1) * direction.getPlatformVector().getZ();
|
||||
}
|
||||
switch (nowDirection) {
|
||||
case EAST:
|
||||
nowZ += 1;
|
||||
break;
|
||||
case SOUTH:
|
||||
nowX -= 1;
|
||||
break;
|
||||
case WEST:
|
||||
nowZ -= 1;
|
||||
break;
|
||||
case NORTH:
|
||||
nowX += 1;
|
||||
break;
|
||||
}
|
||||
} else if (transformType == TransformType.LADDER) {
|
||||
nowY += ladderAmount;
|
||||
if (direction == Direction.EAST || direction == Direction.WEST) {
|
||||
nowX += (ladderAmount * chunkWight) * direction.getLadderVector().getBlockX();
|
||||
} else if (direction == Direction.NORTH || direction == Direction.SOUTH) {
|
||||
nowZ += (ladderAmount * chunkWight) * direction.getLadderVector().getBlockZ();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private class SpawnModeHandler_2 implements ISpawnModeHander {
|
||||
|
||||
@Override
|
||||
public void spawn() {
|
||||
new BukkitRunnable() {
|
||||
private int count = 0;
|
||||
|
||||
@Override
|
||||
public void run() {
|
||||
if (count >= levelAmount) {
|
||||
spawnPlatform(nowX, nowY, nowZ, nowDirection);
|
||||
Region region = getEffectiveRegion(world);
|
||||
int centerX = (region.getMax().getBlockX() - region.getMin().getBlockX() + 1) / 2;
|
||||
int centerZ = (region.getMax().getBlockZ() - region.getMin().getBlockZ() + 1) / 2;
|
||||
Point blockCenterPoint = new Point(region.getMin().getBlockX() + centerZ, region.getMax().getBlockY() - 3, region.getMin().getBlockZ() + centerZ);
|
||||
Block block = world.getBlockAt(blockCenterPoint.getBlockX(), blockCenterPoint.getBlockY(), blockCenterPoint.getBlockZ());
|
||||
for (int i = -6; i <= 6; i++) {
|
||||
for (int j = -6; j <= 6; j++) {
|
||||
if (Math.abs(i) == 6 && Math.abs(j) == 6) {
|
||||
continue;
|
||||
}
|
||||
Block block1 = world.getBlockAt(blockCenterPoint.getBlockX() + i, blockCenterPoint.getBlockY(), blockCenterPoint.getBlockZ() + j);
|
||||
if (Math.abs(i) <= 5 && Math.abs(j) <= 5) {
|
||||
block1.setType(Material.END_PORTAL);
|
||||
} else {
|
||||
block1.setType(Material.END_PORTAL_FRAME);
|
||||
EndPortalFrame endPortalFrame = (EndPortalFrame) block1.getBlockData();
|
||||
endPortalFrame.setEye(true);
|
||||
block1.setBlockData(endPortalFrame);
|
||||
}
|
||||
}
|
||||
}
|
||||
block.getWorld().strikeLightning(block.getLocation().add(0.5, 0, 0.5));
|
||||
block.getWorld().getPlayers().forEach(player -> player.playSound(player.getLocation(), Sound.BLOCK_END_PORTAL_SPAWN, 1.0f, 1.0f));
|
||||
cancel();
|
||||
return;
|
||||
}
|
||||
spawnPlatform(nowX, nowY, nowZ, nowDirection);
|
||||
transformXYZ(TransformType.PLATFORM, nowDirection, 0);
|
||||
spawnLadder(nowX, nowY, nowZ, nowDirection);
|
||||
transformXYZ(TransformType.LADDER, nowDirection, 0);
|
||||
transformDirection();
|
||||
count++;
|
||||
}
|
||||
}.runTaskTimer(Main.plugin, 0L, 3L);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Region getEffectiveRegion(World world) {
|
||||
if (initialDirection == Direction.NORTH || initialDirection == Direction.SOUTH) {
|
||||
int minX = originX + (platformWidth * chunkWight) * initialDirection.getPlatformVector().getBlockX();
|
||||
int minZ = originZ;
|
||||
minZ += (platformLength * chunkLength) * initialDirection.getPlatformVector().getBlockZ();
|
||||
minZ += (ladderAmount * chunkLength) * initialDirection.getLadderVector().getBlockZ();
|
||||
minZ += (platformWidth * chunkWight) * initialDirection.getRightDirection().getPlatformVector().getBlockZ();
|
||||
int maxX = originX + ladderAmount * ladderLength * chunkLength * initialDirection.getLadderVector().getBlockX() + (platformWidth * chunkWight) * initialDirection.getPlatformVector().getBlockX() + 1;
|
||||
int maxZ = originZ;
|
||||
int maxY = originY + levelAmount * 5 + 1;
|
||||
return new Region(world, new Point(minX, originY, minZ), new Point(maxX, maxY, maxZ));
|
||||
} else if (initialDirection == Direction.EAST || initialDirection == Direction.WEST) {
|
||||
int minX = originX;
|
||||
int minZ = originZ + (platformWidth * chunkWight) * initialDirection.getPlatformVector().getBlockZ();
|
||||
minX += (platformLength * chunkLength) * initialDirection.getPlatformVector().getBlockX();
|
||||
minX += (ladderAmount * chunkLength) * initialDirection.getLadderVector().getBlockX();
|
||||
minX += (platformWidth * chunkWight) * initialDirection.getRightDirection().getPlatformVector().getBlockX();
|
||||
int maxX = originX;
|
||||
int maxZ = originZ + ladderAmount * ladderLength * chunkLength * initialDirection.getLadderVector().getBlockZ() + (platformWidth * chunkWight) * initialDirection.getPlatformVector().getBlockZ() + 1;
|
||||
int maxY = originY + levelAmount * 5 + 1;
|
||||
return new Region(world, new Point(minX, originY, minZ), new Point(maxX, maxY, maxZ));
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getHeight() {
|
||||
return levelAmount * 5;
|
||||
}
|
||||
|
||||
private void transformXYZ(TransformType transformType, Direction direction, int type) {
|
||||
if (transformType == TransformType.PLATFORM) {
|
||||
if (type == 0) {
|
||||
if (direction == Direction.EAST || direction == Direction.WEST) {
|
||||
nowX += (platformLength * chunkWight) * direction.getPlatformVector().getX();
|
||||
nowZ += (platformWidth * chunkLength - 1) * direction.getPlatformVector().getZ();
|
||||
} else if (direction == Direction.NORTH || direction == Direction.SOUTH) {
|
||||
nowX += (platformWidth * chunkLength - 1) * direction.getPlatformVector().getX();
|
||||
nowZ += (platformLength * chunkWight) * direction.getPlatformVector().getZ();
|
||||
}
|
||||
} else if (type == 1) {
|
||||
if (direction == Direction.EAST || direction == Direction.WEST) {
|
||||
nowX += (platformLength * chunkWight - 1) * direction.getPlatformVector().getX();
|
||||
} else if (direction == Direction.NORTH || direction == Direction.SOUTH) {
|
||||
nowZ += (platformLength * chunkWight - 1) * direction.getPlatformVector().getZ();
|
||||
}
|
||||
switch (nowDirection) {
|
||||
case EAST:
|
||||
nowZ += 1;
|
||||
break;
|
||||
case SOUTH:
|
||||
nowX -= 1;
|
||||
break;
|
||||
case WEST:
|
||||
nowZ -= 1;
|
||||
break;
|
||||
case NORTH:
|
||||
nowX += 1;
|
||||
break;
|
||||
}
|
||||
}
|
||||
} else if (transformType == TransformType.LADDER) {
|
||||
nowY += ladderAmount;
|
||||
if (direction == Direction.EAST || direction == Direction.WEST) {
|
||||
nowX += (ladderAmount * chunkWight) * direction.getLadderVector().getBlockX();
|
||||
} else if (direction == Direction.NORTH || direction == Direction.SOUTH) {
|
||||
nowZ += (ladderAmount * chunkWight) * direction.getLadderVector().getBlockZ();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
|
@ -0,0 +1,13 @@
|
|||
package com.yaohun.enderdragonwars.util;
|
||||
|
||||
import org.bukkit.entity.Entity;
|
||||
import org.bukkit.util.Vector;
|
||||
|
||||
public class EntityUtil {
|
||||
|
||||
public static void shoot(Entity entity, double p_37266_, double p_37267_, double p_37268_, float p_37269_, float p_37270_) {
|
||||
Vector vec3 = new Vector(p_37266_, p_37267_, p_37268_).normalize().add(new Vector(RandomUtil.triangle(0.0D, 0.0172275D * (double) p_37270_), RandomUtil.triangle(0.0D, 0.0172275D * (double) p_37270_), RandomUtil.triangle(0.0D, 0.0172275D * (double) p_37270_))).multiply(p_37269_);
|
||||
entity.setVelocity(vec3);
|
||||
}
|
||||
|
||||
}
|
47
src/main/java/com/yaohun/enderdragonwars/util/GameUtil.java
Normal file
47
src/main/java/com/yaohun/enderdragonwars/util/GameUtil.java
Normal file
|
@ -0,0 +1,47 @@
|
|||
package com.yaohun.enderdragonwars.util;
|
||||
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
public class GameUtil {
|
||||
|
||||
public static String hideName(String audience) {
|
||||
if (audience.length() <= 2) {
|
||||
return "**";
|
||||
}
|
||||
char firstChar = audience.charAt(0);
|
||||
char lastChar = audience.charAt(audience.length() - 1);
|
||||
StringBuilder maskedString = new StringBuilder();
|
||||
for (int i = 1; i < audience.length() - 1; i++) {
|
||||
maskedString.append('*');
|
||||
}
|
||||
return String.valueOf(firstChar) + maskedString + lastChar;
|
||||
}
|
||||
|
||||
public static void sendAllSound(String sound) {
|
||||
for (Player player : Bukkit.getOnlinePlayers()) {
|
||||
if (!sound.contains("_")) {
|
||||
player.playSound(player.getLocation(), sound, 0.5F, 1);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public static boolean specialGiftEffectTriggers(Player player, String eventName, String show_userName, int amount) {
|
||||
if (eventName.contains("盲盒")) {
|
||||
if (eventName.contains("#")) {
|
||||
String s1 = "love";
|
||||
String s2 = "000304";
|
||||
String box = s1 + "-" + s2 + "-" + eventName.split("#")[1];
|
||||
if (eventName.contains("X")) {
|
||||
amount = Integer.parseInt(eventName.split("X")[1]);
|
||||
}
|
||||
// RBoxAPI.addUserData(player, show_userName, box, amount);
|
||||
} else {
|
||||
System.out.println("[错误 - 盲盒] 随机盲盒在礼物设置中配置错误.");
|
||||
}
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
}
|
|
@ -0,0 +1,346 @@
|
|||
package com.yaohun.enderdragonwars.util;
|
||||
|
||||
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;
|
||||
import org.bukkit.enchantments.Enchantment;
|
||||
import org.bukkit.inventory.EquipmentSlot;
|
||||
import org.bukkit.inventory.ItemFlag;
|
||||
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.potion.PotionEffect;
|
||||
|
||||
import java.lang.reflect.Field;
|
||||
import java.util.*;
|
||||
|
||||
public class ItemStackBuilder {
|
||||
|
||||
private ItemStack itemStack;
|
||||
|
||||
private Material type;
|
||||
|
||||
private int amount;
|
||||
|
||||
private short data;
|
||||
|
||||
private ItemMeta meta;
|
||||
|
||||
private String displayName;
|
||||
|
||||
private int customModelData;
|
||||
|
||||
private List<String> lore;
|
||||
|
||||
private Map<Enchantment, Integer> enchants;
|
||||
|
||||
private Set<ItemFlag> itemFlags;
|
||||
|
||||
private List<PotionEffect> potionEffects;
|
||||
private List<Pattern> patterns;
|
||||
private List<FireworkEffect> fireworkEffects;
|
||||
|
||||
public ItemStackBuilder(Material material) {
|
||||
this.itemStack = new ItemStack(material);
|
||||
this.type = material;
|
||||
this.amount = 1;
|
||||
this.data = 0;
|
||||
this.meta = this.itemStack.getItemMeta();
|
||||
this.displayName = this.meta.getDisplayName();
|
||||
this.customModelData = this.meta.hasCustomModelData() ? this.meta.getCustomModelData() : -1;
|
||||
this.lore = new ArrayList<>();
|
||||
this.enchants = new HashMap<>();
|
||||
this.itemFlags = new HashSet<>();
|
||||
this.potionEffects = new ArrayList<>();
|
||||
this.patterns = new ArrayList<>();
|
||||
this.fireworkEffects = new ArrayList<>();
|
||||
}
|
||||
|
||||
public ItemStackBuilder(ItemStack item) {
|
||||
this.itemStack = item.clone();
|
||||
this.type = item.getType();
|
||||
this.amount = item.getAmount();
|
||||
this.data = item.getDurability();
|
||||
this.meta = item.getItemMeta();
|
||||
this.displayName = this.meta.getDisplayName();
|
||||
this.customModelData = this.meta.hasCustomModelData() ? this.meta.getCustomModelData() : -1;
|
||||
this.lore = this.meta.getLore() == null ? new ArrayList<>() : meta.getLore();
|
||||
this.enchants = this.meta.getEnchants();
|
||||
this.itemFlags = this.meta.getItemFlags();
|
||||
this.potionEffects = new ArrayList<>();
|
||||
this.patterns = new ArrayList<>();
|
||||
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);
|
||||
item.setAmount(amount);
|
||||
if (enchants != null) {
|
||||
item.addUnsafeEnchantments(enchants);
|
||||
}
|
||||
ItemMeta itemMeta = item.getItemMeta();
|
||||
if (displayName != null) {
|
||||
itemMeta.setDisplayName(ChatColor.translateAlternateColorCodes('&', displayName));
|
||||
}
|
||||
if (lore != null) {
|
||||
List<String> l = new ArrayList<>();
|
||||
lore.forEach((s) -> {
|
||||
l.add(ChatColor.translateAlternateColorCodes('&', s));
|
||||
});
|
||||
itemMeta.setLore(l);
|
||||
}
|
||||
if (this.customModelData != -1) {
|
||||
itemMeta.setCustomModelData(customModelData);
|
||||
}
|
||||
if (itemFlags != null) {
|
||||
for (ItemFlag flag : itemFlags) {
|
||||
itemMeta.addItemFlags(flag);
|
||||
}
|
||||
}
|
||||
if (fireworkEffects != null && fireworkEffects.size() > 0 && (type.equals(Material.FIREWORK_STAR) || type.equals(Material.FIREWORK_ROCKET))) {
|
||||
FireworkMeta fireworkMeta = (FireworkMeta) itemMeta;
|
||||
for (FireworkEffect effect : fireworkEffects) {
|
||||
fireworkMeta.addEffect(effect);
|
||||
}
|
||||
}
|
||||
item.setItemMeta(itemMeta);
|
||||
return item;
|
||||
}
|
||||
|
||||
public int getAmount() {
|
||||
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;
|
||||
}
|
||||
|
||||
public List<FireworkEffect> getFireworkEffects() {
|
||||
return fireworkEffects;
|
||||
}
|
||||
|
||||
public List<Pattern> getPatterns() {
|
||||
return patterns;
|
||||
}
|
||||
|
||||
public String getDisplayName() {
|
||||
return displayName;
|
||||
}
|
||||
|
||||
public ItemStackBuilder setDisplayName(String name) {
|
||||
this.displayName = name;
|
||||
return this;
|
||||
}
|
||||
|
||||
public short getData() {
|
||||
return data;
|
||||
}
|
||||
|
||||
public ItemStackBuilder setData(int data) {
|
||||
if (data > 255) {
|
||||
data = 255;
|
||||
}
|
||||
this.data = (short) data;
|
||||
return this;
|
||||
}
|
||||
|
||||
public ItemStackBuilder setData(short data) {
|
||||
this.data = data;
|
||||
return this;
|
||||
}
|
||||
|
||||
public ItemStackBuilder setItemStack(ItemStack item) {
|
||||
this.itemStack = item;
|
||||
return this;
|
||||
}
|
||||
|
||||
public ItemStackBuilder setItemMeta(ItemMeta meta) {
|
||||
this.meta = meta;
|
||||
return this;
|
||||
}
|
||||
|
||||
public ItemStackBuilder addLore(String lore) {
|
||||
this.lore.add(lore);
|
||||
return this;
|
||||
}
|
||||
|
||||
public ItemStackBuilder addLore(String... lores) {
|
||||
this.lore.addAll(Arrays.asList(lores));
|
||||
return this;
|
||||
}
|
||||
|
||||
public ItemStackBuilder addLore(List<String> lores) {
|
||||
for (String lore : lores) {
|
||||
this.lore.add(lore);
|
||||
}
|
||||
return this;
|
||||
}
|
||||
|
||||
public ItemStackBuilder addAttributeModifier(Attribute attribute, AttributeModifier attributeModifier) {
|
||||
this.meta.addAttributeModifier(attribute, attributeModifier);
|
||||
return this;
|
||||
}
|
||||
|
||||
public ItemStackBuilder removeAttributeModifier(Attribute attribute) {
|
||||
this.meta.removeAttributeModifier(attribute);
|
||||
return this;
|
||||
}
|
||||
|
||||
public ItemStackBuilder removeAttributeModifier(EquipmentSlot equipmentSlot) {
|
||||
this.meta.removeAttributeModifier(equipmentSlot);
|
||||
return this;
|
||||
}
|
||||
|
||||
public ItemStackBuilder removeAttributeModifier(Attribute attribute, AttributeModifier attributeModifier) {
|
||||
this.meta.removeAttributeModifier(attribute, attributeModifier);
|
||||
return this;
|
||||
}
|
||||
|
||||
public ItemStackBuilder addEnchant(Enchantment ench, int level) {
|
||||
this.enchants.put(ench, level);
|
||||
return this;
|
||||
}
|
||||
|
||||
public ItemStackBuilder removeEnchant(Enchantment ench) {
|
||||
this.enchants.remove(ench);
|
||||
return this;
|
||||
}
|
||||
|
||||
public ItemStackBuilder addItemFlags(ItemFlag[] itemFlags) {
|
||||
this.itemFlags.addAll(Arrays.asList(itemFlags));
|
||||
return this;
|
||||
}
|
||||
|
||||
public ItemStackBuilder addItemFlags(ItemFlag itemFlag) {
|
||||
this.itemFlags.add(itemFlag);
|
||||
return this;
|
||||
}
|
||||
|
||||
public ItemStackBuilder addPotionEffect(PotionEffect potionEffect) {
|
||||
this.potionEffects.add(potionEffect);
|
||||
return this;
|
||||
}
|
||||
|
||||
public ItemStackBuilder addPattern(Pattern pattern) {
|
||||
this.patterns.add(pattern);
|
||||
return this;
|
||||
}
|
||||
|
||||
public ItemStackBuilder addFireworkEffect(FireworkEffect fireworkEffect) {
|
||||
this.fireworkEffects.add(fireworkEffect);
|
||||
return this;
|
||||
}
|
||||
|
||||
protected Map<Enchantment, Integer> getEnchantsFromList(List<String> enchants) {
|
||||
Map<Enchantment, Integer> map = new HashMap<>();
|
||||
if (enchants == null) {
|
||||
return map;
|
||||
}
|
||||
for (String s : enchants) {
|
||||
if (s.contains(":")) {
|
||||
String[] part = s.split(":");
|
||||
Enchantment en = Enchantment.getByName(part[0]);
|
||||
if (en == null) {
|
||||
continue;
|
||||
}
|
||||
map.put(en, Integer.parseInt(part[1]));
|
||||
}
|
||||
}
|
||||
return map;
|
||||
}
|
||||
|
||||
private void setField(Object instance, String name, Object value) throws ReflectiveOperationException {
|
||||
Field field = instance.getClass().getDeclaredField(name);
|
||||
field.setAccessible(true);
|
||||
field.set(instance, value);
|
||||
}
|
||||
|
||||
}
|
|
@ -0,0 +1,31 @@
|
|||
package com.yaohun.enderdragonwars.util;
|
||||
|
||||
import java.util.Random;
|
||||
|
||||
public class RandomUtil {
|
||||
|
||||
public static boolean random(double d) {
|
||||
return d >= new Random().nextFloat();
|
||||
}
|
||||
|
||||
public static double triangle(double d1, double d2) {
|
||||
Random r = new Random();
|
||||
return d1 + d2 * (r.nextDouble() - r.nextDouble());
|
||||
}
|
||||
|
||||
public static int getRandomInt(int min, int max) {
|
||||
if (min == max) {
|
||||
return max;
|
||||
}
|
||||
Random r = new Random();
|
||||
int i = min < max ? min : max;
|
||||
int a = min < max ? max : min;
|
||||
return r.nextInt(a - i + 1) + i;
|
||||
}
|
||||
|
||||
public static double getRandomDouble(double min, double max, int scl) {
|
||||
int pow = (int) Math.pow(10, scl);
|
||||
return Math.floor((Math.random() * (max - min) + min) * pow) / pow;
|
||||
}
|
||||
|
||||
}
|
44
src/main/java/com/yaohun/enderdragonwars/util/WEUtil.java
Normal file
44
src/main/java/com/yaohun/enderdragonwars/util/WEUtil.java
Normal file
|
@ -0,0 +1,44 @@
|
|||
package com.yaohun.enderdragonwars.util;
|
||||
|
||||
import com.sk89q.worldedit.EditSession;
|
||||
import com.sk89q.worldedit.WorldEdit;
|
||||
import com.sk89q.worldedit.bukkit.BukkitAdapter;
|
||||
import com.sk89q.worldedit.extent.clipboard.Clipboard;
|
||||
import com.sk89q.worldedit.extent.clipboard.io.ClipboardFormats;
|
||||
import com.sk89q.worldedit.math.BlockVector3;
|
||||
import com.yaohun.enderdragonwars.Main;
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.Location;
|
||||
import org.bukkit.World;
|
||||
|
||||
import java.io.File;
|
||||
|
||||
public class WEUtil {
|
||||
|
||||
public static void loadSchematics(Location location, String fileName) {
|
||||
File path = new File(Main.plugin.getDataFolder(), "schematics");
|
||||
if (!path.exists()) {
|
||||
path.mkdirs();
|
||||
}
|
||||
File schematicFile = new File(path, fileName + ".schem");
|
||||
if (!schematicFile.exists()) {
|
||||
Main.plugin.saveResource("schematics/" + fileName + ".schem", false);
|
||||
}
|
||||
World world = location.getWorld();
|
||||
EditSession editSession = WorldEdit.getInstance().newEditSession(BukkitAdapter.adapt(world));
|
||||
Bukkit.getScheduler().runTaskAsynchronously(Main.plugin, () -> {
|
||||
try {
|
||||
Clipboard clipboard = ClipboardFormats.findByFile(schematicFile).load(schematicFile);
|
||||
clipboard.paste(BukkitAdapter.adapt(world), BlockVector3.at(location.getBlockX(), location.getBlockY(), location.getBlockZ()));
|
||||
clipboard.flush();
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
} finally {
|
||||
editSession.close();
|
||||
}
|
||||
}
|
||||
);
|
||||
|
||||
}
|
||||
|
||||
}
|
8
src/main/resources/plugin.yml
Normal file
8
src/main/resources/plugin.yml
Normal file
|
@ -0,0 +1,8 @@
|
|||
name: EnderDragonWar
|
||||
version: 1.0
|
||||
api-version: 1.20
|
||||
main: com.yaohun.enderdragonwars.Main
|
||||
depend: [PixelLiveAPI]
|
||||
commands:
|
||||
enderdragonwar:
|
||||
aliases: [edw]
|
BIN
src/main/resources/schematics/anquanwu.schem
Normal file
BIN
src/main/resources/schematics/anquanwu.schem
Normal file
Binary file not shown.
Loading…
Reference in New Issue
Block a user