mirror of
https://github.com/DRE2N/DungeonsXL.git
synced 2024-12-01 06:53:26 +01:00
Fixed /dxl test command and made it compatible with edit mode
This commit is contained in:
parent
7d254ec019
commit
329876e881
@ -20,12 +20,16 @@ import io.github.dre2n.commons.command.BRCommand;
|
|||||||
import io.github.dre2n.commons.util.messageutil.MessageUtil;
|
import io.github.dre2n.commons.util.messageutil.MessageUtil;
|
||||||
import io.github.dre2n.dungeonsxl.DungeonsXL;
|
import io.github.dre2n.dungeonsxl.DungeonsXL;
|
||||||
import io.github.dre2n.dungeonsxl.config.DMessages;
|
import io.github.dre2n.dungeonsxl.config.DMessages;
|
||||||
|
import io.github.dre2n.dungeonsxl.dungeon.Dungeon;
|
||||||
import io.github.dre2n.dungeonsxl.game.Game;
|
import io.github.dre2n.dungeonsxl.game.Game;
|
||||||
import io.github.dre2n.dungeonsxl.game.GameTypeDefault;
|
import io.github.dre2n.dungeonsxl.game.GameTypeDefault;
|
||||||
|
import io.github.dre2n.dungeonsxl.player.DEditPlayer;
|
||||||
import io.github.dre2n.dungeonsxl.player.DGamePlayer;
|
import io.github.dre2n.dungeonsxl.player.DGamePlayer;
|
||||||
|
import io.github.dre2n.dungeonsxl.player.DGlobalPlayer;
|
||||||
import io.github.dre2n.dungeonsxl.player.DGroup;
|
import io.github.dre2n.dungeonsxl.player.DGroup;
|
||||||
import io.github.dre2n.dungeonsxl.player.DPermissions;
|
import io.github.dre2n.dungeonsxl.player.DPermissions;
|
||||||
import io.github.dre2n.dungeonsxl.world.DGameWorld;
|
import io.github.dre2n.dungeonsxl.world.DGameWorld;
|
||||||
|
import io.github.dre2n.dungeonsxl.world.DResourceWorld;
|
||||||
import org.bukkit.command.CommandSender;
|
import org.bukkit.command.CommandSender;
|
||||||
import org.bukkit.entity.Player;
|
import org.bukkit.entity.Player;
|
||||||
|
|
||||||
@ -43,19 +47,22 @@ public class TestCommand extends BRCommand {
|
|||||||
setHelp(DMessages.HELP_CMD_TEST.getMessage());
|
setHelp(DMessages.HELP_CMD_TEST.getMessage());
|
||||||
setPermission(DPermissions.TEST.getNode());
|
setPermission(DPermissions.TEST.getNode());
|
||||||
setPlayerCommand(true);
|
setPlayerCommand(true);
|
||||||
|
setConsoleCommand(false);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onExecute(String[] args, CommandSender sender) {
|
public void onExecute(String[] args, CommandSender sender) {
|
||||||
Player player = (Player) sender;
|
Player player = (Player) sender;
|
||||||
|
DGlobalPlayer dPlayer = plugin.getDPlayers().getByPlayer(player);
|
||||||
|
|
||||||
|
if (!(dPlayer instanceof DEditPlayer)) {
|
||||||
DGroup dGroup = DGroup.getByPlayer(player);
|
DGroup dGroup = DGroup.getByPlayer(player);
|
||||||
if (dGroup == null) {
|
if (dGroup == null) {
|
||||||
MessageUtil.sendMessage(sender, DMessages.ERROR_JOIN_GROUP.getMessage());
|
MessageUtil.sendMessage(sender, DMessages.ERROR_JOIN_GROUP.getMessage());
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!dGroup.getCaptain().equals(player)) {
|
if (!dGroup.getCaptain().equals(player) && !DPermissions.hasPermission(player, DPermissions.BYPASS)) {
|
||||||
MessageUtil.sendMessage(sender, DMessages.ERROR_NOT_CAPTAIN.getMessage());
|
MessageUtil.sendMessage(sender, DMessages.ERROR_NOT_CAPTAIN.getMessage());
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@ -67,7 +74,7 @@ public class TestCommand extends BRCommand {
|
|||||||
}
|
}
|
||||||
|
|
||||||
Game game = gameWorld.getGame();
|
Game game = gameWorld.getGame();
|
||||||
if (game != null) {
|
if (game != null && game.hasStarted()) {
|
||||||
MessageUtil.sendMessage(sender, DMessages.ERROR_LEAVE_DUNGEON.getMessage());
|
MessageUtil.sendMessage(sender, DMessages.ERROR_LEAVE_DUNGEON.getMessage());
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@ -75,6 +82,16 @@ public class TestCommand extends BRCommand {
|
|||||||
for (Player groupPlayer : dGroup.getPlayers()) {
|
for (Player groupPlayer : dGroup.getPlayers()) {
|
||||||
DGamePlayer.getByPlayer(groupPlayer).ready(GameTypeDefault.TEST);
|
DGamePlayer.getByPlayer(groupPlayer).ready(GameTypeDefault.TEST);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
} else {
|
||||||
|
DEditPlayer editPlayer = (DEditPlayer) dPlayer;
|
||||||
|
editPlayer.leave();
|
||||||
|
DResourceWorld resource = editPlayer.getEditWorld().getResource();
|
||||||
|
Dungeon dungeon = new Dungeon(resource);
|
||||||
|
DGameWorld instance = resource.instantiateAsGameWorld();
|
||||||
|
Game game = new Game(new DGroup(player, dungeon), GameTypeDefault.TEST, instance);
|
||||||
|
DGamePlayer.create(player, game.getWorld(), GameTypeDefault.TEST);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -31,6 +31,8 @@ import org.bukkit.scheduler.BukkitRunnable;
|
|||||||
*/
|
*/
|
||||||
public class AnnouncerStartGameTask extends BukkitRunnable {
|
public class AnnouncerStartGameTask extends BukkitRunnable {
|
||||||
|
|
||||||
|
DungeonsXL plugin = DungeonsXL.getInstance();
|
||||||
|
|
||||||
private Announcer announcer;
|
private Announcer announcer;
|
||||||
private ProgressBar bar;
|
private ProgressBar bar;
|
||||||
|
|
||||||
@ -47,7 +49,7 @@ public class AnnouncerStartGameTask extends BukkitRunnable {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
bar = new ProgressBar(players, 30);
|
bar = new ProgressBar(players, 30);
|
||||||
bar.runTaskTimer(DungeonsXL.getInstance(), 0L, 20L);
|
bar.runTaskTimer(plugin, 0L, 20L);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -72,7 +74,7 @@ public class AnnouncerStartGameTask extends BukkitRunnable {
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (game == null) {
|
if (game == null) {
|
||||||
game = new Game(dGroup, announcer.getMapName());
|
game = new Game(dGroup, plugin.getDWorlds().getResourceByName(announcer.getMapName()));
|
||||||
} else {
|
} else {
|
||||||
game.getDGroups().add(dGroup);
|
game.getDGroups().add(dGroup);
|
||||||
}
|
}
|
||||||
|
@ -17,6 +17,7 @@
|
|||||||
package io.github.dre2n.dungeonsxl.task;
|
package io.github.dre2n.dungeonsxl.task;
|
||||||
|
|
||||||
import io.github.dre2n.commons.util.messageutil.MessageUtil;
|
import io.github.dre2n.commons.util.messageutil.MessageUtil;
|
||||||
|
import io.github.dre2n.dungeonsxl.game.GameType;
|
||||||
import io.github.dre2n.dungeonsxl.player.DEditPlayer;
|
import io.github.dre2n.dungeonsxl.player.DEditPlayer;
|
||||||
import io.github.dre2n.dungeonsxl.player.DGamePlayer;
|
import io.github.dre2n.dungeonsxl.player.DGamePlayer;
|
||||||
import io.github.dre2n.dungeonsxl.world.DEditWorld;
|
import io.github.dre2n.dungeonsxl.world.DEditWorld;
|
||||||
@ -37,7 +38,7 @@ public class CreateDInstancePlayerTask extends BukkitRunnable {
|
|||||||
|
|
||||||
private UUID player;
|
private UUID player;
|
||||||
private DInstanceWorld instance;
|
private DInstanceWorld instance;
|
||||||
private boolean ready;
|
private GameType ready;
|
||||||
|
|
||||||
private int i = 12;
|
private int i = 12;
|
||||||
|
|
||||||
@ -46,7 +47,7 @@ public class CreateDInstancePlayerTask extends BukkitRunnable {
|
|||||||
this.instance = instance;
|
this.instance = instance;
|
||||||
}
|
}
|
||||||
|
|
||||||
public CreateDInstancePlayerTask(Player player, DInstanceWorld instance, boolean ready) {
|
public CreateDInstancePlayerTask(Player player, DInstanceWorld instance, GameType ready) {
|
||||||
this.player = player.getUniqueId();
|
this.player = player.getUniqueId();
|
||||||
this.instance = instance;
|
this.instance = instance;
|
||||||
this.ready = ready;
|
this.ready = ready;
|
||||||
@ -63,8 +64,8 @@ public class CreateDInstancePlayerTask extends BukkitRunnable {
|
|||||||
if (instance.exists()) {
|
if (instance.exists()) {
|
||||||
if (instance instanceof DGameWorld) {
|
if (instance instanceof DGameWorld) {
|
||||||
DGamePlayer gamePlayer = new DGamePlayer(player, (DGameWorld) instance);
|
DGamePlayer gamePlayer = new DGamePlayer(player, (DGameWorld) instance);
|
||||||
if (ready) {
|
if (ready != null) {
|
||||||
gamePlayer.ready();
|
gamePlayer.ready(ready);
|
||||||
}
|
}
|
||||||
|
|
||||||
} else if (instance instanceof DEditWorld) {
|
} else if (instance instanceof DEditWorld) {
|
||||||
|
Loading…
Reference in New Issue
Block a user