Skip to content

Commit

Permalink
Add reset command to fix issues when changing time unit
Browse files Browse the repository at this point in the history
  • Loading branch information
hsyyid committed Apr 16, 2016
1 parent a7e8d83 commit ef68e57
Show file tree
Hide file tree
Showing 5 changed files with 40 additions and 8 deletions.
4 changes: 2 additions & 2 deletions build.gradle
Expand Up @@ -3,7 +3,7 @@ apply plugin: 'eclipse'

sourceCompatibility = 1.8
targetCompatibility = 1.8
version = '1.7.3'
version = '1.7.4'
group = "io.github.hsyyid"
archivesBaseName = "Kits"

Expand All @@ -26,7 +26,7 @@ repositories {
}

dependencies {
compile "org.spongepowered:spongeapi:4.0.0"
compile "org.spongepowered:spongeapi:4.0.3"
compile "com.github.Flibio:Updatifier:v1.0.0"
}

Expand Down
8 changes: 8 additions & 0 deletions src/main/java/io/github/hsyyid/kits/Kits.java
Expand Up @@ -9,6 +9,7 @@
import io.github.hsyyid.kits.cmds.KitIntervalExecutor;
import io.github.hsyyid.kits.cmds.KitListExecutor;
import io.github.hsyyid.kits.cmds.KitReloadExecutor;
import io.github.hsyyid.kits.cmds.KitResetExecutor;
import io.github.hsyyid.kits.config.BookConfig;
import io.github.hsyyid.kits.config.Config;
import io.github.hsyyid.kits.config.KitsConfig;
Expand Down Expand Up @@ -163,6 +164,13 @@ public void onServerInit(GameInitializationEvent event)
.executor(new KitReloadExecutor())
.extendedDescription(Text.of("To reload the config, simply do /kit reload"))
.build());

subcommands.put(Arrays.asList("reset"), CommandSpec.builder()
.permission("kits.reset")
.description(Text.of("Reset the Kit Player Times"))
.arguments(GenericArguments.onlyOne(GenericArguments.string(Text.of("kit"))))
.executor(new KitResetExecutor())
.build());

CommandSpec kitCommandSpec = CommandSpec.builder()
.extendedDescription(Text.of("Kit Command"))
Expand Down
2 changes: 1 addition & 1 deletion src/main/java/io/github/hsyyid/kits/PluginInfo.java
Expand Up @@ -7,6 +7,6 @@ public abstract class PluginInfo
{
public static final String ID = "io.github.hsyyid.kits";
public static final String NAME = "Kits";
public static final String VERSION = "1.7.3";
public static final String VERSION = "1.7.4";
public static final String DESCRIPTION = "This plugin adds Kits, which are sets of items that players can claim through commands.";
}
28 changes: 28 additions & 0 deletions src/main/java/io/github/hsyyid/kits/cmds/KitResetExecutor.java
@@ -0,0 +1,28 @@
package io.github.hsyyid.kits.cmds;

import io.github.hsyyid.kits.Kits;
import org.spongepowered.api.command.CommandException;
import org.spongepowered.api.command.CommandResult;
import org.spongepowered.api.command.CommandSource;
import org.spongepowered.api.command.args.CommandContext;
import org.spongepowered.api.command.spec.CommandExecutor;
import org.spongepowered.api.text.Text;
import org.spongepowered.api.text.format.TextColors;

public class KitResetExecutor implements CommandExecutor
{
public CommandResult execute(CommandSource src, CommandContext ctx) throws CommandException
{
String kit = ctx.<String> getOne("kit").get();

Kits.remainingTime.forEach((k, v) -> {
if (v.containsKey(kit))
{
v.remove(kit);
}
});

src.sendMessage(Text.of(TextColors.GREEN, "Success: ", TextColors.YELLOW, "Reset the player times for specified Kit."));
return CommandResult.success();
}
}
6 changes: 1 addition & 5 deletions src/main/java/io/github/hsyyid/kits/utils/ConfigManager.java
Expand Up @@ -316,15 +316,11 @@ public static Optional<String> getDefaultKit()
{
return Optional.of(valueNode.getString());
}
else if (valueNode.getValue() == null)
else
{
Configs.setValue(config, valueNode.getPath(), "default");
return Optional.of("default");
}
else
{
return Optional.empty();
}
}

public static Text getBookTitle()
Expand Down

0 comments on commit ef68e57

Please sign in to comment.