Basic Nick-ing Command Working

This commit is contained in:
youngchief btw ツ 2021-04-22 17:46:49 -07:00
parent 91efeb7c93
commit 11c8228d8c
5 changed files with 51 additions and 10 deletions

View File

@ -7,6 +7,11 @@
plugins {
id 'java'
id 'application'
}
application {
mainClass = 'tk.youngchief.Disguise.Main'
}
group 'tk.youngchief'
@ -35,4 +40,4 @@ sourceSets {
srcDirs = ['src']
}
}
}
}

View File

@ -1,7 +1,11 @@
main: org.spigotmc.testplugin.Test
name: MyPlugin
main: tk.youngchief.Disguise.Main
name: Disguise
version: 1.0.0
description: This plugin does so much stuff it can't be contained!
description: This plugin does cool appearance changes for players
load: STARTUP
author: youngchief@youngchief.tk
website: disguise.youngchief.tk
website: disguise.youngchief.tk
commands:
nick:
description: Hide your username!
usage: /nick <set/clear> <nick to use> <other params>

View File

@ -1,5 +0,0 @@
public class Main {
public static void main(String[] args) {
System.out.println("Hello World");
}
}

View File

@ -0,0 +1,12 @@
package tk.youngchief.Disguise;
import org.bukkit.plugin.java.JavaPlugin;
public class Main extends JavaPlugin {
// public static void main(String[] args) {
@Override
public void onEnable() {
// Register our command "nick" (set an instance of your command class as executor)
this.getCommand("nick").setExecutor(new NickCommand());
}
// }
}

View File

@ -0,0 +1,25 @@
package tk.youngchief.Disguise;
import org.bukkit.command.Command;
import org.bukkit.command.CommandExecutor;
import org.bukkit.command.CommandSender;
import org.bukkit.entity.Player;
public class NickCommand implements CommandExecutor {
// This method is called, when somebody uses our command
@Override
public boolean onCommand(CommandSender sender, Command command, String label, String[] args) {
if (sender instanceof Player) {
Player player = (Player) sender;
if (args[1] == "set") {
player.setDisplayName(args[2]);
player.setPlayerListName(args[2]);
} else if (args[1] == "clear") {
player.setDisplayName(player.getName());
player.setPlayerListName(player.getName());
}
return true;
} else {
return false;
}
}
}