use of com.solinia.solinia.Interfaces.ISoliniaPlayer in project solinia3-core by mixxit.
the class ConfigurationManager method commitPlayersToCharacterLists.
private void commitPlayersToCharacterLists() {
try {
int count = 0;
for (ISoliniaPlayer player : StateManager.getInstance().getPlayerManager().getPlayers()) {
commitPlayerToCharacterLists(player);
count++;
}
System.out.println("Commited " + count + " characters to the CharacterList repository");
} catch (CoreStateInitException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
}
use of com.solinia.solinia.Interfaces.ISoliniaPlayer in project solinia3-core by mixxit.
the class Solinia3CorePlayerListener method onPlayerRespawn.
@EventHandler
public void onPlayerRespawn(PlayerRespawnEvent event) {
try {
ISoliniaPlayer solplayer = SoliniaPlayerAdapter.Adapt(event.getPlayer());
if (solplayer != null) {
solplayer.updateMaxHp();
if (solplayer.getBindPoint() != null && !solplayer.getBindPoint().equals("")) {
String[] loc = solplayer.getBindPoint().split(",");
Location location = new Location(Bukkit.getWorld(loc[0]), Double.parseDouble(loc[1]), Double.parseDouble(loc[2]), Double.parseDouble(loc[3]));
event.setRespawnLocation(location);
event.getPlayer().teleport(location);
}
}
} catch (CoreStateInitException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
}
use of com.solinia.solinia.Interfaces.ISoliniaPlayer in project solinia3-core by mixxit.
the class SoliniaNPC method processChatInteractionEvent.
@Override
public void processChatInteractionEvent(SoliniaLivingEntity solentity, LivingEntity triggerentity, String data) {
String[] words = data.split(" ");
// Merchant special commands
if (words.length > 0) {
// Check player has sufficient faction
if (triggerentity instanceof Player)
if (solentity.getNpcid() > 0) {
try {
ISoliniaNPC npc = StateManager.getInstance().getConfigurationManager().getNPC(solentity.getNpcid());
if (npc.getFactionid() > 0) {
ISoliniaPlayer solPlayer = SoliniaPlayerAdapter.Adapt((Player) triggerentity);
PlayerFactionEntry factionEntry = solPlayer.getFactionEntry(npc.getFactionid());
if (factionEntry != null) {
switch(Utils.getFactionStandingType(factionEntry.getFactionId(), factionEntry.getValue())) {
case FACTION_THREATENLY:
case FACTION_SCOWLS:
solentity.emote("* " + npc.getName() + " scowls angrily at " + solPlayer.getFullName());
return;
default:
break;
}
}
}
} catch (CoreStateInitException e) {
}
}
switch(words[0].toUpperCase()) {
case "SHOP":
if (triggerentity instanceof Player)
if (getMerchantid() > 0) {
if (words.length == 1) {
sendMerchantItemListToPlayer((Player) triggerentity, 1);
return;
}
int page = 1;
try {
page = Integer.parseInt(words[1]);
} catch (Exception e) {
}
if (page < 1)
page = 1;
sendMerchantItemListToPlayer((Player) triggerentity, page);
}
return;
case "LISTEFFECTS":
if (triggerentity instanceof Player) {
if (((Player) triggerentity).isOp()) {
Player player = (Player) triggerentity;
try {
for (SoliniaActiveSpell spell : StateManager.getInstance().getEntityManager().getActiveEntitySpells(solentity.getBukkitLivingEntity()).getActiveSpells()) {
player.sendMessage(spell.getSpell().getName());
for (ActiveSpellEffect effect : spell.getActiveSpellEffects()) {
player.sendMessage(" - " + effect.getSpellEffectType().name() + " " + effect.getBase());
}
}
} catch (CoreStateInitException e) {
//
}
}
}
return;
default:
break;
}
}
// Normal text matching
for (ISoliniaNPCEventHandler handler : getEventHandlers()) {
if (!handler.getInteractiontype().equals(InteractionType.CHAT))
continue;
if (!data.toUpperCase().contains(handler.getTriggerdata().toUpperCase()))
continue;
if (handler.getChatresponse() != null && !handler.getChatresponse().equals("")) {
if ((triggerentity instanceof Player)) {
if (!handler.playerMeetsRequirements((Player) triggerentity))
return;
}
String response = handler.getChatresponse();
solentity.say(replaceChatWordsWithHints(response), triggerentity);
if (triggerentity instanceof Player)
handler.awardPlayer((Player) triggerentity);
if (handler.getTeleportResponse() != null && !handler.getTeleportResponse().equals("")) {
if (triggerentity instanceof Player) {
String[] zonedata = handler.getTeleportResponse().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]);
Location loc = new Location(Bukkit.getWorld(world), x, y, z);
((Player) triggerentity).teleport(loc);
}
}
}
}
return;
}
use of com.solinia.solinia.Interfaces.ISoliniaPlayer in project solinia3-core by mixxit.
the class SoliniaLivingEntity method checkHitChance.
@Override
public boolean checkHitChance(SoliniaLivingEntity attacker, DamageHitInfo hit) {
ISoliniaLivingEntity defender = this;
if (defender.isPlayer()) {
try {
ISoliniaPlayer player = SoliniaPlayerAdapter.Adapt((Player) defender.getBukkitLivingEntity());
if (player.isMeditating()) {
return true;
}
} catch (CoreStateInitException e) {
// ignore it
}
}
int avoidance = defender.getTotalDefense();
int accuracy = hit.tohit;
// if (accuracy == -1)
// return true;
double hitRoll = Utils.RandomBetween(0, (int) Math.floor(accuracy));
double avoidRoll = Utils.RandomBetween(0, (int) Math.floor(avoidance));
// tie breaker? Don't want to be biased any one way
return hitRoll > avoidRoll;
}
use of com.solinia.solinia.Interfaces.ISoliniaPlayer in project solinia3-core by mixxit.
the class SoliniaLivingEntity method getStrength.
@Override
public int getStrength() {
if (getNpcid() < 1 && !isPlayer())
return 1;
try {
if (getNpcid() > 0) {
ISoliniaNPC npc = StateManager.getInstance().getConfigurationManager().getNPC(getNpcid());
if (npc == null)
return 1;
int stat = npc.getLevel() * 5;
stat += Utils.getTotalEffectStat(this.getBukkitLivingEntity(), "STRENGTH");
if (stat > getMaxStat("STRENGTH"))
stat = getMaxStat("STRENGTH");
return stat;
}
if (isPlayer()) {
ISoliniaPlayer solplayer = SoliniaPlayerAdapter.Adapt((Player) getBukkitLivingEntity());
if (solplayer == null)
return 1;
int stat = 1;
if (solplayer.getRace() != null)
stat += solplayer.getRace().getStrength();
stat += solplayer.getTotalItemStat("STRENGTH");
stat += Utils.getTotalEffectStat(this.getBukkitLivingEntity(), "STRENGTH");
stat += Utils.getTotalAAEffectStat(this.getBukkitLivingEntity(), "STRENGTH");
if (stat > getMaxStat("STRENGTH"))
stat = getMaxStat("STRENGTH");
return stat;
}
} catch (CoreStateInitException e) {
return 1;
}
return 1;
}
Aggregations