Merge pull request #186 from Mineplex-LLC/develop

New map merging
This commit is contained in:
LCastr0 2016-08-25 20:05:53 -03:00 committed by GitHub
commit e9ea832089
153 changed files with 5596 additions and 3339 deletions

View File

@ -42,6 +42,7 @@ public class SortedSchematicLoader<T>
if (entry != null && !entry.getKey().equals(_currentValue))
{
_currentValue = entry.getKey();
Schematic schematic = entry.getValue();
entry.getValue().paste(_pasteLocation, false);
}
}

View File

@ -1,8 +1,16 @@
package mineplex.core.common.util;
import java.util.*;
import net.minecraft.server.v1_8_R3.*;
import mineplex.core.common.MinecraftVersion;
import mineplex.core.common.events.PlayerMessageEvent;
import net.md_5.bungee.api.chat.ClickEvent;
import net.md_5.bungee.api.chat.ClickEvent.Action;
import net.md_5.bungee.api.chat.HoverEvent;
import net.md_5.bungee.api.chat.TextComponent;
import net.minecraft.server.v1_8_R3.EntityPlayer;
import net.minecraft.server.v1_8_R3.Packet;
import net.minecraft.server.v1_8_R3.PacketPlayOutWorldBorder;
import net.minecraft.server.v1_8_R3.PlayerConnection;
import net.minecraft.server.v1_8_R3.WorldBorder;
import org.bukkit.ChatColor;
import org.bukkit.GameMode;
import org.bukkit.Location;
@ -20,8 +28,17 @@ import org.bukkit.potion.PotionEffect;
import org.bukkit.util.BlockIterator;
import org.bukkit.util.Vector;
import mineplex.core.common.MinecraftVersion;
import mineplex.core.common.events.PlayerMessageEvent;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collection;
import java.util.HashMap;
import java.util.HashSet;
import java.util.Iterator;
import java.util.LinkedList;
import java.util.List;
import java.util.Map;
import java.util.Random;
import java.util.UUID;
public class UtilPlayer
{
@ -179,7 +196,7 @@ public class UtilPlayer
for (Entity entity : p.getNearbyEntities(range, range, range))
{
if (entity == p || UtilPlayer.isSpectator(entity))
if (entity == p || UtilPlayer.isSpectator(entity) || !(entity instanceof Player))
continue;
double theirDist = p.getEyeLocation().distance(entity.getLocation());
@ -945,6 +962,67 @@ public class UtilPlayer
ALLOWED_COMMANDS.remove(player.getUniqueId());
}
/**
* Sends a formatted clickable accept or deny (or view) message to a player
* Both ACCEPT and DENY will always be sent, but VIEW will only be sent when <code>viewCommand</code> is not null
*
* @param player The player to send the message to
* @param header The message header, such as Party or Game
* @param acceptCommand The command to be run if ACCEPT is clicked
* @param acceptDisplayText The text displayed when hovering over ACCEPT
* @param declineCommand The command to be run when DENY is clicked
* @param declineDisplayText The text displayed when hovering over DENY
* @param viewCommand <code>Optional</code> The command to be run when VIEW is clicked
* @param viewDisplayText <code>Optional</code> The text displayed when hovering over VIEW
*/
public static void sendAcceptOrDeny(Player player, String header,
String acceptCommand, String acceptDisplayText,
String declineCommand, String declineDisplayText,
String viewCommand, String viewDisplayText)
{
TextComponent textComponent = new TextComponent(F.main(header, "Reply: "));
TextComponent accept = new TextComponent("ACCEPT");
accept.setColor(net.md_5.bungee.api.ChatColor.GREEN);
accept.setBold(true);
accept.setClickEvent(new ClickEvent(Action.RUN_COMMAND, acceptCommand));
accept.setHoverEvent(new HoverEvent(HoverEvent.Action.SHOW_TEXT, new TextComponent[]{
new TextComponent(acceptDisplayText)
}));
textComponent.addExtra(accept);
textComponent.addExtra(" ");
TextComponent deny = new TextComponent("DENY");
deny.setColor(net.md_5.bungee.api.ChatColor.RED);
deny.setBold(true);
deny.setClickEvent(new ClickEvent(Action.RUN_COMMAND, declineCommand));
deny.setHoverEvent(new HoverEvent(HoverEvent.Action.SHOW_TEXT, new TextComponent[]{
new TextComponent(declineDisplayText)
}));
textComponent.addExtra(deny);
if(viewCommand != null)
{
textComponent.addExtra(" ");
TextComponent view = new TextComponent("VIEW");
view.setColor(net.md_5.bungee.api.ChatColor.YELLOW);
view.setBold(true);
view.setClickEvent(new ClickEvent(Action.RUN_COMMAND, viewCommand));
if(viewDisplayText != null)
{
view.setHoverEvent(new HoverEvent(HoverEvent.Action.SHOW_TEXT, new TextComponent[]{
new TextComponent(viewDisplayText)
}));
}
textComponent.addExtra(view);
}
player.spigot().sendMessage(textComponent);
}
/*
* Returns whether the UUID belongs to a slim skin
*/

View File

@ -26,6 +26,7 @@ import mineplex.core.common.util.*;
import mineplex.core.disguise.DisguiseManager;
import mineplex.core.disguise.disguises.DisguiseBase;
import mineplex.core.portal.Portal;
import mineplex.core.preferences.Preference;
import mineplex.core.preferences.PreferencesManager;
import mineplex.core.punish.Category;
import mineplex.core.punish.Punish;
@ -187,7 +188,7 @@ public class AntiHack extends MiniPlugin
{
((CraftPlayer) player).getHandle().sendMessage(getDetailedMessage(violation));
} else if (_clientManager.Get(player).GetRank().has(Rank.HELPER) && (violation.getOriginatingServer().equals(_thisServer) || Managers.get(PreferencesManager.class).Get(player).ShowMacReports))
} else if (_clientManager.Get(player).GetRank().has(Rank.HELPER) && (violation.getOriginatingServer().equals(_thisServer) || Managers.get(PreferencesManager.class).get(player).isActive(Preference.GLOBAL_GWEN_REPORTS)))
{
((CraftPlayer) player).getHandle().sendMessage(component);
}

View File

@ -12,19 +12,13 @@ import mineplex.core.donation.DonationManager;
import mineplex.core.hologram.Hologram;
import mineplex.core.hologram.HologramManager;
import mineplex.core.stats.StatsManager;
import mineplex.core.thread.ThreadPool;
import mineplex.core.updater.UpdateType;
import mineplex.core.updater.event.UpdateEvent;
import mineplex.serverdata.Region;
import mineplex.serverdata.redis.counter.GoalCounter;
import mineplex.serverdata.redis.counter.GoalCounterListener;
import mineplex.serverdata.servers.ConnectionData;
import org.bukkit.Bukkit;
import org.bukkit.Location;
import org.bukkit.Material;
import org.bukkit.block.BlockFace;
import org.bukkit.entity.Player;
import org.bukkit.event.EventHandler;
import java.io.File;
import java.io.IOException;
@ -63,7 +57,7 @@ public class Fountain implements GoalCounterListener
_name = name;
_dataKey = dataKey;
_location = location;
_hologram = new Hologram(hologramManager, location.clone().add(4, 3, -3), name).start();
_hologram = new Hologram(hologramManager, new Location(location.getWorld(), -23, 75, 3), name).start();
_counter = new GoalCounter(writeConnection, readConnection, region, dataKey, goal);
_counter.addListener(this);
_brawlActive = false;

View File

@ -3,17 +3,13 @@ package mineplex.core.brawl.fountain;
import mineplex.core.MiniPlugin;
import mineplex.core.account.CoreClientManager;
import mineplex.core.brawl.fountain.command.FountainCommand;
import mineplex.core.brawl.fountain.gui.FountainShop;
import mineplex.core.common.util.C;
import mineplex.core.common.util.UtilServer;
import mineplex.core.common.util.UtilWorld;
import mineplex.core.donation.DonationManager;
import mineplex.core.hologram.HologramManager;
import mineplex.core.stats.StatsManager;
import mineplex.core.updater.UpdateType;
import mineplex.core.updater.event.UpdateEvent;
import mineplex.serverdata.Region;
import mineplex.serverdata.redis.counter.Counter;
import mineplex.serverdata.servers.ConnectionData;
import org.bukkit.Bukkit;
import org.bukkit.Location;
@ -22,12 +18,9 @@ import org.bukkit.entity.Entity;
import org.bukkit.entity.Player;
import org.bukkit.event.EventHandler;
import org.bukkit.event.entity.EntityDamageByEntityEvent;
import org.bukkit.event.player.PlayerCommandPreprocessEvent;
import org.bukkit.event.player.PlayerInteractAtEntityEvent;
import org.bukkit.plugin.java.JavaPlugin;
import java.io.File;
/**
* @author Shaun Bennett
*/
@ -55,7 +48,7 @@ public class FountainManager extends MiniPlugin
int goal = 70000000;//!new File("eu.dat").exists() ? 200000000 : 20000000;
_gemFountain = new Fountain(new ConnectionData("10.3.203.80", 6379, ConnectionData.ConnectionType.MASTER, "USRedis"),
new ConnectionData("10.3.203.80", 6377, ConnectionData.ConnectionType.SLAVE, "USRedis"), Region.ALL,
new Location(world, -32.5, 72, -23.5), new Location(world, -43.5, 67, -38.5),
new Location(world, -25.5, 73, 19.5), new Location(world, -35.5, 69, 1.5),
C.cGreen + "Gem Fountain", "GemFountain_01", goal, this, clientManager, donationManager, _hologramManager, _statsManager);
}

View File

@ -14,6 +14,7 @@ import mineplex.core.common.util.UtilServer;
import mineplex.core.common.util.UtilText;
import mineplex.core.common.util.UtilTime;
import mineplex.core.incognito.IncognitoManager;
import mineplex.core.preferences.Preference;
import mineplex.core.preferences.PreferencesManager;
import mineplex.core.recharge.Recharge;
import mineplex.core.updater.UpdateType;
@ -210,7 +211,7 @@ public class Chat extends MiniPlugin
{
for (Iterator<Player> playerIterator = event.getRecipients().iterator(); playerIterator.hasNext();)
{
if (!_preferences.Get(playerIterator.next()).ShowChat)
if (!_preferences.get(playerIterator.next()).isActive(Preference.SHOW_CHAT))
playerIterator.remove();
}
}

View File

@ -1,13 +1,5 @@
package mineplex.core.friend;
import java.sql.ResultSet;
import java.sql.SQLException;
import java.util.ArrayList;
import java.util.Collections;
import java.util.Iterator;
import java.util.List;
import java.util.UUID;
import mineplex.core.MiniDbClientPlugin;
import mineplex.core.account.CoreClientManager;
import mineplex.core.common.Rank;
@ -25,10 +17,10 @@ import mineplex.core.friend.data.FriendData;
import mineplex.core.friend.data.FriendRepository;
import mineplex.core.friend.data.FriendStatus;
import mineplex.core.portal.Portal;
import mineplex.core.preferences.Preference;
import mineplex.core.preferences.PreferencesManager;
import mineplex.core.updater.UpdateType;
import mineplex.core.updater.event.UpdateEvent;
import mineplex.serverdata.data.PlayerStatus;
import org.bukkit.Bukkit;
import org.bukkit.ChatColor;
@ -36,6 +28,14 @@ import org.bukkit.entity.Player;
import org.bukkit.event.EventHandler;
import org.bukkit.plugin.java.JavaPlugin;
import java.sql.ResultSet;
import java.sql.SQLException;
import java.util.ArrayList;
import java.util.Collections;
import java.util.Iterator;
import java.util.List;
import java.util.UUID;
public class FriendManager extends MiniDbClientPlugin<FriendData>
{
private static FriendSorter _friendSorter = new FriendSorter();
@ -271,7 +271,7 @@ public class FriendManager extends MiniDbClientPlugin<FriendData>
if (friend.Status == FriendStatusType.Blocked || friend.Status == FriendStatusType.Denied)
continue;
if (!_preferenceManager.Get(caller).PendingFriendRequests && friend.Status == FriendStatusType.Pending)
if (!_preferenceManager.get(caller).isActive(Preference.PENDING_FRIEND_REQUESTS) && friend.Status == FriendStatusType.Pending)
continue;
gotAFriend = true;

View File

@ -1,12 +1,11 @@
package mineplex.core.friend.command;
import org.bukkit.entity.Player;
import mineplex.core.command.CommandBase;
import mineplex.core.common.Rank;
import mineplex.core.common.util.Callback;
import mineplex.core.friend.FriendManager;
import mineplex.core.friend.ui.FriendsGUI;
import mineplex.core.preferences.Preference;
import org.bukkit.entity.Player;
public class AddFriend extends CommandBase<FriendManager>
{
@ -20,7 +19,7 @@ public class AddFriend extends CommandBase<FriendManager>
{
if (args == null || args.length < 1)
{
if (Plugin.getPreferenceManager().Get(caller).friendDisplayInventoryUI)
if (Plugin.getPreferenceManager().get(caller).isActive(Preference.FRIENDS_DISPLAY_INVENTORY_UI))
{
new FriendsGUI(Plugin, caller);
}
@ -31,14 +30,11 @@ public class AddFriend extends CommandBase<FriendManager>
}
else
{
_commandCenter.GetClientManager().checkPlayerName(caller, args[0], new Callback<String>()
_commandCenter.GetClientManager().checkPlayerName(caller, args[0], result ->
{
public void run(String result)
if (result != null)
{
if (result != null)
{
Plugin.addFriend(caller, result);
}
Plugin.addFriend(caller, result);
}
});
}

View File

@ -1,5 +1,6 @@
package mineplex.core.friend.command;
import mineplex.core.preferences.Preference;
import org.bukkit.Sound;
import org.bukkit.entity.Player;
@ -19,15 +20,15 @@ public class FriendsDisplay extends CommandBase<FriendManager>
@Override
public void Execute(Player caller, final String[] args)
{
UserPreferences preferences = Plugin.getPreferenceManager().Get(caller);
UserPreferences preferences = Plugin.getPreferenceManager().get(caller);
preferences.friendDisplayInventoryUI = !preferences.friendDisplayInventoryUI;
preferences.toggle(Preference.FRIENDS_DISPLAY_INVENTORY_UI);
Plugin.getPreferenceManager().savePreferences(caller);
Plugin.getPreferenceManager().save(preferences);
caller.playSound(caller.getLocation(), Sound.NOTE_PLING, 1, 1.6f);
if (preferences.friendDisplayInventoryUI)
if (preferences.isActive(Preference.FRIENDS_DISPLAY_INVENTORY_UI))
{
Plugin.runAsync(() -> new FriendsGUI(Plugin, caller));
}

View File

@ -1,30 +1,20 @@
package mineplex.core.gadget;
import java.util.*;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.HashSet;
import java.util.List;
import java.util.Set;
import java.util.function.Predicate;
import mineplex.core.gadget.commands.LockCosmeticsCommand;
import mineplex.core.gadget.event.GadgetChangeEvent;
import mineplex.core.gadget.event.GadgetEnableEvent;
import mineplex.core.gadget.gadgets.arrowtrail.freedom.ArrowTrailFreedom;
import mineplex.core.gadget.gadgets.death.freedom.DeathFreedom;
import mineplex.core.gadget.gadgets.doublejump.freedom.DoubleJumpFreedom;
import mineplex.core.gadget.gadgets.gamemodifiers.kits.KitModifier;
import mineplex.core.gadget.gadgets.hat.*;
import mineplex.core.gadget.gadgets.morph.*;
import mineplex.core.gadget.gadgets.outfit.windupsuit.*;
import mineplex.core.gadget.gadgets.particle.*;
import mineplex.core.gadget.gadgets.particle.candycane.ParticleCandyCane;
import mineplex.core.gadget.gadgets.particle.freedom.ParticleFreedom;
import mineplex.core.gadget.gadgets.wineffect.*;
import mineplex.core.gadget.persistence.UserGadgetPersistence;
import mineplex.core.gadget.set.*;
import mineplex.core.gadget.types.*;
import mineplex.core.incognito.events.IncognitoHidePlayerEvent;
import mineplex.core.incognito.events.IncognitoStatusChangeEvent;
import org.bukkit.*;
import org.bukkit.Bukkit;
import org.bukkit.Location;
import org.bukkit.Material;
import org.bukkit.Sound;
import org.bukkit.entity.Entity;
import org.bukkit.entity.Player;
import org.bukkit.event.EventHandler;
import org.bukkit.event.EventPriority;
import org.bukkit.event.entity.PlayerDeathEvent;
import org.bukkit.event.player.PlayerJoinEvent;
import org.bukkit.event.player.PlayerMoveEvent;
@ -44,46 +34,55 @@ import mineplex.core.common.util.UtilTime;
import mineplex.core.disguise.DisguiseManager;
import mineplex.core.donation.DonationManager;
import mineplex.core.gadget.commands.AmmoCommand;
import mineplex.core.gadget.commands.LockCosmeticsCommand;
import mineplex.core.gadget.commands.UnlockCosmeticsCommand;
import mineplex.core.gadget.event.GadgetChangeEvent;
import mineplex.core.gadget.event.GadgetCollideEntityEvent;
import mineplex.core.gadget.gadgets.arrowtrail.vampire.ArrowTrailBlood;
import mineplex.core.gadget.event.GadgetEnableEvent;
import mineplex.core.gadget.gadgets.arrowtrail.candycane.ArrowTrailCandyCane;
import mineplex.core.gadget.gadgets.arrowtrail.party.ArrowTrailConfetti;
import mineplex.core.gadget.gadgets.arrowtrail.cupidslove.ArrowTrailCupid;
import mineplex.core.gadget.gadgets.arrowtrail.emerald.ArrowTrailEmerald;
import mineplex.core.gadget.gadgets.arrowtrail.wisdom.ArrowTrailEnchant;
import mineplex.core.gadget.gadgets.arrowtrail.freedom.ArrowTrailFreedom;
import mineplex.core.gadget.gadgets.arrowtrail.frostlord.ArrowTrailFrostLord;
import mineplex.core.gadget.gadgets.arrowtrail.music.ArrowTrailMusic;
import mineplex.core.gadget.gadgets.arrowtrail.shadow.ArrowTrailShadow;
import mineplex.core.gadget.gadgets.arrowtrail.howlingwinds.ArrowTrailStorm;
import mineplex.core.gadget.gadgets.arrowtrail.music.ArrowTrailMusic;
import mineplex.core.gadget.gadgets.arrowtrail.party.ArrowTrailConfetti;
import mineplex.core.gadget.gadgets.arrowtrail.shadow.ArrowTrailShadow;
import mineplex.core.gadget.gadgets.arrowtrail.titan.ArrowTrailTitan;
import mineplex.core.gadget.gadgets.death.vampire.DeathBlood;
import mineplex.core.gadget.gadgets.arrowtrail.vampire.ArrowTrailBlood;
import mineplex.core.gadget.gadgets.arrowtrail.wisdom.ArrowTrailEnchant;
import mineplex.core.gadget.gadgets.death.candycane.DeathCandyCane;
import mineplex.core.gadget.gadgets.death.cupidslove.DeathCupidsBrokenHeart;
import mineplex.core.gadget.gadgets.death.emerald.DeathEmerald;
import mineplex.core.gadget.gadgets.death.wisdom.DeathEnchant;
import mineplex.core.gadget.gadgets.death.freedom.DeathFreedom;
import mineplex.core.gadget.gadgets.death.frostlord.DeathFrostLord;
import mineplex.core.gadget.gadgets.death.howlingwinds.DeathStorm;
import mineplex.core.gadget.gadgets.death.music.DeathMusic;
import mineplex.core.gadget.gadgets.death.party.DeathPinataBurst;
import mineplex.core.gadget.gadgets.death.shadow.DeathShadow;
import mineplex.core.gadget.gadgets.death.howlingwinds.DeathStorm;
import mineplex.core.gadget.gadgets.death.titan.DeathTitan;
import mineplex.core.gadget.gadgets.doublejump.vampire.DoubleJumpBlood;
import mineplex.core.gadget.gadgets.death.vampire.DeathBlood;
import mineplex.core.gadget.gadgets.death.wisdom.DeathEnchant;
import mineplex.core.gadget.gadgets.doublejump.candycane.DoubleJumpCandyCane;
import mineplex.core.gadget.gadgets.doublejump.cupidslove.DoubleJumpCupidsWings;
import mineplex.core.gadget.gadgets.doublejump.emerald.DoubleJumpEmerald;
import mineplex.core.gadget.gadgets.doublejump.wisdom.DoubleJumpEnchant;
import mineplex.core.gadget.gadgets.doublejump.party.DoubleJumpFirecracker;
import mineplex.core.gadget.gadgets.doublejump.freedom.DoubleJumpFreedom;
import mineplex.core.gadget.gadgets.doublejump.frostlord.DoubleJumpFrostLord;
import mineplex.core.gadget.gadgets.doublejump.music.DoubleJumpMusic;
import mineplex.core.gadget.gadgets.doublejump.shadow.DoubleJumpShadow;
import mineplex.core.gadget.gadgets.doublejump.howlingwinds.DoubleJumpStorm;
import mineplex.core.gadget.gadgets.doublejump.music.DoubleJumpMusic;
import mineplex.core.gadget.gadgets.doublejump.party.DoubleJumpFirecracker;
import mineplex.core.gadget.gadgets.doublejump.shadow.DoubleJumpShadow;
import mineplex.core.gadget.gadgets.doublejump.titan.DoubleJumpTitan;
import mineplex.core.gadget.gadgets.doublejump.vampire.DoubleJumpBlood;
import mineplex.core.gadget.gadgets.doublejump.wisdom.DoubleJumpEnchant;
import mineplex.core.gadget.gadgets.gamemodifiers.GameModifierType;
import mineplex.core.gadget.gadgets.gamemodifiers.kits.KitGameModifier;
import mineplex.core.gadget.gadgets.gamemodifiers.kits.KitModifier;
import mineplex.core.gadget.gadgets.gamemodifiers.kits.KitModifierType;
import mineplex.core.gadget.gadgets.gamemodifiers.minestrike.GameModifierMineStrikeSkin;
import mineplex.core.gadget.gadgets.gamemodifiers.minestrike.MineStrikeSkin;
import mineplex.core.gadget.gadgets.hat.HatItem;
import mineplex.core.gadget.gadgets.hat.HatType;
import mineplex.core.gadget.gadgets.item.ItemBatGun;
import mineplex.core.gadget.gadgets.item.ItemBow;
import mineplex.core.gadget.gadgets.item.ItemCoal;
@ -101,6 +100,22 @@ import mineplex.core.gadget.gadgets.item.ItemPaintbrush;
import mineplex.core.gadget.gadgets.item.ItemPartyPopper;
import mineplex.core.gadget.gadgets.item.ItemSnowball;
import mineplex.core.gadget.gadgets.item.ItemTNT;
import mineplex.core.gadget.gadgets.morph.MorphBat;
import mineplex.core.gadget.gadgets.morph.MorphBlaze;
import mineplex.core.gadget.gadgets.morph.MorphBlock;
import mineplex.core.gadget.gadgets.morph.MorphBunny;
import mineplex.core.gadget.gadgets.morph.MorphChicken;
import mineplex.core.gadget.gadgets.morph.MorphCow;
import mineplex.core.gadget.gadgets.morph.MorphCreeper;
import mineplex.core.gadget.gadgets.morph.MorphEnderman;
import mineplex.core.gadget.gadgets.morph.MorphPig;
import mineplex.core.gadget.gadgets.morph.MorphPumpkinKing;
import mineplex.core.gadget.gadgets.morph.MorphSlime;
import mineplex.core.gadget.gadgets.morph.MorphSnowman;
import mineplex.core.gadget.gadgets.morph.MorphTitan;
import mineplex.core.gadget.gadgets.morph.MorphUncleSam;
import mineplex.core.gadget.gadgets.morph.MorphVillager;
import mineplex.core.gadget.gadgets.morph.MorphWither;
import mineplex.core.gadget.gadgets.outfit.OutfitTeam;
import mineplex.core.gadget.gadgets.outfit.ravesuit.OutfitRaveSuitBoots;
import mineplex.core.gadget.gadgets.outfit.ravesuit.OutfitRaveSuitChestplate;
@ -110,20 +125,67 @@ import mineplex.core.gadget.gadgets.outfit.spacesuit.OutfitSpaceSuitBoots;
import mineplex.core.gadget.gadgets.outfit.spacesuit.OutfitSpaceSuitChestplate;
import mineplex.core.gadget.gadgets.outfit.spacesuit.OutfitSpaceSuitHelmet;
import mineplex.core.gadget.gadgets.outfit.spacesuit.OutfitSpaceSuitLeggings;
import mineplex.core.gadget.gadgets.particle.vampire.ParticleBlood;
import mineplex.core.gadget.gadgets.particle.emerald.ParticleEmerald;
import mineplex.core.gadget.gadgets.particle.wisdom.ParticleEnchant;
import mineplex.core.gadget.gadgets.particle.shadow.ParticleFoot;
import mineplex.core.gadget.gadgets.particle.frostlord.ParticleFrostLord;
import mineplex.core.gadget.gadgets.outfit.windupsuit.OutfitWindUpSuitBoosterManager;
import mineplex.core.gadget.gadgets.particle.ParticleCoalFumes;
import mineplex.core.gadget.gadgets.particle.ParticleFairy;
import mineplex.core.gadget.gadgets.particle.ParticleFireRings;
import mineplex.core.gadget.gadgets.particle.ParticleLegend;
import mineplex.core.gadget.gadgets.particle.ParticleWingsAngel;
import mineplex.core.gadget.gadgets.particle.ParticleWingsDemons;
import mineplex.core.gadget.gadgets.particle.ParticleWingsInfernal;
import mineplex.core.gadget.gadgets.particle.ParticleWingsPixie;
import mineplex.core.gadget.gadgets.particle.ParticleYinYang;
import mineplex.core.gadget.gadgets.particle.candycane.ParticleCandyCane;
import mineplex.core.gadget.gadgets.particle.cupidslove.ParticleHeart;
import mineplex.core.gadget.gadgets.particle.emerald.ParticleEmerald;
import mineplex.core.gadget.gadgets.particle.freedom.ParticleFreedom;
import mineplex.core.gadget.gadgets.particle.frostlord.ParticleFrostLord;
import mineplex.core.gadget.gadgets.particle.howlingwinds.ParticleRain;
import mineplex.core.gadget.gadgets.particle.music.ParticleMusic;
import mineplex.core.gadget.gadgets.particle.party.ParticlePartyTime;
import mineplex.core.gadget.gadgets.particle.howlingwinds.ParticleRain;
import mineplex.core.gadget.gadgets.particle.shadow.ParticleFoot;
import mineplex.core.gadget.gadgets.particle.titan.ParticleTitan;
import mineplex.core.gadget.gadgets.particle.vampire.ParticleBlood;
import mineplex.core.gadget.gadgets.particle.wisdom.ParticleEnchant;
import mineplex.core.gadget.gadgets.wineffect.WinEffectBabyChicken;
import mineplex.core.gadget.gadgets.wineffect.WinEffectFlames;
import mineplex.core.gadget.gadgets.wineffect.WinEffectLavaTrap;
import mineplex.core.gadget.gadgets.wineffect.WinEffectLightningStrike;
import mineplex.core.gadget.gadgets.wineffect.WinEffectMrPunchMan;
import mineplex.core.gadget.gadgets.wineffect.WinEffectPodium;
import mineplex.core.gadget.gadgets.wineffect.WinEffectRiseOfTheElderGuardian;
import mineplex.core.gadget.gadgets.wineffect.WinEffectSnowTrails;
import mineplex.core.gadget.persistence.UserGadgetPersistence;
import mineplex.core.gadget.set.SetCandyCane;
import mineplex.core.gadget.set.SetCupidsLove;
import mineplex.core.gadget.set.SetEmerald;
import mineplex.core.gadget.set.SetFreedom;
import mineplex.core.gadget.set.SetFrostLord;
import mineplex.core.gadget.set.SetHowlingWinds;
import mineplex.core.gadget.set.SetMusic;
import mineplex.core.gadget.set.SetParty;
import mineplex.core.gadget.set.SetShadow;
import mineplex.core.gadget.set.SetTitan;
import mineplex.core.gadget.set.SetVampire;
import mineplex.core.gadget.set.SetWisdom;
import mineplex.core.gadget.set.suits.SetRaveSuit;
import mineplex.core.gadget.set.suits.SetSpaceSuit;
import mineplex.core.gadget.types.ArrowEffectGadget;
import mineplex.core.gadget.types.DeathEffectGadget;
import mineplex.core.gadget.types.DoubleJumpEffectGadget;
import mineplex.core.gadget.types.Gadget;
import mineplex.core.gadget.types.GadgetSet;
import mineplex.core.gadget.types.GadgetType;
import mineplex.core.gadget.types.GameModifierGadget;
import mineplex.core.gadget.types.HatGadget;
import mineplex.core.gadget.types.ItemGadget;
import mineplex.core.gadget.types.MusicGadget;
import mineplex.core.gadget.types.OutfitGadget;
import mineplex.core.gadget.types.OutfitGadget.ArmorSlot;
import mineplex.core.gadget.types.ParticleGadget;
import mineplex.core.gadget.types.WinEffectGadget;
import mineplex.core.hologram.HologramManager;
import mineplex.core.incognito.events.IncognitoStatusChangeEvent;
import mineplex.core.inventory.InventoryManager;
import mineplex.core.mount.MountManager;
import mineplex.core.mount.event.MountActivateEvent;
@ -160,6 +222,8 @@ public class GadgetManager extends MiniPlugin
private boolean _hideParticles = false;
private int _activeItemSlot = 3;
private boolean _gadgetsEnabled = true;
private Set<Entity> _gadgetCollideWhitelist = new HashSet<>();
public GadgetManager(JavaPlugin plugin, CoreClientManager clientManager, DonationManager donationManager, InventoryManager inventoryManager,
MountManager mountManager, PetManager petManager, PreferencesManager preferencesManager,
@ -740,7 +804,7 @@ public class GadgetManager extends MiniPlugin
return _mountManager;
}
public boolean collideEvent(Player shooter, Gadget gadget, Player other)
public boolean collideEvent(Player shooter, Gadget gadget, Entity other)
{
GadgetCollideEntityEvent collideEvent = new GadgetCollideEntityEvent(shooter, gadget, other);
@ -796,6 +860,46 @@ public class GadgetManager extends MiniPlugin
{
_lastMove.remove(event.getEntity());
}
@EventHandler(priority = EventPriority.LOW)
public void onGadgetCollide(GadgetCollideEntityEvent event)
{
if(event.getOther() instanceof Player)
{
event.setCancelled(false);
return;
}
if(isAffectedByGadgets(event.getOther()))
{
event.setCancelled(false);
}
}
/**
* @param e The entity to check
* @return Returns true if the entity is affected by gadgets like snowballs, flesh hooks etc
*/
public boolean isAffectedByGadgets(Entity e)
{
return _gadgetCollideWhitelist.contains(e);
}
/**
* Set whether or not the given entity should be affected by gadgets by snowball, flesh hooks etc
* By default only players and naturally spawned entities are affected.
*/
public void setAffectedByGadgets(Entity e, boolean affected)
{
if(affected)
{
_gadgetCollideWhitelist.add(e);
}
else
{
_gadgetCollideWhitelist.remove(e);
}
}
public void setActive(Player player, Gadget gadget)
{

View File

@ -2,12 +2,16 @@ package mineplex.core.gadget.event;
import org.bukkit.entity.Entity;
import org.bukkit.entity.Player;
import org.bukkit.event.Cancellable;
import org.bukkit.event.Event;
import org.bukkit.event.HandlerList;
import mineplex.core.gadget.types.Gadget;
public class GadgetCollideEntityEvent extends Event
/**
* An event called when a gadget used by a player collides with an entity. By default, only players are effected (event is cancelled).
*/
public class GadgetCollideEntityEvent extends Event implements Cancellable
{
private static final HandlerList handlers = new HandlerList();
@ -15,7 +19,7 @@ public class GadgetCollideEntityEvent extends Event
private Gadget _gadget;
private Entity _other;
private boolean _cancelled = false;
private boolean _cancelled = true;
public GadgetCollideEntityEvent(Player player, Gadget gadget, Entity other)
{

View File

@ -1,16 +1,5 @@
package mineplex.core.gadget.gadgets.item;
import java.util.ArrayList;
import java.util.HashMap;
import org.bukkit.Location;
import org.bukkit.Material;
import org.bukkit.Sound;
import org.bukkit.entity.Bat;
import org.bukkit.entity.Player;
import org.bukkit.event.EventHandler;
import org.bukkit.util.Vector;
import mineplex.core.common.util.C;
import mineplex.core.common.util.F;
import mineplex.core.common.util.LineFormat;
@ -18,18 +7,29 @@ import mineplex.core.common.util.UtilAction;
import mineplex.core.common.util.UtilAlg;
import mineplex.core.common.util.UtilEnt;
import mineplex.core.common.util.UtilParticle;
import mineplex.core.common.util.UtilParticle.ParticleType;
import mineplex.core.common.util.UtilParticle.ViewDist;
import mineplex.core.common.util.UtilPlayer;
import mineplex.core.common.util.UtilServer;
import mineplex.core.common.util.UtilText;
import mineplex.core.common.util.UtilTime;
import mineplex.core.common.util.UtilParticle.ParticleType;
import mineplex.core.common.util.UtilParticle.ViewDist;
import mineplex.core.gadget.GadgetManager;
import mineplex.core.gadget.gadgets.Ammo;
import mineplex.core.gadget.types.ItemGadget;
import mineplex.core.preferences.Preference;
import mineplex.core.recharge.Recharge;
import mineplex.core.updater.UpdateType;
import mineplex.core.updater.event.UpdateEvent;
import org.bukkit.Location;
import org.bukkit.Material;
import org.bukkit.Sound;
import org.bukkit.entity.Bat;
import org.bukkit.entity.Player;
import org.bukkit.event.EventHandler;
import org.bukkit.util.Vector;
import java.util.ArrayList;
import java.util.HashMap;
public class ItemBatGun extends ItemGadget
{
@ -102,7 +102,7 @@ public class ItemBatGun extends ItemGadget
if (other.equals(cur))
continue;
if (!Manager.getPreferencesManager().Get(other).HubGames || !Manager.getPreferencesManager().Get(other).ShowPlayers)
if (!Manager.getPreferencesManager().get(other).isActive(Preference.HUB_GAMES) || !Manager.getPreferencesManager().get(other).isActive(Preference.SHOW_PLAYERS))
continue;
if (!Recharge.Instance.usable(other, "Hit by Bat"))

View File

@ -13,9 +13,9 @@ import mineplex.core.common.util.F;
import mineplex.core.common.util.LineFormat;
import mineplex.core.common.util.UtilAction;
import mineplex.core.common.util.UtilAlg;
import mineplex.core.common.util.UtilParticle.ParticleType;
import mineplex.core.common.util.UtilPlayer;
import mineplex.core.common.util.UtilText;
import mineplex.core.common.util.UtilParticle.ParticleType;
import mineplex.core.gadget.GadgetManager;
import mineplex.core.gadget.gadgets.Ammo;
import mineplex.core.gadget.types.ItemGadget;
@ -66,9 +66,8 @@ public class ItemFleshHook extends ItemGadget implements IThrown
if (target == null)
return;
if (target instanceof Player)
if (Manager.collideEvent(player, this, (Player) target))
return;
if (Manager.collideEvent(player, this, target))
return;
//Pull
UtilAction.velocity(target,

View File

@ -14,7 +14,6 @@ import mineplex.core.common.util.NautHashMap;
import mineplex.core.common.util.UtilAction;
import mineplex.core.common.util.UtilText;
import mineplex.core.gadget.GadgetManager;
import mineplex.core.gadget.event.GadgetCollideEntityEvent;
import mineplex.core.gadget.gadgets.Ammo;
import mineplex.core.gadget.types.ItemGadget;
@ -53,9 +52,8 @@ public class ItemSnowball extends ItemGadget
if(!_snowballs.containsKey(ball)) return;
GadgetCollideEntityEvent gevent = new GadgetCollideEntityEvent(_snowballs.remove(ball), this, event.getEntity());
if(gevent.isCancelled()) return;
if(Manager.collideEvent(_snowballs.remove(ball), this, event.getEntity())) return;
UtilAction.velocity(event.getEntity(), event.getDamager().getVelocity().normalize().add(new Vector(0,0.5,0)).multiply(0.5));
event.getDamager().getWorld().playSound(event.getDamager().getLocation(), Sound.STEP_SNOW, 1, 0.5f);

View File

@ -19,15 +19,14 @@ import mineplex.core.common.util.NautHashMap;
import mineplex.core.common.util.UtilAction;
import mineplex.core.common.util.UtilEnt;
import mineplex.core.common.util.UtilEvent;
import mineplex.core.common.util.UtilText;
import mineplex.core.common.util.UtilEvent.ActionType;
import mineplex.core.common.util.UtilMath;
import mineplex.core.common.util.UtilParticle;
import mineplex.core.common.util.UtilParticle.ParticleType;
import mineplex.core.common.util.UtilParticle.ViewDist;
import mineplex.core.common.util.UtilText;
import mineplex.core.disguise.disguises.DisguiseSnowman;
import mineplex.core.gadget.GadgetManager;
import mineplex.core.gadget.event.GadgetCollideEntityEvent;
import mineplex.core.gadget.types.MorphGadget;
import mineplex.core.recharge.Recharge;
import mineplex.core.recharge.RechargeData;
@ -143,10 +142,8 @@ public class MorphSnowman extends MorphGadget
if (!_snowball.containsKey(proj))
return;
GadgetCollideEntityEvent gevent = new GadgetCollideEntityEvent(_snowball.remove(proj), this, event.getEntity());
if(gevent.isCancelled()) return;
if(Manager.collideEvent(_snowball.remove(proj), this, event.getEntity())) return;
UtilAction.velocity(event.getEntity(), proj.getVelocity().multiply(0.15).add(new Vector(0, 0.15, 0)));
}

View File

@ -5,6 +5,7 @@ import mineplex.core.common.Rank;
import mineplex.core.common.util.F;
import mineplex.core.common.util.UtilPlayer;
import mineplex.core.incognito.IncognitoManager;
import mineplex.core.preferences.Preference;
import org.bukkit.entity.Player;
public class IncognitoToggleCommand extends CommandBase<IncognitoManager>
@ -18,7 +19,7 @@ public class IncognitoToggleCommand extends CommandBase<IncognitoManager>
@Override
public void Execute(Player caller, String[] args)
{
if (Plugin.getPreferences().Get(caller).Invisibility && !Plugin.Get(caller).Status)
if (Plugin.getPreferences().get(caller).isActive(Preference.INVISIBILITY) && !Plugin.Get(caller).Status)
{
UtilPlayer.message(caller, F.main("Incognito", "You are not allowed to toggle incognito on while Hub Invisibility is enabled."));
return;

View File

@ -0,0 +1,84 @@
package mineplex.core.interactions;
import mineplex.core.MiniPlugin;
import org.bukkit.Material;
import org.bukkit.entity.Player;
import org.bukkit.event.Event.Result;
import org.bukkit.event.EventHandler;
import org.bukkit.event.EventPriority;
import org.bukkit.event.hanging.HangingBreakEvent;
import org.bukkit.event.inventory.InventoryClickEvent;
import org.bukkit.event.inventory.InventoryType;
import org.bukkit.event.player.PlayerArmorStandManipulateEvent;
import org.bukkit.event.player.PlayerInteractEvent;
import org.bukkit.inventory.Inventory;
/**
* Manages interactions with Armor stands, paintings, and in the main hub, taking items out of chests.
*/
public class NewInteractionsManager extends MiniPlugin
{
public NewInteractionsManager()
{
super("Interactions Manager");
registerEvents(this);
}
@EventHandler
public void onInteract(PlayerArmorStandManipulateEvent event)
{
event.setCancelled(true);
}
@EventHandler
public void onClickBrewingStand(PlayerInteractEvent event)
{
if(event.getClickedBlock() != null && event.getClickedBlock().getType() == Material.BREWING_STAND)
{
event.setCancelled(true);
event.setUseInteractedBlock(Result.DENY);
}
}
@EventHandler
public void onPainting(HangingBreakEvent event)
{
event.setCancelled(true);
}
@EventHandler(priority = EventPriority.HIGHEST)
public void onChestInteract(InventoryClickEvent event)
{
Player player = (Player) event.getWhoClicked();
Inventory inventory = event.getClickedInventory();
if(inventory == null)
{
return;
}
if(event.getCurrentItem() == null || event.getCurrentItem().getType() == Material.AIR)
{
return;
}
if(inventory.getType() != InventoryType.CHEST)
{
return;
}
if(inventory.getSize() != 27 && inventory.getSize() != 54)
{
return;
}
if(inventory.getTitle() != null)
{
return;
}
event.setCancelled(true);
event.setResult(Result.DENY);
}
}

View File

@ -1,27 +1,5 @@
package mineplex.core.inventory;
import java.sql.ResultSet;
import java.sql.SQLException;
import java.util.List;
import java.util.Map;
import java.util.UUID;
import org.bukkit.Bukkit;
import org.bukkit.Material;
import org.bukkit.entity.HumanEntity;
import org.bukkit.entity.Player;
import org.bukkit.event.EventHandler;
import org.bukkit.event.EventPriority;
import org.bukkit.event.block.BlockBreakEvent;
import org.bukkit.event.inventory.InventoryClickEvent;
import org.bukkit.event.inventory.InventoryCloseEvent;
import org.bukkit.event.inventory.InventoryOpenEvent;
import org.bukkit.event.inventory.InventoryType;
import org.bukkit.inventory.EnchantingInventory;
import org.bukkit.inventory.Inventory;
import org.bukkit.inventory.ItemStack;
import org.bukkit.plugin.java.JavaPlugin;
import mineplex.cache.player.PlayerCache;
import mineplex.cache.player.PlayerInfo;
import mineplex.core.MiniDbClientPlugin;
@ -33,6 +11,26 @@ import mineplex.core.inventory.data.InventoryRepository;
import mineplex.core.inventory.data.Item;
import mineplex.core.updater.UpdateType;
import mineplex.core.updater.event.UpdateEvent;
import org.bukkit.Bukkit;
import org.bukkit.Material;
import org.bukkit.entity.HumanEntity;
import org.bukkit.entity.Player;
import org.bukkit.event.EventHandler;
import org.bukkit.event.block.BlockBreakEvent;
import org.bukkit.event.inventory.InventoryClickEvent;
import org.bukkit.event.inventory.InventoryCloseEvent;
import org.bukkit.event.inventory.InventoryOpenEvent;
import org.bukkit.event.inventory.InventoryType;
import org.bukkit.inventory.EnchantingInventory;
import org.bukkit.inventory.Inventory;
import org.bukkit.inventory.ItemStack;
import org.bukkit.plugin.java.JavaPlugin;
import java.sql.ResultSet;
import java.sql.SQLException;
import java.util.List;
import java.util.Map;
import java.util.UUID;
public class InventoryManager extends MiniDbClientPlugin<ClientInventory>
{
@ -266,7 +264,7 @@ public class InventoryManager extends MiniDbClientPlugin<ClientInventory>
@EventHandler
public void onInventoryClick(final InventoryClickEvent event)
{
if (event.getView().getTopInventory().getType() != InventoryType.ENCHANTING)
if (event.getClickedInventory() == null || event.getClickedInventory().getType() != InventoryType.ENCHANTING)
{
return;
}

View File

@ -0,0 +1,70 @@
package mineplex.core.menu;
import mineplex.core.MiniPlugin;
import org.bukkit.entity.Player;
import org.bukkit.event.inventory.ClickType;
import org.bukkit.inventory.ItemStack;
/**
* An abstract class for managing buttons inside of menus
*/
public abstract class Button<T extends MiniPlugin>
{
private ItemStack _item;
private T _plugin;
public Button(ItemStack item, T plugin)
{
_item = item;
_plugin = plugin;
}
public Button(ItemStack itemStack)
{
_item = itemStack;
_plugin = null;
}
/**
* The method called when a players clicks the slot
*
* @param player The player who clicked
* @param clickType Tge type of click
*/
public abstract void onClick(Player player, ClickType clickType);
/**
* Called when clicking on a specific item is needed, rather than just the slot
* Empty by default
*
* @param player The player who clicked
* @param clickType Tge type of click
* @param item The ItemStack clicked
*/
public void onClick(Player player, ClickType clickType, ItemStack item)
{
}
public boolean useItemClick()
{
return false;
}
public ItemStack getItemStack()
{
return _item;
}
public void setItemStack(ItemStack item)
{
_item = item;
}
public T getPlugin()
{
return _plugin;
}
}

View File

@ -1,7 +1,5 @@
package mineplex.core.party.ui.button;
package mineplex.core.menu;
import mineplex.core.party.PartyManager;
import mineplex.core.party.ui.Button;
import org.bukkit.entity.Player;
import org.bukkit.event.inventory.ClickType;
import org.bukkit.inventory.ItemStack;
@ -13,9 +11,9 @@ import org.bukkit.inventory.ItemStack;
public class IconButton extends Button
{
public IconButton(ItemStack item, PartyManager plugin)
public IconButton(ItemStack item)
{
super(item, plugin);
super(item);
}
@Override

View File

@ -1,10 +1,7 @@
package mineplex.core.party.ui;
package mineplex.core.menu;
import mineplex.core.common.util.C;
import mineplex.core.MiniPlugin;
import mineplex.core.itemstack.ItemBuilder;
import mineplex.core.party.PartyManager;
import mineplex.core.party.ui.button.IconButton;
import net.md_5.bungee.api.ChatColor;
import org.bukkit.Bukkit;
import org.bukkit.DyeColor;
import org.bukkit.Material;
@ -20,26 +17,20 @@ import java.util.UUID;
/**
* A class to manage dynamic creation of GUI's
*/
public abstract class Menu
public abstract class Menu<T extends MiniPlugin>
{
protected static final Button PANE = new IconButton(new ItemBuilder(Material.STAINED_GLASS_PANE)
.setTitle(" ")
.setData(DyeColor.LIGHT_BLUE.getWoolData())
.build(), null);
protected static final Button PURCHASE_MORE_SLOTS = new IconButton(new ItemBuilder(Material.REDSTONE_BLOCK)
.setTitle(C.cRed + C.Bold + "Locked!")
.setLore(" ", C.cGray + "Purchase a rank @ mineplex.com/shop", C.cGray + "Purchasing a rank increases your", C.cGray + "party size to allow 10 people!")
.build(), null);
private final ItemStack PANE = new ItemBuilder(Material.STAINED_GLASS_PANE).setTitle(" ").setData(DyeColor.LIGHT_BLUE.getWoolData()).build();
protected static final Button[] EMPTY = new Button[54];
protected static Map<UUID, Menu> MENUS = new HashMap<>();
private String _name;
protected static final Map<UUID, Menu> MENUS = new HashMap<>();
private final String _name;
private final T _plugin;
private boolean _useClose = false;
private Button[] _buttons;
protected PartyManager _plugin;
private Player _player;
public Menu(String name, PartyManager plugin)
public Menu(String name, T plugin)
{
_name = name;
_buttons = EMPTY;
@ -51,50 +42,14 @@ public abstract class Menu
return MENUS.get(name);
}
/**
* Create an icon (no click action)
*
* @param item The itemstack ti display
* @return The created button
*/
protected Button create(ItemStack item)
public T getPlugin()
{
return new IconButton(item, _plugin);
return _plugin;
}
public String getName()
{
return ChatColor.translateAlternateColorCodes('&', _name);
}
public Button[] addPanes(Button[] buttons)
{
for (int i = 0; i < 9; i++)
{
if (buttons[i] == null)
{
buttons[i] = PANE;
}
if(buttons.length == 9)
{
continue;
}
if (buttons[i + buttons.length - 9] == null)
{
buttons[i + buttons.length - 9] = PANE;
}
if (i == 0 || i == 8)
{
for (int a = 9; a < buttons.length; a += 9)
{
buttons[i + a] = PANE;
}
}
}
return buttons;
return _name;
}
/**
@ -105,6 +60,7 @@ public abstract class Menu
*/
public void open(Player player)
{
_player = player;
setButtons(setUp(player));
if (MENUS.get(player.getUniqueId()) != null)
@ -115,7 +71,7 @@ public abstract class Menu
MENUS.put(player.getUniqueId(), this);
int size = (_buttons.length + 8) / 9 * 9;
Inventory inventory = Bukkit.createInventory(player, size, getName());
Inventory inventory = Bukkit.createInventory(player, size, _name);
for (int i = 0; i < _buttons.length; i++)
{
@ -173,9 +129,8 @@ public abstract class Menu
*
* @param slot The slot to set the new button
* @param button The reference to the button
* @param player The player whose GUI we'll be updating
*/
public void setButton(int slot, Button button, Player player)
public void setButton(int slot, Button button)
{
try
{
@ -184,24 +139,22 @@ public abstract class Menu
{
ignored.printStackTrace();
}
update(player);
update();
}
/**
* Refresh the players view, allows to change what the player sees, without opening and closing the GUI
*
* @param player The player whose view you wish to update
*/
public void update(Player player)
public void update()
{
InventoryView view = player.getOpenInventory();
InventoryView view = _player.getOpenInventory();
if (view == null)
{
return;
}
if (!view.getTitle().equalsIgnoreCase(getName()))
if (!view.getTitle().equalsIgnoreCase(_name))
{
return;
}
@ -222,25 +175,23 @@ public abstract class Menu
/**
* Reset this players current menu's buttons and refresh the page
*
* @param player The player whose view you wish to update
*/
public void resetAndUpdate(Player player)
public void resetAndUpdate()
{
InventoryView view = player.getOpenInventory();
InventoryView view = _player.getOpenInventory();
if (view == null)
{
return;
}
if (!view.getTitle().equalsIgnoreCase(getName()))
if (!view.getTitle().equalsIgnoreCase(_name))
{
return;
}
Inventory inventory = view.getTopInventory();
Button[] buttons = setUp(player);
Button[] buttons = setUp(_player);
for (int i = 0; i < buttons.length; i++)
{
if (buttons[i] == null)
@ -254,19 +205,56 @@ public abstract class Menu
}
}
public void setTitle(String title)
protected Button[] pane(Button[] buttons)
{
_name = title;
for (int i = 0; i < 9; i++)
{
if (buttons[i] == null)
{
buttons[i] = new IconButton(PANE);
}
if (buttons[i + buttons.length - 9] == null)
{
buttons[i + buttons.length - 9] = new IconButton(PANE);
}
if (i == 0 || i == 8)
{
for (int a = 0; a < buttons.length; a += 9)
{
if (buttons[i + a] == null)
{
buttons[i + a] = new IconButton(PANE);
}
}
}
}
return buttons;
}
public void onClose(Player player)
{
MENUS.remove(player.getUniqueId());
}
public static Menu remove(UUID uniqueId)
{
return MENUS.remove(uniqueId);
}
public Player getPlayer()
{
return _player;
}
public boolean isUseClose()
{
return _useClose;
}
public void setUseClose(boolean useClose)
{
_useClose = useClose;
}
}

View File

@ -1,12 +1,11 @@
package mineplex.core.party.ui;
package mineplex.core.menu;
import mineplex.core.party.ui.button.PartyMemberIcon;
import mineplex.core.party.ui.menus.PartyOwnerMenu;
import org.bukkit.entity.Player;
import org.bukkit.event.Event;
import org.bukkit.event.EventHandler;
import org.bukkit.event.Listener;
import org.bukkit.event.inventory.InventoryClickEvent;
import org.bukkit.event.inventory.InventoryCloseEvent;
/**
* Listener for the Menu system
@ -41,17 +40,37 @@ public class MenuListener implements Listener
return;
}
if(button instanceof PartyMemberIcon)
if(button.useItemClick())
{
if(!(gui instanceof PartyOwnerMenu))
{
return;
}
((PartyMemberIcon) button).onClick(player, event.getCurrentItem());
button.onClick(player, event.getClick(), event.getCurrentItem());
return;
}
button.onClick(player, event.getClick());
}
@EventHandler
public void onClose(InventoryCloseEvent event)
{
String name = event.getInventory().getName();
Player player = (Player) event.getPlayer();
Menu gui = Menu.get(player.getUniqueId());
if (gui == null)
{
return;
}
if (!gui.getName().equalsIgnoreCase(name))
{
return;
}
if(gui.isUseClose())
{
gui.onClose(player);
gui.setUseClose(false);
}
}
}

View File

@ -0,0 +1,18 @@
package mineplex.core.menu;
import mineplex.core.MiniPlugin;
import org.bukkit.plugin.java.JavaPlugin;
/**
*
*/
public class MenuManager extends MiniPlugin
{
public MenuManager(JavaPlugin plugin)
{
super("Menu Manager", plugin);
getPluginManager().registerEvents(new MenuListener(), plugin);
}
}

View File

@ -25,6 +25,7 @@ import mineplex.core.message.commands.ResendAdminCommand;
import mineplex.core.message.commands.ResendCommand;
import mineplex.core.message.redis.RedisMessage;
import mineplex.core.message.redis.RedisMessageCallback;
import mineplex.core.preferences.Preference;
import mineplex.core.preferences.PreferencesManager;
import mineplex.core.punish.Punish;
import mineplex.core.punish.PunishClient;
@ -145,7 +146,7 @@ public class MessageManager extends MiniClientPlugin<ClientMessage>
public String canReceiverMessageThem(String sender, Player target)
{
// If the receiver has turned off private messaging and the sender isn't a mod
if (!_preferences.Get(target).PrivateMessaging)
if (!_preferences.get(target).isActive(Preference.PRIVATE_MESSAGING))
{
return C.cPurple + target.getName() + " has private messaging disabled.";

View File

@ -1,11 +1,5 @@
package mineplex.core.notifier;
import org.bukkit.Bukkit;
import org.bukkit.ChatColor;
import org.bukkit.entity.Player;
import org.bukkit.event.EventHandler;
import org.bukkit.plugin.java.JavaPlugin;
import mineplex.core.MiniPlugin;
import mineplex.core.account.CoreClientManager;
import mineplex.core.common.Rank;
@ -14,8 +8,10 @@ import mineplex.core.common.util.F;
import mineplex.core.common.util.UtilPlayer;
import mineplex.core.common.util.UtilServer;
import mineplex.core.preferences.PreferencesManager;
import mineplex.core.updater.UpdateType;
import mineplex.core.updater.event.UpdateEvent;
import org.bukkit.entity.Player;
import org.bukkit.event.EventHandler;
import org.bukkit.plugin.java.JavaPlugin;
public class NotificationManager extends MiniPlugin
{
@ -60,7 +56,7 @@ public class NotificationManager extends MiniPlugin
{
for (Player player : UtilServer.getPlayers())
{
if (!_preferencesManager.Get(player).DisableAds)
if (_preferencesManager.getClientManager().Get(player).GetRank() == Rank.ALL)
{
player.sendMessage(C.cWhite + " ");
player.sendMessage(C.cRedB + " MASSIVE WINTER SALE");

View File

@ -1,6 +1,7 @@
package mineplex.core.party;
import mineplex.core.common.util.C;
import mineplex.core.common.util.F;
import org.bukkit.entity.Player;
import java.text.MessageFormat;
@ -44,10 +45,25 @@ public enum Lang
PARTY_FULL("Error: Your party is full!"),
SERVER_CLOSED("Error: Your server is closed and you cannot invite players to join it right now!"),
SERVER_FULL("Error: Your server is full and you cannot invite more players to join it right now!"),
PLAYER_IN_DIFFERENT_PARTY("Error: {0} is in a different party.")
PLAYER_IN_DIFFERENT_PARTY("Error: {0} is in a different party."),
PARTNER_ALREADY_INVITED("Error: You have already invited {0} to be your partner for {1}."),
PARTNER_NO_GAME("Error: {0} is not a valid game name."),
PARTNER_NO_PLAYER("Error: You didn't specify a player to partner with."),
PARTNER_NOT_ONLINE("Error: {0} is not on your server!"),
PARTNER_PLAYER_NOT_REQUESTED("Error: {0} hasn't made a partner request with you yet!"),
PARTNER_USAGE("Usage: /teampref accept/deny <player>."),
PARTNER_HOVER_TEXT_ACCEPT("Click to be {0}''s partner for {1}."),
PARTNER_HOVER_TEXT_DENY("Click to decline being {0}''s partner for {1}."),
PARTNER_REQUEST_SENT("Partner request sent to {0} for {1}."),
PARTNER_REQUEST_RECEIVED("Partner request from {0} for {1}."),
PARTNER_REQUEST_DENIED_SENDER("{0} has declined your partner request for {1}."),
PARTNER_REQUEST_DENIED_PLAYER("You have denied {0}''s partner request for {1}."),
PARTNER_REQUEST_ACCEPT_SENDER("{0} has accepted your partner request for {1}."),
PARTNER_REQUEST_ACCEPT_PLAYER("You have accepted {0}''s partner request for {1}."),
;
private String _message;
Lang(String message)
@ -55,6 +71,16 @@ public enum Lang
_message = message;
}
public String toString(String... args)
{
return getFormatted(args);
}
public void sendHeader(Player player, String header, String... args)
{
player.sendMessage(F.main(header, getFormatted(args)));
}
public void send(Player player, String... args)
{
player.sendMessage(C.mHead + "Party> " + getFormatted(args));
@ -65,16 +91,16 @@ public enum Lang
party.sendMessage(C.mHead + "Party> " + getFormatted(args));
}
private String getFormatted(String[] args)
private String getFormatted(String... args)
{
String color = C.mBody;
if(args.length == 0)
if (args == null || args.length == 0)
{
return color + _message;
}
if(_message.startsWith("Error:"))
if (_message.startsWith("Error:"))
{
color = C.cRed;
}
@ -83,7 +109,7 @@ public enum Lang
String[] coloredArgs = new String[args.length];
for(int i = 0; i < args.length; i++)
for (int i = 0; i < args.length; i++)
{
coloredArgs[i] = C.cYellow + args[i] + color;
}
@ -96,4 +122,4 @@ public enum Lang
return message;
}
}
}

View File

@ -35,10 +35,20 @@ public class Party
*/
private static final int PARTY_MAX_SIZE = 16;
/**
* Partners that have already been placed
*/
private transient final List<UUID> _teamed;
/**
* The current leader of this party
*/
private UUID _owner;
private String _owner;
/**
* The names of all current party members
*/
private List<String> _members;
/**
* The UUIDS of all current party members
@ -55,12 +65,17 @@ public class Party
*/
private int _size;
/**
* Team preferences
*/
private Map<UUID, Map<String, String>> _preferences;
/**
* Empty constructor for GSON
*/
public Party()
{
_teamed = Lists.newArrayList();
}
/**
@ -68,16 +83,31 @@ public class Party
*
* @param owner The owner / leader of the party.
*/
public Party(UUID owner)
public Party(String owner)
{
_owner = owner;
_members = Lists.newArrayList();
_invites = Maps.newHashMap();
_members.add(owner);
_teamed = Lists.newArrayList();
_membersByUUID = Lists.newArrayList();
_preferences = Maps.newHashMap();
_membersByUUID.add(Bukkit.getPlayerExact(owner).getUniqueId());
}
public String getOwner()
{
return Bukkit.getPlayer(_owner).getName();
return _owner;
}
/**
* Get the current members by their IGN
*
* @return The list of named party members
*/
public List<String> getMembers()
{
return _members;
}
public Map<String, Long> getInvites()
@ -94,12 +124,39 @@ public class Party
*/
public String getName()
{
return getOwner();
return _owner;
}
public List<UUID> getMembers()
/**
* Gets the players preferred teammate for a game
*
* @param player The player's UUID
* @return His team preference
*/
public String getPartner(UUID player, String game)
{
return this._membersByUUID;
Map<String, String> prefs = _preferences.get(player);
if (prefs == null)
{
prefs = Maps.newHashMap();
_preferences.put(player, prefs);
return null;
}
return prefs.get(game);
}
/**
* Set a player's partner preference
*
* @param player The player
* @param game The name of the game
* @param partner The name of his partner
*/
public void setPartner(Player player, String game, String partner)
{
Map<String, String> prefs = _preferences.getOrDefault(player.getUniqueId(), Maps.newHashMap());
prefs.put(game, partner);
_preferences.put(player.getUniqueId(), prefs);
}
/**
@ -109,7 +166,7 @@ public class Party
*/
public void sendMessage(String message)
{
getMembers().stream().map(Bukkit::getPlayer).forEach(player -> player.sendMessage(message));
getMembersByUUID().stream().map(Bukkit::getPlayer).forEach(player -> player.sendMessage(message));
}
public int getSize()
@ -133,14 +190,12 @@ public class Party
*/
public void onPlayerAdd(String player)
{
Player pl = Bukkit.getPlayerExact(player);
UUID uuid = pl.getUniqueId();
_invites.remove(player);
if(_membersByUUID.contains(uuid))
if(_members.contains(player))
{
return;
}
_membersByUUID.add(uuid);
_members.add(player);
Lang.ADD_MEMBER.send(this, player);
getMembers().forEach(s ->
{
@ -152,42 +207,46 @@ public class Party
/**
* Called when a member of the party is removed
*
* @param uuid The uuid of the player
* @param player The name of the player
* @param reason The reason for his removal.
*/
public void onPlayerRemove(UUID uuid, PartyRemoveReason reason)
public void onPlayerRemove(String player, PartyRemoveReason reason)
{
Player bukkitPlayer = Bukkit.getPlayer(uuid);
if(reason == PartyRemoveReason.DISBANDED)
{
Player bukkitPlayer = Bukkit.getPlayerExact(player);
Lang.DISBANDED.send(bukkitPlayer);
bukkitPlayer.closeInventory();
return;
}
if(_membersByUUID.size() <= 0)
if(_members.size() <= 0)
{
return;
}
if(reason == PartyRemoveReason.LEFT)
{
if(uuid.equals(_owner) && _membersByUUID.size() > 1)
if(player.equalsIgnoreCase(_owner) && _members.size() > 1)
{
_owner = _membersByUUID.get(0);
Lang.TRANSFER_OWNER.send(this, bukkitPlayer.getName(), getOwner());
PartyTransferOwnerEvent event = new PartyTransferOwnerEvent(this, getOwner(), bukkitPlayer.getName(), TransferReason.LEFT);
_owner = _members.get(0);
Lang.TRANSFER_OWNER.send(this, player, _owner);
PartyTransferOwnerEvent event = new PartyTransferOwnerEvent(this, _owner, player, TransferReason.LEFT);
UtilServer.getServer().getPluginManager().callEvent(event);
return;
}
Lang.REMOVE_PLAYER.send(this, bukkitPlayer.getName());
Lang.REMOVE_PLAYER.send(this, player);
return;
}
if(reason == PartyRemoveReason.OTHER)
{
return;
}
if(reason == PartyRemoveReason.KICKED)
{
Lang.REMOVE_PLAYER_KICK.send(this, bukkitPlayer.getName());
Lang.REMOVE_PLAYER_KICK.send(this, player);
}
}
@ -218,7 +277,7 @@ public class Party
*/
public void setOwner(String owner)
{
_owner = Bukkit.getPlayerExact(owner).getUniqueId();
_owner = owner;
}
/**
@ -241,11 +300,6 @@ public class Party
_alreadyTeamed = alreadyTeamed;
}
public UUID getOwnerId()
{
return this._owner;
}
/**
* Check to see if this party contains a certain player name
* This is case-insensitive
@ -255,7 +309,7 @@ public class Party
*/
public boolean contains(String name)
{
for(UUID member : _membersByUUID)
for (UUID member : _membersByUUID)
{
if (Bukkit.getPlayer(member).getName().equalsIgnoreCase(name))
{
@ -264,4 +318,17 @@ public class Party
}
return false;
}
public boolean isAlreadyTeamed(UUID uuid)
{
return _teamed.contains(uuid);
}
public void setTeamed(Player... players)
{
for (Player player : players)
{
_teamed.add(player.getUniqueId());
}
}
}

View File

@ -1,11 +1,11 @@
package mineplex.core.party;
import mineplex.core.common.Rank;
import mineplex.core.menu.Menu;
import mineplex.core.party.constants.PartyRemoveReason;
import mineplex.core.party.event.PartyMemberKickGUIEvent;
import mineplex.core.party.event.PartySendToServerEvent;
import mineplex.core.party.event.PartyTransferOwnerEvent;
import mineplex.core.party.ui.Menu;
import mineplex.core.portal.ServerTransferEvent;
import mineplex.serverdata.data.MinecraftServer;
import org.bukkit.Bukkit;
@ -47,11 +47,11 @@ public class PartyEventListener implements Listener
Player bukkitPlayer = Bukkit.getPlayerExact(partyName);
if (party == null && bukkitPlayer != null)
if (party == null)
{
party = new Party(bukkitPlayer.getUniqueId());
party = new Party(partyName);
if (_plugin.getClientManager().Get(bukkitPlayer).GetRank().has(Rank.ULTRA))
if (bukkitPlayer != null && _plugin.getClientManager().Get(bukkitPlayer).GetRank().has(Rank.ULTRA))
{
party.setSize();
} else
@ -109,7 +109,7 @@ public class PartyEventListener implements Listener
Player clicked = Bukkit.getPlayerExact(event.getPlayerClicked());
Lang.REMOVED.send(clicked);
_plugin.getMethodManager().removeFromParty(clicked, PartyRemoveReason.KICKED);
Menu.get(event.getOwner().getUniqueId()).resetAndUpdate(event.getOwner());
Menu.get(event.getOwner().getUniqueId()).resetAndUpdate();
}
@EventHandler

View File

@ -10,17 +10,17 @@ import mineplex.core.party.manager.PartyInviteManager;
import mineplex.core.party.manager.PartyJoinManager;
import mineplex.core.party.manager.PartyMethodManager;
import mineplex.core.party.manager.PartyRedisManager;
import mineplex.core.party.ui.MenuListener;
import mineplex.core.portal.Portal;
import mineplex.core.preferences.PreferencesManager;
import mineplex.serverdata.Region;
import mineplex.serverdata.Utility;
import mineplex.serverdata.servers.ServerManager;
import org.bukkit.Bukkit;
import org.bukkit.Material;
import org.bukkit.entity.Player;
import org.bukkit.inventory.ItemStack;
import org.bukkit.plugin.java.JavaPlugin;
import java.io.File;
import java.util.Map;
import java.util.UUID;
@ -58,7 +58,9 @@ public class PartyManager extends MiniPlugin
/**
* A map of owner (name) -> party server wide
*/
private final Map<UUID, Party> _parties = Maps.newHashMap();
private final Map<String, Party> _parties = Maps.newHashMap();
private final Region _region;
public PartyManager(JavaPlugin plugin, Portal portal, CoreClientManager clientManager, PreferencesManager preferenceManager)
{
@ -78,13 +80,14 @@ public class PartyManager extends MiniPlugin
_methodManager = new PartyMethodManager(this);
addCommand(new PartyCommand(this));
getPluginManager().registerEvents(new MenuListener(), getPlugin());
new PartyEventListener(this);
_region = !new File("eu.dat").exists() ? Region.US : Region.EU;
}
public Party getParty(String party)
{
return _parties.get(Bukkit.getPlayerExact(party).getUniqueId());
return _parties.get(party);
}
public Party getParty(Player player)
@ -94,12 +97,12 @@ public class PartyManager extends MiniPlugin
public void addParty(Party party)
{
_parties.put(party.getOwnerId(), party);
_parties.put(party.getName(), party);
}
public void removeParty(Party party)
{
_parties.remove(party.getOwnerId());
_parties.remove(party.getName());
}
public Portal getPortal()
@ -147,8 +150,14 @@ public class PartyManager extends MiniPlugin
return _players;
}
public Map<UUID, Party> getParties()
public Map<String, Party> getParties()
{
return _parties;
}
public Region getRegion()
{
return _region;
}
}

View File

@ -0,0 +1,167 @@
package mineplex.core.party.command;
import com.google.common.collect.Maps;
import mineplex.core.command.CommandBase;
import mineplex.core.common.Rank;
import mineplex.core.common.util.C;
import mineplex.core.common.util.UtilPlayer;
import mineplex.core.game.GameDisplay;
import mineplex.core.party.Lang;
import mineplex.core.party.Party;
import mineplex.core.party.PartyManager;
import org.bukkit.Bukkit;
import org.bukkit.entity.Player;
import java.util.Map;
import java.util.UUID;
/**
* Unused for now.
*/
public class TeamPreferenceCommand extends CommandBase<PartyManager>
{
private static final String[] ARGS = {
"teampref",
"teamprefs",
"teamp",
"tprefs",
"teampreferences"
};
private final String ACCEPT = "accept";
private final String DENY = "deny";
private final String ACCEPT_COMMAND = "/teamprefs accept ";
private final String DENY_COMMAND = "/teamprefs deny ";
private final String HEADER = "Partners";
//Player, Partner, GameName
private Map<UUID, Map<String, String>> INVITES = Maps.newHashMap();
public TeamPreferenceCommand(PartyManager plugin)
{
super(plugin, Rank.ALL, ARGS);
}
@Override
public void Execute(Player player, String[] args)
{
if (args.length < 2)
{
Lang.PARTNER_USAGE.sendHeader(player, HEADER);
return;
}
String arg = args[0];
if (arg.equalsIgnoreCase(ACCEPT) || arg.equalsIgnoreCase(DENY))
{
Party party = Plugin.getParty(player);
if (party == null)
{
Lang.NO_PARTY.send(player);
return;
}
String inviter = args[1];
boolean accept = arg.equalsIgnoreCase(ACCEPT);
Player inviterPlayer = Bukkit.getPlayerExact(inviter);
if (inviterPlayer == null)
{
Lang.PARTNER_NOT_ONLINE.sendHeader(player, HEADER, inviter);
return;
}
Map<String, String> sent = INVITES.get(inviterPlayer.getUniqueId());
if (sent == null || sent.isEmpty())
{
Lang.PARTNER_PLAYER_NOT_REQUESTED.sendHeader(player, HEADER, inviter);
return;
}
if (sent.get(player.getName()) == null)
{
Lang.PARTNER_PLAYER_NOT_REQUESTED.sendHeader(player, HEADER, inviter);
return;
}
String gameName = sent.remove(player.getName());
if (!accept)
{
Lang.PARTNER_REQUEST_DENIED_PLAYER.send(player, inviterPlayer.getName(), gameName);
Lang.PARTNER_REQUEST_DENIED_SENDER.send(inviterPlayer, player.getName(), gameName);
return;
}
Lang.PARTNER_REQUEST_ACCEPT_PLAYER.send(player, inviterPlayer.getName(), gameName);
Lang.PARTNER_REQUEST_ACCEPT_SENDER.send(inviterPlayer, player.getName(), gameName);
party.setPartner(player, gameName, inviterPlayer.getName());
party.setPartner(inviterPlayer, gameName, player.getName());
return;
}
Player target = Bukkit.getPlayerExact(arg);
String gameName = "";
String[] game = new String[args.length - 2];
System.arraycopy(args, 2, game, 0, game.length);
for (String s : game)
{
gameName += s + " ";
}
gameName = gameName.trim();
GameDisplay gameDisplay = GameDisplay.matchName(gameName);
if (gameDisplay == null)
{
Lang.PARTNER_NO_GAME.sendHeader(player, HEADER, gameName);
return;
}
gameName = gameDisplay.getName();
if (alreadyInvited(player, gameName, target.getName()))
{
Lang.PARTNER_ALREADY_INVITED.sendHeader(player, HEADER, target.getName(), gameName);
return;
}
sendRequest(player, gameName, target);
}
private void sendRequest(Player player, String game, Player partner)
{
invite(player, game, partner);
String gameName = C.cGreen + (game);
String playerName = C.cGreen + (player.getName());
String partnerName = C.cGreen + (partner.getName());
String acceptCommand = ACCEPT_COMMAND + player.getName();
String declineCommand = DENY_COMMAND + player.getName();
String acceptText = Lang.PARTNER_HOVER_TEXT_ACCEPT.toString(playerName, gameName);
String declineText = Lang.PARTNER_HOVER_TEXT_DENY.toString(playerName, gameName);
Lang.PARTNER_REQUEST_SENT.sendHeader(player, HEADER, partnerName, gameName);
Lang.PARTNER_REQUEST_RECEIVED.sendHeader(partner, HEADER, playerName, gameName);
UtilPlayer.sendAcceptOrDeny(partner, HEADER, acceptCommand, acceptText, declineCommand, declineText, null, null);
}
private boolean alreadyInvited(Player player, String game, String partner)
{
Map<String, String> sent = INVITES.get(player.getUniqueId());
return !(sent == null || sent.isEmpty()) && sent.get(partner).equalsIgnoreCase(game);
}
private void invite(Player player, String game, Player partner)
{
Map<String, String> sent = INVITES.getOrDefault(player.getUniqueId(), Maps.newHashMap());
sent.put(partner.getName(), game);
INVITES.put(player.getUniqueId(), sent);
}
}

View File

@ -80,7 +80,7 @@ public class PartyInviteManager
}
if (newParty == null)
{
newParty = new Party(possible.getUniqueId());
newParty = new Party(possible.getName());
if(_plugin.getClientManager().Get(possible).GetRank().has(Rank.ULTRA))
{
newParty.setSize();

View File

@ -8,6 +8,7 @@ import mineplex.core.party.Party;
import mineplex.core.party.PartyManager;
import mineplex.core.party.constants.JoinResponseReason;
import mineplex.core.party.redis.RedisMessageType;
import mineplex.serverdata.servers.ServerManager;
import org.bukkit.Bukkit;
import org.bukkit.entity.Player;
@ -32,6 +33,27 @@ public class PartyJoinManager
_transferring = Lists.newArrayList();
}
/**
* Scans through the party to check if all players are some form of VIP
* If the party contains even 1 non-vip, the party cannot be sent to a full server
*
* @param party The party
* @return <code>true</code> if the party contains all VIP's <code>false</code> if it contains even 1 non-vip
*/
public boolean canJoinFullServer(Party party)
{
List<Player> players = party.getMembersByUUID().stream().map(Bukkit::getPlayer).collect(Collectors.toList());
for (Player player : players)
{
Rank rank = _plugin.getClientManager().Get(player).GetRank();
if (rank == Rank.ALL)
{
return false;
}
}
return true;
}
/**
* Initiates a request to join a server for a specific party
*
@ -40,17 +62,7 @@ public class PartyJoinManager
*/
public void requestServerJoin(String server, Party party)
{
boolean canJoinFull = true;
List<Player> players = party.getMembers().stream().map(Bukkit::getPlayer).collect(Collectors.toList());
for (Player player : players)
{
Rank rank = _plugin.getClientManager().Get(player).GetRank();
if (rank == Rank.ALL)
{
canJoinFull = false;
break;
}
}
boolean canJoinFull = canJoinFullServer(party);
_plugin.getRedisManager().publish(server, RedisMessageType.PREJOIN_SERVER_REQUEST,
_plugin.getServerName(), party.getOwner(), "" + party.getMembers().size(), "" + canJoinFull);
}
@ -75,7 +87,7 @@ public class PartyJoinManager
return;
}
}
ServerManager.getServerRepository(_plugin.getRegion()).getServerStatus(_plugin.getServerName()).incrementPlayerCount(partySize);
_plugin.getRedisManager().publish(serverFrom, RedisMessageType.PREJOIN_SERVER_RESPONSE, initiator, JoinResponseReason.SUCCESS.name(), _plugin.getServerName());
}

View File

@ -2,11 +2,12 @@ package mineplex.core.party.manager;
import com.google.common.collect.Lists;
import mineplex.core.common.util.F;
import mineplex.core.menu.Menu;
import mineplex.core.party.Lang;
import mineplex.core.party.Party;
import mineplex.core.party.PartyManager;
import mineplex.core.party.constants.PartyRemoveReason;
import mineplex.core.party.ui.Menu;
import mineplex.core.preferences.Preference;
import org.bukkit.Bukkit;
import org.bukkit.entity.Player;
@ -75,7 +76,7 @@ public class PartyMethodManager
//Same Server
if (possible != null)
{
if(!_plugin.getPreferencesManager().Get(possible).PartyRequests)
if(!_plugin.getPreferencesManager().get(possible).isActive(Preference.PARTY_REQUESTS))
{
caller.sendMessage(F.main("Party> ", F.name(target) + " is not accepting invites at this time."));
return;
@ -83,7 +84,7 @@ public class PartyMethodManager
if (party == null)
{
if(_plugin.getParty(possible) != null)
if(_plugin.getParty(target) != null)
{
Lang.PLAYER_IN_DIFFERENT_PARTY.send(caller, target);
return;
@ -117,7 +118,7 @@ public class PartyMethodManager
}
//Not on the same server
_plugin.getRedisManager().findAndInvite(target, caller);
_plugin.getRedisManager().findAndInvite(target, caller.getName());
}
/**
@ -265,7 +266,8 @@ public class PartyMethodManager
{
return;
}
party.onPlayerRemove(uuid, PartyRemoveReason.OTHER);
String player = Bukkit.getPlayer(uuid).getName();
party.onPlayerRemove(player, PartyRemoveReason.OTHER);
}
public void removeFromParty(UUID uuid, PartyRemoveReason reason)
@ -293,7 +295,7 @@ public class PartyMethodManager
}
party.getMembers().remove(player.getName());
party.getMembersByUUID().remove(uuid);
party.onPlayerRemove(player.getUniqueId(), reason);
party.onPlayerRemove(player.getName(), reason);
int size = party.getMembers().size();
if(size <= 1)
@ -303,7 +305,7 @@ public class PartyMethodManager
_plugin.removeParty(party);
return;
}
_plugin.getPlayerParties().remove(party.getMembers().get(0));
_plugin.getPlayerParties().remove(Bukkit.getPlayerExact(party.getMembers().get(0)).getUniqueId());
party.onPlayerRemove(party.getMembers().get(0), PartyRemoveReason.DISBANDED);
_plugin.removeParty(party);
}
@ -326,14 +328,19 @@ public class PartyMethodManager
public void transferOwner(String newOwner, String oldOwner)
{
Party party = _plugin.getParties().remove(Bukkit.getPlayerExact(oldOwner).getUniqueId());
Party party = _plugin.getParties().remove(oldOwner);
if(party == null)
{
return;
}
_plugin.getParties().put(Bukkit.getPlayerExact(newOwner).getUniqueId(), party);
_plugin.getParties().put(newOwner, party);
party.setOwner(newOwner);
party.getMembers().remove(Bukkit.getPlayerExact(oldOwner).getUniqueId());
party.getMembers().add(Bukkit.getPlayerExact(oldOwner).getUniqueId());
party.getMembers().remove(oldOwner);
party.getMembers().add(oldOwner);
UUID uuid = Bukkit.getPlayerExact(oldOwner).getUniqueId();
party.getMembersByUUID().remove(uuid);
party.getMembersByUUID().add(uuid);
}
}

View File

@ -12,6 +12,7 @@ import mineplex.core.party.constants.JoinResponseReason;
import mineplex.core.party.event.PartyDataReceivedEvent;
import mineplex.core.party.redis.PartyRedisListener;
import mineplex.core.party.redis.RedisMessageType;
import mineplex.core.preferences.Preference;
import org.bukkit.Bukkit;
import org.bukkit.entity.Player;
import org.bukkit.scheduler.BukkitRunnable;
@ -120,7 +121,7 @@ public class PartyRedisManager
return;
}
if(!_plugin.getPreferencesManager().Get(player).PartyRequests)
if(!_plugin.getPreferencesManager().get(player).isActive(Preference.PARTY_REQUESTS))
{
publish(first, RedisMessageType.INVITE_PLAYER_NOT_ACCEPTING_INVITES, _serverName, player.getName(), player.getUniqueId().toString(), third);
return;
@ -191,9 +192,9 @@ public class PartyRedisManager
* @param player The player target
* @param sender The sending player
*/
public void findAndInvite(String player, Player sender)
public void findAndInvite(String player, String sender)
{
sender.sendMessage(F.main("Party", "Locating " + F.elem(player) + "..."));
Bukkit.getPlayerExact(sender).sendMessage(F.main("Party", "Locating " + F.elem(player) + "..."));
TASKS.put(player, new BukkitRunnable()
{
@Override
@ -205,19 +206,25 @@ public class PartyRedisManager
return;
}
TASKS.remove(player);
Player senderPlayer = Bukkit.getPlayerExact(sender);
if (senderPlayer == null)
{
cancel();
return;
}
if (Bukkit.getPlayerExact(player) != null)
{
cancel();
return;
}
sender.sendMessage(F.main("Party", "Could not locate " + F.elem(player) + "."));
senderPlayer.sendMessage(F.main("Party", "Could not locate " + F.elem(player) + "."));
}
}.runTaskLater(_plugin.getPlugin(), 20L * 5));
_plugin.runAsync(() -> {
try (Jedis jedis = _writePool.getResource())
{
jedis.publish(FIND_PLAYERS_CHANNEL, RedisMessageType.PLAYER_FIND_REQUEST.format(_serverName, player, sender.getName()));
jedis.publish(FIND_PLAYERS_CHANNEL, RedisMessageType.PLAYER_FIND_REQUEST.format(_serverName, player, sender));
}
});
}

View File

@ -1,45 +0,0 @@
package mineplex.core.party.ui;
import mineplex.core.party.PartyManager;
import org.bukkit.entity.Player;
import org.bukkit.event.inventory.ClickType;
import org.bukkit.inventory.ItemStack;
/**
* An abstract class for managing buttons inside of menus
*/
public abstract class Button
{
private ItemStack _item;
private PartyManager _plugin;
public Button(ItemStack item, PartyManager plugin)
{
this._item = item;
_plugin = plugin;
}
/**
* The method called when a players clicks the slot
*
* @param player The player who clicked
*/
public abstract void onClick(Player player, ClickType clickType);
public ItemStack getItemStack()
{
return _item;
}
public void setItemStack(ItemStack item)
{
this._item = item;
}
public PartyManager getPlugin()
{
return _plugin;
}
}

View File

@ -0,0 +1,27 @@
package mineplex.core.party.ui;
import mineplex.core.common.util.C;
import mineplex.core.itemstack.ItemBuilder;
import mineplex.core.menu.Button;
import mineplex.core.menu.IconButton;
import mineplex.core.menu.Menu;
import mineplex.core.party.PartyManager;
import org.bukkit.Material;
/**
* A class to manage dynamic creation of GUI's
*/
public abstract class PartyMenu extends Menu<PartyManager>
{
protected static final Button PURCHASE_MORE_SLOTS = new IconButton(new ItemBuilder(Material.REDSTONE_BLOCK)
.setTitle(C.cRed + C.Bold + "Locked!")
.setLore(" ", C.cGray + "Purchase a rank @ mineplex.com/shop", C.cGray + "Purchasing a rank increases your", C.cGray + "party size to allow 10 people!")
.build());
public PartyMenu(String name, PartyManager plugin)
{
super(name, plugin);
}
}

View File

@ -2,8 +2,8 @@ package mineplex.core.party.ui.button.tools;
import mineplex.core.common.util.C;
import mineplex.core.itemstack.ItemBuilder;
import mineplex.core.menu.Button;
import mineplex.core.party.PartyManager;
import mineplex.core.party.ui.Button;
import org.bukkit.Material;
import org.bukkit.entity.Player;
import org.bukkit.event.inventory.ClickType;
@ -12,7 +12,7 @@ import org.bukkit.inventory.ItemStack;
/**
* Leaves a players current party
*/
public class LeavePartyButton extends Button
public class LeavePartyButton extends Button<PartyManager>
{
private static final ItemStack ITEM = new ItemBuilder(Material.REDSTONE_BLOCK)
@ -36,4 +36,4 @@ public class LeavePartyButton extends Button
player.closeInventory();
}
}
}

View File

@ -1,14 +1,14 @@
package mineplex.core.party.ui.button.tools;
import mineplex.core.menu.Button;
import mineplex.core.party.Party;
import mineplex.core.party.PartyManager;
import mineplex.core.party.ui.Button;
import org.bukkit.inventory.ItemStack;
/**
* A wrapper for all buttons which need to interact with a specific party
*/
public abstract class PartyButton extends Button
public abstract class PartyButton extends Button<PartyManager>
{
private Party _party;
@ -23,4 +23,4 @@ public abstract class PartyButton extends Button
{
return _party;
}
}
}

View File

@ -0,0 +1,40 @@
package mineplex.core.party.ui.button.tools;
import mineplex.core.common.util.C;
import mineplex.core.game.GameDisplay;
import mineplex.core.itemstack.ItemBuilder;
import mineplex.core.menu.Button;
import mineplex.core.menu.Menu;
import mineplex.core.party.PartyManager;
import org.bukkit.entity.Player;
import org.bukkit.event.inventory.ClickType;
/**
*
*/
public class SelectPartnerGameButton extends Button<PartyManager>
{
private static final String COMMAND = "/teamprefs ";
private final String _partner;
private final String _gameName;
public SelectPartnerGameButton(GameDisplay gameDisplay, String partner, PartyManager plugin)
{
super(new ItemBuilder(gameDisplay.getMaterial())
.setTitle(C.cYellow + gameDisplay.getName())
.setData(gameDisplay.getMaterialData())
.build(), plugin);
_partner = partner;
_gameName = gameDisplay.getName();
}
@Override
public void onClick(Player player, ClickType clickType)
{
player.chat(COMMAND + _partner + " " + _gameName);
Menu.get(player.getUniqueId()).setUseClose(true);
player.closeInventory();
}
}

View File

@ -1,8 +1,8 @@
package mineplex.core.party.ui.button.tools.invite;
import mineplex.core.itemstack.ItemBuilder;
import mineplex.core.menu.Button;
import mineplex.core.party.PartyManager;
import mineplex.core.party.ui.Button;
import org.bukkit.ChatColor;
import org.bukkit.Material;
import org.bukkit.entity.Player;
@ -12,7 +12,7 @@ import org.bukkit.inventory.ItemStack;
/**
* Sends a player back to the main page
*/
public class BackButton extends Button
public class BackButton extends Button<PartyManager>
{
private static ItemStack ITEM = new ItemBuilder(Material.BED)
@ -30,4 +30,4 @@ public class BackButton extends Button
player.closeInventory();
player.chat("/party");
}
}
}

View File

@ -1,9 +1,9 @@
package mineplex.core.party.ui.button.tools.invite;
import mineplex.core.common.util.C;
import mineplex.core.menu.Button;
import mineplex.core.itemstack.ItemBuilder;
import mineplex.core.party.PartyManager;
import mineplex.core.party.ui.Button;
import mineplex.core.party.ui.menus.PartyInvitesMenu;
import org.bukkit.Material;
import org.bukkit.entity.Player;
@ -13,7 +13,7 @@ import org.bukkit.inventory.ItemStack;
/**
* Deny's all invites currently pending
*/
public class DenyAllButton extends Button
public class DenyAllButton extends Button<PartyManager>
{
private static final ItemStack ITEM = new ItemBuilder(Material.REDSTONE_BLOCK)
@ -32,4 +32,4 @@ public class DenyAllButton extends Button
getPlugin().getInviteManager().getAllInvites(player).forEach(inviteData -> getPlugin().getMethodManager().respondToInvite(player, inviteData.getInvitedTo(), false));
new PartyInvitesMenu(getPlugin()).open(player);
}
}
}

View File

@ -2,8 +2,8 @@ package mineplex.core.party.ui.button.tools.invite;
import mineplex.core.common.util.C;
import mineplex.core.itemstack.ItemBuilder;
import mineplex.core.menu.Button;
import mineplex.core.party.PartyManager;
import mineplex.core.party.ui.Button;
import mineplex.core.party.ui.menus.input.InviteFilterMenu;
import org.bukkit.Material;
import org.bukkit.entity.Player;
@ -13,7 +13,7 @@ import org.bukkit.inventory.ItemStack;
/**
* Filters all current pending invites and displays only the results to a player
*/
public class FilterButton extends Button
public class FilterButton extends Button<PartyManager>
{
private static final ItemStack ITEM = new ItemBuilder(Material.NAME_TAG)
@ -22,8 +22,8 @@ public class FilterButton extends Button
C.cGray + "Click to bring up an Anvil GUI",
C.cGray + "where you type and filter",
C.cGray + "Party invites by their name",
" ",
C.cGreen + "Input \"Clear Filter\" to remove the filter")
" ",
C.cGreen + "Input \"Clear Filter\" to remove the filter")
.build();
public FilterButton(PartyManager plugin)
@ -36,11 +36,11 @@ public class FilterButton extends Button
super(new ItemBuilder(Material.NAME_TAG)
.setTitle(C.cYellow + "Filter Invites")
.setLore(" ", C.cWhite + "Active Filter: " + C.cGreen + filter, " ",
C.cGray + "Click to bring up an Anvil GUI",
C.cGray + "where you type and filter",
C.cGray + "Party invites by their name",
" ",
C.cGreen + "Input \"Clear Filter\" to remove the filter")
C.cGray + "Click to bring up an Anvil GUI",
C.cGray + "where you type and filter",
C.cGray + "Party invites by their name",
" ",
C.cGreen + "Input \"Clear Filter\" to remove the filter")
.setGlow(true)
.build(), plugin);
}
@ -51,4 +51,4 @@ public class FilterButton extends Button
new InviteFilterMenu(getPlugin(), player, null).openInventory();
}
}
}

View File

@ -2,8 +2,8 @@ package mineplex.core.party.ui.button.tools.invite;
import mineplex.core.common.util.C;
import mineplex.core.itemstack.ItemBuilder;
import mineplex.core.menu.Button;
import mineplex.core.party.PartyManager;
import mineplex.core.party.ui.Button;
import org.bukkit.Material;
import org.bukkit.entity.Player;
import org.bukkit.event.inventory.ClickType;
@ -11,7 +11,7 @@ import org.bukkit.event.inventory.ClickType;
/**
* Represents an invitation, to which a player can accept or deny
*/
public class InviteButton extends Button
public class InviteButton extends Button<PartyManager>
{
private String _name;
@ -39,4 +39,4 @@ public class InviteButton extends Button
}
player.closeInventory();
}
}
}

View File

@ -2,10 +2,10 @@ package mineplex.core.party.ui.button.tools.invite;
import mineplex.core.common.util.C;
import mineplex.core.itemstack.ItemBuilder;
import mineplex.core.menu.Button;
import mineplex.core.menu.IconButton;
import mineplex.core.party.InviteData;
import mineplex.core.party.PartyManager;
import mineplex.core.party.ui.Button;
import mineplex.core.party.ui.button.IconButton;
import mineplex.core.party.ui.menus.PartyInvitesMenu;
import org.bukkit.Material;
import org.bukkit.entity.Player;
@ -17,7 +17,7 @@ import java.util.List;
/**
* Shows the next page of invites for a player
*/
public class NextPageButton extends Button
public class NextPageButton extends Button<PartyManager>
{
private static final ItemStack ITEM = new ItemBuilder(Material.SIGN).setTitle(C.cYellow + "Next Page").build();
@ -37,13 +37,13 @@ public class NextPageButton extends Button
_menu.setCurrentPage(_menu.getCurrentPage() + 1);
if(_menu.getCurrentPage() == _menu.getPagesNeeded())
{
_menu.setButton(53, new IconButton(new ItemStack(Material.AIR), getPlugin()));
_menu.setButton(53, new IconButton(new ItemStack(Material.AIR)));
}
List<InviteData> data = _menu.getDataForPage(_menu.getCurrentPage());
for(int i = 0; i < data.size(); i++)
{
_menu.setButton(i + _menu.getStartingSlot(), new InviteButton(data.get(i).getInvitedTo(), getPlugin()));
}
_menu.update(player);
_menu.update();
}
}
}

View File

@ -2,10 +2,10 @@ package mineplex.core.party.ui.button.tools.invite;
import mineplex.core.common.util.C;
import mineplex.core.itemstack.ItemBuilder;
import mineplex.core.menu.Button;
import mineplex.core.menu.IconButton;
import mineplex.core.party.InviteData;
import mineplex.core.party.PartyManager;
import mineplex.core.party.ui.Button;
import mineplex.core.party.ui.button.IconButton;
import mineplex.core.party.ui.menus.PartyInvitesMenu;
import org.bukkit.Material;
import org.bukkit.entity.Player;
@ -17,7 +17,7 @@ import java.util.List;
/**
* Shows the previous page of invites for a player
*/
public class PrevPageButton extends Button
public class PrevPageButton extends Button<PartyManager>
{
private static final ItemStack ITEM = new ItemBuilder(Material.SIGN).setTitle(C.cYellow + "Previous Page").build();
@ -36,13 +36,13 @@ public class PrevPageButton extends Button
_menu.setCurrentPage(_menu.getCurrentPage() - 1);
if(_menu.getCurrentPage() == 0)
{
_menu.setButton(45, new IconButton(new ItemStack(Material.AIR), getPlugin()));
_menu.setButton(45, new IconButton(new ItemStack(Material.AIR)));
}
List<InviteData> data = _menu.getDataForPage(_menu.getCurrentPage());
for(int i = 0; i < data.size(); i++)
{
_menu.setButton(i + _menu.getStartingSlot(), new InviteButton(data.get(i).getInvitedTo(), getPlugin()));
}
_menu.update(player);
_menu.update();
}
}
}

View File

@ -2,8 +2,8 @@ package mineplex.core.party.ui.button.tools.main;
import mineplex.core.common.util.C;
import mineplex.core.itemstack.ItemBuilder;
import mineplex.core.menu.Button;
import mineplex.core.party.PartyManager;
import mineplex.core.party.ui.Button;
import mineplex.core.party.ui.menus.input.PartyInvitePlayerMenu;
import org.bukkit.Material;
import org.bukkit.entity.Player;
@ -13,7 +13,7 @@ import org.bukkit.inventory.ItemStack;
/**
* Invites a player to a new party
*/
public class InvitePlayerButton extends Button
public class InvitePlayerButton extends Button<PartyManager>
{
private static final ItemStack ITEM = new ItemBuilder(Material.NAME_TAG)
@ -31,4 +31,4 @@ public class InvitePlayerButton extends Button
{
new PartyInvitePlayerMenu(getPlugin(), player, null).openInventory();
}
}
}

View File

@ -2,8 +2,8 @@ package mineplex.core.party.ui.button.tools.main;
import mineplex.core.common.util.C;
import mineplex.core.itemstack.ItemBuilder;
import mineplex.core.menu.Button;
import mineplex.core.party.PartyManager;
import mineplex.core.party.ui.Button;
import mineplex.core.party.ui.menus.PartyInvitesMenu;
import org.bukkit.Material;
import org.bukkit.entity.Player;
@ -13,7 +13,7 @@ import org.bukkit.inventory.ItemStack;
/**
* Opens the {@code {@link PartyInvitesMenu}}
*/
public class ViewInvitesButton extends Button
public class ViewInvitesButton extends Button<PartyManager>
{
private static final ItemStack ITEM = new ItemBuilder(Material.BOOK)

View File

@ -33,4 +33,4 @@ public class AddPlayerButton extends PartyButton
new PartyInvitePlayerMenu(getPlugin(), player, getParty()).openInventory();
}
}
}

View File

@ -2,8 +2,8 @@ package mineplex.core.party.ui.button.tools.owner;
import mineplex.core.common.util.C;
import mineplex.core.itemstack.ItemBuilder;
import mineplex.core.menu.Button;
import mineplex.core.party.PartyManager;
import mineplex.core.party.ui.Button;
import org.bukkit.Material;
import org.bukkit.entity.Player;
import org.bukkit.event.inventory.ClickType;
@ -12,7 +12,7 @@ import org.bukkit.inventory.ItemStack;
/**
* Disbands a party
*/
public class DisbandPartyButton extends Button
public class DisbandPartyButton extends Button<PartyManager>
{
private static final ItemStack ITEM = new ItemBuilder(Material.BARRIER)
@ -35,4 +35,4 @@ public class DisbandPartyButton extends Button
getPlugin().getMethodManager().disband(player);
player.closeInventory();
}
}
}

View File

@ -4,7 +4,7 @@ import mineplex.core.common.util.C;
import mineplex.core.common.util.F;
import mineplex.core.itemstack.ItemBuilder;
import mineplex.core.party.Party;
import mineplex.core.party.ui.Menu;
import mineplex.core.party.ui.PartyMenu;
import mineplex.core.party.ui.button.tools.PartyButton;
import org.bukkit.Material;
import org.bukkit.entity.Player;
@ -51,6 +51,6 @@ public class KickPlayerButton extends PartyButton
{
setItemStack(ITEM_OFF);
}
Menu.get(player.getUniqueId()).update(player);
PartyMenu.get(player.getUniqueId()).update();
}
}
}

View File

@ -32,4 +32,4 @@ public class SelectServerButton extends PartyButton
{
UtilServer.getPluginManager().callEvent(new PartySelectServerEvent(player));
}
}
}

View File

@ -20,7 +20,7 @@ public class TransferOwnerButton extends PartyButton
private static final ItemStack ITEM = new ItemBuilder(Material.BOOK_AND_QUILL)
.setTitle(C.cYellow + "Transfer Ownership")
.setLore(" ", C.cGray + "Transfers ownership of the party", C.cGray + "to another player",
" ", C.cDRed + "This cannot be undone!")
" ", C.cDRed + "This cannot be undone!")
.build();
public TransferOwnerButton(Party party, PartyManager plugin)
@ -33,4 +33,4 @@ public class TransferOwnerButton extends PartyButton
{
new PartyTransferOwnerMenu(getPlugin(), player, getParty()).openInventory();
}
}
}

View File

@ -0,0 +1,55 @@
package mineplex.core.party.ui.menus;
import mineplex.core.game.GameDisplay;
import mineplex.core.menu.Button;
import mineplex.core.party.PartyManager;
import mineplex.core.party.ui.PartyMenu;
import mineplex.core.party.ui.button.tools.SelectPartnerGameButton;
import org.bukkit.entity.Player;
/**
*
*/
public class PartnerRequestMenu extends PartyMenu
{
private final GameDisplay[] GAMES = {
GameDisplay.SurvivalGamesTeams,
GameDisplay.SkywarsTeams,
GameDisplay.UHC,
GameDisplay.SmashTeams,
};
private final int INV_SIZE = 54;
private final int START_SLOT = 20;
private final int END_SLOT = 24;
private final int START_SLOT_SECOND = 29;
private final String _partner;
public PartnerRequestMenu(String partner, PartyManager plugin)
{
super("Select a game", plugin);
_partner = partner;
}
@Override
protected Button[] setUp(Player player)
{
Button[] buttons = new Button[INV_SIZE];
int slot = START_SLOT;
for (GameDisplay gameDisplay : GAMES)
{
if (slot > END_SLOT)
{
slot = START_SLOT_SECOND;
}
buttons[slot++] = new SelectPartnerGameButton(gameDisplay, _partner, getPlugin());
}
return pane(buttons);
}
}

View File

@ -5,12 +5,16 @@ import com.google.common.collect.Maps;
import mineplex.core.common.util.C;
import mineplex.core.common.util.F;
import mineplex.core.itemstack.ItemBuilder;
import mineplex.core.menu.Button;
import mineplex.core.menu.IconButton;
import mineplex.core.party.InviteData;
import mineplex.core.party.PartyManager;
import mineplex.core.party.ui.Button;
import mineplex.core.party.ui.Menu;
import mineplex.core.party.ui.button.IconButton;
import mineplex.core.party.ui.button.tools.invite.*;
import mineplex.core.party.ui.PartyMenu;
import mineplex.core.party.ui.button.tools.invite.BackButton;
import mineplex.core.party.ui.button.tools.invite.DenyAllButton;
import mineplex.core.party.ui.button.tools.invite.FilterButton;
import mineplex.core.party.ui.button.tools.invite.InviteButton;
import mineplex.core.party.ui.button.tools.invite.NextPageButton;
import org.bukkit.DyeColor;
import org.bukkit.Material;
import org.bukkit.Sound;
@ -23,13 +27,13 @@ import java.util.stream.Collectors;
/**
* The menu showing all pending invites for a player
*/
public class PartyInvitesMenu extends Menu
public class PartyInvitesMenu extends PartyMenu
{
private final IconButton NO_INVITES = new IconButton(new ItemBuilder(Material.STAINED_GLASS_PANE)
.setData(DyeColor.RED.getWoolData())
.setTitle(C.cRedB + "No Invites")
.build(), null);
.build());
private final int INV_SIZE = 54;
private final int SLOTS_PER_PAGE = 27;
@ -63,9 +67,9 @@ public class PartyInvitesMenu extends Menu
Button[] buttons = new Button[INV_SIZE];
boolean showFiltered = false;
buttons[BACK_BUTTON_SLOT] = new BackButton(_plugin);
buttons[BACK_BUTTON_SLOT] = new BackButton(getPlugin());
List<InviteData> all = (List<InviteData>) _plugin.getInviteManager().getAllInvites(player);
List<InviteData> all = (List<InviteData>) getPlugin().getInviteManager().getAllInvites(player);
if (all == null || all.isEmpty())
{
@ -74,18 +78,18 @@ public class PartyInvitesMenu extends Menu
buttons[i] = NO_INVITES;
}
player.playSound(player.getLocation(), Sound.ITEM_BREAK, 1, .6f);
return addPanes(buttons);
return pane(buttons);
}
buttons[DENY_ALL_BUTTON_SLOW] = new DenyAllButton(_plugin);
buttons[DENY_ALL_BUTTON_SLOW] = new DenyAllButton(getPlugin());
if (_filterBy == null || _filterBy.isEmpty())
{
buttons[FILTER_BUTTON_SLOT] = new FilterButton(_plugin);
buttons[FILTER_BUTTON_SLOT] = new FilterButton(getPlugin());
} else
{
showFiltered = true;
buttons[FILTER_BUTTON_SLOT] = new FilterButton(_filterBy, _plugin);
buttons[FILTER_BUTTON_SLOT] = new FilterButton(_filterBy, getPlugin());
}
if (showFiltered)
@ -101,10 +105,10 @@ public class PartyInvitesMenu extends Menu
.setData(DyeColor.RED.getWoolData())
.setTitle(C.cRedB + "No Invites Found")
.setLore(" ", C.cGray + "The filter " + F.name(_filterBy) + " had no results.")
.build(), _plugin);
.build());
}
player.playSound(player.getLocation(), Sound.ITEM_BREAK, 1, .6f);
return addPanes(buttons);
return pane(buttons);
}
_data = all;
@ -118,7 +122,7 @@ public class PartyInvitesMenu extends Menu
pagesNeeded++;
size -= SLOTS_PER_PAGE;
}
buttons[NEXT_PAGE_SLOT] = new NextPageButton(this, _plugin);
buttons[NEXT_PAGE_SLOT] = new NextPageButton(this, getPlugin());
_pagesNeeded = pagesNeeded;
_pagesOfData = Maps.newHashMap();
@ -147,12 +151,12 @@ public class PartyInvitesMenu extends Menu
for (int i = 0; i < all.size(); i++)
{
String to = all.get(i).getInvitedTo();
buttons[STARTING_SLOT + i] = new InviteButton(to, _plugin);
buttons[STARTING_SLOT + i] = new InviteButton(to, getPlugin());
}
}
return addPanes(buttons);
return pane(buttons);
}
public void setButton(int slot, Button button)
@ -189,4 +193,4 @@ public class PartyInvitesMenu extends Menu
{
return _pagesNeeded;
}
}
}

View File

@ -1,8 +1,8 @@
package mineplex.core.party.ui.menus;
import mineplex.core.menu.Button;
import mineplex.core.party.PartyManager;
import mineplex.core.party.ui.Button;
import mineplex.core.party.ui.Menu;
import mineplex.core.party.ui.PartyMenu;
import mineplex.core.party.ui.button.tools.main.InvitePlayerButton;
import mineplex.core.party.ui.button.tools.main.ViewInvitesButton;
import org.bukkit.entity.Player;
@ -10,7 +10,7 @@ import org.bukkit.entity.Player;
/**
* The main GUI for parties.
*/
public class PartyMainMenu extends Menu
public class PartyMainMenu extends PartyMenu
{
private final int INV_SIZE = 9;
@ -28,9 +28,9 @@ public class PartyMainMenu extends Menu
{
Button[] buttons = new Button[INV_SIZE];
buttons[INVITE_PLAYER_BUTTON_SLOT] = new InvitePlayerButton(_plugin);
buttons[VIEW_INVITES_BUTTON_SLOT] = new ViewInvitesButton(_plugin);
buttons[INVITE_PLAYER_BUTTON_SLOT] = new InvitePlayerButton(getPlugin());
buttons[VIEW_INVITES_BUTTON_SLOT] = new ViewInvitesButton(getPlugin());
return buttons;
}
}
}

View File

@ -1,9 +1,9 @@
package mineplex.core.party.ui.menus;
import mineplex.core.menu.Button;
import mineplex.core.party.Party;
import mineplex.core.party.PartyManager;
import mineplex.core.party.ui.Button;
import mineplex.core.party.ui.Menu;
import mineplex.core.party.ui.PartyMenu;
import mineplex.core.party.ui.button.PartyMemberIcon;
import mineplex.core.party.ui.button.tools.LeavePartyButton;
import mineplex.core.party.ui.button.tools.owner.AddPlayerButton;
@ -20,7 +20,7 @@ import java.util.UUID;
/**
* The display menu for managing parties by the owner
*/
public class PartyOwnerMenu extends Menu
public class PartyOwnerMenu extends PartyMenu
{
private final int INV_SIZE = 54;
@ -36,7 +36,7 @@ public class PartyOwnerMenu extends Menu
private final int SELECT_SERVER_BUTTON_SLOT = 46;
private final int LEAVE_PARTY_BUTTON_SLOT = 49;
private final int DISBAND_PARTY_BUTTON_SLOW = 52;
private Party _party;
public PartyOwnerMenu(Party party, PartyManager plugin)
@ -55,25 +55,25 @@ public class PartyOwnerMenu extends Menu
{
Button[] buttons = new Button[INV_SIZE];
//Tools
buttons[ADD_PLAYER_BUTTON_SLOT] = new AddPlayerButton(_plugin, _party);
buttons[ADD_PLAYER_BUTTON_SLOT] = new AddPlayerButton(getPlugin(), _party);
//Kick player
buttons[KICK_PLAYER_BUTTON_SLOT] = new KickPlayerButton(_party);
//Transfer ownership
buttons[TRANSFER_OWNER_BUTTON_SLOT] = new TransferOwnerButton(_party, _plugin);
buttons[TRANSFER_OWNER_BUTTON_SLOT] = new TransferOwnerButton(_party, getPlugin());
//Go to server
buttons[SELECT_SERVER_BUTTON_SLOT] = new SelectServerButton(_party);
//Leave party
buttons[LEAVE_PARTY_BUTTON_SLOT] = new LeavePartyButton(_plugin);
buttons[LEAVE_PARTY_BUTTON_SLOT] = new LeavePartyButton(getPlugin());
//Disband
buttons[DISBAND_PARTY_BUTTON_SLOW] = new DisbandPartyButton(_plugin);
buttons[DISBAND_PARTY_BUTTON_SLOW] = new DisbandPartyButton(getPlugin());
List<UUID> members = _party.getMembers();
members.remove(_party.getOwnerId());
List<String> members = _party.getMembers();
members.remove(_party.getOwner());
buttons[OWNER_HEAD_SLOT] = new PartyMemberIcon(_party.getOwner(), _party, true);
int slot = STARTING_SLOT;
//Players
for (UUID member: members)
for (String member: members)
{
if (slot == CUT_OFF_SLOT)
{
@ -83,18 +83,9 @@ public class PartyOwnerMenu extends Menu
slot = SKIP_TO_SLOT_2;
}
buttons[slot++] = new PartyMemberIcon(Bukkit.getPlayer(member).getName(), _party, false);
buttons[slot++] = new PartyMemberIcon(Bukkit.getPlayerExact(member).getName(), _party, false);
}
if(_party.getSize() == 5)
{
for(int i = 29; i < 34; i++)
{
buttons[i] = PURCHASE_MORE_SLOTS;
}
}
return addPanes(buttons);
return pane(buttons);
}
}
}

View File

@ -1,9 +1,9 @@
package mineplex.core.party.ui.menus;
import mineplex.core.menu.Button;
import mineplex.core.party.Party;
import mineplex.core.party.PartyManager;
import mineplex.core.party.ui.Button;
import mineplex.core.party.ui.Menu;
import mineplex.core.party.ui.PartyMenu;
import mineplex.core.party.ui.button.PartyMemberIcon;
import mineplex.core.party.ui.button.tools.LeavePartyButton;
import mineplex.core.party.ui.button.tools.view.SuggestPlayerButton;
@ -16,7 +16,7 @@ import java.util.UUID;
/**
* The menu a player see's when he is a member, and not an owner, of a party.
*/
public class PartyViewMenu extends Menu
public class PartyViewMenu extends PartyMenu
{
private final int INV_SIZE = 54;
@ -28,7 +28,7 @@ public class PartyViewMenu extends Menu
private final int SKIP_TO_SLOT_2 = 38;
private final int LEAVE_PARTY_BUTTON_SLOT = 3;
private final int SUGGEST_PLAYER_BUTTON_SLOT = 5;
private Party _party;
public PartyViewMenu(Party party, PartyManager plugin)
@ -42,17 +42,17 @@ public class PartyViewMenu extends Menu
{
Button[] buttons = new Button[INV_SIZE];
//Tools
buttons[LEAVE_PARTY_BUTTON_SLOT] = new LeavePartyButton(_plugin);
buttons[LEAVE_PARTY_BUTTON_SLOT] = new LeavePartyButton(getPlugin());
//Suggest Player
buttons[SUGGEST_PLAYER_BUTTON_SLOT] = new SuggestPlayerButton(_party, _plugin);
buttons[SUGGEST_PLAYER_BUTTON_SLOT] = new SuggestPlayerButton(_party, getPlugin());
List<UUID> members = _party.getMembers();
members.remove(_party.getOwnerId());
List<String> members = _party.getMembers();
members.remove(_party.getOwner());
buttons[OWNER_HEAD_SLOT] = new PartyMemberIcon(_party.getOwner(), _party, true);
int slot = STARTING_SLOT;
//Players
for (UUID member : members)
for (String member : members)
{
if (slot == CUT_OFF_SLOT)
{
@ -65,6 +65,6 @@ public class PartyViewMenu extends Menu
buttons[slot++] = new PartyMemberIcon(Bukkit.getPlayer(member).getName(), _party, false);
}
return addPanes(buttons);
return pane(buttons);
}
}
}

View File

@ -0,0 +1,113 @@
package mineplex.core.preferences;
import com.google.common.collect.Lists;
import com.google.common.collect.Maps;
import org.bukkit.Material;
import java.util.List;
import java.util.Map;
/**
* All ID's are assigned by enum order.
* <p>
* Key:
* Default value: The value this is set at if the user has not toggled it
* Category: Determines which sub menu, along with permissions to view, this preference falls to
* Icon: The material representation in the GUI
* Name: The string shown to players in the menu and for toggling
* Lore: A description of the preference
*/
public enum Preference
{
HUB_GAMES(true, PreferenceCategory.USER, Material.FIREBALL, "Hub Player Stacker"),
SHOW_PLAYERS(true, PreferenceCategory.USER, Material.EYE_OF_ENDER, "Hub Player Visibility"),
SHOW_CHAT(true, PreferenceCategory.USER, Material.PAPER, "Player Chat"),
PRIVATE_MESSAGING(true, PreferenceCategory.USER, Material.MAP, "Private Messaging"),
PARTY_REQUESTS(true, PreferenceCategory.USER, Material.SKULL_ITEM, "Party Requests"),
INVISIBILITY(false, PreferenceCategory.EXCLUSIVE, Material.NETHER_STAR, "Hub Invisibility & Flight"),
FORCE_FIELD(false, PreferenceCategory.EXCLUSIVE, Material.SLIME_BALL, "Hub Forcefield"),
GLOBAL_GWEN_REPORTS(true, PreferenceCategory.EXCLUSIVE, Material.PAPER, "Global GWEN Reports"),
SHOW_USER_REPORTS(false, PreferenceCategory.EXCLUSIVE, Material.BOOK, "User Reports"),
IGNORE_VELOCITY(false, PreferenceCategory.EXCLUSIVE, Material.SADDLE, "Hub Ignore Velocity"),
PENDING_FRIEND_REQUESTS(true, PreferenceCategory.FRIEND, Material.RED_ROSE, "Show Pending Friend Requests"),
FRIENDS_DISPLAY_INVENTORY_UI(true, PreferenceCategory.FRIEND, Material.CHEST, "Display Friend GUI"),
CLAN_TIPS(true, PreferenceCategory.MISC, Material.IRON_SWORD, "Show Clan Tips"),
HUB_MUSIC(true, PreferenceCategory.MISC, Material.NOTE_BLOCK, "Hub Music"),
//AUTO_JOIN_NEXT_GAME(true, PreferenceCategory.GAME_PLAY, Material.DIAMOND_SWORD, "Auto Join Next Game"),
//COUNTDOWN_ON_CLICK(true, PreferenceCategory.GAME_PLAY, Material.EMERALD, "Countdown to Join"),
;
private static final Map<Integer, Preference> PREFERENCE_MAP = Maps.newHashMap();
private static final Map<PreferenceCategory, List<Preference>> PREFERENCES_BY_CATEGORY = Maps.newHashMap();
static
{
int id = 0;
for (Preference preference : values())
{
preference._id = ++id;
PREFERENCE_MAP.put(preference._id, preference);
List<Preference> preferences = PREFERENCES_BY_CATEGORY.getOrDefault(preference._category, Lists.newArrayList());
preferences.add(preference);
PREFERENCES_BY_CATEGORY.put(preference._category, preferences);
}
}
private int _id;
private final boolean _default;
private final PreferenceCategory _category;
private final Material _icon;
private final String _name;
private final String[] _lore;
Preference(boolean defaultSetting, PreferenceCategory category, Material icon, String name, String... lore)
{
_default = defaultSetting;
_category = category;
_icon = icon;
_name = name;
_lore = lore;
}
public String getName()
{
return _name;
}
public Material getIcon()
{
return _icon;
}
public int getId()
{
return _id;
}
public boolean getDefaultValue()
{
return _default;
}
public String[] getLore()
{
return _lore;
}
public static List<Preference> getByCategory(PreferenceCategory category)
{
return PREFERENCES_BY_CATEGORY.get(category);
}
public static Preference get(int id)
{
return PREFERENCE_MAP.get(id);
}
}

View File

@ -0,0 +1,42 @@
package mineplex.core.preferences;
import mineplex.core.common.util.C;
import mineplex.core.itemstack.ItemBuilder;
import org.bukkit.Material;
import org.bukkit.inventory.ItemStack;
/**
*
*/
public enum PreferenceCategory
{
USER("User", Material.PAPER),
EXCLUSIVE("Exclusive", Material.DIAMOND),
//GAME_PLAY("Game Mechanic", Material.REDSTONE_COMPARATOR),
MISC("Miscellaneous", Material.COMPASS),
FRIEND("Friend", Material.CHEST),
;
private String _name;
private ItemStack _itemStack;
PreferenceCategory(String name, Material icon)
{
_name = name + " Preferences";
_itemStack = new ItemBuilder(icon)
.setTitle(C.cYellow + _name)
.build();
}
public ItemStack getItem()
{
return _itemStack;
}
public String getName()
{
return _name;
}
}

View File

@ -1,11 +1,20 @@
package mineplex.core.preferences;
import java.lang.reflect.Field;
import java.sql.ResultSet;
import java.sql.SQLException;
import java.util.Map.Entry;
import java.util.UUID;
import com.google.common.collect.Lists;
import com.google.common.collect.Maps;
import com.google.common.collect.Sets;
import mineplex.core.MiniPlugin;
import mineplex.core.account.CoreClientManager;
import mineplex.core.account.ILoginProcessor;
import mineplex.core.common.util.C;
import mineplex.core.common.util.UtilGear;
import mineplex.core.common.util.UtilInv;
import mineplex.core.incognito.IncognitoManager;
import mineplex.core.itemstack.ItemStackFactory;
import mineplex.core.preferences.command.PreferencesCommand;
import mineplex.core.preferences.ui.PreferenceMainMenu;
import mineplex.core.updater.UpdateType;
import mineplex.core.updater.event.UpdateEvent;
import mineplex.core.utils.UtilGameProfile;
import org.bukkit.ChatColor;
import org.bukkit.Material;
@ -14,68 +23,124 @@ import org.bukkit.event.EventHandler;
import org.bukkit.event.EventPriority;
import org.bukkit.event.player.PlayerInteractEvent;
import org.bukkit.event.player.PlayerJoinEvent;
import org.bukkit.event.player.PlayerQuitEvent;
import org.bukkit.inventory.ItemStack;
import org.bukkit.inventory.meta.SkullMeta;
import org.bukkit.plugin.java.JavaPlugin;
import mineplex.core.MiniDbClientPlugin;
import mineplex.core.account.CoreClientManager;
import mineplex.core.common.util.C;
import mineplex.core.common.util.NautHashMap;
import mineplex.core.common.util.UtilGear;
import mineplex.core.common.util.UtilInv;
import mineplex.core.donation.DonationManager;
import mineplex.core.incognito.IncognitoManager;
import mineplex.core.itemstack.ItemStackFactory;
import mineplex.core.packethandler.PacketHandler;
import mineplex.core.preferences.command.PreferencesCommand;
import mineplex.core.preferences.ui.ExclusivePreferencesShop;
import mineplex.core.preferences.ui.PreferencesShop;
import mineplex.core.updater.UpdateType;
import mineplex.core.updater.event.UpdateEvent;
import java.lang.reflect.Field;
import java.sql.ResultSet;
import java.sql.SQLException;
import java.util.List;
import java.util.Map;
import java.util.Set;
import java.util.UUID;
public class PreferencesManager extends MiniDbClientPlugin<UserPreferences>
public class PreferencesManager extends MiniPlugin implements ILoginProcessor
{
private PreferencesRepository _repository;
private PreferencesShop _shop;
private ExclusivePreferencesShop _exclusiveShop;
private final PreferencesRepository _repository;
private final CoreClientManager _clientManager;
private final IncognitoManager _incognitoManager;
private IncognitoManager _incognitoManager;
private NautHashMap<String, UserPreferences> _saveBuffer = new NautHashMap<String, UserPreferences>();
private final Set<UserPreferences> _saveBuffer = Sets.newHashSet();
private final Map<Integer, UserPreferences> _preferences = Maps.newHashMap();
public boolean GiveItem;
public PreferencesManager(JavaPlugin plugin, IncognitoManager incognito, CoreClientManager clientManager, DonationManager donationManager)
public PreferencesManager(JavaPlugin plugin, IncognitoManager incognito, CoreClientManager clientManager)
{
super("Preferences", plugin, clientManager);
super("Preferences", plugin);
_repository = new PreferencesRepository(plugin);
_exclusiveShop = new ExclusivePreferencesShop(this, clientManager, donationManager);
_shop = new PreferencesShop(this, clientManager, donationManager, _exclusiveShop);
_repository = new PreferencesRepository(this);
_clientManager = clientManager;
_incognitoManager = incognito;
_exclusiveShop.setPreferencesShop(_shop);
_clientManager.addStoredProcedureLoginProcessor(this);
addCommand(new PreferencesCommand(this));
}
@Override
protected UserPreferences addPlayer(UUID uuid)
@EventHandler
public void onQuit(PlayerQuitEvent event)
{
return new UserPreferences();
}
public void savePreferences(Player caller)
{
_saveBuffer.put(caller.getUniqueId().toString(), Get(caller));
Player player = event.getPlayer();
int accountId = _clientManager.getAccountId(player);
_repository.saveUserPreferences(_preferences.remove(accountId));
}
@EventHandler
public void givePlayerItem(PlayerJoinEvent event)
{
handlePlayerJoin(event.getPlayer(), false);
Player player = event.getPlayer();
handlePlayerJoin(player, false);
}
@EventHandler
public void storeBuffer(UpdateEvent event)
{
if (event.getType() != UpdateType.SLOW)
{
return;
}
if(_saveBuffer.isEmpty())
{
return;
}
List<UserPreferences> buffer = Lists.newArrayList(_saveBuffer);
buffer.forEach(_repository::saveUserPreferences);
buffer.clear();
_saveBuffer.clear();
}
@EventHandler(priority = EventPriority.LOWEST)
public void playerInteract(PlayerInteractEvent event)
{
if (!GiveItem)
{
return;
}
if (event.getItem() != null && event.getItem().getType() == Material.REDSTONE_COMPARATOR)
{
openMenu(event.getPlayer());
event.setCancelled(true);
}
}
public UserPreferences get(Player player)
{
UserPreferences preferences = _preferences.get(_clientManager.getAccountId(player));
if(preferences == null)
{
preferences = new UserPreferences(_clientManager.getAccountId(player));
}
return preferences;
}
public void save(UserPreferences preferences)
{
_saveBuffer.add(preferences);
}
public IncognitoManager getIncognitoManager()
{
return _incognitoManager;
}
public CoreClientManager getClientManager()
{
return _clientManager;
}
public void openMenu(Player player)
{
new PreferenceMainMenu(this).open(player);
}
public void handlePlayerJoin(Player player, boolean force)
@ -112,63 +177,27 @@ public class PreferencesManager extends MiniDbClientPlugin<UserPreferences>
}
}
@EventHandler
public void storeBuffer(UpdateEvent event)
public void set(int accountId, UserPreferences preferences)
{
if (event.getType() != UpdateType.SLOW)
return;
final NautHashMap<String, UserPreferences> bufferCopy = new NautHashMap<String, UserPreferences>();
for (Entry<String, UserPreferences> entry : _saveBuffer.entrySet())
{
bufferCopy.put(entry.getKey(), entry.getValue());
}
_saveBuffer.clear();
getPlugin().getServer().getScheduler().runTaskAsynchronously(getPlugin(), new Runnable()
{
public void run()
{
_repository.saveUserPreferences(bufferCopy);
}
});
}
@EventHandler(priority = EventPriority.LOWEST)
public void playerInteract(PlayerInteractEvent event)
{
if (!GiveItem)
return;
if (event.getItem() != null && event.getItem().getType() == Material.REDSTONE_COMPARATOR)
{
_shop.attemptShopOpen(event.getPlayer());
event.setCancelled(true);
}
}
public void openShop(Player caller)
{
_shop.attemptShopOpen(caller);
_preferences.put(accountId, preferences);
}
@Override
public void processLoginResultSet(String playerName, UUID uuid, int accountId, ResultSet resultSet) throws SQLException
{
Set(uuid, _repository.loadClientInformation(resultSet));
UserPreferences preferences = new UserPreferences(accountId);
while (resultSet.next())
{
Preference preference = Preference.get(resultSet.getInt("preference"));
boolean value = resultSet.getInt("value") == 1;
preferences.set(preference, value);
}
_preferences.put(accountId, preferences);
}
@Override
public String getQuery(int accountId, String uuid, String name)
{
return "SELECT games, visibility, showChat, friendChat, privateMessaging, partyRequests, invisibility, forcefield, showMacReports, ignoreVelocity, pendingFriendRequests, friendDisplayInventoryUI, clanTips, hubMusic, disableAds, showUserReports FROM accountPreferences WHERE accountPreferences.uuid = '" + uuid + "' LIMIT 1;";
}
public IncognitoManager getIncognitoManager()
{
return _incognitoManager;
return "SELECT * FROM `preferences` WHERE `accountId` = " + accountId + ";";
}
}

View File

@ -1,140 +1,136 @@
package mineplex.core.preferences;
import mineplex.core.database.MinecraftRepository;
import mineplex.core.progression.util.SQLStatement;
import mineplex.serverdata.database.DBPool;
import mineplex.serverdata.database.column.ColumnInt;
import java.sql.Connection;
import java.sql.PreparedStatement;
import java.sql.ResultSet;
import java.sql.SQLException;
import java.util.Map.Entry;
import mineplex.core.database.MinecraftRepository;
import org.bukkit.plugin.java.JavaPlugin;
import mineplex.core.common.util.NautHashMap;
import mineplex.serverdata.database.DBPool;
import mineplex.serverdata.database.RepositoryBase;
import mineplex.serverdata.database.column.ColumnVarChar;
public class PreferencesRepository extends MinecraftRepository
{
// 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, showUserReports 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 UPDATE_ACCOUNT_PREFERENCES = "UPDATE accountPreferences SET games = ?, visibility = ?, showChat = ?, friendChat = ?, privateMessaging = ?, partyRequests = ?, invisibility = ?, forcefield = ?, showMacReports = ?, ignoreVelocity = ?, pendingFriendRequests = ?, friendDisplayInventoryUI = ?, clanTips = ?, hubMusic = ?, disableAds = ?, showUserReports = ? WHERE uuid=?;";
public PreferencesRepository(JavaPlugin plugin)
private static String UPSERT_ACCOUNT = "INSERT INTO `preferences` VALUES(?, ?, ?) ON DUPLICATE KEY UPDATE `value`= ?";
private final String GET_PREFS = "SELECT * FROM `preferences` WHERE `accountId` = ?";
private final PreferencesManager _manager;
public PreferencesRepository(PreferencesManager plugin)
{
super(plugin, DBPool.getAccount());
super(plugin.getPlugin(), DBPool.getAccount());
_manager = plugin;
}
@Override
protected void initialize()
{
// executeUpdate(CREATE_ACCOUNT_TABLE);
}
@Override
protected void update()
{
}
public void saveUserPreferences(NautHashMap<String, UserPreferences> preferences)
{
try (Connection connection = getConnection(); PreparedStatement preparedStatement = connection.prepareStatement(UPDATE_ACCOUNT_PREFERENCES);)
{
for (Entry<String, UserPreferences> entry : preferences.entrySet())
{
preparedStatement.setBoolean(1, entry.getValue().HubGames);
preparedStatement.setBoolean(2, entry.getValue().ShowPlayers);
preparedStatement.setBoolean(3, entry.getValue().ShowChat);
preparedStatement.setBoolean(4, entry.getValue().FriendChat);
preparedStatement.setBoolean(5, entry.getValue().PrivateMessaging);
preparedStatement.setBoolean(6, entry.getValue().PartyRequests);
preparedStatement.setBoolean(7, entry.getValue().Invisibility);
preparedStatement.setBoolean(8, entry.getValue().HubForcefield);
preparedStatement.setBoolean(9, entry.getValue().ShowMacReports);
preparedStatement.setBoolean(10, entry.getValue().IgnoreVelocity);
preparedStatement.setBoolean(11, entry.getValue().PendingFriendRequests);
preparedStatement.setBoolean(12, entry.getValue().friendDisplayInventoryUI);
preparedStatement.setBoolean(13, entry.getValue().ClanTips);
preparedStatement.setBoolean(14, entry.getValue().HubMusic);
preparedStatement.setBoolean(15, entry.getValue().DisableAds);
preparedStatement.setBoolean(16, entry.getValue().ShowUserReports);
System.out.println(">> " + entry.getValue().ClanTips);
preparedStatement.setString(17, entry.getKey());
preparedStatement.addBatch();
}
int[] rowsAffected = preparedStatement.executeBatch();
int i = 0;
for (Entry<String, UserPreferences> entry : preferences.entrySet())
{
if (rowsAffected[i] < 1)
{
executeUpdate(INSERT_ACCOUNT, new ColumnVarChar("uuid", 100, entry.getKey()));
preparedStatement.setBoolean(1, entry.getValue().HubGames);
preparedStatement.setBoolean(2, entry.getValue().ShowPlayers);
preparedStatement.setBoolean(3, entry.getValue().ShowChat);
preparedStatement.setBoolean(4, entry.getValue().FriendChat);
preparedStatement.setBoolean(5, entry.getValue().PrivateMessaging);
preparedStatement.setBoolean(6, entry.getValue().PartyRequests);
preparedStatement.setBoolean(7, entry.getValue().Invisibility);
preparedStatement.setBoolean(8, entry.getValue().HubForcefield);
preparedStatement.setBoolean(9, entry.getValue().ShowMacReports);
preparedStatement.setBoolean(10, entry.getValue().IgnoreVelocity);
preparedStatement.setBoolean(11, entry.getValue().PendingFriendRequests);
preparedStatement.setBoolean(12, entry.getValue().friendDisplayInventoryUI);
preparedStatement.setBoolean(13, entry.getValue().ClanTips);
preparedStatement.setBoolean(14, entry.getValue().HubMusic);
preparedStatement.setBoolean(15, entry.getValue().DisableAds);
preparedStatement.setBoolean(16, entry.getValue().ShowUserReports);
System.out.println(">> " + entry.getValue().ClanTips);
preparedStatement.setString(17, entry.getKey());
preparedStatement.execute();
}
i++;
}
}
catch (Exception exception)
/**
* Save a player's preferences in SQL
*
* @param preferences The player's specific {@code {@link UserPreferences}} instance
*/
public void saveUserPreferences(UserPreferences preferences)
{
async(() ->
{
exception.printStackTrace();
}
int accountId = preferences.getAccountId();
try (Connection connection = getConnection())
{
for (Preference preference : Preference.values())
{
int value = preferences.isActive(preference) ? 1 : 0;
int id = preference.getId();
PreparedStatement statement = new SQLStatement(UPSERT_ACCOUNT)
.set(1, accountId).set(2, id).set(3, value).set(4, value)
.prepare(connection);
executeUpdate(statement);
}
} catch (SQLException e)
{
e.printStackTrace();
}
});
}
public UserPreferences loadClientInformation(final ResultSet resultSet) throws SQLException
/**
* This method is run on the main thread, as we need this information to be laoded before a player joins
* It's also not the true main thread, as it's being called on AsyncPlayerPreLoginEvent
* If, for whatever reason, you need this information sometime differently, please call this async.
*
* @param accountId The player's accountID
* @return A loaded preference for the player
*/
public UserPreferences loadClientInformation(int accountId)
{
final UserPreferences preferences = new UserPreferences();
UserPreferences preferences = new UserPreferences(accountId);
if (resultSet.next())
executeQuery(GET_PREFS, resultSet ->
{
preferences.HubGames = resultSet.getBoolean(1);
preferences.ShowPlayers = resultSet.getBoolean(2);
preferences.ShowChat = resultSet.getBoolean(3);
preferences.FriendChat = resultSet.getBoolean(4);
preferences.PrivateMessaging = resultSet.getBoolean(5);
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);
preferences.PendingFriendRequests = resultSet.getBoolean(11);
preferences.friendDisplayInventoryUI = resultSet.getBoolean(12);
preferences.ClanTips = resultSet.getBoolean(13);
preferences.HubMusic = resultSet.getBoolean(14);
preferences.DisableAds = resultSet.getBoolean(15);
preferences.ShowUserReports = resultSet.getBoolean(16);
}
while (resultSet.next())
{
Preference preference = Preference.get(resultSet.getInt("preference"));
boolean value = resultSet.getInt("value") == 1;
preferences.set(preference, value);
}
}, new ColumnInt("accountId", accountId));
return preferences;
}
/**
* Load a clients data async and then update the local reference
*
* @param accountId The player's accountID
*/
public void loadClientInformationAsync(int accountId)
{
async(() -> {
UserPreferences preferences = loadClientInformation(accountId);
_manager.set(accountId, preferences);
});
}
public void async(Runnable runnable)
{
getPlugin().getServer().getScheduler().runTaskAsynchronously(getPlugin(), runnable);
}
/**
* Internal method for updating the table
*
* @param preparedStatement The statement to execute
* @return The amount of rows effected
*/
private int executeUpdate(PreparedStatement preparedStatement)
{
try
{
return preparedStatement.executeUpdate();
} catch (SQLException e)
{
e.printStackTrace();
return -1;
} finally
{
try
{
if (preparedStatement != null)
{
preparedStatement.close();
}
} catch (SQLException e)
{
e.printStackTrace();
}
}
}
}

View File

@ -1,22 +1,49 @@
package mineplex.core.preferences;
import com.google.common.collect.Maps;
import java.util.Map;
public class UserPreferences
{
public boolean FilterChat = true;
public boolean HubGames = true;
public boolean ShowPlayers = true;
public boolean ShowChat = true;
public boolean FriendChat = true;
public boolean PrivateMessaging = true;
public boolean PartyRequests = true;
public boolean Invisibility = false;
public boolean HubForcefield = false;
public boolean ShowMacReports = false;
public boolean ShowUserReports = false;
public boolean IgnoreVelocity = false;
public boolean PendingFriendRequests = true;
public boolean friendDisplayInventoryUI = true;
public boolean ClanTips = true;
public volatile boolean HubMusic = true;
public boolean DisableAds = false;
private int _accountId;
private Map<Preference, Boolean> _preferences;
public UserPreferences(int accountId)
{
_accountId = accountId;
_preferences = Maps.newHashMap();
}
public boolean isActive(Preference preference)
{
return _preferences.getOrDefault(preference, preference.getDefaultValue());
}
public void toggle(Preference preference)
{
boolean enabled = _preferences.getOrDefault(preference, preference.getDefaultValue());
_preferences.put(preference, !enabled);
}
public void enable(Preference preference)
{
_preferences.put(preference, true);
}
public void disable(Preference preference)
{
_preferences.put(preference, false);
}
public void set(Preference preference, boolean value)
{
_preferences.put(preference, value);
}
public int getAccountId()
{
return _accountId;
}
}

View File

@ -1,12 +1,9 @@
package mineplex.core.preferences.command;
import org.bukkit.entity.Player;
import mineplex.core.chat.Chat;
import mineplex.core.command.CommandBase;
import mineplex.core.common.Rank;
import mineplex.core.common.util.UtilServer;
import mineplex.core.preferences.PreferencesManager;
import org.bukkit.entity.Player;
public class PreferencesCommand extends CommandBase<PreferencesManager>
{
@ -18,6 +15,6 @@ public class PreferencesCommand extends CommandBase<PreferencesManager>
@Override
public void Execute(Player caller, String[] args)
{
Plugin.openShop(caller);
Plugin.openMenu(caller);
}
}

View File

@ -1,241 +0,0 @@
package mineplex.core.preferences.ui;
import org.bukkit.ChatColor;
import org.bukkit.Material;
import org.bukkit.entity.Player;
import org.bukkit.event.inventory.ClickType;
import mineplex.core.account.CoreClientManager;
import mineplex.core.common.Rank;
import mineplex.core.common.util.C;
import mineplex.core.common.util.F;
import mineplex.core.common.util.UtilPlayer;
import mineplex.core.common.util.UtilUI;
import mineplex.core.donation.DonationManager;
import mineplex.core.preferences.PreferencesManager;
import mineplex.core.preferences.UserPreferences;
import mineplex.core.shop.item.IButton;
import mineplex.core.shop.item.ShopItem;
import mineplex.core.shop.page.ShopPageBase;
public class ExclusivePreferencesPage extends ShopPageBase<PreferencesManager, ExclusivePreferencesShop>
{
private IButton _toggleHubInvisibility;
private IButton _toggleHubForcefield;
private IButton _toggleHubIgnoreVelocity;
private IButton _toggleMacReports;
private IButton _toggleUserReports;
private boolean _hubInvisibilityToggled;
private boolean _hubForcefieldToggled;
private boolean _hubIgnoreVelocityToggled;
private boolean _macReportsToggled;
private boolean _userReportsToggled;
private PreferencesShop _preferencesShop;
public ExclusivePreferencesPage(PreferencesManager plugin, ExclusivePreferencesShop shop, CoreClientManager clientManager, DonationManager donationManager, String name, Player player, PreferencesShop preferencesShop)
{
super(plugin, shop, clientManager, donationManager, name, player, 54);
_preferencesShop = preferencesShop;
createButtons();
buildPage();
}
private void createButtons()
{
_toggleHubInvisibility = new IButton()
{
@Override
public void onClick(Player player, ClickType clickType)
{
toggleHubInvisibility(player);
}
};
_toggleHubForcefield = new IButton()
{
@Override
public void onClick(Player player, ClickType clickType)
{
toggleHubForcefield(player);
}
};
_toggleMacReports = new IButton()
{
@Override
public void onClick(Player player, ClickType clickType)
{
toggleMacReports(player);
}
};
_toggleUserReports = new IButton()
{
@Override
public void onClick(Player player, ClickType clickType)
{
toggleUserReports(player);
}
};
_toggleHubIgnoreVelocity = new IButton()
{
@Override
public void onClick(Player player, ClickType clickType)
{
toggleHubIgnoreVelocity(player);
}
};
}
@Override
public void playerClosed()
{
super.playerClosed();
if (preferencesChanged())
{
getPlugin().savePreferences(getPlayer());
}
}
@Override
protected void buildPage()
{
clear();
UserPreferences userPreferences = getPlugin().Get(getPlayer());
Rank rank = getClientManager().Get(getPlayer()).GetRank();
addButton(45, new ShopItem(Material.REDSTONE_COMPARATOR, (byte) 0, C.cAqua + "/prefs", new String[] { C.cGold + "Return back to the regular preferences" }, 1, false, false), new IButton()
{
@Override
public void onClick(Player player, ClickType clickType)
{
player.closeInventory();
_preferencesShop.attemptShopOpen(player);
}
});
if (rank.has(Rank.ADMIN) || rank == Rank.JNR_DEV)
{
int[] indices = UtilUI.getIndicesFor(5, 0, 2);
buildPreference(indices[0], Material.NETHER_STAR, "Hub Invisibility", userPreferences.Invisibility, _toggleHubInvisibility);
buildPreference(indices[1], Material.SLIME_BALL, "Hub Forcefield", userPreferences.HubForcefield, _toggleHubForcefield);
buildPreference(indices[2], Material.PAPER, "Global GWEN Reports", userPreferences.ShowMacReports, _toggleMacReports);
buildPreference(indices[3], Material.SADDLE, "Hub Ignore Velocity", userPreferences.IgnoreVelocity, _toggleHubIgnoreVelocity);
buildPreference(indices[4], Material.BOOK, "User Reports", userPreferences.ShowUserReports, _toggleUserReports);
}
else if (rank.has(Rank.SNR_MODERATOR))
{
int[] indices = UtilUI.getIndicesFor(3, 0, 2);
buildPreference(indices[0], Material.PAPER, "Global GWEN Reports", userPreferences.ShowMacReports, _toggleMacReports);
buildPreference(indices[1], Material.SADDLE, "Hub Ignore Velocity", userPreferences.IgnoreVelocity, _toggleHubIgnoreVelocity);
buildPreference(indices[2], Material.BOOK, "User Reports", userPreferences.ShowUserReports, _toggleUserReports);
}
else if (rank.has(Rank.MODERATOR))
{
int[] indices = UtilUI.getIndicesFor(3, 0, 2);
buildPreference(indices[0], Material.PAPER, "Global GWEN Reports", userPreferences.ShowMacReports, _toggleMacReports);
buildPreference(indices[1], Material.SADDLE, "Hub Ignore Velocity", userPreferences.IgnoreVelocity, _toggleHubIgnoreVelocity);
buildPreference(indices[2], Material.BOOK, "User Reports", userPreferences.ShowUserReports, _toggleUserReports);
}
else if (rank.has(Rank.HELPER))
{
int[] indices = UtilUI.getIndicesFor(1, 0, 2);
buildPreference(indices[0], Material.PAPER, "Global GWEN Reports", userPreferences.ShowMacReports, _toggleMacReports);
}
else if (rank == Rank.YOUTUBE || rank == Rank.TWITCH)
{
int[] indices = UtilUI.getIndicesFor(3, 0, 2);
buildPreference(indices[0], Material.NETHER_STAR, "Hub Invisibility & Flight", userPreferences.Invisibility, _toggleHubInvisibility);
buildPreference(indices[1], Material.SLIME_BALL, "Hub Forcefield", userPreferences.HubForcefield, _toggleHubForcefield);
buildPreference(indices[2], Material.SADDLE, "Hub Ignore Velocity", userPreferences.IgnoreVelocity, _toggleHubIgnoreVelocity);
}
else if (rank == Rank.YOUTUBE_SMALL)
{
int[] indices = UtilUI.getIndicesFor(2, 0, 2);
buildPreference(indices[0], Material.SLIME_BALL, "Hub Forcefield", userPreferences.HubForcefield, _toggleHubForcefield);
buildPreference(indices[1], Material.SADDLE, "Hub Ignore Velocity", userPreferences.IgnoreVelocity, _toggleHubIgnoreVelocity);
}
}
private void toggleHubForcefield(org.bukkit.entity.Player player)
{
getPlugin().Get(player).HubForcefield = !getPlugin().Get(player).HubForcefield;
_hubForcefieldToggled = !_hubForcefieldToggled;
buildPage();
}
private void toggleHubInvisibility(org.bukkit.entity.Player player)
{
if (getPlugin().getIncognitoManager() != null && getPlugin().getIncognitoManager().Get(player).Status && /* Hub Invis & Incognito stuck prevention */ !getPlugin().Get(player).Invisibility)
{
UtilPlayer.message(player, F.main("Incognito", "You are not allowed to use Hub Visibility whilst in incognito mode."));
return;
}
getPlugin().Get(player).Invisibility = !getPlugin().Get(player).Invisibility;
// Dont save for Mod/SnrMod - prevents them just being invis 24/7
if (getPlugin().Get(player).Invisibility)
{
if (getClient().GetRank().has(Rank.ADMIN) || getClient().GetRank() == Rank.YOUTUBE || getClient().GetRank() == Rank.YOUTUBE_SMALL || getClient().GetRank() == Rank.TWITCH)
{
_hubInvisibilityToggled = !_hubInvisibilityToggled;
}
}
player.setFlying(false);
player.setAllowFlight(false);
buildPage();
}
private void toggleMacReports(org.bukkit.entity.Player player)
{
getPlugin().Get(player).ShowMacReports = !getPlugin().Get(player).ShowMacReports;
_macReportsToggled = !_macReportsToggled;
buildPage();
}
private void toggleUserReports(org.bukkit.entity.Player player)
{
getPlugin().Get(player).ShowUserReports = !getPlugin().Get(player).ShowUserReports;
_userReportsToggled = !_userReportsToggled;
buildPage();
}
private void toggleHubIgnoreVelocity(org.bukkit.entity.Player player)
{
getPlugin().Get(player).IgnoreVelocity = !getPlugin().Get(player).IgnoreVelocity;
_hubIgnoreVelocityToggled = !_hubIgnoreVelocityToggled;
buildPage();
}
private void buildPreference(int index, Material material, String name, boolean preference, IButton button)
{
buildPreference(index, material, (byte) 0, name, preference, button);
}
private void buildPreference(int index, Material material, byte data, String name, boolean preference, IButton button)
{
String[] description = new String[] { "" + (preference ? ChatColor.GREEN + "Enabled" : ChatColor.RED + "Disabled"), ChatColor.RED + " ", 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);
}
public boolean preferencesChanged()
{
return _hubInvisibilityToggled || _macReportsToggled || _hubIgnoreVelocityToggled || _hubForcefieldToggled || _userReportsToggled;
}
}

View File

@ -1,29 +0,0 @@
package mineplex.core.preferences.ui;
import org.bukkit.entity.Player;
import mineplex.core.account.CoreClientManager;
import mineplex.core.preferences.PreferencesManager;
import mineplex.core.shop.ShopBase;
import mineplex.core.shop.page.ShopPageBase;
public class ExclusivePreferencesShop extends ShopBase<PreferencesManager>
{
private PreferencesShop _preferencesShop;
public ExclusivePreferencesShop(PreferencesManager plugin, CoreClientManager clientManager, mineplex.core.donation.DonationManager donationManager)
{
super(plugin, clientManager, donationManager, "Exclusive Preferences");
}
public void setPreferencesShop(PreferencesShop preferencesShop)
{
_preferencesShop = preferencesShop;
}
@Override
protected ShopPageBase<PreferencesManager, ? extends ShopBase<PreferencesManager>> buildPagesFor(Player player)
{
return new ExclusivePreferencesPage(getPlugin(), this, getClientManager(), getDonationManager(), "Exclusive Preferences", player, _preferencesShop);
}
}

View File

@ -0,0 +1,67 @@
package mineplex.core.preferences.ui;
import com.google.common.collect.Lists;
import mineplex.core.common.Rank;
import mineplex.core.common.util.UtilUI;
import mineplex.core.menu.Button;
import mineplex.core.menu.Menu;
import mineplex.core.preferences.PreferenceCategory;
import mineplex.core.preferences.PreferencesManager;
import mineplex.core.preferences.ui.buttons.CategoryButton;
import org.bukkit.entity.Player;
import java.util.List;
/**
*
*/
public class PreferenceMainMenu extends Menu<PreferencesManager>
{
private final int INV_SIZE_MAX = 54;
private final int INV_SIZE_MIN = 45;
private final int[] SLOTS_MAX = {
20, 22, 24, 30, 32
};
private final int[] SLOTS_MIN = {
19, 21, 23, 25
};
public PreferenceMainMenu(PreferencesManager plugin)
{
super("My Preferences", plugin);
}
@Override
protected Button[] setUp(Player player)
{
Rank rank = getPlugin().getClientManager().Get(player).GetRank();
boolean exclusive = rank.has(Rank.HELPER) || rank == Rank.YOUTUBE_SMALL || rank == Rank.YOUTUBE || rank == Rank.TWITCH;
Button[] buttons = new Button[exclusive ? INV_SIZE_MAX : INV_SIZE_MIN];
List<PreferenceCategory> list = Lists.newArrayList(PreferenceCategory.values());
if(!exclusive)
{
list.remove(PreferenceCategory.EXCLUSIVE);
}
int[] slots = UtilUI.getIndicesFor(list.size(), 1, 4, 1);
int size = list.size();
for(int i = 0; i < size; i++)
{
int slot = slots[i];
PreferenceCategory category = list.get(i);
buttons[slot] = new CategoryButton(category, getPlugin());
}
return pane(buttons);
}
}

View File

@ -1,265 +0,0 @@
package mineplex.core.preferences.ui;
import org.bukkit.ChatColor;
import org.bukkit.Material;
import org.bukkit.entity.Player;
import org.bukkit.event.inventory.ClickType;
import mineplex.core.account.CoreClientManager;
import mineplex.core.common.Rank;
import mineplex.core.common.util.C;
import mineplex.core.common.util.UtilUI;
import mineplex.core.donation.DonationManager;
import mineplex.core.preferences.PreferencesManager;
import mineplex.core.preferences.UserPreferences;
import mineplex.core.shop.item.IButton;
import mineplex.core.shop.item.ShopItem;
import mineplex.core.shop.page.ShopPageBase;
public class PreferencesPage extends ShopPageBase<PreferencesManager, PreferencesShop>
{
private IButton _toggleHubGames;
private IButton _toggleHubPlayers;
private IButton _toggleChat;
private IButton _togglePrivateChat;
private IButton _toggleHubPartyRequests;
private IButton _togglePendingFriendRequests;
private IButton _toggleClanTips;
private IButton _toggleHubMusic;
private IButton _toggleDisableAds;
private boolean _hubGamesToggled;
private boolean _hubPlayersToggled;
private boolean _hubChatToggled;
private boolean _hubPrivateChatToggled;
private boolean _hubPartyRequestsToggled;
private boolean _pendingFriendRequestsToggled;
private boolean _clanTipsToggled;
private boolean _hubMusicToggled;
private boolean _disableAdsToggled;
private ExclusivePreferencesShop _exclusiveShop;
public PreferencesPage(PreferencesManager plugin, PreferencesShop shop, CoreClientManager clientManager, DonationManager donationManager, String name, Player player, ExclusivePreferencesShop exclusiveShop)
{
super(plugin, shop, clientManager, donationManager, name, player, 54);
_exclusiveShop = exclusiveShop;
createButtons();
buildPage();
}
private void createButtons()
{
_toggleHubGames = new IButton()
{
@Override
public void onClick(Player player, ClickType clickType)
{
toggleHubGames(player);
}
};
_toggleClanTips = new IButton()
{
@Override
public void onClick(Player player, ClickType clickType)
{
toggleClanTips(player);
}
};
_toggleHubPlayers = new IButton()
{
@Override
public void onClick(Player player, ClickType clickType)
{
toggleHubPlayers(player);
}
};
_toggleChat = new IButton()
{
@Override
public void onClick(Player player, ClickType clickType)
{
toggleChat(player);
}
};
_togglePrivateChat = new IButton()
{
@Override
public void onClick(Player player, ClickType clickType)
{
togglePrivateChat(player);
}
};
_toggleHubPartyRequests = new IButton()
{
@Override
public void onClick(Player player, ClickType clickType)
{
toggleHubPartyRequests(player);
}
};
_togglePendingFriendRequests = new IButton()
{
@Override
public void onClick(Player player, ClickType clickType)
{
togglePendingFriendRequests(player);
}
};
_toggleHubMusic = new IButton()
{
@Override
public void onClick(Player player, ClickType clickType)
{
toggleHubMusic(player);
}
};
_toggleDisableAds = new IButton()
{
@Override
public void onClick(Player player, ClickType clickType)
{
toggleDisableAds(player);
}
};
}
private void toggleHubMusic(Player player)
{
getPlugin().Get(player).HubMusic = !getPlugin().Get(player).HubMusic;
_hubMusicToggled = !_hubMusicToggled;
buildPage();
}
private void toggleDisableAds(Player player)
{
getPlugin().Get(player).DisableAds = !getPlugin().Get(player).DisableAds;
_disableAdsToggled = !_disableAdsToggled;
buildPage();
}
private void toggleHubPartyRequests(Player player)
{
getPlugin().Get(player).PartyRequests = !getPlugin().Get(player).PartyRequests;
_hubPartyRequestsToggled = !_hubPartyRequestsToggled;
buildPage();
}
private void togglePendingFriendRequests(Player player)
{
getPlugin().Get(player).PendingFriendRequests = !getPlugin().Get(player).PendingFriendRequests;
_pendingFriendRequestsToggled = !_pendingFriendRequestsToggled;
buildPage();
}
private void togglePrivateChat(Player player)
{
getPlugin().Get(player).PrivateMessaging = !getPlugin().Get(player).PrivateMessaging;
_hubPrivateChatToggled = !_hubPrivateChatToggled;
buildPage();
}
private void toggleChat(Player player)
{
getPlugin().Get(player).ShowChat = !getPlugin().Get(player).ShowChat;
_hubChatToggled = !_hubChatToggled;
buildPage();
}
private void toggleHubPlayers(Player player)
{
getPlugin().Get(player).ShowPlayers = !getPlugin().Get(player).ShowPlayers;
_hubPlayersToggled = !_hubPlayersToggled;
buildPage();
}
private void toggleClanTips(Player player)
{
getPlugin().Get(player).ClanTips = !getPlugin().Get(player).ClanTips;
_clanTipsToggled = !_clanTipsToggled;
buildPage();
}
private void toggleHubGames(Player player)
{
getPlugin().Get(player).HubGames = !getPlugin().Get(player).HubGames;
_hubGamesToggled = !_hubGamesToggled;
buildPage();
}
@Override
public void playerClosed()
{
super.playerClosed();
System.out.println("Prefs have changed: " + preferencesChanged());
if (preferencesChanged())
{
getPlugin().savePreferences(getPlayer());
}
}
@Override
protected void buildPage()
{
clear();
UserPreferences userPreferences = getPlugin().Get(getPlayer());
Rank rank = getClientManager().Get(getPlayer()).GetRank();
int amount = rank.has(Rank.ULTRA) ? 9 : 8;
int[] indices = UtilUI.getIndicesFor(amount, 0, 2);
buildPreference(indices[0], Material.FIREBALL, "Hub Player Stacker", userPreferences.HubGames, _toggleHubGames);
buildPreference(indices[1], Material.EYE_OF_ENDER, "Hub Player Visibility", userPreferences.ShowPlayers, _toggleHubPlayers);
buildPreference(indices[2], Material.PAPER, "Player Chat", userPreferences.ShowChat, _toggleChat);
buildPreference(indices[3], Material.EMPTY_MAP, "Private Messaging", userPreferences.PrivateMessaging, _togglePrivateChat);
buildPreference(indices[4], Material.SKULL_ITEM, (byte) 3, "Hub Party Requests", userPreferences.PartyRequests, _toggleHubPartyRequests);
buildPreference(indices[5], Material.RED_ROSE, "Show Pending Friend Requests", userPreferences.PendingFriendRequests, _togglePendingFriendRequests);
buildPreference(indices[6], Material.IRON_SWORD, "Show Clan Tips", userPreferences.ClanTips, _toggleClanTips);
buildPreference(indices[7], Material.NOTE_BLOCK, "Hub Music", userPreferences.HubMusic, _toggleHubMusic);
if (rank.has(Rank.ULTRA))
buildPreference(indices[8], Material.BARRIER, "Disable Ads", userPreferences.DisableAds, _toggleDisableAds);
if (rank.has(Rank.HELPER) || rank == Rank.YOUTUBE || rank == Rank.TWITCH || rank == Rank.YOUTUBE_SMALL)
{
addButton(53, new ShopItem(Material.DIAMOND, (byte) 0, C.cAqua + "Exclusive Preferences", new String[]{C.cGold + "This will open a page of preferences", C.cGold + "that are only available to you."}, 1, false, false), new IButton()
{
@Override
public void onClick(Player player, ClickType clickType)
{
player.closeInventory();
_exclusiveShop.attemptShopOpen(player);
}
});
}
}
private void buildPreference(int index, Material material, String name, boolean preference, IButton button)
{
buildPreference(index, material, (byte) 0, name, preference, button);
}
private void buildPreference(int index, Material material, byte data, String name, boolean preference, IButton button)
{
String[] description = new String[] { "" + (preference ? ChatColor.GREEN + "Enabled" : ChatColor.RED + "Disabled"), ChatColor.RED + " ", 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);
}
public boolean preferencesChanged()
{
return _hubGamesToggled || _hubPlayersToggled || _hubChatToggled || _hubPrivateChatToggled || _hubPartyRequestsToggled || _pendingFriendRequestsToggled || _clanTipsToggled || _hubMusicToggled || _disableAdsToggled;
}
}

View File

@ -1,25 +0,0 @@
package mineplex.core.preferences.ui;
import org.bukkit.entity.Player;
import mineplex.core.account.CoreClientManager;
import mineplex.core.preferences.PreferencesManager;
import mineplex.core.shop.ShopBase;
import mineplex.core.shop.page.ShopPageBase;
public class PreferencesShop extends ShopBase<PreferencesManager>
{
private ExclusivePreferencesShop _exclusiveShop;
public PreferencesShop(PreferencesManager plugin, CoreClientManager clientManager, mineplex.core.donation.DonationManager donationManager, ExclusivePreferencesShop exclusiveShop)
{
super(plugin, clientManager, donationManager, "My Preferences");
_exclusiveShop = exclusiveShop;
}
@Override
protected ShopPageBase<PreferencesManager, ? extends ShopBase<PreferencesManager>> buildPagesFor(Player player)
{
return new PreferencesPage(getPlugin(), this, getClientManager(), getDonationManager(), "My Preferences", player, _exclusiveShop);
}
}

View File

@ -0,0 +1,41 @@
package mineplex.core.preferences.ui.buttons;
import mineplex.core.itemstack.ItemBuilder;
import mineplex.core.menu.Button;
import mineplex.core.menu.Menu;
import mineplex.core.preferences.PreferencesManager;
import org.bukkit.ChatColor;
import org.bukkit.Material;
import org.bukkit.entity.Player;
import org.bukkit.event.inventory.ClickType;
import org.bukkit.inventory.ItemStack;
/**
*
*/
public class BackButton extends Button<PreferencesManager>
{
private static ItemStack ITEM = new ItemBuilder(Material.BED)
.setTitle(ChatColor.GRAY + "\u21FD Go Back")
.build();
public BackButton(PreferencesManager plugin)
{
super(ITEM, plugin);
}
@Override
public void onClick(Player player, ClickType clickType)
{
Menu.get(player.getUniqueId()).setUseClose(false);
player.closeInventory();
getPlugin().openMenu(player);
getPlugin().save(getPlugin().get(player));
Menu.get(player.getUniqueId()).setUseClose(true);
}
}

View File

@ -0,0 +1,29 @@
package mineplex.core.preferences.ui.buttons;
import mineplex.core.menu.Button;
import mineplex.core.preferences.PreferenceCategory;
import mineplex.core.preferences.PreferencesManager;
import mineplex.core.preferences.ui.menus.PreferenceMenu;
import org.bukkit.entity.Player;
import org.bukkit.event.inventory.ClickType;
/**
*
*/
public class CategoryButton extends Button<PreferencesManager>
{
private PreferenceCategory _category;
public CategoryButton(PreferenceCategory category, PreferencesManager plugin)
{
super(category.getItem(), plugin);
_category = category;
}
@Override
public void onClick(Player player, ClickType clickType)
{
new PreferenceMenu(_category, getPlugin()).open(player);
}
}

View File

@ -0,0 +1,63 @@
package mineplex.core.preferences.ui.buttons;
import mineplex.core.common.util.C;
import mineplex.core.itemstack.ItemBuilder;
import mineplex.core.menu.Button;
import mineplex.core.menu.Menu;
import mineplex.core.preferences.Preference;
import mineplex.core.preferences.PreferencesManager;
import mineplex.core.preferences.UserPreferences;
import org.bukkit.Material;
import org.bukkit.entity.Player;
import org.bukkit.event.inventory.ClickType;
import org.bukkit.inventory.ItemStack;
/**
*
*/
public class PreferenceButton extends Button<PreferencesManager>
{
protected final Preference _preference;
protected final UserPreferences _user;
private final ItemStack _disabled;
private final ItemStack _enabled;
public PreferenceButton(UserPreferences user, Preference preference, PreferencesManager plugin)
{
super(null, plugin);
_preference = preference;
_user = user;
Material icon = preference.getIcon();
boolean head = icon == Material.SKULL_ITEM;
_disabled = new ItemBuilder(preference.getIcon())
.setTitle(C.cRed + preference.getName())
.setLore(C.cRed + "Disabled", " " , C.cWhite + "Click to Enable")
.setData(head ? (short) 3 : 0)
.build();
_enabled = new ItemBuilder(preference.getIcon())
.setTitle(C.cGreen + preference.getName())
.setLore(C.cGreen + "Enabled", " " , C.cWhite + "Click to Disable")
.setData(head ? (short) 3 : 0)
.build();
}
@Override
public void onClick(Player player, ClickType clickType)
{
_user.toggle(_preference);
Menu.get(player.getUniqueId()).resetAndUpdate();
}
@Override
public ItemStack getItemStack()
{
return _user.isActive(_preference) ? _enabled : _disabled;
}
}

View File

@ -0,0 +1,43 @@
package mineplex.core.preferences.ui.buttons;
import mineplex.core.common.util.C;
import mineplex.core.itemstack.ItemBuilder;
import mineplex.core.preferences.Preference;
import mineplex.core.preferences.PreferencesManager;
import mineplex.core.preferences.UserPreferences;
import org.bukkit.DyeColor;
import org.bukkit.Material;
import org.bukkit.inventory.ItemStack;
/**
*
*/
public class PreferenceDyeButton extends PreferenceButton
{
private final ItemStack _disabledDye;
private final ItemStack _enabledDye;
public PreferenceDyeButton(UserPreferences user, Preference preference, PreferencesManager plugin)
{
super(user, preference, plugin);
_disabledDye = new ItemBuilder(Material.INK_SACK)
.setData(DyeColor.GRAY.getDyeData())
.setTitle(C.cRed + preference.getName())
.setLore(C.cRed + "Disabled", " " , C.cWhite + "Click to Enable")
.build();
_enabledDye = new ItemBuilder(Material.INK_SACK)
.setData(DyeColor.LIME.getDyeData())
.setTitle(C.cGreen + preference.getName())
.setLore(C.cGreen + "Enabled", " " , C.cWhite + "Click to Disable")
.build();
}
@Override
public ItemStack getItemStack()
{
return _user.isActive(_preference) ? _enabledDye : _disabledDye;
}
}

View File

@ -0,0 +1,86 @@
package mineplex.core.preferences.ui.menus;
import com.google.common.collect.Lists;
import mineplex.core.common.Rank;
import mineplex.core.common.util.UtilUI;
import mineplex.core.menu.Button;
import mineplex.core.menu.Menu;
import mineplex.core.preferences.Preference;
import mineplex.core.preferences.PreferenceCategory;
import mineplex.core.preferences.PreferencesManager;
import mineplex.core.preferences.UserPreferences;
import mineplex.core.preferences.ui.buttons.BackButton;
import mineplex.core.preferences.ui.buttons.PreferenceButton;
import mineplex.core.preferences.ui.buttons.PreferenceDyeButton;
import org.bukkit.entity.Player;
import java.util.List;
/**
*
*/
public class PreferenceMenu extends Menu<PreferencesManager>
{
private final int INV_SIZE = 54;
private final PreferenceCategory _category;
public PreferenceMenu(PreferenceCategory category, PreferencesManager plugin)
{
super(category.getName(), plugin);
_category = category;
setUseClose(true);
}
@Override
protected Button[] setUp(Player player)
{
Button[] buttons = new Button[INV_SIZE];
List<Preference> preferences = Lists.newArrayList(Preference.getByCategory(_category));
Rank rank = getPlugin().getClientManager().Get(player).GetRank();
UserPreferences user = getPlugin().get(player);
if (_category == PreferenceCategory.EXCLUSIVE && !rank.has(Rank.ADMIN) && rank != Rank.JNR_DEV)
{
if (rank.has(Rank.HELPER) && !rank.has(Rank.ADMIN))
{
preferences.remove(Preference.INVISIBILITY);
preferences.remove(Preference.FORCE_FIELD);
}
else if (rank == Rank.YOUTUBE || rank == Rank.TWITCH)
{
preferences.remove(Preference.GLOBAL_GWEN_REPORTS);
preferences.remove(Preference.SHOW_USER_REPORTS);
}
else if (rank == Rank.YOUTUBE_SMALL)
{
preferences.remove(Preference.GLOBAL_GWEN_REPORTS);
preferences.remove(Preference.SHOW_USER_REPORTS);
preferences.remove(Preference.INVISIBILITY);
}
}
int[] slots = UtilUI.getIndicesFor(preferences.size(), 1, 4, 1);
for(int i = 0; i < preferences.size(); i++)
{
int slot = slots[i];
Preference preference = preferences.get(i);
buttons[slot] = new PreferenceButton(user, preference, getPlugin());
buttons[slot + 9] = new PreferenceDyeButton(user, preference, getPlugin());
}
buttons[0] = new BackButton(getPlugin());
return pane(buttons);
}
@Override
public void onClose(Player player)
{
remove(player.getUniqueId());
getPlugin().save(getPlugin().get(player));
}
}

View File

@ -4,7 +4,6 @@ import mineplex.core.MiniClientPlugin;
import mineplex.core.account.CoreClientManager;
import mineplex.core.progression.data.PlayerKit;
import mineplex.core.progression.data.PlayerKitDataManager;
import mineplex.core.progression.gui.MenuListener;
import org.bukkit.plugin.java.JavaPlugin;
import java.util.UUID;
@ -25,7 +24,6 @@ public class KitProgressionManager extends MiniClientPlugin<PlayerKit>
_dataManager = new PlayerKitDataManager();
_kitProgressionRepository = new KitProgressionRepository(this);
_coreClientManager = clientManager;
getPlugin().getServer().getPluginManager().registerEvents(new MenuListener(), getPlugin());
}
public CoreClientManager getClientManager()
@ -33,7 +31,6 @@ public class KitProgressionManager extends MiniClientPlugin<PlayerKit>
return _coreClientManager;
}
@Override
protected PlayerKit addPlayer(UUID uuid)
{

View File

@ -148,6 +148,38 @@ public class KitProgressionRepository extends MinecraftRepository
});
}
/**
* Possibly remove
* @param uuid
*/
public void loadInfoSync(UUID uuid)
{
PlayerKit playerKit = new PlayerKit(uuid);
try (Connection connection = getConnection())
{
PreparedStatement preparedStatement = new SQLStatement(QUERY_KITS).set(1, uuid).prepare(connection);
ResultSet resultSet = preparedStatement.executeQuery();
while (resultSet.next())
{
String kitId = resultSet.getString("kitId");
int level = resultSet.getInt("level");
int xp = resultSet.getInt("xp");
int upgradeLevel = resultSet.getInt("upgrade_level");
boolean def = resultSet.getInt("default") == 1;
playerKit.setLevel(level, kitId);
playerKit.setXp(xp, kitId);
playerKit.setUpgradeLevel(upgradeLevel, kitId);
playerKit.setDefault(def, kitId);
}
} catch (SQLException e)
{
e.printStackTrace();
}
_kitProgressionManager.getDataManager().add(playerKit);
}
@SuppressWarnings("Duplicates")
public void getInfo(UUID uuid)

View File

@ -1,16 +1,17 @@
package mineplex.core.progression;
import mineplex.core.common.util.UtilParticle;
import mineplex.core.common.util.UtilParticle.ParticleType;
import mineplex.core.common.util.UtilParticle.ViewDist;
import mineplex.core.progression.data.KitAbilityDetail;
import mineplex.core.progression.math.Calculations;
import java.util.List;
import java.util.Map;
import java.util.UUID;
import org.bukkit.Material;
import org.bukkit.entity.Entity;
import org.bukkit.entity.Player;
import java.util.List;
import java.util.UUID;
import mineplex.core.common.util.UtilParticle;
import mineplex.core.common.util.UtilParticle.ParticleType;
import mineplex.core.common.util.UtilParticle.ViewDist;
import mineplex.core.progression.math.Calculations;
/**
* The API class all kits with the new system must use
@ -49,11 +50,20 @@ public interface ProgressiveKit
/**
* This method gives the GUI information to display about the kit's upgrades and what they do
* This information is being directly displayed in a GUI, so make sure it looks good
* For more information, see the {@link KitAbilityDetail} class
*
* @return The map of upgrades and their details
* @return The map of upgrade level to a list of upgrade details
*/
List<KitAbilityDetail> getAbilityDetails();
Map<Integer, List<String>> getUpgradeDetails();
/**
* Determines whether or not the kit UI is displayed with "Coming Soon" or actual upgrade details.
*
* @return <code>true</code> if the menu should populate from {@code getAbilityDetails}
*/
default boolean showUpgrades()
{
return false;
}
/**
* Retrieve the current level of this kit

View File

@ -1,38 +0,0 @@
package mineplex.core.progression.data;
import org.bukkit.Material;
/**
* General wrapper for Ability Details (The display properties of this kits Abilities) for a GUI
* The purpose is to limit the amount of hard coded data Kit's do and make it as flexible as possible.
*/
public class KitAbilityDetail
{
private Material _icon;
private String _displayName;
private String[] _description;
public KitAbilityDetail(Material icon, String displayName, String[] description)
{
_icon = icon;
_displayName = displayName;
_description = description;
}
public String getDisplayName()
{
return _displayName;
}
public Material getIcon()
{
return _icon;
}
public String[] getDescription()
{
return _description;
}
}

View File

@ -20,7 +20,7 @@ public class PlayerKitDataManager
public PlayerKit get(UUID uuid)
{
return _dataMapAccountUUID.get(uuid);
return _dataMapAccountUUID.getOrDefault(uuid, new PlayerKit(uuid));
}
public void add(PlayerKit playerKit)

View File

@ -1,36 +0,0 @@
package mineplex.core.progression.gui;
import org.bukkit.entity.Player;
import org.bukkit.inventory.ItemStack;
/**
* An abstract class for managing buttons inside of menus
*/
public abstract class Button
{
private ItemStack _item;
public Button(ItemStack item)
{
this._item = item;
}
/**
* The method called when a players clicks the slot
*
* @param player The player who clicked
*/
public abstract void onClick(Player player);
public ItemStack getItemStack()
{
return _item;
}
public void setItemStack(ItemStack item)
{
this._item = item;
}
}

View File

@ -1,191 +0,0 @@
package mineplex.core.progression.gui;
import mineplex.core.progression.gui.buttons.misc.IconButton;
import net.md_5.bungee.api.ChatColor;
import org.bukkit.Bukkit;
import org.bukkit.entity.Player;
import org.bukkit.inventory.Inventory;
import org.bukkit.inventory.InventoryView;
import org.bukkit.inventory.ItemStack;
import java.util.HashMap;
import java.util.Map;
import java.util.UUID;
/**
* A class to manage dynamic creation of GUI's
*/
public abstract class Menu
{
protected static final Button[] EMPTY = new Button[45];
protected static Map<UUID, Menu> MENUS = new HashMap<>();
private String _name;
protected Button[] _buttons;
public Menu(String name)
{
_name = name;
_buttons = EMPTY;
}
public static Menu get(UUID name)
{
return MENUS.get(name);
}
/**
* Create an icon (no click action)
*
* @param item The itemstack ti display
* @return The created button
*/
protected Button create(ItemStack item)
{
return new IconButton(item);
}
public String getName()
{
return ChatColor.translateAlternateColorCodes('&', _name);
}
/**
* Open and setup the inventory for the player to view
* Store a reference to it inside a map for retrieving later
*
* @param player The player who we wish to show the GUI to
*/
public void open(Player player)
{
setButtons(setUp());
if (MENUS.get(player.getUniqueId()) != null)
{
MENUS.remove(player.getUniqueId());
}
MENUS.put(player.getUniqueId(), this);
int size = (_buttons.length + 8) / 9 * 9;
Inventory inventory = Bukkit.createInventory(player, size, getName());
for (int i = 0; i < _buttons.length; i++)
{
if (_buttons[i] == null)
{
continue;
}
ItemStack item = _buttons[i].getItemStack();
inventory.setItem(i, item);
}
player.openInventory(inventory);
}
/**
* Set up the GUI with buttons
*
* @return The setup button array
*/
protected abstract Button[] setUp();
public Button[] getButtons()
{
return _buttons;
}
public void setButtons(Button[] buttons)
{
_buttons = buttons;
}
/**
* Retrieve the button based off the slot
*
* @param slot The slot in the inventory
* @return The button corresponding to that slot
*/
public Button getButton(int slot)
{
try
{
return _buttons[slot];
} catch (ArrayIndexOutOfBoundsException e)
{
//There isn't a button there, so no need to throw an error
//e.printStackTrace();
return null;
}
}
/**
* Replace a button, or create a new button dynamically
* Update the players GUI
*
* @param slot The slot to set the new button
* @param button The reference to the button
* @param player The player whose GUI we'll be updating
*/
public void setButton(int slot, Button button, Player player)
{
try
{
_buttons[slot] = button;
} catch (ArrayIndexOutOfBoundsException ignored)
{
ignored.printStackTrace();
}
update(player);
}
/**
* Refresh the players view, allows to change what the player sees, without opening and closing the GUI
*
* @param player The player whose view you wish to update
*/
public void update(Player player)
{
InventoryView view = player.getOpenInventory();
if (view == null)
{
return;
}
if (!view.getTitle().equalsIgnoreCase(getName()))
{
return;
}
Inventory inventory = view.getTopInventory();
for (int i = 0; i < _buttons.length; i++)
{
if (_buttons[i] == null)
{
continue;
}
ItemStack item = _buttons[i].getItemStack();
inventory.setItem(i, item);
}
}
public void setTitle(String title)
{
_name = title;
}
public void onClose(Player player)
{
MENUS.remove(player.getUniqueId());
}
public static Menu remove(UUID uniqueId)
{
return MENUS.remove(uniqueId);
}
}

View File

@ -1,45 +0,0 @@
package mineplex.core.progression.gui;
import org.bukkit.entity.Player;
import org.bukkit.event.Event;
import org.bukkit.event.EventHandler;
import org.bukkit.event.Listener;
import org.bukkit.event.inventory.InventoryClickEvent;
/**
* Listener for the Menu system
*/
public class MenuListener implements Listener
{
@EventHandler
public void onClick(InventoryClickEvent event)
{
String name = event.getInventory().getName();
Player player = (Player) event.getWhoClicked();
Menu gui = Menu.get(player.getUniqueId());
if (gui == null)
{
return;
}
if (!gui.getName().equalsIgnoreCase(name))
{
return;
}
Button button = gui.getButton(event.getRawSlot());
event.setCancelled(true);
event.setResult(Event.Result.DENY);
if (button == null)
{
return;
}
button.onClick(player);
}
}

View File

@ -1,50 +0,0 @@
package mineplex.core.progression.gui.buttons;
import com.google.common.collect.Lists;
import mineplex.core.itemstack.ItemBuilder;
import mineplex.core.progression.data.KitAbilityDetail;
import mineplex.core.progression.gui.buttons.misc.IconButton;
import org.bukkit.inventory.ItemStack;
import java.util.Arrays;
import java.util.List;
/**
* Representing this kits Abilities in a GUI
*/
public class KitAbilityButton extends IconButton
{
private ItemStack _item;
public KitAbilityButton(KitAbilityDetail detail)
{
super(null);
ItemBuilder builder = new ItemBuilder(detail.getIcon());
builder.setTitle(detail.getDisplayName());
List<String> lore = Lists.newArrayList(" ");
lore.addAll(Arrays.asList(detail.getDescription()));
lore.add(" ");
builder.setLore(lore.toArray(new String[lore.size()]));
_item = builder.build();
}
@Override
public ItemStack getItemStack()
{
return _item;
}
@Override
public void setItemStack(ItemStack item)
{
_item = item;
}
}

View File

@ -1,21 +1,27 @@
package mineplex.core.progression.gui.buttons;
import mineplex.core.menu.Button;
import mineplex.core.progression.KitProgressionManager;
import mineplex.core.progression.ProgressiveKit;
import mineplex.core.progression.gui.Button;
import org.bukkit.inventory.ItemStack;
/**
* Similar to KitMenu, this helps with organizing buttons related to kits
* Since they all share common features.
*/
public abstract class KitButton extends Button
public abstract class KitButton extends Button<KitProgressionManager>
{
private ProgressiveKit _kit;
public KitButton(ProgressiveKit kit, ItemStack itemStack)
{
super(itemStack);
this(kit, itemStack, null);
}
public KitButton(ProgressiveKit kit, ItemStack itemStack, KitProgressionManager plugin)
{
super(itemStack, plugin);
_kit = kit;
}

View File

@ -7,6 +7,7 @@ import mineplex.core.itemstack.ItemBuilder;
import mineplex.core.progression.ProgressiveKit;
import org.bukkit.ChatColor;
import org.bukkit.entity.Player;
import org.bukkit.event.inventory.ClickType;
import org.bukkit.inventory.ItemStack;
import java.util.List;
@ -68,7 +69,7 @@ public class KitIconButton extends KitButton
}
@Override
public void onClick(Player player)
public void onClick(Player player, ClickType clickType)
{
getKit().onSelected(player.getUniqueId());
}

View File

@ -6,6 +6,7 @@ import net.md_5.bungee.api.ChatColor;
import org.bukkit.DyeColor;
import org.bukkit.Material;
import org.bukkit.entity.Player;
import org.bukkit.event.inventory.ClickType;
import org.bukkit.inventory.ItemStack;
/**
@ -37,7 +38,7 @@ public class KitPermanentDefaultButton extends KitButton
}
@Override
public void onClick(Player player)
public void onClick(Player player, ClickType clickType)
{
getKit().onSelected(player.getUniqueId());

View File

@ -8,6 +8,7 @@ import net.md_5.bungee.api.ChatColor;
import org.bukkit.DyeColor;
import org.bukkit.Material;
import org.bukkit.entity.Player;
import org.bukkit.event.inventory.ClickType;
/**
* This manages selecting of the kit for the current game.
@ -31,7 +32,7 @@ public class KitSelectButton extends KitButton
}
@Override
public void onClick(Player player)
public void onClick(Player player, ClickType clickType)
{
getKit().onSelected(player.getUniqueId());
}

View File

@ -1,10 +1,11 @@
package mineplex.core.progression.gui.buttons;
import mineplex.core.common.util.F;
import mineplex.core.menu.Menu;
import mineplex.core.progression.ProgressiveKit;
import mineplex.core.progression.gui.Menu;
import org.bukkit.Sound;
import org.bukkit.entity.Player;
import org.bukkit.event.inventory.ClickType;
import org.bukkit.inventory.ItemStack;
import java.util.UUID;
@ -16,21 +17,19 @@ public class KitUpgradeButton extends KitButton
{
private int _upgradeLevel;
private String _upggradeName;
public KitUpgradeButton(ProgressiveKit kit, ItemStack itemStack, int upgradeLevel, String upggradeName)
public KitUpgradeButton(ProgressiveKit kit, ItemStack itemStack, int upgradeLevel)
{
super(kit, itemStack);
_upgradeLevel = upgradeLevel;
_upggradeName = upggradeName;
}
@Override
public void onClick(Player player)
public void onClick(Player player, ClickType clickType)
{
UUID uuid = player.getUniqueId();
if (!getKit().canPurchaseUpgrade(uuid, _upgradeLevel))
if (!getKit().canPurchaseUpgrade(uuid, _upgradeLevel) || getKit().ownsUpgrade(uuid, _upgradeLevel))
{
player.playSound(player.getLocation(), Sound.ITEM_BREAK, 10.0F, 1.0F);
player.sendMessage(F.main("Kit Progression", "You cannot purchase this upgrade!"));
@ -41,7 +40,7 @@ public class KitUpgradeButton extends KitButton
player.playSound(player.getLocation(), Sound.CAT_MEOW, 5.0f, 1.0f);
player.sendMessage(F.main("Kit Progression", "Purchased " + _upggradeName));
player.sendMessage(F.main("Kit Progression", "Purchased upgrades for " + getKit().getDisplayName() + " level " + _upgradeLevel));
Menu.remove(uuid);

View File

@ -0,0 +1,55 @@
package mineplex.core.progression.gui.buttons;
import com.google.common.collect.Lists;
import mineplex.core.common.util.C;
import mineplex.core.itemstack.ItemBuilder;
import mineplex.core.menu.IconButton;
import mineplex.core.progression.math.Calculations;
import org.bukkit.Material;
import org.bukkit.inventory.ItemStack;
import java.util.List;
/**
* Representing this kits Abilities in a GUI
*/
public class KitUpgradeDetailsButton extends IconButton
{
private ItemStack _item;
public KitUpgradeDetailsButton(int level, List<String> details)
{
super(null);
ItemBuilder builder = new ItemBuilder(Material.SLIME_BALL);
builder.setTitle(C.cYellow + "Level " + level + " upgrades");
List<String> lore = Lists.newArrayList(" ");
for (String detail : details)
{
lore.add(C.cGray + detail);
}
lore.add("");
lore.add(C.cGray + "Unlocks at kit level " + C.cGreen + Calculations.getLevelRequiredFor(level));
builder.setLore(lore.toArray(new String[lore.size()]));
_item = builder.build();
}
@Override
public ItemStack getItemStack()
{
return _item;
}
@Override
public void setItemStack(ItemStack item)
{
_item = item;
}
}

View File

@ -2,6 +2,7 @@ package mineplex.core.progression.gui.buttons;
import mineplex.core.common.util.C;
import mineplex.core.itemstack.ItemBuilder;
import mineplex.core.progression.KitProgressionManager;
import mineplex.core.progression.ProgressiveKit;
import mineplex.core.progression.gui.guis.KitInformationTrackerMenu;
import mineplex.core.progression.gui.guis.KitMenu;
@ -9,12 +10,11 @@ import mineplex.core.progression.math.Calculations;
import net.md_5.bungee.api.ChatColor;
import org.bukkit.Material;
import org.bukkit.entity.Player;
import org.bukkit.event.inventory.ClickType;
import org.bukkit.inventory.ItemStack;
import org.bukkit.scheduler.BukkitRunnable;
import org.bukkit.scheduler.BukkitTask;
import static mineplex.core.common.util.UtilServer.getPlugin;
/**
* This is the button for upgrades. It'll flash when one is available
* Displays information regarding upgrades on hover
@ -31,9 +31,9 @@ public class KitUpgradeMenuButton extends KitButton
private boolean _flash;
private BukkitTask _task;
public KitUpgradeMenuButton(ProgressiveKit kit, Player player)
public KitUpgradeMenuButton(ProgressiveKit kit, Player player, KitProgressionManager plugin)
{
super(kit, null);
super(kit, null, plugin);
_item = ITEM_STACK;
//The current upgrade level out of 5 for this kit
@ -50,13 +50,19 @@ public class KitUpgradeMenuButton extends KitButton
//This ONLY flashes if their next upgrade level isn't their same one.
_flash = Calculations.isUpgradeLevelEligible(level) && (nextUpgradeLevel > upgradeLevel);
ChatColor color = Calculations.getColor(level, nextUpgradeLevelPlayer);
if(kit.showUpgrades())
{
ItemBuilder builder = lore(new ItemBuilder(Material.ENCHANTMENT_TABLE), upgradeLevel, color, diff);
builder.setTitle(C.cYellow + "Upgrade Level " + upgradeLevel);
_item = builder.build();
}
if (_flash)
{
flash();
}
ChatColor color = Calculations.getColor(level, nextUpgradeLevelPlayer);
}
@Override
@ -73,7 +79,7 @@ public class KitUpgradeMenuButton extends KitButton
private void flash()
{
this._task = new BukkitRunnable()
_task = new BukkitRunnable()
{
private ItemStack itemClone = ITEM_STACK.clone();
@ -103,20 +109,20 @@ public class KitUpgradeMenuButton extends KitButton
resetItem = true;
}
}.runTaskTimer(getPlugin(), 0L, 10L);
}.runTaskTimer(getPlugin().getPlugin(), 0L, 10L);
}
@Override
public void onClick(Player player)
public void onClick(Player player, ClickType clickType)
{
this._flash = false;
_flash = false;
if (_task != null)
{
this._task.cancel();
_task.cancel();
}
KitMenu menu = new KitInformationTrackerMenu(getKit());
KitMenu menu = new KitInformationTrackerMenu(getKit(), getPlugin());
menu.open(player);
}

View File

@ -9,6 +9,7 @@ import mineplex.core.progression.math.Calculations;
import net.md_5.bungee.api.ChatColor;
import org.bukkit.Material;
import org.bukkit.entity.Player;
import org.bukkit.event.inventory.ClickType;
import org.bukkit.inventory.ItemStack;
import java.util.List;
@ -87,9 +88,9 @@ public class KitXPButton extends KitButton
@Override
public void onClick(Player player)
public void onClick(Player player, ClickType clickType)
{
KitMenu menu = new KitInformationTrackerMenu(getKit());
KitMenu menu = new KitInformationTrackerMenu(getKit(), getPlugin());
menu.open(player);
}
}

View File

@ -1,17 +1,19 @@
package mineplex.core.progression.gui.buttons.misc;
import mineplex.core.itemstack.ItemBuilder;
import mineplex.core.progression.gui.Button;
import mineplex.core.menu.Button;
import mineplex.core.progression.KitProgressionManager;
import mineplex.core.progression.gui.guis.KitMenu;
import org.bukkit.ChatColor;
import org.bukkit.Material;
import org.bukkit.entity.Player;
import org.bukkit.event.inventory.ClickType;
import org.bukkit.inventory.ItemStack;
/**
* This button take you back to the specified menu
*/
public class BackButton extends Button
public class BackButton extends Button<KitProgressionManager>
{
private static ItemStack ITEM = new ItemBuilder(Material.BED)
@ -22,7 +24,7 @@ public class BackButton extends Button
public BackButton(KitMenu toMenu)
{
super(ITEM);
super(ITEM, null);
_toMenu = toMenu;
}
@ -33,7 +35,7 @@ public class BackButton extends Button
}
@Override
public void onClick(Player player)
public void onClick(Player player, ClickType clickType)
{
_toMenu.open(player);
}

View File

@ -1,23 +0,0 @@
package mineplex.core.progression.gui.buttons.misc;
import mineplex.core.progression.gui.Button;
import org.bukkit.entity.Player;
import org.bukkit.inventory.ItemStack;
/**
* A button designed for purely cosmetic reasons, but has no impact when clicked.
*/
public class IconButton extends Button
{
public IconButton(ItemStack item)
{
super(item);
}
@Override
public void onClick(Player player)
{
}
}

View File

@ -1,11 +1,20 @@
package mineplex.core.progression.gui.guis;
import mineplex.core.menu.Button;
import mineplex.core.menu.IconButton;
import mineplex.core.progression.KitProgressionManager;
import mineplex.core.progression.ProgressiveKit;
import mineplex.core.progression.gui.Button;
import mineplex.core.progression.gui.buttons.*;
import mineplex.core.progression.gui.buttons.misc.IconButton;
import mineplex.core.progression.gui.buttons.KitIconButton;
import mineplex.core.progression.gui.buttons.KitPermanentDefaultButton;
import mineplex.core.progression.gui.buttons.KitSelectButton;
import mineplex.core.progression.gui.buttons.KitUpgradeDetailsButton;
import mineplex.core.progression.gui.buttons.KitUpgradeMenuButton;
import mineplex.core.progression.gui.buttons.KitXPButton;
import org.bukkit.entity.Player;
import java.util.List;
import java.util.Map;
/**
* This is the main menu a player sees when we selects an NPC Kit
* Displays the most important information about this kit
@ -25,13 +34,13 @@ public class KitDisplayMenu extends KitMenu
7, 8, 16, 17
};
public KitDisplayMenu(ProgressiveKit kit)
public KitDisplayMenu(ProgressiveKit kit, KitProgressionManager plugin)
{
super(kit);
super(kit, plugin);
}
@Override
public Button[] setup(Player player)
public Button[] setUp(Player player)
{
Button[] buttons = new Button[51];
@ -39,7 +48,7 @@ public class KitDisplayMenu extends KitMenu
setUpIcon(buttons, player);
setUpDetails(buttons);
setUpDetails(buttons, player);
setUpNextMenuButtons(buttons, player);
@ -55,7 +64,7 @@ public class KitDisplayMenu extends KitMenu
private void setUpNextMenuButtons(Button[] buttons, Player player)
{
buttons[48] = new KitXPButton(getKit(), player);
buttons[50] = new KitUpgradeMenuButton(getKit(), player);
buttons[50] = new KitUpgradeMenuButton(getKit(), player, getPlugin());
}
/**
@ -70,12 +79,22 @@ public class KitDisplayMenu extends KitMenu
/**
* Set up the details (info) regarding the upgrades to this kit
* Lines commented out due to waiting to release upgrades
*
* @param buttons The array of buttons we're modifying
*/
private void setUpDetails(Button[] buttons)
private void setUpDetails(Button[] buttons, Player player)
{
if(getKit().showUpgrades())
{
Map<Integer, List<String>> details = getKit().getUpgradeDetails();
int index = 0;
for(int i : UPGRADE_SLOTS)
{
buttons[i] = new KitUpgradeDetailsButton(index + 1, details.get(index++));
}
return;
}
for (int i : UPGRADE_SLOTS)
{
buttons[i] = new IconButton(COMING_SOON);

View File

@ -3,10 +3,13 @@ package mineplex.core.progression.gui.guis;
import com.google.common.collect.Lists;
import mineplex.core.common.util.C;
import mineplex.core.itemstack.ItemBuilder;
import mineplex.core.menu.Button;
import mineplex.core.menu.IconButton;
import mineplex.core.progression.KitProgressionManager;
import mineplex.core.progression.ProgressiveKit;
import mineplex.core.progression.gui.Button;
import mineplex.core.progression.gui.buttons.KitUpgradeButton;
import mineplex.core.progression.gui.buttons.KitUpgradeDetailsButton;
import mineplex.core.progression.gui.buttons.misc.BackButton;
import mineplex.core.progression.gui.buttons.misc.IconButton;
import mineplex.core.progression.math.Calculations;
import org.bukkit.ChatColor;
import org.bukkit.DyeColor;
@ -15,6 +18,7 @@ import org.bukkit.entity.Player;
import org.bukkit.inventory.ItemStack;
import java.util.List;
import java.util.Map;
import java.util.UUID;
/**
@ -42,17 +46,17 @@ public class KitInformationTrackerMenu extends KitMenu
47, 48, 49, 50, 51
};
public KitInformationTrackerMenu(ProgressiveKit kit)
public KitInformationTrackerMenu(ProgressiveKit kit, KitProgressionManager plugin)
{
super(kit);
super(kit, plugin);
}
@Override
public Button[] setup(Player player)
public Button[] setUp(Player player)
{
Button[] buttons = new Button[52];
buttons[0] = new BackButton(new KitDisplayMenu(getKit()));
buttons[0] = new BackButton(new KitDisplayMenu(getKit(), getPlugin()));
setUpXP(buttons, player);
@ -137,13 +141,46 @@ public class KitInformationTrackerMenu extends KitMenu
}
/**
* Set up the row of Dyes / Music discs symbolizing the players upgrade advancement
* Set up the row of items symbolizing the players upgrade advancement
*
* @param buttons The array of buttons we're modifying
* @param player The player whose data we'll be using
*/
private void setUpUpgrade(Button[] buttons, Player player)
{
if(getKit().showUpgrades())
{
Map<Integer, List<String>> details = getKit().getUpgradeDetails();
int index = 0;
for(int i : UPGRADE_SLOTS)
{
List<String> list = details.get(index++);
KitUpgradeDetailsButton detailsButton = new KitUpgradeDetailsButton(index, list);
ItemBuilder itemStack = new ItemBuilder(detailsButton.getItemStack());
if (getKit().ownsUpgrade(player.getUniqueId(), index))
{
itemStack.addLore(C.cRed + "You already own this upgrade!");
}
else if (getKit().canPurchaseUpgrade(player.getUniqueId(), index))
{
itemStack.setGlow(true);
itemStack.addLore("Costs " + C.cGreen + Calculations.getGemsCost(index) + C.cGray + " gems");
itemStack.addLore(C.cGreen + "Click to purchase this upgrade!");
}
else
{
itemStack.addLore("Costs " + C.cGreen + Calculations.getGemsCost(index) + C.cGray + " gems");
itemStack.addLore(C.cRed + "You cannot purchase this upgrade!");
}
KitUpgradeButton upgradeButton = new KitUpgradeButton(getKit(), itemStack.build(), index);
buttons[i] = upgradeButton;
}
return;
}
for (int i : UPGRADE_SLOTS)
{
buttons[i] = new IconButton(COMING_SOON);

View File

@ -1,21 +1,18 @@
package mineplex.core.progression.gui.guis;
import mineplex.core.itemstack.ItemBuilder;
import mineplex.core.menu.Menu;
import mineplex.core.progression.KitProgressionManager;
import mineplex.core.progression.ProgressiveKit;
import mineplex.core.progression.gui.Button;
import mineplex.core.progression.gui.Menu;
import org.bukkit.Bukkit;
import org.bukkit.ChatColor;
import org.bukkit.DyeColor;
import org.bukkit.Material;
import org.bukkit.entity.Player;
import org.bukkit.inventory.Inventory;
import org.bukkit.inventory.ItemStack;
/**
* An implementation of {@link Menu} corresponding to kits
*/
public abstract class KitMenu extends Menu
public abstract class KitMenu extends Menu<KitProgressionManager>
{
/**
@ -30,72 +27,14 @@ public abstract class KitMenu extends Menu
private ProgressiveKit _kit;
public KitMenu(ProgressiveKit kit)
public KitMenu(ProgressiveKit kit, KitProgressionManager manager)
{
super(kit.getDisplayName());
super(kit.getDisplayName(), manager);
_kit = kit;
}
/**
* Set up a menu based on the specific player
*
* @param player The player who we want to tailor the GUI to
* @return The setup arrangement of buttons
*/
public abstract Button[] setup(Player player);
/**
* Open a GUI tailored to the player
*
* @param player The player who we wish to show the GUI to
*/
@Override
public void open(Player player)
{
this.setButtons(setup(player));
if (MENUS.get(player.getUniqueId()) != null)
{
MENUS.remove(player.getUniqueId());
}
MENUS.put(player.getUniqueId(), this);
int size = (this._buttons.length + 8) / 9 * 9;
Inventory inventory = Bukkit.createInventory(player, size, getName());
for (int i = 0; i < _buttons.length; i++)
{
if (_buttons[i] == null)
{
continue;
}
ItemStack item = _buttons[i].getItemStack();
inventory.setItem(i, item);
}
player.openInventory(inventory);
}
/**
* Get the kit specific to this GUI
*
* @return This GUI's kit
*/
public ProgressiveKit getKit()
{
return _kit;
}
/**
* We don't want to use this, as we may require per player GUI's
* @return The arrangement of buttons
*/
@Override
public Button[] setUp()
{
return new Button[45];
}
}

View File

@ -186,7 +186,6 @@ public class Calculations
return 100;
}
@SuppressWarnings("Duplicates")
public static int getLevelRequiredFor(int upgradeLevel)
{
switch (upgradeLevel)
@ -205,4 +204,15 @@ public class Calculations
return -1;
}
/**
* Get the number of gems required to purchase an upgrade from the upgrade level
*
* @param upgradeLevel The upgrade level (1-5)
* @return The integer value of the number of gems required to purchase an upgrade
*/
public static int getGemsCost(int upgradeLevel)
{
return GEMS_FOR_UPGRADE.get(getLevelRequiredFor(upgradeLevel));
}
}

View File

@ -1,13 +1,5 @@
package mineplex.core.report;
import java.time.LocalDateTime;
import java.util.Collection;
import java.util.HashMap;
import java.util.HashSet;
import java.util.Map;
import java.util.Set;
import java.util.UUID;
import com.google.gson.Gson;
import com.google.gson.JsonObject;
import mineplex.core.account.CoreClientManager;
@ -21,10 +13,11 @@ import mineplex.core.common.jsonchat.JsonMessage;
import mineplex.core.common.util.C;
import mineplex.core.common.util.F;
import mineplex.core.portal.Portal;
import mineplex.core.preferences.Preference;
import mineplex.core.preferences.PreferencesManager;
import mineplex.core.report.command.ReportHandlerNotification;
import mineplex.core.report.command.ReportNotificationCallback;
import mineplex.core.report.command.ReportNotification;
import mineplex.core.report.command.ReportNotificationCallback;
import mineplex.core.report.task.ReportHandlerMessageTask;
import mineplex.core.stats.PlayerStats;
import mineplex.core.stats.StatsManager;
@ -33,16 +26,22 @@ import mineplex.serverdata.Utility;
import mineplex.serverdata.commands.ServerCommandManager;
import mineplex.serverdata.data.DataRepository;
import mineplex.serverdata.redis.RedisDataRepository;
import org.bukkit.Bukkit;
import org.bukkit.entity.Player;
import org.bukkit.event.player.PlayerCommandPreprocessEvent;
import org.bukkit.plugin.java.JavaPlugin;
import redis.clients.jedis.Jedis;
import redis.clients.jedis.JedisPool;
import redis.clients.jedis.exceptions.JedisConnectionException;
import java.time.LocalDateTime;
import java.util.Collection;
import java.util.HashMap;
import java.util.HashSet;
import java.util.Map;
import java.util.Set;
import java.util.UUID;
/**
* ReportManager hooks into a synchronized network-wide report system
* with methods for updating/fetching/closing reports in real time.
@ -356,7 +355,7 @@ public class ReportManager
public boolean hasReportNotifications(Player player)
{
boolean isStaff = CommandCenter.Instance.GetClientManager().Get(player).GetRank().has(Rank.MODERATOR);
boolean hasReportNotifications = _preferencesManager.Get(player).ShowUserReports;
boolean hasReportNotifications = _preferencesManager.get(player).isActive(Preference.SHOW_USER_REPORTS);
return isStaff && hasReportNotifications;
}

View File

@ -1,9 +1,28 @@
package mineplex.core.treasure;
import java.util.List;
import mineplex.core.account.CoreClientManager;
import mineplex.core.common.util.C;
import mineplex.core.common.util.Callback;
import mineplex.core.common.util.F;
import mineplex.core.common.util.UtilAction;
import mineplex.core.common.util.UtilAlg;
import mineplex.core.common.util.UtilPlayer;
import mineplex.core.common.util.UtilText;
import mineplex.core.common.util.UtilTextMiddle;
import mineplex.core.donation.DonationManager;
import mineplex.core.gadget.GadgetManager;
import mineplex.core.reward.RewardPool;
import mineplex.core.gadget.event.GadgetBlockEvent;
import mineplex.core.hologram.Hologram;
import mineplex.core.hologram.HologramInteraction;
import mineplex.core.hologram.HologramManager;
import mineplex.core.inventory.InventoryManager;
import mineplex.core.reward.Reward;
import mineplex.core.status.ServerStatusManager;
import mineplex.core.treasure.event.TreasureFinishEvent;
import mineplex.core.treasure.event.TreasureStartEvent;
import mineplex.core.treasure.gui.TreasureShop;
import mineplex.core.updater.UpdateType;
import mineplex.core.updater.event.UpdateEvent;
import org.bukkit.Bukkit;
import org.bukkit.Location;
import org.bukkit.Material;
@ -21,28 +40,7 @@ import org.bukkit.event.player.PlayerMoveEvent;
import org.bukkit.event.player.PlayerQuitEvent;
import org.bukkit.event.player.PlayerVelocityEvent;
import mineplex.core.account.CoreClientManager;
import mineplex.core.common.util.C;
import mineplex.core.common.util.Callback;
import mineplex.core.common.util.F;
import mineplex.core.common.util.UtilAction;
import mineplex.core.common.util.UtilAlg;
import mineplex.core.common.util.UtilPlayer;
import mineplex.core.common.util.UtilText;
import mineplex.core.common.util.UtilTextMiddle;
import mineplex.core.donation.DonationManager;
import mineplex.core.gadget.event.GadgetBlockEvent;
import mineplex.core.hologram.Hologram;
import mineplex.core.hologram.HologramInteraction;
import mineplex.core.hologram.HologramManager;
import mineplex.core.inventory.InventoryManager;
import mineplex.core.reward.Reward;
import mineplex.core.status.ServerStatusManager;
import mineplex.core.treasure.event.TreasureFinishEvent;
import mineplex.core.treasure.event.TreasureStartEvent;
import mineplex.core.treasure.gui.TreasureShop;
import mineplex.core.updater.UpdateType;
import mineplex.core.updater.event.UpdateEvent;
import java.util.List;
public class TreasureLocation implements Listener
{
@ -69,8 +67,7 @@ public class TreasureLocation implements Listener
_hologramManager = hologramManager;
_statusManager = statusManager;
_currentTreasure = null;
_hologram = new Hologram(_hologramManager, chestBlock.getLocation().add(0.5, 2.5, 0.5), C.cGreen + C.Bold
+ "Open Treasure");
_hologram = new Hologram(_hologramManager, chestBlock.getLocation().add(0.5, 1.5, 0.5), C.cGreen + C.Bold + "Open Treasure");
_hologram.setInteraction(new HologramInteraction()
{
@ -401,4 +398,18 @@ public class TreasureLocation implements Listener
{
_shop.attemptShopOpen(player);
}
@Override
public String toString()
{
StringBuilder builder = new StringBuilder();
builder.append("TesureLoc: ").append(_chestBlock.getX()).append(" : ").append(_chestBlock.getY()).append(" : ").append(_chestBlock.getZ());
builder.append("BlockLocs: [");
for(Block block : _chestSpawns)
{
builder.append("BlockLoc: ").append(block.getX()).append(" : ").append(block.getY()).append(" : ").append(block.getZ()).append(",\n");
}
builder.append("]");
return builder.toString();
}
}

View File

@ -1,10 +1,20 @@
package mineplex.core.treasure;
import java.util.ArrayList;
import java.util.List;
import com.google.common.collect.Lists;
import mineplex.core.MiniPlugin;
import mineplex.core.account.CoreClientManager;
import mineplex.core.blockrestore.BlockRestore;
import mineplex.core.donation.DonationManager;
import mineplex.core.gadget.GadgetManager;
import mineplex.core.hologram.HologramManager;
import mineplex.core.inventory.InventoryManager;
import mineplex.core.pet.PetManager;
import mineplex.core.reward.Reward;
import mineplex.core.reward.RewardManager;
import mineplex.core.reward.RewardPool;
import mineplex.core.reward.RewardType;
import mineplex.core.stats.StatsManager;
import mineplex.core.status.ServerStatusManager;
import org.bukkit.Bukkit;
import org.bukkit.Location;
import org.bukkit.World;
@ -13,20 +23,8 @@ import org.bukkit.entity.Player;
import org.bukkit.event.HandlerList;
import org.bukkit.plugin.java.JavaPlugin;
import mineplex.core.MiniPlugin;
import mineplex.core.account.CoreClientManager;
import mineplex.core.blockrestore.BlockRestore;
import mineplex.core.donation.DonationManager;
import mineplex.core.hologram.HologramManager;
import mineplex.core.inventory.InventoryManager;
import mineplex.core.pet.PetManager;
import mineplex.core.reward.Reward;
import mineplex.core.reward.RewardManager;
import mineplex.core.reward.RewardPool;
import mineplex.core.reward.RewardRarity;
import mineplex.core.reward.RewardType;
import mineplex.core.stats.StatsManager;
import mineplex.core.status.ServerStatusManager;
import java.util.ArrayList;
import java.util.List;
/**
* Created by Shaun on 8/27/2014.
@ -54,61 +52,33 @@ public class TreasureManager extends MiniPlugin
World world = Bukkit.getWorlds().get(0);
_treasureLocations = new ArrayList<TreasureLocation>();
_treasureLocations = new ArrayList<>();
{
Block chestBlock = world.getBlockAt(-19, 72, -19);
Block chestLoc1 = world.getBlockAt(-16, 72, -20);
Block chestLoc2 = world.getBlockAt(-18, 72, -22);
Block chestLoc3 = world.getBlockAt(-20, 72, -22);
Block chestLoc4 = world.getBlockAt(-22, 72, -20);
Block chestLoc5 = world.getBlockAt(-22, 72, -18);
Block chestLoc6 = world.getBlockAt(-20, 72, -16);
Block chestLoc7 = world.getBlockAt(-18, 72, -16);
Block chestLoc8 = world.getBlockAt(-16, 72, -18);
Location resetLocation = new Location(world, -23.5, 72, -23.5);
_treasureLocations.add(new TreasureLocation(this, _inventoryManager, clientManager, donationManager, chestBlock, new Block[]{chestLoc1, chestLoc2, chestLoc3, chestLoc4, chestLoc5, chestLoc6, chestLoc7, chestLoc8}, resetLocation, _hologramManager, gadgetManager, statusManager));
Block chestBlock = world.getBlockAt(-31, 73, -11);
Block[] blocks = setup(chestBlock);
Location resetLocation = new Location(world, -26.5, 72, -11.5);
_treasureLocations.add(new TreasureLocation(this, _inventoryManager, clientManager, donationManager, chestBlock, blocks, resetLocation, _hologramManager, gadgetManager, statusManager));
}
{
Block chestBlock = world.getBlockAt(19, 72, 19);
Block chestLoc1 = world.getBlockAt(16, 72, 20);
Block chestLoc2 = world.getBlockAt(18, 72, 22);
Block chestLoc3 = world.getBlockAt(20, 72, 22);
Block chestLoc4 = world.getBlockAt(22, 72, 20);
Block chestLoc5 = world.getBlockAt(22, 72, 18);
Block chestLoc6 = world.getBlockAt(20, 72, 16);
Block chestLoc7 = world.getBlockAt(18, 72, 16);
Block chestLoc8 = world.getBlockAt(16, 72, 18);
Location resetLocation = new Location(world, 23.5, 72, 23.5);
_treasureLocations.add(new TreasureLocation(this, _inventoryManager, clientManager, donationManager, chestBlock, new Block[]{chestLoc1, chestLoc2, chestLoc3, chestLoc4, chestLoc5, chestLoc6, chestLoc7, chestLoc8}, resetLocation, _hologramManager, gadgetManager, statusManager));
Block chestBlock = world.getBlockAt(-22, 73, -34);
Block[] blocks = setup(chestBlock);
Location resetLocation = new Location(world, -22.5, 72, -29.5);
_treasureLocations.add(new TreasureLocation(this, _inventoryManager, clientManager, donationManager, chestBlock, blocks, resetLocation, _hologramManager, gadgetManager, statusManager));
}
{
Block chestBlock = world.getBlockAt(19, 72, -19);
Block chestLoc1 = world.getBlockAt(16, 72, -20);
Block chestLoc2 = world.getBlockAt(18, 72, -22);
Block chestLoc3 = world.getBlockAt(20, 72, -22);
Block chestLoc4 = world.getBlockAt(22, 72, -20);
Block chestLoc5 = world.getBlockAt(22, 72, -18);
Block chestLoc6 = world.getBlockAt(20, 72, -16);
Block chestLoc7 = world.getBlockAt(18, 72, -16);
Block chestLoc8 = world.getBlockAt(16, 72, -18);
Location resetLocation = new Location(world, 23.5, 72, -23.5);
_treasureLocations.add(new TreasureLocation(this, _inventoryManager, clientManager, donationManager, chestBlock, new Block[]{chestLoc1, chestLoc2, chestLoc3, chestLoc4, chestLoc5, chestLoc6, chestLoc7, chestLoc8}, resetLocation, _hologramManager, gadgetManager, statusManager));
Block chestBlock = world.getBlockAt(22, 75, -34);
Block[] blocks = setup(chestBlock);
Location resetLocation = new Location(world, 19.5, 74, -30.5);
_treasureLocations.add(new TreasureLocation(this, _inventoryManager, clientManager, donationManager, chestBlock, blocks, resetLocation, _hologramManager, gadgetManager, statusManager));
}
{
Block chestBlock = world.getBlockAt(-19, 72, 19);
Block chestLoc1 = world.getBlockAt(-16, 72, 20);
Block chestLoc2 = world.getBlockAt(-18, 72, 22);
Block chestLoc3 = world.getBlockAt(-20, 72, 22);
Block chestLoc4 = world.getBlockAt(-22, 72, 20);
Block chestLoc5 = world.getBlockAt(-22, 72, 18);
Block chestLoc6 = world.getBlockAt(-20, 72, 16);
Block chestLoc7 = world.getBlockAt(-18, 72, 16);
Block chestLoc8 = world.getBlockAt(-16, 72, 18);
Location resetLocation = new Location(world, -23.5, 72, 23.5);
_treasureLocations.add(new TreasureLocation(this, _inventoryManager, clientManager, donationManager, chestBlock, new Block[]{chestLoc1, chestLoc2, chestLoc3, chestLoc4, chestLoc5, chestLoc6, chestLoc7, chestLoc8}, resetLocation, _hologramManager, gadgetManager, statusManager));
Block chestBlock = world.getBlockAt(31, 74, -11);
Block[] blocks = setup(chestBlock);
Location resetLocation = new Location(world, 27.5, 73, -15.5);
_treasureLocations.add(new TreasureLocation(this, _inventoryManager, clientManager, donationManager, chestBlock, blocks, resetLocation, _hologramManager, gadgetManager, statusManager));
}
for (TreasureLocation treasureLocation : _treasureLocations)
@ -117,6 +87,25 @@ public class TreasureManager extends MiniPlugin
}
}
private Block[] setup(Block chestBlock)
{
List<Location> locations = Lists.newArrayList(new Location(chestBlock.getWorld(), chestBlock.getX() + 3, chestBlock.getY(), chestBlock.getZ() - 1),
new Location(chestBlock.getWorld(), chestBlock.getX() + 3, chestBlock.getY(), chestBlock.getZ() + 1),
new Location(chestBlock.getWorld(), chestBlock.getX() - 3, chestBlock.getY(), chestBlock.getZ() - 1),
new Location(chestBlock.getWorld(), chestBlock.getX() - 3, chestBlock.getY(), chestBlock.getZ() + 1),
new Location(chestBlock.getWorld(), chestBlock.getX() - 1, chestBlock.getY(), chestBlock.getZ() + 3),
new Location(chestBlock.getWorld(), chestBlock.getX() + 1, chestBlock.getY(), chestBlock.getZ() - 3),
new Location(chestBlock.getWorld(), chestBlock.getX() + 1, chestBlock.getY(), chestBlock.getZ() + 3),
new Location(chestBlock.getWorld(), chestBlock.getX() - 1, chestBlock.getY(), chestBlock.getZ() - 3));
Block[] blocks = new Block[locations.size()];
for (int i = 0; i < blocks.length; i++)
{
blocks[i] = locations.get(i).getBlock();
}
return blocks;
}
@Override
public void disable()
{
@ -132,7 +121,7 @@ public class TreasureManager extends MiniPlugin
{
_statsManager.incrementStat(player, "Global.Treasure." + treasureType.getStatName(), 1);
}
public void addTreasureLocation(TreasureLocation loc)
{
_treasureLocations.add(loc);
@ -143,7 +132,7 @@ public class TreasureManager extends MiniPlugin
{
return _rewardManager.getRewards(player, pool, rewardType);
}
public boolean hasItemsToGivePlayer(RewardPool.Type pool, Player player)
{
return _rewardManager.hasItemsToGivePlayer(pool, player);
@ -156,10 +145,14 @@ public class TreasureManager extends MiniPlugin
Treasure treasure = treasureLocation.getCurrentTreasure();
if (treasure == null)
{
continue;
}
if (treasure.getPlayer().equals(player))
{
return true;
}
}
return false;

View File

@ -1,28 +1,20 @@
package mineplex.game.clans;
import mineplex.core.Managers;
import mineplex.core.antihack.AntiHackGuardian;
import mineplex.core.creature.Creature;
import mineplex.core.disguise.DisguiseManager;
import org.bukkit.Bukkit;
import org.bukkit.Location;
import org.bukkit.Material;
import org.bukkit.World;
import org.bukkit.craftbukkit.v1_8_R3.CraftWorld;
import org.bukkit.plugin.java.JavaPlugin;
import mineplex.core.CustomTagFix;
import mineplex.core.FoodDupeFix;
import mineplex.core.account.CoreClientManager;
import mineplex.core.achievement.AchievementManager;
import mineplex.core.antihack.AntiHack;
import mineplex.core.antihack.AntiHackGuardian;
import mineplex.core.blockrestore.BlockRestore;
import mineplex.core.chat.Chat;
import mineplex.core.command.CommandCenter;
import mineplex.core.common.MinecraftVersion;
import mineplex.core.common.Pair;
import mineplex.core.common.events.ServerShutdownEvent;
import mineplex.core.creature.Creature;
import mineplex.core.delayedtask.DelayedTask;
import mineplex.core.disguise.DisguiseManager;
import mineplex.core.donation.DonationManager;
import mineplex.core.elo.EloManager;
import mineplex.core.explosion.Explosion;
@ -61,6 +53,12 @@ import mineplex.game.clans.shop.pvp.PvpShop;
import mineplex.game.clans.spawn.travel.TravelShop;
import mineplex.game.clans.world.WorldManager;
import net.minecraft.server.v1_8_R3.MinecraftServer;
import org.bukkit.Bukkit;
import org.bukkit.Location;
import org.bukkit.Material;
import org.bukkit.World;
import org.bukkit.craftbukkit.v1_8_R3.CraftWorld;
import org.bukkit.plugin.java.JavaPlugin;
import static mineplex.core.Managers.require;
@ -77,6 +75,8 @@ public class Clans extends JavaPlugin
@Override
public void onEnable()
{
Bukkit.setSpawnRadius(0);
// Configs
getConfig().addDefault(WEB_CONFIG, "http://accounts.mineplex.com/");
getConfig().set(WEB_CONFIG, getConfig().getString(WEB_CONFIG));
@ -107,7 +107,7 @@ public class Clans extends JavaPlugin
PacketHandler packetHandler = require(PacketHandler.class);
IncognitoManager incognito = new IncognitoManager(this, _clientManager, packetHandler);
PreferencesManager preferenceManager = new PreferencesManager(this, incognito, _clientManager, _donationManager);
PreferencesManager preferenceManager = new PreferencesManager(this, incognito, _clientManager);
incognito.setPreferencesManager(preferenceManager);
@ -130,7 +130,7 @@ public class Clans extends JavaPlugin
AntiHack antiHack = require(AntiHack.class);
antiHack.setKick(false);
antiHack.enableNewAnticheat();
Bukkit.getScheduler().runTask(this, antiHack::enableNewAnticheat);
{
// West Shop

Some files were not shown because too many files have changed in this diff Show More