本文整理汇总了Java中org.bukkit.attribute.AttributeInstance类的典型用法代码示例。如果您正苦于以下问题:Java AttributeInstance类的具体用法?Java AttributeInstance怎么用?Java AttributeInstance使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
AttributeInstance类属于org.bukkit.attribute包,在下文中一共展示了AttributeInstance类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Java代码示例。
示例1: applyToBattle
import org.bukkit.attribute.AttributeInstance; //导入依赖的package包/类
/**
* Apply this templates data to an EnderDragonBattle object
*
* @param nmsAbstract an instance of the NMSAbstract interface
* @param dragon the dragon to modify
* @param battle the battle to modify
*/
public void applyToBattle(NMSAbstract nmsAbstract, EnderDragon dragon, DragonBattle battle) {
Validate.notNull(nmsAbstract, "Instance of NMSAbstract cannot be null. See DragonEggDrop#getNMSAbstract()");
Validate.notNull(dragon, "Ender Dragon cannot be null");
Validate.notNull(battle, "Instance of DragonBattle cannot be null");
if (name != null) {
dragon.setCustomName(name);
battle.setBossBarTitle(name);
}
battle.setBossBarStyle(barStyle, barColour);
this.attributes.forEach((a, v) -> {
AttributeInstance attribute = dragon.getAttribute(a);
if (attribute != null) {
attribute.setBaseValue(v);
}
});
// Set health... max health attribute doesn't do that for me. -,-
if (attributes.containsKey(Attribute.GENERIC_MAX_HEALTH)) {
dragon.setHealth(attributes.get(Attribute.GENERIC_MAX_HEALTH));
}
}
开发者ID:2008Choco,项目名称:DragonEggDrop,代码行数:31,代码来源:DragonTemplate.java
示例2: onPlayerLogin
import org.bukkit.attribute.AttributeInstance; //导入依赖的package包/类
@EventHandler(priority = EventPriority.HIGHEST)
public void onPlayerLogin(PlayerJoinEvent e) {
Player p = e.getPlayer();
World world = p.getWorld();
double GAS = module().getDouble("generic-attack-speed");
AttributeInstance attribute = p.getAttribute(Attribute.GENERIC_ATTACK_SPEED);
double baseValue = attribute.getBaseValue();
if(!Config.moduleEnabled("disable-attack-cooldown", world))
GAS = 4; //If module is disabled, set attack speed to 1.9 default
if(baseValue!=GAS){
attribute.setBaseValue(GAS);
p.saveData();
}
}
开发者ID:gvlfm78,项目名称:BukkitOldCombatMechanics,代码行数:20,代码来源:ModuleAttackCooldown.java
示例3: onWorldChange
import org.bukkit.attribute.AttributeInstance; //导入依赖的package包/类
@EventHandler(priority = EventPriority.HIGHEST)
public void onWorldChange(PlayerChangedWorldEvent e) {
Player player = e.getPlayer();
World world = player.getWorld();
double GAS = module().getDouble("generic-attack-speed");
AttributeInstance attribute = player.getAttribute(Attribute.GENERIC_ATTACK_SPEED);
double baseValue = attribute.getBaseValue();
if(!Config.moduleEnabled("disable-attack-cooldown", world))
GAS = 4; //If module is disabled, set attack speed to 1.9 default
if(baseValue!=GAS){
attribute.setBaseValue(GAS);
player.saveData();
}
}
开发者ID:gvlfm78,项目名称:BukkitOldCombatMechanics,代码行数:19,代码来源:ModuleAttackCooldown.java
示例4: mockPlayer
import org.bukkit.attribute.AttributeInstance; //导入依赖的package包/类
private Player mockPlayer(String name, GameMode gameMode) {
Player mock = mock(Player.class);
PlayerInventory inv = mock(PlayerInventory.class);
inv.setContents(new ItemStack[39]);
inv.setArmorContents(new ItemStack[4]);
Inventory enderChest = mock(Inventory.class);
enderChest.setContents(new ItemStack[27]);
given(mock.getInventory()).willReturn(inv);
given(mock.getEnderChest()).willReturn(enderChest);
given(mock.getName()).willReturn(name);
given(mock.getUniqueId()).willReturn(TestHelper.TEST_UUID);
given(mock.getGameMode()).willReturn(gameMode);
AttributeInstance attribute = mock(AttributeInstance.class);
given(mock.getAttribute(Attribute.GENERIC_MAX_HEALTH)).willReturn(attribute);
given(attribute.getBaseValue()).willReturn(20.0);
return mock;
}
开发者ID:Gnat008,项目名称:PerWorldInventory,代码行数:21,代码来源:PWIPlayerManagerTest.java
示例5: onSpawn
import org.bukkit.attribute.AttributeInstance; //导入依赖的package包/类
@EventHandler
public void onSpawn(CreatureSpawnEvent event) {
LivingEntity e = event.getEntity();
WorldSettings set = plugin.getWorlds().get(event.getEntity().getWorld().getName());
if (set == null) {
return;
}
if (!set.getEntities().contains(e.getType())) {
return;
}
if (!set.shouldExist(e)) {
event.setCancelled(true);
} else if (rand.nextDouble() > set.getRatio(e.getType())) {
event.setCancelled(true);
} else {
AttributeInstance maxHealth = e.getAttribute(Attribute.GENERIC_MAX_HEALTH);
maxHealth.setBaseValue(maxHealth.getBaseValue() * set.getHealth(e.getType()));
e.setHealth(e.getMaxHealth());
}
}
开发者ID:Co0sh,项目名称:Hordes,代码行数:21,代码来源:Blocker.java
示例6: addModifier0
import org.bukkit.attribute.AttributeInstance; //导入依赖的package包/类
private boolean addModifier0(Attribute attribute, AttributeModifier modifier) {
final AttributeInstance attributeInstance = player.getAttribute(attribute);
if(attributeInstance != null && !attributeInstance.getModifiers().contains(modifier)) {
attributeInstance.addModifier(modifier);
return true;
}
return false;
}
开发者ID:OvercastNetwork,项目名称:ProjectAres,代码行数:9,代码来源:AttributePlayerFacet.java
示例7: removeModifier0
import org.bukkit.attribute.AttributeInstance; //导入依赖的package包/类
private boolean removeModifier0(Attribute attribute, AttributeModifier modifier) {
AttributeInstance attributeValue = player.getAttribute(attribute);
if(attributeValue != null && attributeValue.getModifiers().contains(modifier)) {
attributeValue.removeModifier(modifier);
return true;
}
return false;
}
开发者ID:OvercastNetwork,项目名称:ProjectAres,代码行数:9,代码来源:AttributePlayerFacet.java
示例8: getAttribute
import org.bukkit.attribute.AttributeInstance; //导入依赖的package包/类
@Override
public AttributeInstance getAttribute(Attribute attribute)
{
if (attributes.containsKey(attribute))
{
return attributes.get(attribute);
}
else
{
throw new UnimplementedOperationException();
}
}
开发者ID:seeseemelk,项目名称:MockBukkit,代码行数:13,代码来源:PlayerMock.java
示例9: DungeonBoss
import org.bukkit.attribute.AttributeInstance; //导入依赖的package包/类
public DungeonBoss(Location loc, EntityType type, String name, boolean finalBoss) {
super(loc, type, name);
this.finalBoss = finalBoss;
getBukkit().setCustomName(ChatColor.RED + name);
getBukkit().setCustomNameVisible(true);
AttributeInstance a = getLiving().getAttribute(Attribute.GENERIC_MAX_HEALTH);
a.addModifier(new AttributeModifier("mult", 1, AttributeModifier.Operation.ADD_SCALAR)); // Double boss health.
getLiving().setHealth(a.getValue()); // Max out health.
}
开发者ID:Kneesnap,项目名称:Kineticraft,代码行数:10,代码来源:DungeonBoss.java
示例10: clearStats
import org.bukkit.attribute.AttributeInstance; //导入依赖的package包/类
private void clearStats() {
Player player = this.player.getPlayer();
AttributeInstance speedAttribute = player.getAttribute(Attribute.GENERIC_MOVEMENT_SPEED);
AttributeModifier rpgInvModifier = null;
for (AttributeModifier modifier : speedAttribute.getModifiers()) {
if (modifier.getUniqueId().compareTo(Attributes.SPEED_MODIFIER_ID) == 0) {
rpgInvModifier = modifier;
}
}
if (rpgInvModifier != null) {
speedAttribute.removeModifier(rpgInvModifier);
}
}
开发者ID:EndlessCodeGroup,项目名称:RPGInventory,代码行数:16,代码来源:PlayerWrapper.java
示例11: onPlayerJoin
import org.bukkit.attribute.AttributeInstance; //导入依赖的package包/类
@EventHandler(priority = EventPriority.MONITOR)
public void onPlayerJoin(PlayerJoinEvent event)
{
Player player = event.getPlayer();
if (api.getGameManager().isLegacyPvP())
{
AttributeInstance genericAttackSpeedAttribute = player.getAttribute(Attribute.GENERIC_ATTACK_SPEED);
if (genericAttackSpeedAttribute != null)
genericAttackSpeedAttribute.setBaseValue(1024.0D);
}
}
开发者ID:SamaGames,项目名称:SamaGamesCore,代码行数:14,代码来源:CooldownModule.java
示例12: onPlayerQuit
import org.bukkit.attribute.AttributeInstance; //导入依赖的package包/类
@EventHandler(priority = EventPriority.HIGHEST)
public void onPlayerQuit(PlayerQuitEvent e){
Player player = e.getPlayer();
AttributeInstance attribute = player.getAttribute(Attribute.GENERIC_ATTACK_SPEED);
double baseValue = attribute.getBaseValue();
if (baseValue != 4){ //If basevalue is not 1.9 default, set it back
attribute.setBaseValue(4);
player.saveData();
}
}
开发者ID:gvlfm78,项目名称:BukkitOldCombatMechanics,代码行数:11,代码来源:ModuleAttackCooldown.java
示例13: setAttributeModifier
import org.bukkit.attribute.AttributeInstance; //导入依赖的package包/类
/**
* Sets the provided attribute up with a modifier by the given name (overwriting one if it exists)
* for the given amount.
* <b>This is done</b> under the {@link AttributeModifier.Operation#ADD_SCALAR} operation!
*/
public static void setAttributeModifier(AttributeInstance attribute, String name, double amt) {
Collection<AttributeModifier> mods = attribute.getModifiers();
for (AttributeModifier mod : mods) {
if (mod.getName().equals(name)) {
attribute.removeModifier(mod);
break;
}
}
attribute.addModifier(new AttributeModifier(name, amt, AttributeModifier.Operation.ADD_SCALAR));
}
开发者ID:Dove-Bren,项目名称:QuestManager,代码行数:18,代码来源:Skill.java
示例14: rewardMaxHealth
import org.bukkit.attribute.AttributeInstance; //导入依赖的package包/类
/**
* Gives an increased max health reward to a player.
*
* @param player
* @param amount
* @return the reward text to display to the player
*/
@SuppressWarnings("deprecation")
private String rewardMaxHealth(Player player, int amount) {
if (plugin.getServerVersion() >= 9) {
AttributeInstance playerAttribute = player.getAttribute(Attribute.GENERIC_MAX_HEALTH);
playerAttribute.setBaseValue(playerAttribute.getBaseValue() + amount);
} else {
player.setMaxHealth(player.getMaxHealth() + amount);
}
return ChatColor.translateAlternateColorCodes('&',
StringUtils.replaceOnce(langIncreaseMaxHealthRewardReceived, "AMOUNT", Integer.toString(amount)));
}
开发者ID:PyvesB,项目名称:AdvancedAchievements,代码行数:19,代码来源:PlayerAdvancedAchievementListener.java
示例15: onEntityTargetPlayer
import org.bukkit.attribute.AttributeInstance; //导入依赖的package包/类
public static void onEntityTargetPlayer(EntityTargetLivingEntityEvent event) {
if (event.getTarget() instanceof Player) {
Player player = (Player) event.getTarget();
if (event.getEntity() instanceof LivingEntity) {
LivingEntity attacker = (LivingEntity) event.getEntity();
if ((event.getEntity().getCustomName() != null) && (player.getName() != null)) {
if (event.getEntity().getCustomName().startsWith(player.getName())) {
//we are attacking our creator
if (attacker.getHealth() < (player.getLevel() + 1.0f) * player.getHealth() * 0.05f) {
event.setCancelled(true);
} //make minions not harm their creators if the creators are tough enough
//level 20 will do it for normal 20 heart mobs. Assumes you're not injured.
} else {
//we're attacking a player that's not our creator
AttributeInstance speedAttribute = attacker.getAttribute(Attribute.GENERIC_MOVEMENT_SPEED);
if (speedAttribute.getValue() > Math.sqrt(player.getLevel())) {
event.setCancelled(true);
} //ultra hyper mobs are seeking high level players
if ((attacker.getHealth()) > ((player.getLevel() + 1.0f) * player.getHealth())) {
event.setCancelled(true);
}//mobs try to get you down to level*health is less than their health.
//If you're level 0, almost any damage ought to make them relent
//If you're over level 20, you'll be dead before they trust you.
}
} else {
if ((attacker.getHealth()) > ((player.getLevel() + 1.0f) * player.getHealth())) {
event.setCancelled(true);
}//mobs try to get you down to level*health is less than their health.
//If you're level 0, almost any damage ought to make them relent
//If you're over level 20, you'll be dead before they trust you.
}
}
}
}
开发者ID:danieljohnson2,项目名称:SnowballMadness,代码行数:37,代码来源:SnowballLogic.java
示例16: getAttribute
import org.bukkit.attribute.AttributeInstance; //导入依赖的package包/类
@Override
public AttributeInstance getAttribute(Attribute attribute) {
Preconditions.checkArgument(attribute != null, "attribute");
net.minecraft.server.AttributeInstance nms = handle.a(toMinecraft(attribute.name()));
return (nms == null) ? null : new CraftAttributeInstance(nms, attribute);
}
开发者ID:bergerkiller,项目名称:SpigotSource,代码行数:8,代码来源:CraftAttributeMap.java
示例17: AttributeType
import org.bukkit.attribute.AttributeInstance; //导入依赖的package包/类
public AttributeType(AttributeInstance instance) {
this.instance = instance;
set("baseValue", instance.getBaseValue());
//newFunction(new SetBaseValue(instance));
autoFunc(this, AttributeType.class);
}
开发者ID:LukkitPlus,项目名称:Lukkit,代码行数:7,代码来源:AttributeType.java
示例18: SetBaseValue
import org.bukkit.attribute.AttributeInstance; //导入依赖的package包/类
public SetBaseValue(AttributeInstance instance) {
this.instance = instance;
}
开发者ID:LukkitPlus,项目名称:Lukkit,代码行数:4,代码来源:AttributeType.java
示例19: removeModifier
import org.bukkit.attribute.AttributeInstance; //导入依赖的package包/类
public static void removeModifier(Attributable attributable, AttributeModifier modifier) {
for(Attribute attribute : Attribute.values()) {
final AttributeInstance instance = attributable.getAttribute(attribute);
if(instance != null) instance.removeModifier(modifier);
}
}
开发者ID:OvercastNetwork,项目名称:ProjectAres,代码行数:7,代码来源:AttributeUtils.java
示例20: removeAllModifiers
import org.bukkit.attribute.AttributeInstance; //导入依赖的package包/类
public static void removeAllModifiers(AttributeInstance attributeInstance) {
attributeInstance.getModifiers().forEach(attributeInstance::removeModifier);
}
开发者ID:OvercastNetwork,项目名称:ProjectAres,代码行数:4,代码来源:AttributeUtils.java
注:本文中的org.bukkit.attribute.AttributeInstance类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论