Disable the ability to craft Fishing Rods. Fix bug where players could use the Blink or Flash skills to bypass borders on negative coordinate sides of the map and die to border control. Fix bug where players could open the enchantment table GUI and enchant items when shift clicking without an item. Fix bug where players couldn't place blocks on top of Anvils. Fix NPE bug with players clicking on Anvils while not holding an item. Fix bug where the '/c home' command cooldown was reset on a players death, allowing for abuse. Fix duplication bug where BlockToss could be exploited inside claims by throwing valuable blocks into water blocks. Fix bug where players could lose items to NPC shop inventories using inventory drag skills to drag items across open slots. Cap the member size of a clan to 20 and maximum available claim count to 8.
This commit is contained in:
parent
0bafae6485
commit
3a8fd18d2e
@ -1,8 +1,10 @@
|
|||||||
package mineplex.core.recharge;
|
package mineplex.core.recharge;
|
||||||
|
|
||||||
|
import java.util.ArrayList;
|
||||||
import java.util.HashSet;
|
import java.util.HashSet;
|
||||||
import java.util.Iterator;
|
import java.util.Iterator;
|
||||||
import java.util.LinkedList;
|
import java.util.LinkedList;
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
import org.bukkit.entity.Player;
|
import org.bukkit.entity.Player;
|
||||||
import org.bukkit.event.EventHandler;
|
import org.bukkit.event.EventHandler;
|
||||||
@ -40,7 +42,22 @@ public class Recharge extends MiniPlugin
|
|||||||
@EventHandler
|
@EventHandler
|
||||||
public void PlayerDeath(PlayerDeathEvent event)
|
public void PlayerDeath(PlayerDeathEvent event)
|
||||||
{
|
{
|
||||||
Get(event.getEntity().getName()).clear();
|
NautHashMap<String, RechargeData> data = Get(event.getEntity().getName());
|
||||||
|
List<RechargeData> rechargeDatas = new ArrayList<RechargeData>(data.values());
|
||||||
|
|
||||||
|
// Remove/clear all cooldowns that are flagged as ClearOnDeath
|
||||||
|
for (RechargeData rechargeData : rechargeDatas)
|
||||||
|
{
|
||||||
|
if (rechargeData.ClearOnDeath)
|
||||||
|
{
|
||||||
|
data.remove(rechargeData.Name);
|
||||||
|
System.out.println("Cleared " + rechargeData.Name);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
System.out.println("Didn't clear: " + rechargeData.Name);
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public NautHashMap<String, RechargeData> Get(String name)
|
public NautHashMap<String, RechargeData> Get(String name)
|
||||||
@ -100,15 +117,16 @@ public class Recharge extends MiniPlugin
|
|||||||
|
|
||||||
public boolean use(Player player, String ability, String abilityFull, long recharge, boolean inform, boolean attachItem)
|
public boolean use(Player player, String ability, String abilityFull, long recharge, boolean inform, boolean attachItem)
|
||||||
{
|
{
|
||||||
return use(player, ability, abilityFull, recharge, inform, attachItem, false);
|
return use(player, ability, abilityFull, recharge, inform, attachItem, false, true);
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean use(Player player, String ability, long recharge, boolean inform, boolean attachItem, boolean attachDurability)
|
public boolean use(Player player, String ability, long recharge, boolean inform, boolean attachItem, boolean attachDurability)
|
||||||
{
|
{
|
||||||
return use(player, ability, ability, recharge, inform, attachItem, attachDurability);
|
return use(player, ability, ability, recharge, inform, attachItem, attachDurability, true);
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean use(Player player, String ability, String abilityFull, long recharge, boolean inform, boolean attachItem, boolean attachDurability)
|
public boolean use(Player player, String ability, String abilityFull, long recharge, boolean inform,
|
||||||
|
boolean attachItem, boolean attachDurability, boolean clearOnDeath)
|
||||||
{
|
{
|
||||||
if (recharge == 0)
|
if (recharge == 0)
|
||||||
return true;
|
return true;
|
||||||
@ -133,7 +151,7 @@ public class Recharge extends MiniPlugin
|
|||||||
}
|
}
|
||||||
|
|
||||||
//Insert
|
//Insert
|
||||||
UseRecharge(player, ability, recharge, attachItem, attachDurability);
|
UseRecharge(player, ability, recharge, attachItem, attachDurability, clearOnDeath);
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
@ -145,7 +163,7 @@ public class Recharge extends MiniPlugin
|
|||||||
|
|
||||||
public void useForce(Player player, String ability, long recharge, boolean attachItem)
|
public void useForce(Player player, String ability, long recharge, boolean attachItem)
|
||||||
{
|
{
|
||||||
UseRecharge(player, ability, recharge, attachItem, false);
|
UseRecharge(player, ability, recharge, attachItem, false, true);
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean usable(Player player, String ability)
|
public boolean usable(Player player, String ability)
|
||||||
@ -172,14 +190,14 @@ public class Recharge extends MiniPlugin
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public void UseRecharge(Player player, String ability, long recharge, boolean attachItem, boolean attachDurability)
|
public void UseRecharge(Player player, String ability, long recharge, boolean attachItem, boolean attachDurability, boolean clearOnDeath)
|
||||||
{
|
{
|
||||||
//Event
|
//Event
|
||||||
RechargeEvent rechargeEvent = new RechargeEvent(player, ability, recharge);
|
RechargeEvent rechargeEvent = new RechargeEvent(player, ability, recharge);
|
||||||
UtilServer.getServer().getPluginManager().callEvent(rechargeEvent);
|
UtilServer.getServer().getPluginManager().callEvent(rechargeEvent);
|
||||||
|
|
||||||
Get(player).put(ability, new RechargeData(this, player, ability, player.getItemInHand(),
|
Get(player).put(ability, new RechargeData(this, player, ability, player.getItemInHand(),
|
||||||
rechargeEvent.GetRecharge(), attachItem, attachDurability));
|
rechargeEvent.GetRecharge(), attachItem, attachDurability, clearOnDeath));
|
||||||
}
|
}
|
||||||
|
|
||||||
public void recharge(Player player, String ability)
|
public void recharge(Player player, String ability)
|
||||||
|
@ -33,8 +33,10 @@ public class RechargeData
|
|||||||
public boolean Countdown = false; //This will make the output a countdown, instead of a recharge.
|
public boolean Countdown = false; //This will make the output a countdown, instead of a recharge.
|
||||||
public boolean AttachItem;
|
public boolean AttachItem;
|
||||||
public boolean AttachDurability;
|
public boolean AttachDurability;
|
||||||
|
public boolean ClearOnDeath; // Determines whether the cooldon is cleared when a player dies
|
||||||
|
|
||||||
public RechargeData(Recharge host, Player player, String name, ItemStack stack, long rechargeTime, boolean attachitem, boolean attachDurability)
|
public RechargeData(Recharge host, Player player, String name, ItemStack stack, long rechargeTime,
|
||||||
|
boolean attachitem, boolean attachDurability, boolean clearOnDeath)
|
||||||
{
|
{
|
||||||
Host = host;
|
Host = host;
|
||||||
|
|
||||||
@ -46,6 +48,12 @@ public class RechargeData
|
|||||||
|
|
||||||
AttachItem = attachitem;
|
AttachItem = attachitem;
|
||||||
AttachDurability = attachDurability;
|
AttachDurability = attachDurability;
|
||||||
|
ClearOnDeath = clearOnDeath;
|
||||||
|
}
|
||||||
|
|
||||||
|
public RechargeData(Recharge host, Player player, String name, ItemStack stack, long rechargeTime, boolean attachitem, boolean attachDurability)
|
||||||
|
{
|
||||||
|
this(host, player, name, stack, rechargeTime, attachitem, attachDurability, true);
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean Update()
|
public boolean Update()
|
||||||
|
@ -18,6 +18,7 @@ import org.bukkit.event.EventPriority;
|
|||||||
import org.bukkit.event.Listener;
|
import org.bukkit.event.Listener;
|
||||||
import org.bukkit.event.inventory.InventoryClickEvent;
|
import org.bukkit.event.inventory.InventoryClickEvent;
|
||||||
import org.bukkit.event.inventory.InventoryCloseEvent;
|
import org.bukkit.event.inventory.InventoryCloseEvent;
|
||||||
|
import org.bukkit.event.inventory.InventoryDragEvent;
|
||||||
import org.bukkit.event.inventory.InventoryOpenEvent;
|
import org.bukkit.event.inventory.InventoryOpenEvent;
|
||||||
import org.bukkit.event.player.PlayerQuitEvent;
|
import org.bukkit.event.player.PlayerQuitEvent;
|
||||||
|
|
||||||
@ -143,6 +144,20 @@ public abstract class ShopBase<PluginType extends MiniPlugin> implements Listene
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@EventHandler
|
||||||
|
public void onInventoryDrag(InventoryDragEvent event)
|
||||||
|
{
|
||||||
|
if (isPlayerInShop(event.getWhoClicked()))
|
||||||
|
{
|
||||||
|
ShopPageBase<?,?> page = getOpeningPageForPlayer(event.getWhoClicked());
|
||||||
|
|
||||||
|
if (page.matchesInventory(event.getInventory()))
|
||||||
|
{
|
||||||
|
event.setCancelled(true); // Prevent players from dragging items into NPC shop inventories
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
@EventHandler
|
@EventHandler
|
||||||
public void onInventoryClose(InventoryCloseEvent event)
|
public void onInventoryClose(InventoryCloseEvent event)
|
||||||
{
|
{
|
||||||
|
@ -149,7 +149,7 @@ public abstract class ShopPageBase<PluginType extends MiniPlugin, ShopType exten
|
|||||||
{
|
{
|
||||||
playDenySound(_player);
|
playDenySound(_player);
|
||||||
event.setCancelled(true);
|
event.setCancelled(true);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean matchesInventory(Inventory newInventory)
|
public boolean matchesInventory(Inventory newInventory)
|
||||||
|
@ -143,7 +143,7 @@ public class ClanInfo
|
|||||||
if (ssAdmin())
|
if (ssAdmin())
|
||||||
return 1000;
|
return 1000;
|
||||||
|
|
||||||
return 2 + getMembers().size();
|
return Math.min(8, 2 + getMembers().size());
|
||||||
}
|
}
|
||||||
|
|
||||||
public int getAllies()
|
public int getAllies()
|
||||||
@ -237,6 +237,9 @@ public class ClanInfo
|
|||||||
|
|
||||||
// Land
|
// Land
|
||||||
stringList.add(F.value("Territory", getClaims() + "/" + getClaimsMax()));
|
stringList.add(F.value("Territory", getClaims() + "/" + getClaimsMax()));
|
||||||
|
|
||||||
|
// Member count
|
||||||
|
stringList.add(F.value("Members", getSize() + "/" + getMaxSize()));
|
||||||
|
|
||||||
// Energy
|
// Energy
|
||||||
int energy = getEnergy();
|
int energy = getEnergy();
|
||||||
@ -564,6 +567,14 @@ public class ClanInfo
|
|||||||
{
|
{
|
||||||
return _memberMap.size();
|
return _memberMap.size();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public int getMaxSize()
|
||||||
|
{
|
||||||
|
if (ssAdmin())
|
||||||
|
return 1000;
|
||||||
|
|
||||||
|
return 20;
|
||||||
|
}
|
||||||
|
|
||||||
public int getEnergyMax()
|
public int getEnergyMax()
|
||||||
{
|
{
|
||||||
|
@ -80,15 +80,14 @@ public class ClansGame extends MiniPlugin
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@EventHandler
|
@EventHandler(ignoreCancelled = true)
|
||||||
public void openClanShop(PlayerInteractEvent event)
|
public void openClanShop(PlayerInteractEvent event)
|
||||||
{
|
{
|
||||||
if (event.isCancelled())
|
boolean hasItem = event.getPlayer().getItemInHand().getType() != Material.AIR;
|
||||||
return;
|
|
||||||
|
if (UtilEvent.isAction(event, ActionType.R_BLOCK) && event.getClickedBlock().getType() == Material.ENCHANTMENT_TABLE)
|
||||||
if (UtilEvent.isAction(event, ActionType.R_BLOCK))
|
|
||||||
{
|
{
|
||||||
if (event.getClickedBlock().getType() == Material.ENCHANTMENT_TABLE && !event.getPlayer().isSneaking())
|
if (!event.getPlayer().isSneaking() || !hasItem)
|
||||||
{
|
{
|
||||||
Clans.getClanShop().attemptShopOpen(event.getPlayer());
|
Clans.getClanShop().attemptShopOpen(event.getPlayer());
|
||||||
event.setCancelled(true);
|
event.setCancelled(true);
|
||||||
|
@ -436,6 +436,12 @@ public class ClansCommand extends CommandBase<ClansManager>
|
|||||||
UtilPlayer.message(caller, F.main("Clans", "You are not invited to " + F.elem("Clan " + clan.getName()) + "."));
|
UtilPlayer.message(caller, F.main("Clans", "You are not invited to " + F.elem("Clan " + clan.getName()) + "."));
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (clan.getSize() >= clan.getMaxSize())
|
||||||
|
{
|
||||||
|
UtilPlayer.message(caller, F.main("Clans", "The clan " + F.elem("Clan " + clan.getName()) + " is full and cannot be joined!"));
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
//Task
|
//Task
|
||||||
Plugin.getClanDataAccess().join(clan, caller, ClanRole.RECRUIT, new Callback<Boolean>()
|
Plugin.getClanDataAccess().join(clan, caller, ClanRole.RECRUIT, new Callback<Boolean>()
|
||||||
@ -1168,7 +1174,7 @@ public class ClansCommand extends CommandBase<ClansManager>
|
|||||||
}
|
}
|
||||||
*/
|
*/
|
||||||
|
|
||||||
if (!Recharge.Instance.use(caller, "Clans Teleport", 300000, true, false))
|
if (!Recharge.Instance.use(caller, "Clans Teleport", "Clans Teleport", 300000, true, false, false, false))
|
||||||
return;
|
return;
|
||||||
|
|
||||||
//Do
|
//Do
|
||||||
|
@ -261,6 +261,6 @@ public class ClansRegions extends MiniPlugin
|
|||||||
|
|
||||||
private boolean isInsideBorders(Location location)
|
private boolean isInsideBorders(Location location)
|
||||||
{
|
{
|
||||||
return location.getBlockX() < BORDER_RADIUS && location.getBlockZ() < BORDER_RADIUS;
|
return Math.abs(location.getBlockX()) < BORDER_RADIUS && Math.abs(location.getBlockZ()) < BORDER_RADIUS;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -14,7 +14,7 @@ import org.bukkit.inventory.Recipe;
|
|||||||
public class CustomRecipes implements Listener
|
public class CustomRecipes implements Listener
|
||||||
{
|
{
|
||||||
|
|
||||||
private static final Material[] DISABLED_RECIPES = { Material.EXPLOSIVE_MINECART, Material.JUKEBOX };
|
private static final Material[] DISABLED_RECIPES = { Material.EXPLOSIVE_MINECART, Material.JUKEBOX, Material.FISHING_ROD };
|
||||||
|
|
||||||
@EventHandler
|
@EventHandler
|
||||||
public void onPlayerCraftItem(CraftItemEvent event)
|
public void onPlayerCraftItem(CraftItemEvent event)
|
||||||
|
@ -369,12 +369,12 @@ public class Gameplay extends MiniPlugin
|
|||||||
@EventHandler
|
@EventHandler
|
||||||
public void AnvilDisable(PlayerInteractEvent event)
|
public void AnvilDisable(PlayerInteractEvent event)
|
||||||
{
|
{
|
||||||
if (!UtilEvent.isAction(event, ActionType.R_BLOCK))
|
Player player = event.getPlayer();
|
||||||
return;
|
|
||||||
|
if (!UtilEvent.isAction(event, ActionType.R_BLOCK)) return;
|
||||||
if (event.getClickedBlock().getType() != Material.ANVIL)
|
else if (event.getClickedBlock().getType() != Material.ANVIL) return;
|
||||||
return;
|
else if (player.isSneaking() && player.getItemInHand().getType() != Material.AIR) return;
|
||||||
|
|
||||||
event.setCancelled(true);
|
event.setCancelled(true);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -533,7 +533,7 @@ public class Gameplay extends MiniPlugin
|
|||||||
|| event.getClickedBlock().getType() != Material.ANVIL
|
|| event.getClickedBlock().getType() != Material.ANVIL
|
||||||
|| !UtilEvent.isAction(event, ActionType.R_BLOCK)
|
|| !UtilEvent.isAction(event, ActionType.R_BLOCK)
|
||||||
|| player.isSneaking()
|
|| player.isSneaking()
|
||||||
|| player.getItemInHand() == null)
|
|| player.getItemInHand().getType() == Material.AIR)
|
||||||
{
|
{
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
@ -332,7 +332,7 @@ public class BlockToss extends SkillCharge implements IThrown
|
|||||||
{
|
{
|
||||||
if (event.getEntity() instanceof FallingBlock)
|
if (event.getEntity() instanceof FallingBlock)
|
||||||
{
|
{
|
||||||
if (event.getBlock().getType() == Material.AIR) // Falling block is landing and turning block from air to type
|
if (!event.getBlock().getType().isSolid()) // Falling block is landing and turning block from air to type
|
||||||
{
|
{
|
||||||
BlockTossLandEvent landEvent = new BlockTossLandEvent(event.getBlock());
|
BlockTossLandEvent landEvent = new BlockTossLandEvent(event.getBlock());
|
||||||
Bukkit.getServer().getPluginManager().callEvent(landEvent);
|
Bukkit.getServer().getPluginManager().callEvent(landEvent);
|
||||||
|
Loading…
Reference in New Issue
Block a user