本文整理汇总了Java中com.sk89q.worldedit.bukkit.selections.Selection类的典型用法代码示例。如果您正苦于以下问题:Java Selection类的具体用法?Java Selection怎么用?Java Selection使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
Selection类属于com.sk89q.worldedit.bukkit.selections包,在下文中一共展示了Selection类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: processWhoEditedThisAreaCmd
import com.sk89q.worldedit.bukkit.selections.Selection; //导入依赖的package包/类
boolean processWhoEditedThisAreaCmd(String[] args, CommandSender sender) {
if (args.length == 0) {
Selection selection = getWESelection(sender);
if (selection == null) {
return true;
} else {
if (!validateArea(selection.getArea(), sender)) {
return true;
}
plugin.meode.asyncQuerySellection(selection.getMinimumPoint(),
selection.getMaximumPoint(), (Player) sender, null);
return true;
}
}
return false;
}
示例2: isProtected
import com.sk89q.worldedit.bukkit.selections.Selection; //导入依赖的package包/类
private boolean isProtected(Block block, Game game) {
boolean ret = false;
Location loc = block.getLocation();
if (block.getType() == Material.MOB_SPAWNER) {
ret = true;
} else {
if (game.restaurationArea != null && !game.restaurationArea.contains(loc)) {
ret = true;
} else {
for (Selection sel : game.mapData.protectedAreas) {
loc.setWorld(sel.getWorld());
if (sel.contains(loc)) {
ret = true;
break;
}
}
}
}
return ret;
}
示例3: execute
import com.sk89q.worldedit.bukkit.selections.Selection; //导入依赖的package包/类
@Override protected void execute() {
Mine m = Mines.i.mm.getMine(args[1]);
if (m == null) {
sender.sendMessage(MessageUtil.get("mines.notFound"));
return;
}
Selection s =
Mines.i.getWE().getSelection(Prison.i().playerList.getPlayer(sender.getName()));
if (s == null) {
sender.sendMessage(MessageUtil.get("mines.makeWESel"));
return;
}
m.minX = s.getMinimumPoint().getBlockX();
m.minY = s.getMinimumPoint().getBlockY();
m.minZ = s.getMinimumPoint().getBlockZ();
m.maxX = s.getMaximumPoint().getBlockX();
m.maxY = s.getMaximumPoint().getBlockY();
m.maxZ = s.getMaximumPoint().getBlockZ();
m.save();
Mines.i.mm.mines.remove(args[1]);
Mines.i.mm.addMine(m);
sender.sendMessage(MessageUtil.get("mines.redefineSuccess", m.name));
}
示例4: createLobbyFromSelection
import com.sk89q.worldedit.bukkit.selections.Selection; //导入依赖的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());
}
示例5: createArenaFromSelection
import com.sk89q.worldedit.bukkit.selections.Selection; //导入依赖的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);
}
示例6: onCommand
import com.sk89q.worldedit.bukkit.selections.Selection; //导入依赖的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;
}
示例7: getWorldEditSelection
import com.sk89q.worldedit.bukkit.selections.Selection; //导入依赖的package包/类
private CuboidSelection getWorldEditSelection(CommandSender sender) {
if (!(sender instanceof Player)) {
sender.sendMessage(ChatColor.RED + "Only players can use this command.");
return null;
}
Player player = (Player)sender;
Selection selection = plugin.worldEdit.getSelection(player);
if ((selection == null) || !(selection instanceof CuboidSelection)) {
sender.sendMessage(ChatColor.RED + "Please, select a cuboid using WorldEdit.");
return null;
}
return (CuboidSelection) selection;
}
示例8: teleportRandomlyInRegion
import com.sk89q.worldedit.bukkit.selections.Selection; //导入依赖的package包/类
public void teleportRandomlyInRegion(Player p, World w, Selection selection) {
List<Block> blocks = blockList(p, selection);
long seed = System.nanoTime();
Collections.shuffle(blocks, new Random(seed));
Block b = blocks.get(coordinates.getRandomNumberInRange(0, blocks.size() - 1, p));
int y = b.getLocation().getWorld().getHighestBlockYAt(b.getLocation());
Location finalLoc = new Location(b.getWorld(), b.getX() + 0.5, y, b.getZ() + 0.5);
p.teleport(finalLoc);
}
示例9: checkSelection
import com.sk89q.worldedit.bukkit.selections.Selection; //导入依赖的package包/类
public boolean checkSelection(Player p, PlotPlayer pp, int modifier, long max, Cancellable e) {
final Selection selection = PlotSquared.worldEdit.getSelection(p);
if (selection == null) {
return true;
}
final BlockVector pos1 = selection.getNativeMinimumPoint().toBlockVector();
final BlockVector pos2 = selection.getNativeMaximumPoint().toBlockVector();
HashSet<RegionWrapper> mask = WEManager.getMask(pp);
RegionWrapper region = new RegionWrapper(pos1.getBlockX(), pos2.getBlockX(), pos1.getBlockZ(), pos2.getBlockZ());
if (Settings.REQUIRE_SELECTION) {
String arg = null;
if (!WEManager.regionContains(region, mask)) {
arg = "pos1 + pos2";
}
else if (!WEManager.maskContains(mask, pos1.getBlockX(), pos1.getBlockZ())) {
arg = "pos1";
}
else if (!WEManager.maskContains(mask, pos2.getBlockX(), pos2.getBlockZ())) {
arg = "pos2";
}
if (arg != null) {
e.setCancelled(true);
MainUtil.sendMessage(pp, C.REQUIRE_SELECTION_IN_MASK, arg);
if (Permissions.hasPermission(pp, "plots.worldedit.bypass")) {
MainUtil.sendMessage(pp, C.WORLDEDIT_BYPASS);
}
return true;
}
}
if (!WEManager.regionContains(region, mask)) {
MainUtil.sendMessage(pp, C.REQUIRE_SELECTION_IN_MASK, "pos1 + pos2");
e.setCancelled(true);
if (Permissions.hasPermission(pp, "plots.worldedit.bypass")) {
MainUtil.sendMessage(pp, C.WORLDEDIT_BYPASS);
}
return true;
}
long volume = Math.abs((pos1.getBlockX() - pos2.getBlockX()) * (pos1.getBlockY() - pos2.getBlockY()) * (pos1.getBlockZ() - pos2.getBlockZ())) * modifier;
return checkVolume(pp, volume, max, e);
}
示例10: checkConditions
import com.sk89q.worldedit.bukkit.selections.Selection; //导入依赖的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;
}
示例11: getWESelection
import com.sk89q.worldedit.bukkit.selections.Selection; //导入依赖的package包/类
private Selection getWESelection(CommandSender sender) {
if (plugin.we == null) {
sender.sendMessage(ChatColor.RED + "This command must be used with WordlEdit and it is not installed.");
sender.sendMessage(ChatColor.RED + "Instead you can use the radius version of this command by typing it with a single slash.");
return null;
}
Selection selection = plugin.we.getSelection((Player) sender);
if (selection == null) {
sender.sendMessage(ChatColor.RED + "Make a region selection first.");
}
return selection;
}
示例12: processEditedCmd
import com.sk89q.worldedit.bukkit.selections.Selection; //导入依赖的package包/类
boolean processEditedCmd(String[] args, CommandSender sender, boolean undo) {
if (args.length != 1) {
return false;
}
String playerName = args[0];
if (!plugin.getServer().getOfflinePlayer(playerName).hasPlayedBefore()) {
if (plugin.getServer().getPlayer(playerName) == null) {
sender.sendMessage(ChatColor.RED + "The player \"".concat(playerName).concat("\" never played on this server."));
return true;
}
}
Selection selection = getWESelection(sender);
if (selection == null) {
return true;
}
if (!validateArea(selection.getArea(), sender)) {
return true;
}
plugin.meode.asyncEditSellection(selection.getMinimumPoint(),
selection.getMaximumPoint(), (Player) sender, playerName, undo);
return true;
}
示例13: getSelectionList
import com.sk89q.worldedit.bukkit.selections.Selection; //导入依赖的package包/类
private static TreeSet<Selection> getSelectionList(ConfigurationSection cs, World world) {
TreeSet<Selection> result = new TreeSet<>(new Tools.SelectionComparator());
for (String area : cs.getKeys(false)) {
Vector min = new Vector(cs.getInt(area + ".min.x", 0), cs.getInt(area + ".min.y", 0), cs.getInt(area + ".min.z", 0));
Vector max = new Vector(cs.getInt(area + ".max.x", 0), cs.getInt(area + ".max.y", 0), cs.getInt(area + ".max.z", 0));
result.add(new CuboidSelection(world, min, max));
}
return result;
}
示例14: addRedNoAccessArea
import com.sk89q.worldedit.bukkit.selections.Selection; //导入依赖的package包/类
public boolean addRedNoAccessArea(World world, Selection area) {
MapData mapData = maps.get(world.getName());
if (mapData == null) {
return false;
}
if (mapData.redInaccessibleAreas == null) {
mapData.redInaccessibleAreas = new TreeSet<>(new Tools.SelectionComparator());
}
mapData.redInaccessibleAreas.add(new CuboidSelection(area.getWorld(), area.getNativeMaximumPoint(), area.getNativeMinimumPoint()));
return true;
}
示例15: isRedNoAccessArea
import com.sk89q.worldedit.bukkit.selections.Selection; //导入依赖的package包/类
public boolean isRedNoAccessArea(World world, Selection area) {
MapData mapData = maps.get(world.getName());
if (mapData == null) {
return false;
}
if (mapData.redInaccessibleAreas == null) {
return false;
}
return mapData.redInaccessibleAreas.contains(area);
}