当前位置: 首页>>代码示例>>Java>>正文


Java AttributeInstance.setBaseValue方法代码示例

本文整理汇总了Java中org.bukkit.attribute.AttributeInstance.setBaseValue方法的典型用法代码示例。如果您正苦于以下问题:Java AttributeInstance.setBaseValue方法的具体用法?Java AttributeInstance.setBaseValue怎么用?Java AttributeInstance.setBaseValue使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在org.bukkit.attribute.AttributeInstance的用法示例。


在下文中一共展示了AttributeInstance.setBaseValue方法的9个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: 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

示例2: 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

示例3: 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

示例4: 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

示例5: 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

示例6: 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

示例7: onCommand

import org.bukkit.attribute.AttributeInstance; //导入方法依赖的package包/类
public boolean onCommand(CommandSender sender, Command cmd, String label, String[] args) {
    if (args.length < 1) {//Tell them about available commands
        PluginDescriptionFile pdf = plugin.getDescription();

        Chatter.send(sender, ChatColor.DARK_GRAY + Chatter.HORIZONTAL_BAR);

        Chatter.send(sender, "&6&lOldCombatMechanics&e by &cgvlfm78&e and &cRayzr522&e version &6%s", pdf.getVersion());
        Chatter.send(sender, "&eYou can use &c/ocm reload&e to reload the config file");

        if (plugin.getConfig().getBoolean("enableIndividualToggle") && sender.hasPermission("oldcombatmechanics.toggle") && sender instanceof Player) {
            Chatter.send(sender, "&eYou can use &c/ocm toggle&e to turn your attack cooldown on/off");
        }

        Chatter.send(sender, ChatColor.DARK_GRAY + Chatter.HORIZONTAL_BAR);

        // Check for updates
        Bukkit.getScheduler().runTaskAsynchronously(plugin, () -> new UpdateChecker(plugin, pluginFile).sendUpdateMessages(sender));

        return true;
    }

    // Get the sub-command
    String sub = args[0].toLowerCase();

    if (sub.equals("reload")) {// Reloads config
        if (!sender.hasPermission("oldcombatmechanics.reload")) {
            Chatter.send(sender, NO_PERMISSION, "oldcombatmechanics.reload");
            return true;
        }

        Config.reload();

        Chatter.send(sender, "&6&lOldCombatMechanics&e config file reloaded");

        return true;
    } else if (sub.equals("toggle") && plugin.getConfig().getBoolean("enableIndividualToggle") && sender instanceof Player) {
        if (!sender.hasPermission("oldcombatmechanics.toggle")) {
            Chatter.send(sender, NO_PERMISSION, "oldcombatmechanics.toggle");
            return true;
        }

        // Toggle their cooldown
        Player p = (Player) sender;
        double GAS = plugin.getConfig().getDouble("disable-attack-cooldown.generic-attack-speed");

        AttributeInstance attribute = p.getAttribute(Attribute.GENERIC_ATTACK_SPEED);
        double baseValue = attribute.getBaseValue();
        String message = "&1[OCM] &aAttack cooldown ";

        if (baseValue == GAS) { // Toggle
            GAS = 4;
            message += "enabled";
        } else {
            message += "disabled";
        }

        attribute.setBaseValue(GAS);
        p.saveData();
        Chatter.send(p, message);

        return true;
    }

    return false;
}
 
开发者ID:gvlfm78,项目名称:BukkitOldCombatMechanics,代码行数:66,代码来源:OCMCommandHandler.java

示例8: reload

import org.bukkit.attribute.AttributeInstance; //导入方法依赖的package包/类
public static void reload() {
    if (plugin.doesConfigymlExist()) {
        plugin.reloadConfig();
        config = plugin.getConfig();
    } else
        plugin.upgradeConfig();

    if (checkConfigVersion()) {
        // checkConfigVersion will call #reload() again anyways
        return;
    }

    //plugin.restartTask(); //Restart no-collision check
    plugin.restartSweepTask(); //Restart sword sweep check

    Messenger.DEBUG_ENABLED = config.getBoolean("debug.enabled");

    if (Config.moduleEnabled("old-tool-damage"))
        WeaponDamages.Initialise(plugin); //Reload weapon damages from config

    //if(Config.moduleEnabled("old-armour-strength"))
    ArmourValues.Initialise(plugin); //Reload armour values from config

    //Setting correct attack speed and armour values for online players
    for (World world : Bukkit.getWorlds()) {

        List<Player> players = world.getPlayers();

        double GAS = plugin.getConfig().getDouble("disable-attack-cooldown.generic-attack-speed");

        if (!Config.moduleEnabled("disable-attack-cooldown", world))
            GAS = 4; //If module is disabled, set attack speed to 1.9 default

        boolean isArmourEnabled = Config.moduleEnabled("old-armour-strength", world);

        for (Player player : players) {
            //Setting attack speed
            AttributeInstance attribute = player.getAttribute(Attribute.GENERIC_ATTACK_SPEED);
            double baseValue = attribute.getBaseValue();

            if (baseValue != GAS) {
                attribute.setBaseValue(GAS);
                player.saveData();
            }

            //Setting armour values
            ModuleOldArmourStrength.setArmourAccordingly(player, isArmourEnabled);
        }
    }

    ModuleLoader.ToggleModules();

    if (Config.moduleEnabled("disable-offhand"))
        ModuleDisableOffHand.INSTANCE.reloadList();
    if (Config.moduleEnabled("old-golden-apples")) {
        ModuleGoldenApple.INSTANCE.reloadRecipes();
        ModuleGoldenApple.INSTANCE.registerCrafting();
    }
    if (Config.moduleEnabled("sword-blocking") || Config.moduleEnabled("disable-elytra"))
        reloadInteractiveBlocks();
    if (Config.moduleEnabled("sword-blocking"))
        ModuleSwordBlocking.INSTANCE.reload();
    if (moduleEnabled("disable-crafting"))
        ModuleDisableCrafting.INSTANCE.reload();
}
 
开发者ID:gvlfm78,项目名称:BukkitOldCombatMechanics,代码行数:66,代码来源:Config.java

示例9: onJoin

import org.bukkit.attribute.AttributeInstance; //导入方法依赖的package包/类
@EventHandler
public void onJoin(final PlayerJoinEvent e) {
	if (e.getPlayer().isBanned()) {
		e.getPlayer().kickPlayer(NationZ.title + 
				"\n" + NationZ.line(ChatColor.AQUA) + 
				"\n" + ChatColor.RED + " " + 
				"\n" + ChatColor.DARK_RED + "You were banned!" + 
				"\n" + ChatColor.RED + " " + 
				"\n" + ChatColor.RED + "You didn't stick to the Server-Rules and now received your punishment!" + 
				"\n" + ChatColor.RED + " " + 
				"\n" + ChatColor.RED + "There is no chance for unbanning since Players who don't stick to the rules," + 
				"\n" + ChatColor.RED + "ruin the game, the fun and the Server." + 
				"\n" + ChatColor.RED + " " + 
				"\n" + NationZ.line(ChatColor.AQUA));
		notWhitelisted = true;
		return;
	} else if (!e.getPlayer().isWhitelisted()) {
		e.getPlayer().kickPlayer(NationZ.title + 
				"\n" + NationZ.line(ChatColor.AQUA) + 
				"\n" + ChatColor.RED + " " + 
				"\n" + ChatColor.DARK_RED + "You are not whitelisted!" + 
				"\n" + ChatColor.RED + " " + 
				"\n" + ChatColor.RED + "Please buy a " + NationZ.title + ChatColor.RED + "-Pass to join the Server." + 
				"\n" + ChatColor.RED + "You can buy passes here: " + ChatColor.YELLOW + FC.getMainCfg().getString("link.pass") + 
				"\n" + ChatColor.RED + " " + 
				"\n" + ChatColor.DARK_RED + "You" + ChatColor.WHITE + "Tuber" + ChatColor.RED + " and more than 10.000 Subscribers?" + 
				"\n" + ChatColor.DARK_GRAY + "" + ChatColor.STRIKETHROUGH + "-->" + ChatColor.YELLOW + "   " + FC.getMainCfg().getString("link.pass") + 
				"\n" + ChatColor.RED + " " + 
				"\n" + NationZ.line(ChatColor.AQUA));
		notWhitelisted = true;
		return;
	}
	
       AttributeInstance instance = e.getPlayer().getAttribute(Attribute.GENERIC_ATTACK_SPEED);
       if (instance != null) {
           instance.setBaseValue(16);
       }
	
	NZPlayer nz = NZPlayer.getNZPlayer(e.getPlayer());
	if (nz.getNation() != null) {
		nz.getNation().reAddToNation(e.getPlayer());
	}
	if (nz.getJob() != null) {
		nz.getJob().reAddToJob(e.getPlayer(), nz.getJobLevel());
	}
	
	if (nz.getLastName() == null) {
		nz.addName(e.getPlayer().getName());
	} else {
		if (!(nz.getLastName().equals(e.getPlayer().getName()))) {
			nz.addName(e.getPlayer().getName());
		}
	}
	
	AsyncPlayerChatListener.checkForChat(e.getPlayer(), false);
	e.setJoinMessage(null);
	e.getPlayer().getInventory().setItem(8, MainMenuInventory.item());
	e.getPlayer().setOp(nz.hasRank(Rank.DEVELOPER));
	
	PacketContainer tablist = NationZ.protocolManager.createPacket(PacketType.Play.Server.PLAYER_LIST_HEADER_FOOTER);
	tablist.getChatComponents().write(0, WrappedChatComponent.fromText(NationZ.title + ChatColor.DARK_GRAY + " - " + ChatColor.GOLD + "A unique Hardcore-Clan-Survival Experience."));
	tablist.getChatComponents().write(1, WrappedChatComponent.fromText(nz.getJob().getDisplayname() + ChatColor.DARK_GRAY + " (" + ChatColor.DARK_GREEN + nz.getJobLevel() + ChatColor.DARK_GRAY + ") - " + nz.getNation().getDisplayname()));
	
	try {
		NationZ.protocolManager.sendServerPacket(e.getPlayer(), tablist);
	} catch (InvocationTargetException e1) {
		e1.printStackTrace();
	}
}
 
开发者ID:crazyhorse961,项目名称:NationZ,代码行数:70,代码来源:ConnectionListener.java


注:本文中的org.bukkit.attribute.AttributeInstance.setBaseValue方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。