refactor: Changed lists and maps to use the base classes List, Map.
This commit is contained in:
parent
1dba64467c
commit
11d8d9ce48
|
@ -5,29 +5,16 @@ import com.sekwah.advancedportals.core.config.Config;
|
|||
import com.sekwah.advancedportals.core.data.DataStorage;
|
||||
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
|
||||
@Singleton
|
||||
public class ConfigRepositoryImpl implements ConfigRepository {
|
||||
|
||||
private HashMap<String, Config> configs;
|
||||
private Map<String, Config> configs;
|
||||
private Config config;
|
||||
|
||||
public ConfigRepositoryImpl() {
|
||||
configs = new HashMap<String,Config>();
|
||||
}
|
||||
|
||||
public <T> T getValue(String output) {
|
||||
|
||||
try {
|
||||
return (T) configs.get(output);
|
||||
} catch (ClassCastException ignored) {
|
||||
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
private void test() {
|
||||
this.<String>getValue("");
|
||||
configs = new HashMap<>();
|
||||
}
|
||||
|
||||
public boolean getUseOnlySpecialAxe() {
|
||||
|
|
|
@ -9,10 +9,7 @@ import com.sekwah.advancedportals.core.data.DataTag;
|
|||
import com.sekwah.advancedportals.core.data.PlayerLocation;
|
||||
import com.sekwah.advancedportals.core.connector.container.PlayerContainer;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
import java.util.Set;
|
||||
import java.util.*;
|
||||
|
||||
/**
|
||||
* Possibly look at adding the ability to add some tags to destinations such as permissions. Would make it easier
|
||||
|
@ -97,8 +94,8 @@ public class Destination {
|
|||
}
|
||||
}
|
||||
|
||||
public ArrayList<DataTag> getArgs() {
|
||||
ArrayList<DataTag> tagList = new ArrayList<>();
|
||||
public List<DataTag> getArgs() {
|
||||
List<DataTag> tagList = new ArrayList<>();
|
||||
for(Map.Entry<String, String> entry : this.args.entrySet()){
|
||||
tagList.add(new DataTag(entry.getKey(), entry.getValue()));
|
||||
}
|
||||
|
|
|
@ -11,6 +11,7 @@ import com.sekwah.advancedportals.core.connector.container.PlayerContainer;
|
|||
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
/**
|
||||
|
@ -98,8 +99,8 @@ public class AdvancedPortal {
|
|||
this.setArg(portalTag.NAME, portalTag.VALUE);
|
||||
}
|
||||
|
||||
public ArrayList<DataTag> getArgs() {
|
||||
ArrayList<DataTag> tagList = new ArrayList<>();
|
||||
public List<DataTag> getArgs() {
|
||||
List<DataTag> tagList = new ArrayList<>();
|
||||
for(Map.Entry<String, String> entry : this.args.entrySet()){
|
||||
tagList.add(new DataTag(entry.getKey(), entry.getValue()));
|
||||
}
|
||||
|
|
|
@ -22,12 +22,12 @@ public class CreateDestiSubCommand implements SubCommand {
|
|||
sender.sendMessage(Lang.translateColor("messageprefix.negative") + Lang.translate("command.createdesti.console"));
|
||||
return;
|
||||
}
|
||||
ArrayList<DataTag> destiTags = TagReader.getTagsFromArgs(args);
|
||||
List<DataTag> destiTags = TagReader.getTagsFromArgs(args);
|
||||
Destination desti = AdvancedPortalsCore.getDestinationServices().createDesti(args[1], player, player.getLoc(), destiTags);
|
||||
if(desti != null) {
|
||||
sender.sendMessage(Lang.translateColor("messageprefix.positive") + Lang.translateColor("command.createdesti.complete"));
|
||||
sender.sendMessage(Lang.translateColor("command.create.tags"));
|
||||
ArrayList<DataTag> destiArgs = desti.getArgs();
|
||||
List<DataTag> destiArgs = desti.getArgs();
|
||||
if(destiArgs.size() == 0) {
|
||||
sender.sendMessage(Lang.translateColor("desti.info.noargs"));
|
||||
}
|
||||
|
|
|
@ -23,7 +23,7 @@ public class CreatePortalSubCommand implements SubCommand {
|
|||
sender.sendMessage(Lang.translateColor("messageprefix.negative") + Lang.translate("command.create.console"));
|
||||
return;
|
||||
}
|
||||
ArrayList<DataTag> portalTags = TagReader.getTagsFromArgs(args);
|
||||
List<DataTag> portalTags = TagReader.getTagsFromArgs(args);
|
||||
|
||||
AdvancedPortal portal = AdvancedPortalsCore.getPortalServices().createPortal(args[1], player, portalTags);
|
||||
if(portal != null) {
|
||||
|
|
|
@ -8,7 +8,6 @@ import com.sekwah.advancedportals.core.connector.container.CommandSenderContaine
|
|||
|
||||
import java.util.List;
|
||||
|
||||
@SubCmd(name="version", parent=SubCmd.TYPE.PORTAL, minArgs=5, permissions= {"Test"})
|
||||
public class VersionSubCommand implements SubCommand {
|
||||
|
||||
@Override
|
||||
|
|
|
@ -5,7 +5,10 @@ import com.sekwah.advancedportals.core.data.DataTag;
|
|||
import com.sekwah.advancedportals.core.data.PlayerLocation;
|
||||
import com.sekwah.advancedportals.core.connector.container.PlayerContainer;
|
||||
|
||||
import java.util.ArrayList; /**
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* https://github.com/sekwah41/Advanced-Portals/blob/24175610892152828e21f4ff824eb1589ccb0338/src/com/sekwah/advancedportals/core/api/managers/DestinationManager.java
|
||||
* Based off the old manager with the data storage and handling moved to
|
||||
*/
|
||||
|
@ -24,7 +27,7 @@ public final class DestinationServices {
|
|||
* @param destiTags
|
||||
* @return null if not created
|
||||
*/
|
||||
public Destination createDesti(String name, PlayerContainer player, PlayerLocation loc, ArrayList<DataTag> destiTags) {
|
||||
public Destination createDesti(String name, PlayerContainer player, PlayerLocation loc, List<DataTag> destiTags) {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -8,6 +8,7 @@ import com.sekwah.advancedportals.core.data.PlayerLocation;
|
|||
import com.sekwah.advancedportals.core.connector.container.PlayerContainer;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
/**
|
||||
|
@ -41,7 +42,7 @@ public final class PortalServices {
|
|||
return false;
|
||||
}
|
||||
|
||||
public AdvancedPortal createPortal(String name, PlayerContainer player, ArrayList<DataTag> portalTags) {
|
||||
public AdvancedPortal createPortal(String name, PlayerContainer player, List<DataTag> portalTags) {
|
||||
return null;
|
||||
}
|
||||
|
||||
|
|
|
@ -21,7 +21,7 @@ import java.util.Scanner;
|
|||
public class Lang {
|
||||
|
||||
private static final Lang instance = new Lang();
|
||||
private final HashMap<String, String> languageMap = new HashMap<>();
|
||||
private final Map<String, String> languageMap = new HashMap<>();
|
||||
//private final String DEFAULT_LANG = "en_GB";
|
||||
|
||||
/*public Lang() {
|
||||
|
@ -84,8 +84,9 @@ public class Lang {
|
|||
private Map<String, String> parseLang(InputStream inputStream) {
|
||||
Scanner scanner = new Scanner(inputStream, "UTF-8");
|
||||
String line = getNextLine(scanner);
|
||||
HashMap<String, String> newMap = new HashMap<>();
|
||||
while (scanner != null && line != null) {
|
||||
Map<String, String> newMap = new HashMap<>();
|
||||
|
||||
while (line != null) {
|
||||
//System.out.println(line);
|
||||
if (!line.startsWith("#") && line.indexOf('=') > -1) {
|
||||
int split = line.indexOf('=');
|
||||
|
|
|
@ -3,11 +3,12 @@ package com.sekwah.advancedportals.core.util;
|
|||
import com.sekwah.advancedportals.core.data.DataTag;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
public class TagReader {
|
||||
|
||||
public static ArrayList<DataTag> getTagsFromArgs(String[] args) {
|
||||
ArrayList<DataTag> tags = new ArrayList<>();
|
||||
public static List<DataTag> getTagsFromArgs(String[] args) {
|
||||
List<DataTag> tags = new ArrayList<>();
|
||||
boolean partingValueWithSpaces = false;
|
||||
String argBeingParsed = "";
|
||||
String currentParsedValue = "";
|
||||
|
|
|
@ -19,7 +19,7 @@ public class DestinationRepository implements IDestinationRepository<Destination
|
|||
private final String fileLocation = "";
|
||||
|
||||
|
||||
private Map<String, Destination> destinationCache = new HashMap<String, Destination>();
|
||||
private Map<String, Destination> destinationCache = new HashMap<>();
|
||||
|
||||
/*Is there any reason to load it into the array if it's not been used or connected? Q for Sekwah*/
|
||||
public void AddDestination(String name, Destination destination) throws IOException {
|
||||
|
@ -35,6 +35,7 @@ public class DestinationRepository implements IDestinationRepository<Destination
|
|||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean containsKey(String name) {
|
||||
return Files.exists(Paths.get(fileLocation + "\\" + name + ".json"));
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue