java - Bukkit - Get Variables From Other @EventHandlers? -
I was wondering how I would get a variable from a different @EventHandler. At this time, my variable is an array list.
My code is below:
@EventHandlerClockblock on Public Zero (BlockBreak event event) {ArrayList & lt; String & gt; Build = new arrelist (); Player Player = event.getPlayer (); If (! Player.isOp ()) {event.setCancelled (true); } And if (! BuildConnant (player)) {event.setCancelled (true); } And if (BuildConnant (player)) {event.setCancelled (wrong); }} @EventHandlerPlayerJoin on Public Zero (PlayerJoinEvent Event) {Player Player = event.getPlayer (); Event.setJoinMessage ("§4§l & gt; §a§l" + player + "§b§ljoined! §4§l <");); If (build. Player) {build.remove (player);
Now, on the second @EventHandler, this variable can not solve "build" which I have defined in the last @EventHandler, how can I make it so that it works?
build
is a local variable and only onBlockBreak (BlockBreakEvent event ) Is available within
.
What you want to do is declaring a variable out and it's its Enenable () method on what you should do Kingfaris 10 and store the player's UUID. should do. You will need any way to add players to ArrayList.
Private Arrestists & lt; UUID & gt; Creation; @ Override enabled on public null () {build = New Arreelist & lt; UUID & gt; (); } @EventHandlerClockblock at Public Zero (Blockbreaking Event Event) {Player Player = event.getPlayer (); // KingFaris10 has been derived from (! Player.isOp () ||! Build.contains (player.getUUID ())) event.setCancelled (true); Else event.setCancelled (wrong); } @EventHandlerPlayerJoin on Public Zero (PlayerJoinEvent Event) {Player Player = event.getPlayer (); Event.setJoinMessage ("§4§l & gt; §a§l" + player + "§b§ljoined! §4§l <");); UUID ID = Player.GETUID (); If (builds. Id)) {build.remove (id);
Comments
Post a Comment