-
Notifications
You must be signed in to change notification settings - Fork 9
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #3 from dizzyd/dss-add-world-commands-redux
Redux of world commands
- Loading branch information
Showing
4 changed files
with
116 additions
and
5 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
73 changes: 73 additions & 0 deletions
73
src/main/java/cofh/cofhworld/command/CommandCoFHWorld.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,73 @@ | ||
package cofh.cofhworld.command; | ||
|
||
import cofh.cofhworld.feature.IFeatureGenerator; | ||
import cofh.cofhworld.init.WorldHandler; | ||
import net.minecraft.command.CommandBase; | ||
import net.minecraft.command.CommandException; | ||
import net.minecraft.command.ICommandSender; | ||
import net.minecraft.server.MinecraftServer; | ||
import net.minecraftforge.server.command.CommandTreeBase; | ||
|
||
public class CommandCoFHWorld extends CommandTreeBase { | ||
|
||
@Override | ||
public String getName() { | ||
return "cofhworld"; | ||
} | ||
|
||
@Override | ||
public String getUsage(ICommandSender sender) { | ||
return "cofhworld.usage"; | ||
} | ||
|
||
public CommandCoFHWorld() { | ||
addSubcommand(new CommandReload()); | ||
addSubcommand(new CommandList()); | ||
} | ||
|
||
// Command to reload all feature definitions | ||
public static class CommandReload extends CommandBase { | ||
@Override | ||
public String getName() { | ||
return "reload"; | ||
} | ||
|
||
@Override | ||
public String getUsage(ICommandSender sender) { | ||
return "cofhworld.reload.usage"; | ||
} | ||
|
||
@Override | ||
public void execute(MinecraftServer server, ICommandSender sender, String[] args) throws CommandException { | ||
if (WorldHandler.reloadConfig()) { | ||
notifyCommandListener(sender, this, "cofhworld.reload.successful"); | ||
} else { | ||
notifyCommandListener(sender, this, "cofhworld.reload.failed"); | ||
} | ||
} | ||
} | ||
|
||
// Command to list all feature definitions | ||
public static class CommandList extends CommandBase { | ||
|
||
@Override | ||
public String getName() { | ||
return "list"; | ||
} | ||
|
||
@Override | ||
public String getUsage(ICommandSender sender) { | ||
return "cofhworld.list.usage"; | ||
} | ||
|
||
@Override | ||
public void execute(MinecraftServer server, ICommandSender sender, String[] args) throws CommandException { | ||
StringBuilder b = new StringBuilder(); | ||
b.append("\n"); | ||
for (IFeatureGenerator feature: WorldHandler.getFeatures()) { | ||
b.append("* " + feature.getFeatureName() + "\n"); | ||
} | ||
notifyCommandListener(sender, this, "cofhworld.list", b.toString()); | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
|
||
cofhworld.reload.usage=Reloads CoFHWorld configuration | ||
cofhworld.reload.successful=Configuration reloaded. | ||
cofhworld.reload.failed=Failed to reload config; check your logs. | ||
cofhworld.list.usage=Lists all CoFHWorld features | ||
cofhworld.list=Available CoFHWorld features: %s |