Skip to content

Commit

Permalink
Merge pull request #54 from okocraft/develop/master
Browse files Browse the repository at this point in the history
v3.1.6
- Changed event priority to prevent confliction with other plugin that change dropped items
- Changed /box stick command to give stick in off hand
- Commented out buggy method updateItems method
- update project version in pom
  • Loading branch information
LazyGon authored Sep 19, 2021
2 parents 9830066 + 03409e0 commit 5e28bdf
Show file tree
Hide file tree
Showing 4 changed files with 14 additions and 4 deletions.
2 changes: 1 addition & 1 deletion pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@

<groupId>net.okocraft.box</groupId>
<artifactId>Box</artifactId>
<version>3.1.5-SNAPSHOT</version>
<version>3.1.6</version>

<name>Box</name>
<url>https://github.com/okocraft/Box</url>
Expand Down
12 changes: 11 additions & 1 deletion src/main/java/net/okocraft/box/command/box/StickCommand.java
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@

import org.bukkit.command.CommandSender;
import org.bukkit.entity.Player;
import org.bukkit.inventory.PlayerInventory;

import net.okocraft.box.command.BaseCommand;

Expand All @@ -43,6 +44,15 @@ public boolean runCommand(CommandSender sender, String[] args) {
return false;
}

return ((Player) sender).getInventory().addItem(config.getStick()).isEmpty();
Player player = (Player) sender;
PlayerInventory inv = player.getInventory();
int firstEmpty = inv.firstEmpty();
if (firstEmpty == -1) {
messages.sendInventoryIsFull(sender);
return true;
}
inv.setItem(firstEmpty, inv.getItemInOffHand());
inv.setItemInOffHand(config.getStick());
return true;
}
}
2 changes: 1 addition & 1 deletion src/main/java/net/okocraft/box/database/ItemTable.java
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ final class ItemTable {
this.database = database;
database.execute("CREATE TABLE IF NOT EXISTS " + TABLE + " (id INTEGER PRIMARY KEY " + (database.isSQLite() ? "AUTOINCREMENT" : "AUTO_INCREMENT") + ", item VARCHAR(4096) NOT NULL, customname VARCHAR(255) UNIQUE)");
loadItems();
updateItems();
// updateItems();
addDefaultItems();
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -133,7 +133,7 @@ public void onJoin(PlayerJoinEvent event) {
*
* @param event EntityPickupItemEvent
*/
@EventHandler(priority = EventPriority.HIGHEST, ignoreCancelled = true)
@EventHandler(priority = EventPriority.HIGH, ignoreCancelled = true)
public void autoStoreDroppedItem(EntityPickupItemEvent event) {
if (!config.isAutoStoreEnabled()) {
return;
Expand Down

0 comments on commit 5e28bdf

Please sign in to comment.