From d3902cbc8b99a21da26c5747b8e7b857797181ca Mon Sep 17 00:00:00 2001 From: mathiascode Date: Sun, 22 Sep 2019 04:58:53 +0300 Subject: [PATCH] Push old code --- .../kaboom/extras/commands/CommandSkin.java | 1 - .../extras/modules/player/PlayerCommand.java | 117 ++++++++++++++++++ .../modules/player/PlayerConnection.java | 1 - 3 files changed, 117 insertions(+), 2 deletions(-) diff --git a/src/main/java/pw/kaboom/extras/commands/CommandSkin.java b/src/main/java/pw/kaboom/extras/commands/CommandSkin.java index 8bf15f9..b975c6c 100644 --- a/src/main/java/pw/kaboom/extras/commands/CommandSkin.java +++ b/src/main/java/pw/kaboom/extras/commands/CommandSkin.java @@ -52,7 +52,6 @@ class CommandSkin implements CommandExecutor { skinStream.close(); final PlayerProfile textureProfile = player.getPlayerProfile(); - textureProfile.clearProperties(); textureProfile.setProperty(new ProfileProperty("textures", texture, signature)); player.sendMessage("Successfully set your skin to " + name + "'s"); diff --git a/src/main/java/pw/kaboom/extras/modules/player/PlayerCommand.java b/src/main/java/pw/kaboom/extras/modules/player/PlayerCommand.java index 1ea93f6..6de7be0 100644 --- a/src/main/java/pw/kaboom/extras/modules/player/PlayerCommand.java +++ b/src/main/java/pw/kaboom/extras/modules/player/PlayerCommand.java @@ -2,6 +2,7 @@ package pw.kaboom.extras; import java.util.UUID; +import org.bukkit.Bukkit; import org.bukkit.ChatColor; import org.bukkit.command.Command; @@ -13,6 +14,116 @@ import org.bukkit.event.player.PlayerCommandPreprocessEvent; import org.bukkit.scheduler.BukkitRunnable; + +import org.bukkit.command.CommandSender; +import org.bukkit.permissions.Permission; + +import org.bukkit.permissions.PermissionAttachment; + +import org.bukkit.permissions.PermissionAttachmentInfo; +import org.bukkit.Server; +import org.bukkit.plugin.Plugin; + +import java.util.Set; + +class WrappedSender implements CommandSender { + private final CommandSender sender; + + public WrappedSender(CommandSender sender) { + this.sender = sender; + } + + @Override + public void sendMessage(String message) { + sender.sendMessage(message);/*.substring(0, Math.min(256, message.length())));*/ + } + + @Override + public void sendMessage(String[] messages) { + sender.sendMessage(messages); + } + + @Override + public Server getServer() { + return sender.getServer(); + } + + @Override + public String getName() { + return sender.getName(); + } + + @Override + public boolean isPermissionSet(String name) { + return sender.isPermissionSet(name); + } + + @Override + public boolean isPermissionSet(Permission perm) { + return sender.isPermissionSet(perm); + } + + @Override + public boolean hasPermission(String name) { + return sender.hasPermission(name); + } + + @Override + public boolean hasPermission(Permission perm) { + return sender.hasPermission(perm); + } + + @Override + public PermissionAttachment addAttachment(Plugin plugin, String name, boolean value) { + return sender.addAttachment(plugin, name, value); + } + + @Override + public PermissionAttachment addAttachment(Plugin plugin) { + return sender.addAttachment(plugin); + } + + @Override + public PermissionAttachment addAttachment(Plugin plugin, String name, boolean value, int ticks) { + return sender.addAttachment(plugin, name, value, ticks); + } + + @Override + public PermissionAttachment addAttachment(Plugin plugin, int ticks) { + return sender.addAttachment(plugin, ticks); + } + + @Override + public void removeAttachment(PermissionAttachment attachment) { + sender.removeAttachment(attachment); + } + + @Override + public void recalculatePermissions() { + sender.recalculatePermissions(); + } + + @Override + public Set getEffectivePermissions() { + return sender.getEffectivePermissions(); + } + + @Override + public boolean isOp() { + return sender.isOp(); + } + + @Override + public void setOp(boolean value) { + sender.setOp(value); + } + + @Override + public Spigot spigot() { + return null; + } +} + class PlayerCommand implements Listener { private Main main; public PlayerCommand(Main main) { @@ -122,5 +233,11 @@ class PlayerCommand implements Listener { event.setCancelled(true); Command.broadcastCommandMessage(event.getPlayer(), "Stopping the server"); } + + /*if (!event.isCancelled()) { + WrappedSender wrapped = new WrappedSender(event.getPlayer()); + Bukkit.getServer().dispatchCommand(wrapped, event.getMessage().substring(1)); + event.setCancelled(true); + }*/ } } diff --git a/src/main/java/pw/kaboom/extras/modules/player/PlayerConnection.java b/src/main/java/pw/kaboom/extras/modules/player/PlayerConnection.java index 1c9dda1..6dfe701 100644 --- a/src/main/java/pw/kaboom/extras/modules/player/PlayerConnection.java +++ b/src/main/java/pw/kaboom/extras/modules/player/PlayerConnection.java @@ -141,7 +141,6 @@ class PlayerConnection implements Listener { skinStream.close(); final PlayerProfile textureProfile = player.getPlayerProfile(); - textureProfile.clearProperties(); textureProfile.setProperty(new ProfileProperty("textures", texture, signature)); new BukkitRunnable() {