This repository was archived by the owner on Feb 19, 2019. It is now read-only.
File tree Expand file tree Collapse file tree 2 files changed +41
-0
lines changed
example/java/me/zero/example/command
main/java/clientapi/command/executor/parser/impl Expand file tree Collapse file tree 2 files changed +41
-0
lines changed Original file line number Diff line number Diff line change @@ -48,6 +48,7 @@ public final void load() {
4848 handler .registerParser (new CharParser ());
4949 handler .registerParser (new ColorParser ());
5050 handler .registerParser (new CommandParser (ExampleClient .getInstance ().getCommandManager ()));
51+ handler .registerParser (new ItemParser ());
5152 handler .registerParser (new ModuleParser (ExampleClient .getInstance ().getModuleManager ()));
5253 handler .registerParser (new NumberParser ());
5354 handler .registerParser (new OptionalParser ());
Original file line number Diff line number Diff line change 1+ /*
2+ * Copyright 2018 ImpactDevelopment
3+ *
4+ * Licensed under the Apache License, Version 2.0 (the "License");
5+ * you may not use this file except in compliance with the License.
6+ * You may obtain a copy of the License at
7+ *
8+ * http://www.apache.org/licenses/LICENSE-2.0
9+ *
10+ * Unless required by applicable law or agreed to in writing, software
11+ * distributed under the License is distributed on an "AS IS" BASIS,
12+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13+ * See the License for the specific language governing permissions and
14+ * limitations under the License.
15+ */
16+
17+ package clientapi .command .executor .parser .impl ;
18+
19+ import clientapi .command .executor .ExecutionContext ;
20+ import clientapi .command .executor .parser .ArgumentParser ;
21+ import net .minecraft .item .Item ;
22+
23+ import java .lang .reflect .Type ;
24+
25+ /**
26+ * @author Brady
27+ * @since 4/19/2018 3:13 PM
28+ */
29+ public final class ItemParser implements ArgumentParser <Item > {
30+
31+ @ Override
32+ public final Item parse (ExecutionContext context , Type type , String raw ) {
33+ return Item .getByNameOrId (raw );
34+ }
35+
36+ @ Override
37+ public boolean isTarget (Type type ) {
38+ return type instanceof Class && Item .class .isAssignableFrom ((Class ) type );
39+ }
40+ }
You can’t perform that action at this time.
0 commit comments