Starting to add spigot loading

This commit is contained in:
sekwah 2018-01-22 21:36:53 +00:00
parent 64971a7173
commit 06c85f1848
5 changed files with 104 additions and 2 deletions

54
Resources/plugin.yml Normal file
View File

@ -0,0 +1,54 @@
main: com.sekwah.advancedportals.spigot.AdvancedPortalsPlugin
name: AdvancedPortals
version: 1.0.0
author: sekwah41
description: An advanced portals plugin for bukkit.
commands:
advancedportals:
description: The main command for the advanced portals
aliases: [portals, aportals, portal, ap]
usage: /<command>
destination:
description: Can be used to access portal destinations.
aliases: [desti]
usage: /<command>
permissions:
advancedportals.*:
description: Gives access to all commands
default: op
children:
advancedportals.createportal: true
advancedportals.portal: true
advancedportals.build: true
advancedportals.desti: true
advancedportals.createportal:
description: Allows you to create portals
default: op
advancedportals.createportal.commandlevel.*:
description: Gives access to all level raisers
default: false
children:
advancedportals.createportal.commandlevel.op: true
advancedportals.createportal.commandlevel.perms: true
advancedportals.createportal.commandlevel.console: true
advancedportals.createportal.commandlevel.op:
description: Allows you to increase the users level temporaily to op
default: false
advancedportals.createportal.commandlevel.perms:
description: Allows you to increase the users level temporaily to have all perms
default: false
advancedportals.createportal.commandlevel.console:
description: Executes command in the console
default: false
advancedportals.portal:
description: Allows use of portal commands
default: op
advancedportals.build:
description: Allows you to build in the portal regions
default: op
advancedportals.desti:
description: Gives access to all desti commands
default: op
advancedportals.warp.*:
description: Access to all warps (not really used tbh)
default: true

View File

@ -0,0 +1,30 @@
package com.sekwah.advancedportals.coreconnector.command;
import com.sekwah.advancedportals.core.commands.CommandTemplate;
import com.sekwah.advancedportals.coreconnector.container.CommandSenderContainer;
import org.bukkit.command.Command;
import org.bukkit.command.CommandExecutor;
import org.bukkit.command.CommandSender;
import org.bukkit.command.TabCompleter;
import java.util.List;
public class CommandHandler implements CommandExecutor, TabCompleter {
private final CommandTemplate commandExecutor;
public CommandHandler(CommandTemplate commandExecutor) {
this.commandExecutor = commandExecutor;
}
@Override
public boolean onCommand(CommandSender commandSender, Command command, String s, String[] args) {
this.commandExecutor.onCommand(new CommandSenderContainer(commandSender), command.getName(), args);
return true;
}
@Override
public List<String> onTabComplete(CommandSender commandSender, Command command, String s, String[] args) {
return this.commandExecutor.onTabComplete(new CommandSenderContainer(commandSender), args);
}
}

View File

@ -1,18 +1,25 @@
package com.sekwah.advancedportals.coreconnector.command;
import com.sekwah.advancedportals.core.commands.CommandTemplate;
import com.sekwah.advancedportals.spigot.AdvancedPortalsPlugin;
/**
* Register the CommandTemplate files to the appropriate system
*/
public class CommandRegister {
private final AdvancedPortalsPlugin plugin;
public CommandRegister(AdvancedPortalsPlugin plugin) {
this.plugin = plugin;
}
/**
* Registers the command to the appropriate system
* @param commandName
* @param commandExecutor
*/
public void registerCommand(String commandName, CommandTemplate commandExecutor) {
this.plugin.getCommand(commandName).setExecutor(new CommandHandler(commandExecutor));
}
}

View File

@ -1,8 +1,17 @@
package com.sekwah.advancedportals.coreconnector.container;
import com.sekwah.advancedportals.core.util.Lang;
import org.bukkit.command.CommandSender;
public class CommandSenderContainer {
private final CommandSender sender;
public CommandSenderContainer(CommandSender commandSender) {
this.sender = commandSender;
}
public void sendMessage(String message) {
sender.sendMessage(message);
}
}

View File

@ -2,6 +2,7 @@ package com.sekwah.advancedportals.spigot;
import com.sekwah.advancedportals.core.AdvancedPortalsCore;
import com.sekwah.advancedportals.core.util.DataStorage;
import com.sekwah.advancedportals.coreconnector.command.CommandRegister;
import org.bukkit.plugin.java.JavaPlugin;
public class AdvancedPortalsPlugin extends JavaPlugin {
@ -9,7 +10,8 @@ public class AdvancedPortalsPlugin extends JavaPlugin {
private AdvancedPortalsCore portalsCore;
public void onEnable() {
this.portalsCore = new AdvancedPortalsCore(new DataStorage(this.getDataFolder()), new SpigotInfoLogger(this));
this.portalsCore = new AdvancedPortalsCore(new DataStorage(this.getDataFolder()),
new SpigotInfoLogger(this), new CommandRegister(this));
}
public void onDisable() {