@@ -0,0 +1,73 @@
/*
* New BSD License (BSD-new)
*
* Copyright (c) 2015 Maxim Roncacé
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
* - Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* - Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
* - Neither the name of the copyright holder nor the names of its contributors
* may be used to endorse or promote products derived from this software
* without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
* DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR
* ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
package net.caseif.flint.steel.lobby.wizard;

import net.caseif.flint.util.physical.Location3D;

import java.util.UUID;

/**
* Represents a player currently in the lobby wizard.
*
* @author Max Roncacé
*/
interface IWizardPlayer {

/**
* Gets the {@link UUID} of this {@link IWizardPlayer}.
*
* @return The {@link UUID} of this {@link IWizardPlayer}
*/
UUID getUniqueId();

/**
* Gets the {@link Location3D location} that is the target of this
* {@link IWizardPlayer}.
*
* @return The {@link Location3D location} that is the target of this
* {@link IWizardPlayer}.
*/
Location3D getLocation();

/**
* Gets the parent {@link WizardManager} of this {@link IWizardPlayer}.
*
* @return The parent {@link WizardManager} of this {@link IWizardPlayer}
*/
WizardManager getParent();

/**
* Accepts the given string as input and returns a response string.
*
* @param input The input to consider
* @return The response to the given input
*/
String[] accept(String input);

}
@@ -0,0 +1,74 @@
/*
* New BSD License (BSD-new)
*
* Copyright (c) 2015 Maxim Roncacé
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
* - Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* - Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
* - Neither the name of the copyright holder nor the names of its contributors
* may be used to endorse or promote products derived from this software
* without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
* DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR
* ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
package net.caseif.flint.steel.lobby.wizard;

import net.caseif.flint.lobby.LobbySign;

/**
* Implements {@link IWizardCollectedData}.
*
* @author Max Roncacé
*/
public class WizardCollectedData implements IWizardCollectedData {

private String arena;
private LobbySign.Type type;
private int index;

@Override
public String getArena() {
return arena;
}

@Override
public void setArena(String arena) {
this.arena = arena;
}

@Override
public LobbySign.Type getSignType() {
return type;
}

@Override
public void setSignType(LobbySign.Type type) {
this.type = type;
}

@Override
public int getIndex() {
return index;
}

@Override
public void setIndex(int index) {
this.index = index;
}

}
@@ -0,0 +1,144 @@
/*
* New BSD License (BSD-new)
*
* Copyright (c) 2015 Maxim Roncacé
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
* - Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* - Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
* - Neither the name of the copyright holder nor the names of its contributors
* may be used to endorse or promote products derived from this software
* without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
* DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR
* ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
package net.caseif.flint.steel.lobby.wizard;

import net.caseif.flint.minigame.Minigame;
import net.caseif.flint.util.MinigameElement;
import net.caseif.flint.util.physical.Location3D;

import org.bukkit.Bukkit;
import org.bukkit.entity.Player;

import java.util.HashMap;
import java.util.UUID;

/**
* Manager for the integrated lobby wizard.
*/
public class WizardManager implements MinigameElement {

private Minigame minigame;

private final HashMap<UUID, IWizardPlayer> wizardPlayers = new HashMap<>();

/**
* Creates a new {@link WizardManager} for the given {@link Minigame}.
*
* @param minigame The {@link Minigame} to back the new {@link WizardManager}
*/
public WizardManager(Minigame minigame) {
this.minigame = minigame;
}

@Override
public Minigame getMinigame() {
return minigame;
}

@Override
public String getPlugin() {
return getMinigame().getPlugin();
}

/**
* Gets whether the player with the given {@link UUID} is present in this
* {@link WizardManager}.
*
* @param uuid The {@link UUID} of the player to look up
* @return Whether the player is present in this {@link WizardManager}
*/
public boolean isWizardPlayer(UUID uuid) {
return wizardPlayers.containsKey(uuid);
}

/**
* Adds a player to this {@link WizardManager}.
*
* @param uuid The {@link UUID} of the player
* @param location The {@link Location3D location} targeted by the player
*/
public void addWizardPlayer(UUID uuid, Location3D location) {
assert !wizardPlayers.containsKey(uuid);
wizardPlayers.put(uuid, new WizardPlayer(uuid, location, this));
Player player = Bukkit.getPlayer(uuid);
if (player == null) {
throw new AssertionError("Cannot get Bukkit player from UUID in wizard manager. Report this immediately.");
}
player.sendMessage(new String[]{WizardMessages.WELCOME, WizardMessages.GET_ARENA});
}

/**
* Accepts input from the player with the given {@link UUID}.
*
* @param uuid The {@link UUID} of the player to accept input from
* @param input The input to accept
* @return The response to the input
* @throws IllegalArgumentException If the player with the given
* {@link UUID} is not currently engaged in a wizard
*/
public String[] accept(UUID uuid, String input) {
if (wizardPlayers.containsKey(uuid)) {
return wizardPlayers.get(uuid).accept(input);
} else {
throw new IllegalArgumentException("Player with UUID " + uuid.toString() + " is not engaged in a wizard");
}
}

/**
* Removes the player with the given {@link UUID} from this
* {@link WizardManager}.
*
* @param uuid The {@link UUID} of the player to remove
*/
void removePlayer(UUID uuid) {
wizardPlayers.remove(uuid);
}

// _,._
// .||, /_ _\\
// \.`',/ |'L'| |
// = ,. = | -,| L
// / || \ ,-'\"/,'`.
// || ,' `,,. `.
// ,|____,' , ,;' \| |
// (3|\ _/|/' _| |
// ||/,-'' | >-'' _,\\
// ||' ==\ ,-' ,'
// || | V \ ,|
// || | |` |
// || | | \
// || | \ \
// || | | \
// || | \_,-'
// || |___,,--")_\
// || |_| ccc/
// || ccc/
// ||

}
@@ -0,0 +1,91 @@
/*
* New BSD License (BSD-new)
*
* Copyright (c) 2015 Maxim Roncacé
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
* - Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* - Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
* - Neither the name of the copyright holder nor the names of its contributors
* may be used to endorse or promote products derived from this software
* without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
* DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR
* ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
package net.caseif.flint.steel.lobby.wizard;

import org.bukkit.ChatColor;

/**
* Static utility class for wizard messages.
*/
public class WizardMessages {

static final ChatColor INFO_COLOR = ChatColor.DARK_PURPLE;
static final ChatColor ERROR_COLOR = ChatColor.RED;
static final ChatColor EM_COLOR = ChatColor.GOLD;

// informational messages
static final String WELCOME = INFO_COLOR + "Welcome to the lobby sign wizard!";
static final String GET_ARENA = INFO_COLOR + "To start, please type "
+ "the name of the arena you would like to create a lobby sign for. (You may type " + EM_COLOR
+ " cancel " + ChatColor.DARK_PURPLE + " at any time to exit the wizard.";
static final String GET_TYPE = INFO_COLOR + "Next, please select the type of lobby sign you would like "
+ "to create from the list below (type a number):";
static final String GET_TYPE_STATUS = EM_COLOR + "1) " + INFO_COLOR + "Status - Status signs display "
+ "basic information about the round contained by an arena such as timer info and player count.";
static final String GET_TYPE_LISTING = EM_COLOR + "2) " + INFO_COLOR + "Player Listing - Player listing "
+ "signs display a portion of the players in a round. If this is selected, you will be asked next to "
+ "define which portion of players to display.";
static final String GET_INDEX = INFO_COLOR + " Next, please select which portion of players you would "
+ "like the player listing sign to display. ("
+ EM_COLOR + "1" + INFO_COLOR + " will display players " + EM_COLOR + "1-4" + INFO_COLOR + ", "
+ EM_COLOR + "2" + INFO_COLOR + " will display players " + EM_COLOR + "5-8" + INFO_COLOR + ", "
+ "and so on.)";
static final String CONFIRM_1 = INFO_COLOR + "Okay! Your lobby sign will be created with the following "
+ "info:";
static final String CONFIRM_2 = INFO_COLOR + "Is this okay? "
+ "(Type " + EM_COLOR + "yes" + INFO_COLOR + " or " + EM_COLOR + "no" + INFO_COLOR + ".)";
static final String RESET = INFO_COLOR + "The wizard will now reset.";
static final String FINISH = INFO_COLOR + "Your lobby sign was successfully created! The wizard will now exit.";

static final String CANCELLED = ERROR_COLOR + "Lobby sign creation cancelled.";

// error messages
static final String BAD_ARENA = ERROR_COLOR + "No arena by that ID exists! Please enter another arena ID.";
static final String BAD_TYPE = ERROR_COLOR + "Invalid sign type! Please select a valid option.";
static final String BAD_INDEX = ERROR_COLOR + "Invalid sign index! Please enter a number greater than or equal to "
+ "1.";
static final String BAD_CONFIRMATION = ERROR_COLOR + "Please type " + EM_COLOR + "yes" + INFO_COLOR + " or "
+ EM_COLOR + "no" + INFO_COLOR + ".";
static final String ARENA_REMOVED = ERROR_COLOR + "The selected arena has been removed. The wizard will now exit.";
static final String GENERIC_ERROR = ERROR_COLOR + "An internal exception occurred while creating the lobby sign. "
+ "The wizard will now exit.";

// other stuff
static final String DIVIDER;

static {
final int dividerLength = 36;
StringBuilder sb = new StringBuilder();
for (int i = 0; i < dividerLength; i++) {
sb.append("-");
}
DIVIDER = sb.toString();
}

}
@@ -0,0 +1,215 @@
/*
* New BSD License (BSD-new)
*
* Copyright (c) 2015 Maxim Roncacé
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
* - Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* - Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
* - Neither the name of the copyright holder nor the names of its contributors
* may be used to endorse or promote products derived from this software
* without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
* DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR
* ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
package net.caseif.flint.steel.lobby.wizard;

import static net.caseif.flint.steel.lobby.wizard.WizardMessages.EM_COLOR;
import static net.caseif.flint.steel.lobby.wizard.WizardMessages.ERROR_COLOR;
import static net.caseif.flint.steel.lobby.wizard.WizardMessages.INFO_COLOR;

import net.caseif.flint.arena.Arena;
import net.caseif.flint.lobby.LobbySign;
import net.caseif.flint.lobby.type.ChallengerListingLobbySign;
import net.caseif.flint.lobby.type.StatusLobbySign;
import net.caseif.flint.util.physical.Location3D;

import com.google.common.base.Optional;

import java.util.ArrayList;
import java.util.UUID;

/**
* Implements {@link IWizardPlayer}.
*
* @author Max Roncacé
*/
class WizardPlayer implements IWizardPlayer {

private UUID uuid;
private Location3D location;
private WizardManager manager;

private WizardStage stage;
private WizardCollectedData data;

/**
* Creates a new {@link WizardPlayer} with the given {@link UUID} for the
* given {@link WizardManager}.
*
* @param uuid The {@link UUID} of the player backing this
* {@link WizardPlayer}
* @param manager The parent {@link WizardManager} of the new
* {@link WizardManager}
*/
WizardPlayer(UUID uuid, Location3D location, WizardManager manager) {
this.uuid = uuid;
this.location = location;
this.manager = manager;

this.stage = WizardStage.GET_ARENA;
this.data = new WizardCollectedData();
}

@Override
public UUID getUniqueId() {
return uuid;
}

@Override
public Location3D getLocation() {
return location;
}

@Override
public WizardManager getParent() {
return manager;
}

@Override
public String[] accept(String input) {
if (input.equalsIgnoreCase("cancel")) {
getParent().removePlayer(getUniqueId());
return new String[]{WizardMessages.CANCELLED};
}
switch (stage) {
case GET_ARENA: {
Optional<Arena> arena = getParent().getMinigame().getArena(input);
if (arena.isPresent()) {
data.setArena(input);
stage = WizardStage.GET_TYPE;
return new String[]{WizardMessages.DIVIDER, WizardMessages.GET_TYPE,
WizardMessages.GET_TYPE_STATUS, WizardMessages.GET_TYPE_LISTING};
} else {
return new String[]{WizardMessages.BAD_ARENA};
}
}
case GET_TYPE: {
try {
int i = Integer.parseInt(input);
switch (i) {
case 1: {
data.setSignType(LobbySign.Type.STATUS);
stage = WizardStage.CONFIRMATION;
return constructConfirmation();
}
case 2: {
data.setSignType(LobbySign.Type.CHALLENGER_LISTING);
stage = WizardStage.GET_INDEX;
return new String[]{WizardMessages.DIVIDER, WizardMessages.GET_INDEX};
}
default: {
break; // continue to block end
}
}
} catch (NumberFormatException ignored) {
// continue to block end
}
return new String[]{WizardMessages.BAD_TYPE};
}
case GET_INDEX: {
try {
int i = Integer.parseInt(input);
if (i > 0) {
data.setIndex(i - 1);
stage = WizardStage.CONFIRMATION;
return constructConfirmation();
} // else: continue to block end
} catch (NumberFormatException ex) {
// continue to block end
}
return new String[]{WizardMessages.BAD_INDEX};
}
case CONFIRMATION: {
if (input.equalsIgnoreCase("yes")) {
Optional<Arena> arena = getParent().getMinigame().getArena(data.getArena());
if (arena.isPresent()) {
switch (data.getSignType()) {
case STATUS: {
try {
Optional<StatusLobbySign> sign
= arena.get().createStatusLobbySign(getLocation());
if (sign.isPresent()) {
getParent().removePlayer(getUniqueId());
return new String[]{WizardMessages.DIVIDER, WizardMessages.FINISH};
} else {
return new String[]{WizardMessages.DIVIDER, WizardMessages.GENERIC_ERROR};
}
} catch (Exception ex) {
ex.printStackTrace();
return new String[]{WizardMessages.DIVIDER, WizardMessages.GENERIC_ERROR,
ERROR_COLOR + ex.getMessage()};
}
}
case CHALLENGER_LISTING: {
Optional<ChallengerListingLobbySign> sign = arena.get()
.createChallengerListingLobbySign(getLocation(), data.getIndex());
if (sign.isPresent()) {
getParent().removePlayer(getUniqueId());
return new String[]{WizardMessages.DIVIDER, WizardMessages.FINISH};
} else {
return new String[]{WizardMessages.DIVIDER, WizardMessages.GENERIC_ERROR};
}
}
default: {
throw new AssertionError("Invalid sign type in wizard data. "
+ "Report this immediately.");
}
}
} else {
getParent().removePlayer(getUniqueId());
return new String[]{WizardMessages.DIVIDER, WizardMessages.ARENA_REMOVED};
}
} else if (input.equalsIgnoreCase("no")) {
stage = WizardStage.GET_ARENA;
return new String[]{WizardMessages.DIVIDER, WizardMessages.RESET, WizardMessages.GET_ARENA};
} else {
return new String[]{WizardMessages.BAD_CONFIRMATION};
}
}
default: {
throw new AssertionError("Cannot process input for wizard player. Report this immediately.");
}
}
}

private String[] constructConfirmation() {
ArrayList<String> msgs = new ArrayList<>();
msgs.add(WizardMessages.DIVIDER);
msgs.add(WizardMessages.CONFIRM_1);
msgs.add(INFO_COLOR + "Arena ID: " + EM_COLOR + data.getArena());
msgs.add(INFO_COLOR + "Sign type: " + EM_COLOR + data.getSignType().toString());
if (data.getSignType() == LobbySign.Type.CHALLENGER_LISTING) {
msgs.add(INFO_COLOR + "Sign index: " + EM_COLOR + (data.getIndex() + 1));
}
msgs.add(WizardMessages.CONFIRM_2);
String[] arr = new String[msgs.size()];
msgs.toArray(arr);
return arr;
}

}
@@ -0,0 +1,41 @@
/*
* New BSD License (BSD-new)
*
* Copyright (c) 2015 Maxim Roncacé
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
* - Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* - Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
* - Neither the name of the copyright holder nor the names of its contributors
* may be used to endorse or promote products derived from this software
* without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
* DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR
* ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
package net.caseif.flint.steel.lobby.wizard;

/**
* Represents a stage in the lobby wizard.
*/
public enum WizardStage {

GET_ARENA,
GET_TYPE,
GET_INDEX,
CONFIRMATION;

}
@@ -36,6 +36,7 @@
import net.caseif.flint.steel.SteelCore;
import net.caseif.flint.steel.arena.SteelArena;
import net.caseif.flint.steel.lobby.SteelLobbySign;
import net.caseif.flint.steel.lobby.wizard.WizardManager;
import net.caseif.flint.steel.util.file.DataFiles;
import net.caseif.flint.util.physical.Boundary;
import net.caseif.flint.util.physical.Location3D;
@@ -62,6 +63,8 @@ public class SteelMinigame extends CommonMinigame {

private final Plugin plugin;

private final WizardManager wizardManager;

public SteelMinigame(String plugin) {
super();
assert plugin != null;
@@ -71,6 +74,7 @@ public SteelMinigame(String plugin) {
throw new IllegalArgumentException("Plugin \"" + plugin + "\" is not loaded!");
}
SteelCore.logInfo(this.plugin + " has successfully hooked Steel");
wizardManager = new WizardManager(this);
DataFiles.createMinigameDataFiles(this);
loadArenas();
loadLobbySigns();
@@ -140,6 +144,10 @@ public void removeArena(Arena arena) throws IllegalArgumentException {
((CommonArena) arena).orphan();
}

public WizardManager getLobbyWizardManager() {
return wizardManager;
}

private void loadArenas() {
File arenaStore = DataFiles.ARENA_STORE.getFile(this);
YamlConfiguration yaml = new YamlConfiguration();
@@ -220,10 +228,11 @@ public void loadLobbySigns() {
+ "\" - not loading contained lobby sign");
}
continue;
}
} catch (IllegalArgumentException ignored) {
} // else: continue to invalid warning
} catch (IllegalArgumentException ignored) { // continue to invalid warning
ignored.printStackTrace();
}
}
} // else: continue to invalid warning
// never executes unless the serial is invalid in some way
SteelCore.logWarning("Found lobby sign in store with invalid location serial."
+ "Removing...");
@@ -28,9 +28,10 @@
*/
package net.caseif.flint.steel.round;

import net.caseif.flint.config.ConfigNode;
import net.caseif.flint.challenger.Challenger;
import net.caseif.flint.common.event.round.CommonRoundTimerTickEvent;
import net.caseif.flint.config.ConfigNode;
import net.caseif.flint.lobby.LobbySign;
import net.caseif.flint.round.LifecycleStage;
import net.caseif.flint.round.Round;
import net.caseif.flint.steel.util.helper.LocationHelper;
@@ -61,6 +62,12 @@ public void run() {
}
if (!round.isOrphaned()) {
checkPlayerLocations();

for (LobbySign sign : round.getArena().getLobbySigns()) {
if (sign.getType() == LobbySign.Type.STATUS) {
sign.update();
}
}
}
}

@@ -39,6 +39,7 @@
import net.caseif.flint.config.ConfigNode;
import net.caseif.flint.exception.OrphanedObjectException;
import net.caseif.flint.exception.round.RoundJoinException;
import net.caseif.flint.lobby.LobbySign;
import net.caseif.flint.minigame.Minigame;
import net.caseif.flint.round.LifecycleStage;
import net.caseif.flint.round.Round;
@@ -134,26 +135,26 @@ public Challenger addChallenger(UUID uuid) throws IllegalStateException, RoundJo
nextSpawn.set(0);
}
bukkitPlayer.teleport(LocationHelper.convertLocation(getArena().getSpawnPoints().get(spawnIndex)));

getChallengerMap().put(uuid, challenger);

for (LobbySign sign : getArena().getLobbySigns()) {
sign.update();
}

getMinigame().getEventBus().post(new CommonChallengerJoinRoundEvent(challenger));
return challenger;
}

@Override
public void removeChallenger(Challenger challenger) throws OrphanedObjectException {
checkState();
removeChallenger(challenger, false);
removeChallenger(challenger, false, true);
}

/**
* Removes the given {@link Challenger} from this {@link SteelRound}, taking
* note as to whether they are currently disconnecting from the server.
*
* @param challenger The {@link Challenger} to remove
* @param isDisconnecting Whether the {@link Challenger} is currently
* disconnecting from the server
*/
public void removeChallenger(Challenger challenger, boolean isDisconnecting) throws OrphanedObjectException {
@Override // overridden from CommonRound
public void removeChallenger(Challenger challenger, boolean isDisconnecting, boolean updateSigns)
throws OrphanedObjectException {
Player bukkitPlayer = Bukkit.getPlayer(challenger.getUniqueId());
Location3D returnPoint;
try {
@@ -166,7 +167,13 @@ public void removeChallenger(Challenger challenger, boolean isDisconnecting) thr
CommonChallengerLeaveRoundEvent event = new CommonChallengerLeaveRoundEvent(challenger, returnPoint);
getMinigame().getEventBus().post(event);

super.removeChallenger(challenger);
super.removeChallenger(challenger, isDisconnecting, updateSigns);

if (updateSigns) {
for (LobbySign sign : getArena().getLobbySigns()) {
sign.update();
}
}

if (!isDisconnecting) {
try {
@@ -214,6 +221,10 @@ public void setTimerTicking(boolean ticking) throws OrphanedObjectException {
public void end(boolean rollback, boolean natural) {
cancelTimerTask();
super.end(rollback, natural);
for (LobbySign ls : getArena().getLobbySigns()) {
ls.update();
}
this.orphan();
}

@Override