Skip to content

Commit 928fd40

Browse files
authored
Merge pull request #3 from luisBazanDev/development
Added createKitFromPlayer method in KitsHelper and update version to …
2 parents 217592f + 27f9022 commit 928fd40

File tree

2 files changed

+19
-1
lines changed

2 files changed

+19
-1
lines changed

pom.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66

77
<groupId>pe.bazan.luis.plugins</groupId>
88
<artifactId>KitsAPI</artifactId>
9-
<version>1.2</version>
9+
<version>1.2.1</version>
1010
<packaging>jar</packaging>
1111

1212
<name>KitsAPI</name>

src/main/java/pe/bazan/luis/plugins/kitsapi/api/KitsHelper.java

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,8 @@
11
package pe.bazan.luis.plugins.kitsapi.api;
22

3+
import org.bukkit.entity.Player;
4+
import org.bukkit.inventory.ItemStack;
5+
import org.bukkit.inventory.PlayerInventory;
36
import org.bukkit.plugin.Plugin;
47
import org.bukkit.plugin.java.JavaPlugin;
58
import pe.bazan.luis.plugins.kitsapi.KitsAPI;
@@ -50,4 +53,19 @@ public static PluginKitsManager getKitManager(Plugin plugin) {
5053
pluginsKitManagers.put(plugin, new PluginKitsManager(plugin));
5154
return pluginsKitManagers.get(plugin);
5255
}
56+
57+
/**
58+
* Create a kit from player inventory
59+
* @param player player to create kit
60+
* @return new instance of Kit, without any tracking or saving
61+
*/
62+
public static Kit createKitFromPlayer(Player player) {
63+
PlayerInventory playerInventory = player.getInventory();
64+
HashMap<Integer, ItemStack> items = new HashMap<>();
65+
for (int i = 0; i <= 45; i++) {
66+
if (playerInventory.getItem(i) == null) continue;
67+
items.put(i, playerInventory.getItem(i));
68+
}
69+
return new Kit(player.getName(), items);
70+
}
5371
}

0 commit comments

Comments
 (0)