Merge remote-tracking branch 'refs/remotes/origin/develop' into update/ssm

This commit is contained in:
Sam 2017-05-04 20:20:59 +01:00
commit f6cb654e12
44 changed files with 1070 additions and 398 deletions

View File

@ -18,7 +18,7 @@ public enum Rank
JNR_DEV("Jr.Dev", "jrdev", ChatColor.GOLD, "Junior Developers work behind the scenes to \ncreate new games and features, and fix bugs to \ngive the best experience.", -1, DyeColor.ORANGE), JNR_DEV("Jr.Dev", "jrdev", ChatColor.GOLD, "Junior Developers work behind the scenes to \ncreate new games and features, and fix bugs to \ngive the best experience.", -1, DyeColor.ORANGE),
SUPPORT("Support", "spp", ChatColor.BLUE, "Support agents handle tickets and \nprovide customer service.", 47, DyeColor.BLUE), SUPPORT("Support", "spp", ChatColor.BLUE, "Support agents handle tickets and \nprovide customer service.", 47, DyeColor.BLUE),
CMOD("C.Mod", "cmod", ChatColor.GOLD, "Clans Moderators are members of the Clans Management Senior Mod team. \nTheir duties include moderation and support within the Clans servers. \n\nFor assistance, contact them using " + F.elem("/a <message>") + ".", 32, DyeColor.ORANGE), CMOD("C.Mod", "cmod", ChatColor.GOLD, "Clans Moderators are members of the Clans Management Senior Mod team. \nTheir duties include moderation and support within the Clans servers. \n\nFor assistance, contact them using " + F.elem("/a <message>") + ".", 32, DyeColor.ORANGE),
EVENT_MODERATOR("Sr.Mod", "eventmod", ChatColor.GOLD, "Senior Moderators are members of a special \nSenior Moderator team where they have to fulfill specific tasks. \nJust like Moderators, you can always ask them for help. \n\nFor assistance, contact them using " + F.elem("/a <message>") + ".", 44, DyeColor.ORANGE), EVENT_MODERATOR("Sr.Mod", "srmod_event", ChatColor.GOLD, "Senior Moderators are members of a special \nSenior Moderator team where they have to fulfill specific tasks. \nJust like Moderators, you can always ask them for help. \n\nFor assistance, contact them using " + F.elem("/a <message>") + ".", 44, DyeColor.ORANGE),
SNR_MODERATOR("Sr.Mod", "srmod", ChatColor.GOLD, "Senior Moderators are members of a special \nSenior Moderator team where they have to fulfill specific tasks. \nJust like Moderators, you can always ask them for help. \n\nFor assistance, contact them using " + F.elem("/a <message>") + ".", 44, DyeColor.ORANGE), SNR_MODERATOR("Sr.Mod", "srmod", ChatColor.GOLD, "Senior Moderators are members of a special \nSenior Moderator team where they have to fulfill specific tasks. \nJust like Moderators, you can always ask them for help. \n\nFor assistance, contact them using " + F.elem("/a <message>") + ".", 44, DyeColor.ORANGE),
MODERATOR("Mod", "mod", ChatColor.GOLD, "Moderators enforce rules and provide help to \nanyone with questions or concerns. \n\nFor assistance, contact them using " + F.elem("/a <message>") + ".", 32, DyeColor.ORANGE), MODERATOR("Mod", "mod", ChatColor.GOLD, "Moderators enforce rules and provide help to \nanyone with questions or concerns. \n\nFor assistance, contact them using " + F.elem("/a <message>") + ".", 32, DyeColor.ORANGE),
HELPER("Trainee", "train", ChatColor.GOLD, "Trainees are moderators-in-training. \nTheir duties include enforcing the rules and \nproviding help to anyone with questions or concerns. \n\nFor assistance, contact them using " + F.elem("/a <message>") + ".", 24, DyeColor.ORANGE), HELPER("Trainee", "train", ChatColor.GOLD, "Trainees are moderators-in-training. \nTheir duties include enforcing the rules and \nproviding help to anyone with questions or concerns. \n\nFor assistance, contact them using " + F.elem("/a <message>") + ".", 24, DyeColor.ORANGE),

View File

@ -36,6 +36,7 @@ import mineplex.core.gadget.gadgets.particle.king.types.Peasant;
import mineplex.core.hologram.Hologram; import mineplex.core.hologram.Hologram;
import mineplex.core.hologram.HologramManager; import mineplex.core.hologram.HologramManager;
import mineplex.core.mount.event.MountActivateEvent; import mineplex.core.mount.event.MountActivateEvent;
import mineplex.core.pet.event.PetSpawnEvent;
import mineplex.core.updater.UpdateType; import mineplex.core.updater.UpdateType;
import mineplex.core.updater.event.UpdateEvent; import mineplex.core.updater.event.UpdateEvent;
@ -668,6 +669,10 @@ public class CastleManager extends MiniPlugin
} }
} }
/**
* Stops players from using mounts inside the castle
* @param event
*/
@EventHandler @EventHandler
public void onMount(MountActivateEvent event) public void onMount(MountActivateEvent event)
{ {
@ -677,4 +682,14 @@ public class CastleManager extends MiniPlugin
if (isInsideCastle(event.getPlayer().getLocation())) if (isInsideCastle(event.getPlayer().getLocation()))
event.setCancelled(true); event.setCancelled(true);
} }
@EventHandler
public void onPetSpawn(PetSpawnEvent event)
{
if (!isHub())
return;
if (isInsideCastle(event.getLocation()))
event.setCancelled(true);
}
} }

View File

@ -70,9 +70,9 @@ import mineplex.core.disguise.disguises.DisguiseVillager;
import mineplex.core.disguise.disguises.DisguiseWither; import mineplex.core.disguise.disguises.DisguiseWither;
import mineplex.core.disguise.disguises.DisguiseZombie; import mineplex.core.disguise.disguises.DisguiseZombie;
import mineplex.core.donation.DonationManager; import mineplex.core.donation.DonationManager;
import mineplex.core.gadget.gadgets.particle.king.CastleManager;
import mineplex.core.inventory.InventoryManager; import mineplex.core.inventory.InventoryManager;
import mineplex.core.itemstack.ItemStackFactory; import mineplex.core.itemstack.ItemStackFactory;
import mineplex.core.pet.event.PetSpawnEvent;
import mineplex.core.pet.repository.PetRepository; import mineplex.core.pet.repository.PetRepository;
import mineplex.core.pet.repository.token.ClientPetTokenWrapper; import mineplex.core.pet.repository.token.ClientPetTokenWrapper;
import mineplex.core.updater.UpdateType; import mineplex.core.updater.UpdateType;
@ -97,7 +97,6 @@ public class PetManager extends MiniClientPlugin<PetClient>
private DonationManager _donationManager; private DonationManager _donationManager;
private CoreClientManager _clientManager; private CoreClientManager _clientManager;
private InventoryManager _inventoryManager; private InventoryManager _inventoryManager;
private CastleManager _castleManager;
private Map<Entity, FlyingPetManager> _flyingPets = new HashMap<>(); private Map<Entity, FlyingPetManager> _flyingPets = new HashMap<>();
private Map<Entity, TrueLoveData> _trueLovePets = new HashMap<>(); private Map<Entity, TrueLoveData> _trueLovePets = new HashMap<>();
@ -110,8 +109,7 @@ public class PetManager extends MiniClientPlugin<PetClient>
private ShapeWings _cupidWingsEdge = new ShapeWings(UtilParticle.ParticleType.RED_DUST.particleName, new Vector(0, 0, 0), 1, 0, true, ShapeWings.DEFAULT_ROTATION, ShapeWings.SMALL_HEART_WING_PATTERN); private ShapeWings _cupidWingsEdge = new ShapeWings(UtilParticle.ParticleType.RED_DUST.particleName, new Vector(0, 0, 0), 1, 0, true, ShapeWings.DEFAULT_ROTATION, ShapeWings.SMALL_HEART_WING_PATTERN);
public PetManager(JavaPlugin plugin, CoreClientManager clientManager, DonationManager donationManager public PetManager(JavaPlugin plugin, CoreClientManager clientManager, DonationManager donationManager
, InventoryManager inventoryManager, DisguiseManager disguiseManager, mineplex.core.creature.Creature creatureModule, BlockRestore restore, , InventoryManager inventoryManager, DisguiseManager disguiseManager, mineplex.core.creature.Creature creatureModule, BlockRestore restore)
CastleManager castleManager)
{ {
super("Pet Manager", plugin); super("Pet Manager", plugin);
@ -216,11 +214,11 @@ public class PetManager extends MiniClientPlugin<PetClient>
return; return;
} }
if (_castleManager.isInsideCastle(location)) PetSpawnEvent petSpawnEvent = new PetSpawnEvent(player, petType.getEntityType(), location);
{ Bukkit.getPluginManager().callEvent(petSpawnEvent);
UtilPlayer.message(player, F.main("Pets", "You cannot spawn a pet inside the castle!"));
if (petSpawnEvent.isCancelled())
return; return;
}
Entity pet; Entity pet;
EntityType entityType = petType.getEntityType(); EntityType entityType = petType.getEntityType();

View File

@ -23,17 +23,17 @@ public class PetSpawnEvent extends Event implements Cancellable
_location = location; _location = location;
} }
public Player GetPlayer() public Player getPlayer()
{ {
return _player; return _player;
} }
public EntityType GetEntityType() public EntityType getEntityType()
{ {
return _entityType; return _entityType;
} }
public Location GetLocation() public Location getLocation()
{ {
return _location; return _location;
} }

View File

@ -5,6 +5,7 @@ import java.util.Iterator;
import org.bukkit.Bukkit; import org.bukkit.Bukkit;
import org.bukkit.Sound; import org.bukkit.Sound;
import org.bukkit.craftbukkit.v1_8_R3.entity.CraftPlayer;
import org.bukkit.entity.LivingEntity; import org.bukkit.entity.LivingEntity;
import org.bukkit.entity.Player; import org.bukkit.entity.Player;
import org.bukkit.event.EventHandler; import org.bukkit.event.EventHandler;
@ -76,6 +77,8 @@ public class TextTutorialManager extends MiniPlugin
other.hidePlayer(event.getPlayer()); other.hidePlayer(event.getPlayer());
} }
((CraftPlayer) event.getPlayer()).getHandle().spectating = true;
return; return;
} }
} }
@ -117,6 +120,8 @@ public class TextTutorialManager extends MiniPlugin
other.showPlayer(player); other.showPlayer(player);
} }
((CraftPlayer) player).getHandle().spectating = false;
//Gems //Gems
if (tut.getGemReward() > 0) if (tut.getGemReward() > 0)
{ {

View File

@ -123,7 +123,7 @@ public class ClansHub extends JavaPlugin
InventoryManager inventoryManager = new InventoryManager(this, clientManager); InventoryManager inventoryManager = new InventoryManager(this, clientManager);
HologramManager hologramManager = new HologramManager(this, packetHandler); HologramManager hologramManager = new HologramManager(this, packetHandler);
CastleManager castleManager = new CastleManager(this, clientManager, hologramManager, false); CastleManager castleManager = new CastleManager(this, clientManager, hologramManager, false);
PetManager petManager = new PetManager(this, clientManager, donationManager, inventoryManager, disguiseManager, creature, blockRestore, castleManager); PetManager petManager = new PetManager(this, clientManager, donationManager, inventoryManager, disguiseManager, creature, blockRestore);
PollManager pollManager = new PollManager(this, clientManager, donationManager); PollManager pollManager = new PollManager(this, clientManager, donationManager);
//Main Modules //Main Modules

View File

@ -147,7 +147,7 @@ public class Hub extends JavaPlugin implements IRelation
_npcManager = npcManager; _npcManager = npcManager;
InventoryManager inventoryManager = new InventoryManager(this, clientManager); InventoryManager inventoryManager = new InventoryManager(this, clientManager);
CastleManager castleManager = new CastleManager(this, clientManager, hologramManager, true); CastleManager castleManager = new CastleManager(this, clientManager, hologramManager, true);
PetManager petManager = new PetManager(this, clientManager, donationManager, inventoryManager, disguiseManager, creature, blockRestore, castleManager); PetManager petManager = new PetManager(this, clientManager, donationManager, inventoryManager, disguiseManager, creature, blockRestore);
PollManager pollManager = new PollManager(this, clientManager, donationManager); PollManager pollManager = new PollManager(this, clientManager, donationManager);
//new TournamentManager(this, clientManager, donationManager); //new TournamentManager(this, clientManager, donationManager);

View File

@ -130,6 +130,7 @@ import mineplex.hub.modules.MavericksManager;
import mineplex.hub.modules.NewsManager; import mineplex.hub.modules.NewsManager;
import mineplex.hub.modules.ParkourManager; import mineplex.hub.modules.ParkourManager;
import mineplex.hub.modules.SoccerManager; import mineplex.hub.modules.SoccerManager;
import mineplex.hub.modules.TemporaryGemHuntersServerSender;
import mineplex.hub.modules.ValentinesManager; import mineplex.hub.modules.ValentinesManager;
import mineplex.hub.modules.WorldManager; import mineplex.hub.modules.WorldManager;
import mineplex.hub.modules.salesannouncements.SalesAnnouncementManager; import mineplex.hub.modules.salesannouncements.SalesAnnouncementManager;
@ -291,6 +292,8 @@ public class HubManager extends MiniClientPlugin<HubClient> implements IChatMess
new EasterEggHunt(plugin, _clientManager); new EasterEggHunt(plugin, _clientManager);
new TemporaryGemHuntersServerSender(_portal);
ScoreboardManager scoreboardManager = new ScoreboardManager(plugin) ScoreboardManager scoreboardManager = new ScoreboardManager(plugin)
{ {
@Override @Override

View File

@ -42,7 +42,13 @@ public class ForcefieldManager extends MiniPlugin
for (Player player : UtilServer.getPlayers()) for (Player player : UtilServer.getPlayers())
{ {
if (Manager.getPreferences().get(player).isActive(Preference.FORCE_FIELD) && (Manager.GetClients().Get(player).GetRank().has(Rank.ADMIN) || Manager.GetClients().Get(player).GetRank() == Rank.JNR_DEV || Manager.GetClients().Get(player).GetRank() == Rank.YOUTUBE || Manager.GetClients().Get(player).GetRank() == Rank.TWITCH || Manager.GetClients().Get(player).GetRank() == Rank.YOUTUBE_SMALL)) if (Manager.getPreferences().get(player).isActive(Preference.FORCE_FIELD) &&
(Manager.GetClients().Get(player).GetRank().has(Rank.ADMIN) ||
Manager.GetClients().Get(player).GetRank() == Rank.JNR_DEV ||
Manager.GetClients().Get(player).GetRank() == Rank.EVENT_MODERATOR ||
Manager.GetClients().Get(player).GetRank() == Rank.YOUTUBE ||
Manager.GetClients().Get(player).GetRank() == Rank.TWITCH ||
Manager.GetClients().Get(player).GetRank() == Rank.YOUTUBE_SMALL))
{ {
for (Player other : UtilServer.getPlayers()) for (Player other : UtilServer.getPlayers())
{ {
@ -56,7 +62,9 @@ public class ForcefieldManager extends MiniPlugin
if (UtilMath.offset(other, player) > range) if (UtilMath.offset(other, player) > range)
continue; continue;
if (Manager.GetClients().Get(other).GetRank().has(Rank.ADMIN) || Manager.GetClients().Get(other).GetRank() == Rank.JNR_DEV) if (Manager.GetClients().Get(other).GetRank().has(Rank.ADMIN) ||
Manager.GetClients().Get(other).GetRank() == Rank.JNR_DEV ||
Manager.GetClients().Get(other).GetRank() == Rank.EVENT_MODERATOR)
continue; continue;
if (Recharge.Instance.use(other, "Forcefield Bump", 500, false, false)) if (Recharge.Instance.use(other, "Forcefield Bump", 500, false, false))

View File

@ -0,0 +1,94 @@
package mineplex.hub.modules;
import java.util.Comparator;
import java.util.Map;
import java.util.concurrent.ConcurrentHashMap;
import org.bukkit.ChatColor;
import org.bukkit.event.EventHandler;
import mineplex.core.MiniPlugin;
import mineplex.core.common.util.UtilTime;
import mineplex.core.npc.event.NpcInteractEntityEvent;
import mineplex.core.portal.Intent;
import mineplex.core.portal.Portal;
import mineplex.core.updater.UpdateType;
import mineplex.core.updater.event.UpdateEvent;
import mineplex.hub.server.ServerInfo;
import mineplex.serverdata.Region;
import mineplex.serverdata.data.MinecraftServer;
import mineplex.serverdata.servers.ServerManager;
// A hacky mess. Did not have time before release to solve this properly. soon.
// Essentially a copy/paste from the clans hub server load/send mechanism
public class TemporaryGemHuntersServerSender extends MiniPlugin
{
private static final int SERVER_RELOAD_INTERVAL = 5000;
private final Portal _portal;
private final Map<MinecraftServer,ServerInfo> _servers = new ConcurrentHashMap<>();
private long _lastLoaded = 0;
private boolean _loading;
public TemporaryGemHuntersServerSender(Portal portal)
{
super("Gem Hunters Server Sender");
_portal = portal;
}
@EventHandler
public void reloadServers(UpdateEvent event)
{
if (event.getType() != UpdateType.SEC || _loading || !UtilTime.elapsed(_lastLoaded, SERVER_RELOAD_INTERVAL))
{
return;
}
_loading = true;
runAsync(() ->
{
reload();
runSync(() ->
{
_lastLoaded = System.currentTimeMillis();
_loading = false;
});
});
}
public void reload()
{
_servers.clear();
Region region = getPlugin().getConfig().getBoolean("serverstatus.us") ? Region.US : Region.EU;
for (MinecraftServer server : ServerManager.getServerRepository(region).getServerStatusesByPrefix("GH-"))
{
ServerInfo info = new ServerInfo();
info.Name = server.getName();
info.MOTD = server.getMotd();
info.CurrentPlayers = server.getPlayerCount();
info.MaxPlayers = server.getMaxPlayerCount();
_servers.put(server, info);
}
}
@EventHandler
public void onUseNPC(NpcInteractEntityEvent event)
{
if (event.getNpc().getName().contains("Gem Hunters"))
{
java.util.Optional<ServerInfo> info = _servers.entrySet().stream()
// Ignore the type noise here; it's temporary
.sorted(Comparator.<Map.Entry<MinecraftServer,ServerInfo>>comparingInt(entry -> entry.getKey().getPlayerCount()).<Map.Entry<MinecraftServer,ServerInfo>>reversed())
.filter(entry -> entry.getKey().getPlayerCount() < entry.getKey().getMaxPlayerCount() - 5)
.map(Map.Entry::getValue)
.findFirst();
if (info.isPresent())
{
_portal.sendPlayerToServer(event.getPlayer(), info.get().Name, Intent.PLAYER_REQUEST);
}
else
{
event.getPlayer().sendMessage(ChatColor.RED + "All servers are full; please try again in a moment!");
}
}
}
}

View File

@ -120,7 +120,7 @@ public class ServerGameMenu extends ShopPageBase<ServerManager, QuickShop>
C.Reset + "Extremely hard team-based survival ", C.Reset + "Extremely hard team-based survival ",
C.Reset + "Gather materials and fight your way", C.Reset + "Gather materials and fight your way",
C.Reset + "to become the last team standing!", C.Reset + "to become the last team standing!",
}, new String[] {"UHC", "UHC2", "UHCS", "UHCS2"}, "UHC", new SelectUHCButton(this)); }, new String[] {"UHC", "UHC2"}, "UHC", new SelectUHCButton(this));
add(17, Material.BLAZE_ROD, C.cYellowB + "Wizards " + C.cGray + "Last Man Standing", new String[] add(17, Material.BLAZE_ROD, C.cYellowB + "Wizards " + C.cGray + "Last Man Standing", new String[]
{ {

View File

@ -24,38 +24,22 @@ public class UHCServerTypePage extends ShopPageBase<ServerManager, ServerNpcShop
@Override @Override
protected void buildPage() protected void buildPage()
{ {
setItem(10, new ItemBuilder(Material.SKULL_ITEM, 1, (byte) 3).setTitle(C.Reset + C.cYellow + "UHC Solo") setItem(12, new ItemBuilder(Material.SKULL_ITEM, 1, (byte) 3).setTitle(C.Reset + C.cYellow + "UHC Solo")
.addLore(new String[] .addLore(new String[]
{ {
C.Reset + "", C.Reset + "",
C.Reset + C.cGreen + "Click to Play", C.Reset + C.cGreen + "Click to Play",
}).build()); }).build());
setItem(12, new ItemBuilder(Material.SKULL_ITEM, 2, (byte) 3).setTitle(C.Reset + C.cYellow + "UHC Teams") setItem(14, new ItemBuilder(Material.SKULL_ITEM, 2, (byte) 3).setTitle(C.Reset + C.cYellow + "UHC Teams")
.addLore(new String[] .addLore(new String[]
{ {
C.Reset + "", C.Reset + "",
C.Reset + C.cGreen + "Click to Play", C.Reset + C.cGreen + "Click to Play",
}).build()); }).build());
setItem(14, new ItemBuilder(Material.SKULL_ITEM, 1, (byte) 3).setTitle(C.Reset + C.cYellow + "UHC Speed Solo") getButtonMap().put(12, (player, __) -> getShop().openPageForPlayer(player, new ServerNpcPage(getPlugin(), getShop(), getClientManager(), getDonationManager(), "UHC Solo", player, "UHC2")));
.addLore(new String[] getButtonMap().put(14, (player, __) -> getShop().openPageForPlayer(player, new ServerNpcPage(getPlugin(), getShop(), getClientManager(), getDonationManager(), "UHC", player, "UHC")));
{
C.Reset + "",
C.Reset + C.cGreen + "Click to Play"
}).build());
setItem(16, new ItemBuilder(Material.SKULL_ITEM, 2, (byte) 3).setTitle(C.Reset + C.cYellow + "UHC Speed Teams")
.addLore(new String[]
{
C.Reset + "",
C.Reset + C.cGreen + "Click to Play"
}).build());
getButtonMap().put(10, (player, __) -> getShop().openPageForPlayer(player, new ServerNpcPage(getPlugin(), getShop(), getClientManager(), getDonationManager(), "UHC Solo", player, "UHC2")));
getButtonMap().put(12, (player, __) -> getShop().openPageForPlayer(player, new ServerNpcPage(getPlugin(), getShop(), getClientManager(), getDonationManager(), "UHC", player, "UHC")));
getButtonMap().put(14, (player, __) -> getShop().openPageForPlayer(player, new ServerNpcPage(getPlugin(), getShop(), getClientManager(), getDonationManager(), "UHC Speed Solo", player, "UHCS2")));
getButtonMap().put(16, (player, __) -> getShop().openPageForPlayer(player, new ServerNpcPage(getPlugin(), getShop(), getClientManager(), getDonationManager(), "UHC Speed", player, "UHCS")));
} }
public void Update() public void Update()

View File

@ -202,7 +202,7 @@ public class Arcade extends JavaPlugin
//Inventory //Inventory
InventoryManager inventoryManager = new InventoryManager(this, _clientManager); InventoryManager inventoryManager = new InventoryManager(this, _clientManager);
CastleManager castleManager = new CastleManager(this, _clientManager, hologramManager, false); CastleManager castleManager = new CastleManager(this, _clientManager, hologramManager, false);
PetManager petManager = new PetManager(this, _clientManager, _donationManager, inventoryManager, disguiseManager, creature, blockRestore, castleManager); PetManager petManager = new PetManager(this, _clientManager, _donationManager, inventoryManager, disguiseManager, creature, blockRestore);
MountManager mountManager = new MountManager(this, _clientManager, _donationManager, blockRestore, disguiseManager); MountManager mountManager = new MountManager(this, _clientManager, _donationManager, blockRestore, disguiseManager);
GadgetManager gadgetManager = new GadgetManager(this, _clientManager, _donationManager, inventoryManager, mountManager, petManager, preferenceManager, disguiseManager, blockRestore, projectileManager, achievementManager, packetHandler, hologramManager, incognito, castleManager); GadgetManager gadgetManager = new GadgetManager(this, _clientManager, _donationManager, inventoryManager, mountManager, petManager, preferenceManager, disguiseManager, blockRestore, projectileManager, achievementManager, packetHandler, hologramManager, incognito, castleManager);
ThankManager thankManager = new ThankManager(this, _clientManager, _donationManager); ThankManager thankManager = new ThankManager(this, _clientManager, _donationManager);

View File

@ -11,9 +11,15 @@ import org.bukkit.entity.EnderDragon;
import org.bukkit.entity.Item; import org.bukkit.entity.Item;
import org.bukkit.entity.Player; import org.bukkit.entity.Player;
import org.bukkit.event.EventHandler; import org.bukkit.event.EventHandler;
import org.bukkit.event.entity.EntityTargetEvent;
import org.bukkit.event.entity.EntityDamageEvent.DamageCause; import org.bukkit.event.entity.EntityDamageEvent.DamageCause;
import org.bukkit.event.entity.EntityTargetEvent;
import com.mineplex.anticheat.checks.move.Glide;
import com.mineplex.anticheat.checks.move.HeadRoll;
import com.mineplex.anticheat.checks.move.Speed;
import mineplex.core.Managers;
import mineplex.core.antihack.AntiHack;
import mineplex.core.common.util.UtilAction; import mineplex.core.common.util.UtilAction;
import mineplex.core.common.util.UtilAlg; import mineplex.core.common.util.UtilAlg;
import mineplex.core.common.util.UtilEnt; import mineplex.core.common.util.UtilEnt;
@ -22,12 +28,15 @@ import mineplex.core.common.util.UtilTime;
import mineplex.core.updater.UpdateType; import mineplex.core.updater.UpdateType;
import mineplex.core.updater.event.UpdateEvent; import mineplex.core.updater.event.UpdateEvent;
import mineplex.minecraft.game.core.damage.CustomDamageEvent; import mineplex.minecraft.game.core.damage.CustomDamageEvent;
import nautilus.game.arcade.ArcadeManager; import nautilus.game.arcade.ArcadeManager;
import nautilus.game.arcade.GameType; import nautilus.game.arcade.GameType;
import nautilus.game.arcade.events.PlayerStateChangeEvent; import nautilus.game.arcade.events.PlayerStateChangeEvent;
import nautilus.game.arcade.game.SoloGame;
import nautilus.game.arcade.game.GameTeam.PlayerState; import nautilus.game.arcade.game.GameTeam.PlayerState;
import nautilus.game.arcade.game.games.dragons.kits.*; import nautilus.game.arcade.game.SoloGame;
import nautilus.game.arcade.game.games.dragons.kits.KitCoward;
import nautilus.game.arcade.game.games.dragons.kits.KitMarksman;
import nautilus.game.arcade.game.games.dragons.kits.KitPyrotechnic;
import nautilus.game.arcade.game.modules.compass.CompassModule; import nautilus.game.arcade.game.modules.compass.CompassModule;
import nautilus.game.arcade.kit.Kit; import nautilus.game.arcade.kit.Kit;
import nautilus.game.arcade.kit.Perk; import nautilus.game.arcade.kit.Perk;
@ -80,6 +89,12 @@ public class Dragons extends SoloGame
.setGiveCompassToSpecs(true) .setGiveCompassToSpecs(true)
.setGiveCompassToAlive(false) .setGiveCompassToAlive(false)
.register(this); .register(this);
// Disable specific GWEN checks for this game
AntiHack antiHack = Managers.get(AntiHack.class);
antiHack.addIgnoredCheck(Speed.class);
antiHack.addIgnoredCheck(Glide.class);
antiHack.addIgnoredCheck(HeadRoll.class);
} }
@Override @Override

View File

@ -58,6 +58,7 @@ import mineplex.core.gadget.types.Gadget;
import mineplex.core.gadget.types.GadgetType; import mineplex.core.gadget.types.GadgetType;
import mineplex.core.give.Give; import mineplex.core.give.Give;
import mineplex.core.mount.Mount; import mineplex.core.mount.Mount;
import mineplex.core.punish.PunishClient;
import mineplex.core.updater.UpdateType; import mineplex.core.updater.UpdateType;
import mineplex.core.updater.event.UpdateEvent; import mineplex.core.updater.event.UpdateEvent;
@ -643,7 +644,7 @@ public class EventModule extends MiniPlugin
{ {
_keepInventory = !_keepInventory; _keepInventory = !_keepInventory;
UtilPlayer.message(player, F.main("Settings", "BlockBreakCreative: " + F.tf(_keepInventory))); UtilPlayer.message(player, F.main("Settings", "KeepInventory: " + F.tf(_keepInventory)));
} }
public void commandGameKit(Player player, String[] args) public void commandGameKit(Player player, String[] args)
@ -683,7 +684,16 @@ public class EventModule extends MiniPlugin
public void commandEventChat(Player player, String[] args) public void commandEventChat(Player player, String[] args)
{ {
String message = ChatColor.BLUE + "[Event Chat] " + ChatColor.GREEN + player.getName() + ": " + F.combine(args, 1, null, false); if (args.length == 1)
return;
PunishClient client = Manager.getPunishments().GetClient(player.getName());
if (client != null && (client.IsBanned() || client.IsMuted()))
{
return;
}
String message = ChatColor.YELLOW + "Event Chat " + ChatColor.YELLOW + ChatColor.BOLD + player.getName() + " " + ChatColor.RESET + ChatColor.GOLD + F.combine(args, 1, null, false);
UtilPlayer.message(player, message); UtilPlayer.message(player, message);
for (Player other : UtilServer.getPlayers()) for (Player other : UtilServer.getPlayers())
{ {
@ -710,6 +720,7 @@ public class EventModule extends MiniPlugin
Manager.GetGame().SetPlayerState(target, PlayerState.IN); Manager.GetGame().SetPlayerState(target, PlayerState.IN);
Manager.GetGame().RespawnPlayer(target); Manager.GetGame().RespawnPlayer(target);
Manager.GetGame().GetScoreboard().setPlayerTeam(target, Manager.GetGame().GetTeam(target));
UtilPlayer.message(target, F.main("Game", "You have been Respawned!")); UtilPlayer.message(target, F.main("Game", "You have been Respawned!"));
} }

View File

@ -78,6 +78,7 @@ import nautilus.game.arcade.GameType;
import nautilus.game.arcade.events.GameStateChangeEvent; import nautilus.game.arcade.events.GameStateChangeEvent;
import nautilus.game.arcade.game.Game; import nautilus.game.arcade.game.Game;
import nautilus.game.arcade.game.games.skyfall.kits.KitAeronaught; import nautilus.game.arcade.game.games.skyfall.kits.KitAeronaught;
import nautilus.game.arcade.game.games.skyfall.kits.KitBooster;
import nautilus.game.arcade.game.games.skyfall.kits.KitDeadeye; import nautilus.game.arcade.game.games.skyfall.kits.KitDeadeye;
import nautilus.game.arcade.game.games.skyfall.kits.KitJouster; import nautilus.game.arcade.game.games.skyfall.kits.KitJouster;
import nautilus.game.arcade.game.games.skyfall.kits.KitSpeeder; import nautilus.game.arcade.game.games.skyfall.kits.KitSpeeder;
@ -169,7 +170,7 @@ public abstract class Skyfall extends Game
new Kit[] new Kit[]
{ {
new KitSpeeder(manager), new KitSpeeder(manager),
//new KitBooster(manager), // Broken? :( new KitBooster(manager),
new KitJouster(manager), new KitJouster(manager),
new KitStunner(manager), new KitStunner(manager),
//new KitSurefoot(manager), //new KitSurefoot(manager),

View File

@ -40,7 +40,7 @@ public class PerkElytraBoost extends Perk
{ {
super(name, new String[] super(name, new String[]
{ {
C.cYellow + "Double tap jump" + C.cWhite + " to use your " + C.cGreen +"Elytra Boost" C.cYellow + "Double tap jump" + C.cWhite + " to use your " + C.cGreen + "Elytra Boost"
}); });
_cooldown = cooldown; _cooldown = cooldown;
@ -63,6 +63,7 @@ public class PerkElytraBoost extends Perk
if (!UtilPlayer.isGliding(player) || !Recharge.Instance.usable(player, GetName())) if (!UtilPlayer.isGliding(player) || !Recharge.Instance.usable(player, GetName()))
{ {
player.setAllowFlight(false); player.setAllowFlight(false);
player.setFlying(false);
return; return;
} }
player.setAllowFlight(true); player.setAllowFlight(true);

View File

@ -129,7 +129,7 @@ public class Hub extends JavaPlugin
// Inventory // Inventory
CastleManager castleManager = new CastleManager(this, _clientManager, hologramManager, false); CastleManager castleManager = new CastleManager(this, _clientManager, hologramManager, false);
InventoryManager inventoryManager = new InventoryManager(this, _clientManager); InventoryManager inventoryManager = new InventoryManager(this, _clientManager);
PetManager petManager = new PetManager(this, _clientManager, _donationManager, inventoryManager, disguiseManager, creature, blockRestore, castleManager); PetManager petManager = new PetManager(this, _clientManager, _donationManager, inventoryManager, disguiseManager, creature, blockRestore);
MountManager mountManager = new MountManager(this, _clientManager, _donationManager, blockRestore, disguiseManager); MountManager mountManager = new MountManager(this, _clientManager, _donationManager, blockRestore, disguiseManager);
GadgetManager gadgetManager = new GadgetManager(this, _clientManager, _donationManager, inventoryManager, mountManager, petManager, GadgetManager gadgetManager = new GadgetManager(this, _clientManager, _donationManager, inventoryManager, mountManager, petManager,
preferenceManager, disguiseManager, blockRestore, projectileManager, achievementManager, packetHandler, hologramManager, incognito, castleManager); preferenceManager, disguiseManager, blockRestore, projectileManager, achievementManager, packetHandler, hologramManager, incognito, castleManager);

View File

@ -1,21 +1,11 @@
package mineplex.gemhunters; package mineplex.gemhunters;
import net.minecraft.server.v1_8_R3.MinecraftServer;
import org.bukkit.Bukkit;
import org.bukkit.World;
import org.bukkit.craftbukkit.v1_8_R3.CraftWorld;
import org.bukkit.plugin.java.JavaPlugin;
import org.spigotmc.SpigotConfig;
import mineplex.core.CustomTagFix; import mineplex.core.CustomTagFix;
import mineplex.core.FoodDupeFix; import mineplex.core.FoodDupeFix;
import mineplex.core.TimingsFix; import mineplex.core.TimingsFix;
import mineplex.core.account.CoreClientManager; import mineplex.core.account.CoreClientManager;
import mineplex.core.achievement.AchievementManager; import mineplex.core.achievement.AchievementManager;
import mineplex.core.antihack.AntiHack; import mineplex.core.antihack.AntiHack;
import mineplex.core.aprilfools.AprilFoolsManager;
import mineplex.core.beta.BetaWhitelist;
import mineplex.core.blockrestore.BlockRestore; import mineplex.core.blockrestore.BlockRestore;
import mineplex.core.boosters.BoosterManager; import mineplex.core.boosters.BoosterManager;
import mineplex.core.chat.Chat; import mineplex.core.chat.Chat;
@ -54,7 +44,6 @@ import mineplex.core.party.PartyManager;
import mineplex.core.pet.PetManager; import mineplex.core.pet.PetManager;
import mineplex.core.portal.GenericServer; import mineplex.core.portal.GenericServer;
import mineplex.core.portal.Portal; import mineplex.core.portal.Portal;
import mineplex.core.powerplayclub.PowerPlayClubRepository;
import mineplex.core.preferences.PreferencesManager; import mineplex.core.preferences.PreferencesManager;
import mineplex.core.projectile.ProjectileManager; import mineplex.core.projectile.ProjectileManager;
import mineplex.core.punish.Punish; import mineplex.core.punish.Punish;
@ -64,7 +53,9 @@ import mineplex.core.report.ReportPlugin;
import mineplex.core.serverConfig.ServerConfiguration; import mineplex.core.serverConfig.ServerConfiguration;
import mineplex.core.stats.StatsManager; import mineplex.core.stats.StatsManager;
import mineplex.core.status.ServerStatusManager; import mineplex.core.status.ServerStatusManager;
import mineplex.core.task.TaskManager;
import mineplex.core.teleport.Teleport; import mineplex.core.teleport.Teleport;
import mineplex.core.texttutorial.TextTutorialManager;
import mineplex.core.thank.ThankManager; import mineplex.core.thank.ThankManager;
import mineplex.core.twofactor.TwoFactorAuth; import mineplex.core.twofactor.TwoFactorAuth;
import mineplex.core.updater.FileUpdater; import mineplex.core.updater.FileUpdater;
@ -77,11 +68,13 @@ import mineplex.gemhunters.death.DeathModule;
import mineplex.gemhunters.death.quitnpc.QuitNPCModule; import mineplex.gemhunters.death.quitnpc.QuitNPCModule;
import mineplex.gemhunters.economy.CashOutModule; import mineplex.gemhunters.economy.CashOutModule;
import mineplex.gemhunters.economy.EconomyModule; import mineplex.gemhunters.economy.EconomyModule;
import mineplex.gemhunters.join.JoinModule;
import mineplex.gemhunters.loot.InventoryModule; import mineplex.gemhunters.loot.InventoryModule;
import mineplex.gemhunters.loot.LootModule; import mineplex.gemhunters.loot.LootModule;
import mineplex.gemhunters.map.ItemMapModule; import mineplex.gemhunters.map.ItemMapModule;
import mineplex.gemhunters.moderation.ModerationModule; import mineplex.gemhunters.moderation.ModerationModule;
import mineplex.gemhunters.mount.MountModule; import mineplex.gemhunters.mount.MountModule;
import mineplex.gemhunters.persistence.PersistenceModule;
import mineplex.gemhunters.playerstatus.PlayerStatusModule; import mineplex.gemhunters.playerstatus.PlayerStatusModule;
import mineplex.gemhunters.quest.QuestModule; import mineplex.gemhunters.quest.QuestModule;
import mineplex.gemhunters.safezone.SafezoneModule; import mineplex.gemhunters.safezone.SafezoneModule;
@ -89,6 +82,7 @@ import mineplex.gemhunters.scoreboard.ScoreboardModule;
import mineplex.gemhunters.shop.ShopModule; import mineplex.gemhunters.shop.ShopModule;
import mineplex.gemhunters.spawn.SpawnModule; import mineplex.gemhunters.spawn.SpawnModule;
import mineplex.gemhunters.supplydrop.SupplyDropModule; import mineplex.gemhunters.supplydrop.SupplyDropModule;
import mineplex.gemhunters.tutorial.GemHuntersTutorial;
import mineplex.gemhunters.world.DebugListeners; import mineplex.gemhunters.world.DebugListeners;
import mineplex.gemhunters.world.TimeCycle; import mineplex.gemhunters.world.TimeCycle;
import mineplex.gemhunters.world.UndergroundMobs; import mineplex.gemhunters.world.UndergroundMobs;
@ -97,6 +91,12 @@ import mineplex.gemhunters.worldevent.WorldEventModule;
import mineplex.minecraft.game.core.combat.CombatManager; import mineplex.minecraft.game.core.combat.CombatManager;
import mineplex.minecraft.game.core.condition.ConditionManager; import mineplex.minecraft.game.core.condition.ConditionManager;
import mineplex.minecraft.game.core.damage.DamageManager; import mineplex.minecraft.game.core.damage.DamageManager;
import net.minecraft.server.v1_8_R3.MinecraftServer;
import org.bukkit.Bukkit;
import org.bukkit.World;
import org.bukkit.craftbukkit.v1_8_R3.CraftWorld;
import org.bukkit.plugin.java.JavaPlugin;
import org.spigotmc.SpigotConfig;
import static mineplex.core.Managers.require; import static mineplex.core.Managers.require;
@ -252,7 +252,7 @@ public class GemHunters extends JavaPlugin
// :( // :(
CastleManager castleManager = new CastleManager(this, clientManager, hologramManager, false); CastleManager castleManager = new CastleManager(this, clientManager, hologramManager, false);
MountManager mountManager = new MountManager(this, clientManager, donationManager, blockRestore, disguiseManager); MountManager mountManager = new MountManager(this, clientManager, donationManager, blockRestore, disguiseManager);
PetManager petManager = new PetManager(this, clientManager, donationManager, inventoryManager, disguiseManager, creature, blockRestore, castleManager); PetManager petManager = new PetManager(this, clientManager, donationManager, inventoryManager, disguiseManager, creature, blockRestore);
ProjectileManager projectileManager = new ProjectileManager(this); ProjectileManager projectileManager = new ProjectileManager(this);
GadgetManager gadgetManager = new GadgetManager(this, clientManager, donationManager, inventoryManager, mountManager, petManager, preferenceManager, disguiseManager, blockRestore, projectileManager, achievementManager, packetHandler, hologramManager, incognito, castleManager); GadgetManager gadgetManager = new GadgetManager(this, clientManager, donationManager, inventoryManager, mountManager, petManager, preferenceManager, disguiseManager, blockRestore, projectileManager, achievementManager, packetHandler, hologramManager, incognito, castleManager);
ThankManager thankManager = new ThankManager(this, clientManager, donationManager); ThankManager thankManager = new ThankManager(this, clientManager, donationManager);
@ -265,8 +265,8 @@ public class GemHunters extends JavaPlugin
gadgetManager.setGadgetEnabled(false); gadgetManager.setGadgetEnabled(false);
// Tutorials // Tutorials
//TextTutorialManager tutorialManager = new TextTutorialManager(this, donationManager, new TaskManager(this, clientManager)); TextTutorialManager tutorialManager = new TextTutorialManager(this, donationManager, new TaskManager(this, clientManager));
//tutorialManager.addTutorial(new GemHuntersTutorial()); tutorialManager.addTutorial(new GemHuntersTutorial());
// Now we finally get to enable the Gem Hunters modules // Now we finally get to enable the Gem Hunters modules
// Though if any other module needs one of these it will be generated in // Though if any other module needs one of these it will be generated in
@ -280,8 +280,10 @@ public class GemHunters extends JavaPlugin
require(InventoryModule.class); require(InventoryModule.class);
require(LootModule.class); require(LootModule.class);
require(ItemMapModule.class); require(ItemMapModule.class);
require(JoinModule.class);
require(ModerationModule.class); require(ModerationModule.class);
require(MountModule.class); require(MountModule.class);
require(PersistenceModule.class);
require(PlayerStatusModule.class); require(PlayerStatusModule.class);
require(QuestModule.class); require(QuestModule.class);
require(QuitNPCModule.class); require(QuitNPCModule.class);
@ -299,8 +301,6 @@ public class GemHunters extends JavaPlugin
new UndergroundMobs(this); new UndergroundMobs(this);
new DebugListeners(this); new DebugListeners(this);
AprilFoolsManager.getInstance();
// UpdateEvent!!! // UpdateEvent!!!
new Updater(this); new Updater(this);
@ -316,9 +316,6 @@ public class GemHunters extends JavaPlugin
// Two-factor auth // Two-factor auth
require(TwoFactorAuth.class); require(TwoFactorAuth.class);
// beta whitelist
new BetaWhitelist(clientManager, new PowerPlayClubRepository(this, clientManager, donationManager));
} }
@Override @Override

View File

@ -70,14 +70,6 @@ public class DeathModule extends MiniPlugin
_toRemove = new HashMap<>(); _toRemove = new HashMap<>();
} }
@EventHandler(priority = EventPriority.MONITOR)
public void join(PlayerJoinEvent event)
{
PlayerCustomRespawnEvent event2 = new PlayerCustomRespawnEvent(event.getPlayer());
UtilServer.CallEvent(event2);
}
@EventHandler @EventHandler
public void death(PlayerDeathEvent event) public void death(PlayerDeathEvent event)
{ {

View File

@ -12,11 +12,13 @@ public class QuitNPCDespawnEvent extends Event implements Cancellable
private static final HandlerList HANDLERS = new HandlerList(); private static final HandlerList HANDLERS = new HandlerList();
private final QuitNPC _npc; private final QuitNPC _npc;
private final boolean _pluginRemove;
private boolean _cancel; private boolean _cancel;
public QuitNPCDespawnEvent(QuitNPC npc) public QuitNPCDespawnEvent(QuitNPC npc, boolean pluginRemove)
{ {
_npc = npc; _npc = npc;
_pluginRemove = pluginRemove;
} }
public QuitNPC getNpc() public QuitNPC getNpc()
@ -24,6 +26,11 @@ public class QuitNPCDespawnEvent extends Event implements Cancellable
return _npc; return _npc;
} }
public boolean isPluginRemove()
{
return _pluginRemove;
}
public HandlerList getHandlers() public HandlerList getHandlers()
{ {
return HANDLERS; return HANDLERS;

View File

@ -50,15 +50,8 @@ public class QuitNPC implements Listener
private final UUID _uuid; private final UUID _uuid;
private final PlayerInventory _inventory; private final PlayerInventory _inventory;
// Unlocked Slots
private final int _slotsUnlocked;
// Gems
private final int _gems; private final int _gems;
// Quests
private final QuestPlayerData _questPlayerData;
public QuitNPC(QuitNPCModule npc, Player player, long quitMills) public QuitNPC(QuitNPCModule npc, Player player, long quitMills)
{ {
// Managers // Managers
@ -91,50 +84,14 @@ public class QuitNPC implements Listener
_name = player.getName(); _name = player.getName();
_uuid = player.getUniqueId(); _uuid = player.getUniqueId();
_inventory = player.getInventory(); _inventory = player.getInventory();
// Unlocked Slots
_slotsUnlocked = Managers.get(InventoryModule.class).getSlotsUnlocked(player);
// Gems
_gems = Managers.get(EconomyModule.class).Get(player); _gems = Managers.get(EconomyModule.class).Get(player);
// Quests
_questPlayerData = Managers.get(QuestModule.class).Get(player);
UtilServer.RegisterEvents(this); UtilServer.RegisterEvents(this);
} }
public void restore(Player player) public void despawn(boolean pluginRemove)
{ {
// Player QuitNPCDespawnEvent event = new QuitNPCDespawnEvent(this, pluginRemove);
player.getInventory().clear();
player.teleport(_entity.getLocation());
player.setHealth(_entity.getHealth());
// Inventory
int i = 0;
for (ItemStack itemStack : _inventory.getContents())
{
player.getInventory().setItem(i++, itemStack);
}
player.getInventory().setArmorContents(_inventory.getArmorContents());
// Unlocked Slots
Managers.get(InventoryModule.class).setSlotsUnlocked(player, _slotsUnlocked);
// Gems
// Subtract GEM_START_COST (100 by default) because EconomyModule adds
// this value on join regardless if they have an NPC.
Managers.get(EconomyModule.class).setStore(player, _gems - EconomyModule.GEM_START_COST);
// Quests
Managers.require(QuestModule.class).setPlayerData(player, _questPlayerData);
}
public void despawn()
{
QuitNPCDespawnEvent event = new QuitNPCDespawnEvent(this);
UtilServer.CallEvent(event); UtilServer.CallEvent(event);
@ -185,7 +142,7 @@ public class QuitNPC implements Listener
if (UtilTime.elapsed(_start, _quitMills)) if (UtilTime.elapsed(_start, _quitMills))
{ {
despawn(); despawn(true);
} }
else else
{ {
@ -212,7 +169,7 @@ public class QuitNPC implements Listener
event.getDrops().clear(); event.getDrops().clear();
_entity.setHealth(_entity.getMaxHealth()); _entity.setHealth(_entity.getMaxHealth());
dropItems(); dropItems();
despawn(); despawn(false);
} }
@EventHandler @EventHandler
@ -226,6 +183,11 @@ public class QuitNPC implements Listener
event.setCancelled(true); event.setCancelled(true);
} }
public String getName()
{
return _name;
}
public UUID getUniqueId() public UUID getUniqueId()
{ {
return _uuid; return _uuid;

View File

@ -7,6 +7,8 @@ import java.util.Set;
import java.util.UUID; import java.util.UUID;
import java.util.concurrent.TimeUnit; import java.util.concurrent.TimeUnit;
import mineplex.core.common.util.UtilPlayer;
import mineplex.gemhunters.economy.CashOutModule;
import org.bukkit.GameMode; import org.bukkit.GameMode;
import org.bukkit.entity.Player; import org.bukkit.entity.Player;
import org.bukkit.event.EventHandler; import org.bukkit.event.EventHandler;
@ -29,21 +31,19 @@ public class QuitNPCModule extends MiniPlugin
private static final long LOG_OUT_TIME = TimeUnit.SECONDS.toMillis(60); private static final long LOG_OUT_TIME = TimeUnit.SECONDS.toMillis(60);
private final TextTutorialManager _tutorial; private final CashOutModule _cashOut;
private final Map<UUID, QuitNPC> _npcs; private final Map<UUID, QuitNPC> _npcs;
private final Map<UUID, String> _killedBy; private final Map<UUID, String> _killedBy;
private final Set<UUID> _aboutToCashOut;
private QuitNPCModule() private QuitNPCModule()
{ {
super("Quit NPC"); super("Quit NPC");
_tutorial = require(TextTutorialManager.class); _cashOut = require(CashOutModule.class);
_npcs = new HashMap<>(); _npcs = new HashMap<>();
_killedBy = new HashMap<>(); _killedBy = new HashMap<>();
_aboutToCashOut = new HashSet<>();
} }
public void spawnNpc(Player player) public void spawnNpc(Player player)
@ -56,10 +56,9 @@ public class QuitNPCModule extends MiniPlugin
return; return;
} }
if (_aboutToCashOut.contains(player.getUniqueId())) if (_cashOut.isAboutToCashOut(player))
{ {
log(player.getName() + " was cashing out"); log(player.getName() + " was cashing out");
_aboutToCashOut.remove(player.getUniqueId());
return; return;
} }
@ -77,20 +76,12 @@ public class QuitNPCModule extends MiniPlugin
_npcs.put(player.getUniqueId(), new QuitNPC(this, player, LOG_OUT_TIME)); _npcs.put(player.getUniqueId(), new QuitNPC(this, player, LOG_OUT_TIME));
} }
@EventHandler
public void cashOutComplete(PlayerCashOutCompleteEvent event)
{
UUID key = event.getPlayer().getUniqueId();
_aboutToCashOut.add(key);
}
@EventHandler(priority = EventPriority.LOWEST) @EventHandler(priority = EventPriority.LOWEST)
public void playerQuit(PlayerQuitEvent event) public void playerQuit(PlayerQuitEvent event)
{ {
Player player = event.getPlayer(); Player player = event.getPlayer();
if (_tutorial.isInTutorial(player)) if (UtilPlayer.isSpectator(player))
{ {
return; return;
} }
@ -101,7 +92,7 @@ public class QuitNPCModule extends MiniPlugin
@EventHandler @EventHandler
public void npcDespawn(QuitNPCDespawnEvent event) public void npcDespawn(QuitNPCDespawnEvent event)
{ {
log("Despawning npc for " + _npcs.remove(event.getNpc().getUniqueId()).getUniqueId()); log("Despawning npc for " + _npcs.remove(event.getNpc().getUniqueId()).getName());
} }
@EventHandler @EventHandler

View File

@ -1,32 +1,10 @@
package mineplex.gemhunters.economy; package mineplex.gemhunters.economy;
import java.text.DecimalFormat;
import java.util.HashMap;
import java.util.Iterator;
import java.util.Map;
import java.util.UUID;
import org.bukkit.Material;
import org.bukkit.entity.ArmorStand;
import org.bukkit.entity.Player;
import org.bukkit.event.EventHandler;
import org.bukkit.event.EventPriority;
import org.bukkit.event.entity.EntityDamageByEntityEvent;
import org.bukkit.event.entity.EntityDamageEvent;
import org.bukkit.event.entity.ItemSpawnEvent;
import org.bukkit.event.player.PlayerInteractEvent;
import org.bukkit.inventory.ItemStack;
import mineplex.core.MiniPlugin; import mineplex.core.MiniPlugin;
import mineplex.core.ReflectivelyCreateMiniPlugin; import mineplex.core.ReflectivelyCreateMiniPlugin;
import mineplex.core.common.currency.GlobalCurrency; import mineplex.core.common.currency.GlobalCurrency;
import mineplex.core.common.util.C; import mineplex.core.common.util.*;
import mineplex.core.common.util.F;
import mineplex.core.common.util.UtilEvent;
import mineplex.core.common.util.UtilEvent.ActionType; import mineplex.core.common.util.UtilEvent.ActionType;
import mineplex.core.common.util.UtilPlayer;
import mineplex.core.common.util.UtilServer;
import mineplex.core.common.util.UtilTextMiddle;
import mineplex.core.donation.DonationManager; import mineplex.core.donation.DonationManager;
import mineplex.core.itemstack.ItemBuilder; import mineplex.core.itemstack.ItemBuilder;
import mineplex.core.portal.GenericServer; import mineplex.core.portal.GenericServer;
@ -38,13 +16,27 @@ import mineplex.core.updater.event.UpdateEvent;
import mineplex.gemhunters.economy.command.CashOutItemCommand; import mineplex.gemhunters.economy.command.CashOutItemCommand;
import mineplex.gemhunters.economy.event.PlayerCashOutCompleteEvent; import mineplex.gemhunters.economy.event.PlayerCashOutCompleteEvent;
import mineplex.gemhunters.spawn.event.PlayerTeleportIntoMapEvent; import mineplex.gemhunters.spawn.event.PlayerTeleportIntoMapEvent;
import org.bukkit.Material;
import org.bukkit.entity.ArmorStand;
import org.bukkit.entity.Player;
import org.bukkit.event.EventHandler;
import org.bukkit.event.EventPriority;
import org.bukkit.event.entity.EntityDamageByEntityEvent;
import org.bukkit.event.entity.EntityDamageEvent;
import org.bukkit.event.entity.ItemSpawnEvent;
import org.bukkit.event.player.PlayerInteractEvent;
import org.bukkit.event.player.PlayerQuitEvent;
import org.bukkit.inventory.ItemStack;
import java.text.DecimalFormat;
import java.util.*;
@ReflectivelyCreateMiniPlugin @ReflectivelyCreateMiniPlugin
public class CashOutModule extends MiniPlugin public class CashOutModule extends MiniPlugin
{ {
private static final DecimalFormat ARMOUR_STAND_FORMAT = new DecimalFormat("0.0"); private static final DecimalFormat ARMOUR_STAND_FORMAT = new DecimalFormat("0.0");
public static final ItemStack CASH_OUT_ITEM = new ItemBuilder(Material.EMERALD).setTitle(C.cGreen + "Cash Out").addLore("", C.cGray + "Click to begin the process to cash out.", C.cGray + "Cashing out gives you your gems, shards, ", C.cGray + "chests and any particles you have.", C.cGray + "However you will lose all your current loot!").build(); public static final ItemStack CASH_OUT_ITEM = new ItemBuilder(Material.EMERALD).setTitle(C.cGreen + "Cash Out").addLore("", "Click to begin the process to cash out.", "Cashing out gives you your gems, shards,", "chests and any particles you have.", "However you will lose all your current loot!").build();
private static final int CASH_OUT_SECONDS = 10; private static final int CASH_OUT_SECONDS = 10;
private static final int CASH_OUT_COOLDOWN = 10000; private static final int CASH_OUT_COOLDOWN = 10000;
@ -53,6 +45,7 @@ public class CashOutModule extends MiniPlugin
private final DonationManager _donation; private final DonationManager _donation;
private final Map<UUID, CashOutSession> _sessions; private final Map<UUID, CashOutSession> _sessions;
private final Set<UUID> _aboutToCashOut;
public CashOutModule() public CashOutModule()
{ {
@ -61,6 +54,7 @@ public class CashOutModule extends MiniPlugin
_donation = require(DonationManager.class); _donation = require(DonationManager.class);
_sessions = new HashMap<>(); _sessions = new HashMap<>();
_aboutToCashOut = new HashSet<>();
} }
@Override @Override
@ -72,7 +66,7 @@ public class CashOutModule extends MiniPlugin
@EventHandler @EventHandler
public void teleportIn(PlayerTeleportIntoMapEvent event) public void teleportIn(PlayerTeleportIntoMapEvent event)
{ {
if (event.isCancelled()) if (event.isCancelled() || event.getPlayer().getInventory().contains(CASH_OUT_ITEM))
{ {
return; return;
} }
@ -126,7 +120,7 @@ public class CashOutModule extends MiniPlugin
while (iterator.hasNext()) while (iterator.hasNext())
{ {
UUID key = iterator.next(); UUID key = iterator.next();
Player player = UtilPlayer.searchExact(key); final Player player = UtilPlayer.searchExact(key);
CashOutSession session = _sessions.get(key); CashOutSession session = _sessions.get(key);
double current = session.getCurrent(); double current = session.getCurrent();
ArmorStand stand = session.getArmourStand(); ArmorStand stand = session.getArmourStand();
@ -149,11 +143,29 @@ public class CashOutModule extends MiniPlugin
UtilServer.CallEvent(completeEvent); UtilServer.CallEvent(completeEvent);
_aboutToCashOut.add(player.getUniqueId());
_donation.rewardCurrencyUntilSuccess(GlobalCurrency.GEM, player, "Earned", completeEvent.getGems()); _donation.rewardCurrencyUntilSuccess(GlobalCurrency.GEM, player, "Earned", completeEvent.getGems());
session.endSession(); session.endSession();
iterator.remove(); iterator.remove();
if (UtilServer.isTestServer())
{
kickPlayer(player);
}
else
{
Portal.getInstance().sendPlayerToGenericServer(player, GenericServer.BETA_HUB, Intent.FORCE_TRANSFER); Portal.getInstance().sendPlayerToGenericServer(player, GenericServer.BETA_HUB, Intent.FORCE_TRANSFER);
runSyncLater(() ->
{
if (player.isOnline())
{
kickPlayer(player);
}
}, 20);
}
} }
} }
} }
@ -220,6 +232,12 @@ public class CashOutModule extends MiniPlugin
} }
} }
@EventHandler(priority = EventPriority.MONITOR)
public void playerQuit(PlayerQuitEvent event)
{
_aboutToCashOut.remove(event.getPlayer().getUniqueId());
}
public void attemptCashOut(Player player) public void attemptCashOut(Player player)
{ {
UUID key = player.getUniqueId(); UUID key = player.getUniqueId();
@ -253,6 +271,11 @@ public class CashOutModule extends MiniPlugin
return getCashOutSession(player) != null; return getCashOutSession(player) != null;
} }
public boolean isAboutToCashOut(Player player)
{
return _aboutToCashOut.contains(player.getUniqueId());
}
public CashOutSession getCashOutSession(Player player) public CashOutSession getCashOutSession(Player player)
{ {
for (UUID key : _sessions.keySet()) for (UUID key : _sessions.keySet())
@ -266,4 +289,9 @@ public class CashOutModule extends MiniPlugin
return null; return null;
} }
private void kickPlayer(Player player)
{
player.kickPlayer(C.cGreen + "Imagine you are being sent to the lobby.");
}
} }

View File

@ -42,16 +42,12 @@ public class EconomyModule extends MiniClientPlugin<Integer>
addCommand(new GiveGemsCommand(this)); addCommand(new GiveGemsCommand(this));
} }
@EventHandler
public void respawn(PlayerCustomRespawnEvent event)
{
addToStore(event.getPlayer(), null, GEM_START_COST);
}
@EventHandler @EventHandler
public void teleportIn(PlayerTeleportIntoMapEvent event) public void teleportIn(PlayerTeleportIntoMapEvent event)
{ {
Player player = event.getPlayer(); Player player = event.getPlayer();
addToStore(event.getPlayer(), null, GEM_START_COST);
Donor donor = _donation.Get(event.getPlayer()); Donor donor = _donation.Get(event.getPlayer());
if (donor.getBalance(GlobalCurrency.GEM) >= GEM_START_COST) if (donor.getBalance(GlobalCurrency.GEM) >= GEM_START_COST)
@ -68,7 +64,7 @@ public class EconomyModule extends MiniClientPlugin<Integer>
int oldGems = getGems(player); int oldGems = getGems(player);
if (killer instanceof Player) if (killer != null)
{ {
Player killerPlayer = (Player) killer; Player killerPlayer = (Player) killer;
int newGems = (int) (oldGems * GEM_KILL_FACTOR); int newGems = (int) (oldGems * GEM_KILL_FACTOR);

View File

@ -0,0 +1,89 @@
package mineplex.gemhunters.join;
import mineplex.core.MiniPlugin;
import mineplex.core.ReflectivelyCreateMiniPlugin;
import mineplex.core.account.CoreClient;
import mineplex.core.account.CoreClientManager;
import mineplex.core.inventory.InventoryManager;
import mineplex.gemhunters.death.quitnpc.QuitNPC;
import mineplex.gemhunters.death.quitnpc.QuitNPCModule;
import mineplex.gemhunters.economy.EconomyModule;
import mineplex.gemhunters.loot.InventoryModule;
import mineplex.gemhunters.map.ItemMapModule;
import mineplex.gemhunters.persistence.PersistenceData;
import mineplex.gemhunters.persistence.PersistenceModule;
import mineplex.gemhunters.persistence.PersistenceRepository;
import mineplex.gemhunters.quest.QuestModule;
import mineplex.gemhunters.spawn.SpawnModule;
import org.bukkit.entity.Player;
import org.bukkit.event.EventHandler;
import org.bukkit.event.player.PlayerJoinEvent;
import java.util.function.Consumer;
@ReflectivelyCreateMiniPlugin
public class JoinModule extends MiniPlugin
{
private final CoreClientManager _client;
private final EconomyModule _economy;
private final QuestModule _quest;
private final PersistenceModule _persistence;
private final QuitNPCModule _npc;
private final InventoryModule _inventory;
private final SpawnModule _spawn;
private JoinModule()
{
super("Join");
_client = require(CoreClientManager.class);
_economy = require(EconomyModule.class);
_quest = require(QuestModule.class);
_persistence = require(PersistenceModule.class);
_npc = require(QuitNPCModule.class);
_inventory = require(InventoryModule.class);
_spawn = require(SpawnModule.class);
}
@EventHandler
public void playerJoin(PlayerJoinEvent event)
{
Player player = event.getPlayer();
CoreClient client = _client.Get(player);
PersistenceRepository repository = _persistence.getRepository();
Consumer<PersistenceData> response = data ->
runSync(() -> {
_economy.setStore(player, data.getGems());
_quest.setPlayerData(player, data.getQuestData());
player.teleport(data.getLocation());
player.setHealth(data.getHealth());
player.setMaxHealth(data.getMaxHealth());
player.setFoodLevel(data.getHunger());
player.getInventory().addItem(data.getItems());
player.getInventory().setArmorContents(data.getArmour());
_inventory.unlockSlots(player, data.getSlots(), false);
});
player.getInventory().clear();
if (_npc.hasNPC(player))
{
QuitNPC npc = _npc.getNPC(player);
npc.despawn(true);
}
_inventory.resetSlots(player);
runAsync(() ->
{
repository.getPersistenceData(response, client);
if (!repository.exists(client))
{
_spawn.teleportToSpawn(player);
}
});
}
}

View File

@ -10,6 +10,7 @@ import org.bukkit.entity.Player;
import org.bukkit.event.EventHandler; import org.bukkit.event.EventHandler;
import org.bukkit.event.inventory.InventoryClickEvent; import org.bukkit.event.inventory.InventoryClickEvent;
import org.bukkit.event.player.PlayerInteractEvent; import org.bukkit.event.player.PlayerInteractEvent;
import org.bukkit.event.player.PlayerJoinEvent;
import org.bukkit.event.player.PlayerQuitEvent; import org.bukkit.event.player.PlayerQuitEvent;
import org.bukkit.inventory.Inventory; import org.bukkit.inventory.Inventory;
import org.bukkit.inventory.ItemStack; import org.bukkit.inventory.ItemStack;
@ -48,15 +49,7 @@ public class InventoryModule extends MiniPlugin
@EventHandler @EventHandler
public void respawn(PlayerCustomRespawnEvent event) public void respawn(PlayerCustomRespawnEvent event)
{ {
Player player = event.getPlayer(); resetSlots(event.getPlayer());
Inventory inv = player.getInventory();
_slotsUnlocked.put(player.getUniqueId(), 0);
for (int i = START_INDEX; i < inv.getSize(); i++)
{
inv.setItem(i, LOCKED);
}
} }
@EventHandler @EventHandler
@ -111,6 +104,13 @@ public class InventoryModule extends MiniPlugin
public void unlockSlots(Player player, int slots) public void unlockSlots(Player player, int slots)
{ {
unlockSlots(player, slots, true);
}
public void unlockSlots(Player player, int slots, boolean inform)
{
_slotsUnlocked.putIfAbsent(player.getUniqueId(), 0);
Inventory inv = player.getInventory(); Inventory inv = player.getInventory();
UUID key = player.getUniqueId(); UUID key = player.getUniqueId();
@ -123,16 +123,26 @@ public class InventoryModule extends MiniPlugin
inv.setItem(i, null); inv.setItem(i, null);
} }
if (inform)
{
player.sendMessage(F.main(_moduleName, "You unlocked an additional " + F.count(String.valueOf(delta)) + " slots of your inventory!")); player.sendMessage(F.main(_moduleName, "You unlocked an additional " + F.count(String.valueOf(delta)) + " slots of your inventory!"));
}
_slotsUnlocked.put(key, _slotsUnlocked.get(key) + slots); _slotsUnlocked.put(key, _slotsUnlocked.get(key) + slots);
} }
public void setSlotsUnlocked(Player player, int amount) public void resetSlots(Player player)
{ {
_slotsUnlocked.put(player.getUniqueId(), amount); Inventory inv = player.getInventory();
_slotsUnlocked.put(player.getUniqueId(), 0);
for (int i = START_INDEX; i < inv.getSize(); i++)
{
inv.setItem(i, LOCKED);
}
} }
public int getSlotsUnlocked(Player player) public int getSlots(Player player)
{ {
return _slotsUnlocked.get(player.getUniqueId()); return _slotsUnlocked.get(player.getUniqueId());
} }

View File

@ -535,10 +535,7 @@ public class LootModule extends MiniPlugin
String key = metadataSplit[0]; String key = metadataSplit[0];
String[] values = new String[metadataSplit.length - 1]; String[] values = new String[metadataSplit.length - 1];
for (int i = 1; i < metadataSplit.length; i++) System.arraycopy(metadataSplit, 1, values, 0, metadataSplit.length - 1);
{
values[i - 1] = metadataSplit[i];
}
switch (key) switch (key)
{ {
@ -568,8 +565,11 @@ public class LootModule extends MiniPlugin
_itemRewards.add(reward); _itemRewards.add(reward);
} }
if (reward != null)
{
reward.collectItem(player); reward.collectItem(player);
} }
}
public void addItemReward(LootItemReward reward) public void addItemReward(LootItemReward reward)
{ {

View File

@ -29,6 +29,7 @@ import org.bukkit.event.entity.ItemSpawnEvent;
import org.bukkit.event.entity.PlayerDeathEvent; import org.bukkit.event.entity.PlayerDeathEvent;
import org.bukkit.event.player.PlayerInteractEvent; import org.bukkit.event.player.PlayerInteractEvent;
import org.bukkit.event.player.PlayerItemHeldEvent; import org.bukkit.event.player.PlayerItemHeldEvent;
import org.bukkit.event.player.PlayerJoinEvent;
import org.bukkit.event.player.PlayerQuitEvent; import org.bukkit.event.player.PlayerQuitEvent;
import org.bukkit.event.world.ChunkLoadEvent; import org.bukkit.event.world.ChunkLoadEvent;
import org.bukkit.inventory.ItemStack; import org.bukkit.inventory.ItemStack;
@ -662,12 +663,21 @@ public class ItemMapModule extends MiniPlugin
showZoom(player, info); showZoom(player, info);
} }
@EventHandler(priority = EventPriority.HIGHEST)
public void playerJoin(PlayerJoinEvent event)
{
handleGive(event.getPlayer());
}
@EventHandler @EventHandler
public void teleportIn(PlayerCustomRespawnEvent event) public void respawn(PlayerCustomRespawnEvent event)
{
handleGive(event.getPlayer());
}
public void handleGive(Player player)
{ {
MapInfo info = new MapInfo(_mapId); MapInfo info = new MapInfo(_mapId);
Player player = event.getPlayer();
Location loc = player.getLocation(); Location loc = player.getLocation();
int zoom = getZoom(1); int zoom = getZoom(1);

View File

@ -0,0 +1,78 @@
package mineplex.gemhunters.persistence;
import mineplex.gemhunters.quest.QuestPlayerData;
import org.bukkit.Location;
import org.bukkit.inventory.ItemStack;
public class PersistenceData
{
private final int _gems;
private final Location _location;
private final QuestPlayerData _questData;
private final int _health;
private final int _maxHealth;
private final int _hunger;
private final int _slots;
private final ItemStack[] _items;
private final ItemStack[] _armour;
public PersistenceData(int gems, Location location, QuestPlayerData questData, int health, int maxHealth, int hunger, int slots, ItemStack[] items, ItemStack[] armour)
{
_gems = gems;
_location = location;
_questData = questData;
_health = health;
_maxHealth = maxHealth;
_hunger = hunger;
_items = items;
_slots = slots;
_armour = armour;
}
public int getGems()
{
return _gems;
}
public Location getLocation()
{
return _location;
}
public QuestPlayerData getQuestData()
{
return _questData;
}
public int getHealth()
{
return _health;
}
public int getMaxHealth()
{
return _maxHealth;
}
public int getHunger()
{
return _hunger;
}
public int getSlots()
{
return _slots;
}
public ItemStack[] getItems()
{
return _items;
}
public ItemStack[] getArmour()
{
return _armour;
}
}

View File

@ -0,0 +1,139 @@
package mineplex.gemhunters.persistence;
import mineplex.core.MiniPlugin;
import mineplex.core.ReflectivelyCreateMiniPlugin;
import mineplex.core.account.CoreClient;
import mineplex.core.account.CoreClientManager;
import mineplex.gemhunters.death.event.QuitNPCDespawnEvent;
import mineplex.gemhunters.economy.CashOutModule;
import mineplex.gemhunters.economy.EconomyModule;
import mineplex.gemhunters.loot.InventoryModule;
import mineplex.gemhunters.quest.QuestModule;
import mineplex.gemhunters.quest.QuestPlayerData;
import net.minecraft.server.v1_8_R3.EntityItemFrame;
import org.bukkit.Bukkit;
import org.bukkit.Location;
import org.bukkit.Material;
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.AsyncPlayerPreLoginEvent;
import org.bukkit.event.player.AsyncPlayerPreLoginEvent.Result;
import org.bukkit.event.player.PlayerJoinEvent;
import org.bukkit.event.player.PlayerQuitEvent;
import org.bukkit.inventory.ItemStack;
import java.util.ArrayList;
import java.util.Collections;
import java.util.List;
@ReflectivelyCreateMiniPlugin
public class PersistenceModule extends MiniPlugin
{
private final CoreClientManager _client;
private final CashOutModule _cashOut;
private final EconomyModule _economy;
private final QuestModule _quest;
private final InventoryModule _inventory;
private final PersistenceRepository _repository;
private final List<String> _denyJoining;
public PersistenceModule()
{
super("Persistence");
_client = require(CoreClientManager.class);
_cashOut = require(CashOutModule.class);
_quest = require(QuestModule.class);
_economy = require(EconomyModule.class);
_inventory = require(InventoryModule.class);
_repository = new PersistenceRepository();
_denyJoining = Collections.synchronizedList(new ArrayList<>());
}
@EventHandler
public void preLogin(AsyncPlayerPreLoginEvent event)
{
if (_denyJoining.contains(event.getName()))
{
event.disallow(Result.KICK_OTHER, "Please wait a few seconds before connecting again.");
}
}
@EventHandler(priority = EventPriority.LOWEST)
public void playerQuit(PlayerQuitEvent event)
{
Player player = event.getPlayer();
CoreClient client = _client.Get(player);
if (_cashOut.isAboutToCashOut(player))
{
runAsync(() ->
{
_denyJoining.add(player.getName());
_repository.deletePersistence(client);
_denyJoining.remove(player.getName());
});
return;
}
int gems = _economy.Get(player);
Location location = player.getLocation();
QuestPlayerData quest = _quest.Get(player);
int health = (int) player.getHealth();
int maxHealth = (int) player.getMaxHealth();
int hunger = player.getFoodLevel();
int slots = _inventory.getSlots(player);
ItemStack[] items = player.getInventory().getContents();
ItemStack[] armour = player.getInventory().getArmorContents();
PersistenceData data = new PersistenceData(gems, location, quest, health, maxHealth, hunger, slots, items, armour);
runAsync(() ->
{
_denyJoining.add(player.getName());
_repository.savePersistence(client, data);
_denyJoining.remove(player.getName());
});
}
@EventHandler(priority = EventPriority.LOWEST)
public void playerDeath(PlayerDeathEvent event)
{
Player player = event.getEntity();
CoreClient client = _client.Get(player);
runAsync(() ->
{
_denyJoining.add(player.getName());
_repository.deletePersistence(client);
_denyJoining.remove(player.getName());
});
}
@EventHandler
public void npcDespawn(QuitNPCDespawnEvent event)
{
if (!event.isPluginRemove())
{
runAsync(() ->
{
String name = event.getNpc().getName();
_denyJoining.add(name);
_client.getOrLoadClient(event.getNpc().getName(), _repository::deletePersistence);
_denyJoining.remove(name);
});
}
}
public final PersistenceRepository getRepository()
{
return _repository;
}
}

View File

@ -0,0 +1,230 @@
package mineplex.gemhunters.persistence;
import com.google.gson.Gson;
import mineplex.core.account.CoreClient;
import mineplex.gemhunters.quest.QuestPlayerData;
import mineplex.serverdata.database.DBPool;
import mineplex.serverdata.database.RepositoryBase;
import mineplex.serverdata.database.column.ColumnInt;
import mineplex.serverdata.database.column.ColumnVarChar;
import net.minecraft.server.v1_8_R3.ItemMapEmpty;
import org.bukkit.Bukkit;
import org.bukkit.Location;
import org.bukkit.Material;
import org.bukkit.craftbukkit.v1_8_R3.inventory.CraftItemStack;
import org.bukkit.inventory.ItemStack;
import org.bukkit.inventory.meta.ItemMeta;
import java.lang.reflect.Constructor;
import java.util.ArrayList;
import java.util.List;
import java.util.Map;
import java.util.function.Consumer;
public class PersistenceRepository extends RepositoryBase
{
private static final String GET_DATA = "SELECT * FROM gemHunters WHERE accountId=?;";
private static final String INSERT_DATA = "INSERT INTO gemHunters VALUES (?,?,?,?,?,?,?,?,?,?,?,?,?,?);";
private static final String UPDATE_DATA = "UPDATE gemHunters SET gems=?,health=?,maxHealth=?,hunger=?,x=?,y=?,z=?,yaw=?,pitch=?,quests=?,slots=?,items=?,armour=? WHERE accountId=?;";
private static final String DELETE_DATA = "DELETE FROM gemHunters WHERE accountId=?;";
private static final Gson GSON;
private static final ItemStack AIR = new ItemStack(Material.AIR);
static
{
GSON = new Gson();
}
private final List<Integer> _exists;
public PersistenceRepository()
{
super(DBPool.getAccount());
_exists = new ArrayList<>();
}
public void getPersistenceData(Consumer<PersistenceData> response, CoreClient client)
{
int accountId = client.getAccountId();
executeQuery(GET_DATA, resultSet ->
{
if (resultSet.next())
{
int gems = resultSet.getInt("gems");
int health = resultSet.getInt("health");
int maxHealth = resultSet.getInt("maxHealth");
int hunger = resultSet.getInt("hunger");
int x = resultSet.getInt("x");
int y = resultSet.getInt("y");
int z = resultSet.getInt("z");
int yaw = resultSet.getInt("yaw");
int pitch = resultSet.getInt("pitch");
int slots = resultSet.getInt("slots");
String quests = resultSet.getString("quests");
QuestPlayerData questData = GSON.fromJson(quests, QuestPlayerData.class);
String items = resultSet.getString("items");
List<Map<String, Object>> itemsMap = GSON.fromJson(items, List.class);
List<ItemStack> itemsList = new ArrayList<>(itemsMap.size());
for (Map<String, Object> map : itemsMap)
{
ItemStack itemStack = CraftItemStack.deserialize(map);
if (map.containsKey("meta"))
{
itemStack.setItemMeta(deserialiseMeta(map.get("meta")));
}
itemsList.add(itemStack);
}
String armour = resultSet.getString("armour");
List<Map<String, Object>> armourMap = GSON.fromJson(armour, List.class);
List<ItemStack> armourList = new ArrayList<>(armourMap.size());
for (Map<String, Object> map : armourMap)
{
ItemStack itemStack = CraftItemStack.deserialize(map);
if (map.containsKey("meta"))
{
itemStack.setItemMeta(deserialiseMeta(map.get("meta")));
}
armourList.add(CraftItemStack.deserialize(map));
}
_exists.add(accountId);
Location location = new Location(Bukkit.getWorlds().get(0), x, y, z, yaw, pitch);
PersistenceData data = new PersistenceData(gems, location, questData, health, maxHealth, hunger, slots, itemsList.toArray(new ItemStack[0]), armourList.toArray(new ItemStack[0]));
response.accept(data);
}
}, new ColumnInt("accountId", accountId));
}
public void savePersistence(CoreClient client, PersistenceData data)
{
int accountId = client.getAccountId();
int gems = data.getGems();
int health = data.getHealth();
int maxHealth = data.getMaxHealth();
int hunger = data.getHunger();
int x = data.getLocation().getBlockX();
int y = data.getLocation().getBlockY();
int z = data.getLocation().getBlockZ();
int yaw = (int) data.getLocation().getYaw();
int pitch = (int) data.getLocation().getPitch();
int slots = data.getSlots();
ItemStack[] items = data.getItems();
ItemStack[] armour = data.getArmour();
List<Map<String, Object>> itemsMap = new ArrayList<>(items.length);
List<Map<String, Object>> armourMap = new ArrayList<>(armour.length);
for (ItemStack itemStack : items)
{
if (itemStack == null || itemStack.getType() == Material.MAP || itemStack.getType() == Material.STAINED_GLASS_PANE)
{
itemStack = AIR;
}
itemsMap.add(itemStack.serialize());
}
for (ItemStack itemStack : armour)
{
if (itemStack == null)
{
continue;
}
armourMap.add(itemStack.serialize());
}
if (exists(client))
{
executeUpdate(UPDATE_DATA,
new ColumnInt("gems", gems),
new ColumnInt("health", health),
new ColumnInt("maxHealth", maxHealth),
new ColumnInt("hunger", hunger),
new ColumnInt("x", x),
new ColumnInt("y", y),
new ColumnInt("z", z),
new ColumnInt("yaw", yaw),
new ColumnInt("pitch", pitch),
new ColumnVarChar("quests", 500, GSON.toJson(data.getQuestData())),
new ColumnInt("slots", slots),
new ColumnVarChar("items", 10000, GSON.toJson(itemsMap)),
new ColumnVarChar("armour", 1000, GSON.toJson(armourMap)),
new ColumnInt("accountId", accountId)
);
}
else
{
executeInsert(INSERT_DATA, null,
new ColumnInt("accountId", accountId),
new ColumnInt("gems", gems),
new ColumnInt("health", health),
new ColumnInt("maxHealth", maxHealth),
new ColumnInt("hunger", hunger),
new ColumnInt("x", x),
new ColumnInt("y", y),
new ColumnInt("z", z),
new ColumnInt("yaw", yaw),
new ColumnInt("pitch", pitch),
new ColumnVarChar("quests", 500, GSON.toJson(data.getQuestData())),
new ColumnInt("slots", slots),
new ColumnVarChar("items", 10000, GSON.toJson(itemsMap)),
new ColumnVarChar("armour", 1000, GSON.toJson(armourMap))
);
}
_exists.remove(Integer.valueOf(accountId));
}
public void deletePersistence(CoreClient client)
{
int accountId = client.getAccountId();
executeUpdate(DELETE_DATA, new ColumnInt("accountId", accountId));
_exists.remove(Integer.valueOf(accountId));
}
public boolean exists(CoreClient client)
{
return _exists.contains(client.getAccountId());
}
private ItemMeta deserialiseMeta(Object map)
{
if (!(map instanceof Map))
{
return null;
}
try
{
Class<?> clazz = Class.forName("org.bukkit.craftbukkit.v1_8_R3.inventory.CraftMetaItem");
Constructor<?> constructor = clazz.getDeclaredConstructor(Map.class);
constructor.setAccessible(true);
ItemMeta meta = (ItemMeta) constructor.newInstance(map);
meta.setDisplayName((String) ((Map) map).get("displayName"));
return meta;
}
catch (Exception e)
{
e.printStackTrace();
}
return null;
}
}

View File

@ -4,6 +4,7 @@ import java.util.List;
import java.util.UUID; import java.util.UUID;
import java.util.concurrent.TimeUnit; import java.util.concurrent.TimeUnit;
import mineplex.core.common.util.*;
import net.md_5.bungee.api.ChatColor; import net.md_5.bungee.api.ChatColor;
import org.bukkit.Bukkit; import org.bukkit.Bukkit;
@ -25,14 +26,7 @@ import org.bukkit.metadata.FixedMetadataValue;
import mineplex.core.MiniClientPlugin; import mineplex.core.MiniClientPlugin;
import mineplex.core.ReflectivelyCreateMiniPlugin; import mineplex.core.ReflectivelyCreateMiniPlugin;
import mineplex.core.common.currency.GlobalCurrency; import mineplex.core.common.currency.GlobalCurrency;
import mineplex.core.common.util.C;
import mineplex.core.common.util.F;
import mineplex.core.common.util.UtilInv;
import mineplex.core.common.util.UtilItem;
import mineplex.core.common.util.UtilItem.ItemAttribute; import mineplex.core.common.util.UtilItem.ItemAttribute;
import mineplex.core.common.util.UtilMath;
import mineplex.core.common.util.UtilTextMiddle;
import mineplex.core.common.util.UtilTime;
import mineplex.core.itemstack.ItemBuilder; import mineplex.core.itemstack.ItemBuilder;
import mineplex.core.menu.Menu; import mineplex.core.menu.Menu;
import mineplex.core.recharge.Recharge; import mineplex.core.recharge.Recharge;
@ -491,7 +485,7 @@ public class QuestModule extends MiniClientPlugin<QuestPlayerData>
@EventHandler @EventHandler
public void debug(PlayerCommandPreprocessEvent event) public void debug(PlayerCommandPreprocessEvent event)
{ {
if (event.getMessage().startsWith("/test")) if (event.getMessage().startsWith("/questdatatest"))
{ {
event.setCancelled(true); event.setCancelled(true);
Player player = event.getPlayer(); Player player = event.getPlayer();

View File

@ -5,6 +5,7 @@ import java.util.List;
import java.util.Map; import java.util.Map;
import java.util.UUID; import java.util.UUID;
import mineplex.core.recharge.Recharge;
import org.bukkit.Bukkit; import org.bukkit.Bukkit;
import org.bukkit.Location; import org.bukkit.Location;
import org.bukkit.entity.HumanEntity; import org.bukkit.entity.HumanEntity;
@ -12,6 +13,7 @@ import org.bukkit.entity.LivingEntity;
import org.bukkit.entity.Player; import org.bukkit.entity.Player;
import org.bukkit.entity.Projectile; import org.bukkit.entity.Projectile;
import org.bukkit.event.EventHandler; import org.bukkit.event.EventHandler;
import org.bukkit.event.EventPriority;
import org.bukkit.event.entity.EntityDamageByEntityEvent; import org.bukkit.event.entity.EntityDamageByEntityEvent;
import org.bukkit.event.entity.EntityDamageEvent; import org.bukkit.event.entity.EntityDamageEvent;
import org.bukkit.event.entity.FoodLevelChangeEvent; import org.bukkit.event.entity.FoodLevelChangeEvent;
@ -112,7 +114,7 @@ public class SafezoneModule extends MiniPlugin
{ {
_playerStatus.setStatus(player, PlayerStatusType.SAFE, true); _playerStatus.setStatus(player, PlayerStatusType.SAFE, true);
} }
else else if (Recharge.Instance.usable(player, "Cash Out"))
{ {
_playerStatus.setStatus(player, PlayerStatusType.SAFE); _playerStatus.setStatus(player, PlayerStatusType.SAFE);
} }
@ -128,7 +130,7 @@ public class SafezoneModule extends MiniPlugin
_currentSafezone.remove(player.getUniqueId()); _currentSafezone.remove(player.getUniqueId());
} }
@EventHandler @EventHandler(priority = EventPriority.HIGHEST)
public void entityDamage(EntityDamageEvent event) public void entityDamage(EntityDamageEvent event)
{ {
if (!(event.getEntity() instanceof Player)) if (!(event.getEntity() instanceof Player))
@ -138,10 +140,15 @@ public class SafezoneModule extends MiniPlugin
Player player = (Player) event.getEntity(); Player player = (Player) event.getEntity();
if (isInSafeZone(player)) if (isInSafeZone(player) && _playerStatus.Get(player).getStatusType() != PlayerStatusType.COMBAT)
{ {
event.setCancelled(true); event.setCancelled(true);
} }
if (!Recharge.Instance.usable(player, "Cash Out"))
{
event.setCancelled(false);
}
} }
@EventHandler @EventHandler

View File

@ -67,35 +67,16 @@ public class SpawnModule extends MiniPlugin
addCommand(new HubCommand(this)); addCommand(new HubCommand(this));
} }
@EventHandler(priority = EventPriority.HIGHEST) @EventHandler(priority = EventPriority.LOWEST)
public void playerJoin(PlayerJoinEvent event) public void playerJoin(PlayerJoinEvent event)
{ {
if (_spawn == null || _center == null) if (_spawn == null || _center == null)
{ {
_spawn = _worldData.getCustomLocation("PLAYER_SPAWN").get(0); _spawn = _worldData.getCustomLocation("PLAYER_SPAWN").get(0);
_center = new Location(_worldData.World, 0, 64, 0); _center = new Location(_worldData.World, 0, 64, 0);
_worldData.World.setSpawnLocation(_spawn.getBlockX(), _spawn.getBlockY(), _spawn.getBlockZ());
} }
Player player = event.getPlayer();
if (_npc.hasNPC(player))
{
QuitNPC npc = _npc.getNPC(player);
npc.despawn();
npc.restore(player);
return;
}
player.teleport(_spawn);
player.setFoodLevel(20);
player.setExhaustion(0);
player.setLevel(0);
player.setExp(0);
player.getInventory().clear();
player.getInventory().setArmorContents(null);
player.updateInventory();
if (_npcsSpawned) if (_npcsSpawned)
{ {
return; return;

View File

@ -5,19 +5,18 @@ import java.io.IOException;
import java.util.HashSet; import java.util.HashSet;
import java.util.Set; import java.util.Set;
import mineplex.core.common.util.*;
import org.bukkit.DyeColor; import org.bukkit.DyeColor;
import org.bukkit.Location; import org.bukkit.Location;
import org.bukkit.Material; import org.bukkit.Material;
import org.bukkit.block.Block; import org.bukkit.block.Block;
import org.bukkit.entity.FallingBlock; import org.bukkit.entity.FallingBlock;
import org.bukkit.scheduler.BukkitRunnable;
import org.bukkit.util.BlockVector; import org.bukkit.util.BlockVector;
import mineplex.core.common.block.schematic.Schematic; import mineplex.core.common.block.schematic.Schematic;
import mineplex.core.common.block.schematic.SchematicData; import mineplex.core.common.block.schematic.SchematicData;
import mineplex.core.common.block.schematic.UtilSchematic; import mineplex.core.common.block.schematic.UtilSchematic;
import mineplex.core.common.util.UtilFirework;
import mineplex.core.common.util.UtilMath;
import mineplex.core.common.util.UtilShapes;
/** /**
* Represents an instance of a Supply Drop. <br> * Represents an instance of a Supply Drop. <br>
@ -101,11 +100,7 @@ public class SupplyDrop
if (_blade != null) if (_blade != null)
{ {
if (UtilMath.offset2d(_blade, _destination) < 1) if (UtilMath.offset2d(_blade, _despawn) < 1)
{
spawnLootChest();
}
else if (UtilMath.offset2d(_blade, _despawn) < 1)
{ {
for (Block block : _bladeBlocks) for (Block block : _bladeBlocks)
{ {
@ -198,16 +193,6 @@ public class SupplyDrop
} }
} }
public void spawnLootChest()
{
FallingBlock fallingBlock = _blade.getWorld().spawnFallingBlock(_blade.clone().subtract(0, 10, 0), Material.WOOD, (byte) 0);
fallingBlock.setHurtEntities(false);
fallingBlock.setDropItem(false);
UtilFirework.playFirework(fallingBlock.getLocation().add(0.5, 1, 0.5), UtilFirework.getRandomFireworkEffect(false, 2, 1));
}
public final String getName() public final String getName()
{ {
return _name; return _name;
@ -222,4 +207,6 @@ public class SupplyDrop
{ {
return _destination; return _destination;
} }
public final Location getBladeLocation() { return _blade; }
} }

View File

@ -1,37 +1,32 @@
package mineplex.gemhunters.supplydrop; package mineplex.gemhunters.supplydrop;
import mineplex.core.MiniPlugin;
import mineplex.core.ReflectivelyCreateMiniPlugin;
import mineplex.core.blockrestore.BlockRestore;
import mineplex.core.common.Pair;
import mineplex.core.common.util.*;
import mineplex.core.updater.UpdateType;
import mineplex.core.updater.event.UpdateEvent;
import mineplex.gemhunters.loot.LootModule;
import mineplex.gemhunters.supplydrop.command.SupplyDropCommand;
import mineplex.gemhunters.world.WorldDataModule;
import org.bukkit.Color;
import org.bukkit.FireworkEffect;
import org.bukkit.Location;
import org.bukkit.Material;
import org.bukkit.block.Block;
import org.bukkit.block.BlockFace;
import org.bukkit.entity.FallingBlock;
import org.bukkit.event.EventHandler;
import org.bukkit.event.entity.ItemSpawnEvent;
import org.bukkit.scheduler.BukkitRunnable;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.HashSet; import java.util.HashSet;
import java.util.List; import java.util.List;
import java.util.Set; import java.util.Set;
import java.util.concurrent.TimeUnit; import java.util.concurrent.TimeUnit;
import org.bukkit.Location;
import org.bukkit.Material;
import org.bukkit.block.Block;
import org.bukkit.entity.FallingBlock;
import org.bukkit.event.EventHandler;
import org.bukkit.event.entity.EntityChangeBlockEvent;
import org.bukkit.event.entity.ItemSpawnEvent;
import mineplex.core.MiniPlugin;
import mineplex.core.ReflectivelyCreateMiniPlugin;
import mineplex.core.blockrestore.BlockRestore;
import mineplex.core.common.Pair;
import mineplex.core.common.util.C;
import mineplex.core.common.util.F;
import mineplex.core.common.util.UtilBlock;
import mineplex.core.common.util.UtilMath;
import mineplex.core.common.util.UtilServer;
import mineplex.core.common.util.UtilTextMiddle;
import mineplex.core.common.util.UtilTime;
import mineplex.core.common.util.UtilWorld;
import mineplex.core.updater.UpdateType;
import mineplex.core.updater.event.UpdateEvent;
import mineplex.gemhunters.loot.LootModule;
import mineplex.gemhunters.supplydrop.command.SupplyDropCommand;
import mineplex.gemhunters.world.WorldDataModule;
@ReflectivelyCreateMiniPlugin @ReflectivelyCreateMiniPlugin
public class SupplyDropModule extends MiniPlugin public class SupplyDropModule extends MiniPlugin
{ {
@ -85,6 +80,10 @@ public class SupplyDropModule extends MiniPlugin
{ {
stopSequence(); stopSequence();
} }
else if (UtilMath.offset2d(_current.getBladeLocation(), _current.getChestLocation()) < 1)
{
spawnLootChest();
}
} }
else if (UtilTime.elapsed(_lastSupplyDrop, SEQUENCE_TIMER)) else if (UtilTime.elapsed(_lastSupplyDrop, SEQUENCE_TIMER))
{ {
@ -103,31 +102,6 @@ public class SupplyDropModule extends MiniPlugin
} }
} }
@EventHandler
public void fallingBlockChange(EntityChangeBlockEvent event)
{
if (event.getEntity() instanceof FallingBlock && event.getTo() == Material.WOOD && isActive() && UtilMath.offsetSquared(_current.getChestLocation(), event.getBlock().getLocation()) < 16)
{
Block block = event.getBlock();
block.setType(Material.CHEST);
// Add location that the chest will appear at into the spawned
// chests list so that LootModule can populate it with loot.
_loot.addSpawnedChest(block.getLocation(), CHEST_COLOUR);
// Remove beacon
for (Block beacon : _beaconBlocks)
{
_blockRestore.restore(beacon);
}
_beaconBlocks.clear();
event.setCancelled(true);
}
}
public void startSequence(String locationKey) public void startSequence(String locationKey)
{ {
Location spawn = _worldData.getCustomLocation(LOCATION_DATA + " " + locationKey + " Start").get(0); Location spawn = _worldData.getCustomLocation(LOCATION_DATA + " " + locationKey + " Start").get(0);
@ -168,6 +142,43 @@ public class SupplyDropModule extends MiniPlugin
_current = null; _current = null;
} }
public void spawnLootChest()
{
Location chest = _current.getBladeLocation().clone().subtract(0, 10, 0);
runSyncTimer(new BukkitRunnable()
{
Block chestBlock = chest.getBlock();
@Override
public void run()
{
chestBlock.setType(Material.AIR);
chestBlock = chestBlock.getRelative(BlockFace.DOWN);
chestBlock.setType(Material.CHEST);
if (chestBlock.getRelative(BlockFace.DOWN).getType() != Material.AIR)
{
// Add location that the chest will appear at into the spawned
// chests list so that LootModule can populate it with loot.
_loot.addSpawnedChest(chestBlock.getLocation(), CHEST_COLOUR);
// Remove beacon
for (Block beacon : _beaconBlocks)
{
_blockRestore.restore(beacon);
}
_beaconBlocks.clear();
cancel();
}
UtilFirework.playFirework(chestBlock.getLocation().add(0.5, 1, 0.5), FireworkEffect.Type.BALL, Color.YELLOW, true, false);
}
}, 0, 5);
}
public boolean isActive() public boolean isActive()
{ {
return _current != null; return _current != null;

View File

@ -1,5 +1,8 @@
package mineplex.gemhunters.tutorial; package mineplex.gemhunters.tutorial;
import mineplex.core.updater.UpdateType;
import mineplex.core.updater.event.UpdateEvent;
import org.bukkit.Bukkit;
import org.bukkit.Location; import org.bukkit.Location;
import org.bukkit.entity.Player; import org.bukkit.entity.Player;
@ -11,8 +14,10 @@ import mineplex.core.texttutorial.tutorial.Tutorial;
import mineplex.gemhunters.economy.EconomyModule; import mineplex.gemhunters.economy.EconomyModule;
import mineplex.gemhunters.spawn.SpawnModule; import mineplex.gemhunters.spawn.SpawnModule;
import mineplex.gemhunters.world.WorldDataModule; import mineplex.gemhunters.world.WorldDataModule;
import org.bukkit.event.EventHandler;
import org.bukkit.event.Listener;
public class GemHuntersTutorial extends Tutorial public class GemHuntersTutorial extends Tutorial implements Listener
{ {
private final SpawnModule _spawn; private final SpawnModule _spawn;
@ -51,7 +56,7 @@ public class GemHuntersTutorial extends Tutorial
})); }));
addPhase(new Phase(getLocation(1), "PVP", new String[] { addPhase(new Phase(getLocation(1), "PVP", new String[] {
"Players start with " + C.cGreen + EconomyModule.GEM_START_COST + C.cWhite + " Gems and must survive in the city.", "Players start with " + C.cGreen + EconomyModule.GEM_START_COST + C.cWhite + " Gems and must survive in the city.",
"Killing another player will gift you " + C.cYellow + "50%" + C.cWhite + "of their total gems.", "Killing another player will gift you " + C.cYellow + "50%" + C.cWhite + " of their total gems.",
})); }));
addPhase(new Phase(getLocation(2), "Safezones", new String[] { addPhase(new Phase(getLocation(2), "Safezones", new String[] {
"In Safe Zones you cannot take damage and can purchase items like", "In Safe Zones you cannot take damage and can purchase items like",
@ -59,8 +64,8 @@ public class GemHuntersTutorial extends Tutorial
})); }));
addPhase(new Phase(getLocation(3), "Items", new String[] { addPhase(new Phase(getLocation(3), "Items", new String[] {
"Collect items from chests and powerup.", "Collect items from chests and powerup.",
"You can find anything from Weaponrs to Cosmetics.", "You can find anything from Weapons to Cosmetics.",
"If you find somethiing you want to keep you can", "If you find something you want to keep you can",
C.cGreen + "Cash Out" + C.cWhite + " at any time by right clicking the " + C.cGreen + "Emerald" + C.cWhite + " in your inventory.", C.cGreen + "Cash Out" + C.cWhite + " at any time by right clicking the " + C.cGreen + "Emerald" + C.cWhite + " in your inventory.",
})); }));
addPhase(new Phase(getLocation(4), "Cashing Out", new String[] { addPhase(new Phase(getLocation(4), "Cashing Out", new String[] {
@ -71,6 +76,8 @@ public class GemHuntersTutorial extends Tutorial
addPhase(new Phase(getLocation(5), "Good luck", new String[] { addPhase(new Phase(getLocation(5), "Good luck", new String[] {
"Stay safe! Anarchy rules in the world of " + C.cGreen + "Gem Hunters" + C.cWhite + "!" "Stay safe! Anarchy rules in the world of " + C.cGreen + "Gem Hunters" + C.cWhite + "!"
})); }));
UtilServer.RegisterEvents(this);
} }
@Override @Override
@ -100,4 +107,21 @@ public class GemHuntersTutorial extends Tutorial
return new Location(_worldData.World, locations[0] + 0.5, locations[1] + 0.5, locations[2] + 0.5, locations[3], locations[4]); return new Location(_worldData.World, locations[0] + 0.5, locations[1] + 0.5, locations[2] + 0.5, locations[3], locations[4]);
} }
@EventHandler
public void updateFlight(UpdateEvent event)
{
if (event.getType() != UpdateType.FASTER)
{
return;
}
for (Player player : Bukkit.getOnlinePlayers())
{
if (isInTutorial(player) && !player.isFlying())
{
player.setFlying(true);
}
}
}
} }

View File

@ -112,7 +112,9 @@ public class WorldDataModule extends MiniPlugin
{ {
Location loc = stringToLocation(tokens[i]); Location loc = stringToLocation(tokens[i]);
if (loc == null) if (loc == null)
{
continue; continue;
}
loc.setYaw(currentDirection); loc.setYaw(currentDirection);
@ -132,7 +134,9 @@ public class WorldDataModule extends MiniPlugin
{ {
Location loc = stringToLocation(tokens[i]); Location loc = stringToLocation(tokens[i]);
if (loc == null) if (loc == null)
{
continue; continue;
}
currentData.add(loc); currentData.add(loc);
} }
@ -150,7 +154,9 @@ public class WorldDataModule extends MiniPlugin
{ {
Location loc = stringToLocation(tokens[i]); Location loc = stringToLocation(tokens[i]);
if (loc == null) if (loc == null)
{
continue; continue;
}
currentData.add(loc); currentData.add(loc);
} }

View File

@ -14,21 +14,13 @@ import org.bukkit.entity.Player;
import org.bukkit.event.EventHandler; import org.bukkit.event.EventHandler;
import org.bukkit.event.EventPriority; import org.bukkit.event.EventPriority;
import org.bukkit.event.Listener; import org.bukkit.event.Listener;
import org.bukkit.event.block.BlockBreakEvent; import org.bukkit.event.block.*;
import org.bukkit.event.block.BlockBurnEvent;
import org.bukkit.event.block.BlockFadeEvent;
import org.bukkit.event.block.BlockIgniteEvent;
import org.bukkit.event.block.BlockIgniteEvent.IgniteCause; import org.bukkit.event.block.BlockIgniteEvent.IgniteCause;
import org.bukkit.event.block.BlockPlaceEvent;
import org.bukkit.event.block.LeavesDecayEvent;
import org.bukkit.event.entity.EntityDamageEvent; import org.bukkit.event.entity.EntityDamageEvent;
import org.bukkit.event.entity.FoodLevelChangeEvent; import org.bukkit.event.entity.FoodLevelChangeEvent;
import org.bukkit.event.hanging.HangingBreakEvent; import org.bukkit.event.hanging.HangingBreakEvent;
import org.bukkit.event.player.PlayerArmorStandManipulateEvent; import org.bukkit.event.inventory.FurnaceSmeltEvent;
import org.bukkit.event.player.PlayerInteractAtEntityEvent; import org.bukkit.event.player.*;
import org.bukkit.event.player.PlayerInteractEntityEvent;
import org.bukkit.event.player.PlayerInteractEvent;
import org.bukkit.event.player.PlayerQuitEvent;
import org.bukkit.event.weather.WeatherChangeEvent; import org.bukkit.event.weather.WeatherChangeEvent;
import org.bukkit.event.world.ChunkUnloadEvent; import org.bukkit.event.world.ChunkUnloadEvent;
import org.bukkit.plugin.java.JavaPlugin; import org.bukkit.plugin.java.JavaPlugin;
@ -52,7 +44,8 @@ public class WorldListeners implements Listener
@EventHandler @EventHandler
public void deletePlayerData(PlayerQuitEvent event) public void deletePlayerData(PlayerQuitEvent event)
{ {
_plugin.getServer().getScheduler().runTaskLater(_plugin, () -> { _plugin.getServer().getScheduler().runTaskLater(_plugin, () ->
{
World world = event.getPlayer().getWorld(); World world = event.getPlayer().getWorld();
UUID uuid = event.getPlayer().getUniqueId(); UUID uuid = event.getPlayer().getUniqueId();
String path = world.getWorldFolder().getPath(); String path = world.getWorldFolder().getPath();
@ -213,6 +206,29 @@ public class WorldListeners implements Listener
} }
} }
@EventHandler
public void bucketEmpty(PlayerBucketEmptyEvent event)
{
event.setCancelled(true);
}
@EventHandler
public void fishingExpRemove(PlayerFishEvent event)
{
event.setExpToDrop(0);
}
@EventHandler
public void smelt(BlockExpEvent event)
{
Material material = event.getBlock().getType();
if (material == Material.FURNACE || material == Material.BURNING_FURNACE)
{
event.setExpToDrop(0);
}
}
public boolean shouldBlock(Player player) public boolean shouldBlock(Player player)
{ {
return player.getGameMode() != GameMode.CREATIVE; return player.getGameMode() != GameMode.CREATIVE;

View File

@ -37,7 +37,6 @@ public class BlizzardWorldEvent extends WorldEvent
private static final double START_CHANCE = 0.01; private static final double START_CHANCE = 0.01;
private static final long MAX_TIME = TimeUnit.MINUTES.toMillis(10); private static final long MAX_TIME = TimeUnit.MINUTES.toMillis(10);
private static final long GRACE_TIME = TimeUnit.SECONDS.toMillis(60); private static final long GRACE_TIME = TimeUnit.SECONDS.toMillis(60);
private static final long WARM_TIME = TimeUnit.SECONDS.toMillis(5);
private static final int DAMAGE = 2; private static final int DAMAGE = 2;
private static final String TIP = "EQUIP LEATHER ARMOUR OR GET NEAR A FIRE"; private static final String TIP = "EQUIP LEATHER ARMOUR OR GET NEAR A FIRE";
@ -108,8 +107,13 @@ public class BlizzardWorldEvent extends WorldEvent
{ {
if (shouldDamage(player)) if (shouldDamage(player))
{ {
_playerStatus.setStatus(player, PlayerStatusType.COLD);
_damage.NewDamageEvent(player, null, null, DamageCause.CUSTOM, DAMAGE, false, true, true, "Hurricane", "Frostbite"); _damage.NewDamageEvent(player, null, null, DamageCause.CUSTOM, DAMAGE, false, true, true, "Hurricane", "Frostbite");
} }
else
{
_playerStatus.setStatus(player, PlayerStatusType.WARM);
}
} }
} }
} }
@ -141,31 +145,9 @@ public class BlizzardWorldEvent extends WorldEvent
} }
} }
_playerStatus.setStatus(player, PlayerStatusType.WARM, WARM_TIME);
return false; return false;
} }
@EventHandler
public void updatePlayerStatus(UpdateEvent event)
{
if (event.getType() != UpdateType.SLOW || !isLive())
{
return;
}
for (Player player : Bukkit.getOnlinePlayers())
{
PlayerStatus status = _playerStatus.Get(player);
if (status.getStatusType() == PlayerStatusType.COLD)
{
continue;
}
_playerStatus.setStatus(player, PlayerStatusType.COLD, true);
}
}
@Override @Override
public void onStart() public void onStart()
{ {

View File

@ -73,7 +73,7 @@ public class GiantWorldEvent extends WorldEvent
public void onEnd() public void onEnd()
{ {
ItemStack itemStack = SkinData.OMEGA_CHEST.getSkull(C.cAqua + "Omega Chest", new ArrayList<>()); ItemStack itemStack = SkinData.OMEGA_CHEST.getSkull(C.cAqua + "Omega Chest", new ArrayList<>());
LootChestReward reward = new LootChestReward(CASH_OUT_DELAY, SkinData.OMEGA_CHEST.getSkull(C.cAqua + "Omega Chest", null), "Omega", 1); LootChestReward reward = new LootChestReward(CASH_OUT_DELAY, itemStack, "Omega", 1);
_worldData.World.dropItemNaturally(getEventLocations()[0], itemStack); _worldData.World.dropItemNaturally(getEventLocations()[0], itemStack);