Skip to content

Commit

Permalink
Bugfix: Spaces cannot be used in disc names
Browse files Browse the repository at this point in the history
  • Loading branch information
Navoei committed Sep 5, 2022
1 parent f06ad64 commit e646b45
Show file tree
Hide file tree
Showing 5 changed files with 19 additions and 21 deletions.
2 changes: 1 addition & 1 deletion gradle.properties
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,6 @@ mod_id=customdiscsplugin
# Target an older API to make it compatible with older versions of Simple Voice Chat
voicechat_api_version=2.3.3

plugin_version=2.2.1
plugin_version=2.2.2
maven_group=me.Navoei.customdiscsplugin
archives_base_name=custom-discs
1 change: 0 additions & 1 deletion src/main/java/me/Navoei/customdiscsplugin/CustomDiscs.java
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,6 @@
import org.apache.logging.log4j.Logger;
import org.bukkit.NamespacedKey;
import org.bukkit.block.Jukebox;
import org.bukkit.inventory.ItemFlag;
import org.bukkit.persistence.PersistentDataType;
import org.bukkit.plugin.java.JavaPlugin;

Expand Down
16 changes: 7 additions & 9 deletions src/main/java/me/Navoei/customdiscsplugin/HopperManager.java
Original file line number Diff line number Diff line change
@@ -1,7 +1,5 @@
package me.Navoei.customdiscsplugin;

import net.kyori.adventure.text.Component;
import net.kyori.adventure.text.serializer.plain.PlainTextComponentSerializer;
import org.bukkit.Bukkit;
import org.bukkit.Material;
import org.bukkit.NamespacedKey;
Expand All @@ -26,7 +24,7 @@

public class HopperManager implements Listener {

@EventHandler(priority = EventPriority.MONITOR, ignoreCancelled = true)
@EventHandler(priority = EventPriority.HIGHEST, ignoreCancelled = true)
public void onHopperPickupFromOtherSource(InventoryMoveItemEvent event) {

if (event.getDestination().getLocation() == null) return;
Expand Down Expand Up @@ -62,7 +60,7 @@ public void onHopperPickupFromOtherSource(InventoryMoveItemEvent event) {

}

@EventHandler(priority = EventPriority.MONITOR, ignoreCancelled = true)
@EventHandler(priority = EventPriority.HIGHEST, ignoreCancelled = true)
public void onHopperPickupItem(InventoryPickupItemEvent event) {

if (!Objects.requireNonNull(event.getInventory().getLocation()).getChunk().isLoaded()) return;
Expand Down Expand Up @@ -97,7 +95,7 @@ public void onHopperPickupItem(InventoryPickupItemEvent event) {

}

@EventHandler(priority = EventPriority.MONITOR, ignoreCancelled = true)
@EventHandler(priority = EventPriority.HIGHEST, ignoreCancelled = true)
public void onItemPlayerToHopper(InventoryClickEvent event) {

if (event.getClickedInventory() == null) return;
Expand Down Expand Up @@ -182,7 +180,7 @@ public void onItemPlayerToHopper(InventoryClickEvent event) {

}

@EventHandler(priority = EventPriority.MONITOR, ignoreCancelled = true)
@EventHandler(priority = EventPriority.HIGHEST, ignoreCancelled = true)
public void onInventoryDrag(InventoryDragEvent event) {

if (Objects.requireNonNull(event.getInventory()).getLocation() == null) return;
Expand All @@ -204,7 +202,7 @@ public void onInventoryDrag(InventoryDragEvent event) {

}

@EventHandler(priority = EventPriority.MONITOR, ignoreCancelled = true)
@EventHandler(priority = EventPriority.HIGHEST, ignoreCancelled = true)
public void onChunkLoad(ChunkLoadEvent event) {
for (BlockState blockState : event.getChunk().getTileEntities()) {
if (blockState instanceof Jukebox) {
Expand All @@ -215,15 +213,15 @@ public void onChunkLoad(ChunkLoadEvent event) {
}
}

@EventHandler(priority = EventPriority.MONITOR, ignoreCancelled = true)
@EventHandler(priority = EventPriority.HIGHEST, ignoreCancelled = true)
public void onJukeboxPlace(BlockPlaceEvent event) {
if (!event.getBlock().getType().equals(Material.JUKEBOX)) return;

getNextDiscFromHopperIntoJukebox(event.getBlock());

}

@EventHandler(priority = EventPriority.MONITOR, ignoreCancelled = true)
@EventHandler(priority = EventPriority.HIGHEST, ignoreCancelled = true)
public void onHopperPlace(BlockPlaceEvent event) {
if (!event.getBlock().getType().equals(Material.HOPPER)) return;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ public String getSyntax() {
@Override
public void perform(Player player, String[] args) {
if (isMusicDisc(player)) {
if (args.length == 3) {
if (args.length >= 3) {

if (!player.hasPermission("customdiscs.create")) {
player.sendMessage(ChatColor.RED + "You do not have permission to execute this command!");
Expand Down Expand Up @@ -94,10 +94,8 @@ public void perform(Player player, String[] args) {
player.sendMessage("Your filename is: " + ChatColor.GRAY + songname);
player.sendMessage("Your custom name is: " + ChatColor.GRAY + customName(readQuotes(args)));

} else if (args.length < 3) {
player.sendMessage(ChatColor.RED + "Insufficient arguments! ( /customdisc create <filename> \"Custom Lore\" )");
} else {
player.sendMessage(ChatColor.RED + "Too many arguments! ( /customdisc create <filename> \"Custom Lore\" )");
player.sendMessage(ChatColor.RED + "Insufficient arguments! ( /customdisc create <filename> \"Custom Lore\" )");
}
} else {
player.sendMessage(ChatColor.RED + "You are not holding a music disc in your main hand!");
Expand Down
15 changes: 9 additions & 6 deletions src/main/java/me/Navoei/customdiscsplugin/event/JukeBox.java
Original file line number Diff line number Diff line change
Expand Up @@ -13,16 +13,19 @@
import org.bukkit.Material;
import org.bukkit.NamespacedKey;
import org.bukkit.block.Block;
import org.bukkit.block.BlockState;
import org.bukkit.block.Jukebox;
import org.bukkit.block.data.BlockData;
import org.bukkit.block.data.Directional;
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.Action;
import org.bukkit.event.block.BlockBreakEvent;
import org.bukkit.event.block.BlockRedstoneEvent;
import org.bukkit.event.entity.EntityExplodeEvent;
import org.bukkit.event.player.PlayerInteractEvent;
import org.bukkit.inventory.ItemFlag;
import org.bukkit.persistence.PersistentDataType;

import java.io.FileNotFoundException;
Expand All @@ -32,7 +35,7 @@

public class JukeBox implements Listener{

@EventHandler(priority = EventPriority.MONITOR, ignoreCancelled = true)
@EventHandler(priority = EventPriority.HIGHEST, ignoreCancelled = true)
public void onInsert(PlayerInteractEvent event) throws IOException {

Player player = event.getPlayer();
Expand Down Expand Up @@ -69,7 +72,7 @@ public void onInsert(PlayerInteractEvent event) throws IOException {
}
}

@EventHandler(priority = EventPriority.MONITOR, ignoreCancelled = true)
@EventHandler(priority = EventPriority.HIGHEST, ignoreCancelled = true)
public void onEject(PlayerInteractEvent event) {

Player player = event.getPlayer();
Expand All @@ -85,7 +88,7 @@ public void onEject(PlayerInteractEvent event) {

}

@EventHandler(priority = EventPriority.MONITOR, ignoreCancelled = true)
@EventHandler(priority = EventPriority.HIGHEST, ignoreCancelled = true)
public void onJukeboxBreak(BlockBreakEvent event) {

Block block = event.getBlock();
Expand All @@ -96,8 +99,8 @@ public void onJukeboxBreak(BlockBreakEvent event) {
stopDisc(block, player);
}

@EventHandler
public void onJukeBoxExplode(EntityExplodeEvent event) {
@EventHandler(priority = EventPriority.HIGHEST, ignoreCancelled = true)
public void onJukeboxExplode(EntityExplodeEvent event) {

for (Block explodedBlock : event.blockList()) {
if (explodedBlock.getType() == Material.JUKEBOX) {
Expand Down

0 comments on commit e646b45

Please sign in to comment.