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.
Still not implemented in Sponge, but should work fine once they are. Also updated a deprecated Key creating method, and improved ban command to accept players as entity tag input.
- Loading branch information
Showing
7 changed files
with
187 additions
and
13 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
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
70 changes: 70 additions & 0 deletions
70
src/main/java/com/denizenscript/denizen2sponge/commands/player/RemoveRespawnCommand.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,70 @@ | ||
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.utilities.debugging.ColorSet; | ||
import com.denizenscript.denizen2sponge.tags.objects.PlayerTag; | ||
import com.denizenscript.denizen2sponge.tags.objects.WorldTag; | ||
import org.spongepowered.api.data.key.Keys; | ||
import org.spongepowered.api.entity.living.player.Player; | ||
import org.spongepowered.api.util.RespawnLocation; | ||
|
||
import java.util.HashMap; | ||
import java.util.Map; | ||
import java.util.UUID; | ||
|
||
public class RemoveRespawnCommand extends AbstractCommand { | ||
|
||
// <--[command] | ||
// @Since 0.4.0 | ||
// @Name removerespawn | ||
// @Arguments <player> <world> | ||
// @Short removes a respawn location for the player. | ||
// @Updated 2018/02/22 | ||
// @Group Player | ||
// @Warning This command doesn't work due to not being implemented in Sponge yet. | ||
// @Minimum 2 | ||
// @Maximum 2 | ||
// @Description | ||
// Removes the respawn location for the player in the specified world. | ||
// Related commands: <@link command setrespawn>setrespawn<@/link>. | ||
// @Example | ||
// # This example removes the player's respawn point in their current world. | ||
// - removerespawn <player> <player.location.world> | ||
// --> | ||
|
||
@Override | ||
public String getName() { | ||
return "removerespawn"; | ||
} | ||
|
||
@Override | ||
public String getArguments() { | ||
return "<player> <world>"; | ||
} | ||
|
||
@Override | ||
public int getMinimumArguments() { | ||
return 2; | ||
} | ||
|
||
@Override | ||
public int getMaximumArguments() { | ||
return 2; | ||
} | ||
|
||
@Override | ||
public void execute(CommandQueue queue, CommandEntry entry) { | ||
PlayerTag playerTag = PlayerTag.getFor(queue.error, entry.getArgumentObject(queue, 0)); | ||
Player player = playerTag.getOnline(queue.error); | ||
WorldTag world = WorldTag.getFor(queue.error, entry.getArgumentObject(queue, 1)); | ||
Map<UUID, RespawnLocation> map = player.get(Keys.RESPAWN_LOCATIONS).orElse(new HashMap<>()); | ||
map.remove(world.getInternal().getUniqueId()); | ||
player.offer(Keys.RESPAWN_LOCATIONS, map); | ||
if (queue.shouldShowGood()) { | ||
queue.outGood("Removing respawn location for player '" + ColorSet.emphasis + playerTag.debug() | ||
+ ColorSet.good + "' in world '" + ColorSet.emphasis + world.debug() + ColorSet.good + "'!"); | ||
} | ||
} | ||
} |
80 changes: 80 additions & 0 deletions
80
src/main/java/com/denizenscript/denizen2sponge/commands/player/SetRespawnCommand.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,80 @@ | ||
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.denizen2sponge.tags.objects.LocationTag; | ||
import com.denizenscript.denizen2sponge.tags.objects.PlayerTag; | ||
import org.spongepowered.api.data.key.Keys; | ||
import org.spongepowered.api.entity.living.player.Player; | ||
import org.spongepowered.api.util.RespawnLocation; | ||
|
||
import java.util.HashMap; | ||
import java.util.Map; | ||
import java.util.UUID; | ||
|
||
public class SetRespawnCommand extends AbstractCommand { | ||
|
||
// <--[command] | ||
// @Since 0.4.0 | ||
// @Name setrespawn | ||
// @Arguments <player> <location> | ||
// @Short sets a respawn location for the player. | ||
// @Updated 2018/02/22 | ||
// @Group Player | ||
// @Warning This command doesn't work due to not being implemented in Sponge yet. | ||
// @Minimum 2 | ||
// @Maximum 2 | ||
// @Named force (BooleanTag) Sets whether this respawn position is forced. | ||
// @Description | ||
// Sets a respawn location for the player. A player can only have one respawn location | ||
// per world. You can also specify if the position to respawn at is forced or can | ||
// be varied for safety. | ||
// Related commands: <@link command removerespawn>removerespawn<@/link>. | ||
// @Example | ||
// # This example sets the player's respawn point in their current world to their current location. | ||
// - setrespawn <player> <player.location> | ||
// --> | ||
|
||
@Override | ||
public String getName() { | ||
return "setrespawn"; | ||
} | ||
|
||
@Override | ||
public String getArguments() { | ||
return "<player> <location>"; | ||
} | ||
|
||
@Override | ||
public int getMinimumArguments() { | ||
return 2; | ||
} | ||
|
||
@Override | ||
public int getMaximumArguments() { | ||
return 2; | ||
} | ||
|
||
@Override | ||
public void execute(CommandQueue queue, CommandEntry entry) { | ||
PlayerTag playerTag = PlayerTag.getFor(queue.error, entry.getArgumentObject(queue, 0)); | ||
Player player = playerTag.getOnline(queue.error); | ||
LocationTag location = LocationTag.getFor(queue.error, entry.getArgumentObject(queue, 1)); | ||
RespawnLocation.Builder builder = RespawnLocation.builder().location(location.getInternal().toLocation()); | ||
if (entry.namedArgs.containsKey("force")) { | ||
BooleanTag force = BooleanTag.getFor(queue.error, entry.getNamedArgumentObject(queue, "force")); | ||
builder.forceSpawn(force.getInternal()); | ||
} | ||
Map<UUID, RespawnLocation> map = player.get(Keys.RESPAWN_LOCATIONS).orElse(new HashMap<>()); | ||
map.put(location.getInternal().world.getUniqueId(), builder.build()); | ||
player.offer(Keys.RESPAWN_LOCATIONS, map); | ||
queue.outInfo(player.get(Keys.RESPAWN_LOCATIONS).orElse(new HashMap<>()).toString()); | ||
if (queue.shouldShowGood()) { | ||
queue.outGood("Setting respawn location for player '" + ColorSet.emphasis + playerTag.debug() | ||
+ ColorSet.good + "' to '" + ColorSet.emphasis + location.debug() + ColorSet.good + "'!"); | ||
} | ||
} | ||
} |
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