Search in sources :

Example 1 with Block

use of net.minecraft.server.v1_15_R1.Block in project Denizen-For-Bukkit by DenizenScript.

the class BlockHelperImpl method ringBell.

@Override
public void ringBell(Bell block) {
    org.bukkit.block.data.type.Bell bellData = (org.bukkit.block.data.type.Bell) block.getBlockData();
    Direction face = Direction.byName(bellData.getFacing().name());
    Direction dir = Direction.NORTH;
    switch(bellData.getAttachment()) {
        case DOUBLE_WALL:
        case SINGLE_WALL:
            switch(face) {
                case NORTH:
                case SOUTH:
                    dir = Direction.EAST;
                    break;
            }
            break;
        case FLOOR:
            dir = face;
            break;
    }
    CraftBlock craftBlock = (CraftBlock) block.getBlock();
    ((BellBlock) Blocks.BELL).attemptToRing(craftBlock.getCraftWorld().getHandle(), craftBlock.getPosition(), dir);
}
Also used : BellBlock(net.minecraft.world.level.block.BellBlock) org.bukkit.block(org.bukkit.block) org.bukkit.craftbukkit.v1_17_R1.block(org.bukkit.craftbukkit.v1_17_R1.block) Direction(net.minecraft.core.Direction)

Example 2 with Block

use of net.minecraft.server.v1_15_R1.Block in project solinia3-core by mixxit.

the class EntityUtils method teleportSafely.

public static void teleportSafely(Entity targetEntity, Location targetLoc) {
    if (targetEntity == null)
        return;
    if (targetLoc == null)
        return;
    final UUID entityUuid = targetEntity.getUniqueId();
    final Location loc = targetLoc.clone();
    Bukkit.getScheduler().runTask(StateManager.getInstance().getPlugin(), new Runnable() {

        @Override
        public void run() {
            if (StateManager.getInstance().isStopping())
                return;
            Entity entity = Bukkit.getEntity(entityUuid);
            if (entity == null)
                return;
            // if over 3 chunks, remove any pets
            if (entity.getLocation().distance(loc) > 48) {
                if (EntityUtils.HasPet(entityUuid)) {
                    EntityUtils.KillAllPets(entityUuid);
                    entity.sendMessage(ChatColor.GRAY + "* Your pets have been removed due to teleportation" + ChatColor.RESET);
                }
            }
            if (entity instanceof Player) {
                Essentials ess = (Essentials) Bukkit.getPluginManager().getPlugin("Essentials");
                if (ess != null) {
                    User user = ess.getUser((Player) entity);
                    if (user == null)
                        entity.teleport(loc);
                    else
                        try {
                            user.getTeleport().now(loc, false, TeleportCause.PLUGIN);
                        } catch (Exception e) {
                            // TODO Auto-generated catch block
                            e.printStackTrace();
                            entity.teleport(loc);
                        }
                } else {
                    entity.teleport(loc);
                }
            } else {
                entity.teleport(loc);
            }
        }
    });
}
Also used : CraftEntity(org.bukkit.craftbukkit.v1_15_R1.entity.CraftEntity) ISoliniaLivingEntity(com.solinia.solinia.Interfaces.ISoliniaLivingEntity) Entity(org.bukkit.entity.Entity) LivingEntity(org.bukkit.entity.LivingEntity) CraftLivingEntity(org.bukkit.craftbukkit.v1_15_R1.entity.CraftLivingEntity) Player(org.bukkit.entity.Player) CraftPlayer(org.bukkit.craftbukkit.v1_15_R1.entity.CraftPlayer) EntityPlayer(net.minecraft.server.v1_15_R1.EntityPlayer) User(com.earth2me.essentials.User) Essentials(com.earth2me.essentials.Essentials) UUID(java.util.UUID) CoreStateInitException(com.solinia.solinia.Exceptions.CoreStateInitException) Location(org.bukkit.Location)

Example 3 with Block

use of net.minecraft.server.v1_15_R1.Block in project solinia3-core by mixxit.

the class ItemStackAdapter method generateSpellLoreText.

private static List<String> generateSpellLoreText(ISoliniaItem soliniaItem) {
    List<String> loreTxt = new ArrayList<String>();
    ISoliniaSpell spell;
    try {
        spell = StateManager.getInstance().getConfigurationManager().getSpell(soliniaItem.getAbilityid());
        if (spell.getEffectid1() != 254 && !SpellUtils.getSpellEffectType(spell.getEffectid1()).name().contains("LIMIT_") && !(SpellUtils.getSpellEffectType(spell.getEffectid1()).equals(SpellEffectType.CHA) && spell.getEffectBaseValue1() == 0) && !SpellUtils.getSpellEffectType(spell.getEffectid1()).name().contains("StackingCommand_")) {
            String pos = "+";
            if (spell.getEffectBaseValue1() < 0)
                pos = "-";
            loreTxt.add(ChatColor.WHITE + "Effect: " + ChatColor.YELLOW + pos + SpellUtils.getSpellEffectType(spell.getEffectid1()).name() + ChatColor.RESET);
        }
        if (spell.getEffectid2() != 254 && !SpellUtils.getSpellEffectType(spell.getEffectid2()).name().contains("LIMIT_") && !(SpellUtils.getSpellEffectType(spell.getEffectid2()).equals(SpellEffectType.CHA) && spell.getEffectBaseValue2() == 0) && !SpellUtils.getSpellEffectType(spell.getEffectid2()).name().contains("StackingCommand_")) {
            String pos = "+";
            if (spell.getEffectBaseValue2() < 0)
                pos = "-";
            loreTxt.add(ChatColor.WHITE + "Effect: " + ChatColor.YELLOW + pos + SpellUtils.getSpellEffectType(spell.getEffectid2()).name() + ChatColor.RESET);
        }
        if (spell.getEffectid3() != 254 && !SpellUtils.getSpellEffectType(spell.getEffectid3()).name().contains("LIMIT_") && !(SpellUtils.getSpellEffectType(spell.getEffectid3()).equals(SpellEffectType.CHA) && spell.getEffectBaseValue3() == 0) && !SpellUtils.getSpellEffectType(spell.getEffectid3()).name().contains("StackingCommand_")) {
            String pos = "+";
            if (spell.getEffectBaseValue3() < 0)
                pos = "-";
            loreTxt.add(ChatColor.WHITE + "Effect: " + ChatColor.YELLOW + pos + SpellUtils.getSpellEffectType(spell.getEffectid3()).name() + ChatColor.RESET);
        }
        if (spell.getEffectid4() != 254 && !SpellUtils.getSpellEffectType(spell.getEffectid4()).name().contains("LIMIT_") && !(SpellUtils.getSpellEffectType(spell.getEffectid4()).equals(SpellEffectType.CHA) && spell.getEffectBaseValue4() == 0) && !SpellUtils.getSpellEffectType(spell.getEffectid4()).name().contains("StackingCommand_")) {
            String pos = "+";
            if (spell.getEffectBaseValue4() < 0)
                pos = "-";
            loreTxt.add(ChatColor.WHITE + "Effect: " + ChatColor.YELLOW + pos + SpellUtils.getSpellEffectType(spell.getEffectid4()).name() + ChatColor.RESET);
        }
        if (spell.getEffectid5() != 254 && !SpellUtils.getSpellEffectType(spell.getEffectid5()).name().contains("LIMIT_") && !(SpellUtils.getSpellEffectType(spell.getEffectid5()).equals(SpellEffectType.CHA) && spell.getEffectBaseValue5() == 0) && !SpellUtils.getSpellEffectType(spell.getEffectid5()).name().contains("StackingCommand_")) {
            String pos = "+";
            if (spell.getEffectBaseValue5() < 0)
                pos = "-";
            loreTxt.add(ChatColor.WHITE + "Effect: " + ChatColor.YELLOW + pos + SpellUtils.getSpellEffectType(spell.getEffectid5()).name() + ChatColor.RESET);
        }
        if (spell.getEffectid6() != 254 && !SpellUtils.getSpellEffectType(spell.getEffectid6()).name().contains("LIMIT_") && !(SpellUtils.getSpellEffectType(spell.getEffectid6()).equals(SpellEffectType.CHA) && spell.getEffectBaseValue6() == 0) && !SpellUtils.getSpellEffectType(spell.getEffectid6()).name().contains("StackingCommand_")) {
            String pos = "+";
            if (spell.getEffectBaseValue6() < 0)
                pos = "-";
            loreTxt.add(ChatColor.WHITE + "Effect: " + ChatColor.YELLOW + pos + SpellUtils.getSpellEffectType(spell.getEffectid6()).name() + ChatColor.RESET);
        }
        if (spell.getEffectid7() != 254 && !SpellUtils.getSpellEffectType(spell.getEffectid7()).name().contains("LIMIT_") && !(SpellUtils.getSpellEffectType(spell.getEffectid7()).equals(SpellEffectType.CHA) && spell.getEffectBaseValue7() == 0) && !SpellUtils.getSpellEffectType(spell.getEffectid7()).name().contains("StackingCommand_")) {
            String pos = "+";
            if (spell.getEffectBaseValue7() < 0)
                pos = "-";
            loreTxt.add(ChatColor.WHITE + "Effect: " + ChatColor.YELLOW + pos + SpellUtils.getSpellEffectType(spell.getEffectid7()).name() + ChatColor.RESET);
        }
        if (spell.getEffectid8() != 254 && !SpellUtils.getSpellEffectType(spell.getEffectid8()).name().contains("LIMIT_") && !(SpellUtils.getSpellEffectType(spell.getEffectid8()).equals(SpellEffectType.CHA) && spell.getEffectBaseValue8() == 0) && !SpellUtils.getSpellEffectType(spell.getEffectid8()).name().contains("StackingCommand_")) {
            String pos = "+";
            if (spell.getEffectBaseValue8() < 0)
                pos = "-";
            loreTxt.add(ChatColor.WHITE + "Effect: " + ChatColor.YELLOW + pos + SpellUtils.getSpellEffectType(spell.getEffectid8()).name() + ChatColor.RESET);
        }
        if (spell.getEffectid9() != 254 && !SpellUtils.getSpellEffectType(spell.getEffectid9()).name().contains("LIMIT_") && !(SpellUtils.getSpellEffectType(spell.getEffectid9()).equals(SpellEffectType.CHA) && spell.getEffectBaseValue9() == 0) && !SpellUtils.getSpellEffectType(spell.getEffectid9()).name().contains("StackingCommand_")) {
            String pos = "+";
            if (spell.getEffectBaseValue9() < 0)
                pos = "-";
            loreTxt.add(ChatColor.WHITE + "Effect: " + ChatColor.YELLOW + pos + SpellUtils.getSpellEffectType(spell.getEffectid9()).name() + ChatColor.RESET);
        }
        if (spell.getEffectid10() != 254 && !SpellUtils.getSpellEffectType(spell.getEffectid10()).name().contains("LIMIT_") && !(SpellUtils.getSpellEffectType(spell.getEffectid10()).equals(SpellEffectType.CHA) && spell.getEffectBaseValue10() == 0) && !SpellUtils.getSpellEffectType(spell.getEffectid10()).name().contains("StackingCommand_")) {
            String pos = "+";
            if (spell.getEffectBaseValue10() < 0)
                pos = "-";
            loreTxt.add(ChatColor.WHITE + "Effect: " + ChatColor.YELLOW + pos + SpellUtils.getSpellEffectType(spell.getEffectid10()).name() + ChatColor.RESET);
        }
        if (spell.getEffectid11() != 254 && !SpellUtils.getSpellEffectType(spell.getEffectid11()).name().contains("LIMIT_") && !(SpellUtils.getSpellEffectType(spell.getEffectid11()).equals(SpellEffectType.CHA) && spell.getEffectBaseValue11() == 0) && !SpellUtils.getSpellEffectType(spell.getEffectid11()).name().contains("StackingCommand_")) {
            String pos = "+";
            if (spell.getEffectBaseValue11() < 0)
                pos = "-";
            loreTxt.add(ChatColor.WHITE + "Effect: " + ChatColor.YELLOW + pos + SpellUtils.getSpellEffectType(spell.getEffectid11()).name() + ChatColor.RESET);
        }
        if (spell.getEffectid12() != 254 && !SpellUtils.getSpellEffectType(spell.getEffectid12()).name().contains("LIMIT_") && !(SpellUtils.getSpellEffectType(spell.getEffectid12()).equals(SpellEffectType.CHA) && spell.getEffectBaseValue12() == 0) && !SpellUtils.getSpellEffectType(spell.getEffectid12()).name().contains("StackingCommand_")) {
            String pos = "+";
            if (spell.getEffectBaseValue12() < 0)
                pos = "-";
            loreTxt.add(ChatColor.WHITE + "Effect: " + ChatColor.YELLOW + pos + SpellUtils.getSpellEffectType(spell.getEffectid12()).name() + ChatColor.RESET);
        }
        if (!spell.isBardSong()) {
            if (spell.getComponents1() > 0) {
                ISoliniaItem item = StateManager.getInstance().getConfigurationManager().getItem(spell.getComponents1());
                if (item != null && item.isReagent()) {
                    loreTxt.add(ChatColor.WHITE + "Requires Component: " + ChatColor.YELLOW + item.getDisplayname() + " x " + spell.getComponentCounts1() + ChatColor.RESET);
                } else {
                    loreTxt.add(ChatColor.WHITE + "Requires Component: " + ChatColor.YELLOW + "ERROR-ALERT-ADMIN-SPELL" + spell.getId() + "-ID" + spell.getComponents1());
                }
            }
            if (spell.getComponents2() > 0) {
                ISoliniaItem item = StateManager.getInstance().getConfigurationManager().getItem(spell.getComponents2());
                if (item != null && item.isReagent()) {
                    loreTxt.add(ChatColor.WHITE + "Requires Component: " + ChatColor.YELLOW + item.getDisplayname() + " x " + spell.getComponentCounts2() + ChatColor.RESET);
                } else {
                    loreTxt.add(ChatColor.WHITE + "Requires Component: " + ChatColor.YELLOW + "ERROR-ALERT-ADMIN-SPELL" + spell.getId() + "-ID" + spell.getComponents2());
                }
            }
            if (spell.getComponents3() > 0) {
                ISoliniaItem item = StateManager.getInstance().getConfigurationManager().getItem(spell.getComponents3());
                if (item != null && item.isReagent()) {
                    loreTxt.add(ChatColor.WHITE + "Requires Component: " + ChatColor.YELLOW + item.getDisplayname() + " x " + spell.getComponentCounts3() + ChatColor.RESET);
                } else {
                    loreTxt.add(ChatColor.WHITE + "Requires Component: " + ChatColor.YELLOW + "ERROR-ALERT-ADMIN-SPELL" + spell.getId() + "-ID" + spell.getComponents3());
                }
            }
            if (spell.getComponents4() > 0) {
                ISoliniaItem item = StateManager.getInstance().getConfigurationManager().getItem(spell.getComponents4());
                if (item != null && item.isReagent()) {
                    loreTxt.add(ChatColor.WHITE + "Requires Component: " + ChatColor.YELLOW + item.getDisplayname() + " x " + spell.getComponentCounts4() + ChatColor.RESET);
                } else {
                    loreTxt.add(ChatColor.WHITE + "Requires Component: " + ChatColor.YELLOW + "ERROR-ALERT-ADMIN-SPELL" + spell.getId() + "-ID" + spell.getComponents4());
                }
            }
        }
        loreTxt.add(ChatColor.WHITE + "Mana/Power: " + ChatColor.YELLOW + spell.getMana() + ChatColor.RESET);
        loreTxt.add(ChatColor.WHITE + "Spell Skill: " + ChatColor.YELLOW + SkillUtils.getSkillType(spell.getSkill()).name().toUpperCase() + ChatColor.RESET);
        loreTxt.add(ChatColor.WHITE + "Range: " + ChatColor.YELLOW + spell.getRange() + ChatColor.RESET);
        loreTxt.add(ChatColor.WHITE + "Casting Time: " + ChatColor.YELLOW + (spell.getCastTime() / 1000) + " seconds" + ChatColor.RESET);
        if (spell.isAASpell()) {
            loreTxt.add(ChatColor.WHITE + "This spell is an AA spell" + ChatColor.RESET);
        }
        if (spell.isBuffSpell() && spell.getBuffduration() > 0) {
            loreTxt.add(ChatColor.WHITE + "Buff Duration: " + ChatColor.YELLOW + (spell.getBuffduration() * 6) + " seconds" + ChatColor.RESET);
        }
        loreTxt.add(ChatColor.WHITE + "Target Type: " + ChatColor.YELLOW + SpellUtils.getSpellTargetType(spell.getTargettype()).name() + ChatColor.RESET);
        List<String> classInfo = generateClassesText(spell);
        if (classInfo.size() > 0)
            loreTxt.addAll(classInfo);
    } catch (CoreStateInitException e) {
        // TODO Auto-generated catch block
        e.printStackTrace();
    }
    return loreTxt;
}
Also used : ISoliniaSpell(com.solinia.solinia.Interfaces.ISoliniaSpell) ISoliniaItem(com.solinia.solinia.Interfaces.ISoliniaItem) CoreStateInitException(com.solinia.solinia.Exceptions.CoreStateInitException) ArrayList(java.util.ArrayList) NBTTagString(net.minecraft.server.v1_15_R1.NBTTagString)

Example 4 with Block

use of net.minecraft.server.v1_15_R1.Block in project solinia3-core by mixxit.

the class ItemStackAdapter method generateWeaponAbilityLoreText.

private static Collection<String> generateWeaponAbilityLoreText(ISoliniaItem soliniaItem) {
    List<String> loreTxt = new ArrayList<String>();
    ISoliniaSpell spell;
    try {
        spell = StateManager.getInstance().getConfigurationManager().getSpell(soliniaItem.getWeaponabilityid());
        loreTxt.add(ChatColor.WHITE + "Chance to Proc on Hit: " + ChatColor.YELLOW + spell.getName() + ChatColor.RESET);
    } catch (CoreStateInitException e) {
        // TODO Auto-generated catch block
        e.printStackTrace();
    }
    return loreTxt;
}
Also used : ISoliniaSpell(com.solinia.solinia.Interfaces.ISoliniaSpell) CoreStateInitException(com.solinia.solinia.Exceptions.CoreStateInitException) ArrayList(java.util.ArrayList) NBTTagString(net.minecraft.server.v1_15_R1.NBTTagString)

Example 5 with Block

use of net.minecraft.server.v1_15_R1.Block in project java-docs-samples by GoogleCloudPlatform.

the class Detect method detectDocumentText.

// [START vision_detect_document]
/**
 * Performs document text detection on a local image file.
 *
 * @param filePath The path to the local file to detect document text on.
 * @param out A {@link PrintStream} to write the results to.
 * @throws Exception on errors while closing the client.
 * @throws IOException on Input/Output errors.
 */
public static void detectDocumentText(String filePath, PrintStream out) throws Exception, IOException {
    List<AnnotateImageRequest> requests = new ArrayList<>();
    ByteString imgBytes = ByteString.readFrom(new FileInputStream(filePath));
    Image img = Image.newBuilder().setContent(imgBytes).build();
    Feature feat = Feature.newBuilder().setType(Type.DOCUMENT_TEXT_DETECTION).build();
    AnnotateImageRequest request = AnnotateImageRequest.newBuilder().addFeatures(feat).setImage(img).build();
    requests.add(request);
    try (ImageAnnotatorClient client = ImageAnnotatorClient.create()) {
        BatchAnnotateImagesResponse response = client.batchAnnotateImages(requests);
        List<AnnotateImageResponse> responses = response.getResponsesList();
        client.close();
        for (AnnotateImageResponse res : responses) {
            if (res.hasError()) {
                out.printf("Error: %s\n", res.getError().getMessage());
                return;
            }
            // For full list of available annotations, see http://g.co/cloud/vision/docs
            TextAnnotation annotation = res.getFullTextAnnotation();
            for (Page page : annotation.getPagesList()) {
                String pageText = "";
                for (Block block : page.getBlocksList()) {
                    String blockText = "";
                    for (Paragraph para : block.getParagraphsList()) {
                        String paraText = "";
                        for (Word word : para.getWordsList()) {
                            String wordText = "";
                            for (Symbol symbol : word.getSymbolsList()) {
                                wordText = wordText + symbol.getText();
                                out.format("Symbol text: %s (confidence: %f)\n", symbol.getText(), symbol.getConfidence());
                            }
                            out.format("Word text: %s (confidence: %f)\n\n", wordText, word.getConfidence());
                            paraText = String.format("%s %s", paraText, wordText);
                        }
                        // Output Example using Paragraph:
                        out.println("\nParagraph: \n" + paraText);
                        out.format("Paragraph Confidence: %f\n", para.getConfidence());
                        blockText = blockText + paraText;
                    }
                    pageText = pageText + blockText;
                }
            }
            out.println("\nComplete annotation:");
            out.println(annotation.getText());
        }
    }
}
Also used : Word(com.google.cloud.vision.v1.Word) ByteString(com.google.protobuf.ByteString) Symbol(com.google.cloud.vision.v1.Symbol) ImageAnnotatorClient(com.google.cloud.vision.v1.ImageAnnotatorClient) ArrayList(java.util.ArrayList) WebPage(com.google.cloud.vision.v1.WebDetection.WebPage) Page(com.google.cloud.vision.v1.Page) ByteString(com.google.protobuf.ByteString) WebImage(com.google.cloud.vision.v1.WebDetection.WebImage) Image(com.google.cloud.vision.v1.Image) Feature(com.google.cloud.vision.v1.Feature) FileInputStream(java.io.FileInputStream) Paragraph(com.google.cloud.vision.v1.Paragraph) AnnotateImageRequest(com.google.cloud.vision.v1.AnnotateImageRequest) AnnotateImageResponse(com.google.cloud.vision.v1.AnnotateImageResponse) Block(com.google.cloud.vision.v1.Block) TextAnnotation(com.google.cloud.vision.v1.TextAnnotation) BatchAnnotateImagesResponse(com.google.cloud.vision.v1.BatchAnnotateImagesResponse)

Aggregations

ArrayList (java.util.ArrayList)10 ByteString (com.google.protobuf.ByteString)8 Block (net.minecraft.server.v1_12_R1.Block)8 Block (net.minecraft.server.v1_8_R3.Block)8 FallingBlock (org.bukkit.entity.FallingBlock)8 Block (net.minecraft.server.v1_10_R1.Block)7 Block (net.minecraft.server.v1_11_R1.Block)7 BlockPosition (net.minecraft.server.v1_12_R1.BlockPosition)7 AnnotateImageResponse (com.google.cloud.vision.v1.AnnotateImageResponse)6 Block (com.google.cloud.vision.v1.Block)6 Feature (com.google.cloud.vision.v1.Feature)6 ImageAnnotatorClient (com.google.cloud.vision.v1.ImageAnnotatorClient)6 Page (com.google.cloud.vision.v1.Page)6 Paragraph (com.google.cloud.vision.v1.Paragraph)6 Symbol (com.google.cloud.vision.v1.Symbol)6 Word (com.google.cloud.vision.v1.Word)6 BlockPosition (net.minecraft.server.v1_10_R1.BlockPosition)6 BlockPosition (net.minecraft.server.v1_11_R1.BlockPosition)6 Block (net.minecraft.server.v1_15_R1.Block)5 BlockPosition (net.minecraft.server.v1_8_R3.BlockPosition)5