use of com.solinia.solinia.Interfaces.ISoliniaItem in project solinia3-core by mixxit.
the class Solinia3CorePlayerListener method onPlayerConsumeEvent.
@EventHandler
public void onPlayerConsumeEvent(PlayerItemConsumeEvent event) {
if (event.isCancelled())
return;
try {
ISoliniaItem item = SoliniaItemAdapter.Adapt(event.getItem());
item.consume(plugin, event.getPlayer());
} catch (SoliniaItemException | CoreStateInitException e) {
}
}
use of com.solinia.solinia.Interfaces.ISoliniaItem in project solinia3-core by mixxit.
the class ChannelManager method sendItemListToDiscordChannel.
private void sendItemListToDiscordChannel(DiscordChannel discordChannel, String itemMatch) {
try {
String targetChannelId = getDefaultDiscordChannel();
if (discordChannel.equals(DiscordChannel.ADMIN))
targetChannelId = getAdminDiscordChannel();
int itemId = 0;
try {
itemId = StateManager.getInstance().getConfigurationManager().getItem(Integer.parseInt(itemMatch)).getId();
} catch (Exception e) {
}
if (itemId > 0) {
ISoliniaItem item = StateManager.getInstance().getConfigurationManager().getItem(itemId);
sendItemToDiscordChannel(discordChannel, item);
return;
}
if (itemMatch.length() < 3) {
sendToDiscordMC(null, targetChannelId, "Item search must be at least 3 characters: " + itemMatch);
return;
}
List<ISoliniaItem> items = StateManager.getInstance().getConfigurationManager().getItemsByPartialName(itemMatch);
if (items.size() > 20) {
sendToDiscordMC(null, targetChannelId, "Item matched more than 20 items, please be more specific than " + itemMatch);
return;
}
if (items.size() != 1) {
List<String> matchingItemList = new ArrayList<String>();
String currentLine = "";
for (ISoliniaItem item : items) {
if ((currentLine + "[" + item.getId() + "] " + item.getDisplayname() + " ").length() > 2000) {
matchingItemList.add(currentLine);
currentLine = "";
}
currentLine += "[" + item.getId() + "] " + item.getDisplayname() + " ";
}
if (!currentLine.equals("")) {
matchingItemList.add(currentLine);
}
for (String line : matchingItemList) {
sendToDiscordMC(null, targetChannelId, "Item [" + itemMatch + "] matched with: " + line);
}
} else {
for (ISoliniaItem item : items) {
sendItemToDiscordChannel(discordChannel, item);
}
}
} catch (CoreStateInitException e) {
// ignore it
}
}
use of com.solinia.solinia.Interfaces.ISoliniaItem 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.ISoliniaItem in project solinia3-core by mixxit.
the class SoliniaNPCEventHandler method editTriggerEventSetting.
@Override
public void editTriggerEventSetting(String setting, String value) throws InvalidNPCEventSettingException {
switch(setting.toLowerCase()) {
case "randomisedgearsuffix":
setRandomisedGearSuffix(value);
break;
case "title":
setTitle(value);
break;
case "awardstitle":
setAwardsTitle(Boolean.parseBoolean(value));
break;
case "triggerdata":
if (value.equals(""))
throw new InvalidNPCEventSettingException("Triggerdata is empty");
if (value.contains(" "))
throw new InvalidNPCEventSettingException("Triggerdata can only be one value");
setTriggerdata(value.toUpperCase());
break;
case "chatresponse":
if (value.equals(""))
throw new InvalidNPCEventSettingException("Chatresponse is empty");
setChatresponse(value);
break;
case "requiresquest":
int questid = Integer.parseInt(value);
if (questid < 1)
throw new InvalidNPCEventSettingException("Invalid quest id");
try {
ISoliniaQuest quest = StateManager.getInstance().getConfigurationManager().getQuest(questid);
if (quest == null)
throw new InvalidNPCEventSettingException("Invalid quest id");
} catch (CoreStateInitException e) {
throw new InvalidNPCEventSettingException("State not initialised");
}
setRequiresQuest(questid);
break;
case "awardsquest":
int aquestid = Integer.parseInt(value);
if (aquestid < 1)
throw new InvalidNPCEventSettingException("Invalid quest id");
try {
ISoliniaQuest quest = StateManager.getInstance().getConfigurationManager().getQuest(aquestid);
if (quest == null)
throw new InvalidNPCEventSettingException("Invalid quest id");
} catch (CoreStateInitException e) {
throw new InvalidNPCEventSettingException("State not initialised");
}
setAwardsQuest(aquestid);
break;
case "requiresquestflag":
setRequiresQuestFlag(value);
break;
case "awardsquestflag":
setAwardsQuestFlag(value);
break;
case "teleportresponse":
try {
String[] zonedata = value.split(",");
// Dissasemble the value to ensure it is correct
String world = zonedata[0];
double x = Double.parseDouble(zonedata[1]);
double y = Double.parseDouble(zonedata[2]);
double z = Double.parseDouble(zonedata[3]);
setTeleportResponse(world + "," + x + "," + y + "," + z);
break;
} catch (Exception e) {
throw new InvalidNPCEventSettingException("Teleport zone value must be in format: world,x,y,z");
}
case "awardsrandomisedgear":
setAwardsRandomisedGear(Boolean.parseBoolean(value));
break;
case "awardsitem":
int itemId = Integer.parseInt(value);
if (itemId < 1)
throw new InvalidNPCEventSettingException("Invalid item ID");
if (getAwardsQuestFlag() == null || getAwardsQuestFlag().equals(""))
throw new InvalidNPCEventSettingException("You cannot set an awardsitem to a npc event handler unless the npc awards a quest flag - this is to prevent duplicated awards");
try {
ISoliniaItem item = StateManager.getInstance().getConfigurationManager().getItem(itemId);
if (item == null)
throw new InvalidNPCEventSettingException("Invalid item id");
} catch (CoreStateInitException e) {
throw new InvalidNPCEventSettingException("State not initialised");
}
setAwardsItem(itemId);
break;
default:
throw new InvalidNPCEventSettingException("Invalid NPC Event setting. Valid Options are: triggerdata,chatresponse,interactiontype,requiresquest,awardsquest,requiresquestflag,awardsquestflag,awardsitem");
}
}
use of com.solinia.solinia.Interfaces.ISoliniaItem in project solinia3-core by mixxit.
the class SoliniaPlayer method getTotalResist.
@Override
public int getTotalResist(SpellResistType type) {
int total = 0;
// Get resist total from all active effects
try {
total += SoliniaLivingEntityAdapter.Adapt(getBukkitPlayer()).getResistsFromActiveEffects(type);
int effectId = 0;
switch(type) {
case RESIST_FIRE:
effectId = Utils.getEffectIdFromEffectType(SpellEffectType.ResistFire);
break;
case RESIST_COLD:
effectId = Utils.getEffectIdFromEffectType(SpellEffectType.ResistCold);
break;
case RESIST_MAGIC:
effectId = Utils.getEffectIdFromEffectType(SpellEffectType.ResistMagic);
break;
case RESIST_POISON:
effectId = Utils.getEffectIdFromEffectType(SpellEffectType.ResistPoison);
break;
case RESIST_DISEASE:
effectId = Utils.getEffectIdFromEffectType(SpellEffectType.ResistDisease);
break;
default:
break;
}
if (effectId > 0) {
for (SoliniaAARankEffect effect : this.getRanksEffectsOfEffectType(effectId)) {
total += effect.getBase1();
}
}
int resistAllEffectId = Utils.getEffectIdFromEffectType(SpellEffectType.ResistAll);
for (SoliniaAARankEffect effect : this.getRanksEffectsOfEffectType(resistAllEffectId)) {
total += effect.getBase1();
}
} catch (CoreStateInitException e) {
// Skip
}
for (ISoliniaItem item : this.getEquippedSoliniaItems()) {
switch(type) {
case RESIST_FIRE:
if (item.getFireResist() > 0) {
total += item.getFireResist();
}
break;
case RESIST_COLD:
if (item.getColdResist() > 0) {
total += item.getColdResist();
}
break;
case RESIST_MAGIC:
if (item.getMagicResist() > 0) {
total += item.getMagicResist();
}
break;
case RESIST_POISON:
if (item.getPoisonResist() > 0) {
total += item.getPoisonResist();
}
break;
case RESIST_DISEASE:
if (item.getDiseaseResist() > 0) {
total += item.getDiseaseResist();
}
break;
default:
break;
}
}
if (total > 255)
return 255;
return total;
}
Aggregations