This repository has been archived by the owner on Apr 12, 2022. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 6
/
ForgetInventoryCommand.java
70 lines (62 loc) · 2.23 KB
/
ForgetInventoryCommand.java
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
package com.denizenscript.denizen2sponge.commands.items;
import com.denizenscript.denizen2core.commands.AbstractCommand;
import com.denizenscript.denizen2core.commands.CommandEntry;
import com.denizenscript.denizen2core.commands.CommandQueue;
import com.denizenscript.denizen2core.tags.AbstractTagObject;
import com.denizenscript.denizen2core.utilities.debugging.ColorSet;
import com.denizenscript.denizen2sponge.Denizen2Sponge;
import com.denizenscript.denizen2sponge.tags.objects.InventoryTag;
public class ForgetInventoryCommand extends AbstractCommand {
// <--[command]
// @Since 0.3.0
// @Name forgetinventory
// @Arguments <inventory/name>
// @Short forgets a remembered inventory.
// @Updated 2018/06/05
// @Group Items
// @Minimum 1
// @Maximum 1
// @Description
// Forgets an inventory that was remembered.
// See also the <@link command rememberinventory>rememberinventory command<@/link>.
// @Example
// # This example forgets the inventory named "Test".
// - forgetinventory "Test"
// -->
@Override
public String getName() {
return "forgetinventory";
}
@Override
public String getArguments() {
return "<inventory/name>";
}
@Override
public int getMinimumArguments() {
return 1;
}
@Override
public int getMaximumArguments() {
return 1;
}
@Override
public void execute(CommandQueue queue, CommandEntry entry) {
AbstractTagObject inv = entry.getArgumentObject(queue, 0);
String name;
if (inv instanceof InventoryTag) {
if (((InventoryTag) inv).remAs != null) {
name = ((InventoryTag) inv).remAs;
}
else {
queue.error.run("Trying to forget an inventory that isn't a remembered inventory - " + ColorSet.emphasis + inv.debug());
return;
}
}
else {
name = inv.toString();
}
if (Denizen2Sponge.rememberedInventories.remove(name) == null) {
queue.error.run("Trying to forget an inventory by a name that isn't remembered - " + ColorSet.emphasis + inv.debug());
}
}
}