Merge branch 'bring-33b1816'
Bring in proposal by @NotAlexNoyle to hide bet winning title
This commit is contained in:
commit
2a95360562
4 files changed
+108
-101
No files matched your search
@@ -147,6 +147,9 @@ public class Config extends AbstractConfiguration<DuelsPlugin> {
|
||||
private List<String> whitelistedCommands;
|
||||
@Getter
|
||||
private List<String> blacklistedCommands;
|
||||
|
||||
@Getter
|
||||
private boolean isVictoryTitleEnabled;
|
||||
|
||||
@Getter
|
||||
private List<String> queueBlacklistedCommands;
|
||||
@@ -327,6 +330,7 @@ public class Config extends AbstractConfiguration<DuelsPlugin> {
|
||||
blockAllCommands = configuration.getBoolean("duel.block-all-commands", false);
|
||||
whitelistedCommands = configuration.getStringList("duel.whitelisted-commands");
|
||||
blacklistedCommands = configuration.getStringList("duel.blacklisted-commands");
|
||||
isVictoryTitleEnabled = configuration.getBoolean("duel.enable-victory-title");
|
||||
|
||||
queueBlacklistedCommands = configuration.getStringList("queue.blacklisted-commands");
|
||||
|
||||
|
||||
@@ -252,7 +252,7 @@ public class DuelManager implements Loadable {
|
||||
|
||||
final String title = lang.getMessage("DUEL.reward.money.title", "name", opponentName, "money", amount);
|
||||
|
||||
if (title != null) {
|
||||
if (title != null && config.isVictoryTitleEnabled()) {
|
||||
Titles.send(player, title, null, 0, 20, 50);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -22,127 +22,128 @@ import org.bukkit.plugin.java.JavaPlugin;
|
||||
|
||||
public class GuiListener<P extends JavaPlugin> implements Loadable, Listener {
|
||||
|
||||
private final Multimap<UUID, AbstractGui<P>> privateGuis = HashMultimap.create();
|
||||
private final List<AbstractGui<P>> publicGuis = new ArrayList<>();
|
||||
private final Multimap<UUID, AbstractGui<P>> privateGuis = HashMultimap.create();
|
||||
private final List<AbstractGui<P>> publicGuis = new ArrayList<>();
|
||||
|
||||
public GuiListener(final P plugin) {
|
||||
Bukkit.getPluginManager().registerEvents(this, plugin);
|
||||
}
|
||||
public GuiListener(final P plugin) {
|
||||
Bukkit.getPluginManager().registerEvents(this, plugin);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void handleLoad() {}
|
||||
@Override
|
||||
public void handleLoad() {}
|
||||
|
||||
@Override
|
||||
public void handleUnload() {
|
||||
privateGuis.values().forEach(AbstractGui::clear);
|
||||
privateGuis.clear();
|
||||
publicGuis.forEach(AbstractGui::clear);
|
||||
publicGuis.clear();
|
||||
}
|
||||
@Override
|
||||
public void handleUnload() {
|
||||
privateGuis.values().forEach(AbstractGui::clear);
|
||||
privateGuis.clear();
|
||||
publicGuis.forEach(AbstractGui::clear);
|
||||
publicGuis.clear();
|
||||
}
|
||||
|
||||
public void addGui(final AbstractGui<P> gui) {
|
||||
publicGuis.add(gui);
|
||||
}
|
||||
public void addGui(final AbstractGui<P> gui) {
|
||||
publicGuis.add(gui);
|
||||
}
|
||||
|
||||
/**
|
||||
* @param removeSameType Prevents memory leaks in case of gui open failing for guis that remove themselves on inventory close.
|
||||
*/
|
||||
public <T extends AbstractGui<P>> T addGui(final Player player, final T gui, final boolean removeSameType) {
|
||||
if (removeSameType) {
|
||||
final Collection<AbstractGui<P>> guis = privateGuis.asMap().get(player.getUniqueId());
|
||||
/**
|
||||
* @param removeSameType Prevents memory leaks in case of gui open failing for guis that remove themselves on inventory close.
|
||||
*/
|
||||
public <T extends AbstractGui<P>> T addGui(final Player player, final T gui, final boolean removeSameType) {
|
||||
if (removeSameType) {
|
||||
final Collection<AbstractGui<P>> guis = privateGuis.asMap().get(player.getUniqueId());
|
||||
|
||||
if (guis != null) {
|
||||
guis.removeIf(cached -> gui.getClass().isInstance(cached));
|
||||
}
|
||||
}
|
||||
if (guis != null) {
|
||||
guis.removeIf(cached -> gui.getClass().isInstance(cached));
|
||||
}
|
||||
}
|
||||
|
||||
privateGuis.put(player.getUniqueId(), gui);
|
||||
return gui;
|
||||
}
|
||||
privateGuis.put(player.getUniqueId(), gui);
|
||||
return gui;
|
||||
}
|
||||
|
||||
public <T extends AbstractGui<P>> T addGui(final Player player, final T gui) {
|
||||
return addGui(player, gui, false);
|
||||
}
|
||||
public <T extends AbstractGui<P>> T addGui(final Player player, final T gui) {
|
||||
return addGui(player, gui, false);
|
||||
}
|
||||
|
||||
public void removeGui(final AbstractGui<P> gui) {
|
||||
gui.clear();
|
||||
publicGuis.remove(gui);
|
||||
}
|
||||
public void removeGui(final AbstractGui<P> gui) {
|
||||
gui.clear();
|
||||
publicGuis.remove(gui);
|
||||
}
|
||||
|
||||
public void removeGui(final Player player, final AbstractGui<P> gui) {
|
||||
gui.clear();
|
||||
public void removeGui(final Player player, final AbstractGui<P> gui) {
|
||||
gui.clear();
|
||||
|
||||
final Collection<AbstractGui<P>> guis = privateGuis.asMap().get(player.getUniqueId());
|
||||
final Collection<AbstractGui<P>> guis = privateGuis.asMap().get(player.getUniqueId());
|
||||
|
||||
if (guis != null) {
|
||||
guis.remove(gui);
|
||||
}
|
||||
}
|
||||
if (guis != null) {
|
||||
guis.remove(gui);
|
||||
}
|
||||
}
|
||||
|
||||
private List<AbstractGui<P>> get(final Player player) {
|
||||
final List<AbstractGui<P>> guis = Lists.newArrayList(publicGuis);
|
||||
private List<AbstractGui<P>> get(final Player player) {
|
||||
final List<AbstractGui<P>> guis = Lists.newArrayList(publicGuis);
|
||||
|
||||
if (privateGuis.containsKey(player.getUniqueId())) {
|
||||
guis.addAll(privateGuis.get(player.getUniqueId()));
|
||||
}
|
||||
if (privateGuis.containsKey(player.getUniqueId())) {
|
||||
guis.addAll(privateGuis.get(player.getUniqueId()));
|
||||
}
|
||||
|
||||
return guis;
|
||||
}
|
||||
return guis;
|
||||
}
|
||||
|
||||
@EventHandler
|
||||
public void on(final InventoryClickEvent event) {
|
||||
final Player player = (Player) event.getWhoClicked();
|
||||
final Inventory top = player.getOpenInventory().getTopInventory();
|
||||
@EventHandler
|
||||
public void on(final InventoryClickEvent event) {
|
||||
final Player player = (Player) event.getWhoClicked();
|
||||
final Inventory top = player.getOpenInventory().getTopInventory();
|
||||
|
||||
for (final AbstractGui<P> gui : get(player)) {
|
||||
if (gui.isPart(top)) {
|
||||
gui.on(player, top, event);
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
for (final AbstractGui<P> gui : get(player)) {
|
||||
if (gui.isPart(top)) {
|
||||
gui.on(player, top, event);
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@EventHandler
|
||||
public void on(final InventoryDragEvent event) {
|
||||
final Player player = (Player) event.getWhoClicked();
|
||||
final Inventory inventory = event.getInventory();
|
||||
@EventHandler
|
||||
public void on(final InventoryDragEvent event) {
|
||||
final Player player = (Player) event.getWhoClicked();
|
||||
final Inventory inventory = event.getInventory();
|
||||
|
||||
for (final AbstractGui<P> gui : get(player)) {
|
||||
if (gui.isPart(inventory)) {
|
||||
gui.on(player, event.getRawSlots(), event);
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
for (final AbstractGui<P> gui : get(player)) {
|
||||
if (gui.isPart(inventory)) {
|
||||
gui.on(player, event.getRawSlots(), event);
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@EventHandler
|
||||
public void on(final InventoryCloseEvent event) {
|
||||
final Player player = (Player) event.getPlayer();
|
||||
final Inventory inventory = event.getInventory();
|
||||
@EventHandler
|
||||
public void on(final InventoryCloseEvent event) {
|
||||
final Player player = (Player) event.getPlayer();
|
||||
final Inventory inventory = event.getInventory();
|
||||
|
||||
for (final AbstractGui<P> gui : get(player)) {
|
||||
if (gui.isPart(inventory)) {
|
||||
gui.on(player, event.getInventory(), event);
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
for (final AbstractGui<P> gui : get(player)) {
|
||||
if (gui.isPart(inventory)) {
|
||||
gui.on(player, event.getInventory(), event);
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@EventHandler
|
||||
public void on(final EntityPickupItemEvent event) {
|
||||
if (event.getEntity() instanceof Player player) {
|
||||
final Inventory inventory = player.getOpenInventory().getTopInventory();
|
||||
for (final AbstractGui<P> gui : get(player)) {
|
||||
if (gui.isPart(inventory)) {
|
||||
event.setCancelled(true);
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@EventHandler
|
||||
public void on(final EntityPickupItemEvent event) {
|
||||
if (event.getEntity() instanceof Player) {
|
||||
Player player = (Player) event.getEntity();
|
||||
final Inventory inventory = player.getOpenInventory().getTopInventory();
|
||||
for (final AbstractGui<P> gui : get(player)) {
|
||||
if (gui.isPart(inventory)) {
|
||||
event.setCancelled(true);
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@EventHandler
|
||||
public void on(final PlayerQuitEvent event) {
|
||||
privateGuis.removeAll(event.getPlayer().getUniqueId());
|
||||
}
|
||||
@EventHandler
|
||||
public void on(final PlayerQuitEvent event) {
|
||||
privateGuis.removeAll(event.getPlayer().getUniqueId());
|
||||
}
|
||||
}
|
||||
@@ -366,6 +366,8 @@ duel:
|
||||
- 'playervaults:pv'
|
||||
- 'playervaults:playervaults'
|
||||
|
||||
# Determines whether a victory title will be sent upon winning a bet.
|
||||
enable-victory-title: true
|
||||
|
||||
queue:
|
||||
# List of commands to block while in a queue.
|
||||
|
||||
Reference in new issue
Block a user