clans buggy fixers
This commit is contained in:
parent
8559a63887
commit
459e1beeff
@ -721,25 +721,30 @@ public class UtilBlock
|
||||
}
|
||||
|
||||
|
||||
public static boolean deleteBed(Location home)
|
||||
public static boolean deleteBed(Location bed)
|
||||
{
|
||||
if (home == null)
|
||||
if (bed == null)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
if (home.getY() <= 0)
|
||||
if (bed.getY() <= 0)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
if (!bed.getBlock().getType().equals(Material.BED_BLOCK))
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
int xModif = 0;
|
||||
int zModif = 0;
|
||||
byte data = home.getBlock().getData();
|
||||
byte data = bed.getBlock().getData();
|
||||
|
||||
boolean isSpecifiedHead = (data & 0x8) != 0;
|
||||
Location head = isSpecifiedHead ? home : null;
|
||||
Location foot = isSpecifiedHead ? null : home;
|
||||
Location head = isSpecifiedHead ? bed : null;
|
||||
Location foot = isSpecifiedHead ? null : bed;
|
||||
|
||||
EnumDirection direction = null;
|
||||
|
||||
|
@ -102,4 +102,8 @@ public class UtilText {
|
||||
return new String(new byte[times]).replace("\0", txt);
|
||||
}
|
||||
|
||||
public static boolean plural(int x){
|
||||
return x <= 0 ? true : x > 1;
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -3,11 +3,11 @@ package mineplex.game.clans.clans;
|
||||
import java.util.EnumMap;
|
||||
import java.util.concurrent.TimeUnit;
|
||||
|
||||
import org.apache.commons.lang3.tuple.Triple;
|
||||
import org.bukkit.event.EventHandler;
|
||||
import org.bukkit.plugin.java.JavaPlugin;
|
||||
|
||||
import mineplex.core.MiniPlugin;
|
||||
import mineplex.core.common.Pair;
|
||||
import mineplex.core.common.util.C;
|
||||
import mineplex.core.common.util.F;
|
||||
import mineplex.core.updater.UpdateType;
|
||||
@ -16,18 +16,17 @@ import mineplex.core.updater.event.UpdateEvent;
|
||||
public class ClanEnergyTracker extends MiniPlugin
|
||||
{
|
||||
private ClansManager _clans;
|
||||
private EnumMap<UpdateType, Pair<Long, Long>> _updateMap;
|
||||
private EnumMap<UpdateType, Triple<Long, Long, String[]>> _updateMap;
|
||||
|
||||
public ClanEnergyTracker(JavaPlugin plugin, ClansManager clans)
|
||||
{
|
||||
super("Clan Energy Tracker", plugin);
|
||||
_clans = clans;
|
||||
|
||||
_updateMap = new EnumMap<UpdateType, Pair<Long, Long>>(UpdateType.class);
|
||||
_updateMap.put(UpdateType.MIN_05, Pair.create(0L, TimeUnit.HOURS.toMillis(1)));
|
||||
_updateMap.put(UpdateType.MIN_10, Pair.create(TimeUnit.HOURS.toMillis(1), TimeUnit.HOURS.toMillis(4)));
|
||||
_updateMap.put(UpdateType.MIN_30, Pair.create(TimeUnit.HOURS.toMillis(4), TimeUnit.DAYS.toMillis(1)));
|
||||
_updateMap.put(UpdateType.HOUR_01, Pair.create(TimeUnit.DAYS.toMillis(1), TimeUnit.DAYS.toMillis(2)));
|
||||
_updateMap = new EnumMap<>(UpdateType.class);
|
||||
_updateMap.put(UpdateType.MIN_05, Triple.of(0L, TimeUnit.HOURS.toMillis(1), new String[] { C.cRed + "Urgent", "Clan Energy is almost depleted" }));
|
||||
_updateMap.put(UpdateType.MIN_10, Triple.of(TimeUnit.HOURS.toMillis(1), TimeUnit.HOURS.toMillis(4), new String[] { C.cGold + "Warning", "Clan Energy is low" }));
|
||||
_updateMap.put(UpdateType.MIN_30, Triple.of(TimeUnit.HOURS.toMillis(4), TimeUnit.DAYS.toMillis(1), new String[] { C.cGold + "Notice", "Clan Energy is running low" }));
|
||||
}
|
||||
|
||||
@EventHandler
|
||||
@ -36,27 +35,34 @@ public class ClanEnergyTracker extends MiniPlugin
|
||||
if (_updateMap.containsKey(event.getType()))
|
||||
{
|
||||
for (ClanInfo clan : _clans.getClanMap().values())
|
||||
{
|
||||
display(clan, event.getType());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private void display(ClanInfo clan, UpdateType type)
|
||||
{
|
||||
// No point in doing anything if nobody is online!
|
||||
if (!clan.isOnlineNow())
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
// Avoid divide by 0
|
||||
if (clan.getEnergyCostPerMinute() <= 0)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
// Energy Remaining in milliseconds
|
||||
long energyRemaining = (clan.getEnergy() / clan.getEnergyCostPerMinute()) * 60000L;
|
||||
Pair<Long, Long> energyBounds = _updateMap.get(type);
|
||||
|
||||
if (energyBounds != null && energyRemaining > energyBounds.getLeft() && energyRemaining < energyBounds.getRight())
|
||||
Triple<Long, Long, String[]> energyBounds = _updateMap.get(type);
|
||||
|
||||
if (energyBounds != null && energyRemaining > energyBounds.getLeft() && energyRemaining < energyBounds.getMiddle())
|
||||
{
|
||||
_clans.middleTextClan(clan, C.cRed + "Urgent", "Clan Energy is almost depleted", 20, 200, 80);
|
||||
_clans.middleTextClan(clan, energyBounds.getRight()[0], energyBounds.getRight()[1], 20, 200, 80);
|
||||
_clans.messageClan(clan, F.main("Energy", "To top up your Clan's Energy, head to the shop and go to the Energy Shop!"));
|
||||
}
|
||||
}
|
||||
|
@ -192,13 +192,9 @@ public class ClansAdmin
|
||||
return;
|
||||
}
|
||||
|
||||
for (String cur : Clans.denyClan)
|
||||
{
|
||||
if (cur.equalsIgnoreCase(args[2]))
|
||||
if (!ClansBlacklist.isValidClanName(args[2]))
|
||||
{
|
||||
UtilPlayer.message(caller, F.main("Clans Admin", "Clan name cannot be a Clan command."));
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
if (Clans.getClan(args[2]) != null)
|
||||
|
@ -575,6 +575,14 @@ public class ClansDataAccessLayer
|
||||
// Log
|
||||
if (player != null) _manager.log("Removed Claim for [" + clan.getName() + "] at [" + chunk + "] by [" + player + "].");
|
||||
|
||||
// Bed Removal
|
||||
if (clan.getHome() != null && UtilWorld.chunkToStr(clan.getHome().getChunk()).equals(chunk))
|
||||
{
|
||||
UtilBlock.deleteBed(clan.getHome());
|
||||
clan.setHome(null);
|
||||
clan.inform("Clan has lost it's Home because of a Territory loss.", null);
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
|
@ -172,9 +172,6 @@ public class ClansManager extends MiniClientPlugin<ClientClan> implements IRelat
|
||||
|
||||
// Spawn area
|
||||
|
||||
public String[] denyClan = new String[] {
|
||||
"neut", "neutral", "sethome", "promote", "demote", "admin", "help", "create", "disband", "delete", "invite", "join", "kick", "ally", "trust", "claim", "unclaim", "territory", "home", };
|
||||
|
||||
public ClansManager(JavaPlugin plugin, String serverName, CoreClientManager clientManager, DonationManager donationManager, PreferencesManager preferencesManager, BlockRestore blockRestore, Teleport teleport, Chat chat, GearManager gearManager, HologramManager hologramManager, String webServerAddress)
|
||||
{
|
||||
super("Clans Manager", plugin);
|
||||
|
@ -17,6 +17,7 @@ import org.bukkit.entity.Player;
|
||||
import mineplex.core.common.util.C;
|
||||
import mineplex.core.common.util.Callback;
|
||||
import mineplex.core.common.util.F;
|
||||
import mineplex.core.common.util.UtilBlock;
|
||||
import mineplex.core.common.util.UtilInput;
|
||||
import mineplex.core.common.util.UtilMath;
|
||||
import mineplex.core.common.util.UtilPlayer;
|
||||
@ -1136,10 +1137,14 @@ public class ClansUtility
|
||||
ArrayList<String> toUnclaim = new ArrayList<String>();
|
||||
|
||||
for (String chunk : clan.getClaimSet())
|
||||
{
|
||||
toUnclaim.add(chunk);
|
||||
}
|
||||
|
||||
for (String chunk : toUnclaim)
|
||||
{
|
||||
Clans.getClanDataAccess().unclaim(chunk, caller.getName(), true);
|
||||
}
|
||||
|
||||
// Inform
|
||||
UtilPlayer.message(caller, F.main("Clans", "You unclaimed all your Clans Territory."));
|
||||
|
@ -1,11 +1,7 @@
|
||||
package mineplex.game.clans.clans.commands;
|
||||
|
||||
import java.util.ArrayList;
|
||||
|
||||
import org.bukkit.Location;
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.block.Block;
|
||||
import org.bukkit.block.BlockState;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
import mineplex.core.command.CommandBase;
|
||||
@ -19,14 +15,13 @@ import mineplex.core.common.util.UtilPlayer;
|
||||
import mineplex.core.common.util.UtilServer;
|
||||
import mineplex.core.common.util.UtilTime;
|
||||
import mineplex.core.common.util.UtilTime.TimeUnit;
|
||||
import mineplex.core.recharge.Recharge;
|
||||
import mineplex.core.common.util.UtilWorld;
|
||||
import mineplex.game.clans.clans.ClanInfo;
|
||||
import mineplex.game.clans.clans.ClanRole;
|
||||
import mineplex.game.clans.clans.ClansBlacklist;
|
||||
import mineplex.game.clans.clans.ClansManager;
|
||||
import mineplex.game.clans.clans.ClansPlayer;
|
||||
import mineplex.game.clans.clans.ClientClan;
|
||||
import mineplex.game.clans.clans.event.ClanDisbandedEvent;
|
||||
import mineplex.game.clans.clans.event.ClansCommandExecutedEvent;
|
||||
import mineplex.game.clans.tutorials.TutorialManager;
|
||||
import net.minecraft.server.v1_8_R3.EnumDirection;
|
||||
@ -225,6 +220,12 @@ public class ClansCommand extends CommandBase<ClansManager>
|
||||
return;
|
||||
}
|
||||
|
||||
if (Recharge.Instance.use(caller, "Clan Create", 30000, false, false))
|
||||
{
|
||||
UtilPlayer.message(caller, F.main("Clans", "You may not spam the Clan create command."));
|
||||
return;
|
||||
}
|
||||
|
||||
if (!UtilInput.valid(args[1]))
|
||||
{
|
||||
UtilPlayer.message(caller, F.main("Clans", "Invalid characters in Clan name."));
|
||||
@ -255,15 +256,6 @@ public class ClansCommand extends CommandBase<ClansManager>
|
||||
return;
|
||||
}
|
||||
|
||||
for (String cur : Plugin.denyClan)
|
||||
{
|
||||
if (cur.equalsIgnoreCase(args[1]))
|
||||
{
|
||||
UtilPlayer.message(caller, F.main("Clans", "Clan name cannot be a Clan command."));
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
Plugin.getClanDataAccess().clanExists(args[1], new Callback<Boolean>()
|
||||
{
|
||||
@Override
|
||||
|
@ -34,6 +34,7 @@ public class ClansPlayerScoreboard extends PlayerScoreboard
|
||||
|
||||
public void refreshTeams(Player player)
|
||||
{
|
||||
System.out.println("<--> SB refresh");
|
||||
for (Player otherPlayer : Bukkit.getOnlinePlayers())
|
||||
{
|
||||
if (otherPlayer.equals(player))
|
||||
@ -59,6 +60,17 @@ public class ClansPlayerScoreboard extends PlayerScoreboard
|
||||
}
|
||||
}
|
||||
|
||||
public void removeFromAllTeams(Scoreboard scoreboard, Player player)
|
||||
{
|
||||
for (Team team : scoreboard.getTeams())
|
||||
{
|
||||
if (team.hasPlayer(player))
|
||||
{
|
||||
team.removePlayer(player);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public void add(Scoreboard scoreboard, Player otherPlayer, ClanInfo clanInfo, ClanRelation relation, int ownScore)
|
||||
{
|
||||
String teamName = getTeamName(clanInfo, relation, ownScore);
|
||||
@ -72,6 +84,7 @@ public class ClansPlayerScoreboard extends PlayerScoreboard
|
||||
team.setPrefix(relation.getColor(false).toString());
|
||||
}
|
||||
|
||||
|
||||
Objective domObjective;
|
||||
if ((domObjective = scoreboard.getObjective(DisplaySlot.BELOW_NAME)) == null)
|
||||
{
|
||||
|
@ -25,6 +25,7 @@ import mineplex.core.common.util.F;
|
||||
import mineplex.core.common.util.UtilFirework;
|
||||
import mineplex.core.common.util.UtilPlayer;
|
||||
import mineplex.core.common.util.UtilServer;
|
||||
import mineplex.core.common.util.UtilText;
|
||||
import mineplex.core.scoreboard.ScoreboardManager;
|
||||
import mineplex.core.scoreboard.elements.ScoreboardElement;
|
||||
import mineplex.core.task.TaskManager;
|
||||
@ -148,7 +149,7 @@ public abstract class Tutorial implements ScoreboardElement, Listener
|
||||
{
|
||||
public void run(final Boolean completed)
|
||||
{
|
||||
UtilPlayer.message(player, F.main("Tutorials", "You have completed Task " + F.elem(taskID + ": " + task.getFriendlyName()) + ". " + (_tasks.size() - taskID) + " tasks to go!"));
|
||||
UtilPlayer.message(player, F.main("Tutorials", "You have completed Task " + F.elem(taskID + ": " + task.getFriendlyName()) + ". " + (_tasks.size() - taskID) + " task" + (UtilText.plural(_tasks.size() - taskID) ? "s" : "") + " to go!"));
|
||||
|
||||
if (taskID == _tasks.size())
|
||||
{
|
||||
|
Loading…
Reference in New Issue
Block a user