Merge branch 'develop' into update/mayitems
This commit is contained in:
commit
92eaf4f8d8
@ -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),
|
||||
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),
|
||||
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),
|
||||
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),
|
||||
|
@ -5,6 +5,7 @@ import java.util.Iterator;
|
||||
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.Sound;
|
||||
import org.bukkit.craftbukkit.v1_8_R3.entity.CraftPlayer;
|
||||
import org.bukkit.entity.LivingEntity;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.event.EventHandler;
|
||||
@ -75,6 +76,8 @@ public class TextTutorialManager extends MiniPlugin
|
||||
{
|
||||
other.hidePlayer(event.getPlayer());
|
||||
}
|
||||
|
||||
((CraftPlayer) event.getPlayer()).getHandle().spectating = true;
|
||||
|
||||
return;
|
||||
}
|
||||
@ -116,7 +119,9 @@ public class TextTutorialManager extends MiniPlugin
|
||||
{
|
||||
other.showPlayer(player);
|
||||
}
|
||||
|
||||
|
||||
((CraftPlayer) player).getHandle().spectating = false;
|
||||
|
||||
//Gems
|
||||
if (tut.getGemReward() > 0)
|
||||
{
|
||||
|
@ -130,6 +130,7 @@ import mineplex.hub.modules.MavericksManager;
|
||||
import mineplex.hub.modules.NewsManager;
|
||||
import mineplex.hub.modules.ParkourManager;
|
||||
import mineplex.hub.modules.SoccerManager;
|
||||
import mineplex.hub.modules.TemporaryGemHuntersServerSender;
|
||||
import mineplex.hub.modules.ValentinesManager;
|
||||
import mineplex.hub.modules.WorldManager;
|
||||
import mineplex.hub.modules.salesannouncements.SalesAnnouncementManager;
|
||||
@ -291,6 +292,8 @@ public class HubManager extends MiniClientPlugin<HubClient> implements IChatMess
|
||||
|
||||
new EasterEggHunt(plugin, _clientManager);
|
||||
|
||||
new TemporaryGemHuntersServerSender(_portal);
|
||||
|
||||
ScoreboardManager scoreboardManager = new ScoreboardManager(plugin)
|
||||
{
|
||||
@Override
|
||||
|
@ -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!");
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
@ -120,7 +120,7 @@ public class ServerGameMenu extends ShopPageBase<ServerManager, QuickShop>
|
||||
C.Reset + "Extremely hard team-based survival ",
|
||||
C.Reset + "Gather materials and fight your way",
|
||||
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[]
|
||||
{
|
||||
|
@ -24,38 +24,22 @@ public class UHCServerTypePage extends ShopPageBase<ServerManager, ServerNpcShop
|
||||
@Override
|
||||
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[]
|
||||
{
|
||||
C.Reset + "",
|
||||
C.Reset + C.cGreen + "Click to Play",
|
||||
}).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[]
|
||||
{
|
||||
C.Reset + "",
|
||||
C.Reset + C.cGreen + "Click to Play",
|
||||
}).build());
|
||||
|
||||
setItem(14, new ItemBuilder(Material.SKULL_ITEM, 1, (byte) 3).setTitle(C.Reset + C.cYellow + "UHC Speed Solo")
|
||||
.addLore(new String[]
|
||||
{
|
||||
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")));
|
||||
getButtonMap().put(12, (player, __) -> getShop().openPageForPlayer(player, new ServerNpcPage(getPlugin(), getShop(), getClientManager(), getDonationManager(), "UHC Solo", player, "UHC2")));
|
||||
getButtonMap().put(14, (player, __) -> getShop().openPageForPlayer(player, new ServerNpcPage(getPlugin(), getShop(), getClientManager(), getDonationManager(), "UHC", player, "UHC")));
|
||||
}
|
||||
|
||||
public void Update()
|
||||
|
@ -11,9 +11,15 @@ import org.bukkit.entity.EnderDragon;
|
||||
import org.bukkit.entity.Item;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.event.EventHandler;
|
||||
import org.bukkit.event.entity.EntityTargetEvent;
|
||||
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.UtilAlg;
|
||||
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.event.UpdateEvent;
|
||||
import mineplex.minecraft.game.core.damage.CustomDamageEvent;
|
||||
|
||||
import nautilus.game.arcade.ArcadeManager;
|
||||
import nautilus.game.arcade.GameType;
|
||||
import nautilus.game.arcade.events.PlayerStateChangeEvent;
|
||||
import nautilus.game.arcade.game.SoloGame;
|
||||
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.kit.Kit;
|
||||
import nautilus.game.arcade.kit.Perk;
|
||||
@ -80,6 +89,12 @@ public class Dragons extends SoloGame
|
||||
.setGiveCompassToSpecs(true)
|
||||
.setGiveCompassToAlive(false)
|
||||
.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
|
||||
|
@ -78,6 +78,7 @@ import nautilus.game.arcade.GameType;
|
||||
import nautilus.game.arcade.events.GameStateChangeEvent;
|
||||
import nautilus.game.arcade.game.Game;
|
||||
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.KitJouster;
|
||||
import nautilus.game.arcade.game.games.skyfall.kits.KitSpeeder;
|
||||
@ -169,7 +170,7 @@ public abstract class Skyfall extends Game
|
||||
new Kit[]
|
||||
{
|
||||
new KitSpeeder(manager),
|
||||
//new KitBooster(manager), // Broken? :(
|
||||
new KitBooster(manager),
|
||||
new KitJouster(manager),
|
||||
new KitStunner(manager),
|
||||
//new KitSurefoot(manager),
|
||||
|
@ -40,7 +40,7 @@ public class PerkElytraBoost extends Perk
|
||||
{
|
||||
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;
|
||||
@ -63,6 +63,7 @@ public class PerkElytraBoost extends Perk
|
||||
if (!UtilPlayer.isGliding(player) || !Recharge.Instance.usable(player, GetName()))
|
||||
{
|
||||
player.setAllowFlight(false);
|
||||
player.setFlying(false);
|
||||
return;
|
||||
}
|
||||
player.setAllowFlight(true);
|
||||
|
@ -14,8 +14,6 @@ import mineplex.core.TimingsFix;
|
||||
import mineplex.core.account.CoreClientManager;
|
||||
import mineplex.core.achievement.AchievementManager;
|
||||
import mineplex.core.antihack.AntiHack;
|
||||
import mineplex.core.aprilfools.AprilFoolsManager;
|
||||
import mineplex.core.beta.BetaWhitelist;
|
||||
import mineplex.core.blockrestore.BlockRestore;
|
||||
import mineplex.core.boosters.BoosterManager;
|
||||
import mineplex.core.chat.Chat;
|
||||
@ -54,7 +52,6 @@ import mineplex.core.party.PartyManager;
|
||||
import mineplex.core.pet.PetManager;
|
||||
import mineplex.core.portal.GenericServer;
|
||||
import mineplex.core.portal.Portal;
|
||||
import mineplex.core.powerplayclub.PowerPlayClubRepository;
|
||||
import mineplex.core.preferences.PreferencesManager;
|
||||
import mineplex.core.projectile.ProjectileManager;
|
||||
import mineplex.core.punish.Punish;
|
||||
@ -64,7 +61,9 @@ import mineplex.core.report.ReportPlugin;
|
||||
import mineplex.core.serverConfig.ServerConfiguration;
|
||||
import mineplex.core.stats.StatsManager;
|
||||
import mineplex.core.status.ServerStatusManager;
|
||||
import mineplex.core.task.TaskManager;
|
||||
import mineplex.core.teleport.Teleport;
|
||||
import mineplex.core.texttutorial.TextTutorialManager;
|
||||
import mineplex.core.thank.ThankManager;
|
||||
import mineplex.core.twofactor.TwoFactorAuth;
|
||||
import mineplex.core.updater.FileUpdater;
|
||||
@ -77,11 +76,13 @@ import mineplex.gemhunters.death.DeathModule;
|
||||
import mineplex.gemhunters.death.quitnpc.QuitNPCModule;
|
||||
import mineplex.gemhunters.economy.CashOutModule;
|
||||
import mineplex.gemhunters.economy.EconomyModule;
|
||||
import mineplex.gemhunters.join.JoinModule;
|
||||
import mineplex.gemhunters.loot.InventoryModule;
|
||||
import mineplex.gemhunters.loot.LootModule;
|
||||
import mineplex.gemhunters.map.ItemMapModule;
|
||||
import mineplex.gemhunters.moderation.ModerationModule;
|
||||
import mineplex.gemhunters.mount.MountModule;
|
||||
import mineplex.gemhunters.persistence.PersistenceModule;
|
||||
import mineplex.gemhunters.playerstatus.PlayerStatusModule;
|
||||
import mineplex.gemhunters.quest.QuestModule;
|
||||
import mineplex.gemhunters.safezone.SafezoneModule;
|
||||
@ -89,6 +90,7 @@ import mineplex.gemhunters.scoreboard.ScoreboardModule;
|
||||
import mineplex.gemhunters.shop.ShopModule;
|
||||
import mineplex.gemhunters.spawn.SpawnModule;
|
||||
import mineplex.gemhunters.supplydrop.SupplyDropModule;
|
||||
import mineplex.gemhunters.tutorial.GemHuntersTutorial;
|
||||
import mineplex.gemhunters.world.DebugListeners;
|
||||
import mineplex.gemhunters.world.TimeCycle;
|
||||
import mineplex.gemhunters.world.UndergroundMobs;
|
||||
@ -173,7 +175,7 @@ public class GemHunters extends JavaPlugin
|
||||
Portal portal = new Portal();
|
||||
|
||||
// File Updater
|
||||
new FileUpdater(this, portal, serverStatusManager.getCurrentServerName(), serverStatusManager.getRegion(), GenericServer.BETA_HUB);
|
||||
new FileUpdater(this, portal, serverStatusManager.getCurrentServerName(), serverStatusManager.getRegion(), GenericServer.HUB);
|
||||
|
||||
// Punish
|
||||
Punish punish = new Punish(this, clientManager);
|
||||
@ -265,8 +267,8 @@ public class GemHunters extends JavaPlugin
|
||||
gadgetManager.setGadgetEnabled(false);
|
||||
|
||||
// Tutorials
|
||||
//TextTutorialManager tutorialManager = new TextTutorialManager(this, donationManager, new TaskManager(this, clientManager));
|
||||
//tutorialManager.addTutorial(new GemHuntersTutorial());
|
||||
TextTutorialManager tutorialManager = new TextTutorialManager(this, donationManager, new TaskManager(this, clientManager));
|
||||
tutorialManager.addTutorial(new GemHuntersTutorial());
|
||||
|
||||
// Now we finally get to enable the Gem Hunters modules
|
||||
// Though if any other module needs one of these it will be generated in
|
||||
@ -280,8 +282,10 @@ public class GemHunters extends JavaPlugin
|
||||
require(InventoryModule.class);
|
||||
require(LootModule.class);
|
||||
require(ItemMapModule.class);
|
||||
require(JoinModule.class);
|
||||
require(ModerationModule.class);
|
||||
require(MountModule.class);
|
||||
require(PersistenceModule.class);
|
||||
require(PlayerStatusModule.class);
|
||||
require(QuestModule.class);
|
||||
require(QuitNPCModule.class);
|
||||
@ -297,10 +301,8 @@ public class GemHunters extends JavaPlugin
|
||||
new WorldListeners(this);
|
||||
new TimeCycle(this);
|
||||
new UndergroundMobs(this);
|
||||
new DebugListeners(this);
|
||||
|
||||
AprilFoolsManager.getInstance();
|
||||
|
||||
new DebugListeners(this);
|
||||
|
||||
// UpdateEvent!!!
|
||||
new Updater(this);
|
||||
|
||||
@ -316,9 +318,6 @@ public class GemHunters extends JavaPlugin
|
||||
|
||||
// Two-factor auth
|
||||
require(TwoFactorAuth.class);
|
||||
|
||||
// beta whitelist
|
||||
new BetaWhitelist(clientManager, new PowerPlayClubRepository(this, clientManager, donationManager));
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -70,14 +70,6 @@ public class DeathModule extends MiniPlugin
|
||||
_toRemove = new HashMap<>();
|
||||
}
|
||||
|
||||
@EventHandler(priority = EventPriority.MONITOR)
|
||||
public void join(PlayerJoinEvent event)
|
||||
{
|
||||
PlayerCustomRespawnEvent event2 = new PlayerCustomRespawnEvent(event.getPlayer());
|
||||
|
||||
UtilServer.CallEvent(event2);
|
||||
}
|
||||
|
||||
@EventHandler
|
||||
public void death(PlayerDeathEvent event)
|
||||
{
|
||||
|
@ -10,20 +10,27 @@ public class QuitNPCDespawnEvent extends Event implements Cancellable
|
||||
{
|
||||
|
||||
private static final HandlerList HANDLERS = new HandlerList();
|
||||
|
||||
|
||||
private final QuitNPC _npc;
|
||||
private final boolean _pluginRemove;
|
||||
private boolean _cancel;
|
||||
|
||||
public QuitNPCDespawnEvent(QuitNPC npc)
|
||||
|
||||
public QuitNPCDespawnEvent(QuitNPC npc, boolean pluginRemove)
|
||||
{
|
||||
_npc = npc;
|
||||
_pluginRemove = pluginRemove;
|
||||
}
|
||||
|
||||
public QuitNPC getNpc()
|
||||
{
|
||||
return _npc;
|
||||
}
|
||||
|
||||
|
||||
public boolean isPluginRemove()
|
||||
{
|
||||
return _pluginRemove;
|
||||
}
|
||||
|
||||
public HandlerList getHandlers()
|
||||
{
|
||||
return HANDLERS;
|
||||
@ -45,5 +52,5 @@ public class QuitNPCDespawnEvent extends Event implements Cancellable
|
||||
{
|
||||
_cancel = cancel;
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
@ -50,15 +50,8 @@ public class QuitNPC implements Listener
|
||||
private final UUID _uuid;
|
||||
private final PlayerInventory _inventory;
|
||||
|
||||
// Unlocked Slots
|
||||
private final int _slotsUnlocked;
|
||||
|
||||
// Gems
|
||||
private final int _gems;
|
||||
|
||||
// Quests
|
||||
private final QuestPlayerData _questPlayerData;
|
||||
|
||||
public QuitNPC(QuitNPCModule npc, Player player, long quitMills)
|
||||
{
|
||||
// Managers
|
||||
@ -91,53 +84,17 @@ public class QuitNPC implements Listener
|
||||
_name = player.getName();
|
||||
_uuid = player.getUniqueId();
|
||||
_inventory = player.getInventory();
|
||||
|
||||
// Unlocked Slots
|
||||
_slotsUnlocked = Managers.get(InventoryModule.class).getSlotsUnlocked(player);
|
||||
|
||||
// Gems
|
||||
_gems = Managers.get(EconomyModule.class).Get(player);
|
||||
|
||||
// Quests
|
||||
_questPlayerData = Managers.get(QuestModule.class).Get(player);
|
||||
|
||||
UtilServer.RegisterEvents(this);
|
||||
}
|
||||
|
||||
public void restore(Player player)
|
||||
public void despawn(boolean pluginRemove)
|
||||
{
|
||||
// Player
|
||||
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);
|
||||
QuitNPCDespawnEvent event = new QuitNPCDespawnEvent(this, pluginRemove);
|
||||
|
||||
UtilServer.CallEvent(event);
|
||||
|
||||
|
||||
if (event.isCancelled())
|
||||
{
|
||||
return;
|
||||
@ -153,24 +110,24 @@ public class QuitNPC implements Listener
|
||||
public void dropItems()
|
||||
{
|
||||
Location location = _entity.getLocation().add(0, 1, 0);
|
||||
|
||||
|
||||
for (ItemStack itemStack : _inventory.getContents())
|
||||
{
|
||||
if (itemStack == null || itemStack.getType() == Material.AIR)
|
||||
{
|
||||
continue;
|
||||
}
|
||||
|
||||
|
||||
location.getWorld().dropItemNaturally(location, itemStack);
|
||||
}
|
||||
|
||||
|
||||
for (ItemStack itemStack : _inventory.getArmorContents())
|
||||
{
|
||||
if (itemStack == null || itemStack.getType() == Material.AIR)
|
||||
{
|
||||
continue;
|
||||
}
|
||||
|
||||
|
||||
location.getWorld().dropItemNaturally(location, itemStack);
|
||||
}
|
||||
}
|
||||
@ -185,7 +142,7 @@ public class QuitNPC implements Listener
|
||||
|
||||
if (UtilTime.elapsed(_start, _quitMills))
|
||||
{
|
||||
despawn();
|
||||
despawn(true);
|
||||
}
|
||||
else
|
||||
{
|
||||
@ -200,21 +157,21 @@ public class QuitNPC implements Listener
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
Player killer = event.getEntity().getKiller();
|
||||
|
||||
|
||||
if (killer != null)
|
||||
{
|
||||
_npc.setKilledBy(_uuid, killer.getName());
|
||||
Managers.get(EconomyModule.class).addToStore(killer, "Killing " + F.name(_name + "'s") + " NPC", (int) (_gems * EconomyModule.GEM_KILL_FACTOR));
|
||||
}
|
||||
|
||||
|
||||
event.getDrops().clear();
|
||||
_entity.setHealth(_entity.getMaxHealth());
|
||||
dropItems();
|
||||
despawn();
|
||||
despawn(false);
|
||||
}
|
||||
|
||||
|
||||
@EventHandler
|
||||
public void entityCombust(EntityCombustEvent event)
|
||||
{
|
||||
@ -226,6 +183,11 @@ public class QuitNPC implements Listener
|
||||
event.setCancelled(true);
|
||||
}
|
||||
|
||||
public String getName()
|
||||
{
|
||||
return _name;
|
||||
}
|
||||
|
||||
public UUID getUniqueId()
|
||||
{
|
||||
return _uuid;
|
||||
|
@ -7,6 +7,8 @@ import java.util.Set;
|
||||
import java.util.UUID;
|
||||
import java.util.concurrent.TimeUnit;
|
||||
|
||||
import mineplex.core.common.util.UtilPlayer;
|
||||
import mineplex.gemhunters.economy.CashOutModule;
|
||||
import org.bukkit.GameMode;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.event.EventHandler;
|
||||
@ -28,22 +30,20 @@ public class QuitNPCModule extends MiniPlugin
|
||||
{
|
||||
|
||||
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, String> _killedBy;
|
||||
private final Set<UUID> _aboutToCashOut;
|
||||
|
||||
|
||||
private QuitNPCModule()
|
||||
{
|
||||
super("Quit NPC");
|
||||
|
||||
_tutorial = require(TextTutorialManager.class);
|
||||
|
||||
|
||||
_cashOut = require(CashOutModule.class);
|
||||
|
||||
_npcs = new HashMap<>();
|
||||
_killedBy = new HashMap<>();
|
||||
_aboutToCashOut = new HashSet<>();
|
||||
}
|
||||
|
||||
public void spawnNpc(Player player)
|
||||
@ -56,10 +56,9 @@ public class QuitNPCModule extends MiniPlugin
|
||||
return;
|
||||
}
|
||||
|
||||
if (_aboutToCashOut.contains(player.getUniqueId()))
|
||||
if (_cashOut.isAboutToCashOut(player))
|
||||
{
|
||||
log(player.getName() + " was cashing out");
|
||||
_aboutToCashOut.remove(player.getUniqueId());
|
||||
return;
|
||||
}
|
||||
|
||||
@ -77,20 +76,12 @@ public class QuitNPCModule extends MiniPlugin
|
||||
_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)
|
||||
public void playerQuit(PlayerQuitEvent event)
|
||||
{
|
||||
Player player = event.getPlayer();
|
||||
|
||||
if (_tutorial.isInTutorial(player))
|
||||
if (UtilPlayer.isSpectator(player))
|
||||
{
|
||||
return;
|
||||
}
|
||||
@ -101,7 +92,7 @@ public class QuitNPCModule extends MiniPlugin
|
||||
@EventHandler
|
||||
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
|
||||
|
@ -1,32 +1,10 @@
|
||||
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.ReflectivelyCreateMiniPlugin;
|
||||
import mineplex.core.common.currency.GlobalCurrency;
|
||||
import mineplex.core.common.util.C;
|
||||
import mineplex.core.common.util.F;
|
||||
import mineplex.core.common.util.UtilEvent;
|
||||
import mineplex.core.common.util.*;
|
||||
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.itemstack.ItemBuilder;
|
||||
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.event.PlayerCashOutCompleteEvent;
|
||||
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
|
||||
public class CashOutModule extends MiniPlugin
|
||||
{
|
||||
|
||||
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_COOLDOWN = 10000;
|
||||
@ -53,7 +45,8 @@ public class CashOutModule extends MiniPlugin
|
||||
private final DonationManager _donation;
|
||||
|
||||
private final Map<UUID, CashOutSession> _sessions;
|
||||
|
||||
private final Set<UUID> _aboutToCashOut;
|
||||
|
||||
public CashOutModule()
|
||||
{
|
||||
super("Cash Out");
|
||||
@ -61,6 +54,7 @@ public class CashOutModule extends MiniPlugin
|
||||
_donation = require(DonationManager.class);
|
||||
|
||||
_sessions = new HashMap<>();
|
||||
_aboutToCashOut = new HashSet<>();
|
||||
}
|
||||
|
||||
@Override
|
||||
@ -72,7 +66,7 @@ public class CashOutModule extends MiniPlugin
|
||||
@EventHandler
|
||||
public void teleportIn(PlayerTeleportIntoMapEvent event)
|
||||
{
|
||||
if (event.isCancelled())
|
||||
if (event.isCancelled() || event.getPlayer().getInventory().contains(CASH_OUT_ITEM))
|
||||
{
|
||||
return;
|
||||
}
|
||||
@ -126,7 +120,7 @@ public class CashOutModule extends MiniPlugin
|
||||
while (iterator.hasNext())
|
||||
{
|
||||
UUID key = iterator.next();
|
||||
Player player = UtilPlayer.searchExact(key);
|
||||
final Player player = UtilPlayer.searchExact(key);
|
||||
CashOutSession session = _sessions.get(key);
|
||||
double current = session.getCurrent();
|
||||
ArmorStand stand = session.getArmourStand();
|
||||
@ -146,14 +140,32 @@ public class CashOutModule extends MiniPlugin
|
||||
if (session.getCurrent() <= 0)
|
||||
{
|
||||
PlayerCashOutCompleteEvent completeEvent = new PlayerCashOutCompleteEvent(player);
|
||||
|
||||
|
||||
UtilServer.CallEvent(completeEvent);
|
||||
|
||||
_aboutToCashOut.add(player.getUniqueId());
|
||||
|
||||
_donation.rewardCurrencyUntilSuccess(GlobalCurrency.GEM, player, "Earned", completeEvent.getGems());
|
||||
|
||||
session.endSession();
|
||||
iterator.remove();
|
||||
Portal.getInstance().sendPlayerToGenericServer(player, GenericServer.BETA_HUB, Intent.FORCE_TRANSFER);
|
||||
|
||||
if (UtilServer.isTestServer())
|
||||
{
|
||||
kickPlayer(player);
|
||||
}
|
||||
else
|
||||
{
|
||||
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)
|
||||
{
|
||||
UUID key = player.getUniqueId();
|
||||
@ -253,6 +271,11 @@ public class CashOutModule extends MiniPlugin
|
||||
return getCashOutSession(player) != null;
|
||||
}
|
||||
|
||||
public boolean isAboutToCashOut(Player player)
|
||||
{
|
||||
return _aboutToCashOut.contains(player.getUniqueId());
|
||||
}
|
||||
|
||||
public CashOutSession getCashOutSession(Player player)
|
||||
{
|
||||
for (UUID key : _sessions.keySet())
|
||||
@ -266,4 +289,9 @@ public class CashOutModule extends MiniPlugin
|
||||
return null;
|
||||
}
|
||||
|
||||
private void kickPlayer(Player player)
|
||||
{
|
||||
player.kickPlayer(C.cGreen + "Imagine you are being sent to the lobby.");
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -42,16 +42,12 @@ public class EconomyModule extends MiniClientPlugin<Integer>
|
||||
addCommand(new GiveGemsCommand(this));
|
||||
}
|
||||
|
||||
@EventHandler
|
||||
public void respawn(PlayerCustomRespawnEvent event)
|
||||
{
|
||||
addToStore(event.getPlayer(), null, GEM_START_COST);
|
||||
}
|
||||
|
||||
@EventHandler
|
||||
public void teleportIn(PlayerTeleportIntoMapEvent event)
|
||||
{
|
||||
Player player = event.getPlayer();
|
||||
addToStore(event.getPlayer(), null, GEM_START_COST);
|
||||
|
||||
Donor donor = _donation.Get(event.getPlayer());
|
||||
|
||||
if (donor.getBalance(GlobalCurrency.GEM) >= GEM_START_COST)
|
||||
@ -68,7 +64,7 @@ public class EconomyModule extends MiniClientPlugin<Integer>
|
||||
|
||||
int oldGems = getGems(player);
|
||||
|
||||
if (killer instanceof Player)
|
||||
if (killer != null)
|
||||
{
|
||||
Player killerPlayer = (Player) killer;
|
||||
int newGems = (int) (oldGems * GEM_KILL_FACTOR);
|
||||
|
@ -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);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
}
|
@ -10,6 +10,7 @@ import org.bukkit.entity.Player;
|
||||
import org.bukkit.event.EventHandler;
|
||||
import org.bukkit.event.inventory.InventoryClickEvent;
|
||||
import org.bukkit.event.player.PlayerInteractEvent;
|
||||
import org.bukkit.event.player.PlayerJoinEvent;
|
||||
import org.bukkit.event.player.PlayerQuitEvent;
|
||||
import org.bukkit.inventory.Inventory;
|
||||
import org.bukkit.inventory.ItemStack;
|
||||
@ -48,15 +49,7 @@ public class InventoryModule extends MiniPlugin
|
||||
@EventHandler
|
||||
public void respawn(PlayerCustomRespawnEvent event)
|
||||
{
|
||||
Player player = event.getPlayer();
|
||||
Inventory inv = player.getInventory();
|
||||
|
||||
_slotsUnlocked.put(player.getUniqueId(), 0);
|
||||
|
||||
for (int i = START_INDEX; i < inv.getSize(); i++)
|
||||
{
|
||||
inv.setItem(i, LOCKED);
|
||||
}
|
||||
resetSlots(event.getPlayer());
|
||||
}
|
||||
|
||||
@EventHandler
|
||||
@ -111,6 +104,13 @@ public class InventoryModule extends MiniPlugin
|
||||
|
||||
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();
|
||||
UUID key = player.getUniqueId();
|
||||
|
||||
@ -123,16 +123,26 @@ public class InventoryModule extends MiniPlugin
|
||||
inv.setItem(i, null);
|
||||
}
|
||||
|
||||
player.sendMessage(F.main(_moduleName, "You unlocked an additional " + F.count(String.valueOf(delta)) + " slots of your inventory!"));
|
||||
if (inform)
|
||||
{
|
||||
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);
|
||||
}
|
||||
|
||||
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());
|
||||
}
|
||||
|
@ -534,41 +534,41 @@ public class LootModule extends MiniPlugin
|
||||
String[] metadataSplit = lootItem.getMetadata().split(" ");
|
||||
String key = metadataSplit[0];
|
||||
String[] values = new String[metadataSplit.length - 1];
|
||||
|
||||
for (int i = 1; i < metadataSplit.length; i++)
|
||||
{
|
||||
values[i - 1] = metadataSplit[i];
|
||||
}
|
||||
|
||||
|
||||
System.arraycopy(metadataSplit, 1, values, 0, metadataSplit.length - 1);
|
||||
|
||||
switch (key)
|
||||
{
|
||||
case "RANK_UPGRADE":
|
||||
reward = new LootRankReward(itemStack);
|
||||
break;
|
||||
case "SHARD":
|
||||
reward = new LootShardReward(Integer.parseInt(values[0]) * 1000, itemStack, Integer.parseInt(values[1]));
|
||||
break;
|
||||
case "CHEST":
|
||||
reward = new LootChestReward(Integer.parseInt(values[0]) * 1000, itemStack, values[1], Integer.parseInt(values[2]));
|
||||
break;
|
||||
case "GADGET":
|
||||
String gadget = "";
|
||||
|
||||
for (int i = 1; i < values.length; i++)
|
||||
{
|
||||
gadget += values[i] + " ";
|
||||
}
|
||||
|
||||
reward = new LootGadgetReward(Integer.parseInt(values[0]) * 1000, itemStack, gadget.trim());
|
||||
break;
|
||||
default:
|
||||
return;
|
||||
case "RANK_UPGRADE":
|
||||
reward = new LootRankReward(itemStack);
|
||||
break;
|
||||
case "SHARD":
|
||||
reward = new LootShardReward(Integer.parseInt(values[0]) * 1000, itemStack, Integer.parseInt(values[1]));
|
||||
break;
|
||||
case "CHEST":
|
||||
reward = new LootChestReward(Integer.parseInt(values[0]) * 1000, itemStack, values[1], Integer.parseInt(values[2]));
|
||||
break;
|
||||
case "GADGET":
|
||||
String gadget = "";
|
||||
|
||||
for (int i = 1; i < values.length; i++)
|
||||
{
|
||||
gadget += values[i] + " ";
|
||||
}
|
||||
|
||||
reward = new LootGadgetReward(Integer.parseInt(values[0]) * 1000, itemStack, gadget.trim());
|
||||
break;
|
||||
default:
|
||||
return;
|
||||
}
|
||||
|
||||
_itemRewards.add(reward);
|
||||
}
|
||||
|
||||
reward.collectItem(player);
|
||||
if (reward != null)
|
||||
{
|
||||
reward.collectItem(player);
|
||||
}
|
||||
}
|
||||
|
||||
public void addItemReward(LootItemReward reward)
|
||||
@ -613,20 +613,20 @@ public class LootModule extends MiniPlugin
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
_shownPlayers.clear();
|
||||
|
||||
|
||||
for (Player player : Bukkit.getOnlinePlayers())
|
||||
{
|
||||
UUID key = player.getUniqueId();
|
||||
|
||||
|
||||
for (LootItemReward itemReward : _itemRewards)
|
||||
{
|
||||
if (itemReward.getPlayer() == null)
|
||||
{
|
||||
continue;
|
||||
}
|
||||
|
||||
|
||||
if (itemReward.getPlayer().equals(player))
|
||||
{
|
||||
_shownPlayers.add(key);
|
||||
@ -641,7 +641,7 @@ public class LootModule extends MiniPlugin
|
||||
{
|
||||
event.getPlayer().getInventory().addItem(SPAWN_ITEMS);
|
||||
}
|
||||
|
||||
|
||||
@EventHandler
|
||||
public void cashOutComplete(PlayerCashOutCompleteEvent event)
|
||||
{
|
||||
|
@ -29,6 +29,7 @@ import org.bukkit.event.entity.ItemSpawnEvent;
|
||||
import org.bukkit.event.entity.PlayerDeathEvent;
|
||||
import org.bukkit.event.player.PlayerInteractEvent;
|
||||
import org.bukkit.event.player.PlayerItemHeldEvent;
|
||||
import org.bukkit.event.player.PlayerJoinEvent;
|
||||
import org.bukkit.event.player.PlayerQuitEvent;
|
||||
import org.bukkit.event.world.ChunkLoadEvent;
|
||||
import org.bukkit.inventory.ItemStack;
|
||||
@ -662,12 +663,21 @@ public class ItemMapModule extends MiniPlugin
|
||||
showZoom(player, info);
|
||||
}
|
||||
|
||||
@EventHandler(priority = EventPriority.HIGHEST)
|
||||
public void playerJoin(PlayerJoinEvent event)
|
||||
{
|
||||
handleGive(event.getPlayer());
|
||||
}
|
||||
|
||||
@EventHandler
|
||||
public void teleportIn(PlayerCustomRespawnEvent event)
|
||||
public void respawn(PlayerCustomRespawnEvent event)
|
||||
{
|
||||
handleGive(event.getPlayer());
|
||||
}
|
||||
|
||||
public void handleGive(Player player)
|
||||
{
|
||||
MapInfo info = new MapInfo(_mapId);
|
||||
|
||||
Player player = event.getPlayer();
|
||||
Location loc = player.getLocation();
|
||||
|
||||
int zoom = getZoom(1);
|
||||
|
@ -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;
|
||||
}
|
||||
|
||||
}
|
@ -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;
|
||||
}
|
||||
}
|
@ -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;
|
||||
}
|
||||
}
|
@ -4,6 +4,7 @@ import java.util.List;
|
||||
import java.util.UUID;
|
||||
import java.util.concurrent.TimeUnit;
|
||||
|
||||
import mineplex.core.common.util.*;
|
||||
import net.md_5.bungee.api.ChatColor;
|
||||
|
||||
import org.bukkit.Bukkit;
|
||||
@ -25,14 +26,7 @@ import org.bukkit.metadata.FixedMetadataValue;
|
||||
import mineplex.core.MiniClientPlugin;
|
||||
import mineplex.core.ReflectivelyCreateMiniPlugin;
|
||||
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.UtilMath;
|
||||
import mineplex.core.common.util.UtilTextMiddle;
|
||||
import mineplex.core.common.util.UtilTime;
|
||||
import mineplex.core.itemstack.ItemBuilder;
|
||||
import mineplex.core.menu.Menu;
|
||||
import mineplex.core.recharge.Recharge;
|
||||
@ -491,7 +485,7 @@ public class QuestModule extends MiniClientPlugin<QuestPlayerData>
|
||||
@EventHandler
|
||||
public void debug(PlayerCommandPreprocessEvent event)
|
||||
{
|
||||
if (event.getMessage().startsWith("/test"))
|
||||
if (event.getMessage().startsWith("/questdatatest"))
|
||||
{
|
||||
event.setCancelled(true);
|
||||
Player player = event.getPlayer();
|
||||
|
@ -5,6 +5,7 @@ import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.UUID;
|
||||
|
||||
import mineplex.core.recharge.Recharge;
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.Location;
|
||||
import org.bukkit.entity.HumanEntity;
|
||||
@ -12,6 +13,7 @@ import org.bukkit.entity.LivingEntity;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.entity.Projectile;
|
||||
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.FoodLevelChangeEvent;
|
||||
@ -112,7 +114,7 @@ public class SafezoneModule extends MiniPlugin
|
||||
{
|
||||
_playerStatus.setStatus(player, PlayerStatusType.SAFE, true);
|
||||
}
|
||||
else
|
||||
else if (Recharge.Instance.usable(player, "Cash Out"))
|
||||
{
|
||||
_playerStatus.setStatus(player, PlayerStatusType.SAFE);
|
||||
}
|
||||
@ -128,7 +130,7 @@ public class SafezoneModule extends MiniPlugin
|
||||
_currentSafezone.remove(player.getUniqueId());
|
||||
}
|
||||
|
||||
@EventHandler
|
||||
@EventHandler(priority = EventPriority.HIGHEST)
|
||||
public void entityDamage(EntityDamageEvent event)
|
||||
{
|
||||
if (!(event.getEntity() instanceof Player))
|
||||
@ -138,10 +140,15 @@ public class SafezoneModule extends MiniPlugin
|
||||
|
||||
Player player = (Player) event.getEntity();
|
||||
|
||||
if (isInSafeZone(player))
|
||||
if (isInSafeZone(player) && _playerStatus.Get(player).getStatusType() != PlayerStatusType.COMBAT)
|
||||
{
|
||||
event.setCancelled(true);
|
||||
}
|
||||
|
||||
if (!Recharge.Instance.usable(player, "Cash Out"))
|
||||
{
|
||||
event.setCancelled(false);
|
||||
}
|
||||
}
|
||||
|
||||
@EventHandler
|
||||
|
@ -67,35 +67,16 @@ public class SpawnModule extends MiniPlugin
|
||||
addCommand(new HubCommand(this));
|
||||
}
|
||||
|
||||
@EventHandler(priority = EventPriority.HIGHEST)
|
||||
@EventHandler(priority = EventPriority.LOWEST)
|
||||
public void playerJoin(PlayerJoinEvent event)
|
||||
{
|
||||
if (_spawn == null || _center == null)
|
||||
{
|
||||
_spawn = _worldData.getCustomLocation("PLAYER_SPAWN").get(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)
|
||||
{
|
||||
return;
|
||||
|
@ -20,7 +20,7 @@ public class HubCommand extends CommandBase<SpawnModule>
|
||||
@Override
|
||||
public void Execute(Player caller, String[] args)
|
||||
{
|
||||
Portal.getInstance().sendPlayerToGenericServer(caller, GenericServer.BETA_HUB, Intent.PLAYER_REQUEST);
|
||||
Portal.getInstance().sendPlayerToGenericServer(caller, GenericServer.HUB, Intent.PLAYER_REQUEST);
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -5,19 +5,18 @@ import java.io.IOException;
|
||||
import java.util.HashSet;
|
||||
import java.util.Set;
|
||||
|
||||
import mineplex.core.common.util.*;
|
||||
import org.bukkit.DyeColor;
|
||||
import org.bukkit.Location;
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.block.Block;
|
||||
import org.bukkit.entity.FallingBlock;
|
||||
import org.bukkit.scheduler.BukkitRunnable;
|
||||
import org.bukkit.util.BlockVector;
|
||||
|
||||
import mineplex.core.common.block.schematic.Schematic;
|
||||
import mineplex.core.common.block.schematic.SchematicData;
|
||||
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>
|
||||
@ -101,11 +100,7 @@ public class SupplyDrop
|
||||
|
||||
if (_blade != null)
|
||||
{
|
||||
if (UtilMath.offset2d(_blade, _destination) < 1)
|
||||
{
|
||||
spawnLootChest();
|
||||
}
|
||||
else if (UtilMath.offset2d(_blade, _despawn) < 1)
|
||||
if (UtilMath.offset2d(_blade, _despawn) < 1)
|
||||
{
|
||||
for (Block block : _bladeBlocks)
|
||||
{
|
||||
@ -197,16 +192,6 @@ public class SupplyDrop
|
||||
block.setType(Material.AIR);
|
||||
}
|
||||
}
|
||||
|
||||
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()
|
||||
{
|
||||
@ -222,4 +207,6 @@ public class SupplyDrop
|
||||
{
|
||||
return _destination;
|
||||
}
|
||||
|
||||
public final Location getBladeLocation() { return _blade; }
|
||||
}
|
||||
|
@ -1,37 +1,32 @@
|
||||
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.HashSet;
|
||||
import java.util.List;
|
||||
import java.util.Set;
|
||||
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
|
||||
public class SupplyDropModule extends MiniPlugin
|
||||
{
|
||||
@ -85,6 +80,10 @@ public class SupplyDropModule extends MiniPlugin
|
||||
{
|
||||
stopSequence();
|
||||
}
|
||||
else if (UtilMath.offset2d(_current.getBladeLocation(), _current.getChestLocation()) < 1)
|
||||
{
|
||||
spawnLootChest();
|
||||
}
|
||||
}
|
||||
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)
|
||||
{
|
||||
Location spawn = _worldData.getCustomLocation(LOCATION_DATA + " " + locationKey + " Start").get(0);
|
||||
@ -168,6 +142,43 @@ public class SupplyDropModule extends MiniPlugin
|
||||
_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()
|
||||
{
|
||||
return _current != null;
|
||||
|
@ -1,5 +1,8 @@
|
||||
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.entity.Player;
|
||||
|
||||
@ -11,8 +14,10 @@ import mineplex.core.texttutorial.tutorial.Tutorial;
|
||||
import mineplex.gemhunters.economy.EconomyModule;
|
||||
import mineplex.gemhunters.spawn.SpawnModule;
|
||||
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;
|
||||
@ -51,7 +56,7 @@ public class GemHuntersTutorial extends Tutorial
|
||||
}));
|
||||
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.",
|
||||
"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[] {
|
||||
"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[] {
|
||||
"Collect items from chests and powerup.",
|
||||
"You can find anything from Weaponrs to Cosmetics.",
|
||||
"If you find somethiing you want to keep you can",
|
||||
"You can find anything from Weapons to Cosmetics.",
|
||||
"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.",
|
||||
}));
|
||||
addPhase(new Phase(getLocation(4), "Cashing Out", new String[] {
|
||||
@ -71,13 +76,15 @@ public class GemHuntersTutorial extends Tutorial
|
||||
addPhase(new Phase(getLocation(5), "Good luck", new String[] {
|
||||
"Stay safe! Anarchy rules in the world of " + C.cGreen + "Gem Hunters" + C.cWhite + "!"
|
||||
}));
|
||||
|
||||
UtilServer.RegisterEvents(this);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void startTutorial(Player player)
|
||||
{
|
||||
super.startTutorial(player);
|
||||
|
||||
|
||||
player.setAllowFlight(true);
|
||||
player.setFlying(true);
|
||||
}
|
||||
@ -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]);
|
||||
}
|
||||
|
||||
@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);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -112,7 +112,9 @@ public class WorldDataModule extends MiniPlugin
|
||||
{
|
||||
Location loc = stringToLocation(tokens[i]);
|
||||
if (loc == null)
|
||||
{
|
||||
continue;
|
||||
}
|
||||
|
||||
loc.setYaw(currentDirection);
|
||||
|
||||
@ -132,7 +134,9 @@ public class WorldDataModule extends MiniPlugin
|
||||
{
|
||||
Location loc = stringToLocation(tokens[i]);
|
||||
if (loc == null)
|
||||
{
|
||||
continue;
|
||||
}
|
||||
|
||||
currentData.add(loc);
|
||||
}
|
||||
@ -150,7 +154,9 @@ public class WorldDataModule extends MiniPlugin
|
||||
{
|
||||
Location loc = stringToLocation(tokens[i]);
|
||||
if (loc == null)
|
||||
{
|
||||
continue;
|
||||
}
|
||||
|
||||
currentData.add(loc);
|
||||
}
|
||||
@ -280,7 +286,7 @@ public class WorldDataModule extends MiniPlugin
|
||||
|
||||
return CUSTOM_LOCAITONS.get(id);
|
||||
}
|
||||
|
||||
|
||||
public Map<String, List<Location>> getAllSpawnLocations()
|
||||
{
|
||||
return SPAWN_LOCATIONS;
|
||||
|
@ -14,21 +14,13 @@ import org.bukkit.entity.Player;
|
||||
import org.bukkit.event.EventHandler;
|
||||
import org.bukkit.event.EventPriority;
|
||||
import org.bukkit.event.Listener;
|
||||
import org.bukkit.event.block.BlockBreakEvent;
|
||||
import org.bukkit.event.block.BlockBurnEvent;
|
||||
import org.bukkit.event.block.BlockFadeEvent;
|
||||
import org.bukkit.event.block.BlockIgniteEvent;
|
||||
import org.bukkit.event.block.*;
|
||||
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.FoodLevelChangeEvent;
|
||||
import org.bukkit.event.hanging.HangingBreakEvent;
|
||||
import org.bukkit.event.player.PlayerArmorStandManipulateEvent;
|
||||
import org.bukkit.event.player.PlayerInteractAtEntityEvent;
|
||||
import org.bukkit.event.player.PlayerInteractEntityEvent;
|
||||
import org.bukkit.event.player.PlayerInteractEvent;
|
||||
import org.bukkit.event.player.PlayerQuitEvent;
|
||||
import org.bukkit.event.inventory.FurnaceSmeltEvent;
|
||||
import org.bukkit.event.player.*;
|
||||
import org.bukkit.event.weather.WeatherChangeEvent;
|
||||
import org.bukkit.event.world.ChunkUnloadEvent;
|
||||
import org.bukkit.plugin.java.JavaPlugin;
|
||||
@ -52,7 +44,8 @@ public class WorldListeners implements Listener
|
||||
@EventHandler
|
||||
public void deletePlayerData(PlayerQuitEvent event)
|
||||
{
|
||||
_plugin.getServer().getScheduler().runTaskLater(_plugin, () -> {
|
||||
_plugin.getServer().getScheduler().runTaskLater(_plugin, () ->
|
||||
{
|
||||
World world = event.getPlayer().getWorld();
|
||||
UUID uuid = event.getPlayer().getUniqueId();
|
||||
String path = world.getWorldFolder().getPath();
|
||||
@ -60,7 +53,7 @@ public class WorldListeners implements Listener
|
||||
new File(path + File.separator + "stats" + File.separator + uuid + ".json").delete();
|
||||
}, 10);
|
||||
}
|
||||
|
||||
|
||||
@EventHandler
|
||||
public void customDamage(CustomDamageEvent event)
|
||||
{
|
||||
@ -117,7 +110,7 @@ public class WorldListeners implements Listener
|
||||
{
|
||||
event.setCancelled(true);
|
||||
}
|
||||
|
||||
|
||||
@EventHandler
|
||||
public void itemFrames(PlayerInteractEntityEvent event)
|
||||
{
|
||||
@ -134,16 +127,16 @@ public class WorldListeners implements Listener
|
||||
{
|
||||
event.setCancelled(true);
|
||||
}
|
||||
|
||||
|
||||
Block block = event.getClickedBlock();
|
||||
|
||||
|
||||
if (block == null)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
Material material = block.getType();
|
||||
|
||||
|
||||
if (material == Material.BEACON || material == Material.DISPENSER || material == Material.HOPPER || material == Material.BREWING_STAND || material == Material.DROPPER)
|
||||
{
|
||||
event.setCancelled(true);
|
||||
@ -162,7 +155,7 @@ public class WorldListeners implements Listener
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
event.setCancelled(true);
|
||||
}
|
||||
|
||||
@ -173,7 +166,7 @@ public class WorldListeners implements Listener
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
event.setCancelled(true);
|
||||
}
|
||||
|
||||
@ -188,7 +181,7 @@ public class WorldListeners implements Listener
|
||||
{
|
||||
event.setCancelled(true);
|
||||
}
|
||||
|
||||
|
||||
@EventHandler
|
||||
public void leavesDecay(LeavesDecayEvent event)
|
||||
{
|
||||
@ -203,7 +196,7 @@ public class WorldListeners implements Listener
|
||||
// Some witchcraft from the arcade, seems to make hunger not ridiculous.
|
||||
player.setSaturation(3.8F);
|
||||
}
|
||||
|
||||
|
||||
@EventHandler(priority = EventPriority.LOWEST)
|
||||
public void weather(WeatherChangeEvent event)
|
||||
{
|
||||
@ -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)
|
||||
{
|
||||
return player.getGameMode() != GameMode.CREATIVE;
|
||||
|
@ -37,7 +37,6 @@ public class BlizzardWorldEvent extends WorldEvent
|
||||
private static final double START_CHANCE = 0.01;
|
||||
private static final long MAX_TIME = TimeUnit.MINUTES.toMillis(10);
|
||||
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 String TIP = "EQUIP LEATHER ARMOUR OR GET NEAR A FIRE";
|
||||
|
||||
@ -108,8 +107,13 @@ public class BlizzardWorldEvent extends WorldEvent
|
||||
{
|
||||
if (shouldDamage(player))
|
||||
{
|
||||
_playerStatus.setStatus(player, PlayerStatusType.COLD);
|
||||
_damage.NewDamageEvent(player, null, null, DamageCause.CUSTOM, DAMAGE, false, true, true, "Hurricane", "Frostbite");
|
||||
}
|
||||
else
|
||||
{
|
||||
_playerStatus.setStatus(player, PlayerStatusType.WARM);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -141,30 +145,8 @@ public class BlizzardWorldEvent extends WorldEvent
|
||||
}
|
||||
}
|
||||
|
||||
_playerStatus.setStatus(player, PlayerStatusType.WARM, WARM_TIME);
|
||||
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
|
||||
public void onStart()
|
||||
|
@ -73,7 +73,7 @@ public class GiantWorldEvent extends WorldEvent
|
||||
public void onEnd()
|
||||
{
|
||||
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);
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user