mirror of
https://github.com/plexusorg/Plex.git
synced 2024-12-22 17:17:37 +00:00
first listener ayyyy
This commit is contained in:
parent
af23d3d2ed
commit
52be58872e
@ -0,0 +1,44 @@
|
||||
package me.totalfreedom.plex.command.impl;
|
||||
|
||||
import me.totalfreedom.plex.cache.PlayerCache;
|
||||
import me.totalfreedom.plex.command.PlexCommand;
|
||||
import me.totalfreedom.plex.command.annotation.CommandParameters;
|
||||
import me.totalfreedom.plex.command.annotation.CommandPermissions;
|
||||
import me.totalfreedom.plex.command.exception.CommandArgumentException;
|
||||
import me.totalfreedom.plex.command.source.CommandSource;
|
||||
import me.totalfreedom.plex.player.PunishedPlayer;
|
||||
import me.totalfreedom.plex.rank.enums.Rank;
|
||||
import me.totalfreedom.plex.util.PlexUtils;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import static me.totalfreedom.plex.util.PlexUtils.tl;
|
||||
|
||||
@CommandParameters(description = "Freeze/unfreeze a player on the server", usage = "/<command> <player>")
|
||||
@CommandPermissions(level = Rank.ADMIN)
|
||||
public class FreezeCMD extends PlexCommand
|
||||
{
|
||||
public FreezeCMD()
|
||||
{
|
||||
super("freeze");
|
||||
}
|
||||
|
||||
@Override
|
||||
public void execute(CommandSource sender, String[] args)
|
||||
{
|
||||
if (args.length != 1)
|
||||
throw new CommandArgumentException();
|
||||
Player player = getNonNullPlayer(args[0]);
|
||||
PunishedPlayer punishedPlayer = PlayerCache.getPunishedPlayer(player.getUniqueId());
|
||||
punishedPlayer.setFrozen(!punishedPlayer.isFrozen());
|
||||
PlexUtils.broadcast(punishedPlayer.isFrozen() ? tl("frozePlayer", sender.getName(), player.getName()) :
|
||||
tl("unfrozePlayer", sender.getName(), player.getName()));
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<String> onTabComplete(CommandSource sender, String[] args)
|
||||
{
|
||||
return args.length == 1 ? PlexUtils.getPlayerNameList() : null;
|
||||
}
|
||||
}
|
@ -28,6 +28,7 @@ public class OpCMD extends PlexCommand
|
||||
if (args.length != 1)
|
||||
throw new CommandArgumentException();
|
||||
Player player = getNonNullPlayer(args[0]);
|
||||
player.setOp(true);
|
||||
PlexUtils.broadcast(tl("oppedPlayer", sender.getName(), player.getName()));
|
||||
}
|
||||
|
||||
|
@ -0,0 +1,24 @@
|
||||
package me.totalfreedom.plex.event;
|
||||
|
||||
import lombok.Getter;
|
||||
import lombok.Setter;
|
||||
import me.totalfreedom.plex.player.PunishedPlayer;
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.event.Cancellable;
|
||||
import org.bukkit.event.player.PlayerEvent;
|
||||
|
||||
import java.util.UUID;
|
||||
|
||||
@Getter
|
||||
public abstract class PunishedPlayerEvent extends PlayerEvent implements Cancellable
|
||||
{
|
||||
protected PunishedPlayer punishedPlayer;
|
||||
@Setter
|
||||
protected boolean cancelled;
|
||||
|
||||
protected PunishedPlayerEvent(PunishedPlayer punishedPlayer)
|
||||
{
|
||||
super(Bukkit.getPlayer(UUID.fromString(punishedPlayer.getUuid())));
|
||||
this.punishedPlayer = punishedPlayer;
|
||||
}
|
||||
}
|
@ -0,0 +1,33 @@
|
||||
package me.totalfreedom.plex.event;
|
||||
|
||||
import lombok.Getter;
|
||||
import me.totalfreedom.plex.player.PunishedPlayer;
|
||||
import org.bukkit.event.Cancellable;
|
||||
import org.bukkit.event.HandlerList;
|
||||
@Getter
|
||||
public class PunishedPlayerFreezeEvent extends PunishedPlayerEvent implements Cancellable
|
||||
{
|
||||
private static final HandlerList handlers = new HandlerList();
|
||||
|
||||
/**
|
||||
* Status of the Punished Player being frozen before the event's occurrence.
|
||||
*/
|
||||
private final boolean frozen;
|
||||
|
||||
public PunishedPlayerFreezeEvent(PunishedPlayer punishedPlayer, boolean frozen)
|
||||
{
|
||||
super(punishedPlayer);
|
||||
this.frozen = frozen;
|
||||
}
|
||||
|
||||
@Override
|
||||
public HandlerList getHandlers()
|
||||
{
|
||||
return handlers;
|
||||
}
|
||||
|
||||
public static HandlerList getHandlerList()
|
||||
{
|
||||
return handlers;
|
||||
}
|
||||
}
|
@ -20,6 +20,7 @@ public class CommandHandler
|
||||
commands.add(new WorldCMD());
|
||||
commands.add(new OpAllCMD());
|
||||
commands.add(new OpCMD());
|
||||
commands.add(new FreezeCMD());
|
||||
|
||||
PlexLog.log(String.format("Registered %s commands!", commands.size()));
|
||||
}
|
||||
|
@ -2,10 +2,7 @@ package me.totalfreedom.plex.handlers;
|
||||
|
||||
import com.google.common.collect.Lists;
|
||||
import me.totalfreedom.plex.listener.PlexListener;
|
||||
import me.totalfreedom.plex.listener.impl.ChatListener;
|
||||
import me.totalfreedom.plex.listener.impl.FreezeListener;
|
||||
import me.totalfreedom.plex.listener.impl.PlayerListener;
|
||||
import me.totalfreedom.plex.listener.impl.WorldListener;
|
||||
import me.totalfreedom.plex.listener.impl.*;
|
||||
import me.totalfreedom.plex.util.PlexLog;
|
||||
|
||||
import java.util.List;
|
||||
|
@ -4,9 +4,10 @@ import java.util.UUID;
|
||||
import lombok.AccessLevel;
|
||||
import lombok.Getter;
|
||||
import lombok.Setter;
|
||||
import me.totalfreedom.plex.event.PunishedPlayerFreezeEvent;
|
||||
import org.bukkit.Bukkit;
|
||||
|
||||
@Getter
|
||||
@Setter
|
||||
public class PunishedPlayer
|
||||
{
|
||||
//everything in here will be stored in redis
|
||||
@ -23,4 +24,11 @@ public class PunishedPlayer
|
||||
this.frozen = false;
|
||||
}
|
||||
|
||||
public void setFrozen(boolean frozen)
|
||||
{
|
||||
PunishedPlayerFreezeEvent e = new PunishedPlayerFreezeEvent(this, this.frozen);
|
||||
Bukkit.getServer().getPluginManager().callEvent(e);
|
||||
if (!e.isCancelled())
|
||||
this.frozen = frozen;
|
||||
}
|
||||
}
|
||||
|
@ -29,10 +29,16 @@ noAdminWorldBlockBreak: <e>You are not allowed to break blocks in the admin worl
|
||||
# 1: the world you have been teleported to
|
||||
playerWorldTeleport: You have been teleported to <v>.
|
||||
# 1: the command sender who opped everyone
|
||||
oppedAllPlayers: <b><v> has opped all players on the server
|
||||
oppedAllPlayers: <b><v> - Opped all players on the server
|
||||
# 1: the person who is opping
|
||||
# 2: the person who has been opped
|
||||
oppedPlayer: <b><v> has opped <v>
|
||||
oppedPlayer: <b><v> - Opped <v>
|
||||
# 1: the person who is freezing
|
||||
# 2: the person who has been frozen
|
||||
frozePlayer: <b><v> - Froze <v>
|
||||
# 1: the person who is unfreezing
|
||||
# 2: the person who has been unfrozen
|
||||
unfrozePlayer: <b><v> - Unfroze <v>
|
||||
noPermission: <e>You cannot use this command!
|
||||
# 1: the login message (uncolored) of the rank required to use the command
|
||||
noPermissionRank: <e>You must be at least <v> rank to use this command!
|
||||
|
Loading…
Reference in New Issue
Block a user