PC-46 + adding in events for buttons
This commit is contained in:
parent
62280a8fa5
commit
86bdbbb8bc
@ -1,5 +1,7 @@
|
||||
package mineplex.game.clans.clans.gui.button;
|
||||
|
||||
import mineplex.core.common.util.UtilServer;
|
||||
import mineplex.game.clans.clans.gui.events.ClansButtonClickEvent;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.event.inventory.ClickType;
|
||||
|
||||
@ -13,8 +15,10 @@ public class ClanAddAllyButton implements IButton
|
||||
@Override
|
||||
public void onClick(Player player, ClickType clickType)
|
||||
{
|
||||
player.closeInventory();
|
||||
if (UtilServer.CallEvent(new ClansButtonClickEvent(player, ClansButtonClickEvent.ButtonType.AddAlly)).isCancelled())
|
||||
return;
|
||||
|
||||
player.closeInventory();
|
||||
JsonMessage message = new JsonMessage(C.cRed + C.Bold + "Click here to add an Ally").click(ClickEvent.SUGGEST_COMMAND, "/c ally ");
|
||||
message.sendToPlayer(player);
|
||||
}
|
||||
|
@ -1,5 +1,7 @@
|
||||
package mineplex.game.clans.clans.gui.button;
|
||||
|
||||
import mineplex.core.common.util.UtilServer;
|
||||
import mineplex.game.clans.clans.gui.events.ClansButtonClickEvent;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.event.inventory.ClickType;
|
||||
|
||||
@ -13,6 +15,9 @@ public class ClanAddTrustedButton implements IButton
|
||||
@Override
|
||||
public void onClick(Player player, ClickType clickType)
|
||||
{
|
||||
if (UtilServer.CallEvent(new ClansButtonClickEvent(player, ClansButtonClickEvent.ButtonType.AddTrusted)).isCancelled())
|
||||
return;
|
||||
|
||||
player.closeInventory();
|
||||
|
||||
JsonMessage message = new JsonMessage(C.cRed + C.Bold + "Click here to trust a clan").click(ClickEvent.SUGGEST_COMMAND, "/c trust ");
|
||||
|
@ -1,5 +1,7 @@
|
||||
package mineplex.game.clans.clans.gui.button;
|
||||
|
||||
import mineplex.core.common.util.UtilServer;
|
||||
import mineplex.game.clans.clans.gui.events.ClansButtonClickEvent;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.event.inventory.ClickType;
|
||||
|
||||
@ -13,6 +15,8 @@ public class ClanAddWarButton implements IButton
|
||||
@Override
|
||||
public void onClick(Player player, ClickType clickType)
|
||||
{
|
||||
if (UtilServer.CallEvent(new ClansButtonClickEvent(player, ClansButtonClickEvent.ButtonType.AddWar)).isCancelled())
|
||||
return;
|
||||
player.closeInventory();
|
||||
|
||||
JsonMessage message = new JsonMessage(C.cRed + C.Bold + "Click here to war a clan").click(ClickEvent.SUGGEST_COMMAND, "/war ");
|
||||
|
@ -1,5 +1,7 @@
|
||||
package mineplex.game.clans.clans.gui.button;
|
||||
|
||||
import mineplex.core.common.util.UtilServer;
|
||||
import mineplex.game.clans.clans.gui.events.ClansButtonClickEvent;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.event.inventory.ClickType;
|
||||
|
||||
@ -18,5 +20,6 @@ public class ClanCreateButton implements IButton
|
||||
@Override
|
||||
public void onClick(Player player, ClickType clickType)
|
||||
{
|
||||
UtilServer.CallEvent(new ClansButtonClickEvent(player, ClansButtonClickEvent.ButtonType.Create));
|
||||
}
|
||||
}
|
||||
|
@ -1,5 +1,7 @@
|
||||
package mineplex.game.clans.clans.gui.button;
|
||||
|
||||
import mineplex.core.common.util.UtilServer;
|
||||
import mineplex.game.clans.clans.gui.events.ClansButtonClickEvent;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.event.inventory.ClickType;
|
||||
|
||||
@ -18,6 +20,8 @@ public class ClanDisbandButton extends ClanButton
|
||||
@Override
|
||||
public void onClick(Player player, ClickType clickType)
|
||||
{
|
||||
if (UtilServer.CallEvent(new ClansButtonClickEvent(player, ClansButtonClickEvent.ButtonType.Disband)).isCancelled())
|
||||
return;
|
||||
getPlayer().closeInventory();
|
||||
getClansManager().getClanUtility().delete(getPlayer());
|
||||
}
|
||||
|
@ -1,5 +1,7 @@
|
||||
package mineplex.game.clans.clans.gui.button;
|
||||
|
||||
import mineplex.core.common.util.UtilServer;
|
||||
import mineplex.game.clans.clans.gui.events.ClansButtonClickEvent;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.event.inventory.ClickType;
|
||||
|
||||
@ -18,6 +20,6 @@ public class ClanEnergyButton extends ClanButton
|
||||
@Override
|
||||
public void onClick(Player player, ClickType clickType)
|
||||
{
|
||||
|
||||
UtilServer.CallEvent(new ClansButtonClickEvent(player, ClansButtonClickEvent.ButtonType.Energy));
|
||||
}
|
||||
}
|
||||
|
@ -1,5 +1,7 @@
|
||||
package mineplex.game.clans.clans.gui.button;
|
||||
|
||||
import mineplex.core.common.util.UtilServer;
|
||||
import mineplex.game.clans.clans.gui.events.ClansButtonClickEvent;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.event.inventory.ClickType;
|
||||
|
||||
@ -23,6 +25,8 @@ public class ClanInviteButton extends ClanButton
|
||||
@Override
|
||||
public void onClick(Player player, ClickType clickType)
|
||||
{
|
||||
if (UtilServer.CallEvent(new ClansButtonClickEvent(player, ClansButtonClickEvent.ButtonType.Invite)).isCancelled())
|
||||
return;
|
||||
getShop().openPageForPlayer(getPlayer(), new ClanInvitePage(getClansManager(), getShop(), getClansManager().getClientManager(), _donationManager, player));
|
||||
}
|
||||
}
|
||||
|
@ -1,5 +1,7 @@
|
||||
package mineplex.game.clans.clans.gui.button;
|
||||
|
||||
import mineplex.core.common.util.UtilServer;
|
||||
import mineplex.game.clans.clans.gui.events.ClansButtonClickEvent;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.event.inventory.ClickType;
|
||||
|
||||
@ -21,6 +23,8 @@ public class ClanJoinButton implements IButton
|
||||
@Override
|
||||
public void onClick(Player player, ClickType clickType)
|
||||
{
|
||||
if (UtilServer.CallEvent(new ClansButtonClickEvent(player, ClansButtonClickEvent.ButtonType.Join)).isCancelled())
|
||||
return;
|
||||
player.closeInventory();
|
||||
_clansManager.getClanUtility().join(player, _clanInfo);
|
||||
}
|
||||
|
@ -1,5 +1,7 @@
|
||||
package mineplex.game.clans.clans.gui.button;
|
||||
|
||||
import mineplex.core.common.util.UtilServer;
|
||||
import mineplex.game.clans.clans.gui.events.ClansButtonClickEvent;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.event.inventory.ClickType;
|
||||
|
||||
@ -18,7 +20,22 @@ public class ClanLeaveButton extends ClanButton
|
||||
@Override
|
||||
public void onClick(Player player, ClickType clickType)
|
||||
{
|
||||
getPlayer().closeInventory();
|
||||
getClansManager().getClanUtility().leave(getPlayer());
|
||||
if(clickType.equals(ClickType.SHIFT_RIGHT)) //disband
|
||||
{
|
||||
if (UtilServer.CallEvent(new ClansButtonClickEvent(player, ClansButtonClickEvent.ButtonType.Disband)).isCancelled())
|
||||
return;
|
||||
|
||||
getPlayer().closeInventory();
|
||||
getClansManager().getClanUtility().delete(getPlayer());
|
||||
|
||||
}else if(clickType.equals(ClickType.SHIFT_LEFT)) //leave
|
||||
{
|
||||
if (UtilServer.CallEvent(new ClansButtonClickEvent(player, ClansButtonClickEvent.ButtonType.Leave)).isCancelled())
|
||||
return;
|
||||
|
||||
getPlayer().closeInventory();
|
||||
getClansManager().getClanUtility().leave(getPlayer());
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
@ -1,5 +1,7 @@
|
||||
package mineplex.game.clans.clans.gui.button;
|
||||
|
||||
import mineplex.core.common.util.UtilServer;
|
||||
import mineplex.game.clans.clans.gui.events.ClansButtonClickEvent;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.event.inventory.ClickType;
|
||||
|
||||
@ -24,6 +26,8 @@ public class ClanMemeberButton extends ClanButton
|
||||
@Override
|
||||
public void onClick(Player player, ClickType clickType)
|
||||
{
|
||||
if (UtilServer.CallEvent(new ClansButtonClickEvent(player, ClansButtonClickEvent.ButtonType.Member)).isCancelled())
|
||||
return;
|
||||
if (clickType == ClickType.LEFT)
|
||||
{
|
||||
// Promote
|
||||
|
@ -1,5 +1,7 @@
|
||||
package mineplex.game.clans.clans.gui.button;
|
||||
|
||||
import mineplex.core.common.util.UtilServer;
|
||||
import mineplex.game.clans.clans.gui.events.ClansButtonClickEvent;
|
||||
import org.bukkit.ChatColor;
|
||||
import org.bukkit.Chunk;
|
||||
import org.bukkit.entity.Player;
|
||||
@ -23,6 +25,8 @@ public class ClanTerritoryButton extends ClanButton
|
||||
@Override
|
||||
public void onClick(Player player, ClickType clickType)
|
||||
{
|
||||
if (UtilServer.CallEvent(new ClansButtonClickEvent(player, ClansButtonClickEvent.ButtonType.Territory)).isCancelled())
|
||||
return;
|
||||
// if (_clansManager.getNetherManager().isInNether(player))
|
||||
// {
|
||||
// _clansManager.message(player, "You are not allowed to do anything with Territory while in " + F.clansNether("The Nether") + ".");
|
||||
|
@ -1,5 +1,7 @@
|
||||
package mineplex.game.clans.clans.gui.button;
|
||||
|
||||
import mineplex.core.common.util.UtilServer;
|
||||
import mineplex.game.clans.clans.gui.events.ClansButtonClickEvent;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.event.inventory.ClickType;
|
||||
|
||||
@ -13,6 +15,8 @@ public class ClanWhoButton implements IButton
|
||||
@Override
|
||||
public void onClick(Player player, ClickType clickType)
|
||||
{
|
||||
if (UtilServer.CallEvent(new ClansButtonClickEvent(player, ClansButtonClickEvent.ButtonType.Who)).isCancelled())
|
||||
return;
|
||||
player.closeInventory();
|
||||
|
||||
JsonMessage message = new JsonMessage(C.cRed + C.Bold + "Click here to lookup a clan").click(ClickEvent.SUGGEST_COMMAND, "/c who ");
|
||||
|
@ -0,0 +1,65 @@
|
||||
package mineplex.game.clans.clans.gui.events;
|
||||
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.event.Event;
|
||||
import org.bukkit.event.HandlerList;
|
||||
|
||||
public class ClansButtonClickEvent extends Event
|
||||
{
|
||||
private static final HandlerList handlers = new HandlerList();
|
||||
|
||||
private Player _player;
|
||||
private ButtonType _type;
|
||||
|
||||
private boolean _cancelled;
|
||||
|
||||
public ClansButtonClickEvent(Player player, ButtonType type)
|
||||
{
|
||||
_player = player;
|
||||
_type = type;
|
||||
}
|
||||
|
||||
public Player getPlayer()
|
||||
{
|
||||
return _player;
|
||||
}
|
||||
|
||||
public void setCancelled(boolean cancelled)
|
||||
{
|
||||
_cancelled = cancelled;
|
||||
}
|
||||
|
||||
public boolean isCancelled()
|
||||
{
|
||||
return _cancelled;
|
||||
}
|
||||
|
||||
public ButtonType getButtonType() { return _type}
|
||||
|
||||
public HandlerList getHandlers()
|
||||
{
|
||||
return handlers;
|
||||
}
|
||||
|
||||
public static HandlerList getHandlerList()
|
||||
{
|
||||
return handlers;
|
||||
}
|
||||
|
||||
|
||||
public enum ButtonType
|
||||
{
|
||||
AddAlly,
|
||||
AddTrusted,
|
||||
AddWar,
|
||||
Create,
|
||||
Disband,
|
||||
Energy,
|
||||
Invite,
|
||||
Join,
|
||||
Leave,
|
||||
Member,
|
||||
Territory,
|
||||
Who;
|
||||
}
|
||||
}
|
@ -4,6 +4,7 @@ import java.io.IOException;
|
||||
import java.util.List;
|
||||
import java.util.UUID;
|
||||
|
||||
import mineplex.game.clans.clans.gui.events.ClansButtonClickEvent;
|
||||
import org.bukkit.DyeColor;
|
||||
import org.bukkit.GameMode;
|
||||
import org.bukkit.Location;
|
||||
@ -378,4 +379,10 @@ public class ClansMainTutorial extends Tutorial
|
||||
{
|
||||
return _mapManager;
|
||||
}
|
||||
|
||||
@EventHandler (priority = EventPriority.LOWEST)
|
||||
public void onClick(ClansButtonClickEvent event) {
|
||||
if(isInTutorial(event.getPlayer()))
|
||||
event.setCancelled(true);
|
||||
}
|
||||
}
|
||||
|
@ -2,6 +2,7 @@ package mineplex.game.clans.tutorial.tutorials.clans.objective.goals.clan;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import mineplex.game.clans.clans.gui.events.ClansButtonClickEvent;
|
||||
import org.bukkit.Location;
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.entity.Player;
|
||||
@ -15,6 +16,7 @@ import mineplex.game.clans.clans.event.PlayerPreClaimTerritoryEvent;
|
||||
import mineplex.game.clans.tutorial.TutorialRegion;
|
||||
import mineplex.game.clans.tutorial.tutorials.clans.ClansMainTutorial;
|
||||
import mineplex.game.clans.tutorial.tutorials.clans.objective.ClanObjective;
|
||||
import org.bukkit.event.EventPriority;
|
||||
|
||||
public class ClaimLandGoal extends ObjectiveGoal<ClanObjective>
|
||||
{
|
||||
@ -54,4 +56,11 @@ public class ClaimLandGoal extends ObjectiveGoal<ClanObjective>
|
||||
event.setCancelled(true);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@EventHandler (priority = EventPriority.HIGHEST)
|
||||
public void onClick(ClansButtonClickEvent event) {
|
||||
if(contains(event.getPlayer()) && event.getButtonType().equals(ClansButtonClickEvent.ButtonType.Territory))
|
||||
event.setCancelled(false);
|
||||
}
|
||||
}
|
||||
|
@ -1,5 +1,6 @@
|
||||
package mineplex.game.clans.tutorial.tutorials.clans.objective.goals.clan;
|
||||
|
||||
import mineplex.game.clans.clans.gui.events.ClansButtonClickEvent;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.event.EventHandler;
|
||||
|
||||
@ -8,6 +9,7 @@ import mineplex.game.clans.clans.ClanInfo;
|
||||
import mineplex.game.clans.clans.ClansManager;
|
||||
import mineplex.game.clans.clans.event.ClansCommandExecutedEvent;
|
||||
import mineplex.game.clans.tutorial.tutorials.clans.objective.ClanObjective;
|
||||
import org.bukkit.event.EventPriority;
|
||||
|
||||
public class ClanDetailsGoal extends ObjectiveGoal<ClanObjective>
|
||||
{
|
||||
@ -51,4 +53,11 @@ public class ClanDetailsGoal extends ObjectiveGoal<ClanObjective>
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@EventHandler (priority = EventPriority.HIGHEST)
|
||||
public void onClick(ClansButtonClickEvent event) {
|
||||
if(contains(event.getPlayer()) && (event.getButtonType().equals(ClansButtonClickEvent.ButtonType.Who)))
|
||||
event.setCancelled(false);
|
||||
}
|
||||
}
|
||||
|
@ -5,10 +5,12 @@ import mineplex.game.clans.clans.ClanInfo;
|
||||
import mineplex.game.clans.clans.ClansManager;
|
||||
import mineplex.game.clans.clans.event.ClansCommandExecutedEvent;
|
||||
import mineplex.game.clans.clans.event.ClansCommandPreExecutedEvent;
|
||||
import mineplex.game.clans.clans.gui.events.ClansButtonClickEvent;
|
||||
import mineplex.game.clans.tutorial.objective.ObjectiveGoal;
|
||||
import mineplex.game.clans.tutorial.tutorials.clans.objective.ClanObjective;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.event.EventHandler;
|
||||
import org.bukkit.event.EventPriority;
|
||||
|
||||
/**
|
||||
* Created by Adam on 29/03/2016.
|
||||
@ -42,4 +44,11 @@ public class ClanManagementGoal extends ObjectiveGoal<ClanObjective>
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@EventHandler (priority = EventPriority.HIGHEST)
|
||||
public void onClick(ClansButtonClickEvent event) {
|
||||
if(contains(event.getPlayer()) && event.getButtonType().equals(ClansButtonClickEvent.ButtonType.Energy))
|
||||
event.setCancelled(false);
|
||||
}
|
||||
}
|
||||
|
@ -1,5 +1,6 @@
|
||||
package mineplex.game.clans.tutorial.tutorials.clans.objective.goals.clan;
|
||||
|
||||
import mineplex.game.clans.clans.gui.events.ClansButtonClickEvent;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.event.EventHandler;
|
||||
|
||||
@ -7,6 +8,7 @@ import mineplex.game.clans.tutorial.objective.ObjectiveGoal;
|
||||
import mineplex.game.clans.clans.ClansManager;
|
||||
import mineplex.game.clans.clans.event.ClanCreationCompleteEvent;
|
||||
import mineplex.game.clans.tutorial.tutorials.clans.objective.ClanObjective;
|
||||
import org.bukkit.event.EventPriority;
|
||||
|
||||
public class CreateClanGoal extends ObjectiveGoal<ClanObjective>
|
||||
{
|
||||
@ -39,4 +41,11 @@ public class CreateClanGoal extends ObjectiveGoal<ClanObjective>
|
||||
finish(event.getFounder());
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@EventHandler (priority = EventPriority.HIGHEST)
|
||||
public void onClick(ClansButtonClickEvent event) {
|
||||
if(contains(event.getPlayer()) && event.getButtonType().equals(ClansButtonClickEvent.ButtonType.Create))
|
||||
event.setCancelled(false);
|
||||
}
|
||||
}
|
||||
|
@ -48,7 +48,7 @@ public class SetHomeGoal extends ObjectiveGoal<ClanObjective>
|
||||
|
||||
// we need to save this for later when the player teleports home!
|
||||
getObjective().getPlugin().getTutorialSession(event.getPlayer()).setHomeLocation(event.getPlayer().getLocation());
|
||||
|
||||
|
||||
finish(event.getPlayer());
|
||||
|
||||
UtilPlayer.message(event.getPlayer(), F.main("Clans", "You have successfully set your Clan's Home to " + UtilWorld.locToStrClean(event.getPlayer().getLocation()) + "."));
|
||||
@ -57,7 +57,7 @@ public class SetHomeGoal extends ObjectiveGoal<ClanObjective>
|
||||
{
|
||||
UtilPlayer.message(event.getPlayer(), F.main("Tutorial", "You must set your home in your own land claim."));
|
||||
}
|
||||
|
||||
|
||||
event.setCancelled(true);
|
||||
}
|
||||
}
|
||||
|
@ -1,5 +1,6 @@
|
||||
package mineplex.game.clans.tutorial.tutorials.clans.objective.goals.energy;
|
||||
|
||||
import mineplex.game.clans.clans.gui.events.ClansButtonClickEvent;
|
||||
import org.bukkit.Sound;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
@ -9,6 +10,8 @@ import mineplex.core.common.util.UtilTextMiddle;
|
||||
import mineplex.game.clans.clans.ClansManager;
|
||||
import mineplex.game.clans.tutorial.objective.ObjectiveGoal;
|
||||
import mineplex.game.clans.tutorial.tutorials.clans.objective.EnergyObjective;
|
||||
import org.bukkit.event.EventHandler;
|
||||
import org.bukkit.event.EventPriority;
|
||||
|
||||
public class ExplainEnergyGoal extends ObjectiveGoal<EnergyObjective>
|
||||
{
|
||||
@ -40,4 +43,11 @@ public class ExplainEnergyGoal extends ObjectiveGoal<EnergyObjective>
|
||||
protected void customFinish(Player player)
|
||||
{
|
||||
}
|
||||
|
||||
|
||||
@EventHandler(priority = EventPriority.HIGHEST)
|
||||
public void onClick(ClansButtonClickEvent event) {
|
||||
if(contains(event.getPlayer()) && event.getButtonType().equals(ClansButtonClickEvent.ButtonType.Energy))
|
||||
event.setCancelled(false);
|
||||
}
|
||||
}
|
||||
|
@ -1,6 +1,7 @@
|
||||
package mineplex.game.clans.tutorial.tutorials.clans.objective.goals.finalobj;
|
||||
|
||||
import mineplex.game.clans.clans.event.ClanDisbandedEvent;
|
||||
import mineplex.game.clans.clans.gui.events.ClansButtonClickEvent;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.event.EventHandler;
|
||||
import org.bukkit.event.EventPriority;
|
||||
@ -44,4 +45,11 @@ public class DisbandClanGoal extends ObjectiveGoal<FinalObjective>
|
||||
ClansManager.getInstance().getClanDataAccess().delete(ClansManager.getInstance().getClan(event.getDisbander()), null);
|
||||
finish(event.getDisbander());
|
||||
}
|
||||
|
||||
|
||||
@EventHandler (priority = EventPriority.HIGHEST)
|
||||
public void onClick(ClansButtonClickEvent event) {
|
||||
if(contains(event.getPlayer()) && event.getButtonType().equals(ClansButtonClickEvent.ButtonType.Disband))
|
||||
event.setCancelled(false);
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user