Merge pull request #168 in MIN/mineplex from clans/alpha to develop

* commit '67c355bf652e9c802dc1e8e56b088c44cdaaac3b': (21 commits)
  remove more eclipse files
  remove eclipse files
  moar undead fixes
  Fixes to observer settings
  Clans Alpha 1.0 changes
  WP Evade
  More alphs bug fixes
  Fixes to flame and broadsword
  Clans alpha bug fixes
  Fixed /c stuck timer taking 7 seconds instead of 2 minutes
  Fixes to TntProtection
  Added safe zone protection for flame
  finalized alpha patches
  alpha fixes
  raised war points for invasion to 25
  Fixes to war point evasion
  Added fix to WarPoint evasion bug + 1 dmg bug
  that's not needed
  MAVEN TEST COMMIT
  Fixed issues with Broadsword Added max building height of 100
  ...
This commit is contained in:
Shaun Bennett 2016-02-19 01:30:09 -06:00
commit d3d22bbec9
22 changed files with 432 additions and 90 deletions

View File

@ -464,6 +464,11 @@ public class UtilBlock
return getHighest(world, x, z, null);
}
public static Block getHighest(World world, Location location)
{
return getHighest(world, location.getBlockX(), location.getBlockZ(), null);
}
public static Block getHighest(World world, int x, int z, HashSet<Material> ignore)
{
Block block = world.getHighestBlockAt(x, z);

View File

@ -1,15 +1,19 @@
package mineplex.core.common.util;
import java.util.Collection;
import java.util.List;
import java.util.function.Predicate;
import org.bukkit.Chunk;
import org.bukkit.Location;
import org.bukkit.World;
import org.bukkit.World.Environment;
import org.bukkit.block.Block;
import org.bukkit.block.BlockFace;
import org.bukkit.util.Vector;
import com.google.common.collect.Lists;
public class UtilWorld
{
public static World getWorld(String world)
@ -194,4 +198,15 @@ public class UtilWorld
return vec.toLocation(world);
}
private static List<Block> branch(Location origin)
{
return Lists.newArrayList(origin.getBlock(),
origin.getBlock().getRelative(BlockFace.DOWN),
origin.getBlock().getRelative(BlockFace.UP),
origin.getBlock().getRelative(BlockFace.NORTH),
origin.getBlock().getRelative(BlockFace.EAST),
origin.getBlock().getRelative(BlockFace.SOUTH),
origin.getBlock().getRelative(BlockFace.WEST));
}
}

View File

@ -53,7 +53,7 @@ import net.minecraft.server.v1_8_R3.MinecraftServer;
public class Clans extends JavaPlugin
{
public static final String VERSION = "0.19";
public static final String VERSION = "1.0";
private String WEB_CONFIG = "webServer";
// Modules

View File

@ -67,6 +67,7 @@ public class ClanInfo
private HashMap<String, ClanWarData> _warOut = new HashMap<String, ClanWarData>();
// Temporary
private NautHashMap<String, Long> _recentlyLeft = new NautHashMap<>();
private NautHashMap<String, Long> _inviteeMap = new NautHashMap<String, Long>();
private NautHashMap<String, String> _inviterMap = new NautHashMap<String, String>();
private List<UUID> _onlinePlayers = new ArrayList<UUID>();
@ -77,6 +78,7 @@ public class ClanInfo
private BedStatus _bedStatus = null;
public ClanInfo(ClansManager clans, ClanToken token)
{
Clans = clans;
@ -478,7 +480,7 @@ public class ClanInfo
public boolean isOnline()
{
return isOnlineNow();// || System.currentTimeMillis() - _lastOnline.getTime() < Clans.getOnlineTime();
return isOnlineNow();
}
public String getProtected()
@ -487,7 +489,7 @@ public class ClanInfo
if (cur.isOnline())
return C.cRed + "No - Clan Members are Online";
if (System.currentTimeMillis() - _lastOnline.getTime() > Clans.getOnlineTime())
if (UtilTime.elapsed(_lastOnline.getTime(), Clans.getOnlineTime()))
return C.cGreen + "Yes - Clan Members are Offline";
return C.cGold
@ -496,6 +498,10 @@ public class ClanInfo
TimeUnit.FIT) + " to Protection";
}
public boolean isProtected() {
return getProtected().startsWith(C.cGreen + "Yes");
}
public TntGenerator getGenerator()
{
return _generator;
@ -800,4 +806,9 @@ public class ClanInfo
{
return _bedStatus == BedStatus.DESTROYED ? C.cRed + "Destroyed" : (_bedStatus == BedStatus.DOESNT_EXIST ? C.cWhite + "None" : (_bedStatus == BedStatus.EXISTS_AND_OBSTRUCTED ? C.cRed + "Obstructed" : (_bedStatus == BedStatus.EXISTS_AND_UNOBSTRUCTED ? C.cGreen + UtilWorld.locToStrClean(_home) : "N/A")));
}
public void left(String name)
{
_recentlyLeft.put(name, System.currentTimeMillis());
}
}

View File

@ -85,6 +85,9 @@ public class ClansAdmin
else if (args[1].equalsIgnoreCase("wp"))
wp(caller, args);
else if (args[1].equalsIgnoreCase("timer"))
resetTime(caller, args);
else
help(caller);
}
@ -111,9 +114,27 @@ public class ClansAdmin
UtilPlayer.message(caller, F.help("/c x unclaim (all)", "Unclaim Territory for Mimic", Rank.CMOD));
UtilPlayer.message(caller, F.help("/c x delete", "Delete Mimic Clan", Rank.CMOD));
UtilPlayer.message(caller, F.help("/c x autoclaim", "AutoClaim for Mimic Clan", Rank.CMOD));
UtilPlayer.message(caller, F.help("/c x timer <player>", "Reset Clan Create Timer", Rank.CMOD));
UtilPlayer.message(caller, F.main("Mimic Clan", Clans.Get(caller).getMimic()));
}
private void resetTime(Player caller, String[] args)
{
if (args.length < 3)
{
UtilPlayer.message(caller, F.main("Clans Admin", "You did not enter a player name"));
return;
}
Player player = UtilPlayer.searchOnline(caller, args[2], true);
if (player != null)
{
Clans.resetLeftTimer(player.getUniqueId());
UtilPlayer.message(caller, F.main("Clans Admin", "Reset Clan create timer for " + F.name(player.getName())));
}
}
private void autoclaim(Player caller)
{
Clans.Get(caller).setAutoClaim(!Clans.Get(caller).isAutoClaim());

View File

@ -297,6 +297,8 @@ public class ClansDataAccessLayer
clan.getMembers().remove(clansPlayer.getUuid());
_manager.getClanMemberUuidMap().remove(clansPlayer.getUuid());
clan.playerOffline(clansPlayer.getPlayerName());
_manager.justLeft(clansPlayer.getUuid(), clan);
// Log
_manager.log("Removed [" + clansPlayer.getPlayerName() + "] from [" + clan.getName() + "].");
}
@ -603,7 +605,7 @@ public class ClansDataAccessLayer
{
UtilBlock.deleteBed(clan.getHome());
clan.setHome(null);
clan.inform("Clan has lost it's Home because of a Territory loss.", null);
clan.inform("Clan has lost its Home because of a Territory loss.", null);
}
return true;
@ -750,6 +752,8 @@ public class ClansDataAccessLayer
if (callback != null)
{
callback.run(ran);
} else {
if(!ran) System.out.println("Tnt Gen didn't save!");
}
}
});

View File

@ -521,7 +521,8 @@ public class ClansGame extends MiniPlugin
ClanInfo clan = _clans.getClanUtility().getClanByPlayer(event.getPlayer());
if (clan == null) return;
clan.setLastOnline(new Timestamp(System.currentTimeMillis()));
if(!clan.isOnline()) clan.setLastOnline(new Timestamp(System.currentTimeMillis())); //Noone else on
else clan.setLastOnline(new Timestamp(0));
}
@EventHandler(priority = EventPriority.LOWEST)
@ -545,7 +546,7 @@ public class ClansGame extends MiniPlugin
return;
}
if (!clan.isOnline())
if (!clan.isProtected())
event.setCancelled(true);
else
clan.inform(C.cRed + "Your Territory is under attack!", null);

View File

@ -39,7 +39,7 @@ import mineplex.core.account.CoreClientManager;
import mineplex.core.achievement.AchievementManager;
import mineplex.core.blockrestore.BlockRestore;
import mineplex.core.chat.Chat;
import mineplex.core.chat.MessageData;
import mineplex.core.common.Pair;
import mineplex.core.common.Rank;
import mineplex.core.common.util.C;
import mineplex.core.common.util.F;
@ -75,10 +75,8 @@ import mineplex.game.clans.clans.commands.ClanManagementCommand;
import mineplex.game.clans.clans.commands.ClansAllyChatCommand;
import mineplex.game.clans.clans.commands.ClansChatCommand;
import mineplex.game.clans.clans.commands.ClansCommand;
import mineplex.game.clans.clans.commands.ClansLoginManager;
import mineplex.game.clans.clans.commands.KillCommand;
import mineplex.game.clans.clans.commands.MapCommand;
import mineplex.game.clans.clans.commands.Meow;
import mineplex.game.clans.clans.commands.RegionsCommand;
import mineplex.game.clans.clans.data.PlayerClan;
import mineplex.game.clans.clans.event.ClansPlayerDeathEvent;
@ -86,7 +84,6 @@ import mineplex.game.clans.clans.gui.ClanShop;
import mineplex.game.clans.clans.loot.LootManager;
import mineplex.game.clans.clans.map.ItemMapManager;
import mineplex.game.clans.clans.observer.ObserverManager;
import mineplex.game.clans.clans.outpost.OutpostManager;
import mineplex.game.clans.clans.playtime.Playtime;
import mineplex.game.clans.clans.potato.PotatoManager;
import mineplex.game.clans.clans.pvptimer.PvpTimer;
@ -98,6 +95,7 @@ import mineplex.game.clans.clans.stuck.StuckManager;
import mineplex.game.clans.clans.supplyDrop.SupplyDropManager;
import mineplex.game.clans.clans.tntGenerator.TntGeneratorManager;
import mineplex.game.clans.clans.war.WarManager;
import mineplex.game.clans.clans.warpoints.WarPointEvasion;
import mineplex.game.clans.clans.worldevent.WorldEventManager;
import mineplex.game.clans.core.ClanDeleteCommand;
import mineplex.game.clans.core.ClanLoadCommand;
@ -183,7 +181,8 @@ public class ClansManager extends MiniClientPlugin<ClientClan>implements IRelati
private NpcManager _npcManager;
private Explosion _explosion;
private GoldManager _goldManager;
private WarPointEvasion _warPointEvasion;
private ObserverManager _observerManager;
private Punish _punish;
private int _inviteExpire = 2;
@ -200,6 +199,7 @@ public class ClansManager extends MiniClientPlugin<ClientClan>implements IRelati
// private NautHashMap<String, ClanInfo> _clanMemberNameMap = new
// NautHashMap<String, ClanInfo>();
private NautHashMap<UUID, ClanInfo> _clanMemberUuidMap = new NautHashMap<UUID, ClanInfo>();
private NautHashMap<UUID, Pair<ClanInfo, Long>> _clanMemberLeftMap = new NautHashMap<>();
private NautHashMap<String, ClanTerritory> _claimMap = new NautHashMap<String, ClanTerritory>();
private NautHashMap<String, Long> _unclaimMap = new NautHashMap<String, Long>();
@ -213,11 +213,6 @@ public class ClansManager extends MiniClientPlugin<ClientClan>implements IRelati
{
super("Clans Manager", plugin);
if (serverName.equals("GarboClans-1"))
{
addCommand(new Meow(new OutpostManager(this)));
}
_instance = this;
_punish = punish;
@ -259,8 +254,8 @@ public class ClansManager extends MiniClientPlugin<ClientClan>implements IRelati
_itemMapManager = new ItemMapManager(this, _worldEvent);
new TntGeneratorManager(plugin, this);
new SupplyDropManager(plugin, this);
_explosion = new Explosion(plugin, blockRestore);
_warPointEvasion = new WarPointEvasion(plugin);
// new ClansLoginManager(getPlugin(), clientManager, _serverName);
@ -276,7 +271,7 @@ public class ClansManager extends MiniClientPlugin<ClientClan>implements IRelati
new Spawn(plugin, this);
new NPCManager(this, _hologramManager);
new SafeLog(plugin, this);
new ObserverManager(plugin, _condition, this);
_observerManager = new ObserverManager(plugin, _condition, this);
new ClanEnergyTracker(plugin, this);
new StuckManager(this);
@ -608,6 +603,13 @@ public class ClansManager extends MiniClientPlugin<ClientClan>implements IRelati
{
player.setOp(true);
}
if(player.getInventory().getHelmet() != null) { //Reset helmet to fix 1 damage bug
ItemStack helmet = player.getInventory().getHelmet().clone();
player.getInventory().setHelmet(null);
runSyncLater(() -> {
player.getInventory().setHelmet(helmet);
}, 20L);
}
}
@EventHandler
@ -743,23 +745,9 @@ public class ClansManager extends MiniClientPlugin<ClientClan>implements IRelati
}
}
@EventHandler(priority = EventPriority.HIGHEST)
@EventHandler(priority = EventPriority.HIGHEST, ignoreCancelled = true)
public void handlePlayerChat(AsyncPlayerChatEvent event)
{
event.setCancelled(false);
_chat.HandleChat(event);
if (event.isCancelled())
{
return;
}
else
{
event.setCancelled(true);
}
// PunishClient punishclient = _punish.GetClient(event.getPlayer().getName());
//
// if (punishclient != null && punishclient.IsMuted())
@ -809,6 +797,8 @@ public class ClansManager extends MiniClientPlugin<ClientClan>implements IRelati
handleRegularChat(event, clan, rank);
}
event.setCancelled(true);
System.out.println((clan == null ? "" : clan.getName()) + " " + _clientManager.Get(event.getPlayer()).GetRank().name() + " " + event.getPlayer().getName() + " " + event.getMessage());
}
@ -1160,4 +1150,32 @@ public class ClansManager extends MiniClientPlugin<ClientClan>implements IRelati
ClansPlayerDeathEvent clansPlayerDeathEvent = new ClansPlayerDeathEvent(event, playerClan, killerClan);
Bukkit.getServer().getPluginManager().callEvent(clansPlayerDeathEvent);
}
public void justLeft(UUID uniqueId, ClanInfo clan)
{
_clanMemberLeftMap.put(uniqueId, Pair.create(clan, System.currentTimeMillis()));
}
public void resetLeftTimer(UUID uuid)
{
_clanMemberLeftMap.remove(uuid);
_warPointEvasion.resetCooldown(uuid);
}
public Pair<ClanInfo, Long> leftRecently(UUID uniqueId, long time)
{
if (_clanMemberLeftMap.containsKey(uniqueId) && (System.currentTimeMillis() - _clanMemberLeftMap.get(uniqueId).getRight()) <= time)
{
return Pair.create(_clanMemberLeftMap.get(uniqueId).getLeft(), time - (System.currentTimeMillis() - _clanMemberLeftMap.get(uniqueId).getRight()));
}
return null;
}
public ObserverManager getObserverManager()
{
return _observerManager;
}
}

View File

@ -632,6 +632,8 @@ public class ClansUtility
// Inform
Clans.getTutorials().sendTutorialMsg(caller, F.main("Clans", "You left " + F.elem("Clan " + clan.getName()) + "."));
clan.inform(F.name(caller.getName()) + " has left your Clan.", null);
clan.left(caller.getName());
}
});
}
@ -677,8 +679,8 @@ public class ClansUtility
if (!data)
{
Clans.getTutorials().sendTutorialMsg(caller, F.main("Clans", "There was an error processing your request. Try again later"));
}else
}
else
{
Clans.getTutorials().sendTutorialMsg(caller, F.main("Clans", "You disbanded your Clan."));
}

View File

@ -1,10 +1,17 @@
package mineplex.game.clans.clans.commands;
import java.util.Collections;
import java.util.List;
import org.bukkit.Bukkit;
import org.bukkit.Chunk;
import org.bukkit.Location;
import org.bukkit.Material;
import org.bukkit.block.BlockFace;
import org.bukkit.entity.Player;
import org.bukkit.plugin.Plugin;
import com.google.common.collect.Lists;
import mineplex.core.command.CommandBase;
import mineplex.core.common.Rank;
@ -13,6 +20,7 @@ import mineplex.core.common.util.Callback;
import mineplex.core.common.util.F;
import mineplex.core.common.util.UtilBlock;
import mineplex.core.common.util.UtilInput;
import mineplex.core.common.util.UtilMath;
import mineplex.core.common.util.UtilPlayer;
import mineplex.core.common.util.UtilServer;
import mineplex.core.common.util.UtilTextMiddle;
@ -30,6 +38,7 @@ import mineplex.game.clans.clans.ClansManager;
import mineplex.game.clans.clans.ClientClan;
import mineplex.game.clans.clans.event.ClanJoinEvent;
import mineplex.game.clans.clans.event.ClansCommandExecutedEvent;
import mineplex.game.clans.core.repository.ClanTerritory;
import net.minecraft.server.v1_8_R3.EnumDirection;
public class ClansCommand extends CommandBase<ClansManager>
@ -105,6 +114,8 @@ public class ClansCommand extends CommandBase<ClansManager>
else if (args[0].equalsIgnoreCase("sethome"))
homeSet(caller);
else if (args[0].equalsIgnoreCase("stuck"))
stuck(caller);
/*
* else if (args[0].equalsIgnoreCase("enemy") || args[0].equals("e"))
@ -211,6 +222,8 @@ public class ClansCommand extends CommandBase<ClansManager>
_manager.getTutorials().sendTutorialMsg(caller, F.help("/c map <toggle>", "View Clan Map", Rank.ALL));
_manager.getTutorials().sendTutorialMsg(caller, F.help("/cc (Message)", "Clan Chat (Toggle)", Rank.ALL));
_manager.getTutorials().sendTutorialMsg(caller, F.help("/c stuck", "Teleports you to the nearest Wilderness location", Rank.ALL));
_manager.getTutorials().sendTutorialMsg(caller, F.help("/c promote <player>", "Promote Player in Clan", Rank.MODERATOR));
_manager.getTutorials().sendTutorialMsg(caller, F.help("/c demote <player>", "Demote Player in Clan", Rank.MODERATOR));
@ -242,6 +255,12 @@ public class ClansCommand extends CommandBase<ClansManager>
return;
}
if (Plugin.leftRecently(caller.getUniqueId(), 5 * 60 * 1000) != null)
{
_manager.getTutorials().sendTutorialMsg(caller, F.main("Clans", "You cannot create a Clan for " + C.mTime + UtilTime.MakeStr(Plugin.leftRecently(caller.getUniqueId(), 20 * 60 * 1000).getRight()) + C.mBody + "."));
return;
}
/*
* TODO if (!client.canJoin()) { _manager.getTutorials().sendTutorialMsg(caller,
* F.main("Clans", "You cannot join a Clan for " + C.mTime +
@ -344,6 +363,83 @@ public class ClansCommand extends CommandBase<ClansManager>
Plugin.getClanUtility().invite(caller, clan, target);
}
public void stuck(final Player caller)
{
ClanTerritory territory = Plugin.getClanUtility().getClaim(caller.getLocation());
String clanName = Plugin.getClanUtility().getClanByPlayer(caller) == null ? null : Plugin.getClanUtility().getClanByPlayer(caller).getName();
if (territory == null || territory.Safe || territory.Owner.equals(clanName))
{
_manager.getTutorials().sendTutorialMsg(caller, F.main("Clans", "You must be in another Clan's territory to use this."));
return;
}
DelayedTask.Instance.doDelay(caller, "Wilderness Teleport", new Callback<DelayedTaskClient>() {
public void run(DelayedTaskClient player)
{
// Do
Location loc = getWildLoc(player.getPlayer().getLocation());
if (loc == null)
{
_manager.getTutorials().sendTutorialMsg(caller, F.main("Clans", "Error whilst finding location to teleport to."));
return;
}
player.getPlayer().teleport(loc);
// Inform
_manager.getTutorials().sendTutorialMsg(caller, F.main("Clans", "You have been teleported to the Wilderness."));
}
}, new Callback<DelayedTaskClient>() {
public void run(DelayedTaskClient client)
{
UtilTextMiddle.display("", "Teleporting to Wilderness in " + F.elem(UtilTime.MakeStr(Math.max(0, client.getTimeLeft("Wilderness Teleport")))), 0, 5, 0, client.getPlayer());
}
}, new Callback<DelayedTaskClient>() {
public void run(DelayedTaskClient client)
{
UtilPlayer.message(client.getPlayer(), F.main("Clans", "Teleport has been cancelled due to movement."));
}
}, 2 * 60 * 1000, false);
}
public Location getWildLoc(Location origin)
{
Chunk wildLoc = origin.getChunk();
List<Chunk> worldChunks = Lists.newArrayList(origin.getWorld().getLoadedChunks());
Collections.sort(
worldChunks,
(c1, c2) ->
(int) ((int)
origin.distance(
UtilBlock.getHighest(origin.getWorld(),
c1.getBlock(7, origin.getBlockY(), 7).getLocation()
).getLocation())
-
origin.distance(
UtilBlock.getHighest(origin.getWorld(),
c2.getBlock(7, origin.getBlockY(), 7).getLocation()
).getLocation())
)
);
for (Chunk chunk : worldChunks)
{
if (Plugin.getClanUtility().getClaim(chunk) == null)
{
return chunk.getBlock(6, UtilBlock.getHighest(origin.getWorld(), chunk.getBlock(6, 0, 6).getLocation()).getY(), 6).getLocation();
}
}
return null;
}
public void join(final Player caller, String[] args)
{
if (Plugin.getClanMemberUuidMap().containsKey(caller.getUniqueId()))
@ -352,6 +448,12 @@ public class ClansCommand extends CommandBase<ClansManager>
return;
}
if (Plugin.leftRecently(caller.getUniqueId(), 20 * 60 * 1000) != null)
{
_manager.getTutorials().sendTutorialMsg(caller, F.main("Clans", "You cannot join a Clan for " + C.mTime + UtilTime.MakeStr(Plugin.leftRecently(caller.getUniqueId(), 20 * 60 * 1000).getRight()) + C.mBody + "."));
return;
}
if (!Plugin.Get(caller).canJoin())
{
_manager.getTutorials().sendTutorialMsg(caller, F.main("Clans", "You cannot join a Clan for " + C.mTime + UtilTime.convertString(System.currentTimeMillis() - Plugin.Get(caller).getDelay(), 1, TimeUnit.FIT) + C.mBody + "."));

View File

@ -10,6 +10,7 @@ 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.entity.EntityDamageByEntityEvent;
import org.bukkit.event.inventory.InventoryClickEvent;
import org.bukkit.event.player.PlayerInteractEvent;
@ -106,6 +107,17 @@ public class ObserverManager extends MiniPlugin
}
}
@EventHandler
public void onBreak(BlockBreakEvent event)
{
ObserverData data = _observerMap.get(event.getPlayer());
if (data != null)
{
if (!data.getSettings().contains(ObserverSettings.CAN_BREAK_BLOCKS))
event.setCancelled(true);
} }
@EventHandler
public void onInventoryClick(InventoryClickEvent event)
{

View File

@ -16,7 +16,7 @@ public enum ObserverSettings
public static EnumSet<ObserverSettings> getSettings(Rank rank)
{
if (rank.has(Rank.DEVELOPER))
return EnumSet.of(CAN_OPEN_CHESTS);
return EnumSet.of(CAN_OPEN_CHESTS, CAN_BREAK_BLOCKS);
return EnumSet.noneOf(ObserverSettings.class);
}

View File

@ -4,6 +4,7 @@ import org.bukkit.Material;
import org.bukkit.block.Block;
import org.bukkit.craftbukkit.v1_8_R3.CraftWorld;
import org.bukkit.craftbukkit.v1_8_R3.inventory.CraftItemStack;
import org.bukkit.entity.Player;
import org.bukkit.event.EventHandler;
import org.bukkit.event.EventPriority;
import org.bukkit.event.block.Action;
@ -167,6 +168,28 @@ public class TntGeneratorManager extends MiniPlugin
ClanInfo clan = getGenerator(event.getClickedBlock());
if (clan != null)
{
interact(clan, event.getPlayer());
}else { //fix tnt gen issues
//Can only place one of these in a clan location. so it must be a generator
ClanInfo owner = _clansManager.getClanUtility().getOwner(event.getClickedBlock().getLocation());
if(owner == null) return; //Wilderness
TntGenerator generator = owner.getGenerator();
System.out.println("Unable to find generator");
//Create generator if not exist
if(generator == null || !generator.getBlock().equals(event.getClickedBlock())) {
generator = new TntGenerator(event.getClickedBlock());
generator.setStock(2);
clan.setGenerator(generator);
_clansManager.getClanDataAccess().updateGenerator(clan, null);
}
interact(owner, event.getPlayer());
}
event.setCancelled(true);
}
}
private void interact(ClanInfo clan, Player player) {
final TntGenerator generator = clan.getGenerator();
final int stock = generator.getStock();
@ -181,7 +204,7 @@ public class TntGeneratorManager extends MiniPlugin
if (data)
{
updateBrewingStand(generator);
dropItem(event.getClickedBlock(), new ItemStack(Material.TNT));
dropItem(generator.getBlock(), new ItemStack(Material.TNT));
}
else
{
@ -195,11 +218,7 @@ public class TntGeneratorManager extends MiniPlugin
{
int secondLeft = SECONDS_PER_TNT - generator.getTicks();
int msLeft = secondLeft * 1000;
UtilTextMiddle.display("", C.cRed + "Next TNT in " + C.cGold + UtilTime.convertString(msLeft, 1, UtilTime.TimeUnit.FIT), event.getPlayer());
}
}
event.setCancelled(true);
UtilTextMiddle.display("", C.cRed + "Next TNT in " + C.cGold + UtilTime.convertString(msLeft, 1, UtilTime.TimeUnit.FIT), player);
}
}

View File

@ -25,9 +25,9 @@ import mineplex.core.scoreboard.elements.ScoreboardElement;
import mineplex.core.updater.UpdateType;
import mineplex.core.updater.event.UpdateEvent;
import mineplex.game.clans.clans.ClanInfo;
import mineplex.game.clans.clans.ClanTips.TipType;
import mineplex.game.clans.clans.ClansManager;
import mineplex.game.clans.clans.ClansUtility;
import mineplex.game.clans.clans.ClanTips.TipType;
import mineplex.game.clans.clans.event.ClanDisbandedEvent;
import mineplex.game.clans.clans.event.ClansPlayerDeathEvent;
import mineplex.game.clans.clans.war.command.WarPointsCommand;
@ -38,7 +38,7 @@ import mineplex.game.clans.core.war.ClanWarData;
public class WarManager extends MiniPlugin implements ScoreboardElement
{
public static final int WAR_START_POINTS = 0;
public static final int WAR_FINISH_POINTS = 20;
public static final int WAR_FINISH_POINTS = 25;
public static final long INVADE_LENGTH = 60000L * 30; // 30 Minutes
public static final long WAR_COOLDOWN = 60000L * 30; // 30 Minutes
@ -117,11 +117,18 @@ public class WarManager extends MiniPlugin implements ScoreboardElement
@EventHandler
public void handleDeath(final ClansPlayerDeathEvent event)
{
if (event.getPlayer() != null && event.getPlayer().getClan() != null)
ClanInfo deathClan = event.getPlayer().getClan();
if (deathClan == null)
{
deathClan = _clansManager.leftRecently(event.getPlayer().getPlayer().getUniqueId(), 60000) == null ? deathClan : _clansManager.leftRecently(event.getPlayer().getPlayer().getUniqueId(), 60000).getLeft();
}
if (event.getPlayer() != null && deathClan != null)
{
if (event.getKiller() != null && event.getKiller().getClan() != null)
{
final ClanInfo clan = event.getPlayer().getClan();
final ClanInfo clan = deathClan;
final ClanInfo killerClan = event.getKiller().getClan();
ClanWarData war = clan.getWarData(killerClan);

View File

@ -0,0 +1,93 @@
package mineplex.game.clans.clans.warpoints;
import com.google.common.collect.Maps;
import mineplex.core.MiniPlugin;
import mineplex.core.common.util.F;
import mineplex.core.common.util.UtilPlayer;
import mineplex.core.common.util.UtilServer;
import mineplex.core.common.util.UtilTime;
import mineplex.core.updater.UpdateType;
import mineplex.core.updater.event.UpdateEvent;
import mineplex.game.clans.clans.ClansManager;
import mineplex.game.clans.clans.event.*;
import org.bukkit.Bukkit;
import org.bukkit.Chunk;
import org.bukkit.OfflinePlayer;
import org.bukkit.entity.Player;
import org.bukkit.event.EventHandler;
import org.bukkit.plugin.java.JavaPlugin;
import java.util.HashMap;
import java.util.UUID;
public class WarPointEvasion extends MiniPlugin{
private HashMap<Chunk, Long> _chunkCooldown;
private HashMap<UUID, Long> _playerCooldown;
private final long COOLDOWN_TIME = 1000 * 60 * 10;
public WarPointEvasion(JavaPlugin plugin) {
super("WP Evasion", plugin);
_chunkCooldown = Maps.newHashMap();
_playerCooldown = Maps.newHashMap();
}
@EventHandler
public void updateCooldown(UpdateEvent event) {
if(!event.getType().equals(UpdateType.SEC)) return;
_chunkCooldown.keySet().stream().filter(chunk -> UtilTime.elapsed(_chunkCooldown.get(chunk), COOLDOWN_TIME)).forEach(chunk -> _chunkCooldown.remove(chunk));
_playerCooldown.keySet().stream().filter(player -> UtilTime.elapsed(_playerCooldown.get(player), COOLDOWN_TIME)).forEach(player -> {
_playerCooldown.remove(player);
if(Bukkit.getOfflinePlayer(player).isOnline()) {
if(ClansManager.getInstance().getClan(Bukkit.getPlayer(player)) == null) {
Bukkit.getPlayer(player).sendMessage(F.main("Clans", "You can now create a clan."));
}
}
});
}
@EventHandler
public void onClaim(PlayerPreClaimTerritoryEvent event) {
Chunk chunk = event.getClaimedChunk();
if(_chunkCooldown.containsKey(chunk)) {
event.setCancelled(true);
event.getClaimer().sendMessage(F.main("Clans", "You cannot claim this chunk for another " + UtilTime.convertString(COOLDOWN_TIME - (System.currentTimeMillis() - _chunkCooldown.get(chunk)), 1, UtilTime.TimeUnit.MINUTES)));
}
}
@EventHandler
public void onunClaim(PlayerUnClaimTerritoryEvent event) {
Chunk chunk = event.getUnClaimedChunk();
_chunkCooldown.put(chunk, System.currentTimeMillis());
}
@EventHandler
public void onClanDisband(ClanDisbandedEvent event) {
_playerCooldown.put(event.getDisbander().getUniqueId(), System.currentTimeMillis());
}
@EventHandler
public void onClanLeave(ClanLeaveEvent event) {
_playerCooldown.put(event.getPlayer().getUuid(), System.currentTimeMillis());
}
@EventHandler
public void onClanCreate(ClanCreatedEvent event) {
if (event.getFounder() == null)
return;
if (_playerCooldown.containsKey(event.getFounder().getUniqueId())) {
event.setCancelled(true);
event.getFounder().sendMessage(F.main("Clans", "You cannot create a clan for another " + UtilTime.convertString(COOLDOWN_TIME - (System.currentTimeMillis() - _playerCooldown.get(event.getFounder().getUniqueId())), 1, UtilTime.TimeUnit.MINUTES)));
}
}
public void resetCooldown(UUID uuid)
{
_playerCooldown.remove(uuid);
}
}

View File

@ -4,6 +4,7 @@ import java.util.HashSet;
import java.util.Iterator;
import java.util.Set;
import mineplex.game.clans.clans.ClansManager;
import org.bukkit.Effect;
import org.bukkit.Location;
import org.bukkit.Material;
@ -474,6 +475,7 @@ public class UndeadCamp extends WorldEvent
@EventHandler(priority = EventPriority.HIGHEST)
public void onChestOpen(PlayerInteractEvent event)
{
if(ClansManager.getInstance().getObserverManager().isObserver(event.getPlayer())) return;;
Block block = event.getClickedBlock();
if (_containers.contains(block))
{

View File

@ -14,6 +14,7 @@ import org.bukkit.Sound;
import org.bukkit.block.Biome;
import org.bukkit.block.Block;
import org.bukkit.block.BlockFace;
import org.bukkit.block.BlockState;
import org.bukkit.entity.EntityType;
import org.bukkit.entity.ItemFrame;
import org.bukkit.entity.Player;
@ -40,6 +41,7 @@ import org.bukkit.event.player.PlayerFishEvent.State;
import org.bukkit.event.player.PlayerInteractEntityEvent;
import org.bukkit.event.player.PlayerInteractEvent;
import org.bukkit.event.weather.WeatherChangeEvent;
import org.bukkit.event.world.StructureGrowEvent;
import org.bukkit.inventory.ItemStack;
import org.bukkit.inventory.meta.ItemMeta;
import org.bukkit.material.Dye;
@ -264,6 +266,24 @@ public class Gameplay extends MiniPlugin
}
}
@EventHandler(priority = EventPriority.LOWEST)
public void MaxHeight(BlockPlaceEvent event)
{
if (event.getBlock().getLocation().getBlockY() > 100)
{
UtilPlayer.message(event.getPlayer(), F.main("Game", "You cannot place blocks this high."));
event.setCancelled(true);
} else if(event.getBlock().getLocation().getBlockY() == 99 && event.getBlock().getType().name().contains("DOOR") && !event.getBlock().getType().equals(Material.TRAP_DOOR)) {
UtilPlayer.message(event.getPlayer(), F.main("Game", "You cannot place blocks this high."));
event.setCancelled(true);
}
}
@EventHandler(priority = EventPriority.LOWEST)
public void GrowTree(StructureGrowEvent event) {
event.getBlocks().stream().filter(blockState -> blockState.getLocation().getBlockY() > 100).forEach(blockState -> blockState.setType(Material.AIR) );
}
/**
* Disable all Piston related events in Clans
*
@ -449,6 +469,7 @@ public class Gameplay extends MiniPlugin
@EventHandler(priority = EventPriority.HIGHEST)
public void disableSaplings(BlockPlaceEvent event)
{
if(event.isCancelled()) return; //Can't place this block
if (!event.getItemInHand().getType().equals(Material.SAPLING))
{
return;

View File

@ -130,7 +130,10 @@ public class GearManager extends MiniPlugin implements IPacketHandler, Runnable
// TODO: Introduce configurable non-hardcoded values for generation
// weights?
_attributeWeights = new WeightSet<Integer>(new Weight<Integer>(3, 3), new Weight<Integer>(20, 2), new Weight<Integer>(77, 1));
_typeWeights = new WeightSet<ItemType>(new Weight<ItemType>(10, ItemType.LEGENDARY), new Weight<ItemType>(45, ItemType.ARMOR), new Weight<ItemType>(23, ItemType.WEAPON), new Weight<ItemType>(22, ItemType.BOW));
_typeWeights = new WeightSet<ItemType>(new Weight<ItemType>(6, ItemType.LEGENDARY),
new Weight<ItemType>(46, ItemType.ARMOR),
new Weight<ItemType>(25, ItemType.WEAPON),
new Weight<ItemType>(23, ItemType.BOW));
// Weapon-based attributes
_weaponAttributes = new WeightSet<Class<? extends ItemAttribute>>(FrostedAttribute.class, SharpAttribute.class, JaggedAttribute.class, HasteAttribute.class, FlamingAttribute.class, ConqueringAttribute.class);

View File

@ -30,6 +30,7 @@ public abstract class AttackAttribute extends ItemAttribute
@Override
public void onAttack(CustomDamageEvent event)
{
if(event.IsCancelled() || event.isCancelled()) return;
_attackCount++;
System.out.println("Attack count " + _attackCount + " - " + _attackLimit);
if (_attackCount >= _attackLimit)

View File

@ -1,10 +1,14 @@
package mineplex.game.clans.items.attributes.weapon;
import mineplex.game.clans.clans.ClansManager;
import mineplex.game.clans.clans.gui.page.ClanMainPage;
import mineplex.game.clans.items.attributes.AttackAttribute;
import mineplex.game.clans.items.attributes.AttributeType;
import mineplex.game.clans.items.generation.ValueDistribution;
import org.bukkit.GameMode;
import org.bukkit.entity.Entity;
import org.bukkit.entity.Player;
public class FlamingAttribute extends AttackAttribute
{
@ -34,6 +38,9 @@ public class FlamingAttribute extends AttackAttribute
@Override
public void triggerAttack(Entity attacker, Entity defender)
{
if(attacker instanceof Player && ClansManager.getInstance().isSafe((Player) attacker)) return;
if(defender instanceof Player && ClansManager.getInstance().isSafe((Player) defender)) return;
if(attacker instanceof Player && ((Player)attacker).getGameMode().equals(GameMode.CREATIVE)) return;
defender.setFireTicks(_fireDuration);
}

View File

@ -13,10 +13,8 @@ import mineplex.minecraft.game.core.damage.CustomDamageEvent;
public class GiantsBroadsword extends LegendaryItem
{
public static final int SLOW_AMPLIFIER = 4;
public static final int REGEN_AMPLIFIER = 1;
public static final int EFFECT_DURATION = 10; // Duration of potion effect
// (in ticks)
public static final int SLOW_AMPLIFIER = 43;
public static final int REGEN_AMPLIFIER = 3;
public GiantsBroadsword()
{
@ -34,8 +32,7 @@ public class GiantsBroadsword extends LegendaryItem
@Override
public void update(Player wielder)
{
if (isHoldingRightClick())
{
if (isHoldingRightClick()) {
buffPlayer(wielder);
UtilParticle.PlayParticle(ParticleType.HEART, wielder.getEyeLocation().add(0, 0.25, 0), -.5f + (float) Math.random(), -.5f + (float) Math.random(), -.5f + (float) Math.random(), .2f, 1, ViewDist.NORMAL);
@ -62,7 +59,7 @@ public class GiantsBroadsword extends LegendaryItem
private void buffPlayer(Player player)
{
grantPotionEffect(player, PotionEffectType.SLOW, 40, 43);
grantPotionEffect(player, PotionEffectType.REGENERATION, 2, 43);
grantPotionEffect(player, PotionEffectType.SLOW, 40, SLOW_AMPLIFIER);
grantPotionEffect(player, PotionEffectType.REGENERATION, 40, REGEN_AMPLIFIER); //Regen
}
}

View File

@ -92,6 +92,7 @@ public class LegendaryItem extends CustomItem
*/
public static void grantPotionEffect(Player player, PotionEffectType type, int tickDuration, int amplifier)
{
player.removePotionEffect(type);
player.addPotionEffect(new PotionEffect(type, amplifier, tickDuration));
}
}