當前位置: 首頁>>代碼示例>>Java>>正文


Java ObjectMappingException類代碼示例

本文整理匯總了Java中ninja.leaping.configurate.objectmapping.ObjectMappingException的典型用法代碼示例。如果您正苦於以下問題:Java ObjectMappingException類的具體用法?Java ObjectMappingException怎麽用?Java ObjectMappingException使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。


ObjectMappingException類屬於ninja.leaping.configurate.objectmapping包,在下文中一共展示了ObjectMappingException類的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: SignsConfig

import ninja.leaping.configurate.objectmapping.ObjectMappingException; //導入依賴的package包/類
public SignsConfig(File baseDir) {
    super(baseDir, "signs");

    for (Object objKey : config.getChildrenMap().keySet()) {
        if (objKey instanceof String) {
            String key = (String) objKey;
            if (Utils.isInt(key)) {
                Set<DonorSign> signs = new HashSet<>();
                System.out.println("key " + key);
                try {
                    for (Location<World> loc : stringsToLocArray(config.getChildrenMap().get(objKey).getList(TypeToken.of(String.class)))) {
                        if (loc != null && loc.getTileEntity().isPresent() && loc.getTileEntity().get() instanceof Sign) {
                            System.out.println("2");
                            signs.add(new DonorSign(Utils.getInt(key), loc));
                        }
                    }
                } catch (ObjectMappingException e) {
                    e.printStackTrace();
                }
                donorSigns.put(Utils.getInt(key), signs);
            }
        }
    }
}
 
開發者ID:MinecraftMarket,項目名稱:MinecraftMarket-Plugin,代碼行數:25,代碼來源:SignsConfig.java

示例2: deserialize

import ninja.leaping.configurate.objectmapping.ObjectMappingException; //導入依賴的package包/類
@Override
public Location deserialize(TypeToken<?> typeToken, ConfigurationNode value) throws ObjectMappingException {
    String name = value.getNode("world").getValue(TypeToken.of(String.class));
    Double x = value.getNode("x").getValue(TypeToken.of(Double.class));
    Double y = value.getNode("y").getValue(TypeToken.of(Double.class));
    Double z = value.getNode("z").getValue(TypeToken.of(Double.class));

    Optional<World> optional = Sponge.getServer().getWorld(name);

    if (!optional.isPresent()) {
        throw new ObjectMappingException("Unknown world");
    }

    World world = optional.get();
    return world.getLocation(x, y, z);
}
 
開發者ID:Lergin,項目名稱:Vigilate,代碼行數:17,代碼來源:LocationSerializer.java

示例3: loadCameras

import ninja.leaping.configurate.objectmapping.ObjectMappingException; //導入依賴的package包/類
/**
 * loads the cameras from the config
 *
 * may only be called after the worlds of the server have been loaded
 */
public void loadCameras() {
    plugin.getCameras().clear();

    // yes i know it is bad to register it every time the config is loaded but i doesn't seem to work otherwise...
    TypeSerializers.getDefaultSerializers().registerType(TypeToken.of(Location.class), new LocationSerializer());

    config.getNode("cameras").getChildrenList().forEach((node) -> {
        try {
            Camera cam = node.getValue(TypeToken.of(Camera.class));
            cam.setLocation(node.getNode("location").getValue(TypeToken.of(Location.class)));
            plugin.getCameras().put(cam.getId(), cam);
        } catch (ObjectMappingException e) {
            System.out.println(TypeSerializers.getDefaultSerializers().get(TypeToken.of(Location.class)));
            logger.warn("Couldn't load Camera: " + e.getMessage());
        }
    });

    logger.info(String.format("Loaded %d Cameras", plugin.getCameras().size()));
}
 
開發者ID:Lergin,項目名稱:Vigilate,代碼行數:25,代碼來源:Config.java

示例4: initMcrmbCore

import ninja.leaping.configurate.objectmapping.ObjectMappingException; //導入依賴的package包/類
public static void initMcrmbCore() {
    commentedConfig = ConfigManager.get().getConfig();
    config.sid = commentedConfig.getNode("sid").getString();
    if (config.sid.equalsIgnoreCase("null")) {
        config.sid = null;
    }
    config.key = commentedConfig.getNode("key").getString();
    if (config.key.equalsIgnoreCase("null")) {
        config.key = null;
    }

    config.logApi = commentedConfig.getNode("logApi").getBoolean();
    config.renewOnJoin = commentedConfig.getNode("renewOnJoin").getBoolean();
    config.opModifyWhiteList = new ArrayList<>();
    try {
        config.opModifyWhiteList.addAll(commentedConfig.getNode("opModifyWhiteList").getList(TypeToken.of(String.class)));
    } catch (ObjectMappingException e) {
    }
    config.point = commentedConfig.getNode("point").getString().replace("&", "§");
    config.prefix = commentedConfig.getNode("prefix").getString().replace("&", "§");
    config.command = commentedConfig.getNode("command").getString();

}
 
開發者ID:txgs888,項目名稱:McrmbCore_Sponge,代碼行數:24,代碼來源:McrmbPluginInfo.java

示例5: createConfig

import ninja.leaping.configurate.objectmapping.ObjectMappingException; //導入依賴的package包/類
/**
 * Creates a config object of the specified type
 *
 * @param file The {@link Path} where the config file will be created
 * @param clazz The {@link Class} of the object that is being retrieved
 * @param loader The {@link ConfigurationLoader} that this config will use
 * @param <M> The type of object which will be created
 * @return The created config object, or null if an exception was thrown
 */
@SuppressWarnings("unchecked")
public <M extends BaseConfig> M createConfig(Path file, Class<M> clazz, ConfigurationLoader loader) {
    try {
        if (!Files.exists(file)) {
            Files.createFile(file);
        }

        TypeToken<M> token = TypeToken.of(clazz);
        ConfigurationNode node = loader.load(ConfigurationOptions.defaults().setObjectMapperFactory(this.factory));
        M config = node.getValue(token, clazz.newInstance());
        config.init(loader, node, token);
        config.save();
        return config;
    } catch (IOException | ObjectMappingException | IllegalAccessException | InstantiationException e) {
        e.printStackTrace();
        return null;
    }
}
 
開發者ID:NucleusPowered,項目名稱:Phonon,代碼行數:28,代碼來源:Phonon.java

示例6: setInternalValue

import ninja.leaping.configurate.objectmapping.ObjectMappingException; //導入依賴的package包/類
private <T> void setInternalValue(T storageHandler) {
    if (storageHandler instanceof ConfigurationNode) {
        ConfigurationNode node = ((ConfigurationNode) storageHandler).getNode(this.key.get());
        if (this.comment != null && node instanceof CommentedConfigurationNode) {
            ((CommentedConfigurationNode) node).setComment(this.comment);
        }

        if (this.modified) {
            if (this.valueTypeToken != null) {
                try {
                    node.setValue(this.valueTypeToken, this.value);
                } catch (ObjectMappingException e) {
                    e.printStackTrace();
                }
            } else {
                node.setValue(this.value);
            }
            this.modified = false;
        }
    }
}
 
開發者ID:ichorpowered,項目名稱:elderguardian,代碼行數:22,代碼來源:StorageValue.java

示例7: deserializeForKeys

import ninja.leaping.configurate.objectmapping.ObjectMappingException; //導入依賴的package包/類
private <T, U extends BaseValue<T>> void deserializeForKeys(
        ConfigurationNode node, DataQuery dataQuery, BiConsumer<Key<U>, T> consumer) throws InvalidDataException
{
    if (KEYS.containsKey(dataQuery))
    {
        try
        {
            @SuppressWarnings("unchecked")
            Key<U> key = (Key<U>) KEYS.get(dataQuery);
            @SuppressWarnings("unchecked")
            TypeToken<T> elementToken = (TypeToken<T>) key.getElementToken();
            consumer.accept(key, Optional.ofNullable(node.getValue(elementToken))
                    .orElseThrow(() -> new InvalidDataException("No value present")));
        }
        catch (ObjectMappingException e)
        {
            throw new InvalidDataException(e);
        }
    }
    else if (!EXCEPTIONS.contains(dataQuery))
    {
        throw new InvalidDataException("No matched query present");
    }
}
 
開發者ID:ustc-zzzz,項目名稱:VirtualChest,代碼行數:25,代碼來源:VirtualChestItemStackSerializer.java

示例8: deserialize

import ninja.leaping.configurate.objectmapping.ObjectMappingException; //導入依賴的package包/類
@Override
public CuboidRegion deserialize(TypeToken<?> type, ConfigurationNode value) throws ObjectMappingException {
    int aX = value.getNode("parA", "x").getInt();
    int aY = value.getNode("parA", "y").getInt();
    int aZ = value.getNode("parA", "z").getInt();

    int bX = value.getNode("parB", "x").getInt();
    int bY = value.getNode("parB", "y").getInt();
    int bZ = value.getNode("parB", "z").getInt();

    // Check for degenerate dimensions (distance of 0)
    if (aX == bX) {
        bX++;
    }
    if (aY == bY) {
        bY++;
    }
    if (aZ == bZ) {
        bZ++;
    }

    return new CuboidRegion(new Vector3i(aX, aY, aZ), new Vector3i(bX, bY, bZ));
}
 
開發者ID:Zerthick,項目名稱:PlayerShopsRPG,代碼行數:24,代碼來源:CuboidRegionSerializer.java

示例9: deserialize

import ninja.leaping.configurate.objectmapping.ObjectMappingException; //導入依賴的package包/類
@Override
public Shop deserialize(TypeToken<?> type, ConfigurationNode value) throws ObjectMappingException {
    UUID shopUUID = value.getNode("shopUUID").getValue(TypeToken.of(UUID.class));
    String name = value.getNode("shopName").getString();
    UUID ownerUUID = value.getNode("ownerUUID").getValue(TypeToken.of(UUID.class));
    UUID renterUUID = value.getNode("renterUUID").getValue(TypeToken.of(UUID.class));
    Set<UUID> managerUUIDset = new HashSet<>(value.getNode("managerSet").getList(TypeToken.of(UUID.class)));
    Map<UUID, ShopItem> items = value.getNode("items").getList(TypeToken.of(ShopItem.class)).stream().collect(Collectors.toMap(ShopItem::getShopItemUUID, shopItem -> shopItem));
    boolean unlimitedMoney = value.getNode("unlimitedMoney").getBoolean();
    boolean unlimitedStock = value.getNode("unlimitedStock").getBoolean();
    String shopType = value.getNode("type").getString();
    double price = value.getNode("price").getDouble(-1);
    double rent = value.getNode("rent").getDouble(-1);

    return new Shop(shopUUID, name, ownerUUID, renterUUID, managerUUIDset, items, unlimitedMoney, unlimitedStock, shopType, price, rent, null);
}
 
開發者ID:Zerthick,項目名稱:PlayerShopsRPG,代碼行數:17,代碼來源:ShopSerializer.java

示例10: serialize

import ninja.leaping.configurate.objectmapping.ObjectMappingException; //導入依賴的package包/類
@Override
public void serialize(TypeToken<?> type, Shop obj, ConfigurationNode value) throws ObjectMappingException {
    value.getNode("shopUUID").setValue(TypeToken.of(UUID.class), obj.getUUID());
    value.getNode("shopName").setValue(obj.getName());
    value.getNode("ownerUUID").setValue(TypeToken.of(UUID.class), obj.getOwnerUUID().orElse(null));
    value.getNode("renterUUID").setValue(TypeToken.of(UUID.class), obj.getRenterUUID());
    Set<UUID> managerUUIDSet = obj.getManagerUUIDSet();
    value.getNode("managerSet").setValue(new TypeToken<List<UUID>>() {
    }, new ArrayList<>(managerUUIDSet));
    value.getNode("items").setValue(new TypeToken<List<ShopItem>>() {
    }, new ArrayList<>(obj.getItems().values()));
    value.getNode("unlimitedMoney").setValue(obj.isUnlimitedMoney());
    value.getNode("unlimitedStock").setValue(obj.isUnlimitedStock());
    value.getNode("type").setValue(obj.getType());
    value.getNode("price").setValue(obj.getPrice());
    value.getNode("rent").setValue(obj.getRent());
}
 
開發者ID:Zerthick,項目名稱:PlayerShopsRPG,代碼行數:18,代碼來源:ShopSerializer.java

示例11: onPreInit

import ninja.leaping.configurate.objectmapping.ObjectMappingException; //導入依賴的package包/類
@Listener //During this state, the plugin gets ready for initialization. Logger and config
public void onPreInit(GamePreInitializationEvent preInitEvent) {
    logger.info("Setting up config");

    rootNode = configManager.createEmptyNode();
    try {
        configMapper = ObjectMapper.forClass(ColorConsoleConfig.class).bindToNew();

        rootNode = configManager.load();
        configMapper.populate(rootNode);

        //add and save missing values
        configMapper.serialize(rootNode);
        configManager.save(rootNode);
    } catch (IOException | ObjectMappingException ioEx) {
        logger.error("Cannot save default config", ioEx);
        return;
    }

    installLogFormat();
}
 
開發者ID:games647,項目名稱:ColorConsole,代碼行數:22,代碼來源:ColorConsoleSponge.java

示例12: getList

import ninja.leaping.configurate.objectmapping.ObjectMappingException; //導入依賴的package包/類
public EMessageBuilder getList(String name, EMessageBuilder builder, ConfigurationNode node, boolean prefix) {
  	try {
	List<String> messages = node.getList(TypeToken.of(String.class));
	if (!messages.isEmpty()) {
  			if (this.plugin.getChat() != null) {
  				builder.chat(new EFormatListString(this.plugin.getChat().replace(messages)), prefix);
  			} else {
  				builder.chat(new EFormatListString(node.getList(TypeToken.of(String.class))), prefix);
  			}
	}
} catch (ObjectMappingException e) {
	this.plugin.getELogger().warn("Impossible de charger la liste des messages : '" + name + "'");
	builder.chat(new EFormatString(name), false);
}
return builder;
  }
 
開發者ID:EverCraft,項目名稱:EverAPI,代碼行數:17,代碼來源:EMessage.java

示例13: loadData

import ninja.leaping.configurate.objectmapping.ObjectMappingException; //導入依賴的package包/類
synchronized public void loadData() throws IOException, ObjectMappingException {
	HoconConfigurationLoader loader = getDataLoader();
	ConfigurationNode rootNode = loader.load();

	List<Kit> kitsList = rootNode.getNode("Kits").getList(TypeToken.of(Kit.class));
	this.kits = new HashMap<String, Kit>();
	for (Kit kit : kitsList) {
		this.kits.put(kit.getName().toLowerCase(), kit);
	}

	List<PlayerData> playersDataList = rootNode.getNode("PlayersData").getList(TypeToken.of(PlayerData.class));
	this.playersData = new HashMap<UUID, PlayerData>();
	for (PlayerData pd : playersDataList) {
		this.playersData.put(pd.getPlayerUUID(), pd);
	}
}
 
開發者ID:KaiKikuchi,項目名稱:BetterKits,代碼行數:17,代碼來源:BetterKits.java

示例14: registerCollection

import ninja.leaping.configurate.objectmapping.ObjectMappingException; //導入依賴的package包/類
public void registerCollection(String collection) {
	if (collection.equals(PermissionService.SUBJECTS_DEFAULT)) return;
	
	ConfigurationNode config = this.get("collections." + collection).getNode(EPConfig.DEFAULT);
	boolean save = false;
	
	List<String> worlds = new ArrayList<String>();
	try {
		worlds.addAll(config.getList(TypeToken.of(String.class)));
	} catch (ObjectMappingException e) {}
	
	for (World world : this.plugin.getGame().getServer().getWorlds()) {
		if (this.getTypeWorld(collection, world.getName()).equals(EPConfig.DEFAULT) && !worlds.contains(world.getName())) {
			worlds.add(world.getName());
			save = true;
		}
	}
	
	config.setValue(worlds);
	if (config.isVirtual()) {
		config.setValue(ImmutableList.of());
		save = true;
	}
	
	if (save) this.save(true);
}
 
開發者ID:EverCraft,項目名稱:EverPermissions,代碼行數:27,代碼來源:EPConfig.java

示例15: registerWorld

import ninja.leaping.configurate.objectmapping.ObjectMappingException; //導入依賴的package包/類
public void registerWorld(String world) {
	boolean save = false;
	
	for (String collection : this.getCollections()) {
		if (!this.getWorld(collection, world).isPresent()) {
			CommentedConfigurationNode config = this.get("collections." + collection).getNode(EPConfig.DEFAULT);
			
			try {
				List<String> worlds = new ArrayList<String>();
				worlds.addAll(config.getList(TypeToken.of(String.class)));
				worlds.add(world);
				config.setValue(worlds);
				
				save = true;
			} catch (ObjectMappingException e) {}
		}
	}
	
	if (save) this.save(true);
}
 
開發者ID:EverCraft,項目名稱:EverPermissions,代碼行數:21,代碼來源:EPConfig.java


注:本文中的ninja.leaping.configurate.objectmapping.ObjectMappingException類示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。