mirror of
https://github.com/mcMMO-Dev/mcMMO.git
synced 2024-11-26 07:06:45 +01:00
AntiTheft option for Disarm Ability
This commit is contained in:
parent
86b92b5b30
commit
2d577e92f1
@ -741,6 +741,7 @@ public class AdvancedConfig extends AutoUpdateConfigLoader {
|
|||||||
public double getIronArmMinBonus() { return config.getDouble("Skills.Unarmed.IronArm.BonusMin", 3.0D); }
|
public double getIronArmMinBonus() { return config.getDouble("Skills.Unarmed.IronArm.BonusMin", 3.0D); }
|
||||||
public double getIronArmMaxBonus() { return config.getDouble("Skills.Unarmed.IronArm.BonusMax", 8.0D); }
|
public double getIronArmMaxBonus() { return config.getDouble("Skills.Unarmed.IronArm.BonusMax", 8.0D); }
|
||||||
public int getIronArmIncreaseLevel() { return config.getInt("Skills.Unarmed.IronArm.IncreaseLevel", 50); }
|
public int getIronArmIncreaseLevel() { return config.getInt("Skills.Unarmed.IronArm.IncreaseLevel", 50); }
|
||||||
|
public boolean getDisarmProtected() { return config.getBoolean("Skills.Unarmed.Disarm.AntiTheft", false); }
|
||||||
|
|
||||||
/* WOODCUTTING */
|
/* WOODCUTTING */
|
||||||
public int getLeafBlowUnlockLevel() { return config.getInt("Skills.Woodcutting.LeafBlower.UnlockLevel", 100); }
|
public int getLeafBlowUnlockLevel() { return config.getInt("Skills.Woodcutting.LeafBlower.UnlockLevel", 100); }
|
||||||
|
@ -10,6 +10,7 @@ import org.bukkit.Server;
|
|||||||
import org.bukkit.Sound;
|
import org.bukkit.Sound;
|
||||||
import org.bukkit.entity.Player;
|
import org.bukkit.entity.Player;
|
||||||
import org.bukkit.inventory.ItemStack;
|
import org.bukkit.inventory.ItemStack;
|
||||||
|
import org.bukkit.metadata.FixedMetadataValue;
|
||||||
import org.bukkit.scheduler.BukkitRunnable;
|
import org.bukkit.scheduler.BukkitRunnable;
|
||||||
|
|
||||||
import com.gmail.nossr50.mcMMO;
|
import com.gmail.nossr50.mcMMO;
|
||||||
@ -87,11 +88,13 @@ public class McMMOPlayer {
|
|||||||
private Location teleportCommence;
|
private Location teleportCommence;
|
||||||
|
|
||||||
private boolean isUsingUnarmed;
|
private boolean isUsingUnarmed;
|
||||||
|
private final FixedMetadataValue playerMetadata;
|
||||||
|
|
||||||
public McMMOPlayer(Player player) {
|
public McMMOPlayer(Player player) {
|
||||||
String playerName = player.getName();
|
String playerName = player.getName();
|
||||||
|
|
||||||
this.player = player;
|
this.player = player;
|
||||||
|
playerMetadata = new FixedMetadataValue(mcMMO.p, playerName);
|
||||||
profile = mcMMO.getDatabaseManager().loadPlayerProfile(playerName, true);
|
profile = mcMMO.getDatabaseManager().loadPlayerProfile(playerName, true);
|
||||||
party = PartyManager.getPlayerParty(playerName);
|
party = PartyManager.getPlayerParty(playerName);
|
||||||
ptpRecord = new PartyTeleportRecord();
|
ptpRecord = new PartyTeleportRecord();
|
||||||
@ -913,4 +916,8 @@ public class McMMOPlayer {
|
|||||||
public void resetCooldowns() {
|
public void resetCooldowns() {
|
||||||
profile.resetCooldowns();
|
profile.resetCooldowns();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public FixedMetadataValue getPlayerMetadata() {
|
||||||
|
return playerMetadata;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@ -44,7 +44,7 @@ public class InventoryListener implements Listener {
|
|||||||
Block furnaceBlock = Misc.processInventoryOpenorCloseEvent(event);
|
Block furnaceBlock = Misc.processInventoryOpenorCloseEvent(event);
|
||||||
|
|
||||||
if (furnaceBlock != null && !furnaceBlock.hasMetadata(mcMMO.furnaceMetadataKey)) {
|
if (furnaceBlock != null && !furnaceBlock.hasMetadata(mcMMO.furnaceMetadataKey)) {
|
||||||
furnaceBlock.setMetadata(mcMMO.furnaceMetadataKey, new FixedMetadataValue(plugin, player.getName()));
|
furnaceBlock.setMetadata(mcMMO.furnaceMetadataKey, UserManager.getPlayer((Player) player).getPlayerMetadata());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -300,6 +300,14 @@ public class PlayerListener implements Listener {
|
|||||||
Item drop = event.getItem();
|
Item drop = event.getItem();
|
||||||
ItemStack dropStack = drop.getItemStack();
|
ItemStack dropStack = drop.getItemStack();
|
||||||
|
|
||||||
|
if (drop.hasMetadata(mcMMO.disarmedItemKey)) {
|
||||||
|
if (!player.getName().equals(drop.getMetadata(mcMMO.disarmedItemKey).get(0).value())) {
|
||||||
|
event.setCancelled(true);
|
||||||
|
}
|
||||||
|
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
if (!drop.hasMetadata(mcMMO.droppedItemKey) && mcMMOPlayer.inParty() && ItemUtils.isSharable(dropStack)) {
|
if (!drop.hasMetadata(mcMMO.droppedItemKey) && mcMMOPlayer.inParty() && ItemUtils.isSharable(dropStack)) {
|
||||||
event.setCancelled(ShareHandler.handleItemShare(drop, mcMMOPlayer));
|
event.setCancelled(ShareHandler.handleItemShare(drop, mcMMOPlayer));
|
||||||
|
|
||||||
|
@ -105,6 +105,7 @@ public class mcMMO extends JavaPlugin {
|
|||||||
public final static String bowForceKey = "mcMMO: Bow Force";
|
public final static String bowForceKey = "mcMMO: Bow Force";
|
||||||
public final static String arrowDistanceKey = "mcMMO: Arrow Distance";
|
public final static String arrowDistanceKey = "mcMMO: Arrow Distance";
|
||||||
public final static String customDamageKey = "mcMMO: Custom Damage";
|
public final static String customDamageKey = "mcMMO: Custom Damage";
|
||||||
|
public final static String disarmedItemKey = "mcMMO: Disarmed Item";
|
||||||
|
|
||||||
public static FixedMetadataValue metadataValue;
|
public static FixedMetadataValue metadataValue;
|
||||||
|
|
||||||
|
@ -9,8 +9,6 @@ import org.bukkit.block.BlockState;
|
|||||||
import org.bukkit.enchantments.Enchantment;
|
import org.bukkit.enchantments.Enchantment;
|
||||||
import org.bukkit.entity.Player;
|
import org.bukkit.entity.Player;
|
||||||
import org.bukkit.entity.TNTPrimed;
|
import org.bukkit.entity.TNTPrimed;
|
||||||
import org.bukkit.metadata.FixedMetadataValue;
|
|
||||||
|
|
||||||
import com.gmail.nossr50.mcMMO;
|
import com.gmail.nossr50.mcMMO;
|
||||||
import com.gmail.nossr50.config.Config;
|
import com.gmail.nossr50.config.Config;
|
||||||
import com.gmail.nossr50.datatypes.player.McMMOPlayer;
|
import com.gmail.nossr50.datatypes.player.McMMOPlayer;
|
||||||
@ -105,7 +103,7 @@ public class MiningManager extends SkillManager {
|
|||||||
SkillUtils.sendSkillMessage(player, AbilityType.BLAST_MINING.getAbilityPlayer(player));
|
SkillUtils.sendSkillMessage(player, AbilityType.BLAST_MINING.getAbilityPlayer(player));
|
||||||
player.sendMessage(LocaleLoader.getString("Mining.Blast.Boom"));
|
player.sendMessage(LocaleLoader.getString("Mining.Blast.Boom"));
|
||||||
|
|
||||||
tnt.setMetadata(mcMMO.tntMetadataKey, new FixedMetadataValue(mcMMO.p, player.getName()));
|
tnt.setMetadata(mcMMO.tntMetadataKey, mcMMOPlayer.getPlayerMetadata());
|
||||||
tnt.setFuseTicks(0);
|
tnt.setFuseTicks(0);
|
||||||
targetBlock.setType(Material.AIR);
|
targetBlock.setType(Material.AIR);
|
||||||
|
|
||||||
|
@ -2,12 +2,14 @@ package com.gmail.nossr50.skills.unarmed;
|
|||||||
|
|
||||||
import org.bukkit.Material;
|
import org.bukkit.Material;
|
||||||
import org.bukkit.block.BlockState;
|
import org.bukkit.block.BlockState;
|
||||||
|
import org.bukkit.entity.Item;
|
||||||
import org.bukkit.entity.LivingEntity;
|
import org.bukkit.entity.LivingEntity;
|
||||||
import org.bukkit.entity.Player;
|
import org.bukkit.entity.Player;
|
||||||
import org.bukkit.inventory.ItemStack;
|
import org.bukkit.inventory.ItemStack;
|
||||||
import org.bukkit.material.MaterialData;
|
import org.bukkit.material.MaterialData;
|
||||||
import org.bukkit.material.SmoothBrick;
|
import org.bukkit.material.SmoothBrick;
|
||||||
|
import com.gmail.nossr50.mcMMO;
|
||||||
|
import com.gmail.nossr50.config.AdvancedConfig;
|
||||||
import com.gmail.nossr50.datatypes.player.McMMOPlayer;
|
import com.gmail.nossr50.datatypes.player.McMMOPlayer;
|
||||||
import com.gmail.nossr50.datatypes.skills.AbilityType;
|
import com.gmail.nossr50.datatypes.skills.AbilityType;
|
||||||
import com.gmail.nossr50.datatypes.skills.SecondaryAbility;
|
import com.gmail.nossr50.datatypes.skills.SecondaryAbility;
|
||||||
@ -18,6 +20,7 @@ import com.gmail.nossr50.skills.SkillManager;
|
|||||||
import com.gmail.nossr50.util.EventUtils;
|
import com.gmail.nossr50.util.EventUtils;
|
||||||
import com.gmail.nossr50.util.Misc;
|
import com.gmail.nossr50.util.Misc;
|
||||||
import com.gmail.nossr50.util.Permissions;
|
import com.gmail.nossr50.util.Permissions;
|
||||||
|
import com.gmail.nossr50.util.player.UserManager;
|
||||||
import com.gmail.nossr50.util.skills.CombatUtils;
|
import com.gmail.nossr50.util.skills.CombatUtils;
|
||||||
import com.gmail.nossr50.util.skills.SkillUtils;
|
import com.gmail.nossr50.util.skills.SkillUtils;
|
||||||
|
|
||||||
@ -87,7 +90,11 @@ public class UnarmedManager extends SkillManager {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
Misc.dropItem(defender.getLocation(), defender.getItemInHand());
|
Item item = Misc.dropItem(defender.getLocation(), defender.getItemInHand());
|
||||||
|
|
||||||
|
if (item != null && AdvancedConfig.getInstance().getDisarmProtected()) {
|
||||||
|
item.setMetadata(mcMMO.disarmedItemKey, UserManager.getPlayer(defender).getPlayerMetadata());
|
||||||
|
}
|
||||||
|
|
||||||
defender.setItemInHand(new ItemStack(Material.AIR));
|
defender.setItemInHand(new ItemStack(Material.AIR));
|
||||||
defender.sendMessage(LocaleLoader.getString("Skills.Disarmed"));
|
defender.sendMessage(LocaleLoader.getString("Skills.Disarmed"));
|
||||||
|
@ -14,6 +14,7 @@ import org.bukkit.block.BlockState;
|
|||||||
import org.bukkit.block.Furnace;
|
import org.bukkit.block.Furnace;
|
||||||
import org.bukkit.entity.Entity;
|
import org.bukkit.entity.Entity;
|
||||||
import org.bukkit.entity.HumanEntity;
|
import org.bukkit.entity.HumanEntity;
|
||||||
|
import org.bukkit.entity.Item;
|
||||||
import org.bukkit.entity.NPC;
|
import org.bukkit.entity.NPC;
|
||||||
import org.bukkit.entity.Player;
|
import org.bukkit.entity.Player;
|
||||||
import org.bukkit.event.inventory.InventoryEvent;
|
import org.bukkit.event.inventory.InventoryEvent;
|
||||||
@ -172,10 +173,11 @@ public final class Misc {
|
|||||||
*
|
*
|
||||||
* @param location The location to drop the item at
|
* @param location The location to drop the item at
|
||||||
* @param itemStack The item to drop
|
* @param itemStack The item to drop
|
||||||
|
* @return Dropped Item entity or null if invalid or cancelled
|
||||||
*/
|
*/
|
||||||
public static void dropItem(Location location, ItemStack itemStack) {
|
public static Item dropItem(Location location, ItemStack itemStack) {
|
||||||
if (itemStack.getType() == Material.AIR) {
|
if (itemStack.getType() == Material.AIR) {
|
||||||
return;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
// We can't get the item until we spawn it and we want to make it cancellable, so we have a custom event.
|
// We can't get the item until we spawn it and we want to make it cancellable, so we have a custom event.
|
||||||
@ -183,10 +185,10 @@ public final class Misc {
|
|||||||
mcMMO.p.getServer().getPluginManager().callEvent(event);
|
mcMMO.p.getServer().getPluginManager().callEvent(event);
|
||||||
|
|
||||||
if (event.isCancelled()) {
|
if (event.isCancelled()) {
|
||||||
return;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
location.getWorld().dropItemNaturally(location, itemStack);
|
return location.getWorld().dropItemNaturally(location, itemStack);
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void profileCleanup(String playerName) {
|
public static void profileCleanup(String playerName) {
|
||||||
|
@ -456,8 +456,10 @@ Skills:
|
|||||||
Disarm:
|
Disarm:
|
||||||
# ChanceMax: Maximum chance of disarming other players
|
# ChanceMax: Maximum chance of disarming other players
|
||||||
# MaxBonusLevel: Level when the maximum chance to disarm is reached
|
# MaxBonusLevel: Level when the maximum chance to disarm is reached
|
||||||
|
# AntiTheft: Determines if only the disarmed player can retrieve disarmed items
|
||||||
ChanceMax: 33.0
|
ChanceMax: 33.0
|
||||||
MaxBonusLevel: 1000
|
MaxBonusLevel: 1000
|
||||||
|
AntiTheft: false
|
||||||
|
|
||||||
Deflect:
|
Deflect:
|
||||||
# ChanceMax: Maximum chance of deflecting arrows
|
# ChanceMax: Maximum chance of deflecting arrows
|
||||||
|
Loading…
Reference in New Issue
Block a user