use of com.solinia.solinia.Interfaces.ISoliniaLootDrop in project solinia3-core by mixxit.
the class JsonLootDropRepository method reload.
@Override
public void reload() {
List<ISoliniaLootDrop> file = new ArrayList<ISoliniaLootDrop>();
try {
GsonBuilder gsonbuilder = new GsonBuilder();
gsonbuilder.registerTypeAdapterFactory(new ISoliniaLootDropEntryTypeAdapterFactory(SoliniaLootDropEntry.class));
Gson gson = gsonbuilder.create();
BufferedReader br = new BufferedReader(new FileReader(filePath));
file = gson.fromJson(br, new TypeToken<List<SoliniaLootDrop>>() {
}.getType());
} catch (FileNotFoundException e) {
e.printStackTrace();
}
lootdrops.clear();
for (ISoliniaLootDrop i : file) {
lootdrops.put(i.getId(), i);
}
System.out.println("Reloaded " + lootdrops.size() + " lootdrops");
}
use of com.solinia.solinia.Interfaces.ISoliniaLootDrop in project solinia3-core by mixxit.
the class MythicMobsNPCEntityProvider method createNpcFile.
public String createNpcFile(ISoliniaNPC npc) {
String mob = "";
String uniquename = "NPCID_" + npc.getId();
if (npc.getMctype() == null)
return "";
mob = uniquename + ":\r\n";
mob = mob + " Type: " + npc.getMctype() + "\r\n";
if (npc.isUpsidedown() == true) {
mob = mob + " Display: Dinnerbone\r\n";
} else {
mob = mob + " Display: " + npc.getName() + "\r\n";
}
double hp = Utils.getStatMaxHP(npc.getClassObj(), npc.getLevel(), 75);
double damage = Utils.getMaxDamage(npc.getLevel(), 75);
if (npc.isHeroic()) {
hp += (Utils.getHeroicHPMultiplier() * npc.getLevel());
damage += (Utils.getHeroicDamageMultiplier() * npc.getLevel());
}
if (npc.isBoss()) {
hp += (Utils.getBossHPMultiplier() * npc.getLevel());
damage += (Utils.getBossDamageMultiplier() * npc.getLevel());
}
if (npc.isRaidheroic()) {
hp += (Utils.getRaidHeroicHPMultiplier() * npc.getLevel());
damage += (Utils.getRaidHeroicDamageMultiplier() * npc.getLevel());
}
if (npc.isRaidboss()) {
hp += (Utils.getRaidBossHPMultiplier() * npc.getLevel());
damage += (Utils.getRaidBossDamageMultiplier() * npc.getLevel());
}
float movementSpeed = 0.3f;
if (npc.isHeroic()) {
movementSpeed = Utils.getHeroicRunSpeed();
}
if (npc.isBoss()) {
movementSpeed = Utils.getBossRunSpeed();
}
if (npc.isRaidheroic()) {
movementSpeed = Utils.getRaidHeroicRunSpeed();
}
if (npc.isRaidboss()) {
movementSpeed = Utils.getRaidBossRunSpeed();
}
mob = mob + " Health: " + hp + "\r\n";
mob = mob + " Damage: " + damage + "\r\n";
mob = mob + " MaxCombatDistance: 25\r\n";
mob = mob + " PreventOtherDrops: true\r\n";
mob = mob + " PreventRandomEquipment: true\r\n";
mob = mob + " Options:\r\n";
mob = mob + " MovementSpeed: " + movementSpeed + "\r\n";
mob = mob + " KnockbackResistance: 0.75\r\n";
mob = mob + " PreventMobKillDrops: true\r\n";
mob = mob + " PreventOtherDrops: true\r\n";
mob = mob + " Silent: true\r\n";
mob = mob + " ShowHealth: true\r\n";
mob = mob + " PreventRenaming: true\r\n";
mob = mob + " PreventRandomEquipment: true\r\n";
mob = mob + " AlwaysShowName: true\r\n";
mob = mob + " Modules:\r\n";
mob = mob + " ThreatTable: false\r\n";
if (npc.isPet()) {
mob = mob + " Faction: FACTIONID_-1\r\n";
} else {
mob = mob + " Faction: FACTIONID_" + npc.getFactionid() + "\r\n";
}
// Act as normal mob if without faction
if (npc.getFactionid() > 0 || npc.isPet()) {
mob = mob + " AIGoalSelectors:\r\n";
mob = mob + " - 0 clear\r\n";
mob = mob + " - 1 skeletonbowattack\r\n";
mob = mob + " - 2 meleeattack\r\n";
mob = mob + " - 3 lookatplayers\r\n";
if (npc.isRoamer()) {
mob = mob + " - 4 randomstroll\r\n";
}
mob = mob + " AITargetSelectors:\r\n";
mob = mob + " - 0 clear\r\n";
mob = mob + " - 1 attacker\r\n";
// NPC attack players
if (!npc.isPet()) {
try {
ISoliniaFaction npcfaction = StateManager.getInstance().getConfigurationManager().getFaction(npc.getFactionid());
if (npcfaction.getBase() == -1500) {
mob = mob + " - 2 players\r\n";
}
} catch (CoreStateInitException e) {
// skip
}
}
// NPC attack NPCs
if (npc.isGuard() || npc.isPet()) {
// Always attack mobs with factionid 0
mob = mob + " - 3 SpecificFaction FACTIONID_0\r\n";
// Attack all mobs with -1500 faction
try {
int curnum = 4;
for (ISoliniaFaction faction : StateManager.getInstance().getConfigurationManager().getFactions()) {
if (faction.getBase() == -1500 && faction.getId() != npc.getFactionid()) {
mob = mob + " - " + curnum + " SpecificFaction FACTIONID_" + faction.getId() + "\r\n";
curnum++;
}
}
} catch (CoreStateInitException e) {
// skip
}
}
}
// then go ahead and use it! Better than that crap we have right?
if (npc.getLoottableid() > 0) {
try {
ISoliniaLootTable lootTable = StateManager.getInstance().getConfigurationManager().getLootTable(npc.getLoottableid());
if (lootTable != null) {
List<ISoliniaItem> potentialChestArmour = new ArrayList<ISoliniaItem>();
List<ISoliniaItem> potentialLegsArmour = new ArrayList<ISoliniaItem>();
List<ISoliniaItem> potentialFeetArmour = new ArrayList<ISoliniaItem>();
List<ISoliniaItem> potentialWeapons = new ArrayList<ISoliniaItem>();
List<ISoliniaItem> potentialBows = new ArrayList<ISoliniaItem>();
List<ISoliniaItem> potentialShields = new ArrayList<ISoliniaItem>();
for (ISoliniaLootTableEntry loottableentry : lootTable.getEntries()) {
ISoliniaLootDrop lootdrop = StateManager.getInstance().getConfigurationManager().getLootDrop(loottableentry.getLootdropid());
for (ISoliniaLootDropEntry lootdropentry : lootdrop.getEntries()) {
ISoliniaItem item = StateManager.getInstance().getConfigurationManager().getItem(lootdropentry.getItemid());
if (ConfigurationManager.ArmourMaterials.contains(item.getBasename().toUpperCase())) {
if (item.getAllowedClassNames().size() == 0) {
if (item.getBasename().contains("CHESTPLATE"))
potentialChestArmour.add(item);
if (item.getBasename().contains("LEGGINGS"))
potentialLegsArmour.add(item);
if (item.getBasename().contains("BOOTS"))
potentialFeetArmour.add(item);
continue;
}
if (npc.getClassObj() != null) {
if (item.getAllowedClassNames().contains(npc.getClassObj().getName())) {
if (item.getBasename().contains("CHESTPLATE"))
potentialChestArmour.add(item);
if (item.getBasename().contains("LEGGINGS"))
potentialLegsArmour.add(item);
if (item.getBasename().contains("BOOTS"))
potentialFeetArmour.add(item);
continue;
}
}
}
if (ConfigurationManager.WeaponMaterials.contains(item.getBasename().toUpperCase())) {
if (item.getAllowedClassNames().size() == 0) {
if (item.getBasename().contains("SHIELD"))
potentialShields.add(item);
else if (item.getBasename().contains("BOW"))
potentialBows.add(item);
else
potentialWeapons.add(item);
continue;
}
if (npc.getClassObj() != null) {
if (item.getAllowedClassNames().contains(npc.getClassObj().getName())) {
if (item.getBasename().contains("SHIELD"))
potentialShields.add(item);
else
potentialWeapons.add(item);
continue;
}
}
}
if (ConfigurationManager.HandMaterials.contains(item.getBasename().toUpperCase())) {
if (item.getAllowedClassNames().size() == 0) {
if (item.getBasename().contains("SHIELD"))
potentialShields.add(item);
else if (item.getBasename().contains("BOW"))
potentialBows.add(item);
else
potentialWeapons.add(item);
continue;
}
if (npc.getClassObj() != null) {
if (item.getAllowedClassNames().contains(npc.getClassObj().getName())) {
if (item.getBasename().contains("SHIELD"))
potentialShields.add(item);
else
potentialWeapons.add(item);
continue;
}
}
}
}
mob = mob + " Equipment:\r\n";
if (potentialShields.size() > 0) {
Collections.sort(potentialShields, new Comparator<ISoliniaItem>() {
public int compare(ISoliniaItem o1, ISoliniaItem o2) {
if (o1.getMinLevel() == o2.getMinLevel())
return 0;
return o1.getMinLevel() > o2.getMinLevel() ? -1 : 1;
}
});
Collections.reverse(potentialShields);
System.out.println("Found better shield in lootdrop (" + potentialWeapons.get(0).getDisplayname() + "), using as shield");
writeCustomItem("plugins/MythicMobs/Items/CUSTOMITEMID" + potentialWeapons.get(0).getId() + ".yml", potentialWeapons.get(0));
mob = mob + " - " + "CUSTOMITEMID_" + potentialWeapons.get(0).getId() + ":5\r\n";
} else {
if (npc.getOffhanditem() != null)
mob = mob + " - " + npc.getOffhanditem() + ":5\r\n";
}
if (npc.isCustomhead() == true) {
if (npc.getCustomheaddata() != null) {
mob = mob + " - CUSTOMHEADNPCID_" + npc.getId() + ":4\r\n";
} else {
if (npc.getHeaditem() != null)
mob = mob + " - " + npc.getHeaditem() + ":4\r\n";
}
} else {
if (npc.getHeaditem() != null)
mob = mob + " - " + npc.getHeaditem() + ":4\r\n";
}
if (potentialChestArmour.size() > 0) {
Collections.sort(potentialChestArmour, new Comparator<ISoliniaItem>() {
public int compare(ISoliniaItem o1, ISoliniaItem o2) {
if (o1.getMinLevel() == o2.getMinLevel())
return 0;
return o1.getMinLevel() > o2.getMinLevel() ? -1 : 1;
}
});
Collections.reverse(potentialChestArmour);
System.out.println("Found better chest in lootdrop (" + potentialChestArmour.get(0).getDisplayname() + "), using as chest");
writeCustomItem("plugins/MythicMobs/Items/CUSTOMITEMID" + potentialChestArmour.get(0).getId() + ".yml", potentialChestArmour.get(0));
mob = mob + " - " + "CUSTOMITEMID_" + potentialChestArmour.get(0).getId() + ":3\r\n";
} else {
if (npc.getChestitem() != null)
mob = mob + " - " + npc.getChestitem() + ":3\r\n";
}
if (potentialLegsArmour.size() > 0) {
Collections.sort(potentialLegsArmour, new Comparator<ISoliniaItem>() {
public int compare(ISoliniaItem o1, ISoliniaItem o2) {
if (o1.getMinLevel() == o2.getMinLevel())
return 0;
return o1.getMinLevel() > o2.getMinLevel() ? -1 : 1;
}
});
Collections.reverse(potentialLegsArmour);
System.out.println("Found better legs in lootdrop (" + potentialLegsArmour.get(0).getDisplayname() + "), using as weapon");
writeCustomItem("plugins/MythicMobs/Items/CUSTOMITEMID" + potentialLegsArmour.get(0).getId() + ".yml", potentialLegsArmour.get(0));
mob = mob + " - " + "CUSTOMITEMID_" + potentialLegsArmour.get(0).getId() + ":2\r\n";
} else {
if (npc.getLegsitem() != null)
mob = mob + " - " + npc.getLegsitem() + ":2\r\n";
}
if (potentialFeetArmour.size() > 0) {
Collections.sort(potentialFeetArmour, new Comparator<ISoliniaItem>() {
public int compare(ISoliniaItem o1, ISoliniaItem o2) {
if (o1.getMinLevel() == o2.getMinLevel())
return 0;
return o1.getMinLevel() > o2.getMinLevel() ? -1 : 1;
}
});
Collections.reverse(potentialFeetArmour);
System.out.println("Found better feet in lootdrop (" + potentialFeetArmour.get(0).getDisplayname() + "), using as feet");
writeCustomItem("plugins/MythicMobs/Items/CUSTOMITEMID" + potentialFeetArmour.get(0).getId() + ".yml", potentialFeetArmour.get(0));
mob = mob + " - " + "CUSTOMITEMID_" + potentialFeetArmour.get(0).getId() + ":1\r\n";
} else {
if (npc.getFeetitem() != null)
mob = mob + " - " + npc.getFeetitem() + ":1\r\n";
}
if (npc.getClassObj() != null && npc.getClassObj().getName().toUpperCase().equals("RANGER") && potentialBows.size() > 0) {
Collections.sort(potentialBows, new Comparator<ISoliniaItem>() {
public int compare(ISoliniaItem o1, ISoliniaItem o2) {
if (o1.getMinLevel() == o2.getMinLevel())
return 0;
return o1.getMinLevel() > o2.getMinLevel() ? -1 : 1;
}
});
Collections.reverse(potentialBows);
System.out.println("Found better weapon (bow) in lootdrop (" + potentialBows.get(0).getDisplayname() + "), using as weapon");
writeCustomItem("plugins/MythicMobs/Items/CUSTOMITEMID" + potentialBows.get(0).getId() + ".yml", potentialBows.get(0));
mob = mob + " - " + "CUSTOMITEMID_" + potentialBows.get(0).getId() + ":0\r\n";
} else {
if (potentialWeapons.size() > 0) {
Collections.sort(potentialWeapons, new Comparator<ISoliniaItem>() {
public int compare(ISoliniaItem o1, ISoliniaItem o2) {
if (o1.getMinLevel() == o2.getMinLevel())
return 0;
return o1.getMinLevel() > o2.getMinLevel() ? -1 : 1;
}
});
Collections.reverse(potentialWeapons);
System.out.println("Found better weapon in lootdrop (" + potentialWeapons.get(0).getDisplayname() + "), using as weapon");
writeCustomItem("plugins/MythicMobs/Items/CUSTOMITEMID" + potentialWeapons.get(0).getId() + ".yml", potentialWeapons.get(0));
mob = mob + " - " + "CUSTOMITEMID_" + potentialWeapons.get(0).getId() + ":0\r\n";
} else {
if (npc.getHanditem() != null)
mob = mob + " - " + npc.getHanditem() + ":0\r\n";
}
}
}
}
} catch (CoreStateInitException e) {
// skip
}
} else {
if (npc.getHeaditem() != null || npc.getChestitem() != null || npc.getLegsitem() != null || npc.getFeetitem() != null || npc.getHanditem() != null || npc.getOffhanditem() != null) {
mob = mob + " Equipment:\r\n";
if (npc.getOffhanditem() != null)
mob = mob + " - " + npc.getOffhanditem() + ":5\r\n";
if (npc.isCustomhead() == true) {
if (npc.getCustomheaddata() != null) {
mob = mob + " - CUSTOMHEADNPCID_" + npc.getId() + ":4\r\n";
} else {
if (npc.getHeaditem() != null)
mob = mob + " - " + npc.getHeaditem() + ":4\r\n";
}
} else {
if (npc.getHeaditem() != null)
mob = mob + " - " + npc.getHeaditem() + ":4\r\n";
}
if (npc.getChestitem() != null)
mob = mob + " - " + npc.getChestitem() + ":3\r\n";
if (npc.getLegsitem() != null)
mob = mob + " - " + npc.getLegsitem() + ":2\r\n";
if (npc.getFeetitem() != null)
mob = mob + " - " + npc.getFeetitem() + ":1\r\n";
if (npc.getHanditem() != null)
mob = mob + " - " + npc.getHanditem() + ":0\r\n";
}
}
if (npc.isUsedisguise() == true) {
mob = mob + " Disguise:\r\n";
if (npc.getDisguisetype().toLowerCase().contains("player-")) {
mob = mob + " Type: player\r\n";
} else {
mob = mob + " Type: " + npc.getDisguisetype() + "\r\n";
}
if (npc.isBurning() == true) {
mob = mob + " Burning: true\r\n";
}
if (npc.getDisguisetype().toLowerCase().contains("player-")) {
String[] disguisedata = npc.getDisguisetype().split("-");
mob = mob + " Player: " + npc.getName() + "\r\n";
mob = mob + " Skin: '" + disguisedata[1] + "'\r\n";
}
}
if (npc.isBoss() == true || npc.isRaidboss()) {
/*
mob = mob + " BossBar:\r\n";
mob = mob + " Enabled: true\r\n";
mob = mob + " Title: " + npc.getName() + "\r\n";
mob = mob + " Range: 200\r\n";
mob = mob + " CreateFog: true\r\n";
mob = mob + " DarkenSky: true\r\n";
mob = mob + " PlayMusic: true\r\n";
*/
if (npc.getDisguisetype() != null)
if (npc.getDisguisetype().toLowerCase().contains("player-")) {
String[] disguisedata = npc.getDisguisetype().split("-");
mob = mob + " Player: " + npc.getName() + "\r\n";
mob = mob + " Skin: '" + disguisedata[1] + "'\r\n";
}
}
mob = mob + " Skills:\r\n";
if (npc.isInvisible() == true) {
mob = mob + " - potion{t=INVISIBILITY;d=2147483647;l=1} @self ~onSpawn\r\n";
}
return mob;
}
use of com.solinia.solinia.Interfaces.ISoliniaLootDrop in project solinia3-core by mixxit.
the class SoliniaLootTable method sendLootTableSettingsToSender.
@Override
public void sendLootTableSettingsToSender(CommandSender sender) {
try {
for (ISoliniaLootTableEntry le : getEntries()) {
ISoliniaLootDrop ld = StateManager.getInstance().getConfigurationManager().getLootDrop(le.getLootdropid());
sender.sendMessage("- " + ChatColor.GOLD + ld.getName().toUpperCase() + ChatColor.RESET + "[" + ld.getId() + "]:");
for (ISoliniaLootDropEntry lde : ld.getEntries()) {
ISoliniaItem i = StateManager.getInstance().getConfigurationManager().getItem(lde.getItemid());
sender.sendMessage(" - " + ChatColor.GOLD + i.getDisplayname() + ChatColor.RESET + "[" + i.getId() + "] - " + lde.getChance() + "% chance Count: " + lde.getCount() + " Always: " + lde.isAlways());
}
}
} catch (CoreStateInitException e) {
sender.sendMessage(e.getMessage());
}
}
use of com.solinia.solinia.Interfaces.ISoliniaLootDrop in project solinia3-core by mixxit.
the class CommandCreateAllArmourSets method onCommand.
@Override
public boolean onCommand(CommandSender sender, Command cmd, String label, String[] args) {
if (!(sender instanceof Player) && !(sender instanceof CommandSender))
return false;
try {
if (sender instanceof Player) {
Player player = (Player) sender;
if (!player.isOp() && !player.hasPermission("solinia.createallarmorsets")) {
player.sendMessage("You do not have permission to access this command");
return false;
}
}
if (args.length < 3) {
return false;
}
// args
// lootdropid
// armourtier
// chance
// suffixname
int lootdropid = Integer.parseInt(args[0]);
int armourtier = Integer.parseInt(args[1]);
ISoliniaLootDrop lootdrop = StateManager.getInstance().getConfigurationManager().getLootDrop(lootdropid);
if (lootdrop == null) {
sender.sendMessage("Lootdrop ID does not exist");
return true;
}
if (lootdrop.isOperatorCreated() && !sender.isOp()) {
sender.sendMessage("This lootdrop was op created and you are not an op. Only ops can edit op lootdrop items");
return false;
}
int chance = Integer.parseInt(args[2]);
if (chance < 1 || chance > 100) {
sender.sendMessage("Chance must be between 1 and 100");
return true;
}
String partialname = "";
int count = 0;
for (String entry : args) {
if (count < 3) {
count++;
continue;
}
partialname += entry + " ";
count++;
}
partialname = partialname.trim();
if (partialname.equals("")) {
sender.sendMessage("Blank suffix name not allowed when creating armour set");
return false;
}
String itemscreated = "";
for (ISoliniaClass classEntry : StateManager.getInstance().getConfigurationManager().getClasses()) {
List<Integer> items = SoliniaItemFactory.CreateClassItemSet(classEntry, armourtier, partialname, true, sender.isOp());
for (Integer item : items) {
SoliniaLootFactory.CreateLootDropItem(lootdropid, item, 1, false, chance, sender.isOp());
itemscreated += item + " ";
}
}
sender.sendMessage("Created items as IDs: " + itemscreated + " with " + chance + "% chance in lootdrop: " + lootdropid);
} catch (CoreStateInitException e) {
sender.sendMessage(e.getMessage());
} catch (SoliniaItemException e) {
// TODO Auto-generated catch block
sender.sendMessage(e.getMessage());
}
return true;
}
use of com.solinia.solinia.Interfaces.ISoliniaLootDrop in project solinia3-core by mixxit.
the class CommandEditLootDrop method onCommand.
@Override
public boolean onCommand(CommandSender sender, Command cmd, String label, String[] args) {
if (!(sender instanceof Player) && !(sender instanceof CommandSender))
return false;
if (sender instanceof Player) {
Player player = (Player) sender;
if (!player.isOp() && !player.hasPermission("solinia.editlootdrop")) {
player.sendMessage("You do not have permission to access this command");
return false;
}
}
if (args.length < 1) {
sender.sendMessage("Insufficient arguments: lootdropid");
return false;
}
if (args.length == 0) {
return false;
}
int LootDropid = Integer.parseInt(args[0]);
if (args.length == 1) {
try {
ISoliniaLootDrop LootDrop = StateManager.getInstance().getConfigurationManager().getLootDrop(LootDropid);
if (LootDrop != null) {
LootDrop.sendLootDropSettingsToSender(sender);
} else {
sender.sendMessage("LootDrop ID doesnt exist");
}
return true;
} catch (CoreStateInitException e) {
sender.sendMessage(e.getMessage());
}
}
if (args.length < 3) {
sender.sendMessage("Insufficient arguments: LootDropid setting value");
return false;
}
String setting = args[1];
String value = args[2];
if (LootDropid < 1) {
sender.sendMessage("Invalid LootDrop id");
return false;
}
try {
if (StateManager.getInstance().getConfigurationManager().getLootDrop(LootDropid) == null) {
sender.sendMessage("Cannot locate LootDrop id: " + LootDropid);
return false;
}
if (StateManager.getInstance().getConfigurationManager().getLootDrop(LootDropid).isOperatorCreated() && !sender.isOp()) {
sender.sendMessage("This lootdrop was op created and you are not an op. Only ops can edit op lootdrop items");
return false;
}
StateManager.getInstance().getConfigurationManager().editLootDrop(LootDropid, setting, value);
sender.sendMessage("Updating setting on LootDrop");
} catch (InvalidLootDropSettingException ne) {
sender.sendMessage("Invalid LootDrop setting: " + ne.getMessage());
} catch (CoreStateInitException e) {
// TODO Auto-generated catch block
sender.sendMessage(e.getMessage());
}
return true;
}
Aggregations