use of pw.codehusky.huskycrates.lang.SharedLangData in project HuskyCrates-Sponge by codeHusky.
the class CrateRewardHolderParser method fromConfig.
public static CrateRewardHolder fromConfig(ConfigurationNode holderNode, VirtualCrate vc) {
ItemStack dispItem = itemFromNode(holderNode);
CrateReward reward = new CrateReward(null, "CODE ERROR, CONTACT DEVELOPER", false);
boolean dispAwardSimilar = false;
String name;
boolean single = false;
SharedLangData langData = HuskyCrates.instance.langData;
if (!holderNode.getNode("huskydata", "lang").isVirtual()) {
langData = new SharedLangData(vc.langData, holderNode.getNode("huskydata", "lang"));
}
//System.out.println(dispItem.get(Keys.DISPLAY_NAME));
if (holderNode.getNode("huskydata", "reward").getNode("overrideRewardName").isVirtual()) {
//System.out.println("Virtual");
if (dispItem.get(Keys.DISPLAY_NAME).isPresent()) {
name = dispItem.get(Keys.DISPLAY_NAME).get().toPlain();
} else {
name = dispItem.getItem().getName();
}
} else {
//System.out.println("Real");
name = holderNode.getNode("huskydata", "reward").getNode("overrideRewardName").getString("strings, please.");
}
if (!holderNode.getNode("huskydata", "reward").getNode("treatAsSingle").isVirtual()) {
single = holderNode.getNode("huskydata", "reward").getNode("treatAsSingle").getBoolean();
}
if (holderNode.getNode("huskydata", "reward", "type").getString().equalsIgnoreCase("item")) {
ItemStack rewardItem;
if (holderNode.getNode("huskydata", "reward").getNode("overrideItem").isVirtual()) {
ItemStack rr = dispItem.copy();
if (!holderNode.getNode("huskydata", "reward").getNode("overrideCount").isVirtual()) {
rr.setQuantity(holderNode.getNode("huskydata", "reward").getNode("overrideCount").getInt());
}
reward = new CrateReward(rr, name, single);
dispAwardSimilar = true;
} else {
reward = new CrateReward(itemFromNode(holderNode.getNode("huskydata", "reward", "overrideItem")), name, single);
}
} else if (holderNode.getNode("huskydata", "reward", "type").getString().equalsIgnoreCase("command")) {
reward = new CrateReward(holderNode.getNode("huskydata", "reward", "command").getString("/say You didn't set a command or something..."), name, single);
} else {
System.out.println("?! Invalid Reward Type !? " + holderNode.getNode("huskydata", "reward", "type").getString());
}
return new CrateRewardHolder(dispItem, reward, holderNode.getNode("huskydata", "weight").getDouble(1), dispAwardSimilar, langData);
}
use of pw.codehusky.huskycrates.lang.SharedLangData in project HuskyCrates-Sponge by codeHusky.
the class HuskyCrates method gameReloaded.
@Listener
public void gameReloaded(GameReloadEvent event) {
for (World bit : Sponge.getServer().getWorlds()) {
for (Entity ent : bit.getEntities()) {
if (ent instanceof ArmorStand) {
ArmorStand arm = (ArmorStand) ent;
if (arm.getCreator().isPresent()) {
if (arm.getCreator().get().equals(UUID.fromString(armorStandIdentifier))) {
arm.remove();
}
}
}
}
}
langData = new SharedLangData("", "You won %a %R&rfrom a %C&r!", "&e%p just won %a %R&r&e from a %C&r!", "You need a %K&r to open this crate.");
CommentedConfigurationNode conf = null;
try {
conf = crateConfig.load();
if (!conf.getNode("lang").isVirtual())
langData = new SharedLangData(conf.getNode("lang"));
else
logger.info("Using default lang settings.");
} catch (IOException e) {
e.printStackTrace();
logger.warn("Lang load failed, using defaults.");
}
crateUtilities.generateVirtualCrates(crateConfig);
CommentedConfigurationNode root = null;
try {
root = crateConfig.load();
for (CommentedConfigurationNode node : root.getNode("positions").getChildrenList()) {
Location<World> ee;
try {
ee = node.getNode("location").getValue(TypeToken.of(Location.class));
} catch (InvalidDataException err2) {
logger.warn("Bug sponge developers about world UUIDs!");
ee = new Location<World>(Sponge.getServer().getWorld(node.getNode("location", "WorldName").getString()).get(), node.getNode("location", "X").getDouble(), node.getNode("location", "Y").getDouble(), node.getNode("location", "Z").getDouble());
}
if (!crateUtilities.physicalCrates.containsKey(ee))
crateUtilities.physicalCrates.put(ee, new PhysicalCrate(ee, node.getNode("crateID").getString(), HuskyCrates.instance));
}
} catch (IOException e) {
e.printStackTrace();
} catch (ObjectMappingException e) {
e.printStackTrace();
}
crateUtilities.startParticleEffects();
}
use of pw.codehusky.huskycrates.lang.SharedLangData in project HuskyCrates-Sponge by codeHusky.
the class HuskyCrates method gameInit.
@Listener
public void gameInit(GamePreInitializationEvent event) {
logger = LoggerFactory.getLogger(pC.getName());
CommentedConfigurationNode conf = null;
try {
conf = crateConfig.load();
if (!conf.getNode("lang").isVirtual()) {
langData = new SharedLangData(conf.getNode("lang"));
} else
logger.info("Using default lang settings.");
} catch (IOException e) {
e.printStackTrace();
logger.warn("Lang load failed, using defaults.");
}
logger.info("Let's not init VCrates here anymore. ://)");
instance = this;
}
Aggregations