Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

worldguard regions support #1

Open
wants to merge 31 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
31 commits
Select commit Hold shift + click to select a range
9f2a8c1
Update TextMode.java
crazyhorse961 Dec 8, 2016
0528b2d
Update SendPlayerMessageTask.java
crazyhorse961 Dec 8, 2016
4d79c33
Update PlayerData.java
crazyhorse961 Dec 8, 2016
ade183c
Update README.md
crazyhorse961 Dec 8, 2016
15a5986
Updated plugin.yml with additional infos
crazyhorse961 Dec 8, 2016
a36767d
Create pom.xml
crazyhorse961 Dec 8, 2016
7670b4a
Delete PlayerData.java
crazyhorse961 Dec 8, 2016
de3ae2f
Delete FindChestsThread.java
crazyhorse961 Dec 8, 2016
5505185
Delete TextMode.java
crazyhorse961 Dec 8, 2016
fbf93a2
Delete SendPlayerMessageTask.java
crazyhorse961 Dec 8, 2016
f163b6b
Delete Messages.java
crazyhorse961 Dec 8, 2016
b107141
Delete Features.java
crazyhorse961 Dec 8, 2016
edf4eb1
Delete DepositRecord.java
crazyhorse961 Dec 8, 2016
80e6bb7
Delete DataStore.java
crazyhorse961 Dec 8, 2016
9d8dd27
Delete CustomizableMessage.java
crazyhorse961 Dec 8, 2016
f0df35a
Delete AutomaticInventory.java
crazyhorse961 Dec 8, 2016
6343871
Delete AIEventHandler.java
crazyhorse961 Dec 8, 2016
270f37f
Create plugin.yml
crazyhorse961 Dec 8, 2016
2861f5f
Create TextMode
crazyhorse961 Dec 8, 2016
5db0654
Create SendPlayerMessageTask
crazyhorse961 Dec 8, 2016
c89c751
Create PlayerData
crazyhorse961 Dec 8, 2016
ffaff5f
Create Messages
crazyhorse961 Dec 8, 2016
9bfc6f3
Create FindChestsThread
crazyhorse961 Dec 8, 2016
5b58603
Create Features
crazyhorse961 Dec 8, 2016
5c926e9
Create DepositRecord
crazyhorse961 Dec 8, 2016
0fab365
Create DataStore
crazyhorse961 Dec 8, 2016
779f28c
Create CustomizableMessage
crazyhorse961 Dec 8, 2016
0455b2d
Create AutomaticInventory
crazyhorse961 Dec 8, 2016
aa8ffa8
Create AIEventHandler
crazyhorse961 Dec 8, 2016
eb2f13a
Update README.md
crazyhorse961 Dec 9, 2016
f24d090
Update README.md
crazyhorse961 Jan 13, 2017
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 7 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,3 +3,10 @@
I created this Minecraft server plugin using the Bukkit API to minimize the pain of inventory management. It automatically sorts player and chest inventories, intelligently deposits player loot into correct containers, and auto-refills hotbar slots when players use the last item in a stack (or break a tool!) but have more of the same in their backpacks.

I stopped working on this project after Minecraft 1.10. Anyone may use my source code to continue the project, but see the LICENSE file for restrictions.

# The future of this project
Actually, me (crazyhoorse961) i want to continue this project with a fork. Ill try update it, i won't publish it on spigot or bukkit but feel free to build it, i've now leaved releases too.

# READ
I'm realizing that i haven't much time to take this project but, i will take it updated to 1.12 and all the future versions, but, i won't (probably) add many features and i won't be that active on solving issues. Sorry

16 changes: 10 additions & 6 deletions plugin.yml
Original file line number Diff line number Diff line change
@@ -1,17 +1,17 @@
main: me.ryanhamshire.automaticinventory.AutomaticInventory
name: AutomaticInventory
main: me.ryanhamshire.AutomaticInventory.AutomaticInventory
version: 2.7.1
version: 2.7.2 Fork
commands:
debugai:
description: Debug command for AutomaticInventory.
description: The debug command for AutomaticInventory
usage: /debugai
permission: automaticinventory.debug
autosort:
description: Toggles auto-sorting options.
usage: /AutoSort
usage: /autosort
depositall:
description: Deposits your non-hotbar inventory into any nearby chests containing matching items.
usage: /DepositAll
usage: /depositall
aliases: [da, dumpitems, dumploot, depositloot]
permission: automaticinventory.depositall
permissions:
Expand Down Expand Up @@ -44,4 +44,8 @@ permissions:
default: true
automaticinventory.depositall:
description: Grants permission to use /DepositAll.
default: true
default: true
load: STARTUP
authors: [ryanhamshire,crazyhoorse961]
website: https://github.com/crazyhorse961/AutomaticInventory
database: false
49 changes: 49 additions & 0 deletions pom.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>com.crazyhoorse961</groupId>
<artifactId>auto-inv</artifactId>
<version>0.0.1-SNAPSHOT</version>
<name>AutomaticInventory</name>
<build>
<sourceDirectory>src</sourceDirectory>
<plugins>
<plugin>
<artifactId>maven-compiler-plugin</artifactId>
<version>3.5.1</version>
<configuration>
<source>1.8</source>
<target>1.8</target>
</configuration>
</plugin>
</plugins>
</build>
<repositories>
<repository>
<id>spigot-repo</id>
<url>https://hub.spigotmc.org/nexus/content/repositories/snapshots/</url>
</repository>
</repositories>
<dependencies>
<!--Spigot API-->
<dependency>
<groupId>org.spigotmc</groupId>
<artifactId>spigot-api</artifactId>
<version>1.11-R0.1-SNAPSHOT</version>
<scope>provided</scope>
</dependency>
<!--Bukkit API-->
<dependency>
<groupId>org.bukkit</groupId>
<artifactId>bukkit</artifactId>
<version>1.11-R0.1-SNAPSHOT</version>
<scope>provided</scope>
</dependency>
<!--CraftBukkit-->
<dependency>
<groupId>org.bukkit</groupId>
<artifactId>craftbukkit</artifactId>
<version>1.11-R0.1-SNAPSHOT</version>
<scope>provided</scope>
</dependency>
</dependencies>
</project>
10 changes: 0 additions & 10 deletions src/me/ryanhamshire/AutomaticInventory/Features.java

This file was deleted.

23 changes: 0 additions & 23 deletions src/me/ryanhamshire/AutomaticInventory/Messages.java

This file was deleted.

15 changes: 0 additions & 15 deletions src/me/ryanhamshire/AutomaticInventory/TextMode.java

This file was deleted.

Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
//Copyright 2015 Ryan Hamshire

package me.ryanhamshire.AutomaticInventory;
package me.ryanhamshire.automaticinventory;

import java.util.ArrayList;
import java.util.Collections;
Expand Down Expand Up @@ -98,7 +98,7 @@ private void tryRefillStackInHand(Player player, EquipmentSlot slot, boolean dat
{
if(slot == null) return;

if(!featureEnabled(Features.RefillStacks, player)) return;
if(!featureEnabled(Features.REFILLSTACKS, player)) return;

ItemStack stack = null;
int slotIndex = 0;
Expand All @@ -117,44 +117,44 @@ else if(slot == EquipmentSlot.OFF_HAND)
return;
}

if(AutomaticInventory.instance.config_noAutoRefillIDs.contains(stack.getTypeId())) return;
if(AutomaticInventory.getInstance().config_noAutoRefillIDs.contains(stack.getTypeId())) return;
if(!dataValueMatters || stack.getAmount() == 1)
{
PlayerInventory inventory = player.getInventory();
AutomaticInventory.instance.getServer().getScheduler().scheduleSyncDelayedTask(
AutomaticInventory.instance,
AutomaticInventory.getInstance().getServer().getScheduler().scheduleSyncDelayedTask(
AutomaticInventory.getInstance(),
new AutoRefillHotBarTask(player, inventory, slotIndex, stack.clone(), dataValueMatters),
2L);
}
}

static boolean featureEnabled(Features feature, Player player)
public static boolean featureEnabled(Features feature, Player player)
{
if(!AutomaticInventory.hasPermission(feature, player)) return false;

PlayerData data = PlayerData.FromPlayer(player);

switch(feature)
{
case SortInventory:
case SORTINVENTORY:
if(data.isSortInventory()) return true;
break;
case SortChests:
case SORTCHESTS:
if(data.isSortChests()) return true;
break;
case RefillStacks:
case REFILLSTACKS:
return true;
case QuickDeposit:
case QUICKDEPOSIT:
return true;
case DepositAll:
case DEPOSITALL:
return true;
}

return false;
}

@SuppressWarnings("deprecation")
private static boolean itemsAreSimilar(ItemStack a, ItemStack b, boolean dataValueMatters)
private boolean itemsAreSimilar(ItemStack a, ItemStack b, boolean dataValueMatters)
{
if(a.getType() == b.getType() && (!dataValueMatters || a.getData().getData() == b.getData().getData()))
{
Expand Down Expand Up @@ -237,7 +237,7 @@ public void run()
PlayerData playerData = PlayerData.FromPlayer(player);
if(!playerData.isGotRestackInfo())
{
AutomaticInventory.sendMessage(player, TextMode.Info, Messages.AutoRefillEducation);
AutomaticInventory.getInstance().sendMessage(player, TextMode.INFO, Messages.AUTOREFILLEDUCATION);
playerData.setGotRestackInfo(true);
}
}
Expand All @@ -249,7 +249,7 @@ public void onBlockDamage(BlockDamageEvent event)
Player player = event.getPlayer();
if(!player.isSneaking()) return;

if(!featureEnabled(Features.QuickDeposit, player)) return;
if(!featureEnabled(Features.QUICKDEPOSIT, player)) return;

Block clickedBlock = event.getBlock();
if(clickedBlock == null) return;
Expand All @@ -258,9 +258,10 @@ public void onBlockDamage(BlockDamageEvent event)
if(clickedMaterial != Material.CHEST && clickedMaterial != Material.TRAPPED_CHEST) return;

@SuppressWarnings("deprecation")
PlayerInteractEvent fakeEvent = AutomaticInventory.instance.new FakePlayerInteractEvent(player, Action.RIGHT_CLICK_BLOCK, player.getItemInHand(), clickedBlock, BlockFace.EAST);
PlayerInteractEvent fakeEvent = AutomaticInventory.getInstance().new FakePlayerInteractEvent(player, Action.RIGHT_CLICK_BLOCK, player.getItemInHand(), clickedBlock, BlockFace.EAST);
Bukkit.getServer().getPluginManager().callEvent(fakeEvent);
if(fakeEvent.isCancelled()) return;
if(fakeEvent.isCancelled())
{ return; }

InventoryHolder chest = (InventoryHolder)clickedBlock.getState();
Inventory chestInventory = chest.getInventory();
Expand All @@ -270,9 +271,9 @@ public void onBlockDamage(BlockDamageEvent event)

@SuppressWarnings("deprecation")
int aboveBlockID = clickedBlock.getRelative(BlockFace.UP).getTypeId();
if(AutomaticInventory.preventsChestOpen(aboveBlockID))
if(AutomaticInventory.getInstance().preventsChestOpen(aboveBlockID))
{
AutomaticInventory.sendMessage(player, TextMode.Err, Messages.ChestLidBlocked);
AutomaticInventory.getInstance().sendMessage(player, TextMode.ERR, Messages.CHESTLIDBLOCKED);
return;
}

Expand All @@ -281,15 +282,15 @@ public void onBlockDamage(BlockDamageEvent event)
//send confirmation message to player with counts deposited. if none deposited, give instructions on how to set up the chest.
if(deposits.destinationFull && deposits.totalItems == 0)
{
AutomaticInventory.sendMessage(player, TextMode.Err, Messages.FailedDepositChestFull2);
AutomaticInventory.getInstance().sendMessage(player, TextMode.ERR, Messages.FAILEDDEPOSITCHESTFULL2);
}
else if(deposits.totalItems == 0)
{
AutomaticInventory.sendMessage(player, TextMode.Info, Messages.FailedDepositNoMatch);
AutomaticInventory.getInstance().sendMessage(player, TextMode.INFO, Messages.FAILEDDEPOSITNOMATCH);
}
else
{
AutomaticInventory.sendMessage(player, TextMode.Success, Messages.SuccessfulDeposit2, String.valueOf(deposits.totalItems));
AutomaticInventory.getInstance().sendMessage(player, TextMode.SUCCESS, Messages.SUCCESSFULDEPOSIT2, String.valueOf(deposits.totalItems));

//make a note that quick deposit was used so that player will not be bothered with advertisement messages again.
PlayerData playerData = PlayerData.FromPlayer(player);
Expand All @@ -314,17 +315,17 @@ public void onInventoryOpen(InventoryOpenEvent event)
PlayerData playerData = PlayerData.FromPlayer(player);
sortPlayerIfEnabled(player, playerData, bottomInventory);

if(!player.isSneaking() && featureEnabled(Features.SortChests, player))
if(!player.isSneaking() && featureEnabled(Features.SORTCHESTS, player))
{
Inventory topInventory = event.getView().getTopInventory();
if(!isSortableChestInventory(topInventory)) return;

InventorySorter sorter = new InventorySorter(topInventory, 0);
Bukkit.getServer().getScheduler().scheduleSyncDelayedTask(AutomaticInventory.instance, sorter, 1L);
Bukkit.getServer().getScheduler().scheduleSyncDelayedTask(AutomaticInventory.getInstance(), sorter, 1L);

if(!playerData.isGotChestSortInfo())
{
AutomaticInventory.sendMessage(player, TextMode.Info, Messages.ChestSortEducation3);
AutomaticInventory.getInstance().sendMessage(player, TextMode.INFO, Messages.CHESTSORTEDUCATION3);
playerData.setGotChestSortInfo(true);
}
}
Expand All @@ -345,12 +346,12 @@ public void onInventoryClose(InventoryCloseEvent event)

sortPlayerIfEnabled(player, playerData, bottomInventory);

if(player.getGameMode() != GameMode.CREATIVE && Math.random() < .1 && !playerData.isGotDepositAllInfo() && featureEnabled(Features.DepositAll, player))
if(player.getGameMode() != GameMode.CREATIVE && Math.random() < .1 && !playerData.isGotDepositAllInfo() && featureEnabled(Features.DEPOSITALL, player))
{
Inventory topInventory = event.getView().getTopInventory();
if(topInventory != null && topInventory.getType() == InventoryType.CHEST)
{
AutomaticInventory.sendMessage(player, TextMode.Instr, Messages.DepositAllAdvertisement);
AutomaticInventory.getInstance().sendMessage(player, TextMode.INSTR, Messages.DEPOSITALLADVERTISEMENT);
playerData.setGotDepositAllInfo(true);
}
}
Expand All @@ -360,7 +361,7 @@ public void onInventoryClose(InventoryCloseEvent event)
public void onPickupItem(PlayerPickupItemEvent event)
{
Player player = event.getPlayer();
if(featureEnabled(Features.SortInventory, player))
if(featureEnabled(Features.SORTINVENTORY, player))
{
PlayerData playerData = PlayerData.FromPlayer(player);
if(playerData.firstEmptySlot >= 0) return;
Expand All @@ -370,25 +371,25 @@ public void onPickupItem(PlayerPickupItemEvent event)
if(firstEmpty < 9) return;
playerData.firstEmptySlot = firstEmpty;
PickupSortTask task = new PickupSortTask(player, playerData, inventory);
Bukkit.getServer().getScheduler().scheduleSyncDelayedTask(AutomaticInventory.instance, task, 100L);
Bukkit.getServer().getScheduler().scheduleSyncDelayedTask(AutomaticInventory.getInstance(), task, 100L);
}
}

static void sortPlayerIfEnabled(Player player, PlayerData playerData, Inventory inventory)
public static void sortPlayerIfEnabled(Player player, PlayerData playerData, Inventory inventory)
{
if(featureEnabled(Features.SortInventory, player))
if(featureEnabled(Features.SORTINVENTORY, player))
{
new InventorySorter(inventory, 9).run();

if(!playerData.isGotInventorySortInfo())
{
AutomaticInventory.sendMessage(player, TextMode.Info, Messages.InventorySortEducation);
AutomaticInventory.getInstance().sendMessage(player, TextMode.INFO, Messages.INVENTORYSORTEDUCATION);
playerData.setGotInventorySortInfo(true);
}
}
}

static boolean isSortableChestInventory(Inventory inventory)
public static boolean isSortableChestInventory(Inventory inventory)
{
if(inventory == null) return false;

Expand All @@ -405,14 +406,14 @@ static boolean isSortableChestInventory(Inventory inventory)
}

@EventHandler(ignoreCancelled = true, priority = EventPriority.MONITOR)
void onPlayerJoin(PlayerJoinEvent event)
public void onPlayerJoin(PlayerJoinEvent event)
{
Player player = event.getPlayer();
PlayerData.Preload(player);
}

@EventHandler(ignoreCancelled = true, priority = EventPriority.MONITOR)
void onPlayerQuit(PlayerQuitEvent event)
public void onPlayerQuit(PlayerQuitEvent event)
{
Player player = event.getPlayer();
PlayerData.FromPlayer(player).saveChanges();
Expand Down
Loading