-
Notifications
You must be signed in to change notification settings - Fork 59
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
10 changed files
with
295 additions
and
111 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
60 changes: 60 additions & 0 deletions
60
src/main/java/fr/communaywen/core/listeners/PlayersMenuListener.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,60 @@ | ||
package fr.communaywen.core.listeners; | ||
|
||
|
||
import fr.communaywen.core.utils.FreezeUtils; | ||
import fr.communaywen.core.utils.PlayersMenuUtils; | ||
import org.bukkit.BanList; | ||
import org.bukkit.ChatColor; | ||
import org.bukkit.Material; | ||
import org.bukkit.entity.Player; | ||
import org.bukkit.event.EventHandler; | ||
import org.bukkit.event.Listener; | ||
import org.bukkit.event.inventory.InventoryClickEvent; | ||
|
||
import java.util.Objects; | ||
|
||
public class PlayersMenuListener implements Listener { | ||
|
||
@EventHandler | ||
public void onMenuClick(InventoryClickEvent e) { | ||
Player player = (Player) e.getWhoClicked(); | ||
|
||
if (e.getView().getTitle().equalsIgnoreCase(ChatColor.BLUE + "Liste des joueurs")) { | ||
if (Objects.requireNonNull(e.getCurrentItem()).getType() == (Material.PLAYER_HEAD)) { | ||
Player target = player.getServer().getPlayerExact(ChatColor.stripColor(Objects.requireNonNull(e.getCurrentItem().getItemMeta()).getDisplayName())); | ||
assert target != null; | ||
PlayersMenuUtils.openDetailsPlayersMenu(player, target); | ||
} | ||
e.setCancelled(true); | ||
} else if (e.getView().getTitle().equalsIgnoreCase(ChatColor.BLUE + "Détails")) { | ||
Player target = player.getServer().getPlayerExact(ChatColor.stripColor(e.getClickedInventory().getItem(4).getItemMeta().getDisplayName())); | ||
if (e.getCurrentItem().getType() == Material.BARRIER) { | ||
PlayersMenuUtils.openPlayersMenu(player); | ||
return; | ||
} | ||
else if (e.getCurrentItem().getType() == Material.COMPASS) { | ||
assert target != null; | ||
player.teleport(target.getLocation()); | ||
player.sendMessage(ChatColor.DARK_GREEN + "Vous avez été téléporté au joueur " + ChatColor.BLUE + target.getDisplayName() + ChatColor.DARK_GREEN + " !"); | ||
player.closeInventory(); | ||
} | ||
else if (e.getCurrentItem().getType() == Material.ENDER_EYE) { | ||
assert target != null; | ||
player.openInventory(target.getInventory()); | ||
} | ||
else if (e.getCurrentItem().getType() == Material.PACKED_ICE) { | ||
FreezeUtils.switch_freeze(player, target); | ||
player.closeInventory(); | ||
} | ||
else if (e.getCurrentItem().getType() == Material.WOODEN_AXE) { | ||
assert target != null; | ||
String name = target.getDisplayName(); | ||
player.getServer().getBanList(BanList.Type.NAME).addBan(name, "Aucune raison spécifiée", null, player.getDisplayName()); | ||
player.sendMessage(ChatColor.BLUE + name + ChatColor.DARK_RED + " a bien été banni !"); | ||
target.kickPlayer("Vous avez été banni pour Aucune raison spécifiée"); | ||
player.closeInventory(); | ||
} | ||
e.setCancelled(true); | ||
} | ||
} | ||
} |
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
52 changes: 0 additions & 52 deletions
52
src/main/java/fr/communaywen/core/staff/freeze/UnfreezeCommand.java
This file was deleted.
Oops, something went wrong.
24 changes: 24 additions & 0 deletions
24
src/main/java/fr/communaywen/core/staff/players/PlayersCommand.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,24 @@ | ||
package fr.communaywen.core.staff.players; | ||
|
||
import fr.communaywen.core.utils.PlayersMenuUtils; | ||
import org.bukkit.ChatColor; | ||
import org.bukkit.command.Command; | ||
import org.bukkit.command.CommandExecutor; | ||
import org.bukkit.command.CommandSender; | ||
import org.bukkit.entity.Player; | ||
|
||
public class PlayersCommand implements CommandExecutor { | ||
@Override | ||
public boolean onCommand(CommandSender sender, Command cmd, String label, String[] args) { | ||
if (sender instanceof Player player) { | ||
if (args.length != 0) { | ||
player.sendMessage(ChatColor.RED + "La commande est " + ChatColor.BLUE + "/players"); | ||
return false; | ||
} | ||
PlayersMenuUtils.openPlayersMenu(player); | ||
} else { | ||
return false; | ||
} | ||
return true; | ||
} | ||
} |
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,37 @@ | ||
package fr.communaywen.core.utils; | ||
|
||
import fr.communaywen.core.AywenCraftPlugin; | ||
import org.bukkit.ChatColor; | ||
import org.bukkit.entity.Player; | ||
|
||
import java.util.ArrayList; | ||
|
||
public class FreezeUtils { | ||
public static String prefix = ChatColor.GRAY + "[" + ChatColor.BLUE + "Freeze" + ChatColor.GRAY + "] "; | ||
|
||
private static AywenCraftPlugin plugin; | ||
|
||
public FreezeUtils(AywenCraftPlugin plugin) { | ||
this.plugin = plugin; | ||
} | ||
|
||
public static void switch_freeze(Player player, Player target) { | ||
if (target == null) { | ||
player.sendMessage(prefix + ChatColor.DARK_RED + "Joueur introuvable !"); | ||
} else { | ||
if (!plugin.frozenPlayers.contains(target)) { | ||
target.sendTitle(ChatColor.DARK_RED + "Vous êtes freeze !", ChatColor.YELLOW + "Regardez votre chat", 10, 70, 20); | ||
target.sendMessage(prefix + ChatColor.DARK_RED + "Vous êtes freeze, si vous déconnectez, vous serez banni !"); | ||
player.sendMessage(prefix + ChatColor.DARK_RED + "Vous avez freeze " + ChatColor.BLUE + target.getDisplayName() + ChatColor.DARK_RED + " !"); | ||
plugin.frozenPlayers.add(target); | ||
PlayersMenuUtils.state = "§4Freeze"; | ||
} else { | ||
target.resetTitle(); | ||
target.sendMessage(prefix + ChatColor.DARK_GREEN + "Tu a été unfreeze !"); | ||
player.sendMessage(prefix + ChatColor.DARK_GREEN + "Vous avez unfreeze " + ChatColor.BLUE + target.getDisplayName() + ChatColor.DARK_GREEN + " !"); | ||
plugin.frozenPlayers.remove(target); | ||
PlayersMenuUtils.state = "§2Unfreeze"; | ||
} | ||
} | ||
} | ||
} |
Oops, something went wrong.