Clipboard command (for info...)

This commit is contained in:
Sauilitired 2014-10-13 19:40:30 +02:00
parent 2b22ebf3d8
commit a19b13fded
5 changed files with 49 additions and 1 deletions

View File

@ -23,6 +23,7 @@ public enum C {
PASTED("&cThe plot selection was successfully pasted"),
PASTE_FAILED("&cFailed to paste the selection. Reason: &c%s"),
NO_CLIPBOARD("&cYou don't have a selection in your clipboard"),
CLIPBOARD_INFO("&Current Clipboard - Plot ID: &6%id&c, Width: &6%width&c, Total Blocks: &6%total&c"),
/*
* Ratings
*/

View File

@ -17,8 +17,11 @@ public class PlotSelection {
private int width;
private Plot plot;
public PlotSelection(int width, World world, Plot plot) {
this.width = width;
this.plot = plot;
plotBlocks = new PlotBlock[(width * width) * (world.getMaxHeight() - 1)];
@ -57,6 +60,10 @@ public class PlotSelection {
return width;
}
public Plot getPlot() {
return plot;
}
public void paste(World world, Plot plot) {
Location
bot = PlotHelper.getPlotBottomLocAbs(world, plot.getId()),

View File

@ -0,0 +1,39 @@
package com.intellectualcrafters.plot.commands;
import com.intellectualcrafters.plot.C;
import com.intellectualcrafters.plot.PlayerFunctions;
import com.intellectualcrafters.plot.PlotId;
import com.intellectualcrafters.plot.PlotSelection;
import org.bukkit.entity.Player;
import static com.intellectualcrafters.plot.PlotSelection.currentSelection;
/**
* Created by Citymonstret on 2014-10-13.
*/
public class Clipboard extends SubCommand {
public Clipboard() {
super(Command.CLIPBOARD, "View information about your current copy", "clipboard", CommandCategory.INFO);
}
@Override
public boolean execute(Player plr, String... args) {
if(!currentSelection.containsKey(plr.getName())) {
sendMessage(plr, C.NO_CLIPBOARD);
return true;
}
PlotSelection selection = currentSelection.get(plr.getName());
PlotId plotId = selection.getPlot().getId();
int width = selection.getWidth();
int total = selection.getBlocks().length;
String message = C.CLIPBOARD_INFO.s();
message = message.replace("%id", plotId.toString()).replace("%width", width + "").replace("%total", total + "");
PlayerFunctions.sendMessage(plr, message);
return true;
}
}

View File

@ -33,6 +33,7 @@ public enum Command {
*
*/
PASTE("paste"),
CLIPBOARD("clipboard", "cboard"),
COPY("copy"),
/**
*

View File

@ -27,7 +27,7 @@ import java.util.Arrays;
*/
public class MainCommand implements CommandExecutor {
private static SubCommand[] _subCommands = new SubCommand[] { new Claim(), new Paste(), new Copy(), new Auto(), new Home(), new Visit(),
private static SubCommand[] _subCommands = new SubCommand[] { new Claim(), new Paste(), new Copy(), new Clipboard(), new Auto(), new Home(), new Visit(),
new TP(), new Set(), new Clear(), new Delete(), new SetOwner(), new Denied(), new Helpers(), new Trusted(),
new Info(), new list(), new Help(), new Debug(), new Schematic(), new plugin(), new Inventory(),
new Reload(), new Merge(), new Unlink(), new Kick(), new Setup() };