mirror of
https://github.com/sekwah41/Advanced-Portals.git
synced 2024-11-07 19:39:47 +01:00
Updated core code
This commit is contained in:
commit
58dad44cd4
@ -1,6 +1,6 @@
|
|||||||
package com.sekwah.advancedportals.core.api.commands;
|
package com.sekwah.advancedportals.core.api.commands;
|
||||||
|
|
||||||
import org.bukkit.command.CommandSender;
|
import com.sekwah.advancedportals.coreconnector.container.CommandSenderContainer;
|
||||||
|
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
@ -16,7 +16,7 @@ public interface SubCommand {
|
|||||||
* @param args arguments including the subcommand that has been specified.
|
* @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)
|
* @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.
|
* @param args arguments including the subcommand that has been specified.
|
||||||
* @return tab completion for the subcommand
|
* @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)
|
* @return the string to show on the above help menu. (describing the subcommand)
|
||||||
|
@ -1,8 +1,8 @@
|
|||||||
package com.sekwah.advancedportals.core.api.effect;
|
package com.sekwah.advancedportals.core.api.effect;
|
||||||
|
|
||||||
import com.sekwah.advancedportals.core.api.portal.Portal;
|
import com.sekwah.advancedportals.core.api.portal.Portal;
|
||||||
import org.bukkit.Location;
|
import com.sekwah.advancedportals.core.data.PortalLocation;
|
||||||
import org.bukkit.entity.Player;
|
import com.sekwah.advancedportals.coreconnector.container.PlayerContainer;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @author sekwah41
|
* @author sekwah41
|
||||||
@ -10,7 +10,7 @@ import org.bukkit.entity.Player;
|
|||||||
public class TestEffect implements WarpEffect {
|
public class TestEffect implements WarpEffect {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onWarp(Player player, Location loc, Action action, Portal portal) {
|
public void onWarp(PlayerContainer player, PortalLocation loc, Action action, Portal portal) {
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1,8 +1,8 @@
|
|||||||
package com.sekwah.advancedportals.core.api.effect;
|
package com.sekwah.advancedportals.core.api.effect;
|
||||||
|
|
||||||
import com.sekwah.advancedportals.core.api.portal.Portal;
|
import com.sekwah.advancedportals.core.api.portal.Portal;
|
||||||
import org.bukkit.Location;
|
import com.sekwah.advancedportals.core.data.PortalLocation;
|
||||||
import org.bukkit.entity.Player;
|
import com.sekwah.advancedportals.coreconnector.container.PlayerContainer;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Effects to be registered to the list.
|
* Effects to be registered to the list.
|
||||||
@ -15,7 +15,7 @@ import org.bukkit.entity.Player;
|
|||||||
*/
|
*/
|
||||||
public interface WarpEffect {
|
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();
|
Type getType();
|
||||||
|
|
||||||
|
@ -1,16 +1,16 @@
|
|||||||
package com.sekwah.advancedportals.core.api.events;
|
package com.sekwah.advancedportals.core.api.events;
|
||||||
|
|
||||||
import org.bukkit.event.Event;
|
|
||||||
import org.bukkit.event.HandlerList;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Triggered once all the portals are loaded
|
* Triggered once all the portals are loaded
|
||||||
*
|
*
|
||||||
|
* TODO Need to make a custom event handler to be able to register against
|
||||||
|
*
|
||||||
* @author sekwah41
|
* @author sekwah41
|
||||||
*/
|
*/
|
||||||
public class PortalsLoadedEvent extends Event {
|
public class PortalsLoadedEvent/* extends Event*/ {
|
||||||
@Override
|
/*@Override
|
||||||
public HandlerList getHandlers() {
|
public HandlerList getHandlers() {
|
||||||
return null;
|
return null;
|
||||||
}
|
}*/
|
||||||
}
|
}
|
||||||
|
@ -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 com.sekwah.advancedportals.core.api.portal.Portal;
|
||||||
import org.bukkit.entity.Player;
|
|
||||||
import org.bukkit.event.Cancellable;
|
|
||||||
import org.bukkit.event.Event;
|
|
||||||
import org.bukkit.event.HandlerList;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Trigered whenever a player activates the warp after the tags are handled.
|
* 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;
|
private boolean cancelled = false;
|
||||||
|
|
||||||
@ -21,20 +20,20 @@ public class WarpEvent extends Event implements Cancellable {
|
|||||||
|
|
||||||
private boolean hasWarped = false;
|
private boolean hasWarped = false;
|
||||||
|
|
||||||
/*public WarpEvent(Player player, AdvancedPortal portalData) {
|
*//*public WarpEvent(Player player, AdvancedPortal portalData) {
|
||||||
this.player = player;
|
this.player = player;
|
||||||
this.portalData = portalData;
|
this.portalData = portalData;
|
||||||
}*/
|
}*//*
|
||||||
|
|
||||||
public static HandlerList getHandlerList() {
|
public static HandlerList getHandlerList() {
|
||||||
return handlers;
|
return handlers;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
*//**
|
||||||
* Returns if the event has been cancelled
|
* Returns if the event has been cancelled
|
||||||
*
|
*
|
||||||
* @return cancelled
|
* @return cancelled
|
||||||
*/
|
*//*
|
||||||
public boolean isCancelled() {
|
public boolean isCancelled() {
|
||||||
return cancelled;
|
return cancelled;
|
||||||
}
|
}
|
||||||
@ -43,24 +42,24 @@ public class WarpEvent extends Event implements Cancellable {
|
|||||||
cancelled = cancel;
|
cancelled = cancel;
|
||||||
}
|
}
|
||||||
|
|
||||||
/*public AdvancedPortal getPortalData() {
|
*//*public AdvancedPortal getPortalData() {
|
||||||
return portalData;
|
return portalData;
|
||||||
}*/
|
}*//*
|
||||||
|
|
||||||
/**
|
*//**
|
||||||
* This will return true if another plugin has warped the player(and set this to true)
|
* This will return true if another plugin has warped the player(and set this to true)
|
||||||
*
|
*
|
||||||
* @return hasWarped
|
* @return hasWarped
|
||||||
*/
|
*//*
|
||||||
public boolean getHasWarped() {
|
public boolean getHasWarped() {
|
||||||
return hasWarped;
|
return hasWarped;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
*//**
|
||||||
* If the
|
* If the
|
||||||
*
|
*
|
||||||
* @param warped
|
* @param warped
|
||||||
*/
|
*//*
|
||||||
public void setHasWarped(boolean warped) {
|
public void setHasWarped(boolean warped) {
|
||||||
this.hasWarped = warped;
|
this.hasWarped = warped;
|
||||||
}
|
}
|
||||||
@ -71,5 +70,5 @@ public class WarpEvent extends Event implements Cancellable {
|
|||||||
|
|
||||||
public HandlerList getHandlers() {
|
public HandlerList getHandlers() {
|
||||||
return handlers;
|
return handlers;
|
||||||
}
|
}*/
|
||||||
}
|
}
|
@ -1,7 +1,7 @@
|
|||||||
package com.sekwah.advancedportals.core.api.managers;
|
package com.sekwah.advancedportals.core.api.managers;
|
||||||
|
|
||||||
import com.sekwah.advancedportals.core.api.portal.Portal;
|
import com.sekwah.advancedportals.core.api.portal.Portal;
|
||||||
import org.bukkit.entity.Player;
|
import com.sekwah.advancedportals.coreconnector.container.PlayerContainer;
|
||||||
|
|
||||||
import java.util.HashMap;
|
import java.util.HashMap;
|
||||||
|
|
||||||
@ -21,11 +21,11 @@ public class PortalManager {
|
|||||||
/**
|
/**
|
||||||
* Store data of when the player last entered the portal
|
* 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
|
* Tracks what portal a player has selected
|
||||||
*/
|
*/
|
||||||
private HashMap<Player, Portal> selectedPortal = new HashMap();
|
private HashMap<String, Portal> selectedPortal = new HashMap();
|
||||||
|
|
||||||
public PortalManager() {
|
public PortalManager() {
|
||||||
this.loadPortals();
|
this.loadPortals();
|
||||||
@ -36,9 +36,9 @@ public class PortalManager {
|
|||||||
*
|
*
|
||||||
* @param player
|
* @param player
|
||||||
*/
|
*/
|
||||||
public static void playerLeave(Player player) {
|
public static void playerLeave(PlayerContainer player) {
|
||||||
instance.lastAttempt.remove(player);
|
instance.lastAttempt.remove(player.getUUID());
|
||||||
instance.selectedPortal.remove(player);
|
instance.selectedPortal.remove(player.getUUID());
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -4,13 +4,10 @@ public class PortalTag {
|
|||||||
|
|
||||||
public final String NAME;
|
public final String NAME;
|
||||||
public final String VALUE;
|
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.NAME = argName;
|
||||||
this.VALUE = value;
|
this.VALUE = value;
|
||||||
// may be used if values need to be 100% not string
|
|
||||||
//this.type = type;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -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 com.sekwah.advancedportals.core.AdvancedPortalsCore;
|
||||||
|
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
package com.sekwah.advancedportals.api.warphandler;
|
package com.sekwah.advancedportals.core.api.warphandler;
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -1,8 +1,6 @@
|
|||||||
package com.sekwah.advancedportals.api.warphandler;
|
package com.sekwah.advancedportals.core.api.warphandler;
|
||||||
|
|
||||||
import org.bukkit.entity.Player;
|
import com.sekwah.advancedportals.coreconnector.container.PlayerContainer;
|
||||||
|
|
||||||
import javax.annotation.Nullable;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Created by on 30/07/2016.
|
* Created by on 30/07/2016.
|
||||||
@ -31,7 +29,7 @@ public class TagHandler {
|
|||||||
* @param argData
|
* @param argData
|
||||||
* @return if the portal can be created.
|
* @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.
|
* Example if the player does not have access to remove the portal.
|
||||||
@ -41,7 +39,7 @@ public class TagHandler {
|
|||||||
* @param argData
|
* @param argData
|
||||||
* @return if the portal can be destroyed.
|
* @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 activeData
|
||||||
* @param argData
|
* @param argData
|
||||||
*/
|
*/
|
||||||
void portalPreActivated(Player player, ActivationData activeData, String argData);
|
void portalPreActivated(PlayerContainer player, ActivationData activeData, String argData);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Activates after portal activation
|
* Activates after portal activation
|
||||||
@ -63,7 +61,7 @@ public class TagHandler {
|
|||||||
* @param activeData
|
* @param activeData
|
||||||
* @param argData
|
* @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
|
* Activates if the portal is allowed from pre
|
||||||
@ -72,7 +70,7 @@ public class TagHandler {
|
|||||||
* @param activeData
|
* @param activeData
|
||||||
* @param argData
|
* @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
|
* @param argData
|
||||||
* @return if the tag will be added.
|
* @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
|
* If the user has access to remove the tag
|
||||||
@ -96,7 +94,7 @@ public class TagHandler {
|
|||||||
* @param argData
|
* @param argData
|
||||||
* @return if the tag will be removed.
|
* @return if the tag will be removed.
|
||||||
*/
|
*/
|
||||||
boolean tagRemoved(@Nullable Player player, ActivationData activeData, String argData);
|
boolean tagRemoved(PlayerContainer player, ActivationData activeData, String argData);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -0,0 +1,4 @@
|
|||||||
|
package com.sekwah.advancedportals.core.data;
|
||||||
|
|
||||||
|
public class PortalLocation {
|
||||||
|
}
|
@ -1,10 +1,9 @@
|
|||||||
package com.sekwah.advancedportals.core.util;
|
package com.sekwah.advancedportals.core.util;
|
||||||
|
|
||||||
import com.google.common.collect.Maps;
|
|
||||||
import com.sekwah.advancedportals.core.AdvancedPortalsCore;
|
import com.sekwah.advancedportals.core.AdvancedPortalsCore;
|
||||||
|
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
import java.io.InputStream;
|
import java.io.InputStream;
|
||||||
|
import java.util.HashMap;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
import java.util.Scanner;
|
import java.util.Scanner;
|
||||||
|
|
||||||
@ -21,7 +20,7 @@ import java.util.Scanner;
|
|||||||
public class Lang {
|
public class Lang {
|
||||||
|
|
||||||
private static final Lang instance = new 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";
|
private final String DEFAULT_LANG = "en_GB";
|
||||||
|
|
||||||
public Lang() {
|
public Lang() {
|
||||||
@ -84,7 +83,7 @@ public class Lang {
|
|||||||
private Map<String, String> parseLang(InputStream inputStream) {
|
private Map<String, String> parseLang(InputStream inputStream) {
|
||||||
Scanner scanner = new Scanner(inputStream, "UTF-8");
|
Scanner scanner = new Scanner(inputStream, "UTF-8");
|
||||||
String line = getNextLine(scanner);
|
String line = getNextLine(scanner);
|
||||||
Map<String, String> newMap = Maps.newHashMap();
|
HashMap<String, String> newMap = new HashMap<>();
|
||||||
while (scanner != null && line != null) {
|
while (scanner != null && line != null) {
|
||||||
//System.out.println(line);
|
//System.out.println(line);
|
||||||
if (!line.startsWith("#") && line.indexOf('=') > -1) {
|
if (!line.startsWith("#") && line.indexOf('=') > -1) {
|
||||||
@ -94,7 +93,6 @@ public class Lang {
|
|||||||
newMap.put(key, value);
|
newMap.put(key, value);
|
||||||
}
|
}
|
||||||
line = getNextLine(scanner);
|
line = getNextLine(scanner);
|
||||||
// TODO add split code at the first = and also conversion of strings/codes which are constants like colors.
|
|
||||||
}
|
}
|
||||||
try {
|
try {
|
||||||
inputStream.close();
|
inputStream.close();
|
||||||
|
@ -0,0 +1,4 @@
|
|||||||
|
package com.sekwah.advancedportals.coreconnector.container;
|
||||||
|
|
||||||
|
public class CommandSenderContainer {
|
||||||
|
}
|
@ -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 "";
|
||||||
|
}
|
||||||
|
}
|
Loading…
Reference in New Issue
Block a user