Removed useless class

This commit is contained in:
Sekwah 2020-07-03 23:39:36 +01:00 committed by Sekwah
parent 8c04b82e02
commit 0249b929ab
3 changed files with 57 additions and 66 deletions

View File

@ -3,16 +3,16 @@ package com.sekwah.advancedportals.core.commands.subcommands.desti;
import com.sekwah.advancedportals.core.AdvancedPortalsCore; import com.sekwah.advancedportals.core.AdvancedPortalsCore;
import com.sekwah.advancedportals.core.api.commands.SubCommand; import com.sekwah.advancedportals.core.api.commands.SubCommand;
import com.sekwah.advancedportals.core.api.destination.Destination; import com.sekwah.advancedportals.core.api.destination.Destination;
import com.sekwah.advancedportals.core.commands.subcommands.CreateSubCommand;
import com.sekwah.advancedportals.core.data.DataTag; import com.sekwah.advancedportals.core.data.DataTag;
import com.sekwah.advancedportals.core.util.Lang; import com.sekwah.advancedportals.core.util.Lang;
import com.sekwah.advancedportals.core.connector.container.CommandSenderContainer; import com.sekwah.advancedportals.core.connector.container.CommandSenderContainer;
import com.sekwah.advancedportals.core.connector.container.PlayerContainer; import com.sekwah.advancedportals.core.connector.container.PlayerContainer;
import com.sekwah.advancedportals.core.util.TagReader;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.List; import java.util.List;
public class CreateDestiSubCommand extends CreateSubCommand implements SubCommand { public class CreateDestiSubCommand implements SubCommand {
@Override @Override
public void onCommand(CommandSenderContainer sender, String[] args) { public void onCommand(CommandSenderContainer sender, String[] args) {
@ -22,7 +22,7 @@ public class CreateDestiSubCommand extends CreateSubCommand implements SubComman
sender.sendMessage(Lang.translateColor("messageprefix.negative") + Lang.translate("command.createdesti.console")); sender.sendMessage(Lang.translateColor("messageprefix.negative") + Lang.translate("command.createdesti.console"));
return; return;
} }
ArrayList<DataTag> destiTags = this.getTagsFromArgs(args); ArrayList<DataTag> destiTags = TagReader.getTagsFromArgs(args);
Destination desti = AdvancedPortalsCore.getDestinationServices().createDesti(args[1], player, player.getLoc(), destiTags); Destination desti = AdvancedPortalsCore.getDestinationServices().createDesti(args[1], player, player.getLoc(), destiTags);
if(desti != null) { if(desti != null) {
sender.sendMessage(Lang.translateColor("messageprefix.positive") + Lang.translateColor("command.createdesti.complete")); sender.sendMessage(Lang.translateColor("messageprefix.positive") + Lang.translateColor("command.createdesti.complete"));
@ -46,14 +46,6 @@ public class CreateDestiSubCommand extends CreateSubCommand implements SubComman
} }
} }
protected String getTag(String arg) {
int splitLoc = arg.indexOf(":");
if(splitLoc != -1) {
return arg.substring(0,splitLoc);
}
return null;
}
@Override @Override
public boolean hasPermission(CommandSenderContainer sender) { public boolean hasPermission(CommandSenderContainer sender) {
return sender.isOp() || sender.hasPermission("advancedportals.createportal"); return sender.isOp() || sender.hasPermission("advancedportals.createportal");

View File

@ -3,17 +3,17 @@ package com.sekwah.advancedportals.core.commands.subcommands.portal;
import com.sekwah.advancedportals.core.AdvancedPortalsCore; import com.sekwah.advancedportals.core.AdvancedPortalsCore;
import com.sekwah.advancedportals.core.api.commands.SubCommand; import com.sekwah.advancedportals.core.api.commands.SubCommand;
import com.sekwah.advancedportals.core.api.portal.AdvancedPortal; import com.sekwah.advancedportals.core.api.portal.AdvancedPortal;
import com.sekwah.advancedportals.core.commands.subcommands.CreateSubCommand;
import com.sekwah.advancedportals.core.data.DataTag; import com.sekwah.advancedportals.core.data.DataTag;
import com.sekwah.advancedportals.core.util.Lang; import com.sekwah.advancedportals.core.util.Lang;
import com.sekwah.advancedportals.core.connector.container.CommandSenderContainer; import com.sekwah.advancedportals.core.connector.container.CommandSenderContainer;
import com.sekwah.advancedportals.core.connector.container.PlayerContainer; import com.sekwah.advancedportals.core.connector.container.PlayerContainer;
import com.sekwah.advancedportals.core.util.TagReader;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.Arrays; import java.util.Arrays;
import java.util.List; import java.util.List;
public class CreatePortalSubCommand extends CreateSubCommand implements SubCommand { public class CreatePortalSubCommand implements SubCommand {
@Override @Override
public void onCommand(CommandSenderContainer sender, String[] args) { public void onCommand(CommandSenderContainer sender, String[] args) {
@ -23,7 +23,7 @@ public class CreatePortalSubCommand extends CreateSubCommand implements SubComma
sender.sendMessage(Lang.translateColor("messageprefix.negative") + Lang.translate("command.create.console")); sender.sendMessage(Lang.translateColor("messageprefix.negative") + Lang.translate("command.create.console"));
return; return;
} }
ArrayList<DataTag> portalTags = this.getTagsFromArgs(args); ArrayList<DataTag> portalTags = TagReader.getTagsFromArgs(args);
AdvancedPortal portal = AdvancedPortalsCore.getPortalServices().createPortal(args[1], player, portalTags); AdvancedPortal portal = AdvancedPortalsCore.getPortalServices().createPortal(args[1], player, portalTags);
if(portal != null) { if(portal != null) {
@ -41,14 +41,6 @@ public class CreatePortalSubCommand extends CreateSubCommand implements SubComma
} }
} }
protected String getTag(String arg) {
int splitLoc = arg.indexOf(":");
if(splitLoc != -1) {
return arg.substring(0,splitLoc);
}
return null;
}
@Override @Override
public boolean hasPermission(CommandSenderContainer sender) { public boolean hasPermission(CommandSenderContainer sender) {
return sender.isOp() || sender.hasPermission("advancedportals.createportal"); return sender.isOp() || sender.hasPermission("advancedportals.createportal");

View File

@ -1,12 +1,12 @@
package com.sekwah.advancedportals.core.commands.subcommands; package com.sekwah.advancedportals.core.util;
import com.sekwah.advancedportals.core.data.DataTag; import com.sekwah.advancedportals.core.data.DataTag;
import java.util.ArrayList; import java.util.ArrayList;
public abstract class CreateSubCommand { public class TagReader {
protected ArrayList<DataTag> getTagsFromArgs(String[] args) { public static ArrayList<DataTag> getTagsFromArgs(String[] args) {
ArrayList<DataTag> tags = new ArrayList<>(); ArrayList<DataTag> tags = new ArrayList<>();
boolean partingValueWithSpaces = false; boolean partingValueWithSpaces = false;
String argBeingParsed = ""; String argBeingParsed = "";
@ -23,7 +23,7 @@ public abstract class CreateSubCommand {
} }
} }
else { else {
String detectedTag = this.getTag(args[i].toLowerCase()); String detectedTag = TagReader.getTag(args[i].toLowerCase());
if(detectedTag != null) { if(detectedTag != null) {
String arg = args[i].substring(detectedTag.length() + 1); String arg = args[i].substring(detectedTag.length() + 1);
if(arg.length() > 0 && arg.charAt(0) == '"') { if(arg.length() > 0 && arg.charAt(0) == '"') {
@ -40,5 +40,12 @@ public abstract class CreateSubCommand {
} }
protected abstract String getTag(String arg); public static String getTag(String arg) {
int splitLoc = arg.indexOf(":");
if(splitLoc != -1) {
return arg.substring(0,splitLoc);
}
return null;
}
} }