mirror of
https://github.com/mcMMO-Dev/mcMMO.git
synced 2024-11-26 15:16:45 +01:00
Assorted event updates. Created new McMMOPlayerRepairEvent for when a
repair is completed.
This commit is contained in:
parent
6a8737547f
commit
2d3b01ba34
@ -18,8 +18,8 @@ import org.bukkit.inventory.ItemStack;
|
||||
import com.gmail.nossr50.config.LoadProperties;
|
||||
import com.gmail.nossr50.datatypes.PlayerProfile;
|
||||
import com.gmail.nossr50.datatypes.SkillType;
|
||||
import com.gmail.nossr50.events.FakeEntityDamageByEntityEvent;
|
||||
import com.gmail.nossr50.events.FakeEntityDamageEvent;
|
||||
import com.gmail.nossr50.events.fake.FakeEntityDamageByEntityEvent;
|
||||
import com.gmail.nossr50.events.fake.FakeEntityDamageEvent;
|
||||
import com.gmail.nossr50.locale.mcLocale;
|
||||
import com.gmail.nossr50.party.Party;
|
||||
import com.gmail.nossr50.runnables.GainXp;
|
||||
|
@ -2,6 +2,7 @@ package com.gmail.nossr50.datatypes;
|
||||
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
import com.gmail.nossr50.Users;
|
||||
import com.gmail.nossr50.mcPermissions;
|
||||
import com.gmail.nossr50.config.LoadProperties;
|
||||
|
||||
@ -99,4 +100,8 @@ public enum SkillType
|
||||
public double getXpModifier() {
|
||||
return xpModifier;
|
||||
}
|
||||
|
||||
public int getSkillLevel(Player player) {
|
||||
return Users.getProfile(player).getSkillLevel(this);
|
||||
}
|
||||
}
|
||||
|
@ -0,0 +1,33 @@
|
||||
package com.gmail.nossr50.events;
|
||||
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.event.HandlerList;
|
||||
import org.bukkit.event.player.PlayerEvent;
|
||||
|
||||
import com.gmail.nossr50.datatypes.SkillType;
|
||||
|
||||
public class McMMOPlayerExperienceEvent extends PlayerEvent{
|
||||
|
||||
protected SkillType skill;
|
||||
|
||||
public McMMOPlayerExperienceEvent(Player player, SkillType skill) {
|
||||
super(player);
|
||||
this.skill = skill;
|
||||
}
|
||||
|
||||
public SkillType getSkill() {
|
||||
return skill;
|
||||
}
|
||||
|
||||
/** Rest of file is required boilerplate for custom events **/
|
||||
private static final HandlerList handlers = new HandlerList();
|
||||
|
||||
@Override
|
||||
public HandlerList getHandlers() {
|
||||
return handlers;
|
||||
}
|
||||
|
||||
public static HandlerList getHandlerList() {
|
||||
return handlers;
|
||||
}
|
||||
}
|
@ -1,54 +1,24 @@
|
||||
package com.gmail.nossr50.events;
|
||||
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.event.Event;
|
||||
import org.bukkit.event.HandlerList;
|
||||
|
||||
import com.gmail.nossr50.datatypes.SkillType;
|
||||
|
||||
/**
|
||||
* Called when a user levels up in a skill
|
||||
*/
|
||||
public class McMMOPlayerLevelUpEvent extends Event {
|
||||
private Player player;
|
||||
private SkillType skill;
|
||||
public class McMMOPlayerLevelUpEvent extends McMMOPlayerExperienceEvent {
|
||||
private int levelsGained;
|
||||
|
||||
public McMMOPlayerLevelUpEvent(Player player, SkillType skill) {
|
||||
this.player = player;
|
||||
this.skill = skill;
|
||||
super(player, skill);
|
||||
this.levelsGained = 1; // Always 1 for now as we call in the loop where the levelups are calculated, could change later!
|
||||
}
|
||||
|
||||
/**
|
||||
* @return Player leveling up
|
||||
*/
|
||||
public Player getPlayer() {
|
||||
return player;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return SkillType that is being leveled up
|
||||
*/
|
||||
public SkillType getSkill() {
|
||||
return skill;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return The number of levels gained in this event
|
||||
*/
|
||||
public int getLevelsGained() {
|
||||
return levelsGained;
|
||||
}
|
||||
|
||||
/** Rest of file is required boilerplate for custom events **/
|
||||
private static final HandlerList handlers = new HandlerList();
|
||||
|
||||
public HandlerList getHandlers() {
|
||||
return handlers;
|
||||
}
|
||||
|
||||
public static HandlerList getHandlerList() {
|
||||
return handlers;
|
||||
}
|
||||
}
|
||||
|
@ -0,0 +1,26 @@
|
||||
package com.gmail.nossr50.events;
|
||||
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.inventory.ItemStack;
|
||||
|
||||
import com.gmail.nossr50.datatypes.SkillType;
|
||||
|
||||
public class McMMOPlayerRepairEvent extends McMMOPlayerSkillEvent{
|
||||
|
||||
private ItemStack item;
|
||||
private short repairAmount;
|
||||
|
||||
public McMMOPlayerRepairEvent(Player player, ItemStack item, short repairAmount) {
|
||||
super(player, SkillType.REPAIR);
|
||||
this.item = item;
|
||||
this.repairAmount = repairAmount;
|
||||
}
|
||||
|
||||
public ItemStack getItem() {
|
||||
return item;
|
||||
}
|
||||
|
||||
public int getRepairAmount() {
|
||||
return repairAmount;
|
||||
}
|
||||
}
|
@ -0,0 +1,35 @@
|
||||
package com.gmail.nossr50.events;
|
||||
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.event.HandlerList;
|
||||
import org.bukkit.event.player.PlayerEvent;
|
||||
|
||||
import com.gmail.nossr50.datatypes.SkillType;
|
||||
|
||||
public class McMMOPlayerSkillEvent extends PlayerEvent{
|
||||
|
||||
protected SkillType skill;
|
||||
protected int skillLevel;
|
||||
|
||||
public McMMOPlayerSkillEvent(Player player, SkillType skill) {
|
||||
super(player);
|
||||
this.skill = skill;
|
||||
}
|
||||
|
||||
public SkillType getSkill() {
|
||||
return skill;
|
||||
}
|
||||
|
||||
/** Rest of file is required boilerplate for custom events **/
|
||||
private static final HandlerList handlers = new HandlerList();
|
||||
|
||||
@Override
|
||||
public HandlerList getHandlers() {
|
||||
return handlers;
|
||||
}
|
||||
|
||||
public static HandlerList getHandlerList() {
|
||||
return handlers;
|
||||
}
|
||||
}
|
||||
|
@ -1,51 +1,21 @@
|
||||
package com.gmail.nossr50.events;
|
||||
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.event.Event;
|
||||
import org.bukkit.event.HandlerList;
|
||||
|
||||
import com.gmail.nossr50.datatypes.SkillType;
|
||||
|
||||
public class McMMOPlayerXpGainEvent extends Event {
|
||||
private Player player;
|
||||
private SkillType skill;
|
||||
public class McMMOPlayerXpGainEvent extends McMMOPlayerExperienceEvent {
|
||||
private int xpGained;
|
||||
|
||||
public McMMOPlayerXpGainEvent(Player player, SkillType skill, int xpGained) {
|
||||
this.player = player;
|
||||
this.skill = skill;
|
||||
super(player, skill);
|
||||
this.xpGained = xpGained;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return Player gaining experience (can be null)
|
||||
*/
|
||||
public Player getPlayer() {
|
||||
return player;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return SkillType that is gaining experience
|
||||
*/
|
||||
public SkillType getSkill() {
|
||||
return skill;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return The number experience gained in this event
|
||||
*/
|
||||
public int getXpGained() {
|
||||
return xpGained;
|
||||
}
|
||||
|
||||
/** Rest of file is required boilerplate for custom events **/
|
||||
private static final HandlerList handlers = new HandlerList();
|
||||
|
||||
public HandlerList getHandlers() {
|
||||
return handlers;
|
||||
}
|
||||
|
||||
public static HandlerList getHandlerList() {
|
||||
return handlers;
|
||||
}
|
||||
}
|
||||
|
@ -1,4 +1,4 @@
|
||||
package com.gmail.nossr50.events;
|
||||
package com.gmail.nossr50.events.fake;
|
||||
|
||||
import java.util.ArrayList;
|
||||
|
@ -1,9 +1,10 @@
|
||||
package com.gmail.nossr50.events;
|
||||
package com.gmail.nossr50.events.fake;
|
||||
|
||||
import org.bukkit.entity.Entity;
|
||||
import org.bukkit.event.entity.EntityDamageByEntityEvent;
|
||||
|
||||
public class FakeEntityDamageByEntityEvent extends EntityDamageByEntityEvent {
|
||||
|
||||
public FakeEntityDamageByEntityEvent(Entity damager, Entity damagee, DamageCause cause, int damage) {
|
||||
super(damager, damagee, cause, damage);
|
||||
}
|
@ -1,4 +1,4 @@
|
||||
package com.gmail.nossr50.events;
|
||||
package com.gmail.nossr50.events.fake;
|
||||
|
||||
import org.bukkit.entity.Entity;
|
||||
import org.bukkit.event.entity.EntityDamageEvent;
|
@ -0,0 +1,12 @@
|
||||
package com.gmail.nossr50.events.fake;
|
||||
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.event.player.PlayerAnimationEvent;
|
||||
|
||||
public class FakePlayerAnimationEvent extends PlayerAnimationEvent{
|
||||
|
||||
public FakePlayerAnimationEvent(Player player) {
|
||||
super(player);
|
||||
}
|
||||
|
||||
}
|
@ -18,7 +18,8 @@ import com.gmail.nossr50.skills.Repair;
|
||||
import com.gmail.nossr50.skills.Skills;
|
||||
import com.gmail.nossr50.skills.WoodCutting;
|
||||
import com.gmail.nossr50.spout.SpoutSounds;
|
||||
import com.gmail.nossr50.events.FakeBlockBreakEvent;
|
||||
import com.gmail.nossr50.events.fake.FakeBlockBreakEvent;
|
||||
import com.gmail.nossr50.events.fake.FakePlayerAnimationEvent;
|
||||
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.CropState;
|
||||
@ -34,7 +35,6 @@ import org.bukkit.event.block.BlockDamageEvent;
|
||||
import org.bukkit.event.block.BlockPistonExtendEvent;
|
||||
import org.bukkit.event.block.BlockPistonRetractEvent;
|
||||
import org.bukkit.event.block.BlockPlaceEvent;
|
||||
import org.bukkit.event.player.PlayerAnimationEvent;
|
||||
import org.bukkit.inventory.ItemStack;
|
||||
import org.bukkit.metadata.FixedMetadataValue;
|
||||
|
||||
@ -266,7 +266,7 @@ public class mcBlockListener implements Listener {
|
||||
}
|
||||
else if (PP.getBerserkMode() && Skills.triggerCheck(player, block, AbilityType.BERSERK)) {
|
||||
if (inhand.getType().equals(Material.AIR)) {
|
||||
PlayerAnimationEvent armswing = new PlayerAnimationEvent(player);
|
||||
FakePlayerAnimationEvent armswing = new FakePlayerAnimationEvent(player);
|
||||
Bukkit.getPluginManager().callEvent(armswing);
|
||||
|
||||
event.setInstaBreak(true);
|
||||
|
@ -30,8 +30,8 @@ import com.gmail.nossr50.mcPermissions;
|
||||
import com.gmail.nossr50.config.LoadProperties;
|
||||
import com.gmail.nossr50.datatypes.PlayerProfile;
|
||||
import com.gmail.nossr50.datatypes.SkillType;
|
||||
import com.gmail.nossr50.events.FakeEntityDamageByEntityEvent;
|
||||
import com.gmail.nossr50.events.FakeEntityDamageEvent;
|
||||
import com.gmail.nossr50.events.fake.FakeEntityDamageByEntityEvent;
|
||||
import com.gmail.nossr50.events.fake.FakeEntityDamageEvent;
|
||||
import com.gmail.nossr50.party.Party;
|
||||
import com.gmail.nossr50.runnables.mcBleedTimer;
|
||||
import com.gmail.nossr50.skills.Acrobatics;
|
||||
|
@ -9,13 +9,13 @@ import org.bukkit.block.Block;
|
||||
import org.bukkit.entity.LivingEntity;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.event.entity.EntityDamageEvent;
|
||||
import org.bukkit.event.player.PlayerAnimationEvent;
|
||||
import org.bukkit.inventory.ItemStack;
|
||||
|
||||
import com.gmail.nossr50.datatypes.PlayerProfile;
|
||||
import com.gmail.nossr50.datatypes.SkillType;
|
||||
import com.gmail.nossr50.events.FakeBlockBreakEvent;
|
||||
import com.gmail.nossr50.events.McMMOItemSpawnEvent;
|
||||
import com.gmail.nossr50.events.fake.FakeBlockBreakEvent;
|
||||
import com.gmail.nossr50.events.fake.FakePlayerAnimationEvent;
|
||||
|
||||
public class m {
|
||||
|
||||
@ -127,7 +127,7 @@ public class m {
|
||||
|
||||
//Support for NoCheat
|
||||
if (shouldArmSwing) {
|
||||
PlayerAnimationEvent armswing = new PlayerAnimationEvent(player);
|
||||
FakePlayerAnimationEvent armswing = new FakePlayerAnimationEvent(player);
|
||||
Bukkit.getPluginManager().callEvent(armswing);
|
||||
}
|
||||
|
||||
|
@ -10,7 +10,6 @@ import org.bukkit.Material;
|
||||
import org.bukkit.block.Block;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.inventory.ItemStack;
|
||||
import org.bukkit.event.player.PlayerAnimationEvent;
|
||||
|
||||
import com.gmail.nossr50.spout.SpoutSounds;
|
||||
import com.gmail.nossr50.Users;
|
||||
@ -21,6 +20,7 @@ import com.gmail.nossr50.config.LoadTreasures;
|
||||
import com.gmail.nossr50.datatypes.PlayerProfile;
|
||||
import com.gmail.nossr50.datatypes.SkillType;
|
||||
import com.gmail.nossr50.datatypes.treasure.ExcavationTreasure;
|
||||
import com.gmail.nossr50.events.fake.FakePlayerAnimationEvent;
|
||||
|
||||
import org.getspout.spoutapi.sound.SoundEffect;
|
||||
|
||||
@ -134,7 +134,7 @@ public class Excavation {
|
||||
Skills.abilityDurabilityLoss(player.getItemInHand(), LoadProperties.abilityDurabilityLoss);
|
||||
|
||||
if (!block.hasMetadata("mcmmoPlacedBlock")) {
|
||||
PlayerAnimationEvent armswing = new PlayerAnimationEvent(player);
|
||||
FakePlayerAnimationEvent armswing = new FakePlayerAnimationEvent(player);
|
||||
Bukkit.getPluginManager().callEvent(armswing);
|
||||
|
||||
Excavation.excavationProcCheck(block, player);
|
||||
|
@ -11,7 +11,6 @@ import org.bukkit.entity.Player;
|
||||
import org.bukkit.inventory.ItemStack;
|
||||
import org.getspout.spoutapi.sound.SoundEffect;
|
||||
import org.bukkit.enchantments.Enchantment;
|
||||
import org.bukkit.event.player.PlayerAnimationEvent;
|
||||
|
||||
import com.gmail.nossr50.Users;
|
||||
import com.gmail.nossr50.m;
|
||||
@ -20,6 +19,7 @@ import com.gmail.nossr50.config.LoadProperties;
|
||||
import com.gmail.nossr50.spout.SpoutSounds;
|
||||
import com.gmail.nossr50.datatypes.PlayerProfile;
|
||||
import com.gmail.nossr50.datatypes.SkillType;
|
||||
import com.gmail.nossr50.events.fake.FakePlayerAnimationEvent;
|
||||
|
||||
public class Mining {
|
||||
|
||||
@ -217,7 +217,7 @@ public class Mining {
|
||||
Material type = block.getType();
|
||||
int tier = m.getTier(player.getItemInHand());
|
||||
int durabilityLoss = LoadProperties.abilityDurabilityLoss;
|
||||
PlayerAnimationEvent armswing = new PlayerAnimationEvent(player);
|
||||
FakePlayerAnimationEvent armswing = new FakePlayerAnimationEvent(player);
|
||||
|
||||
switch (type) {
|
||||
case OBSIDIAN:
|
||||
|
@ -4,6 +4,7 @@ import java.util.Map;
|
||||
import java.util.Random;
|
||||
import java.util.Map.Entry;
|
||||
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.ChatColor;
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.enchantments.Enchantment;
|
||||
@ -21,6 +22,7 @@ import com.gmail.nossr50.config.LoadProperties;
|
||||
import com.gmail.nossr50.spout.SpoutSounds;
|
||||
import com.gmail.nossr50.datatypes.PlayerProfile;
|
||||
import com.gmail.nossr50.datatypes.SkillType;
|
||||
import com.gmail.nossr50.events.McMMOPlayerRepairEvent;
|
||||
import com.gmail.nossr50.locale.mcLocale;
|
||||
|
||||
public class Repair {
|
||||
@ -437,7 +439,11 @@ public class Repair {
|
||||
addEnchants(player, is);
|
||||
}
|
||||
|
||||
is.setDurability(getRepairAmount(is, player));
|
||||
short repairAmount = getRepairAmount(is, player);
|
||||
is.setDurability(repairAmount);
|
||||
|
||||
McMMOPlayerRepairEvent event = new McMMOPlayerRepairEvent(player, is, repairAmount);
|
||||
Bukkit.getPluginManager().callEvent(event);
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -10,7 +10,6 @@ import org.bukkit.entity.Player;
|
||||
import org.bukkit.inventory.ItemStack;
|
||||
import org.bukkit.material.Tree;
|
||||
import org.bukkit.event.block.BlockBreakEvent;
|
||||
import org.bukkit.event.player.PlayerAnimationEvent;
|
||||
import org.bukkit.Bukkit;
|
||||
|
||||
import com.gmail.nossr50.Combat;
|
||||
@ -20,6 +19,7 @@ import com.gmail.nossr50.mcPermissions;
|
||||
import com.gmail.nossr50.config.LoadProperties;
|
||||
import com.gmail.nossr50.datatypes.PlayerProfile;
|
||||
import com.gmail.nossr50.datatypes.SkillType;
|
||||
import com.gmail.nossr50.events.fake.FakePlayerAnimationEvent;
|
||||
import com.gmail.nossr50.locale.mcLocale;
|
||||
import com.gmail.nossr50.spout.SpoutSounds;
|
||||
|
||||
@ -306,7 +306,7 @@ public class WoodCutting {
|
||||
* @param block Block being broken
|
||||
*/
|
||||
public static void leafBlower(Player player, Block block) {
|
||||
PlayerAnimationEvent armswing = new PlayerAnimationEvent(player);
|
||||
FakePlayerAnimationEvent armswing = new FakePlayerAnimationEvent(player);
|
||||
Bukkit.getPluginManager().callEvent(armswing);
|
||||
|
||||
if (LoadProperties.woodcuttingrequiresaxe) {
|
||||
|
Loading…
Reference in New Issue
Block a user