First ever plugin I made (/Welcome)
This commit is contained in:
@@ -3,7 +3,7 @@ plugins {
|
||||
}
|
||||
|
||||
group = 'io.github.itzispyder'
|
||||
version = '(YourPluginVersion)'
|
||||
version = ''
|
||||
|
||||
repositories {
|
||||
mavenCentral()
|
||||
|
||||
@@ -30,17 +30,18 @@ public final class ExamplePlugin extends JavaPlugin {
|
||||
*/
|
||||
@Override
|
||||
public void onEnable() {
|
||||
// Files
|
||||
getConfig().options().copyDefaults();
|
||||
saveDefaultConfig();
|
||||
// Plugin startup logic
|
||||
log.info("Example plugin has loaded! (" + getDescription().getVersion() + ")");
|
||||
starter = Config.Plugin.getPrefix() + " ";
|
||||
|
||||
// Files
|
||||
getConfig().options().copyDefaults();
|
||||
saveDefaultConfig();
|
||||
|
||||
|
||||
// Commands -> BE SURE TO REGISTER ANY NEW COMMANDS IN PLUGIN.YML (src/main/java/resources/plugin.yml)!
|
||||
getCommand("example").setExecutor(new CommandExample());
|
||||
getCommand("example").setTabCompleter(new CommandExample.Tabs());
|
||||
getCommand("welcome").setExecutor(new CommandExample());
|
||||
getCommand("welcome").setTabCompleter(new CommandExample.Tabs());
|
||||
|
||||
// Events
|
||||
manager.registerEvents(new ExampleEvent(),this);
|
||||
@@ -61,6 +62,6 @@ public final class ExamplePlugin extends JavaPlugin {
|
||||
* @return an instance of this plugin
|
||||
*/
|
||||
public static Plugin getInstance() {
|
||||
return manager.getPlugin("ExamplePlugin");
|
||||
return manager.getPlugin("SlashWelcome");
|
||||
}
|
||||
}
|
||||
|
||||
@@ -4,11 +4,15 @@
|
||||
|
||||
package io.github.itzispyder.exampleplugin.commands;
|
||||
|
||||
import io.github.itzispyder.exampleplugin.ExamplePlugin;
|
||||
import io.github.itzispyder.exampleplugin.exceptions.CmdExHandler;
|
||||
import io.github.itzispyder.exampleplugin.server.util.ServerUtils;
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.command.Command;
|
||||
import org.bukkit.command.CommandExecutor;
|
||||
import org.bukkit.command.CommandSender;
|
||||
import org.bukkit.command.TabCompleter;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
@@ -21,7 +25,15 @@ public class CommandExample implements CommandExecutor {
|
||||
@Override
|
||||
public boolean onCommand(CommandSender sender, Command command, String label, String[] args) {
|
||||
try {
|
||||
sender.sendMessage("You've execute an example command!");
|
||||
Player P = (Player) sender;
|
||||
Player W = Bukkit.getPlayer(args[0]);
|
||||
for (int i = 0; i < 1; i++) {
|
||||
P.chat("§bWelcome " + W.getName() + "!");
|
||||
Bukkit.getScheduler().scheduleSyncDelayedTask(ExamplePlugin.getInstance(),() -> {
|
||||
P.chat("§bDo /daily for a key and /kit for some free gear!");
|
||||
}, 20);
|
||||
|
||||
}
|
||||
return true;
|
||||
} catch (Exception ex) {
|
||||
CmdExHandler handler = new CmdExHandler(ex,command);
|
||||
@@ -39,7 +51,7 @@ public class CommandExample implements CommandExecutor {
|
||||
public List<String> onTabComplete(CommandSender sender, Command command, String alias, String[] args) {
|
||||
List<String> list = new ArrayList<>();
|
||||
switch (args.length) {
|
||||
case 1 -> list.add("test");
|
||||
case 1 -> list.addAll(ServerUtils.listPlayers());
|
||||
}
|
||||
list.removeIf(s -> !s.toLowerCase().contains(args[args.length - 1].toLowerCase()));
|
||||
return list;
|
||||
|
||||
@@ -1,8 +1,8 @@
|
||||
name: ExamplePlugin
|
||||
name: SlashWelcome
|
||||
version: '${version}'
|
||||
main: io.github.itzispyder.exampleplugin.ExamplePlugin
|
||||
api-version: 1.17
|
||||
authors: [ YourNameHere ]
|
||||
authors: [ TheTrouper ]
|
||||
description: An example plugin template for Spigot/Paper.
|
||||
website: https://ItziSpyder.github.io/
|
||||
permissions:
|
||||
@@ -10,8 +10,7 @@ permissions:
|
||||
description: An example permission
|
||||
default: op
|
||||
commands:
|
||||
example:
|
||||
welcome:
|
||||
description: An example command.
|
||||
usage: /example
|
||||
permission: example.commands
|
||||
permission-message: You do not have permission!
|
||||
Reference in New Issue
Block a user