This repository has been archived by the owner on Apr 12, 2022. It is now read-only.
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
They are now built in order. It also wanrs you if they change on reload. Merged the grant and revoke commands into one.
- Loading branch information
Showing
6 changed files
with
164 additions
and
171 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
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
82 changes: 82 additions & 0 deletions
82
src/main/java/com/denizenscript/denizen2sponge/commands/player/AdvancementCommand.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,82 @@ | ||
package com.denizenscript.denizen2sponge.commands.player; | ||
|
||
import com.denizenscript.denizen2core.commands.AbstractCommand; | ||
import com.denizenscript.denizen2core.commands.CommandEntry; | ||
import com.denizenscript.denizen2core.commands.CommandQueue; | ||
import com.denizenscript.denizen2core.tags.objects.BooleanTag; | ||
import com.denizenscript.denizen2core.utilities.debugging.ColorSet; | ||
import com.denizenscript.denizen2core.utilities.debugging.Debug; | ||
import com.denizenscript.denizen2sponge.tags.objects.PlayerTag; | ||
import com.denizenscript.denizen2sponge.utilities.Utilities; | ||
import org.spongepowered.api.advancement.Advancement; | ||
|
||
public class AdvancementCommand extends AbstractCommand { | ||
|
||
// <--[command] | ||
// @Since 0.4.0 | ||
// @Name advancement | ||
// @Arguments <player> <id> <state> | ||
// @Short manages the state of a player's advancement. | ||
// @Updated 2018/02/06 | ||
// @Group Player | ||
// @Minimum 3 | ||
// @Maximum 3 | ||
// @Description | ||
// Manages the state of a player's advancement. Set the state | ||
// to true to grant the advancement, and to false to revoke it. | ||
// @Example | ||
// # This example grants the advancement "iron_man" to the player. | ||
// - advancement <player> iron_man true | ||
// @Example | ||
// # This example revokes the advancement "legend" from the player. | ||
// - advancement <player> legend false | ||
// --> | ||
|
||
@Override | ||
public String getName() { | ||
return "advancement"; | ||
} | ||
|
||
@Override | ||
public String getArguments() { | ||
return "<player> <id> <state>"; | ||
} | ||
|
||
@Override | ||
public int getMinimumArguments() { | ||
return 3; | ||
} | ||
|
||
@Override | ||
public int getMaximumArguments() { | ||
return 3; | ||
} | ||
|
||
@Override | ||
public void execute(CommandQueue queue, CommandEntry entry) { | ||
PlayerTag player = PlayerTag.getFor(queue.error, entry.getArgumentObject(queue, 0)); | ||
String id = entry.getArgumentObject(queue, 1).toString(); | ||
Advancement advancement = (Advancement) Utilities.getTypeWithDefaultPrefix(Advancement.class, id); | ||
if (advancement == null) { | ||
Debug.error("There's no registered advancement that matches the specified id!"); | ||
return; | ||
} | ||
BooleanTag state = BooleanTag.getFor(queue.error, entry.getArgumentObject(queue, 2)); | ||
if (state.getInternal()) { | ||
player.getOnline(queue.error).getProgress(advancement).grant(); | ||
if (queue.shouldShowGood()) { | ||
queue.outGood("Granting advancement '" + ColorSet.emphasis + advancement.getId() | ||
+ ColorSet.good + "' to player '" + ColorSet.emphasis + player.debug() | ||
+ ColorSet.good + "'!"); | ||
} | ||
} | ||
else { | ||
player.getOnline(queue.error).getProgress(advancement).revoke(); | ||
if (queue.shouldShowGood()) { | ||
queue.outGood("Revoking advancement '" + ColorSet.emphasis + advancement.getId() | ||
+ ColorSet.good + "' from player '" + ColorSet.emphasis + player.debug() | ||
+ ColorSet.good + "'!"); | ||
} | ||
} | ||
} | ||
} |
66 changes: 0 additions & 66 deletions
66
src/main/java/com/denizenscript/denizen2sponge/commands/player/GrantAdvancementCommand.java
This file was deleted.
Oops, something went wrong.
66 changes: 0 additions & 66 deletions
66
src/main/java/com/denizenscript/denizen2sponge/commands/player/RevokeAdvancementCommand.java
This file was deleted.
Oops, something went wrong.
Oops, something went wrong.