Merge branch 'clans-beta' of ssh://184.154.0.242:7999/min/mineplex into clans-beta
This commit is contained in:
commit
e94eb056dc
@ -1,8 +1,10 @@
|
||||
package mineplex.core.recharge;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashSet;
|
||||
import java.util.Iterator;
|
||||
import java.util.LinkedList;
|
||||
import java.util.List;
|
||||
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.event.EventHandler;
|
||||
@ -40,7 +42,22 @@ public class Recharge extends MiniPlugin
|
||||
@EventHandler
|
||||
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)
|
||||
@ -100,15 +117,16 @@ public class Recharge extends MiniPlugin
|
||||
|
||||
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)
|
||||
{
|
||||
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)
|
||||
return true;
|
||||
@ -133,7 +151,7 @@ public class Recharge extends MiniPlugin
|
||||
}
|
||||
|
||||
//Insert
|
||||
UseRecharge(player, ability, recharge, attachItem, attachDurability);
|
||||
UseRecharge(player, ability, recharge, attachItem, attachDurability, clearOnDeath);
|
||||
|
||||
return true;
|
||||
}
|
||||
@ -145,7 +163,7 @@ public class Recharge extends MiniPlugin
|
||||
|
||||
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)
|
||||
@ -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
|
||||
RechargeEvent rechargeEvent = new RechargeEvent(player, ability, recharge);
|
||||
UtilServer.getServer().getPluginManager().callEvent(rechargeEvent);
|
||||
|
||||
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)
|
||||
|
@ -33,8 +33,10 @@ public class RechargeData
|
||||
public boolean Countdown = false; //This will make the output a countdown, instead of a recharge.
|
||||
public boolean AttachItem;
|
||||
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;
|
||||
|
||||
@ -46,6 +48,12 @@ public class RechargeData
|
||||
|
||||
AttachItem = attachitem;
|
||||
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()
|
||||
|
@ -18,6 +18,7 @@ import org.bukkit.event.EventPriority;
|
||||
import org.bukkit.event.Listener;
|
||||
import org.bukkit.event.inventory.InventoryClickEvent;
|
||||
import org.bukkit.event.inventory.InventoryCloseEvent;
|
||||
import org.bukkit.event.inventory.InventoryDragEvent;
|
||||
import org.bukkit.event.inventory.InventoryOpenEvent;
|
||||
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
|
||||
public void onInventoryClose(InventoryCloseEvent event)
|
||||
{
|
||||
|
@ -149,7 +149,7 @@ public abstract class ShopPageBase<PluginType extends MiniPlugin, ShopType exten
|
||||
{
|
||||
playDenySound(_player);
|
||||
event.setCancelled(true);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public boolean matchesInventory(Inventory newInventory)
|
||||
|
@ -143,7 +143,7 @@ public class ClanInfo
|
||||
if (ssAdmin())
|
||||
return 1000;
|
||||
|
||||
return 2 + getMembers().size();
|
||||
return Math.min(8, 2 + getMembers().size());
|
||||
}
|
||||
|
||||
public int getAllies()
|
||||
@ -237,6 +237,9 @@ public class ClanInfo
|
||||
|
||||
// Land
|
||||
stringList.add(F.value("Territory", getClaims() + "/" + getClaimsMax()));
|
||||
|
||||
// Member count
|
||||
stringList.add(F.value("Members", getSize() + "/" + getMaxSize()));
|
||||
|
||||
// Energy
|
||||
int energy = getEnergy();
|
||||
@ -564,6 +567,14 @@ public class ClanInfo
|
||||
{
|
||||
return _memberMap.size();
|
||||
}
|
||||
|
||||
public int getMaxSize()
|
||||
{
|
||||
if (ssAdmin())
|
||||
return 1000;
|
||||
|
||||
return 20;
|
||||
}
|
||||
|
||||
public int getEnergyMax()
|
||||
{
|
||||
|
@ -80,15 +80,14 @@ public class ClansGame extends MiniPlugin
|
||||
}
|
||||
}
|
||||
|
||||
@EventHandler
|
||||
@EventHandler(ignoreCancelled = true)
|
||||
public void openClanShop(PlayerInteractEvent event)
|
||||
{
|
||||
if (event.isCancelled())
|
||||
return;
|
||||
|
||||
if (UtilEvent.isAction(event, ActionType.R_BLOCK))
|
||||
boolean hasItem = event.getPlayer().getItemInHand().getType() != Material.AIR;
|
||||
|
||||
if (UtilEvent.isAction(event, ActionType.R_BLOCK) && event.getClickedBlock().getType() == Material.ENCHANTMENT_TABLE)
|
||||
{
|
||||
if (event.getClickedBlock().getType() == Material.ENCHANTMENT_TABLE && !event.getPlayer().isSneaking())
|
||||
if (!event.getPlayer().isSneaking() || !hasItem)
|
||||
{
|
||||
Clans.getClanShop().attemptShopOpen(event.getPlayer());
|
||||
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()) + "."));
|
||||
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
|
||||
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;
|
||||
|
||||
//Do
|
||||
|
@ -261,6 +261,6 @@ public class ClansRegions extends MiniPlugin
|
||||
|
||||
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
|
||||
{
|
||||
|
||||
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
|
||||
public void onPlayerCraftItem(CraftItemEvent event)
|
||||
|
@ -369,12 +369,12 @@ public class Gameplay extends MiniPlugin
|
||||
@EventHandler
|
||||
public void AnvilDisable(PlayerInteractEvent event)
|
||||
{
|
||||
if (!UtilEvent.isAction(event, ActionType.R_BLOCK))
|
||||
return;
|
||||
|
||||
if (event.getClickedBlock().getType() != Material.ANVIL)
|
||||
return;
|
||||
|
||||
Player player = event.getPlayer();
|
||||
|
||||
if (!UtilEvent.isAction(event, ActionType.R_BLOCK)) return;
|
||||
else if (event.getClickedBlock().getType() != Material.ANVIL) return;
|
||||
else if (player.isSneaking() && player.getItemInHand().getType() != Material.AIR) return;
|
||||
|
||||
event.setCancelled(true);
|
||||
}
|
||||
|
||||
@ -533,7 +533,7 @@ public class Gameplay extends MiniPlugin
|
||||
|| event.getClickedBlock().getType() != Material.ANVIL
|
||||
|| !UtilEvent.isAction(event, ActionType.R_BLOCK)
|
||||
|| player.isSneaking()
|
||||
|| player.getItemInHand() == null)
|
||||
|| player.getItemInHand().getType() == Material.AIR)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
@ -332,7 +332,7 @@ public class BlockToss extends SkillCharge implements IThrown
|
||||
{
|
||||
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());
|
||||
Bukkit.getServer().getPluginManager().callEvent(landEvent);
|
||||
|
Loading…
Reference in New Issue
Block a user