Merge branch 'develop' of ssh://184.154.0.242:7999/min/mineplex into develop

This commit is contained in:
libraryaddict 2015-12-18 10:03:41 +13:00
commit 7f188072ad
32 changed files with 753 additions and 95 deletions

View File

@ -1,6 +1,6 @@
<?xml version="1.0" encoding="UTF-8"?> <?xml version="1.0" encoding="UTF-8"?>
<project version="4"> <project version="4">
<component name="DataSourceManagerImpl" format="xml" hash="2876127046"> <component name="DataSourceManagerImpl" format="xml" hash="1486084220">
<data-source source="LOCAL" name="Mineplex" uuid="14dfc55d-5343-47c4-ab24-76a055b8059e"> <data-source source="LOCAL" name="Mineplex" uuid="14dfc55d-5343-47c4-ab24-76a055b8059e">
<driver-ref>mysql</driver-ref> <driver-ref>mysql</driver-ref>
<synchronize>true</synchronize> <synchronize>true</synchronize>

View File

@ -678,22 +678,19 @@ public class BonusManager extends MiniClientPlugin<BonusClientData> implements I
if (rank.has(Rank.TITAN)) if (rank.has(Rank.TITAN))
{ {
data.setAncientChests(6); data.setMythicalChests(5);
data.setMythicalChests(3);
} }
else if (rank.has(Rank.LEGEND)) else if (rank.has(Rank.LEGEND))
{ {
data.setAncientChests(4); data.setMythicalChests(3);
data.setMythicalChests(1);
} }
else if (rank.has(Rank.HERO)) else if (rank.has(Rank.HERO))
{ {
data.setAncientChests(3); data.setMythicalChests(2);
} }
else if (rank.has(Rank.ULTRA)) else if (rank.has(Rank.ULTRA))
{ {
data.setOldChests(3); data.setMythicalChests(1);
data.setAncientChests(1);
} }
return data; return data;

View File

@ -117,7 +117,7 @@ public class Menu extends ShopPageBase<CosmeticManager, CosmeticShop>
Mount<?> mountActive = getPlugin().getMountManager().getActive(getPlayer()); Mount<?> mountActive = getPlugin().getMountManager().getActive(getPlayer());
for (Mount<?> mount : getPlugin().getMountManager().getMounts()) for (Mount<?> mount : getPlugin().getMountManager().getMounts())
{ {
if (mount.HasMount(getPlayer())) if (getDonationManager().Get(getPlayer()).OwnsUnknownPackage(mount.GetName()) || mount.HasMount(getPlayer()))
{ {
mountOwned++; mountOwned++;
} }

View File

@ -45,6 +45,9 @@ import mineplex.core.gadget.set.SetFrostLord;
import mineplex.core.gadget.set.SetRaveSuit; import mineplex.core.gadget.set.SetRaveSuit;
import mineplex.core.gadget.set.SetSpaceSuit; import mineplex.core.gadget.set.SetSpaceSuit;
import mineplex.core.gadget.set.SetTitan; import mineplex.core.gadget.set.SetTitan;
import mineplex.core.gadget.types.ArrowEffectGadget;
import mineplex.core.gadget.types.DeathEffectGadget;
import mineplex.core.gadget.types.DoubleJumpEffectGadget;
import mineplex.core.gadget.types.Gadget; import mineplex.core.gadget.types.Gadget;
import mineplex.core.gadget.types.GadgetSet; import mineplex.core.gadget.types.GadgetSet;
import mineplex.core.gadget.types.GadgetType; import mineplex.core.gadget.types.GadgetType;
@ -328,6 +331,15 @@ public class GadgetManager extends MiniPlugin
{ {
if (gadget instanceof ParticleGadget) if (gadget instanceof ParticleGadget)
continue; continue;
if (gadget instanceof ArrowEffectGadget)
continue;
if (gadget instanceof DoubleJumpEffectGadget)
continue;
if (gadget instanceof DeathEffectGadget)
continue;
for (Player player : UtilServer.getPlayers()) for (Player player : UtilServer.getPlayers())
gadget.Disable(player); gadget.Disable(player);

View File

@ -15,7 +15,7 @@ public class HatGrinch extends HatGadget
super(manager, "The Grinch", super(manager, "The Grinch",
UtilText.splitLineToArray(C.cGray + "Great! Now wheres the Roast Beast?!", LineFormat.LORE), UtilText.splitLineToArray(C.cGray + "Great! Now wheres the Roast Beast?!", LineFormat.LORE),
-3, -3,
SkinData.THE_GRINCH.getSkull()); SkinData.THE_GRINCH.getSkull(), "The Grinch Hat");
} }
} }

View File

@ -17,9 +17,9 @@ public abstract class HatGadget extends OutfitGadget
private ItemStack _hat; private ItemStack _hat;
public HatGadget(GadgetManager manager, String name, String[] desc, int cost, ItemStack item) public HatGadget(GadgetManager manager, String name, String[] desc, int cost, ItemStack item, String... altNames)
{ {
super(manager, name, desc, cost, ArmorSlot.Helmet, item.getType(), item.getData().getData()); super(manager, name, desc, cost, ArmorSlot.Helmet, item.getType(), item.getData().getData(), altNames);
_hat = item; _hat = item;
ItemMeta im = _hat.getItemMeta(); ItemMeta im = _hat.getItemMeta();

View File

@ -20,9 +20,9 @@ public abstract class OutfitGadget extends Gadget
protected ArmorSlot _slot; protected ArmorSlot _slot;
public OutfitGadget(GadgetManager manager, String name, String[] desc, int cost, ArmorSlot slot, Material mat, byte data) public OutfitGadget(GadgetManager manager, String name, String[] desc, int cost, ArmorSlot slot, Material mat, byte data, String... altNames)
{ {
super(manager, GadgetType.Costume, name, desc, cost, mat, data); super(manager, GadgetType.Costume, name, desc, cost, mat, data, 1, altNames);
_slot = slot; _slot = slot;
} }

View File

@ -45,7 +45,7 @@ public class RewardManager
private int _uncommonShards = 100; private int _uncommonShards = 100;
private int _rareShards = 500; private int _rareShards = 500;
private int _legendaryShards = 6000; private int _legendaryShards = 5000;
public RewardManager(CoreClientManager clientManager, ServerStatusManager statusManager, DonationManager donationManager, InventoryManager inventoryManager, PetManager petManager, StatsManager statsManager, GiveawayManager giveawayManager, public RewardManager(CoreClientManager clientManager, ServerStatusManager statusManager, DonationManager donationManager, InventoryManager inventoryManager, PetManager petManager, StatsManager statsManager, GiveawayManager giveawayManager,
@ -264,11 +264,11 @@ public class RewardManager
addReward(RewardPool.Type.WINTER_HOLIDAY, new UnknownPackageReward(donationManager, "Death Effect", "Candy Cane Remains", "Candy Cane Remains", addReward(RewardPool.Type.WINTER_HOLIDAY, new UnknownPackageReward(donationManager, "Death Effect", "Candy Cane Remains", "Candy Cane Remains",
new ItemStack(Material.SNOW_BALL), rarity, 5, _rareShards)); new ItemStack(Material.SNOW_BALL), rarity, 5, _rareShards));
addReward(RewardPool.Type.WINTER_HOLIDAY, new UnknownPackageReward(donationManager, "Particles", "Crushed Candy Cane", "Crushed Candy Cane", addReward(RewardPool.Type.WINTER_HOLIDAY, new UnknownPackageReward(donationManager, "Particles", "Crushed Candy Cane", "Crushed Candy Cane",
new ItemStack(Material.SNOW_BALL), rarity, 5, _legendaryShards)); new ItemStack(Material.SNOW_BALL), rarity, 5, _rareShards));
addReward(RewardPool.Type.WINTER_HOLIDAY, new UnknownPackageReward(donationManager, "Arrow Effect", "Candy Cane Arrows", "Candy Cane Arrows", addReward(RewardPool.Type.WINTER_HOLIDAY, new UnknownPackageReward(donationManager, "Arrow Effect", "Candy Cane Arrows", "Candy Cane Arrows",
new ItemStack(Material.SNOW_BALL), rarity, 5, _legendaryShards)); new ItemStack(Material.SNOW_BALL), rarity, 5, _rareShards));
addReward(RewardPool.Type.WINTER_HOLIDAY, new UnknownPackageReward(donationManager, "Jump Effect", "Candy Cane Blast", "Candy Cane Blast", addReward(RewardPool.Type.WINTER_HOLIDAY, new UnknownPackageReward(donationManager, "Jump Effect", "Candy Cane Blast", "Candy Cane Blast",
new ItemStack(Material.SNOW_BALL), rarity, 5, _legendaryShards)); new ItemStack(Material.SNOW_BALL), rarity, 5, _rareShards));
// Mounts // Mounts
addReward(new UnknownPackageReward(donationManager, "Mount", "Mule", "Mount Mule", addReward(new UnknownPackageReward(donationManager, "Mount", "Mule", "Mount Mule",
@ -326,7 +326,7 @@ public class RewardManager
// addReward(new CoinReward(donationManager, (int)minValue, (int)maxValue, 25, rarity)); // addReward(new CoinReward(donationManager, (int)minValue, (int)maxValue, 25, rarity));
} }
addReward(RewardPool.Type.WINTER_HOLIDAY, new UnknownPackageReward(donationManager, "Hat", "The Grinch", "The Grinch Hat", addReward(RewardPool.Type.WINTER_HOLIDAY, new UnknownPackageReward(donationManager, "Hat", "The Grinch", "The Grinch",
SkinData.THE_GRINCH.getSkull(), rarity, 5, _legendaryShards)); SkinData.THE_GRINCH.getSkull(), rarity, 5, _legendaryShards));
addReward(RewardPool.Type.WINTER_HOLIDAY, new UnknownPackageReward(donationManager, "Morph", "Olaf", "Olaf Morph", addReward(RewardPool.Type.WINTER_HOLIDAY, new UnknownPackageReward(donationManager, "Morph", "Olaf", "Olaf Morph",
new ItemStack(Material.SNOW_BALL), rarity, 5, _legendaryShards)); new ItemStack(Material.SNOW_BALL), rarity, 5, _legendaryShards));
@ -341,7 +341,7 @@ public class RewardManager
addReward(RewardPool.Type.WINTER_HOLIDAY, new UnknownPackageReward(donationManager, "Jump Effect", "Gust of the Frost Lord", "Gust of the Frost Lord", addReward(RewardPool.Type.WINTER_HOLIDAY, new UnknownPackageReward(donationManager, "Jump Effect", "Gust of the Frost Lord", "Gust of the Frost Lord",
new ItemStack(Material.SNOW_BALL), rarity, 5, _legendaryShards)); new ItemStack(Material.SNOW_BALL), rarity, 5, _legendaryShards));
addReward(RewardPool.Type.WINTER_HOLIDAY, new UnknownPackageReward(donationManager, "Death Effect", "Fall of the Frost Lord", "Fall of the Frost Lord", addReward(RewardPool.Type.WINTER_HOLIDAY, new UnknownPackageReward(donationManager, "Death Effect", "Fall of the Frost Lord", "Fall of the Frost Lord",
new ItemStack(Material.SNOW_BALL), rarity, 5, _rareShards)); new ItemStack(Material.SNOW_BALL), rarity, 5, _legendaryShards));
// Mounts // Mounts
addReward(new UnknownPackageReward(donationManager, "Mount", "Infernal Horror", "Infernal Horror", addReward(new UnknownPackageReward(donationManager, "Mount", "Infernal Horror", "Infernal Horror",
@ -480,12 +480,17 @@ public class RewardManager
} }
} }
possibleRewards.add(treasure); if (!isExcluded)
totalWeight += treasure.getWeight(); {
possibleRewards.add(treasure);
totalWeight += treasure.getWeight();
}
} }
if (possibleRewards.size() == 0) if (possibleRewards.size() == 0)
{ {
totalWeight = 0;
// go again, ignore excluded // go again, ignore excluded
for (Reward treasure : treasureList) for (Reward treasure : treasureList)
{ {

View File

@ -9,8 +9,8 @@ public enum RewardType
OldChest( 0, 0.06, 0.8, 16), OldChest( 0, 0.06, 0.8, 16),
AncientChest( 0, 2, 8, 32), AncientChest( 0, 2, 8, 32),
MythicalChest( 0.3, 4, 16, 72), MythicalChest( 0.1, 4, 16, 72),
WinterChest( 0, 6, 20, 32), WinterChest( 0, 5, 18, 32),
SpinnerFiller( 0.1, 1, 4, 20), SpinnerFiller( 0.1, 1, 4, 20),
SpinnerReal( 0.000001, 0.05, 0.4, 5); SpinnerReal( 0.000001, 0.05, 0.4, 5);

View File

@ -21,7 +21,14 @@ public class PlayerStats
return _statHash.get(statName); return _statHash.get(statName);
} }
public long setStat(String statName, long value)
{
_statHash.put(statName, value);
return _statHash.get(statName);
}
public long getStat(String statName) public long getStat(String statName)
{ {
return _statHash.containsKey(statName) ? _statHash.get(statName) : 0L; return _statHash.containsKey(statName) ? _statHash.get(statName) : 0L;

View File

@ -14,6 +14,7 @@ import mineplex.core.database.RepositoryBase;
import mineplex.core.database.ResultSetCallable; import mineplex.core.database.ResultSetCallable;
import mineplex.core.database.column.ColumnVarChar; import mineplex.core.database.column.ColumnVarChar;
import mineplex.database.Tables; import mineplex.database.Tables;
import net.md_5.bungee.chat.TranslatableComponentSerializer;
import org.jooq.DSLContext; import org.jooq.DSLContext;
import org.jooq.Insert; import org.jooq.Insert;
@ -134,8 +135,9 @@ public class StatsRepository extends RepositoryBase
.on(Tables.stats.id.eq(Tables.accountStat.statId)) .on(Tables.stats.id.eq(Tables.accountStat.statId))
.where(Tables.accountStat.accountId.eq(DSL.select(Tables.accounts.id) .where(Tables.accountStat.accountId.eq(DSL.select(Tables.accounts.id)
.from(Tables.accounts) .from(Tables.accounts)
.where(Tables.accounts.name.eq(playerName))) .where(Tables.accounts.name.eq(playerName)).limit(1))
).fetch(); )
.fetch();
if (result.isNotEmpty()) if (result.isNotEmpty())

View File

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

View File

@ -10,7 +10,6 @@ import java.util.TimeZone;
import java.util.UUID; import java.util.UUID;
import org.bukkit.Bukkit; import org.bukkit.Bukkit;
import org.bukkit.GameMode;
import org.bukkit.Location; import org.bukkit.Location;
import org.bukkit.Material; import org.bukkit.Material;
import org.bukkit.entity.Player; import org.bukkit.entity.Player;
@ -66,7 +65,6 @@ import mineplex.core.updater.UpdateType;
import mineplex.core.updater.event.UpdateEvent; import mineplex.core.updater.event.UpdateEvent;
import mineplex.game.clans.clans.ClanTips.TipType; import mineplex.game.clans.clans.ClanTips.TipType;
import mineplex.game.clans.clans.ClansUtility.ClanRelation; import mineplex.game.clans.clans.ClansUtility.ClanRelation;
import mineplex.game.clans.clans.claimview.ClaimVisualizer;
import mineplex.game.clans.clans.commands.ClanManagementCommand; import mineplex.game.clans.clans.commands.ClanManagementCommand;
import mineplex.game.clans.clans.commands.ClansAllyChatCommand; import mineplex.game.clans.clans.commands.ClansAllyChatCommand;
import mineplex.game.clans.clans.commands.ClansChatCommand; import mineplex.game.clans.clans.commands.ClansChatCommand;
@ -81,7 +79,9 @@ import mineplex.game.clans.clans.gui.ClanShop;
import mineplex.game.clans.clans.loot.LootManager; import mineplex.game.clans.clans.loot.LootManager;
import mineplex.game.clans.clans.map.ItemMapManager; import mineplex.game.clans.clans.map.ItemMapManager;
import mineplex.game.clans.clans.observer.ObserverManager; import mineplex.game.clans.clans.observer.ObserverManager;
import mineplex.game.clans.clans.playtime.Playtime;
import mineplex.game.clans.clans.potato.PotatoManager; import mineplex.game.clans.clans.potato.PotatoManager;
import mineplex.game.clans.clans.pvptimer.PvpTimer;
import mineplex.game.clans.clans.redis.ClanDeleteCommandHandler; import mineplex.game.clans.clans.redis.ClanDeleteCommandHandler;
import mineplex.game.clans.clans.redis.ClanLoadCommandHandler; import mineplex.game.clans.clans.redis.ClanLoadCommandHandler;
import mineplex.game.clans.clans.regions.ClansRegions; import mineplex.game.clans.clans.regions.ClansRegions;
@ -155,6 +155,8 @@ public class ClansManager extends MiniClientPlugin<ClientClan>implements IRelati
private LootManager _lootManager; private LootManager _lootManager;
private DonationManager _donationManager; private DonationManager _donationManager;
private Playtime _playTracker;
private TutorialManager _tutorialManager; private TutorialManager _tutorialManager;
private ClassManager _classManager; private ClassManager _classManager;
@ -228,18 +230,12 @@ public class ClansManager extends MiniClientPlugin<ClientClan>implements IRelati
TaskManager taskManager = new TaskManager(plugin, _clientManager, webServerAddress); TaskManager taskManager = new TaskManager(plugin, _clientManager, webServerAddress);
_tutorialManager = new TutorialManager(plugin, _goldManager, taskManager, donationManager, preferencesManager, this, packetHandler);
ClanTips = new ClanTips(plugin, this, preferencesManager); ClanTips = new ClanTips(plugin, this, preferencesManager);
new StuckManager(this);
_scoreboard = new ClansScoreboardManager(plugin, _tutorialManager, this, _warManager, _worldEvent, clientManager, donationManager);
// new MurderManager(plugin, this); // new MurderManager(plugin, this);
_clanAdmin = new ClansAdmin(this); _clanAdmin = new ClansAdmin(this);
_clanBlocks = new ClansBlocks(); _clanBlocks = new ClansBlocks();
_clanDataAccess = new ClansDataAccessLayer(this, _scoreboard);
_clanDisplay = new ClansDisplay(plugin, this); _clanDisplay = new ClansDisplay(plugin, this);
_clanGame = new ClansGame(plugin, this); _clanGame = new ClansGame(plugin, this);
_clanUtility = new ClansUtility(this); _clanUtility = new ClansUtility(this);
@ -266,11 +262,12 @@ public class ClansManager extends MiniClientPlugin<ClientClan>implements IRelati
new ObserverManager(plugin, _condition, this); new ObserverManager(plugin, _condition, this);
new ClanEnergyTracker(plugin, this); new ClanEnergyTracker(plugin, this);
new StuckManager(this);
new ClansAlphaManager(this, taskManager); new ClansAlphaManager(this, taskManager);
new PotatoManager(plugin, this); new PotatoManager(plugin, this);
new Weapon(plugin, energy); new Weapon(plugin, energy);
new Gameplay(plugin, this, blockRestore, damageManager); new Gameplay(plugin, this, blockRestore, damageManager);
_projectileManager = new ProjectileManager(plugin); _projectileManager = new ProjectileManager(plugin);
@ -298,7 +295,15 @@ public class ClansManager extends MiniClientPlugin<ClientClan>implements IRelati
ClassShopManager shopManager = new ClassShopManager(plugin, _classManager, skillManager, itemFactory, achievementManager, _clientManager); ClassShopManager shopManager = new ClassShopManager(plugin, _classManager, skillManager, itemFactory, achievementManager, _clientManager);
_classShop = new ClassCombatShop(shopManager, _clientManager, donationManager, true, "Class Shop"); _classShop = new ClassCombatShop(shopManager, _clientManager, donationManager, true, "Class Shop");
ClanEnergyManager clanEnergyManager = new ClanEnergyManager(plugin, this, clientManager, donationManager); new ClanEnergyManager(plugin, this, clientManager, donationManager);
_playTracker = new Playtime(this, statsManager);
new PvpTimer(this, _playTracker, statsManager);
_tutorialManager = new TutorialManager(plugin, _playTracker, _goldManager, taskManager, donationManager, preferencesManager, this, packetHandler);
_scoreboard = new ClansScoreboardManager(plugin, this, _warManager, _worldEvent, clientManager, donationManager);
_clanDataAccess = new ClansDataAccessLayer(this, _scoreboard);
for (ClanToken token : _clanDataAccess.getRepository().retrieveClans()) for (ClanToken token : _clanDataAccess.getRepository().retrieveClans())
{ {
@ -377,7 +382,7 @@ public class ClansManager extends MiniClientPlugin<ClientClan>implements IRelati
@Override @Override
public void addCommands() public void addCommands()
{ {
addCommand(new ClansCommand(this, _tutorialManager)); addCommand(new ClansCommand(this));
addCommand(new RegionsCommand(this)); addCommand(new RegionsCommand(this));
addCommand(new ClansChatCommand(this)); addCommand(new ClansChatCommand(this));
addCommand(new ClansAllyChatCommand(this)); addCommand(new ClansAllyChatCommand(this));
@ -460,7 +465,7 @@ public class ClansManager extends MiniClientPlugin<ClientClan>implements IRelati
int x = Math.abs(location.getBlockX()); int x = Math.abs(location.getBlockX());
int z = Math.abs(location.getBlockZ()); int z = Math.abs(location.getBlockZ());
return (x <= CLAIMABLE_RADIUS && z <= CLAIMABLE_RADIUS) && !Spawn.getInstance().isInSpawn(location); return (x <= CLAIMABLE_RADIUS && z <= CLAIMABLE_RADIUS) && !Spawn.getInstance().isSafe(location);
} }
public boolean isFields(Location location) public boolean isFields(Location location)
@ -624,7 +629,7 @@ public class ClansManager extends MiniClientPlugin<ClientClan>implements IRelati
String rank = _clientManager.Get(event.getPlayer()).GetRank().getTag(true, true) + " "; String rank = _clientManager.Get(event.getPlayer()).GetRank().getTag(true, true) + " ";
if (!_clientManager.Get(event.getPlayer()).GetRank().has(Rank.MEDIA)) if (!_clientManager.Get(event.getPlayer()).GetRank().has(Rank.TWITCH))
rank = ""; rank = "";
if (client.isClanChat() && clan != null) if (client.isClanChat() && clan != null)
@ -957,6 +962,7 @@ public class ClansManager extends MiniClientPlugin<ClientClan>implements IRelati
_blockRestore.onDisable(); _blockRestore.onDisable();
_worldEvent.onDisable(); _worldEvent.onDisable();
_goldManager.onDisable(); _goldManager.onDisable();
_playTracker.onDisable();
} }
@EventHandler(priority = EventPriority.HIGHEST) @EventHandler(priority = EventPriority.HIGHEST)

View File

@ -0,0 +1,18 @@
package mineplex.game.clans.clans;
public enum ClansPlayerStats
{
PLAY_TIME("Clans.TimePlaying");
private String _id;
ClansPlayerStats(String id)
{
_id = id;
}
public String id()
{
return _id;
}
}

View File

@ -24,6 +24,7 @@ import mineplex.game.clans.clans.event.PlayerClaimTerritoryEvent;
import mineplex.game.clans.clans.event.PlayerPreClaimTerritoryEvent; import mineplex.game.clans.clans.event.PlayerPreClaimTerritoryEvent;
import mineplex.game.clans.clans.event.PlayerUnClaimTerritoryEvent; import mineplex.game.clans.clans.event.PlayerUnClaimTerritoryEvent;
import mineplex.game.clans.core.repository.ClanTerritory; import mineplex.game.clans.core.repository.ClanTerritory;
import mineplex.game.clans.spawn.Spawn;
public class ClansUtility public class ClansUtility
{ {
@ -238,7 +239,7 @@ public class ClansUtility
public boolean isSafe(Player player) public boolean isSafe(Player player)
{ {
if (!UtilTime.elapsed(Clans.getCombatManager().Get(player).GetLastDamaged(), 15000)) return false; if (!UtilTime.elapsed(Clans.getCombatManager().Get(player).GetLastDamaged(), Spawn.COMBAT_TAG_DURATION)) return false;
return isSafe(player.getLocation()); return isSafe(player.getLocation());
} }

View File

@ -35,7 +35,7 @@ public class ClansCommand extends CommandBase<ClansManager>
{ {
private ClansManager _manager; private ClansManager _manager;
public ClansCommand(ClansManager plugin, TutorialManager tutorialManager) public ClansCommand(ClansManager plugin)
{ {
super(plugin, Rank.ALL, "c", "clan", "clans", "factions"); super(plugin, Rank.ALL, "c", "clan", "clans", "factions");

View File

@ -0,0 +1,13 @@
package mineplex.game.clans.clans.playtime;
public class PlayingClient
{
public long StartTime;
public boolean FirstSession;
public PlayingClient(boolean first)
{
StartTime = System.currentTimeMillis();
FirstSession = first;
}
}

View File

@ -0,0 +1,86 @@
package mineplex.game.clans.clans.playtime;
import org.bukkit.Bukkit;
import org.bukkit.entity.Player;
import org.bukkit.event.EventHandler;
import org.bukkit.event.player.PlayerJoinEvent;
import org.bukkit.event.player.PlayerKickEvent;
import org.bukkit.event.player.PlayerQuitEvent;
import mineplex.core.MiniClientPlugin;
import mineplex.core.stats.StatsManager;
import mineplex.game.clans.clans.ClansManager;
import mineplex.game.clans.clans.ClansPlayerStats;
import mineplex.game.clans.clans.playtime.command.PlayTimeCommand;
import mineplex.game.clans.clans.playtime.command.cemde;
public class Playtime extends MiniClientPlugin<PlayingClient>
{
private StatsManager _statsManager;
public Playtime(ClansManager clans, StatsManager statsManager)
{
super("Clans Play Time Tracker", clans.getPlugin());
_statsManager = statsManager;
addCommand(new PlayTimeCommand(_statsManager, this));
}
@Override
public void disable()
{
for (Player player : Bukkit.getOnlinePlayers())
{
save(player);
}
}
// Seconds
public long getPlaytime(Player player)
{
return _statsManager.Get(player).getStat(ClansPlayerStats.PLAY_TIME.id());
}
@EventHandler
public void onPlayerJoin(PlayerJoinEvent event)
{
Set(event.getPlayer(), AddPlayer(event.getPlayer().getName()));
}
@EventHandler
public void onPlayerQuit(PlayerQuitEvent event)
{
save(event.getPlayer());
}
@EventHandler
public void onPlayerKicked(PlayerKickEvent event)
{
save(event.getPlayer());
}
private void save(Player player)
{
long timePlaying = getUnsavedPlaytime(player);
_statsManager.incrementStat(player, ClansPlayerStats.PLAY_TIME.id(), timePlaying);
// Increment main time in game as well
_statsManager.incrementStat(player, "Global.TimeInGame", timePlaying);
Get(player).StartTime = System.currentTimeMillis();
}
@Override
protected PlayingClient AddPlayer(String player)
{
return new PlayingClient(_statsManager.Get(player).getStat(ClansPlayerStats.PLAY_TIME.id()) == 0);
}
// Seconds
public long getUnsavedPlaytime(Player player)
{
return (System.currentTimeMillis() - Get(player).StartTime) / 1000;
}
}

View File

@ -0,0 +1,81 @@
package mineplex.game.clans.clans.playtime.command;
import java.sql.SQLException;
import org.bukkit.entity.Player;
import mineplex.core.command.CommandBase;
import mineplex.core.common.Rank;
import mineplex.core.common.util.F;
import mineplex.core.common.util.UtilPlayer;
import mineplex.core.common.util.UtilTime;
import mineplex.core.stats.PlayerStats;
import mineplex.core.stats.StatsManager;
import mineplex.game.clans.clans.ClansPlayerStats;
import mineplex.game.clans.clans.playtime.Playtime;
public class PlayTimeCommand extends CommandBase<StatsManager>
{
private Playtime _playTracker;
public PlayTimeCommand(StatsManager plugin, Playtime tracker)
{
super(plugin, Rank.MODERATOR, "clanstime");
_playTracker = tracker;
}
@Override
public void Execute(final Player caller, final String[] args)
{
if (args == null || args.length == 0)
{
UtilPlayer.message(caller, F.main("Clans", "Usage: /clanstime <playerName>"));
}
else
{
final Player target = UtilPlayer.searchOnline(caller, args[0], false);
if (target == null)
{
Plugin.getPlugin().getServer().getScheduler().runTaskAsynchronously(Plugin.getPlugin(), new Runnable()
{
@Override
public void run()
{
try
{
final PlayerStats stats = Plugin.getOfflinePlayerStats(args[0]);
Plugin.getPlugin().getServer().getScheduler().runTask(Plugin.getPlugin(), new Runnable()
{
@Override
public void run()
{
if (stats == null)
{
UtilPlayer.message(caller, F.main("Clans", "Player " + F.elem(args[0]) + " not found!"));
}
else
{
long time = stats.getStat(ClansPlayerStats.PLAY_TIME.id());
UtilPlayer.message(caller, F.main("Clans", F.name(args[0]) + " has spent " + F.elem(UtilTime.convertString(time * 1000L, 1, UtilTime.TimeUnit.FIT)) + " playing Clans."));
}
}
});
}
catch (SQLException e)
{
UtilPlayer.message(caller, F.main("Clans", F.name(target.getName()) + " does not have any play time in Clans."));
}
}
});
}
else
{
long time = Plugin.Get(target).getStat(ClansPlayerStats.PLAY_TIME.id());
UtilPlayer.message(caller, F.main("Clans", F.name(target.getName()) + " has spent " + F.elem(UtilTime.convertString(time * 1000L, 1, UtilTime.TimeUnit.FIT) + " (+" + UtilTime.MakeStr(_playTracker.getUnsavedPlaytime(target) * 1000) + ")") + " playing Clans."));
}
}
}
}

View File

@ -0,0 +1,30 @@
package mineplex.game.clans.clans.playtime.command;
import org.bukkit.entity.Player;
import mineplex.core.command.CommandBase;
import mineplex.core.common.Rank;
import mineplex.core.common.util.UtilPlayer;
import mineplex.core.stats.StatsManager;
import mineplex.game.clans.clans.ClansPlayerStats;
import mineplex.game.clans.clans.pvptimer.PvpTimer;
public class cemde extends CommandBase<StatsManager>
{
PvpTimer _timer;
public cemde(StatsManager plugin, PvpTimer timer)
{
super(plugin, Rank.ALL, "rstime");
_timer = timer;
}
@Override
public void Execute(final Player caller, final String[] args)
{
Plugin.Get(caller).setStat(ClansPlayerStats.PLAY_TIME.id(), 0);
_timer.Get(caller).Skipped = false;
_timer.Get(caller).InformedTimes.clear();
UtilPlayer.message(caller, "Reset time.");
}
}

View File

@ -0,0 +1,217 @@
package mineplex.game.clans.clans.pvptimer;
import org.bukkit.Bukkit;
import org.bukkit.Sound;
import org.bukkit.entity.Player;
import org.bukkit.event.EventHandler;
import org.bukkit.event.EventPriority;
import org.bukkit.event.player.PlayerJoinEvent;
import mineplex.core.MiniClientPlugin;
import mineplex.core.common.util.C;
import mineplex.core.common.util.Callback;
import mineplex.core.common.util.F;
import mineplex.core.common.util.UtilPlayer;
import mineplex.core.common.util.UtilTextMiddle;
import mineplex.core.common.util.UtilTime;
import mineplex.core.stats.StatsManager;
import mineplex.core.task.TaskManager;
import mineplex.core.updater.UpdateType;
import mineplex.core.updater.event.UpdateEvent;
import mineplex.game.clans.clans.ClansManager;
import mineplex.game.clans.clans.playtime.Playtime;
import mineplex.game.clans.clans.playtime.command.cemde;
import mineplex.game.clans.clans.pvptimer.command.PvPTimerCommand;
import mineplex.minecraft.game.core.damage.CustomDamageEvent;
public class PvpTimer extends MiniClientPlugin<PvpTimerClient>
{
private Playtime _tracker;
public static final String SKIPPED_TASK = "PvpTimer.Skipped";
private static long TIMER_LENGTH = 30 * 60;
public PvpTimer(ClansManager clans, Playtime playtime, StatsManager statsManager)
{
super("PvP Timer", clans.getPlugin());
_tracker = playtime;
addCommand(new cemde(statsManager, this));
}
@Override
public void addCommands()
{
addCommand(new PvPTimerCommand(this));
}
public void disableFor(final Player caller)
{
TaskManager.Instance.completedTask(new Callback<Boolean>() {
@Override
public void run(Boolean data)
{
Get(caller).Skipped = true;
caller.playSound(caller.getLocation(), Sound.ENDERDRAGON_GROWL, 1f, 0.75f);
}
}, caller, "PvpTimer.Skipped");
}
@EventHandler
public void onPlayerJoin(PlayerJoinEvent event)
{
final Player player = event.getPlayer();
if (hasTimer(player))
{
Bukkit.getScheduler().scheduleSyncDelayedTask(getPlugin(), new Runnable() {
public void run()
{
UtilTextMiddle.display(C.cGold + "PvP Timer", "will end in " + UtilTime.MakeStr(getPvPTimerLeft(player) * 1000), 40, 70, 40, player);
}
}, 10);
UtilPlayer.message(player, F.main("Clans", "You are currently on your PvP timer. It will end in " + F.elem(UtilTime.MakeStr(getPvPTimerLeft(player) * 1000))));
UtilPlayer.message(player, F.main("Clans", "Until it ends, you are immune to, and unable to deal PvP damage."));
UtilPlayer.message(player, F.main("Clans", "If you would like to disable the PvP timer permanently, then type " + F.elem("/pvptimer") + ", and follow the instructions given."));
}
}
@EventHandler
public void inform(UpdateEvent event)
{
if (event.getType() == UpdateType.TWOSEC)
{
for (Player player : Bukkit.getOnlinePlayers())
{
if (hasTimer(player))
{
long time = getPvPTimerLeft(player);
PvpTimerClient client = Get(player);
// end
if (time <= 2)
{
UtilPlayer.message(player, F.main("Clans", "Your " + F.elem("Pvp Timer") + " has ended!"));
UtilPlayer.message(player, F.main("Clans", "You are now completely open to attacks, and you can also attack others."));
player.playSound(player.getLocation(), Sound.ENDERDRAGON_GROWL, 1f, 0.75f);
}
// 5 secs
else if (time <= 5 && !client.InformedTimes.contains(5))
{
UtilPlayer.message(player, F.main("Clans", "Your " + F.elem("Pvp Timer") + " will end in " + F.time("5.0 Seconds")));
UtilTextMiddle.display("Pvp Timer", "ending in 5 Seconds");
client.InformedTimes.add(5);
}
// 10 secs
else if (time <= 10 && !client.InformedTimes.contains(10))
{
UtilPlayer.message(player, F.main("Clans", "Your " + F.elem("Pvp Timer") + " will end in " + F.time("10.0 Seconds")));
UtilTextMiddle.display("Pvp Timer", "ending in 10 Seconds");
client.InformedTimes.add(10);
}
// 30 secs
else if (time <= 30 && !client.InformedTimes.contains(30))
{
UtilPlayer.message(player, F.main("Clans", "Your " + F.elem("Pvp Timer") + " will end in " + F.time("30.0 Seconds")));
UtilTextMiddle.display("Pvp Timer", "ending in 30 Seconds");
client.InformedTimes.add(30);
}
// 1 minute
else if (time <= 1 * 60 && !client.InformedTimes.contains(1 * 60))
{
UtilPlayer.message(player, F.main("Clans", "Your " + F.elem("Pvp Timer") + " will end in " + F.time("1.0 Minute")));
UtilTextMiddle.display("Pvp Timer", "ending in 1 Minute");
client.InformedTimes.add(5);
}
// 5 minutes
else if (time <= 5 * 60 && !client.InformedTimes.contains(5 * 60))
{
UtilPlayer.message(player, F.main("Clans", "Your " + F.elem("Pvp Timer") + " will end in " + F.time("5.0 Minutes")));
UtilTextMiddle.display("Pvp Timer", "ending in 5 Minutes");
client.InformedTimes.add(5 * 60);
}
// 10 minutes
else if (time <= 10 * 60 && !client.InformedTimes.contains(10 * 60))
{
UtilPlayer.message(player, F.main("Clans", "Your " + F.elem("Pvp Timer") + " will end in " + F.time("10.0 Minutes")));
UtilTextMiddle.display("Pvp Timer", "ending in 10 Minutes");
client.InformedTimes.add(10 * 60);
}
// 20 minutes
else if (time <= 20 * 60 && !client.InformedTimes.contains(20 * 60))
{
UtilPlayer.message(player, F.main("Clans", "Your " + F.elem("Pvp Timer") + " will end in " + F.time("20.0 Minutes")));
UtilTextMiddle.display("Pvp Timer", "ending in 20 Minutes");
client.InformedTimes.add(20 * 60);
}
}
}
}
}
@EventHandler(priority = EventPriority.LOWEST)
public void onPlayerAttack(CustomDamageEvent event)
{
if (event.GetDamageePlayer() == null || event.GetDamagerEntity(true) == null)
{
return;
}
Player victim = event.GetDamageePlayer();
Player damager = event.GetDamagerPlayer(true);
boolean victimTimer = victim != null && hasTimer(victim);
boolean damagerTimer = damager != null && hasTimer(damager);
boolean bothMsg = false;
if (victimTimer)
{
if (damagerTimer)
{
UtilPlayer.message(damager, F.main("Clans", "You and " + F.name(victim.getName()) + " are still on your PvP timer. Type " + F.elem("/pvptimer") + " to disable."));
bothMsg = true;
}
else if (damager != null)
{
UtilPlayer.message(damager, F.main("Clans", F.name(victim.getName()) + " is still on their Pvp timer."));
}
event.SetCancelled("Pvp Timer");
}
if (damagerTimer)
{
if (victimTimer)
{
if (!bothMsg) UtilPlayer.message(damager, F.main("Clans", "You and " + F.name(victim.getName()) + " are still on your PvP timer. Type " + F.elem("/pvptimer") + " to disable."));
}
else if (damager != null)
{
UtilPlayer.message(damager, F.main("Clans", "You are still on your PvP timer."));
}
event.SetCancelled("PvP Timer");
}
}
public long getPvPTimerLeft(Player player)
{
long time = (_tracker.getPlaytime(player) + _tracker.getUnsavedPlaytime(player));
return (TIMER_LENGTH <= time ? 0 : TIMER_LENGTH - time);
}
private boolean hasTimer(Player victim)
{
return victim != null && getPvPTimerLeft(victim) > 0 && !Get(victim).Skipped;
}
@Override
protected PvpTimerClient AddPlayer(String player)
{
return new PvpTimerClient(Bukkit.getPlayer(player));
}
}

View File

@ -0,0 +1,20 @@
package mineplex.game.clans.clans.pvptimer;
import java.util.ArrayList;
import java.util.List;
import org.bukkit.entity.Player;
import mineplex.core.task.TaskManager;
public class PvpTimerClient
{
public boolean Skipped;
public List<Integer> InformedTimes;
public PvpTimerClient(Player player)
{
Skipped = TaskManager.Instance.hasCompletedTask(player, PvpTimer.SKIPPED_TASK);
InformedTimes = new ArrayList<>();
}
}

View File

@ -0,0 +1,61 @@
package mineplex.game.clans.clans.pvptimer.command;
import org.bukkit.entity.Player;
import mineplex.core.command.CommandBase;
import mineplex.core.common.Rank;
import mineplex.core.common.jsonchat.ClickEvent;
import mineplex.core.common.jsonchat.JsonMessage;
import mineplex.core.common.util.F;
import mineplex.core.common.util.UtilPlayer;
import mineplex.core.common.util.UtilTime;
import mineplex.game.clans.clans.pvptimer.PvpTimer;
public class PvPTimerCommand extends CommandBase<PvpTimer>
{
public PvPTimerCommand(PvpTimer plugin)
{
super(plugin, Rank.ALL, "pvptimer", "timer", "pvp");
}
@Override
public void Execute(Player caller, String[] args)
{
if (args.length == 0)
{
if (Plugin.Get(caller).Skipped)
{
UtilPlayer.message(caller, F.main("Clans", "You have skipped your PvP timer."));
return;
}
long pvpTimerLeft = Plugin.getPvPTimerLeft(caller);
if (pvpTimerLeft == 0)
{
UtilPlayer.message(caller, F.main("Clans", "Your PvP timer has ended."));
}
else
{
UtilPlayer.message(caller, F.main("Clans", "You have " + F.elem(UtilTime.MakeStr(pvpTimerLeft * 1000)) + " before your PvP timer runs out."));
new JsonMessage(F.main("Clans", "If you would like to permanently disable Pvp timer, click "))
.extra("here")
.color("green")
.click(ClickEvent.RUN_COMMAND, "/pvptimer yesiconfirmthatiwouldliketodisablemypvptimerforever")
.extra(".")
.color("gray")
.sendToPlayer(caller);
}
}
else
{
if (args[0].equalsIgnoreCase("yesiconfirmthatiwouldliketodisablemypvptimerforever"))
{
Plugin.disableFor(caller);
UtilPlayer.message(caller, F.main("Clans", "You have disabled your Pvp timer."));
}
}
}
}

View File

@ -1,10 +1,13 @@
package mineplex.game.clans.clans.scoreboard; package mineplex.game.clans.clans.scoreboard;
import org.bukkit.Bukkit;
import org.bukkit.entity.Player; import org.bukkit.entity.Player;
import org.bukkit.event.EventHandler; import org.bukkit.event.EventHandler;
import org.bukkit.event.player.PlayerGameModeChangeEvent;
import org.bukkit.plugin.java.JavaPlugin; import org.bukkit.plugin.java.JavaPlugin;
import mineplex.core.account.CoreClientManager; import mineplex.core.account.CoreClientManager;
import mineplex.core.account.event.OnlineRankUpdateEvent;
import mineplex.core.common.util.C; import mineplex.core.common.util.C;
import mineplex.core.donation.DonationManager; import mineplex.core.donation.DonationManager;
import mineplex.core.scoreboard.PlayerScoreboard; import mineplex.core.scoreboard.PlayerScoreboard;
@ -29,7 +32,7 @@ public class ClansScoreboardManager extends ScoreboardManager
private WarManager _warManager; private WarManager _warManager;
private WorldEventManager _worldEvent; private WorldEventManager _worldEvent;
public ClansScoreboardManager(JavaPlugin plugin, TutorialManager tutorialManager, ClansManager clansManager, WarManager warManager, WorldEventManager worldEvent, CoreClientManager clientManager, DonationManager donationManager) public ClansScoreboardManager(JavaPlugin plugin, ClansManager clansManager, WarManager warManager, WorldEventManager worldEvent, CoreClientManager clientManager, DonationManager donationManager)
{ {
super(plugin, clientManager, donationManager); super(plugin, clientManager, donationManager);
@ -37,10 +40,10 @@ public class ClansScoreboardManager extends ScoreboardManager
_warManager = warManager; _warManager = warManager;
_worldEvent = worldEvent; _worldEvent = worldEvent;
init(tutorialManager); init();
} }
private void init(TutorialManager tutorialManager) private void init()
{ {
setTitle("Clans Alpha " + Clans.VERSION); setTitle("Clans Alpha " + Clans.VERSION);
@ -53,12 +56,40 @@ public class ClansScoreboardManager extends ScoreboardManager
data.writeElement(_warManager); data.writeElement(_warManager);
data.writeElement(_worldEvent); data.writeElement(_worldEvent);
for (Tutorial tutorial : tutorialManager.getTutorials().values()) for (Tutorial tutorial : TutorialManager.Instance.getTutorials().values())
{ {
data.writeElement(tutorial); data.writeElement(tutorial);
} }
} }
@EventHandler
public void onGamemodeChanged(PlayerGameModeChangeEvent event)
{
Bukkit.getScheduler().scheduleSyncDelayedTask(_clansManager.getPlugin(), new Runnable() {
public void run()
{
for (Player player : Bukkit.getOnlinePlayers())
{
refresh(player);
}
}
}, 20);
}
@EventHandler
public void onRankUpdate(OnlineRankUpdateEvent event)
{
Bukkit.getScheduler().scheduleSyncDelayedTask(_clansManager.getPlugin(), new Runnable() {
public void run()
{
for (Player player : Bukkit.getOnlinePlayers())
{
refresh(player);
}
}
}, 20);
}
@EventHandler @EventHandler
public void drawUpdate(UpdateEvent event) public void drawUpdate(UpdateEvent event)
{ {

View File

@ -39,7 +39,6 @@ import org.bukkit.event.player.PlayerFishEvent;
import org.bukkit.event.player.PlayerFishEvent.State; import org.bukkit.event.player.PlayerFishEvent.State;
import org.bukkit.event.player.PlayerInteractEntityEvent; import org.bukkit.event.player.PlayerInteractEntityEvent;
import org.bukkit.event.player.PlayerInteractEvent; import org.bukkit.event.player.PlayerInteractEvent;
import org.bukkit.event.weather.WeatherChangeEvent;
import org.bukkit.inventory.ItemStack; import org.bukkit.inventory.ItemStack;
import org.bukkit.inventory.meta.ItemMeta; import org.bukkit.inventory.meta.ItemMeta;
import org.bukkit.plugin.java.JavaPlugin; import org.bukkit.plugin.java.JavaPlugin;
@ -47,7 +46,6 @@ import org.bukkit.plugin.java.JavaPlugin;
import mineplex.core.MiniPlugin; import mineplex.core.MiniPlugin;
import mineplex.core.blockrestore.BlockRestore; import mineplex.core.blockrestore.BlockRestore;
import mineplex.core.common.util.F; import mineplex.core.common.util.F;
import mineplex.core.common.util.UtilBlock;
import mineplex.core.common.util.UtilEvent; import mineplex.core.common.util.UtilEvent;
import mineplex.core.common.util.UtilEvent.ActionType; import mineplex.core.common.util.UtilEvent.ActionType;
import mineplex.core.common.util.UtilGear; import mineplex.core.common.util.UtilGear;
@ -94,14 +92,14 @@ public class Gameplay extends MiniPlugin
Bukkit.getPluginManager().registerEvents(new CustomCreatures(), plugin); Bukkit.getPluginManager().registerEvents(new CustomCreatures(), plugin);
} }
@EventHandler(priority = EventPriority.LOWEST) // @EventHandler(priority = EventPriority.LOWEST)
public void spawnDamage(CustomDamageEvent event) // public void spawnDamage(CustomDamageEvent event)
{ // {
if (_clansManager.getClanUtility().getClaim(event.GetDamageeEntity().getLocation()) != null && _clansManager.getClanUtility().getClaim(event.GetDamageeEntity().getLocation()).isSafe(event.GetDamageeEntity().getLocation())) // if (_clansManager.getClanUtility().getClaim(event.GetDamageeEntity().getLocation()) != null && _clansManager.getClanUtility().getClaim(event.GetDamageeEntity().getLocation()).isSafe(event.GetDamageeEntity().getLocation()))
{ // {
event.SetCancelled("Safe Zone"); // event.SetCancelled("Safe Zone");
} // }
} // }
@EventHandler @EventHandler
public void onPlayerFishing(PlayerFishEvent event) public void onPlayerFishing(PlayerFishEvent event)
@ -436,6 +434,11 @@ public class Gameplay extends MiniPlugin
{ {
final Block block = event.getBlock(); final Block block = event.getBlock();
if (_clansManager.getClanUtility().isSafe(block.getLocation()))
{
return;
}
if (!UtilItem.isLog(block.getType())) if (!UtilItem.isLog(block.getType()))
{ {
return; return;

View File

@ -16,23 +16,24 @@ import org.bukkit.entity.LivingEntity;
import org.bukkit.entity.Monster; import org.bukkit.entity.Monster;
import org.bukkit.entity.Player; import org.bukkit.entity.Player;
import org.bukkit.event.EventHandler; import org.bukkit.event.EventHandler;
import org.bukkit.event.EventPriority;
import org.bukkit.event.block.BlockBreakEvent; import org.bukkit.event.block.BlockBreakEvent;
import org.bukkit.event.block.BlockBurnEvent; import org.bukkit.event.block.BlockBurnEvent;
import org.bukkit.event.block.BlockFromToEvent; import org.bukkit.event.block.BlockFromToEvent;
import org.bukkit.event.block.BlockIgniteEvent; import org.bukkit.event.block.BlockIgniteEvent;
import org.bukkit.event.block.BlockIgniteEvent.IgniteCause; import org.bukkit.event.block.BlockIgniteEvent.IgniteCause;
import org.bukkit.event.entity.CreatureSpawnEvent; import org.bukkit.event.entity.CreatureSpawnEvent;
import org.bukkit.event.entity.EntityDamageByEntityEvent;
import org.bukkit.event.entity.EntityDamageEvent; import org.bukkit.event.entity.EntityDamageEvent;
import org.bukkit.event.entity.EntityDeathEvent; import org.bukkit.event.entity.EntityDeathEvent;
import org.bukkit.event.entity.EntitySpawnEvent;
import org.bukkit.event.entity.EntityTargetEvent; import org.bukkit.event.entity.EntityTargetEvent;
import org.bukkit.event.hanging.HangingBreakByEntityEvent; import org.bukkit.event.hanging.HangingBreakByEntityEvent;
import org.bukkit.event.player.PlayerJoinEvent; import org.bukkit.event.player.PlayerJoinEvent;
import org.bukkit.event.player.PlayerRespawnEvent; import org.bukkit.event.player.PlayerRespawnEvent;
import org.bukkit.event.player.PlayerVelocityEvent;
import org.bukkit.plugin.java.JavaPlugin; import org.bukkit.plugin.java.JavaPlugin;
import mineplex.core.MiniPlugin; import mineplex.core.MiniPlugin;
import mineplex.core.common.Rank;
import mineplex.core.common.util.F; import mineplex.core.common.util.F;
import mineplex.core.common.util.UtilParticle; import mineplex.core.common.util.UtilParticle;
import mineplex.core.common.util.UtilPlayer; import mineplex.core.common.util.UtilPlayer;
@ -45,7 +46,6 @@ import mineplex.core.updater.event.UpdateEvent;
import mineplex.game.clans.clans.ClansManager; import mineplex.game.clans.clans.ClansManager;
import mineplex.game.clans.items.generation.WeightSet; import mineplex.game.clans.items.generation.WeightSet;
import mineplex.minecraft.game.classcombat.Skill.event.SkillTriggerEvent; import mineplex.minecraft.game.classcombat.Skill.event.SkillTriggerEvent;
import mineplex.minecraft.game.classcombat.item.event.ItemTriggerEvent;
import mineplex.minecraft.game.classcombat.item.event.WebTossEvent; import mineplex.minecraft.game.classcombat.item.event.WebTossEvent;
import mineplex.minecraft.game.core.condition.Condition.ConditionType; import mineplex.minecraft.game.core.condition.Condition.ConditionType;
import mineplex.minecraft.game.core.damage.CustomDamageEvent; import mineplex.minecraft.game.core.damage.CustomDamageEvent;
@ -102,7 +102,7 @@ public class Spawn extends MiniPlugin
{ {
Block block = event.getToBlock(); Block block = event.getToBlock();
if (block.isLiquid() && isInSpawn(block.getLocation())) if (block.isLiquid() && isSafe(block.getLocation()))
{ {
event.setCancelled(true); event.setCancelled(true);
} }
@ -115,7 +115,7 @@ public class Spawn extends MiniPlugin
@EventHandler @EventHandler
public void onWebToss(WebTossEvent event) public void onWebToss(WebTossEvent event)
{ {
if (isInSpawn(event.getLocation())) if (isSafe(event.getLocation()))
{ {
event.setCancelled(true); event.setCancelled(true);
} }
@ -138,7 +138,7 @@ public class Spawn extends MiniPlugin
@EventHandler @EventHandler
public void onBlockBurn(BlockBurnEvent event) public void onBlockBurn(BlockBurnEvent event)
{ {
if (isInSpawn(event.getBlock().getLocation())) if (isSafe(event.getBlock().getLocation()))
{ {
event.setCancelled(true); event.setCancelled(true);
} }
@ -153,7 +153,7 @@ public class Spawn extends MiniPlugin
{ {
if (event.getEntity() instanceof ItemFrame) if (event.getEntity() instanceof ItemFrame)
{ {
if (isInSpawn(event.getEntity().getLocation())) if (isSafe(event.getEntity().getLocation()))
{ {
event.setCancelled(true); event.setCancelled(true);
} }
@ -165,7 +165,7 @@ public class Spawn extends MiniPlugin
{ {
if (event.GetDamageeEntity() instanceof ItemFrame) if (event.GetDamageeEntity() instanceof ItemFrame)
{ {
if (isInSpawn(event.GetDamageeEntity().getLocation())) if (isSafe(event.GetDamageeEntity().getLocation()))
{ {
event.SetCancelled("Item Frame Cancel"); event.SetCancelled("Item Frame Cancel");
} }
@ -177,7 +177,7 @@ public class Spawn extends MiniPlugin
{ {
if (event.getEntity() instanceof ItemFrame) if (event.getEntity() instanceof ItemFrame)
{ {
if (isInSpawn(event.getEntity().getLocation())) if (isSafe(event.getEntity().getLocation()))
{ {
event.setCancelled(true); event.setCancelled(true);
} }
@ -192,9 +192,9 @@ public class Spawn extends MiniPlugin
for (Player cur : UtilServer.getPlayers()) for (Player cur : UtilServer.getPlayers())
{ {
if (isInSpawn(cur.getLocation())) if (isSafe(cur.getLocation()))
{ {
long lastDamager = _clansManager.getCombatManager().Get(cur).GetLastCombat(); long lastDamager = _clansManager.getCombatManager().Get(cur).GetLastCombatEngaged();
long duration = System.currentTimeMillis() - lastDamager; long duration = System.currentTimeMillis() - lastDamager;
if (!UtilTime.elapsed(lastDamager, COMBAT_TAG_DURATION)) if (!UtilTime.elapsed(lastDamager, COMBAT_TAG_DURATION))
@ -203,7 +203,7 @@ public class Spawn extends MiniPlugin
+ ChatColor.YELLOW + F.time(UtilTime.convertString(COMBAT_TAG_DURATION - duration, 1, TimeUnit.FIT)); + ChatColor.YELLOW + F.time(UtilTime.convertString(COMBAT_TAG_DURATION - duration, 1, TimeUnit.FIT));
UtilTextMiddle.display(null, message, 0, 20, 0, cur); UtilTextMiddle.display(null, message, 0, 20, 0, cur);
_clansManager.getCondition().Factory().Custom(COMBAT_TAG_NAME, cur, cur, ConditionType.CUSTOM, 1, 0, false, Material.FIRE, (byte)0, true); _clansManager.getCondition().Factory().Custom(COMBAT_TAG_NAME, cur, cur, ConditionType.CUSTOM, 1.d, 0, false, Material.FIRE, (byte)0, true);
playUnsafeParticles(cur); playUnsafeParticles(cur);
} }
else if (!UtilTime.elapsed(lastDamager, COMBAT_TAG_DURATION + 600)) else if (!UtilTime.elapsed(lastDamager, COMBAT_TAG_DURATION + 600))
@ -214,6 +214,25 @@ public class Spawn extends MiniPlugin
} }
} }
@EventHandler
public void ignoreVelocity(PlayerVelocityEvent event)
{
if (_clansManager.getClanUtility().isSafe(event.getPlayer()))
{
event.setCancelled(true);
System.out.println("cancelled");
}
}
@EventHandler
public void onSkill(SkillTriggerEvent event)
{
if (!isSafe(event.GetPlayer().getLocation()))
{
_clansManager.getCombatManager().Get(event.GetPlayer()).SetLastCombatEngaged(System.currentTimeMillis());
}
}
private void playUnsafeParticles(Player player) private void playUnsafeParticles(Player player)
{ {
UtilParticle.PlayParticle(UtilParticle.ParticleType.CRIT, player.getEyeLocation().add(0, 0.75d, 0), 0, 0, 0, 0.2f, 35, UtilParticle.ViewDist.NORMAL); UtilParticle.PlayParticle(UtilParticle.ParticleType.CRIT, player.getEyeLocation().add(0, 0.75d, 0), 0, 0, 0, 0.2f, 35, UtilParticle.ViewDist.NORMAL);
@ -283,7 +302,7 @@ public class Spawn extends MiniPlugin
@EventHandler @EventHandler
public void onEntitySpawn(CreatureSpawnEvent event) public void onEntitySpawn(CreatureSpawnEvent event)
{ {
if (event.getSpawnReason() != CreatureSpawnEvent.SpawnReason.CUSTOM && isInSpawn(event.getLocation())) if (event.getSpawnReason() != CreatureSpawnEvent.SpawnReason.CUSTOM && isSafe(event.getLocation()))
{ {
event.setCancelled(true); event.setCancelled(true);
} }
@ -325,7 +344,7 @@ public class Spawn extends MiniPlugin
if (isInSpawn(monster)) if (isInSpawn(monster))
{ {
int size = event.getDrops().size(); // int size = event.getDrops().size();
event.getDrops().clear(); event.getDrops().clear();
} }
} }
@ -338,7 +357,7 @@ public class Spawn extends MiniPlugin
@EventHandler @EventHandler
public void onEntityTarget(EntityTargetEvent event) public void onEntityTarget(EntityTargetEvent event)
{ {
if (event.getTarget() != null && isInSpawn(event.getTarget().getLocation())) if (event.getTarget() != null && isSafe(event.getTarget().getLocation()))
{ {
event.setCancelled(true); event.setCancelled(true);
} }
@ -353,7 +372,7 @@ public class Spawn extends MiniPlugin
{ {
if (event.getPlayer().getGameMode() == GameMode.CREATIVE) return; if (event.getPlayer().getGameMode() == GameMode.CREATIVE) return;
if (isInSpawn(event.getBlock().getLocation()) || isInSpawn(event.getPlayer())) if (isSafe(event.getBlock().getLocation()) || isInSpawn(event.getPlayer()))
{ {
event.setCancelled(true); event.setCancelled(true);
} }
@ -366,22 +385,37 @@ public class Spawn extends MiniPlugin
@EventHandler @EventHandler
public void onPlayerAttack(CustomDamageEvent event) public void onPlayerAttack(CustomDamageEvent event)
{ {
Player defender = event.GetDamageePlayer(); Player victim = event.GetDamageePlayer();
Player attacker = event.GetDamagerPlayer(true); // Get (potentially ranged) attacker Player attacker = event.GetDamagerPlayer(true); // Get (potentially ranged) attacker
if (defender != null && !isCombatTagged(defender)) // wat
if (victim == null)
{ {
if (isInSpawn(defender)) return;
}
if (attacker == null)
{
return;
}
if (!isCombatTagged(victim))
{
if (isInSpawn(victim))
{ {
event.SetCancelled("Safe Zone"); event.SetCancelled("Safe Zone");
attemptNotify(attacker, "You cannot attack players who are in spawn!"); attemptNotify(attacker, "You cannot attack players who are in spawn!");
return;
} }
else if (isInSpawn(attacker)) else if (isInSpawn(attacker) && !isCombatTagged(attacker))
{ {
event.SetCancelled("Safe Zone"); event.SetCancelled("Safe Zone");
attemptNotify(attacker, "You cannot attack untagged players while in spawn!"); attemptNotify(attacker, "You cannot attack untagged players while in spawn!");
} return;
}
} }
System.out.println(event.GetCancellers());
} }
public Location getSpawnLocation() public Location getSpawnLocation()
@ -401,7 +435,7 @@ public class Spawn extends MiniPlugin
return _shops.elements(); return _shops.elements();
} }
public boolean isInSpawn(Location location) public boolean isSafe(Location location)
{ {
return _clansManager.getClanUtility().isSafe(location); // Check to see if location is in a SafeZone chunk return _clansManager.getClanUtility().isSafe(location); // Check to see if location is in a SafeZone chunk
} }
@ -414,9 +448,10 @@ public class Spawn extends MiniPlugin
return xOffset <= radius && zOffset <= radius; return xOffset <= radius && zOffset <= radius;
} }
// this is basically just isSafe();
public boolean isInSpawn(Entity entity) public boolean isInSpawn(Entity entity)
{ {
return entity != null && isInSpawn(entity.getLocation()); return entity != null && isSafe(entity.getLocation());
} }
public static World getSpawnWorld() public static World getSpawnWorld()

View File

@ -46,6 +46,7 @@ import mineplex.core.updater.event.UpdateEvent;
import mineplex.game.clans.clans.ClansManager; import mineplex.game.clans.clans.ClansManager;
import mineplex.game.clans.clans.event.ClanJoinEvent; import mineplex.game.clans.clans.event.ClanJoinEvent;
import mineplex.game.clans.clans.event.ClanTipEvent; import mineplex.game.clans.clans.event.ClanTipEvent;
import mineplex.game.clans.clans.playtime.Playtime;
import mineplex.game.clans.economy.GoldManager; import mineplex.game.clans.economy.GoldManager;
import net.minecraft.server.v1_8_R3.PacketPlayOutChat; import net.minecraft.server.v1_8_R3.PacketPlayOutChat;
@ -89,7 +90,9 @@ public abstract class Tutorial implements ScoreboardElement, Listener
protected int _gemReward = -1; protected int _gemReward = -1;
protected int _coinReward = -1; protected int _coinReward = -1;
public Tutorial(final GoldManager goldManager, final TaskManager taskManager, final ClansManager clansManager, final DonationManager donationManager, final TutorialManager manager, final PacketHandler packetHandler) protected Playtime _playtime;
public Tutorial(final GoldManager goldManager, final Playtime playtime, final TaskManager taskManager, final ClansManager clansManager, final DonationManager donationManager, final TutorialManager manager, final PacketHandler packetHandler)
{ {
_clansManager = clansManager; _clansManager = clansManager;
_goldManager = goldManager; _goldManager = goldManager;
@ -99,6 +102,7 @@ public abstract class Tutorial implements ScoreboardElement, Listener
_tasks = new ArrayList<TutorialTask<?>>(); _tasks = new ArrayList<TutorialTask<?>>();
_inTutorial = new LinkedHashMap<>(); _inTutorial = new LinkedHashMap<>();
_nameToTask = new LinkedHashMap<>(); _nameToTask = new LinkedHashMap<>();
_playtime = playtime;
_manager.getPluginManager().registerEvents(this, _manager.getPlugin()); _manager.getPluginManager().registerEvents(this, _manager.getPlugin());
} }
@ -499,6 +503,12 @@ public abstract class Tutorial implements ScoreboardElement, Listener
{ {
public void run(Boolean data) public void run(Boolean data)
{ {
if (_playtime.Get(player).FirstSession)
{
_playtime.Get(player).StartTime = System.currentTimeMillis();
_playtime.Get(player).FirstSession = false;
}
cancelFor(player); cancelFor(player);
} }
}, player, String.format(SKIPPED_TASK, _technicalName)); }, player, String.format(SKIPPED_TASK, _technicalName));

View File

@ -11,7 +11,6 @@ import org.bukkit.plugin.java.JavaPlugin;
import mineplex.core.MiniPlugin; import mineplex.core.MiniPlugin;
import mineplex.core.common.util.F; import mineplex.core.common.util.F;
import mineplex.core.common.util.UtilPlayer;
import mineplex.core.donation.DonationManager; import mineplex.core.donation.DonationManager;
import mineplex.core.packethandler.IPacketHandler; import mineplex.core.packethandler.IPacketHandler;
import mineplex.core.packethandler.PacketHandler; import mineplex.core.packethandler.PacketHandler;
@ -20,12 +19,12 @@ import mineplex.core.preferences.PreferencesManager;
import mineplex.core.task.TaskManager; import mineplex.core.task.TaskManager;
import mineplex.game.clans.clans.ClansManager; import mineplex.game.clans.clans.ClansManager;
import mineplex.game.clans.clans.commands.RestartTutCommand; import mineplex.game.clans.clans.commands.RestartTutCommand;
import mineplex.game.clans.clans.playtime.Playtime;
import mineplex.game.clans.economy.GoldManager; import mineplex.game.clans.economy.GoldManager;
import mineplex.game.clans.tutorials.commands.DoSkipTutorialCommand; import mineplex.game.clans.tutorials.commands.DoSkipTutorialCommand;
import mineplex.game.clans.tutorials.commands.SkipTutorialCommand; import mineplex.game.clans.tutorials.commands.SkipTutorialCommand;
import mineplex.game.clans.tutorials.gettingstarted.TutorialGettingStarted; import mineplex.game.clans.tutorials.gettingstarted.TutorialGettingStarted;
import net.md_5.bungee.api.ChatColor; import net.md_5.bungee.api.ChatColor;
import net.minecraft.server.v1_8_R3.IChatBaseComponent;
import net.minecraft.server.v1_8_R3.PacketPlayOutChat; import net.minecraft.server.v1_8_R3.PacketPlayOutChat;
public class TutorialManager extends MiniPlugin public class TutorialManager extends MiniPlugin
@ -37,7 +36,7 @@ public class TutorialManager extends MiniPlugin
private final TaskManager _taskManager; private final TaskManager _taskManager;
public TutorialManager(final JavaPlugin plugin, final GoldManager goldManager, final TaskManager taskManager, final DonationManager donationManager, final PreferencesManager preferencesManager, final ClansManager clansManager, final PacketHandler packetHandler) public TutorialManager(final JavaPlugin plugin, final Playtime playtime, final GoldManager goldManager, final TaskManager taskManager, final DonationManager donationManager, final PreferencesManager preferencesManager, final ClansManager clansManager, final PacketHandler packetHandler)
{ {
super("Tutorials", plugin); super("Tutorials", plugin);
@ -45,7 +44,7 @@ public class TutorialManager extends MiniPlugin
_taskManager = taskManager; _taskManager = taskManager;
_tutorials.put(TutorialGettingStarted.class, new TutorialGettingStarted(this, clansManager, donationManager, goldManager, taskManager, packetHandler)); // _tutorials.put(TutorialGettingStarted.class, new TutorialGettingStarted(this, playtime, clansManager, donationManager, goldManager, taskManager, packetHandler));
packetHandler.addPacketHandler(new IPacketHandler() { packetHandler.addPacketHandler(new IPacketHandler() {
public void handle(PacketInfo packet) public void handle(PacketInfo packet)

View File

@ -12,6 +12,7 @@ import mineplex.core.task.TaskManager;
import mineplex.core.updater.UpdateType; import mineplex.core.updater.UpdateType;
import mineplex.core.updater.event.UpdateEvent; import mineplex.core.updater.event.UpdateEvent;
import mineplex.game.clans.clans.ClansManager; import mineplex.game.clans.clans.ClansManager;
import mineplex.game.clans.clans.playtime.Playtime;
import mineplex.game.clans.economy.GoldManager; import mineplex.game.clans.economy.GoldManager;
import mineplex.game.clans.spawn.Spawn; import mineplex.game.clans.spawn.Spawn;
import mineplex.game.clans.tutorials.Tutorial; import mineplex.game.clans.tutorials.Tutorial;
@ -19,9 +20,9 @@ import mineplex.game.clans.tutorials.TutorialManager;
public class TutorialGettingStarted extends Tutorial public class TutorialGettingStarted extends Tutorial
{ {
public TutorialGettingStarted(final TutorialManager manager, final ClansManager clansManager, final DonationManager donationManager, final GoldManager goldManager, final TaskManager taskManager, final PacketHandler packetHandler) public TutorialGettingStarted(final TutorialManager manager, final Playtime playtime, final ClansManager clansManager, final DonationManager donationManager, final GoldManager goldManager, final TaskManager taskManager, final PacketHandler packetHandler)
{ {
super(goldManager, taskManager, clansManager, donationManager, manager, packetHandler); super(goldManager, playtime, taskManager, clansManager, donationManager, manager, packetHandler);
// addTask(new TaskWelcome(this, 1)); // addTask(new TaskWelcome(this, 1));
@ -52,8 +53,14 @@ public class TutorialGettingStarted extends Tutorial
{ {
player.resetPlayerTime(); player.resetPlayerTime();
player.teleport(Spawn.getEastSpawn()); player.teleport(Spawn.getEastSpawn());
if (_playtime.Get(player).FirstSession)
{
_playtime.Get(player).StartTime = System.currentTimeMillis();
_playtime.Get(player).FirstSession = false;
}
} }
@Override @Override
protected void onFinishedDelay(Player player) protected void onFinishedDelay(Player player)
{ {

View File

@ -28,6 +28,7 @@ public class CombatLog
protected CombatComponent LastDamager; protected CombatComponent LastDamager;
protected long _lastDamaged; protected long _lastDamaged;
protected long _lastCombat; protected long _lastCombat;
protected long _lastCombatEngaged;
public CombatLog(Player player, long expireTime) public CombatLog(Player player, long expireTime)
{ {
@ -185,6 +186,16 @@ public class CombatLog
return _lastCombat; return _lastCombat;
} }
public long GetLastCombatEngaged()
{
return _lastCombatEngaged;
}
public void SetLastCombatEngaged(long time)
{
_lastCombatEngaged = time;
}
public void SetLastCombat(long time) public void SetLastCombat(long time)
{ {
_lastCombat = time; _lastCombat = time;

View File

@ -3,8 +3,6 @@ package mineplex.minecraft.game.core.combat;
import java.util.HashSet; import java.util.HashSet;
import java.util.Iterator; import java.util.Iterator;
import net.minecraft.server.v1_8_R3.ItemStack;
import org.bukkit.craftbukkit.v1_8_R3.inventory.CraftItemStack; import org.bukkit.craftbukkit.v1_8_R3.inventory.CraftItemStack;
import org.bukkit.entity.Arrow; import org.bukkit.entity.Arrow;
import org.bukkit.entity.Fireball; import org.bukkit.entity.Fireball;
@ -18,8 +16,6 @@ import org.bukkit.event.entity.PlayerDeathEvent;
import org.bukkit.plugin.java.JavaPlugin; import org.bukkit.plugin.java.JavaPlugin;
import mineplex.core.MiniPlugin; import mineplex.core.MiniPlugin;
import mineplex.core.updater.event.UpdateEvent;
import mineplex.core.updater.UpdateType;
import mineplex.core.account.event.ClientUnloadEvent; import mineplex.core.account.event.ClientUnloadEvent;
import mineplex.core.common.util.C; import mineplex.core.common.util.C;
import mineplex.core.common.util.F; import mineplex.core.common.util.F;
@ -30,9 +26,12 @@ import mineplex.core.common.util.UtilPlayer;
import mineplex.core.common.util.UtilServer; import mineplex.core.common.util.UtilServer;
import mineplex.core.common.util.UtilTime; import mineplex.core.common.util.UtilTime;
import mineplex.core.itemstack.ItemStackFactory; import mineplex.core.itemstack.ItemStackFactory;
import mineplex.core.updater.UpdateType;
import mineplex.core.updater.event.UpdateEvent;
import mineplex.minecraft.game.core.combat.event.ClearCombatEvent; import mineplex.minecraft.game.core.combat.event.ClearCombatEvent;
import mineplex.minecraft.game.core.combat.event.CombatDeathEvent; import mineplex.minecraft.game.core.combat.event.CombatDeathEvent;
import mineplex.minecraft.game.core.damage.CustomDamageEvent; import mineplex.minecraft.game.core.damage.CustomDamageEvent;
import net.minecraft.server.v1_8_R3.ItemStack;
public class CombatManager extends MiniPlugin public class CombatManager extends MiniPlugin
{ {
@ -201,7 +200,7 @@ public class CombatManager extends MiniPlugin
// Not Player > No Log // Not Player > No Log
if (event.GetDamageePlayer() == null) if (event.GetDamageePlayer() == null)
return; return;
// Damager is ENTITY // Damager is ENTITY
if (event.GetDamagerEntity(true) != null) if (event.GetDamagerEntity(true) != null)
{ {
@ -256,8 +255,12 @@ public class CombatManager extends MiniPlugin
} }
if (event.GetDamagerEntity(true) instanceof Player) if (event.GetDamagerEntity(true) instanceof Player)
{
Get((Player)event.GetDamagerEntity(true)).SetLastCombat(System.currentTimeMillis()); Get((Player)event.GetDamagerEntity(true)).SetLastCombat(System.currentTimeMillis());
Get((Player)event.GetDamagerEntity(true)).SetLastCombatEngaged(System.currentTimeMillis());
Get(event.GetDamageePlayer()).SetLastCombatEngaged(System.currentTimeMillis());
}
Get(event.GetDamageePlayer()).Attacked( Get(event.GetDamageePlayer()).Attacked(
UtilEnt.getName(event.GetDamagerEntity(true)), UtilEnt.getName(event.GetDamagerEntity(true)),
(int) event.GetDamage(), event.GetDamagerEntity(true), (int) event.GetDamage(), event.GetDamagerEntity(true),

View File

@ -469,6 +469,9 @@ public class Christmas extends SoloGame
{ {
if (Manager.IsRewardItems()) if (Manager.IsRewardItems())
{ {
if (!player.isOnline())
continue;
if (Manager.GetTaskManager().hasCompletedTask(player, "CC Reward 2015")) if (Manager.GetTaskManager().hasCompletedTask(player, "CC Reward 2015"))
{ {
SetCustomWinMessage(player, "You already earned your reward"); SetCustomWinMessage(player, "You already earned your reward");