Java 类net.minecraft.server.MobEffectList 实例源码

项目:SpigotSource    文件:CraftTippedArrow.java   
@Override
public boolean addCustomEffect(PotionEffect effect, boolean override) {
    int effectId = effect.getType().getId();
    MobEffect existing = null;
    for (MobEffect mobEffect : getHandle().h) {
        if (MobEffectList.getId(mobEffect.getMobEffect()) == effectId) {
            existing = mobEffect;
        }
    }
    if (existing != null) {
        if (!override) {
            return false;
        }
        getHandle().h.remove(existing);
    }
    getHandle().a(CraftPotionUtil.fromBukkit(effect));
    getHandle().refreshEffects();
    return true;
}
项目:SpigotSource    文件:CraftTippedArrow.java   
@Override
public boolean removeCustomEffect(PotionEffectType effect) {
    int effectId = effect.getId();
    MobEffect existing = null;
    for (MobEffect mobEffect : getHandle().h) {
        if (MobEffectList.getId(mobEffect.getMobEffect()) == effectId) {
            existing = mobEffect;
        }
    }
    if (existing == null) {
        return false;
    }
    Validate.isTrue(getBasePotionData().getType() != PotionType.UNCRAFTABLE || getHandle().h.size() != 1, "Tipped Arrows must have at least 1 effect");
    getHandle().h.remove(existing);
    getHandle().refreshEffects();
    return true;
}
项目:SpigotSource    文件:CraftAreaEffectCloud.java   
@Override
public boolean addCustomEffect(PotionEffect effect, boolean override) {
    int effectId = effect.getType().getId();
    MobEffect existing = null;
    for (MobEffect mobEffect : getHandle().effects) {
        if (MobEffectList.getId(mobEffect.getMobEffect()) == effectId) {
            existing = mobEffect;
        }
    }
    if (existing != null) {
        if (!override) {
            return false;
        }
        getHandle().effects.remove(existing);
    }
    getHandle().a(CraftPotionUtil.fromBukkit(effect));
    getHandle().refreshEffects();
    return true;
}
项目:SpigotSource    文件:CraftAreaEffectCloud.java   
@Override
public boolean removeCustomEffect(PotionEffectType effect) {
    int effectId = effect.getId();
    MobEffect existing = null;
    for (MobEffect mobEffect : getHandle().effects) {
        if (MobEffectList.getId(mobEffect.getMobEffect()) == effectId) {
            existing = mobEffect;
        }
    }
    if (existing == null) {
        return false;
    }
    getHandle().effects.remove(existing);
    getHandle().refreshEffects();
    return true;
}
项目:SpigotSource    文件:PotionTest.java   
@Test
public void testEffectCompleteness() throws Throwable {
    Map<PotionType, String> effects = new EnumMap(PotionType.class);
    for (PotionRegistry reg : PotionRegistry.a) {
        List<MobEffect> eff = reg.a();
        if (eff.size() != 1) continue;
        int id = MobEffectList.getId(eff.get(0).getMobEffect());
        PotionEffectType type = PotionEffectType.getById(id);
        assertNotNull(String.valueOf(id), PotionEffectType.getById(id));

        PotionType enumType = PotionType.getByEffect(type);
        assertNotNull(type.getName(), enumType);

        effects.put(enumType, enumType.name());
    }

    assertEquals(effects.entrySet().size(), PotionType.values().length - /* PotionTypes with no Effects */ 5);
}
项目:CardinalPGM    文件:Parser.java   
public static PotionEffect getPotion(Element potion) {
    PotionEffectType type = PotionEffectType.getByName(Strings.getTechnicalName(potion.getText()));
    if (type == null) type = new CraftPotionEffectType(MobEffectList.getByName(potion.getText().toLowerCase().replace(" ","_")));
    int duration = (int) (Strings.timeStringToExactSeconds(potion.getAttributeValue("duration")) * 20);
    int amplifier = 0;
    boolean ambient = false;
    if (potion.getAttributeValue("amplifier") != null)
        amplifier = Numbers.parseInt(potion.getAttributeValue("amplifier")) - 1;
    if (potion.getAttributeValue("ambient") != null)
        ambient = Boolean.parseBoolean(potion.getAttributeValue("ambient").toUpperCase());
    return new PotionEffect(type, duration, amplifier, ambient);
}
项目:SpigotSource    文件:CraftLivingEntity.java   
public boolean addPotionEffect(PotionEffect effect, boolean force) {
    if (hasPotionEffect(effect.getType())) {
        if (!force) {
            return false;
        }
        removePotionEffect(effect.getType());
    }
    getHandle().addEffect(new MobEffect(MobEffectList.fromId(effect.getType().getId()), effect.getDuration(), effect.getAmplifier(), effect.isAmbient(), effect.hasParticles()));
    return true;
}
项目:SpigotSource    文件:CraftLivingEntity.java   
public Collection<PotionEffect> getActivePotionEffects() {
    List<PotionEffect> effects = new ArrayList<PotionEffect>();
    for (MobEffect handle : getHandle().effects.values()) {
        effects.add(new PotionEffect(PotionEffectType.getById(MobEffectList.getId(handle.getMobEffect())), handle.getDuration(), handle.getAmplifier(), handle.isAmbient(), handle.isShowParticles()));
    }
    return effects;
}
项目:SpigotSource    文件:CraftPotionUtil.java   
public static PotionEffect toBukkit(MobEffect effect) {
    PotionEffectType type = PotionEffectType.getById(MobEffectList.getId(effect.getMobEffect()));
    int amp = effect.getAmplifier();
    int duration = effect.getDuration();
    boolean ambient = effect.isAmbient();
    boolean particles = effect.isShowParticles();
    return new PotionEffect(type, duration, amp, ambient, particles);
}
项目:ProjectAres    文件:NMSHacks.java   
public static void sendDeathEffects(Player player, boolean blackout) {
    sendPacket(player, new PacketPlayOutEntityEffect(player.getEntityId(),
            new MobEffect(MobEffectList.getByName("nausea"), 100, 0, true, false)));
    sendPacket(player, new PacketPlayOutEntityEffect(player.getEntityId(),
            new MobEffect(MobEffectList.getByName("blindness"), blackout ? Integer.MAX_VALUE : 21, 0, true, false)));
}
项目:ProjectAres    文件:NMSHacks.java   
public static void clearDeathEffects(Player player) {
    sendPacket(player, new PacketPlayOutRemoveEntityEffect(player.getEntityId(), MobEffectList.getByName("nausea")));
    sendPacket(player, new PacketPlayOutRemoveEntityEffect(player.getEntityId(), MobEffectList.getByName("blindness")));
}
项目:CraftBukkit    文件:CraftLivingEntity.java   
public boolean hasPotionEffect(PotionEffectType type) {
    return getHandle().hasEffect(MobEffectList.byId[type.getId()]);
}
项目:CraftBukkit    文件:CraftPotionEffectType.java   
public CraftPotionEffectType(MobEffectList handle) {
    super(handle.id);
    this.handle = handle;
}
项目:CraftBukkit    文件:CraftPotionEffectType.java   
public MobEffectList getHandle() {
    return handle;
}
项目:Craftbukkit    文件:CraftLivingEntity.java   
public boolean hasPotionEffect(PotionEffectType type) {
    return getHandle().hasEffect(MobEffectList.byId[type.getId()]);
}
项目:Craftbukkit    文件:CraftPotionEffectType.java   
public CraftPotionEffectType(MobEffectList handle) {
    super(handle.id);
    this.handle = handle;
}
项目:Craftbukkit    文件:CraftPotionEffectType.java   
public MobEffectList getHandle() {
    return handle;
}
项目:Almura-Server    文件:CraftLivingEntity.java   
public boolean hasPotionEffect(PotionEffectType type) {
    return getHandle().hasEffect(MobEffectList.byId[type.getId()]);
}
项目:Almura-Server    文件:CraftServer.java   
public CraftServer(MinecraftServer console, PlayerList playerList) {
    this.console = console;
    this.playerList = (DedicatedPlayerList) playerList;
    this.serverVersion = CraftServer.class.getPackage().getImplementationVersion();
    online.value = console.getPropertyManager().getBoolean("online-mode", true);

    Bukkit.setServer(this);

    // Register all the Enchantments and PotionTypes now so we can stop new registration immediately after
    Enchantment.DAMAGE_ALL.getClass();
    org.bukkit.enchantments.Enchantment.stopAcceptingRegistrations();

    Potion.setPotionBrewer(new CraftPotionBrewer());
    MobEffectList.BLINDNESS.getClass();
    PotionEffectType.stopAcceptingRegistrations();
    // Ugly hack :(

    if (!Main.useConsole) {
        getLogger().info("Console input is disabled due to --noconsole command argument");
    }

    configuration = YamlConfiguration.loadConfiguration(getConfigFile());
    configuration.options().copyDefaults(true);
    configuration.setDefaults(YamlConfiguration.loadConfiguration(getClass().getClassLoader().getResourceAsStream("configurations/bukkit.yml")));
    saveConfig();
    ((SimplePluginManager) pluginManager).useTimings(configuration.getBoolean("settings.plugin-profiling"));
    monsterSpawn = configuration.getInt("spawn-limits.monsters");
    animalSpawn = configuration.getInt("spawn-limits.animals");
    waterAnimalSpawn = configuration.getInt("spawn-limits.water-animals");
    ambientSpawn = configuration.getInt("spawn-limits.ambient");
    console.autosavePeriod = configuration.getInt("ticks-per.autosave");
    warningState = WarningState.value(configuration.getString("settings.deprecated-verbose"));
    chunkGCPeriod = configuration.getInt("chunk-gc.period-in-ticks");
    chunkGCLoadThresh = configuration.getInt("chunk-gc.load-threshold");

    updater = new AutoUpdater(new BukkitDLUpdaterService(configuration.getString("auto-updater.host")), getLogger(), configuration.getString("auto-updater.preferred-channel"));
    updater.setEnabled(false); // Spigot
    updater.setSuggestChannels(configuration.getBoolean("auto-updater.suggest-channels"));
    updater.getOnBroken().addAll(configuration.getStringList("auto-updater.on-broken"));
    updater.getOnUpdate().addAll(configuration.getStringList("auto-updater.on-update"));
    updater.check(serverVersion);

    // Spigot Start - Moved to old location of new DedicatedPlayerList in DedicatedServer
    // loadPlugins();
    // enablePlugins(PluginLoadOrder.STARTUP);
    // Spigot End
}
项目:Almura-Server    文件:CraftPotionEffectType.java   
public CraftPotionEffectType(MobEffectList handle) {
    super(handle.id);
    this.handle = handle;
}
项目:Almura-Server    文件:CraftPotionEffectType.java   
public MobEffectList getHandle() {
    return handle;
}
项目:Tweakkit-Server    文件:CraftLivingEntity.java   
public boolean hasPotionEffect(PotionEffectType type) {
    return getHandle().hasEffect(MobEffectList.byId[type.getId()]);
}
项目:Tweakkit-Server    文件:CraftPotionEffectType.java   
public CraftPotionEffectType(MobEffectList handle) {
    super(handle.id);
    this.handle = handle;
}
项目:Tweakkit-Server    文件:CraftPotionEffectType.java   
public MobEffectList getHandle() {
    return handle;
}
项目:SpigotSource    文件:CraftLivingEntity.java   
public boolean hasPotionEffect(PotionEffectType type) {
    return getHandle().hasEffect(MobEffectList.fromId(type.getId()));
}
项目:SpigotSource    文件:CraftLivingEntity.java   
public void removePotionEffect(PotionEffectType type) {
    getHandle().removeEffect(MobEffectList.fromId(type.getId()));
}
项目:SpigotSource    文件:CraftPotionUtil.java   
public static MobEffect fromBukkit(PotionEffect effect) {
    MobEffectList type = MobEffectList.fromId(effect.getType().getId());
    return new MobEffect(type, effect.getDuration(), effect.getAmplifier(), effect.isAmbient(), effect.hasParticles());
}
项目:SpigotSource    文件:CraftPotionUtil.java   
public static boolean equals(MobEffectList mobEffect, PotionEffectType type) {
    PotionEffectType typeV = PotionEffectType.getById(MobEffectList.getId(mobEffect));
    return typeV.equals(type);
}
项目:SpigotSource    文件:CraftPotionEffectType.java   
public CraftPotionEffectType(MobEffectList handle) {
    super(MobEffectList.getId(handle));
    this.handle = handle;
}
项目:SpigotSource    文件:CraftPotionEffectType.java   
public MobEffectList getHandle() {
    return handle;
}
项目:Craft-city    文件:CraftLivingEntity.java   
public boolean hasPotionEffect(PotionEffectType type) {
    return getHandle().hasEffect(MobEffectList.byId[type.getId()]);
}
项目:Craft-city    文件:CraftServer.java   
public CraftServer(MinecraftServer console, PlayerList playerList) {
    this.console = console;
    this.playerList = (DedicatedPlayerList) playerList;
    this.serverVersion = CraftServer.class.getPackage().getImplementationVersion();
    online.value = console.getPropertyManager().getBoolean("online-mode", true);

    Bukkit.setServer(this);

    // Register all the Enchantments and PotionTypes now so we can stop new registration immediately after
    Enchantment.DAMAGE_ALL.getClass();
    org.bukkit.enchantments.Enchantment.stopAcceptingRegistrations();

    Potion.setPotionBrewer(new CraftPotionBrewer());
    MobEffectList.BLINDNESS.getClass();
    PotionEffectType.stopAcceptingRegistrations();
    // Ugly hack :(

    if (!Main.useConsole) {
        getLogger().info("Console input is disabled due to --noconsole command argument");
    }

    configuration = YamlConfiguration.loadConfiguration(getConfigFile());
    configuration.options().copyDefaults(true);
    configuration.setDefaults(YamlConfiguration.loadConfiguration(getClass().getClassLoader().getResourceAsStream("configurations/bukkit.yml")));
    saveConfig();
    ((SimplePluginManager) pluginManager).useTimings(configuration.getBoolean("settings.plugin-profiling"));
    monsterSpawn = configuration.getInt("spawn-limits.monsters");
    animalSpawn = configuration.getInt("spawn-limits.animals");
    waterAnimalSpawn = configuration.getInt("spawn-limits.water-animals");
    ambientSpawn = configuration.getInt("spawn-limits.ambient");
    console.autosavePeriod = configuration.getInt("ticks-per.autosave");
    warningState = WarningState.value(configuration.getString("settings.deprecated-verbose"));
    chunkGCPeriod = configuration.getInt("chunk-gc.period-in-ticks");
    chunkGCLoadThresh = configuration.getInt("chunk-gc.load-threshold");

    updater = new AutoUpdater(new BukkitDLUpdaterService(configuration.getString("auto-updater.host")), getLogger(), configuration.getString("auto-updater.preferred-channel"));
    updater.setEnabled(configuration.getBoolean("auto-updater.enabled"));
    updater.setSuggestChannels(configuration.getBoolean("auto-updater.suggest-channels"));
    updater.getOnBroken().addAll(configuration.getStringList("auto-updater.on-broken"));
    updater.getOnUpdate().addAll(configuration.getStringList("auto-updater.on-update"));
    updater.check(serverVersion);

    loadPlugins();
    enablePlugins(PluginLoadOrder.STARTUP);
}
项目:Craft-city    文件:CraftPotionEffectType.java   
public CraftPotionEffectType(MobEffectList handle) {
    super(handle.id);
    this.handle = handle;
}
项目:Craft-city    文件:CraftPotionEffectType.java   
public MobEffectList getHandle() {
    return handle;
}