mirror of
https://github.com/sekwah41/Advanced-Portals.git
synced 2024-11-25 12:06:17 +01:00
Updated create commands
This commit is contained in:
parent
e8633063e3
commit
ea55da453f
@ -46,6 +46,8 @@ command.createdesti.console= You cannot create a destination using the console.
|
||||
command.createdesti.detailedhelp=Format is /desti 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.createdesti.complete= The destination has been successfully created.
|
||||
|
||||
command.create.tags=\u00A7aTags:
|
||||
|
||||
command.playeronly= Sorry but that command can only be run by a player.
|
||||
|
||||
command.remove.noname= You need to give the name of the portal you want to remove.
|
||||
|
@ -10,6 +10,7 @@ import com.sekwah.advancedportals.core.api.warphandler.TagHandler;
|
||||
import com.sekwah.advancedportals.core.data.PlayerLocation;
|
||||
import com.sekwah.advancedportals.coreconnector.container.PlayerContainer;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
import java.util.Set;
|
||||
@ -101,4 +102,12 @@ public class Destination {
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public ArrayList<DataTag> getArgs() {
|
||||
ArrayList<DataTag> tagList = new ArrayList<>();
|
||||
for(Map.Entry<String, String> entry : this.args.entrySet()){
|
||||
tagList.add(new DataTag(entry.getKey(), entry.getValue()));
|
||||
}
|
||||
return tagList;
|
||||
}
|
||||
}
|
||||
|
@ -28,7 +28,7 @@ public class DestinationManager {
|
||||
this.portalsCore = portalsCore;
|
||||
}
|
||||
|
||||
public void createDesti(String name, PlayerContainer player, PlayerLocation playerLocation, ArrayList<DataTag> tags) throws PortalException {
|
||||
public Destination createDesti(String name, PlayerContainer player, PlayerLocation playerLocation, ArrayList<DataTag> tags) throws PortalException {
|
||||
if(name == null || name.equals("")) {
|
||||
throw new PortalException("desti.error.noname");
|
||||
}
|
||||
@ -47,6 +47,7 @@ public class DestinationManager {
|
||||
}
|
||||
}
|
||||
this.destiHashMap.put(name, desti);
|
||||
return desti;
|
||||
}
|
||||
|
||||
|
||||
|
@ -98,7 +98,7 @@ public class PortalManager {
|
||||
return false;
|
||||
}
|
||||
|
||||
public void createPortal(String name, PlayerContainer player, ArrayList<DataTag> tags) throws PortalException {
|
||||
public AdvancedPortal 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(name, player, this.portalSelectorLeftClick.get(player.getUUID().toString()),
|
||||
@ -106,6 +106,7 @@ public class PortalManager {
|
||||
} else {
|
||||
throw new PortalException("portal.invalidselection");
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
/**
|
||||
@ -131,7 +132,7 @@ public class PortalManager {
|
||||
* @param tags
|
||||
* @throws PortalException
|
||||
*/
|
||||
public void createPortal(String name, PlayerContainer player, PortalLocation loc1, PortalLocation loc2, ArrayList<DataTag> tags) throws PortalException {
|
||||
public AdvancedPortal 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);
|
||||
@ -171,6 +172,7 @@ public class PortalManager {
|
||||
}
|
||||
this.portalHashMap.put(name, portal);
|
||||
this.updatePortalArray();
|
||||
return portal;
|
||||
}
|
||||
|
||||
private void updatePortalArray() {
|
||||
|
@ -2,6 +2,7 @@ package com.sekwah.advancedportals.core.commands.subcommands.desti;
|
||||
|
||||
import com.sekwah.advancedportals.core.AdvancedPortalsCore;
|
||||
import com.sekwah.advancedportals.core.api.commands.SubCommand;
|
||||
import com.sekwah.advancedportals.core.api.destination.Destination;
|
||||
import com.sekwah.advancedportals.core.api.portal.DataTag;
|
||||
import com.sekwah.advancedportals.core.api.portal.PortalException;
|
||||
import com.sekwah.advancedportals.core.commands.subcommands.CreateSubCommand;
|
||||
@ -24,7 +25,12 @@ public class CreateDestiSubCommand extends CreateSubCommand implements SubComman
|
||||
}
|
||||
ArrayList<DataTag> destiTags = this.getTagsFromArgs(args);
|
||||
try {
|
||||
AdvancedPortalsCore.getDestinationManager().createDesti(args[1], player, player.getLoc(), destiTags);
|
||||
Destination desti = AdvancedPortalsCore.getDestinationManager().createDesti(args[1], player, player.getLoc(), destiTags);
|
||||
sender.sendMessage(Lang.translateColor("messageprefix.positive") + Lang.translateColor("command.createdesti.complete"));
|
||||
sender.sendMessage(Lang.translateColor("command.create.tags"));
|
||||
for (DataTag tag: desti.getArgs()) {
|
||||
sender.sendMessage(tag.NAME + ":" + tag.VALUE);
|
||||
}
|
||||
} catch (PortalException portalTagExeption) {
|
||||
sender.sendMessage(Lang.translateColor("messageprefix.negative") + Lang.translateColor("command.createdesti.error") + " "
|
||||
+ Lang.translate(portalTagExeption.getMessage()));
|
||||
|
@ -1,4 +0,0 @@
|
||||
package com.sekwah.advancedportals.core.commands.subcommands.desti;
|
||||
|
||||
public class TestSubCommand {
|
||||
}
|
@ -2,6 +2,7 @@ package com.sekwah.advancedportals.core.commands.subcommands.portal;
|
||||
|
||||
import com.sekwah.advancedportals.core.AdvancedPortalsCore;
|
||||
import com.sekwah.advancedportals.core.api.commands.SubCommand;
|
||||
import com.sekwah.advancedportals.core.api.portal.AdvancedPortal;
|
||||
import com.sekwah.advancedportals.core.api.portal.DataTag;
|
||||
import com.sekwah.advancedportals.core.api.portal.PortalException;
|
||||
import com.sekwah.advancedportals.core.commands.subcommands.CreateSubCommand;
|
||||
@ -24,8 +25,12 @@ public class CreatePortalSubCommand extends CreateSubCommand implements SubComma
|
||||
}
|
||||
ArrayList<DataTag> portalTags = this.getTagsFromArgs(args);
|
||||
try {
|
||||
AdvancedPortalsCore.getPortalManager().createPortal(args[1], player, portalTags);
|
||||
sender.sendMessage(Lang.translateColor("messageprefix.positive") + Lang.translateColor(""));
|
||||
AdvancedPortal portal = AdvancedPortalsCore.getPortalManager().createPortal(args[1], player, portalTags);
|
||||
sender.sendMessage(Lang.translateColor("messageprefix.positive") + Lang.translateColor("command.create.complete"));
|
||||
sender.sendMessage(Lang.translateColor("command.create.tags"));
|
||||
for (DataTag tag: portal.getArgs()) {
|
||||
sender.sendMessage(tag.NAME + ":" + tag.VALUE);
|
||||
}
|
||||
} catch (PortalException portalTagExeption) {
|
||||
sender.sendMessage(Lang.translateColor("messageprefix.negative") + Lang.translateColor("command.create.error") + " "
|
||||
+ Lang.translate(portalTagExeption.getMessage()));
|
||||
|
Loading…
Reference in New Issue
Block a user