Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- package me.mttprvst13.modmode;
- import java.util.HashMap;
- import java.util.Map;
- 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.configuration.file.FileConfiguration;
- import org.bukkit.entity.Player;
- import org.bukkit.inventory.ItemStack;
- import org.bukkit.inventory.PlayerInventory;
- public class Commands implements CommandExecutor {
- public Main main;
- Map<Integer, Map<String, Object>> info;
- public String ticketsFile;
- public ConfigAccessor tickets;
- public FileConfiguration ticket;
- @Override
- public boolean onCommand(CommandSender sender, Command cmd, String label,
- String[] args) {
- if (cmd.getName().equalsIgnoreCase("sm")) {
- if (args.length < 1) {
- } else if (args[0].equalsIgnoreCase("on")) {
- } else if (args[0].equalsIgnoreCase("off")) {
- } else if (args[0].equalsIgnoreCase("group")){
- }
- } else if (cmd.getName().equalsIgnoreCase("ticket")) {
- if (args.length < 1) {
- sender.sendMessage(ChatColor.BLUE + "Ticket command help for "
- + ChatColor.GREEN + main.getDescription().getName()
- + " v" + main.getDescription().getVersion()
- + ChatColor.BLUE + "!");
- sender.sendMessage(ChatColor.LIGHT_PURPLE
- + "/ticket submit [reason]" + ChatColor.GOLD + " - "
- + ChatColor.BLUE + "Submit a ticket!");
- sender.sendMessage(ChatColor.LIGHT_PURPLE
- + "/ticket status [id]" + ChatColor.GOLD + " - "
- + ChatColor.BLUE
- + "Check the status of one of your tickets");
- sender.sendMessage(ChatColor.LIGHT_PURPLE + "/ticket mine"
- + ChatColor.GOLD + " - " + ChatColor.BLUE
- + "Get all the IDs of your tickets.");
- } else if (args[0].equalsIgnoreCase("submit")) {
- if (sender instanceof Player) {
- String reason = null;
- for (String word : args) {
- reason = reason + " " + word;
- }
- reason = reason.substring(args[0].length() + 1);
- Player player = (Player) sender;
- Map<String, Object> stuff = new HashMap<String, Object>();
- Map<String, Object> loca = new HashMap<String, Object>();
- Location loc = player.getLocation();
- loca.put("x", loc.getX());
- loca.put("y", loc.getY());
- loca.put("z", loc.getZ());
- loca.put("world", loc.getWorld().getName());
- double health = player.getHealth();
- int hunger = player.getFoodLevel();
- String gm = player.getGameMode().toString();
- float exp = player.getExp();
- PlayerInventory inv = player.getInventory();
- ItemStack[] invcont = inv.getContents();
- ItemStack[] armour = inv.getArmorContents();
- stuff.put("location", loca);
- stuff.put("health", health);
- stuff.put("hunger", hunger);
- stuff.put("gamemode", gm);
- stuff.put("experionce", exp);
- stuff.put("inventory", invcont);
- stuff.put("armour", armour);
- stuff.put("reason", reason);
- stuff.put("playername", player.getName());
- int id = info.size() + 1;
- info.put(id, stuff);
- ticket.set("tickets", info);
- tickets.saveConfig("tickets", ticket);
- player.sendMessage(ChatColor.GREEN
- + "Successfully submitted your ticket with an ID of "
- + Integer.toString(id) + "!");
- } else {
- sender.sendMessage(ChatColor.RED
- + "You must be a player to send that command.");
- }
- } else if (args[0].equalsIgnoreCase("status")) {
- if (args.length < 2) {
- sender.sendMessage(ChatColor.RED + "You must put the ID of the ticket!");
- } else {
- String id = args[1];
- Map<String, Object> stuff = info.get(Integer.parseInt(id));
- if (stuff == null) {
- sender.sendMessage(ChatColor.RED + "There is no ticket with an ID of " + id);
- // sender.sendMessage(info.get(info.size()).get("playername").toString());
- } else if (!sender.isOp() && !stuff.get("playername").toString().equalsIgnoreCase(sender.getName())) {
- sender.sendMessage(ChatColor.RED + "That ticket does not belong to you!");
- } else {
- @SuppressWarnings("unchecked")
- Map<String, Object> location = (Map<String, Object>) stuff.get("location");
- World world = (World) location.get("world");
- sender.sendMessage(ChatColor.GREEN + "Status for ticket: " + id);
- sender.sendMessage("Location X: " + location.get("x"));
- sender.sendMessage("Location Y: " + location.get("y"));
- sender.sendMessage("Location Z: " + location.get("z"));
- sender.sendMessage("Location World: " + world.getName());
- sender.sendMessage("Health: " + stuff.get("health"));
- sender.sendMessage("hunger: " + stuff.get("hunger"));
- sender.sendMessage("EXP: " + stuff.get("experionce"));
- sender.sendMessage("Gamemode: " + stuff.get("gamemode"));
- sender.sendMessage("Reason: " + stuff.get("reason"));
- }
- }
- } else if (args[0].equalsIgnoreCase("mine")) {
- boolean found = false;
- for (Integer key : info.keySet()) {
- Map<String, Object> stuff = info.get(key);
- if (stuff.get("playername").toString().equalsIgnoreCase(sender.getName())) {
- found = true;
- sender.sendMessage(ChatColor.GREEN
- + "Found a ticket for you with an ID of "
- + Integer.toString(key));
- }
- }
- if (found == false) {
- sender.sendMessage(ChatColor.RED
- + "No tickets could be found for you!");
- }
- }
- }
- return false;
- }
- /**
- * @param args
- */
- @SuppressWarnings("unchecked")
- public Commands(Main main) {
- this.main = main;
- tickets = new ConfigAccessor(main);
- ticketsFile = "tickets.yml";
- tickets.createConfig(ticketsFile);
- ticket = tickets.getConfig("tickets");
- if(ticket == null){
- info = new HashMap<Integer, Map<String, Object>>();
- }else{
- info = (Map<Integer, Map<String, Object>>) ticket.getConfigurationSection("tickets");
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement