1.0
This commit is contained in:
parent
9e1a8f0298
commit
e20a708e89
|
@ -52,15 +52,13 @@ public final class TheWarDungeon extends JavaPlugin {
|
||||||
|
|
||||||
CommandManager.unregisterAll();
|
CommandManager.unregisterAll();
|
||||||
|
|
||||||
/*
|
|
||||||
for (Dungeon dungeon : DungeonManager.getDungeons()) {
|
for (Dungeon dungeon : DungeonManager.getDungeons()) {
|
||||||
for (DungeonInstance dungeonInstance : dungeon.getQueue().getAllDungeonInstance()) {
|
for (DungeonInstance dungeonInstance : dungeon.getQueue().getAllDungeonInstance()) {
|
||||||
dungeonInstance.getWorldInstance().remove();
|
dungeonInstance.getWorldInstance().remove();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
*/
|
|
||||||
|
|
||||||
checkWorldFile();
|
//checkWorldFile();
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -6,6 +6,7 @@ import com.io.yutian.thewardungeon.dungeon.queue.DungeonQueue;
|
||||||
import com.io.yutian.thewardungeon.dungeon.world.WorldInstance;
|
import com.io.yutian.thewardungeon.dungeon.world.WorldInstance;
|
||||||
import com.io.yutian.thewardungeon.util.Log;
|
import com.io.yutian.thewardungeon.util.Log;
|
||||||
import com.io.yutian.thewarskyblocklib.util.FileUtil;
|
import com.io.yutian.thewarskyblocklib.util.FileUtil;
|
||||||
|
import org.bukkit.GameRule;
|
||||||
import org.bukkit.World;
|
import org.bukkit.World;
|
||||||
import org.bukkit.WorldCreator;
|
import org.bukkit.WorldCreator;
|
||||||
import org.jetbrains.annotations.Nullable;
|
import org.jetbrains.annotations.Nullable;
|
||||||
|
@ -87,8 +88,7 @@ public class Dungeon {
|
||||||
WorldCreator dungeonWorldCreator = new WorldCreator(worldName);
|
WorldCreator dungeonWorldCreator = new WorldCreator(worldName);
|
||||||
try {
|
try {
|
||||||
world = dungeonWorldCreator.createWorld();
|
world = dungeonWorldCreator.createWorld();
|
||||||
world.setKeepSpawnInMemory(false);
|
initWorld(world);
|
||||||
world.setAutoSave(false);
|
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
e.printStackTrace();
|
e.printStackTrace();
|
||||||
return null;
|
return null;
|
||||||
|
@ -98,6 +98,16 @@ public class Dungeon {
|
||||||
return worldInstance;
|
return worldInstance;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private void initWorld(World world) {
|
||||||
|
world.setGameRule(GameRule.KEEP_INVENTORY, true);
|
||||||
|
world.setGameRule(GameRule.MOB_GRIEFING, false);
|
||||||
|
world.setGameRule(GameRule.DO_DAYLIGHT_CYCLE, false);
|
||||||
|
world.setGameRule(GameRule.DO_WEATHER_CYCLE, false);
|
||||||
|
world.setGameRule(GameRule.DO_MOB_SPAWNING, false);
|
||||||
|
world.setKeepSpawnInMemory(false);
|
||||||
|
world.setAutoSave(false);
|
||||||
|
}
|
||||||
|
|
||||||
@Nullable
|
@Nullable
|
||||||
public DungeonInstance newInstance() {
|
public DungeonInstance newInstance() {
|
||||||
if (!hasFreeInstance()) {
|
if (!hasFreeInstance()) {
|
||||||
|
|
|
@ -12,6 +12,7 @@ import com.io.yutian.thewardungeon.dungeon.world.WorldInstance;
|
||||||
import com.io.yutian.thewardungeon.lang.Lang;
|
import com.io.yutian.thewardungeon.lang.Lang;
|
||||||
import com.io.yutian.thewardungeon.manager.DungeonManager;
|
import com.io.yutian.thewardungeon.manager.DungeonManager;
|
||||||
import com.io.yutian.thewardungeon.script.ScriptGourp;
|
import com.io.yutian.thewardungeon.script.ScriptGourp;
|
||||||
|
import com.io.yutian.thewardungeon.util.BossBarUtil;
|
||||||
import com.io.yutian.thewardungeon.util.LogUtil;
|
import com.io.yutian.thewardungeon.util.LogUtil;
|
||||||
import com.io.yutian.thewarskyblocklib.math.Point;
|
import com.io.yutian.thewarskyblocklib.math.Point;
|
||||||
import io.lumine.mythic.bukkit.BukkitAdapter;
|
import io.lumine.mythic.bukkit.BukkitAdapter;
|
||||||
|
@ -21,6 +22,9 @@ import io.lumine.mythic.core.mobs.MobRegistry;
|
||||||
import org.bukkit.Bukkit;
|
import org.bukkit.Bukkit;
|
||||||
import org.bukkit.Location;
|
import org.bukkit.Location;
|
||||||
import org.bukkit.World;
|
import org.bukkit.World;
|
||||||
|
import org.bukkit.boss.BarColor;
|
||||||
|
import org.bukkit.boss.BarStyle;
|
||||||
|
import org.bukkit.boss.BossBar;
|
||||||
import org.bukkit.entity.Entity;
|
import org.bukkit.entity.Entity;
|
||||||
import org.bukkit.entity.Player;
|
import org.bukkit.entity.Player;
|
||||||
import org.bukkit.scheduler.BukkitRunnable;
|
import org.bukkit.scheduler.BukkitRunnable;
|
||||||
|
@ -38,6 +42,8 @@ public class DungeonInstance {
|
||||||
|
|
||||||
private DungeonState state = DungeonState.WAITING;
|
private DungeonState state = DungeonState.WAITING;
|
||||||
|
|
||||||
|
private BossBar bossBar;
|
||||||
|
|
||||||
private DungeonLobby dungeonLobby;
|
private DungeonLobby dungeonLobby;
|
||||||
|
|
||||||
private Point spawnPoint;
|
private Point spawnPoint;
|
||||||
|
@ -60,12 +66,14 @@ public class DungeonInstance {
|
||||||
this.uuid = uuid;
|
this.uuid = uuid;
|
||||||
this.dungeon = dungeon;
|
this.dungeon = dungeon;
|
||||||
this.worldInstance = worldInstance;
|
this.worldInstance = worldInstance;
|
||||||
|
this.bossBar = Bukkit.createBossBar("倒计时", BarColor.WHITE, BarStyle.SOLID);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void join(Player player, boolean start) {
|
public void join(Player player, boolean start) {
|
||||||
if (!canJoin(player)) {
|
if (!canJoin(player)) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
this.bossBar.addPlayer(player);
|
||||||
addPlayer(player);
|
addPlayer(player);
|
||||||
if (start && players.size() == 1) {
|
if (start && players.size() == 1) {
|
||||||
player.teleport(dungeon.getConfig().getLobbyPoint().toLocation(worldInstance.getWorld()));
|
player.teleport(dungeon.getConfig().getLobbyPoint().toLocation(worldInstance.getWorld()));
|
||||||
|
@ -93,6 +101,7 @@ public class DungeonInstance {
|
||||||
}
|
}
|
||||||
|
|
||||||
public void leave(Player player) {
|
public void leave(Player player) {
|
||||||
|
this.bossBar.removePlayer(player);
|
||||||
if (dungeonLobby != null && state.equals(DungeonState.WAITING)) {
|
if (dungeonLobby != null && state.equals(DungeonState.WAITING)) {
|
||||||
dungeonLobby.removeBossBar(player);
|
dungeonLobby.removeBossBar(player);
|
||||||
}
|
}
|
||||||
|
@ -256,6 +265,7 @@ public class DungeonInstance {
|
||||||
cancel();
|
cancel();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
updateBossBar();
|
||||||
}
|
}
|
||||||
}.runTaskTimer(TheWarDungeon.inst(), 20L, 20L));
|
}.runTaskTimer(TheWarDungeon.inst(), 20L, 20L));
|
||||||
tasks.add(new BukkitRunnable() {
|
tasks.add(new BukkitRunnable() {
|
||||||
|
@ -293,6 +303,13 @@ public class DungeonInstance {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private void updateBossBar() {
|
||||||
|
bossBar.setTitle("倒计时: " + countdown + "/" + dungeon.getConfig().getOption().getCountdown());
|
||||||
|
float progress = (float) countdown / (float) dungeon.getConfig().getOption().getCountdown();
|
||||||
|
bossBar.setProgress(progress);
|
||||||
|
bossBar.setColor(BossBarUtil.getBarColor(progress));
|
||||||
|
}
|
||||||
|
|
||||||
private boolean isWorldLoaded() {
|
private boolean isWorldLoaded() {
|
||||||
try {
|
try {
|
||||||
BukkitAdapter.adapt(worldInstance.getWorld());
|
BukkitAdapter.adapt(worldInstance.getWorld());
|
||||||
|
|
|
@ -1,12 +1,9 @@
|
||||||
package com.io.yutian.thewardungeon.dungeon.world;
|
package com.io.yutian.thewardungeon.dungeon.world;
|
||||||
|
|
||||||
import com.io.yutian.thewardungeon.TheWarDungeon;
|
|
||||||
import org.apache.commons.io.FileUtils;
|
|
||||||
import org.bukkit.Bukkit;
|
import org.bukkit.Bukkit;
|
||||||
import org.bukkit.World;
|
import org.bukkit.World;
|
||||||
|
|
||||||
import java.io.File;
|
import java.io.File;
|
||||||
import java.io.IOException;
|
|
||||||
import java.util.UUID;
|
import java.util.UUID;
|
||||||
|
|
||||||
public class WorldInstance {
|
public class WorldInstance {
|
||||||
|
@ -52,6 +49,7 @@ public class WorldInstance {
|
||||||
}
|
}
|
||||||
destroyed = true;
|
destroyed = true;
|
||||||
unloadWorld();
|
unloadWorld();
|
||||||
|
/*
|
||||||
Bukkit.getScheduler().runTaskLater(TheWarDungeon.inst(), ()->{
|
Bukkit.getScheduler().runTaskLater(TheWarDungeon.inst(), ()->{
|
||||||
try {
|
try {
|
||||||
FileUtils.deleteDirectory(folder);
|
FileUtils.deleteDirectory(folder);
|
||||||
|
@ -59,6 +57,7 @@ public class WorldInstance {
|
||||||
e.printStackTrace();
|
e.printStackTrace();
|
||||||
}
|
}
|
||||||
}, 10L);
|
}, 10L);
|
||||||
|
*/
|
||||||
}
|
}
|
||||||
|
|
||||||
private void unloadWorld() {
|
private void unloadWorld() {
|
||||||
|
|
|
@ -1,7 +0,0 @@
|
||||||
package com.io.yutian.thewardungeon.event;
|
|
||||||
|
|
||||||
public class Event {
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
}
|
|
|
@ -27,7 +27,7 @@ public class TitleScript extends Script {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void execute(DungeonInstance dungeonInstance) {
|
public void execute(DungeonInstance dungeonInstance) {
|
||||||
dungeonInstance.getPlayers().forEach(player -> player.getPlayer().showTitle(Title.title(Component.text(title), Component.text(subtitle), Title.Times.times(Duration.ofMillis(fadeIn), Duration.ofMillis(stay), Duration.ofMillis(fadeOut)))));
|
dungeonInstance.getPlayers().forEach(player -> player.getPlayer().showTitle(Title.title(Component.text(title), Component.text(subtitle), Title.Times.times(Duration.ofMillis(fadeIn * 50), Duration.ofMillis(stay * 50), Duration.ofMillis(fadeOut * 50)))));
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -0,0 +1,17 @@
|
||||||
|
package com.io.yutian.thewardungeon.util;
|
||||||
|
|
||||||
|
import org.bukkit.boss.BarColor;
|
||||||
|
|
||||||
|
public class BossBarUtil {
|
||||||
|
|
||||||
|
public static BarColor getBarColor(double d) {
|
||||||
|
if (d >= 0 && d <= 0.3333) {
|
||||||
|
return BarColor.RED;
|
||||||
|
} else if (d <= 0.6666) {
|
||||||
|
return BarColor.YELLOW;
|
||||||
|
} else {
|
||||||
|
return BarColor.GREEN;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
Loading…
Reference in New Issue
Block a user