Search in sources :

Example 61 with Item

use of net.minecraft.server.v1_12_R1.Item in project ORCID-Source by ORCID.

the class ExternalIDValidatorTest method testEmptyRelationshipOnNotificationItemExternalIds_flagOff.

@Test
public void testEmptyRelationshipOnNotificationItemExternalIds_flagOff() {
    Item i = new Item();
    Item i2 = new Item();
    Items items = new Items();
    ExternalID id1 = new ExternalID();
    id1.setRelationship(Relationship.SELF);
    id1.setType("doi");
    id1.setValue("value1");
    id1.setUrl(new Url("http://value1.com"));
    ExternalID id2 = new ExternalID();
    id2.setRelationship(null);
    id2.setType("source-work-id");
    id2.setValue("value2");
    id2.setUrl(new Url("http://value1.com"));
    i.setExternalIdentifier(id1);
    i2.setExternalIdentifier(id2);
    items.getItems().add(i);
    items.getItems().add(i2);
    // both valid
    validator.validateNotificationItems(items);
}
Also used : Item(org.orcid.jaxb.model.notification.permission_v2.Item) ExternalID(org.orcid.jaxb.model.record_v2.ExternalID) Items(org.orcid.jaxb.model.notification.permission_v2.Items) Url(org.orcid.jaxb.model.common_v2.Url) Test(org.junit.Test)

Example 62 with Item

use of net.minecraft.server.v1_12_R1.Item in project ORCID-Source by ORCID.

the class MapperFacadeFactory method getObject.

@Override
public MapperFacade getObject() throws Exception {
    MapperFactory mapperFactory = getNewMapperFactory();
    // Register converters
    ConverterFactory converterFactory = mapperFactory.getConverterFactory();
    converterFactory.registerConverter("externalIdentifierIdConverter", new ExternalIdentifierTypeConverter());
    // Register factories
    mapperFactory.registerObjectFactory(new WorkEntityFactory(workDao), TypeFactory.<NotificationWorkEntity>valueOf(NotificationWorkEntity.class), TypeFactory.<Item>valueOf(Item.class));
    // Custom notification
    ClassMapBuilder<NotificationCustom, NotificationCustomEntity> notificationCustomClassMap = mapperFactory.classMap(NotificationCustom.class, NotificationCustomEntity.class);
    registerSourceConverters(mapperFactory, notificationCustomClassMap);
    mapCommonFields(notificationCustomClassMap).register();
    // Permission notification
    ClassMapBuilder<NotificationPermission, NotificationAddItemsEntity> notificationPermissionClassMap = mapperFactory.classMap(NotificationPermission.class, NotificationAddItemsEntity.class);
    registerSourceConverters(mapperFactory, notificationPermissionClassMap);
    mapCommonFields(notificationPermissionClassMap.field("authorizationUrl.uri", "authorizationUrl").field("items.items", "notificationItems").customize(new CustomMapper<NotificationPermission, NotificationAddItemsEntity>() {

        @Override
        public void mapAtoB(NotificationPermission notification, NotificationAddItemsEntity entity, MappingContext context) {
            if (StringUtils.isBlank(entity.getAuthorizationUrl())) {
                String authUrl = orcidUrlManager.getBaseUrl() + notification.getAuthorizationUrl().getPath();
                // validate
                validateAndConvertToURI(authUrl);
                entity.setAuthorizationUrl(authUrl);
            }
        }

        @Override
        public void mapBtoA(NotificationAddItemsEntity entity, NotificationPermission notification, MappingContext context) {
            AuthorizationUrl authUrl = notification.getAuthorizationUrl();
            if (authUrl != null) {
                authUrl.setPath(extractFullPath(authUrl.getUri()));
                authUrl.setHost(orcidUrlManager.getBaseHost());
            }
        }
    })).register();
    // Institutional sign in notification
    ClassMapBuilder<NotificationInstitutionalConnection, NotificationInstitutionalConnectionEntity> institutionalConnectionNotificationClassMap = mapperFactory.classMap(NotificationInstitutionalConnection.class, NotificationInstitutionalConnectionEntity.class);
    registerSourceConverters(mapperFactory, institutionalConnectionNotificationClassMap);
    mapCommonFields(institutionalConnectionNotificationClassMap.field("authorizationUrl.uri", "authorizationUrl").customize(new CustomMapper<NotificationInstitutionalConnection, NotificationInstitutionalConnectionEntity>() {

        @Override
        public void mapAtoB(NotificationInstitutionalConnection notification, NotificationInstitutionalConnectionEntity entity, MappingContext context) {
            if (StringUtils.isBlank(entity.getAuthorizationUrl())) {
                String authUrl = orcidUrlManager.getBaseUrl() + notification.getAuthorizationUrl().getPath();
                // validate
                validateAndConvertToURI(authUrl);
                entity.setAuthorizationUrl(authUrl);
            }
        }

        @Override
        public void mapBtoA(NotificationInstitutionalConnectionEntity entity, NotificationInstitutionalConnection notification, MappingContext context) {
            AuthorizationUrl authUrl = notification.getAuthorizationUrl();
            if (authUrl != null) {
                authUrl.setPath(extractFullPath(authUrl.getUri()));
                authUrl.setHost(orcidUrlManager.getBaseHost());
            }
            String providerId = entity.getAuthenticationProviderId();
            if (StringUtils.isNotBlank(providerId)) {
                String idpName = identityProviderManager.retrieveIdentitifyProviderName(providerId);
                notification.setIdpName(idpName);
            } else {
                notification.setIdpName(LAST_RESORT_IDENTITY_PROVIDER_NAME);
            }
        }
    })).register();
    // Amend notification
    ClassMapBuilder<NotificationAmended, NotificationAmendedEntity> amendNotificationClassMap = mapperFactory.classMap(NotificationAmended.class, NotificationAmendedEntity.class);
    registerSourceConverters(mapperFactory, amendNotificationClassMap);
    mapCommonFields(amendNotificationClassMap.exclude("amendedSection").customize(new CustomMapper<NotificationAmended, NotificationAmendedEntity>() {

        @Override
        public void mapAtoB(NotificationAmended a, NotificationAmendedEntity b, MappingContext context) {
            if (a.getAmendedSection() != null) {
                switch(a.getAmendedSection()) {
                    case AFFILIATION:
                        b.setAmendedSection(AmendedSection.AFFILIATION);
                        break;
                    case BIO:
                        b.setAmendedSection(AmendedSection.BIO);
                        break;
                    case EDUCATION:
                        b.setAmendedSection(AmendedSection.EDUCATION);
                        break;
                    case EMPLOYMENT:
                        b.setAmendedSection(AmendedSection.EMPLOYMENT);
                        break;
                    case EXTERNAL_IDENTIFIERS:
                        b.setAmendedSection(AmendedSection.EXTERNAL_IDENTIFIERS);
                        break;
                    case FUNDING:
                        b.setAmendedSection(AmendedSection.FUNDING);
                        break;
                    case PEER_REVIEW:
                        b.setAmendedSection(AmendedSection.PEER_REVIEW);
                        break;
                    case PREFERENCES:
                        b.setAmendedSection(AmendedSection.PREFERENCES);
                        break;
                    case UNKNOWN:
                        b.setAmendedSection(AmendedSection.UNKNOWN);
                        break;
                    case WORK:
                        b.setAmendedSection(AmendedSection.WORK);
                        break;
                    default:
                        b.setAmendedSection(AmendedSection.UNKNOWN);
                        break;
                }
            }
        }

        /**
         * From database to model object, map amended sections for new affiliation types as AFFILIATION
         */
        @Override
        public void mapBtoA(NotificationAmendedEntity b, NotificationAmended a, MappingContext context) {
            if (b.getAmendedSection() != null) {
                switch(b.getAmendedSection()) {
                    case AFFILIATION:
                    case DISTINCTION:
                    case INVITED_POSITION:
                    case MEMBERSHIP:
                    case QUALIFICATION:
                    case SERVICE:
                        a.setAmendedSection(org.orcid.jaxb.model.notification.amended_v2.AmendedSection.AFFILIATION);
                        break;
                    case BIO:
                        a.setAmendedSection(org.orcid.jaxb.model.notification.amended_v2.AmendedSection.BIO);
                        break;
                    case EDUCATION:
                        a.setAmendedSection(org.orcid.jaxb.model.notification.amended_v2.AmendedSection.EDUCATION);
                        break;
                    case EMPLOYMENT:
                        a.setAmendedSection(org.orcid.jaxb.model.notification.amended_v2.AmendedSection.EMPLOYMENT);
                        break;
                    case EXTERNAL_IDENTIFIERS:
                        a.setAmendedSection(org.orcid.jaxb.model.notification.amended_v2.AmendedSection.EXTERNAL_IDENTIFIERS);
                        break;
                    case FUNDING:
                        a.setAmendedSection(org.orcid.jaxb.model.notification.amended_v2.AmendedSection.FUNDING);
                        break;
                    case PEER_REVIEW:
                        a.setAmendedSection(org.orcid.jaxb.model.notification.amended_v2.AmendedSection.PEER_REVIEW);
                        break;
                    case PREFERENCES:
                        a.setAmendedSection(org.orcid.jaxb.model.notification.amended_v2.AmendedSection.PREFERENCES);
                        break;
                    case UNKNOWN:
                        a.setAmendedSection(org.orcid.jaxb.model.notification.amended_v2.AmendedSection.UNKNOWN);
                        break;
                    case WORK:
                        a.setAmendedSection(org.orcid.jaxb.model.notification.amended_v2.AmendedSection.WORK);
                        break;
                }
            }
        }
    })).register();
    mapperFactory.classMap(NotificationItemEntity.class, Item.class).fieldMap("externalIdType", "externalIdentifier.type").converter("externalIdentifierIdConverter").add().field("externalIdValue", "externalIdentifier.value").byDefault().register();
    return mapperFactory.getMapperFacade();
}
Also used : NotificationInstitutionalConnectionEntity(org.orcid.persistence.jpa.entities.NotificationInstitutionalConnectionEntity) ConverterFactory(ma.glasnost.orika.converter.ConverterFactory) NotificationCustom(org.orcid.jaxb.model.notification.custom_v2.NotificationCustom) NotificationAddItemsEntity(org.orcid.persistence.jpa.entities.NotificationAddItemsEntity) MappingContext(ma.glasnost.orika.MappingContext) AuthorizationUrl(org.orcid.jaxb.model.notification.permission_v2.AuthorizationUrl) Item(org.orcid.jaxb.model.notification.permission_v2.Item) NotificationPermission(org.orcid.jaxb.model.notification.permission_v2.NotificationPermission) NotificationAmendedEntity(org.orcid.persistence.jpa.entities.NotificationAmendedEntity) NotificationInstitutionalConnection(org.orcid.model.notification.institutional_sign_in_v2.NotificationInstitutionalConnection) NotificationCustomEntity(org.orcid.persistence.jpa.entities.NotificationCustomEntity) NotificationWorkEntity(org.orcid.persistence.jpa.entities.NotificationWorkEntity) ExternalIdentifierTypeConverter(org.orcid.core.adapter.jsonidentifier.converter.ExternalIdentifierTypeConverter) DefaultMapperFactory(ma.glasnost.orika.impl.DefaultMapperFactory) MapperFactory(ma.glasnost.orika.MapperFactory) NotificationAmended(org.orcid.jaxb.model.notification.amended_v2.NotificationAmended)

Example 63 with Item

use of net.minecraft.server.v1_12_R1.Item in project solinia3-core by mixxit.

the class ItemStackAdapter method Adapt.

public static ItemStack Adapt(ISoliniaItem soliniaItem) {
    ItemStack stack = new ItemStack(Material.valueOf(soliniaItem.getBasename().toUpperCase()), 1, soliniaItem.getColor());
    if (soliniaItem.getDamage() > 0) {
        if (soliniaItem.getBasename().equals("WOOD_SWORD") || soliniaItem.getBasename().equals("STONE_SWORD") || soliniaItem.getBasename().equals("IRON_SWORD") || soliniaItem.getBasename().equals("GOLD_SWORD") || soliniaItem.getBasename().equals("DIAMOND_SWORD") || soliniaItem.getBasename().equals("WOOD_AXE") || soliniaItem.getBasename().equals("STONE_AXE") || soliniaItem.getBasename().equals("IRON_AXE") || soliniaItem.getBasename().equals("GOLD_AXE") || soliniaItem.getBasename().equals("DIAMOND_AXE") || soliniaItem.getBasename().equals("WOOD_SPADE") || soliniaItem.getBasename().equals("STONE_SPADE") || soliniaItem.getBasename().equals("IRON_SPADE") || soliniaItem.getBasename().equals("GOLD_SPADE") || soliniaItem.getBasename().equals("DIAMOND_SPADE")) {
            net.minecraft.server.v1_12_R1.ItemStack nmsStack = CraftItemStack.asNMSCopy(stack);
            NBTTagCompound compound = (nmsStack.hasTag()) ? nmsStack.getTag() : new NBTTagCompound();
            NBTTagList modifiers = new NBTTagList();
            NBTTagCompound damagecompound = new NBTTagCompound();
            damagecompound.set("AttributeName", new NBTTagString("generic.attackDamage"));
            damagecompound.set("Name", new NBTTagString("generic.attackDamage"));
            damagecompound.set("Amount", new NBTTagInt(soliniaItem.getDamage()));
            damagecompound.set("Operation", new NBTTagInt(0));
            damagecompound.set("UUIDLeast", new NBTTagInt(894654));
            damagecompound.set("UUIDMost", new NBTTagInt(2872));
            damagecompound.set("Slot", new NBTTagString("mainhand"));
            modifiers.add(damagecompound);
            compound.set("AttributeModifiers", modifiers);
            nmsStack.setTag(compound);
            stack = CraftItemStack.asBukkitCopy(nmsStack);
        }
    }
    ItemMeta i = stack.getItemMeta();
    if (soliniaItem.getBasename().equals("POTION") || soliniaItem.getBasename().equals("SPLASH_POTION") || soliniaItem.getBasename().equals("LINGERING_POTION")) {
        i = (PotionMeta) stack.getItemMeta();
        PotionData data = new PotionData(PotionType.INSTANT_HEAL);
        ((PotionMeta) i).setBasePotionData(data);
    }
    if (soliniaItem.getTexturebase64() != null && !soliniaItem.getTexturebase64().equals("") && soliniaItem.getBasename().equals("SKULL_ITEM")) {
        UUID skinuuid = getUUIDFromString(soliniaItem.getTexturebase64());
        i = buildSkull((SkullMeta) i, skinuuid, soliniaItem.getTexturebase64(), null);
    }
    i.setUnbreakable(true);
    i.setDisplayName(soliniaItem.getDisplayname());
    List<String> loretxt = new ArrayList<String>();
    if (soliniaItem.getLore() != null) {
        String[] lorestr = soliniaItem.getLore().split("(?<=\\G.{34})");
        loretxt.addAll(Arrays.asList(lorestr));
    }
    if (soliniaItem.isArtifact() == true) {
        loretxt.add(ChatColor.GREEN + "This item is a unique artifact!" + ChatColor.RESET);
    }
    if (soliniaItem.isQuest() == true) {
        loretxt.add(ChatColor.YELLOW + "This item is part of a quest line" + ChatColor.RESET);
    }
    if (soliniaItem.isCrafting() == true) {
        loretxt.add(ChatColor.GOLD + "This looks like it could be crafted" + ChatColor.RESET);
        loretxt.add(ChatColor.GOLD + "into something useful" + ChatColor.RESET);
    }
    if (soliniaItem.isExperienceBonus() == true) {
        loretxt.add(ChatColor.GOLD + "Grant XP Experience!" + ChatColor.RESET);
    }
    if (soliniaItem.isFingersItem()) {
        loretxt.add(ChatColor.AQUA + "/EQUIP : FINGERS" + ChatColor.RESET);
    }
    if (soliniaItem.isNeckItem()) {
        loretxt.add(ChatColor.AQUA + "/EQUIP : NECK" + ChatColor.RESET);
    }
    if (soliniaItem.isShouldersItem()) {
        loretxt.add(ChatColor.AQUA + "/EQUIP : SHOULDERS" + ChatColor.RESET);
    }
    if (soliniaItem.isAugmentation() == true) {
        loretxt.add(ChatColor.AQUA + "This looks like it could augment " + ChatColor.RESET);
        loretxt.add(ChatColor.AQUA + "weapon or armour" + ChatColor.RESET);
        loretxt.add(ChatColor.AQUA + "Augments Item Slots: " + soliniaItem.getAugmentationFitsSlotType().name() + ChatColor.RESET);
    }
    if (soliniaItem.getDamage() > 0) {
        if (soliniaItem.getBasename().equals("BOW")) {
            loretxt.add("Modifies Arrow Dmg: " + ChatColor.GREEN + soliniaItem.getDamage() + ChatColor.RESET);
        }
    }
    if (soliniaItem.getBaneUndead() > 0) {
        loretxt.add("Bane UNDEAD: " + ChatColor.GREEN + soliniaItem.getBaneUndead() + ChatColor.RESET);
    }
    if (soliniaItem.getAC() > 0) {
        loretxt.add("Armour Class: " + ChatColor.GREEN + soliniaItem.getAC() + ChatColor.RESET);
    }
    String classtxt = "";
    if (soliniaItem.getAllowedClassNames().size() > 0) {
        classtxt = "Usable By: ";
        for (String classname : soliniaItem.getAllowedClassNames()) {
            classtxt += ChatColor.YELLOW + classname + ChatColor.RESET + " ";
        }
    }
    if (!classtxt.equals("")) {
        loretxt.add(classtxt);
    }
    if (soliniaItem.getMinLevel() > 0) {
        loretxt.add("Minimum Level: " + ChatColor.YELLOW + soliniaItem.getMinLevel() + ChatColor.RESET);
    }
    String stattxt = "";
    if (soliniaItem.getStrength() > 0) {
        stattxt = "STR: " + ChatColor.GREEN + soliniaItem.getStrength() + ChatColor.RESET + " ";
    }
    if (soliniaItem.getStamina() > 0) {
        stattxt += "STA: " + ChatColor.GREEN + soliniaItem.getStamina() + ChatColor.RESET + " ";
    }
    if (soliniaItem.getAgility() > 0) {
        stattxt += "AGI: " + ChatColor.GREEN + soliniaItem.getAgility() + ChatColor.RESET + " ";
    }
    if (!stattxt.equals("")) {
        loretxt.add(stattxt);
    }
    stattxt = "";
    if (soliniaItem.getDexterity() > 0) {
        stattxt = "DEX: " + ChatColor.GREEN + soliniaItem.getDexterity() + ChatColor.RESET + " ";
    }
    if (soliniaItem.getIntelligence() > 0) {
        stattxt += "INT: " + ChatColor.GREEN + soliniaItem.getIntelligence() + ChatColor.RESET + " ";
    }
    if (soliniaItem.getWisdom() > 0) {
        stattxt += "WIS: " + ChatColor.GREEN + soliniaItem.getWisdom() + ChatColor.RESET + " ";
    }
    if (soliniaItem.getCharisma() > 0) {
        stattxt += "CHA: " + ChatColor.GREEN + soliniaItem.getCharisma() + ChatColor.RESET + " ";
    }
    if (!stattxt.equals("")) {
        loretxt.add(stattxt);
    }
    String resisttxt = "";
    if (soliniaItem.getFireResist() > 0) {
        resisttxt += "FR: " + ChatColor.AQUA + soliniaItem.getFireResist() + ChatColor.RESET + " ";
    }
    if (soliniaItem.getColdResist() > 0) {
        resisttxt += "CR: " + ChatColor.AQUA + soliniaItem.getColdResist() + ChatColor.RESET + " ";
    }
    if (soliniaItem.getMagicResist() > 0) {
        resisttxt += "MR: " + ChatColor.AQUA + soliniaItem.getMagicResist() + ChatColor.RESET + " ";
    }
    if (soliniaItem.getPoisonResist() > 0) {
        resisttxt += "PR: " + ChatColor.AQUA + soliniaItem.getPoisonResist() + ChatColor.RESET + " ";
    }
    if (!resisttxt.equals("")) {
        loretxt.add(resisttxt);
    }
    String regentxt = "";
    if (soliniaItem.getHpregen() > 0 || soliniaItem.getMpregen() > 0) {
        if (soliniaItem.getHpregen() > 0) {
            regentxt = ChatColor.WHITE + "HPRegen: " + ChatColor.YELLOW + soliniaItem.getHpregen() + ChatColor.RESET;
        }
        if (soliniaItem.getMpregen() > 0) {
            if (!regentxt.equals(""))
                regentxt += " ";
            regentxt += ChatColor.WHITE + "MPRegen: " + ChatColor.YELLOW + soliniaItem.getMpregen() + ChatColor.RESET;
        }
    }
    if (!(soliniaItem.getSkillModType().equals(SkillType.None))) {
        loretxt.add(ChatColor.WHITE + "Modifies skill checks for: " + ChatColor.YELLOW + soliniaItem.getSkillModType().toString() + "  +(" + soliniaItem.getSkillModValue() + ")" + ChatColor.RESET);
    }
    if (!(soliniaItem.getSkillModType2().equals(SkillType.None))) {
        loretxt.add(ChatColor.WHITE + "Modifies skill checks for: " + ChatColor.YELLOW + soliniaItem.getSkillModType2().toString() + "  +(" + soliniaItem.getSkillModValue2() + ")" + ChatColor.RESET);
    }
    if (!(soliniaItem.getSkillModType3().equals(SkillType.None))) {
        loretxt.add(ChatColor.WHITE + "Modifies skill checks for: " + ChatColor.YELLOW + soliniaItem.getSkillModType3().toString() + "  +(" + soliniaItem.getSkillModValue3() + ")" + ChatColor.RESET);
    }
    if (!(soliniaItem.getSkillModType4().equals(SkillType.None))) {
        loretxt.add(ChatColor.WHITE + "Modifies skill checks for: " + ChatColor.YELLOW + soliniaItem.getSkillModType4().toString() + "  +(" + soliniaItem.getSkillModValue4() + ")" + ChatColor.RESET);
    }
    if (!(soliniaItem.getAcceptsAugmentationSlotType().equals(AugmentationSlotType.NONE))) {
        loretxt.add(ChatColor.WHITE + "Augmentation Slot Types: " + ChatColor.YELLOW + soliniaItem.getAcceptsAugmentationSlotType().name() + ChatColor.RESET);
    }
    if (!regentxt.equals("")) {
        loretxt.add(regentxt);
    }
    String hpmanatxt = "";
    if (soliniaItem.getHp() > 0 || soliniaItem.getMana() > 0) {
        if (soliniaItem.getHp() > 0) {
            hpmanatxt = ChatColor.WHITE + "HP: " + ChatColor.YELLOW + soliniaItem.getHp() + ChatColor.RESET;
        }
        if (soliniaItem.getMana() > 0) {
            if (!hpmanatxt.equals(""))
                hpmanatxt += " ";
            hpmanatxt += ChatColor.WHITE + "Mana: " + ChatColor.YELLOW + soliniaItem.getMana() + ChatColor.RESET;
        }
    }
    if (!hpmanatxt.equals("")) {
        loretxt.add(hpmanatxt);
    }
    if (soliniaItem.getAbilityid() > 0 && soliniaItem.isSpellscroll()) {
        loretxt.addAll(generateSpellLoreText(soliniaItem));
    }
    if (soliniaItem.getAbilityid() > 0 && !soliniaItem.isSpellscroll()) {
        loretxt.addAll(generateConsumableAbilityLoreText(soliniaItem));
    }
    if (soliniaItem.getWeaponabilityid() > 0 && !soliniaItem.isSpellscroll()) {
        loretxt.addAll(generateWeaponAbilityLoreText(soliniaItem));
    }
    loretxt.add("Discovered By: " + soliniaItem.getDiscoverer());
    if (soliniaItem.getWorth() > 0) {
        loretxt.add(ChatColor.WHITE + "Worth: " + ChatColor.YELLOW + soliniaItem.getWorth() + ChatColor.RESET);
    }
    if (soliniaItem.isTemporary()) {
        loretxt.add("Temporary: " + StateManager.getInstance().getInstanceGuid());
    }
    i.setLore(loretxt);
    stack.setItemMeta(i);
    stack.addUnsafeEnchantment(Enchantment.DURABILITY, 1000 + soliniaItem.getId());
    if (soliniaItem.getEnchantment1() != null) {
        if (soliniaItem.getEnchantment1val() > 0) {
            try {
                Enchantment enchantment = Utils.getEnchantmentFromEnchantmentName(soliniaItem.getEnchantment1());
                stack.addUnsafeEnchantment(enchantment, soliniaItem.getEnchantment1val());
            } catch (Exception e) {
                System.out.println("WARNING: Invalid Enchantment Item on SoliniaItem: " + soliniaItem.getId());
            }
        }
    }
    if (soliniaItem.getEnchantment2() != null) {
        if (soliniaItem.getEnchantment2val() > 0) {
            try {
                Enchantment enchantment = Utils.getEnchantmentFromEnchantmentName(soliniaItem.getEnchantment2());
                stack.addUnsafeEnchantment(enchantment, soliniaItem.getEnchantment2val());
            } catch (Exception e) {
                System.out.println("WARNING: Invalid Enchantment Item on SoliniaItem: " + soliniaItem.getId());
            }
        }
    }
    if (soliniaItem.getEnchantment3() != null) {
        if (soliniaItem.getEnchantment3val() > 0) {
            try {
                Enchantment enchantment = Utils.getEnchantmentFromEnchantmentName(soliniaItem.getEnchantment3());
                stack.addUnsafeEnchantment(enchantment, soliniaItem.getEnchantment3val());
            } catch (Exception e) {
                System.out.println("WARNING: Invalid Enchantment Item on SoliniaItem: " + soliniaItem.getId());
            }
        }
    }
    if (soliniaItem.getEnchantment4() != null) {
        if (soliniaItem.getEnchantment4val() > 0) {
            try {
                Enchantment enchantment = Utils.getEnchantmentFromEnchantmentName(soliniaItem.getEnchantment4());
                stack.addUnsafeEnchantment(enchantment, soliniaItem.getEnchantment4val());
            } catch (Exception e) {
                System.out.println("WARNING: Invalid Enchantment Item on SoliniaItem: " + soliniaItem.getId());
            }
        }
    }
    if (soliniaItem.getTexturebase64() != null && !soliniaItem.getTexturebase64().equals("") && soliniaItem.getBasename().equals("SKULL_ITEM")) {
        stack.setDurability((short) 3);
    }
    return stack;
}
Also used : NBTTagInt(net.minecraft.server.v1_12_R1.NBTTagInt) NBTTagCompound(net.minecraft.server.v1_12_R1.NBTTagCompound) ArrayList(java.util.ArrayList) PotionMeta(org.bukkit.inventory.meta.PotionMeta) SkullMeta(org.bukkit.inventory.meta.SkullMeta) NBTTagString(net.minecraft.server.v1_12_R1.NBTTagString) CoreStateInitException(com.solinia.solinia.Exceptions.CoreStateInitException) NoSuchAlgorithmException(java.security.NoSuchAlgorithmException) NBTTagList(net.minecraft.server.v1_12_R1.NBTTagList) PotionData(org.bukkit.potion.PotionData) NBTTagString(net.minecraft.server.v1_12_R1.NBTTagString) CraftItemStack(org.bukkit.craftbukkit.v1_12_R1.inventory.CraftItemStack) ItemStack(org.bukkit.inventory.ItemStack) UUID(java.util.UUID) Enchantment(org.bukkit.enchantments.Enchantment) ItemMeta(org.bukkit.inventory.meta.ItemMeta)

Example 64 with Item

use of net.minecraft.server.v1_12_R1.Item in project solinia3-core by mixxit.

the class SoliniaItem method convertItemStackToJsonRegular.

private String convertItemStackToJsonRegular() {
    // First we convert the item stack into an NMS itemstack
    net.minecraft.server.v1_12_R1.ItemStack nmsItemStack = CraftItemStack.asNMSCopy(asItemStack());
    NBTTagCompound compound = new NBTTagCompound();
    compound = nmsItemStack.save(compound);
    return compound.toString();
}
Also used : NBTTagCompound(net.minecraft.server.v1_12_R1.NBTTagCompound)

Example 65 with Item

use of net.minecraft.server.v1_12_R1.Item in project powerbot by powerbot.

the class DrawItems method repaint.

public void repaint(final Graphics render) {
    if (!ctx.game.loggedIn()) {
        return;
    }
    render.setFont(new Font("Arial", 0, 10));
    render.setColor(Color.green);
    for (final Item item : ctx.inventory.select()) {
        final Point p = item.centerPoint();
        p.translate(-21, -18);
        render.drawString(item.id() + "", p.x, p.y + 36);
    }
}
Also used : Item(org.powerbot.script.rt4.Item) Point(java.awt.Point) Font(java.awt.Font)

Aggregations

CraftItemStack (org.bukkit.craftbukkit.v1_12_R1.inventory.CraftItemStack)30 NBTTagCompound (net.minecraft.server.v1_12_R1.NBTTagCompound)27 ItemStack (org.bukkit.inventory.ItemStack)25 Item (org.orcid.jaxb.model.notification.permission_v2.Item)19 ItemMeta (org.bukkit.inventory.meta.ItemMeta)12 ArrayList (java.util.ArrayList)10 Player (org.bukkit.entity.Player)9 Field (java.lang.reflect.Field)7 PreparedStatement (java.sql.PreparedStatement)7 ItemStack (net.minecraft.server.v1_12_R1.ItemStack)7 Test (org.junit.Test)7 ExternalID (org.orcid.jaxb.model.record_v2.ExternalID)7 ResultSet (java.sql.ResultSet)6 SQLException (java.sql.SQLException)5 SimpleDateFormat (java.text.SimpleDateFormat)5 Date (java.util.Date)5 Item (net.minecraft.server.v1_12_R1.Item)5 NBTTagList (net.minecraft.server.v1_12_R1.NBTTagList)5 Location (org.bukkit.Location)5 OfflinePlayer (org.bukkit.OfflinePlayer)5