Merge remote-tracking branch 'remotes/origin/clans/alpha' into develop
This commit is contained in:
commit
607c164753
@ -21,7 +21,14 @@ public class PlayerStats
|
||||
|
||||
return _statHash.get(statName);
|
||||
}
|
||||
|
||||
|
||||
public long setStat(String statName, long value)
|
||||
{
|
||||
_statHash.put(statName, value);
|
||||
|
||||
return _statHash.get(statName);
|
||||
}
|
||||
|
||||
public long getStat(String statName)
|
||||
{
|
||||
return _statHash.containsKey(statName) ? _statHash.get(statName) : 0L;
|
||||
|
@ -14,6 +14,7 @@ import mineplex.core.database.RepositoryBase;
|
||||
import mineplex.core.database.ResultSetCallable;
|
||||
import mineplex.core.database.column.ColumnVarChar;
|
||||
import mineplex.database.Tables;
|
||||
import net.md_5.bungee.chat.TranslatableComponentSerializer;
|
||||
|
||||
import org.jooq.DSLContext;
|
||||
import org.jooq.Insert;
|
||||
@ -134,8 +135,9 @@ public class StatsRepository extends RepositoryBase
|
||||
.on(Tables.stats.id.eq(Tables.accountStat.statId))
|
||||
.where(Tables.accountStat.accountId.eq(DSL.select(Tables.accounts.id)
|
||||
.from(Tables.accounts)
|
||||
.where(Tables.accounts.name.eq(playerName)))
|
||||
).fetch();
|
||||
.where(Tables.accounts.name.eq(playerName)).limit(1))
|
||||
)
|
||||
.fetch();
|
||||
|
||||
|
||||
if (result.isNotEmpty())
|
||||
|
@ -49,7 +49,7 @@ import net.minecraft.server.v1_8_R3.MinecraftServer;
|
||||
|
||||
public class Clans extends JavaPlugin
|
||||
{
|
||||
public static final String VERSION = "0.17b";
|
||||
public static final String VERSION = "0.17d";
|
||||
private String WEB_CONFIG = "webServer";
|
||||
|
||||
// Modules
|
||||
|
@ -10,7 +10,6 @@ import java.util.TimeZone;
|
||||
import java.util.UUID;
|
||||
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.GameMode;
|
||||
import org.bukkit.Location;
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.entity.Player;
|
||||
@ -66,7 +65,6 @@ import mineplex.core.updater.UpdateType;
|
||||
import mineplex.core.updater.event.UpdateEvent;
|
||||
import mineplex.game.clans.clans.ClanTips.TipType;
|
||||
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.ClansAllyChatCommand;
|
||||
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.map.ItemMapManager;
|
||||
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.pvptimer.PvpTimer;
|
||||
import mineplex.game.clans.clans.redis.ClanDeleteCommandHandler;
|
||||
import mineplex.game.clans.clans.redis.ClanLoadCommandHandler;
|
||||
import mineplex.game.clans.clans.regions.ClansRegions;
|
||||
@ -155,6 +155,8 @@ public class ClansManager extends MiniClientPlugin<ClientClan>implements IRelati
|
||||
private LootManager _lootManager;
|
||||
private DonationManager _donationManager;
|
||||
|
||||
private Playtime _playTracker;
|
||||
|
||||
private TutorialManager _tutorialManager;
|
||||
|
||||
private ClassManager _classManager;
|
||||
@ -228,18 +230,12 @@ public class ClansManager extends MiniClientPlugin<ClientClan>implements IRelati
|
||||
|
||||
TaskManager taskManager = new TaskManager(plugin, _clientManager, webServerAddress);
|
||||
|
||||
_tutorialManager = new TutorialManager(plugin, _goldManager, taskManager, donationManager, preferencesManager, this, packetHandler);
|
||||
|
||||
ClanTips = new ClanTips(plugin, this, preferencesManager);
|
||||
|
||||
new StuckManager(this);
|
||||
|
||||
_scoreboard = new ClansScoreboardManager(plugin, _tutorialManager, this, _warManager, _worldEvent, clientManager, donationManager);
|
||||
// new MurderManager(plugin, this);
|
||||
|
||||
_clanAdmin = new ClansAdmin(this);
|
||||
_clanBlocks = new ClansBlocks();
|
||||
_clanDataAccess = new ClansDataAccessLayer(this, _scoreboard);
|
||||
_clanDisplay = new ClansDisplay(plugin, this);
|
||||
_clanGame = new ClansGame(plugin, this);
|
||||
_clanUtility = new ClansUtility(this);
|
||||
@ -266,11 +262,12 @@ public class ClansManager extends MiniClientPlugin<ClientClan>implements IRelati
|
||||
new ObserverManager(plugin, _condition, this);
|
||||
|
||||
new ClanEnergyTracker(plugin, this);
|
||||
new StuckManager(this);
|
||||
|
||||
new ClansAlphaManager(this, taskManager);
|
||||
|
||||
|
||||
new PotatoManager(plugin, this);
|
||||
|
||||
|
||||
new Weapon(plugin, energy);
|
||||
new Gameplay(plugin, this, blockRestore, damageManager);
|
||||
_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);
|
||||
_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())
|
||||
{
|
||||
@ -377,7 +382,7 @@ public class ClansManager extends MiniClientPlugin<ClientClan>implements IRelati
|
||||
@Override
|
||||
public void addCommands()
|
||||
{
|
||||
addCommand(new ClansCommand(this, _tutorialManager));
|
||||
addCommand(new ClansCommand(this));
|
||||
addCommand(new RegionsCommand(this));
|
||||
addCommand(new ClansChatCommand(this));
|
||||
addCommand(new ClansAllyChatCommand(this));
|
||||
@ -460,7 +465,7 @@ public class ClansManager extends MiniClientPlugin<ClientClan>implements IRelati
|
||||
int x = Math.abs(location.getBlockX());
|
||||
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)
|
||||
@ -624,7 +629,7 @@ public class ClansManager extends MiniClientPlugin<ClientClan>implements IRelati
|
||||
|
||||
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 = "";
|
||||
|
||||
if (client.isClanChat() && clan != null)
|
||||
@ -957,6 +962,7 @@ public class ClansManager extends MiniClientPlugin<ClientClan>implements IRelati
|
||||
_blockRestore.onDisable();
|
||||
_worldEvent.onDisable();
|
||||
_goldManager.onDisable();
|
||||
_playTracker.onDisable();
|
||||
}
|
||||
|
||||
@EventHandler(priority = EventPriority.HIGHEST)
|
||||
|
@ -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;
|
||||
}
|
||||
}
|
@ -24,6 +24,7 @@ import mineplex.game.clans.clans.event.PlayerClaimTerritoryEvent;
|
||||
import mineplex.game.clans.clans.event.PlayerPreClaimTerritoryEvent;
|
||||
import mineplex.game.clans.clans.event.PlayerUnClaimTerritoryEvent;
|
||||
import mineplex.game.clans.core.repository.ClanTerritory;
|
||||
import mineplex.game.clans.spawn.Spawn;
|
||||
|
||||
public class ClansUtility
|
||||
{
|
||||
@ -238,7 +239,7 @@ public class ClansUtility
|
||||
|
||||
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());
|
||||
}
|
||||
|
@ -35,7 +35,7 @@ public class ClansCommand extends CommandBase<ClansManager>
|
||||
{
|
||||
private ClansManager _manager;
|
||||
|
||||
public ClansCommand(ClansManager plugin, TutorialManager tutorialManager)
|
||||
public ClansCommand(ClansManager plugin)
|
||||
{
|
||||
super(plugin, Rank.ALL, "c", "clan", "clans", "factions");
|
||||
|
||||
|
@ -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;
|
||||
}
|
||||
}
|
@ -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;
|
||||
}
|
||||
}
|
@ -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."));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
@ -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.");
|
||||
}
|
||||
}
|
@ -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));
|
||||
}
|
||||
}
|
@ -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<>();
|
||||
}
|
||||
}
|
@ -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."));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
@ -1,10 +1,13 @@
|
||||
package mineplex.game.clans.clans.scoreboard;
|
||||
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.event.EventHandler;
|
||||
import org.bukkit.event.player.PlayerGameModeChangeEvent;
|
||||
import org.bukkit.plugin.java.JavaPlugin;
|
||||
|
||||
import mineplex.core.account.CoreClientManager;
|
||||
import mineplex.core.account.event.OnlineRankUpdateEvent;
|
||||
import mineplex.core.common.util.C;
|
||||
import mineplex.core.donation.DonationManager;
|
||||
import mineplex.core.scoreboard.PlayerScoreboard;
|
||||
@ -29,7 +32,7 @@ public class ClansScoreboardManager extends ScoreboardManager
|
||||
private WarManager _warManager;
|
||||
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);
|
||||
|
||||
@ -37,10 +40,10 @@ public class ClansScoreboardManager extends ScoreboardManager
|
||||
_warManager = warManager;
|
||||
_worldEvent = worldEvent;
|
||||
|
||||
init(tutorialManager);
|
||||
init();
|
||||
}
|
||||
|
||||
private void init(TutorialManager tutorialManager)
|
||||
private void init()
|
||||
{
|
||||
setTitle("Clans Alpha " + Clans.VERSION);
|
||||
|
||||
@ -53,12 +56,40 @@ public class ClansScoreboardManager extends ScoreboardManager
|
||||
data.writeElement(_warManager);
|
||||
data.writeElement(_worldEvent);
|
||||
|
||||
for (Tutorial tutorial : tutorialManager.getTutorials().values())
|
||||
for (Tutorial tutorial : TutorialManager.Instance.getTutorials().values())
|
||||
{
|
||||
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
|
||||
public void drawUpdate(UpdateEvent event)
|
||||
{
|
||||
|
@ -39,7 +39,6 @@ import org.bukkit.event.player.PlayerFishEvent;
|
||||
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.inventory.ItemStack;
|
||||
import org.bukkit.inventory.meta.ItemMeta;
|
||||
import org.bukkit.plugin.java.JavaPlugin;
|
||||
@ -47,7 +46,6 @@ import org.bukkit.plugin.java.JavaPlugin;
|
||||
import mineplex.core.MiniPlugin;
|
||||
import mineplex.core.blockrestore.BlockRestore;
|
||||
import mineplex.core.common.util.F;
|
||||
import mineplex.core.common.util.UtilBlock;
|
||||
import mineplex.core.common.util.UtilEvent;
|
||||
import mineplex.core.common.util.UtilEvent.ActionType;
|
||||
import mineplex.core.common.util.UtilGear;
|
||||
@ -94,14 +92,14 @@ public class Gameplay extends MiniPlugin
|
||||
Bukkit.getPluginManager().registerEvents(new CustomCreatures(), plugin);
|
||||
}
|
||||
|
||||
@EventHandler(priority = EventPriority.LOWEST)
|
||||
public void spawnDamage(CustomDamageEvent event)
|
||||
{
|
||||
if (_clansManager.getClanUtility().getClaim(event.GetDamageeEntity().getLocation()) != null && _clansManager.getClanUtility().getClaim(event.GetDamageeEntity().getLocation()).isSafe(event.GetDamageeEntity().getLocation()))
|
||||
{
|
||||
event.SetCancelled("Safe Zone");
|
||||
}
|
||||
}
|
||||
// @EventHandler(priority = EventPriority.LOWEST)
|
||||
// public void spawnDamage(CustomDamageEvent event)
|
||||
// {
|
||||
// if (_clansManager.getClanUtility().getClaim(event.GetDamageeEntity().getLocation()) != null && _clansManager.getClanUtility().getClaim(event.GetDamageeEntity().getLocation()).isSafe(event.GetDamageeEntity().getLocation()))
|
||||
// {
|
||||
// event.SetCancelled("Safe Zone");
|
||||
// }
|
||||
// }
|
||||
|
||||
@EventHandler
|
||||
public void onPlayerFishing(PlayerFishEvent event)
|
||||
@ -436,6 +434,11 @@ public class Gameplay extends MiniPlugin
|
||||
{
|
||||
final Block block = event.getBlock();
|
||||
|
||||
if (_clansManager.getClanUtility().isSafe(block.getLocation()))
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
if (!UtilItem.isLog(block.getType()))
|
||||
{
|
||||
return;
|
||||
|
@ -16,23 +16,24 @@ import org.bukkit.entity.LivingEntity;
|
||||
import org.bukkit.entity.Monster;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.event.EventHandler;
|
||||
import org.bukkit.event.EventPriority;
|
||||
import org.bukkit.event.block.BlockBreakEvent;
|
||||
import org.bukkit.event.block.BlockBurnEvent;
|
||||
import org.bukkit.event.block.BlockFromToEvent;
|
||||
import org.bukkit.event.block.BlockIgniteEvent;
|
||||
import org.bukkit.event.block.BlockIgniteEvent.IgniteCause;
|
||||
import org.bukkit.event.entity.CreatureSpawnEvent;
|
||||
import org.bukkit.event.entity.EntityDamageByEntityEvent;
|
||||
import org.bukkit.event.entity.EntityDamageEvent;
|
||||
import org.bukkit.event.entity.EntityDeathEvent;
|
||||
import org.bukkit.event.entity.EntitySpawnEvent;
|
||||
import org.bukkit.event.entity.EntityTargetEvent;
|
||||
import org.bukkit.event.hanging.HangingBreakByEntityEvent;
|
||||
import org.bukkit.event.player.PlayerJoinEvent;
|
||||
import org.bukkit.event.player.PlayerRespawnEvent;
|
||||
import org.bukkit.event.player.PlayerVelocityEvent;
|
||||
import org.bukkit.plugin.java.JavaPlugin;
|
||||
|
||||
import mineplex.core.MiniPlugin;
|
||||
import mineplex.core.common.Rank;
|
||||
import mineplex.core.common.util.F;
|
||||
import mineplex.core.common.util.UtilParticle;
|
||||
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.items.generation.WeightSet;
|
||||
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.core.condition.Condition.ConditionType;
|
||||
import mineplex.minecraft.game.core.damage.CustomDamageEvent;
|
||||
@ -102,7 +102,7 @@ public class Spawn extends MiniPlugin
|
||||
{
|
||||
Block block = event.getToBlock();
|
||||
|
||||
if (block.isLiquid() && isInSpawn(block.getLocation()))
|
||||
if (block.isLiquid() && isSafe(block.getLocation()))
|
||||
{
|
||||
event.setCancelled(true);
|
||||
}
|
||||
@ -115,7 +115,7 @@ public class Spawn extends MiniPlugin
|
||||
@EventHandler
|
||||
public void onWebToss(WebTossEvent event)
|
||||
{
|
||||
if (isInSpawn(event.getLocation()))
|
||||
if (isSafe(event.getLocation()))
|
||||
{
|
||||
event.setCancelled(true);
|
||||
}
|
||||
@ -138,7 +138,7 @@ public class Spawn extends MiniPlugin
|
||||
@EventHandler
|
||||
public void onBlockBurn(BlockBurnEvent event)
|
||||
{
|
||||
if (isInSpawn(event.getBlock().getLocation()))
|
||||
if (isSafe(event.getBlock().getLocation()))
|
||||
{
|
||||
event.setCancelled(true);
|
||||
}
|
||||
@ -153,7 +153,7 @@ public class Spawn extends MiniPlugin
|
||||
{
|
||||
if (event.getEntity() instanceof ItemFrame)
|
||||
{
|
||||
if (isInSpawn(event.getEntity().getLocation()))
|
||||
if (isSafe(event.getEntity().getLocation()))
|
||||
{
|
||||
event.setCancelled(true);
|
||||
}
|
||||
@ -165,7 +165,7 @@ public class Spawn extends MiniPlugin
|
||||
{
|
||||
if (event.GetDamageeEntity() instanceof ItemFrame)
|
||||
{
|
||||
if (isInSpawn(event.GetDamageeEntity().getLocation()))
|
||||
if (isSafe(event.GetDamageeEntity().getLocation()))
|
||||
{
|
||||
event.SetCancelled("Item Frame Cancel");
|
||||
}
|
||||
@ -177,7 +177,7 @@ public class Spawn extends MiniPlugin
|
||||
{
|
||||
if (event.getEntity() instanceof ItemFrame)
|
||||
{
|
||||
if (isInSpawn(event.getEntity().getLocation()))
|
||||
if (isSafe(event.getEntity().getLocation()))
|
||||
{
|
||||
event.setCancelled(true);
|
||||
}
|
||||
@ -192,9 +192,9 @@ public class Spawn extends MiniPlugin
|
||||
|
||||
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;
|
||||
|
||||
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));
|
||||
|
||||
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);
|
||||
}
|
||||
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)
|
||||
{
|
||||
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
|
||||
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);
|
||||
}
|
||||
@ -325,7 +344,7 @@ public class Spawn extends MiniPlugin
|
||||
|
||||
if (isInSpawn(monster))
|
||||
{
|
||||
int size = event.getDrops().size();
|
||||
// int size = event.getDrops().size();
|
||||
event.getDrops().clear();
|
||||
}
|
||||
}
|
||||
@ -338,7 +357,7 @@ public class Spawn extends MiniPlugin
|
||||
@EventHandler
|
||||
public void onEntityTarget(EntityTargetEvent event)
|
||||
{
|
||||
if (event.getTarget() != null && isInSpawn(event.getTarget().getLocation()))
|
||||
if (event.getTarget() != null && isSafe(event.getTarget().getLocation()))
|
||||
{
|
||||
event.setCancelled(true);
|
||||
}
|
||||
@ -353,7 +372,7 @@ public class Spawn extends MiniPlugin
|
||||
{
|
||||
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);
|
||||
}
|
||||
@ -366,22 +385,37 @@ public class Spawn extends MiniPlugin
|
||||
@EventHandler
|
||||
public void onPlayerAttack(CustomDamageEvent event)
|
||||
{
|
||||
Player defender = event.GetDamageePlayer();
|
||||
Player victim = event.GetDamageePlayer();
|
||||
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");
|
||||
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");
|
||||
attemptNotify(attacker, "You cannot attack untagged players while in spawn!");
|
||||
}
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
System.out.println(event.GetCancellers());
|
||||
}
|
||||
|
||||
public Location getSpawnLocation()
|
||||
@ -401,7 +435,7 @@ public class Spawn extends MiniPlugin
|
||||
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
|
||||
}
|
||||
@ -414,9 +448,10 @@ public class Spawn extends MiniPlugin
|
||||
return xOffset <= radius && zOffset <= radius;
|
||||
}
|
||||
|
||||
// this is basically just isSafe();
|
||||
public boolean isInSpawn(Entity entity)
|
||||
{
|
||||
return entity != null && isInSpawn(entity.getLocation());
|
||||
return entity != null && isSafe(entity.getLocation());
|
||||
}
|
||||
|
||||
public static World getSpawnWorld()
|
||||
|
@ -46,6 +46,7 @@ import mineplex.core.updater.event.UpdateEvent;
|
||||
import mineplex.game.clans.clans.ClansManager;
|
||||
import mineplex.game.clans.clans.event.ClanJoinEvent;
|
||||
import mineplex.game.clans.clans.event.ClanTipEvent;
|
||||
import mineplex.game.clans.clans.playtime.Playtime;
|
||||
import mineplex.game.clans.economy.GoldManager;
|
||||
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 _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;
|
||||
_goldManager = goldManager;
|
||||
@ -99,6 +102,7 @@ public abstract class Tutorial implements ScoreboardElement, Listener
|
||||
_tasks = new ArrayList<TutorialTask<?>>();
|
||||
_inTutorial = new LinkedHashMap<>();
|
||||
_nameToTask = new LinkedHashMap<>();
|
||||
_playtime = playtime;
|
||||
|
||||
_manager.getPluginManager().registerEvents(this, _manager.getPlugin());
|
||||
}
|
||||
@ -499,6 +503,12 @@ public abstract class Tutorial implements ScoreboardElement, Listener
|
||||
{
|
||||
public void run(Boolean data)
|
||||
{
|
||||
if (_playtime.Get(player).FirstSession)
|
||||
{
|
||||
_playtime.Get(player).StartTime = System.currentTimeMillis();
|
||||
_playtime.Get(player).FirstSession = false;
|
||||
}
|
||||
|
||||
cancelFor(player);
|
||||
}
|
||||
}, player, String.format(SKIPPED_TASK, _technicalName));
|
||||
|
@ -11,7 +11,6 @@ import org.bukkit.plugin.java.JavaPlugin;
|
||||
|
||||
import mineplex.core.MiniPlugin;
|
||||
import mineplex.core.common.util.F;
|
||||
import mineplex.core.common.util.UtilPlayer;
|
||||
import mineplex.core.donation.DonationManager;
|
||||
import mineplex.core.packethandler.IPacketHandler;
|
||||
import mineplex.core.packethandler.PacketHandler;
|
||||
@ -20,12 +19,12 @@ import mineplex.core.preferences.PreferencesManager;
|
||||
import mineplex.core.task.TaskManager;
|
||||
import mineplex.game.clans.clans.ClansManager;
|
||||
import mineplex.game.clans.clans.commands.RestartTutCommand;
|
||||
import mineplex.game.clans.clans.playtime.Playtime;
|
||||
import mineplex.game.clans.economy.GoldManager;
|
||||
import mineplex.game.clans.tutorials.commands.DoSkipTutorialCommand;
|
||||
import mineplex.game.clans.tutorials.commands.SkipTutorialCommand;
|
||||
import mineplex.game.clans.tutorials.gettingstarted.TutorialGettingStarted;
|
||||
import net.md_5.bungee.api.ChatColor;
|
||||
import net.minecraft.server.v1_8_R3.IChatBaseComponent;
|
||||
import net.minecraft.server.v1_8_R3.PacketPlayOutChat;
|
||||
|
||||
public class TutorialManager extends MiniPlugin
|
||||
@ -37,7 +36,7 @@ public class TutorialManager extends MiniPlugin
|
||||
|
||||
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);
|
||||
|
||||
@ -45,7 +44,7 @@ public class TutorialManager extends MiniPlugin
|
||||
|
||||
_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() {
|
||||
public void handle(PacketInfo packet)
|
||||
|
@ -12,6 +12,7 @@ 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.economy.GoldManager;
|
||||
import mineplex.game.clans.spawn.Spawn;
|
||||
import mineplex.game.clans.tutorials.Tutorial;
|
||||
@ -19,9 +20,9 @@ import mineplex.game.clans.tutorials.TutorialManager;
|
||||
|
||||
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));
|
||||
|
||||
@ -52,8 +53,14 @@ public class TutorialGettingStarted extends Tutorial
|
||||
{
|
||||
player.resetPlayerTime();
|
||||
player.teleport(Spawn.getEastSpawn());
|
||||
|
||||
if (_playtime.Get(player).FirstSession)
|
||||
{
|
||||
_playtime.Get(player).StartTime = System.currentTimeMillis();
|
||||
_playtime.Get(player).FirstSession = false;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
protected void onFinishedDelay(Player player)
|
||||
{
|
||||
|
@ -28,6 +28,7 @@ public class CombatLog
|
||||
protected CombatComponent LastDamager;
|
||||
protected long _lastDamaged;
|
||||
protected long _lastCombat;
|
||||
protected long _lastCombatEngaged;
|
||||
|
||||
public CombatLog(Player player, long expireTime)
|
||||
{
|
||||
@ -185,6 +186,16 @@ public class CombatLog
|
||||
return _lastCombat;
|
||||
}
|
||||
|
||||
public long GetLastCombatEngaged()
|
||||
{
|
||||
return _lastCombatEngaged;
|
||||
}
|
||||
|
||||
public void SetLastCombatEngaged(long time)
|
||||
{
|
||||
_lastCombatEngaged = time;
|
||||
}
|
||||
|
||||
public void SetLastCombat(long time)
|
||||
{
|
||||
_lastCombat = time;
|
||||
|
@ -3,8 +3,6 @@ package mineplex.minecraft.game.core.combat;
|
||||
import java.util.HashSet;
|
||||
import java.util.Iterator;
|
||||
|
||||
import net.minecraft.server.v1_8_R3.ItemStack;
|
||||
|
||||
import org.bukkit.craftbukkit.v1_8_R3.inventory.CraftItemStack;
|
||||
import org.bukkit.entity.Arrow;
|
||||
import org.bukkit.entity.Fireball;
|
||||
@ -18,8 +16,6 @@ import org.bukkit.event.entity.PlayerDeathEvent;
|
||||
import org.bukkit.plugin.java.JavaPlugin;
|
||||
|
||||
import mineplex.core.MiniPlugin;
|
||||
import mineplex.core.updater.event.UpdateEvent;
|
||||
import mineplex.core.updater.UpdateType;
|
||||
import mineplex.core.account.event.ClientUnloadEvent;
|
||||
import mineplex.core.common.util.C;
|
||||
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.UtilTime;
|
||||
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.CombatDeathEvent;
|
||||
import mineplex.minecraft.game.core.damage.CustomDamageEvent;
|
||||
import net.minecraft.server.v1_8_R3.ItemStack;
|
||||
|
||||
public class CombatManager extends MiniPlugin
|
||||
{
|
||||
@ -201,7 +200,7 @@ public class CombatManager extends MiniPlugin
|
||||
// Not Player > No Log
|
||||
if (event.GetDamageePlayer() == null)
|
||||
return;
|
||||
|
||||
|
||||
// Damager is ENTITY
|
||||
if (event.GetDamagerEntity(true) != null)
|
||||
{
|
||||
@ -256,8 +255,12 @@ public class CombatManager extends MiniPlugin
|
||||
}
|
||||
|
||||
if (event.GetDamagerEntity(true) instanceof Player)
|
||||
{
|
||||
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(
|
||||
UtilEnt.getName(event.GetDamagerEntity(true)),
|
||||
(int) event.GetDamage(), event.GetDamagerEntity(true),
|
||||
|
Loading…
Reference in New Issue
Block a user