60 lines
2.3 KiB
Java
60 lines
2.3 KiB
Java
|
package xyz.etztech.minecraftmanager.command;
|
||
|
|
||
|
import org.apache.commons.lang.StringUtils;
|
||
|
import org.bukkit.ChatColor;
|
||
|
import org.bukkit.Location;
|
||
|
import org.bukkit.World;
|
||
|
import org.bukkit.command.Command;
|
||
|
import org.bukkit.command.CommandExecutor;
|
||
|
import org.bukkit.command.CommandSender;
|
||
|
import org.bukkit.entity.Player;
|
||
|
import xyz.etztech.minecraftmanager.MCMAPI;
|
||
|
import xyz.etztech.minecraftmanager.MCMResponse;
|
||
|
import xyz.etztech.minecraftmanager.MinecraftManager;
|
||
|
|
||
|
public class CommandTicket implements CommandExecutor {
|
||
|
|
||
|
MinecraftManager plugin;
|
||
|
|
||
|
public CommandTicket(MinecraftManager plugin) {
|
||
|
this.plugin = plugin;
|
||
|
}
|
||
|
|
||
|
@Override
|
||
|
public boolean onCommand(CommandSender sender, Command command, String base, String[] args) {
|
||
|
if (!(sender instanceof Player)) {
|
||
|
sender.sendMessage(ChatColor.RED + "The console cannot submit tickets.");
|
||
|
return true;
|
||
|
}
|
||
|
Player player = (Player) sender;
|
||
|
if (sender.hasPermission("minecraftmanager.ticket")) {
|
||
|
if (args.length == 0) {
|
||
|
sender.sendMessage(ChatColor.RED + "You cannot send a ticket with no message.");
|
||
|
return true;
|
||
|
}
|
||
|
Location location = player.getLocation();
|
||
|
String x = String.valueOf(location.getBlockX());
|
||
|
String y = String.valueOf(location.getBlockY());
|
||
|
String z = String.valueOf(location.getBlockZ());
|
||
|
World.Environment env = location.getWorld().getEnvironment();
|
||
|
String world = "";
|
||
|
if (World.Environment.NORMAL == env) {
|
||
|
world = "O";
|
||
|
} else if (World.Environment.NETHER == env) {
|
||
|
world = "N";
|
||
|
} else if (World.Environment.THE_END == env) {
|
||
|
world = "E";
|
||
|
}
|
||
|
MCMResponse response = new MCMResponse(MCMAPI.postTicket(player.getUniqueId().toString(),
|
||
|
StringUtils.join(args, " "), x, y, z, world));
|
||
|
sender.sendMessage(response.getMCMessage());
|
||
|
} else {
|
||
|
sender.sendMessage(ChatColor.RED + "You do not have permission to submit a ticket.");
|
||
|
sender.sendMessage(ChatColor.RED + "If you were submitting a ticket about not being able to submit a ticket, that is known as irony.");
|
||
|
}
|
||
|
|
||
|
return true;
|
||
|
}
|
||
|
|
||
|
}
|