Updated core code

This commit is contained in:
Alastair 2018-01-05 21:14:46 +00:00
commit 58dad44cd4
14 changed files with 73 additions and 62 deletions

View File

@ -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<String> onTabComplete(CommandSender sender, String[] args);
List<String> onTabComplete(CommandSenderContainer sender, String[] args);
/**
* @return the string to show on the above help menu. (describing the subcommand)

View File

@ -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) {
}

View File

@ -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();

View File

@ -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;
}
}*/
}

View File

@ -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;
}
}*/
}

View File

@ -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<Player, Long> lastAttempt = new HashMap();
private HashMap<String, Long> lastAttempt = new HashMap();
/**
* Tracks what portal a player has selected
*/
private HashMap<Player, Portal> selectedPortal = new HashMap();
private HashMap<String, Portal> 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());
}
/**

View File

@ -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;
}
}

View File

@ -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;

View File

@ -1,4 +1,4 @@
package com.sekwah.advancedportals.api.warphandler;
package com.sekwah.advancedportals.core.api.warphandler;
/**

View File

@ -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);
}

View File

@ -0,0 +1,4 @@
package com.sekwah.advancedportals.core.data;
public class PortalLocation {
}

View File

@ -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<String, String> languageMap = Maps.newHashMap();
private final HashMap<String, String> languageMap = new HashMap<>();
private final String DEFAULT_LANG = "en_GB";
public Lang() {
@ -84,7 +83,7 @@ public class Lang {
private Map<String, String> parseLang(InputStream inputStream) {
Scanner scanner = new Scanner(inputStream, "UTF-8");
String line = getNextLine(scanner);
Map<String, String> newMap = Maps.newHashMap();
HashMap<String, String> 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();

View File

@ -0,0 +1,4 @@
package com.sekwah.advancedportals.coreconnector.container;
public class CommandSenderContainer {
}

View File

@ -0,0 +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 "";
}
}