-
Notifications
You must be signed in to change notification settings - Fork 1
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 #85 from Nookure/dev
Merge Dev
- Loading branch information
Showing
18 changed files
with
345 additions
and
76 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
4 changes: 4 additions & 0 deletions
4
MAStaff-API/src/main/java/com/nookure/mast/api/config/package-info.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,4 @@ | ||
/** | ||
* Here you will find the config files API. | ||
*/ | ||
package com.nookure.mast.api.config; |
4 changes: 4 additions & 0 deletions
4
MAStaff-API/src/main/java/com/nookure/mast/api/staff/package-info.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,4 @@ | ||
/** | ||
* This package contains the classes related to the staff. | ||
*/ | ||
package com.nookure.mast.api.staff; |
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
4 changes: 4 additions & 0 deletions
4
MAStaff-API/src/main/java/es/angelillo15/mast/api/Replace.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,4 @@ | ||
package es.angelillo15.mast.api; | ||
|
||
public record Replace(String search, String replace) { | ||
} |
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
126 changes: 72 additions & 54 deletions
126
MAStaff-Bukkit/src/main/java/es/angelillo15/mast/bukkit/cmd/FreezeCMD.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 |
---|---|---|
@@ -1,84 +1,102 @@ | ||
package es.angelillo15.mast.bukkit.cmd; | ||
|
||
import com.google.inject.Inject; | ||
import com.nookure.mast.api.cmd.Command; | ||
import com.nookure.mast.api.cmd.CommandData; | ||
import com.nookure.mast.api.cmd.sender.CommandSender; | ||
import com.nookure.mast.api.cmd.sender.PlayerCommandSender; | ||
import es.angelillo15.mast.api.IStaffPlayer; | ||
import es.angelillo15.mast.api.TextUtils; | ||
import es.angelillo15.mast.api.config.bukkit.Messages; | ||
import es.angelillo15.mast.api.managers.StaffManager; | ||
import com.nookure.mast.api.manager.FreezeManager; | ||
import es.angelillo15.mast.bukkit.gui.SelectTargetGUI; | ||
|
||
import java.util.List; | ||
import java.util.Objects; | ||
|
||
import org.bukkit.Bukkit; | ||
import org.bukkit.command.Command; | ||
import org.bukkit.command.CommandExecutor; | ||
import org.bukkit.command.CommandSender; | ||
import org.bukkit.entity.Player; | ||
import org.jetbrains.annotations.NotNull; | ||
|
||
public class FreezeCMD implements CommandExecutor { | ||
@Inject | ||
private StaffManager staffManager; | ||
@Inject | ||
private FreezeManager freezeManager; | ||
|
||
@Override | ||
public boolean onCommand(CommandSender sender, Command command, String label, String[] args) { | ||
if(!(sender instanceof Player p)) return false; | ||
@CommandData( | ||
name = "freeze", | ||
permission = "mast.freeze", | ||
aliases = {"fr"}, | ||
usage = "/freeze <player>", | ||
description = "Freeze a player" | ||
) | ||
public class FreezeCMD extends Command { | ||
@Inject | ||
private StaffManager staffManager; | ||
@Inject | ||
private FreezeManager freezeManager; | ||
|
||
if (!staffManager.isStaffPlayer(p.getName())) return false; | ||
@Override | ||
public void onCommand(@NotNull CommandSender sender, @NotNull String label, @NotNull String[] args) { | ||
if (!(sender instanceof PlayerCommandSender pcs)) return; | ||
|
||
IStaffPlayer staff = staffManager.getStaffPlayer(p.getName()); | ||
Player p = pcs.getPlayer(); | ||
|
||
assert staff != null; | ||
if (!staffManager.isStaffPlayer(p.getName())) return; | ||
|
||
if(!p.hasPermission("mast.freeze")){ | ||
TextUtils.colorize(Messages.GET_NO_PERMISSION_MESSAGE(), p); | ||
return true; | ||
} | ||
IStaffPlayer staff = staffManager.getStaffPlayer(p.getName()); | ||
|
||
if(args.length < 1){ | ||
new SelectTargetGUI(p).callback( (target) -> { | ||
execute(staff, target); | ||
p.closeInventory(); | ||
}).open(); | ||
return false; | ||
} | ||
assert staff != null; | ||
|
||
if (args[0].equalsIgnoreCase("/remove")) { | ||
if (freezeManager.isFrozen(args[1])) | ||
staff.unfreezePlayer(args[1]); | ||
return true; | ||
} | ||
if (!p.hasPermission("mast.freeze")) { | ||
TextUtils.colorize(Messages.GET_NO_PERMISSION_MESSAGE(), p); | ||
return; | ||
} | ||
|
||
if (args[0].equalsIgnoreCase("/exec")) { | ||
if (freezeManager.isFrozen(args[1])) | ||
staff.executeFreezedPunishments(args[1]); | ||
return true; | ||
} | ||
if (args.length < 1) { | ||
new SelectTargetGUI(p).callback((target) -> { | ||
execute(staff, target); | ||
p.closeInventory(); | ||
}).open(); | ||
return; | ||
} | ||
|
||
if (onlineCheck(p, args, 0)) return true; | ||
if (args[0].equalsIgnoreCase("/remove")) { | ||
if (freezeManager.isFrozen(args[1])) | ||
staff.unfreezePlayer(args[1]); | ||
return; | ||
} | ||
|
||
if (Objects.requireNonNull(Bukkit.getPlayer(args[0])).hasPermission("mast.freeze.bypass")) { | ||
TextUtils.colorize(Messages.GET_FREEZE_CANNOT_FREEZE_THAT_PLAYER_MESSAGE(), p); | ||
return true; | ||
} | ||
if (args[0].equalsIgnoreCase("/exec")) { | ||
if (freezeManager.isFrozen(args[1])) | ||
staff.executeFreezedPunishments(args[1]); | ||
return; | ||
} | ||
|
||
execute(staff, Bukkit.getPlayer(args[0])); | ||
if (onlineCheck(p, args, 0)) return; | ||
|
||
return true; | ||
if (Objects.requireNonNull(Bukkit.getPlayer(args[0])).hasPermission("mast.freeze.bypass")) { | ||
TextUtils.colorize(Messages.GET_FREEZE_CANNOT_FREEZE_THAT_PLAYER_MESSAGE(), p); | ||
return; | ||
} | ||
|
||
public void execute(IStaffPlayer staff, Player target){ | ||
if (staff.isFreezed(target)) staff.unfreezePlayer(target.getName()); | ||
else staff.freezePlayer(target); | ||
} | ||
execute(staff, Bukkit.getPlayer(args[0])); | ||
} | ||
|
||
public void execute(IStaffPlayer staff, Player target) { | ||
if (staff.isFreezed(target)) staff.unfreezePlayer(target.getName()); | ||
else staff.freezePlayer(target); | ||
} | ||
|
||
public boolean onlineCheck(Player p, String[] args, int index){ | ||
Player target = Bukkit.getPlayer(args[index]); | ||
public boolean onlineCheck(Player p, String[] args, int index) { | ||
Player target = Bukkit.getPlayer(args[index]); | ||
|
||
if(target == null){ | ||
TextUtils.colorize(Messages.GET_NO_PLAYER_FOUND_MESSAGE(), p); | ||
return true; | ||
} | ||
return false; | ||
if (target == null) { | ||
TextUtils.colorize(Messages.GET_NO_PLAYER_FOUND_MESSAGE(), p); | ||
return true; | ||
} | ||
return false; | ||
} | ||
|
||
@NotNull | ||
@Override | ||
public List<String> onTabComplete(@NotNull CommandSender sender, @NotNull String[] args) { | ||
return Bukkit.getOnlinePlayers().stream().map(Player::getName).toList(); | ||
} | ||
} |
51 changes: 51 additions & 0 deletions
51
MAStaff-Bukkit/src/main/java/es/angelillo15/mast/bukkit/cmd/teleport/TpCommand.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,51 @@ | ||
package es.angelillo15.mast.bukkit.cmd.teleport; | ||
|
||
import com.nookure.mast.api.cmd.CommandData; | ||
import com.nookure.mast.api.cmd.StaffCommand; | ||
import com.nookure.mast.api.cmd.sender.CommandSender; | ||
import es.angelillo15.mast.api.IStaffPlayer; | ||
import es.angelillo15.mast.api.Replace; | ||
import es.angelillo15.mast.api.config.bukkit.Messages; | ||
import io.papermc.lib.PaperLib; | ||
import org.bukkit.Bukkit; | ||
import org.bukkit.entity.Player; | ||
import org.jetbrains.annotations.NotNull; | ||
|
||
import java.util.List; | ||
|
||
import static es.angelillo15.mast.bukkit.utils.ColorUtils.cmp; | ||
|
||
@CommandData( | ||
name = "mtp", | ||
permission = "mast.teleport.tp", | ||
usage = "/mtp <player> [target]", | ||
description = "Teleport a player to another player" | ||
) | ||
public class TpCommand extends StaffCommand { | ||
@Override | ||
public void onStaffCommand(@NotNull IStaffPlayer sender, @NotNull String label, @NotNull String[] args) { | ||
if (args.length < 1) { | ||
sender.sendMessage(cmp("Teleport.tp.badUsage")); | ||
return; | ||
} | ||
|
||
Player target = Bukkit.getPlayer(args[0]); | ||
|
||
if (target == null) { | ||
sender.sendMessage(cmp(Messages.GET_NO_PLAYER_FOUND_MESSAGE())); | ||
return; | ||
} | ||
|
||
PaperLib.teleportAsync(sender.getPlayer(), target.getLocation()); | ||
|
||
sender.sendMessage(cmp("Teleport.tp.teleported", | ||
new Replace("player", target.getName())) | ||
); | ||
} | ||
|
||
@NotNull | ||
@Override | ||
public List<String> onTabComplete(@NotNull CommandSender sender, @NotNull String @NotNull [] args) { | ||
return Bukkit.getOnlinePlayers().stream().map(Player::getName).toList(); | ||
} | ||
} |
Oops, something went wrong.