-
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Took 15 minutes
- Loading branch information
Showing
14 changed files
with
484 additions
and
7 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
65 changes: 65 additions & 0 deletions
65
src/main/java/xyz/oribuin/playerwarps/command/impl/BanCommand.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,65 @@ | ||
package xyz.oribuin.playerwarps.command.impl; | ||
|
||
import dev.rosewood.rosegarden.RosePlugin; | ||
import dev.rosewood.rosegarden.command.argument.ArgumentHandlers; | ||
import dev.rosewood.rosegarden.command.framework.ArgumentsDefinition; | ||
import dev.rosewood.rosegarden.command.framework.BaseRoseCommand; | ||
import dev.rosewood.rosegarden.command.framework.CommandContext; | ||
import dev.rosewood.rosegarden.command.framework.CommandInfo; | ||
import dev.rosewood.rosegarden.command.framework.annotation.RoseExecutable; | ||
import org.bukkit.OfflinePlayer; | ||
import org.bukkit.entity.Player; | ||
import org.bukkit.inventory.ItemStack; | ||
import xyz.oribuin.playerwarps.command.argument.WarpArgumentHandler; | ||
import xyz.oribuin.playerwarps.manager.DataManager; | ||
import xyz.oribuin.playerwarps.model.Warp; | ||
|
||
public class BanCommand extends BaseRoseCommand { | ||
|
||
public BanCommand(RosePlugin rosePlugin) { | ||
super(rosePlugin); | ||
} | ||
|
||
@RoseExecutable | ||
public void execute(CommandContext context) { | ||
Player player = (Player) context.getSender(); | ||
Warp warp = context.get("warp"); | ||
OfflinePlayer target = context.get("target"); | ||
|
||
if (!warp.getOwner().equals(player.getUniqueId())) { | ||
player.sendMessage("You don't own this warp"); | ||
return; | ||
} | ||
|
||
if (warp.isBanned(target)) { | ||
player.sendMessage("Player is already banned from " + warp.getId()); | ||
return; | ||
} | ||
|
||
if (warp.getOwner().equals(target.getUniqueId())) { | ||
player.sendMessage("You cannot ban the owner of " + warp.getId()); | ||
return; | ||
} | ||
|
||
warp.getBanned().add(target.getUniqueId()); | ||
warp.save(); | ||
player.sendMessage("Banned " + target.getName() + " from " + warp.getId()); | ||
} | ||
|
||
@Override | ||
protected CommandInfo createCommandInfo() { | ||
return CommandInfo.builder("ban") | ||
.descriptionKey("command-ban-description") | ||
.permission("playerwarps.ban") | ||
.build(); | ||
} | ||
|
||
@Override | ||
protected ArgumentsDefinition createArgumentsDefinition() { | ||
return ArgumentsDefinition.builder() | ||
.required("warp", new WarpArgumentHandler()) | ||
.required("target", ArgumentHandlers.OFFLINE_PLAYER) | ||
.build(); | ||
} | ||
|
||
} |
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
78 changes: 78 additions & 0 deletions
78
src/main/java/xyz/oribuin/playerwarps/command/impl/DescCommand.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,78 @@ | ||
package xyz.oribuin.playerwarps.command.impl; | ||
|
||
import dev.rosewood.rosegarden.RosePlugin; | ||
import dev.rosewood.rosegarden.command.argument.ArgumentHandlers; | ||
import dev.rosewood.rosegarden.command.framework.ArgumentsDefinition; | ||
import dev.rosewood.rosegarden.command.framework.BaseRoseCommand; | ||
import dev.rosewood.rosegarden.command.framework.CommandContext; | ||
import dev.rosewood.rosegarden.command.framework.CommandInfo; | ||
import dev.rosewood.rosegarden.command.framework.annotation.RoseExecutable; | ||
import org.bukkit.entity.Player; | ||
import xyz.oribuin.playerwarps.command.argument.WarpArgumentHandler; | ||
import xyz.oribuin.playerwarps.manager.ConfigurationManager.Setting; | ||
import xyz.oribuin.playerwarps.manager.DataManager; | ||
import xyz.oribuin.playerwarps.model.Warp; | ||
|
||
import java.util.ArrayList; | ||
import java.util.Arrays; | ||
import java.util.List; | ||
import java.util.regex.Pattern; | ||
import java.util.stream.Collectors; | ||
|
||
public class DescCommand extends BaseRoseCommand { | ||
|
||
public DescCommand(RosePlugin rosePlugin) { | ||
super(rosePlugin); | ||
} | ||
|
||
@RoseExecutable | ||
public void execute(CommandContext context) { | ||
Player player = (Player) context.getSender(); | ||
Warp warp = context.get("warp"); | ||
String desc = context.get("desc"); | ||
|
||
if (!warp.getOwner().equals(player.getUniqueId())) { | ||
player.sendMessage("You don't own this warp"); | ||
return; | ||
} | ||
|
||
if (desc == null) { | ||
warp.setDescription(new ArrayList<>()); | ||
warp.save(); | ||
player.sendMessage("Removed description for " + warp.getId()); | ||
return; | ||
} | ||
|
||
if (this.getPatterns().stream().anyMatch(p -> p.matcher(desc).matches())) { | ||
player.sendMessage("Invalid name"); | ||
return; | ||
} | ||
|
||
warp.setDescription(Arrays.stream(desc.split("\n")).toList()); | ||
warp.save(); | ||
player.sendMessage("Set description for " + warp.getId()); | ||
} | ||
|
||
public List<Pattern> getPatterns() { | ||
return Setting.WARP_DESC_FILTERS.getStringList().stream() | ||
.map(Pattern::compile) | ||
.collect(Collectors.toList()); | ||
} | ||
|
||
@Override | ||
protected CommandInfo createCommandInfo() { | ||
return CommandInfo.builder("desc") | ||
.descriptionKey("command-desc-description") | ||
.permission("playerwarps.desc") | ||
.build(); | ||
} | ||
|
||
@Override | ||
protected ArgumentsDefinition createArgumentsDefinition() { | ||
return ArgumentsDefinition.builder() | ||
.required("warp", new WarpArgumentHandler()) | ||
.optional("desc", ArgumentHandlers.GREEDY_STRING) | ||
.build(); | ||
} | ||
|
||
} |
59 changes: 59 additions & 0 deletions
59
src/main/java/xyz/oribuin/playerwarps/command/impl/IconCommand.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,59 @@ | ||
package xyz.oribuin.playerwarps.command.impl; | ||
|
||
import dev.rosewood.rosegarden.RosePlugin; | ||
import dev.rosewood.rosegarden.command.framework.ArgumentsDefinition; | ||
import dev.rosewood.rosegarden.command.framework.BaseRoseCommand; | ||
import dev.rosewood.rosegarden.command.framework.CommandContext; | ||
import dev.rosewood.rosegarden.command.framework.CommandInfo; | ||
import dev.rosewood.rosegarden.command.framework.annotation.RoseExecutable; | ||
import org.bukkit.entity.Player; | ||
import org.bukkit.inventory.ItemStack; | ||
import xyz.oribuin.playerwarps.command.argument.WarpArgumentHandler; | ||
import xyz.oribuin.playerwarps.manager.DataManager; | ||
import xyz.oribuin.playerwarps.model.Warp; | ||
|
||
public class IconCommand extends BaseRoseCommand { | ||
|
||
public IconCommand(RosePlugin rosePlugin) { | ||
super(rosePlugin); | ||
} | ||
|
||
@RoseExecutable | ||
public void execute(CommandContext context) { | ||
Player player = (Player) context.getSender(); | ||
Warp warp = context.get("warp"); | ||
|
||
if (!warp.getOwner().equals(player.getUniqueId())) { | ||
player.sendMessage("You don't own this warp"); | ||
return; | ||
} | ||
|
||
ItemStack handIcon = player.getInventory().getItemInMainHand(); | ||
if (handIcon.getType().isAir()) { | ||
warp.setIcon(null); | ||
warp.save(); | ||
player.sendMessage("removed icon from " + warp.getId()); | ||
return; | ||
} | ||
|
||
warp.setIcon(handIcon); | ||
warp.save(); | ||
player.sendMessage("set icon for " + warp.getId()); | ||
} | ||
|
||
@Override | ||
protected CommandInfo createCommandInfo() { | ||
return CommandInfo.builder("icon") | ||
.descriptionKey("command-icon-description") | ||
.permission("playerwarps.icon") | ||
.build(); | ||
} | ||
|
||
@Override | ||
protected ArgumentsDefinition createArgumentsDefinition() { | ||
return ArgumentsDefinition.builder() | ||
.required("warp", new WarpArgumentHandler()) | ||
.build(); | ||
} | ||
|
||
} |
69 changes: 69 additions & 0 deletions
69
src/main/java/xyz/oribuin/playerwarps/command/impl/NameCommand.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,69 @@ | ||
package xyz.oribuin.playerwarps.command.impl; | ||
|
||
import dev.rosewood.rosegarden.RosePlugin; | ||
import dev.rosewood.rosegarden.command.argument.ArgumentHandlers; | ||
import dev.rosewood.rosegarden.command.framework.ArgumentsDefinition; | ||
import dev.rosewood.rosegarden.command.framework.BaseRoseCommand; | ||
import dev.rosewood.rosegarden.command.framework.CommandContext; | ||
import dev.rosewood.rosegarden.command.framework.CommandInfo; | ||
import dev.rosewood.rosegarden.command.framework.annotation.RoseExecutable; | ||
import org.bukkit.entity.Player; | ||
import xyz.oribuin.playerwarps.command.argument.WarpArgumentHandler; | ||
import xyz.oribuin.playerwarps.manager.ConfigurationManager.Setting; | ||
import xyz.oribuin.playerwarps.manager.DataManager; | ||
import xyz.oribuin.playerwarps.model.Warp; | ||
|
||
import java.util.List; | ||
import java.util.regex.Pattern; | ||
import java.util.stream.Collectors; | ||
|
||
public class NameCommand extends BaseRoseCommand { | ||
|
||
public NameCommand(RosePlugin rosePlugin) { | ||
super(rosePlugin); | ||
} | ||
|
||
@RoseExecutable | ||
public void execute(CommandContext context) { | ||
Player player = (Player) context.getSender(); | ||
Warp warp = context.get("warp"); | ||
String name = context.get("name"); | ||
|
||
if (!warp.getOwner().equals(player.getUniqueId())) { | ||
player.sendMessage("You don't own this warp"); | ||
return; | ||
} | ||
|
||
if (this.getPatterns().stream().anyMatch(p -> p.matcher(name).matches())) { | ||
player.sendMessage("Invalid name"); | ||
return; | ||
} | ||
|
||
warp.setDisplayName(name); | ||
warp.save(); | ||
player.sendMessage("Set name for " + warp.getId()); | ||
} | ||
|
||
public List<Pattern> getPatterns() { | ||
return Setting.WARP_NAME_FILTERS.getStringList().stream() | ||
.map(Pattern::compile) | ||
.collect(Collectors.toList()); | ||
} | ||
|
||
@Override | ||
protected CommandInfo createCommandInfo() { | ||
return CommandInfo.builder("name") | ||
.descriptionKey("command-name-description") | ||
.permission("playerwarps.name") | ||
.build(); | ||
} | ||
|
||
@Override | ||
protected ArgumentsDefinition createArgumentsDefinition() { | ||
return ArgumentsDefinition.builder() | ||
.required("warp", new WarpArgumentHandler()) | ||
.required("name", ArgumentHandlers.GREEDY_STRING) | ||
.build(); | ||
} | ||
|
||
} |
56 changes: 56 additions & 0 deletions
56
src/main/java/xyz/oribuin/playerwarps/command/impl/OwnerCommand.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,56 @@ | ||
package xyz.oribuin.playerwarps.command.impl; | ||
|
||
import dev.rosewood.rosegarden.RosePlugin; | ||
import dev.rosewood.rosegarden.command.argument.ArgumentHandlers; | ||
import dev.rosewood.rosegarden.command.framework.ArgumentsDefinition; | ||
import dev.rosewood.rosegarden.command.framework.BaseRoseCommand; | ||
import dev.rosewood.rosegarden.command.framework.CommandContext; | ||
import dev.rosewood.rosegarden.command.framework.CommandInfo; | ||
import dev.rosewood.rosegarden.command.framework.annotation.RoseExecutable; | ||
import org.bukkit.OfflinePlayer; | ||
import org.bukkit.entity.Player; | ||
import xyz.oribuin.playerwarps.command.argument.WarpArgumentHandler; | ||
import xyz.oribuin.playerwarps.manager.DataManager; | ||
import xyz.oribuin.playerwarps.model.Warp; | ||
|
||
public class OwnerCommand extends BaseRoseCommand { | ||
|
||
public OwnerCommand(RosePlugin rosePlugin) { | ||
super(rosePlugin); | ||
} | ||
|
||
@RoseExecutable | ||
public void execute(CommandContext context) { | ||
Player player = (Player) context.getSender(); | ||
Warp warp = context.get("warp"); | ||
OfflinePlayer target = context.get("target"); | ||
|
||
if (!warp.getOwner().equals(player.getUniqueId())) { | ||
player.sendMessage("You don't own this warp"); | ||
return; | ||
} | ||
|
||
// TODO: ARE YOU SURE???????????????????????? | ||
warp.setOwner(target.getUniqueId()); | ||
warp.setOwnerName(target.getName()); | ||
warp.save(); | ||
player.sendMessage("Set owner of " + warp.getId() + " to " + target.getName()); | ||
} | ||
|
||
@Override | ||
protected CommandInfo createCommandInfo() { | ||
return CommandInfo.builder("owner") | ||
.descriptionKey("command-owner-description") | ||
.permission("playerwarps.owner") | ||
.build(); | ||
} | ||
|
||
@Override | ||
protected ArgumentsDefinition createArgumentsDefinition() { | ||
return ArgumentsDefinition.builder() | ||
.required("warp", new WarpArgumentHandler()) | ||
.required("target", ArgumentHandlers.OFFLINE_PLAYER) | ||
.build(); | ||
} | ||
|
||
} |
Oops, something went wrong.