Search in sources :

Example 6 with Tuple

use of net.minecraft.server.v1_15_R1.Tuple in project solinia3-core by mixxit.

the class SoliniaZonesDynmapTimer method GetStripsX.

public static HashMap<String, List<Point>> GetStripsX(HashMap<Point, Boolean> rows) {
    HashMap<String, List<Point>> strips = new HashMap<String, List<Point>>();
    int minX = rows.keySet().stream().min(Comparator.comparing(v -> v.x)).get().x;
    int minZ = rows.keySet().stream().min(Comparator.comparing(v -> v.y)).get().y;
    int maxX = rows.keySet().stream().max(Comparator.comparing(v -> v.x)).get().x;
    int maxZ = rows.keySet().stream().max(Comparator.comparing(v -> v.y)).get().y;
    // System.out.println("minX: " + minX);
    // System.out.println("minZ: " + minZ);
    // System.out.println("maxX: " + maxX);
    // System.out.println("maxZ: " + maxZ);
    Tuple<String, List<Point>> newStrip = null;
    for (int x = minX; x <= maxX; x++) {
        for (int z = minZ; z <= maxZ; z++) {
            // System.out.println("x: " + x + " z: " + z);
            if (!rows.containsKey(new Point(x, z))) {
                // Skip it and save last Strip
                if (newStrip != null) {
                    strips.put(newStrip.a(), newStrip.b());
                    newStrip = null;
                }
                continue;
            }
            if (newStrip == null) {
                newStrip = new Tuple<String, List<Point>>(x + "_" + z, new ArrayList<Point>());
            }
            newStrip.b().add(new Point(x, z));
        }
        // at end, we can write it if we havent already
        if (newStrip != null) {
            strips.put(newStrip.a(), newStrip.b());
            newStrip = null;
        }
    }
    return strips;
}
Also used : MarkerIcon(org.dynmap.markers.MarkerIcon) BukkitRunnable(org.bukkit.scheduler.BukkitRunnable) ISoliniaSpawnGroup(com.solinia.solinia.Interfaces.ISoliniaSpawnGroup) Point(java.awt.Point) HashMap(java.util.HashMap) StateManager(com.solinia.solinia.Managers.StateManager) Marker(org.dynmap.markers.Marker) SoliniaZone(com.solinia.solinia.Models.SoliniaZone) ArrayList(java.util.ArrayList) List(java.util.List) CoreStateInitException(com.solinia.solinia.Exceptions.CoreStateInitException) TownBlock(com.palmergames.bukkit.towny.object.TownBlock) Map(java.util.Map) Entry(java.util.Map.Entry) AreaMarker(org.dynmap.markers.AreaMarker) Town(com.palmergames.bukkit.towny.object.Town) Comparator(java.util.Comparator) Color(org.bukkit.Color) Tuple(net.minecraft.server.v1_15_R1.Tuple) HashMap(java.util.HashMap) ArrayList(java.util.ArrayList) ArrayList(java.util.ArrayList) List(java.util.List) Point(java.awt.Point) Point(java.awt.Point)

Example 7 with Tuple

use of net.minecraft.server.v1_15_R1.Tuple in project solinia3-core by mixxit.

the class SoliniaLivingEntity method ApplySpellsBonuses.

private Tuple<Integer, Integer> ApplySpellsBonuses(int spellId, LivingEntity sourceEntity, LivingEntity targetEntity, SpellEffect effect, int sourceLevel, int ticksleft, int instrument_mod) {
    int newbonus = 0;
    int newbonus2 = 0;
    try {
        ISoliniaSpell spell = StateManager.getInstance().getConfigurationManager().getSpell(spellId);
        int effectid = effect.getSpellEffectId();
        // this is remaining
        int effect_value = spell.calcSpellEffectValue(effect, sourceEntity, targetEntity, sourceLevel, ticksleft, instrument_mod);
        int base2 = effect.getBase2();
        int max = effect.getMax();
        switch(effect.getSpellEffectType()) {
            case AttackSpeed:
                {
                    if ((effect_value - 100) > 0) {
                        // Slowed - Don't apply haste
                        if (newbonus < 0)
                            break;
                        if ((effect_value - 100) > newbonus) {
                            newbonus = effect_value - 100;
                        }
                    } else if ((effect_value - 100) < 0) {
                        // Slow
                        int real_slow_value = (100 - effect_value) * -1;
                        real_slow_value -= ((real_slow_value * GetSlowMitigation() / 100));
                        if (real_slow_value < newbonus)
                            newbonus = real_slow_value;
                    }
                    break;
                }
            case AttackSpeed2:
                {
                    if ((effect_value - 100) > 0) {
                        // Slowed - Don't apply haste2
                        if (newbonus < 0)
                            break;
                        if ((effect_value - 100) > newbonus) {
                            newbonus = effect_value - 100;
                        }
                    } else if ((effect_value - 100) < 0) {
                        // Slow
                        int real_slow_value = (100 - effect_value) * -1;
                        real_slow_value -= ((real_slow_value * GetSlowMitigation() / 100));
                        if (real_slow_value < newbonus)
                            newbonus = real_slow_value;
                    }
                    break;
                }
            case AttackSpeed3:
                {
                    if (effect_value < 0) {
                        // Slow
                        effect_value -= ((effect_value * GetSlowMitigation() / 100));
                        if (effect_value < newbonus)
                            newbonus = effect_value;
                    } else if (effect_value > 0) {
                        // Haste V3 - Stacks and Overcaps
                        if (effect_value > newbonus) {
                            newbonus = effect_value;
                        }
                    }
                    break;
                }
            case AttackSpeed4:
                {
                    // but have no effect on the mobs attack speed
                    if (getSpecialAbility(SpecialAbility.UNSLOWABLE) > 0)
                        break;
                    if (// A few spells use negative values(Descriptions all indicate it should be a slow)
                    effect_value < 0)
                        effect_value = effect_value * -1;
                    if (effect_value > 0 && effect_value > newbonus) {
                        effect_value -= ((effect_value * GetSlowMitigation() / 100));
                        if (effect_value > newbonus)
                            newbonus = effect_value;
                    }
                    break;
                }
            default:
                // this is remaining
                newbonus = spell.calcSpellEffectValue(effect, sourceEntity, targetEntity, sourceLevel, ticksleft, instrument_mod);
                newbonus2 = effect.getBase2();
                break;
        }
    } catch (CoreStateInitException e) {
    }
    return new Tuple<Integer, Integer>(newbonus, newbonus2);
}
Also used : ISoliniaSpell(com.solinia.solinia.Interfaces.ISoliniaSpell) CoreStateInitException(com.solinia.solinia.Exceptions.CoreStateInitException) Tuple(net.minecraft.server.v1_15_R1.Tuple)

Example 8 with Tuple

use of net.minecraft.server.v1_15_R1.Tuple in project solinia3-core by mixxit.

the class SoliniaLivingEntity method getItemBonusesTuple.

public Tuple<Integer, Integer> getItemBonusesTuple(SpellEffectType spellEffectType, SpellResistType filterResistType) {
    List<ISoliniaItem> equippedItems = this.getEquippedSoliniaItems();
    int highest = 0;
    int highest2 = 0;
    // Check if item focus effect exists for the client.
    if (equippedItems.size() > 0) {
        ISoliniaItem TempItem = null;
        // item focus
        for (ISoliniaItem item : equippedItems) {
            TempItem = item;
            if (TempItem == null)
                continue;
            if (TempItem.getFocusEffectId() < 1) {
                continue;
            }
            ISoliniaSpell spell = null;
            try {
                spell = StateManager.getInstance().getConfigurationManager().getSpell(item.getFocusEffectId());
                if (spell == null)
                    continue;
                if (!filterResistType.equals(SpellResistType.RESIST_NONE))
                    if (spell.isEffectInSpell(SpellEffectType.LimitResist)) {
                        try {
                            // For spells like Pet Focus where the spell type has type limits (ie fire resist = fire pet)
                            int resistTypeId = spell.getSpellEffectBase(SpellEffectType.LimitResist);
                            if (SpellUtils.getSpellResistType(resistTypeId) != filterResistType)
                                continue;
                        } catch (Exception e) {
                            e.printStackTrace();
                        }
                    }
                if (!spell.isEffectInSpell(spellEffectType))
                    continue;
                Tuple<Integer, Integer> spellBonuses = ApplySpellsBonuses(spell.getId(), getBukkitLivingEntity(), getBukkitLivingEntity(), spell.getSpellEffect(spellEffectType), getMentorLevel(), 0, 0);
                if (spellBonuses.a() > highest) {
                    highest = spellBonuses.a();
                    highest2 = spellBonuses.b();
                }
            } catch (CoreStateInitException e) {
            }
        }
    }
    return new Tuple<Integer, Integer>(highest, highest2);
}
Also used : ISoliniaItem(com.solinia.solinia.Interfaces.ISoliniaItem) ISoliniaSpell(com.solinia.solinia.Interfaces.ISoliniaSpell) CoreStateInitException(com.solinia.solinia.Exceptions.CoreStateInitException) SoliniaItemException(com.solinia.solinia.Exceptions.SoliniaItemException) CoreStateInitException(com.solinia.solinia.Exceptions.CoreStateInitException) Tuple(net.minecraft.server.v1_15_R1.Tuple)

Example 9 with Tuple

use of net.minecraft.server.v1_15_R1.Tuple in project solinia3-core by mixxit.

the class SoliniaLivingEntity method getSpellBonusesTuple.

// In EQEmu this gets done only once (ApplySpellsBonuses/NegateSpellBonuses), for now we should just work around it
@Override
public Tuple<Integer, Integer> getSpellBonusesTuple(SpellEffectType spellEffectType, Integer base2filter) {
    int bonus = 0;
    int bonus2 = 0;
    for (ActiveSpellEffect effect : SpellUtils.getActiveSpellEffects(getBukkitLivingEntity(), spellEffectType)) {
        Entity sentity = Bukkit.getEntity(effect.getSourceEntityUUID());
        Entity tentity = Bukkit.getEntity(effect.getTargetEntityUUID());
        if (sentity == null || tentity == null)
            continue;
        if (!(sentity instanceof LivingEntity) || !(sentity instanceof LivingEntity))
            continue;
        if (base2filter != null && effect.getBase2() != base2filter)
            continue;
        Tuple<Integer, Integer> spellBonuses = ApplySpellsBonuses(effect.getSpellId(), (LivingEntity) sentity, (LivingEntity) tentity, effect, effect.getSourceLevel(), effect.getTicksLeft(), effect.getInstrumentMod());
        bonus += spellBonuses.a();
        bonus2 += spellBonuses.b();
    }
    return new Tuple<Integer, Integer>(bonus, bonus2);
}
Also used : ISoliniaLivingEntity(com.solinia.solinia.Interfaces.ISoliniaLivingEntity) LivingEntity(org.bukkit.entity.LivingEntity) CraftEntity(org.bukkit.craftbukkit.v1_15_R1.entity.CraftEntity) ISoliniaLivingEntity(com.solinia.solinia.Interfaces.ISoliniaLivingEntity) Entity(org.bukkit.entity.Entity) LivingEntity(org.bukkit.entity.LivingEntity) Tuple(net.minecraft.server.v1_15_R1.Tuple)

Example 10 with Tuple

use of net.minecraft.server.v1_15_R1.Tuple in project solinia3-core by mixxit.

the class EntityManager method clearHateList.

@Override
public void clearHateList(UUID entityUuid) {
    clearRampageList(entityUuid);
    if (hateList.get(entityUuid) != null) {
        if (hateList.get(entityUuid).size() == 0)
            return;
        // clear reverse hate list in advance
        for (Entry<UUID, Tuple<Integer, Boolean>> entitesHateList : hateList.get(entityUuid).entrySet()) {
            if (reverseHateList.get(entitesHateList.getKey()) == null)
                continue;
            if (reverseHateList.get(entitesHateList.getKey()).get(entityUuid) != null)
                reverseHateList.get(entitesHateList.getKey()).remove(entityUuid);
        }
    }
    hateList.put(entityUuid, new ConcurrentHashMap<UUID, Tuple<Integer, Boolean>>());
    Entity entity = Bukkit.getEntity(entityUuid);
    if (entity == null)
        return;
    if (entity instanceof Creature) {
        try {
            SoliniaLivingEntityAdapter.Adapt((Creature) entity).setAttackTarget(null);
        } catch (CoreStateInitException e) {
        }
    }
}
Also used : ISoliniaLivingEntity(com.solinia.solinia.Interfaces.ISoliniaLivingEntity) Entity(org.bukkit.entity.Entity) LivingEntity(org.bukkit.entity.LivingEntity) SoliniaLivingEntity(com.solinia.solinia.Models.SoliniaLivingEntity) Creature(org.bukkit.entity.Creature) CoreStateInitException(com.solinia.solinia.Exceptions.CoreStateInitException) UUID(java.util.UUID) Tuple(net.minecraft.server.v1_15_R1.Tuple)

Aggregations

Tuple (net.minecraft.server.v1_15_R1.Tuple)10 CoreStateInitException (com.solinia.solinia.Exceptions.CoreStateInitException)8 ISoliniaLivingEntity (com.solinia.solinia.Interfaces.ISoliniaLivingEntity)5 LivingEntity (org.bukkit.entity.LivingEntity)5 Entity (org.bukkit.entity.Entity)4 ISoliniaItem (com.solinia.solinia.Interfaces.ISoliniaItem)3 ISoliniaPlayer (com.solinia.solinia.Interfaces.ISoliniaPlayer)3 ISoliniaSpell (com.solinia.solinia.Interfaces.ISoliniaSpell)3 LocalDateTime (java.time.LocalDateTime)3 UUID (java.util.UUID)3 Creature (org.bukkit.entity.Creature)3 Player (org.bukkit.entity.Player)3 SoliniaItemException (com.solinia.solinia.Exceptions.SoliniaItemException)2 ISoliniaNPC (com.solinia.solinia.Interfaces.ISoliniaNPC)2 StateManager (com.solinia.solinia.Managers.StateManager)2 SoliniaLivingEntity (com.solinia.solinia.Models.SoliniaLivingEntity)2 Timestamp (java.sql.Timestamp)2 TextComponent (net.md_5.bungee.api.chat.TextComponent)2 ItemStack (org.bukkit.inventory.ItemStack)2 Town (com.palmergames.bukkit.towny.object.Town)1