Java 类org.bukkit.material.MaterialData 实例源码

项目:Arcadia-Spigot    文件:BombardmentGame.java   
private void fireCannon(Location cannon, Location target) {
    FallingBlock entity = cannon.getWorld().spawnFallingBlock(cannon, new MaterialData(Material.COAL_BLOCK));
    this.playParticles(entity.getLocation());
    entity.setGravity(true);
    entity.setDropItem(false);
    entity.setHurtEntities(false);
    entity.setInvulnerable(true);
    this.moveToward(entity, target, 2D);
    new BukkitRunnable() {
        public void run() {
            if(entity.isDead()) {
                this.cancel();
            } else {
                entity.setTicksLived(1);
            }
        }
    }.runTaskTimer(this.getAPI().getPlugin(), 0, 20L);
    totalCannonShots++;
}
项目:Arcadia-Spigot    文件:ColorShuffleGame.java   
public void shuffleColors() {
    for (int x = 0; x < squaresPerSide; x++) {
        for (int z = 0; z < squaresPerSide; z++) {
            colors[x][z] = fetchRandomColor();
        }
    }
    for (int x = 0; x < squaresPerSide * squareSizes; x++) {
        int offsetX = location.getBlockX() + x;
        int squareX = x / 3;
        for (int z = 0; z < squaresPerSide * squareSizes; z++) {
            int offsetZ = location.getBlockZ() + z;
            int squareZ = z / 3;
            MaterialData materialData = colors[squareX][squareZ];
            Block block = new Location(location.getWorld(), offsetX, location.getY(), offsetZ).getBlock();
            block.setType(materialData.getItemType());
            block.setData(materialData.getData());
        }
    }
}
项目:ProjectAres    文件:CoreFactory.java   
public CoreFactoryImpl(String name,
                       @Nullable Boolean required,
                       boolean visible,
                       TeamFactory owner,
                       ProximityMetric proximityMetric,
                       Region region,
                       MaterialData material,
                       int leakLevel,
                       boolean modeChanges) {

    super(name, required, visible, Optional.of(owner), proximityMetric);
    this.region = region;
    this.material = material;
    this.leakLevel = leakLevel;
    this.modeChanges = modeChanges;
}
项目:Debuggery    文件:OutputFormatterTest.java   
@Test
public void testBlockState() {
    MaterialData data = new MaterialData(Material.DIAMOND, (byte) 12);
    byte lightLevel = 5;
    Location loc = TestLocation.LOC_ZERO;

    BlockState blockState = new TestBlockState(data, lightLevel, loc);

    String out = OutputFormatter.getOutput(blockState);

    assertNotNull(out);
    assertTrue(out.contains(data.toString()));
    assertTrue(out.contains(String.valueOf(data.getItemTypeId())));
    assertTrue(out.contains(String.valueOf(lightLevel)));
    assertTrue(out.contains(loc.toString()));
}
项目:bskyblock    文件:IslandGuard.java   
/**
 * Drops the Enderman's block when he dies if he has one
 *
 * @param e
 */
@EventHandler(priority = EventPriority.LOW, ignoreCancelled = true)
public void onEndermanDeath(final EntityDeathEvent e) {
    if (DEBUG) {
        plugin.getLogger().info(e.getEventName());
    }
    if (!Settings.endermanDeathDrop)
        return;
    if (!Util.inWorld(e.getEntity())) {
        return;
    }
    if (!(e.getEntity() instanceof Enderman)) {
        // plugin.getLogger().info("Not an Enderman!");
        return;
    }
    // Get the block the enderman is holding
    Enderman ender = (Enderman) e.getEntity();
    MaterialData m = ender.getCarriedMaterial();
    if (m != null && !m.getItemType().equals(Material.AIR)) {
        // Drop the item
        // plugin.getLogger().info("Dropping item " + m.toString());
        e.getEntity().getWorld().dropItemNaturally(e.getEntity().getLocation(), m.toItemStack(1));
    }
}
项目:Slimefun4-Chinese-Version    文件:XPCollector.java   
protected void constructMenu(BlockMenuPreset preset)
    {
        int ai[];
        int k = (ai = border).length;
        for(int j = 0; j < k; j++)
        {
            int i = ai[j];
            preset.addItem(i, new CustomItem(new MaterialData(Material.STAINED_GLASS_PANE, (byte)10), " ", new String[0]), new me.mrCookieSlime.CSCoreLibPlugin.general.Inventory.ChestMenu.MenuClickHandler() {

                final XPCollector this$0;

                public boolean onClick(Player arg0, int arg1, ItemStack arg2, ClickAction clickaction)
                {
                    return false;
                }


            {
                this$0 = XPCollector.this;
                super();
            }
            }
);
        }

    }
项目:Slimefun4-Chinese-Version    文件:CropGrowthAccelerator.java   
protected void constructMenu(BlockMenuPreset preset)
    {
        int ai[];
        int k = (ai = border).length;
        for(int j = 0; j < k; j++)
        {
            int i = ai[j];
            preset.addItem(i, new CustomItem(new MaterialData(Material.STAINED_GLASS_PANE, (byte)9), " ", new String[0]), new me.mrCookieSlime.CSCoreLibPlugin.general.Inventory.ChestMenu.MenuClickHandler() {

                final CropGrowthAccelerator this$0;

                public boolean onClick(Player arg0, int arg1, ItemStack arg2, ClickAction clickaction)
                {
                    return false;
                }


            {
                this$0 = CropGrowthAccelerator.this;
                super();
            }
            }
);
        }

    }
项目:Slimefun4-Chinese-Version    文件:AutoBreeder.java   
protected void constructMenu(BlockMenuPreset preset)
    {
        int ai[];
        int k = (ai = border).length;
        for(int j = 0; j < k; j++)
        {
            int i = ai[j];
            preset.addItem(i, new CustomItem(new MaterialData(Material.STAINED_GLASS_PANE, (byte)9), " ", new String[0]), new me.mrCookieSlime.CSCoreLibPlugin.general.Inventory.ChestMenu.MenuClickHandler() {

                final AutoBreeder this$0;

                public boolean onClick(Player arg0, int arg1, ItemStack arg2, ClickAction clickaction)
                {
                    return false;
                }


            {
                this$0 = AutoBreeder.this;
                super();
            }
            }
);
        }

    }
项目:Slimefun4-Chinese-Version    文件:TrashCan.java   
private void constructMenu(BlockMenuPreset preset)
    {
        int ai[];
        int k = (ai = border).length;
        for(int j = 0; j < k; j++)
        {
            int i = ai[j];
            preset.addItem(i, new CustomItem(new MaterialData(Material.STAINED_GLASS_PANE, (byte)14), " ", new String[0]), new me.mrCookieSlime.CSCoreLibPlugin.general.Inventory.ChestMenu.MenuClickHandler() {

                final TrashCan this$0;

                public boolean onClick(Player arg0, int arg1, ItemStack arg2, ClickAction clickaction)
                {
                    return false;
                }


            {
                this$0 = TrashCan.this;
                super();
            }
            }
);
        }

    }
项目:ProjectAres    文件:BlockDropsMatchModule.java   
@EventHandler(priority = EventPriority.MONITOR, ignoreCancelled = true)
public void onBlockPunch(BlockPunchEvent event) {
    final MatchPlayer player = getMatch().getPlayer(event.getPlayer());
    if(player == null) return;

    RayBlockIntersection hit = event.getIntersection();

    BlockDrops drops = getRuleSet().getDrops(event, hit.getBlock().getState(), player.getParticipantState());
    if(drops == null) return;

    MaterialData oldMaterial = hit.getBlock().getState().getData();
    replaceBlock(drops, hit.getBlock(), player);

    // Play a fake punching effect if the block is punchable. Use raw particles instead of
    // playBlockBreakEffect so the position is precise rather than in the block center.
    Object packet = NMSHacks.blockCrackParticlesPacket(oldMaterial, false, hit.getPosition(), new Vector(), 0, 5);
    for(MatchPlayer viewer : getMatch().getPlayers()) {
        if(viewer.getBukkit().getEyeLocation().toVector().distanceSquared(hit.getPosition()) < 16 * 16) {
            NMSHacks.sendPacket(viewer.getBukkit(), packet);
        }
    }
    NMSHacks.playBlockPlaceSound(hit.getBlock().getWorld(), hit.getPosition(), oldMaterial.getItemType(), 1);

    dropObjects(drops, player, hit.getPosition().toLocation(hit.getBlock().getWorld()), 1d, false);
}
项目:ProjectAres    文件:MaterialCounter.java   
public Iterable<MaterialData> materials() {
    return new Iterable<MaterialData>() {
        @Override
        public Iterator<MaterialData> iterator() {
            return new Iterator<MaterialData>() {
                final TIntIterator iter = counts.keySet().iterator();

                @Override
                public boolean hasNext() {
                    return iter.hasNext();
                }

                @Override
                public MaterialData next() {
                    return decodeMaterial(iter.next());
                }

                @Override
                public void remove() {
                    iter.remove();
                }
            };
        }
    };
}
项目:ProjectAres    文件:Renewable.java   
boolean renew(BlockVector pos) {
    MaterialData material;
    if(isOriginalShuffleable(pos)) {
        // If position is shuffled, first try to find a nearby shuffleable block to swap with.
        // This helps to make shuffling less predictable when the material deficit is small or
        // out of proportion to the original distribution of materials.
        material = sampleShuffledMaterial(pos);

        // If that fails, choose a random material, weighted by the current material deficits.
        if(material == null) material = chooseShuffledMaterial();
    } else {
        material = snapshot().getOriginalMaterial(pos);
    }

    if(material != null) {
        return renew(pos, material);
    }

    return false;
}
项目:ProjectAres    文件:DestroyableMatchModule.java   
@EventHandler(priority = EventPriority.HIGHEST, ignoreCancelled = true)
public void processBlockDamage(BlockDamageEvent event) {
    if(this.match.getWorld() != event.getBlock().getWorld()) return;

    Block block = event.getBlock();
    MaterialData material = block.getState().getData();
    MatchPlayer player = this.match.getPlayer(event.getPlayer());

    for(Destroyable destroyable : this.destroyables) {
        if(player != null &&
           player.getParty() == destroyable.getOwner() &&
           !destroyable.isDestroyed() &&
           destroyable.getBlockRegion().contains(block) &&
           destroyable.hasMaterial(material)) {

            event.setCancelled(true);
            player.sendWarning(new TranslatableComponent("match.destroyable.damageOwn"), true);
        }
    }
}
项目:ProjectAres    文件:Destroyable.java   
protected boolean isAffectedByBlockReplacementRules() {
    if (this.blockDropsRuleSet.getRules().isEmpty()) {
        return false;
    }

    for(Block block : this.blockRegion.getBlocks(match.getWorld())) {
        for(MaterialData material : this.materials) {
            BlockDrops drops = this.blockDropsRuleSet.getDrops(block.getState(), material);
            if(drops != null && drops.replacement != null && this.hasMaterial(drops.replacement)) {
                return true;
            }
        }
    }

    return false;
}
项目:Arcadia-Spigot    文件:ElectricFloorGame.java   
@Override
public void onPreStart() {
    Location spawnLocation = Utils.parseLocation((String) this.getGameMap().fetchSetting("startPosition"));
    for(Player player : Bukkit.getOnlinePlayers()) {
        if(!this.getAPI().getGameManager().isAlive(player)) continue;
        player.teleport(spawnLocation);
        player.setGameMode(GameMode.ADVENTURE);
    }
    List<MaterialData> floorData = new ArrayList<MaterialData>();
    for(String temp : ((String) this.getGameMap().fetchSetting("blocks")).split(",")) {
        floorData.add(Utils.parseMaterialData(temp));
    }
    this.floorOrder = new FloorOrder(floorData);
}
项目:Arcadia-Spigot    文件:ElectricFloorGame.java   
private void updateBlock(Player player, Block block) {
    if(this.getAPI().getGameManager().isAlive(player)) {
        if(block.getType() == Material.AIR
                && block.getRelative(BlockFace.DOWN).getType() != Material.AIR) {
            block = block.getRelative(BlockFace.DOWN);
        }
        MaterialData currentData = floorOrder.currentData(block);
        if(floorOrder.match(block, floorOrder.last())) {
            this.getAPI().getGameManager().setAlive(player, false);
        } else {
            if(floorOrder.contains(block)) {
                if(!changePending.contains(block)) {
                    final Block finalBlock = block;
                    final MaterialData next = floorOrder.nextData(block);
                    changePending.add(block);
                    new BukkitRunnable() {
                        public void run() {
                            if(changePending.contains(finalBlock)) {
                                finalBlock.setTypeIdAndData(next.getItemTypeId(), next.getData(), false);
                                changePending.remove(finalBlock);
                            }
                        }
                    }.runTaskLater(this.getAPI().getPlugin(), 10L);
                }
            }
        }
    }
}
项目:ProjectAres    文件:NMSHacks.java   
/**
 * Test if the given tool is capable of "efficiently" mining the given block.
 *
 * Derived from CraftBlock.itemCausesDrops()
 */
public static boolean canMineBlock(MaterialData blockMaterial, org.bukkit.inventory.ItemStack tool) {
    if(!blockMaterial.getItemType().isBlock()) {
        throw new IllegalArgumentException("Material '" + blockMaterial + "' is not a block");
    }

    net.minecraft.server.Block nmsBlock = CraftMagicNumbers.getBlock(blockMaterial.getItemType());
    net.minecraft.server.Item nmsTool = tool == null ? null : CraftMagicNumbers.getItem(tool.getType());

    return nmsBlock != null && (nmsBlock.getBlockData().getMaterial().isAlwaysDestroyable() ||
                                (nmsTool != null && nmsTool.canDestroySpecialBlock(nmsBlock.getBlockData())));
}
项目:ProjectAres    文件:BlockMaterialMap.java   
@Override
Entry<BlockVector, MaterialData> castEntry(Object obj) {
    if(!(obj instanceof Entry)) return null;
    Entry entry = (Entry) obj;
    if(entry.getKey() instanceof BlockVector && entry.getValue() instanceof MaterialData) {
        return (Entry<BlockVector, MaterialData>) entry;
    } else {
        return null;
    }
}
项目:Arcadia-Spigot    文件:FloorOrder.java   
public MaterialData nextData(Block block) {
    if(current.containsKey(block)) {
        if((current.get(block)+1) < materialData.size()) {
            current.put(block, (current.get(block)+1));
        }
    } else {
        current.put(block, 1);
    }
    return materialData.get(current.get(block));
}
项目:ProjectAres    文件:MaterialUtils.java   
public static TIntSet encodeMaterialSet(Collection<?> materials) {
    TIntSet set = new TIntHashSet(materials.size());
    for(Object material : materials) {
        if(material instanceof MaterialData) {
            set.add(encodeMaterial((MaterialData) material));
        }
    }
    return set;
}
项目:Arcadia-Spigot    文件:WorldListener.java   
@EventHandler
public void onBlockBreak(BlockBreakEvent event) {
    ArcadiaAPI api = Arcadia.getPlugin(Arcadia.class).getAPI();
    if(!api.getGameManager().isAlive(event.getPlayer())) event.setCancelled(true);
    if(api.getGameManager().getCurrentGame() != null) {
        MaterialData materialData = new MaterialData(event.getBlock().getType(), event.getBlock().getData());
        if(!api.getGameManager().getCurrentGame().breakableBlocks.contains(materialData)) {
            event.setCancelled(true);
        }
    }
}
项目:Arcadia-Spigot    文件:Utils.java   
public static MaterialData parseMaterialData(String data) {
    if(data.split(":").length > 1) {
        return new MaterialData(Material.getMaterial(data.split(":")[0]),
            Integer.valueOf(data.split(":")[1]).byteValue());
    } else {
        return new MaterialData(Material.getMaterial(data.split(":")[0]));
    }
}
项目:ProjectAres    文件:NMSHacks.java   
public static Set<MaterialData> getBlockStates(Material material) {
    ImmutableSet.Builder<MaterialData> materials = ImmutableSet.builder();
    Block nmsBlock = CraftMagicNumbers.getBlock(material);
    List<IBlockData> states = nmsBlock.s().a();
    if(states != null) {
        for(IBlockData state : states) {
            int data = nmsBlock.toLegacyData(state);
            materials.add(material.getNewData((byte) data));
        }
    }
    return materials.build();
}
项目:ProjectAres    文件:Destroyable.java   
@SuppressWarnings("deprecation")
@Override
public void replaceBlocks(MaterialData newMaterial) {
    // Calling this method causes all non-destroyed blocks to be replaced, and the material
    // list to be replaced with one containing only the new block. If called on a multi-stage
    // destroyable, i.e. one which is affected by block replacement rules, it effectively ceases
    // to be multi-stage. Even if there are block replacement rules for the new block, the
    // replacements will not be in the material list, and so those blocks will be considered
    // destroyed the first time they are mined. This can have some strange effects on the health
    // of the destroyable: individual block health can only decrease, while the total health
    // percentage can only increase.
    double oldCompletion = getCompletion();

    for (Block block : this.getBlockRegion().getBlocks(match.getWorld())) {
        BlockState oldState = block.getState();
        int oldHealth = this.getBlockHealth(oldState);

        if (oldHealth > 0) {
            block.setTypeIdAndData(newMaterial.getItemTypeId(), newMaterial.getData(), true);
        }
    }

    // Update the materials list on switch
    this.materialPatterns.clear();
    this.materials.clear();
    addMaterials(new MaterialPattern(newMaterial));

    // If there is a block health map, get rid of it, since there is now only one material in the list
    this.blockMaterialHealth = null;

    this.recalculateHealth();

    if(oldCompletion != getCompletion()) {
        match.callEvent(new DestroyableHealthChangeEvent(match, this, null));
    }
}
项目:CSGO_lobby    文件:ItemFactory.java   
public static ItemStack create(Material material, byte data, String displayName, String... lore) {
    ItemStack itemStack = new MaterialData(material, data).toItemStack(1);
    ItemMeta itemMeta = itemStack.getItemMeta();
    itemMeta.setDisplayName(displayName);
    if (lore != null) {
        List<String> finalLore = new ArrayList<>();
        for (String s : lore)
            if (s != null)
                finalLore.add(ChatColor.GRAY + s.replace('&', ChatColor.COLOR_CHAR));
        itemMeta.setLore(finalLore);
    }
    itemStack.setItemMeta(itemMeta);
    return itemStack;
}
项目:KingdomFactions    文件:PlayerInteractEventListener.java   
public void onPlayerInteract(PlayerInteractEvent e) {
    if (e.isCancelled()) return;
     KingdomFactionsPlayer p = PlayerModule.getInstance().getPlayer(e.getPlayer());        
        if(p.getSettingsProfile().hasAdminMode()) return;
    if (e.getAction().equals(Action.RIGHT_CLICK_BLOCK)) {
        if (e.getClickedBlock() == null) return;

        Block clickedBlock = e.getClickedBlock();


        if (clickedBlock.getType().equals(Material.CHEST) || clickedBlock.getType().equals(Material.TRAPPED_CHEST) || clickedBlock.getType().equals(Material.BEACON)) {
            e.setCancelled(!ProtectionModule.getInstance().tryInfluence(p, 500));
            return;
        }

        if (clickedBlock.getType().equals(Material.BURNING_FURNACE) || clickedBlock.getType().equals(Material.FURNACE) || clickedBlock.getType().equals(Material.DISPENSER) || clickedBlock.getType().equals(Material.HOPPER) || clickedBlock.getType().equals(Material.DROPPER)) {
            e.setCancelled(!ProtectionModule.getInstance().tryInfluence(p, 150));
            return;
        }

        MaterialData data = clickedBlock.getState() != null ? clickedBlock.getState().getData() : null;
        if (data instanceof Openable) {
            if (clickedBlock.getType() == Material.IRON_TRAPDOOR || clickedBlock.getType() == Material.IRON_DOOR) return;
            e.setCancelled(!ProtectionModule.getInstance().tryInfluence(p, 150));
            return;
        }
    }
}
项目:ProjectAres    文件:XMLUtils.java   
public static MaterialData parseBlockMaterialData(Node node, String text) throws InvalidXMLException {
    if(node == null) return null;
    MaterialData material = parseMaterialData(node, text);
    if(!material.getItemType().isBlock()) {
        throw new InvalidXMLException("Material " + material.getItemType().name() + " is not a block", node);
    }
    return material;
}
项目:ProjectAres    文件:BukkitTranslatorImpl.java   
@Override
public Optional<String> materialKey(MaterialData material) {
    return Optionals.first(
        Optional.ofNullable(substance(material.getItemType()))
                .map(Substance::key),
        Optional.ofNullable(NMSHacks.getTranslationKey(material))
    );
}
项目:MinecraftMarket-Plugin    文件:SignsTask.java   
private Block getAttachedBlock(Block block) {
    MaterialData data = block.getState().getData();
    if (data instanceof Attachable) {
        return block.getRelative(((Attachable) data).getAttachedFace());
    }
    return null;
}
项目:ChestTerminal    文件:QuartzDrill.java   
@SuppressWarnings("deprecation")
protected void tick(Block b) {
    if (isProcessing(b)) {
        int timeleft = progress.get(b);
        if (timeleft > 0) {
            ItemStack item = getProgressBar().clone();
            item.setDurability(MachineHelper.getDurability(item, timeleft, processing.get(b).getTicks()));
            ItemMeta im = item.getItemMeta();
            im.setDisplayName(" ");
            List<String> lore = new ArrayList<String>();
            lore.add(MachineHelper.getProgress(timeleft, processing.get(b).getTicks()));
            lore.add("");
            lore.add(MachineHelper.getTimeLeft(timeleft / 2));
            im.setLore(lore);
            item.setItemMeta(im);

            BlockStorage.getInventory(b).replaceExistingItem(22, item);

            if (ChargableBlock.getCharge(b) < getEnergyConsumption()) return;
            ChargableBlock.addCharge(b, -getEnergyConsumption());

            progress.put(b, timeleft - 1);
        }
        else {
            BlockStorage.getInventory(b).replaceExistingItem(22, new CustomItem(new MaterialData(Material.STAINED_GLASS_PANE, (byte) 15), " "));
            pushItems(b, processing.get(b).getOutput());

            progress.remove(b);
            processing.remove(b);
        }
    }
    else if (OreGenSystem.getSupplies(OreGenSystem.getResource("Milky Quartz"), b.getChunk(), false) > 0) {
        MachineRecipe r = new MachineRecipe(24, new ItemStack[0], new ItemStack[] {ChestTerminal.quartz});
        if (!fits(b, r.getOutput())) return;
        processing.put(b, r);
        progress.put(b, r.getTicks());
        OreGenSystem.setSupplies(OreGenSystem.getResource("Milky Quartz"), b.getChunk(), OreGenSystem.getSupplies(OreGenSystem.getResource("Milky Quartz"), b.getChunk(), false) - 1);
    }
}
项目:ProjectAres    文件:CompoundMaterialMatcher.java   
@Override
public boolean matches(MaterialData materialData) {
    for(MaterialMatcher child : children) {
        if(child.matches(materialData)) return true;
    }
    return false;
}
项目:ProjectAres    文件:BlockDropsRuleSet.java   
/**
 * Return the subset of rules that may act on any of the given materials
 */
public BlockDropsRuleSet subsetAffecting(Set<MaterialData> materials) {
    ImmutableList.Builder<BlockDropsRule> subset = ImmutableList.builder();
    for(BlockDropsRule rule : this.rules) {
        for(MaterialData material : materials) {
            if(rule.filter == null || rule.filter.query(MaterialQuery.of(material)) != Filter.QueryResponse.DENY) {
                subset.add(rule);
                break;
            }
        }
    }

    return new BlockDropsRuleSet(subset.build());
}
项目:ProjectAres    文件:BlockDrops.java   
public BlockDrops(List<Pair<Double, ItemStack>> items,
                  Kit kit,
                  int experience,
                  @Nullable MaterialData replacement,
                  @Nullable Float fallChance,
                  @Nullable Float landChance,
                  @Nullable Double fallSpeed) {
    this.items = ImmutableList.copyOf(items);
    this.kit = kit;
    this.experience = experience;
    this.replacement = replacement;
    this.fallChance = fallChance;
    this.landChance = landChance;
    this.fallSpeed = fallSpeed;
}
项目:HCFCore    文件:SignSubclaimListener.java   
@EventHandler(ignoreCancelled = true, priority = EventPriority.HIGH)
public void onBlockBreak(BlockBreakEvent event) {
    if (plugin.getEotwHandler().isEndOfTheWorld())
        return;

    Player player = event.getPlayer();
    if (player.getGameMode() == GameMode.CREATIVE && player.hasPermission(ProtectionListener.PROTECTION_BYPASS_PERMISSION)) {
        return;
    }

    Block block = event.getBlock();
    BlockState state = block.getState();

    Block subclaimObjectBlock = null;
    if (!(state instanceof Sign)) {
        subclaimObjectBlock = block;
    } else {
        Sign sign = (Sign) state;
        MaterialData signData = sign.getData();
        if (signData instanceof org.bukkit.material.Sign) {
            org.bukkit.material.Sign materialSign = (org.bukkit.material.Sign) signData;
            subclaimObjectBlock = block.getRelative(materialSign.getAttachedFace());
        }
    }

    if (subclaimObjectBlock != null && !this.checkSubclaimIntegrity(player, subclaimObjectBlock)) {
        event.setCancelled(true);
        player.sendMessage(ChatColor.RED + "You cannot break this subclaimed " + subclaimObjectBlock.getType().toString() + '.');
    }
}
项目:ProjectAres    文件:MaterialDataParser.java   
@Override
protected MaterialData parseInternal(Node node, String text) throws FormatException, InvalidXMLException {
    final String[] pieces = text.split(":");
    final Material material = materialParser.parse(node, pieces[0]);
    final byte data;
    if(pieces.length > 1) {
        data = byteParser.parse(node, pieces[1]);
    } else {
        data = 0;
    }
    return material.getNewData(data);
}
项目:ProjectAres    文件:ParserManifest.java   
@Override
protected void configure() {
    NumberFactory.numberTypes().forEach(type -> bindNumber((Class) type));

    bindPrimitiveParser(Boolean.class).to(BooleanParser.class);
    bindPrimitiveParser(String.class).to(StringParser.class);
    bindPrimitiveParser(Duration.class).to(DurationParser.class);
    bindPrimitiveParser(ImVector.class).to(new TypeLiteral<VectorParser<Double>>(){});
    bindPrimitiveParser(Vector.class).to((TypeLiteral) new TypeLiteral<PrimitiveParser<ImVector>>(){});
    bindPrimitiveParser(Team.OptionStatus.class).to(TeamRelationParser.class);
    bindPrimitiveParser(MessageTemplate.class).to(MessageTemplateParser.class);
    bindPrimitiveParser(Material.class).to(MaterialParser.class);
    bindPrimitiveParser(MaterialData.class).to(MaterialDataParser.class);
    bindPrimitiveParser(Attribute.class).to(AttributeParser.class);

    bind(PercentageParser.class);
    bind(PercentagePropertyFactory.class);

    install(new EnumPropertyManifest<ChatColor>(){});
    install(new EnumPropertyManifest<EntityType>(){});
    install(new EnumPropertyManifest<DyeColor>(){});
    // etc...

    install(new PropertyManifest<>(Boolean.class));
    install(new PropertyManifest<>(String.class));
    install(new PropertyManifest<>(Duration.class, DurationProperty.class));
    install(new PropertyManifest<>(ImVector.class));
    install(new PropertyManifest<>(Vector.class));
    install(new PropertyManifest<>(MessageTemplate.class, MessageTemplateProperty.class));
}
项目:ProjectAres    文件:Renewable.java   
boolean isNew(BlockState currentState) {
    // If original block does not match renewable rule, block is new
    BlockVector pos = BlockUtils.position(currentState);
    if(!isOriginalRenewable(pos)) return true;

    // If original and current material are both shuffleable, block is new
    MaterialData currentMaterial = currentState.getMaterialData();
    if(isOriginalShuffleable(pos) && definition.shuffleableBlocks.query(new BlockQuery(currentState)).isAllowed()) return true;

    // If current material matches original, block is new
    if(currentMaterial.equals(snapshot().getOriginalMaterial(pos))) return true;

    // Otherwise, block is not new (can be renewed)
    return false;
}
项目:ProjectAres    文件:Renewable.java   
MaterialData sampleShuffledMaterial(BlockVector pos) {
    Random random = match.getRandom();
    int range = SHUFFLE_SAMPLE_RANGE;
    int diameter = range * 2 + 1;
    for(int i = 0; i < SHUFFLE_SAMPLE_ITERATIONS; i++) {
        BlockState block = snapshot().getOriginalBlock(pos.getBlockX() + random.nextInt(diameter) - range,
                                                       pos.getBlockY() + random.nextInt(diameter) - range,
                                                       pos.getBlockZ() + random.nextInt(diameter) - range);
        if(definition.shuffleableBlocks.query(new BlockQuery(block)).isAllowed()) return block.getMaterialData();
    }
    return null;
}
项目:ProjectAres    文件:Renewable.java   
MaterialData chooseShuffledMaterial() {
    ImmutableRangeMap.Builder<Double, MaterialData> weightsBuilder = ImmutableRangeMap.builder();
    double sum = 0d;
    for(MaterialData material : shuffleableMaterialDeficit.materials()) {
        double weight = shuffleableMaterialDeficit.get(material);
        if(weight > 0) {
            weightsBuilder.put(Range.closedOpen(sum, sum + weight), material);
            sum += weight;
        }
    }
    RangeMap<Double, MaterialData> weights = weightsBuilder.build();
    return weights.get(match.getRandom().nextDouble() * sum);
}
项目:ChestTerminal    文件:AccessTerminal.java   
@Override
public void register(boolean slimefun) {
    addItemHandler(new BlockTicker() {

        final ItemStack item = new CustomItem(new MaterialData(Material.BARRIER), "�4No Cargo Net connected!");
        final MenuClickHandler click = new MenuClickHandler() {

            @Override
            public boolean onClick(Player arg0, int arg1, ItemStack arg2, ClickAction arg3) {
                return false;
            }
        };

        @Override
        public void tick(Block b, SlimefunItem sf, Config data) {
            if (!CargoNet.isConnected(b)) {
                BlockMenu menu = BlockStorage.getInventory(b);
                for (int slot: CargoNet.terminal_slots) {
                    menu.replaceExistingItem(slot, item);
                    menu.addMenuClickHandler(slot, click);
                }
            }
        }

        @Override
        public void uniqueTick() {
        }

        @Override
        public boolean isSynchronized() {
            return true;
        }
    });

    super.register(slimefun);
}