From a656fce13e9f59105c752165621ad1616698ef87 Mon Sep 17 00:00:00 2001 From: Alastair Date: Wed, 3 Jan 2018 23:37:40 +0000 Subject: [PATCH 1/6] Fixed issue with wrong name --- pom.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pom.xml b/pom.xml index 60d318a..9e2fd32 100644 --- a/pom.xml +++ b/pom.xml @@ -6,7 +6,7 @@ ${basedir}/src/ - ${basedir}/CoreResources + ${basedir}/Resources From 51e426c274cd8acdca879576abe6a8310cb26730 Mon Sep 17 00:00:00 2001 From: Alastair Date: Thu, 4 Jan 2018 14:51:40 +0000 Subject: [PATCH 2/6] Fixed some referenced but still need to finish removing bukkit references --- .../core/api/events/PortalsLoadedEvent.java | 10 ++--- .../core/api/events/WarpEvent.java | 37 +++++++++---------- 2 files changed, 23 insertions(+), 24 deletions(-) diff --git a/src/com/sekwah/advancedportals/core/api/events/PortalsLoadedEvent.java b/src/com/sekwah/advancedportals/core/api/events/PortalsLoadedEvent.java index 1fb73a6..e696118 100644 --- a/src/com/sekwah/advancedportals/core/api/events/PortalsLoadedEvent.java +++ b/src/com/sekwah/advancedportals/core/api/events/PortalsLoadedEvent.java @@ -1,16 +1,16 @@ package com.sekwah.advancedportals.core.api.events; -import org.bukkit.event.Event; -import org.bukkit.event.HandlerList; /** * Triggered once all the portals are loaded * + * TODO Need to make a custom event handler to be able to register against + * * @author sekwah41 */ -public class PortalsLoadedEvent extends Event { - @Override +public class PortalsLoadedEvent/* extends Event*/ { + /*@Override public HandlerList getHandlers() { return null; - } + }*/ } diff --git a/src/com/sekwah/advancedportals/core/api/events/WarpEvent.java b/src/com/sekwah/advancedportals/core/api/events/WarpEvent.java index d2f6052..29ea786 100644 --- a/src/com/sekwah/advancedportals/core/api/events/WarpEvent.java +++ b/src/com/sekwah/advancedportals/core/api/events/WarpEvent.java @@ -1,17 +1,16 @@ -package com.sekwah.advancedportals.api.events; +package com.sekwah.advancedportals.core.api.events; -import com.sekwah.advancedportals.api.portal.Portal; -import org.bukkit.entity.Player; -import org.bukkit.event.Cancellable; -import org.bukkit.event.Event; -import org.bukkit.event.HandlerList; +import com.sekwah.advancedportals.core.api.portal.Portal; /** * Trigered whenever a player activates the warp after the tags are handled. + * + * + * TODO Need to make a custom event handler to be able to register against or something similar like a general events data */ -public class WarpEvent extends Event implements Cancellable { +public class WarpEvent /*extends Event implements Cancellable*/ { - private static HandlerList handlers = new HandlerList(); + /*private static HandlerList handlers = new HandlerList(); private boolean cancelled = false; @@ -21,20 +20,20 @@ public class WarpEvent extends Event implements Cancellable { private boolean hasWarped = false; - /*public WarpEvent(Player player, AdvancedPortal portalData) { + *//*public WarpEvent(Player player, AdvancedPortal portalData) { this.player = player; this.portalData = portalData; - }*/ + }*//* public static HandlerList getHandlerList() { return handlers; } - /** + *//** * Returns if the event has been cancelled * * @return cancelled - */ + *//* public boolean isCancelled() { return cancelled; } @@ -43,24 +42,24 @@ public class WarpEvent extends Event implements Cancellable { cancelled = cancel; } - /*public AdvancedPortal getPortalData() { + *//*public AdvancedPortal getPortalData() { return portalData; - }*/ + }*//* - /** + *//** * This will return true if another plugin has warped the player(and set this to true) * * @return hasWarped - */ + *//* public boolean getHasWarped() { return hasWarped; } - /** + *//** * If the * * @param warped - */ + *//* public void setHasWarped(boolean warped) { this.hasWarped = warped; } @@ -71,5 +70,5 @@ public class WarpEvent extends Event implements Cancellable { public HandlerList getHandlers() { return handlers; - } + }*/ } \ No newline at end of file From f9041ea83fa1c1b1946777b8b8958943b96de862 Mon Sep 17 00:00:00 2001 From: Alastair Date: Fri, 5 Jan 2018 01:01:08 +0000 Subject: [PATCH 3/6] Preparing to design container implementation idea --- .../core/api/registry/TagRegistry.java | 4 ++-- .../core/api/warphandler/ActivationData.java | 2 +- .../core/api/warphandler/TagHandler.java | 20 +++++++++---------- .../container/PlayerContainer.java | 4 ++++ 4 files changed, 16 insertions(+), 14 deletions(-) create mode 100644 src/com/sekwah/advancedportals/coreconnector/container/PlayerContainer.java diff --git a/src/com/sekwah/advancedportals/core/api/registry/TagRegistry.java b/src/com/sekwah/advancedportals/core/api/registry/TagRegistry.java index 6079cf4..4aac4b7 100644 --- a/src/com/sekwah/advancedportals/core/api/registry/TagRegistry.java +++ b/src/com/sekwah/advancedportals/core/api/registry/TagRegistry.java @@ -1,6 +1,6 @@ -package com.sekwah.advancedportals.api.registry; +package com.sekwah.advancedportals.core.api.registry; -import com.sekwah.advancedportals.api.warphandler.TagHandler; +import com.sekwah.advancedportals.core.api.warphandler.TagHandler; import com.sekwah.advancedportals.core.AdvancedPortalsCore; import java.util.ArrayList; diff --git a/src/com/sekwah/advancedportals/core/api/warphandler/ActivationData.java b/src/com/sekwah/advancedportals/core/api/warphandler/ActivationData.java index b6e42bc..eac2b22 100644 --- a/src/com/sekwah/advancedportals/core/api/warphandler/ActivationData.java +++ b/src/com/sekwah/advancedportals/core/api/warphandler/ActivationData.java @@ -1,4 +1,4 @@ -package com.sekwah.advancedportals.api.warphandler; +package com.sekwah.advancedportals.core.api.warphandler; /** diff --git a/src/com/sekwah/advancedportals/core/api/warphandler/TagHandler.java b/src/com/sekwah/advancedportals/core/api/warphandler/TagHandler.java index 6ec4eb8..a00c770 100644 --- a/src/com/sekwah/advancedportals/core/api/warphandler/TagHandler.java +++ b/src/com/sekwah/advancedportals/core/api/warphandler/TagHandler.java @@ -1,8 +1,6 @@ -package com.sekwah.advancedportals.api.warphandler; +package com.sekwah.advancedportals.core.api.warphandler; -import org.bukkit.entity.Player; - -import javax.annotation.Nullable; +import com.sekwah.advancedportals.coreconnector.container.PlayerContainer; /** * Created by on 30/07/2016. @@ -31,7 +29,7 @@ public class TagHandler { * @param argData * @return if the portal can be created. */ - boolean portalCreated(@Nullable Player player, ActivationData activeData, String argData); + boolean portalCreated(PlayerContainer player, ActivationData activeData, String argData); /** * Example if the player does not have access to remove the portal. @@ -41,7 +39,7 @@ public class TagHandler { * @param argData * @return if the portal can be destroyed. */ - boolean portalDestroyed(@Nullable Player player, ActivationData activeData, String argData); + boolean portalDestroyed(PlayerContainer player, ActivationData activeData, String argData); } @@ -54,7 +52,7 @@ public class TagHandler { * @param activeData * @param argData */ - void portalPreActivated(Player player, ActivationData activeData, String argData); + void portalPreActivated(PlayerContainer player, ActivationData activeData, String argData); /** * Activates after portal activation @@ -63,7 +61,7 @@ public class TagHandler { * @param activeData * @param argData */ - void portalPostActivated(Player player, ActivationData activeData, String argData); + void portalPostActivated(PlayerContainer player, ActivationData activeData, String argData); /** * Activates if the portal is allowed from pre @@ -72,7 +70,7 @@ public class TagHandler { * @param activeData * @param argData */ - void portalActivated(Player player, ActivationData activeData, String argData); + void portalActivated(PlayerContainer player, ActivationData activeData, String argData); } @@ -86,7 +84,7 @@ public class TagHandler { * @param argData * @return if the tag will be added. */ - boolean tagAdded(@Nullable Player player, ActivationData activeData, String argData); + boolean tagAdded(PlayerContainer player, ActivationData activeData, String argData); /** * If the user has access to remove the tag @@ -96,7 +94,7 @@ public class TagHandler { * @param argData * @return if the tag will be removed. */ - boolean tagRemoved(@Nullable Player player, ActivationData activeData, String argData); + boolean tagRemoved(PlayerContainer player, ActivationData activeData, String argData); } diff --git a/src/com/sekwah/advancedportals/coreconnector/container/PlayerContainer.java b/src/com/sekwah/advancedportals/coreconnector/container/PlayerContainer.java new file mode 100644 index 0000000..044dc80 --- /dev/null +++ b/src/com/sekwah/advancedportals/coreconnector/container/PlayerContainer.java @@ -0,0 +1,4 @@ +package com.sekwah.advancedportals.coreconnector.container; + +public class PlayerContainer { +} From a02b69483083cbff0657b36943c81746bf75d853 Mon Sep 17 00:00:00 2001 From: Alastair Date: Fri, 5 Jan 2018 20:47:22 +0000 Subject: [PATCH 4/6] removed all bukkit references --- .../core/api/managers/PortalManager.java | 12 ++++++------ .../advancedportals/core/api/portal/PortalTag.java | 5 +---- .../coreconnector/container/PlayerContainer.java | 7 +++++++ 3 files changed, 14 insertions(+), 10 deletions(-) diff --git a/src/com/sekwah/advancedportals/core/api/managers/PortalManager.java b/src/com/sekwah/advancedportals/core/api/managers/PortalManager.java index 1760618..879975d 100644 --- a/src/com/sekwah/advancedportals/core/api/managers/PortalManager.java +++ b/src/com/sekwah/advancedportals/core/api/managers/PortalManager.java @@ -1,7 +1,7 @@ package com.sekwah.advancedportals.core.api.managers; import com.sekwah.advancedportals.core.api.portal.Portal; -import org.bukkit.entity.Player; +import com.sekwah.advancedportals.coreconnector.container.PlayerContainer; import java.util.HashMap; @@ -21,11 +21,11 @@ public class PortalManager { /** * Store data of when the player last entered the portal */ - private HashMap lastAttempt = new HashMap(); + private HashMap lastAttempt = new HashMap(); /** * Tracks what portal a player has selected */ - private HashMap selectedPortal = new HashMap(); + private HashMap selectedPortal = new HashMap(); public PortalManager() { this.loadPortals(); @@ -36,9 +36,9 @@ public class PortalManager { * * @param player */ - public static void playerLeave(Player player) { - instance.lastAttempt.remove(player); - instance.selectedPortal.remove(player); + public static void playerLeave(PlayerContainer player) { + instance.lastAttempt.remove(player.getUUID()); + instance.selectedPortal.remove(player.getUUID()); } /** diff --git a/src/com/sekwah/advancedportals/core/api/portal/PortalTag.java b/src/com/sekwah/advancedportals/core/api/portal/PortalTag.java index 9868a5a..3d6e047 100644 --- a/src/com/sekwah/advancedportals/core/api/portal/PortalTag.java +++ b/src/com/sekwah/advancedportals/core/api/portal/PortalTag.java @@ -4,13 +4,10 @@ public class PortalTag { public final String NAME; public final String VALUE; - //public final int type; - public PortalTag(String argName, String value/*, int type*/) { + public PortalTag(String argName, String value) { this.NAME = argName; this.VALUE = value; - // may be used if values need to be 100% not string - //this.type = type; } } diff --git a/src/com/sekwah/advancedportals/coreconnector/container/PlayerContainer.java b/src/com/sekwah/advancedportals/coreconnector/container/PlayerContainer.java index 044dc80..2f2ea07 100644 --- a/src/com/sekwah/advancedportals/coreconnector/container/PlayerContainer.java +++ b/src/com/sekwah/advancedportals/coreconnector/container/PlayerContainer.java @@ -1,4 +1,11 @@ package com.sekwah.advancedportals.coreconnector.container; +/** + * Just a temporary container for whenever advanced portals needs to get data from a player + */ public class PlayerContainer { + + public String getUUID() { + return ""; + } } From 9a6bfa143a2cf0f1160b8f21e44ae75b0d7eabab Mon Sep 17 00:00:00 2001 From: Alastair Date: Fri, 5 Jan 2018 20:56:09 +0000 Subject: [PATCH 5/6] removed all bukkit references --- src/com/sekwah/advancedportals/core/util/Lang.java | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-) diff --git a/src/com/sekwah/advancedportals/core/util/Lang.java b/src/com/sekwah/advancedportals/core/util/Lang.java index c480d49..73383f5 100644 --- a/src/com/sekwah/advancedportals/core/util/Lang.java +++ b/src/com/sekwah/advancedportals/core/util/Lang.java @@ -1,10 +1,9 @@ package com.sekwah.advancedportals.core.util; -import com.google.common.collect.Maps; import com.sekwah.advancedportals.core.AdvancedPortalsCore; - import java.io.IOException; import java.io.InputStream; +import java.util.HashMap; import java.util.Map; import java.util.Scanner; @@ -21,7 +20,7 @@ import java.util.Scanner; public class Lang { private static final Lang instance = new Lang(); - private final Map languageMap = Maps.newHashMap(); + private final HashMap languageMap = new HashMap<>(); private final String DEFAULT_LANG = "en_GB"; public Lang() { @@ -84,7 +83,7 @@ public class Lang { private Map parseLang(InputStream inputStream) { Scanner scanner = new Scanner(inputStream, "UTF-8"); String line = getNextLine(scanner); - Map newMap = Maps.newHashMap(); + HashMap newMap = new HashMap<>(); while (scanner != null && line != null) { //System.out.println(line); if (!line.startsWith("#") && line.indexOf('=') > -1) { @@ -94,7 +93,6 @@ public class Lang { newMap.put(key, value); } line = getNextLine(scanner); - // TODO add split code at the first = and also conversion of strings/codes which are constants like colors. } try { inputStream.close(); From 3e1623f688647a6590e696311f56e11f2584664a Mon Sep 17 00:00:00 2001 From: Alastair Date: Fri, 5 Jan 2018 21:14:15 +0000 Subject: [PATCH 6/6] Actually finished removing bukkit references now --- .../advancedportals/core/api/commands/SubCommand.java | 6 +++--- .../sekwah/advancedportals/core/api/effect/TestEffect.java | 6 +++--- .../sekwah/advancedportals/core/api/effect/WarpEffect.java | 6 +++--- .../sekwah/advancedportals/core/data/PortalLocation.java | 4 ++++ .../coreconnector/container/CommandSenderContainer.java | 4 ++++ 5 files changed, 17 insertions(+), 9 deletions(-) create mode 100644 src/com/sekwah/advancedportals/core/data/PortalLocation.java create mode 100644 src/com/sekwah/advancedportals/coreconnector/container/CommandSenderContainer.java diff --git a/src/com/sekwah/advancedportals/core/api/commands/SubCommand.java b/src/com/sekwah/advancedportals/core/api/commands/SubCommand.java index 61c9a13..840bb8a 100644 --- a/src/com/sekwah/advancedportals/core/api/commands/SubCommand.java +++ b/src/com/sekwah/advancedportals/core/api/commands/SubCommand.java @@ -1,6 +1,6 @@ package com.sekwah.advancedportals.core.api.commands; -import org.bukkit.command.CommandSender; +import com.sekwah.advancedportals.coreconnector.container.CommandSenderContainer; import java.util.List; @@ -16,7 +16,7 @@ public interface SubCommand { * @param args arguments including the subcommand that has been specified. * @return if the command has worked (if false it will just display a message from the command suggesting to check help) */ - boolean onCommand(CommandSender sender, String[] args); + boolean onCommand(CommandSenderContainer sender, String[] args); /** * @@ -25,7 +25,7 @@ public interface SubCommand { * @param args arguments including the subcommand that has been specified. * @return tab completion for the subcommand */ - List onTabComplete(CommandSender sender, String[] args); + List onTabComplete(CommandSenderContainer sender, String[] args); /** * @return the string to show on the above help menu. (describing the subcommand) diff --git a/src/com/sekwah/advancedportals/core/api/effect/TestEffect.java b/src/com/sekwah/advancedportals/core/api/effect/TestEffect.java index 397aac8..d597664 100644 --- a/src/com/sekwah/advancedportals/core/api/effect/TestEffect.java +++ b/src/com/sekwah/advancedportals/core/api/effect/TestEffect.java @@ -1,8 +1,8 @@ package com.sekwah.advancedportals.core.api.effect; import com.sekwah.advancedportals.core.api.portal.Portal; -import org.bukkit.Location; -import org.bukkit.entity.Player; +import com.sekwah.advancedportals.core.data.PortalLocation; +import com.sekwah.advancedportals.coreconnector.container.PlayerContainer; /** * @author sekwah41 @@ -10,7 +10,7 @@ import org.bukkit.entity.Player; public class TestEffect implements WarpEffect { @Override - public void onWarp(Player player, Location loc, Action action, Portal portal) { + public void onWarp(PlayerContainer player, PortalLocation loc, Action action, Portal portal) { } diff --git a/src/com/sekwah/advancedportals/core/api/effect/WarpEffect.java b/src/com/sekwah/advancedportals/core/api/effect/WarpEffect.java index 7ddcd8e..2f3715c 100644 --- a/src/com/sekwah/advancedportals/core/api/effect/WarpEffect.java +++ b/src/com/sekwah/advancedportals/core/api/effect/WarpEffect.java @@ -1,8 +1,8 @@ package com.sekwah.advancedportals.core.api.effect; import com.sekwah.advancedportals.core.api.portal.Portal; -import org.bukkit.Location; -import org.bukkit.entity.Player; +import com.sekwah.advancedportals.core.data.PortalLocation; +import com.sekwah.advancedportals.coreconnector.container.PlayerContainer; /** * Effects to be registered to the list. @@ -15,7 +15,7 @@ import org.bukkit.entity.Player; */ public interface WarpEffect { - void onWarp(Player player, Location loc, Action action, Portal portal); + void onWarp(PlayerContainer player, PortalLocation loc, Action action, Portal portal); Type getType(); diff --git a/src/com/sekwah/advancedportals/core/data/PortalLocation.java b/src/com/sekwah/advancedportals/core/data/PortalLocation.java new file mode 100644 index 0000000..44dccaf --- /dev/null +++ b/src/com/sekwah/advancedportals/core/data/PortalLocation.java @@ -0,0 +1,4 @@ +package com.sekwah.advancedportals.core.data; + +public class PortalLocation { +} diff --git a/src/com/sekwah/advancedportals/coreconnector/container/CommandSenderContainer.java b/src/com/sekwah/advancedportals/coreconnector/container/CommandSenderContainer.java new file mode 100644 index 0000000..b4b037a --- /dev/null +++ b/src/com/sekwah/advancedportals/coreconnector/container/CommandSenderContainer.java @@ -0,0 +1,4 @@ +package com.sekwah.advancedportals.coreconnector.container; + +public class CommandSenderContainer { +}