Merge branch 'master' of ssh://184.154.0.242:7999/min/mineplex
This commit is contained in:
commit
17e34e2060
@ -35,6 +35,14 @@ public class ChildJsonMessage extends JsonMessage
|
||||
return this;
|
||||
}
|
||||
|
||||
@Override
|
||||
public ChildJsonMessage bold()
|
||||
{
|
||||
super.bold();
|
||||
|
||||
return this;
|
||||
}
|
||||
|
||||
@Override
|
||||
public ChildJsonMessage click(String action, String value)
|
||||
{
|
||||
|
@ -25,6 +25,13 @@ public class JsonMessage
|
||||
return this;
|
||||
}
|
||||
|
||||
public JsonMessage bold()
|
||||
{
|
||||
Builder.append(", bold:true");
|
||||
|
||||
return this;
|
||||
}
|
||||
|
||||
public ChildJsonMessage extra(String text)
|
||||
{
|
||||
Builder.append(", \"extra\":[");
|
||||
|
@ -5,8 +5,8 @@ import java.util.Calendar;
|
||||
|
||||
public class UtilTime
|
||||
{
|
||||
public static final String DATE_FORMAT_NOW = "yyyy-MM-dd HH:mm:ss";
|
||||
public static final String DATE_FORMAT_DAY = "yyyy-MM-dd";
|
||||
public static final String DATE_FORMAT_NOW = "MM-dd-yyyy HH:mm:ss";
|
||||
public static final String DATE_FORMAT_DAY = "MM-dd-yyyy";
|
||||
|
||||
public static String now()
|
||||
{
|
||||
|
@ -1,6 +1,7 @@
|
||||
package mineplex.core;
|
||||
|
||||
import java.lang.reflect.Field;
|
||||
import java.util.Iterator;
|
||||
import java.util.List;
|
||||
|
||||
import mineplex.core.common.DummyEntity;
|
||||
@ -11,6 +12,8 @@ import mineplex.core.packethandler.PacketHandler;
|
||||
import mineplex.core.common.util.UtilPlayer;
|
||||
import mineplex.core.packethandler.PacketVerifier;
|
||||
import mineplex.core.packethandler.PacketInfo;
|
||||
import mineplex.core.updater.UpdateType;
|
||||
import mineplex.core.updater.event.UpdateEvent;
|
||||
import net.minecraft.server.v1_7_R4.DataWatcher;
|
||||
import net.minecraft.server.v1_7_R4.EnumEntitySize;
|
||||
import net.minecraft.server.v1_7_R4.MathHelper;
|
||||
@ -23,6 +26,7 @@ import net.minecraft.server.v1_7_R4.WatchableObject;
|
||||
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.craftbukkit.v1_7_R4.CraftWorld;
|
||||
import org.bukkit.entity.EntityType;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.event.EventHandler;
|
||||
import org.bukkit.event.player.PlayerQuitEvent;
|
||||
@ -31,6 +35,7 @@ import org.bukkit.plugin.java.JavaPlugin;
|
||||
public class CustomTagFix extends MiniPlugin implements IPacketHandler
|
||||
{
|
||||
private NautHashMap<Player, NautHashMap<Integer, Integer>> _entityMap = new NautHashMap<Player, NautHashMap<Integer, Integer>>();
|
||||
private NautHashMap<Player, Long> _loggedIn = new NautHashMap<Player, Long>();
|
||||
|
||||
private Field _destroyId;
|
||||
|
||||
@ -56,6 +61,26 @@ public class CustomTagFix extends MiniPlugin implements IPacketHandler
|
||||
public void playerQuit(PlayerQuitEvent event)
|
||||
{
|
||||
_entityMap.remove(event.getPlayer());
|
||||
_loggedIn.remove(event.getPlayer());
|
||||
}
|
||||
|
||||
@EventHandler
|
||||
public void cleanMap(UpdateEvent event)
|
||||
{
|
||||
if (event.getType() != UpdateType.SEC)
|
||||
return;
|
||||
|
||||
for (Iterator<Player> iterator = _loggedIn.keySet().iterator(); iterator.hasNext();)
|
||||
{
|
||||
Player player = iterator.next();
|
||||
|
||||
if (System.currentTimeMillis() - _loggedIn.get(player) > 5000 && !player.isOnline())
|
||||
{
|
||||
iterator.remove();
|
||||
_entityMap.remove(player);
|
||||
System.out.println("Found broken player in CustomTagFix.... '" + player.getName() + "'");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@SuppressWarnings("unchecked")
|
||||
@ -68,10 +93,13 @@ public class CustomTagFix extends MiniPlugin implements IPacketHandler
|
||||
Player owner = packetInfo.getPlayer();
|
||||
PacketVerifier verifier = packetInfo.getVerifier();
|
||||
|
||||
if (UtilPlayer.is1_8(owner))
|
||||
if (owner.isOnline() && UtilPlayer.is1_8(owner))
|
||||
{
|
||||
if (owner.isOnline() && !_entityMap.containsKey(owner))
|
||||
{
|
||||
_entityMap.put(owner, new NautHashMap<Integer, Integer>());
|
||||
_loggedIn.put(owner, System.currentTimeMillis());
|
||||
}
|
||||
|
||||
if (packet instanceof PacketPlayOutSpawnEntityLiving)
|
||||
{
|
||||
@ -152,13 +180,15 @@ public class CustomTagFix extends MiniPlugin implements IPacketHandler
|
||||
|
||||
if (attachPacket.c == owner.getEntityId())
|
||||
{
|
||||
packetInfo.setCancelled(true);
|
||||
//verifier.bypassProcess(new PacketPlayOutEntityDestroy(attachPacket.b));
|
||||
/*
|
||||
System.out.println("Adding patch item.");
|
||||
System.out.println("Yea, adding patch mount item.");
|
||||
if (_entityMap.get(owner).containsKey(attachPacket.b))
|
||||
{
|
||||
verifier.bypassProcess(new PacketPlayOutEntityDestroy(_entityMap.get(owner).get(attachPacket.b)));
|
||||
}
|
||||
|
||||
PacketPlayOutSpawnEntityLiving armorPacket = new PacketPlayOutSpawnEntityLiving();
|
||||
armorPacket.a = _fakeIdCounter++;
|
||||
armorPacket.b = (byte) EntityType.SLIME.getTypeId();
|
||||
armorPacket.a = UtilEnt.getNewEntityId();
|
||||
armorPacket.b = (byte) 30;
|
||||
armorPacket.c = (int)EnumEntitySize.SIZE_2.a(100);
|
||||
armorPacket.d = (int)MathHelper.floor(64 * 32.0D);
|
||||
armorPacket.e = (int)EnumEntitySize.SIZE_2.a(100);
|
||||
@ -230,16 +260,21 @@ public class CustomTagFix extends MiniPlugin implements IPacketHandler
|
||||
|
||||
armorPacket.l = watcher;
|
||||
|
||||
verifier.bypassProcess(packet);
|
||||
|
||||
attachPacket.c = armorPacket.a;
|
||||
// Spawn armor packet
|
||||
verifier.bypassProcess(armorPacket);
|
||||
|
||||
PacketPlayOutAttachEntity attachPacket2 = new PacketPlayOutAttachEntity();
|
||||
attachPacket2.c = owner.getEntityId();
|
||||
attachPacket2.b = attachPacket.a;
|
||||
attachPacket2.b = armorPacket.a;
|
||||
attachPacket2.a = 0;
|
||||
verifier.bypassProcess(packet);
|
||||
*/
|
||||
|
||||
// Send armor attach to player.
|
||||
verifier.bypassProcess(attachPacket2);
|
||||
|
||||
// Change original packet to attach to armor stand
|
||||
attachPacket.c = armorPacket.a;
|
||||
|
||||
_entityMap.get(owner).put(attachPacket.b, armorPacket.a);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -1,8 +1,6 @@
|
||||
package mineplex.core.achievement;
|
||||
|
||||
import org.bukkit.ChatColor;
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.inventory.ItemStack;
|
||||
|
||||
/**
|
||||
* Created by Shaun on 8/21/2014.
|
||||
@ -11,8 +9,8 @@ import org.bukkit.inventory.ItemStack;
|
||||
public enum AchievementCategory
|
||||
{
|
||||
GLOBAL("Global", null,
|
||||
new String[] { "GemsEarned" },
|
||||
new String[] { "Gems Earned" },
|
||||
new String[] { "GemsEarned", null, "GamesPlayed", "TimeInGame" },
|
||||
new String[] { "Gems Earned", null, "Games Played", "Time In Game" },
|
||||
Material.EMERALD, 0, GameCategory.GLOBAL),
|
||||
|
||||
//Survival
|
||||
|
@ -15,7 +15,9 @@ import mineplex.core.achievement.AchievementManager;
|
||||
import mineplex.core.achievement.ui.AchievementShop;
|
||||
import mineplex.core.achievement.ui.button.ArcadeButton;
|
||||
import mineplex.core.achievement.ui.button.CategoryButton;
|
||||
import mineplex.core.common.Rank;
|
||||
import mineplex.core.common.util.C;
|
||||
import mineplex.core.common.util.UtilTime;
|
||||
import mineplex.core.donation.DonationManager;
|
||||
import mineplex.core.shop.item.ShopItem;
|
||||
import mineplex.core.shop.page.ShopPageBase;
|
||||
@ -55,7 +57,7 @@ public class AchievementMainPage extends ShopPageBase<AchievementManager, Achiev
|
||||
|
||||
ArrayList<String> lore = new ArrayList<String>();
|
||||
lore.add(" ");
|
||||
addStats(category, lore, 2);
|
||||
addStats(category, lore, category == AchievementCategory.GLOBAL ? 5 : 2);
|
||||
lore.add(" ");
|
||||
addAchievements(category, lore, 9);
|
||||
lore.add(" ");
|
||||
@ -88,17 +90,27 @@ public class AchievementMainPage extends ShopPageBase<AchievementManager, Achiev
|
||||
PlayerStats stats = _statsManager.Get(_target);
|
||||
for (int i = 0; i < statsToDisplay.length && i < max; i++)
|
||||
{
|
||||
// Skip showing Losses, Kills, Deaths for other players
|
||||
if ((!Player.equals(_target)) && (statsToDisplay[i].equalsIgnoreCase("Losses") || statsToDisplay[i].contains("Kills") || statsToDisplay[i].contains("Deaths")))
|
||||
// If the stat is null then just display a blank line instead
|
||||
if (statsToDisplay[i] == null || friendlyStatNames[i] == null)
|
||||
{
|
||||
lore.add(" ");
|
||||
continue;
|
||||
}
|
||||
|
||||
String statName = statsToDisplay[i];
|
||||
// Skip showing Losses, Kills, Deaths for other players
|
||||
if (!ClientManager.Get(Player).GetRank().Has(Rank.MODERATOR) && !Player.equals(_target) && (statsToDisplay[i].contains("Losses") || statsToDisplay[i].contains("Kills") || statsToDisplay[i].contains("Deaths") || statsToDisplay[i].equals("Time In Game") || statsToDisplay.equals("Games Played")))
|
||||
continue;
|
||||
|
||||
int statNumber = 0;
|
||||
for (String statToPull : category.getStatsToPull())
|
||||
statNumber += stats.getStat(statToPull + "." + statName);
|
||||
statNumber += stats.getStat(statToPull + "." + statsToDisplay[i]);
|
||||
|
||||
lore.add(C.cYellow + friendlyStatNames[i] + ": " + C.cWhite + statNumber);
|
||||
String statString = C.cWhite + statNumber;
|
||||
// Need to display special for time
|
||||
if (statsToDisplay[i].equalsIgnoreCase("TimeInGame"))
|
||||
statString = C.cWhite + UtilTime.convertString(statNumber, 0, UtilTime.TimeUnit.SECONDS);
|
||||
|
||||
lore.add(C.cYellow + friendlyStatNames[i] + ": " + statString);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -16,7 +16,9 @@ import mineplex.core.achievement.AchievementCategory;
|
||||
import mineplex.core.achievement.AchievementData;
|
||||
import mineplex.core.achievement.AchievementManager;
|
||||
import mineplex.core.achievement.ui.AchievementShop;
|
||||
import mineplex.core.common.Rank;
|
||||
import mineplex.core.common.util.C;
|
||||
import mineplex.core.common.util.UtilTime;
|
||||
import mineplex.core.donation.DonationManager;
|
||||
import mineplex.core.shop.item.ShopItem;
|
||||
import mineplex.core.shop.item.SingleButton;
|
||||
@ -162,15 +164,28 @@ public class AchievementPage extends ShopPageBase<AchievementManager, Achievemen
|
||||
String[] friendlyStatNames = _category.getFriendlyStatNames();
|
||||
for (int i = 0; i < statsToDisplay.length; i++)
|
||||
{
|
||||
// If the stat is null then just display a blank line instead
|
||||
if (statsToDisplay[i] == null || friendlyStatNames[i] == null)
|
||||
{
|
||||
lore.add(" ");
|
||||
continue;
|
||||
}
|
||||
|
||||
// Skip showing Losses, Kills, Deaths for other players
|
||||
if ((!Player.equals(_target)) && (statsToDisplay[i].equalsIgnoreCase("Losses") || statsToDisplay[i].contains("Kills") || statsToDisplay[i].contains("Deaths")))
|
||||
if (!ClientManager.Get(Player).GetRank().Has(Rank.MODERATOR) && !Player.equals(_target) && (statsToDisplay[i].contains("Losses") || statsToDisplay[i].contains("Kills") || statsToDisplay[i].contains("Deaths") || statsToDisplay[i].equals("Time In Game") || statsToDisplay.equals("Games Played")))
|
||||
continue;
|
||||
|
||||
int statNumber = 0;
|
||||
for (String statToPull : _category.getStatsToPull())
|
||||
statNumber += stats.getStat(statToPull + "." + statsToDisplay[i]);
|
||||
|
||||
lore.add(C.cYellow + friendlyStatNames[i] + ": " + C.cWhite + statNumber);
|
||||
String statString = C.cWhite + statNumber;
|
||||
|
||||
// Need to display special for time
|
||||
if (statsToDisplay[i].equalsIgnoreCase("TimeInGame"))
|
||||
statString = UtilTime.convertString(statNumber, 0, UtilTime.TimeUnit.SECONDS);
|
||||
|
||||
lore.add(C.cYellow + friendlyStatNames[i] + ": " + statString);
|
||||
}
|
||||
|
||||
ItemStack item = new ItemStack(material);
|
||||
|
@ -6,20 +6,6 @@ import java.util.HashSet;
|
||||
import java.util.Iterator;
|
||||
import java.util.Map.Entry;
|
||||
|
||||
import mineplex.core.MiniPlugin;
|
||||
import mineplex.core.antihack.types.*;
|
||||
import mineplex.core.common.util.C;
|
||||
import mineplex.core.common.util.F;
|
||||
import mineplex.core.common.util.UtilEnt;
|
||||
import mineplex.core.common.util.UtilGear;
|
||||
import mineplex.core.common.util.UtilPlayer;
|
||||
import mineplex.core.common.util.UtilServer;
|
||||
import mineplex.core.common.util.UtilTime;
|
||||
import mineplex.core.portal.Portal;
|
||||
import mineplex.core.punish.Punish;
|
||||
import mineplex.core.updater.UpdateType;
|
||||
import mineplex.core.updater.event.UpdateEvent;
|
||||
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.GameMode;
|
||||
import org.bukkit.Material;
|
||||
@ -33,6 +19,24 @@ import org.bukkit.event.player.PlayerVelocityEvent;
|
||||
import org.bukkit.event.server.ServerListPingEvent;
|
||||
import org.bukkit.plugin.java.JavaPlugin;
|
||||
|
||||
import mineplex.core.MiniPlugin;
|
||||
import mineplex.core.account.CoreClientManager;
|
||||
import mineplex.core.antihack.types.Fly;
|
||||
import mineplex.core.antihack.types.Idle;
|
||||
import mineplex.core.antihack.types.Speed;
|
||||
import mineplex.core.common.Rank;
|
||||
import mineplex.core.common.util.C;
|
||||
import mineplex.core.common.util.F;
|
||||
import mineplex.core.common.util.UtilEnt;
|
||||
import mineplex.core.common.util.UtilPlayer;
|
||||
import mineplex.core.common.util.UtilServer;
|
||||
import mineplex.core.common.util.UtilTime;
|
||||
import mineplex.core.portal.Portal;
|
||||
import mineplex.core.preferences.PreferencesManager;
|
||||
import mineplex.core.punish.Punish;
|
||||
import mineplex.core.updater.UpdateType;
|
||||
import mineplex.core.updater.event.UpdateEvent;
|
||||
|
||||
public class AntiHack extends MiniPlugin
|
||||
{
|
||||
private static Object _antiHackLock = new Object();
|
||||
@ -43,6 +47,8 @@ public class AntiHack extends MiniPlugin
|
||||
|
||||
public Punish Punish;
|
||||
public Portal Portal;
|
||||
private PreferencesManager _preferences;
|
||||
private CoreClientManager _clientManager;
|
||||
|
||||
//Record Offenses
|
||||
private HashMap<Player, HashMap<String, ArrayList<Long>>> _suspicion = new HashMap<Player, HashMap<String, ArrayList<Long>>>();
|
||||
@ -71,12 +77,14 @@ public class AntiHack extends MiniPlugin
|
||||
|
||||
private AntiHackRepository _repository;
|
||||
|
||||
protected AntiHack(JavaPlugin plugin, Punish punish, Portal portal)
|
||||
protected AntiHack(JavaPlugin plugin, Punish punish, Portal portal, PreferencesManager preferences, CoreClientManager clientManager)
|
||||
{
|
||||
super("AntiHack", plugin);
|
||||
|
||||
Punish = punish;
|
||||
Portal = portal;
|
||||
_preferences = preferences;
|
||||
_clientManager = clientManager;
|
||||
|
||||
_repository = new AntiHackRepository(plugin.getConfig().getString("serverstatus.name"));
|
||||
_repository.initialize();
|
||||
@ -88,9 +96,9 @@ public class AntiHack extends MiniPlugin
|
||||
_detectors.add(new Speed(this));
|
||||
}
|
||||
|
||||
public static void Initialize(JavaPlugin plugin, Punish punish, Portal portal)
|
||||
public static void Initialize(JavaPlugin plugin, Punish punish, Portal portal, PreferencesManager preferences, CoreClientManager clientManager)
|
||||
{
|
||||
Instance = new AntiHack(plugin, punish, portal);
|
||||
Instance = new AntiHack(plugin, punish, portal, preferences, clientManager);
|
||||
}
|
||||
|
||||
@EventHandler
|
||||
@ -248,7 +256,7 @@ public class AntiHack extends MiniPlugin
|
||||
}
|
||||
|
||||
for (Player admin : UtilServer.getPlayers())
|
||||
if (admin.isOp() && UtilGear.isMat(admin.getItemInHand(), Material.PAPER))
|
||||
if (_clientManager.Get(admin).GetRank().Has(Rank.MODERATOR) && _preferences.Get(admin).ShowMacReports)
|
||||
UtilPlayer.message(admin, C.cRed + C.Bold + player.getName() + " suspected for " + type + ".");
|
||||
|
||||
// Print (Debug)
|
||||
|
@ -1,47 +1,42 @@
|
||||
package mineplex.core.friend;
|
||||
|
||||
import net.minecraft.server.v1_7_R4.PacketPlayOutPlayerInfo;
|
||||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.ChatColor;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.event.EventHandler;
|
||||
import org.bukkit.event.player.PlayerJoinEvent;
|
||||
import org.bukkit.event.player.PlayerQuitEvent;
|
||||
import org.bukkit.plugin.java.JavaPlugin;
|
||||
|
||||
import mineplex.core.MiniClientPlugin;
|
||||
import mineplex.core.account.event.RetrieveClientInformationEvent;
|
||||
import mineplex.core.common.jsonchat.ChildJsonMessage;
|
||||
import mineplex.core.common.jsonchat.JsonMessage;
|
||||
import mineplex.core.common.util.C;
|
||||
import mineplex.core.common.util.F;
|
||||
import mineplex.core.common.util.NautHashMap;
|
||||
import mineplex.core.common.util.UtilServer;
|
||||
import mineplex.core.common.util.UtilTime;
|
||||
import mineplex.core.friend.command.AddFriend;
|
||||
import mineplex.core.friend.command.DeleteFriend;
|
||||
import mineplex.core.friend.data.FriendData;
|
||||
import mineplex.core.friend.data.FriendRepository;
|
||||
import mineplex.core.friend.ui.FriendTabList;
|
||||
import mineplex.core.packethandler.IPacketHandler;
|
||||
import mineplex.core.packethandler.PacketHandler;
|
||||
import mineplex.core.packethandler.PacketInfo;
|
||||
import mineplex.core.timing.TimingManager;
|
||||
import mineplex.core.friend.data.FriendStatus;
|
||||
import mineplex.core.updater.UpdateType;
|
||||
import mineplex.core.updater.event.UpdateEvent;
|
||||
|
||||
public class FriendManager extends MiniClientPlugin<FriendData> implements IPacketHandler
|
||||
public class FriendManager extends MiniClientPlugin<FriendData>
|
||||
{
|
||||
private static FriendSorter _friendSorter = new FriendSorter();
|
||||
|
||||
private FriendRepository _repository;
|
||||
|
||||
private NautHashMap<Player, FriendTabList> _playerTabMap;
|
||||
private boolean _sendingPackets = false;
|
||||
|
||||
public FriendManager(JavaPlugin plugin, PacketHandler packetHandler)
|
||||
public FriendManager(JavaPlugin plugin)
|
||||
{
|
||||
super("Friends", plugin);
|
||||
|
||||
packetHandler.addPacketHandler(this);
|
||||
|
||||
_repository = new FriendRepository(plugin);
|
||||
_playerTabMap = new NautHashMap<Player, FriendTabList>();
|
||||
}
|
||||
|
||||
@Override
|
||||
@ -65,31 +60,12 @@ public class FriendManager extends MiniClientPlugin<FriendData> implements IPack
|
||||
{
|
||||
public void run()
|
||||
{
|
||||
TimingManager.start(event.getPlayerName() + " friend Account call.");
|
||||
Set(event.getPlayerName(), _repository.loadClientInformation(event.getUniqueId()));
|
||||
TimingManager.stop(event.getPlayerName() + " friend Account call.");
|
||||
event.decreaseProcessingCount();
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
@EventHandler
|
||||
public void updateTabLists(UpdateEvent event)
|
||||
{
|
||||
if (event.getType() != UpdateType.SEC)
|
||||
return;
|
||||
|
||||
_sendingPackets = true;
|
||||
for (Player player : Bukkit.getOnlinePlayers())
|
||||
{
|
||||
if (!_playerTabMap.containsKey(player) || !_playerTabMap.get(player).shouldUpdate())
|
||||
continue;
|
||||
|
||||
_playerTabMap.get(player).refreshForPlayer(player);
|
||||
}
|
||||
_sendingPackets = false;
|
||||
}
|
||||
|
||||
@EventHandler
|
||||
public void updateFriends(UpdateEvent event)
|
||||
{
|
||||
@ -106,7 +82,7 @@ public class FriendManager extends MiniClientPlugin<FriendData> implements IPack
|
||||
{
|
||||
public void run()
|
||||
{
|
||||
for (Player player : _playerTabMap.keySet())
|
||||
for (Player player : Bukkit.getOnlinePlayers())
|
||||
{
|
||||
if (newData.containsKey(player.getUniqueId().toString()))
|
||||
{
|
||||
@ -116,8 +92,6 @@ public class FriendManager extends MiniClientPlugin<FriendData> implements IPack
|
||||
{
|
||||
Get(player).Friends.clear();
|
||||
}
|
||||
|
||||
_playerTabMap.get(player).updateFriends(Get(player).Friends);
|
||||
}
|
||||
}
|
||||
});
|
||||
@ -125,37 +99,13 @@ public class FriendManager extends MiniClientPlugin<FriendData> implements IPack
|
||||
});
|
||||
}
|
||||
|
||||
@EventHandler
|
||||
public void addFriendTab(PlayerJoinEvent event)
|
||||
{
|
||||
_playerTabMap.put(event.getPlayer(), new FriendTabList(Get(event.getPlayer().getName()).Friends));
|
||||
_playerTabMap.get(event.getPlayer()).refreshForPlayer(event.getPlayer());
|
||||
}
|
||||
|
||||
@EventHandler
|
||||
public void removeFriendTab(PlayerQuitEvent event)
|
||||
{
|
||||
_playerTabMap.remove(event.getPlayer());
|
||||
}
|
||||
|
||||
public void handle(PacketInfo packetInfo)
|
||||
{
|
||||
if (packetInfo.isCancelled())
|
||||
return;
|
||||
|
||||
if (packetInfo.getPacket() instanceof PacketPlayOutPlayerInfo)
|
||||
{
|
||||
packetInfo.setCancelled(_sendingPackets);
|
||||
}
|
||||
}
|
||||
|
||||
public void addFriend(final Player caller, final String name)
|
||||
{
|
||||
Bukkit.getServer().getScheduler().runTaskAsynchronously(GetPlugin(), new Runnable()
|
||||
{
|
||||
public void run()
|
||||
{
|
||||
_repository.addFriend(caller.getUniqueId().toString(), name);
|
||||
_repository.addFriend(caller, name);
|
||||
|
||||
Bukkit.getServer().getScheduler().runTask(_plugin, new Runnable()
|
||||
{
|
||||
@ -186,4 +136,31 @@ public class FriendManager extends MiniClientPlugin<FriendData> implements IPack
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
public void showFriends(Player caller)
|
||||
{
|
||||
List<FriendStatus> friendStatuses = Get(caller).Friends;
|
||||
Collections.sort(friendStatuses, _friendSorter);
|
||||
|
||||
caller.sendMessage(C.cBlue + "======================[" + ChatColor.RESET + C.cYellow + C.Bold + "Friends" + ChatColor.RESET + C.cBlue + "]======================");
|
||||
|
||||
for (FriendStatus friend : friendStatuses)
|
||||
{
|
||||
ChildJsonMessage message = new JsonMessage(friend.Name).color(friend.Online ? "gold" : "gray").extra(" - ").color("white");
|
||||
|
||||
if (friend.Online)
|
||||
{
|
||||
if (friend.Mutual)
|
||||
message.add(friend.ServerName + " Connect").color("green").bold().click("run_command", "/server " + friend.ServerName).add(" - ").color("white");
|
||||
else
|
||||
message.add("Friend request pending").color("yellow").add(" - ").color("white");
|
||||
}
|
||||
else
|
||||
message.add("Last online : ").color("blue").add(UtilTime.when(friend.LastSeenOnline)).color("yellow").add(" - ").color("white");
|
||||
|
||||
message.add("Unfriend").color("red").bold().click("run_command", "/unfriend " + friend.Name).sendToPlayer(caller);
|
||||
}
|
||||
|
||||
caller.sendMessage(C.cBlue + "=====================================================");
|
||||
}
|
||||
}
|
||||
|
@ -19,7 +19,9 @@ public class AddFriend extends CommandBase<FriendManager>
|
||||
public void Execute(final Player caller, final String[] args)
|
||||
{
|
||||
if (args == null)
|
||||
F.main(Plugin.GetName(), "You need to include a player's name.");
|
||||
{
|
||||
Plugin.showFriends(caller);
|
||||
}
|
||||
else
|
||||
{
|
||||
CommandCenter.GetClientManager().checkPlayerName(caller, args[0], new Callback<Boolean>()
|
||||
|
@ -14,12 +14,18 @@ import mineplex.core.database.column.ColumnVarChar;
|
||||
|
||||
public class FriendRepository extends RepositoryBase
|
||||
{
|
||||
private static String CREATE_FRIEND_TABLE = "CREATE TABLE IF NOT EXISTS accountFriend (id INT NOT NULL AUTO_INCREMENT, uuidSource VARCHAR(100), uuidTarget VARCHAR(100), mutual BOOL, PRIMARY KEY (id), INDEX uuidIndex (uuidSource, uuidTarget));";
|
||||
private static String RETRIEVE_MULTIPLE_FRIEND_RECORDS = "SELECT uuidSource, tA.Name, mutual, serverName, tA.lastLogin FROM accountFriend INNER Join accounts AS fA ON fA.uuid = uuidSource INNER JOIN accounts AS tA ON tA.uuid = uuidTarget LEFT JOIN playerMap ON tA.name = playerName WHERE uuidSource IN ";
|
||||
private static String CREATE_FRIEND_TABLE = "CREATE TABLE IF NOT EXISTS accountFriend (id INT NOT NULL AUTO_INCREMENT, uuidSource VARCHAR(100), uuidTarget VARCHAR(100), status VARCHAR(100), PRIMARY KEY (id), UNIQUE INDEX uuidIndex (uuidSource, uuidTarget));";
|
||||
private static String RETRIEVE_MULTIPLE_FRIEND_RECORDS = "SELECT uuidSource, tA.Name, status, serverName, tA.lastLogin FROM accountFriend INNER Join accounts AS fA ON fA.uuid = uuidSource INNER JOIN accounts AS tA ON tA.uuid = uuidTarget LEFT JOIN playerMap ON tA.name = playerName WHERE uuidSource IN ";
|
||||
private static String RETRIEVE_FRIEND_RECORDS = "SELECT tA.Name, mutual, serverName, tA.lastLogin FROM accountFriend INNER Join accounts AS fA ON fA.uuid = uuidSource INNER JOIN accounts AS tA ON tA.uuid = uuidTarget LEFT JOIN playerMap ON tA.name = playerName WHERE uuidSource = ?;";
|
||||
private static String ADD_FRIEND_RECORD = "INSERT INTO accountFriend (uuidSource, uuidTarget) SELECT fA.uuid AS uuidSource, tA.uuid AS uuidTarget FROM accounts as fA LEFT JOIN accounts AS tA ON tA.name = ? WHERE fA.uuid = ?;";
|
||||
private static String RETRIEVE_OTHER_FRIEND_RECORDS_BY_NAME = "SELECT tA.Name, mutual, serverName, tA.lastLogin FROM accountFriend INNER Join accounts AS fA ON fA.uuid = uuidSource INNER JOIN accounts AS tA ON tA.uuid = uuidTarget LEFT JOIN playerMap ON tA.name = playerName WHERE name = ?;";
|
||||
private static String ADD_FRIEND_RECORD = "INSERT INTO accountFriend (uuidSource, uuidTarget, status) SELECT fA.uuid AS uuidSource, tA.uuid AS uuidTarget, 'Pending' FROM accounts as fA LEFT JOIN accounts AS tA ON tA.name = ? WHERE fA.name = ?;";
|
||||
private static String UPDATE_MUTUAL_RECORD = "UPDATE aF SET status = ? FROM accountFriend AS aF INNER JOIN accounts as fA LEFT JOIN accounts AS tA ON tA.name = ? WHERE fA.name = ?;";
|
||||
private static String DELETE_FRIEND_RECORD = "DELETE aF FROM accountFriend AS aF INNER JOIN accounts ON accounts.name = ? WHERE uuidSource = ? AND uuidTarget = accounts.uuid;";
|
||||
|
||||
|
||||
// Not mutual, need to drop accountFriend to recreate with constraint.
|
||||
// On add record need to check for a reverse uuidsource/uuidtarget and set mutual
|
||||
|
||||
public FriendRepository(JavaPlugin plugin)
|
||||
{
|
||||
super(plugin, "jdbc:mysql://db.mineplex.com:3306/Account?autoReconnect=true&failOverReadOnly=false&maxReconnects=10", "root", "tAbechAk3wR7tuTh");
|
||||
@ -36,14 +42,34 @@ public class FriendRepository extends RepositoryBase
|
||||
{
|
||||
}
|
||||
|
||||
public boolean addFriend(String uuid, String name)
|
||||
public boolean addFriend(final Player caller, String name)
|
||||
{
|
||||
return executeUpdate(ADD_FRIEND_RECORD, new ColumnVarChar("name", 40, name), new ColumnVarChar("uuid", 100, uuid)) > 0;
|
||||
int rowsAffected = executeUpdate(ADD_FRIEND_RECORD, new ColumnVarChar("name", 100, name), new ColumnVarChar("name", 100, caller.getName()));
|
||||
|
||||
if (rowsAffected > 0)
|
||||
return executeUpdate(ADD_FRIEND_RECORD, new ColumnVarChar("name", 100, caller.getName()), new ColumnVarChar("uuid", 100, name)) > 0;
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
public boolean removeFriend(String uuid, String name)
|
||||
public boolean updateFriend(Player caller, String name, String status)
|
||||
{
|
||||
return executeUpdate(DELETE_FRIEND_RECORD, new ColumnVarChar("name", 40, name), new ColumnVarChar("uuid", 100, uuid)) > 0;
|
||||
int rowsAffected = executeUpdate(UPDATE_MUTUAL_RECORD, new ColumnVarChar("status", 100, status), new ColumnVarChar("name", 100, name), new ColumnVarChar("name", 100, caller.getName()));
|
||||
|
||||
if (rowsAffected > 0)
|
||||
return executeUpdate(UPDATE_MUTUAL_RECORD, new ColumnVarChar("status", 100, status), new ColumnVarChar("name", 100, caller.getName()), new ColumnVarChar("uuid", 100, name)) > 0;
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
public boolean removeFriend(String caller, String name)
|
||||
{
|
||||
int rowsAffected = executeUpdate(DELETE_FRIEND_RECORD, new ColumnVarChar("name", 100, name), new ColumnVarChar("name", 100, caller));
|
||||
|
||||
if (rowsAffected > 0)
|
||||
return executeUpdate(DELETE_FRIEND_RECORD, new ColumnVarChar("name", 100, caller), new ColumnVarChar("uuid", 100, name)) > 0;
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
public NautHashMap<String, FriendData> getFriendsForAll(Player...players)
|
||||
@ -73,7 +99,9 @@ public class FriendRepository extends RepositoryBase
|
||||
friend.Name = resultSet.getString(2);
|
||||
friend.Mutual = resultSet.getBoolean(3);
|
||||
friend.ServerName = resultSet.getString(4);
|
||||
friend.LastSeenOnline = resultSet.getLong(5);
|
||||
friend.Online = !friend.ServerName.isEmpty();
|
||||
|
||||
friend.LastSeenOnline = resultSet.getTimestamp(5).getTime();
|
||||
|
||||
if (!friends.containsKey(uuidSource))
|
||||
friends.put(uuidSource, new FriendData());
|
||||
@ -103,8 +131,6 @@ public class FriendRepository extends RepositoryBase
|
||||
friend.ServerName = resultSet.getString(3);
|
||||
friend.LastSeenOnline = resultSet.getLong(4);
|
||||
|
||||
System.out.println("Adding friend " + friend.Name + " for UUID " + uniqueId.toString());
|
||||
|
||||
friendData.Friends.add(friend);
|
||||
}
|
||||
}
|
||||
|
@ -30,7 +30,7 @@ public class FriendTabList extends TabList
|
||||
Collections.sort(friends, _friendSorter);
|
||||
|
||||
int row = 1;
|
||||
for (int i = 0; i < 19; i++)
|
||||
for (int i = 0; i < 16; i++)
|
||||
{
|
||||
if (i < friends.size())
|
||||
{
|
||||
|
@ -13,6 +13,9 @@ import mineplex.core.common.util.NautHashMap;
|
||||
|
||||
public class TabList implements Listener
|
||||
{
|
||||
private static int MAX_SLOTS = 64;
|
||||
private static int COLUMN_SLOTS = 16;
|
||||
|
||||
private static NautHashMap<Integer, String> _invisibleHolders = new NautHashMap<Integer, String>();
|
||||
|
||||
private NautHashMap<Integer, LineTracker> _tabSlots = new NautHashMap<Integer, LineTracker>();
|
||||
@ -23,12 +26,12 @@ public class TabList implements Listener
|
||||
static {
|
||||
String spaces = "";
|
||||
|
||||
for (int i=0; i < 60; i++)
|
||||
for (int i=0; i < MAX_SLOTS; i++)
|
||||
{
|
||||
int markerSymbol = i / 15;
|
||||
int markerSymbol = i / COLUMN_SLOTS;
|
||||
String symbol = null;
|
||||
|
||||
if (i % 15 == 0)
|
||||
if (i % COLUMN_SLOTS == 0)
|
||||
spaces = "";
|
||||
else
|
||||
spaces += " ";
|
||||
@ -56,7 +59,7 @@ public class TabList implements Listener
|
||||
|
||||
public TabList()
|
||||
{
|
||||
for (Integer i=0; i < 60; i++)
|
||||
for (Integer i=0; i < MAX_SLOTS; i++)
|
||||
{
|
||||
_tabSlots.put(i, new LineTracker(_invisibleHolders.get(i)));
|
||||
}
|
||||
@ -64,9 +67,9 @@ public class TabList implements Listener
|
||||
|
||||
public void set(int column, int row, String lineContent)
|
||||
{
|
||||
int index = row * 3 + column;
|
||||
int index = row * 4 + column;
|
||||
|
||||
if (index >= 60)
|
||||
if (index >= MAX_SLOTS)
|
||||
return;
|
||||
|
||||
if (lineContent == null || lineContent.isEmpty())
|
||||
@ -83,21 +86,21 @@ public class TabList implements Listener
|
||||
{
|
||||
EntityPlayer entityPlayer = ((CraftPlayer)player).getHandle();
|
||||
|
||||
int indexChanged = 60;
|
||||
int indexChanged = MAX_SLOTS;
|
||||
|
||||
for (int i=0; i < 60; i++)
|
||||
for (int i=0; i < MAX_SLOTS; i++)
|
||||
{
|
||||
if (indexChanged == 60 && _updatedSlots.contains(i))
|
||||
if (indexChanged == MAX_SLOTS && _updatedSlots.contains(i))
|
||||
{
|
||||
indexChanged = i;
|
||||
}
|
||||
else if (indexChanged != 60 && !_updatedSlots.contains(i))
|
||||
else if (indexChanged != MAX_SLOTS && !_updatedSlots.contains(i))
|
||||
{
|
||||
_tabSlots.get(i).removeLineForPlayer(entityPlayer);
|
||||
}
|
||||
}
|
||||
|
||||
for (int i=indexChanged; i < 60; i++)
|
||||
for (int i=indexChanged; i < MAX_SLOTS; i++)
|
||||
{
|
||||
_tabSlots.get(i).displayLineToPlayer(entityPlayer);
|
||||
}
|
||||
|
@ -1,5 +1,8 @@
|
||||
package mineplex.core.gadget.gadgets;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
import mineplex.core.common.util.C;
|
||||
import mineplex.core.common.util.F;
|
||||
import mineplex.core.common.util.MapUtil;
|
||||
@ -8,9 +11,11 @@ import mineplex.core.common.util.UtilPlayer;
|
||||
import mineplex.core.common.util.UtilServer;
|
||||
import mineplex.core.disguise.disguises.DisguiseCat;
|
||||
import mineplex.core.disguise.disguises.DisguiseChicken;
|
||||
import mineplex.core.gadget.event.GadgetBlockEvent;
|
||||
import mineplex.core.itemstack.ItemStackFactory;
|
||||
import mineplex.core.recharge.Recharge;
|
||||
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.Effect;
|
||||
import org.bukkit.Location;
|
||||
import org.bukkit.Material;
|
||||
@ -24,20 +29,17 @@ import org.bukkit.entity.Player;
|
||||
|
||||
public class BlockForm
|
||||
{
|
||||
public MorphBlock Host;
|
||||
|
||||
public Player Player;
|
||||
private MorphBlock _host;
|
||||
private Player _player;
|
||||
|
||||
private Material _mat;
|
||||
|
||||
private Block _block;
|
||||
|
||||
private Location _loc;
|
||||
|
||||
public BlockForm(MorphBlock host, Player player, Material mat)
|
||||
{
|
||||
Host = host;
|
||||
Player = player;
|
||||
_host = host;
|
||||
_player = player;
|
||||
|
||||
_mat = mat;
|
||||
_loc = player.getLocation();
|
||||
@ -48,21 +50,21 @@ public class BlockForm
|
||||
public void Apply()
|
||||
{
|
||||
//Remove Old
|
||||
if (Player.getPassenger() != null)
|
||||
if (_player.getPassenger() != null)
|
||||
{
|
||||
Recharge.Instance.useForce(Player, "PassengerChange", 100);
|
||||
Recharge.Instance.useForce(_player, "PassengerChange", 100);
|
||||
|
||||
Player.getPassenger().remove();
|
||||
Player.eject();
|
||||
_player.getPassenger().remove();
|
||||
_player.eject();
|
||||
}
|
||||
|
||||
((CraftEntity)Player).getHandle().getDataWatcher().watch(0, Byte.valueOf((byte) 32));
|
||||
((CraftEntity)_player).getHandle().getDataWatcher().watch(0, Byte.valueOf((byte) 32));
|
||||
|
||||
//Player > Chicken
|
||||
DisguiseChicken disguise = new DisguiseChicken(Player);
|
||||
DisguiseChicken disguise = new DisguiseChicken(_player);
|
||||
disguise.setBaby();
|
||||
disguise.setSoundDisguise(new DisguiseCat(Player));
|
||||
Host.Manager.getDisguiseManager().disguise(disguise);
|
||||
disguise.setSoundDisguise(new DisguiseCat(_player));
|
||||
_host.Manager.getDisguiseManager().disguise(disguise);
|
||||
|
||||
//Apply Falling Block
|
||||
FallingBlockCheck();
|
||||
@ -70,63 +72,70 @@ public class BlockForm
|
||||
//Inform
|
||||
String blockName = F.elem(ItemStackFactory.Instance.GetName(_mat, (byte)0, false));
|
||||
if (!blockName.contains("Block"))
|
||||
UtilPlayer.message(Player, F.main("Game", C.cWhite + "You are now a " + F.elem(ItemStackFactory.Instance.GetName(_mat, (byte)0, false) + " Block") + "!"));
|
||||
UtilPlayer.message(_player, F.main("Game", C.cWhite + "You are now a " + F.elem(ItemStackFactory.Instance.GetName(_mat, (byte)0, false) + " Block") + "!"));
|
||||
else
|
||||
UtilPlayer.message(Player, F.main("Game", C.cWhite + "You are now a " + F.elem(ItemStackFactory.Instance.GetName(_mat, (byte)0, false)) + "!"));
|
||||
UtilPlayer.message(_player, F.main("Game", C.cWhite + "You are now a " + F.elem(ItemStackFactory.Instance.GetName(_mat, (byte)0, false)) + "!"));
|
||||
|
||||
//Sound
|
||||
Player.playSound(Player.getLocation(), Sound.ZOMBIE_UNFECT, 2f, 2f);
|
||||
_player.playSound(_player.getLocation(), Sound.ZOMBIE_UNFECT, 2f, 2f);
|
||||
}
|
||||
|
||||
public void Remove()
|
||||
{
|
||||
SolidifyRemove();
|
||||
|
||||
Host.Manager.getDisguiseManager().undisguise(Player);
|
||||
_host.Manager.getDisguiseManager().undisguise(_player);
|
||||
|
||||
//Remove FB
|
||||
if (Player.getPassenger() != null)
|
||||
if (_player.getPassenger() != null)
|
||||
{
|
||||
Recharge.Instance.useForce(Player, "PassengerChange", 100);
|
||||
Recharge.Instance.useForce(_player, "PassengerChange", 100);
|
||||
|
||||
Player.getPassenger().remove();
|
||||
Player.eject();
|
||||
_player.getPassenger().remove();
|
||||
_player.eject();
|
||||
}
|
||||
|
||||
((CraftEntity)Player).getHandle().getDataWatcher().watch(0, Byte.valueOf((byte) 0));
|
||||
((CraftEntity)_player).getHandle().getDataWatcher().watch(0, Byte.valueOf((byte) 0));
|
||||
}
|
||||
|
||||
public void SolidifyUpdate()
|
||||
{
|
||||
if (!Player.isSprinting())
|
||||
((CraftEntity)Player).getHandle().getDataWatcher().watch(0, Byte.valueOf((byte) 32));
|
||||
if (!_player.isSprinting())
|
||||
((CraftEntity)_player).getHandle().getDataWatcher().watch(0, Byte.valueOf((byte) 32));
|
||||
|
||||
//Not a Block
|
||||
if (_block == null)
|
||||
{
|
||||
//Moved
|
||||
if (!_loc.getBlock().equals(Player.getLocation().getBlock()))
|
||||
if (!_loc.getBlock().equals(_player.getLocation().getBlock()))
|
||||
{
|
||||
Player.setExp(0);
|
||||
_loc = Player.getLocation();
|
||||
_player.setExp(0);
|
||||
_loc = _player.getLocation();
|
||||
}
|
||||
//Unmoved
|
||||
else
|
||||
{
|
||||
double hideBoost = 0.025;
|
||||
|
||||
Player.setExp((float) Math.min(0.999f, Player.getExp() + hideBoost));
|
||||
_player.setExp((float) Math.min(0.999f, _player.getExp() + hideBoost));
|
||||
|
||||
//Set Block
|
||||
if (Player.getExp() >= 0.999f)
|
||||
if (_player.getExp() >= 0.999f)
|
||||
{
|
||||
Block block = Player.getLocation().getBlock();
|
||||
Block block = _player.getLocation().getBlock();
|
||||
|
||||
List<Block> blockList = new ArrayList<Block>();
|
||||
blockList.add(block);
|
||||
|
||||
GadgetBlockEvent event = new GadgetBlockEvent(_host, blockList);
|
||||
|
||||
Bukkit.getServer().getPluginManager().callEvent(event);
|
||||
|
||||
//Not Able
|
||||
if (block.getType() != Material.AIR || !UtilBlock.solid(block.getRelative(BlockFace.DOWN)))
|
||||
if (block.getType() != Material.AIR || !UtilBlock.solid(block.getRelative(BlockFace.DOWN)) || event.getBlocks().isEmpty())
|
||||
{
|
||||
UtilPlayer.message(Player, F.main("Game", "You cannot become a Solid Block here."));
|
||||
Player.setExp(0f);
|
||||
UtilPlayer.message(_player, F.main("Game", "You cannot become a Solid Block here."));
|
||||
_player.setExp(0f);
|
||||
return;
|
||||
}
|
||||
|
||||
@ -134,7 +143,7 @@ public class BlockForm
|
||||
_block = block;
|
||||
|
||||
//Effect
|
||||
Player.playEffect(Player.getLocation(), Effect.STEP_SOUND, _mat);
|
||||
_player.playEffect(_player.getLocation(), Effect.STEP_SOUND, _mat);
|
||||
//block.getWorld().playEffect(block.getLocation(), Effect.STEP_SOUND, _mat);
|
||||
|
||||
//Display
|
||||
@ -144,7 +153,7 @@ public class BlockForm
|
||||
//Host.Manager.GetCondition().Factory().Cloak("Disguised as Block", Player, Player, 60000, false, false);
|
||||
|
||||
//Sound
|
||||
Player.playSound(Player.getLocation(), Sound.NOTE_PLING, 1f, 2f);
|
||||
_player.playSound(_player.getLocation(), Sound.NOTE_PLING, 1f, 2f);
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -152,7 +161,7 @@ public class BlockForm
|
||||
else
|
||||
{
|
||||
//Moved
|
||||
if (!_loc.getBlock().equals(Player.getLocation().getBlock()))
|
||||
if (!_loc.getBlock().equals(_player.getLocation().getBlock()))
|
||||
{
|
||||
SolidifyRemove();
|
||||
}
|
||||
@ -172,12 +181,12 @@ public class BlockForm
|
||||
_block = null;
|
||||
}
|
||||
|
||||
Player.setExp(0f);
|
||||
_player.setExp(0f);
|
||||
|
||||
//Host.Manager.GetCondition().EndCondition(Player, null, "Disguised as Block");
|
||||
|
||||
//Inform
|
||||
Player.playSound(Player.getLocation(), Sound.NOTE_PLING, 1f, 0.5f);
|
||||
_player.playSound(_player.getLocation(), Sound.NOTE_PLING, 1f, 0.5f);
|
||||
|
||||
FallingBlockCheck();
|
||||
}
|
||||
@ -189,20 +198,20 @@ public class BlockForm
|
||||
return;
|
||||
|
||||
//Remove Old
|
||||
if (Player.getPassenger() != null)
|
||||
if (_player.getPassenger() != null)
|
||||
{
|
||||
Recharge.Instance.useForce(Player, "PassengerChange", 100);
|
||||
Recharge.Instance.useForce(_player, "PassengerChange", 100);
|
||||
|
||||
Player.getPassenger().remove();
|
||||
Player.eject();
|
||||
_player.getPassenger().remove();
|
||||
_player.eject();
|
||||
}
|
||||
|
||||
//Others
|
||||
for (Player other : UtilServer.getPlayers())
|
||||
other.sendBlockChange(Player.getLocation(), _mat, (byte)0);
|
||||
other.sendBlockChange(_player.getLocation(), _mat, (byte)0);
|
||||
|
||||
//Self
|
||||
Player.sendBlockChange(Player.getLocation(), 36, (byte)0);
|
||||
_player.sendBlockChange(_player.getLocation(), 36, (byte)0);
|
||||
|
||||
FallingBlockCheck();
|
||||
}
|
||||
@ -214,27 +223,27 @@ public class BlockForm
|
||||
return;
|
||||
|
||||
//Recreate Falling
|
||||
if (Player.getPassenger() == null || !Player.getPassenger().isValid())
|
||||
if (_player.getPassenger() == null || !_player.getPassenger().isValid())
|
||||
{
|
||||
if (!Recharge.Instance.use(Player, "PassengerChange", 100, false, false))
|
||||
if (!Recharge.Instance.use(_player, "PassengerChange", 100, false, false))
|
||||
return;
|
||||
|
||||
//Falling Block
|
||||
FallingBlock block = Player.getWorld().spawnFallingBlock(Player.getEyeLocation(), _mat, (byte)0);
|
||||
FallingBlock block = _player.getWorld().spawnFallingBlock(_player.getEyeLocation(), _mat, (byte)0);
|
||||
|
||||
//No Arrow Collision
|
||||
((CraftFallingSand)block).getHandle().spectating = true;
|
||||
|
||||
Player.setPassenger(block);
|
||||
_player.setPassenger(block);
|
||||
|
||||
Host.fallingBlockRegister(block);
|
||||
_host.fallingBlockRegister(block);
|
||||
}
|
||||
|
||||
//Ensure Falling doesnt Despawn
|
||||
else
|
||||
{
|
||||
((CraftFallingSand)Player.getPassenger()).getHandle().ticksLived = 1;
|
||||
Player.getPassenger().setTicksLived(1);
|
||||
((CraftFallingSand)_player.getPassenger()).getHandle().ticksLived = 1;
|
||||
_player.getPassenger().setTicksLived(1);
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -5,6 +5,7 @@ import java.util.HashMap;
|
||||
import java.util.HashSet;
|
||||
import java.util.Iterator;
|
||||
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.entity.FallingBlock;
|
||||
import org.bukkit.entity.Player;
|
||||
@ -21,6 +22,8 @@ import mineplex.core.common.util.UtilEvent.ActionType;
|
||||
import mineplex.core.disguise.disguises.DisguiseBlock;
|
||||
import mineplex.core.event.StackerEvent;
|
||||
import mineplex.core.gadget.GadgetManager;
|
||||
import mineplex.core.gadget.event.GadgetActivateEvent;
|
||||
import mineplex.core.gadget.event.GadgetBlockEvent;
|
||||
import mineplex.core.gadget.types.MorphGadget;
|
||||
import mineplex.core.recharge.Recharge;
|
||||
import mineplex.core.updater.UpdateType;
|
||||
|
@ -3,9 +3,13 @@ package mineplex.core.mount;
|
||||
import mineplex.core.common.util.UtilAlg;
|
||||
import mineplex.core.common.util.UtilEnt;
|
||||
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.Location;
|
||||
import org.bukkit.Sound;
|
||||
import org.bukkit.craftbukkit.v1_7_R4.entity.CraftEnderDragon;
|
||||
import org.bukkit.craftbukkit.v1_7_R4.entity.CraftEntity;
|
||||
import org.bukkit.craftbukkit.v1_7_R4.entity.CraftPlayer;
|
||||
import org.bukkit.entity.Chicken;
|
||||
import org.bukkit.entity.EnderDragon;
|
||||
import org.bukkit.entity.Entity;
|
||||
import org.bukkit.entity.Player;
|
||||
@ -25,6 +29,8 @@ public class DragonData
|
||||
public float Pitch = 0;
|
||||
public Vector Velocity = new Vector(0,0,0);
|
||||
|
||||
public Entity Chicken;
|
||||
|
||||
public DragonData(DragonMount dragonMount, Player rider)
|
||||
{
|
||||
Host = dragonMount;
|
||||
@ -36,6 +42,7 @@ public class DragonData
|
||||
|
||||
Location = rider.getLocation();
|
||||
|
||||
|
||||
//Spawn Dragon
|
||||
Dragon = rider.getWorld().spawn(rider.getLocation(), EnderDragon.class);
|
||||
UtilEnt.Vegetate(Dragon);
|
||||
@ -43,7 +50,18 @@ public class DragonData
|
||||
|
||||
rider.getWorld().playSound(rider.getLocation(), Sound.ENDERDRAGON_GROWL, 20f, 1f);
|
||||
|
||||
Dragon.setPassenger(Rider);
|
||||
Chicken = rider.getWorld().spawn(rider.getLocation(), Chicken.class);
|
||||
Dragon.setPassenger(Chicken);
|
||||
|
||||
Chicken.setPassenger(Rider);
|
||||
|
||||
Bukkit.getServer().getScheduler().runTaskLater(Host.Manager.GetPlugin(), new Runnable()
|
||||
{
|
||||
public void run()
|
||||
{
|
||||
Chicken.setPassenger(Rider);
|
||||
}
|
||||
}, 10L);
|
||||
}
|
||||
|
||||
public void Move()
|
||||
|
@ -5,6 +5,7 @@ import org.bukkit.entity.Player;
|
||||
|
||||
import mineplex.core.common.util.F;
|
||||
import mineplex.core.common.util.UtilPlayer;
|
||||
import mineplex.core.disguise.disguises.DisguiseChicken;
|
||||
|
||||
public class DragonMount extends Mount<DragonData>
|
||||
{
|
||||
@ -42,6 +43,7 @@ public class DragonMount extends Mount<DragonData>
|
||||
if (data != null)
|
||||
{
|
||||
data.Dragon.remove();
|
||||
data.Chicken.remove();
|
||||
|
||||
//Inform
|
||||
UtilPlayer.message(player, F.main("Mount", "You despawned " + F.elem(GetName()) + "."));
|
||||
|
@ -76,7 +76,7 @@ public class MountDragon extends DragonMount
|
||||
continue;
|
||||
}
|
||||
|
||||
if (!data.Dragon.isValid() || data.Dragon.getPassenger() == null)
|
||||
if (!data.Dragon.isValid() || data.Dragon.getPassenger().getPassenger() == null)
|
||||
{
|
||||
data.Dragon.remove();
|
||||
toRemove.add(player);
|
||||
|
@ -15,10 +15,10 @@ import mineplex.core.database.column.ColumnVarChar;
|
||||
|
||||
public class PreferencesRepository extends RepositoryBase
|
||||
{
|
||||
private static String CREATE_ACCOUNT_TABLE = "CREATE TABLE IF NOT EXISTS accountPreferences (id INT NOT NULL AUTO_INCREMENT, uuid VARCHAR(256), games BOOL NOT NULL DEFAULT 1, visibility BOOL NOT NULL DEFAULT 1, showChat BOOL NOT NULL DEFAULT 1, friendChat BOOL NOT NULL DEFAULT 1, privateMessaging BOOL NOT NULL DEFAULT 1, partyRequests BOOL NOT NULL DEFAULT 0, invisibility BOOL NOT NULL DEFAULT 0, forcefield BOOL NOT NULL DEFAULT 0, PRIMARY KEY (id), UNIQUE INDEX uuid_index (uuid));";
|
||||
private static String CREATE_ACCOUNT_TABLE = "CREATE TABLE IF NOT EXISTS accountPreferences (id INT NOT NULL AUTO_INCREMENT, uuid VARCHAR(256), games BOOL NOT NULL DEFAULT 1, visibility BOOL NOT NULL DEFAULT 1, showChat BOOL NOT NULL DEFAULT 1, friendChat BOOL NOT NULL DEFAULT 1, privateMessaging BOOL NOT NULL DEFAULT 1, partyRequests BOOL NOT NULL DEFAULT 0, invisibility BOOL NOT NULL DEFAULT 0, forcefield BOOL NOT NULL DEFAULT 0, showMacReports BOOL NOT NULL DEFAULT 0, ignoreVelocity BOOL NOT NULL DEFAULT 0, PRIMARY KEY (id), UNIQUE INDEX uuid_index (uuid));";
|
||||
private static String INSERT_ACCOUNT = "INSERT INTO accountPreferences (uuid) VALUES (?) ON DUPLICATE KEY UPDATE uuid=uuid;";
|
||||
private static String RETRIEVE_ACCOUNT_PREFERENCES = "SELECT games, visibility, showChat, friendChat, privateMessaging, partyRequests, invisibility, forcefield FROM accountPreferences WHERE uuid = ?;";
|
||||
private static String UPDATE_ACCOUNT_PREFERENCES = "UPDATE accountPreferences SET games = ?, visibility = ?, showChat = ?, friendChat = ?, privateMessaging = ?, partyRequests = ?, invisibility = ?, forcefield = ? WHERE uuid=?;";
|
||||
private static String RETRIEVE_ACCOUNT_PREFERENCES = "SELECT games, visibility, showChat, friendChat, privateMessaging, partyRequests, invisibility, forcefield, showMacReports, ignoreVelocity FROM accountPreferences WHERE uuid = ?;";
|
||||
private static String UPDATE_ACCOUNT_PREFERENCES = "UPDATE accountPreferences SET games = ?, visibility = ?, showChat = ?, friendChat = ?, privateMessaging = ?, partyRequests = ?, invisibility = ?, forcefield = ?, showMacReports = ?, ignoreVelocity = ? WHERE uuid=?;";
|
||||
|
||||
public PreferencesRepository(JavaPlugin plugin, String connectionString)
|
||||
{
|
||||
@ -54,7 +54,9 @@ public class PreferencesRepository extends RepositoryBase
|
||||
preparedStatement.setBoolean(6, entry.getValue().PartyRequests);
|
||||
preparedStatement.setBoolean(7, entry.getValue().Invisibility);
|
||||
preparedStatement.setBoolean(8, entry.getValue().HubForcefield);
|
||||
preparedStatement.setString(9, entry.getKey());
|
||||
preparedStatement.setBoolean(9, entry.getValue().ShowMacReports);
|
||||
preparedStatement.setBoolean(10, entry.getValue().IgnoreVelocity);
|
||||
preparedStatement.setString(11, entry.getKey());
|
||||
|
||||
preparedStatement.addBatch();
|
||||
}
|
||||
@ -103,6 +105,8 @@ public class PreferencesRepository extends RepositoryBase
|
||||
preferences.PartyRequests = resultSet.getBoolean(6);
|
||||
preferences.Invisibility = resultSet.getBoolean(7);
|
||||
preferences.HubForcefield = resultSet.getBoolean(8);
|
||||
preferences.ShowMacReports = resultSet.getBoolean(9);
|
||||
preferences.IgnoreVelocity = resultSet.getBoolean(10);
|
||||
}
|
||||
}
|
||||
}, new ColumnVarChar("uuid", 100, uuid.toString()));
|
||||
|
@ -11,4 +11,6 @@ public class UserPreferences
|
||||
public boolean PartyRequests = true;
|
||||
public boolean Invisibility = false;
|
||||
public boolean HubForcefield = false;
|
||||
public boolean ShowMacReports = false;
|
||||
public boolean IgnoreVelocity = false;
|
||||
}
|
||||
|
@ -1,5 +1,9 @@
|
||||
package mineplex.core.preferences.ui;
|
||||
|
||||
import org.bukkit.ChatColor;
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
import mineplex.core.account.CoreClientManager;
|
||||
import mineplex.core.common.Rank;
|
||||
import mineplex.core.donation.DonationManager;
|
||||
@ -9,10 +13,6 @@ import mineplex.core.shop.item.IButton;
|
||||
import mineplex.core.shop.item.ShopItem;
|
||||
import mineplex.core.shop.page.ShopPageBase;
|
||||
|
||||
import org.bukkit.ChatColor;
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
public class PreferencesPage extends ShopPageBase<PreferencesManager, PreferencesShop>
|
||||
{
|
||||
private IButton _toggleHubGames;
|
||||
@ -22,6 +22,8 @@ public class PreferencesPage extends ShopPageBase<PreferencesManager, Preference
|
||||
private IButton _toggleHubPartyRequests;
|
||||
private IButton _toggleHubInvisibility;
|
||||
private IButton _toggleHubForcefield;
|
||||
private IButton _toggleHubIgnoreVelocity;
|
||||
private IButton _toggleMacReports;
|
||||
|
||||
private boolean _hubGamesToggled;
|
||||
private boolean _hubPlayersToggled;
|
||||
@ -30,6 +32,8 @@ public class PreferencesPage extends ShopPageBase<PreferencesManager, Preference
|
||||
private boolean _hubPartyRequestsToggled;
|
||||
private boolean _hubInvisibilityToggled;
|
||||
private boolean _hubForcefieldToggled;
|
||||
private boolean _macReportsToggled;
|
||||
private boolean _hubIgnoreVelocityToggled;
|
||||
|
||||
public PreferencesPage(PreferencesManager plugin, PreferencesShop shop, CoreClientManager clientManager, DonationManager donationManager, String name, Player player)
|
||||
{
|
||||
@ -145,6 +149,36 @@ public class PreferencesPage extends ShopPageBase<PreferencesManager, Preference
|
||||
toggleHubForcefield(player);
|
||||
}
|
||||
};
|
||||
|
||||
_toggleMacReports = new IButton()
|
||||
{
|
||||
@Override
|
||||
public void ClickedLeft(Player player)
|
||||
{
|
||||
toggleMacReports(player);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void ClickedRight(Player player)
|
||||
{
|
||||
toggleMacReports(player);
|
||||
}
|
||||
};
|
||||
|
||||
_toggleHubIgnoreVelocity = new IButton()
|
||||
{
|
||||
@Override
|
||||
public void ClickedLeft(Player player)
|
||||
{
|
||||
toggleHubIgnoreVelocity(player);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void ClickedRight(Player player)
|
||||
{
|
||||
toggleHubIgnoreVelocity(player);
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
private void buildPreference(int index, Material material, String name, boolean preference, IButton button)
|
||||
@ -157,7 +191,7 @@ public class PreferencesPage extends ShopPageBase<PreferencesManager, Preference
|
||||
String[] description = new String[] {
|
||||
"" + (preference ? ChatColor.GREEN + "Enabled" : ChatColor.RED + "Disabled"),
|
||||
ChatColor.RED + " ",
|
||||
"Click to " + (preference ? "Disable" : "Enable") };
|
||||
ChatColor.RESET + "Click to " + (preference ? "Disable" : "Enable") };
|
||||
|
||||
AddButton(index, new ShopItem(material, data, (preference ? ChatColor.GREEN : ChatColor.RED) + name, description, 1, false, false), button);
|
||||
AddButton(index + 9, new ShopItem(Material.INK_SACK, (preference ? (byte)10 : (byte)8), (preference ? ChatColor.GREEN : ChatColor.RED) + name, description, 1, false, false), button);
|
||||
@ -212,6 +246,20 @@ public class PreferencesPage extends ShopPageBase<PreferencesManager, Preference
|
||||
BuildPage();
|
||||
}
|
||||
|
||||
protected void toggleMacReports(org.bukkit.entity.Player player)
|
||||
{
|
||||
Plugin.Get(player).ShowMacReports = !Plugin.Get(player).ShowMacReports;
|
||||
_macReportsToggled = !_macReportsToggled;
|
||||
BuildPage();
|
||||
}
|
||||
|
||||
protected void toggleHubIgnoreVelocity(org.bukkit.entity.Player player)
|
||||
{
|
||||
Plugin.Get(player).IgnoreVelocity = !Plugin.Get(player).IgnoreVelocity;
|
||||
_hubIgnoreVelocityToggled = !_hubIgnoreVelocityToggled;
|
||||
BuildPage();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void PlayerClosed()
|
||||
{
|
||||
@ -230,7 +278,7 @@ public class PreferencesPage extends ShopPageBase<PreferencesManager, Preference
|
||||
UserPreferences userPreferences = Plugin.Get(Player);
|
||||
int index = 18;
|
||||
|
||||
if (ClientManager.Get(Player).GetRank().Has(Rank.ADMIN) || ClientManager.Get(Player).GetRank() == Rank.YOUTUBE)
|
||||
if (ClientManager.Get(Player).GetRank().Has(Rank.MODERATOR) || ClientManager.Get(Player).GetRank() == Rank.YOUTUBE)
|
||||
{
|
||||
index = 9;
|
||||
}
|
||||
@ -245,11 +293,23 @@ public class PreferencesPage extends ShopPageBase<PreferencesManager, Preference
|
||||
index += 2;
|
||||
buildPreference(index, Material.SKULL_ITEM, (byte)3, "Hub Party Requests", userPreferences.PartyRequests, _toggleHubPartyRequests);
|
||||
|
||||
if (ClientManager.Get(Player).GetRank().Has(Rank.ADMIN) || ClientManager.Get(Player).GetRank() == Rank.YOUTUBE)
|
||||
if (ClientManager.Get(Player).GetRank() == Rank.YOUTUBE)
|
||||
{
|
||||
buildPreference(39, Material.NETHER_STAR, "Hub Invisibility", userPreferences.Invisibility, _toggleHubInvisibility);
|
||||
buildPreference(41, Material.SLIME_BALL, "Hub Forcefield", userPreferences.HubForcefield, _toggleHubForcefield);
|
||||
}
|
||||
if (ClientManager.Get(Player).GetRank().Has(Rank.ADMIN))
|
||||
{
|
||||
buildPreference(37, Material.NETHER_STAR, "Hub Invisibility", userPreferences.Invisibility, _toggleHubInvisibility);
|
||||
buildPreference(39, Material.SLIME_BALL, "Hub Forcefield", userPreferences.HubForcefield, _toggleHubForcefield);
|
||||
buildPreference(41, Material.PAPER, "Mac Reports", userPreferences.ShowMacReports, _toggleMacReports);
|
||||
buildPreference(43, Material.SADDLE, "Hub Ignore Velocity", userPreferences.IgnoreVelocity, _toggleHubIgnoreVelocity);
|
||||
}
|
||||
else if (ClientManager.Get(Player).GetRank().Has(Rank.MODERATOR))
|
||||
{
|
||||
buildPreference(39, Material.PAPER, "Mac Reports", userPreferences.ShowMacReports, _toggleMacReports);
|
||||
buildPreference(41, Material.SADDLE, "Hub Ignore Velocity", userPreferences.IgnoreVelocity, _toggleHubIgnoreVelocity);
|
||||
}
|
||||
}
|
||||
|
||||
public boolean preferencesChanged()
|
||||
|
@ -57,45 +57,7 @@ public class StatsManager extends MiniClientPlugin<PlayerStats>
|
||||
|
||||
final String uuidString = player.getUniqueId().toString();
|
||||
|
||||
// Verify stat is in our local cache, if not add it remotely.
|
||||
if (!_stats.containsKey(statName))
|
||||
{
|
||||
Bukkit.getScheduler().runTaskAsynchronously(GetPlugin(), new Runnable()
|
||||
{
|
||||
public void run()
|
||||
{
|
||||
synchronized (_statSync)
|
||||
{
|
||||
// If many players come in for a new stat, when the first add finishes the others are queued to add again
|
||||
// This makes a second check for the stat name (already added before lock was released)
|
||||
// Then it pops into queue and forgets adding the new stat to db.
|
||||
if (_stats.containsKey(statName))
|
||||
{
|
||||
addToQueue(statName, uuidString, value);
|
||||
return;
|
||||
}
|
||||
|
||||
_repository.addStat(statName);
|
||||
|
||||
_stats.clear();
|
||||
|
||||
for (Stat stat : _repository.retrieveStats())
|
||||
{
|
||||
_stats.put(stat.Name, stat.Id);
|
||||
}
|
||||
|
||||
addToQueue(statName, uuidString, value);
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
else
|
||||
{
|
||||
synchronized (_statSync)
|
||||
{
|
||||
addToQueue(statName, uuidString, value);
|
||||
}
|
||||
}
|
||||
incrementStat(uuidString, statName, value);
|
||||
}
|
||||
|
||||
private void addToQueue(String statName, String uuidString, int value)
|
||||
@ -181,4 +143,47 @@ public class StatsManager extends MiniClientPlugin<PlayerStats>
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
public void incrementStat(final String uuidString, final String statName, final int value)
|
||||
{
|
||||
// Verify stat is in our local cache, if not add it remotely.
|
||||
if (!_stats.containsKey(statName))
|
||||
{
|
||||
Bukkit.getScheduler().runTaskAsynchronously(GetPlugin(), new Runnable()
|
||||
{
|
||||
public void run()
|
||||
{
|
||||
synchronized (_statSync)
|
||||
{
|
||||
// If many players come in for a new stat, when the first add finishes the others are queued to add again
|
||||
// This makes a second check for the stat name (already added before lock was released)
|
||||
// Then it pops into queue and forgets adding the new stat to db.
|
||||
if (_stats.containsKey(statName))
|
||||
{
|
||||
addToQueue(statName, uuidString, value);
|
||||
return;
|
||||
}
|
||||
|
||||
_repository.addStat(statName);
|
||||
|
||||
_stats.clear();
|
||||
|
||||
for (Stat stat : _repository.retrieveStats())
|
||||
{
|
||||
_stats.put(stat.Name, stat.Id);
|
||||
}
|
||||
|
||||
addToQueue(statName, uuidString, value);
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
else
|
||||
{
|
||||
synchronized (_statSync)
|
||||
{
|
||||
addToQueue(statName, uuidString, value);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -102,7 +102,7 @@ public class TreasureManager extends MiniPlugin
|
||||
{
|
||||
// Remove a treasure and a key
|
||||
_inventoryManager.addItemToInventory(player, "Treasure", "Treasure Key", -1);
|
||||
_inventoryManager.addItemToInventory(player, "Treasure", "Treasure Chest", -1);
|
||||
_inventoryManager.addItemToInventory(player, "Utility", "Treasure Chest", -1);
|
||||
}
|
||||
|
||||
Bukkit.broadcastMessage(F.main("Treasure", F.name(player.getName()) + " is opening a " + C.cGreen + "Treasure Chest"));
|
||||
|
@ -275,10 +275,13 @@ public class DDoSProtectionSwitcher
|
||||
private static void switchServer(final String privateIp, String currentIp, String newIp, String currentGateway,
|
||||
String newGateway)
|
||||
{
|
||||
String cmd = "/home/mineplex/switchBungeeIp.sh";
|
||||
String cmd = "/usr/bin/ssh";
|
||||
String args = "-to StrictHostKeyChecking=no -o ServerAliveInterval=10 mineplex@" + privateIp + " -p 5191";
|
||||
String remoteCmd = "\"sh /home/mineplex/config/switchBungeeIpRemote.sh";
|
||||
String remoteCmdEnd = "\"";
|
||||
|
||||
ProcessRunner pr = new ProcessRunner(new String[] { "/bin/sh", cmd, privateIp, currentIp, newIp,
|
||||
currentGateway, newGateway });
|
||||
ProcessRunner pr = new ProcessRunner(new String[] { cmd, args, remoteCmd, currentIp, newIp,
|
||||
currentGateway, newGateway, remoteCmdEnd });
|
||||
pr.start(new GenericRunnable<Boolean>()
|
||||
{
|
||||
public void run(Boolean error)
|
||||
|
@ -10,12 +10,12 @@ import mineplex.core.antistack.AntiStack;
|
||||
import mineplex.core.blockrestore.BlockRestore;
|
||||
import mineplex.core.chat.Chat;
|
||||
import mineplex.core.command.CommandCenter;
|
||||
import mineplex.minecraft.game.core.condition.ConditionManager;
|
||||
import mineplex.core.creature.Creature;
|
||||
import mineplex.core.disguise.DisguiseManager;
|
||||
import mineplex.core.donation.DonationManager;
|
||||
import mineplex.core.elo.EloManager;
|
||||
import mineplex.core.energy.Energy;
|
||||
import mineplex.core.friend.FriendManager;
|
||||
import mineplex.core.itemstack.ItemStackFactory;
|
||||
import mineplex.core.logger.Logger;
|
||||
import mineplex.core.memory.MemoryFix;
|
||||
@ -50,6 +50,7 @@ import mineplex.minecraft.game.classcombat.shop.ClassCombatShop;
|
||||
import mineplex.minecraft.game.classcombat.shop.ClassShopManager;
|
||||
import mineplex.minecraft.game.core.IRelation;
|
||||
import mineplex.minecraft.game.core.combat.CombatManager;
|
||||
import mineplex.minecraft.game.core.condition.ConditionManager;
|
||||
import mineplex.minecraft.game.core.damage.DamageManager;
|
||||
import mineplex.minecraft.game.core.fire.Fire;
|
||||
|
||||
@ -94,7 +95,7 @@ public class Hub extends JavaPlugin implements IRelation
|
||||
//new FriendManager(this, packetHandler);
|
||||
PartyManager partyManager = new PartyManager(this, clientManager, preferenceManager);
|
||||
Portal portal = new Portal(this, serverStatusManager.getCurrentServerName());
|
||||
AntiHack.Initialize(this, punish, portal);
|
||||
AntiHack.Initialize(this, punish, portal, preferenceManager, clientManager);
|
||||
PacketHandler packetHandler = new PacketHandler(this);
|
||||
DisguiseManager disguiseManager = new DisguiseManager(this, packetHandler);
|
||||
HubManager hubManager = new HubManager(this, new BlockRestore(this), clientManager, donationManager, new ConditionManager(this), disguiseManager, new TaskManager(this, webServerAddress), portal, partyManager, preferenceManager, petManager, pollManager);
|
||||
@ -131,6 +132,8 @@ public class Hub extends JavaPlugin implements IRelation
|
||||
new ClassCombatShop(shopManager, clientManager, donationManager, "Knight", classManager.GetClass("Knight"));
|
||||
new ClassCombatShop(shopManager, clientManager, donationManager, "Assassin", classManager.GetClass("Assassin"));
|
||||
|
||||
//new FriendManager(this);
|
||||
|
||||
//Updates
|
||||
getServer().getScheduler().scheduleSyncRepeatingTask(this, new Updater(this), 1, 1);
|
||||
}
|
||||
|
@ -28,6 +28,7 @@ import org.bukkit.event.player.PlayerJoinEvent;
|
||||
import org.bukkit.event.player.PlayerLoginEvent;
|
||||
import org.bukkit.event.player.PlayerQuitEvent;
|
||||
import org.bukkit.event.player.PlayerRespawnEvent;
|
||||
import org.bukkit.event.player.PlayerVelocityEvent;
|
||||
import org.bukkit.event.server.ServerListPingEvent;
|
||||
import org.bukkit.event.world.ChunkLoadEvent;
|
||||
import org.bukkit.inventory.ItemStack;
|
||||
@ -949,4 +950,13 @@ public class HubManager extends MiniClientPlugin<HubClient>
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
@EventHandler
|
||||
public void ignoreVelocity(PlayerVelocityEvent event)
|
||||
{
|
||||
if (_clientManager.Get(event.getPlayer()).GetRank().Has(Rank.MODERATOR) && _preferences.Get(event.getPlayer()).IgnoreVelocity)
|
||||
{
|
||||
event.setCancelled(true);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -45,7 +45,7 @@ public class JumpManager extends MiniPlugin
|
||||
|
||||
//Chicken Cancel
|
||||
DisguiseBase disguise = Manager.GetDisguise().getDisguise(player);
|
||||
if (disguise != null && (disguise instanceof DisguiseChicken || disguise instanceof DisguiseBat || disguise instanceof DisguiseEnderman))
|
||||
if (disguise != null && ((disguise instanceof DisguiseChicken && !((DisguiseChicken)disguise).isBaby()) || disguise instanceof DisguiseBat || disguise instanceof DisguiseEnderman))
|
||||
return;
|
||||
|
||||
event.setCancelled(true);
|
||||
|
@ -107,7 +107,10 @@ public class WorldManager
|
||||
|
||||
try
|
||||
{
|
||||
FileUtils.copyFile(new File(fileName), new File(File.separator + "home" + File.separator + "mineplex" + File.separator + "update" + File.separator + "maps" + File.separator + gameType.GetName() + File.separator + fileName));
|
||||
File zipFile = new File(fileName);
|
||||
FileUtils.copyFile(zipFile, new File(File.separator + "home" + File.separator + "mineplex" + File.separator + "update" + File.separator + "maps" + File.separator + gameType.GetName() + File.separator + fileName));
|
||||
// Delete the zip file in root directory once zip is copied
|
||||
FileUtils.deleteQuietly(zipFile);
|
||||
}
|
||||
catch (IOException e)
|
||||
{
|
||||
|
@ -2,10 +2,8 @@ package mineplex.serverdata;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collection;
|
||||
import java.util.HashMap;
|
||||
import java.util.HashSet;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Set;
|
||||
|
||||
import redis.clients.jedis.Jedis;
|
||||
|
@ -17,9 +17,6 @@ import redis.clients.jedis.Transaction;
|
||||
import redis.clients.jedis.Tuple;
|
||||
import redis.clients.jedis.exceptions.JedisConnectionException;
|
||||
|
||||
import com.google.gson.Gson;
|
||||
import com.google.gson.GsonBuilder;
|
||||
|
||||
/**
|
||||
* RedisServerRepository offers a Redis-based implementation of {@link ServerRepository}
|
||||
* using a mixture of hash and JSON encoded storage.
|
||||
@ -72,7 +69,12 @@ public class RedisServerRepository implements ServerRepository
|
||||
for (Response<String> response : responses)
|
||||
{
|
||||
String serializedData = response.get();
|
||||
servers.add(Utility.deserialize(serializedData, MinecraftServer.class));
|
||||
MinecraftServer server = Utility.deserialize(serializedData, MinecraftServer.class);
|
||||
|
||||
if (server != null)
|
||||
{
|
||||
servers.add(server);
|
||||
}
|
||||
}
|
||||
}
|
||||
catch (JedisConnectionException exception)
|
||||
@ -183,7 +185,7 @@ public class RedisServerRepository implements ServerRepository
|
||||
String dataKey = concatenate(setKey, serverName);
|
||||
|
||||
Transaction transaction = jedis.multi();
|
||||
transaction.set(dataKey, null);
|
||||
transaction.del(dataKey);
|
||||
transaction.zrem(setKey, serverName);
|
||||
transaction.exec();
|
||||
}
|
||||
@ -256,25 +258,6 @@ public class RedisServerRepository implements ServerRepository
|
||||
}
|
||||
}
|
||||
|
||||
Map<String, ServerGroup> serverGroups = new HashMap<String, ServerGroup>();
|
||||
for (ServerGroup serverGroup : getServerGroups())
|
||||
{
|
||||
serverGroups.put(serverGroup.getName(), serverGroup);
|
||||
}
|
||||
|
||||
// TODO: Find cleaner way to prep dedicated server group counts?
|
||||
for (DedicatedServer server : servers)
|
||||
{
|
||||
for (MinecraftServer minecraftServer : getServerStatuses())
|
||||
{
|
||||
if (serverGroups.containsKey(minecraftServer.getGroup()))
|
||||
{
|
||||
ServerGroup serverGroup = serverGroups.get(minecraftServer.getGroup());
|
||||
server.incrementServerCount(serverGroup);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return servers;
|
||||
}
|
||||
|
||||
@ -413,7 +396,10 @@ public class RedisServerRepository implements ServerRepository
|
||||
for (Response<String> response : responses)
|
||||
{
|
||||
String serializedData = response.get();
|
||||
servers.add(Utility.deserialize(serializedData, MinecraftServer.class));
|
||||
MinecraftServer server = Utility.deserialize(serializedData, MinecraftServer.class);
|
||||
|
||||
if (server != null)
|
||||
servers.add(server);
|
||||
}
|
||||
}
|
||||
catch (JedisConnectionException exception)
|
||||
|
@ -1,10 +1,7 @@
|
||||
package mineplex.serverdata;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collection;
|
||||
import java.util.HashMap;
|
||||
import java.util.HashSet;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Set;
|
||||
|
||||
@ -237,7 +234,7 @@ public class ServerGroup
|
||||
|
||||
for (MinecraftServer server : _servers)
|
||||
{
|
||||
if (server.isEmpty() && server.getUptime() <= 150) // Only return empty servers that have been online for >150 seconds
|
||||
if (server.isEmpty() && server.getUptime() >= 150) // Only return empty servers that have been online for >150 seconds
|
||||
{
|
||||
emptyServers.add(server);
|
||||
}
|
||||
|
@ -1,6 +1,5 @@
|
||||
package mineplex.serverdata;
|
||||
|
||||
import java.util.Collection;
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
|
||||
|
@ -14,6 +14,7 @@ import java.util.HashMap;
|
||||
import java.util.HashSet;
|
||||
import java.util.Iterator;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Map.Entry;
|
||||
import java.util.logging.FileHandler;
|
||||
import java.util.logging.Logger;
|
||||
@ -74,6 +75,7 @@ public class ServerMonitor
|
||||
while (true)
|
||||
{
|
||||
Collection<ServerGroup> serverGroups = _repository.getServerGroups();
|
||||
Collection<MinecraftServer> serverStatuses = _repository.getServerStatuses();
|
||||
|
||||
for (MinecraftServer deadServer : _repository.getDeadServers())
|
||||
{
|
||||
@ -82,6 +84,24 @@ public class ServerMonitor
|
||||
|
||||
List<DedicatedServer> dedicatedServers = new ArrayList<DedicatedServer>(_repository.getDedicatedServers());
|
||||
|
||||
Map<String, ServerGroup> serverGroupMap = new HashMap<String, ServerGroup>();
|
||||
for (ServerGroup serverGroup : serverGroups)
|
||||
{
|
||||
serverGroupMap.put(serverGroup.getName(), serverGroup);
|
||||
}
|
||||
|
||||
for (MinecraftServer minecraftServer : serverStatuses)
|
||||
{
|
||||
for (DedicatedServer server : dedicatedServers)
|
||||
{
|
||||
if (serverGroupMap.containsKey(minecraftServer.getGroup()) && minecraftServer.getPublicAddress().equalsIgnoreCase(server.getPrivateAddress()))
|
||||
{
|
||||
ServerGroup serverGroup = serverGroupMap.get(minecraftServer.getGroup());
|
||||
server.incrementServerCount(serverGroup);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (_count % 15 == 0)
|
||||
{
|
||||
_badServers.clear();
|
||||
@ -129,7 +149,7 @@ public class ServerMonitor
|
||||
|
||||
HashSet<String> onlineServers = new HashSet<String>();
|
||||
|
||||
for (MinecraftServer minecraftServer : _repository.getServerStatuses())
|
||||
for (MinecraftServer minecraftServer : serverStatuses)
|
||||
{
|
||||
onlineServers.add(minecraftServer.getName());
|
||||
|
||||
@ -237,7 +257,10 @@ public class ServerMonitor
|
||||
int availableSlots = serverGroup.getMaxPlayerCount() - serverGroup.getPlayerCount();
|
||||
|
||||
if (availableSlots < 1500)
|
||||
{
|
||||
serversToAdd = Math.max(1, (1500 - availableSlots) / serverGroup.getMaxPlayers());
|
||||
serversToKill = 0;
|
||||
}
|
||||
else if (serversToKill > 0)
|
||||
serversToKill = Math.min(serversToKill, (availableSlots - 1500) / 80);
|
||||
}
|
||||
|
@ -13,6 +13,7 @@ import mineplex.core.playerTracker.PlayerTracker;
|
||||
import mineplex.core.portal.Portal;
|
||||
import mineplex.core.preferences.PreferencesManager;
|
||||
import mineplex.core.recharge.Recharge;
|
||||
import mineplex.core.stats.StatsManager;
|
||||
import mineplex.core.status.ServerStatusManager;
|
||||
import mineplex.core.updater.FileUpdater;
|
||||
import mineplex.core.updater.Updater;
|
||||
@ -56,7 +57,7 @@ public class StaffServer extends JavaPlugin
|
||||
new MemoryFix(this);
|
||||
new FileUpdater(this, portal);
|
||||
|
||||
new CustomerSupport(this, clientManager, donationManager, new SalesPackageManager(this, clientManager, donationManager, new InventoryManager(this)));
|
||||
new CustomerSupport(this, clientManager, donationManager, new SalesPackageManager(this, clientManager, donationManager, new InventoryManager(this), new StatsManager(this)));
|
||||
new Password(this);
|
||||
|
||||
//Updates
|
||||
|
@ -1,6 +1,5 @@
|
||||
package mineplex.staffServer.salespackage;
|
||||
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.plugin.java.JavaPlugin;
|
||||
|
||||
@ -8,12 +7,13 @@ import mineplex.core.MiniPlugin;
|
||||
import mineplex.core.account.CoreClientManager;
|
||||
import mineplex.core.common.jsonchat.JsonMessage;
|
||||
import mineplex.core.common.util.NautHashMap;
|
||||
import mineplex.core.common.util.UtilServer;
|
||||
import mineplex.core.donation.DonationManager;
|
||||
import mineplex.core.inventory.InventoryManager;
|
||||
import mineplex.core.stats.StatsManager;
|
||||
import mineplex.staffServer.salespackage.command.DisplayPackageCommand;
|
||||
import mineplex.staffServer.salespackage.command.Sales;
|
||||
import mineplex.staffServer.salespackage.salespackages.Coins;
|
||||
import mineplex.staffServer.salespackage.salespackages.GemHunter;
|
||||
import mineplex.staffServer.salespackage.salespackages.LifetimeHero;
|
||||
import mineplex.staffServer.salespackage.salespackages.LifetimeUltra;
|
||||
import mineplex.staffServer.salespackage.salespackages.MonthlyHero;
|
||||
@ -25,16 +25,18 @@ public class SalesPackageManager extends MiniPlugin
|
||||
private CoreClientManager _clientManager;
|
||||
private DonationManager _donationManager;
|
||||
private InventoryManager _inventoryManager;
|
||||
private StatsManager _statsManager;
|
||||
|
||||
private NautHashMap<String, SalesPackageBase> _salesPackages = new NautHashMap<String, SalesPackageBase>();
|
||||
|
||||
public SalesPackageManager(JavaPlugin plugin, CoreClientManager clientManager, DonationManager donationManager, InventoryManager inventoryManager)
|
||||
public SalesPackageManager(JavaPlugin plugin, CoreClientManager clientManager, DonationManager donationManager, InventoryManager inventoryManager, StatsManager statsManager)
|
||||
{
|
||||
super("SalesPackageManager", plugin);
|
||||
|
||||
_clientManager = clientManager;
|
||||
_donationManager = donationManager;
|
||||
_inventoryManager = inventoryManager;
|
||||
_statsManager = statsManager;
|
||||
|
||||
AddSalesPackage(new Coins(this, 5000));
|
||||
AddSalesPackage(new Coins(this, 25000));
|
||||
@ -43,6 +45,8 @@ public class SalesPackageManager extends MiniPlugin
|
||||
AddSalesPackage(new MonthlyHero(this));
|
||||
AddSalesPackage(new LifetimeUltra(this));
|
||||
AddSalesPackage(new LifetimeHero(this));
|
||||
AddSalesPackage(new GemHunter(this, 8));
|
||||
AddSalesPackage(new GemHunter(this, 12));
|
||||
}
|
||||
|
||||
private void AddSalesPackage(SalesPackageBase salesPackage)
|
||||
@ -101,4 +105,9 @@ public class SalesPackageManager extends MiniPlugin
|
||||
coinBuilder.sendToPlayer(caller);
|
||||
packageBuilder.sendToPlayer(caller);
|
||||
}
|
||||
|
||||
public StatsManager getStatsManager()
|
||||
{
|
||||
return _statsManager;
|
||||
}
|
||||
}
|
||||
|
@ -0,0 +1,31 @@
|
||||
package mineplex.staffServer.salespackage.command;
|
||||
|
||||
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.UUIDFetcher;
|
||||
import mineplex.staffServer.salespackage.SalesPackageManager;
|
||||
|
||||
public class GemHunterCommand extends CommandBase<SalesPackageManager>
|
||||
{
|
||||
public GemHunterCommand(SalesPackageManager plugin)
|
||||
{
|
||||
super(plugin, Rank.MODERATOR, "gemhunter");
|
||||
}
|
||||
|
||||
@Override
|
||||
public void Execute(Player caller, String[] args)
|
||||
{
|
||||
if (args == null || args.length != 2)
|
||||
return;
|
||||
|
||||
String playerName = args[0];
|
||||
int amount = Integer.parseInt(args[1]);
|
||||
|
||||
Plugin.getDonationManager().PurchaseUnknownSalesPackage(null, playerName, "Gem Hunter Level " + amount, false, 0, false);
|
||||
Plugin.getStatsManager().incrementStat(UUIDFetcher.getUUIDOf(playerName).toString(), "Global.GemsEarned", amount);
|
||||
caller.sendMessage(F.main(Plugin.GetName(), "Added Level " + amount + " Gem Hunter to " + playerName + "'s account!"));
|
||||
}
|
||||
}
|
@ -6,7 +6,6 @@ import org.bukkit.event.player.PlayerCommandPreprocessEvent;
|
||||
|
||||
import mineplex.core.command.CommandBase;
|
||||
import mineplex.core.common.Rank;
|
||||
import mineplex.core.recharge.Recharge;
|
||||
import mineplex.staffServer.salespackage.SalesPackageManager;
|
||||
|
||||
public class HeroCommand extends CommandBase<SalesPackageManager>
|
||||
@ -20,15 +19,18 @@ public class HeroCommand extends CommandBase<SalesPackageManager>
|
||||
public void Execute(Player caller, String[] args)
|
||||
{
|
||||
resetCommandCharge(caller);
|
||||
PlayerCommandPreprocessEvent event = new PlayerCommandPreprocessEvent(caller, "/sales rank " + args[0] + " HERO false");
|
||||
Bukkit.getServer().getPluginManager().callEvent(event);
|
||||
Bukkit.getServer().getPluginManager().callEvent(new PlayerCommandPreprocessEvent(caller, "/sales rank " + args[0] + " HERO false"));
|
||||
|
||||
resetCommandCharge(caller);
|
||||
event = new PlayerCommandPreprocessEvent(caller, "/sales coin " + args[0] + " 15000");
|
||||
Bukkit.getServer().getPluginManager().callEvent(event);
|
||||
Bukkit.getServer().getPluginManager().callEvent(new PlayerCommandPreprocessEvent(caller, "/sales coin " + args[0] + " 15000"));
|
||||
|
||||
resetCommandCharge(caller);
|
||||
event = new PlayerCommandPreprocessEvent(caller, "/sales booster " + args[0] + " 90");
|
||||
Bukkit.getServer().getPluginManager().callEvent(event);
|
||||
Bukkit.getServer().getPluginManager().callEvent(new PlayerCommandPreprocessEvent(caller, "/sales booster " + args[0] + " 90"));
|
||||
|
||||
resetCommandCharge(caller);
|
||||
Bukkit.getServer().getPluginManager().callEvent(new PlayerCommandPreprocessEvent(caller, "/sales chest " + args[0] + " 40"));
|
||||
|
||||
resetCommandCharge(caller);
|
||||
Bukkit.getServer().getPluginManager().callEvent(new PlayerCommandPreprocessEvent(caller, "/sales key " + args[0] + " 10"));
|
||||
}
|
||||
}
|
||||
|
@ -19,15 +19,18 @@ public class LifetimeHeroCommand extends CommandBase<SalesPackageManager>
|
||||
public void Execute(Player caller, String[] args)
|
||||
{
|
||||
resetCommandCharge(caller);
|
||||
PlayerCommandPreprocessEvent event = new PlayerCommandPreprocessEvent(caller, "/sales rank " + args[0] + " HERO true");
|
||||
Bukkit.getServer().getPluginManager().callEvent(event);
|
||||
Bukkit.getServer().getPluginManager().callEvent(new PlayerCommandPreprocessEvent(caller, "/sales rank " + args[0] + " HERO true"));
|
||||
|
||||
resetCommandCharge(caller);
|
||||
event = new PlayerCommandPreprocessEvent(caller, "/sales coin " + args[0] + " 40000");
|
||||
Bukkit.getServer().getPluginManager().callEvent(event);
|
||||
Bukkit.getServer().getPluginManager().callEvent(new PlayerCommandPreprocessEvent(caller, "/sales coin " + args[0] + " 40000"));
|
||||
|
||||
resetCommandCharge(caller);
|
||||
event = new PlayerCommandPreprocessEvent(caller, "/sales booster " + args[0] + " 180");
|
||||
Bukkit.getServer().getPluginManager().callEvent(event);
|
||||
Bukkit.getServer().getPluginManager().callEvent(new PlayerCommandPreprocessEvent(caller, "/sales booster " + args[0] + " 180"));
|
||||
|
||||
resetCommandCharge(caller);
|
||||
Bukkit.getServer().getPluginManager().callEvent(new PlayerCommandPreprocessEvent(caller, "/sales chest " + args[0] + " 40"));
|
||||
|
||||
resetCommandCharge(caller);
|
||||
Bukkit.getServer().getPluginManager().callEvent(new PlayerCommandPreprocessEvent(caller, "/sales key " + args[0] + " 10"));
|
||||
}
|
||||
}
|
||||
|
@ -19,15 +19,18 @@ public class LifetimeUltraCommand extends CommandBase<SalesPackageManager>
|
||||
public void Execute(Player caller, String[] args)
|
||||
{
|
||||
resetCommandCharge(caller);
|
||||
PlayerCommandPreprocessEvent event = new PlayerCommandPreprocessEvent(caller, "/sales rank " + args[0] + " ULTRA true");
|
||||
Bukkit.getServer().getPluginManager().callEvent(event);
|
||||
Bukkit.getServer().getPluginManager().callEvent(new PlayerCommandPreprocessEvent(caller, "/sales rank " + args[0] + " ULTRA true"));
|
||||
|
||||
resetCommandCharge(caller);
|
||||
event = new PlayerCommandPreprocessEvent(caller, "/sales coin " + args[0] + " 20000");
|
||||
Bukkit.getServer().getPluginManager().callEvent(event);
|
||||
Bukkit.getServer().getPluginManager().callEvent(new PlayerCommandPreprocessEvent(caller, "/sales coin " + args[0] + " 20000"));
|
||||
|
||||
resetCommandCharge(caller);
|
||||
event = new PlayerCommandPreprocessEvent(caller, "/sales booster " + args[0] + " 60");
|
||||
Bukkit.getServer().getPluginManager().callEvent(event);
|
||||
Bukkit.getServer().getPluginManager().callEvent(new PlayerCommandPreprocessEvent(caller, "/sales booster " + args[0] + " 60"));
|
||||
|
||||
resetCommandCharge(caller);
|
||||
Bukkit.getServer().getPluginManager().callEvent(new PlayerCommandPreprocessEvent(caller, "/sales chest " + args[0] + " 20"));
|
||||
|
||||
resetCommandCharge(caller);
|
||||
Bukkit.getServer().getPluginManager().callEvent(new PlayerCommandPreprocessEvent(caller, "/sales key " + args[0] + " 5"));
|
||||
}
|
||||
}
|
||||
|
@ -15,6 +15,9 @@ public class Sales extends MultiCommandBase<SalesPackageManager>
|
||||
AddCommand(new RankCommand(plugin));
|
||||
AddCommand(new CoinCommand(plugin));
|
||||
AddCommand(new BoosterCommand(plugin));
|
||||
AddCommand(new TreasureChestCommand(plugin));
|
||||
AddCommand(new TreasureKeyCommand(plugin));
|
||||
AddCommand(new GemHunterCommand(plugin));
|
||||
AddCommand(new UltraCommand(plugin));
|
||||
AddCommand(new HeroCommand(plugin));
|
||||
AddCommand(new LifetimeUltraCommand(plugin));
|
||||
|
@ -0,0 +1,31 @@
|
||||
package mineplex.staffServer.salespackage.command;
|
||||
|
||||
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.UUIDFetcher;
|
||||
import mineplex.staffServer.salespackage.SalesPackageManager;
|
||||
|
||||
public class TreasureChestCommand extends CommandBase<SalesPackageManager>
|
||||
{
|
||||
public TreasureChestCommand(SalesPackageManager plugin)
|
||||
{
|
||||
super(plugin, Rank.MODERATOR, "chest");
|
||||
}
|
||||
|
||||
@Override
|
||||
public void Execute(Player caller, String[] args)
|
||||
{
|
||||
if (args == null || args.length != 2)
|
||||
return;
|
||||
|
||||
String playerName = args[0];
|
||||
int amount = Integer.parseInt(args[1]);
|
||||
|
||||
Plugin.getDonationManager().PurchaseUnknownSalesPackage(null, playerName, "Treasure Chest " + amount, false, 0, false);
|
||||
Plugin.getInventoryManager().addItemToInventoryForOffline(UUIDFetcher.getUUIDOf(playerName).toString(), "Utility", "Treasure Chest", amount);
|
||||
caller.sendMessage(F.main(Plugin.GetName(), "Added " + amount + " treasure chests to " + playerName + "'s account!"));
|
||||
}
|
||||
}
|
@ -0,0 +1,31 @@
|
||||
package mineplex.staffServer.salespackage.command;
|
||||
|
||||
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.UUIDFetcher;
|
||||
import mineplex.staffServer.salespackage.SalesPackageManager;
|
||||
|
||||
public class TreasureKeyCommand extends CommandBase<SalesPackageManager>
|
||||
{
|
||||
public TreasureKeyCommand(SalesPackageManager plugin)
|
||||
{
|
||||
super(plugin, Rank.MODERATOR, "key");
|
||||
}
|
||||
|
||||
@Override
|
||||
public void Execute(Player caller, String[] args)
|
||||
{
|
||||
if (args == null || args.length != 2)
|
||||
return;
|
||||
|
||||
String playerName = args[0];
|
||||
int amount = Integer.parseInt(args[1]);
|
||||
|
||||
Plugin.getDonationManager().PurchaseUnknownSalesPackage(null, playerName, "Treasure Key " + amount, false, 0, false);
|
||||
Plugin.getInventoryManager().addItemToInventoryForOffline(UUIDFetcher.getUUIDOf(playerName).toString(), "Treasure", "Treasure Key", amount);
|
||||
caller.sendMessage(F.main(Plugin.GetName(), "Added " + amount + " treasure Keys to " + playerName + "'s account!"));
|
||||
}
|
||||
}
|
@ -19,15 +19,18 @@ public class UltraCommand extends CommandBase<SalesPackageManager>
|
||||
public void Execute(Player caller, String[] args)
|
||||
{
|
||||
resetCommandCharge(caller);
|
||||
PlayerCommandPreprocessEvent event = new PlayerCommandPreprocessEvent(caller, "/sales rank " + args[0] + " ULTRA false");
|
||||
Bukkit.getServer().getPluginManager().callEvent(event);
|
||||
Bukkit.getServer().getPluginManager().callEvent(new PlayerCommandPreprocessEvent(caller, "/sales rank " + args[0] + " ULTRA false"));
|
||||
|
||||
resetCommandCharge(caller);
|
||||
event = new PlayerCommandPreprocessEvent(caller, "/sales coin " + args[0] + " 7500");
|
||||
Bukkit.getServer().getPluginManager().callEvent(event);
|
||||
Bukkit.getServer().getPluginManager().callEvent(new PlayerCommandPreprocessEvent(caller, "/sales coin " + args[0] + " 7500"));
|
||||
|
||||
resetCommandCharge(caller);
|
||||
event = new PlayerCommandPreprocessEvent(caller, "/sales booster " + args[0] + " 30");
|
||||
Bukkit.getServer().getPluginManager().callEvent(event);
|
||||
Bukkit.getServer().getPluginManager().callEvent(new PlayerCommandPreprocessEvent(caller, "/sales booster " + args[0] + " 30"));
|
||||
|
||||
resetCommandCharge(caller);
|
||||
Bukkit.getServer().getPluginManager().callEvent(new PlayerCommandPreprocessEvent(caller, "/sales chest " + args[0] + " 20"));
|
||||
|
||||
resetCommandCharge(caller);
|
||||
Bukkit.getServer().getPluginManager().callEvent(new PlayerCommandPreprocessEvent(caller, "/sales key " + args[0] + " 5"));
|
||||
}
|
||||
}
|
||||
|
@ -0,0 +1,23 @@
|
||||
package mineplex.staffServer.salespackage.salespackages;
|
||||
|
||||
import mineplex.staffServer.salespackage.SalesPackageManager;
|
||||
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
public class GemHunter extends SalesPackageBase
|
||||
{
|
||||
private int _level;
|
||||
|
||||
public GemHunter(SalesPackageManager manager, int level)
|
||||
{
|
||||
super(manager, "Level " + level + " Gem Hunter");
|
||||
|
||||
_level = level;
|
||||
}
|
||||
public void displayToAgent(Player agent, String playerName)
|
||||
{
|
||||
addButton(agent, "/sales gemhunter " + playerName + " " + _level, "Level " + _level + " Gem Hunter.");
|
||||
agent.sendMessage(" ");
|
||||
addBackButton(agent, playerName);
|
||||
}
|
||||
}
|
@ -15,7 +15,9 @@ public class LifetimeHero extends SalesPackageBase
|
||||
{
|
||||
addButton(agent, "/sales coin " + playerName + " 40000", " 40,000 Coins");
|
||||
addButton(agent, "/sales booster " + playerName + " 180", " 180 Gem Boosters");
|
||||
addButton(agent, "/sales rank " + playerName + " HERO true", " Lifetime Hero (Also, unlocks kits).");
|
||||
addButton(agent, "/sales chest " + playerName + " 40", " 40 Treasure Chests");
|
||||
addButton(agent, "/sales key " + playerName + " 10", " 10 Treasure Keys");
|
||||
addButton(agent, "/sales rank " + playerName + " HERO true", " Lifetime Hero.");
|
||||
addButton(agent, "Apply All", "/sales lifetimehero " + playerName, " Apply all above.");
|
||||
agent.sendMessage(" ");
|
||||
addBackButton(agent, playerName);
|
||||
|
@ -15,7 +15,9 @@ public class LifetimeUltra extends SalesPackageBase
|
||||
{
|
||||
addButton(agent, "/sales coin " + playerName + " 20000", " 20,000 Coins");
|
||||
addButton(agent, "/sales booster " + playerName + " 60", " 60 Gem Boosters");
|
||||
addButton(agent, "/sales rank " + playerName + " ULTRA true", " Lifetime Ultra (Also, unlocks kits).");
|
||||
addButton(agent, "/sales chest " + playerName + " 20", " 20 Treasure Chests");
|
||||
addButton(agent, "/sales key " + playerName + " 5", " 5 Treasure Keys");
|
||||
addButton(agent, "/sales rank " + playerName + " ULTRA true", " Lifetime Ultra.");
|
||||
addButton(agent, "Apply All", "/sales lifetimeultra " + playerName, " Apply all above.");
|
||||
agent.sendMessage(" ");
|
||||
addBackButton(agent, playerName);
|
||||
|
@ -15,6 +15,8 @@ public class MonthlyHero extends SalesPackageBase
|
||||
{
|
||||
addButton(agent, "/sales coin " + playerName + " 15000", " 15,000 Coins");
|
||||
addButton(agent, "/sales booster " + playerName + " 90", " 90 Gem Boosters");
|
||||
addButton(agent, "/sales chest " + playerName + " 40", " 40 Treasure Chests");
|
||||
addButton(agent, "/sales key " + playerName + " 10", " 10 Treasure Keys");
|
||||
addButton(agent, "/sales rank " + playerName + " HERO false", " Monthly Hero.");
|
||||
addButton(agent, "Apply All", "/sales hero " + playerName, " Apply all above.");
|
||||
agent.sendMessage(" ");
|
||||
|
@ -15,6 +15,8 @@ public class MonthlyUltra extends SalesPackageBase
|
||||
{
|
||||
addButton(agent, "/sales coin " + playerName + " 7500", " 7,500 Coins");
|
||||
addButton(agent, "/sales booster " + playerName + " 30", " 30 Gem Boosters");
|
||||
addButton(agent, "/sales chest " + playerName + " 20", " 20 Treasure Chests");
|
||||
addButton(agent, "/sales key " + playerName + " 5", " 5 Treasure Keys");
|
||||
addButton(agent, "/sales rank " + playerName + " ULTRA false", " Monthly Ultra.");
|
||||
addButton(agent, "Apply All", "/sales ultra " + playerName, " Apply all above.");
|
||||
agent.sendMessage(" ");
|
||||
|
@ -104,7 +104,7 @@ public class Arcade extends JavaPlugin
|
||||
_damageManager = new DamageManager(this, new CombatManager(this), new NpcManager(this, creature), disguiseManager);
|
||||
|
||||
Punish punish = new Punish(this, webServerAddress, _clientManager);
|
||||
AntiHack.Initialize(this, punish, portal);
|
||||
AntiHack.Initialize(this, punish, portal, preferenceManager, _clientManager);
|
||||
|
||||
BlockRestore blockRestore = new BlockRestore(this);
|
||||
|
||||
|
@ -53,11 +53,13 @@ import nautilus.game.arcade.stats.AssistsStatTracker;
|
||||
import nautilus.game.arcade.stats.DamageDealtStatTracker;
|
||||
import nautilus.game.arcade.stats.DamageTakenStatTracker;
|
||||
import nautilus.game.arcade.stats.DeathsStatTracker;
|
||||
import nautilus.game.arcade.stats.GamesPlayedStatTracker;
|
||||
import nautilus.game.arcade.stats.KillsStatTracker;
|
||||
import nautilus.game.arcade.stats.LoseStatTracker;
|
||||
import nautilus.game.arcade.stats.StatTracker;
|
||||
import nautilus.game.arcade.stats.TeamDeathsStatTracker;
|
||||
import nautilus.game.arcade.stats.TeamKillsStatTracker;
|
||||
import nautilus.game.arcade.stats.TimeInGameStatTracker;
|
||||
import nautilus.game.arcade.stats.WinStatTracker;
|
||||
import nautilus.game.arcade.world.WorldData;
|
||||
|
||||
@ -283,7 +285,9 @@ public abstract class Game implements Listener
|
||||
new DamageDealtStatTracker(this),
|
||||
new DamageTakenStatTracker(this),
|
||||
new TeamDeathsStatTracker(this),
|
||||
new TeamKillsStatTracker(this)
|
||||
new TeamKillsStatTracker(this),
|
||||
new GamesPlayedStatTracker(this),
|
||||
new TimeInGameStatTracker(this)
|
||||
);
|
||||
|
||||
System.out.println("Loading " + GetName() + "...");
|
||||
|
@ -0,0 +1,26 @@
|
||||
package nautilus.game.arcade.stats;
|
||||
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.event.EventHandler;
|
||||
import org.bukkit.event.EventPriority;
|
||||
|
||||
import nautilus.game.arcade.events.GameStateChangeEvent;
|
||||
import nautilus.game.arcade.game.Game;
|
||||
|
||||
public class GamesPlayedStatTracker extends StatTracker<Game>
|
||||
{
|
||||
public GamesPlayedStatTracker(Game game)
|
||||
{
|
||||
super(game);
|
||||
}
|
||||
|
||||
@EventHandler(ignoreCancelled = true, priority = EventPriority.MONITOR)
|
||||
public void onGameStateChange(GameStateChangeEvent event)
|
||||
{
|
||||
if (event.GetState() == Game.GameState.Live)
|
||||
{
|
||||
for (Player player : getGame().GetPlayers(true))
|
||||
getGame().AddStat(player, "GamesPlayed", 1, false, true);
|
||||
}
|
||||
}
|
||||
}
|
@ -0,0 +1,39 @@
|
||||
package nautilus.game.arcade.stats;
|
||||
|
||||
import java.util.HashMap;
|
||||
import java.util.UUID;
|
||||
|
||||
import org.bukkit.event.EventHandler;
|
||||
import org.bukkit.event.EventPriority;
|
||||
import org.bukkit.event.player.PlayerJoinEvent;
|
||||
import org.bukkit.event.player.PlayerQuitEvent;
|
||||
|
||||
import nautilus.game.arcade.game.Game;
|
||||
|
||||
public class TimeInGameStatTracker extends StatTracker<Game>
|
||||
{
|
||||
private final HashMap<UUID, Long> _joinTimes = new HashMap<>();
|
||||
|
||||
public TimeInGameStatTracker(Game game)
|
||||
{
|
||||
super(game);
|
||||
}
|
||||
|
||||
@EventHandler(priority = EventPriority.MONITOR)
|
||||
public void onPlayerJoin(PlayerJoinEvent event)
|
||||
{
|
||||
_joinTimes.put(event.getPlayer().getUniqueId(), System.currentTimeMillis());
|
||||
}
|
||||
|
||||
@EventHandler
|
||||
public void onPlayerQuit(PlayerQuitEvent event)
|
||||
{
|
||||
Long joinTime = _joinTimes.remove(event.getPlayer().getUniqueId());
|
||||
|
||||
if (joinTime != null)
|
||||
{
|
||||
int timeInGame = (int) ((System.currentTimeMillis() - joinTime) / 1000);
|
||||
getGame().AddStat(event.getPlayer(), "TimeInGame", timeInGame, false, true);
|
||||
}
|
||||
}
|
||||
}
|
@ -3,7 +3,6 @@
|
||||
<classpathentry kind="src" path="src"/>
|
||||
<classpathentry combineaccessrules="false" kind="src" path="/Core"/>
|
||||
<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER"/>
|
||||
<classpathentry combineaccessrules="false" kind="src" path="/Nautilus.Core.CraftBukkit"/>
|
||||
<classpathentry kind="var" path="REPO_DIR/Plugins/Libraries/craftbukkit.jar" sourcepath="/REPO_DIR/GitHubLibraries/CraftBukkit/src"/>
|
||||
<classpathentry combineaccessrules="false" kind="src" path="/Mineplex.Core"/>
|
||||
<classpathentry combineaccessrules="false" kind="src" path="/Mineplex.Core.Common"/>
|
||||
|
Loading…
Reference in New Issue
Block a user