Added portal saving

This commit is contained in:
sekwah 2018-02-22 03:06:12 +00:00 committed by Sekwah
parent bed94dc936
commit 641154a965
5 changed files with 15 additions and 7 deletions

View File

@ -53,11 +53,11 @@ command.selector.help=Gives you a portal region selector
command.selector.detailedhelp=Gives you a portal selector to select the regions for making portals.
portal.error.invalidselection=You must have both pos1 and pos2 selected to create a portal.
portal.error.noname=No name for the portal has been given.
portal.error.takenname=The name given for the portal is already taken.
portal.error.selection.differentworlds=Both the selected points need to be in the same world.
desti.error.noname=No name for the portal has been given.
command.error.noname= No name has been given.
desti.error.takenname=The name given for the portal is already taken.
error.notplayer=Only players can do that.

View File

@ -55,6 +55,10 @@ public class DestinationManager {
Type type = new TypeToken<HashMap<String, Destination>>() {
}.getType();
this.destiHashMap = this.portalsCore.getDataStorage().loadJson(type, "destinations.json");
this.saveDestinations();
}
public void saveDestinations() {
if (this.destiHashMap == null) {
this.destiHashMap = new HashMap<>();
}

View File

@ -67,11 +67,15 @@ public class PortalManager {
Type type = new TypeToken<HashMap<String, AdvancedPortal>>() {
}.getType();
this.portalHashMap = this.portalsCore.getDataStorage().loadJson(type, "portals.json");
this.savePortals();
this.updatePortalArray();
}
public void savePortals() {
if (this.portalHashMap == null) {
this.portalHashMap = new HashMap<>();
}
this.portalsCore.getDataStorage().storeJson(this.portalHashMap, "portals.json");
this.updatePortalArray();
}
public void activateCooldown(PlayerContainer player) {

View File

@ -16,7 +16,7 @@ public class CreateDestiSubCommand extends CreateSubCommand implements SubComman
@Override
public void onCommand(CommandSenderContainer sender, String[] args) {
if(args.length > 2) {
if(args.length > 1) {
PlayerContainer player = sender.getPlayerContainer();
if(player == null) {
sender.sendMessage(Lang.translateColor("messageprefix.negative") + Lang.translate("command.create.console"));
@ -31,7 +31,7 @@ public class CreateDestiSubCommand extends CreateSubCommand implements SubComman
}
}
else {
sender.sendMessage(Lang.translate("command.error.noname"));
sender.sendMessage(Lang.translateColor("messageprefix.positive") + Lang.translate("command.error.noname"));
}
}

View File

@ -16,7 +16,7 @@ public class CreatePortalSubCommand extends CreateSubCommand implements SubComma
@Override
public void onCommand(CommandSenderContainer sender, String[] args) {
if(args.length > 2) {
if(args.length > 1) {
PlayerContainer player = sender.getPlayerContainer();
if(player == null) {
sender.sendMessage(Lang.translateColor("messageprefix.negative") + Lang.translate("command.create.console"));
@ -31,7 +31,7 @@ public class CreatePortalSubCommand extends CreateSubCommand implements SubComma
}
}
else {
sender.sendMessage(Lang.translate("command.error.noname"));
sender.sendMessage(Lang.translateColor("messageprefix.positive") + Lang.translate("command.error.noname"));
}
}