本文整理汇总了Java中com.sk89q.worldedit.bukkit.WorldEditPlugin.getSelection方法的典型用法代码示例。如果您正苦于以下问题:Java WorldEditPlugin.getSelection方法的具体用法?Java WorldEditPlugin.getSelection怎么用?Java WorldEditPlugin.getSelection使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类com.sk89q.worldedit.bukkit.WorldEditPlugin
的用法示例。
在下文中一共展示了WorldEditPlugin.getSelection方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: createLobbyFromSelection
import com.sk89q.worldedit.bukkit.WorldEditPlugin; //导入方法依赖的package包/类
public void createLobbyFromSelection(Player p, Game game){
WorldEditPlugin worldEdit = plugin.getWorldEdit();
Selection selection = worldEdit.getSelection(p);
if(selection == null){
MessageManager.getInstance().sendFMessage("error.noselection", p);
return;
}
Location pos1 = selection.getMaximumPoint();//Max
Location pos2 = selection.getMinimumPoint();//Min
game.setLobby(new Lobby(pos1, pos2));
YamlConfiguration config = SettingsManager.getInstance().getArenaConfig(game.getId());
config.set("lobby.world", pos1.getWorld().getName());
config.set("lobby.pos1.x", pos1.getBlockX());
config.set("lobby.pos1.y", pos1.getBlockY());
config.set("lobby.pos1.z", pos1.getBlockZ());
config.set("lobby.pos2.x", pos2.getBlockX());
config.set("lobby.pos2.y", pos2.getBlockY());
config.set("lobby.pos2.z", pos2.getBlockZ());
SettingsManager.getInstance().saveArenaConfig(game.getId());
MessageManager.getInstance().sendFMessage("info.createlobby", p, "arena-" + game.getId());
}
示例2: createArenaFromSelection
import com.sk89q.worldedit.bukkit.WorldEditPlugin; //导入方法依赖的package包/类
public void createArenaFromSelection(Player p){
WorldEditPlugin we = plugin.getWorldEdit();
Selection selection = we.getSelection(p);
if(selection == null){
msg.sendFMessage("error.noselection", p);
return;
}
Location pos1 = selection.getMaximumPoint();
Location pos2 = selection.getMinimumPoint();
int id = settingsManager.getNextArenaID();
YamlConfiguration config = SettingsManager.getInstance().createArenaConfig(id, pos1, pos2);
if(config == null){
MessageManager.getInstance().sendFMessage("error.nextid", p,
"type-"+MessageManager.getInstance().getFValue("words.arena"));
return;
}
SettingsManager.getInstance().incrementNextArenaId();
addArena(id);
msg.sendFMessage("info.create", p, "arena-" + id);
}
示例3: onCommand
import com.sk89q.worldedit.bukkit.WorldEditPlugin; //导入方法依赖的package包/类
public boolean onCommand(CommandSender sender, Command command, String label, String[] args)
{
if (!(sender instanceof Player))
{
sender.sendMessage(ChatColor.RED + "This command is only executable by players.");
return true;
}
if (args.length < 2)
{
sender.sendMessage(ChatColor.RED + "Usage: " + getUsage(label));
return true;
}
Faction targetFaction = this.plugin.getFactionManager().getFaction(args[1]);
if (!(targetFaction instanceof ClaimableFaction))
{
sender.sendMessage(ChatColor.RED + "Claimable faction named " + args[1] + " not found.");
return true;
}
Player player = (Player)sender;
WorldEditPlugin worldEditPlugin = this.plugin.getWorldEdit();
if (worldEditPlugin == null)
{
sender.sendMessage(ChatColor.RED + "WorldEdit must be installed to set claim areas.");
return true;
}
Selection selection = worldEditPlugin.getSelection(player);
if (selection == null)
{
sender.sendMessage(ChatColor.RED + "You must make a WorldEdit selection to do this.");
return true;
}
ClaimableFaction claimableFaction = (ClaimableFaction)targetFaction;
if (claimableFaction.addClaim(new Claim(claimableFaction, selection.getMinimumPoint(), selection.getMaximumPoint()), sender)) {
sender.sendMessage(ChatColor.YELLOW + "Successfully claimed this land for " + ChatColor.RED + targetFaction.getName() + ChatColor.YELLOW + '.');
}
return true;
}
示例4: checkConditions
import com.sk89q.worldedit.bukkit.WorldEditPlugin; //导入方法依赖的package包/类
public boolean checkConditions(Player p) {
WorldEditPlugin worldEdit = (WorldEditPlugin) Bukkit.getServer().getPluginManager().getPlugin("WorldEdit");
Selection selection = worldEdit.getSelection(p);
if (selection != null) {
World world = selection.getWorld();
if (selection.getHeight() == 1) {
if (world.equals(getWorld())) {
Location min = selection.getMinimumPoint();
Location max = selection.getMaximumPoint();
FloorPoints.set(min, max, Config.arenaName);
this.cfg.set("configuration.floor.length", Integer.valueOf(selection.getLength()));
this.cfg.set("configuration.floor.width", Integer.valueOf(selection.getWidth()));
this.floorLength = selection.getLength();
this.floorWidth = selection.getWidth();
p.sendMessage(BlockParty.messageManager.SETUP_FLOOR_SET.replace("$ARENANAME$", Config.arenaName));
return true;
}
p.sendMessage(BlockParty.messageManager.SETUP_FLOOR_ERROR_SAME_WORLD);
} else {
p.sendMessage(BlockParty.messageManager.SETUP_FLOOR_ERROR_MIN_HEIGHT);
}
} else {
p.sendMessage(BlockParty.messageManager.SETUP_FLOOR_ERROR_WORLD_EDIT_SELECT);
}
return false;
}
示例5: getSelection
import com.sk89q.worldedit.bukkit.WorldEditPlugin; //导入方法依赖的package包/类
public static Location[] getSelection(Player p) {
WorldEditPlugin we = getWorldEdit();
Selection sel = we.getSelection(p);
if (sel == null) {
return null;
}
Location max = sel.getMaximumPoint();
Location min = sel.getMinimumPoint();
return new Location[]{min, max};
}
示例6: getSelection
import com.sk89q.worldedit.bukkit.WorldEditPlugin; //导入方法依赖的package包/类
@Override
public IRegionSelection getSelection(Player player) {
PreCon.notNull(player);
// Check that World Edit is installed
if (!isWorldEditInstalled()) {
return null;
}
WorldEditPlugin plugin = (WorldEditPlugin)_wePlugin;
Selection sel;
synchronized (_sync) {
// Check for World Edit selection
if ((sel = plugin.getSelection(player)) == null) {
return null;
}
// Make sure both points are selected
if (sel.getMaximumPoint() == null || sel.getMinimumPoint() == null) {
return null;
}
if (!sel.getMaximumPoint().getWorld().equals(sel.getMinimumPoint().getWorld())) {
return null;
}
return new SimpleRegionSelection(sel.getMinimumPoint(), sel.getMaximumPoint());
}
}
示例7: addWarp
import com.sk89q.worldedit.bukkit.WorldEditPlugin; //导入方法依赖的package包/类
/**
* Add a multi-point warp
*
* @param player The player adding the warp
* @param warpname The name of the warp to add to
*/
@Override
public void addWarp(Player player, String warpname) {
if (warpname.equalsIgnoreCase("checkpoint")) {
WorldEditPlugin worldEdit = MineKart.getInstance().getWorldEditPlugin();
Selection selection = worldEdit.getSelection(player);
if (selection == null) {
LangUtils.sendMessage(player, "course.checkpoint.error.worldedit");
return;
}
try {
this.checkPoints.add(selection.getRegionSelector().getRegion().clone());
} catch (Exception ex) {
LangUtils.sendMessage(player, "course.create.error.region");
return;
}
LangUtils.sendMessage(player, "course.checkpoint.success");
outputRequirements(player);
save();
return;
}
// if it's not a checkpoint pass it on
super.addWarp(player, warpname);
outputRequirements(player);
save();
}
示例8: addWarp
import com.sk89q.worldedit.bukkit.WorldEditPlugin; //导入方法依赖的package包/类
/**
* Add a multi-point warp
*
* @param player The player adding the warp
* @param warpname The name of the warp to add to
*/
@Override
public void addWarp(Player player, String warpname) {
if (warpname.equalsIgnoreCase("checkpoint")) {
WorldEditPlugin worldEdit = MineKart.getInstance().getWorldEditPlugin();
Selection selection = worldEdit.getSelection(player);
if (selection == null) {
LangUtils.sendMessage(player, "course.checkpoint.error.worldedit");
return;
}
try {
this.checkPoints.add(selection.getRegionSelector().getRegion().clone());
} catch (Exception ex) {
LangUtils.sendMessage(player, "course.create.error.region");
return;
}
LangUtils.sendMessage(player, "course.checkpoint.success");
outputRequirements(player);
save();
return;
}
// if it's not a checkpoint pass it on
super.addWarp(player, warpname);
outputRequirements(player);
save();
}
示例9: onCommand
import com.sk89q.worldedit.bukkit.WorldEditPlugin; //导入方法依赖的package包/类
@Override
public boolean onCommand(CommandSender sender, Command command, String label, String[] args) {
if (!(sender instanceof Player)) {
sender.sendMessage(ChatColor.RED + "Only players can set event claim areas");
return true;
}
if (args.length < 2) {
sender.sendMessage(ChatColor.RED + "Usage: " + getUsage(label));
return true;
}
WorldEditPlugin worldEditPlugin = plugin.getWorldEdit();
if (worldEditPlugin == null) {
sender.sendMessage(ChatColor.RED + "WorldEdit must be installed to set event claim areas.");
return true;
}
Player player = (Player) sender;
Selection selection = worldEditPlugin.getSelection(player);
if (selection == null) {
sender.sendMessage(ChatColor.RED + "You must make a WorldEdit selection to do this.");
return true;
}
if (selection.getWidth() < MIN_EVENT_CLAIM_AREA || selection.getLength() < MIN_EVENT_CLAIM_AREA) {
sender.sendMessage(ChatColor.RED + "Event claim areas must be at least " + MIN_EVENT_CLAIM_AREA + 'x' + MIN_EVENT_CLAIM_AREA + '.');
return true;
}
Faction faction = plugin.getFactionManager().getFaction(args[1]);
if (!(faction instanceof EventFaction)) {
sender.sendMessage(ChatColor.RED + "There is not an event faction named '" + args[1] + "'.");
return true;
}
((EventFaction) faction).setClaim(new Cuboid(selection.getMinimumPoint(), selection.getMaximumPoint()), player);
sender.sendMessage(ChatColor.YELLOW + "Updated the claim for event " + faction.getName() + ChatColor.YELLOW + '.');
return true;
}
示例10: createArena
import com.sk89q.worldedit.bukkit.WorldEditPlugin; //导入方法依赖的package包/类
public void createArena(Player p, String arenaname, String gamename) {
if(!cfg.contains("Games." + gamename)) {
p.sendMessage(MessageHandler.getMessage("game-not-found").replace("%0%", gamename));
return;
}
if(cfg.contains("Games." + gamename + ".Arenas." + arenaname)) {
p.sendMessage(MessageHandler.getMessage("arena-already-exists").replace("%0%", arenaname).replace("%1%", gamename));
return;
}
WorldEditPlugin we = SurvivalGames.getWorldEdit();
Selection sel = null;
if(we != null) {
com.sk89q.worldedit.bukkit.selections.Selection s = we.getSelection(p);
if(s == null || s.getMinimumPoint() == null || s.getMaximumPoint() == null) {
p.sendMessage(MessageHandler.getMessage("arena-no-selection").replace("%0%", "/sg arena tools"));
return;
}
sel = new Selection(s.getMinimumPoint(), s.getMaximumPoint());
} else {
if(SelectionListener.selections.containsKey(p.getName())) {
sel = SelectionListener.selections.get(p.getName());
if(sel == null || !sel.isFullDefined()) {
p.sendMessage(MessageHandler.getMessage("arena-no-selection").replace("%0%", "/sg arena tools"));
return;
}
} else {
p.sendMessage(MessageHandler.getMessage("arena-no-selection").replace("%0%", "/sg arena tools"));
return;
}
}
int chesttype = SurvivalGames.instance.getConfig().getInt("Default.Arena.Chests.TypeID");
int chestdata = SurvivalGames.instance.getConfig().getInt("Default.Arena.Chests.Data");
String path = "Games." + gamename + ".Arenas." + arenaname + ".";
cfg.set(path + "Enabled", false);
cfg.set(path + "Grace-Period", SurvivalGames.instance.getConfig().getInt("Default.Arena.Grace-Period"));
cfg.set(path + "Min", Util.serializeLocation(sel.getMinimumLocation(), false));
cfg.set(path + "Max", Util.serializeLocation(sel.getMaximumLocation(), false));
cfg.set(path + "Allowed-Blocks", SurvivalGames.instance.getConfig().getIntegerList("Default.Arena.Allowed-Blocks"));
cfg.set(path + "Chest.TypeID", chesttype);
cfg.set(path + "Chest.Data", chestdata);
cfg.set(path + "Spawns", new ArrayList<String>());
cfg.set(path + "Enable-Deathmatch", false);
cfg.set(path + "Player-Deathmatch", SurvivalGames.instance.getConfig().getInt("Default.Arena.Player-Deathmatch-Start"));
cfg.set(path + "Auto-Deathmatch", SurvivalGames.instance.getConfig().getInt("Default.Arena.Automaticly-Deathmatch-Time"));
cfg.set(path + "Deathmatch-Spawns", new ArrayList<String>());
cfg.set(path + "Money-on-Kill", SurvivalGames.instance.getConfig().getDouble("Default.Money-on-Kill"));
cfg.set(path + "Money-on-Win", SurvivalGames.instance.getConfig().getDouble("Default.Money-on-Win"));
cfg.set(path + "Midnight-chest-refill", SurvivalGames.instance.getConfig().getBoolean("Default.Midnight-chest-refill"));
SurvivalGames.saveDataBase();
selectArena(p, arenaname, gamename);
p.sendMessage(MessageHandler.getMessage("arena-created").replace("%0%", arenaname).replace("%1%", gamename));
if(SurvivalGames.instance.getConfig().getBoolean("Enable-Arena-Reset"))
save(p);
p.sendMessage(MessageHandler.getMessage("arena-check").replace("%0%", "/sg arena check"));
return;
}
示例11: onRightClick
import com.sk89q.worldedit.bukkit.WorldEditPlugin; //导入方法依赖的package包/类
@EventHandler(priority = EventPriority.HIGHEST)
public void onRightClick(PlayerInteractEvent e) {
Action eAction = e.getAction();
Player p = e.getPlayer();
if(eAction.equals(Action.RIGHT_CLICK_BLOCK)) {
if (p.getItemInHand().getType().equals(Material.CLAY_BALL)) {
if (p.getItemInHand().getItemMeta().hasDisplayName()) {
if (p.getItemInHand().getItemMeta().getDisplayName().equals("Mine Creator")) {
mineLoc.put(p, e.getClickedBlock().getLocation());
//initialise WorldEdit
worldEditPlugin = (WorldEditPlugin) Bukkit.getServer().getPluginManager().getPlugin("WorldEdit");
if(worldEditPlugin == null){
p.sendMessage("Error: WorldEdit is null.");
}
Selection sel = worldEditPlugin.getSelection(p);
//allow proceed if selection is of correct type
if (sel instanceof CuboidSelection) {
mineMin.put(p, new Vector(sel.getNativeMinimumPoint().getBlockX(),
sel.getNativeMinimumPoint().getBlockY(),
sel.getNativeMinimumPoint().getBlockZ()));
mineMax.put(p, new Vector(sel.getNativeMaximumPoint().getBlockX(),
sel.getNativeMaximumPoint().getBlockY(),
sel.getNativeMaximumPoint().getBlockZ()));
//make sure the Entrance block is inside the WorlEdit selection
if(sel.contains(e.getClickedBlock().getLocation())) {
p.sendMessage("Mine entrance donated at: " +
mineLoc.get(p).getX() + ", " +
mineLoc.get(p).getY() + ", " +
mineLoc.get(p).getZ() + ".");
p.sendMessage("Use '/mine create (name) to create mine");
} else {
p.sendMessage(ChatColor.RED + "Entrance is not within WorldEdit Selection");
}
}else{
p.sendMessage(ChatColor.DARK_RED + "Invalid Selection!");
}
}
}
}
}
}
示例12: run
import com.sk89q.worldedit.bukkit.WorldEditPlugin; //导入方法依赖的package包/类
@Override
public void run(DuelArena duelArena, CommandSender sender, String subCmd, String[] args) {
if (!(sender instanceof Player)) {
Util.sendMsg(sender, NO_CONSOLE);
return;
}
if (args.length < 1) {
Util.sendMsg(sender, ChatColor.GREEN + "Usage: /dueladmin create <arenaname>");
return;
}
Player p = (Player) sender;
Location pos1 = null;
Location pos2 = null;
WorldEditPlugin worldEdit = (WorldEditPlugin) Bukkit.getServer().getPluginManager().getPlugin("WorldEdit");
Selection selection = worldEdit.getSelection(p);
if (selection != null) {
World world = selection.getWorld();
pos1 = selection.getMinimumPoint();
pos2 = selection.getMaximumPoint();
} else {
Util.sendMsg(p, ChatColor.RED + "You have not selected a region, please select one first!");
return;
}
String arenaName = getValue(args, 0, "Arena");
DuelManager dm = plugin.getDuelManager();
for (DuelArena da : dm.getDuelArenas()) {
if (da.getName().equalsIgnoreCase(arenaName)) {
Util.sendMsg(sender, ChatColor.RED + "There is already a duel arena with the name " + arenaName + ".");
return;
}
}
DuelArena newArena = new DuelArena(arenaName, pos1, pos2);
dm.addDuelArena(newArena);
Util.sendMsg(sender, ChatColor.GREEN + "Created a new Duel arena called " + ChatColor.GOLD + arenaName + ".");
}
示例13: executeForPlayer
import com.sk89q.worldedit.bukkit.WorldEditPlugin; //导入方法依赖的package包/类
@Override
protected boolean executeForPlayer(final Player player, final TypeSafeList<String> args) {
PlayerInfo playerInfo = infoManager.getPlayerInfo(player);
WorldEditPlugin worldEditPlugin = (WorldEditPlugin) Bukkit.getPluginManager().getPlugin("WorldEdit");
Selection selection = worldEditPlugin.getSelection(player);
if (selection.getArea() == 0) {
if (playerInfo.isReceivingTextFeedback) {
player.sendMessage("No blocks were selected for reinforcement.");
}
return true;
}
Iterable<BlockVector> selector;
if (!(selection instanceof CuboidSelection || selection instanceof Polygonal2DRegion)) {
try {
selector = selection.getRegionSelector().getRegion();
} catch (IncompleteRegionException e) {
e.printStackTrace();
return false;
}
} else {
if (playerInfo.isReceivingTextFeedback) {
player.sendMessage("Invalid selection.");
}
return false;
}
int reinforceCount = 0;
for (BlockVector blockVector : selector) {
Block block = selection.getWorld().getBlockAt(blockVector.getBlockX(), blockVector.getBlockY(), blockVector.getBlockZ());
if (!reinforcementManager.isReinforceable(block)) {
continue;
}
Bukkit.getServer().getPluginManager().callEvent(new BlockReinforceEvent(block, player.getName(), true));
reinforceCount++;
}
if (playerInfo.isReceivingTextFeedback) {
if (reinforceCount == 0) {
player.sendMessage(ChatColor.GRAY + "You failed to reinforce any blocks.");
}
player.sendMessage(ChatColor.GRAY + "Successfully reinforced " + reinforceCount + " blocks.");
}
return true;
}
示例14: setup
import com.sk89q.worldedit.bukkit.WorldEditPlugin; //导入方法依赖的package包/类
/**
* Setup the racecourse. Setting up the bounds of the arena based on
* player world edit seleciton.
*
* @param player The player who is setting up the course
* @return True if the location is within the course bounds, false
* otherwise.
*/
public boolean setup(Player player, String name) {
WorldEditPlugin worldEdit = MineKart.getInstance().getWorldEditPlugin();
Selection selection = worldEdit.getSelection(player);
if (selection == null) {
LangUtils.sendMessage(player, "course.create.error.worldedit");
return false;
}
// Set the arena bounds from the selection
world = selection.getWorld();
try {
bounds = selection.getRegionSelector().getRegion().clone();
} catch (IncompleteRegionException e) {
LangUtils.sendMessage(player, "course.create.error.region");
return false;
}
this.name = name;
this.readyblock = Material.IRON_BLOCK;
this.mountType = MountType.HORSE;
this.mountTypeData = MineKart.getInstance().getMountDataRegistry().getMountData(mountType);
this.fileConfiguration = new File(MineKart.getRacecourseFolder() + File.separator + this.name + "." + this.type + ".yml");
if (!this.fileConfiguration.exists()) {
try {
if (!this.fileConfiguration.createNewFile()) {
LangUtils.sendMessage(player, "course.create.error.config", this.name);
LangUtils.sendMessage(player, "course.create.error.config.loc", this.fileConfiguration.getAbsolutePath());
return false;
}
} catch (Exception ex) {
LangUtils.sendMessage(player, "course.create.error.config", this.name);
LangUtils.sendMessage(player, "course.create.error.config.loc", this.fileConfiguration.getAbsolutePath());
return false;
}
}
this.race = new RaceSinglePlayer();
this.race.setCourse(this);
return true;
}
示例15: onCommand
import com.sk89q.worldedit.bukkit.WorldEditPlugin; //导入方法依赖的package包/类
/**
* @param player Player
* @param args String[]
* @return boolean
*/
@Override
public boolean onCommand(Player player, String[] args) {
String aname = args[0];
ArenaRegion AER;
WorldEditPlugin wm = new WEManager().getWEP();
Selection S = wm.getSelection(player);
Vector cen = null;
try {
cen = new Vector(S.getRegionSelector().getRegion().getCenter());
} catch (IncompleteRegionException e) {
player.sendMessage(SkyApi.getMessageManager().getErrorMessage("command.message.noSelection"));
SkyApi.getCMsg().SERVE("Error setting Arena Region, WorldEdit selection not set correctly");
e.printStackTrace();
return true;
}
ArenaConfig ac = SkyApi.getSm().getArenaConfig();
Integer last = ac.getConfig().getInt("arena.lastId");
last += 1;
org.bukkit.util.Vector rmax = new org.bukkit.util.Vector(S.getMaximumPoint().getBlockX(), S.getMaximumPoint().getBlockY(), S.getMaximumPoint().getBlockZ());
org.bukkit.util.Vector rmin = new org.bukkit.util.Vector(S.getMinimumPoint().getBlockX(), S.getMinimumPoint().getBlockY(), S.getMinimumPoint().getBlockZ());
org.bukkit.util.Vector radmin = null;
radmin = new org.bukkit.util.Vector(cen.getBlockX() + 0.5, S.getMaximumPoint().getBlockY() + 2, cen.getBlockZ() + 0.5);
List<org.bukkit.util.Vector> chunks = new ArrayList<>();
chunks.add(S.getMaximumPoint().toVector());
chunks.get(0).setY(radmin.getY());
AER = new ArenaRegion(rmin, rmax, radmin, last, player.getWorld().getName(), aname, new SerializedLocation(S.getMaximumPoint()),
new SerializedLocation(S.getMinimumPoint()), new SerializedLocation(radmin.toLocation(player.getWorld())));
ArenaIO AIO = new ArenaIO();
if (AIO.newCreate(AER, chunks)) {
SkyApi.getCMsg().INFO("Region has been created");
// player.sendMessage("A new arena has been created and stored");
} else {
SkyApi.getCMsg().SERVE("Error creating or saving new Arena");
player.sendMessage(SkyApi.getMessageManager().getErrorMessage("command.message.failedToCreateArena"));
return true;
}
if (SkyApi.getSCB().getConfig().getString("serverStatus").equalsIgnoreCase(ServerStatus.SETARENA.name())) {
SkyApi.getSCB().getConfig().set("serverStatus", ServerStatus.SETAREASPAWNS.name());
SkyApi.getSCB().saveConfig();
}
String cm = SkyApi.getMessageManager().getAdminMessage("command.message.createArenaSucceeded");
String ct;
ct = cm.replace("%nn%", last.toString());
player.sendMessage(ct);
player.sendMessage("");
player.sendMessage(SkyApi.getMessageManager().getMessage("setup.setspawns"));
return true;
}