mirror of
https://github.com/sekwah41/Advanced-Portals.git
synced 2024-11-22 18:46:35 +01:00
Working on create command and portal listeners
This commit is contained in:
parent
d29d668196
commit
4c1dae79e3
@ -26,13 +26,20 @@ logger.plugincrafterror=This version of craftbukkit is not yet supported or some
|
|||||||
command.noargs= Sorry but you need to specify a sub command, please use \u00A7e/%1$s help \u00A7cif you would like a list of possible sub commands.
|
command.noargs= Sorry but you need to specify a sub command, please use \u00A7e/%1$s help \u00A7cif you would like a list of possible sub commands.
|
||||||
command.subcommand.invalid= Sorry but that is not a valid sub command.
|
command.subcommand.invalid= Sorry but that is not a valid sub command.
|
||||||
|
|
||||||
command.help.header=\u00A7e--------- \u00A7a%1$s Help - Page %2$s of %3$s\u00A7e ---------------
|
command.help.header=\u00A7e--------------- \u00A7a%1$s Help - Page %2$s of %3$s\u00A7e ---------------
|
||||||
command.help.invalidnum= Sorry but \u00A7e%1$s\u00A7c is not a valid page number.
|
command.help.subcommandheader=\u00A7e--------- \u00A7a%1$s Help - %2$s\u00A7e ---------
|
||||||
|
command.help.invalidhelp= Sorry but \u00A7e%1$s\u00A7c is not a valid page number or sub command.
|
||||||
|
|
||||||
command.reload.help=Reloads portal data
|
command.reload.help=Reloads portal data
|
||||||
command.reload.detailedhelp=Reloads all portal data from files in the data folder
|
command.reload.detailedhelp=Reloads all portal data from files in the data folder
|
||||||
command.reload.reloaded= All Advanced Portals data reloaded
|
command.reload.reloaded= All Advanced Portals data reloaded
|
||||||
|
|
||||||
|
command.create.help=Creates portals
|
||||||
|
command.create.noargs= You need to actually list args for portal creation.
|
||||||
|
command.create.noname= You need to at least give a name to the portal no matter how many other tags you give it.
|
||||||
|
command.create.detailedhelp=List tags after create in the format tag:value, if your value needs spaces use the format tag:"value with spaces"
|
||||||
|
|
||||||
|
|
||||||
command.version.help=Returns the current version of the plugin
|
command.version.help=Returns the current version of the plugin
|
||||||
|
|
||||||
command.subcommand.nopermission= Sorry but you don't have permission for that, please use \u00A7e/%1$s help \u00A7cif you would like a list of possible sub commands.
|
command.subcommand.nopermission= Sorry but you don't have permission for that, please use \u00A7e/%1$s help \u00A7cif you would like a list of possible sub commands.
|
||||||
|
@ -52,6 +52,7 @@ public class AdvancedPortalsCore {
|
|||||||
this.instance = this;
|
this.instance = this;
|
||||||
this.commandRegister = commandRegister;
|
this.commandRegister = commandRegister;
|
||||||
this.mcMinorVer = this.checkMcVer(mcVer);
|
this.mcMinorVer = this.checkMcVer(mcVer);
|
||||||
|
|
||||||
this.onEnable();
|
this.onEnable();
|
||||||
|
|
||||||
}
|
}
|
||||||
@ -121,7 +122,7 @@ public class AdvancedPortalsCore {
|
|||||||
|
|
||||||
this.portalCommand.registerSubCommand("version", new VersionSubCommand());
|
this.portalCommand.registerSubCommand("version", new VersionSubCommand());
|
||||||
this.portalCommand.registerSubCommand("transupdate", new TransUpdateSubCommand());
|
this.portalCommand.registerSubCommand("transupdate", new TransUpdateSubCommand());
|
||||||
this.portalCommand.registerSubCommand("reload", new ReloadSubCommand());
|
this.portalCommand.registerSubCommand("reload", new ReloadSubCommand(this));
|
||||||
|
|
||||||
this.commandRegister.registerCommand("portal", this.portalCommand);
|
this.commandRegister.registerCommand("portal", this.portalCommand);
|
||||||
}
|
}
|
||||||
@ -155,8 +156,12 @@ public class AdvancedPortalsCore {
|
|||||||
this.infoLogger.log(Lang.translate("logger.plugindisable"));
|
this.infoLogger.log(Lang.translate("logger.plugindisable"));
|
||||||
}
|
}
|
||||||
|
|
||||||
public static AdvancedPortalsCore getInstance() {
|
/*public static AdvancedPortalsCore getInstance() {
|
||||||
return instance;
|
return instance;
|
||||||
|
}*/
|
||||||
|
|
||||||
|
public Config getConfig() {
|
||||||
|
return this.config;
|
||||||
}
|
}
|
||||||
|
|
||||||
public DataStorage getDataStorage() {
|
public DataStorage getDataStorage() {
|
||||||
|
@ -1,6 +1,8 @@
|
|||||||
package com.sekwah.advancedportals.core;
|
package com.sekwah.advancedportals.core;
|
||||||
|
|
||||||
|
import com.sekwah.advancedportals.core.api.portal.AdvancedPortal;
|
||||||
import com.sekwah.advancedportals.core.data.PlayerLocation;
|
import com.sekwah.advancedportals.core.data.PlayerLocation;
|
||||||
|
import com.sekwah.advancedportals.core.data.PortalLocation;
|
||||||
import com.sekwah.advancedportals.core.util.Lang;
|
import com.sekwah.advancedportals.core.util.Lang;
|
||||||
import com.sekwah.advancedportals.coreconnector.container.PlayerContainer;
|
import com.sekwah.advancedportals.coreconnector.container.PlayerContainer;
|
||||||
|
|
||||||
@ -13,6 +15,7 @@ public class CoreListeners {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public void playerJoin(PlayerContainer player) {
|
public void playerJoin(PlayerContainer player) {
|
||||||
|
AdvancedPortalsCore.getPortalManager().playerJoin(player);
|
||||||
if(player.isOp()) {
|
if(player.isOp()) {
|
||||||
if(!Lang.translate("translatedata.lastchange").equals(AdvancedPortalsCore.lastTranslationUpdate)) {
|
if(!Lang.translate("translatedata.lastchange").equals(AdvancedPortalsCore.lastTranslationUpdate)) {
|
||||||
player.sendMessage(Lang.translateColor("messageprefix.negative")
|
player.sendMessage(Lang.translateColor("messageprefix.negative")
|
||||||
@ -23,8 +26,26 @@ public class CoreListeners {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public void playerMove(PlayerContainer player, PlayerLocation fromLoc, PlayerLocation toLoc) {
|
public void playerLeave(PlayerContainer player) {
|
||||||
|
AdvancedPortalsCore.getPortalManager().playerLeave(player);
|
||||||
|
}
|
||||||
|
|
||||||
|
public boolean playerMove(PlayerContainer player, PlayerLocation fromLoc, PlayerLocation toLoc) {
|
||||||
|
return AdvancedPortalsCore.getPortalManager().playerMove(player, fromLoc, toLoc);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
* @param player
|
||||||
|
* @param blockLoc
|
||||||
|
* @param leftClick true = left click, false = right click
|
||||||
|
*/
|
||||||
|
public void playerInteractWithBlock(PlayerContainer player, String materialName, String itemName,
|
||||||
|
PortalLocation blockLoc, boolean leftClick) {
|
||||||
|
if(materialName.equalsIgnoreCase(this.portalsCore.getConfig().getSelectorMaterial())
|
||||||
|
&& (!this.portalsCore.getConfig().getUseOnlySpecialAxe() || itemName.equals("\u00A7ePortal Region Selector"))) {
|
||||||
|
AdvancedPortalsCore.getPortalManager().playerSelectorActivate(player, blockLoc, leftClick);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -3,6 +3,8 @@ package com.sekwah.advancedportals.core.api.managers;
|
|||||||
import com.google.gson.reflect.TypeToken;
|
import com.google.gson.reflect.TypeToken;
|
||||||
import com.sekwah.advancedportals.core.AdvancedPortalsCore;
|
import com.sekwah.advancedportals.core.AdvancedPortalsCore;
|
||||||
import com.sekwah.advancedportals.core.api.portal.AdvancedPortal;
|
import com.sekwah.advancedportals.core.api.portal.AdvancedPortal;
|
||||||
|
import com.sekwah.advancedportals.core.data.PlayerLocation;
|
||||||
|
import com.sekwah.advancedportals.core.data.PortalLocation;
|
||||||
import com.sekwah.advancedportals.coreconnector.container.PlayerContainer;
|
import com.sekwah.advancedportals.coreconnector.container.PlayerContainer;
|
||||||
|
|
||||||
import java.lang.reflect.Type;
|
import java.lang.reflect.Type;
|
||||||
@ -16,13 +18,6 @@ import java.util.Map;
|
|||||||
*/
|
*/
|
||||||
public class PortalManager {
|
public class PortalManager {
|
||||||
|
|
||||||
/**
|
|
||||||
* Cooldown time for players to try entering portals.
|
|
||||||
*/
|
|
||||||
private static final int COOLDOWN = 0;
|
|
||||||
|
|
||||||
private static PortalManager instance;
|
|
||||||
|
|
||||||
private final AdvancedPortalsCore portalsCore;
|
private final AdvancedPortalsCore portalsCore;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -34,6 +29,9 @@ public class PortalManager {
|
|||||||
*/
|
*/
|
||||||
private HashMap<String, AdvancedPortal> selectedPortal = new HashMap();
|
private HashMap<String, AdvancedPortal> selectedPortal = new HashMap();
|
||||||
|
|
||||||
|
private HashMap<String, PortalLocation> portalSelectorLeftClick = new HashMap();
|
||||||
|
private HashMap<String, PortalLocation> portalSelectorRightClick = new HashMap();
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Contains all the data for the portals
|
* Contains all the data for the portals
|
||||||
*/
|
*/
|
||||||
@ -42,7 +40,6 @@ public class PortalManager {
|
|||||||
private AdvancedPortal[] portals;
|
private AdvancedPortal[] portals;
|
||||||
|
|
||||||
public PortalManager(AdvancedPortalsCore portalsCore) {
|
public PortalManager(AdvancedPortalsCore portalsCore) {
|
||||||
this.instance = this;
|
|
||||||
this.portalsCore = portalsCore;
|
this.portalsCore = portalsCore;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -52,10 +49,14 @@ public class PortalManager {
|
|||||||
* @param player
|
* @param player
|
||||||
*/
|
*/
|
||||||
public void playerLeave(PlayerContainer player) {
|
public void playerLeave(PlayerContainer player) {
|
||||||
this.lastAttempt.remove(player.getUUID());
|
this.lastAttempt.remove(player.getUUID().toString());
|
||||||
this.selectedPortal.remove(player.getUUID());
|
this.selectedPortal.remove(player.getUUID().toString());
|
||||||
|
this.portalSelectorLeftClick.remove(player.getUUID().toString());
|
||||||
|
this.portalSelectorRightClick.remove(player.getUUID().toString());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Load the default data into the portals.
|
* Load the default data into the portals.
|
||||||
*/
|
*/
|
||||||
@ -67,4 +68,16 @@ public class PortalManager {
|
|||||||
}
|
}
|
||||||
this.portalsCore.getDataStorage().storeJson(this.portalHashMap, "config.json");
|
this.portalsCore.getDataStorage().storeJson(this.portalHashMap, "config.json");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void playerJoin(PlayerContainer player) {
|
||||||
|
this.lastAttempt.put(player.getUUID().toString(), System.currentTimeMillis());
|
||||||
|
}
|
||||||
|
|
||||||
|
public void playerSelectorActivate(PlayerContainer player, PortalLocation blockLoc, boolean leftClick) {
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
public boolean playerMove(PlayerContainer player, PlayerLocation fromLoc, PlayerLocation toLoc) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@ -1,11 +1,11 @@
|
|||||||
package com.sekwah.advancedportals.core.api.portal;
|
package com.sekwah.advancedportals.core.api.portal;
|
||||||
|
|
||||||
class PortalTag {
|
public class PortalTag {
|
||||||
|
|
||||||
public final String NAME;
|
public final String NAME;
|
||||||
public final String VALUE;
|
public final String VALUE;
|
||||||
|
|
||||||
PortalTag(String argName, String value) {
|
public PortalTag(String argName, String value) {
|
||||||
this.NAME = argName;
|
this.NAME = argName;
|
||||||
this.VALUE = value;
|
this.VALUE = value;
|
||||||
}
|
}
|
||||||
|
@ -53,7 +53,16 @@ public class CommandWithSubCommands implements CommandTemplate {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
catch(NumberFormatException e) {
|
catch(NumberFormatException e) {
|
||||||
sender.sendMessage(Lang.translateColor("messageprefix.negative") + Lang.translateInsertVariablesColor("command.help.invalidnum", args[1]));
|
String subCommand = args[1].toLowerCase();
|
||||||
|
if(this.subCommandRegistry.isArgRegistered(subCommand)) {
|
||||||
|
sender.sendMessage(Lang.translateInsertVariablesColor("command.help.subcommandheader",
|
||||||
|
commandExecuted.substring(0,1).toUpperCase() + commandExecuted.substring(1).toLowerCase(), subCommand));
|
||||||
|
sender.sendMessage(Lang.translateInsertVariablesColor("command.help.invalidhelp", args[1]));
|
||||||
|
sender.sendMessage(this.getSubCommand(subCommand).getDetailedHelpText());
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
sender.sendMessage(Lang.translateColor("messageprefix.negative") + Lang.translateInsertVariablesColor("command.help.invalidhelp", args[1]));
|
||||||
|
}
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -0,0 +1,42 @@
|
|||||||
|
package com.sekwah.advancedportals.core.commands.subcommands.portal;
|
||||||
|
|
||||||
|
import com.sekwah.advancedportals.core.api.commands.SubCommand;
|
||||||
|
import com.sekwah.advancedportals.core.api.portal.AdvancedPortal;
|
||||||
|
import com.sekwah.advancedportals.core.util.Lang;
|
||||||
|
import com.sekwah.advancedportals.coreconnector.container.CommandSenderContainer;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
public class CreateSubCommand implements SubCommand {
|
||||||
|
@Override
|
||||||
|
public void onCommand(CommandSenderContainer sender, String[] args) {
|
||||||
|
if(args.length > 1) {
|
||||||
|
//AdvancedPortal newPortal = new AdvancedPortal();
|
||||||
|
|
||||||
|
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
sender.sendMessage(Lang.translate(""));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean hasPermission(CommandSenderContainer sender) {
|
||||||
|
return sender.isOp();
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public List<String> onTabComplete(CommandSenderContainer sender, String[] args) {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String getBasicHelpText() {
|
||||||
|
return Lang.translate("command.create.help");
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String getDetailedHelpText() {
|
||||||
|
return Lang.translate("command.create.detailedhelp");
|
||||||
|
}
|
||||||
|
}
|
@ -9,10 +9,17 @@ import com.sekwah.advancedportals.coreconnector.container.CommandSenderContainer
|
|||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
public class ReloadSubCommand implements SubCommand {
|
public class ReloadSubCommand implements SubCommand {
|
||||||
|
|
||||||
|
private final AdvancedPortalsCore portalsCore;
|
||||||
|
|
||||||
|
public ReloadSubCommand(AdvancedPortalsCore portalsCore) {
|
||||||
|
this.portalsCore = portalsCore;
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onCommand(CommandSenderContainer sender, String[] args) {
|
public void onCommand(CommandSenderContainer sender, String[] args) {
|
||||||
AdvancedPortalsCore.getInstance().loadPortalConfig();
|
portalsCore.loadPortalConfig();
|
||||||
AdvancedPortalsCore.getPortalManager().loadPortals();
|
portalsCore.getPortalManager().loadPortals();
|
||||||
sender.sendMessage(Lang.translateColor("messageprefix.positive") + Lang.translateColor("command.reload.reloaded"));
|
sender.sendMessage(Lang.translateColor("messageprefix.positive") + Lang.translateColor("command.reload.reloaded"));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -17,13 +17,15 @@ public class Config {
|
|||||||
|
|
||||||
private boolean stopWaterFlow = true;
|
private boolean stopWaterFlow = true;
|
||||||
|
|
||||||
private String selectionBlock_OLD_MATERIAL = "STAINED_GLASS";
|
private int portalCooldown = 5;
|
||||||
|
|
||||||
|
private String selectionBlock_BELOW_1_13 = "STAINED_GLASS";
|
||||||
|
|
||||||
private String selectionBlock = "RED_STAINED_GLASS";
|
private String selectionBlock = "RED_STAINED_GLASS";
|
||||||
|
|
||||||
private String translationFile = "en_GB";
|
private String translationFile = "en_GB";
|
||||||
|
|
||||||
private int blockSubID_BELOW_1_13_ONLY = 14;
|
private int selectionSubID_BELOW_1_13 = 14;
|
||||||
|
|
||||||
public boolean getUseOnlySpecialAxe() {
|
public boolean getUseOnlySpecialAxe() {
|
||||||
return useOnlySpecialAxe;
|
return useOnlySpecialAxe;
|
||||||
@ -36,4 +38,8 @@ public class Config {
|
|||||||
public String getTranslation() {
|
public String getTranslation() {
|
||||||
return translationFile;
|
return translationFile;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public String getSelectorMaterial() {
|
||||||
|
return selectorMaterial;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@ -1,5 +1,6 @@
|
|||||||
package com.sekwah.advancedportals.coreconnector.container;
|
package com.sekwah.advancedportals.coreconnector.container;
|
||||||
|
|
||||||
|
import com.sekwah.advancedportals.core.data.PlayerLocation;
|
||||||
import com.sekwah.advancedportals.core.util.Lang;
|
import com.sekwah.advancedportals.core.util.Lang;
|
||||||
import org.bukkit.command.CommandSender;
|
import org.bukkit.command.CommandSender;
|
||||||
|
|
||||||
@ -19,6 +20,13 @@ public class CommandSenderContainer {
|
|||||||
return sender.isOp();
|
return sender.isOp();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @return null if there isnt a player e.g. the console
|
||||||
|
*/
|
||||||
|
public PlayerContainer getPlayerContainer() {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
public boolean hasPermission(String permission) {
|
public boolean hasPermission(String permission) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
@ -31,7 +31,11 @@ public class PlayerContainer {
|
|||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void teleport(PlayerLocation location) {}
|
||||||
|
|
||||||
public boolean hasPermission(String permission) {
|
public boolean hasPermission(String permission) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void giveItem(String material, String itemName, String... itemDescription) {}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user