-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathBetterInvGUI.java
More file actions
140 lines (112 loc) · 3.6 KB
/
Copy pathBetterInvGUI.java
File metadata and controls
140 lines (112 loc) · 3.6 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
package top.n0rthmaster123.betterinvgui;
import org.bukkit.*;
import org.bukkit.inventory.*;
import org.bukkit.inventory.meta.ItemMeta;
import java.util.*;
public class BetterInvGUI {
public BetterInvGUI(){
}
/**
*
* @author BaGuAr
*
* I remake InvGUI.java. old own is here:
* https://github.com/BaGuAr/InvGUI/blob/main/InvGUI.java
* also BetterInvGUI.java is not tested. if you found bugs. please report it!
* If you'll use this , do not remove this message
* and If you'll upload your project(that using this) to Internet(spigot-mc/mc-market etc) please put this github(BetterInvGUI.java) link to your project's description
* Thanks for using this!
*
*/
private Inventory inv;
private int hight;
private int width;
public BetterInvGUI create(Inventory from){
inv = from;
return this;
}
public BetterInvGUI create(String name,int hight,int width){
this.hight = hight;
this.width = width;
inv = Bukkit.createInventory( null ,hight * width ,name );
return this;
}
public BetterInvGUI create(String name,int size){
inv = Bukkit.createInventory( null ,size ,name );
return this;
}
public enum ChestType{
LARGE,NORMAL
}
public BetterInvGUI create(String name,ChestType c){
return create( name ,( c == ChestType.LARGE ? 6 : 3 ) * 9 );
}
public BetterInvGUI setName(String name){
Inventory inv = new InvGUI().create( name , getSlotLength() + 1 ).getInventory();
inv.setContents( this.inv.getContents() );
this.inv = inv;
return this;
}
public BetterInvGUI setHight(int hight){
this.hight = hight;
inv.setMaxStackSize( hight * width );
return this;
}
public BetterInvGUI setWidth(int width){
this.width = width;
inv.setMaxStackSize( hight * width );
return this;
}
public int getHight(){
return hight;
}
public int getWidth(){
return width;
}
public int[] getSize(){
return new int[]{getHight(),getWidth()};
}
public BetterInvGUI addItem(String name,ItemStack stack,int index){
ItemMeta meta = stack.getItemMeta();
meta.setDisplayName(name);
stack.setItemMeta(meta);
inv.setItem( index,stack );
return this;
}
public BetterInvGUI addItem(String name,Material material,int index){
return addItem( name , new ItemStack( material ) , index );
}
public BetterInvGUI addItem(String name,ItemStack stack,List list,int index){
ItemMeta meta = stack.getItemMeta();
meta.setDisplayName(name);
meta.setLore(list);
stack.setItemMeta(meta);
inv.setItem( index , stack );
return this;
}
public BetterInvGUI addItem(String name,Material material,List list,int index){
return addItem( name , new ItemStack( material ) , list, index );
}
public BetterInvGUI addItem(ItemStack stack,int index){
inv.setItem( index , stack );
return this;
}
public BetterInvGUI addItem(Material material,int index){
return addItem( new ItemStack( material ) , index );
}
public int getSlotLength(){
return ( hight * width ) - 1;
}
public Inventory getInventory(){
return inv;
}
@Deprecated
public List getAsList(String str){
List list = new ArrayList();
String[] strx = str.split( "\n" );
for( String string : strx ){
list.add( string );
}
return list;
}
}