Skip to content

Commit c11dafe

Browse files
committed
Added debug command, removed old commented code.
1 parent 0385adc commit c11dafe

File tree

4 files changed

+77
-31
lines changed

4 files changed

+77
-31
lines changed

build.gradle

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ plugins {
44

55

66
group = 'com.bencrow11'
7-
version = '1.0.2'
7+
version = '1.0.3'
88

99
java {
1010
archivesBaseName = 'BetterBreeding'

src/main/java/com/bencrow11/betterbreeding/BetterBreeding.java

Lines changed: 1 addition & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,7 @@ public void onServerStarting(FMLServerStartingEvent event) {
3333
@SubscribeEvent
3434
public void registerCommand(RegisterCommandsEvent event) {
3535
new CommandPokebuilder(event.getDispatcher());
36+
new CommandDebug(event.getDispatcher());
3637
}
3738

3839

@@ -64,34 +65,6 @@ public void checkEgg(PokemonReceivedEvent event) {
6465
}
6566

6667
pokemon.addFlag("unbreedable");
67-
68-
// If the pokemon isn't given with /pokegive
69-
// if (pokemon.getOriginalTrainerUUID() != null) {
70-
// // if the player UUID is the same as the pokemon OT UUID and the pokemon hasn't been pokebuilt
71-
//
72-
// // If OT and UUID match, and no pb flag, its breedable
73-
// if (targetPlayerUUID.equals(pokemon.getOriginalTrainerUUID()) && !pokemon.hasFlag("Pokebuilder")) {
74-
// pokemon.removeFlag("unbreedable");
75-
// // If the pokemon has been sold on gts as breedable
76-
// } else if (targetPlayerUUID.toString().equals(pokemon.getPersistentData().getString("currentOwner"))) {
77-
// pokemon.removeFlag("unbreedable");
78-
// } else {
79-
// pokemon.addFlag("unbreedable");
80-
// }
81-
//
82-
//
83-
//
84-
//
85-
// if (pokemon.getOriginalTrainerUUID().equals(event.getPlayer().getUniqueID()) && !pokemon.hasFlag("Pokebuilder")) {
86-
// // Set the pokemon to breedable
87-
// pokemon.removeFlag("unbreedable");
88-
// // If the pokemon isn't already set as unbreedable
89-
// } else if (!pokemon.isUnbreedable()) {
90-
// // Set the pokemon to unbreedable
91-
// pokemon.addFlag("unbreedable");
92-
//// }
93-
// }
94-
9568
}
9669

9770
}
Lines changed: 73 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,73 @@
1+
package com.bencrow11.betterbreeding;
2+
3+
import com.google.common.collect.Lists;
4+
import com.mojang.brigadier.CommandDispatcher;
5+
import com.mojang.brigadier.exceptions.CommandSyntaxException;
6+
import com.pixelmonmod.pixelmon.api.pokemon.Pokemon;
7+
import com.pixelmonmod.pixelmon.api.storage.PartyStorage;
8+
import com.pixelmonmod.pixelmon.api.storage.StorageProxy;
9+
import com.pixelmonmod.pixelmon.comm.CommandChatHandler;
10+
import com.pixelmonmod.pixelmon.command.PixelCommand;
11+
import net.minecraft.command.CommandException;
12+
import net.minecraft.command.CommandSource;
13+
import net.minecraft.entity.player.ServerPlayerEntity;
14+
import net.minecraft.util.text.TextFormatting;
15+
import net.minecraftforge.fml.server.ServerLifecycleHooks;
16+
import net.minecraftforge.server.permission.PermissionAPI;
17+
import org.w3c.dom.Text;
18+
19+
import java.util.List;
20+
import java.util.Objects;
21+
22+
public class CommandDebug extends PixelCommand {
23+
24+
25+
public CommandDebug(CommandDispatcher<CommandSource> dispatcher) {
26+
super(dispatcher);
27+
}
28+
29+
public String getName() {
30+
return "pbdebug";
31+
}
32+
33+
@Override
34+
public List<String> getAliases() {
35+
return Lists.newArrayList("pbdebug");
36+
}
37+
38+
@Override
39+
public void execute(CommandSource sender, String[] args) throws CommandException, CommandSyntaxException {
40+
// Checks for permission to use the command
41+
if (!PermissionAPI.hasPermission(sender.asPlayer(), "pokebuilder.admin")) {
42+
CommandChatHandler.sendChat(sender, TextFormatting.RED + "You do not have permission for this command!");
43+
} else {
44+
// checks arg amount is correct
45+
if (args.length != 1) {
46+
CommandChatHandler.sendChat(sender, TextFormatting.RED + "Usage: /pbdebug <slot>");
47+
} else {
48+
try {
49+
int slot = Integer.parseInt(args[0]);
50+
PartyStorage storage = StorageProxy.getParty(sender.asPlayer().getUniqueID());
51+
Pokemon pokemon = storage.get(slot - 1);
52+
53+
if (pokemon == null) {
54+
CommandChatHandler.sendChat(sender, TextFormatting.RED + "No Pokemon in slot " + slot);
55+
return;
56+
}
57+
58+
// Prints pokemon information to chat
59+
CommandChatHandler.sendChat(sender, TextFormatting.AQUA + "Pokebuilt: " + pokemon.hasFlag(
60+
"Pokebuilder"));
61+
CommandChatHandler.sendChat(sender, TextFormatting.AQUA + "Can breed: " + !pokemon.hasFlag(
62+
"unbreedable"));
63+
CommandChatHandler.sendChat(sender,
64+
TextFormatting.AQUA + "Current Owner: " + pokemon.getPersistentData().getString(
65+
"currentOwner"));
66+
67+
} catch (Exception error) {
68+
CommandChatHandler.sendChat(sender, TextFormatting.RED + "Usage: /pbdebug <slot>");
69+
}
70+
}
71+
}
72+
}
73+
}

src/main/java/com/bencrow11/betterbreeding/CommandPokebuilder.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@ public void execute(CommandSource sender, String[] args) throws CommandException
4141
} else {
4242
// checks arg amount is correct
4343
if (args.length != 2) {
44-
CommandChatHandler.sendChat(sender, TextFormatting.RED + "Usage: /pokebuilder <player> <slot>");
44+
CommandChatHandler.sendChat(sender, TextFormatting.RED + "Usage: /pbtag <player> <slot>");
4545
} else {
4646
try {
4747
// gets the player given
@@ -59,7 +59,7 @@ public void execute(CommandSource sender, String[] args) throws CommandException
5959
Objects.requireNonNull(storage.get(slot - 1)).addFlag("unbreedable");
6060
Objects.requireNonNull(storage.get(slot - 1)).getPersistentData().remove("currentOwner");
6161
} catch (Exception error) {
62-
CommandChatHandler.sendChat(sender, TextFormatting.RED + "Usage: /pokebuilder <player> <slot>");
62+
CommandChatHandler.sendChat(sender, TextFormatting.RED + "Usage: /pbtag <player> <slot>");
6363
}
6464
}
6565
}

0 commit comments

Comments
 (0)