Started updating how portals are made

This commit is contained in:
sekwah41 2018-02-20 16:46:29 +00:00
parent dcee3c210a
commit 32a21873be
4 changed files with 13 additions and 20 deletions

View File

@ -38,7 +38,7 @@ command.create.help=Creates portals
command.create.noargs= You need to actually list args for portal creation.
command.create.error= There was an error making the portal:
command.create.console= You cannot create a portal using the console.
command.create.detailedhelp=List tags after create in the format tag:value, if your value needs spaces use the format tag:"value with spaces"
command.create.detailedhelp=Format is /portal create (name) [tag:tagvalue] List tags after create in the format tag:value, if your value needs spaces use the format tag:"value with spaces"
command.playeronly= Sorry but that command can only be run by a player.

View File

@ -94,10 +94,10 @@ public class PortalManager {
return false;
}
public void createPortal(PlayerContainer player, ArrayList<DataTag> tags) throws PortalException {
public void createPortal(String name, PlayerContainer player, ArrayList<DataTag> tags) throws PortalException {
if (this.portalSelectorLeftClick.containsKey(player.getUUID().toString())
&& this.portalSelectorRightClick.containsKey(player.getUUID().toString())) {
this.createPortal(player, this.portalSelectorLeftClick.get(player.getUUID().toString()),
this.createPortal(name, player, this.portalSelectorLeftClick.get(player.getUUID().toString()),
this.portalSelectorRightClick.get(player.getUUID().toString()), tags);
} else {
throw new PortalException(Lang.translate("portal.invalidselection"));
@ -112,8 +112,8 @@ public class PortalManager {
* @return
* @throws PortalException
*/
public void createPortal(PortalLocation loc1, PortalLocation loc2, ArrayList<DataTag> tags) throws PortalException {
createPortal(null, loc1, loc2, tags);
public void createPortal(String name, PortalLocation loc1, PortalLocation loc2, ArrayList<DataTag> tags) throws PortalException {
createPortal(name, null, loc1, loc2, tags);
}
@ -127,10 +127,7 @@ public class PortalManager {
* @param tags
* @throws PortalException
*/
public void createPortal(PlayerContainer player, PortalLocation loc1, PortalLocation loc2, ArrayList<DataTag> tags) throws PortalException {
if(player == null) {
throw new PortalException(Lang.translate("error.notplayer"));
}
public void createPortal(String name, PlayerContainer player, PortalLocation loc1, PortalLocation loc2, ArrayList<DataTag> tags) throws PortalException {
int maxX = Math.max(loc1.posX, loc2.posX);
int maxY = Math.max(loc1.posY, loc2.posY);
@ -154,15 +151,13 @@ public class PortalManager {
TagHandler.Creation creation = AdvancedPortalsCore.getTagRegistry().getCreationHandler(portalTag.NAME);
creation.portalCreated(portal, player, portalTag.VALUE);
}
String portalName = portal.getArg("name");
if(portalName == null || portalName.equals("")) {
if(name == null || name.equals("")) {
throw new PortalException(Lang.translate("portal.error.noname"));
}
else if(this.portalHashMap.containsKey(portalName)) {
else if(this.portalHashMap.containsKey(name)) {
throw new PortalException(Lang.translate("portal.error.takenname"));
}
portal.removeArg("name");
this.portalHashMap.put(portalName, portal);
this.portalHashMap.put(name, portal);
this.updatePortalArray();
}

View File

@ -21,7 +21,6 @@ public class TagHandler {
*
* @param player if null the portal has been created by the server or a plugin
* @param argData
* @return if the portal can be created.
* @throws PortalException message given is the reason the portal cant be made
*/
void portalCreated(T target, PlayerContainer player, String argData) throws PortalException;
@ -31,7 +30,6 @@ public class TagHandler {
*
* @param player if null the portal has been destroyed by the server or a plugin
* @param argData
* @return if the portal can be destroyed.
* @throws PortalException message given is the reason the portal cant be removed
*/
void portalDestroyed(T target, PlayerContainer player, String argData) throws PortalException;

View File

@ -15,7 +15,7 @@ public class CreateSubCommand implements SubCommand {
@Override
public void onCommand(CommandSenderContainer sender, String[] args) {
if(args.length > 1) {
if(args.length > 2) {
PlayerContainer player = sender.getPlayerContainer();
if(player == null) {
sender.sendMessage(Lang.translateColor("messageprefix.negative") + Lang.translate("command.create.console"));
@ -25,7 +25,7 @@ public class CreateSubCommand implements SubCommand {
boolean partingValueWithSpaces = false;
String argBeingParsed = "";
String currentParsedValue = "";
for (int i = 1; i < args.length; i++) {
for (int i = 2; i < args.length; i++) {
if(partingValueWithSpaces) {
if(args[i].charAt(args[i].length() - 1) == '"') {
args[i] = args[i].substring(0, args[i].length() - 1);
@ -51,14 +51,14 @@ public class CreateSubCommand implements SubCommand {
}
}
try {
AdvancedPortalsCore.getPortalManager().createPortal(player, portalTags);
AdvancedPortalsCore.getPortalManager().createPortal(args[1], player, portalTags);
} catch (PortalException portalTagExeption) {
sender.sendMessage(Lang.translateColor("messageprefix.negative") + Lang.translateColor("command.create.error") + " "
+ portalTagExeption.getMessage());
}
}
else {
sender.sendMessage(Lang.translate("command.create.noargs"));
sender.sendMessage(Lang.translate("command.error.noname"));
}
}