@@ -45,7 +45,7 @@ public static void initValidCommandArguments(InputStream file)
45
45
validCommands .add ("changelog" );
46
46
validCommands .add ("guide" );
47
47
validCommands .add ("removeBooks" );
48
-
48
+
49
49
supportedModsAndList .add ("list" );
50
50
51
51
supportedModsAndList .addAll (TxtParser .getSupportedMods (file ));
@@ -72,7 +72,7 @@ public String getCommandUsage(ICommandSender icommandsender)
72
72
{
73
73
return "tppi <arg>" ;
74
74
}
75
-
75
+
76
76
@ Override
77
77
public boolean canCommandSenderUseCommand (ICommandSender par1iCommandSender )
78
78
{
@@ -111,15 +111,25 @@ public void processCommand(ICommandSender icommandsender, String[] astring)
111
111
else if (astring [0 ].equalsIgnoreCase ("mods" ))
112
112
{
113
113
processCommandMods (icommandsender , astring );
114
- }else if (astring [0 ].equalsIgnoreCase ("ores" )) {
114
+ }
115
+ else if (astring [0 ].equalsIgnoreCase ("ores" ))
116
+ {
115
117
processVanillaBookCommand ("TPPI Ore Generation Guide" , "OreGen.txt" , icommandsender , astring );
116
- }else if (astring [0 ].equalsIgnoreCase ("getInvolved" )) {
118
+ }
119
+ else if (astring [0 ].equalsIgnoreCase ("getInvolved" ))
120
+ {
117
121
processVanillaBookCommand ("Getting Involved In TPPI" , "GetInvolved.txt" , icommandsender , astring );
118
- }else if (astring [0 ].equalsIgnoreCase ("changelog" )) {
122
+ }
123
+ else if (astring [0 ].equalsIgnoreCase ("changelog" ))
124
+ {
119
125
processCommandChangelog (icommandsender );
120
- }else if (astring [0 ].equalsIgnoreCase ("guide" )) {
126
+ }
127
+ else if (astring [0 ].equalsIgnoreCase ("guide" ))
128
+ {
121
129
processCommandGuide (icommandsender );
122
- }else if (astring [0 ].equalsIgnoreCase ("removeBooks" )) {
130
+ }
131
+ else if (astring [0 ].equalsIgnoreCase ("removeBooks" ))
132
+ {
123
133
removeGuideBooks (icommandsender );
124
134
}
125
135
@@ -141,34 +151,39 @@ else if (astring[0].equalsIgnoreCase("mods"))
141
151
142
152
}
143
153
144
- private void removeGuideBooks (ICommandSender command ) {
154
+ private void removeGuideBooks (ICommandSender command )
155
+ {
145
156
EntityPlayer player = command .getEntityWorld ().getPlayerEntityByName (command .getCommandSenderName ());
146
157
ItemStack [] inv = player .inventory .mainInventory ;
147
158
for (int i = 0 ; i < inv .length ; i ++)
148
159
{
149
160
if (inv [i ] != null && // no null itemstack
150
- inv [i ].stackTagCompound != null && // no null stack tag
151
- inv [i ].stackTagCompound .toString ().contains (ConfigurationHandler .bookAuthor ) && // has the author
152
- inv [i ].itemID == Item .writtenBook .itemID ) // is a vanilla book
153
-
154
- inv [i ] = null ;
161
+ inv [i ].stackTagCompound != null && // no null stack tag
162
+ inv [i ].stackTagCompound .toString ().contains (ConfigurationHandler .bookAuthor ) && // has
163
+ // the
164
+ // author
165
+ inv [i ].itemID == Item .writtenBook .itemID ) // is a vanilla
166
+ // book
167
+
168
+ inv [i ] = null ;
155
169
}
156
170
}
157
171
158
172
private void processCommandGuide (ICommandSender command )
159
173
{
160
174
ItemStack stack = new ItemStack (ModItems .tppiBook , 1 , 2 );
161
-
175
+
162
176
if (!command .getEntityWorld ().getPlayerEntityByName (command .getCommandSenderName ()).inventory .addItemStackToInventory (stack ))
163
177
command .getEntityWorld ().getPlayerEntityByName (command .getCommandSenderName ()).entityDropItem (stack , 0 );
164
178
}
165
179
166
- private void processVanillaBookCommand (String title , String textFileName , ICommandSender command , String [] astring ) {
167
-
168
- InputStream file = TPPITweaks .class .getResourceAsStream ("/assets/tppitweaks/lang/" +textFileName );
180
+ private void processVanillaBookCommand (String title , String textFileName , ICommandSender command , String [] astring )
181
+ {
182
+
183
+ InputStream file = TPPITweaks .class .getResourceAsStream ("/assets/tppitweaks/lang/" + textFileName );
169
184
List <String > vanillaBookText = file == null ? new ArrayList <String >() : TxtParser .parseFileMain (file );
170
185
ItemStack book = new ItemStack (Item .writtenBook );
171
-
186
+
172
187
book .setTagInfo ("author" , new NBTTagString ("author" , ConfigurationHandler .bookAuthor ));
173
188
book .setTagInfo ("title" , new NBTTagString ("title" , title ));
174
189
@@ -182,10 +197,10 @@ private void processVanillaBookCommand(String title, String textFileName, IComma
182
197
183
198
nbttagcompound .setTag ("pages" , bookPages );
184
199
nbttagcompound .setString ("version" , TPPITweaks .VERSION );
185
-
200
+
186
201
if (!command .getEntityWorld ().getPlayerEntityByName (command .getCommandSenderName ()).inventory .addItemStackToInventory (book ))
187
202
command .getEntityWorld ().getPlayerEntityByName (command .getCommandSenderName ()).entityDropItem (book , 0 );
188
-
203
+
189
204
}
190
205
191
206
private boolean processCommandMods (ICommandSender command , String [] args )
@@ -233,20 +248,21 @@ private boolean processCommandDownload(ICommandSender command, String[] args)
233
248
PacketDispatcher .sendPacketToPlayer (packet , (Player ) command .getEntityWorld ().getPlayerEntityByName (command .getCommandSenderName ()));
234
249
return true ;
235
250
}
236
-
251
+
237
252
return false ;
238
253
}
239
-
254
+
240
255
private boolean processCommandChangelog (ICommandSender command )
241
256
{
242
257
ItemStack changelog = ModItems .tppiBook .getChangelog ();
243
-
258
+
244
259
if (changelog == null )
245
260
return false ;
246
-
247
- if (!command .getEntityWorld ().getPlayerEntityByName (command .getCommandSenderName ()).inventory .addItemStackToInventory (changelog ));
248
- command .getEntityWorld ().getPlayerEntityByName (command .getCommandSenderName ()).entityDropItem (changelog , 0 );
249
-
261
+
262
+ if (!command .getEntityWorld ().getPlayerEntityByName (command .getCommandSenderName ()).inventory .addItemStackToInventory (changelog ))
263
+ ;
264
+ command .getEntityWorld ().getPlayerEntityByName (command .getCommandSenderName ()).entityDropItem (changelog , 0 );
265
+
250
266
return true ;
251
267
}
252
268
@@ -283,7 +299,7 @@ private void giveModBook(String modName, ICommandSender command)
283
299
NBTTagList bookPages = new NBTTagList ("pages" );
284
300
285
301
ArrayList <String > pages ;
286
-
302
+
287
303
pages = TxtParser .parseFileMods (FileLoader .getSupportedModsFile (), modName + ", " + properName );
288
304
289
305
if (pages .get (0 ).startsWith ("<" ) && pages .get (0 ).endsWith ("> " ))
@@ -302,21 +318,18 @@ private void giveModBook(String modName, ICommandSender command)
302
318
if (!command .getEntityWorld ().getPlayerEntityByName (command .getCommandSenderName ()).inventory .addItemStackToInventory (stack ))
303
319
command .getEntityWorld ().getPlayerEntityByName (command .getCommandSenderName ()).entityDropItem (stack , 0 );
304
320
}
305
-
321
+
306
322
public static String getProperName (String modid )
307
323
{
308
324
return modProperNames .get (modid );
309
325
}
310
-
311
- @ Override
312
- public int compareTo (Object arg0 )
313
- {
314
- return this .compareTo ((ICommand ) arg0 );
315
- }
316
326
317
327
@ Override
318
- public boolean equals (Object obj )
319
- {
320
- return this .compareTo (obj ) == 0 ;
321
- }
328
+ public int compareTo (Object o ) {
329
+ if (o instanceof ICommand ) {
330
+ return this .compareTo ((ICommand ) o );
331
+ } else {
332
+ return 0 ;
333
+ }
334
+ }
322
335
}
0 commit comments