├── .gitignore
├── .idea
└── uiDesigner.xml
├── DSP1.4
├── DSP1.4.zip
├── assets
│ └── minecraft
│ │ ├── items
│ │ └── stone_axe.json
│ │ ├── models
│ │ └── item
│ │ │ ├── stone_axe_01.json
│ │ │ ├── stone_axe_02.json
│ │ │ ├── stone_axe_03.json
│ │ │ ├── stone_axe_04.json
│ │ │ ├── stone_axe_05.json
│ │ │ ├── stone_axe_06.json
│ │ │ ├── stone_axe_07.json
│ │ │ ├── stone_axe_08.json
│ │ │ ├── stone_axe_09.json
│ │ │ ├── stone_axe_10.json
│ │ │ ├── stone_axe_101.json
│ │ │ ├── stone_axe_102.json
│ │ │ ├── stone_axe_103.json
│ │ │ ├── stone_axe_104.json
│ │ │ ├── stone_axe_105.json
│ │ │ ├── stone_axe_11.json
│ │ │ └── stone_axe_12.json
│ │ └── textures
│ │ └── item
│ │ └── dsp
│ │ ├── linkmodule.png
│ │ ├── receiver.png
│ │ ├── sorterwrench.png
│ │ ├── storagecell16k.png
│ │ ├── storagecell1k.png
│ │ ├── storagecell1m.png
│ │ ├── storagecell256k.png
│ │ ├── storagecell4k.png
│ │ ├── storagecell64k.png
│ │ ├── storagecontainer16k.png
│ │ ├── storagecontainer1k.png
│ │ ├── storagecontainer1m.png
│ │ ├── storagecontainer256k.png
│ │ ├── storagecontainer4k.png
│ │ ├── storagecontainer64k.png
│ │ ├── storagewrench.png
│ │ └── wireless.png
└── pack.mcmeta
├── LICENSE
├── README.md
├── img
├── DSPbanner.png
├── MoreInfoBanner.png
├── RecipesBanner.png
├── fulltypes.png
└── permissions.png
├── pom.xml
└── src
└── main
├── java
└── me
│ └── darkolythe
│ └── deepstorageplus
│ ├── DeepStoragePlus.java
│ ├── dsu
│ ├── StorageUtils.java
│ ├── listeners
│ │ ├── IOListener.java
│ │ ├── InventoryListener.java
│ │ ├── StorageBreakListener.java
│ │ ├── WirelessListener.java
│ │ └── WrenchListener.java
│ └── managers
│ │ ├── DSUManager.java
│ │ ├── DSUUpdateManager.java
│ │ ├── SettingsManager.java
│ │ ├── SorterManager.java
│ │ ├── SorterUpdateManager.java
│ │ └── WirelessManager.java
│ ├── io
│ ├── CommandHandler.java
│ └── ConfigManager.java
│ ├── todo.md
│ └── utils
│ ├── ItemList.java
│ ├── LanguageManager.java
│ └── RecipeManager.java
└── resources
├── config.yml
└── plugin.yml
/.gitignore:
--------------------------------------------------------------------------------
1 | *.iml
2 | .idea/
3 | dependency-reduced-pom.xml
4 | /target/
5 |
--------------------------------------------------------------------------------
/.idea/uiDesigner.xml:
--------------------------------------------------------------------------------
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 |
--------------------------------------------------------------------------------
/DSP1.4/DSP1.4.zip:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/christopherwalkerml/DeepStoragePlus/9ccc635869a70d707213716b8e6c2178ee8d864f/DSP1.4/DSP1.4.zip
--------------------------------------------------------------------------------
/DSP1.4/assets/minecraft/items/stone_axe.json:
--------------------------------------------------------------------------------
1 | {
2 | "model": {
3 | "type": "range_dispatch",
4 | "property": "custom_model_data",
5 | "fallback": {
6 | "type": "model",
7 | "model": "item/stone_axe"
8 | },
9 | "entries": [
10 | {
11 | "threshold": 13000,
12 | "model": {
13 | "type": "model",
14 | "model": "item/stone_axe_102"
15 | }
16 | },
17 | {
18 | "threshold": 13001,
19 | "model": {
20 | "type": "model",
21 | "model": "item/stone_axe_103"
22 | }
23 | },
24 | {
25 | "threshold": 13002,
26 | "model": {
27 | "type": "model",
28 | "model": "item/stone_axe_104"
29 | }
30 | },
31 | {
32 | "threshold": 13003,
33 | "model": {
34 | "type": "model",
35 | "model": "item/stone_axe_101"
36 | }
37 | },
38 | {
39 | "threshold": 13004,
40 | "model": {
41 | "type": "model",
42 | "model": "item/stone_axe_105"
43 | }
44 | },
45 | {
46 | "threshold": 13010,
47 | "model": {
48 | "type": "model",
49 | "model": "item/stone_axe_01"
50 | }
51 | },
52 | {
53 | "threshold": 13011,
54 | "model": {
55 | "type": "model",
56 | "model": "item/stone_axe_02"
57 | }
58 | },
59 | {
60 | "threshold": 13012,
61 | "model": {
62 | "type": "model",
63 | "model": "item/stone_axe_03"
64 | }
65 | },
66 | {
67 | "threshold": 13013,
68 | "model": {
69 | "type": "model",
70 | "model": "item/stone_axe_04"
71 | }
72 | },
73 | {
74 | "threshold": 13014,
75 | "model": {
76 | "type": "model",
77 | "model": "item/stone_axe_05"
78 | }
79 | },
80 | {
81 | "threshold": 13015,
82 | "model": {
83 | "type": "model",
84 | "model": "item/stone_axe_11"
85 | }
86 | },
87 | {
88 | "threshold": 13016,
89 | "model": {
90 | "type": "model",
91 | "model": "item/stone_axe_06"
92 | }
93 | },
94 | {
95 | "threshold": 13017,
96 | "model": {
97 | "type": "model",
98 | "model": "item/stone_axe_07"
99 | }
100 | },
101 | {
102 | "threshold": 13018,
103 | "model": {
104 | "type": "model",
105 | "model": "item/stone_axe_08"
106 | }
107 | },
108 | {
109 | "threshold": 13019,
110 | "model": {
111 | "type": "model",
112 | "model": "item/stone_axe_09"
113 | }
114 | },
115 | {
116 | "threshold": 13020,
117 | "model": {
118 | "type": "model",
119 | "model": "item/stone_axe_10"
120 | }
121 | },
122 | {
123 | "threshold": 13021,
124 | "model": {
125 | "type": "model",
126 | "model": "item/stone_axe_12"
127 | }
128 | }
129 | ]
130 | }
131 | }
132 |
--------------------------------------------------------------------------------
/DSP1.4/assets/minecraft/models/item/stone_axe_01.json:
--------------------------------------------------------------------------------
1 | {
2 | "parent": "item/handheld",
3 | "textures": {
4 | "layer0": "item/dsp/storagecell1k"
5 | }
6 | }
--------------------------------------------------------------------------------
/DSP1.4/assets/minecraft/models/item/stone_axe_02.json:
--------------------------------------------------------------------------------
1 | {
2 | "parent": "item/handheld",
3 | "textures": {
4 | "layer0": "item/dsp/storagecell4k"
5 | }
6 | }
--------------------------------------------------------------------------------
/DSP1.4/assets/minecraft/models/item/stone_axe_03.json:
--------------------------------------------------------------------------------
1 | {
2 | "parent": "item/handheld",
3 | "textures": {
4 | "layer0": "item/dsp/storagecell16k"
5 | }
6 | }
--------------------------------------------------------------------------------
/DSP1.4/assets/minecraft/models/item/stone_axe_04.json:
--------------------------------------------------------------------------------
1 | {
2 | "parent": "item/handheld",
3 | "textures": {
4 | "layer0": "item/dsp/storagecell64k"
5 | }
6 | }
--------------------------------------------------------------------------------
/DSP1.4/assets/minecraft/models/item/stone_axe_05.json:
--------------------------------------------------------------------------------
1 | {
2 | "parent": "item/handheld",
3 | "textures": {
4 | "layer0": "item/dsp/storagecell256k"
5 | }
6 | }
--------------------------------------------------------------------------------
/DSP1.4/assets/minecraft/models/item/stone_axe_06.json:
--------------------------------------------------------------------------------
1 | {
2 | "parent": "item/handheld",
3 | "textures": {
4 | "layer0": "item/dsp/storagecontainer1k"
5 | }
6 | }
--------------------------------------------------------------------------------
/DSP1.4/assets/minecraft/models/item/stone_axe_07.json:
--------------------------------------------------------------------------------
1 | {
2 | "parent": "item/handheld",
3 | "textures": {
4 | "layer0": "item/dsp/storagecontainer4k"
5 | }
6 | }
--------------------------------------------------------------------------------
/DSP1.4/assets/minecraft/models/item/stone_axe_08.json:
--------------------------------------------------------------------------------
1 | {
2 | "parent": "item/handheld",
3 | "textures": {
4 | "layer0": "item/dsp/storagecontainer16k"
5 | }
6 | }
--------------------------------------------------------------------------------
/DSP1.4/assets/minecraft/models/item/stone_axe_09.json:
--------------------------------------------------------------------------------
1 | {
2 | "parent": "item/handheld",
3 | "textures": {
4 | "layer0": "item/dsp/storagecontainer64k"
5 | }
6 | }
--------------------------------------------------------------------------------
/DSP1.4/assets/minecraft/models/item/stone_axe_10.json:
--------------------------------------------------------------------------------
1 | {
2 | "parent": "item/handheld",
3 | "textures": {
4 | "layer0": "item/dsp/storagecontainer256k"
5 | }
6 | }
--------------------------------------------------------------------------------
/DSP1.4/assets/minecraft/models/item/stone_axe_101.json:
--------------------------------------------------------------------------------
1 | {
2 | "parent": "item/handheld",
3 | "textures": {
4 | "layer0": "item/dsp/storagewrench"
5 | }
6 | }
--------------------------------------------------------------------------------
/DSP1.4/assets/minecraft/models/item/stone_axe_102.json:
--------------------------------------------------------------------------------
1 | {
2 | "parent": "item/handheld",
3 | "textures": {
4 | "layer0": "item/dsp/wireless"
5 | }
6 | }
--------------------------------------------------------------------------------
/DSP1.4/assets/minecraft/models/item/stone_axe_103.json:
--------------------------------------------------------------------------------
1 | {
2 | "parent": "item/handheld",
3 | "textures": {
4 | "layer0": "item/dsp/receiver"
5 | }
6 | }
--------------------------------------------------------------------------------
/DSP1.4/assets/minecraft/models/item/stone_axe_104.json:
--------------------------------------------------------------------------------
1 | {
2 | "parent": "item/handheld",
3 | "textures": {
4 | "layer0": "item/dsp/sorterwrench"
5 | }
6 | }
--------------------------------------------------------------------------------
/DSP1.4/assets/minecraft/models/item/stone_axe_105.json:
--------------------------------------------------------------------------------
1 | {
2 | "parent": "item/handheld",
3 | "textures": {
4 | "layer0": "item/dsp/linkmodule"
5 | }
6 | }
--------------------------------------------------------------------------------
/DSP1.4/assets/minecraft/models/item/stone_axe_11.json:
--------------------------------------------------------------------------------
1 | {
2 | "parent": "item/handheld",
3 | "textures": {
4 | "layer0": "item/dsp/storagecell1m"
5 | }
6 | }
--------------------------------------------------------------------------------
/DSP1.4/assets/minecraft/models/item/stone_axe_12.json:
--------------------------------------------------------------------------------
1 | {
2 | "parent": "item/handheld",
3 | "textures": {
4 | "layer0": "item/dsp/storagecontainer1m"
5 | }
6 | }
--------------------------------------------------------------------------------
/DSP1.4/assets/minecraft/textures/item/dsp/linkmodule.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/christopherwalkerml/DeepStoragePlus/9ccc635869a70d707213716b8e6c2178ee8d864f/DSP1.4/assets/minecraft/textures/item/dsp/linkmodule.png
--------------------------------------------------------------------------------
/DSP1.4/assets/minecraft/textures/item/dsp/receiver.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/christopherwalkerml/DeepStoragePlus/9ccc635869a70d707213716b8e6c2178ee8d864f/DSP1.4/assets/minecraft/textures/item/dsp/receiver.png
--------------------------------------------------------------------------------
/DSP1.4/assets/minecraft/textures/item/dsp/sorterwrench.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/christopherwalkerml/DeepStoragePlus/9ccc635869a70d707213716b8e6c2178ee8d864f/DSP1.4/assets/minecraft/textures/item/dsp/sorterwrench.png
--------------------------------------------------------------------------------
/DSP1.4/assets/minecraft/textures/item/dsp/storagecell16k.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/christopherwalkerml/DeepStoragePlus/9ccc635869a70d707213716b8e6c2178ee8d864f/DSP1.4/assets/minecraft/textures/item/dsp/storagecell16k.png
--------------------------------------------------------------------------------
/DSP1.4/assets/minecraft/textures/item/dsp/storagecell1k.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/christopherwalkerml/DeepStoragePlus/9ccc635869a70d707213716b8e6c2178ee8d864f/DSP1.4/assets/minecraft/textures/item/dsp/storagecell1k.png
--------------------------------------------------------------------------------
/DSP1.4/assets/minecraft/textures/item/dsp/storagecell1m.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/christopherwalkerml/DeepStoragePlus/9ccc635869a70d707213716b8e6c2178ee8d864f/DSP1.4/assets/minecraft/textures/item/dsp/storagecell1m.png
--------------------------------------------------------------------------------
/DSP1.4/assets/minecraft/textures/item/dsp/storagecell256k.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/christopherwalkerml/DeepStoragePlus/9ccc635869a70d707213716b8e6c2178ee8d864f/DSP1.4/assets/minecraft/textures/item/dsp/storagecell256k.png
--------------------------------------------------------------------------------
/DSP1.4/assets/minecraft/textures/item/dsp/storagecell4k.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/christopherwalkerml/DeepStoragePlus/9ccc635869a70d707213716b8e6c2178ee8d864f/DSP1.4/assets/minecraft/textures/item/dsp/storagecell4k.png
--------------------------------------------------------------------------------
/DSP1.4/assets/minecraft/textures/item/dsp/storagecell64k.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/christopherwalkerml/DeepStoragePlus/9ccc635869a70d707213716b8e6c2178ee8d864f/DSP1.4/assets/minecraft/textures/item/dsp/storagecell64k.png
--------------------------------------------------------------------------------
/DSP1.4/assets/minecraft/textures/item/dsp/storagecontainer16k.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/christopherwalkerml/DeepStoragePlus/9ccc635869a70d707213716b8e6c2178ee8d864f/DSP1.4/assets/minecraft/textures/item/dsp/storagecontainer16k.png
--------------------------------------------------------------------------------
/DSP1.4/assets/minecraft/textures/item/dsp/storagecontainer1k.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/christopherwalkerml/DeepStoragePlus/9ccc635869a70d707213716b8e6c2178ee8d864f/DSP1.4/assets/minecraft/textures/item/dsp/storagecontainer1k.png
--------------------------------------------------------------------------------
/DSP1.4/assets/minecraft/textures/item/dsp/storagecontainer1m.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/christopherwalkerml/DeepStoragePlus/9ccc635869a70d707213716b8e6c2178ee8d864f/DSP1.4/assets/minecraft/textures/item/dsp/storagecontainer1m.png
--------------------------------------------------------------------------------
/DSP1.4/assets/minecraft/textures/item/dsp/storagecontainer256k.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/christopherwalkerml/DeepStoragePlus/9ccc635869a70d707213716b8e6c2178ee8d864f/DSP1.4/assets/minecraft/textures/item/dsp/storagecontainer256k.png
--------------------------------------------------------------------------------
/DSP1.4/assets/minecraft/textures/item/dsp/storagecontainer4k.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/christopherwalkerml/DeepStoragePlus/9ccc635869a70d707213716b8e6c2178ee8d864f/DSP1.4/assets/minecraft/textures/item/dsp/storagecontainer4k.png
--------------------------------------------------------------------------------
/DSP1.4/assets/minecraft/textures/item/dsp/storagecontainer64k.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/christopherwalkerml/DeepStoragePlus/9ccc635869a70d707213716b8e6c2178ee8d864f/DSP1.4/assets/minecraft/textures/item/dsp/storagecontainer64k.png
--------------------------------------------------------------------------------
/DSP1.4/assets/minecraft/textures/item/dsp/storagewrench.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/christopherwalkerml/DeepStoragePlus/9ccc635869a70d707213716b8e6c2178ee8d864f/DSP1.4/assets/minecraft/textures/item/dsp/storagewrench.png
--------------------------------------------------------------------------------
/DSP1.4/assets/minecraft/textures/item/dsp/wireless.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/christopherwalkerml/DeepStoragePlus/9ccc635869a70d707213716b8e6c2178ee8d864f/DSP1.4/assets/minecraft/textures/item/dsp/wireless.png
--------------------------------------------------------------------------------
/DSP1.4/pack.mcmeta:
--------------------------------------------------------------------------------
1 | {
2 | "pack": {
3 | "pack_format": 32,
4 | "description": "DeepStoragePlus pack"
5 | }
6 | }
7 |
--------------------------------------------------------------------------------
/LICENSE:
--------------------------------------------------------------------------------
1 | GNU GENERAL PUBLIC LICENSE
2 | Version 3, 29 June 2007
3 |
4 | Copyright (C) 2007 Free Software Foundation, Inc.
5 | Everyone is permitted to copy and distribute verbatim copies
6 | of this license document, but changing it is not allowed.
7 |
8 | Preamble
9 |
10 | The GNU General Public License is a free, copyleft license for
11 | software and other kinds of works.
12 |
13 | The licenses for most software and other practical works are designed
14 | to take away your freedom to share and change the works. By contrast,
15 | the GNU General Public License is intended to guarantee your freedom to
16 | share and change all versions of a program--to make sure it remains free
17 | software for all its users. We, the Free Software Foundation, use the
18 | GNU General Public License for most of our software; it applies also to
19 | any other work released this way by its authors. You can apply it to
20 | your programs, too.
21 |
22 | When we speak of free software, we are referring to freedom, not
23 | price. Our General Public Licenses are designed to make sure that you
24 | have the freedom to distribute copies of free software (and charge for
25 | them if you wish), that you receive source code or can get it if you
26 | want it, that you can change the software or use pieces of it in new
27 | free programs, and that you know you can do these things.
28 |
29 | To protect your rights, we need to prevent others from denying you
30 | these rights or asking you to surrender the rights. Therefore, you have
31 | certain responsibilities if you distribute copies of the software, or if
32 | you modify it: responsibilities to respect the freedom of others.
33 |
34 | For example, if you distribute copies of such a program, whether
35 | gratis or for a fee, you must pass on to the recipients the same
36 | freedoms that you received. You must make sure that they, too, receive
37 | or can get the source code. And you must show them these terms so they
38 | know their rights.
39 |
40 | Developers that use the GNU GPL protect your rights with two steps:
41 | (1) assert copyright on the software, and (2) offer you this License
42 | giving you legal permission to copy, distribute and/or modify it.
43 |
44 | For the developers' and authors' protection, the GPL clearly explains
45 | that there is no warranty for this free software. For both users' and
46 | authors' sake, the GPL requires that modified versions be marked as
47 | changed, so that their problems will not be attributed erroneously to
48 | authors of previous versions.
49 |
50 | Some devices are designed to deny users access to install or run
51 | modified versions of the software inside them, although the manufacturer
52 | can do so. This is fundamentally incompatible with the aim of
53 | protecting users' freedom to change the software. The systematic
54 | pattern of such abuse occurs in the area of products for individuals to
55 | use, which is precisely where it is most unacceptable. Therefore, we
56 | have designed this version of the GPL to prohibit the practice for those
57 | products. If such problems arise substantially in other domains, we
58 | stand ready to extend this provision to those domains in future versions
59 | of the GPL, as needed to protect the freedom of users.
60 |
61 | Finally, every program is threatened constantly by software patents.
62 | States should not allow patents to restrict development and use of
63 | software on general-purpose computers, but in those that do, we wish to
64 | avoid the special danger that patents applied to a free program could
65 | make it effectively proprietary. To prevent this, the GPL assures that
66 | patents cannot be used to render the program non-free.
67 |
68 | The precise terms and conditions for copying, distribution and
69 | modification follow.
70 |
71 | TERMS AND CONDITIONS
72 |
73 | 0. Definitions.
74 |
75 | "This License" refers to version 3 of the GNU General Public License.
76 |
77 | "Copyright" also means copyright-like laws that apply to other kinds of
78 | works, such as semiconductor masks.
79 |
80 | "The Program" refers to any copyrightable work licensed under this
81 | License. Each licensee is addressed as "you". "Licensees" and
82 | "recipients" may be individuals or organizations.
83 |
84 | To "modify" a work means to copy from or adapt all or part of the work
85 | in a fashion requiring copyright permission, other than the making of an
86 | exact copy. The resulting work is called a "modified version" of the
87 | earlier work or a work "based on" the earlier work.
88 |
89 | A "covered work" means either the unmodified Program or a work based
90 | on the Program.
91 |
92 | To "propagate" a work means to do anything with it that, without
93 | permission, would make you directly or secondarily liable for
94 | infringement under applicable copyright law, except executing it on a
95 | computer or modifying a private copy. Propagation includes copying,
96 | distribution (with or without modification), making available to the
97 | public, and in some countries other activities as well.
98 |
99 | To "convey" a work means any kind of propagation that enables other
100 | parties to make or receive copies. Mere interaction with a user through
101 | a computer network, with no transfer of a copy, is not conveying.
102 |
103 | An interactive user interface displays "Appropriate Legal Notices"
104 | to the extent that it includes a convenient and prominently visible
105 | feature that (1) displays an appropriate copyright notice, and (2)
106 | tells the user that there is no warranty for the work (except to the
107 | extent that warranties are provided), that licensees may convey the
108 | work under this License, and how to view a copy of this License. If
109 | the interface presents a list of user commands or options, such as a
110 | menu, a prominent item in the list meets this criterion.
111 |
112 | 1. Source Code.
113 |
114 | The "source code" for a work means the preferred form of the work
115 | for making modifications to it. "Object code" means any non-source
116 | form of a work.
117 |
118 | A "Standard Interface" means an interface that either is an official
119 | standard defined by a recognized standards body, or, in the case of
120 | interfaces specified for a particular programming language, one that
121 | is widely used among developers working in that language.
122 |
123 | The "System Libraries" of an executable work include anything, other
124 | than the work as a whole, that (a) is included in the normal form of
125 | packaging a Major Component, but which is not part of that Major
126 | Component, and (b) serves only to enable use of the work with that
127 | Major Component, or to implement a Standard Interface for which an
128 | implementation is available to the public in source code form. A
129 | "Major Component", in this context, means a major essential component
130 | (kernel, window system, and so on) of the specific operating system
131 | (if any) on which the executable work runs, or a compiler used to
132 | produce the work, or an object code interpreter used to run it.
133 |
134 | The "Corresponding Source" for a work in object code form means all
135 | the source code needed to generate, install, and (for an executable
136 | work) run the object code and to modify the work, including scripts to
137 | control those activities. However, it does not include the work's
138 | System Libraries, or general-purpose tools or generally available free
139 | programs which are used unmodified in performing those activities but
140 | which are not part of the work. For example, Corresponding Source
141 | includes interface definition files associated with source files for
142 | the work, and the source code for shared libraries and dynamically
143 | linked subprograms that the work is specifically designed to require,
144 | such as by intimate data communication or control flow between those
145 | subprograms and other parts of the work.
146 |
147 | The Corresponding Source need not include anything that users
148 | can regenerate automatically from other parts of the Corresponding
149 | Source.
150 |
151 | The Corresponding Source for a work in source code form is that
152 | same work.
153 |
154 | 2. Basic Permissions.
155 |
156 | All rights granted under this License are granted for the term of
157 | copyright on the Program, and are irrevocable provided the stated
158 | conditions are met. This License explicitly affirms your unlimited
159 | permission to run the unmodified Program. The output from running a
160 | covered work is covered by this License only if the output, given its
161 | content, constitutes a covered work. This License acknowledges your
162 | rights of fair use or other equivalent, as provided by copyright law.
163 |
164 | You may make, run and propagate covered works that you do not
165 | convey, without conditions so long as your license otherwise remains
166 | in force. You may convey covered works to others for the sole purpose
167 | of having them make modifications exclusively for you, or provide you
168 | with facilities for running those works, provided that you comply with
169 | the terms of this License in conveying all material for which you do
170 | not control copyright. Those thus making or running the covered works
171 | for you must do so exclusively on your behalf, under your direction
172 | and control, on terms that prohibit them from making any copies of
173 | your copyrighted material outside their relationship with you.
174 |
175 | Conveying under any other circumstances is permitted solely under
176 | the conditions stated below. Sublicensing is not allowed; section 10
177 | makes it unnecessary.
178 |
179 | 3. Protecting Users' Legal Rights From Anti-Circumvention Law.
180 |
181 | No covered work shall be deemed part of an effective technological
182 | measure under any applicable law fulfilling obligations under article
183 | 11 of the WIPO copyright treaty adopted on 20 December 1996, or
184 | similar laws prohibiting or restricting circumvention of such
185 | measures.
186 |
187 | When you convey a covered work, you waive any legal power to forbid
188 | circumvention of technological measures to the extent such circumvention
189 | is effected by exercising rights under this License with respect to
190 | the covered work, and you disclaim any intention to limit operation or
191 | modification of the work as a means of enforcing, against the work's
192 | users, your or third parties' legal rights to forbid circumvention of
193 | technological measures.
194 |
195 | 4. Conveying Verbatim Copies.
196 |
197 | You may convey verbatim copies of the Program's source code as you
198 | receive it, in any medium, provided that you conspicuously and
199 | appropriately publish on each copy an appropriate copyright notice;
200 | keep intact all notices stating that this License and any
201 | non-permissive terms added in accord with section 7 apply to the code;
202 | keep intact all notices of the absence of any warranty; and give all
203 | recipients a copy of this License along with the Program.
204 |
205 | You may charge any price or no price for each copy that you convey,
206 | and you may offer support or warranty protection for a fee.
207 |
208 | 5. Conveying Modified Source Versions.
209 |
210 | You may convey a work based on the Program, or the modifications to
211 | produce it from the Program, in the form of source code under the
212 | terms of section 4, provided that you also meet all of these conditions:
213 |
214 | a) The work must carry prominent notices stating that you modified
215 | it, and giving a relevant date.
216 |
217 | b) The work must carry prominent notices stating that it is
218 | released under this License and any conditions added under section
219 | 7. This requirement modifies the requirement in section 4 to
220 | "keep intact all notices".
221 |
222 | c) You must license the entire work, as a whole, under this
223 | License to anyone who comes into possession of a copy. This
224 | License will therefore apply, along with any applicable section 7
225 | additional terms, to the whole of the work, and all its parts,
226 | regardless of how they are packaged. This License gives no
227 | permission to license the work in any other way, but it does not
228 | invalidate such permission if you have separately received it.
229 |
230 | d) If the work has interactive user interfaces, each must display
231 | Appropriate Legal Notices; however, if the Program has interactive
232 | interfaces that do not display Appropriate Legal Notices, your
233 | work need not make them do so.
234 |
235 | A compilation of a covered work with other separate and independent
236 | works, which are not by their nature extensions of the covered work,
237 | and which are not combined with it such as to form a larger program,
238 | in or on a volume of a storage or distribution medium, is called an
239 | "aggregate" if the compilation and its resulting copyright are not
240 | used to limit the access or legal rights of the compilation's users
241 | beyond what the individual works permit. Inclusion of a covered work
242 | in an aggregate does not cause this License to apply to the other
243 | parts of the aggregate.
244 |
245 | 6. Conveying Non-Source Forms.
246 |
247 | You may convey a covered work in object code form under the terms
248 | of sections 4 and 5, provided that you also convey the
249 | machine-readable Corresponding Source under the terms of this License,
250 | in one of these ways:
251 |
252 | a) Convey the object code in, or embodied in, a physical product
253 | (including a physical distribution medium), accompanied by the
254 | Corresponding Source fixed on a durable physical medium
255 | customarily used for software interchange.
256 |
257 | b) Convey the object code in, or embodied in, a physical product
258 | (including a physical distribution medium), accompanied by a
259 | written offer, valid for at least three years and valid for as
260 | long as you offer spare parts or customer support for that product
261 | model, to give anyone who possesses the object code either (1) a
262 | copy of the Corresponding Source for all the software in the
263 | product that is covered by this License, on a durable physical
264 | medium customarily used for software interchange, for a price no
265 | more than your reasonable cost of physically performing this
266 | conveying of source, or (2) access to copy the
267 | Corresponding Source from a network server at no charge.
268 |
269 | c) Convey individual copies of the object code with a copy of the
270 | written offer to provide the Corresponding Source. This
271 | alternative is allowed only occasionally and noncommercially, and
272 | only if you received the object code with such an offer, in accord
273 | with subsection 6b.
274 |
275 | d) Convey the object code by offering access from a designated
276 | place (gratis or for a charge), and offer equivalent access to the
277 | Corresponding Source in the same way through the same place at no
278 | further charge. You need not require recipients to copy the
279 | Corresponding Source along with the object code. If the place to
280 | copy the object code is a network server, the Corresponding Source
281 | may be on a different server (operated by you or a third party)
282 | that supports equivalent copying facilities, provided you maintain
283 | clear directions next to the object code saying where to find the
284 | Corresponding Source. Regardless of what server hosts the
285 | Corresponding Source, you remain obligated to ensure that it is
286 | available for as long as needed to satisfy these requirements.
287 |
288 | e) Convey the object code using peer-to-peer transmission, provided
289 | you inform other peers where the object code and Corresponding
290 | Source of the work are being offered to the general public at no
291 | charge under subsection 6d.
292 |
293 | A separable portion of the object code, whose source code is excluded
294 | from the Corresponding Source as a System Library, need not be
295 | included in conveying the object code work.
296 |
297 | A "User Product" is either (1) a "consumer product", which means any
298 | tangible personal property which is normally used for personal, family,
299 | or household purposes, or (2) anything designed or sold for incorporation
300 | into a dwelling. In determining whether a product is a consumer product,
301 | doubtful cases shall be resolved in favor of coverage. For a particular
302 | product received by a particular user, "normally used" refers to a
303 | typical or common use of that class of product, regardless of the status
304 | of the particular user or of the way in which the particular user
305 | actually uses, or expects or is expected to use, the product. A product
306 | is a consumer product regardless of whether the product has substantial
307 | commercial, industrial or non-consumer uses, unless such uses represent
308 | the only significant mode of use of the product.
309 |
310 | "Installation Information" for a User Product means any methods,
311 | procedures, authorization keys, or other information required to install
312 | and execute modified versions of a covered work in that User Product from
313 | a modified version of its Corresponding Source. The information must
314 | suffice to ensure that the continued functioning of the modified object
315 | code is in no case prevented or interfered with solely because
316 | modification has been made.
317 |
318 | If you convey an object code work under this section in, or with, or
319 | specifically for use in, a User Product, and the conveying occurs as
320 | part of a transaction in which the right of possession and use of the
321 | User Product is transferred to the recipient in perpetuity or for a
322 | fixed term (regardless of how the transaction is characterized), the
323 | Corresponding Source conveyed under this section must be accompanied
324 | by the Installation Information. But this requirement does not apply
325 | if neither you nor any third party retains the ability to install
326 | modified object code on the User Product (for example, the work has
327 | been installed in ROM).
328 |
329 | The requirement to provide Installation Information does not include a
330 | requirement to continue to provide support service, warranty, or updates
331 | for a work that has been modified or installed by the recipient, or for
332 | the User Product in which it has been modified or installed. Access to a
333 | network may be denied when the modification itself materially and
334 | adversely affects the operation of the network or violates the rules and
335 | protocols for communication across the network.
336 |
337 | Corresponding Source conveyed, and Installation Information provided,
338 | in accord with this section must be in a format that is publicly
339 | documented (and with an implementation available to the public in
340 | source code form), and must require no special password or key for
341 | unpacking, reading or copying.
342 |
343 | 7. Additional Terms.
344 |
345 | "Additional permissions" are terms that supplement the terms of this
346 | License by making exceptions from one or more of its conditions.
347 | Additional permissions that are applicable to the entire Program shall
348 | be treated as though they were included in this License, to the extent
349 | that they are valid under applicable law. If additional permissions
350 | apply only to part of the Program, that part may be used separately
351 | under those permissions, but the entire Program remains governed by
352 | this License without regard to the additional permissions.
353 |
354 | When you convey a copy of a covered work, you may at your option
355 | remove any additional permissions from that copy, or from any part of
356 | it. (Additional permissions may be written to require their own
357 | removal in certain cases when you modify the work.) You may place
358 | additional permissions on material, added by you to a covered work,
359 | for which you have or can give appropriate copyright permission.
360 |
361 | Notwithstanding any other provision of this License, for material you
362 | add to a covered work, you may (if authorized by the copyright holders of
363 | that material) supplement the terms of this License with terms:
364 |
365 | a) Disclaiming warranty or limiting liability differently from the
366 | terms of sections 15 and 16 of this License; or
367 |
368 | b) Requiring preservation of specified reasonable legal notices or
369 | author attributions in that material or in the Appropriate Legal
370 | Notices displayed by works containing it; or
371 |
372 | c) Prohibiting misrepresentation of the origin of that material, or
373 | requiring that modified versions of such material be marked in
374 | reasonable ways as different from the original version; or
375 |
376 | d) Limiting the use for publicity purposes of names of licensors or
377 | authors of the material; or
378 |
379 | e) Declining to grant rights under trademark law for use of some
380 | trade names, trademarks, or service marks; or
381 |
382 | f) Requiring indemnification of licensors and authors of that
383 | material by anyone who conveys the material (or modified versions of
384 | it) with contractual assumptions of liability to the recipient, for
385 | any liability that these contractual assumptions directly impose on
386 | those licensors and authors.
387 |
388 | All other non-permissive additional terms are considered "further
389 | restrictions" within the meaning of section 10. If the Program as you
390 | received it, or any part of it, contains a notice stating that it is
391 | governed by this License along with a term that is a further
392 | restriction, you may remove that term. If a license document contains
393 | a further restriction but permits relicensing or conveying under this
394 | License, you may add to a covered work material governed by the terms
395 | of that license document, provided that the further restriction does
396 | not survive such relicensing or conveying.
397 |
398 | If you add terms to a covered work in accord with this section, you
399 | must place, in the relevant source files, a statement of the
400 | additional terms that apply to those files, or a notice indicating
401 | where to find the applicable terms.
402 |
403 | Additional terms, permissive or non-permissive, may be stated in the
404 | form of a separately written license, or stated as exceptions;
405 | the above requirements apply either way.
406 |
407 | 8. Termination.
408 |
409 | You may not propagate or modify a covered work except as expressly
410 | provided under this License. Any attempt otherwise to propagate or
411 | modify it is void, and will automatically terminate your rights under
412 | this License (including any patent licenses granted under the third
413 | paragraph of section 11).
414 |
415 | However, if you cease all violation of this License, then your
416 | license from a particular copyright holder is reinstated (a)
417 | provisionally, unless and until the copyright holder explicitly and
418 | finally terminates your license, and (b) permanently, if the copyright
419 | holder fails to notify you of the violation by some reasonable means
420 | prior to 60 days after the cessation.
421 |
422 | Moreover, your license from a particular copyright holder is
423 | reinstated permanently if the copyright holder notifies you of the
424 | violation by some reasonable means, this is the first time you have
425 | received notice of violation of this License (for any work) from that
426 | copyright holder, and you cure the violation prior to 30 days after
427 | your receipt of the notice.
428 |
429 | Termination of your rights under this section does not terminate the
430 | licenses of parties who have received copies or rights from you under
431 | this License. If your rights have been terminated and not permanently
432 | reinstated, you do not qualify to receive new licenses for the same
433 | material under section 10.
434 |
435 | 9. Acceptance Not Required for Having Copies.
436 |
437 | You are not required to accept this License in order to receive or
438 | run a copy of the Program. Ancillary propagation of a covered work
439 | occurring solely as a consequence of using peer-to-peer transmission
440 | to receive a copy likewise does not require acceptance. However,
441 | nothing other than this License grants you permission to propagate or
442 | modify any covered work. These actions infringe copyright if you do
443 | not accept this License. Therefore, by modifying or propagating a
444 | covered work, you indicate your acceptance of this License to do so.
445 |
446 | 10. Automatic Licensing of Downstream Recipients.
447 |
448 | Each time you convey a covered work, the recipient automatically
449 | receives a license from the original licensors, to run, modify and
450 | propagate that work, subject to this License. You are not responsible
451 | for enforcing compliance by third parties with this License.
452 |
453 | An "entity transaction" is a transaction transferring control of an
454 | organization, or substantially all assets of one, or subdividing an
455 | organization, or merging organizations. If propagation of a covered
456 | work results from an entity transaction, each party to that
457 | transaction who receives a copy of the work also receives whatever
458 | licenses to the work the party's predecessor in interest had or could
459 | give under the previous paragraph, plus a right to possession of the
460 | Corresponding Source of the work from the predecessor in interest, if
461 | the predecessor has it or can get it with reasonable efforts.
462 |
463 | You may not impose any further restrictions on the exercise of the
464 | rights granted or affirmed under this License. For example, you may
465 | not impose a license fee, royalty, or other charge for exercise of
466 | rights granted under this License, and you may not initiate litigation
467 | (including a cross-claim or counterclaim in a lawsuit) alleging that
468 | any patent claim is infringed by making, using, selling, offering for
469 | sale, or importing the Program or any portion of it.
470 |
471 | 11. Patents.
472 |
473 | A "contributor" is a copyright holder who authorizes use under this
474 | License of the Program or a work on which the Program is based. The
475 | work thus licensed is called the contributor's "contributor version".
476 |
477 | A contributor's "essential patent claims" are all patent claims
478 | owned or controlled by the contributor, whether already acquired or
479 | hereafter acquired, that would be infringed by some manner, permitted
480 | by this License, of making, using, or selling its contributor version,
481 | but do not include claims that would be infringed only as a
482 | consequence of further modification of the contributor version. For
483 | purposes of this definition, "control" includes the right to grant
484 | patent sublicenses in a manner consistent with the requirements of
485 | this License.
486 |
487 | Each contributor grants you a non-exclusive, worldwide, royalty-free
488 | patent license under the contributor's essential patent claims, to
489 | make, use, sell, offer for sale, import and otherwise run, modify and
490 | propagate the contents of its contributor version.
491 |
492 | In the following three paragraphs, a "patent license" is any express
493 | agreement or commitment, however denominated, not to enforce a patent
494 | (such as an express permission to practice a patent or covenant not to
495 | sue for patent infringement). To "grant" such a patent license to a
496 | party means to make such an agreement or commitment not to enforce a
497 | patent against the party.
498 |
499 | If you convey a covered work, knowingly relying on a patent license,
500 | and the Corresponding Source of the work is not available for anyone
501 | to copy, free of charge and under the terms of this License, through a
502 | publicly available network server or other readily accessible means,
503 | then you must either (1) cause the Corresponding Source to be so
504 | available, or (2) arrange to deprive yourself of the benefit of the
505 | patent license for this particular work, or (3) arrange, in a manner
506 | consistent with the requirements of this License, to extend the patent
507 | license to downstream recipients. "Knowingly relying" means you have
508 | actual knowledge that, but for the patent license, your conveying the
509 | covered work in a country, or your recipient's use of the covered work
510 | in a country, would infringe one or more identifiable patents in that
511 | country that you have reason to believe are valid.
512 |
513 | If, pursuant to or in connection with a single transaction or
514 | arrangement, you convey, or propagate by procuring conveyance of, a
515 | covered work, and grant a patent license to some of the parties
516 | receiving the covered work authorizing them to use, propagate, modify
517 | or convey a specific copy of the covered work, then the patent license
518 | you grant is automatically extended to all recipients of the covered
519 | work and works based on it.
520 |
521 | A patent license is "discriminatory" if it does not include within
522 | the scope of its coverage, prohibits the exercise of, or is
523 | conditioned on the non-exercise of one or more of the rights that are
524 | specifically granted under this License. You may not convey a covered
525 | work if you are a party to an arrangement with a third party that is
526 | in the business of distributing software, under which you make payment
527 | to the third party based on the extent of your activity of conveying
528 | the work, and under which the third party grants, to any of the
529 | parties who would receive the covered work from you, a discriminatory
530 | patent license (a) in connection with copies of the covered work
531 | conveyed by you (or copies made from those copies), or (b) primarily
532 | for and in connection with specific products or compilations that
533 | contain the covered work, unless you entered into that arrangement,
534 | or that patent license was granted, prior to 28 March 2007.
535 |
536 | Nothing in this License shall be construed as excluding or limiting
537 | any implied license or other defenses to infringement that may
538 | otherwise be available to you under applicable patent law.
539 |
540 | 12. No Surrender of Others' Freedom.
541 |
542 | If conditions are imposed on you (whether by court order, agreement or
543 | otherwise) that contradict the conditions of this License, they do not
544 | excuse you from the conditions of this License. If you cannot convey a
545 | covered work so as to satisfy simultaneously your obligations under this
546 | License and any other pertinent obligations, then as a consequence you may
547 | not convey it at all. For example, if you agree to terms that obligate you
548 | to collect a royalty for further conveying from those to whom you convey
549 | the Program, the only way you could satisfy both those terms and this
550 | License would be to refrain entirely from conveying the Program.
551 |
552 | 13. Use with the GNU Affero General Public License.
553 |
554 | Notwithstanding any other provision of this License, you have
555 | permission to link or combine any covered work with a work licensed
556 | under version 3 of the GNU Affero General Public License into a single
557 | combined work, and to convey the resulting work. The terms of this
558 | License will continue to apply to the part which is the covered work,
559 | but the special requirements of the GNU Affero General Public License,
560 | section 13, concerning interaction through a network will apply to the
561 | combination as such.
562 |
563 | 14. Revised Versions of this License.
564 |
565 | The Free Software Foundation may publish revised and/or new versions of
566 | the GNU General Public License from time to time. Such new versions will
567 | be similar in spirit to the present version, but may differ in detail to
568 | address new problems or concerns.
569 |
570 | Each version is given a distinguishing version number. If the
571 | Program specifies that a certain numbered version of the GNU General
572 | Public License "or any later version" applies to it, you have the
573 | option of following the terms and conditions either of that numbered
574 | version or of any later version published by the Free Software
575 | Foundation. If the Program does not specify a version number of the
576 | GNU General Public License, you may choose any version ever published
577 | by the Free Software Foundation.
578 |
579 | If the Program specifies that a proxy can decide which future
580 | versions of the GNU General Public License can be used, that proxy's
581 | public statement of acceptance of a version permanently authorizes you
582 | to choose that version for the Program.
583 |
584 | Later license versions may give you additional or different
585 | permissions. However, no additional obligations are imposed on any
586 | author or copyright holder as a result of your choosing to follow a
587 | later version.
588 |
589 | 15. Disclaimer of Warranty.
590 |
591 | THERE IS NO WARRANTY FOR THE PROGRAM, TO THE EXTENT PERMITTED BY
592 | APPLICABLE LAW. EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT
593 | HOLDERS AND/OR OTHER PARTIES PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY
594 | OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO,
595 | THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
596 | PURPOSE. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE PROGRAM
597 | IS WITH YOU. SHOULD THE PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF
598 | ALL NECESSARY SERVICING, REPAIR OR CORRECTION.
599 |
600 | 16. Limitation of Liability.
601 |
602 | IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING
603 | WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MODIFIES AND/OR CONVEYS
604 | THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES, INCLUDING ANY
605 | GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THE
606 | USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED TO LOSS OF
607 | DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD
608 | PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER PROGRAMS),
609 | EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF
610 | SUCH DAMAGES.
611 |
612 | 17. Interpretation of Sections 15 and 16.
613 |
614 | If the disclaimer of warranty and limitation of liability provided
615 | above cannot be given local legal effect according to their terms,
616 | reviewing courts shall apply local law that most closely approximates
617 | an absolute waiver of all civil liability in connection with the
618 | Program, unless a warranty or assumption of liability accompanies a
619 | copy of the Program in return for a fee.
620 |
621 | END OF TERMS AND CONDITIONS
622 |
623 | How to Apply These Terms to Your New Programs
624 |
625 | If you develop a new program, and you want it to be of the greatest
626 | possible use to the public, the best way to achieve this is to make it
627 | free software which everyone can redistribute and change under these terms.
628 |
629 | To do so, attach the following notices to the program. It is safest
630 | to attach them to the start of each source file to most effectively
631 | state the exclusion of warranty; and each file should have at least
632 | the "copyright" line and a pointer to where the full notice is found.
633 |
634 |
635 | Copyright (C)
636 |
637 | This program is free software: you can redistribute it and/or modify
638 | it under the terms of the GNU General Public License as published by
639 | the Free Software Foundation, either version 3 of the License, or
640 | (at your option) any later version.
641 |
642 | This program is distributed in the hope that it will be useful,
643 | but WITHOUT ANY WARRANTY; without even the implied warranty of
644 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
645 | GNU General Public License for more details.
646 |
647 | You should have received a copy of the GNU General Public License
648 | along with this program. If not, see .
649 |
650 | Also add information on how to contact you by electronic and paper mail.
651 |
652 | If the program does terminal interaction, make it output a short
653 | notice like this when it starts in an interactive mode:
654 |
655 | Copyright (C)
656 | This program comes with ABSOLUTELY NO WARRANTY; for details type `show w'.
657 | This is free software, and you are welcome to redistribute it
658 | under certain conditions; type `show c' for details.
659 |
660 | The hypothetical commands `show w' and `show c' should show the appropriate
661 | parts of the General Public License. Of course, your program's commands
662 | might be different; for a GUI interface, you would use an "about box".
663 |
664 | You should also get your employer (if you work as a programmer) or school,
665 | if any, to sign a "copyright disclaimer" for the program, if necessary.
666 | For more information on this, and how to apply and follow the GNU GPL, see
667 | .
668 |
669 | The GNU General Public License does not permit incorporating your program
670 | into proprietary programs. If your program is a subroutine library, you
671 | may consider it more useful to permit linking proprietary applications with
672 | the library. If this is what you want to do, use the GNU Lesser General
673 | Public License instead of this License. But first, please read
674 | .
675 |
--------------------------------------------------------------------------------
/README.md:
--------------------------------------------------------------------------------
1 | # DeepStoragePlus
2 | Adds the Applied Energistics 2 feature of storing bulk items
3 |
4 | Dependency: CustomRecipeAPI
5 | You need to download CustomRecipeAPI and put it in your plugins folder for this plugin to run
6 | DeepStoragePlus Is a mini-clone of the very popular mod Applied Energistics. This plugin includes the bulk storage feature of AE, and may have more features coming in the future.
7 | DeepStoragePlus helps you store bulk items in a Deep Storage Unit, and implements "Storage Containers" which are super easy to move in your inventory.
8 |
9 | In the above image, we can see that a Storage Container with 1K storage space is full with 7 types, and has more space for items. Storage containers are super easy to move around, as mentioned above, which means you can just take the container out of the DSU and keep it elsewhere. (Note, only the DSU can manipulate the items inside the Storage Container)
10 | Features:
11 | - Hopper Input/Output
12 | - Inventory Sorting
13 | - Custom Recipes
14 | - Wireless Terminal
15 | - Locking + Whitelist
16 | - Speed Upgrades
17 | - Easy Item Movement (using storage containers)
18 | - Realistic, not too OP
19 |
20 |
21 | There are Many important recipes to know, so I've made a docs page for more info here: DOCS PAGE (not being updated anymore. CustomRecipeAPI 1.1.0 has a recipe book)
22 |
23 | If you're running the latest versions of DeepStoragePlus and CustomRecipeAPI, there is a recipe book that shows all these recipes. Check it out on the CustomRecipeAPI page.
24 |
25 |
26 | deepstorageplus.create:
27 | description: Allows the user to create a DSU
28 | default: op
29 | deepstorageplus.adminopen:
30 | description: Allows the user to open locked DSUs
31 | default: op
32 | crapi.command:
33 | description: Allows the use of CustomRecipeAPI commands
34 | default: op
35 | crapi.book:
36 | description: Allows the use of CustomRecipeAPI recipe book
37 | default: op
38 | deepstorageplus.wireless:
39 | description: Allows the user to use the wireless terminal
40 | default: op
41 |
42 |
43 |
44 | Following in the spirit of AE, Storage Containers have a max storage, and a max data types amount. Due to the size of a double chest, I've limited the types to 7. This cannot be changed to anything higher.
45 | There's also a custom texture pack that will be prompted upon joining the server with the plugin enabled. I HIGHLY recommend using it. This plugin is very ugly without it enabled, and it's super light. Takes about 3 seconds to load.
46 | if the player breaks the DSU, the DSU will be lost. The Storage Containers will drop on the floor, and no data will be lost, however the DSU feature will be lost, and another Loader Wrench will be required to make another.
47 | To use the Wireless terminal, right click on a Deep Storage Unit. Then go anywhere in the same dimension as the DSU, and right click your Wireless Terminal. To unlink it, crouch and swap to offhand at the same time.
48 |
49 |
50 | Planned Potential Features:
51 | - IO Speed Upgrades - Done! Version 1.7.0
52 | - Recipe Book - Done! Supported by CustomRecipeAPI
53 | - Maximum DSUs per person? (will be optional)
54 | - DSU Locking feature - Done! Version 1.6.0
55 | - Crafting terminal upgrade - will look into possibility
56 | - Wireless terminal - Done! Version 1.5.0
57 |
58 | Donate to support my work here -> DONATE
59 |
60 | Join my discord server for help/suggestions. I'm active there every day.
61 | https://discord.gg/AET9mWj
62 |
63 | Tutorial Video - Basics:
64 | Kw5qMgHamTk
65 |
66 | Can conflict with auto-sorting inventory plugins
67 |
--------------------------------------------------------------------------------
/img/DSPbanner.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/christopherwalkerml/DeepStoragePlus/9ccc635869a70d707213716b8e6c2178ee8d864f/img/DSPbanner.png
--------------------------------------------------------------------------------
/img/MoreInfoBanner.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/christopherwalkerml/DeepStoragePlus/9ccc635869a70d707213716b8e6c2178ee8d864f/img/MoreInfoBanner.png
--------------------------------------------------------------------------------
/img/RecipesBanner.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/christopherwalkerml/DeepStoragePlus/9ccc635869a70d707213716b8e6c2178ee8d864f/img/RecipesBanner.png
--------------------------------------------------------------------------------
/img/fulltypes.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/christopherwalkerml/DeepStoragePlus/9ccc635869a70d707213716b8e6c2178ee8d864f/img/fulltypes.png
--------------------------------------------------------------------------------
/img/permissions.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/christopherwalkerml/DeepStoragePlus/9ccc635869a70d707213716b8e6c2178ee8d864f/img/permissions.png
--------------------------------------------------------------------------------
/pom.xml:
--------------------------------------------------------------------------------
1 |
2 |
5 | 4.0.0
6 |
7 | me.Darkolythe
8 | DeepStoragePlus
9 | 1.11.7
10 | jar
11 |
12 |
13 | UTF-8
14 | 1.8
15 | 1.8
16 |
17 |
18 |
19 |
20 | spigotmc-repo
21 | https://hub.spigotmc.org/nexus/content/groups/public/
22 |
23 |
24 | CodeMC
25 | https://repo.codemc.org/repository/maven-public
26 |
27 |
28 |
29 |
30 |
31 | org.spigotmc
32 | spigot-api
33 | 1.15-R0.1-SNAPSHOT
34 | provided
35 |
36 |
37 | org.bstats
38 | bstats-bukkit
39 | 3.0.0
40 | compile
41 |
42 |
43 | me.Darkolythe
44 | CustomRecipeAPI
45 | 1.6.0
46 | system
47 | C:\Users\Chris Walker\Desktop\servers\SERVERLIST\1.21\plugins\CustomRecipeAPI-1.6.0.jar
48 |
49 |
50 | de.tr7zw
51 | item-nbt-api
52 | 2.15.0
53 |
54 |
55 |
56 |
57 |
58 |
59 | org.apache.maven.plugins
60 | maven-jar-plugin
61 | 2.3.1
62 |
63 | C:\Users\Chris Walker\Desktop\servers\SERVERLIST\1.21\plugins
64 |
65 |
66 |
67 | org.apache.maven.plugins
68 | maven-shade-plugin
69 | 3.1.0
70 |
71 |
72 |
73 | org.bstats
74 | me.darkolythe.deepstorageplus
75 |
76 |
77 | de.tr7zw.changeme.nbtapi
78 | me.darkolythe.deepstorageplus
79 |
80 |
81 |
82 |
83 |
84 | package
85 |
86 | shade
87 |
88 |
89 |
90 |
91 |
92 |
93 |
--------------------------------------------------------------------------------
/src/main/java/me/darkolythe/deepstorageplus/DeepStoragePlus.java:
--------------------------------------------------------------------------------
1 | package me.darkolythe.deepstorageplus;
2 |
3 | import me.darkolythe.customrecipeapi.APIManager;
4 | import me.darkolythe.customrecipeapi.CustomRecipeAPI;
5 | import me.darkolythe.deepstorageplus.dsu.listeners.*;
6 | import me.darkolythe.deepstorageplus.dsu.managers.DSUManager;
7 | import me.darkolythe.deepstorageplus.dsu.managers.DSUUpdateManager;
8 | import me.darkolythe.deepstorageplus.dsu.managers.SorterManager;
9 | import me.darkolythe.deepstorageplus.dsu.managers.SorterUpdateManager;
10 | import me.darkolythe.deepstorageplus.io.CommandHandler;
11 | import me.darkolythe.deepstorageplus.io.ConfigManager;
12 | import me.darkolythe.deepstorageplus.utils.*;
13 | import org.bstats.bukkit.Metrics;
14 | import org.bukkit.ChatColor;
15 | import org.bukkit.Chunk;
16 | import org.bukkit.Location;
17 | import org.bukkit.Material;
18 | import org.bukkit.block.Container;
19 | import org.bukkit.entity.Player;
20 | import org.bukkit.inventory.Inventory;
21 | import org.bukkit.plugin.java.JavaPlugin;
22 |
23 | import java.util.*;
24 | import java.util.logging.Level;
25 |
26 | public final class DeepStoragePlus extends JavaPlugin {
27 |
28 | private static DeepStoragePlus plugin;
29 |
30 | public static String prefix;
31 | public static boolean loadpack;
32 | public static int maxrange;
33 | public static boolean packmsg;
34 | public static String DSUname = ChatColor.BLUE.toString() + ChatColor.BOLD.toString() + "Deep Storage Unit";
35 | public static String sortername = ChatColor.BLUE.toString() + ChatColor.BOLD.toString() + "Deep Storage Sorter";
36 |
37 | public static final long minTimeSinceLastSortPlayer = 500L;
38 | public static final long minTimeSinceLastSortHopper = 30000L;
39 |
40 | /*Currently open DSU for each player*/
41 | public static Map openDSU = new HashMap<>();
42 | /*Currently or last open DSU for each player*/
43 | public static Map stashedDSU = new HashMap<>();
44 | /*Buffered IO inventory, used for getting chat when adding players to lock*/
45 | public static Map stashedIO = new HashMap<>();
46 | /*Boolean for if the user is getting check for user input*/
47 | public static Map gettingInput = new HashMap<>();
48 | /*Boolean for IO inventory to be opened for player*/
49 | public static Map openIOInv = new HashMap<>();
50 | /*Inventory that had bulk items put in that needs to be updated. Updating every item is inefficient and causes lag*/
51 | public static Map recentDSUCalls = new HashMap<>();
52 | /*Inventory of a sorter that needs to be processed*/
53 | public static Map recentSortCalls = new HashMap<>();
54 | /*Cache of DSUs stored per sorter per material. Updated whenever a sort fails.*/
55 | public static Map>> sorterLocationCache = new HashMap<>();
56 | /*Chunk loaded for players opening DSUs far away*/
57 | public static Map loadedChunks = new HashMap<>();
58 |
59 | private ItemList itemList;
60 | private InventoryListener inventorylistener;
61 | private WrenchListener wrenchlistener;
62 | private WirelessListener wirelesslistener;
63 | private IOListener iolistener;
64 | private StorageBreakListener storagebreakslistener;
65 | private RecipeManager recipemanager;
66 | public DSUUpdateManager dsuupdatemanager;
67 | public DSUManager dsumanager;
68 | public SorterUpdateManager sorterUpdateManager;
69 | public SorterManager sorterManager;
70 | public APIManager crapimanager;
71 | ConfigManager configmanager;
72 |
73 | public static int maxTypes = 7;
74 |
75 | @Override
76 | public void onEnable() {
77 | plugin = this;
78 |
79 | saveDefaultConfig();
80 | prefix = ChatColor.translateAlternateColorCodes('&', getConfig().getString("prefix")) + " ";
81 | loadpack = getConfig().getBoolean("loadresourcepack");
82 | packmsg = getConfig().getBoolean("resourcepackmessage");
83 | maxrange = getConfig().getInt("range");
84 |
85 | LanguageManager.setup(plugin);
86 |
87 |
88 | itemList = new ItemList(plugin);
89 | inventorylistener = new InventoryListener(plugin);
90 | wrenchlistener = new WrenchListener(plugin);
91 | wirelesslistener = new WirelessListener(plugin);
92 | iolistener = new IOListener(plugin);
93 | storagebreakslistener = new StorageBreakListener(plugin);
94 | recipemanager = new RecipeManager(plugin, itemList);
95 | configmanager = new ConfigManager(plugin);
96 | dsuupdatemanager = new DSUUpdateManager(plugin);
97 | dsumanager = new DSUManager(plugin);
98 | sorterUpdateManager = new SorterUpdateManager(plugin);
99 | sorterManager = new SorterManager(plugin);
100 | crapimanager = CustomRecipeAPI.getManager();
101 |
102 | inventorylistener.addText();
103 |
104 | getServer().getPluginManager().registerEvents(inventorylistener, plugin);
105 | getServer().getPluginManager().registerEvents(wrenchlistener, plugin);
106 | getServer().getPluginManager().registerEvents(wirelesslistener, plugin);
107 | getServer().getPluginManager().registerEvents(iolistener, plugin);
108 | getServer().getPluginManager().registerEvents(storagebreakslistener, plugin);
109 | getServer().getPluginManager().registerEvents(configmanager, plugin);
110 |
111 | getCommand("deepstorageplus").setExecutor(new CommandHandler(itemList));
112 | getCommand("dsp").setExecutor(new CommandHandler(itemList));
113 |
114 | Metrics metrics = new Metrics(plugin, 6221);
115 |
116 | getLogger().log(Level.INFO, (prefix + ChatColor.GREEN + "DeepStoragePlus enabled!"));
117 | }
118 |
119 | @Override
120 | public void onDisable() {
121 | // Plugin shutdown logic
122 | }
123 |
124 | public static DeepStoragePlus getInstance() {
125 | return plugin;
126 | }
127 | }
128 |
--------------------------------------------------------------------------------
/src/main/java/me/darkolythe/deepstorageplus/dsu/StorageUtils.java:
--------------------------------------------------------------------------------
1 | package me.darkolythe.deepstorageplus.dsu;
2 |
3 | import me.darkolythe.deepstorageplus.dsu.managers.DSUManager;
4 | import me.darkolythe.deepstorageplus.dsu.managers.SorterManager;
5 | import me.darkolythe.deepstorageplus.utils.ItemList;
6 | import org.apache.commons.lang.WordUtils;
7 | import org.bukkit.ChatColor;
8 | import org.bukkit.Material;
9 | import org.bukkit.block.Block;
10 | import org.bukkit.block.Chest;
11 | import org.bukkit.block.DoubleChest;
12 | import org.bukkit.event.inventory.InventoryType;
13 | import org.bukkit.inventory.Inventory;
14 | import org.bukkit.inventory.ItemStack;
15 |
16 | import java.util.Optional;
17 |
18 | public class StorageUtils {
19 |
20 | /*
21 | Check if the item "has no meta" which counts enchants, damage, lore, name, etc.
22 | */
23 | public static boolean hasNoMeta(ItemStack item) {
24 | if (item.getDurability() != 0) {
25 | return false;
26 | }
27 | if (item.getType().toString().contains("SHULKER_BOX")) {
28 | return false;
29 | }
30 | if (item.hasItemMeta()) {
31 | if (item.getItemMeta().hasEnchants()) {
32 | return false;
33 | }
34 | if (item.getItemMeta().hasDisplayName()) {
35 | return false;
36 | }
37 | if (item.getType() == Material.ENCHANTED_BOOK) {
38 | return false;
39 | }
40 | if (item.getType() == Material.FIREWORK_ROCKET) {
41 | return false;
42 | }
43 | if (item.getType().toString().contains("POTION")) {
44 | return false;
45 | }
46 | if (item.getType() == Material.TIPPED_ARROW) {
47 | return false;
48 | }
49 | if (item.getItemMeta().hasLore()) {
50 | if (item.getItemMeta().getLore().get(0).contains("Item Count: ")) {
51 | if (item.getDurability() != 0) {
52 | return false;
53 | }
54 | if (item.getEnchantments().size() > 0) {
55 | return false;
56 | }
57 | return true;
58 | }
59 | return false;
60 | }
61 | }
62 | return true;
63 | }
64 |
65 | /*
66 | Turns a Material into a String. ex: EMERALD_ORE -> Emerald Ore
67 | */
68 | public static String matToString(Material mat) {
69 | return WordUtils.capitalize(mat.toString().toLowerCase().replaceAll("_", " "));
70 | }
71 |
72 | /*
73 | Turns a String into a Material. ex: Emerald Ore -> EMERALD_ORE
74 | */
75 | public static Material stringToMat(String str, String remStr) {
76 | return Material.valueOf(str.replace(remStr, "").toUpperCase().replace(" ", "_").toUpperCase());
77 | }
78 |
79 | public static boolean isDSU(Inventory inv) {
80 | if (inv.getSize() != 54)
81 | return false;
82 |
83 | if (inv.getType() != InventoryType.CHEST)
84 | return false;
85 |
86 | for (ItemStack i : inv.getContents()) {
87 | if (i != null) {
88 | if (i.getType().equals(Material.TRIPWIRE_HOOK)
89 | && i.hasItemMeta()
90 | && i.getItemMeta().hasDisplayName()
91 | && i.getItemMeta().getDisplayName().equals(ChatColor.BLUE.toString() + "Lock DSU")) {
92 | return false;
93 | }
94 | }
95 | }
96 |
97 | int slots[] = {7, 16, 25, 34, 43, 52};
98 | boolean isDSU = false;
99 |
100 | for (int i : slots) {
101 | if (inv.getItem(i) != null && inv.getItem(i).equals(DSUManager.getDSUWall()))
102 | isDSU = true;
103 | }
104 |
105 | if (!isDSU)
106 | return false;
107 |
108 | return true;
109 | }
110 |
111 | public static boolean isSorter(Inventory inv) {
112 | if (inv.getSize() != 54)
113 | return false;
114 |
115 | if (inv.getType() != InventoryType.CHEST)
116 | return false;
117 |
118 | int slots[] = {18, 19, 20, 21, 22, 23, 24, 25, 26};
119 | boolean isSorter = false;
120 |
121 | for (int i : slots) {
122 | if (inv.getItem(i) != null && inv.getItem(i).equals(SorterManager.getSorterWall()))
123 | isSorter = true;
124 | }
125 |
126 | if (!isSorter)
127 | return false;
128 |
129 | return true;
130 | }
131 |
132 | /**
133 | * Returns the custom name of a chest or double chest, if either side has one. Prefers the left chest.
134 | * @param block
135 | * @return
136 | */
137 | public static Optional getChestCustomName(Block block) {
138 | Chest chest = (Chest) block.getState();
139 | if (chest.getInventory().getHolder() instanceof DoubleChest) {
140 | DoubleChest doubleChest = (DoubleChest) chest.getInventory().getHolder();
141 | Chest leftChest = (Chest) doubleChest.getLeftSide();
142 | Chest rightChest = (Chest) doubleChest.getRightSide();
143 | if (leftChest.getCustomName() != null) {
144 | return Optional.of(leftChest.getCustomName());
145 | }
146 | if (rightChest.getCustomName() != null) {
147 | return Optional.of(rightChest.getCustomName());
148 | }
149 | }
150 | return Optional.ofNullable(chest.getCustomName());
151 | }
152 | }
153 |
--------------------------------------------------------------------------------
/src/main/java/me/darkolythe/deepstorageplus/dsu/listeners/IOListener.java:
--------------------------------------------------------------------------------
1 | package me.darkolythe.deepstorageplus.dsu.listeners;
2 |
3 | import me.darkolythe.deepstorageplus.DeepStoragePlus;
4 | import me.darkolythe.deepstorageplus.dsu.StorageUtils;
5 | import me.darkolythe.deepstorageplus.dsu.managers.DSUManager;
6 | import me.darkolythe.deepstorageplus.dsu.managers.SorterManager;
7 | import me.darkolythe.deepstorageplus.utils.LanguageManager;
8 | import org.bukkit.Bukkit;
9 | import org.bukkit.ChatColor;
10 | import org.bukkit.Material;
11 | import org.bukkit.block.Block;
12 | import org.bukkit.block.Chest;
13 | import org.bukkit.block.Container;
14 | import org.bukkit.entity.Player;
15 | import org.bukkit.event.EventHandler;
16 | import org.bukkit.event.EventPriority;
17 | import org.bukkit.event.Listener;
18 | import org.bukkit.event.block.Action;
19 | import org.bukkit.event.inventory.InventoryMoveItemEvent;
20 | import org.bukkit.event.player.PlayerInteractEvent;
21 | import org.bukkit.inventory.Inventory;
22 | import org.bukkit.inventory.ItemStack;
23 | import org.bukkit.inventory.meta.ItemMeta;
24 |
25 | import java.util.HashMap;
26 | import java.util.HashSet;
27 | import java.util.List;
28 |
29 | import static me.darkolythe.deepstorageplus.dsu.StorageUtils.hasNoMeta;
30 | import static me.darkolythe.deepstorageplus.dsu.StorageUtils.stringToMat;
31 | import static me.darkolythe.deepstorageplus.dsu.managers.DSUManager.addDataToContainer;
32 | import static me.darkolythe.deepstorageplus.dsu.managers.SettingsManager.addSpeedUpgrade;
33 | import static me.darkolythe.deepstorageplus.dsu.managers.SettingsManager.getSpeedUpgrade;
34 | import static me.darkolythe.deepstorageplus.utils.ItemList.createSpeedUpgrade;
35 |
36 | public class IOListener implements Listener {
37 |
38 | private DeepStoragePlus main;
39 | public IOListener(DeepStoragePlus plugin) {
40 | this.main = plugin; // set it equal to an instance of main
41 | }
42 |
43 | @EventHandler(priority = EventPriority.HIGHEST)
44 | private void onDSUClick(PlayerInteractEvent event) {
45 | if (event.getAction() == Action.RIGHT_CLICK_BLOCK || event.getAction() == Action.RIGHT_CLICK_AIR) {
46 | Player player = event.getPlayer();
47 | Block block = event.getClickedBlock();
48 | if (block != null && block.getType() == Material.CHEST) {
49 | if (!event.isCancelled()) {
50 | Chest chest = (Chest) block.getState();
51 | Inventory inv = chest.getInventory();
52 | if (chest.getInventory().contains(DSUManager.getDSUWall())) {
53 | ItemStack item = player.getInventory().getItemInMainHand();
54 | if (compareItemStacks(item, createSpeedUpgrade())) {
55 | ItemStack IOItem = inv.getItem(53);
56 | ItemStack newIOItem = addSpeedUpgrade(IOItem);
57 | if (newIOItem != null) {
58 | inv.setItem(53, newIOItem);
59 | player.sendMessage(DeepStoragePlus.prefix + ChatColor.GREEN + LanguageManager.getValue("upgradesuccess"));
60 | item.setAmount(item.getAmount() - 1);
61 | } else {
62 | player.sendMessage(DeepStoragePlus.prefix + ChatColor.RED + LanguageManager.getValue("upgradefail"));
63 | }
64 | inv.getLocation().getBlock().getState().update();
65 | event.setCancelled(true);
66 | }
67 | }
68 | }
69 | }
70 | }
71 | }
72 |
73 | @EventHandler(priority = EventPriority.HIGHEST)
74 | private void onHopperInput(InventoryMoveItemEvent event) {
75 | Inventory initial = event.getSource();
76 | Inventory dest = event.getDestination();
77 |
78 | if (initial.getSize() == 54 || dest.getSize() == 54) {
79 |
80 | ItemStack moveItem = event.getItem();
81 |
82 | ItemStack IOSettings;
83 | Inventory IOInv;
84 | Material input;
85 | Material output;
86 | String IOStatus = "input";
87 |
88 | if (initial.getSize() == 54) {
89 | IOSettings = initial.getItem(53);
90 | IOInv = initial;
91 | IOStatus = "output";
92 | } else {
93 | IOSettings = dest.getItem(53);
94 | IOInv = dest;
95 | }
96 |
97 | if (StorageUtils.isDSU(IOInv)) {
98 | event.setCancelled(true);
99 |
100 | if (hasNoMeta(moveItem)) {
101 | if (IOSettings != null) {
102 | input = getInput(IOSettings);
103 | output = getOutput(IOSettings);
104 |
105 | int amt = getSpeedUpgrade(IOSettings);
106 |
107 | if (IOStatus.equals("input")) {
108 | lookForItemInHopper(initial, dest, input, amt + 1);
109 | return;
110 | } else {
111 | lookForItemInChest(output, initial, dest, moveItem, amt + 1);
112 | return;
113 | }
114 | }
115 | }
116 | } else if (StorageUtils.isSorter(IOInv)) {
117 | if (IOStatus.equals("input")) {
118 | main.sorterUpdateManager.sortItems(IOInv, DeepStoragePlus.minTimeSinceLastSortHopper);
119 | } else {
120 | event.setCancelled(true);
121 | }
122 | }
123 | }
124 | }
125 |
126 | private static Material getInput(ItemStack item) {
127 | ItemMeta meta = item.getItemMeta();
128 | List lore = meta.getLore();
129 | if (lore.get(0).contains(LanguageManager.getValue("all"))) {
130 | return null;
131 | } else {
132 | return stringToMat(lore.get(0), ChatColor.GRAY + LanguageManager.getValue("input") + ": " + ChatColor.GREEN);
133 | }
134 | }
135 |
136 | private static Material getOutput(ItemStack item) {
137 | ItemMeta meta = item.getItemMeta();
138 | List lore = meta.getLore();
139 | if (lore.get(1).contains(LanguageManager.getValue("none"))) {
140 | return null;
141 | } else {
142 | return stringToMat(lore.get(1), ChatColor.GRAY + LanguageManager.getValue("output") + ": " + ChatColor.GREEN);
143 | }
144 | }
145 |
146 | private void lookForItemInHopper(Inventory initial, Inventory dest, Material input, int amt) {
147 | Bukkit.getServer().getScheduler().scheduleSyncDelayedTask(main, new Runnable() {
148 | @Override
149 | public void run() {
150 | boolean moved_stack = false;
151 | for (int i = 0; i < 5; i++) {
152 | if (!moved_stack) {
153 | ItemStack toMove = initial.getItem(i);
154 | if (toMove != null && (input == null || input == toMove.getType())) {
155 | ItemStack moving = toMove.clone();
156 | moving.setAmount(Math.min(amt, toMove.getAmount()));
157 | if (hasNoMeta(moving)) { //items being stored cannot have any special features. ie: damage, enchants, name, lore.
158 | for (int j = 0; j < 5; j++) {
159 | if (moving.getAmount() > 0) { //if the item amount is greater than 0, it means there are still items to put in the containers
160 | addDataToContainer(dest.getItem(8 + (9 * j)), moving); //add the item to the current loop container
161 | toMove.setAmount(toMove.getAmount() - (amt - moving.getAmount()));
162 |
163 | main.dsuupdatemanager.updateItems(dest, input);
164 | moved_stack = true;
165 | } else {
166 | break;
167 | }
168 | }
169 | }
170 | }
171 | }
172 | }
173 | }
174 | }, 1);
175 | }
176 |
177 | private void lookForItemInChest(Material output, Inventory initial, Inventory dest, ItemStack moveItem, int amt) {
178 | Bukkit.getServer().getScheduler().scheduleSyncDelayedTask(main, new Runnable() {
179 | @Override
180 | public void run() {
181 |
182 | if (initial.first(moveItem.getType()) != 0) {
183 | return;
184 | }
185 |
186 | if (output != null) {
187 | for (int i = 0; i < 5; i++) {
188 | ItemStack container = initial.getItem(8 + (9 * i));
189 | if (container.getType() != Material.WHITE_STAINED_GLASS_PANE) {
190 | HashSet mats = DSUManager.getTypes(container.getItemMeta().getLore());
191 | // get the amount that can be taken from the DSU
192 | int allowed_amt = Math.min(amt, DSUManager.getTotalMaterialAmount(initial, output));
193 | if (mats.contains(output)) {
194 | HashMap items = dest.addItem(new ItemStack(output, allowed_amt));
195 | // subtract any item counts that cant fit into the output hopper
196 | int sub = 0;
197 | for (ItemStack overflow : items.values()) {
198 | sub += overflow.getAmount();
199 | }
200 | DSUManager.takeItems(output, initial, allowed_amt - sub);
201 |
202 | main.dsuupdatemanager.updateItems(initial, output);
203 | return;
204 | }
205 | }
206 | }
207 | }
208 | }
209 | }, 1);
210 | }
211 |
212 | private static boolean compareItemStacks(ItemStack item1, ItemStack item2) {
213 | ItemStack i1 = item1.clone();
214 | ItemStack i2 = item2.clone();
215 | i1.setAmount(1);
216 | i2.setAmount(1);
217 | return i1.equals(i2);
218 | }
219 | }
220 |
--------------------------------------------------------------------------------
/src/main/java/me/darkolythe/deepstorageplus/dsu/listeners/InventoryListener.java:
--------------------------------------------------------------------------------
1 | package me.darkolythe.deepstorageplus.dsu.listeners;
2 |
3 | import me.darkolythe.deepstorageplus.DeepStoragePlus;
4 | import me.darkolythe.deepstorageplus.dsu.StorageUtils;
5 | import me.darkolythe.deepstorageplus.dsu.managers.DSUManager;
6 | import me.darkolythe.deepstorageplus.dsu.managers.SorterManager;
7 | import me.darkolythe.deepstorageplus.utils.LanguageManager;
8 | import org.bukkit.Bukkit;
9 | import org.bukkit.ChatColor;
10 | import org.bukkit.Chunk;
11 | import org.bukkit.Material;
12 | import org.bukkit.block.Container;
13 | import org.bukkit.entity.Player;
14 | import org.bukkit.event.EventHandler;
15 | import org.bukkit.event.Listener;
16 | import org.bukkit.event.inventory.*;
17 | import org.bukkit.event.player.AsyncPlayerChatEvent;
18 | import org.bukkit.inventory.Inventory;
19 | import org.bukkit.inventory.ItemStack;
20 | import org.bukkit.inventory.meta.ItemMeta;
21 |
22 | import java.util.ArrayList;
23 | import java.util.Arrays;
24 | import java.util.List;
25 |
26 | import static me.darkolythe.deepstorageplus.dsu.StorageUtils.matToString;
27 | import static me.darkolythe.deepstorageplus.dsu.managers.SettingsManager.*;
28 |
29 | public class InventoryListener implements Listener {
30 |
31 | private DeepStoragePlus main;
32 | public InventoryListener(DeepStoragePlus plugin) {
33 | this.main = plugin; // set it equal to an instance of main
34 | }
35 |
36 | @EventHandler
37 | private void onStorageOpen(InventoryOpenEvent event) {
38 | if (event.getPlayer() instanceof Player) {
39 | Player player = (Player) event.getPlayer();
40 | if (event.getInventory().getSize() == 54) {
41 | if (event.getView().getTitle().equals(DeepStoragePlus.DSUname) || StorageUtils.isDSU(event.getInventory())) {
42 | ItemStack lock = event.getInventory().getItem(53);
43 | boolean isOp = player.hasPermission("deepstorageplus.adminopen");
44 | boolean isLocked = isLocked(lock);
45 | boolean canOpen = getLocked(lock, player);
46 |
47 | if (canOpen || isOp || !isLocked) {
48 | DeepStoragePlus.stashedDSU.put(player.getUniqueId(), event.getInventory());
49 | DeepStoragePlus.openDSU.put(player.getUniqueId(), (Container) event.getInventory().getLocation().getBlock().getState());
50 | DSUManager.verifyInventory(event.getInventory(), player);
51 | main.dsuupdatemanager.updateItems(event.getInventory(), null);
52 | return;
53 | }
54 | player.sendMessage(DeepStoragePlus.prefix + ChatColor.RED + LanguageManager.getValue("notallowedtoopen"));
55 | event.setCancelled(true);
56 | }
57 | else if (event.getView().getTitle().equals(DeepStoragePlus.sortername) || StorageUtils.isDSU(event.getInventory())) {
58 | SorterManager.verifyInventory(event.getInventory(), player);
59 | main.sorterUpdateManager.sortItems(event.getInventory(), DeepStoragePlus.minTimeSinceLastSortPlayer);
60 | }
61 | }
62 | }
63 | }
64 |
65 | @EventHandler
66 | private void onStorageInteract(InventoryClickEvent event) {
67 | if (event.getClickedInventory() != null) {
68 | if (event.getWhoClicked() instanceof Player) {
69 | Player player = (Player) event.getWhoClicked();
70 | Inventory inv = event.getInventory();
71 | ItemStack item = event.getCurrentItem();
72 | ItemStack cursor = event.getCursor();
73 |
74 | if (event.getView().getTitle().equals(DeepStoragePlus.DSUname) || StorageUtils.isDSU(inv)) {
75 | if (event.getClickedInventory() != player.getInventory()) {
76 | if (event.getSlot() % 9 == 8) { //rightmost column
77 | if (event.getSlot() != 53) { //if containers clicked
78 | if (cursor != null && cursor.getType() != Material.AIR) { //if putting container in
79 | if (item != null && item.getType() == Material.WHITE_STAINED_GLASS_PANE) {
80 | event.setCancelled(true);
81 | if (cursor.hasItemMeta()) { //if putting a Storage Container in the dsu
82 | if (cursor.getItemMeta().getDisplayName().contains(LanguageManager.getValue("storagecontainer")) && cursor.getItemMeta().isUnbreakable()) {
83 | inv.setItem(event.getSlot(), cursor);
84 | cursor.setAmount(0);
85 | main.dsuupdatemanager.updateItems(inv, null);
86 | }
87 | }
88 | } else { //if trying to take placeholder out
89 | if (!(cursor.hasItemMeta() && cursor.getItemMeta().getDisplayName().contains(LanguageManager.getValue("storagecontainer")) && cursor.getItemMeta().isUnbreakable())) {
90 | event.setCancelled(true);
91 | } else if (event.isShiftClick()) {
92 | event.setCancelled(true);
93 | }
94 | }
95 | } else { //if taking container out
96 | event.setCancelled(true);
97 | if (item != null && item.getType() != Material.WHITE_STAINED_GLASS_PANE) {
98 | player.setItemOnCursor(item.clone());
99 | inv.setItem(event.getSlot(), DSUManager.getEmptyBlock());
100 | main.dsuupdatemanager.updateItems(inv, null);
101 | }
102 | }
103 | } else { //if io is clicked
104 | event.setCancelled(true);
105 | if (cursor == null || cursor.getType() == Material.AIR) {
106 | if (item != null && item.hasItemMeta()) {
107 | if (item.getItemMeta().getDisplayName().contains(LanguageManager.getValue("dsuioconfig"))) { //BOTTOM RIGHT FOR SETTINGS
108 | player.openInventory(createIOInventory(inv));
109 | player.updateInventory();
110 | }
111 | }
112 | }
113 | }
114 | } else if (event.getSlot() % 9 == 7) { //walls
115 | event.setCancelled(true);
116 | } else { //items
117 | event.setCancelled(true);
118 | if (cursor != null && cursor.getType() != Material.AIR) {
119 | Material mat = cursor.getType();
120 | boolean isvaliditem = DSUManager.addToDSU(cursor, event.getClickedInventory(), player); //try to add item to dsu
121 |
122 | main.dsuupdatemanager.updateItems(inv, mat);
123 |
124 | if (cursor.getAmount() > 0 && isvaliditem) {
125 | player.sendMessage(DeepStoragePlus.prefix + ChatColor.RED.toString() + LanguageManager.getValue("containersfull"));
126 | }
127 | } else if (cursor == null || cursor.getType() == Material.AIR && item != null) { //taking item out of dsu
128 | if (event.getClick() != ClickType.DOUBLE_CLICK) {
129 | Material mat = item.getType();
130 | if (event.isShiftClick()) {
131 | if (player.getInventory().firstEmpty() != -1) {
132 | int amtTaken = DSUManager.takeItems(item.getType(), inv, item.getType().getMaxStackSize());
133 | player.getInventory().addItem(new ItemStack(item.getType(), amtTaken));
134 | } else {
135 | player.sendMessage(DeepStoragePlus.prefix + ChatColor.RED.toString() + LanguageManager.getValue("nomorespace"));
136 | }
137 | } else {
138 | int amtTaken = DSUManager.takeItems(item.getType(), inv, item.getType().getMaxStackSize());
139 | player.setItemOnCursor(new ItemStack(item.getType(), amtTaken));
140 | }
141 |
142 | main.dsuupdatemanager.updateItems(inv, mat);
143 | }
144 | }
145 | }
146 | } else { //if click is in player inventory
147 | if (event.isShiftClick()) {
148 | if (item != null && item.getType() != Material.AIR) {
149 | main.dsumanager.addItemToDSU(item, player);
150 | event.setCancelled(true);
151 | }
152 | } else if (event.getClick() == ClickType.DOUBLE_CLICK) {
153 | event.setCancelled(true);
154 | }
155 | }
156 |
157 | } else if (event.getView().getTitle().equals(DeepStoragePlus.sortername) || StorageUtils.isSorter(inv)) {
158 | if (event.getClickedInventory() != player.getInventory()) {
159 | if (event.getSlot() > 26) { // link module field
160 | if (cursor != null && cursor.getType() != Material.AIR) { //if putting container in
161 | if (item != null && item.getType() == Material.WHITE_STAINED_GLASS_PANE) {
162 | event.setCancelled(true);
163 | //if putting a link module into the sorter
164 | if (cursor.hasItemMeta() && cursor.getItemMeta().getDisplayName().contains(LanguageManager.getValue("linkmodule")) && cursor.getItemMeta().isUnbreakable()) {
165 | inv.setItem(event.getSlot(), cursor);
166 | cursor.setAmount(0);
167 | }
168 | } else { //if trying to take placeholder out
169 | if (!(cursor.hasItemMeta() && cursor.getItemMeta().getDisplayName().contains(LanguageManager.getValue("linkmodule")) && cursor.getItemMeta().isUnbreakable())) {
170 | event.setCancelled(true);
171 | } else if (event.isShiftClick()) {
172 | event.setCancelled(true);
173 | }
174 | }
175 | } else { //if taking link module out
176 | event.setCancelled(true);
177 | if (item != null && item.getType() != Material.WHITE_STAINED_GLASS_PANE) {
178 | player.setItemOnCursor(item.clone());
179 | inv.setItem(event.getSlot(), DSUManager.getEmptyBlock());
180 | }
181 | }
182 | } else if (event.getSlot() > 17 && event.getSlot() < 27) { //walls
183 | event.setCancelled(true);
184 | } else { //items
185 | if (cursor != null && cursor.getType() != Material.AIR) { //putting an item into the sorter
186 | main.sorterUpdateManager.sortItems(inv, DeepStoragePlus.minTimeSinceLastSortPlayer);
187 | }
188 | }
189 | }
190 | else { //if click is in player inventory
191 | if (event.isShiftClick()) {
192 | if (item != null && item.getType() != Material.AIR) {
193 | main.sorterUpdateManager.sortItems(inv, DeepStoragePlus.minTimeSinceLastSortPlayer);
194 | }
195 | }
196 | }
197 |
198 | } else if (event.getView().getTitle().equals(ChatColor.BLUE.toString() + ChatColor.BOLD.toString() + LanguageManager.getValue("dsuioconfig"))) {
199 | event.setCancelled(true);
200 | if (event.getSlot() == 8 || event.getSlot() == 17) {
201 | startSelection(event.getSlot(), inv);
202 | } else { //change selection and io items
203 | if (event.getSlot() % 9 != 8 && event.getSlot() % 9 != 7) {
204 | if (item != null) {
205 | for (int i = 0; i < inv.getContents().length; i++) {
206 | if (inv.getItem(i) != null && inv.getItem(i).getEnchantments().size() > 0) {
207 | //If the item clicked is one of the DSU items to choose an IO item
208 | ItemStack newitem = item.clone();
209 | ItemMeta itemmeta = newitem.getItemMeta();
210 | if (i == 8) {
211 | itemmeta.setDisplayName(ChatColor.GRAY + LanguageManager.getValue("input") + ": " + ChatColor.GREEN + matToString(newitem.getType()));
212 | } else {
213 | itemmeta.setDisplayName(ChatColor.GRAY + LanguageManager.getValue("output") + ": " + ChatColor.GREEN + matToString(newitem.getType()));
214 | }
215 | itemmeta.setLore(Arrays.asList(ChatColor.GRAY + LanguageManager.getValue("clicktoclear")));
216 | newitem.setItemMeta(itemmeta);
217 | inv.setItem(i, newitem);
218 | }
219 | }
220 | }
221 | } else { //change sorting types in io config
222 | if (item != null && item.getType() == Material.COMPASS) {
223 | if (event.getClick() != ClickType.DOUBLE_CLICK) {
224 | ItemMeta meta = item.getItemMeta();
225 | if (meta.getDisplayName().contains(LanguageManager.getValue("container"))) {
226 | meta.setDisplayName(meta.getDisplayName().replace(LanguageManager.getValue("container"), LanguageManager.getValue("alpha")));
227 | } else if (meta.getDisplayName().contains(LanguageManager.getValue("alpha"))) {
228 | meta.setDisplayName(meta.getDisplayName().replace(LanguageManager.getValue("alpha"), LanguageManager.getValue("amount")));
229 | } else if (meta.getDisplayName().contains(LanguageManager.getValue("amount"))) {
230 | meta.setDisplayName(meta.getDisplayName().replace(LanguageManager.getValue("amount"), "ID"));
231 | } else {
232 | meta.setDisplayName(meta.getDisplayName().replace("ID", LanguageManager.getValue("container")));
233 | }
234 | item.setItemMeta(meta);
235 | inv.setItem(event.getSlot(), item);
236 | }
237 | } else if (item != null && item.getType() == Material.TRIPWIRE_HOOK) {
238 | boolean isOwner = player.getUniqueId().toString().equals(getOwner(item)[1]);
239 | boolean isOp = player.hasPermission("deepstorageplus.adminopen");
240 | if (isOwner || isOp) { //only the owner or admin can edit the lock settings
241 | if (event.getClick() == ClickType.RIGHT) {
242 | ItemMeta meta = item.getItemMeta();
243 | meta.setLore(Arrays.asList(
244 | ChatColor.GRAY + LanguageManager.getValue("leftclicktoadd"),
245 | ChatColor.GRAY + LanguageManager.getValue("rightclicktoremove"),
246 | "",
247 | ChatColor.GRAY + LanguageManager.getValue("owner") + ": " + ChatColor.BLUE + getOwner(item)[0],
248 | ChatColor.GREEN + LanguageManager.getValue("unlocked")));
249 | item.setItemMeta(meta);
250 | } else if (event.getClick() == ClickType.LEFT) {
251 | player.sendMessage(DeepStoragePlus.prefix + ChatColor.GRAY + LanguageManager.getValue("entername"));
252 | player.sendMessage(ChatColor.GRAY + LanguageManager.getValue("typecancel"));
253 | DeepStoragePlus.stashedIO.put(player.getUniqueId(), inv);
254 | DeepStoragePlus.gettingInput.put(player.getUniqueId(), true);
255 | player.closeInventory();
256 | }
257 | } else {
258 | player.sendMessage(DeepStoragePlus.prefix + ChatColor.GRAY + LanguageManager.getValue("notowner"));
259 | }
260 | }
261 | }
262 | }
263 | }
264 | }
265 | }
266 | }
267 |
268 | @EventHandler
269 | private void onInventoryDrag(InventoryDragEvent event) {
270 | if (event.getView().getTitle().equals(DeepStoragePlus.DSUname) || StorageUtils.isDSU(event.getInventory())) {
271 | if (event.getWhoClicked() instanceof Player) {
272 | for (Integer slot : event.getRawSlots()) {
273 | if (slot <= 51) {
274 | event.setCancelled(true);
275 | }
276 | }
277 | }
278 | }
279 | }
280 |
281 | /*
282 | * Update DSU with IO settings when closing IO settings menu
283 | */
284 | @EventHandler
285 | private void onInventoryClose(InventoryCloseEvent event) {
286 | if (event.getPlayer() instanceof Player) {
287 | Player player = (Player) event.getPlayer();
288 | if (event.getView().getTitle().equals(ChatColor.BLUE.toString() + ChatColor.BOLD.toString() + LanguageManager.getValue("dsuioconfig"))) {
289 | Container DSUContainer = DeepStoragePlus.openDSU.get(player.getUniqueId());
290 | Inventory DSU = DSUContainer.getInventory();
291 |
292 | Inventory IOInv = event.getInventory();
293 | ItemStack input = IOInv.getItem(8);
294 | ItemStack output = IOInv.getItem(17);
295 | ItemStack sorting = IOInv.getItem(26);
296 | ItemStack lock = IOInv.getItem(53);
297 |
298 | int speedUpgrade = getSpeedUpgrade(DSU.getItem(53));
299 |
300 | List lore = new ArrayList<>();
301 |
302 | if (!input.getItemMeta().getDisplayName().contains(LanguageManager.getValue("all"))) {
303 | lore.add(ChatColor.GRAY + LanguageManager.getValue("input") + ": " + ChatColor.GREEN + matToString(input.getType()));
304 | } else {
305 | lore.add(ChatColor.GRAY + LanguageManager.getValue("input") + ": " + ChatColor.BLUE + LanguageManager.getValue("all"));
306 | }
307 | if (!output.getItemMeta().getDisplayName().contains(LanguageManager.getValue("none"))) {
308 | lore.add(ChatColor.GRAY + LanguageManager.getValue("output") + ": " + ChatColor.GREEN + matToString(output.getType()));
309 | } else {
310 | lore.add(ChatColor.GRAY + LanguageManager.getValue("output") + ": " + ChatColor.BLUE + LanguageManager.getValue("none"));
311 | }
312 | lore.add(sorting.getItemMeta().getDisplayName());
313 |
314 | lore.add(ChatColor.GRAY + LanguageManager.getValue("iospeed") + ": " + ChatColor.GREEN + "+" + speedUpgrade);
315 |
316 | lore.add(ChatColor.GRAY + LanguageManager.getValue("owner") + ": " + ChatColor.BLUE + getOwner(lock)[0]);
317 |
318 | List locklore = lock.getItemMeta().getLore();
319 | if (locklore.contains(ChatColor.RED + LanguageManager.getValue("locked"))) {
320 | lore.add(ChatColor.RED + LanguageManager.getValue("locked"));
321 | for (String s : getLockedUsers(lock)) {
322 | lore.add(ChatColor.WHITE + s);
323 | }
324 | } else {
325 | lore.add(ChatColor.GREEN + LanguageManager.getValue("unlocked"));
326 | }
327 |
328 | ItemStack i = DSU.getItem(53);
329 | ItemMeta m = i.getItemMeta();
330 | m.setLore(lore);
331 | i.setItemMeta(m);
332 |
333 | // Open the DSU's main inventory after the player closes the settings menu
334 | Bukkit.getServer().getScheduler().scheduleSyncDelayedTask(main, new Runnable() {
335 | @Override
336 | public void run() {
337 | if (DeepStoragePlus.gettingInput.containsKey(player.getUniqueId()) && !DeepStoragePlus.gettingInput.get(player.getUniqueId())) {
338 | player.openInventory(DSU);
339 | }
340 | }
341 | }, 1L);
342 | } else if (event.getView().getTitle().equals(DeepStoragePlus.DSUname) || StorageUtils.isDSU(event.getInventory())) {
343 | DeepStoragePlus.stashedDSU.remove(player.getUniqueId());
344 | if (DeepStoragePlus.loadedChunks.containsKey(player)) {
345 | Chunk c = DeepStoragePlus.loadedChunks.get(player);
346 | c.unload();
347 | DeepStoragePlus.loadedChunks.remove(player);
348 | }
349 | } else if (event.getView().getTitle().equals(DeepStoragePlus.sortername) || StorageUtils.isSorter(event.getInventory())) {
350 | main.sorterUpdateManager.sortItems(event.getInventory(), DeepStoragePlus.minTimeSinceLastSortPlayer);
351 | }
352 | }
353 | }
354 |
355 | @EventHandler
356 | public void onAsyncChat(AsyncPlayerChatEvent event) {
357 | Player player = event.getPlayer();
358 | if (DeepStoragePlus.gettingInput.containsKey(player.getUniqueId()) && DeepStoragePlus.gettingInput.get(player.getUniqueId())) {
359 | if (event.getMessage().equalsIgnoreCase("cancel")) {
360 | DeepStoragePlus.gettingInput.put(player.getUniqueId(), false);
361 | DeepStoragePlus.openIOInv.put(player, true);
362 | event.setCancelled(true);
363 | return;
364 | }
365 | Inventory openIO = main.stashedIO.get(player.getUniqueId());
366 | ItemStack lock = createDSULock(openIO);
367 | ItemMeta meta = lock.getItemMeta();
368 | List lore = meta.getLore();
369 | if (getLockedUsers(lock).size() == 0) {
370 | lore.set(lore.size() - 1, ChatColor.RED + LanguageManager.getValue("locked"));
371 | }
372 | lore.add(ChatColor.WHITE + event.getMessage());
373 | meta.setLore(lore);
374 | lock.setItemMeta(meta);
375 | openIO.setItem(53, lock);
376 |
377 | DeepStoragePlus.gettingInput.put(player.getUniqueId(), false);
378 | DeepStoragePlus.openIOInv.put(player, true);
379 |
380 | event.setCancelled(true);
381 | }
382 | }
383 |
384 | public void addText() {
385 | Bukkit.getServer().getScheduler().scheduleSyncRepeatingTask(main, new Runnable() {
386 | @Override
387 | public void run() {
388 | for (Player player : DeepStoragePlus.openIOInv.keySet()) {
389 | if (DeepStoragePlus.stashedIO.containsKey(player.getUniqueId())) {
390 | player.openInventory(DeepStoragePlus.stashedIO.get(player.getUniqueId()));
391 | DeepStoragePlus.openIOInv.remove(player);
392 | DeepStoragePlus.stashedIO.remove(player.getUniqueId());
393 | }
394 | }
395 | }
396 | }, 1L, 5L);
397 | }
398 | }
399 |
--------------------------------------------------------------------------------
/src/main/java/me/darkolythe/deepstorageplus/dsu/listeners/StorageBreakListener.java:
--------------------------------------------------------------------------------
1 | package me.darkolythe.deepstorageplus.dsu.listeners;
2 |
3 | import me.darkolythe.deepstorageplus.DeepStoragePlus;
4 | import me.darkolythe.deepstorageplus.dsu.StorageUtils;
5 | import me.darkolythe.deepstorageplus.dsu.managers.DSUManager;
6 | import me.darkolythe.deepstorageplus.dsu.managers.SorterManager;
7 | import me.darkolythe.deepstorageplus.utils.ItemList;
8 | import org.bukkit.Bukkit;
9 | import org.bukkit.Material;
10 | import org.bukkit.block.Container;
11 | import org.bukkit.block.DoubleChest;
12 | import org.bukkit.entity.Player;
13 | import org.bukkit.event.EventHandler;
14 | import org.bukkit.event.EventPriority;
15 | import org.bukkit.event.Listener;
16 | import org.bukkit.event.block.BlockBreakEvent;
17 | import org.bukkit.inventory.ItemStack;
18 |
19 | import static me.darkolythe.deepstorageplus.dsu.managers.SettingsManager.getLocked;
20 | import static me.darkolythe.deepstorageplus.dsu.managers.SettingsManager.getLockedUsers;
21 |
22 | public class StorageBreakListener implements Listener {
23 |
24 | DeepStoragePlus main;
25 | public StorageBreakListener(DeepStoragePlus plugin) {
26 | main = plugin;
27 | }
28 |
29 | @EventHandler (priority = EventPriority.HIGHEST)
30 | private void onStorageBreak(BlockBreakEvent event) {
31 | Player player = event.getPlayer();
32 | if (!event.isCancelled()) {
33 | if (event.getBlock().getState() instanceof Container) {
34 | Container chest = (Container) event.getBlock().getState();
35 | if (chest.getInventory().contains(DSUManager.getDSUWall()) || chest.getInventory().contains(SorterManager.getSorterWall())) {
36 |
37 | ItemStack lock = chest.getInventory().getItem(53);
38 | boolean isOp = player.hasPermission("deepstorageplus.adminopen");
39 | boolean canOpen = getLocked(lock, player);
40 | if (canOpen || isOp || getLockedUsers(lock).size() == 0) {
41 |
42 | DoubleChest doublechest = (DoubleChest) chest.getInventory().getHolder();
43 | event.setCancelled(true);
44 |
45 | Container chestLeft = (Container) doublechest.getLeftSide();
46 | Container chestRight = (Container) doublechest.getRightSide();
47 |
48 | removeItems(chestLeft);
49 | removeItems(chestRight);
50 | event.setDropItems(false);
51 | } else {
52 | event.setCancelled(true);
53 | }
54 | }
55 | }
56 | }
57 | }
58 |
59 | private void breakStorage(Container chest) {
60 | Bukkit.getServer().getScheduler().scheduleSyncDelayedTask(main, new Runnable() {
61 | @Override
62 | public void run() {
63 | chest.getWorld().getBlockAt(chest.getLocation()).setType(Material.AIR);
64 | }
65 | }, 1);
66 | chest.getWorld().dropItemNaturally(chest.getLocation(), new ItemStack(Material.CHEST, 1));
67 | }
68 |
69 | private void removeItems(Container chest) {
70 | chest.setCustomName(null);
71 | Bukkit.getServer().getScheduler().scheduleSyncDelayedTask(main, new Runnable() {
72 | @Override
73 | public void run() {
74 | emptyChest(chest);
75 | }
76 | }, 1);
77 | breakStorage(chest);
78 | }
79 |
80 | private static void emptyChest(Container chest) {
81 | if (StorageUtils.isSorter(chest.getInventory())) {
82 | chest.getInventory().addItem(ItemList.createSorterWrench());
83 | } else if (StorageUtils.isDSU(chest.getInventory())) {
84 | chest.getInventory().addItem(ItemList.createStorageWrench());
85 | }
86 | for (int i = 0; i < chest.getInventory().getContents().length; i++) {
87 | ItemStack item = chest.getInventory().getItem(i);
88 | if (item != null) {
89 | if (!(item.hasItemMeta() && (item.getType() == Material.STONE_AXE))) {
90 | chest.getInventory().setItem(i, null);
91 | } else {
92 | chest.getWorld().dropItemNaturally(chest.getLocation(), item);
93 | chest.getInventory().setItem(i, null);
94 | }
95 | }
96 | }
97 | }
98 | }
99 |
--------------------------------------------------------------------------------
/src/main/java/me/darkolythe/deepstorageplus/dsu/listeners/WirelessListener.java:
--------------------------------------------------------------------------------
1 | package me.darkolythe.deepstorageplus.dsu.listeners;
2 |
3 | import me.darkolythe.deepstorageplus.DeepStoragePlus;
4 | import me.darkolythe.deepstorageplus.dsu.managers.DSUManager;
5 | import me.darkolythe.deepstorageplus.utils.LanguageManager;
6 | import me.darkolythe.deepstorageplus.utils.RecipeManager;
7 | import org.bukkit.ChatColor;
8 | import org.bukkit.Chunk;
9 | import org.bukkit.Material;
10 | import org.bukkit.block.Block;
11 | import org.bukkit.block.Chest;
12 | import org.bukkit.block.Container;
13 | import org.bukkit.enchantments.Enchantment;
14 | import org.bukkit.entity.Player;
15 | import org.bukkit.event.EventHandler;
16 | import org.bukkit.event.EventPriority;
17 | import org.bukkit.event.Listener;
18 | import org.bukkit.event.block.Action;
19 | import org.bukkit.event.player.PlayerDropItemEvent;
20 | import org.bukkit.event.player.PlayerInteractEvent;
21 | import org.bukkit.event.player.PlayerSwapHandItemsEvent;
22 | import org.bukkit.inventory.Inventory;
23 | import org.bukkit.inventory.InventoryHolder;
24 | import org.bukkit.inventory.ItemFlag;
25 | import org.bukkit.inventory.ItemStack;
26 | import org.bukkit.inventory.meta.ItemMeta;
27 |
28 | import java.util.Arrays;
29 |
30 | import static me.darkolythe.deepstorageplus.dsu.managers.WirelessManager.*;
31 |
32 |
33 | public class WirelessListener implements Listener {
34 |
35 | private DeepStoragePlus main;
36 | public WirelessListener(DeepStoragePlus plugin) {
37 | this.main = plugin; // set it equal to an instance of main
38 | }
39 |
40 | @EventHandler(priority = EventPriority.HIGHEST)
41 | private void onDSUClick(PlayerInteractEvent event) {
42 | if (event.getAction() == Action.RIGHT_CLICK_BLOCK || event.getAction() == Action.RIGHT_CLICK_AIR) {
43 | Player player = event.getPlayer();
44 | Block block = event.getClickedBlock();
45 | if (block != null && block.getType() == Material.CHEST) {
46 | if (!event.isCancelled()) {
47 | Chest chest = (Chest) block.getState();
48 | if (chest.getInventory().contains(DSUManager.getDSUWall())) {
49 | ItemStack item = player.getInventory().getItemInMainHand();
50 | if (isWirelessTerminal(item)) {
51 | if (item.getItemMeta().getLore().contains(ChatColor.RED.toString() + ChatColor.BOLD.toString() + LanguageManager.getValue("unlinked"))) {
52 | event.setCancelled(true);
53 | updateTerminal(item, block.getX(), block.getY(), block.getZ(), block.getWorld());
54 | return;
55 | }
56 | }
57 | }
58 | }
59 | }
60 | if (block == null || !(block.getState() instanceof InventoryHolder)) {
61 | ItemStack hand = player.getInventory().getItemInMainHand();
62 | if (isWirelessTerminal(hand)) {
63 | if (hand.getItemMeta().getLore().contains(ChatColor.GREEN.toString() + ChatColor.BOLD.toString() + LanguageManager.getValue("linked"))) {
64 | Inventory dsu = getWirelessDSU(hand, player);
65 | if (dsu != null) {
66 | if (player.hasPermission("deepstorageplus.wireless")) {
67 | event.setCancelled(true);
68 | player.openInventory(dsu);
69 | Chunk c = dsu.getLocation().getChunk();
70 | c.setForceLoaded(true);
71 | DeepStoragePlus.loadedChunks.put(player, c);
72 | } else {
73 | player.sendMessage(DeepStoragePlus.prefix + ChatColor.RED + LanguageManager.getValue("nowirelesspermission"));
74 | }
75 | }
76 | }
77 | }
78 | }
79 | }
80 | }
81 |
82 | @EventHandler
83 | private void onTerminalSwap(PlayerSwapHandItemsEvent event) {
84 | ItemStack item = event.getOffHandItem();
85 | if (event.getPlayer().isSneaking()) {
86 | if (isWirelessTerminal(item)) {
87 | if (item.getItemMeta().getLore().get(0).equals(ChatColor.GREEN.toString() + ChatColor.BOLD.toString() + LanguageManager.getValue("linked"))) {
88 | String name = item.getItemMeta().getDisplayName();
89 | ItemStack newitem = createTerminal();
90 | ItemMeta meta = newitem.getItemMeta();
91 | meta.setDisplayName(name);
92 | newitem.setItemMeta(meta);
93 | event.getPlayer().getInventory().setItemInMainHand(newitem);
94 |
95 | event.setCancelled(true);
96 | }
97 | }
98 | }
99 | }
100 | }
101 |
--------------------------------------------------------------------------------
/src/main/java/me/darkolythe/deepstorageplus/dsu/listeners/WrenchListener.java:
--------------------------------------------------------------------------------
1 | package me.darkolythe.deepstorageplus.dsu.listeners;
2 |
3 | import me.darkolythe.deepstorageplus.DeepStoragePlus;
4 | import me.darkolythe.deepstorageplus.utils.ItemList;
5 | import me.darkolythe.deepstorageplus.utils.LanguageManager;
6 | import org.bukkit.Bukkit;
7 | import org.bukkit.ChatColor;
8 | import org.bukkit.Material;
9 | import org.bukkit.block.*;
10 | import org.bukkit.entity.Player;
11 | import org.bukkit.event.EventHandler;
12 | import org.bukkit.event.EventPriority;
13 | import org.bukkit.event.Listener;
14 | import org.bukkit.event.block.Action;
15 | import org.bukkit.event.entity.ItemMergeEvent;
16 | import org.bukkit.event.player.PlayerInteractEvent;
17 | import org.bukkit.inventory.Inventory;
18 | import org.bukkit.inventory.ItemStack;
19 | import org.bukkit.inventory.meta.ItemMeta;
20 |
21 | import java.util.Arrays;
22 | import java.util.Optional;
23 |
24 | public class WrenchListener implements Listener {
25 |
26 | private DeepStoragePlus main;
27 | public WrenchListener(DeepStoragePlus plugin) {
28 | main = plugin;
29 | }
30 |
31 | @EventHandler (priority = EventPriority.HIGHEST)
32 | private void onWrenchUse(PlayerInteractEvent event) {
33 | if (event.getAction() == Action.RIGHT_CLICK_BLOCK) {
34 | Player player = event.getPlayer();
35 | ItemStack storageWrench = ItemList.createStorageWrench();
36 | ItemStack sorterWrench = ItemList.createSorterWrench();
37 | ItemStack linkModule = ItemList.createLinkModule();
38 |
39 | Block block = event.getClickedBlock();
40 | if (player.getInventory().getItemInMainHand().equals(storageWrench)
41 | || player.getInventory().getItemInMainHand().equals(sorterWrench)) {
42 | if (block != null && block.getType() == Material.CHEST) {
43 | if (player.hasPermission("deepstorageplus.create")) {
44 | if (!event.isCancelled()) {
45 | event.setCancelled(true);
46 | if (isInventoryEmpty(block)) {
47 | if (sizeOfInventory(block) == 54) {
48 | if (player.getInventory().getItemInMainHand().equals(storageWrench)) {
49 | createDSU(block);
50 | player.getInventory().getItemInMainHand().setAmount(0);
51 | player.sendMessage(DeepStoragePlus.prefix + ChatColor.GREEN + LanguageManager.getValue("dsucreate"));
52 | } else if (player.getInventory().getItemInMainHand().equals(sorterWrench)) {
53 | createSorter(block);
54 | player.getInventory().getItemInMainHand().setAmount(0);
55 | player.sendMessage(DeepStoragePlus.prefix + ChatColor.GREEN + LanguageManager.getValue("sortercreate"));
56 | }
57 | } else {
58 | player.sendMessage(DeepStoragePlus.prefix + ChatColor.RED + LanguageManager.getValue("chestmustbedouble"));
59 | }
60 | } else {
61 | player.sendMessage(DeepStoragePlus.prefix + ChatColor.RED + LanguageManager.getValue("chestmustbeempty"));
62 | }
63 | }
64 | } else {
65 | player.sendMessage(DeepStoragePlus.prefix + ChatColor.RED + LanguageManager.getValue("nopermission"));
66 | }
67 | }
68 | }
69 |
70 |
71 | if (ItemList.compareItem(player.getInventory().getItemInMainHand(), linkModule)) {
72 | if (block != null && block.getType() == Material.CHEST) {
73 | if (!event.isCancelled()) {
74 | event.setCancelled(true);
75 | if (isDSU(block) || isSorter(block)) {
76 | ItemMeta linkModuleMeta = player.getInventory().getItemInMainHand().getItemMeta();
77 | linkModuleMeta.setLore(Arrays.asList(ChatColor.BLUE + String.format("%s %s %s %s", block.getWorld().getName(), block.getX(), block.getY(), block.getZ())));
78 | player.getInventory().getItemInMainHand().setItemMeta(linkModuleMeta);
79 | player.sendMessage(DeepStoragePlus.prefix + ChatColor.GREEN + "DSU Coordinates Saved");
80 | } else {
81 | player.sendMessage(DeepStoragePlus.prefix + ChatColor.RED + "This is not a DSU");
82 | }
83 | }
84 | }
85 | }
86 | }
87 | }
88 |
89 | private static boolean isInventoryEmpty(Block block) {
90 | Inventory inv = getInventoryFromBlock(block);
91 | for (int i = 0; i < inv.getSize(); i++) {
92 | if (inv.getItem(i) != null) {
93 | return false;
94 | }
95 | }
96 | return true;
97 | }
98 |
99 | private static int sizeOfInventory(Block block) {
100 | Inventory inv = getInventoryFromBlock(block);
101 | return inv.getSize();
102 | }
103 |
104 | private void createDSU(Block block) {
105 | Chest chest = (Chest) block.getState();
106 | chest.setCustomName(DeepStoragePlus.DSUname);
107 | chest.update();
108 | }
109 |
110 | private boolean isDSU(Block block) {
111 | Chest chest = (Chest) block.getState();
112 | if (chest.getInventory().getHolder() instanceof DoubleChest) {
113 | DoubleChest doubleChest = (DoubleChest) chest.getInventory().getHolder();
114 | Chest leftChest = (Chest) doubleChest.getLeftSide();
115 | Chest rightChest = (Chest) doubleChest.getRightSide();
116 | return (leftChest.getCustomName() != null && leftChest.getCustomName().equals(DeepStoragePlus.DSUname)) ||
117 | (rightChest.getCustomName() != null && rightChest.getCustomName().equals(DeepStoragePlus.DSUname));
118 | }
119 | return chest.getCustomName() != null && chest.getCustomName().equals(DeepStoragePlus.DSUname);
120 | }
121 |
122 | private void createSorter(Block block) {
123 | Chest chest = (Chest) block.getState();
124 | chest.setCustomName(DeepStoragePlus.sortername);
125 | chest.update();
126 | }
127 |
128 | private boolean isSorter(Block block) {
129 | Chest chest = (Chest) block.getState();
130 | if (chest.getInventory().getHolder() instanceof DoubleChest) {
131 | DoubleChest doubleChest = (DoubleChest) chest.getInventory().getHolder();
132 | Chest leftChest = (Chest) doubleChest.getLeftSide();
133 | Chest rightChest = (Chest) doubleChest.getRightSide();
134 | return (leftChest.getCustomName() != null && leftChest.getCustomName().equals(DeepStoragePlus.sortername)) ||
135 | (rightChest.getCustomName() != null && rightChest.getCustomName().equals(DeepStoragePlus.sortername));
136 | }
137 | return chest.getCustomName() != null && chest.getCustomName().equals(DeepStoragePlus.sortername);
138 | }
139 |
140 | private static Inventory getInventoryFromBlock(Block block) {
141 | BlockState bs = block.getState();
142 | Chest chest = (Chest) bs;
143 | return chest.getInventory();
144 | }
145 | }
146 |
--------------------------------------------------------------------------------
/src/main/java/me/darkolythe/deepstorageplus/dsu/managers/DSUManager.java:
--------------------------------------------------------------------------------
1 | package me.darkolythe.deepstorageplus.dsu.managers;
2 |
3 | import de.tr7zw.changeme.nbtapi.NBTItem;
4 | import me.darkolythe.deepstorageplus.DeepStoragePlus;
5 | import me.darkolythe.deepstorageplus.utils.LanguageManager;
6 | import org.bukkit.ChatColor;
7 | import org.bukkit.Material;
8 | import org.bukkit.entity.Player;
9 | import org.bukkit.inventory.Inventory;
10 | import org.bukkit.inventory.ItemFlag;
11 | import org.bukkit.inventory.ItemStack;
12 | import org.bukkit.inventory.meta.ItemMeta;
13 |
14 | import java.util.*;
15 |
16 | import static me.darkolythe.deepstorageplus.dsu.StorageUtils.*;
17 |
18 | public class DSUManager {
19 |
20 | DeepStoragePlus main;
21 | public DSUManager(DeepStoragePlus plugin) {
22 | main = plugin;
23 | }
24 |
25 | /*
26 | Add an item to the dsu
27 | */
28 | public void addItemToDSU(ItemStack item, Player player) {
29 | Material mat = item.getType();
30 | boolean isvaliditem = addToDSU(item, player.getOpenInventory().getTopInventory(), player); //try to add item to dsu
31 | main.dsuupdatemanager.updateItems(player.getOpenInventory().getTopInventory(), mat);
32 | if (item.getAmount() > 0 && isvaliditem) {
33 | player.sendMessage(DeepStoragePlus.prefix + ChatColor.RED.toString() + LanguageManager.getValue("containersfull"));
34 | }
35 | }
36 |
37 | /*
38 | Create the dsu inventory and make it so that it's correct upon opening
39 | */
40 | public static void verifyInventory(Inventory inv, Player player) {
41 | for (int i = 0; i < 6; i++) {
42 | inv.setItem(7 + (9 * i), getDSUWall());
43 | }
44 |
45 | for (int i = 0; i < 5; i++) {
46 | if (inv.getItem(8 + (9 * i)) == null) {
47 | inv.setItem(8 + (9 * i), getEmptyBlock());
48 | }
49 | }
50 |
51 | ItemStack IOItem = inv.getItem(53);
52 | if (IOItem == null
53 | || !IOItem.hasItemMeta()
54 | || !IOItem.getItemMeta().hasDisplayName()
55 | || !IOItem.getItemMeta().getDisplayName().equals(ChatColor.WHITE + LanguageManager.getValue("dsuioconfig"))) {
56 | inv.setItem(53, createIOItem(player));
57 | }
58 | }
59 |
60 | public static ItemStack createIOItem(Player player) {
61 | ItemStack settings = new ItemStack(Material.REDSTONE);
62 | ItemMeta settingsmeta = settings.getItemMeta();
63 | settingsmeta.setDisplayName(ChatColor.WHITE + ChatColor.stripColor(LanguageManager.getValue("dsuioconfig")));
64 | settingsmeta.setLore(Arrays.asList(ChatColor.GRAY + LanguageManager.getValue("input") + ": " + ChatColor.BLUE + LanguageManager.getValue("all"),
65 | ChatColor.GRAY + LanguageManager.getValue("output") + ": " + ChatColor.BLUE + LanguageManager.getValue("none"),
66 | ChatColor.GRAY + LanguageManager.getValue("sortingby") + ": " + ChatColor.BLUE + LanguageManager.getValue("container"),
67 | ChatColor.GRAY + LanguageManager.getValue("owner") + ": " + ChatColor.BLUE + player.getName(),
68 | ChatColor.RED + LanguageManager.getValue("locked")));
69 |
70 | // set texture data ID
71 | settingsmeta.setCustomModelData(13003);
72 |
73 | settings.setItemMeta(settingsmeta);
74 |
75 | NBTItem nbt = new NBTItem(settings);
76 | nbt.setString("dsu_owner_uuid", player.getUniqueId().toString());
77 | settings = nbt.getItem();
78 |
79 | return settings;
80 | }
81 |
82 |
83 | private static ItemStack dsuWall;
84 | /*
85 | Create a dsu Wall item to fill the dsu Inventory
86 | */
87 | public static ItemStack getDSUWall() {
88 | if (dsuWall != null)
89 | return dsuWall;
90 | ItemStack border = new ItemStack(Material.BLACK_STAINED_GLASS_PANE);
91 | ItemMeta bordermeta = border.getItemMeta();
92 | bordermeta.setDisplayName(ChatColor.DARK_GRAY + LanguageManager.getValue("dsuwalls"));
93 | border.setItemMeta(bordermeta);
94 |
95 | return dsuWall = border;
96 | }
97 |
98 | /*
99 | Create an Empty Block item to fill the dsu Inventory
100 | */
101 | public static ItemStack getEmptyBlock() {
102 | ItemStack storage = new ItemStack(Material.WHITE_STAINED_GLASS_PANE);
103 | ItemMeta storagemeta = storage.getItemMeta();
104 | storagemeta.setDisplayName(ChatColor.YELLOW + LanguageManager.getValue("emptystorageblock"));
105 | storage.setItemMeta(storagemeta);
106 |
107 | return storage;
108 | }
109 |
110 | /*
111 | Get the remaining data in a container by passing it a type field. Data or Type. (not literal strings)
112 | */
113 | private static int countStorage(ItemStack container, String typeString) {
114 | int spaceTotal = 0;
115 | int spaceCur = 0;
116 | if (container != null && container.hasItemMeta() && container.getItemMeta().hasLore()) {
117 | ItemMeta meta = container.getItemMeta();
118 | List lore = meta.getLore();
119 | for (String l : lore) {
120 | if (l.contains(typeString)) {
121 | String data = getData(l);
122 | spaceCur += getCurrentData(data);
123 | spaceTotal += getMaxData(data);
124 | }
125 | }
126 | }
127 | return spaceTotal - spaceCur;
128 | }
129 |
130 | /*
131 | Get the data portion of the lore string. Format: Type: data
132 | */
133 | private static String getData(String lore) {
134 | int spaceAt = -1;
135 | String data = "";
136 | boolean foundColon = false;
137 | for (int z = 0; z < lore.length(); z++) {
138 | if (spaceAt != -1) {
139 | data += lore.charAt(z);
140 | }
141 | if (lore.charAt(z) == ' ' && foundColon) {
142 | spaceAt = z;
143 | }
144 | if (lore.charAt(z) == ':') {
145 | foundColon = true;
146 | }
147 | }
148 | return data;
149 | }
150 |
151 | /*
152 | Get the current data in the storage info format: Type: cur/max
153 | */
154 | private static int getCurrentData(String data) {
155 | String curData = "";
156 | int slashAt = -1;
157 | for (int z = 0; z < data.length(); z++) {
158 | if (data.charAt(z) == '/') {
159 | slashAt = z;
160 | }
161 | if (slashAt == -1) {
162 | curData += data.charAt(z);
163 | }
164 | }
165 | return Integer.parseInt(curData);
166 | }
167 |
168 | /*
169 | Get the max data in the storage info format: Type: cur/max
170 | */
171 | private static int getMaxData(String data) {
172 | String maxData = "";
173 | int slashAt = -1;
174 | for (int z = 0; z < data.length(); z++) {
175 | if (slashAt != -1) {
176 | maxData += data.charAt(z);
177 | }
178 | if (data.charAt(z) == '/') {
179 | slashAt = z;
180 | }
181 | }
182 | return Integer.parseInt(maxData);
183 | }
184 |
185 | /*
186 | Get the list of types that a container has
187 | */
188 | public static HashSet getTypes(List lore) {
189 | LinkedHashSet list = new LinkedHashSet<>();
190 | if (lore == null) {
191 | return list;
192 | }
193 | for (String str : lore) {
194 | if (str.contains(" - ") && !str.contains(LanguageManager.getValue("empty"))) {
195 | Material mat = getType(str);
196 | if (mat != null) {
197 | list.add(mat);
198 | }
199 | }
200 | }
201 | return list;
202 | }
203 |
204 | /*
205 | Get the type of Material from a specific lore line of a Storage Container
206 | */
207 | private static Material getType(String lore) {
208 | String mat = "";
209 | String[] strl = lore.replace(ChatColor.WHITE + " - ", "").split("\\s+");
210 | for (String s : strl) {
211 | if (!s.equals(strl[strl.length - 1])) {
212 | mat += s + " ";
213 | }
214 | }
215 | return Material.getMaterial(mat.trim().replaceAll(" ", "_").toUpperCase());
216 | }
217 |
218 | /*
219 | Update the container with the itemstack being added
220 | */
221 | public static void addDataToContainer(ItemStack container, ItemStack item) {
222 | if (container.hasItemMeta() && container.getItemMeta().hasDisplayName() && container.getItemMeta().getDisplayName().contains(LanguageManager.getValue("storagecontainer"))) {
223 | Material mat = item.getType();
224 | int amount = item.getAmount();
225 |
226 | int storage = countStorage(container, LanguageManager.getValue("currentstorage") + ": ");
227 | int types = countStorage(container, LanguageManager.getValue("currenttypes") + ": ");
228 | HashSet mats = getTypes(container.getItemMeta().getLore());
229 | int canAdd = Math.min(storage, amount);
230 | if (mats.contains(mat)) { //if the material is already stored in the container
231 | editContainerTypeAmount(container, mat, amount); //update material storage amount
232 | editContainerStorage(container, canAdd, LanguageManager.getValue("currentstorage") + ": "); //update data storage amt
233 | item.setAmount(amount - canAdd); //update item amount. if this is not 0 in the main loop, it means this container ran out of memory - IMPORTANT TO NOTE <--------------------
234 | } else { //if the material isnt currently being stored in the container
235 | if (types > 0 && (getMaxData(getData(container.getItemMeta().getLore().get(0))) - getCurrentData(getData(container.getItemMeta().getLore().get(0))) > 0)) {
236 | editContainerTypes(container, item); //add the material type to the container
237 | editContainerStorage(container, canAdd, LanguageManager.getValue("currentstorage") + ": "); //add amt to data storage
238 | editContainerStorage(container, 1, LanguageManager.getValue("currenttypes") + ": "); //add 1 to types
239 | item.setAmount(amount - canAdd);
240 | }
241 | }
242 | }
243 | }
244 |
245 | /*
246 | This method loops until the item trying to be added is either done being added, or the containers run out of memory.
247 | */
248 | public static boolean addToDSU(ItemStack toAdd, Inventory inv, Player player) {
249 | if (hasNoMeta(toAdd)) { //items being stored cannot have any special features. ie: damage, enchants, name, lore.
250 | for (int i = 0; i < 5; i++) {
251 | if (toAdd.getAmount() > 0) { //if the item amount is greater than 0, it means there are still items to put in the containers
252 | addDataToContainer(inv.getItem(8 + (9 * i)), toAdd); //add the item to the current loop container
253 | } else {
254 | break;
255 | }
256 | }
257 | player.updateInventory();
258 | } else {
259 | player.sendMessage(DeepStoragePlus.prefix + ChatColor.RED + LanguageManager.getValue("onlydefaultitems"));
260 | return false;
261 | }
262 | return true;
263 | }
264 |
265 | /*
266 | This method loops until the item trying to be added is either done being added, or the containers run out of memory.
267 | */
268 | public static boolean addToDSUSilent(ItemStack toAdd, Inventory inv) {
269 | if (hasNoMeta(toAdd)) { //items being stored cannot have any special features. ie: damage, enchants, name, lore.
270 | for (int i = 0; i < 5; i++) {
271 | ItemStack container = inv.getItem(8 + (9 * i));
272 | if (container == null) {
273 | continue;
274 | }
275 | addDataToContainer(container, toAdd); //add the item to the current loop container
276 | if (toAdd.getAmount() < 1) { //if the item amount is greater than 0, it means there are still items to put in the containers
277 | break;
278 | }
279 | }
280 | } else {
281 | return false;
282 | }
283 | return true;
284 | }
285 |
286 | /*
287 | Update the storage info on the container with the type, amt being added, and container being edited.
288 | */
289 | private static void editContainerStorage(ItemStack container, int amt, String type) {
290 | ItemMeta meta = container.getItemMeta();
291 | List lore = meta.getLore();
292 | String data;
293 | if (type.equals(LanguageManager.getValue("currentstorage") + ": ")) { //edit the line of lore depending on which storage field is being edited
294 | data = getData(meta.getLore().get(0));
295 | } else {
296 | data = getData(meta.getLore().get(1));
297 | }
298 | int curAmt = getCurrentData(data);
299 | int maxAmt = getMaxData(data);
300 | curAmt += amt;
301 | String colourStorage; //Edit the colour of the storage tag based on how much storage is available
302 | if (curAmt < (maxAmt / 2) + 1) {
303 | colourStorage = ChatColor.GREEN.toString();
304 | } else if (curAmt < maxAmt) {
305 | colourStorage = ChatColor.YELLOW.toString();
306 | } else {
307 | colourStorage = ChatColor.RED.toString();
308 | }
309 | if (type.equals(LanguageManager.getValue("currentstorage") + ": ")) {
310 | lore.set(0, colourStorage + type + curAmt + "/" + maxAmt);
311 | } else {
312 | lore.set(1, colourStorage + type + curAmt + "/" + maxAmt);
313 | }
314 | meta.setLore(lore);
315 | container.setItemMeta(meta);
316 | }
317 |
318 | /*
319 | This method adds a new material type to the container and sets the ammount
320 | */
321 | private static void editContainerTypes(ItemStack container, ItemStack item) {
322 | Material mat = item.getType();
323 | ItemMeta meta = container.getItemMeta();
324 | List lore = meta.getLore();
325 | for (int i = 2; i < DeepStoragePlus.maxTypes + 2; i++) {
326 | if (lore.get(i).contains(LanguageManager.getValue("empty"))) { //find the first empty material type and update it to the new material
327 | int curStorage = countStorage(container, LanguageManager.getValue("currentstorage") + ": ");
328 | lore.set(i, ChatColor.WHITE.toString() + " - " + matToString(mat) + " " + Math.min(item.getAmount(), curStorage));
329 | meta.setLore(lore);
330 | container.setItemMeta(meta);
331 | return;
332 | }
333 | }
334 | }
335 |
336 | /*
337 | Edit the amount of a certain material being stored in a container.
338 | */
339 | private static void editContainerTypeAmount(ItemStack container, Material mat, int amt) {
340 | ItemMeta meta = container.getItemMeta();
341 | List lore = meta.getLore();
342 | for (int i = 2; i < DeepStoragePlus.maxTypes + 2; i++) {
343 | String cleanLore = lore.get(i).replace(ChatColor.WHITE.toString(), "").replace(" - ", "");
344 | if (!lore.get(i).contains(" - " + LanguageManager.getValue("empty")) && cleanLore.equals(matToString(mat) + " " + getMaterialAmount(lore.get(i)))) {
345 | String loreStr = lore.get(i);
346 | int curStorage = countStorage(container, LanguageManager.getValue("currentstorage") + ": ");
347 | int newAmt = getMaterialAmount(loreStr) + Math.min(amt, curStorage);
348 | if (newAmt > 0) {
349 | lore.set(i, ChatColor.WHITE.toString() + " - " + matToString(mat) + " " + newAmt);
350 | } else {
351 | lore.set(i, ChatColor.GRAY + " - " + LanguageManager.getValue("empty")); //if an item is completely removed from the container, set the type to empty
352 | }
353 | meta.setLore(lore);
354 | container.setItemMeta(meta);
355 | if (newAmt <= 0) {
356 | editContainerStorage(container, -1, LanguageManager.getValue("currenttypes") + ": "); //and then remove the type count from the counter. Must be done after meta is saved.
357 | }
358 | return;
359 | }
360 | }
361 | }
362 |
363 | /*
364 | Get the amount of material being stored on the one line of lore in a container
365 | */
366 | private static int getMaterialAmount(String str) {
367 | int len = str.split("\\s+").length;
368 | String matAmt = str.split("\\s+")[len - 1];
369 | return Integer.parseInt(matAmt);
370 | }
371 |
372 | public static int getTotalMaterialAmount(Inventory inv, Material mat) {
373 | int amount = 0;
374 | for (int i = 0; i < 5; i++) {
375 | ItemStack container = inv.getItem(8 + (9 * i));
376 | if (container != null && container.getItemMeta() != null && container.getItemMeta().hasLore()) {
377 | for (String lore : container.getItemMeta().getLore()) {
378 | if (!lore.contains(" - " + LanguageManager.getValue("empty")) && lore.contains("-")) {
379 | if (lore.contains(" - " + matToString(mat) + " " + getMaterialAmount(lore))) {
380 | amount += getMaterialAmount(lore);
381 | }
382 | }
383 | }
384 | }
385 | }
386 | return amount;
387 | }
388 |
389 | /*
390 | Get a complete list of types in a DSU
391 | */
392 | public static Set getTotalTypes(Inventory dsu) {
393 | LinkedHashSet list = new LinkedHashSet<>();
394 | for (int i = 0; i < 5; i++) {
395 | ItemStack container = dsu.getItem(8 + (9 * i));
396 | if (container != null && container.getItemMeta() != null && container.getItemMeta().getDisplayName().contains(LanguageManager.getValue("storagecontainer"))) {
397 | HashSet mats = DSUManager.getTypes(container.getItemMeta().getLore());
398 | list.addAll(mats);
399 | }
400 | }
401 | return list;
402 | }
403 |
404 | public static boolean dsuContainsType(Inventory dsu, Material material) {
405 | for (int i = 0; i < 5; i++) {
406 | ItemStack container = dsu.getItem(8 + (9 * i));
407 | if (container != null && container.getItemMeta() != null && container.getItemMeta().getDisplayName().contains(LanguageManager.getValue("storagecontainer"))) {
408 | HashSet mats = DSUManager.getTypes(container.getItemMeta().getLore());
409 | if (mats.contains(material)) {
410 | return true;
411 | }
412 | }
413 | }
414 | return false;
415 | }
416 |
417 | /*
418 | Calculate how many items the player can take of a specific Material (max of the stack size of the Material). Remove that count from containers, and give it to the player.
419 | */
420 | public static int takeItems(Material mat, Inventory inv, int amt) {
421 | int amount = 0;
422 | int amountTaken = 0;
423 | for (int i = 4; i >= 0; i--) {
424 | if (mat != null) {
425 | if (amount != amt) {
426 | ItemStack container = inv.getItem(8 + (9 * i));
427 | if (container.hasItemMeta() && container.getItemMeta().hasDisplayName() && container.getItemMeta().getDisplayName().contains(LanguageManager.getValue("storagecontainer"))) {
428 | for (int x = 2; x < DeepStoragePlus.maxTypes + 2; x++) {
429 | if (getType(container.getItemMeta().getLore().get(x)) == mat) {
430 | amount = Math.min(amount + getMaterialAmount(container.getItemMeta().getLore().get(x)), amt);
431 | editContainerTypeAmount(container, mat, -Math.min(getMaterialAmount(container.getItemMeta().getLore().get(x)), amt - amountTaken));
432 | editContainerStorage(container, amountTaken - amount, LanguageManager.getValue("currentstorage") + ": ");
433 | amountTaken += amount - amountTaken;
434 | break;
435 | }
436 | }
437 | }
438 | } else {
439 | break;
440 | }
441 | }
442 | }
443 | return amount;
444 | }
445 | }
446 |
--------------------------------------------------------------------------------
/src/main/java/me/darkolythe/deepstorageplus/dsu/managers/DSUUpdateManager.java:
--------------------------------------------------------------------------------
1 | package me.darkolythe.deepstorageplus.dsu.managers;
2 |
3 | import me.darkolythe.deepstorageplus.DeepStoragePlus;
4 | import me.darkolythe.deepstorageplus.utils.LanguageManager;
5 | import org.bukkit.Bukkit;
6 | import org.bukkit.ChatColor;
7 | import org.bukkit.Material;
8 | import org.bukkit.inventory.Inventory;
9 | import org.bukkit.inventory.ItemStack;
10 | import org.bukkit.inventory.meta.ItemMeta;
11 |
12 | import java.util.*;
13 |
14 | public class DSUUpdateManager {
15 |
16 | private DeepStoragePlus main;
17 | public DSUUpdateManager(DeepStoragePlus plugin) {
18 | main = plugin;
19 | }
20 |
21 | /*
22 | Update the items in the dsu. This is done when items are added, taken, Storage Containers are added, taken, and when opening the dsu.
23 | */
24 | public void updateItems(Inventory inv, Material mat) {
25 | if (inv.getLocation() == null) {
26 | return;
27 | }
28 | if (!DeepStoragePlus.recentDSUCalls.containsKey(inv.getLocation())) {
29 | DeepStoragePlus.recentDSUCalls.put(inv.getLocation(), 0L);
30 | }
31 | Bukkit.getServer().getScheduler().scheduleSyncDelayedTask(main, new Runnable() {
32 | @Override
33 | public void run() {
34 | // if over a second has passed since the last bulk item was placed in the dsu, update it
35 | if (!DeepStoragePlus.recentDSUCalls.containsKey(inv.getLocation())) {
36 | return;
37 | }
38 | if (System.currentTimeMillis() - DeepStoragePlus.recentDSUCalls.get(inv.getLocation()) < 200) {
39 | return;
40 | }
41 |
42 | DeepStoragePlus.recentDSUCalls.put(inv.getLocation(), System.currentTimeMillis());
43 |
44 | if (mat != null && DSUManager.getTotalTypes(inv).contains(mat)) {
45 | for (int i = 0; i < 54; i++) {
46 | if (i % 9 != 8 && i % 9 != 7) {
47 | if (inv.getItem(i) == null || inv.getItem(i).getType() == Material.AIR) {
48 | break;
49 | }
50 | if (inv.getItem(i).getType() == mat) {
51 | inv.setItem(i, createItem(inv.getItem(i).getType(), inv));
52 | return;
53 | }
54 | }
55 | }
56 | }
57 |
58 | for (UUID key : DeepStoragePlus.stashedDSU.keySet()) {
59 | Inventory openInv = DeepStoragePlus.openDSU.get(key).getInventory();
60 | if (inv.getItem(8).equals(openInv.getItem(8))) {
61 | sortInventory(inv);
62 | return;
63 | }
64 | }
65 | }
66 | }, 5L);
67 | }
68 |
69 | private void sortInventory(Inventory inv) {
70 | ItemStack IOSettings = inv.getItem(53);
71 | if (IOSettings != null && IOSettings.hasItemMeta() && IOSettings.getItemMeta().hasLore()) {
72 | String sort = IOSettings.getItemMeta().getLore().get(2).replace(ChatColor.GRAY + LanguageManager.getValue("sortingby") + ": " + ChatColor.BLUE, "");
73 |
74 | if (sort.equals(LanguageManager.getValue("container"))) {
75 | clearItems(inv);
76 | addNewItems(inv);
77 | } else if (sort.equals(LanguageManager.getValue("amount"))) {
78 | clearItems(inv);
79 | Map data = new HashMap<>();
80 | List mats = getMats(inv);
81 | for (Material m : mats) {
82 | data.put(m, (double) DSUManager.getTotalMaterialAmount(inv, m));
83 | }
84 | int dataAmount = data.keySet().size();
85 | for (int i = 0; i < dataAmount; i++) {
86 | double top = 0;
87 | Material topMat = Material.AIR;
88 | for (Material m : data.keySet()) {
89 | if ((data.get(m) > top)) {
90 | topMat = m;
91 | top = data.get(m);
92 | }
93 | }
94 | inv.addItem(createItem(topMat, inv));
95 | data.remove(topMat);
96 | }
97 | } else if (sort.equalsIgnoreCase(LanguageManager.getValue("alpha"))) {
98 | List mats = getMats(inv);
99 | Collections.sort(mats, Comparator.comparing(Material::toString));
100 | clearItems(inv);
101 | for (Material m : mats) {
102 | inv.addItem(createItem(m, inv));
103 | }
104 | } else if (sort.equalsIgnoreCase("ID")) {
105 | clearItems(inv);
106 |
107 | SortedSet list = new TreeSet<>();
108 | list.addAll(DSUManager.getTotalTypes(inv));
109 | for (Material m : list) {
110 | inv.addItem(createItem(m, inv));
111 | }
112 | }
113 | }
114 | updateInventory(inv);
115 | }
116 |
117 | private static void addNewItems(Inventory inv) {
118 | Set mats = DSUManager.getTotalTypes(inv);
119 | for (Material m : mats) {
120 | ItemStack item = new ItemStack(m);
121 | boolean canAdd = true;
122 | for (ItemStack it : inv.getContents()) { //This section adds the items based on the Storage Containers
123 | if (item.equals(it)) {
124 | canAdd = false;
125 | break;
126 | }
127 | }
128 | if (canAdd) {
129 | inv.addItem(createItem(m, inv));
130 | }
131 | }
132 | }
133 |
134 | private void updateInventory(Inventory inv) {
135 | Bukkit.getServer().getScheduler().scheduleSyncDelayedTask(main, new Runnable() {
136 | @Override
137 | public void run() {
138 | inv.getLocation().getBlock().getState().update();
139 | }
140 | }, 1);
141 | }
142 |
143 | private static void clearItems(Inventory inv) {
144 | for (int i = 0; i < 54; i++) {
145 | if (i % 9 != 8 && i % 9 != 7) {
146 | inv.setItem(i, null);
147 | }
148 | }
149 | }
150 |
151 | private static List getMats(Inventory inv) {
152 | Set mats = new HashSet<>();
153 | for (int i = 0; i < 5; i++) {
154 | ItemStack container = inv.getItem(8 + (9 * i));
155 | if (container != null && container.getType() != Material.WHITE_STAINED_GLASS_PANE) {
156 | HashSet tempMats = DSUManager.getTypes(container.getItemMeta().getLore());
157 | mats.addAll(tempMats);
158 | }
159 | }
160 | return new ArrayList<>(mats);
161 | }
162 |
163 | private static ItemStack createItem(Material mat, Inventory inv) {
164 | ItemStack item = new ItemStack(mat);
165 | ItemMeta meta = item.getItemMeta();
166 | meta.setLore(Arrays.asList(ChatColor.GRAY + "Item Count: " + DSUManager.getTotalMaterialAmount(inv, mat)));
167 | item.setItemMeta(meta);
168 | return item;
169 | }
170 | }
171 |
--------------------------------------------------------------------------------
/src/main/java/me/darkolythe/deepstorageplus/dsu/managers/SettingsManager.java:
--------------------------------------------------------------------------------
1 | package me.darkolythe.deepstorageplus.dsu.managers;
2 |
3 | import de.tr7zw.changeme.nbtapi.NBTItem;
4 | import me.darkolythe.deepstorageplus.utils.LanguageManager;
5 | import org.bukkit.Bukkit;
6 | import org.bukkit.ChatColor;
7 | import org.bukkit.Material;
8 | import org.bukkit.enchantments.Enchantment;
9 | import org.bukkit.entity.Player;
10 | import org.bukkit.inventory.Inventory;
11 | import org.bukkit.inventory.ItemFlag;
12 | import org.bukkit.inventory.ItemStack;
13 | import org.bukkit.inventory.meta.ItemMeta;
14 |
15 | import java.util.ArrayList;
16 | import java.util.Arrays;
17 | import java.util.List;
18 |
19 | import static me.darkolythe.deepstorageplus.dsu.StorageUtils.stringToMat;
20 |
21 | public class SettingsManager {
22 |
23 | /*
24 | Takes the dsu's inventory and lets the player choose an item to export from the list. (Also allow for other things? we shall see. maybe amount of item? Upgrades?)
25 | */
26 | public static Inventory createIOInventory(Inventory DSUInv) {
27 | Inventory IOInv = Bukkit.createInventory(null, 54, ChatColor.BLUE.toString() + ChatColor.BOLD.toString() + LanguageManager.getValue("dsuioconfig"));
28 |
29 | for (int x = 0; x < 53; x++) {
30 | if (x % 9 != 8) {
31 | if (DSUInv.getItem(x) != null) {
32 | IOInv.setItem(x, DSUInv.getItem(x).clone());
33 | }
34 | }
35 | }
36 |
37 | ItemStack IOItem = DSUInv.getItem(53);
38 | ItemMeta IOMeta = IOItem.getItemMeta();
39 | List lore = IOMeta.getLore();
40 |
41 | /*
42 | * Create the IO settings item with use of the DSUinv to check for existing IO items
43 | */
44 | if (lore.get(0).contains(ChatColor.BLUE + LanguageManager.getValue("all"))) {
45 | IOInv.setItem(8, getEmptyInputSlot());
46 | } else {
47 | ItemStack newInput = getEmptyInputSlot();
48 | newInput.setType(stringToMat(lore.get(0), ChatColor.GRAY + LanguageManager.getValue("input") + ": " + ChatColor.GREEN));
49 | ItemMeta inputMeta = newInput.getItemMeta();
50 | inputMeta.setDisplayName(ChatColor.GRAY + LanguageManager.getValue("input") + ": " + lore.get(0).replace(ChatColor.GRAY + LanguageManager.getValue("input") + ": ", ""));
51 | inputMeta.setLore(Arrays.asList(ChatColor.GRAY + LanguageManager.getValue("clicktoclear")));
52 | newInput.setItemMeta(inputMeta);
53 | IOInv.setItem(8, newInput);
54 | }
55 | if (lore.get(1).contains(ChatColor.BLUE + LanguageManager.getValue("none"))) {
56 | IOInv.setItem(17, getEmptyOutputSlot());
57 | } else {
58 | ItemStack newOutput = getEmptyOutputSlot();
59 | newOutput.setType(stringToMat(lore.get(1), ChatColor.GRAY + LanguageManager.getValue("output") + ": " + ChatColor.GREEN));
60 | ItemMeta outputMeta = newOutput.getItemMeta();
61 | outputMeta.setDisplayName(ChatColor.GRAY + LanguageManager.getValue("output") + ": " + lore.get(1).replace(ChatColor.GRAY + LanguageManager.getValue("output") + ": ", ""));
62 | outputMeta.setLore(Arrays.asList(ChatColor.GRAY + LanguageManager.getValue("clicktoclear")));
63 | newOutput.setItemMeta(outputMeta);
64 | IOInv.setItem(17, newOutput);
65 | }
66 |
67 | ItemStack sortSlot = new ItemStack(Material.COMPASS);
68 | ItemMeta sortMeta = sortSlot.getItemMeta();
69 | sortMeta.setDisplayName(ChatColor.GRAY + LanguageManager.getValue("sortingby") + ": " + lore.get(2).replace(ChatColor.GRAY + LanguageManager.getValue("sortingby") + ": ", ""));
70 | sortMeta.setLore(Arrays.asList(ChatColor.GRAY + LanguageManager.getValue("changesorting"),
71 | ChatColor.BLUE + LanguageManager.getValue("container") + ": " + ChatColor.GRAY + LanguageManager.getValue("sortscontainer"),
72 | ChatColor.BLUE + LanguageManager.getValue("alpha") + ": " + ChatColor.GRAY + LanguageManager.getValue("sortsalpha"),
73 | ChatColor.BLUE + LanguageManager.getValue("amount") + ": " + ChatColor.GRAY + LanguageManager.getValue("sortsamount"),
74 | ChatColor.BLUE + "ID: " + ChatColor.GRAY + LanguageManager.getValue("sortsid")));
75 | sortSlot.setItemMeta(sortMeta);
76 | IOInv.setItem(26, sortSlot);
77 |
78 | IOInv.setItem(53, createDSULock(DSUInv));
79 |
80 | return IOInv;
81 | }
82 |
83 | /*
84 | * Add lock to IO settings menu
85 | */
86 | public static ItemStack createDSULock(Inventory LockInv) {
87 | ItemStack lock = new ItemStack(Material.TRIPWIRE_HOOK);
88 | ItemMeta lockmeta = lock.getItemMeta();
89 | lockmeta.setDisplayName(ChatColor.BLUE + "Lock DSU");
90 | List locklore = new ArrayList<>();
91 | locklore.add(ChatColor.GRAY + LanguageManager.getValue("leftclicktoadd"));
92 | locklore.add(ChatColor.GRAY + LanguageManager.getValue("rightclicktoremove"));
93 | locklore.add("");
94 | locklore.add(ChatColor.GRAY + LanguageManager.getValue("owner") + ": " + ChatColor.BLUE + getOwner(LockInv.getItem(53))[0]);
95 |
96 | if (isLocked(LockInv.getItem(53))) {
97 | locklore.add(ChatColor.RED + LanguageManager.getValue("locked"));
98 | for (String s : getLockedUsers(LockInv.getItem(53))) {
99 | locklore.add(ChatColor.WHITE + s);
100 | }
101 | } else {
102 | locklore.add(ChatColor.GREEN + LanguageManager.getValue("unlocked"));
103 | }
104 | lockmeta.setLore(locklore);
105 | lock.setItemMeta(lockmeta);
106 |
107 | NBTItem nbt = new NBTItem(lock);
108 | nbt.setString("dsu_owner_uuid", getOwner(LockInv.getItem(53))[1]);
109 | lock = nbt.getItem();
110 |
111 | return lock;
112 | }
113 |
114 | /*
115 | Create an empty input slot item
116 | */
117 | private static ItemStack getEmptyInputSlot() {
118 | ItemStack inputSlot = new ItemStack(Material.WHITE_STAINED_GLASS_PANE);
119 | ItemMeta inputMeta = inputSlot.getItemMeta();
120 | inputMeta.setDisplayName(ChatColor.GRAY + LanguageManager.getValue("input") + ": " + ChatColor.BLUE + LanguageManager.getValue("all"));
121 | inputMeta.setLore(Arrays.asList(ChatColor.GRAY + LanguageManager.getValue("clicktostart"),
122 | ChatColor.GRAY + LanguageManager.getValue("clickinput"),
123 | ChatColor.GRAY + LanguageManager.getValue("leaveasall")));
124 | inputSlot.setItemMeta(inputMeta);
125 |
126 | return inputSlot;
127 | }
128 |
129 | /*
130 | Create an empty output slot item
131 | */
132 | private static ItemStack getEmptyOutputSlot() {
133 | ItemStack outputSlot = new ItemStack(Material.WHITE_STAINED_GLASS_PANE);
134 | ItemMeta outputMeta = outputSlot.getItemMeta();
135 | outputMeta.setDisplayName(ChatColor.GRAY + LanguageManager.getValue("output") + ": " + ChatColor.BLUE + LanguageManager.getValue("none"));
136 | outputMeta.setLore(Arrays.asList(ChatColor.GRAY + LanguageManager.getValue("clicktostart"),
137 | ChatColor.GRAY + LanguageManager.getValue("clickoutput")));
138 | outputSlot.setItemMeta(outputMeta);
139 |
140 | return outputSlot;
141 | }
142 |
143 | /*
144 | Initialize the selection tool by cancelling all other current selections and enchanting the current slot
145 | */
146 | public static void startSelection(int slot, Inventory inv) {
147 | for (int i = 0; i < inv.getContents().length; i++) {
148 | if (inv.getItem(i) != null) {
149 | if (inv.getItem(i).getEnchantments().size() > 0) {
150 | ItemStack newItem = inv.getItem(i);
151 | newItem.removeEnchantment(Enchantment.DURABILITY);
152 | inv.setItem(i, newItem);
153 | }
154 | }
155 | }
156 | ItemStack item;
157 | if (slot == 8) {
158 | item = getEmptyInputSlot();
159 | } else {
160 | item = getEmptyOutputSlot();
161 | }
162 | ItemMeta meta = item.getItemMeta();
163 | meta.addItemFlags(ItemFlag.HIDE_ENCHANTS);
164 | item.setItemMeta(meta);
165 | item.addUnsafeEnchantment(Enchantment.DURABILITY, 1);
166 | inv.setItem(slot, item);
167 | }
168 |
169 | public static String[] getOwner(ItemStack IOSettings) {
170 | if (IOSettings != null) {
171 | ItemMeta meta = IOSettings.getItemMeta();
172 | if (meta != null) {
173 | List lore = meta.getLore();
174 | if (lore != null) {
175 | for (String s : lore) {
176 | String ownstr = ChatColor.GRAY + LanguageManager.getValue("owner");
177 | if (s.contains(ownstr + ": ")) {
178 | String owner = s.replaceAll(ownstr + ": " + ChatColor.BLUE, "");
179 | String uuid = "";
180 |
181 | NBTItem nbt = new NBTItem(IOSettings);
182 | if (nbt.hasNBTData()) {
183 | uuid = nbt.getString("dsu_owner_uuid");
184 | }
185 |
186 | return new String[]{owner, uuid};
187 | }
188 | }
189 | }
190 | }
191 | }
192 | return new String[]{"", ""};
193 | }
194 |
195 | public static List getLockedUsers(ItemStack IOSettings) {
196 | List users = new ArrayList<>();
197 | if (IOSettings != null) {
198 | ItemMeta meta = IOSettings.getItemMeta();
199 | if (meta != null) {
200 | List lore = meta.getLore();
201 | boolean pastLocked = false;
202 | if (lore != null) {
203 | for (String s : lore) {
204 | if (pastLocked) {
205 | if (s.contains(ChatColor.WHITE.toString())) {
206 | users.add(s.replaceAll(ChatColor.WHITE.toString(), ""));
207 | } else {
208 | break;
209 | }
210 | }
211 | if (s.equals(ChatColor.RED + LanguageManager.getValue("locked"))) {
212 | pastLocked = true;
213 | }
214 | }
215 | }
216 | }
217 | }
218 | return users;
219 | }
220 |
221 | public static boolean isLocked(ItemStack IOSettings) {
222 | if (IOSettings != null) {
223 | ItemMeta meta = IOSettings.getItemMeta();
224 | if (meta != null) {
225 | List lore = meta.getLore();
226 | if (lore != null) {
227 | for (String s : lore) {
228 | if (s.equals(ChatColor.RED + LanguageManager.getValue("locked"))) {
229 | return true;
230 | }
231 | }
232 | }
233 | }
234 | }
235 | return false;
236 | }
237 |
238 | public static boolean getLocked(ItemStack IOSettings, Player player) {
239 | List users = getLockedUsers(IOSettings);
240 | users.add(getOwner(IOSettings)[0]);
241 | for (String s : users) {
242 | if (player.getName().equals(s)) {
243 | return true;
244 | }
245 | }
246 | return (player.getUniqueId().toString().equals(getOwner(IOSettings)[1]));
247 | }
248 |
249 | public static int getSpeedUpgrade(ItemStack item) {
250 | for (String lore : item.getItemMeta().getLore()) {
251 | if (lore.contains(ChatColor.GRAY + LanguageManager.getValue("iospeed") + ": ")) {
252 | return Integer.parseInt(ChatColor.stripColor(lore).replaceAll("[\\D]", ""));
253 | }
254 | }
255 | return 0;
256 | }
257 |
258 | public static ItemStack addSpeedUpgrade(ItemStack item) {
259 | int i = 0;
260 | int amt = 0;
261 | boolean found = false;
262 |
263 | ItemMeta meta = item.getItemMeta();
264 | List lore = meta.getLore();
265 |
266 | for (String l : lore) {
267 | if (l.contains(ChatColor.GRAY + LanguageManager.getValue("iospeed") + ": ")) {
268 | found = true;
269 | amt = Integer.parseInt(ChatColor.stripColor(l).replaceAll("[\\D]", ""));
270 | if (amt >= 63) {
271 | return null;
272 | }
273 | break;
274 | }
275 | i++;
276 | }
277 |
278 | if (found) {
279 | lore.set(i, ChatColor.GRAY + LanguageManager.getValue("iospeed") + ": " + ChatColor.GREEN + "+" + (amt + 1));
280 | } else {
281 | lore.add(ChatColor.GRAY + LanguageManager.getValue("iospeed") + ": " + ChatColor.GREEN + "+" + (amt + 1));
282 | }
283 | meta.setLore(lore);
284 | item.setItemMeta(meta);
285 | return item;
286 | }
287 | }
288 |
--------------------------------------------------------------------------------
/src/main/java/me/darkolythe/deepstorageplus/dsu/managers/SorterManager.java:
--------------------------------------------------------------------------------
1 | package me.darkolythe.deepstorageplus.dsu.managers;
2 |
3 | import me.darkolythe.deepstorageplus.DeepStoragePlus;
4 | import me.darkolythe.deepstorageplus.dsu.StorageUtils;
5 | import me.darkolythe.deepstorageplus.utils.ItemList;
6 | import me.darkolythe.deepstorageplus.utils.LanguageManager;
7 | import org.bukkit.Bukkit;
8 | import org.bukkit.ChatColor;
9 | import org.bukkit.Location;
10 | import org.bukkit.Material;
11 | import org.bukkit.block.Block;
12 | import org.bukkit.block.Container;
13 | import org.bukkit.entity.Player;
14 | import org.bukkit.inventory.Inventory;
15 | import org.bukkit.inventory.ItemStack;
16 | import org.bukkit.inventory.meta.ItemMeta;
17 |
18 | import java.util.*;
19 | import java.util.logging.Level;
20 | import java.util.stream.Collectors;
21 |
22 | import static org.bukkit.Bukkit.getLogger;
23 |
24 | public class SorterManager {
25 |
26 | DeepStoragePlus main;
27 | public SorterManager(DeepStoragePlus plugin) {
28 | main = plugin;
29 | }
30 |
31 | /*
32 | Create the sorter inventory and make it so that it's correct upon opening
33 | */
34 | public static void verifyInventory(Inventory inv, Player player) {
35 | for (int i = 0; i < 9; i++) {
36 | inv.setItem( 18 + i, getSorterWall());
37 | }
38 |
39 | for (int i = 0; i < 27; i++) {
40 | if (inv.getItem(27 + i) == null) {
41 | inv.setItem(27 + i, getEmptyBlock());
42 | }
43 | }
44 | }
45 |
46 | private static ItemStack sorterWall;
47 |
48 | /*
49 | Create a dsu Wall item to fill the dsu Inventory
50 | */
51 | public static ItemStack getSorterWall() {
52 | if (sorterWall != null)
53 | return sorterWall;
54 | ItemStack border = new ItemStack(Material.BLACK_STAINED_GLASS_PANE);
55 | ItemMeta bordermeta = border.getItemMeta();
56 | bordermeta.setDisplayName(ChatColor.DARK_GRAY + LanguageManager.getValue("sorterwalls"));
57 | border.setItemMeta(bordermeta);
58 |
59 | return sorterWall = border;
60 | }
61 |
62 | /*
63 | Create an Empty Block item to fill the dsu Inventory
64 | */
65 | public static ItemStack getEmptyBlock() {
66 | ItemStack storage = new ItemStack(Material.WHITE_STAINED_GLASS_PANE);
67 | ItemMeta storagemeta = storage.getItemMeta();
68 | storagemeta.setDisplayName(ChatColor.YELLOW + LanguageManager.getValue("emptysorterblock"));
69 | storage.setItemMeta(storagemeta);
70 |
71 | return storage;
72 | }
73 |
74 |
75 | public static boolean sortItems(Inventory sorterInventory) {
76 | Location sorterLocation = sorterInventory.getLocation();
77 |
78 | // Get the materials we're trying to sort
79 | Set materialsToSort = getMaterialsToSort(sorterInventory);
80 |
81 | Map> containingDSUs;
82 |
83 | // Look for a cached set of linked DSUs
84 | if (DeepStoragePlus.sorterLocationCache.containsKey(sorterLocation)) {
85 | Map> cachedDSULocations = DeepStoragePlus.sorterLocationCache.get(sorterLocation);
86 | containingDSUs = new HashMap<>();
87 | for (Material material: cachedDSULocations.keySet()) {
88 | containingDSUs.put(material, SorterManager.getDSUInventories(cachedDSULocations.get(material)));
89 | }
90 | if (moveItems(sorterInventory, containingDSUs)) {
91 |
92 | return true;
93 | }
94 | }
95 |
96 | // Get all linked DSUs
97 | Set locations = new HashSet(SorterManager.getLinkedLocations(sorterInventory));
98 | Set dsuInventories = SorterManager.getDSUInventories(locations);
99 |
100 | // Get the DSUs that contain those materials, organized by material
101 | containingDSUs = getDSUsWithMaterial(dsuInventories, materialsToSort);
102 |
103 | // Update cache
104 | updateCache(sorterLocation, containingDSUs);
105 |
106 | return moveItems(sorterInventory, containingDSUs);
107 | }
108 |
109 | private static void updateCache(Location sorterLocation, Map> containingDSUs) {
110 | if (DeepStoragePlus.sorterLocationCache.containsKey(sorterLocation)) {
111 | Map> existingCache = DeepStoragePlus.sorterLocationCache.get(sorterLocation);
112 | for (Material material: containingDSUs.keySet()) {
113 | if (existingCache.containsKey(material)) {
114 | existingCache.get(material).addAll(containingDSUs.get(material).stream().map(Inventory::getLocation).collect(Collectors.toSet()));
115 | }
116 | else {
117 | existingCache.put(material, containingDSUs.get(material).stream().map(Inventory::getLocation).collect(Collectors.toSet()));
118 | }
119 | }
120 | } else {
121 | Map> cachedDSULocations = new HashMap<>();
122 | for (Material material: containingDSUs.keySet()) {
123 | cachedDSULocations.put(material, containingDSUs.get(material).stream().map(Inventory::getLocation).collect(Collectors.toSet()));
124 | }
125 | DeepStoragePlus.sorterLocationCache.put(sorterLocation, cachedDSULocations);
126 | }
127 | }
128 |
129 | private static boolean moveItems(Inventory sorterInventory, Map> containingDSUs) {
130 | // For each item and for each DSU that contains
131 | boolean success = true;
132 | for (int i = 0; i < 18; i++) {
133 | ItemStack item = sorterInventory.getItem(i);
134 | boolean didMoveAll = false;
135 | if (item != null && item.getType() != Material.AIR && StorageUtils.hasNoMeta(item)) {
136 | if (containingDSUs.containsKey(item.getType())) {
137 | for (Inventory dsu : containingDSUs.get(item.getType())) { // Try to add the item to each DSU until we successfully add all of it.
138 | if (DSUManager.addToDSUSilent(item, dsu)) {
139 | didMoveAll = true;
140 | break;
141 | }
142 | }
143 | }
144 | }
145 | else {
146 | didMoveAll = true;
147 | }
148 | success = success && didMoveAll;
149 | }
150 | return success;
151 | }
152 |
153 | private static Set getMaterialsToSort(Inventory sorterInventory) {
154 | Set materialsToSort = new HashSet<>();
155 | for (int i = 0; i < 18; i++) { // Get each unique item type we're trying to sort
156 | ItemStack item = sorterInventory.getItem(i);
157 | if (item != null && StorageUtils.hasNoMeta(item)) {
158 | materialsToSort.add(item.getType());
159 | }
160 | }
161 | return materialsToSort;
162 | }
163 |
164 | private static Map> getDSUsWithMaterial(Set dsuInventories, Set materials) {
165 | // Get the DSUs that contain those materials
166 | Map> containingDSUs = new HashMap<>();
167 | for (Material material : materials) {
168 | if (!containingDSUs.containsKey(material)) {
169 | containingDSUs.put(material, new HashSet<>());
170 | }
171 | containingDSUs.get(material).addAll(SorterManager.getDSUContainingMaterial(dsuInventories, material));
172 | }
173 | return containingDSUs;
174 | }
175 |
176 | /**
177 | * Recursively find the location of all sorters and DSUs linked to this sorter and linked to sorters linked to this sorter.
178 | * We should cache this where possible, but we can't know when it's invalidated with certainty because sorters down the tree
179 | * may be changed without our knowing. Refreshing only when we fail to find a spot for something or a link card is added to the root sorter
180 | * should be fine.
181 | * @param inv
182 | * @return
183 | */
184 | private static List getLinkedLocations(Inventory inv) {
185 | List locations = getLinkedLocations(inv, new ArrayList<>());
186 | for (int i = 0; i < locations.size(); i++) {
187 | // Check if this location has another sorter
188 | Block block = locations.get(i).getBlock();
189 | if (block.getType() == Material.CHEST && StorageUtils.getChestCustomName(block).orElse("").equals(DeepStoragePlus.sortername)) {
190 | List newLocations = getLinkedLocations(((Container) block.getState()).getInventory(), locations);
191 | locations.addAll(newLocations);
192 | }
193 | }
194 | return locations;
195 | }
196 |
197 | private static List getLinkedLocations(Inventory inv, List locations) {
198 | // Check each link module slot for locations referenced in this sorter
199 | List newLocations = new ArrayList<>();
200 | for (int i = 27; i < 54; i++) {
201 | ItemStack item = inv.getItem(i);
202 | if (item != null) { // Only link modules should be possible in these slots
203 | getLinkModuleLocation(item).ifPresent(x -> {if (!locations.contains(x)) newLocations.add(x);});
204 | }
205 | }
206 | return newLocations;
207 | }
208 |
209 | private static Optional getLinkModuleLocation(ItemStack linkModule) {
210 | if (linkModule.hasItemMeta()
211 | && linkModule.getItemMeta().hasDisplayName() && linkModule.getItemMeta().getDisplayName().equals(ItemList.createLinkModule().getItemMeta().getDisplayName())
212 | && linkModule.getItemMeta().hasLore() && linkModule.getItemMeta().getLore().size() > 0) {
213 | try {
214 | String[] loreLocationArr = ChatColor.stripColor(linkModule.getItemMeta().getLore().get(0)).split("\\s+");
215 | if (loreLocationArr.length == 4) {
216 | return Optional.of(new Location(
217 | Bukkit.getWorld(loreLocationArr[0]),
218 | Double.parseDouble(loreLocationArr[1]),
219 | Double.parseDouble(loreLocationArr[2]),
220 | Double.parseDouble(loreLocationArr[3]))
221 | );
222 | }
223 | }
224 | catch (Exception ignored) {
225 | getLogger().log(Level.INFO, "Exception parsing link module lore " + linkModule.getItemMeta().getLore().get(0));
226 | }
227 | }
228 | return Optional.empty();
229 | }
230 |
231 | /**
232 | * Get each DSU inventory from a list of locations (which may contain DSUs and Sorters
233 | * @param locations
234 | * @return
235 | */
236 | public static Set getDSUInventories(Set locations) {
237 | Set inventories = new HashSet<>();
238 | for (Location location: locations) {
239 | Block block = location.getBlock();
240 | if (block.getType() == Material.CHEST && StorageUtils.getChestCustomName(block).orElse("").equals(DeepStoragePlus.DSUname)) {
241 | inventories.add(((Container) block.getState()).getInventory());
242 | }
243 | }
244 | return inventories;
245 | }
246 |
247 | /**
248 | * Returns an optional inventory that contains the given material.
249 | */
250 | public static Set getDSUContainingMaterial(Set inventories, Material material) {
251 | Set DSUs = new HashSet<>();
252 | for (Inventory inventory: inventories) {
253 | if (DSUManager.dsuContainsType(inventory, material)) {
254 | DSUs.add(inventory);
255 | }
256 | }
257 | return DSUs;
258 | }
259 | }
260 |
--------------------------------------------------------------------------------
/src/main/java/me/darkolythe/deepstorageplus/dsu/managers/SorterUpdateManager.java:
--------------------------------------------------------------------------------
1 | package me.darkolythe.deepstorageplus.dsu.managers;
2 |
3 | import me.darkolythe.deepstorageplus.DeepStoragePlus;
4 | import org.bukkit.Bukkit;
5 | import org.bukkit.inventory.Inventory;
6 |
7 | public class SorterUpdateManager {
8 |
9 | private DeepStoragePlus main;
10 | public SorterUpdateManager(DeepStoragePlus plugin) {
11 | main = plugin;
12 | }
13 |
14 | /*
15 | Update the items in the dsu. This is done when items are added, taken, Storage Containers are added, taken, and when opening the dsu.
16 | */
17 | public void sortItems(Inventory inv, Long minTimeSinceLast) {
18 | if (inv.getLocation() == null) {
19 | return;
20 | }
21 | if (!DeepStoragePlus.recentSortCalls.containsKey(inv.getLocation())) {
22 | DeepStoragePlus.recentSortCalls.put(inv.getLocation(), 0L);
23 | }
24 | Bukkit.getServer().getScheduler().scheduleSyncDelayedTask(main, new Runnable() {
25 | @Override
26 | public void run() {
27 | // if over a second has passed since the last bulk item was placed in the dsu, update it
28 | if (!DeepStoragePlus.recentSortCalls.containsKey(inv.getLocation())) {
29 | return;
30 | }
31 | if (System.currentTimeMillis() - DeepStoragePlus.recentSortCalls.get(inv.getLocation()) < minTimeSinceLast) {
32 | return;
33 | }
34 | if(SorterManager.sortItems(inv)) {
35 | DeepStoragePlus.recentSortCalls.put(inv.getLocation(), System.currentTimeMillis());
36 | }
37 | else { // On a failed sort we know the next run will probably cache miss, so we delay it even further for performance reasons
38 | DeepStoragePlus.recentSortCalls.put(inv.getLocation(), System.currentTimeMillis() + 30000L);
39 | }
40 | }
41 | }, 5L);
42 | }
43 | }
44 |
--------------------------------------------------------------------------------
/src/main/java/me/darkolythe/deepstorageplus/dsu/managers/WirelessManager.java:
--------------------------------------------------------------------------------
1 | package me.darkolythe.deepstorageplus.dsu.managers;
2 |
3 | import me.darkolythe.deepstorageplus.DeepStoragePlus;
4 | import me.darkolythe.deepstorageplus.utils.LanguageManager;
5 | import org.bukkit.ChatColor;
6 | import org.bukkit.Material;
7 | import org.bukkit.World;
8 | import org.bukkit.block.Block;
9 | import org.bukkit.block.Chest;
10 | import org.bukkit.enchantments.Enchantment;
11 | import org.bukkit.entity.Player;
12 | import org.bukkit.inventory.Inventory;
13 | import org.bukkit.inventory.ItemFlag;
14 | import org.bukkit.inventory.ItemStack;
15 | import org.bukkit.inventory.meta.ItemMeta;
16 |
17 | import java.util.Arrays;
18 | import java.util.List;
19 |
20 | public class WirelessManager {
21 |
22 | public static ItemStack createTerminal() {
23 | ItemStack terminal = new ItemStack(Material.STONE_AXE);
24 | ItemMeta meta = terminal.getItemMeta();
25 | meta.setUnbreakable(true);
26 | meta.addItemFlags(ItemFlag.HIDE_UNBREAKABLE);
27 | meta.addItemFlags(ItemFlag.HIDE_ATTRIBUTES);
28 | meta.setDisplayName(ChatColor.AQUA + LanguageManager.getValue("terminal"));
29 | meta.setLore(Arrays.asList(ChatColor.GRAY + "---------------------",
30 | ChatColor.RED.toString() + ChatColor.BOLD.toString() + LanguageManager.getValue("unlinked"),
31 | ChatColor.GRAY.toString() + LanguageManager.getValue("clicktolink"),
32 | ChatColor.GRAY + "---------------------",
33 | ChatColor.AQUA.toString() + LanguageManager.getValue("terminal")));
34 | // set texture data ID
35 | meta.setCustomModelData(13000);
36 |
37 | terminal.setItemMeta(meta);
38 | return terminal;
39 | }
40 |
41 | public static ItemStack createReceiver() {
42 | ItemStack receiver = new ItemStack(Material.STONE_AXE);
43 | ItemMeta meta = receiver.getItemMeta();
44 | meta.setUnbreakable(true);
45 | meta.setDisplayName(ChatColor.AQUA + LanguageManager.getValue("receiver"));
46 | // set texture data ID
47 | meta.setCustomModelData(13001);
48 | receiver.setItemMeta(meta);
49 | return receiver;
50 | }
51 |
52 | public static void updateTerminal(ItemStack terminal, int x, int y, int z, World world) {
53 | ItemMeta meta = terminal.getItemMeta();
54 | meta.addItemFlags(ItemFlag.HIDE_ENCHANTS);
55 |
56 | String range = DeepStoragePlus.maxrange == -1 ? "none" : String.valueOf(DeepStoragePlus.maxrange);
57 |
58 | meta.setLore(Arrays.asList(ChatColor.GREEN.toString() + ChatColor.BOLD.toString() + LanguageManager.getValue("linked"),
59 | ChatColor.GRAY.toString() + "X: " + ChatColor.RED.toString() + x,
60 | ChatColor.GRAY.toString() + "Y: " + ChatColor.RED.toString() + y,
61 | ChatColor.GRAY.toString() + "Z: " + ChatColor.RED.toString() + z,
62 | ChatColor.GRAY.toString() + LanguageManager.getValue("world") + ": " + ChatColor.RED.toString() + world.getName(),
63 | ChatColor.GRAY.toString() + LanguageManager.getValue("maxdistance") + ": " + ChatColor.RED.toString() + range,
64 | "",
65 | ChatColor.GRAY + LanguageManager.getValue("shiftswap"),
66 | ChatColor.AQUA.toString() + LanguageManager.getValue("terminal")));
67 | terminal.setItemMeta(meta);
68 | terminal.addUnsafeEnchantment(Enchantment.DURABILITY, 1);
69 | }
70 |
71 | public static Inventory getWirelessDSU(ItemStack terminal, Player player) {
72 | ItemMeta meta = terminal.getItemMeta();
73 | List lore = meta.getLore();
74 | int x = Integer.parseInt(lore.get(1).replaceAll("^[^_]*:", "").replace(" ", "").replace(ChatColor.RED.toString(), ""));
75 | int y = Integer.parseInt(lore.get(2).replaceAll("^[^_]*:", "").replace(" ", "").replace(ChatColor.RED.toString(), ""));
76 | int z = Integer.parseInt(lore.get(3).replaceAll("^[^_]*:", "").replace(" ", "").replace(ChatColor.RED.toString(), ""));
77 | int range = -1;
78 | if (!lore.get(5).contains("none") && lore.get(5).length() > 1) {
79 | range = Integer.parseInt(lore.get(5).replaceAll("^[^_]*:", "").replace(" ", "").replace(ChatColor.RED.toString(), ""));
80 | }
81 |
82 | String world = ChatColor.GRAY.toString() + LanguageManager.getValue("world") + ": " + player.getWorld().getName();
83 | String newWorld = ChatColor.GRAY.toString() + LanguageManager.getValue("world") + ": " + ChatColor.RED.toString() + player.getWorld().getName();
84 | if (!world.equals(lore.get(4)) && !newWorld.equals(lore.get(4))) {
85 | player.sendMessage(DeepStoragePlus.prefix + ChatColor.RED + LanguageManager.getValue("cantopenin") + " " + ChatColor.GRAY + player.getWorld().getName());
86 | return null;
87 | }
88 |
89 | Block block = player.getWorld().getBlockAt(x, y, z);
90 | if (block.getType() != Material.CHEST) {
91 | player.sendMessage(DeepStoragePlus.prefix + ChatColor.RED + LanguageManager.getValue("dsunolongerthere"));
92 | return null;
93 | }
94 |
95 | if (block.getLocation().distance(player.getLocation()) > range && range != -1) {
96 | player.sendMessage(DeepStoragePlus.prefix + ChatColor.RED + LanguageManager.getValue("toofar"));
97 | return null;
98 | }
99 |
100 | Chest chest = (Chest) block.getState();
101 | if (chest.getInventory().contains(DSUManager.getDSUWall())) {
102 | return chest.getInventory();
103 | } else {
104 | player.sendMessage(DeepStoragePlus.prefix + ChatColor.RED + LanguageManager.getValue("dsunolongerthere"));
105 | }
106 |
107 | return null;
108 | }
109 |
110 | public static boolean isWirelessTerminal(ItemStack item) {
111 | if (item != null && item.hasItemMeta()) {
112 | ItemMeta meta = item.getItemMeta();
113 | if (meta.hasDisplayName() && meta.hasLore()) {
114 | if (meta.getLore().get(meta.getLore().size() - 1).equals(ChatColor.AQUA + LanguageManager.getValue("terminal"))) {
115 | return true;
116 | }
117 | }
118 | }
119 | return false;
120 | }
121 | }
122 |
--------------------------------------------------------------------------------
/src/main/java/me/darkolythe/deepstorageplus/io/CommandHandler.java:
--------------------------------------------------------------------------------
1 | package me.darkolythe.deepstorageplus.io;
2 |
3 | import me.darkolythe.deepstorageplus.DeepStoragePlus;
4 | import me.darkolythe.deepstorageplus.utils.ItemList;
5 | import org.apache.commons.lang.StringUtils;
6 | import org.bukkit.Bukkit;
7 | import org.bukkit.ChatColor;
8 | import org.bukkit.block.CommandBlock;
9 | import org.bukkit.command.BlockCommandSender;
10 | import org.bukkit.command.Command;
11 | import org.bukkit.command.CommandExecutor;
12 | import org.bukkit.command.CommandSender;
13 | import org.bukkit.entity.Player;
14 | import org.bukkit.inventory.ItemStack;
15 |
16 | import java.util.Arrays;
17 | import java.util.Optional;
18 |
19 | public class CommandHandler implements CommandExecutor {
20 |
21 | private DeepStoragePlus main = DeepStoragePlus.getInstance();
22 |
23 | private ItemList itemList;
24 |
25 | public CommandHandler(ItemList itemList) {
26 | super();
27 | this.itemList = itemList;
28 | }
29 |
30 | @Override
31 | public boolean onCommand(CommandSender sender, Command cmd, String commandlabel, String[] args) {
32 | if (sender instanceof Player || sender instanceof BlockCommandSender) {
33 | // Example give commands
34 | // give storagecell16k 6
35 | // give joe storagecontainer1M 2
36 | // give wrench
37 | if (args.length == 1 && args[0].equalsIgnoreCase("items") && sender.hasPermission("deepstorageplus.give")) {
38 | String items = "";
39 | for (String s : itemList.itemListMap.keySet()) {
40 | items += ChatColor.GREEN + s + ChatColor.BLUE + ", ";
41 | }
42 | sender.sendMessage(DeepStoragePlus.prefix + items);
43 | } else if (args.length >= 2 && args[0].equalsIgnoreCase("give") && (sender instanceof BlockCommandSender || sender.hasPermission("deepstorageplus.give"))) {
44 | Optional player = Bukkit.getServer().getOnlinePlayers().stream().map(x -> (Player) x).filter(x -> x.getName().equalsIgnoreCase(args[1])).findAny();
45 | String itemName = null;
46 | int quantity = 1;
47 | if (player.isPresent()) { // A recipient player was specified
48 | if (args.length >= 4) {
49 | itemName = args[2];
50 | quantity = StringUtils.isNumeric(args[3]) ? Integer.parseInt(args[3]) : 1;
51 | }
52 | else if (args.length >= 3) {
53 | itemName = args[2];
54 | }
55 | } else {
56 | if (sender instanceof BlockCommandSender) {
57 | return false;
58 | }
59 |
60 | if (args.length >= 3) {
61 | itemName = args[1];
62 | quantity = StringUtils.isNumeric(args[2]) ? Integer.parseInt(args[2]) : 1;
63 | }
64 | else {
65 | itemName = args[1];
66 | }
67 | }
68 | Optional item = itemList.getItem(itemName);
69 | if (item.isPresent()) {
70 | for (int i = 0; i < quantity; i++) {
71 | sender.sendMessage(DeepStoragePlus.prefix + ChatColor.GREEN + "given " + itemName + " to " + player.orElseGet(() -> (Player) sender).getName());
72 | player.orElseGet(() -> (Player) sender).getInventory().addItem(item.get());
73 | }
74 | } else {
75 | sender.sendMessage(DeepStoragePlus.prefix + ChatColor.RED + "Invalid Arguments: /dsp give item ");
76 | return true;
77 | }
78 | } else {
79 | if (sender.hasPermission("deepstorageplus.give")) {
80 | sender.sendMessage(DeepStoragePlus.prefix + ChatColor.RED + "Invalid Arguments: /dsp [(give item ), items]");
81 | } else {
82 | sender.sendMessage(DeepStoragePlus.prefix + ChatColor.RED + "No permissions");
83 | }
84 | }
85 | }
86 | return true;
87 | }
88 | }
89 |
--------------------------------------------------------------------------------
/src/main/java/me/darkolythe/deepstorageplus/io/ConfigManager.java:
--------------------------------------------------------------------------------
1 | package me.darkolythe.deepstorageplus.io;
2 |
3 | import me.darkolythe.deepstorageplus.DeepStoragePlus;
4 | import me.darkolythe.deepstorageplus.utils.LanguageManager;
5 | import org.bukkit.Bukkit;
6 | import org.bukkit.ChatColor;
7 | import org.bukkit.event.EventHandler;
8 | import org.bukkit.event.Listener;
9 | import org.bukkit.event.player.PlayerJoinEvent;
10 | import org.bukkit.event.player.PlayerResourcePackStatusEvent;
11 | import org.bukkit.event.player.PlayerResourcePackStatusEvent.Status;
12 |
13 | public class ConfigManager implements Listener {
14 |
15 | private DeepStoragePlus main;
16 | public ConfigManager(DeepStoragePlus plugin) {
17 | main = plugin;
18 | }
19 | private String link = "https://drive.google.com/uc?export=download&id=1SW84tMz7UEnGnwEgiSNONxb4GbR0a1h9";
20 | //MAKE SURE NOT TO ZIP WHOLE FOLDER. ONLY ZIP TWO FILES INSIDE
21 |
22 | @EventHandler
23 | private void onPlayerJoin(PlayerJoinEvent event) {
24 | if (DeepStoragePlus.loadpack) {
25 | Bukkit.getServer().getScheduler().scheduleSyncDelayedTask(main, new Runnable() {
26 | @Override
27 | public void run() {
28 | event.getPlayer().setResourcePack(link);
29 | }
30 | }, 1);
31 | }
32 | }
33 |
34 | @EventHandler
35 | private void onResourcePackClick(PlayerResourcePackStatusEvent event) {
36 | Status status = event.getStatus();
37 | if (status == Status.DECLINED || status == Status.FAILED_DOWNLOAD) {
38 | if (DeepStoragePlus.packmsg) {
39 | event.getPlayer().sendMessage(DeepStoragePlus.prefix + ChatColor.RED + LanguageManager.getValue("faileddownload"));
40 | event.getPlayer().sendMessage(DeepStoragePlus.prefix + ChatColor.GRAY + LanguageManager.getValue("downloadhere") + ": " + link);
41 | }
42 | }
43 | }
44 | }
45 |
--------------------------------------------------------------------------------
/src/main/java/me/darkolythe/deepstorageplus/todo.md:
--------------------------------------------------------------------------------
1 | ##For Wireless terminal: - DONE
2 | - create texture
3 | - linking feature will be in config page. bottom right item
4 | - When linked, the item will get 'linked to DSU at:', 'x', 'y', 'z'
5 | - x y z will be how we get the inventory and update it
6 |
7 | ##For crafting terminal:
8 | - Honestly idk where the item should be yet
9 | - Will have to look into recipes that contain items in the inventory. May be too inefficient
10 |
11 | ##For IO upgrades:
12 | - There should be something in hopper listener :D
--------------------------------------------------------------------------------
/src/main/java/me/darkolythe/deepstorageplus/utils/ItemList.java:
--------------------------------------------------------------------------------
1 | package me.darkolythe.deepstorageplus.utils;
2 |
3 | import me.darkolythe.deepstorageplus.DeepStoragePlus;
4 | import org.bukkit.ChatColor;
5 | import org.bukkit.Material;
6 | import org.bukkit.enchantments.Enchantment;
7 | import org.bukkit.inventory.ItemFlag;
8 | import org.bukkit.inventory.ItemStack;
9 | import org.bukkit.inventory.meta.ItemMeta;
10 |
11 | import java.util.*;
12 |
13 | import static me.darkolythe.deepstorageplus.dsu.managers.WirelessManager.createReceiver;
14 | import static me.darkolythe.deepstorageplus.dsu.managers.WirelessManager.createTerminal;
15 |
16 | public class ItemList {
17 |
18 | private DeepStoragePlus main;
19 |
20 | public ItemStack storageCell1K;
21 | public ItemStack storageCell4K;
22 | public ItemStack storageCell16K;
23 | public ItemStack storageCell64K;
24 | public ItemStack storageCell256K;
25 | public ItemStack storageCell1M;
26 | public ItemStack storageContainer1K;
27 | public ItemStack storageContainer4K;
28 | public ItemStack storageContainer16K;
29 | public ItemStack storageContainer64K;
30 | public ItemStack storageContainer256K;
31 | public ItemStack storageContainer1M;
32 | public ItemStack creativeStorageContainer;
33 | public ItemStack storageWrench;
34 | public ItemStack sorterWrench;
35 | public ItemStack receiver;
36 | public ItemStack terminal;
37 | public ItemStack speedUpgrade;
38 | public ItemStack linkModule;
39 |
40 | public Map itemListMap = new HashMap<>();
41 |
42 | public ItemList(DeepStoragePlus plugin) {
43 | this.main = plugin; // set it equal to an instance of main
44 |
45 | // Item Definitions
46 | this.storageCell1K = createStorageCell(13010, ChatColor.WHITE + LanguageManager.getValue("storagecell") + " " + ChatColor.GRAY + ChatColor.BOLD + "1K");
47 |
48 | this.storageCell4K = createStorageCell(13011, ChatColor.WHITE + LanguageManager.getValue("storagecell") + " " + ChatColor.WHITE + ChatColor.BOLD + "4K");
49 |
50 | this.storageCell16K = createStorageCell(13012, ChatColor.WHITE + LanguageManager.getValue("storagecell") + " " + ChatColor.YELLOW + ChatColor.BOLD + "16K");
51 |
52 | this.storageCell64K = createStorageCell(13013, ChatColor.WHITE + LanguageManager.getValue("storagecell") + " " + ChatColor.GREEN + ChatColor.BOLD + "64K");
53 |
54 | this.storageCell256K = createStorageCell(13014, ChatColor.WHITE + LanguageManager.getValue("storagecell") + " " + ChatColor.BLUE + ChatColor.BOLD + "256K");
55 |
56 | this.storageCell1M = createStorageCell(13015, ChatColor.WHITE + LanguageManager.getValue("storagecell") + " " + ChatColor.LIGHT_PURPLE + ChatColor.BOLD + "1M");
57 |
58 | this.storageContainer1K = createStorageCell(13016, ChatColor.WHITE + LanguageManager.getValue("storagecontainer") + " " + ChatColor.GRAY + ChatColor.BOLD + "1K");
59 | createLore(storageContainer1K, getStorageMaxConfig("1kmax"));
60 |
61 | this.storageContainer4K = createStorageCell(13017, ChatColor.WHITE + LanguageManager.getValue("storagecontainer") + " " + ChatColor.WHITE + ChatColor.BOLD + "4K");
62 | createLore(storageContainer4K, getStorageMaxConfig("4kmax"));
63 |
64 | this.storageContainer16K = createStorageCell(13018, ChatColor.WHITE + LanguageManager.getValue("storagecontainer") + " " + ChatColor.YELLOW + ChatColor.BOLD + "16K");
65 | createLore(storageContainer16K, getStorageMaxConfig("16kmax"));
66 |
67 | this.storageContainer64K = createStorageCell(13019, ChatColor.WHITE + LanguageManager.getValue("storagecontainer") + " " + ChatColor.GREEN + ChatColor.BOLD + "64K");
68 | createLore(storageContainer64K, getStorageMaxConfig("64kmax"));
69 |
70 | this.storageContainer256K = createStorageCell(13020, ChatColor.WHITE + LanguageManager.getValue("storagecontainer") + " " + ChatColor.BLUE + ChatColor.BOLD + "256K");
71 | createLore(storageContainer256K, this.getStorageMaxConfig("256kmax"));
72 |
73 | this.storageContainer1M = createStorageCell(13021, ChatColor.WHITE + LanguageManager.getValue("storagecontainer") + " " + ChatColor.LIGHT_PURPLE + ChatColor.BOLD + "1M");
74 | createLore(storageContainer1M, getStorageMaxConfig("1mmax"));
75 |
76 | this.creativeStorageContainer = createStorageCell(13021, ChatColor.DARK_PURPLE + LanguageManager.getValue("creativestoragecontainer"));
77 | createLore(creativeStorageContainer, Integer.MAX_VALUE);
78 |
79 | this.storageWrench = createStorageWrench();
80 | this.sorterWrench = createSorterWrench();
81 | this.linkModule = createLinkModule();
82 | this.receiver = createReceiver();
83 | this.terminal = createTerminal();
84 | this.speedUpgrade = createSpeedUpgrade();
85 |
86 | itemListMap.put("storage_cell_1k", storageCell1K);
87 | itemListMap.put("storage_cell_4k", storageCell4K);
88 | itemListMap.put("storage_cell_16k", storageCell16K);
89 | itemListMap.put("storage_cell_64k", storageCell64K);
90 | itemListMap.put("storage_cell_256k", storageCell256K);
91 | itemListMap.put("storage_cell_1m", storageCell1M);
92 | itemListMap.put("storage_container_1k", storageContainer1K);
93 | itemListMap.put("storage_container_4k", storageContainer4K);
94 | itemListMap.put("storage_container_16k", storageContainer16K);
95 | itemListMap.put("storage_container_64k", storageContainer64K);
96 | itemListMap.put("storage_container_256k", storageContainer256K);
97 | itemListMap.put("storage_container_1m", storageContainer1M);
98 | itemListMap.put("creative_storage_container", creativeStorageContainer);
99 | itemListMap.put("storage_wrench", storageWrench);
100 | itemListMap.put("sorter_wrench", sorterWrench);
101 | itemListMap.put("receiver", receiver);
102 | itemListMap.put("terminal", terminal);
103 | itemListMap.put("speed_upgrade", speedUpgrade);
104 | itemListMap.put("link_module", linkModule);
105 | }
106 |
107 | // Helper methods
108 | public Optional getItem(String itemName) {
109 | ItemStack item = null;
110 | if (itemName == null) {
111 | return Optional.empty();
112 | }
113 | if (itemListMap.containsKey(itemName)) {
114 | item = itemListMap.get(itemName);
115 | }
116 | return Optional.ofNullable(item);
117 | }
118 |
119 | private int getStorageMaxConfig(String size) {
120 | if (main.getConfig().getBoolean("countinstacks")) {
121 | return main.getConfig().getInt(size) * 1024 * 64;
122 | }
123 | return main.getConfig().getInt(size) * 1024;
124 | }
125 |
126 | private static ItemStack createStorageCell(int textureId, String name) {
127 | ItemStack storageCell = new ItemStack(Material.STONE_AXE);
128 | ItemMeta storageCellMeta = storageCell.getItemMeta();
129 | storageCellMeta.setDisplayName(name);
130 | // set texture data ID
131 | storageCellMeta.setCustomModelData(textureId);
132 |
133 | storageCellMeta.setUnbreakable(true);
134 | storageCellMeta.addItemFlags(ItemFlag.HIDE_UNBREAKABLE);
135 | storageCellMeta.addItemFlags(ItemFlag.HIDE_ATTRIBUTES);
136 |
137 | storageCell.setItemMeta(storageCellMeta);
138 |
139 | return storageCell;
140 | }
141 |
142 | private static void createLore(ItemStack container, int storageMax) {
143 | int maxTypes = 7;
144 | List lore = new ArrayList<>();
145 |
146 | ItemMeta meta = container.getItemMeta();
147 | lore.add(ChatColor.GREEN + LanguageManager.getValue("currentstorage") + ": " + 0 + "/" + storageMax);
148 |
149 | lore.add(ChatColor.GREEN + LanguageManager.getValue("currenttypes") + ": " + 0 + "/" + maxTypes);
150 |
151 | for (int i = 0; i < maxTypes; i++) {
152 | lore.add(ChatColor.GRAY + " - " + LanguageManager.getValue("empty"));
153 | }
154 |
155 | meta.setLore(lore);
156 | container.setItemMeta(meta);
157 | }
158 |
159 | public static ItemStack createStorageWrench() {
160 | ItemStack storageWrench = createStorageCell(13003, ChatColor.AQUA + LanguageManager.getValue("storageloader"));
161 | storageWrench.setType(Material.STONE_AXE);
162 | ItemMeta wrenchmeta = storageWrench.getItemMeta();
163 | wrenchmeta.setLore(Arrays.asList(ChatColor.GRAY + LanguageManager.getValue("clickempty"),
164 | ChatColor.GRAY + LanguageManager.getValue("tocreatedsu"), "", ChatColor.GRAY + LanguageManager.getValue("onetimeuse")));
165 | storageWrench.setItemMeta(wrenchmeta);
166 |
167 | return storageWrench;
168 | }
169 |
170 | public static ItemStack createSorterWrench() {
171 | ItemStack sorterWrench = createStorageCell(13002, ChatColor.AQUA + LanguageManager.getValue("sorterloader"));
172 | sorterWrench.setType(Material.STONE_AXE);
173 | ItemMeta wrenchmeta = sorterWrench.getItemMeta();
174 | wrenchmeta.setLore(Arrays.asList(ChatColor.GRAY + LanguageManager.getValue("clickempty"),
175 | ChatColor.GRAY + LanguageManager.getValue("tocreatesorter"), "", ChatColor.GRAY + LanguageManager.getValue("onetimeuse")));
176 | sorterWrench.setItemMeta(wrenchmeta);
177 |
178 | return sorterWrench;
179 | }
180 |
181 | public static ItemStack createLinkModule() {
182 | ItemStack linkModule = createStorageCell(13004, ChatColor.AQUA + LanguageManager.getValue("linkmodule"));
183 | linkModule.setType(Material.STONE_AXE);
184 | ItemMeta wrenchmeta = linkModule.getItemMeta();
185 | wrenchmeta.setLore(Arrays.asList(ChatColor.GRAY + "Click DSU",
186 | ChatColor.GRAY + "To save DSU coordinates to this link module"));
187 | linkModule.setItemMeta(wrenchmeta);
188 |
189 | return linkModule;
190 | }
191 |
192 | public static ItemStack createSpeedUpgrade() {
193 | ItemStack item = new ItemStack(Material.GLOWSTONE_DUST);
194 | ItemMeta meta = item.getItemMeta();
195 | meta.setDisplayName(ChatColor.WHITE.toString() + ChatColor.BOLD.toString() + LanguageManager.getValue("ioupgrade"));
196 | meta.setLore(Arrays.asList(ChatColor.GRAY + LanguageManager.getValue("clicktoupgrade")));
197 | meta.addItemFlags(ItemFlag.HIDE_ENCHANTS);
198 | item.setItemMeta(meta);
199 | item.addUnsafeEnchantment(Enchantment.DURABILITY, 1);
200 |
201 | return item;
202 | }
203 |
204 | /**
205 | * Used to compare two ItemStacks from this mod. Returns true if they are of the same type, even if they have different lore.
206 | * @return true if the items are similar
207 | */
208 | public static boolean compareItem(ItemStack item1, ItemStack item2) {
209 | if (!item1.hasItemMeta() || !item2.hasItemMeta()) {
210 | return false;
211 | }
212 |
213 | return item1.getItemMeta().getDisplayName().equals(item2.getItemMeta().getDisplayName())
214 | && item1.getItemMeta().isUnbreakable() == item2.getItemMeta().isUnbreakable();
215 | }
216 | }
217 |
--------------------------------------------------------------------------------
/src/main/java/me/darkolythe/deepstorageplus/utils/LanguageManager.java:
--------------------------------------------------------------------------------
1 | package me.darkolythe.deepstorageplus.utils;
2 |
3 | import me.darkolythe.deepstorageplus.DeepStoragePlus;
4 |
5 | import java.util.HashMap;
6 | import java.util.Map;
7 |
8 | public class LanguageManager {
9 |
10 | private static Map translateMap = new HashMap<>();
11 |
12 | public static void setup(DeepStoragePlus main) {
13 | translateMap.put("faileddownload", main.getConfig().getString("faileddownload"));
14 | translateMap.put("downloadhere", main.getConfig().getString("downloadhere"));
15 | translateMap.put("containersfull", main.getConfig().getString("containersfull"));
16 | translateMap.put("dsuioconfig", main.getConfig().getString("dsuioconfig"));
17 | translateMap.put("input", main.getConfig().getString("input"));
18 | translateMap.put("all", main.getConfig().getString("all"));
19 | translateMap.put("output", main.getConfig().getString("output"));
20 | translateMap.put("none", main.getConfig().getString("none"));
21 | translateMap.put("sortingby", main.getConfig().getString("sortingby"));
22 | translateMap.put("container", main.getConfig().getString("container"));
23 | translateMap.put("dsuwalls", main.getConfig().getString("dsuwalls"));
24 | translateMap.put("sorterwalls", main.getConfig().getString("sorterwalls"));
25 | translateMap.put("emptystorageblock", main.getConfig().getString("emptystorageblock"));
26 | translateMap.put("empty", main.getConfig().getString("empty"));
27 | translateMap.put("storagecontainer", main.getConfig().getString("storagecontainer"));
28 | translateMap.put("creativestoragecontainer", main.getConfig().getString("creativestoragecontainer"));
29 | translateMap.put("currentstorage", main.getConfig().getString("currentstorage"));
30 | translateMap.put("currenttypes", main.getConfig().getString("currenttypes"));
31 | translateMap.put("onlydefaultitems", main.getConfig().getString("onlydefaultitems"));
32 | translateMap.put("specialcrafting", main.getConfig().getString("specialcrafting"));
33 | translateMap.put("storagecell", main.getConfig().getString("storagecell"));
34 | translateMap.put("storageloader", main.getConfig().getString("storageloader"));
35 | translateMap.put("linkmodule", main.getConfig().getString("linkmodule"));
36 | translateMap.put("sorterloader", main.getConfig().getString("sorterloader"));
37 | translateMap.put("clickempty", main.getConfig().getString("clickempty"));
38 | translateMap.put("tocreatedsu", main.getConfig().getString("tocreatedsu"));
39 | translateMap.put("tocreatesorter", main.getConfig().getString("tocreatesorter"));
40 | translateMap.put("onetimeuse", main.getConfig().getString("onetimeuse"));
41 | translateMap.put("amount", main.getConfig().getString("amount"));
42 | translateMap.put("alpha", main.getConfig().getString("alpha"));
43 | translateMap.put("nomorespace", main.getConfig().getString("nomorespace"));
44 | translateMap.put("clicktoclear", main.getConfig().getString("clicktoclear"));
45 | translateMap.put("changesorting", main.getConfig().getString("changesorting"));
46 | translateMap.put("sortscontainer", main.getConfig().getString("sortscontainer"));
47 | translateMap.put("sortsalpha", main.getConfig().getString("sortsalpha"));
48 | translateMap.put("sortsamount", main.getConfig().getString("sortsamount"));
49 | translateMap.put("sortsid", main.getConfig().getString("sortsid"));
50 | translateMap.put("clicktostart", main.getConfig().getString("clicktostart"));
51 | translateMap.put("clickinput", main.getConfig().getString("clickinput"));
52 | translateMap.put("leaveasall", main.getConfig().getString("leaveasall"));
53 | translateMap.put("clickoutput", main.getConfig().getString("clickoutput"));
54 | translateMap.put("dsucreate", main.getConfig().getString("dsucreate"));
55 | translateMap.put("sortercreate", main.getConfig().getString("sortercreate"));
56 | translateMap.put("chestmustbedouble", main.getConfig().getString("chestmustbedouble"));
57 | translateMap.put("chestmustbeempty", main.getConfig().getString("chestmustbeempty"));
58 | translateMap.put("nopermission", main.getConfig().getString("nopermission"));
59 | translateMap.put("unlinked", main.getConfig().getString("unlinked"));
60 | translateMap.put("linked", main.getConfig().getString("linked"));
61 | translateMap.put("terminal", main.getConfig().getString("terminal"));
62 | translateMap.put("receiver", main.getConfig().getString("receiver"));
63 | translateMap.put("clicktolink", main.getConfig().getString("clicktolink"));
64 | translateMap.put("cantopenin", main.getConfig().getString("cantopenin"));
65 | translateMap.put("dsunolongerthere", main.getConfig().getString("dsunolongerthere"));
66 | translateMap.put("shiftswap", main.getConfig().getString("shiftswap"));
67 | translateMap.put("world", main.getConfig().getString("world"));
68 | translateMap.put("locked", main.getConfig().getString("locked"));
69 | translateMap.put("unlocked", main.getConfig().getString("unlocked"));
70 | translateMap.put("leftclicktoadd", main.getConfig().getString("leftclicktoadd"));
71 | translateMap.put("rightclicktoremove", main.getConfig().getString("rightclicktoremove"));
72 | translateMap.put("notallowedtoopen", main.getConfig().getString("notallowedtoopen"));
73 | translateMap.put("entername", main.getConfig().getString("entername"));
74 | translateMap.put("iospeed", main.getConfig().getString("iospeed"));
75 | translateMap.put("ioupgrade", main.getConfig().getString("ioupgrade"));
76 | translateMap.put("clicktoupgrade", main.getConfig().getString("clicktoupgrade"));
77 | translateMap.put("upgradesuccess", main.getConfig().getString("upgradesuccess"));
78 | translateMap.put("upgradefail", main.getConfig().getString("upgradefail"));
79 | translateMap.put("owner", main.getConfig().getString("owner"));
80 | translateMap.put("notowner", main.getConfig().getString("notowner"));
81 | translateMap.put("typecancel", main.getConfig().getString("typecancel"));
82 | translateMap.put("maxdistance", main.getConfig().getString("maxdistance"));
83 | translateMap.put("toofar", main.getConfig().getString("toofar"));
84 | translateMap.put("givecommand", main.getConfig().getString("givecommand"));
85 | translateMap.put("emptysorterblock", main.getConfig().getString("emptysorterblock"));
86 | translateMap.put("nowirelesspermission", main.getConfig().getString("nowirelesspermission"));
87 | }
88 |
89 | public static String getValue(String key) {
90 | if (translateMap.containsKey(key)) {
91 | return translateMap.get(key);
92 | } else {
93 | return "[Invalid Translate Key]";
94 | }
95 | }
96 | }
97 |
--------------------------------------------------------------------------------
/src/main/java/me/darkolythe/deepstorageplus/utils/RecipeManager.java:
--------------------------------------------------------------------------------
1 | package me.darkolythe.deepstorageplus.utils;
2 |
3 | import me.darkolythe.customrecipeapi.APIManager;
4 | import me.darkolythe.customrecipeapi.CustomRecipeAPI;
5 | import me.darkolythe.deepstorageplus.DeepStoragePlus;
6 | import org.bukkit.Bukkit;
7 | import org.bukkit.ChatColor;
8 | import org.bukkit.Material;
9 | import org.bukkit.NamespacedKey;
10 | import org.bukkit.inventory.ItemStack;
11 | import org.bukkit.inventory.ShapedRecipe;
12 | import org.bukkit.inventory.meta.ItemMeta;
13 |
14 | public class RecipeManager {
15 |
16 | private DeepStoragePlus main;
17 | private ItemList itemList;
18 |
19 | public RecipeManager(DeepStoragePlus plugin, ItemList itemList) {
20 | this.main = plugin; // set it equal to an instance of main
21 | this.itemList = itemList;
22 |
23 | if (APIManager.getWorkbench() == null) {
24 | createWorkbench();
25 | }
26 | createStorages();
27 | }
28 |
29 | private void createWorkbench() {
30 | ItemStack workbenchItem = new ItemStack(Material.DISPENSER);
31 | ItemMeta meta = workbenchItem.getItemMeta();
32 | meta.setDisplayName(ChatColor.YELLOW.toString() + ChatColor.BOLD.toString() + LanguageManager.getValue("specialcrafting"));
33 | workbenchItem.setItemMeta(meta);
34 | ShapedRecipe workbenchRecipe = new ShapedRecipe(new NamespacedKey(main, "Workbench"), workbenchItem);
35 | workbenchRecipe.shape("IGI", "GDG", "IGI");
36 | workbenchRecipe.setIngredient('I', Material.IRON_BLOCK);
37 | workbenchRecipe.setIngredient('G', Material.GLASS);
38 | workbenchRecipe.setIngredient('D', Material.DIAMOND_BLOCK);
39 | Bukkit.getServer().addRecipe(workbenchRecipe);
40 |
41 | APIManager.setWorkBench(workbenchRecipe);
42 | }
43 |
44 | private void createStorages() {
45 | ItemStack redstone = new ItemStack(Material.REDSTONE);
46 | ItemStack quartz = new ItemStack(Material.QUARTZ);
47 | ItemStack gold = new ItemStack(Material.GOLD_INGOT);
48 | ItemStack iron = new ItemStack(Material.IRON_INGOT);
49 | ItemStack glass = new ItemStack(Material.GLASS);
50 | ItemStack glowstone = new ItemStack(Material.GLOWSTONE_DUST);
51 | ItemStack diamond = new ItemStack(Material.DIAMOND);
52 | ItemStack emerald = new ItemStack(Material.EMERALD);
53 | ItemStack air = new ItemStack(Material.AIR);
54 | ItemStack diamondblock = new ItemStack(Material.DIAMOND_BLOCK);
55 | ItemStack redstoneblock = new ItemStack(Material.REDSTONE_BLOCK, 32);
56 | ItemStack endereye = new ItemStack(Material.ENDER_EYE);
57 |
58 | CustomRecipeAPI.createRecipe(itemList.storageCell1K, redstone, quartz, redstone, quartz, gold, quartz, redstone, quartz, redstone);
59 | CustomRecipeAPI.createRecipe(itemList.storageCell4K, redstone, iron, redstone, itemList.storageCell1K, glass, itemList.storageCell1K, redstone, itemList.storageCell1K, redstone);
60 | CustomRecipeAPI.createRecipe(itemList.storageCell16K, glowstone, diamond, glowstone, itemList.storageCell4K, glass, itemList.storageCell4K, glowstone, itemList.storageCell4K, glowstone);
61 | CustomRecipeAPI.createRecipe(itemList.storageCell64K, glowstone, diamond, glowstone, itemList.storageCell16K, glass, itemList.storageCell16K, glowstone, itemList.storageCell16K, glowstone);
62 | CustomRecipeAPI.createRecipe(itemList.storageCell256K, emerald, diamond, emerald, itemList.storageCell64K, glass, itemList.storageCell64K, emerald, itemList.storageCell64K, emerald);
63 | CustomRecipeAPI.createRecipe(itemList.storageCell1M, emerald, diamond, emerald, itemList.storageCell256K, glass, itemList.storageCell256K, emerald, itemList.storageCell256K, emerald);
64 |
65 | CustomRecipeAPI.createRecipe(itemList.storageContainer1K, glass, redstone, glass, redstone, itemList.storageCell1K, redstone, iron, iron, iron);
66 | CustomRecipeAPI.createRecipe(itemList.storageContainer4K, glass, redstone, glass, redstone, itemList.storageCell4K, redstone, iron, iron, iron);
67 | CustomRecipeAPI.createRecipe(itemList.storageContainer16K, glass, redstone, glass, redstone, itemList.storageCell16K, redstone, gold, gold, gold);
68 | CustomRecipeAPI.createRecipe(itemList.storageContainer64K, glass, redstone, glass, redstone, itemList.storageCell64K, redstone, gold, gold, gold);
69 | CustomRecipeAPI.createRecipe(itemList.storageContainer256K, glass, redstone, glass, redstone, itemList.storageCell256K, redstone, diamond, diamond, diamond);
70 | CustomRecipeAPI.createRecipe(itemList.storageContainer1M, glass, redstone, glass, redstone, itemList.storageCell1M, redstone, diamond, diamond, diamond);
71 |
72 | CustomRecipeAPI.createRecipe(itemList.sorterWrench, iron, air, iron, air, gold, air, iron, air, iron);
73 | CustomRecipeAPI.createRecipe(itemList.storageWrench, iron, air, iron, air, quartz, air, iron, air, iron);
74 | CustomRecipeAPI.createRecipe(itemList.linkModule, redstone, quartz, redstone, diamond, gold, diamond, redstone, quartz, redstone);
75 | CustomRecipeAPI.createRecipe(itemList.receiver, air, endereye, air, air, quartz, air, iron, diamond, iron);
76 | CustomRecipeAPI.createRecipe(itemList.terminal, air, itemList.receiver, air, redstoneblock, diamondblock, redstoneblock, diamond, quartz, diamond);
77 | CustomRecipeAPI.createRecipe(itemList.speedUpgrade, redstone, redstone, redstone, redstone, diamond, redstone, redstone, redstone, redstone);
78 | }
79 | }
80 |
--------------------------------------------------------------------------------
/src/main/resources/config.yml:
--------------------------------------------------------------------------------
1 | loadresourcepack: true
2 | resourcepackmessage: true
3 | prefix: "&f&l[&9&lDeepStoragePlus&f&l]"
4 | range: 500
5 | # range is used for the maximum distance a player can be from the DSU to use the wireless terminal.
6 | # Set to -1 for no max distance.
7 |
8 | all: "all"
9 | alpha: "alpha"
10 | amount: "amount"
11 | cantopenin: "You can't open that in"
12 | changesorting: "Click to change sorting type."
13 | chestmustbedouble: "The chest must be a double chest"
14 | chestmustbeempty: "The chest must be empty"
15 | clickempty: "Click on an empty double chest"
16 | clickinput: "Then click an item in the dsu to input via hopper"
17 | clickoutput: "Then click an item in the dsu to output via hopper."
18 | clicktoclear: "Click on this slot to clear selection."
19 | clicktolink: "Right click on a DSU to link with it"
20 | clicktostart: "Click on this slot to start selection."
21 | clicktoupgrade: "Right click on a DSU to apply the upgrade"
22 | container: "container"
23 | containersfull: "Storage containers are full"
24 | creativestoragecontainer: "Creative Storage Container"
25 | currentstorage: "Current Storage"
26 | currenttypes: "Current Types"
27 | downloadhere: "Download it here:"
28 | dsucreate: "Deep Storage Unit successfully created"
29 | dsuioconfig: "DSU IO Configuration"
30 | dsunolongerthere: "Your DSU is no longer there"
31 | dsuwalls: "dsu Walls"
32 | empty: "empty"
33 | emptysorterblock: "Empty Sorter Block"
34 | emptystorageblock: "Empty Storage Block"
35 | entername: "Enter username to add to lock"
36 | faileddownload: "This plugin will be hard to use without the very light resource pack that's designed for it."
37 | givecommand: "give"
38 | input: "Input"
39 | iospeed: "IO Speed"
40 | ioupgrade: "IO Speed Upgrade"
41 | leaveasall: "Leave as 'all' to allow all items."
42 | leftclicktoadd: "Left Click to add users to DSU"
43 | linked: "Linked"
44 | linkmodule: "Link Module"
45 | locked: "Locked"
46 | maxdistance: "Max Distance"
47 | nomorespace: "No more space for items in your inventory"
48 | none: "none"
49 | nopermission: "You do not have permission to create a dsu!"
50 | notallowedtoopen: "You are not allowed to open that DSU"
51 | notowner: "You are not the owner of this DSU"
52 | nowirelesspermission: "You do not have permission to use wireless terminals"
53 | onetimeuse: "One-time use."
54 | onlydefaultitems: "You can only store default items in the dsu"
55 | output: "Output"
56 | owner: "Owner"
57 | receiver: "Wireless Receiver"
58 | rightclicktoremove: "Right Click to unlock and remove all users"
59 | shiftswap: "Crouch + Swap Offhand to Unlink"
60 | sortercreate: "Sorter successfully created"
61 | sorterloader: "Sorter Loader"
62 | sorterwalls: "sorter walls"
63 | sortingby: "Sorting By"
64 | sortsalpha: "sorts in alphabetical order."
65 | sortsamount: "sorts by descending amount of items."
66 | sortscontainer: "sorts in order of items in storage containers."
67 | sortsid: "sorts by ID number."
68 | specialcrafting: "Special Crafting"
69 | storagecell: "Storage Cell"
70 | storagecontainer: "Storage Container"
71 | storageloader: "Deep Storage Loader"
72 | terminal: "Wireless Terminal"
73 | tocreatedsu: "to create a deep storage unit"
74 | tocreatesorter: "to create a sorter"
75 | toofar: "You are too far away"
76 | typecancel: "Type 'cancel' to cancel"
77 | unlinked: "Unlinked"
78 | unlocked: "Unlocked"
79 | upgradefail: "DSU IO Speed at maximum"
80 | upgradesuccess: "DSU IO Speed Upgraded"
81 | world: "World"
82 |
83 | # Max Storage Sizes (in kilobytes)
84 | # These settings determine the size of containers at the time of crafting, not retroactively
85 | countinstacks: false # Max items counted in stacks rather than by single items
86 | 1kmax: 1
87 | 4kmax: 4
88 | 16kmax: 16
89 | 64kmax: 64
90 | 256kmax: 256
91 | 1mmax: 1024
--------------------------------------------------------------------------------
/src/main/resources/plugin.yml:
--------------------------------------------------------------------------------
1 | name: DeepStoragePlus
2 | version: 1.11.8
3 | main: me.darkolythe.deepstorageplus.DeepStoragePlus
4 | api-version: 1.13
5 | depend: [CustomRecipeAPI]
6 |
7 | commands:
8 | deepstorageplus:
9 | usage: /
10 | aliases: [dsp]
11 | description: the base dsp command
12 | permission: deepstorageplus.command
13 | permission-message: You do not have permission!
14 |
15 | permissions:
16 | deepstorageplus.create:
17 | description: Allows the user to create a DSU
18 | default: op
19 | deepstorageplus.adminopen:
20 | description: Allows the user to open locked DSUs
21 | default: op
22 | deepstorageplus.wireless:
23 | description: Allows the user to use the wireless terminal
24 | default: op
25 | deepstorageplus.give:
26 | description: Allows access to give command to give players items from this plugin
27 | default: op
--------------------------------------------------------------------------------