-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
23f5efc
commit 89d3cb9
Showing
7 changed files
with
257 additions
and
12 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
79 changes: 79 additions & 0 deletions
79
...dQuitMessages/src/main/java/jss/customjoinandquitmessages/listener/InventoryListener.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,79 @@ | ||
package jss.customjoinandquitmessages.listener; | ||
|
||
import org.bukkit.entity.Player; | ||
import org.bukkit.event.Listener; | ||
import org.bukkit.event.inventory.InventoryClickEvent; | ||
|
||
import jss.customjoinandquitmessages.CustomJoinAndQuitMessages; | ||
import jss.customjoinandquitmessages.manager.DisplayManager; | ||
import jss.customjoinandquitmessages.manager.InventoryView; | ||
import jss.customjoinandquitmessages.utils.EventUtils; | ||
|
||
public class InventoryListener implements Listener{ | ||
|
||
private CustomJoinAndQuitMessages plugin; | ||
private EventUtils eventUtils = new EventUtils(plugin); | ||
|
||
public InventoryListener(CustomJoinAndQuitMessages plugin) { | ||
this.plugin = plugin; | ||
eventUtils.getEventManager().registerEvents(this, plugin); | ||
} | ||
|
||
public void onInventoryClick(InventoryClickEvent e) { | ||
Player j = (Player) e.getWhoClicked(); | ||
InventoryView view = plugin.getInventoryView(j); | ||
|
||
if(view == null) return; | ||
if(!view.getInventoryName().contains("displaygui")) return; | ||
if(e.isShiftClick()) return; | ||
if(e.getCurrentItem() == null || e.getCurrentItem().getType().name().contains("AIR")) { | ||
e.setCancelled(true); | ||
return; | ||
} | ||
|
||
if(e.getSlotType() == null) { | ||
e.setCancelled(true); | ||
return; | ||
}else { | ||
if(!e.getClickedInventory().equals(j.getOpenInventory().getTopInventory())) return; | ||
|
||
int slot = e.getSlot(); | ||
e.setCancelled(true); | ||
|
||
DisplayManager displayManager = new DisplayManager(j); | ||
|
||
if(slot == 11) { | ||
displayManager.showJoinMessage(); | ||
} | ||
|
||
if(slot == 13) { | ||
displayManager.showQuitMessage(); | ||
} | ||
|
||
if(slot == 15) { | ||
displayManager.showWelcomeMessage(); | ||
} | ||
|
||
if(slot == 29) { | ||
displayManager.showTitleMessage(); | ||
} | ||
|
||
if(slot == 31) { | ||
displayManager.showActionbar(); | ||
} | ||
|
||
if(slot == 33) { | ||
displayManager.showFirstJoinMessage(); | ||
} | ||
|
||
if(slot == 39) { | ||
displayManager.showJoinSound(); | ||
} | ||
|
||
if(slot == 41) { | ||
displayManager.showQuitSound(); | ||
} | ||
} | ||
} | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.