parent
5428730d15
commit
64bc6e88d0
|
@ -3,7 +3,7 @@ plugins {
|
|||
}
|
||||
|
||||
group = 'xyz.daviddgtnt.sc.doctorattend'
|
||||
version = '1.0'
|
||||
version = '1.1'
|
||||
|
||||
repositories {
|
||||
mavenCentral()
|
||||
|
@ -13,5 +13,5 @@ repositories {
|
|||
|
||||
dependencies {
|
||||
implementation 'org.apache.groovy:groovy:4.0.2'
|
||||
compileOnly 'org.spigotmc:spigot-api:1.16.5-R0.1-SNAPSHOT'
|
||||
compileOnly 'org.spigotmc:spigot-api:1.20.1-R0.1-SNAPSHOT'
|
||||
}
|
|
@ -1,56 +1,18 @@
|
|||
package xyz.daviddgtnt.sc.doctorattend;
|
||||
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.ChatColor;
|
||||
import org.bukkit.command.Command;
|
||||
import org.bukkit.command.CommandExecutor;
|
||||
import org.bukkit.command.CommandSender;
|
||||
import org.bukkit.command.ConsoleCommandSender;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.plugin.java.JavaPlugin;
|
||||
|
||||
import java.util.Collection;
|
||||
|
||||
public class DoctorAttend implements CommandExecutor {
|
||||
public class DoctorAttend extends JavaPlugin {
|
||||
@Override
|
||||
public boolean onCommand(CommandSender sender, Command command, String label, String[] args) {
|
||||
if (sender instanceof ConsoleCommandSender) {
|
||||
Bukkit.getLogger().warning("You cannot use this command from the console!");
|
||||
return true;
|
||||
public void onEnable() {
|
||||
Bukkit.getLogger().info("Enabled " + this.getName());
|
||||
this.getCommand("needdoctor").setExecutor(new NeedDoctorCommand());
|
||||
this.getCommand("doctorattend").setExecutor(new DoctorAttendCommand());
|
||||
}
|
||||
|
||||
if (sender.hasPermission("doctorattend.doctor")) {
|
||||
if (args.length < 1) {
|
||||
sender.sendMessage("You need to supply which player you are attending to!");
|
||||
return true;
|
||||
}
|
||||
|
||||
Player player = Bukkit.getPlayer(args[0]);
|
||||
|
||||
if (player == null) {
|
||||
sender.sendMessage(ChatColor.RED + args[0] + " isn't online!");
|
||||
return true;
|
||||
}
|
||||
|
||||
ConsoleCommandSender commandSender = Bukkit.getConsoleSender();
|
||||
Bukkit.dispatchCommand(commandSender, "warp hospital " + sender.getName());
|
||||
this.notifyDoctors(sender, player);
|
||||
} else {
|
||||
sender.sendMessage(ChatColor.RED + "You need to be a doctor to attend to patients!");
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
private void notifyDoctors(CommandSender sender, Player player) {
|
||||
String senderName = sender.getName();
|
||||
String playerName = player.getName();
|
||||
|
||||
Collection<? extends Player> players = Bukkit.getOnlinePlayers();
|
||||
|
||||
for (Player p : players) {
|
||||
if (p.hasPermission("doctorattend.doctor")) {
|
||||
p.sendMessage(ChatColor.RED + senderName + " is attending to " + playerName + ".");
|
||||
}
|
||||
}
|
||||
@Override
|
||||
public void onDisable() {
|
||||
Bukkit.getLogger().info("Disabled " + this.getName());
|
||||
}
|
||||
}
|
||||
|
|
|
@ -0,0 +1,56 @@
|
|||
package xyz.daviddgtnt.sc.doctorattend;
|
||||
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.ChatColor;
|
||||
import org.bukkit.command.Command;
|
||||
import org.bukkit.command.CommandExecutor;
|
||||
import org.bukkit.command.CommandSender;
|
||||
import org.bukkit.command.ConsoleCommandSender;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
import java.util.Collection;
|
||||
|
||||
public class DoctorAttendCommand implements CommandExecutor {
|
||||
@Override
|
||||
public boolean onCommand(CommandSender sender, Command command, String label, String[] args) {
|
||||
if (sender instanceof ConsoleCommandSender) {
|
||||
Bukkit.getLogger().warning("You cannot use this command from the console!");
|
||||
return true;
|
||||
}
|
||||
|
||||
if (sender.hasPermission("doctorattend.doctor")) {
|
||||
if (args.length < 1) {
|
||||
sender.sendMessage("You need to supply which player you are attending to!");
|
||||
return true;
|
||||
}
|
||||
|
||||
Player player = Bukkit.getPlayer(args[0]);
|
||||
|
||||
if (player == null) {
|
||||
sender.sendMessage(ChatColor.RED + args[0] + " isn't online!");
|
||||
return true;
|
||||
}
|
||||
|
||||
ConsoleCommandSender commandSender = Bukkit.getConsoleSender();
|
||||
Bukkit.dispatchCommand(commandSender, "warp hospital " + sender.getName());
|
||||
this.notifyDoctors(sender, player);
|
||||
} else {
|
||||
sender.sendMessage(ChatColor.RED + "You need to be a doctor to attend to patients!");
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
private void notifyDoctors(CommandSender sender, Player player) {
|
||||
String senderName = sender.getName();
|
||||
String playerName = player.getName();
|
||||
|
||||
Collection<? extends Player> players = Bukkit.getOnlinePlayers();
|
||||
|
||||
for (Player p : players) {
|
||||
if (p.hasPermission("doctorattend.doctor")) {
|
||||
p.sendMessage(ChatColor.RED + senderName + " is attending to " + playerName + ".");
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
|
@ -1,18 +0,0 @@
|
|||
package xyz.daviddgtnt.sc.doctorattend;
|
||||
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.plugin.java.JavaPlugin;
|
||||
|
||||
public class Main extends JavaPlugin {
|
||||
@Override
|
||||
public void onEnable() {
|
||||
Bukkit.getLogger().info("Enabled " + this.getName());
|
||||
this.getCommand("needdoctor").setExecutor(new NeedDoctor());
|
||||
this.getCommand("doctorattend").setExecutor(new DoctorAttend());
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onDisable() {
|
||||
Bukkit.getLogger().info("Disabled " + this.getName());
|
||||
}
|
||||
}
|
|
@ -10,7 +10,7 @@ import org.bukkit.entity.Player;
|
|||
|
||||
import java.util.Collection;
|
||||
|
||||
public class NeedDoctor implements CommandExecutor {
|
||||
public class NeedDoctorCommand implements CommandExecutor {
|
||||
@Override
|
||||
public boolean onCommand(CommandSender sender, Command command, String label, String[] args) {
|
||||
Player player;
|
|
@ -1,7 +1,7 @@
|
|||
name: SCDoctorAttend
|
||||
version: 1.0
|
||||
version: 1.1
|
||||
author: DavidDGTNT
|
||||
main: xyz.daviddgtnt.sc.doctorattend.Main
|
||||
main: xyz.daviddgtnt.sc.doctorattend.DoctorAttend
|
||||
api-version: '1.20'
|
||||
softdepend:
|
||||
- Essentials
|
||||
|
|
Loading…
Reference in New Issue