Merge branch 'update/clans' into develop

This commit is contained in:
cnr 2016-08-03 12:39:52 -04:00
commit 3f0938815d
14 changed files with 217 additions and 113 deletions

View File

@ -218,7 +218,7 @@ public class MessageManager extends MiniClientPlugin<ClientMessage>
if (GetClientManager().Get(to).GetRank() == Rank.DEVELOPER)
{
UtilPlayer.message(from, C.cPurple + to.getName() + " is often AFK or minimized, due to plugin development.");
UtilPlayer.message(from, C.cPurple + "Please be patient if she does not reply instantly.");
UtilPlayer.message(from, C.cPurple + "Please be patient if they do not reply instantly.");
}
// Log

View File

@ -767,13 +767,7 @@ public class ClansAdmin
ClanInfo clientClan = getMimic(caller, true);
if (clientClan == null)
return;
if (clientClan.getClaims() >= clientClan.getClaimsMax())
{
UtilPlayer.message(caller, F.main("Clans Admin", "Your Clan cannot claim more Territory."));
return;
}
String chunk = UtilWorld.chunkToStr(caller.getLocation().getChunk());
ClanInfo ownerClan = Clans.getClanUtility().getOwner(caller.getLocation());
@ -788,8 +782,12 @@ public class ClansAdmin
//Task
Clans.getClanDataAccess().claim(clientClan.getName(), chunk, caller.getName(), false);
//Inform
if (clientClan.getClaims() >= clientClan.getClaimsMax())
{
UtilPlayer.message(caller, F.main("Clans Admin", "You have claimed for that clan past their normal limit."));
}
UtilPlayer.message(caller, F.main("Clans Admin", "You claimed Territory " + F.elem(UtilWorld.chunkToStrClean(caller.getLocation().getChunk())) + "."));
clientClan.inform(caller.getName() + " claimed Territory " + F.elem(UtilWorld.chunkToStrClean(caller.getLocation().getChunk())) + ".", caller.getName());
}

View File

@ -1192,6 +1192,9 @@ public class ClansManager extends MiniClientPlugin<ClientClan>implements IRelati
_worldEvent.onDisable();
_goldManager.onDisable();
_playTracker.onDisable();
_bannerManager.onDisable();
_amplifierManager.onDisable();
_netherManager.onDisable();
}
@EventHandler(priority = EventPriority.HIGHEST)

View File

@ -2,21 +2,6 @@ package mineplex.game.clans.clans.banners;
import java.util.HashMap;
import mineplex.core.MiniPlugin;
import mineplex.core.common.Rank;
import mineplex.core.common.util.F;
import mineplex.core.common.util.UtilBlock;
import mineplex.core.common.util.UtilPlayer;
import mineplex.core.common.util.UtilTime;
import mineplex.core.common.util.UtilTime.TimeUnit;
import mineplex.core.recharge.Recharge;
import mineplex.core.updater.UpdateType;
import mineplex.core.updater.event.UpdateEvent;
import mineplex.game.clans.clans.ClanInfo;
import mineplex.game.clans.clans.ClansManager;
import mineplex.game.clans.clans.banners.command.BannerCommand;
import mineplex.game.clans.core.repository.ClanTerritory;
import org.bukkit.Bukkit;
import org.bukkit.Material;
import org.bukkit.block.Banner;
@ -25,18 +10,36 @@ import org.bukkit.block.BlockFace;
import org.bukkit.entity.Player;
import org.bukkit.event.EventHandler;
import org.bukkit.event.block.BlockBreakEvent;
import org.bukkit.event.block.BlockPhysicsEvent;
import org.bukkit.event.block.BlockPlaceEvent;
import org.bukkit.event.inventory.CraftItemEvent;
import org.bukkit.event.inventory.PrepareItemCraftEvent;
import org.bukkit.event.player.PlayerDropItemEvent;
import org.bukkit.event.player.PlayerJoinEvent;
import org.bukkit.event.player.PlayerPickupItemEvent;
import org.bukkit.inventory.ItemStack;
import org.bukkit.inventory.meta.BannerMeta;
import org.bukkit.plugin.java.JavaPlugin;
import mineplex.core.MiniPlugin;
import mineplex.core.common.Rank;
import mineplex.core.common.util.F;
import mineplex.core.common.util.UtilBlock;
import mineplex.core.common.util.UtilPlayer;
import mineplex.core.recharge.Recharge;
import mineplex.game.clans.clans.ClanInfo;
import mineplex.game.clans.clans.ClansManager;
import mineplex.game.clans.clans.banners.command.BannerCommand;
import mineplex.game.clans.core.repository.ClanTerritory;
import net.minecraft.server.v1_8_R3.MinecraftServer;
/**
* Manager class for cosmetic clans banners
*/
public class BannerManager extends MiniPlugin
{
private static final long BANNER_PLACE_DURATION = UtilTime.convert(30, TimeUnit.MINUTES, TimeUnit.MILLISECONDS);
public final HashMap<String, ClanBanner> LoadedBanners = new HashMap<>();
private final HashMap<Block, Long> _placedBanners = new HashMap<>();
private final BlockFace[] _radial = { BlockFace.SOUTH, BlockFace.SOUTH_WEST, BlockFace.WEST, BlockFace.NORTH_WEST, BlockFace.NORTH, BlockFace.NORTH_EAST, BlockFace.EAST, BlockFace.SOUTH_EAST };
private BannerRepository _repo;
public BannerManager(JavaPlugin plugin)
@ -48,18 +51,6 @@ public class BannerManager extends MiniPlugin
addCommand(new BannerCommand(this));
}
/**
* Resets all placed banners to air
*/
@Override
public void disable()
{
for (Block changed : _placedBanners.keySet())
{
changed.setType(Material.AIR);
}
}
/**
* Checks what type of banner unlock a player has
* @param player The player to check
@ -127,10 +118,6 @@ public class BannerManager extends MiniPlugin
*/
public void placeBanner(Player placing, ClanBanner banner)
{
if (!Recharge.Instance.use(placing, "Place Banner", 30000, true, false))
{
return;
}
Block block = placing.getLocation().getBlock();
BlockPlaceEvent event = new BlockPlaceEvent(block, block.getState(), block, placing.getItemInHand(), placing, true);
Bukkit.getPluginManager().callEvent(event);
@ -145,12 +132,25 @@ public class BannerManager extends MiniPlugin
ClansManager.getInstance().getBlockRestore().restore(block);
if (block.getType() == Material.AIR && UtilBlock.fullSolid(block.getRelative(BlockFace.DOWN)))
{
if (!Recharge.Instance.use(placing, "Place Banner", 30000, true, false))
{
return;
}
block.setType(Material.STANDING_BANNER);
Banner state = (Banner) block.getState();
state.setBaseColor(banner.getBaseColor());
state.setPatterns(((BannerMeta)banner.getBanner().getItemMeta()).getPatterns());
org.bukkit.material.Banner data = (org.bukkit.material.Banner) state.getData();
try
{
data.setFacingDirection(_radial[Math.round(placing.getLocation().getYaw() / 45f) & 0x7]);
}
catch (Exception e)
{
e.printStackTrace();
}
state.setData(data);
state.update();
_placedBanners.put(block, System.currentTimeMillis());
}
else
{
@ -163,26 +163,79 @@ public class BannerManager extends MiniPlugin
@EventHandler
public void onBreak(BlockBreakEvent event)
{
if (_placedBanners.containsKey(event.getBlock()))
if (event.getBlock().getType() == Material.STANDING_BANNER || event.getBlock().getType() == Material.WALL_BANNER)
{
_placedBanners.remove(event.getBlock());
event.setCancelled(true);
event.getBlock().setType(Material.AIR);
}
}
@EventHandler
public void onUpdate(UpdateEvent event)
public void onDropBanner(BlockPhysicsEvent event)
{
if (event.getType() == UpdateType.FAST)
if (event.getBlock().getType() == Material.STANDING_BANNER || event.getBlock().getType() == Material.WALL_BANNER)
{
for (Block reset : _placedBanners.keySet())
event.setCancelled(true);
}
}
@EventHandler
public void onCraftBanner(PrepareItemCraftEvent event)
{
if (event.getInventory().getResult() == null || event.getInventory().getResult().getType() != Material.BANNER)
{
return;
}
event.getInventory().setResult(null);
}
@EventHandler
public void onCraftBanner(CraftItemEvent event)
{
if (event.getInventory().getResult() == null || event.getInventory().getResult().getType() != Material.BANNER)
{
return;
}
event.setCancelled(true);
}
@EventHandler
public void onJoinWithBanner(PlayerJoinEvent event)
{
if (MinecraftServer.getServer().recentTps[0] < 19)
{
return;
}
runSyncLater(() ->
{
for (ItemStack item : event.getPlayer().getInventory().getContents())
{
if (UtilTime.elapsed(_placedBanners.get(reset), BANNER_PLACE_DURATION))
if (item != null && item.getType() == Material.BANNER)
{
reset.setType(Material.AIR);
event.getPlayer().getInventory().remove(item);
}
}
}, 20);
}
@EventHandler
public void onPickupBanner(PlayerPickupItemEvent event)
{
if (event.getItem().getItemStack().getType() == Material.BANNER)
{
event.setCancelled(true);
event.getItem().remove();
}
}
@EventHandler
public void onPickupBanner(PlayerDropItemEvent event)
{
if (event.getItemDrop().getItemStack().getType() == Material.BANNER)
{
event.getItemDrop().remove();
}
}
}

View File

@ -110,17 +110,20 @@ public class InvseeInventory implements Listener
else
{
// This should always work
_targetPlayer = Bukkit.getOfflinePlayer(_uuid);
updateInventory();
if (_uuid.equals(event.getPlayer().getUniqueId()))
{
_targetPlayer = Bukkit.getOfflinePlayer(_uuid);
updateInventory();
}
}
}
@EventHandler(priority = EventPriority.LOWEST, ignoreCancelled = true)
public void on(InventoryOpenEvent event)
{
if (event.getPlayer().getUniqueId().equals(_targetPlayer.getUniqueId()) && !_canOpenInventory)
if (event.getPlayer().getUniqueId().equals(_uuid) && !_canOpenInventory)
{
event.setCancelled(true);
Bukkit.getScheduler().runTaskLater(UtilServer.getPlugin(), () -> {event.getPlayer().closeInventory();}, 20);
}
}
@ -295,7 +298,7 @@ public class InvseeInventory implements Listener
}
}
/*
/**
* Update the player inventory and invsee inventory.
*
* @param targetClick If true, then it means the player being invseen has modified their inventory. Otherwise, it's the admin who has modified something

View File

@ -102,16 +102,6 @@ public class BossNetherPortal implements Listener
{
_portalFacing = (byte)0;
}
_closeWarnings.add(UtilTime.convert(5, TimeUnit.MINUTES, TimeUnit.MILLISECONDS));
_closeWarnings.add(UtilTime.convert(1, TimeUnit.MINUTES, TimeUnit.MILLISECONDS));
_closeWarnings.add(30000L);
_closeWarnings.add(10000L);
_closeWarnings.add(5000L);
_closeWarnings.add(4000L);
_closeWarnings.add(3000L);
_closeWarnings.add(2000L);
_closeWarnings.add(1000L);
}
private boolean isInPortal(Block block)
@ -177,6 +167,15 @@ public class BossNetherPortal implements Listener
block.setType(Material.PORTAL);
block.setData(_portalFacing);
}
_closeWarnings.add(UtilTime.convert(5, TimeUnit.MINUTES, TimeUnit.MILLISECONDS));
_closeWarnings.add(UtilTime.convert(1, TimeUnit.MINUTES, TimeUnit.MILLISECONDS));
_closeWarnings.add(30000L);
_closeWarnings.add(10000L);
_closeWarnings.add(5000L);
_closeWarnings.add(4000L);
_closeWarnings.add(3000L);
_closeWarnings.add(2000L);
_closeWarnings.add(1000L);
}
}
@ -196,6 +195,7 @@ public class BossNetherPortal implements Listener
block.setType(Material.AIR);
}
HandlerList.unregisterAll(this);
_closeWarnings.clear();
}
@EventHandler(priority = EventPriority.HIGHEST)
@ -245,12 +245,14 @@ public class BossNetherPortal implements Listener
ClansManager.getInstance().getNetherManager().OverworldOrigins.remove((Player)event.getEntity());
((Player)event.getEntity()).removePotionEffect(PotionEffectType.NIGHT_VISION);
UtilPlayer.message(event.getEntity(), F.main(ClansManager.getInstance().getNetherManager().getName(), "You have escaped " + F.clansNether("The Nether") + "!"));
ClansManager.getInstance().runSyncLater(() ->
{
ClansManager.getInstance().getCombatManager().Get((Player)event.getEntity()).SetLastCombatEngaged(System.currentTimeMillis());
}, 20);
}
else
{
ClansManager.getInstance().getNetherManager().InNether.put((Player)event.getEntity(), Expire);
Location from = event.getEntity().getLocation();
ClansManager.getInstance().getNetherManager().OverworldOrigins.put((Player)event.getEntity(), from);
event.getEntity().teleport(ClansManager.getInstance().getNetherManager().getNetherWorld().getSpawnLocation());
ClansManager.getInstance().ClanTips.displayTip(TipType.ENTER_NETHER, (Player)event.getEntity());
}

View File

@ -4,6 +4,32 @@ import java.util.Comparator;
import java.util.HashMap;
import java.util.List;
import org.bukkit.Bukkit;
import org.bukkit.GameMode;
import org.bukkit.Location;
import org.bukkit.Material;
import org.bukkit.World;
import org.bukkit.WorldBorder;
import org.bukkit.WorldCreator;
import org.bukkit.block.Block;
import org.bukkit.entity.Player;
import org.bukkit.event.EventHandler;
import org.bukkit.event.EventPriority;
import org.bukkit.event.block.Action;
import org.bukkit.event.block.BlockBreakEvent;
import org.bukkit.event.block.BlockPlaceEvent;
import org.bukkit.event.entity.EntityPortalEvent;
import org.bukkit.event.entity.PlayerDeathEvent;
import org.bukkit.event.player.PlayerDropItemEvent;
import org.bukkit.event.player.PlayerInteractEvent;
import org.bukkit.event.player.PlayerPortalEvent;
import org.bukkit.event.player.PlayerQuitEvent;
import org.bukkit.inventory.ItemStack;
import org.bukkit.potion.PotionEffect;
import org.bukkit.potion.PotionEffectType;
import com.google.common.collect.Lists;
import mineplex.core.MiniPlugin;
import mineplex.core.common.Rank;
import mineplex.core.common.generator.VoidGenerator;
@ -31,32 +57,6 @@ import mineplex.minecraft.game.core.boss.broodmother.SpiderCreature;
import mineplex.minecraft.game.core.boss.ironwizard.GolemCreature;
import mineplex.minecraft.game.core.boss.skeletonking.SkeletonCreature;
import org.bukkit.Bukkit;
import org.bukkit.GameMode;
import org.bukkit.Location;
import org.bukkit.Material;
import org.bukkit.World;
import org.bukkit.WorldBorder;
import org.bukkit.WorldCreator;
import org.bukkit.block.Block;
import org.bukkit.entity.Player;
import org.bukkit.event.EventHandler;
import org.bukkit.event.EventPriority;
import org.bukkit.event.block.Action;
import org.bukkit.event.block.BlockBreakEvent;
import org.bukkit.event.block.BlockPlaceEvent;
import org.bukkit.event.entity.EntityPortalEvent;
import org.bukkit.event.entity.PlayerDeathEvent;
import org.bukkit.event.player.PlayerDropItemEvent;
import org.bukkit.event.player.PlayerInteractEvent;
import org.bukkit.event.player.PlayerPortalEvent;
import org.bukkit.event.player.PlayerQuitEvent;
import org.bukkit.inventory.ItemStack;
import org.bukkit.potion.PotionEffect;
import org.bukkit.potion.PotionEffectType;
import com.google.common.collect.Lists;
/**
* Manager for all nether features
*/
@ -155,7 +155,12 @@ public class NetherManager extends MiniPlugin
*/
public Location getReturnLocation(Player player)
{
return OverworldOrigins.getOrDefault(player, Spawn.getNorthSpawn());
Location defaultLoc = Spawn.getWestTown();
if (UtilMath.random.nextDouble() <= .5)
{
defaultLoc = Spawn.getEastTown();
}
return OverworldOrigins.getOrDefault(player, defaultLoc);
}
/**

View File

@ -104,16 +104,6 @@ public class NetherPortal implements Listener
{
_portalFacing = (byte)0;
}
_closeWarnings.add(UtilTime.convert(5, TimeUnit.MINUTES, TimeUnit.MILLISECONDS));
_closeWarnings.add(UtilTime.convert(1, TimeUnit.MINUTES, TimeUnit.MILLISECONDS));
_closeWarnings.add(30000L);
_closeWarnings.add(10000L);
_closeWarnings.add(5000L);
_closeWarnings.add(4000L);
_closeWarnings.add(3000L);
_closeWarnings.add(2000L);
_closeWarnings.add(1000L);
}
private boolean isInPortal(Block block)
@ -188,6 +178,15 @@ public class NetherPortal implements Listener
block.setType(Material.PORTAL);
block.setData(_portalFacing);
}
_closeWarnings.add(UtilTime.convert(5, TimeUnit.MINUTES, TimeUnit.MILLISECONDS));
_closeWarnings.add(UtilTime.convert(1, TimeUnit.MINUTES, TimeUnit.MILLISECONDS));
_closeWarnings.add(30000L);
_closeWarnings.add(10000L);
_closeWarnings.add(5000L);
_closeWarnings.add(4000L);
_closeWarnings.add(3000L);
_closeWarnings.add(2000L);
_closeWarnings.add(1000L);
}
}
@ -207,6 +206,7 @@ public class NetherPortal implements Listener
block.setType(Material.AIR);
}
HandlerList.unregisterAll(this);
_closeWarnings.clear();
}
@EventHandler(priority = EventPriority.HIGHEST)
@ -256,12 +256,14 @@ public class NetherPortal implements Listener
ClansManager.getInstance().getNetherManager().OverworldOrigins.remove((Player)event.getEntity());
((Player)event.getEntity()).removePotionEffect(PotionEffectType.NIGHT_VISION);
UtilPlayer.message(event.getEntity(), F.main(ClansManager.getInstance().getNetherManager().getName(), "You have escaped " + F.clansNether("The Nether") + "!"));
ClansManager.getInstance().runSyncLater(() ->
{
ClansManager.getInstance().getCombatManager().Get((Player)event.getEntity()).SetLastCombatEngaged(System.currentTimeMillis());
}, 20);
}
else
{
ClansManager.getInstance().getNetherManager().InNether.put((Player)event.getEntity(), Expire);
Location from = event.getEntity().getLocation();
ClansManager.getInstance().getNetherManager().OverworldOrigins.put((Player)event.getEntity(), from);
event.getEntity().teleport(ClansManager.getInstance().getNetherManager().getNetherWorld().getSpawnLocation());
ClansManager.getInstance().ClanTips.displayTip(TipType.ENTER_NETHER, (Player)event.getEntity());
}
@ -292,7 +294,7 @@ public class NetherPortal implements Listener
Long warning = -1L;
for (Long test : _closeWarnings)
{
if ((Expire - System.currentTimeMillis()) < warning)
if ((Expire - System.currentTimeMillis()) < test)
{
warning = test;
break;

View File

@ -43,6 +43,10 @@ public class ForceTeleportCommand extends CommandBase<NetherManager>
Plugin.OverworldOrigins.remove(caller);
caller.removePotionEffect(PotionEffectType.NIGHT_VISION);
UtilPlayer.message(caller, F.main(ClansManager.getInstance().getNetherManager().getName(), "You have escaped " + F.clansNether("The Nether") + "!"));
ClansManager.getInstance().runSyncLater(() ->
{
ClansManager.getInstance().getCombatManager().Get(caller).SetLastCombatEngaged(System.currentTimeMillis());
}, 20);
}
else
{
@ -54,7 +58,6 @@ public class ForceTeleportCommand extends CommandBase<NetherManager>
if (natural)
{
Plugin.InNether.put(caller, System.currentTimeMillis() + UtilTime.convert(10, TimeUnit.MINUTES, TimeUnit.MILLISECONDS));
Plugin.OverworldOrigins.put(caller, caller.getLocation());
caller.teleport(Plugin.getNetherWorld().getSpawnLocation());
ClansManager.getInstance().ClanTips.displayTip(TipType.ENTER_NETHER, caller);
}

View File

@ -398,20 +398,41 @@ public class GoldManager extends MiniDbClientPlugin<GoldData>
@Override
public String getQuery(int accountId, String uuid, String name) {
public String getQuery(int accountId, String uuid, String name)
{
return "SELECT gold FROM clansGold WHERE id = '" + accountId + "' AND serverId=" + _serverId + ";";
}
@Override
public void processLoginResultSet(String playerName, int accountId, ResultSet resultSet) throws SQLException {
public void processLoginResultSet(String playerName, int accountId, ResultSet resultSet) throws SQLException
{
if (resultSet.next())
{
Get(playerName).setBalance(resultSet.getInt(1));
if (resultSet.getInt(1) < 0)
{
setGold(new Callback<Boolean>()
{
public void run(Boolean success)
{
if (success)
{
System.out.println("Fixed negative gold balance for " + playerName + "!");
}
else
{
System.out.println("Failed to fix negative gold balance for " + playerName + "!");
}
}
}, "", playerName, accountId, 0, true);
}
}
}
@Override
protected GoldData addPlayer(String player) {
protected GoldData addPlayer(String player)
{
return new GoldData();
}
}

View File

@ -15,6 +15,7 @@ import mineplex.core.common.util.InventoryUtil;
import mineplex.core.common.util.UtilItem;
import mineplex.core.common.util.UtilPlayer;
import mineplex.core.common.util.UtilServer;
import mineplex.core.recharge.Recharge;
import mineplex.core.shop.item.IButton;
import mineplex.core.shop.page.ShopPageBase;
import mineplex.game.clans.clans.event.ClansPlayerBuyItemEvent;
@ -57,6 +58,10 @@ public class ShopItemButton<T extends ShopPageBase<?, ?>> implements IButton
@Override
public void onClick(final Player player, ClickType clickType)
{
if (!Recharge.Instance.use(player, "Attempt Buy Clans Shop Item", 1500, false, false))
{
return;
}
boolean shiftClick = (clickType == ClickType.SHIFT_LEFT || clickType == ClickType.SHIFT_RIGHT);
if (clickType == ClickType.SHIFT_RIGHT || clickType == ClickType.RIGHT)

View File

@ -170,6 +170,12 @@ public class Blink extends SkillActive
public void Deblink(Player player, int level)
{
Location target = _loc.remove(player);
if (!player.getWorld().equals(target.getWorld()))
{
UtilPlayer.message(player, F.main(GetClassType().name(), "You cannot use " + F.skill("De-Blink") + " between worlds!"));
return;
}
UtilPlayer.message(player, F.main(GetClassType().name(), "You used " + F.skill("De-Blink") + "."));
//Smoke Trail
@ -177,8 +183,6 @@ public class Blink extends SkillActive
double curRange = 0;
Location target = _loc.remove(player);
boolean done = false;
while (!done)
{

View File

@ -12,6 +12,7 @@ import mineplex.core.common.util.UtilServer;
import mineplex.minecraft.game.classcombat.Skill.Mage.events.FissureModifyBlockEvent;
import org.bukkit.Effect;
import org.bukkit.Location;
import org.bukkit.Material;
import org.bukkit.block.Block;
import org.bukkit.block.BlockFace;
import org.bukkit.entity.Player;
@ -133,6 +134,10 @@ public class FissureData
return false;
if (block.getRelative(BlockFace.UP).getType().toString().contains("BANNER"))
return false;
if (block.getType() == Material.ANVIL)
return false;
if (block.getRelative(BlockFace.UP).getType() == Material.ANVIL)
return false;
Block up = block.getRelative(0, _height + 1, 0);

View File

@ -284,7 +284,7 @@ public class CustomerSupport extends MiniPlugin implements ResultSetCallable
caller.sendMessage(C.cBlue + "Uncle Sam Hat: " + getLockedFreedomStr(playerName, "Uncle Sam Hat"));
caller.sendMessage(C.cDGreen + C.Strike + "=============================================");
caller.sendMessage(C.cBlue + "Clan Banner Usage: " + getLockedFreedomStr(playerName, "Clan Banner Usage"));
caller.sendMessage(C.cBlue + "Uncle Sam Morph: " + getLockedFreedomStr(playerName, "Clan Banner Editor"));
caller.sendMessage(C.cBlue + "Clan Banner Editor: " + getLockedFreedomStr(playerName, "Clan Banner Editor"));
caller.sendMessage(C.cDGreen + C.Strike + "=============================================");
_accountBonusLog.remove(client.getAccountId());