The title is 10/10
Thi is a "guide"/tutorial/something that help you understand how "Advanced Reports" works, quite simple and easy to explain
There isn't the command executor thing, why? I am lazy.
If someone could "improve" the code, give me tips, etc, I'd be very happy
Thi is a "guide"/tutorial/something that help you understand how "Advanced Reports" works, quite simple and easy to explain
There isn't the command executor thing, why? I am lazy.
Code:
package eu.hangar;
import java.util.List;
import org.bukkit.Bukkit;
import org.bukkit.ChatColor;
import org.bukkit.command.Command;
import org.bukkit.command.CommandSender;
import org.bukkit.entity.Player;
import org.bukkit.event.Listener;
import org.bukkit.plugin.java.JavaPlugin;
public class Main extends JavaPlugin implements Listener {
public void onEnable(){ //config requirments
getServer().getPluginManager().registerEvents(this, this);
getConfig().options().copyDefaults(true);
saveConfig();
}
List<String> Reports = getConfig().getStringList("Reports"); //creates the list
public boolean onCommand(CommandSender sender, Command cmd, String aliases,
String[] args) {
if (cmd.getName().equalsIgnoreCase("report")) { //command
Player p = (Player) sender;
if (args.length == 0) { //gets the args
if(!p.hasPermission("report.staff")){ //! means no
p.sendMessage(ChatColor.GREEN +""+ ChatColor.STRIKETHROUGH +"= =");
p.sendMessage(ChatColor.BLUE + "Usage:");
p.sendMessage(ChatColor.BLUE + "/report player <playername> will report a player");
p.sendMessage(ChatColor.BLUE + "/report check <playername> will check if the player is reported");
p.sendMessage(ChatColor.GREEN +""+ ChatColor.STRIKETHROUGH +"= =");
}else{ //if they di have perms
p.sendMessage(ChatColor.GREEN +""+ ChatColor.STRIKETHROUGH +"= =");
p.sendMessage(ChatColor.BLUE + "Usage:");
p.sendMessage(ChatColor.BLUE + "/report player <playername> will report a player");
p.sendMessage(ChatColor.BLUE + "/report claim <playername> will remove the report. TO-DO: TP to the player");
p.sendMessage(ChatColor.BLUE + "/report check <playername> will check if the player is reported");
p.sendMessage(ChatColor.GREEN +""+ ChatColor.STRIKETHROUGH +"= =");
}
}
if (args.length == 2) {
Player target = Bukkit.getPlayer(args[1]); //the target, needs to be bungee
if (args[0].equalsIgnoreCase("player")) {
if(target != null){ //checks if the target exists
if (!Reports.contains(args[1])){
p.sendMessage(ChatColor.BLUE + target.getName() + " was reported. Report ID " + target.getUniqueId());
Reports.add(target.getName().toString()); //adds the player to the list, reason of why it is not possible to bypass
}else{ //the player is reported
p.sendMessage(ChatColor.RED + "That player is alredy reported! ");
return true;
}
}else{ //the targte doesn't exists
p.sendMessage(ChatColor.RED + "Invalid player");
}
}
if (args[0].equalsIgnoreCase("check")) {
if(target !=null){
if(args.length !=2){ //missing arguments
p.sendMessage(ChatColor.RED + "Not enough arguments");
}
else if (!Reports.contains(args[1])) {//wheres that player?
p.sendMessage(ChatColor.BLUE + "That player was never reported");
}else{//the target is reported
p.sendMessage(ChatColor.BLUE + "That player was reported");
return true;
}
}else{
p.sendMessage(ChatColor.RED + "Invalid player");
}
}
if (args[0].equalsIgnoreCase("claim")) {
if(p.hasPermission("report.claim")){
if (target != null) {
Reports.remove(args[1]);//bye bye reported
p.sendMessage(ChatColor.BLUE + "Report claimed");
p.teleport(target); //;-;
return true;
}else{
p.sendMessage(ChatColor.RED + "Invalid player");
}
}else{ //perms
p.sendMessage(ChatColor.RED + "Not enough permissions");
}
}
return true;
}
return true;
}
return true;
}}
If someone could "improve" the code, give me tips, etc, I'd be very happy