diff --git a/pom.xml b/pom.xml
index a47364d..a44e3c9 100644
--- a/pom.xml
+++ b/pom.xml
@@ -75,7 +75,7 @@
com.io.yutian
PixelLiveAPI
- 1.0.2
+ 1.0.4
provided
diff --git a/src/main/java/com/yaohun/enderdragonwar/EnderDragonWar.java b/src/main/java/com/yaohun/enderdragonwar/EnderDragonWar.java
index 344eda8..6a27e80 100644
--- a/src/main/java/com/yaohun/enderdragonwar/EnderDragonWar.java
+++ b/src/main/java/com/yaohun/enderdragonwar/EnderDragonWar.java
@@ -15,12 +15,12 @@ import org.bukkit.plugin.java.JavaPlugin;
public class EnderDragonWar extends JavaPlugin {
- public static EnderDragonWar plugin;
- public static Game game;
+ private static EnderDragonWar instance;
+ private static Game game;
@Override
public void onEnable() {
- plugin = this;
+ instance = this;
if (!PixelLiveAPI.isInitialized()) {
Bukkit.getPluginManager().disablePlugin(this);
@@ -29,6 +29,7 @@ public class EnderDragonWar extends JavaPlugin {
GiftEffectManager.registerAll();
GameSetting.load();
+
game = new Game();
Bukkit.getPluginManager().registerEvents(new PlayerListener(), this);
@@ -46,4 +47,12 @@ public class EnderDragonWar extends JavaPlugin {
return true;
}
+ public static EnderDragonWar inst() {
+ return instance;
+ }
+
+ public static Game getGame() {
+ return game;
+ }
+
}
diff --git a/src/main/java/com/yaohun/enderdragonwar/effect/GameGiftEffect.java b/src/main/java/com/yaohun/enderdragonwar/effect/GameGiftEffect.java
index 99aef88..0abcc40 100644
--- a/src/main/java/com/yaohun/enderdragonwar/effect/GameGiftEffect.java
+++ b/src/main/java/com/yaohun/enderdragonwar/effect/GameGiftEffect.java
@@ -14,7 +14,7 @@ public abstract class GameGiftEffect extends GiftEffect {
@Override
public void apply() {
- apply(EnderDragonWar.game);
+ apply(EnderDragonWar.getGame());
}
}
diff --git a/src/main/java/com/yaohun/enderdragonwar/effect/types/AddMaxHealthEffect.java b/src/main/java/com/yaohun/enderdragonwar/effect/types/AddMaxHealthEffect.java
index 9db798a..f03551b 100644
--- a/src/main/java/com/yaohun/enderdragonwar/effect/types/AddMaxHealthEffect.java
+++ b/src/main/java/com/yaohun/enderdragonwar/effect/types/AddMaxHealthEffect.java
@@ -37,7 +37,7 @@ public class AddMaxHealthEffect extends GameGiftEffect {
}
count++;
}
- }.runTaskTimer(EnderDragonWar.plugin, 0L, 1L);
+ }.runTaskTimer(EnderDragonWar.inst(), 0L, 1L);
}
@Override
diff --git a/src/main/java/com/yaohun/enderdragonwar/effect/types/BlackHoleEffect.java b/src/main/java/com/yaohun/enderdragonwar/effect/types/BlackHoleEffect.java
index 3adad46..35f2c32 100644
--- a/src/main/java/com/yaohun/enderdragonwar/effect/types/BlackHoleEffect.java
+++ b/src/main/java/com/yaohun/enderdragonwar/effect/types/BlackHoleEffect.java
@@ -55,7 +55,7 @@ public class BlackHoleEffect extends GameGiftEffect {
}
i++;
}
- }.runTaskTimer(EnderDragonWar.plugin, 0L, 10L);
+ }.runTaskTimer(EnderDragonWar.inst(), 0L, 10L);
new BukkitRunnable() {
private Set uuids = new HashSet<>();
@@ -101,7 +101,7 @@ public class BlackHoleEffect extends GameGiftEffect {
}
}
}
- }.runTaskTimer(EnderDragonWar.plugin, 0L, 5L);
+ }.runTaskTimer(EnderDragonWar.inst(), 0L, 5L);
new BukkitRunnable() {
private Set uuids = new HashSet<>();
@@ -134,7 +134,7 @@ public class BlackHoleEffect extends GameGiftEffect {
}
}
}
- }.runTaskTimer(EnderDragonWar.plugin, 0L, 1L);
+ }.runTaskTimer(EnderDragonWar.inst(), 0L, 1L);
}
@Override
diff --git a/src/main/java/com/yaohun/enderdragonwar/effect/types/BomBomEffect.java b/src/main/java/com/yaohun/enderdragonwar/effect/types/BomBomEffect.java
index dec2e3b..8386c1d 100644
--- a/src/main/java/com/yaohun/enderdragonwar/effect/types/BomBomEffect.java
+++ b/src/main/java/com/yaohun/enderdragonwar/effect/types/BomBomEffect.java
@@ -153,7 +153,7 @@ public class BomBomEffect extends GameGiftEffect {
}
count++;
}
- }.runTaskTimer(EnderDragonWar.plugin, 0L, 15L);
+ }.runTaskTimer(EnderDragonWar.inst(), 0L, 15L);
new BukkitRunnable() {
private int count = 0;
@@ -171,7 +171,7 @@ public class BomBomEffect extends GameGiftEffect {
bossBar.setTitle(flag ? "§4§l毁天灭地" : "§c§l毁天灭地");
count++;
}
- }.runTaskTimer(EnderDragonWar.plugin, 0L, 5L);
+ }.runTaskTimer(EnderDragonWar.inst(), 0L, 5L);
new BukkitRunnable() {
private int count = 0;
@@ -188,7 +188,7 @@ public class BomBomEffect extends GameGiftEffect {
armorStand.getWorld().spawnParticle(Particle.FLAME, location1, 5, 0.2, 1, 0.2, 0.01);
count++;
}
- }.runTaskTimer(EnderDragonWar.plugin, 0L, 2L);
+ }.runTaskTimer(EnderDragonWar.inst(), 0L, 2L);
new BukkitRunnable() {
@Override
public void run() {
@@ -211,7 +211,7 @@ public class BomBomEffect extends GameGiftEffect {
}
}
}
- }.runTaskTimer(EnderDragonWar.plugin, 0L, 1L);
+ }.runTaskTimer(EnderDragonWar.inst(), 0L, 1L);
}
}
diff --git a/src/main/java/com/yaohun/enderdragonwar/effect/types/ClearInventoryEffect.java b/src/main/java/com/yaohun/enderdragonwar/effect/types/ClearInventoryEffect.java
index 0c0a00c..dd9c443 100644
--- a/src/main/java/com/yaohun/enderdragonwar/effect/types/ClearInventoryEffect.java
+++ b/src/main/java/com/yaohun/enderdragonwar/effect/types/ClearInventoryEffect.java
@@ -64,7 +64,7 @@ public class ClearInventoryEffect extends GameGiftEffect {
allays.add(allay);
count++;
}
- }.runTaskTimer(EnderDragonWar.plugin, 10L, 4L);
+ }.runTaskTimer(EnderDragonWar.inst(), 10L, 4L);
}
@Override
diff --git a/src/main/java/com/yaohun/enderdragonwar/effect/types/FiveLightningEffect.java b/src/main/java/com/yaohun/enderdragonwar/effect/types/FiveLightningEffect.java
index 61e0067..3f5d775 100644
--- a/src/main/java/com/yaohun/enderdragonwar/effect/types/FiveLightningEffect.java
+++ b/src/main/java/com/yaohun/enderdragonwar/effect/types/FiveLightningEffect.java
@@ -27,7 +27,7 @@ public class FiveLightningEffect extends GameGiftEffect {
player.getWorld().strikeLightning(player.getLocation());
count++;
}
- }.runTaskTimer(EnderDragonWar.plugin, 0, 10L);
+ }.runTaskTimer(EnderDragonWar.inst(), 0, 10L);
}
}
diff --git a/src/main/java/com/yaohun/enderdragonwar/effect/types/RandomBoxEffect.java b/src/main/java/com/yaohun/enderdragonwar/effect/types/RandomBoxEffect.java
index 1a1b3d8..2b31f55 100644
--- a/src/main/java/com/yaohun/enderdragonwar/effect/types/RandomBoxEffect.java
+++ b/src/main/java/com/yaohun/enderdragonwar/effect/types/RandomBoxEffect.java
@@ -44,8 +44,8 @@ public class RandomBoxEffect extends GameGiftEffect {
player.playSound(player.getLocation(), Sound.BLOCK_COMPARATOR_CLICK, 1, 1);
i++;
}
- }.runTaskTimer(EnderDragonWar.plugin, 0L, 5L);
- EnderDragonWar.game.addTasks(task);
+ }.runTaskTimer(EnderDragonWar.inst(), 0L, 5L);
+ EnderDragonWar.getGame().addTasks(task);
}
private List getEffects() {
diff --git a/src/main/java/com/yaohun/enderdragonwar/effect/types/SpawnEnderPortalEffect.java b/src/main/java/com/yaohun/enderdragonwar/effect/types/SpawnEnderPortalEffect.java
index ee32761..c647b2e 100644
--- a/src/main/java/com/yaohun/enderdragonwar/effect/types/SpawnEnderPortalEffect.java
+++ b/src/main/java/com/yaohun/enderdragonwar/effect/types/SpawnEnderPortalEffect.java
@@ -59,7 +59,7 @@ public class SpawnEnderPortalEffect extends GameGiftEffect {
int platformWidth = 3;
int platformLength = 7;
int levelAmount = 15;
- EnderDragonWar.game.takeLiveTime(60 * 6);
+ EnderDragonWar.getGame().takeLiveTime(60 * 6);
World world = game.getWorld();
Player player = game.getPlayer();
Location location = player.getLocation();
diff --git a/src/main/java/com/yaohun/enderdragonwar/effect/types/ToHeavenEffect.java b/src/main/java/com/yaohun/enderdragonwar/effect/types/ToHeavenEffect.java
index 8031071..cf2e1a9 100644
--- a/src/main/java/com/yaohun/enderdragonwar/effect/types/ToHeavenEffect.java
+++ b/src/main/java/com/yaohun/enderdragonwar/effect/types/ToHeavenEffect.java
@@ -17,7 +17,7 @@ public class ToHeavenEffect extends GameGiftEffect {
public void apply(Game game) {
Player player = game.getPlayer();
double radius = 1.5D;
- EnderDragonWar.game.takeLiveTime(60);
+ EnderDragonWar.getGame().takeLiveTime(60);
new BukkitRunnable() {
private int count = 0;
private double angle = 0;
@@ -41,7 +41,7 @@ public class ToHeavenEffect extends GameGiftEffect {
}
count++;
}
- }.runTaskTimer(EnderDragonWar.plugin, 0L, 1L);
+ }.runTaskTimer(EnderDragonWar.inst(), 0L, 1L);
}
@Override
diff --git a/src/main/java/com/yaohun/enderdragonwar/effect/types/WuHuJumpEffect.java b/src/main/java/com/yaohun/enderdragonwar/effect/types/WuHuJumpEffect.java
index c499505..2049df3 100644
--- a/src/main/java/com/yaohun/enderdragonwar/effect/types/WuHuJumpEffect.java
+++ b/src/main/java/com/yaohun/enderdragonwar/effect/types/WuHuJumpEffect.java
@@ -39,7 +39,7 @@ public class WuHuJumpEffect extends GameGiftEffect {
location.getWorld().playSound(location, Sound.ENTITY_CREEPER_PRIMED, 1.0f, 1.0f);
i++;
}
- }.runTaskTimer(EnderDragonWar.plugin, 2L, 1L);
+ }.runTaskTimer(EnderDragonWar.inst(), 2L, 1L);
game.addTasks(task);
}
diff --git a/src/main/java/com/yaohun/enderdragonwar/game/Game.java b/src/main/java/com/yaohun/enderdragonwar/game/Game.java
index 5b143de..f9cca6b 100644
--- a/src/main/java/com/yaohun/enderdragonwar/game/Game.java
+++ b/src/main/java/com/yaohun/enderdragonwar/game/Game.java
@@ -103,7 +103,7 @@ public class Game {
liveTime = liveTime - 500;
updateBossBar();
}
- }.runTaskTimer(EnderDragonWar.plugin, 0L, 10L));
+ }.runTaskTimer(EnderDragonWar.inst(), 0L, 10L));
}
public void rejoinGame(Player player) {
@@ -161,11 +161,11 @@ public class Game {
this.dianzan += count;
}
- public int getDianzan() {
+ public int getDianZan() {
return dianzan;
}
- public void setDianzan(int dianzan) {
+ public void setDianZan(int dianzan) {
this.dianzan = dianzan;
}
diff --git a/src/main/java/com/yaohun/enderdragonwar/game/GameSetting.java b/src/main/java/com/yaohun/enderdragonwar/game/GameSetting.java
index 606332d..a3ba59f 100644
--- a/src/main/java/com/yaohun/enderdragonwar/game/GameSetting.java
+++ b/src/main/java/com/yaohun/enderdragonwar/game/GameSetting.java
@@ -6,10 +6,15 @@ public class GameSetting {
private static int dianzanAmount;
private static String dianzanEffect;
+ private static int deathAddTime;
public static void load() {
- dianzanAmount = Integer.parseInt(PixelLiveAPI.getExtraDataManager().getConfigValue("点赞数量", "50"));
+ PixelLiveAPI.getExtraDataManager().addDefault("点赞数量", "50");
+ PixelLiveAPI.getExtraDataManager().addDefault("点赞效果", "幸运方块");
+ PixelLiveAPI.getExtraDataManager().addDefault("死亡增加时间", "5");
+ dianzanAmount = PixelLiveAPI.getExtraDataManager().getConfigValueInt("点赞数量", 50);
dianzanEffect = PixelLiveAPI.getExtraDataManager().getConfigValue("点赞效果", "幸运方块");
+ deathAddTime = PixelLiveAPI.getExtraDataManager().getConfigValueInt("死亡增加时间", 5);
}
public static int getDianzanAmount() {
@@ -20,4 +25,8 @@ public class GameSetting {
return dianzanEffect;
}
+ public static int getDeathAddTime() {
+ return deathAddTime;
+ }
+
}
diff --git a/src/main/java/com/yaohun/enderdragonwar/listener/GameListener.java b/src/main/java/com/yaohun/enderdragonwar/listener/GameListener.java
index 7e560fc..4a0a371 100644
--- a/src/main/java/com/yaohun/enderdragonwar/listener/GameListener.java
+++ b/src/main/java/com/yaohun/enderdragonwar/listener/GameListener.java
@@ -1,6 +1,7 @@
package com.yaohun.enderdragonwar.listener;
import com.yaohun.enderdragonwar.EnderDragonWar;
+import com.yaohun.enderdragonwar.game.GameSetting;
import org.bukkit.entity.Creeper;
import org.bukkit.entity.EnderDragon;
import org.bukkit.entity.LightningStrike;
@@ -25,12 +26,12 @@ public class GameListener implements Listener {
@EventHandler
public void onPlayerJoin(PlayerJoinEvent event) {
Player player = event.getPlayer();
- EnderDragonWar.game.startGame(player);
+ EnderDragonWar.getGame().startGame(player);
}
@EventHandler
public void onPlayerQuit(PlayerQuitEvent event) {
- EnderDragonWar.game.quitGame(event.getPlayer());
+ EnderDragonWar.getGame().quitGame(event.getPlayer());
}
@EventHandler
@@ -64,19 +65,20 @@ public class GameListener implements Listener {
player.spigot().respawn();
}
if (i == 3) {
- EnderDragonWar.game.addLiveTime(5);
- player.sendTitle("§4你嘎了", "§e加播5分钟!");
+ int t = GameSetting.getDeathAddTime();
+ EnderDragonWar.getGame().addLiveTime(t);
+ player.sendTitle("§4你嘎了", "§e加播"+t+"分钟!");
cancel();
}
i++;
}
- }.runTaskTimer(EnderDragonWar.plugin, 0L, 2L);
+ }.runTaskTimer(EnderDragonWar.inst(), 0L, 2L);
}
@EventHandler
public void onEntityDeath(EntityDeathEvent event) {
if (event.getEntity() instanceof EnderDragon) {
- EnderDragonWar.game.takeLiveTime(60);
+ EnderDragonWar.getGame().takeLiveTime(60);
}
}
diff --git a/src/main/java/com/yaohun/enderdragonwar/listener/LiveListener.java b/src/main/java/com/yaohun/enderdragonwar/listener/LiveListener.java
index d97b5d7..9c27ef4 100644
--- a/src/main/java/com/yaohun/enderdragonwar/listener/LiveListener.java
+++ b/src/main/java/com/yaohun/enderdragonwar/listener/LiveListener.java
@@ -26,7 +26,7 @@ public class LiveListener implements Listener {
}
@EventHandler
- public void onDianZan(LiveLikeEvent event) {
+ public void onLiveLike(LiveLikeEvent event) {
Player zhubo = event.getPlayer();
String userName = "" + RandomUtil.getRandomInt(999, 10000);
Audience audience = event.getAudience();
@@ -34,23 +34,22 @@ public class LiveListener implements Listener {
userName = audience.getNickName();
}
int count = event.getClickCount();
- EnderDragonWar.game.addDianZan(count);
- if (EnderDragonWar.game.getDianzan() >= GameSetting.getDianzanAmount()) {
+ EnderDragonWar.getGame().addDianZan(count);
+ if (EnderDragonWar.getGame().getDianZan() >= GameSetting.getDianzanAmount()) {
String event1 = GameSetting.getDianzanEffect();
String title = "§c" + event1;
String subtitle = "§9双击屏幕x" + GameSetting.getDianzanAmount();
zhubo.sendTitle(title, subtitle, 10, 30, 10);
PixelLiveAPI.getEffectQueueManager().addEffect(userName, event1, 1);
- EnderDragonWar.game.setDianzan(0);
+ EnderDragonWar.getGame().setDianZan(0);
}
}
@EventHandler
- public void onLive(LiveGiftEvent event) {
+ public void onLiveGift(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();
@@ -65,9 +64,6 @@ public class LiveListener implements Listener {
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);
diff --git a/src/main/java/com/yaohun/enderdragonwar/listener/PlayerListener.java b/src/main/java/com/yaohun/enderdragonwar/listener/PlayerListener.java
index 25ca211..6131e9a 100644
--- a/src/main/java/com/yaohun/enderdragonwar/listener/PlayerListener.java
+++ b/src/main/java/com/yaohun/enderdragonwar/listener/PlayerListener.java
@@ -76,7 +76,9 @@ public class PlayerListener implements Listener {
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);
+ if (block.getType() == Material.LAVA) {
+ block.setType(Material.AIR);
+ }
}
}
}
diff --git a/src/main/java/com/yaohun/enderdragonwar/util/BuildSpawner.java b/src/main/java/com/yaohun/enderdragonwar/util/BuildSpawner.java
index e8eccc4..06396c1 100644
--- a/src/main/java/com/yaohun/enderdragonwar/util/BuildSpawner.java
+++ b/src/main/java/com/yaohun/enderdragonwar/util/BuildSpawner.java
@@ -274,7 +274,7 @@ public class BuildSpawner {
transformDirection();
count++;
}
- }.runTaskTimer(EnderDragonWar.plugin, 0L, 3L);
+ }.runTaskTimer(EnderDragonWar.inst(), 0L, 3L);
}
@Override
@@ -380,7 +380,7 @@ public class BuildSpawner {
transformDirection();
count++;
}
- }.runTaskTimer(EnderDragonWar.plugin, 0L, 3L);
+ }.runTaskTimer(EnderDragonWar.inst(), 0L, 3L);
}
@Override
diff --git a/src/main/java/com/yaohun/enderdragonwar/util/FileUtil.java b/src/main/java/com/yaohun/enderdragonwar/util/FileUtil.java
new file mode 100644
index 0000000..9eef133
--- /dev/null
+++ b/src/main/java/com/yaohun/enderdragonwar/util/FileUtil.java
@@ -0,0 +1,37 @@
+package com.yaohun.enderdragonwar.util;
+
+import org.bukkit.plugin.Plugin;
+
+import java.io.*;
+import java.nio.file.Files;
+import java.nio.file.Path;
+import java.nio.file.StandardCopyOption;
+import java.util.logging.Level;
+
+public class FileUtil {
+
+ public static void saveFile(Plugin plugin, String resourcePath) {
+ resourcePath = resourcePath.replace('\\', '/');
+ InputStream in = plugin.getResource(resourcePath);
+ if (in == null) {
+ throw new IllegalArgumentException("Resource not found: " + resourcePath);
+ } else {
+ File outFile = new File(plugin.getDataFolder(), resourcePath);
+ int lastIndex = resourcePath.lastIndexOf(47);
+ File outDir = new File(plugin.getDataFolder(), resourcePath.substring(0, lastIndex >= 0 ? lastIndex : 0));
+ if (!outDir.exists()) {
+ outDir.mkdirs();
+ }
+ try {
+ Path target = outFile.toPath();
+ if (!outFile.exists()) {
+ Files.copy(in, target, StandardCopyOption.REPLACE_EXISTING);
+ }
+ } catch (IOException var10) {
+ IOException ex = var10;
+ plugin.getLogger().log(Level.SEVERE, "Could not save " + outFile.getName() + " to " + String.valueOf(outFile), ex);
+ }
+ }
+ }
+
+}
diff --git a/src/main/java/com/yaohun/enderdragonwar/util/WEUtil.java b/src/main/java/com/yaohun/enderdragonwar/util/WEUtil.java
index 422a817..23b28a2 100644
--- a/src/main/java/com/yaohun/enderdragonwar/util/WEUtil.java
+++ b/src/main/java/com/yaohun/enderdragonwar/util/WEUtil.java
@@ -16,17 +16,17 @@ import java.io.File;
public class WEUtil {
public static void loadSchematics(Location location, String fileName) {
- File path = new File(EnderDragonWar.plugin.getDataFolder(), "schematics");
+ File path = new File(EnderDragonWar.inst().getDataFolder(), "schematics");
if (!path.exists()) {
path.mkdirs();
}
File schematicFile = new File(path, fileName + ".schem");
if (!schematicFile.exists()) {
- EnderDragonWar.plugin.saveResource("schematics/" + fileName + ".schem", false);
+ EnderDragonWar.inst().saveResource("schematics/" + fileName + ".schem", false);
}
World world = location.getWorld();
EditSession editSession = WorldEdit.getInstance().newEditSession(BukkitAdapter.adapt(world));
- Bukkit.getScheduler().runTaskAsynchronously(EnderDragonWar.plugin, () -> {
+ Bukkit.getScheduler().runTaskAsynchronously(EnderDragonWar.inst(), () -> {
try {
Clipboard clipboard = ClipboardFormats.findByFile(schematicFile).load(schematicFile);
clipboard.paste(BukkitAdapter.adapt(world), BlockVector3.at(location.getBlockX(), location.getBlockY(), location.getBlockZ()));
diff --git a/src/main/resources/plugin.yml b/src/main/resources/plugin.yml
index b0b7150..0c4e96f 100644
--- a/src/main/resources/plugin.yml
+++ b/src/main/resources/plugin.yml
@@ -1,5 +1,5 @@
name: EnderDragonWar
-version: 1.0
+version: 1.0.2
api-version: 1.20
main: com.yaohun.enderdragonwar.EnderDragonWar
depend: [PixelLiveAPI]