Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- package me.Geekenex.creativetour;
- import java.util.Arrays;
- import java.util.List;
- import org.bukkit.Bukkit;
- import org.bukkit.Location;
- import org.bukkit.World;
- import org.bukkit.command.Command;
- import org.bukkit.command.CommandSender;
- import org.bukkit.entity.Player;
- import org.bukkit.plugin.java.JavaPlugin;
- import com.intellectualcrafters.plot.api.PlotAPI;
- import com.intellectualcrafters.plot.object.Plot;
- public class creative_tour extends JavaPlugin {
- PlotAPI API;
- @SuppressWarnings("deprecation")
- @Override
- public void onEnable() {
- API = new PlotAPI(null);
- }
- @Override
- public void onDisable() {
- }
- public Plot getplot2(Player p) {
- Plot plot = API.getPlot(p.getLocation());
- return plot;
- }
- public String plottostring(Plot plot){
- String msg = plot.toString();
- msg = msg.replace(";", ",");
- return msg;
- }
- public void tptoplot(Player p, Plot plot) {
- double x = API.getHomeLocation(plot).getX();
- double y = API.getHomeLocation(plot).getY();
- double z = API.getHomeLocation(plot).getZ();
- World world = API.getHomeLocation(plot).getWorld();
- Location loc = new Location(world,x,y,z);
- p.teleport(loc);
- }
- public Plot stringtoplot(String word){
- List<String> items = Arrays.asList(word.split("\\s*,\\s*"));
- Bukkit.broadcastMessage(items.toString());
- String name = items.get(0);
- World world= Bukkit.getWorld(name);
- int one = Integer.valueOf(items.get(1));
- int two =Integer.valueOf(items.get(2));
- @SuppressWarnings("deprecation")
- Plot plot = API.getPlot(world, one, two);
- return plot;
- }
- public boolean onCommand(CommandSender sender, Command cmd, String label, String[] args) {
- Player player = (Player) sender;
- if (cmd.getName().equalsIgnoreCase("tour") && sender instanceof Player) {
- if(args.length == 0) {
- player.sendMessage("Specify a tour");
- } else {
- if (args[0].equalsIgnoreCase(args[0])) {
- if (getConfig().contains(args[0])) {
- player.sendMessage("Welcome to the tour of " + args[0]);
- }
- if (!args[0].equalsIgnoreCase("add") && !args[0].equalsIgnoreCase("remove")) {
- if(!getConfig().contains(args[0])) {
- player.sendMessage("That tour doesn't exist!");
- }
- }
- }
- //creative manager command add plot to list
- if (args[0].equalsIgnoreCase("add") && player.hasPermission("creative")) {
- if (args.length == 2) {
- if (!args[1].equalsIgnoreCase("add") && !args[1].equalsIgnoreCase("remove")) {
- List<String> playerlist = getConfig().getStringList(args[1]);
- if (!playerlist.contains(plottostring(getplot2(player)))) {
- playerlist.add(plottostring(getplot2(player)));
- if (playerlist.size() == 1) {
- player.sendMessage(playerlist + " is now in " + args[1]);
- }
- if (playerlist.size() != 1) {
- player.sendMessage(playerlist + " are now in " + args[1]);
- }
- }
- this.getConfig().set(args[1], playerlist);
- saveConfig();
- reloadConfig();
- }
- }
- else {
- player.sendMessage("Please use /tour add <tourtype>.");
- }
- }
- //creative manager command remove plot from list
- if (args[0].equalsIgnoreCase("remove") && player.hasPermission("creative")) {
- if (args.length == 2) {
- List<String> playerlist = getConfig().getStringList(args[1]);
- if (playerlist.size() != 0) {
- if (playerlist.contains(plottostring(getplot2(player)))) {
- playerlist.remove(plottostring(getplot2(player)));
- if (playerlist.size() == 1) {
- player.sendMessage(playerlist + " is now in " + args[1]);
- }
- if (playerlist.size() > 1) {
- player.sendMessage(playerlist + " are now in " + args[1]);
- }
- this.getConfig().set(args[1], playerlist);
- if (playerlist.isEmpty()) {
- this.getConfig().set(args[1],null);
- player.sendMessage(args[1] + " was empty and was removed");
- }
- }
- }
- saveConfig();
- reloadConfig();
- }
- else {
- player.sendMessage("Please use /tour remove <tourtype>.");
- }
- }
- }
- return true;
- }
- return false;
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement