Added fix to WarPoint evasion bug + 1 dmg bug
This commit is contained in:
parent
9c83c64d01
commit
8a0f585432
@ -9,6 +9,7 @@ import java.util.Set;
|
||||
import java.util.TimeZone;
|
||||
import java.util.UUID;
|
||||
|
||||
import mineplex.game.clans.clans.warpoints.WarPointEvasion;
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.Location;
|
||||
import org.bukkit.Material;
|
||||
@ -259,9 +260,9 @@ public class ClansManager extends MiniClientPlugin<ClientClan>implements IRelati
|
||||
_itemMapManager = new ItemMapManager(this, _worldEvent);
|
||||
new TntGeneratorManager(plugin, this);
|
||||
new SupplyDropManager(plugin, this);
|
||||
|
||||
_explosion = new Explosion(plugin, blockRestore);
|
||||
|
||||
new WarPointEvasion(plugin);
|
||||
|
||||
// new ClansLoginManager(getPlugin(), clientManager, _serverName);
|
||||
|
||||
_clanShop = new ClanShop(this, clientManager, donationManager);
|
||||
@ -608,6 +609,13 @@ public class ClansManager extends MiniClientPlugin<ClientClan>implements IRelati
|
||||
{
|
||||
player.setOp(true);
|
||||
}
|
||||
if(player.getInventory().getHelmet() != null) { //Reset helmet to fix 1 damage bug
|
||||
ItemStack helmet = player.getInventory().getHelmet().clone();
|
||||
player.getInventory().setHelmet(null);
|
||||
runSyncLater(() -> {
|
||||
player.getInventory().setHelmet(helmet);
|
||||
}, 5L);
|
||||
}
|
||||
}
|
||||
|
||||
@EventHandler
|
||||
|
@ -0,0 +1,58 @@
|
||||
package mineplex.game.clans.clans.warpoints;
|
||||
|
||||
import com.google.common.collect.Maps;
|
||||
import mineplex.core.MiniPlugin;
|
||||
import mineplex.core.common.util.F;
|
||||
import mineplex.core.common.util.UtilTime;
|
||||
import mineplex.core.updater.UpdateType;
|
||||
import mineplex.core.updater.event.UpdateEvent;
|
||||
import mineplex.game.clans.clans.event.PlayerPreClaimTerritoryEvent;
|
||||
import mineplex.game.clans.clans.event.PlayerUnClaimTerritoryEvent;
|
||||
import org.bukkit.Chunk;
|
||||
import org.bukkit.event.EventHandler;
|
||||
import org.bukkit.plugin.java.JavaPlugin;
|
||||
|
||||
import java.util.HashMap;
|
||||
|
||||
public class WarPointEvasion extends MiniPlugin{
|
||||
private HashMap<Chunk, Long> _cooldown;
|
||||
private final long COOLDOWN_TIME = 1000 * 60 * 30;
|
||||
|
||||
public WarPointEvasion(JavaPlugin plugin) {
|
||||
super("WP Evasion", plugin);
|
||||
_cooldown = Maps.newHashMap();
|
||||
}
|
||||
|
||||
@EventHandler
|
||||
public void updateCooldown(UpdateEvent event) {
|
||||
if(!event.getType().equals(UpdateType.SEC)) return;
|
||||
|
||||
for(Chunk chunk : _cooldown.keySet()) {
|
||||
if(UtilTime.elapsed(_cooldown.get(chunk), COOLDOWN_TIME)) {
|
||||
_cooldown.remove(chunk);
|
||||
} else {
|
||||
_cooldown.put(chunk, _cooldown.get(chunk) - 1000);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@EventHandler
|
||||
public void onClaim(PlayerPreClaimTerritoryEvent event) {
|
||||
Chunk chunk = event.getClaimedChunk();
|
||||
if(_cooldown.containsKey(chunk)) {
|
||||
event.setCancelled(true);
|
||||
event.getClaimer().sendMessage(F.main("Clans", "You cannot claim this chunk for another " + UtilTime.convertString(_cooldown.get(chunk), 1, UtilTime.TimeUnit.MINUTES)));
|
||||
}
|
||||
}
|
||||
|
||||
@EventHandler
|
||||
public void onunClaim(PlayerUnClaimTerritoryEvent event) {
|
||||
Chunk chunk = event.getUnClaimedChunk();
|
||||
if(_cooldown.containsKey(chunk)) {
|
||||
// Error maybe?
|
||||
_cooldown.remove(chunk);
|
||||
}
|
||||
_cooldown.put(chunk, System.currentTimeMillis());
|
||||
|
||||
}
|
||||
}
|
Loading…
Reference in New Issue
Block a user