Fix portal rotation; resolves #668

This commit is contained in:
Daniel Saukel 2020-04-05 15:00:39 +02:00
parent 2bf5910222
commit dfda93f664
12 changed files with 93 additions and 47 deletions

View File

@ -96,6 +96,7 @@ public class BlockAdapterBlockData implements BlockAdapter {
}
Orientable data = (Orientable) block.getBlockData();
data.setAxis(z ? Axis.Z : Axis.X);
block.setBlockData(data, false);
}
}

View File

@ -54,11 +54,11 @@ public class DeleteCommand extends DCommand {
if (args.length == 2 && sender instanceof Player) {
ClickEvent onClickConfirm = new ClickEvent(ClickEvent.Action.RUN_COMMAND, "/dungeonsxl delete " + args[1] + " true");
TextComponent confirm = new TextComponent(DMessage.MISC_YES.getMessage());
TextComponent confirm = new TextComponent(DMessage.BUTTON_ACCEPT.getMessage());
confirm.setClickEvent(onClickConfirm);
ClickEvent onClickDeny = new ClickEvent(ClickEvent.Action.RUN_COMMAND, "/dungeonsxl delete " + args[1] + " false");
TextComponent deny = new TextComponent(DMessage.MISC_NO.getMessage());
TextComponent deny = new TextComponent(DMessage.BUTTON_DENY.getMessage());
deny.setClickEvent(onClickDeny);
MessageUtil.sendMessage(sender, DMessage.CMD_DELETE_BACKUPS.getMessage());

View File

@ -70,10 +70,12 @@ public class LivesCommand extends DCommand {
GamePlayer gamePlayer = (GamePlayer) globalPlayer;
PlayerGroup group = gamePlayer != null ? gamePlayer.getGroup() : plugin.getGroupCache().get(args[1]);
if (gamePlayer != null) {
MessageUtil.sendMessage(sender, DMessage.CMD_LIVES_PLAYER.getMessage(gamePlayer.getName(), gamePlayer.getLives() == -1 ? DMessage.MISC_UNLIMITED.getMessage() : String.valueOf(gamePlayer.getLives())));
MessageUtil.sendMessage(sender, DMessage.CMD_LIVES_PLAYER.getMessage(gamePlayer.getName(),
gamePlayer.getLives() == -1 ? DMessage.PLAYER_UNLIMITED_LIVES.getMessage() : String.valueOf(gamePlayer.getLives())));
} else if (group != null) {
MessageUtil.sendMessage(sender, DMessage.CMD_LIVES_GROUP.getMessage(group.getName(), String.valueOf(group.getLives() == -1 ? "UNLIMITED" : group.getLives())));
MessageUtil.sendMessage(sender, DMessage.CMD_LIVES_GROUP.getMessage(group.getName(),
String.valueOf(group.getLives() == -1 ? "UNLIMITED" : group.getLives())));
} else {
MessageUtil.sendMessage(sender, DMessage.ERROR_NO_SUCH_PLAYER.getMessage(args[1]));

View File

@ -40,7 +40,7 @@ public class PortalCommand extends DCommand {
super(plugin);
setCommand("portal");
setMinArgs(0);
setMaxArgs(1);
setMaxArgs(2);
setHelp(DMessage.CMD_PORTAL_HELP.getMessage());
setPermission(DPermission.PORTAL.getNode());
setPlayerCommand(true);
@ -72,14 +72,23 @@ public class PortalCommand extends DCommand {
dPortal = new DPortal(plugin, plugin.getGlobalProtectionCache().generateId(DPortal.class, player.getWorld()), player.getWorld(), material, false);
dGlobalPlayer.setCreatingPortal(dPortal);
dPortal.setWorld(player.getWorld());
dGlobalPlayer.setCachedItem(player.getItemInHand());
dGlobalPlayer.setCachedItem(player.getInventory().getItemInHand());
player.getInventory().setItemInHand(VanillaItem.WOODEN_SWORD.toItemStack());
MessageUtil.sendMessage(player, DMessage.PLAYER_PORTAL_INTRODUCTION.getMessage());
} else {
if (args.length == 3 && VanillaItem.NETHER_PORTAL.getName().equalsIgnoreCase(args[1])) {
if (args[2].equalsIgnoreCase("-rotate")) {
dPortal.rotate();
}
dGlobalPlayer.setCreatingPortal(null);
MessageUtil.sendMessage(player, DMessage.PLAYER_PORTAL_CREATED.getMessage());
return;
}
dPortal.delete();
dGlobalPlayer.setCreatingPortal(null);
player.setItemInHand(dGlobalPlayer.getCachedItem());
player.getInventory().setItemInHand(dGlobalPlayer.getCachedItem());
dGlobalPlayer.setCachedItem(null);
MessageUtil.sendMessage(player, DMessage.PLAYER_PORTAL_ABORT.getMessage());
}

View File

@ -55,7 +55,7 @@ public class ReloadCommand extends DCommand {
if (!dPlayers.isEmpty() && args.length == 1 && sender instanceof Player) {
MessageUtil.sendMessage(sender, DMessage.CMD_RELOAD_PLAYERS.getMessage());
ClickEvent onClick = new ClickEvent(ClickEvent.Action.RUN_COMMAND, "/dungeonsxl reload -force");
String message = DefaultFontInfo.center(DMessage.MISC_OKAY.getMessage());
String message = DefaultFontInfo.center(DMessage.BUTTON_OKAY.getMessage());
TextComponent text = new TextComponent(message);
text.setClickEvent(onClick);
MessageUtil.sendMessage(sender, text);

View File

@ -161,10 +161,9 @@ public enum DMessage implements Message {
GROUP_REWARD_CHEST("group.rewardChest"),
GROUP_UNINVITED_PLAYER("group.uninvitedPlayer"),
GROUP_WAVE_FINISHED("group.waveFinished"),
MISC_NO("misc.no"),
MISC_OKAY("misc.okay"),
MISC_UNLIMITED("misc.unlimited"),
MISC_YES("misc.yes"),
BUTTON_ACCEPT("button.accept"),
BUTTON_DENY("button.deny"),
BUTTON_OKAY("button.okay"),
PLAYER_BLOCK_INFO("player.blockInfo"),
PLAYER_CHECKPOINT_REACHED("player.checkpointReached"),
PLAYER_DEATH("player.death"),
@ -185,10 +184,11 @@ public enum DMessage implements Message {
PLAYER_NEW_LEADER("player.newLeader"),
PLAYER_OFFLINE("player.offline"),
PLAYER_OFFLINE_NEVER("player.offlineNever"),
PLAYER_PORTAL_ABORT("player.portalAbort"),
PLAYER_PORTAL_INTRODUCTION("player.portalIntroduction"),
PLAYER_PORTAL_CREATED("player.portalCreated"),
PLAYER_PORTAL_PROGRESS("player.portalProgress"),
PLAYER_PORTAL_ABORT("player.portal.abort"),
PLAYER_PORTAL_INTRODUCTION("player.portal.introduction"),
PLAYER_PORTAL_CREATED("player.portal.created"),
PLAYER_PORTAL_PROGRESS("player.portal.progress"),
PLAYER_PORTAL_ROTATE("player.portal.rotate"),
PLAYER_PROTECTED_BLOCK_DELETED("player.protectedBlockDeleted"),
PLAYER_READY("player.ready"),
PLAYER_SIGN_CREATED("player.signCreated"),
@ -196,6 +196,7 @@ public enum DMessage implements Message {
PLAYER_TIME_LEFT("player.timeLeft"),
PLAYER_TIME_KICK("player.timeKick"),
PLAYER_TREASURES("player.treasures"),
PLAYER_UNLIMITED_LIVES("player.unlimitedLives"),
PLAYER_WAIT_FOR_OTHER_PLAYERS("player.waitForOtherPlayers"),
REQUIREMENT_FEE("requirement.fee"),
REWARD_GENERAL("reward.general"),

View File

@ -31,6 +31,8 @@ import de.erethon.dungeonsxl.player.DGamePlayer;
import de.erethon.dungeonsxl.player.DGlobalPlayer;
import java.util.HashSet;
import java.util.Set;
import net.md_5.bungee.api.chat.ClickEvent;
import net.md_5.bungee.api.chat.TextComponent;
import org.bukkit.Location;
import org.bukkit.Material;
import org.bukkit.World;
@ -197,8 +199,36 @@ public class DPortal extends GlobalProtection {
xx = xx + xcount;
} while (xx != x2 + xcount);
if (player != null) {
if (player == null) {
return;
}
player.getPlayer().getInventory().setItemInHand(player.getCachedItem());
player.setCachedItem(null);
if (material != VanillaItem.NETHER_PORTAL) {
player.sendMessage(DMessage.PLAYER_PORTAL_CREATED.getMessage());
player.setCreatingPortal(null);
} else {
ClickEvent onClickYes = new ClickEvent(ClickEvent.Action.RUN_COMMAND, "/dungeonsxl portal NETHER_PORTAL -rotate");
TextComponent yes = new TextComponent(DMessage.BUTTON_ACCEPT.getMessage());
yes.setClickEvent(onClickYes);
ClickEvent onClickNo = new ClickEvent(ClickEvent.Action.RUN_COMMAND, "/dungeonsxl portal NETHER_PORTAL -norotate");
TextComponent no = new TextComponent(DMessage.BUTTON_DENY.getMessage());
no.setClickEvent(onClickNo);
player.sendMessage(DMessage.PLAYER_PORTAL_ROTATE.getMessage());
MessageUtil.sendMessage(player.getPlayer(), yes, new TextComponent(" "), no);
}
}
public void rotate() {
zAxis = !zAxis;
for (Block block : getBlocks()) {
if (block.getType() == VanillaItem.NETHER_PORTAL.getMaterial()) {
DungeonsXL.BLOCK_ADAPTER.setAxis(block, zAxis);
}
}
}

View File

@ -205,9 +205,6 @@ public class GlobalProtectionListener implements Listener {
dPortal.setBlock2(event.getClickedBlock());
dPortal.setActive(true);
dPortal.create(dPlayer);
dPlayer.sendMessage(DMessage.PLAYER_PORTAL_CREATED.getMessage());
dPlayer.getPlayer().getInventory().setItemInHand(dPlayer.getCachedItem());
dPlayer.setCachedItem(null);
}
event.setCancelled(true);
}

View File

@ -775,7 +775,7 @@ public class DGamePlayer extends DInstancePlayer implements GamePlayer {
}
GamePlayer killer = plugin.getPlayerCache().getGamePlayer(player.getKiller());
String newLives = lives == -1 ? DMessage.MISC_UNLIMITED.getMessage() : String.valueOf(this.lives);
String newLives = lives == -1 ? DMessage.PLAYER_UNLIMITED_LIVES.getMessage() : String.valueOf(this.lives);
if (killer != null) {
gameWorld.sendMessage(DMessage.PLAYER_KILLED.getMessage(getName(), killer.getName(), newLives));
} else {

View File

@ -1,5 +1,9 @@
announcer:
click: "&4&l=> &6CLICK HERE TO JOIN &4&l<="
button:
accept: "&a[ YES ]"
deny: "&4[ NO ]"
okay: "&a[ OK ]"
cmd:
break:
breakMode: "&6You may break a block protected by DungeonsXL."
@ -171,11 +175,6 @@ group:
rewardChest: "&6Your group has found a reward chest."
uninvitedPlayer: "&4&v1&6 took back the invitation for &4&v2&6 to the group &4&v3&6."
waveFinished: "&6Your group finished wave no. &4&v1&6. The next one is going to start in &4&v2&6 seconds."
misc:
false: "&4[ NO ]"
okay: "&a[ OK ]"
true: "&a[ YES ]"
unlimited: unlimited
player:
blockInfo: "&6Block ID: &2&v1"
checkpointReached: "&6Checkpoint reached."
@ -196,10 +195,12 @@ player:
newLeader: "&6You are now the new captain of your group."
offline: "&Player &4&v1&6 went offline. In &4&v2&6 seconds he will autmatically be kicked from the dungeon."
offlineNever: "&6The player &4&v1&6 went offline. He will &4not&6 be kicked from the dungeon automatically."
portalAbort: "&6Portal creation cancelled."
portalCreated: "&6Portal created."
portalIntroduction: "&6Click on the two edges of the portal with the wooden sword."
portalProgress: "&6First edge successfully marked. You may now click on the other edge."
portal:
abort: "&6Portal creation cancelled."
created: "&6Portal created."
introduction: "&6Click on the two edges of the portal with the wooden sword."
progress: "&6First edge successfully marked. You may now click on the other edge."
rotate: "&6Do you wish to rotate the portal?"
protectedBlockDeleted: "&6Successfully removed the protection."
ready: "&6You are now ready to start the dungeon."
signCopied: "&6Sign data copied."
@ -208,6 +209,7 @@ player:
timeLeft: "&v1You have &6&v2 &v1seconds left to finish the dungeon."
treasures: "&1Treasures"
uninvited: "&4&v1&6 took back your invitation to the group &4&v2&6."
unlimitedLives: "unlimited"
waitForOtherPlayers: "&6Waiting for team members..."
requirement:
fee: "&6You have been charged &4&v1 &6for entering the dungeon."

View File

@ -171,11 +171,10 @@ group:
rewardChest: "&6Votre groupe a trouvé un coffre de récompenses."
uninvitedPlayer: "&4&v1&6 a repris l'invitation de &4&v2&6 pour le groupe &4&v3&6."
waveFinished: "&6Votre groupe a fini la vague numéro &4&v1&6. La suivante va commencer dans &4&v2&6 secondes."
misc:
false: "&4[ NON ]"
button:
accept: "&a[ OUI ]"
deny: "&4[ NON ]"
okay: "&a[ OK ]"
true: "&a[ OUI ]"
unlimited: Illimité
player:
blockInfo: "&6Block ID: &2&v1"
checkpointReached: "&6Point de sauvegarde atteint."
@ -196,10 +195,12 @@ player:
newLeader: "&6Vous êtes maintenant le nouveau capitaine du groupe."
offline: "&Le joueur &4&v1&6 est passé hors ligne. Dans &4&v2&6 secondes il va être automatiquement éjecté du donjon."
offlineNever: "&6Le joueur &4&v1&6 est passé hors ligne. Il ne va &4pas&6 être éjecté du donjon automatiquement."
portalAbort: "&6Création de portails annulée."
portalCreated: "&6Portail créé."
portalIntroduction: "&6Cliquez sur les deux bords du portail avec l'épée en bois."
portalProgress: "&6Le premier bord a été marqué avec succès. Vous devez maintenant cliquer sur le deuxième bord."
portal:
abort: "&6Création de portails annulée."
created: "&6Portail créé."
introduction: "&6Cliquez sur les deux bords du portail avec l'épée en bois."
progress: "&6Le premier bord a été marqué avec succès. Vous devez maintenant cliquer sur le deuxième bord."
rotate: "&6Voulez-vous tourner le portail ?"
protectedBlockDeleted: "&6Protection retirée avec succès."
ready: "&6Vous êtes maintenant prêt à démarrer le donjon."
signCopied: "&6Données du panneau copiées."
@ -208,6 +209,7 @@ player:
timeLeft: "&v1Il vous reste &6&v2 &v1secondes pour finir le donjon."
treasures: "&1trésors"
uninvited: "&4&v1&6 a annulé votre invitation au groupe &4&v2&6."
unlimitedLives: "illimité"
waitForOtherPlayers: "&6En attente des membres de l'équipe..."
requirement:
fee: "&6Vous avez été débité de &4&v1 &6pour entrer dans le donjon."

View File

@ -1,5 +1,9 @@
announcer:
click: "&4&l=> &6KLICKE HIER ZUM BEITRETEN &4&l<="
button:
accept: "&a[ JA ]"
deny: "&4[ NEIN ]"
okay: "&a[ OK ]"
cmd:
break:
breakMode: "&6Du darfst jetzt von DungeonsXL geschützte Blöcke zerstören."
@ -171,11 +175,6 @@ group:
rewardChest: "&6Deine Gruppe hat eine Schatztruhe gefunden."
uninvitedPlayer: "&4&v1&6 hat die Einladung für &4&v2&6 in die Gruppe &4&v3&6 zurückgezogen."
waveFinished: "&6Deine Gruppe hat die &4&v1&6te Welle beendet. Die nächste fängt in &4&v2&6 Sekunden an."
misc:
false: "&4[ NEIN ]"
okay: "&a[ OK ]"
true: "&a[ JA ]"
unlimited: "unendlich viele"
player:
blockInfo: "&6Block-ID: &2&v1"
checkpointReached: "&6Checkpoint erreicht."
@ -196,10 +195,12 @@ player:
newLeader: "&6Du bist jetzt der neue Kapitän Deiner Gruppe."
offline: "&Der Spieler &4&v1&6 hat den Server verlassen. In &4&v2&6 Sekunden wird er automatisch aus dem Spiel geworfen."
offlineNever: "&6Der Spieler &4&v1&6 hat den Server verlassen. Er wird aber &4nicht&6 automatisch aus dem Spiel geworfen."
portalAbort: "&6Das Erstellen des Portals wurde abgebrochen."
portalCreated: "&6Das Portal wurde erstellt."
portalIntroduction: "&6Klicke die zwei Ecken des Portals mit dem Holzschwert an."
portalProgress: "&6Das erste Eck wurde erfolgreich markiert. Klicke nun das zweite Eck an."
portal:
abort: "&6Das Erstellen des Portals wurde abgebrochen."
created: "&6Das Portal wurde erstellt."
introduction: "&6Klicke die zwei Ecken des Portals mit dem Holzschwert an."
progress: "&6Das erste Eck wurde erfolgreich markiert. Klicke nun das zweite Eck an."
rotate: "&6Möchtest Du das Portal drehen?"
protectedBlockDeleted: "&6Die Sicherung wurde erfolgreich entfernt."
ready: "&6Du bist jetzt bereit, das Spiel zu starten."
signCopied: "&6Schilddaten kopiert."
@ -208,6 +209,7 @@ player:
timeLeft: "&v1Du hast &6&v2 &v1Sekunden übrig, um den Dungeon zu beenden."
treasures: "&1Schätze"
uninvited: "&4&v1&6 hat Deine Einladung zur Gruppe &4&v2&6 zurückgezogen."
unlimitedLives: "unendlich viele"
waitForOtherPlayers: "&6Warte auf andere Gruppenmitglieder..."
requirement:
fee: "&6Du hast &4&v1 &6bezahlt, um den Dungeon zu betreten."