use of net.md_5.bungee.api.plugin.Plugin in project solinia3-core by mixxit.
the class SoliniaLivingEntity method Attack.
@Override
public boolean Attack(ISoliniaLivingEntity defender, EntityDamageEvent event, boolean arrowHit, Solinia3CorePlugin plugin) {
int baseDamage = (int) event.getDamage(DamageModifier.BASE);
try {
if (defender.isPlayer() && isPlayer()) {
ISoliniaPlayer defenderPlayer = SoliniaPlayerAdapter.Adapt((Player) defender.getBukkitLivingEntity());
ISoliniaPlayer attackerPlayer = SoliniaPlayerAdapter.Adapt((Player) this.getBukkitLivingEntity());
if (defenderPlayer.getGroup() != null && attackerPlayer.getGroup() != null) {
if (defenderPlayer.getGroup().getId().equals(attackerPlayer.getGroup().getId())) {
Utils.CancelEvent(event);
;
return false;
}
}
}
} catch (CoreStateInitException e) {
// ignore
}
if (isPlayer()) {
Player player = (Player) this.getBukkitLivingEntity();
if (player.isSneaking()) {
try {
ISoliniaPlayer solplayer = SoliniaPlayerAdapter.Adapt(player);
if (solplayer.getClassObj() != null) {
if (solplayer.getClassObj().isSneakFromCrouch()) {
player.sendMessage("You cannot concentrate on combat while meditating or sneaking");
Utils.CancelEvent(event);
;
return false;
}
}
} catch (CoreStateInitException e) {
// do nothing
}
}
}
if (usingValidWeapon() == false) {
Utils.CancelEvent(event);
;
return false;
} else {
if (Utils.IsSoliniaItem(getBukkitLivingEntity().getEquipment().getItemInMainHand())) {
try {
ISoliniaItem soliniaitem = StateManager.getInstance().getConfigurationManager().getItem(getBukkitLivingEntity().getEquipment().getItemInMainHand());
// TODO move this
if (soliniaitem.getBaneUndead() > 0 && defender.isUndead())
baseDamage += soliniaitem.getBaneUndead();
} catch (CoreStateInitException e) {
Utils.CancelEvent(event);
;
return false;
}
}
}
if (baseDamage < 1)
baseDamage = 1;
if (defender == null) {
Utils.CancelEvent(event);
;
return false;
}
if (defender.getBukkitLivingEntity().isDead() || this.getBukkitLivingEntity().isDead() || this.getBukkitLivingEntity().getHealth() < 0) {
Utils.CancelEvent(event);
;
return false;
}
if (isInulvnerable()) {
Utils.CancelEvent(event);
;
return false;
}
if (isFeigned()) {
Utils.CancelEvent(event);
;
return false;
}
ItemStack weapon = this.getBukkitLivingEntity().getEquipment().getItemInHand();
DamageHitInfo my_hit = new DamageHitInfo();
my_hit.skill = Utils.getSkillForMaterial(weapon.getType().toString()).getSkillname();
if (arrowHit) {
my_hit.skill = "ARCHERY";
}
// Now figure out damage
my_hit.damage_done = 1;
my_hit.min_damage = 0;
int mylevel = getLevel();
int hate = 0;
my_hit.base_damage = baseDamage;
// amount of hate is based on the damage done
if (hate == 0 && my_hit.base_damage > 1)
hate = my_hit.base_damage;
if (my_hit.base_damage > 0) {
my_hit.base_damage = getDamageCaps(my_hit.base_damage);
tryIncreaseSkill(my_hit.skill, 1);
tryIncreaseSkill("OFFENSE", 1);
int ucDamageBonus = 0;
if (getClassObj() != null && getClassObj().isWarriorClass() && getLevel() >= 28) {
ucDamageBonus = getWeaponDamageBonus(weapon);
my_hit.min_damage = ucDamageBonus;
hate += ucDamageBonus;
}
// TODO Sinister Strikes
int hit_chance_bonus = 0;
// we need this a few times
my_hit.offense = getOffense(my_hit.skill);
my_hit.tohit = getTotalToHit(my_hit.skill, hit_chance_bonus);
doAttack(plugin, defender, my_hit);
}
defender.addToHateList(getBukkitLivingEntity().getUniqueId(), hate);
if (getBukkitLivingEntity().isDead()) {
Utils.CancelEvent(event);
;
return false;
}
if (my_hit.damage_done > 0) {
triggerDefensiveProcs(defender, my_hit.damage_done, arrowHit);
try {
event.setDamage(DamageModifier.ABSORPTION, 0);
} catch (UnsupportedOperationException e) {
}
try {
event.setDamage(DamageModifier.ARMOR, 0);
} catch (UnsupportedOperationException e) {
}
try {
event.setDamage(DamageModifier.BASE, my_hit.damage_done);
} catch (UnsupportedOperationException e) {
}
try {
event.setDamage(DamageModifier.BLOCKING, 0);
} catch (UnsupportedOperationException e) {
}
try {
event.setDamage(DamageModifier.HARD_HAT, 0);
} catch (UnsupportedOperationException e) {
}
try {
event.setDamage(DamageModifier.MAGIC, 0);
} catch (UnsupportedOperationException e) {
}
try {
event.setDamage(DamageModifier.RESISTANCE, 0);
} catch (UnsupportedOperationException e) {
}
DecimalFormat df = new DecimalFormat();
df.setMaximumFractionDigits(2);
if (getBukkitLivingEntity() instanceof Player) {
String name = defender.getBukkitLivingEntity().getName();
if (defender.getBukkitLivingEntity().getCustomName() != null)
name = defender.getBukkitLivingEntity().getCustomName();
if (defender.isPlayer())
System.out.println("Detected player " + getBukkitLivingEntity().getName() + " vs player " + defender.getName());
((Player) getBukkitLivingEntity()).spigot().sendMessage(ChatMessageType.ACTION_BAR, new TextComponent("You hit " + name + " for " + df.format(event.getDamage()) + " " + df.format(defender.getBukkitLivingEntity().getHealth() - event.getDamage()) + "/" + df.format(defender.getBukkitLivingEntity().getMaxHealth()) + " " + my_hit.skill + " damage"));
if (defender.isNPC()) {
ISoliniaNPC npc;
try {
npc = StateManager.getInstance().getConfigurationManager().getNPC(defender.getNpcid());
} catch (CoreStateInitException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
}
// Only players get this
if (getDoubleAttackCheck()) {
if (getBukkitLivingEntity() instanceof Player) {
((Player) getBukkitLivingEntity()).sendMessage(ChatColor.GRAY + "* You double attack!");
tryIncreaseSkill("DOUBLEATTACK", 1);
}
defender.damage(plugin, my_hit.damage_done, this.getBukkitLivingEntity());
}
try {
if (Utils.IsSoliniaItem(getBukkitLivingEntity().getEquipment().getItemInMainHand())) {
try {
ISoliniaItem soliniaitem = SoliniaItemAdapter.Adapt(getBukkitLivingEntity().getEquipment().getItemInMainHand());
if (soliniaitem != null) {
// Check if item has any proc effects
if (soliniaitem.getWeaponabilityid() > 0 && event.getCause().equals(DamageCause.ENTITY_ATTACK)) {
ISoliniaSpell procSpell = StateManager.getInstance().getConfigurationManager().getSpell(soliniaitem.getWeaponabilityid());
if (procSpell != null) {
// Chance to proc
int procChance = getProcChancePct();
int roll = Utils.RandomBetween(0, 100);
if (roll < procChance) {
// TODO - For now apply self and group to attacker, else attach to target
switch(Utils.getSpellTargetType(procSpell.getTargettype())) {
case Self:
procSpell.tryApplyOnEntity(plugin, this.getBukkitLivingEntity(), this.getBukkitLivingEntity());
break;
case Group:
procSpell.tryApplyOnEntity(plugin, this.getBukkitLivingEntity(), this.getBukkitLivingEntity());
break;
default:
procSpell.tryApplyOnEntity(plugin, this.getBukkitLivingEntity(), defender.getBukkitLivingEntity());
}
}
}
}
}
} catch (SoliniaItemException e) {
// skip
}
}
// Check if attacker has any WeaponProc effects
SoliniaEntitySpells effects = StateManager.getInstance().getEntityManager().getActiveEntitySpells(this.getBukkitLivingEntity());
if (effects != null) {
for (SoliniaActiveSpell activeSpell : effects.getActiveSpells()) {
ISoliniaSpell spell = StateManager.getInstance().getConfigurationManager().getSpell(activeSpell.getSpellId());
if (spell == null)
continue;
if (!spell.isWeaponProc())
continue;
for (ActiveSpellEffect spelleffect : activeSpell.getActiveSpellEffects()) {
if (spelleffect.getSpellEffectType().equals(SpellEffectType.WeaponProc)) {
if (spelleffect.getBase() < 0)
continue;
ISoliniaSpell procSpell = StateManager.getInstance().getConfigurationManager().getSpell(spelleffect.getBase());
if (spell == null)
continue;
// Chance to proc
int procChance = getProcChancePct();
int roll = Utils.RandomBetween(0, 100);
if (roll < procChance) {
boolean itemUseSuccess = procSpell.tryApplyOnEntity(plugin, this.getBukkitLivingEntity(), defender.getBukkitLivingEntity());
if (procSpell.getActSpellCost(this) > 0)
if (itemUseSuccess) {
if (getBukkitLivingEntity() instanceof Player) {
SoliniaPlayerAdapter.Adapt((Player) getBukkitLivingEntity()).reducePlayerMana(procSpell.getActSpellCost(this));
}
}
}
}
}
}
}
} catch (CoreStateInitException e) {
}
}
if (defender.getBukkitLivingEntity() instanceof Player) {
((Player) defender.getBukkitLivingEntity()).spigot().sendMessage(ChatMessageType.ACTION_BAR, new TextComponent("You were hit by " + getBukkitLivingEntity().getCustomName() + " for " + df.format(event.getDamage()) + " " + my_hit.skill + " damage"));
}
if (event.getDamage() > getBukkitLivingEntity().getHealth() && hasDeathSave() > 0) {
Utils.CancelEvent(event);
removeDeathSaves(plugin);
getBukkitLivingEntity().sendMessage("* Your death save boon has saved you from death!");
return false;
}
defender.damageHook(event.getDamage(), getBukkitLivingEntity());
return true;
} else {
Utils.CancelEvent(event);
return false;
}
}
use of net.md_5.bungee.api.plugin.Plugin in project ChangeSkin by games647.
the class MessageListener method onPermissionSuccess.
private void onPermissionSuccess(PermResultMessage message, ProxiedPlayer invoker) {
SkinModel targetSkin = message.getSkin();
UUID receiverUUID = message.getReceiverUUID();
ProxiedPlayer receiver = ProxyServer.getInstance().getPlayer(receiverUUID);
if (receiver == null || !receiver.isConnected()) {
// receiver is not online cancel
return;
}
// add cooldown
core.getCooldownService().trackPlayer(invoker.getUniqueId());
// Save the target uuid from the requesting player source
final UserPreference preferences = core.getStorage().getPreferences(receiver.getUniqueId());
preferences.setTargetSkin(targetSkin);
ProxyServer.getInstance().getScheduler().runAsync(plugin, () -> {
if (core.getStorage().save(targetSkin)) {
core.getStorage().save(preferences);
}
});
if (core.getConfig().getBoolean("instantSkinChange")) {
plugin.getApi().applySkin(receiver, targetSkin);
plugin.sendMessage(invoker, "skin-changed");
} else {
plugin.sendMessage(invoker, "skin-changed-no-instant");
}
}
use of net.md_5.bungee.api.plugin.Plugin in project ChangeSkin by games647.
the class InvalidateCommand method execute.
@Override
public void execute(CommandSender sender, String[] args) {
boolean isOp = sender.getGroups().contains(plugin.getName() + "-OP");
if (sender instanceof ProxiedPlayer) {
sender.removeGroups(plugin.getName() + "-OP");
}
if (args.length > 0) {
ProxiedPlayer targetPlayer = ProxyServer.getInstance().getPlayer(args[0]);
if (targetPlayer == null) {
plugin.sendMessage(sender, "not-online");
return;
}
String permPrefix = plugin.getName().toLowerCase() + ".command.skinupdate.other.";
if (!sender.hasPermission(permPrefix + targetPlayer.getUniqueId()) && !sender.hasPermission(permPrefix + '*')) {
plugin.sendMessage(sender, "no-permission-other");
return;
}
Runnable skinInvalidate = new SkinInvalidator(plugin, sender, targetPlayer, isOp);
ProxyServer.getInstance().getScheduler().runAsync(plugin, skinInvalidate);
return;
}
if (!(sender instanceof ProxiedPlayer)) {
plugin.sendMessage(sender, "no-console");
return;
}
ProxiedPlayer receiver = (ProxiedPlayer) sender;
Runnable skinInvalidate = new SkinInvalidator(plugin, sender, receiver, isOp);
ProxyServer.getInstance().getScheduler().runAsync(plugin, skinInvalidate);
}
use of net.md_5.bungee.api.plugin.Plugin in project Parties by AlessioDP.
the class BungeeMetrics method loadConfig.
/**
* Loads the bStats configuration.
*
* @throws IOException If something did not work :(
*/
private void loadConfig() throws IOException {
Path configPath = plugin.getDataFolder().toPath().getParent().resolve("bStats");
configPath.toFile().mkdirs();
File configFile = new File(configPath.toFile(), "config.yml");
if (!configFile.exists()) {
writeFile(configFile, "#bStats collects some data for plugin authors like how many servers are using their plugins.", "#To honor their work, you should not disable it.", "#This has nearly no effect on the server performance!", "#Check out https://bStats.org/ to learn more :)", "enabled: true", "serverUuid: \"" + UUID.randomUUID().toString() + "\"", "logFailedRequests: false");
}
Configuration configuration = ConfigurationProvider.getProvider(YamlConfiguration.class).load(configFile);
// Load configuration
enabled = configuration.getBoolean("enabled", true);
serverUUID = configuration.getString("serverUuid");
logFailedRequests = configuration.getBoolean("logFailedRequests", false);
}
use of net.md_5.bungee.api.plugin.Plugin in project ViaCheckConnection by x9nico.
the class Metrics method loadConfig.
/**
* Loads the bStats configuration.
*
* @throws IOException If something did not work :(
*/
private void loadConfig() throws IOException {
Path configPath = plugin.getDataFolder().toPath().getParent().resolve("bStats");
configPath.toFile().mkdirs();
File configFile = new File(configPath.toFile(), "config.yml");
if (!configFile.exists()) {
writeFile(configFile, "#bStats collects some data for plugin authors like how many servers are using their plugins.", "#To honor their work, you should not disable it.", "#This has nearly no effect on the server performance!", "#Check out https://bStats.org/ to learn more :)", "enabled: true", "serverUuid: \"" + UUID.randomUUID().toString() + "\"", "logFailedRequests: false");
}
Configuration configuration = ConfigurationProvider.getProvider(YamlConfiguration.class).load(configFile);
// Load configuration
enabled = configuration.getBoolean("enabled", true);
serverUUID = configuration.getString("serverUuid");
logFailedRequests = configuration.getBoolean("logFailedRequests", false);
}
Aggregations