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