mirror of
https://github.com/sekwah41/Advanced-Portals.git
synced 2024-11-22 02:25:49 +01:00
Started to get forge working
This commit is contained in:
parent
76bd76d015
commit
6877e22b3b
@ -55,7 +55,7 @@ group = 'com.sekwah.advancedportals'
|
||||
|
||||
description = ""
|
||||
|
||||
/*minecraft {
|
||||
minecraft {
|
||||
version = "1.12.2-14.23.2.2611"
|
||||
runDir = "run"
|
||||
|
||||
@ -66,7 +66,7 @@ description = ""
|
||||
// simply re-run your setup task after changing the mappings to update your workspace.
|
||||
mappings = "snapshot_20180607"
|
||||
// makeObfSourceJar = false // an Srg named sources jar is made by default. uncomment this to disable.
|
||||
}*/
|
||||
}
|
||||
|
||||
sourceCompatibility = 1.8
|
||||
targetCompatibility = 1.8
|
||||
@ -458,7 +458,7 @@ task runJar() << {
|
||||
}
|
||||
}
|
||||
|
||||
/*processResources
|
||||
processResources
|
||||
{
|
||||
// this will ensure that this task is redone when the versions change.
|
||||
inputs.property "version", project.version
|
||||
@ -476,4 +476,4 @@ task runJar() << {
|
||||
from(sourceSets.main.resources.srcDirs) {
|
||||
exclude 'mcmod.info'
|
||||
}
|
||||
}*/
|
||||
}
|
||||
|
@ -27,7 +27,6 @@ public class AdvancedPortalsCore {
|
||||
|
||||
private static AdvancedPortalsCore instance;
|
||||
|
||||
private final CommandRegister commandRegister;
|
||||
private final InfoLogger infoLogger;
|
||||
private final int mcMinorVer;
|
||||
private final DataCollector dataCollector;
|
||||
@ -57,15 +56,13 @@ public class AdvancedPortalsCore {
|
||||
/**
|
||||
* @param dataStorageLoc - Where the files will be located
|
||||
* @param infoLogger - The implementation of the logger for the specific platform
|
||||
* @param commandRegister - Handles the command registry, different on each platform
|
||||
* @param mcVer Minecraft version e.g. 1.12.2
|
||||
*/
|
||||
public AdvancedPortalsCore(File dataStorageLoc, InfoLogger infoLogger, CommandRegister commandRegister,
|
||||
public AdvancedPortalsCore(File dataStorageLoc, InfoLogger infoLogger,
|
||||
DataCollector dataCollector, int[] mcVer) {
|
||||
this.dataStorage = new DataStorage(dataStorageLoc);
|
||||
this.infoLogger = infoLogger;
|
||||
instance = this;
|
||||
this.commandRegister = commandRegister;
|
||||
this.dataCollector = dataCollector;
|
||||
this.mcMinorVer = this.checkMcVer(mcVer);
|
||||
|
||||
@ -122,9 +119,6 @@ public class AdvancedPortalsCore {
|
||||
|
||||
Lang.loadLanguage(configRepository.getTranslation());
|
||||
|
||||
this.registerPortalCommand();
|
||||
this.registerDestinationCommand();
|
||||
|
||||
this.portalServices.loadPortals();
|
||||
|
||||
this.destiServices.loadDestinations();
|
||||
@ -132,7 +126,16 @@ public class AdvancedPortalsCore {
|
||||
this.infoLogger.log(Lang.translate("logger.pluginenable"));
|
||||
}
|
||||
|
||||
private void registerPortalCommand() {
|
||||
/**
|
||||
*
|
||||
* @param commandRegister - Handles the command registry, different on each platform
|
||||
*/
|
||||
public void registerCommands(CommandRegister commandRegister) {
|
||||
this.registerPortalCommand(commandRegister);
|
||||
this.registerDestinationCommand(commandRegister);
|
||||
}
|
||||
|
||||
private void registerPortalCommand(CommandRegister commandRegister) {
|
||||
this.portalCommand = new CommandWithSubCommands();
|
||||
|
||||
this.portalCommand.registerSubCommand("version", new VersionSubCommand());
|
||||
@ -145,15 +148,15 @@ public class AdvancedPortalsCore {
|
||||
this.portalCommand.registerSubCommand("create", new CreatePortalSubCommand());
|
||||
this.portalCommand.registerSubCommand("remove", new RemoveSubCommand());
|
||||
|
||||
this.commandRegister.registerCommand("portal", this.portalCommand);
|
||||
commandRegister.registerCommand("portal", this.portalCommand);
|
||||
}
|
||||
|
||||
private void registerDestinationCommand() {
|
||||
private void registerDestinationCommand(CommandRegister commandRegister) {
|
||||
this.destiCommand = new CommandWithSubCommands();
|
||||
|
||||
this.destiCommand.registerSubCommand("create", new CreateDestiSubCommand());
|
||||
|
||||
this.commandRegister.registerCommand("destination", this.destiCommand);
|
||||
commandRegister.registerCommand("destination", this.destiCommand);
|
||||
}
|
||||
|
||||
public static boolean registerDestiSubCommand(String arg, SubCommand subCommand) {
|
||||
|
@ -22,6 +22,5 @@ public final class PortalTempDataServices {
|
||||
}
|
||||
|
||||
public void playerSelectorActivate(PlayerContainer player, PortalLocation blockLoc, boolean leftClick) {
|
||||
|
||||
}
|
||||
}
|
||||
|
@ -5,10 +5,10 @@ import com.sekwah.advancedportals.core.commands.CommandTemplate;
|
||||
|
||||
public abstract class CommandHandler {
|
||||
|
||||
protected final CommandTemplate commandExecutor;
|
||||
|
||||
private final CommandTemplate commandExecutor;
|
||||
|
||||
public CommandHandler(CommandTemplate commandExecutor) {
|
||||
this.commandExecutor = commandExecutor;
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -0,0 +1,43 @@
|
||||
package com.sekwah.advancedportals.forge;
|
||||
|
||||
import com.sekwah.advancedportals.core.AdvancedPortalsCore;
|
||||
import com.sekwah.advancedportals.forge.coreconnector.command.ForgeCommandRegister;
|
||||
import com.sekwah.advancedportals.forge.coreconnector.info.ForgeDataCollector;
|
||||
import net.minecraftforge.fml.common.Mod;
|
||||
import net.minecraftforge.fml.common.event.FMLInitializationEvent;
|
||||
import net.minecraftforge.fml.common.event.FMLPreInitializationEvent;
|
||||
import net.minecraftforge.fml.common.event.FMLServerStartingEvent;
|
||||
import org.apache.logging.log4j.LogManager;
|
||||
import org.apache.logging.log4j.Logger;
|
||||
|
||||
import java.io.File;
|
||||
|
||||
/**
|
||||
* The mod is not needed client side but will add some useful additions
|
||||
*/
|
||||
@Mod(modid = AdvancedPortalsMod.modid, name = "Advanced Portals", version = AdvancedPortalsCore.version, acceptableRemoteVersions = "*")
|
||||
public class AdvancedPortalsMod {
|
||||
|
||||
public static final String modid = "advancedportals";
|
||||
|
||||
public static final Logger logger = LogManager.getLogger("Advanced Portals");
|
||||
|
||||
private AdvancedPortalsCore portalsCore;
|
||||
|
||||
@Mod.EventHandler
|
||||
public void init(FMLPreInitializationEvent event) {
|
||||
this.portalsCore = new AdvancedPortalsCore(new File(event.getModConfigurationDirectory(), modid),
|
||||
new ForgeInfoLogger(logger), new ForgeDataCollector(), new int[] {1,12,2});
|
||||
}
|
||||
|
||||
@Mod.EventHandler
|
||||
public void init(FMLInitializationEvent event) {
|
||||
}
|
||||
|
||||
@Mod.EventHandler
|
||||
public void init(FMLServerStartingEvent event)
|
||||
{
|
||||
this.portalsCore.registerCommands(new ForgeCommandRegister(event));
|
||||
}
|
||||
|
||||
}
|
@ -0,0 +1,23 @@
|
||||
package com.sekwah.advancedportals.forge;
|
||||
|
||||
import com.sekwah.advancedportals.core.util.InfoLogger;
|
||||
import org.apache.logging.log4j.Logger;
|
||||
|
||||
public class ForgeInfoLogger extends InfoLogger {
|
||||
|
||||
private final Logger logger;
|
||||
|
||||
public ForgeInfoLogger(Logger logger) {
|
||||
this.logger = logger;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void logWarning(String s) {
|
||||
this.logger.warn(s);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void log(String s) {
|
||||
this.logger.info(s);
|
||||
}
|
||||
}
|
@ -0,0 +1,45 @@
|
||||
package com.sekwah.advancedportals.forge.coreconnector.command;
|
||||
|
||||
import com.sekwah.advancedportals.core.commands.CommandTemplate;
|
||||
import com.sekwah.advancedportals.forge.coreconnector.container.ForgeCommandSenderContainer;
|
||||
import net.minecraft.command.CommandBase;
|
||||
import net.minecraft.command.CommandException;
|
||||
import net.minecraft.command.ICommandSender;
|
||||
import net.minecraft.server.MinecraftServer;
|
||||
import net.minecraft.util.math.BlockPos;
|
||||
|
||||
import javax.annotation.Nullable;
|
||||
import java.util.List;
|
||||
|
||||
public class ForgeCommandHandler extends CommandBase
|
||||
{
|
||||
|
||||
private final String commandName;
|
||||
private final CommandTemplate commandExecutor;
|
||||
|
||||
public ForgeCommandHandler(String commandName, CommandTemplate commandExecutor) {
|
||||
|
||||
this.commandName = commandName;
|
||||
this.commandExecutor = commandExecutor;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getName() {
|
||||
return commandName;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getUsage(ICommandSender iCommandSender) {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void execute(MinecraftServer minecraftServer, ICommandSender sender, String[] strings) throws CommandException {
|
||||
this.commandExecutor.onCommand(new ForgeCommandSenderContainer(sender), this.commandName, strings);
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<String> getTabCompletions(MinecraftServer mcServer, ICommandSender sender, String[] strings, @Nullable BlockPos location) {
|
||||
return this.commandExecutor.onTabComplete(new ForgeCommandSenderContainer(sender), strings);
|
||||
}
|
||||
}
|
@ -0,0 +1,26 @@
|
||||
package com.sekwah.advancedportals.forge.coreconnector.command;
|
||||
|
||||
import com.sekwah.advancedportals.core.commands.CommandTemplate;
|
||||
import com.sekwah.advancedportals.coreconnector.command.CommandRegister;
|
||||
import net.minecraftforge.fml.common.event.FMLServerStartingEvent;
|
||||
|
||||
/**
|
||||
* Register the CommandTemplate files to the appropriate system
|
||||
*/
|
||||
public class ForgeCommandRegister implements CommandRegister {
|
||||
|
||||
private final FMLServerStartingEvent event;
|
||||
|
||||
public ForgeCommandRegister(FMLServerStartingEvent event) {
|
||||
this.event = event;
|
||||
}
|
||||
|
||||
/**
|
||||
* Registers the command to the appropriate system
|
||||
* @param commandName
|
||||
* @param commandExecutor
|
||||
*/
|
||||
public void registerCommand(String commandName, CommandTemplate commandExecutor) {
|
||||
event.registerServerCommand(new ForgeCommandHandler(commandName, commandExecutor));
|
||||
}
|
||||
}
|
@ -0,0 +1,26 @@
|
||||
package com.sekwah.advancedportals.forge.coreconnector.command;
|
||||
|
||||
import com.sekwah.advancedportals.core.entities.PortalLocation;
|
||||
import com.sekwah.advancedportals.coreconnector.container.WorldContainer;
|
||||
|
||||
public class ForgeWorldContainer implements WorldContainer {
|
||||
@Override
|
||||
public void setBlock(PortalLocation location, String material) {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setBlockData(PortalLocation location, byte data) {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getBlock(PortalLocation location) {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public byte getBlockData(PortalLocation location) {
|
||||
return 0;
|
||||
}
|
||||
}
|
@ -0,0 +1,38 @@
|
||||
package com.sekwah.advancedportals.forge.coreconnector.container;
|
||||
|
||||
import com.sekwah.advancedportals.coreconnector.container.CommandSenderContainer;
|
||||
import com.sekwah.advancedportals.coreconnector.container.PlayerContainer;
|
||||
import net.minecraft.command.ICommandSender;
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.util.text.TextComponentString;
|
||||
|
||||
public class ForgeCommandSenderContainer implements CommandSenderContainer {
|
||||
private final ICommandSender sender;
|
||||
|
||||
public ForgeCommandSenderContainer(ICommandSender sender) {
|
||||
this.sender = sender;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void sendMessage(String message) {
|
||||
sender.sendMessage(new TextComponentString(message));
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isOp() {
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public PlayerContainer getPlayerContainer() {
|
||||
if(this.sender.getCommandSenderEntity() instanceof EntityPlayer) {
|
||||
return new ForgePlayerContainer((EntityPlayer) this.sender);
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean hasPermission(String permission) {
|
||||
return false;
|
||||
}
|
||||
}
|
@ -0,0 +1,76 @@
|
||||
package com.sekwah.advancedportals.forge.coreconnector.container;
|
||||
|
||||
import com.sekwah.advancedportals.core.entities.PlayerLocation;
|
||||
import com.sekwah.advancedportals.core.entities.PortalLocation;
|
||||
import com.sekwah.advancedportals.coreconnector.container.PlayerContainer;
|
||||
import com.sekwah.advancedportals.coreconnector.container.WorldContainer;
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
|
||||
import java.util.UUID;
|
||||
|
||||
public class ForgePlayerContainer implements PlayerContainer {
|
||||
|
||||
public ForgePlayerContainer(EntityPlayer sender) {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public UUID getUUID() {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void sendMessage(String message) {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isOp() {
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public PlayerLocation getLoc() {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public double getEyeHeight() {
|
||||
return 0;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void teleport(PlayerLocation location) {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean hasPermission(String permission) {
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public WorldContainer getWorld() {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void sendFakeBlock(PortalLocation blockPos, String material) {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void sendFakeBlockWithData(PortalLocation blockPos, String material, byte data) {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void giveWool(String dyeColor, String itemName, String... itemDescription) {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void giveItem(String material, String itemName, String... itemDescription) {
|
||||
|
||||
}
|
||||
}
|
@ -0,0 +1,10 @@
|
||||
package com.sekwah.advancedportals.forge.coreconnector.info;
|
||||
|
||||
import com.sekwah.advancedportals.coreconnector.info.DataCollector;
|
||||
|
||||
public class ForgeDataCollector implements DataCollector {
|
||||
|
||||
public boolean materialExists(String materialName) {
|
||||
return false;
|
||||
}
|
||||
}
|
@ -35,7 +35,8 @@ public class AdvancedPortalsPlugin extends JavaPlugin {
|
||||
versionInts[i] = Integer.parseInt(versionNums[i]);
|
||||
}
|
||||
this.portalsCore = new AdvancedPortalsCore(this.getDataFolder(),
|
||||
new SpigotInfoLogger(this), new SpigotCommandRegister(this), new SpigotDataCollector(), versionInts);
|
||||
new SpigotInfoLogger(this), new SpigotDataCollector(), versionInts);
|
||||
this.portalsCore.registerCommands(new SpigotCommandRegister(this));
|
||||
}
|
||||
else {
|
||||
this.getLogger().warning("Could not parse mc version from: " + Bukkit.getVersion());
|
||||
|
@ -1,8 +1,8 @@
|
||||
package com.sekwah.advancedportals.coreconnector.spigot.command;
|
||||
package com.sekwah.advancedportals.spigot.coreconnector.command;
|
||||
|
||||
import com.sekwah.advancedportals.core.commands.CommandTemplate;
|
||||
import com.sekwah.advancedportals.coreconnector.command.CommandHandler;
|
||||
import com.sekwah.advancedportals.coreconnector.spigot.container.SpigotCommandSenderContainer;
|
||||
import com.sekwah.advancedportals.spigot.coreconnector.container.SpigotCommandSenderContainer;
|
||||
import org.bukkit.command.Command;
|
||||
import org.bukkit.command.CommandExecutor;
|
||||
import org.bukkit.command.CommandSender;
|
||||
@ -10,10 +10,12 @@ import org.bukkit.command.TabCompleter;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
public class SpigotCommandHandler extends CommandHandler implements CommandExecutor, TabCompleter {
|
||||
public class SpigotCommandHandler implements CommandExecutor, TabCompleter {
|
||||
|
||||
private final CommandTemplate commandExecutor;
|
||||
|
||||
public SpigotCommandHandler(CommandTemplate commandExecutor) {
|
||||
super(commandExecutor);
|
||||
this.commandExecutor = commandExecutor;
|
||||
}
|
||||
|
||||
@Override
|
@ -1,4 +1,4 @@
|
||||
package com.sekwah.advancedportals.coreconnector.spigot.command;
|
||||
package com.sekwah.advancedportals.spigot.coreconnector.command;
|
||||
|
||||
import com.sekwah.advancedportals.core.commands.CommandTemplate;
|
||||
import com.sekwah.advancedportals.coreconnector.command.CommandRegister;
|
@ -1,4 +1,4 @@
|
||||
package com.sekwah.advancedportals.coreconnector.spigot.container;
|
||||
package com.sekwah.advancedportals.spigot.coreconnector.container;
|
||||
|
||||
import com.sekwah.advancedportals.coreconnector.container.CommandSenderContainer;
|
||||
import org.bukkit.command.CommandSender;
|
@ -1,4 +1,4 @@
|
||||
package com.sekwah.advancedportals.coreconnector.spigot.container;
|
||||
package com.sekwah.advancedportals.spigot.coreconnector.container;
|
||||
|
||||
import com.google.inject.Inject;
|
||||
import com.sekwah.advancedportals.core.AdvancedPortalsCore;
|
@ -1,4 +1,4 @@
|
||||
package com.sekwah.advancedportals.coreconnector.spigot.container;
|
||||
package com.sekwah.advancedportals.spigot.coreconnector.container;
|
||||
|
||||
import com.sekwah.advancedportals.core.entities.PortalLocation;
|
||||
import com.sekwah.advancedportals.coreconnector.container.WorldContainer;
|
@ -1,4 +1,4 @@
|
||||
package com.sekwah.advancedportals.coreconnector.spigot.info;
|
||||
package com.sekwah.advancedportals.spigot.coreconnector.info;
|
||||
|
||||
import com.sekwah.advancedportals.coreconnector.info.DataCollector;
|
||||
import org.bukkit.Material;
|
16
src/main/resources/mcmod.info
Normal file
16
src/main/resources/mcmod.info
Normal file
@ -0,0 +1,16 @@
|
||||
[
|
||||
{
|
||||
"modid": "advancedportals",
|
||||
"name": "Advanced Portals",
|
||||
"description": "A server side mod for portals",
|
||||
"version": "${version}",
|
||||
"mcversion": "${mcversion}",
|
||||
"url": "https://www.spigotmc.org/resources/advanced-portals.14356/",
|
||||
"updateUrl": "",
|
||||
"authorList": ["sekwah41"],
|
||||
"credits": "",
|
||||
"logoFile": "",
|
||||
"screenshots": [],
|
||||
"dependencies": []
|
||||
}
|
||||
]
|
Loading…
Reference in New Issue
Block a user