1.0
This commit is contained in:
parent
9e1a8f0298
commit
e20a708e89
|
@ -52,15 +52,13 @@ public final class TheWarDungeon extends JavaPlugin {
|
|||
|
||||
CommandManager.unregisterAll();
|
||||
|
||||
/*
|
||||
for (Dungeon dungeon : DungeonManager.getDungeons()) {
|
||||
for (DungeonInstance dungeonInstance : dungeon.getQueue().getAllDungeonInstance()) {
|
||||
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.util.Log;
|
||||
import com.io.yutian.thewarskyblocklib.util.FileUtil;
|
||||
import org.bukkit.GameRule;
|
||||
import org.bukkit.World;
|
||||
import org.bukkit.WorldCreator;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
|
@ -87,8 +88,7 @@ public class Dungeon {
|
|||
WorldCreator dungeonWorldCreator = new WorldCreator(worldName);
|
||||
try {
|
||||
world = dungeonWorldCreator.createWorld();
|
||||
world.setKeepSpawnInMemory(false);
|
||||
world.setAutoSave(false);
|
||||
initWorld(world);
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
return null;
|
||||
|
@ -98,6 +98,16 @@ public class Dungeon {
|
|||
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
|
||||
public DungeonInstance newInstance() {
|
||||
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.manager.DungeonManager;
|
||||
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.thewarskyblocklib.math.Point;
|
||||
import io.lumine.mythic.bukkit.BukkitAdapter;
|
||||
|
@ -21,6 +22,9 @@ import io.lumine.mythic.core.mobs.MobRegistry;
|
|||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.Location;
|
||||
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.Player;
|
||||
import org.bukkit.scheduler.BukkitRunnable;
|
||||
|
@ -38,6 +42,8 @@ public class DungeonInstance {
|
|||
|
||||
private DungeonState state = DungeonState.WAITING;
|
||||
|
||||
private BossBar bossBar;
|
||||
|
||||
private DungeonLobby dungeonLobby;
|
||||
|
||||
private Point spawnPoint;
|
||||
|
@ -60,12 +66,14 @@ public class DungeonInstance {
|
|||
this.uuid = uuid;
|
||||
this.dungeon = dungeon;
|
||||
this.worldInstance = worldInstance;
|
||||
this.bossBar = Bukkit.createBossBar("倒计时", BarColor.WHITE, BarStyle.SOLID);
|
||||
}
|
||||
|
||||
public void join(Player player, boolean start) {
|
||||
if (!canJoin(player)) {
|
||||
return;
|
||||
}
|
||||
this.bossBar.addPlayer(player);
|
||||
addPlayer(player);
|
||||
if (start && players.size() == 1) {
|
||||
player.teleport(dungeon.getConfig().getLobbyPoint().toLocation(worldInstance.getWorld()));
|
||||
|
@ -93,6 +101,7 @@ public class DungeonInstance {
|
|||
}
|
||||
|
||||
public void leave(Player player) {
|
||||
this.bossBar.removePlayer(player);
|
||||
if (dungeonLobby != null && state.equals(DungeonState.WAITING)) {
|
||||
dungeonLobby.removeBossBar(player);
|
||||
}
|
||||
|
@ -256,6 +265,7 @@ public class DungeonInstance {
|
|||
cancel();
|
||||
}
|
||||
}
|
||||
updateBossBar();
|
||||
}
|
||||
}.runTaskTimer(TheWarDungeon.inst(), 20L, 20L));
|
||||
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() {
|
||||
try {
|
||||
BukkitAdapter.adapt(worldInstance.getWorld());
|
||||
|
|
|
@ -1,12 +1,9 @@
|
|||
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.World;
|
||||
|
||||
import java.io.File;
|
||||
import java.io.IOException;
|
||||
import java.util.UUID;
|
||||
|
||||
public class WorldInstance {
|
||||
|
@ -52,6 +49,7 @@ public class WorldInstance {
|
|||
}
|
||||
destroyed = true;
|
||||
unloadWorld();
|
||||
/*
|
||||
Bukkit.getScheduler().runTaskLater(TheWarDungeon.inst(), ()->{
|
||||
try {
|
||||
FileUtils.deleteDirectory(folder);
|
||||
|
@ -59,6 +57,7 @@ public class WorldInstance {
|
|||
e.printStackTrace();
|
||||
}
|
||||
}, 10L);
|
||||
*/
|
||||
}
|
||||
|
||||
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
|
||||
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