Fix merge issues, fix observer command

This commit is contained in:
Shaun Bennett 2015-10-01 22:57:39 -04:00
parent b8cc967fb0
commit 5bce1b5f2e
14 changed files with 81 additions and 30 deletions

View File

@ -20,6 +20,7 @@
<element id="extracted-dir" path="$PROJECT_DIR$/Libraries/jooq-3.5.2.jar" path-in-jar="/" />
<element id="extracted-dir" path="$PROJECT_DIR$/Libraries/commons-dbcp2-2.0.1.jar" path-in-jar="/" />
<element id="module-output" name="Mineplex.Game.Clans.Core" />
<element id="module-output" name="Mineplex.PlayerCache" />
</root>
</artifact>
</component>

View File

@ -1,6 +1,8 @@
package mineplex.core.common.util;
import java.util.ArrayList;
import java.util.Collection;
import java.util.Comparator;
import java.util.List;
import java.util.Set;
import java.util.TreeSet;
@ -16,8 +18,13 @@ public class UtilAlg
{
public static TreeSet<String> sortKey(Set<String> toSort)
{
TreeSet<String> sortedSet = new TreeSet<String>();
for (String cur : toSort)
return sortSet(toSort, null);
}
public static <T> TreeSet<T> sortSet(Collection<T> toSort, Comparator<T> comparator)
{
TreeSet<T> sortedSet = new TreeSet<T>(comparator);
for (T cur : toSort)
sortedSet.add(cur);
return sortedSet;

View File

@ -33,6 +33,7 @@ import org.bukkit.event.EventHandler;
import org.bukkit.event.EventPriority;
import org.bukkit.event.player.AsyncPlayerPreLoginEvent;
import org.bukkit.event.player.AsyncPlayerPreLoginEvent.Result;
import org.bukkit.event.player.PlayerInteractEvent;
import org.bukkit.event.player.PlayerKickEvent;
import org.bukkit.event.player.PlayerLoginEvent;
import org.bukkit.event.player.PlayerQuitEvent;
@ -552,4 +553,10 @@ public class CoreClientManager extends MiniPlugin
return client.GetRank().has(rank);
}
public int getCachedClientAccountId(UUID uuid)
{
PlayerInfo playerInfo = PlayerCache.getInstance().getPlayer(uuid);
return playerInfo == null ? -1 : playerInfo.getAccountId();
}
}

View File

@ -394,7 +394,16 @@ public class DonationManager extends MiniDbClientPlugin<Donor>
{
public void run()
{
rewardGold(callback, caller, player.getName(), ClientManager.getCachedClientAccountId(player.getUniqueId()), total, false);
int accountId = ClientManager.getCachedClientAccountId(player.getUniqueId());
if (accountId != -1)
{
rewardGold(callback, caller, player.getName(), accountId, total, false);
}
else
{
System.out.println("Failed to reward gold to [" + player.getName() + "]. " + "Cached account id was not found");
}
}
});
}

View File

@ -1,6 +1,5 @@
package mineplex.game.clans;
import org.bukkit.Location;
import org.bukkit.Material;
import org.bukkit.World;
import org.bukkit.craftbukkit.v1_7_R4.CraftWorld;
@ -8,6 +7,7 @@ import org.bukkit.plugin.java.JavaPlugin;
import net.minecraft.server.v1_7_R4.MinecraftServer;
import mineplex.core.FoodDupeFix;
import mineplex.core.TablistFix;
import mineplex.core.account.CoreClientManager;
import mineplex.core.achievement.AchievementManager;
@ -19,13 +19,14 @@ import mineplex.core.donation.DonationManager;
import mineplex.core.explosion.Explosion;
import mineplex.core.friend.FriendManager;
import mineplex.core.give.Give;
import mineplex.core.hologram.HologramManager;
import mineplex.core.ignore.IgnoreManager;
import mineplex.core.inventory.InventoryManager;
import mineplex.core.itemstack.ItemStackFactory;
import mineplex.core.memory.MemoryFix;
import mineplex.core.message.MessageManager;
import mineplex.core.monitor.LagMeter;
import mineplex.core.observer.ObserverManager;
import mineplex.game.clans.clans.observer.ObserverManager;
import mineplex.core.packethandler.PacketHandler;
import mineplex.core.portal.Portal;
import mineplex.core.preferences.PreferencesManager;
@ -41,7 +42,6 @@ import mineplex.core.updater.FileUpdater;
import mineplex.core.updater.Updater;
import mineplex.core.visibility.VisibilityManager;
import mineplex.game.clans.clans.ClansManager;
import mineplex.game.clans.clans.worldevent.WorldEventManager;
import mineplex.game.clans.items.GearManager;
import mineplex.game.clans.shop.building.BuildingShop;
import mineplex.game.clans.shop.farming.FarmingShop;
@ -110,10 +110,9 @@ public class Clans extends JavaPlugin
Chat chat = new Chat(this, _clientManager, preferenceManager, achievementManager, serverStatusManager.getCurrentServerName());
new MessageManager(this, _clientManager, preferenceManager, ignoreManager, punish, new FriendManager(this, _clientManager, preferenceManager, portal), chat);
new ObserverManager(this);
new TablistFix(this);
new MemoryFix(this);
new FoodDupeFix(this);
new Explosion(this, blockRestore);
new FriendManager(this, _clientManager, preferenceManager, portal);
new InventoryManager(this, _clientManager);
@ -122,7 +121,8 @@ public class Clans extends JavaPlugin
PacketHandler packetHandler = new PacketHandler(this);
GearManager customGear = new GearManager(this, packetHandler);
_clansManager = new ClansManager(this, serverStatusManager.getCurrentServerName(), _clientManager, _donationManager, blockRestore, teleport, chat, customGear, webServerAddress);
HologramManager hologram = new HologramManager(this);
_clansManager = new ClansManager(this, serverStatusManager.getCurrentServerName(), _clientManager, _donationManager, blockRestore, teleport, chat, customGear, hologram, webServerAddress);
new Recipes(this);
new Farming(this);
new BuildingShop(_clansManager, _clientManager, _donationManager);

View File

@ -65,6 +65,7 @@ import mineplex.game.clans.clans.commands.ServerTimeCommand;
import mineplex.game.clans.clans.loot.LootManager;
import mineplex.game.clans.clans.map.ItemMapManager;
import mineplex.game.clans.clans.murder.MurderManager;
import mineplex.game.clans.clans.observer.ObserverManager;
import mineplex.game.clans.clans.redis.ClanDeleteCommandHandler;
import mineplex.game.clans.clans.redis.ClanLoadCommandHandler;
import mineplex.game.clans.clans.regions.ClansRegions;
@ -219,6 +220,7 @@ public class ClansManager extends MiniClientPlugin<ClientClan> implements IRelat
new Spawn(plugin, this);
new NPCManager(this);
new LoggingManager(plugin, this);
new ObserverManager(plugin, _condition, this);
new Weapon(plugin, energy);
new Gameplay(plugin, this, blockRestore, damageManager);

View File

@ -1,4 +1,4 @@
package mineplex.core.observer;
package mineplex.game.clans.clans.observer;
import java.util.EnumSet;

View File

@ -1,4 +1,4 @@
package mineplex.core.observer;
package mineplex.game.clans.clans.observer;
import java.util.HashMap;
import java.util.Map;
@ -19,19 +19,24 @@ 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.observer.command.ObserverCommand;
import mineplex.game.clans.clans.ClansManager;
import mineplex.game.clans.clans.observer.command.ObserverCommand;
import mineplex.game.clans.core.repository.ClanTerritory;
import mineplex.minecraft.game.core.condition.ConditionManager;
public class ObserverManager extends MiniPlugin
{
// Used to Cloak Players
// private ConditionManager _conditionManager;
private ConditionManager _conditionManager;
private ClansManager _clansManager;
private HashMap<Player, ObserverData> _observerMap;
public ObserverManager(JavaPlugin plugin)
public ObserverManager(JavaPlugin plugin, ConditionManager conditionManager, ClansManager clansManager)
{
super("Observer", plugin);
// _conditionManager = conditionManager;
_conditionManager = conditionManager;
_clansManager = clansManager;
_observerMap = new HashMap<Player, ObserverData>();
}
@ -39,8 +44,8 @@ public class ObserverManager extends MiniPlugin
{
ObserverData data = new ObserverData(player);
((CraftPlayer) player).getHandle().spectating = true;
// _conditionManager.Clean(player);
// _conditionManager.Factory().Cloak("Observer", player, null, 999999999, true, true);
_conditionManager.Clean(player);
_conditionManager.Factory().Cloak("Observer", player, null, 999999999, true, true);
UtilPlayer.clearInventory(player);
UtilPlayer.clearPotionEffects(player);
player.setGameMode(GameMode.CREATIVE);
@ -139,6 +144,21 @@ public class ObserverManager extends MiniPlugin
}
}
public boolean canEnterObserverMode(Player player, boolean notify)
{
ClanTerritory territory = _clansManager.getClanUtility().getClaim(player.getLocation());
if (territory == null || !territory.Safe)
{
if (notify)
UtilPlayer.message(player, F.main("Observer", "You must be in a Safe Zone to use observer mode!"));
return false;
}
return true;
}
private void notify(Player player, String message)
{
UtilPlayer.message(player, F.main("Observer", message));

View File

@ -1,4 +1,4 @@
package mineplex.core.observer;
package mineplex.game.clans.clans.observer;
import java.util.EnumSet;
@ -15,7 +15,7 @@ public enum ObserverSettings
public static EnumSet<ObserverSettings> getSettings(Rank rank)
{
if (rank.Has(Rank.DEVELOPER))
if (rank.has(Rank.DEVELOPER))
return EnumSet.of(CAN_OPEN_CHESTS);
return EnumSet.noneOf(ObserverSettings.class);

View File

@ -1,4 +1,4 @@
package mineplex.core.observer.command;
package mineplex.game.clans.clans.observer.command;
import org.bukkit.entity.Player;
@ -6,13 +6,15 @@ 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.observer.ObserverManager;
import mineplex.game.clans.clans.ClansManager;
import mineplex.game.clans.clans.ClansUtility;
import mineplex.game.clans.clans.observer.ObserverManager;
public class ObserverCommand extends CommandBase<ObserverManager>
{
public ObserverCommand(ObserverManager plugin)
{
super(plugin, Rank.DEVELOPER, "observer", "o");
super(plugin, Rank.ALL, "observer", "o");
}
@Override
@ -28,6 +30,9 @@ public class ObserverCommand extends CommandBase<ObserverManager>
}
else
{
if (!Plugin.canEnterObserverMode(caller, true))
return;
Plugin.setObserver(caller);
UtilPlayer.message(caller, F.main("Observer", "You have entered " + F.elem("Observer Mode")));
}

View File

@ -431,7 +431,7 @@ public class ServerNpcPage extends ShopPageInventory<ServerManager, ServerNpcSho
ShopItem shopItem = buildShopItem(serverInfo, slotsNeeded);
addButton(slot, shopItem, new JoinServerButton(this, serverInfo));
addButton(slot, shopItem, new JoinServerButton(this, getPlugin(), serverInfo, getPlayer()));
slot++;
}

View File

@ -38,7 +38,7 @@ public class JoinServerButton implements IButton
System.out.println("Selecting server :" + serverInfo.Name);
int slots = _serverManager.getRequiredSlots(player, serverInfo.ServerType);
if (serverInfo.getAvailableSlots() < slots && !(_page.getDonationManager().Get(_player.getName()).OwnsUnknownPackage(serverInfo.ServerType + " ULTRA") || _page.getClient().GetRank().Has(Rank.ULTRA)))
if (serverInfo.getAvailableSlots() < slots && !(_page.getDonationManager().Get(_player.getName()).OwnsUnknownPackage(serverInfo.ServerType + " ULTRA") || _page.getClient().GetRank().has(Rank.ULTRA)))
{
_page.playDenySound(player);

View File

@ -90,7 +90,7 @@ public class PerkBlockTossEVO extends Perk implements IThrown
if (UtilBlock.usable(grab))
return;
if (!UtilBlock.airFoliage(grab.getRelative(BlockFace.UP)) || Manager.GetBlockRestore().Contains(grab.getRelative(BlockFace.UP)))
if (!UtilBlock.airFoliage(grab.getRelative(BlockFace.UP)) || Manager.GetBlockRestore().contains(grab.getRelative(BlockFace.UP)))
{
UtilPlayer.message(player, F.main("Game", "You may not pick up that block!"));
return;

View File

@ -111,6 +111,6 @@ public class PerkWebEVO extends Perk implements IThrown
Location loc = data.GetThrown().getLocation();
data.GetThrown().remove();
Manager.GetBlockRestore().Add(loc.getBlock(), 30, (byte)0, 4000);
Manager.GetBlockRestore().add(loc.getBlock(), 30, (byte)0, 4000);
}
}