13
0

Add inspection option #13

Manuell gemergt
YoyoNow hat 2 Commits von inspection nach master 2021-03-21 13:40:26 +01:00 zusammengeführt
9 geänderte Dateien mit 68 neuen und 9 gelöschten Zeilen

Datei anzeigen

@ -20,6 +20,7 @@
package de.steamwar.spectatesystem;
import com.sk89q.worldedit.EditSession;
import de.steamwar.spectatesystem.commands.InspectCommand;
import de.steamwar.spectatesystem.elements.*;
import de.steamwar.spectatesystem.util.BlockTextCreator;
import de.steamwar.spectatesystem.util.ColorConverter;
@ -203,7 +204,7 @@ class PacketProcessor {
if(Config.ArenaMinX > x || Config.ArenaMaxX < x || Config.ArenaMinZ > z || Config.ArenaMaxZ < z)
return; //Outside of the arena
if (Config.TechhiderActive && Config.HiddenBlocks.contains(blockState)) {
if (!InspectCommand.inspecting && Config.TechhiderActive && Config.HiddenBlocks.contains(blockState)) {
blockState = Config.ObfuscateWith;
}
IBlockData blockData = Objects.requireNonNull(Block.REGISTRY_ID.fromId(blockState));

Datei anzeigen

@ -26,6 +26,7 @@ import com.comphenix.protocol.wrappers.EnumWrappers;
import com.comphenix.protocol.wrappers.PlayerInfoData;
import com.comphenix.protocol.wrappers.WrappedChatComponent;
import com.comphenix.protocol.wrappers.WrappedGameProfile;
import de.steamwar.spectatesystem.commands.InspectCommand;
import org.bukkit.Bukkit;
import org.bukkit.GameMode;
import org.bukkit.Location;
@ -102,6 +103,9 @@ public class PlayerSetup {
}
}
Bukkit.getScheduler().runTaskLater(SpectateSystem.get(), () -> {
if(InspectCommand.inspecting)
return;
PacketContainer gm1packet = ProtocolLibrary.getProtocolManager().createPacket(PacketType.Play.Server.PLAYER_INFO);
gm1packet.getPlayerInfoAction().write(0, EnumWrappers.PlayerInfoAction.UPDATE_GAME_MODE);
List<PlayerInfoData> playerInfoActions = new ArrayList<>();

Datei anzeigen

@ -19,6 +19,7 @@
package de.steamwar.spectatesystem;
import de.steamwar.spectatesystem.commands.InspectCommand;
import de.steamwar.spectatesystem.commands.ReplayCommand;
import de.steamwar.spectatesystem.elements.RScoreboard;
import de.steamwar.spectatesystem.listener.PlayerListener;
@ -26,14 +27,19 @@ import de.steamwar.spectatesystem.listener.CancelListener;
import de.steamwar.spectatesystem.listener.JoinListener;
import de.steamwar.spectatesystem.listener.PlayerSeatListener;
import de.steamwar.spectatesystem.util.WorldLoader;
import de.steamwar.sql.UserGroup;
import org.bukkit.Bukkit;
import org.bukkit.plugin.java.JavaPlugin;
import java.io.IOException;
import java.util.EnumSet;
import java.util.Set;
import java.util.logging.Level;
public class SpectateSystem extends JavaPlugin {
public static final Set<UserGroup> allowedGroups = EnumSet.of(UserGroup.Admin, UserGroup.Developer, UserGroup.Moderator);
private static SpectateSystem instance;
private static RScoreboard scoreboard;
private ConnectionAcceptor acceptor;
@ -53,6 +59,7 @@ public class SpectateSystem extends JavaPlugin {
}
Bukkit.getPluginCommand("replay").setExecutor(new ReplayCommand());
Bukkit.getPluginCommand("inspect").setExecutor(new InspectCommand());
WorldLoader.configureForceLoad();
}

Datei anzeigen

@ -0,0 +1,29 @@
package de.steamwar.spectatesystem.commands;
import de.steamwar.spectatesystem.SpectateSystem;
import de.steamwar.sql.SteamwarUser;
import org.bukkit.command.Command;
import org.bukkit.command.CommandExecutor;
import org.bukkit.command.CommandSender;
import org.bukkit.entity.Player;
public class InspectCommand implements CommandExecutor {
public static boolean inspecting = false;
@Override
public boolean onCommand(CommandSender sender, Command command, String alias, String[] args) {
if(sender instanceof Player){
Player player = (Player) sender;
SteamwarUser user = SteamwarUser.get(player.getUniqueId());
if(!SpectateSystem.allowedGroups.contains(user.getUserGroup())){
player.sendMessage("§eSteam§8War» §cUnbekannter Befehl.");
return false;
}
}
inspecting = !inspecting;
sender.sendMessage("Inspection: " + inspecting);
return false;
}
}

Datei anzeigen

@ -20,8 +20,8 @@
package de.steamwar.spectatesystem.commands;
import de.steamwar.spectatesystem.FightfileConnection;
import de.steamwar.spectatesystem.SpectateSystem;
import de.steamwar.sql.SteamwarUser;
import de.steamwar.sql.UserGroup;
import org.bukkit.Bukkit;
import org.bukkit.command.Command;
import org.bukkit.command.CommandExecutor;
@ -30,20 +30,16 @@ import org.bukkit.entity.Player;
import java.io.File;
import java.io.IOException;
import java.util.EnumSet;
import java.util.Set;
import java.util.logging.Level;
public class ReplayCommand implements CommandExecutor {
private static final Set<UserGroup> allowedGroups = EnumSet.of(UserGroup.Admin, UserGroup.Developer, UserGroup.Moderator);
@Override
public boolean onCommand(CommandSender sender, Command command, String alias, String[] args) {
if(sender instanceof Player){
Player player = (Player) sender;
SteamwarUser user = SteamwarUser.get(player.getUniqueId());
if(!allowedGroups.contains(user.getUserGroup())){
if(!SpectateSystem.allowedGroups.contains(user.getUserGroup())){
player.sendMessage("§eSteam§8War» §cUnbekannter Befehl.");
return false;
}

Datei anzeigen

@ -23,18 +23,34 @@ import de.steamwar.scoreboard.SWScoreboard;
import de.steamwar.spectatesystem.Config;
import de.steamwar.spectatesystem.PlayerSetup;
import de.steamwar.spectatesystem.SpectateSystem;
import de.steamwar.spectatesystem.commands.InspectCommand;
import de.steamwar.spectatesystem.elements.REntity;
import de.steamwar.sql.SteamwarUser;
import org.bukkit.entity.Player;
import org.bukkit.event.EventHandler;
import org.bukkit.event.player.PlayerJoinEvent;
import org.bukkit.event.player.PlayerLoginEvent;
import org.bukkit.event.player.PlayerQuitEvent;
public class JoinListener extends BasicListener {
@EventHandler
public void onLogin(PlayerLoginEvent e){
Player player = e.getPlayer();
if(InspectCommand.inspecting){
SteamwarUser user = SteamwarUser.get(player.getUniqueId());
if(!SpectateSystem.allowedGroups.contains(user.getUserGroup())){
e.disallow(PlayerLoginEvent.Result.KICK_WHITELIST, "§eSteam§8War» §cDerzeit ist das Zuschauen nicht gestattet.");
}
}
}
@EventHandler
public void onJoin(PlayerJoinEvent e){
e.setJoinMessage(null);
Player player = e.getPlayer();
player.teleport(Config.SpecSpawn);
REntity.playerJoins(player);
PlayerSetup.playerJoins(player);

Datei anzeigen

@ -22,6 +22,7 @@ package de.steamwar.spectatesystem.listener;
import de.steamwar.spectatesystem.Config;
import de.steamwar.spectatesystem.PlayerSetup;
import de.steamwar.spectatesystem.SpectateSystem;
import de.steamwar.spectatesystem.commands.InspectCommand;
import de.steamwar.spectatesystem.util.Region;
import net.md_5.bungee.api.ChatMessageType;
import net.md_5.bungee.api.chat.BaseComponent;
@ -53,6 +54,9 @@ public class PlayerListener extends BasicListener {
}
private void checkMovementInArena(PlayerMoveEvent event, Location to){
if(InspectCommand.inspecting)
return;
boolean inArenaY = to.getY() + 1.8 <= Config.upperArenaBorder;
boolean inBlueArea = inArenaY && Region.isIn2DRange(to, Config.TeamBlueCornerX, Config.TeamBlueCornerZ, Config.SchemsizeX, Config.SchemsizeZ, Config.BorderFromSchematic);
boolean inRedArea = inArenaY && Region.isIn2DRange(to, Config.TeamRedCornerX, Config.TeamRedCornerZ, Config.SchemsizeX, Config.SchemsizeZ, Config.BorderFromSchematic);

Datei anzeigen

@ -35,6 +35,7 @@ import com.sk89q.worldedit.world.World;
import com.sk89q.worldedit.world.block.BaseBlock;
import com.sk89q.worldedit.world.block.BlockTypes;
import de.steamwar.spectatesystem.Config;
import de.steamwar.spectatesystem.commands.InspectCommand;
import de.steamwar.sql.NoClipboardException;
import de.steamwar.sql.Schematic;
import org.bukkit.Bukkit;
@ -90,7 +91,7 @@ public class Paster {
for(int y = 0; y < clipboard.getDimensions().getY(); y++){
for(int z = 0; z < clipboard.getDimensions().getZ(); z++){
BlockVector3 blockPos = minimum.add(x, y, z);
if(Config.HiddenBlockTags.contains(BukkitAdapter.adapt(clipboard.getFullBlock(blockPos).getBlockType()).name())){
if(!InspectCommand.inspecting && Config.HiddenBlockTags.contains(BukkitAdapter.adapt(clipboard.getFullBlock(blockPos).getBlockType()).name())){
try {
clipboard.setBlock(blockPos, obfuscateWith);
} catch (WorldEditException e) {

Datei anzeigen

@ -10,4 +10,5 @@ depend:
- WorldEdit
- ProtocolLib
commands:
replay:
replay:
inspect: