use of com.solinia.solinia.Exceptions.CoreStateInitException in project solinia3-core by mixxit.
the class CommandAddClass method onCommand.
@Override
public boolean onCommand(CommandSender sender, Command cmd, String label, String[] args) {
if (!(sender instanceof Player) && !(sender instanceof CommandSender)) {
sender.sendMessage("This is a Player/Console only command");
return false;
}
if (sender instanceof Player) {
Player player = (Player) sender;
if (!player.isOp()) {
player.sendMessage("This is an operator only command");
return true;
}
}
if (args.length < 2)
return false;
String classname = args[0];
boolean adminonly = Boolean.parseBoolean(args[1]);
try {
SoliniaClassFactory.CreateClass(classname, adminonly);
sender.sendMessage("* Class created");
} catch (CoreStateInitException | SoliniaClassCreationException e) {
// TODO Auto-generated catch block
e.printStackTrace();
sender.sendMessage("Error: " + e.getMessage());
return true;
}
return true;
}
use of com.solinia.solinia.Exceptions.CoreStateInitException in project solinia3-core by mixxit.
the class ChannelManager method sendItemToDiscordChannel.
private void sendItemToDiscordChannel(DiscordChannel discordChannel, ISoliniaItem item) {
String targetChannelId = getDefaultDiscordChannel();
if (discordChannel.equals(DiscordChannel.ADMIN))
targetChannelId = getAdminDiscordChannel();
String proc = "";
if (item.getWeaponabilityid() > 0) {
try {
ISoliniaSpell spell = StateManager.getInstance().getConfigurationManager().getSpell(item.getWeaponabilityid());
proc = "Chance to Proc on Hit: " + ChatColor.YELLOW + spell.getName() + ChatColor.RESET;
} catch (CoreStateInitException e) {
//
}
}
sendToDiscordMC(null, targetChannelId, "Item " + item.getId() + " (" + item.getDisplayname() + ") Base: " + item.getBasename() + " MinLevel: " + item.getMinLevel());
sendToDiscordMC(null, targetChannelId, "Damage " + item.getDamage() + " UndeadBaneDmg: " + item.getBaneUndead() + " AC: " + item.getAC() + " Proc: " + proc + " Worth: $" + item.getWorth());
sendToDiscordMC(null, targetChannelId, "Strength: " + item.getStrength() + " Stamina: " + item.getStamina() + " Agility: " + item.getAgility() + " Dexterity: " + item.getDexterity() + " Intelligence: " + item.getIntelligence() + " Wisdom: " + item.getWisdom() + " Charisma: " + item.getCharisma());
sendToDiscordMC(null, targetChannelId, "DR: " + item.getDiseaseResist() + " CR: " + item.getColdResist() + " FR: " + item.getFireResist() + " PR: " + item.getPoisonResist() + " MR: " + item.getMagicResist());
sendToDiscordMC(null, targetChannelId, "HP: " + item.getHp() + " Mana: " + item.getMana() + " HPRegen: " + item.getHpregen() + " MPRegen: " + item.getMpregen() + " Temporary: " + item.isTemporary() + " Augmentation " + item.isAugmentation() + " Quest: " + item.isQuest());
sendToDiscordMC(null, targetChannelId, "Accepts Aug Type: " + item.getAcceptsAugmentationSlotType().name() + " Fits Aug Types: " + item.getAugmentationFitsSlotType().name());
}
use of com.solinia.solinia.Exceptions.CoreStateInitException in project solinia3-core by mixxit.
the class Solinia3CorePlayerListener method onPlayerSwapHandItems.
@EventHandler
public void onPlayerSwapHandItems(PlayerSwapHandItemsEvent event) {
if (event.isCancelled())
return;
try {
ItemStack itemstack = event.getOffHandItem();
if (itemstack == null)
return;
if (Utils.IsSoliniaItem(itemstack) && !itemstack.getType().equals(Material.ENCHANTED_BOOK)) {
ISoliniaPlayer solplayer = SoliniaPlayerAdapter.Adapt((Player) event.getPlayer());
ISoliniaItem soliniaitem = StateManager.getInstance().getConfigurationManager().getItem(itemstack);
if (soliniaitem.getAllowedClassNames().size() == 0)
return;
if (solplayer.getClassObj() == null) {
Utils.CancelEvent(event);
;
event.getPlayer().sendMessage(ChatColor.GRAY + "Your class cannot wear this armour");
return;
}
if (!soliniaitem.getAllowedClassNames().contains(solplayer.getClassObj().getName().toUpperCase())) {
Utils.CancelEvent(event);
;
event.getPlayer().getPlayer().sendMessage(ChatColor.GRAY + "Your class cannot wear this armour");
return;
}
if (soliniaitem.getMinLevel() > solplayer.getLevel()) {
Utils.CancelEvent(event);
;
event.getPlayer().getPlayer().sendMessage(ChatColor.GRAY + "Your are not sufficient level wear this armour");
return;
}
solplayer.updateMaxHp();
}
} catch (CoreStateInitException e) {
}
}
use of com.solinia.solinia.Exceptions.CoreStateInitException in project solinia3-core by mixxit.
the class Solinia3CorePlayerListener method onPlayerInteract.
@EventHandler
public void onPlayerInteract(PlayerInteractEvent event) {
// We need it for spells
if (event.getAction() != Action.RIGHT_CLICK_AIR) {
if (event.isCancelled())
return;
}
try {
Timestamp mezExpiry = StateManager.getInstance().getEntityManager().getMezzed((LivingEntity) event.getPlayer());
if (mezExpiry != null) {
event.getPlayer().sendMessage("* You are mezzed!");
Utils.CancelEvent(event);
;
return;
}
} catch (CoreStateInitException e) {
}
// Handle changing armour
if ((event.getHand() == EquipmentSlot.HAND || event.getHand() == EquipmentSlot.OFF_HAND) && (event.getAction() == Action.RIGHT_CLICK_AIR || event.getAction() == Action.RIGHT_CLICK_BLOCK)) {
try {
Utils.checkArmourEquip(SoliniaPlayerAdapter.Adapt(event.getPlayer()), event);
} catch (CoreStateInitException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
}
try {
SoliniaPlayerAdapter.Adapt(event.getPlayer()).interact(plugin, event);
} catch (CoreStateInitException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
}
use of com.solinia.solinia.Exceptions.CoreStateInitException in project solinia3-core by mixxit.
the class Solinia3CorePlayerListener method onPlayerMove.
@EventHandler
public void onPlayerMove(PlayerMoveEvent event) {
try {
if (StateManager.getInstance().getEntityManager().getTrance(event.getPlayer().getUniqueId()) == true) {
StateManager.getInstance().getEntityManager().setTrance(event.getPlayer().getUniqueId(), false);
}
Timestamp mezExpiry = StateManager.getInstance().getEntityManager().getMezzed((LivingEntity) event.getPlayer());
if (mezExpiry != null) {
event.getPlayer().sendMessage("* You are mezzed!");
if (event.getTo().getY() < event.getFrom().getY()) {
event.getTo().setX(event.getFrom().getX());
event.getTo().setZ(event.getFrom().getZ());
event.getTo().setYaw(event.getFrom().getYaw());
event.getTo().setPitch(event.getFrom().getPitch());
} else {
event.getTo().setX(event.getFrom().getX());
event.getTo().setY(event.getFrom().getY());
event.getTo().setZ(event.getFrom().getZ());
event.getTo().setYaw(event.getFrom().getYaw());
event.getTo().setPitch(event.getFrom().getPitch());
}
return;
}
} catch (CoreStateInitException e) {
// do nothing
}
}
Aggregations