Merge pull request 'Add inspection option' (#13) from inspection into master
Reviewed-on: #13 Reviewed-by: Chaoscaot <chaoscaot444@gmail.com>
Dieser Commit ist enthalten in:
Commit
8b22558572
@ -20,6 +20,7 @@
|
|||||||
package de.steamwar.spectatesystem;
|
package de.steamwar.spectatesystem;
|
||||||
|
|
||||||
import com.sk89q.worldedit.EditSession;
|
import com.sk89q.worldedit.EditSession;
|
||||||
|
import de.steamwar.spectatesystem.commands.InspectCommand;
|
||||||
import de.steamwar.spectatesystem.elements.*;
|
import de.steamwar.spectatesystem.elements.*;
|
||||||
import de.steamwar.spectatesystem.util.BlockTextCreator;
|
import de.steamwar.spectatesystem.util.BlockTextCreator;
|
||||||
import de.steamwar.spectatesystem.util.ColorConverter;
|
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)
|
if(Config.ArenaMinX > x || Config.ArenaMaxX < x || Config.ArenaMinZ > z || Config.ArenaMaxZ < z)
|
||||||
return; //Outside of the arena
|
return; //Outside of the arena
|
||||||
|
|
||||||
if (Config.TechhiderActive && Config.HiddenBlocks.contains(blockState)) {
|
if (!InspectCommand.inspecting && Config.TechhiderActive && Config.HiddenBlocks.contains(blockState)) {
|
||||||
blockState = Config.ObfuscateWith;
|
blockState = Config.ObfuscateWith;
|
||||||
}
|
}
|
||||||
IBlockData blockData = Objects.requireNonNull(Block.REGISTRY_ID.fromId(blockState));
|
IBlockData blockData = Objects.requireNonNull(Block.REGISTRY_ID.fromId(blockState));
|
||||||
|
@ -26,6 +26,7 @@ import com.comphenix.protocol.wrappers.EnumWrappers;
|
|||||||
import com.comphenix.protocol.wrappers.PlayerInfoData;
|
import com.comphenix.protocol.wrappers.PlayerInfoData;
|
||||||
import com.comphenix.protocol.wrappers.WrappedChatComponent;
|
import com.comphenix.protocol.wrappers.WrappedChatComponent;
|
||||||
import com.comphenix.protocol.wrappers.WrappedGameProfile;
|
import com.comphenix.protocol.wrappers.WrappedGameProfile;
|
||||||
|
import de.steamwar.spectatesystem.commands.InspectCommand;
|
||||||
import org.bukkit.Bukkit;
|
import org.bukkit.Bukkit;
|
||||||
import org.bukkit.GameMode;
|
import org.bukkit.GameMode;
|
||||||
import org.bukkit.Location;
|
import org.bukkit.Location;
|
||||||
@ -102,6 +103,9 @@ public class PlayerSetup {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
Bukkit.getScheduler().runTaskLater(SpectateSystem.get(), () -> {
|
Bukkit.getScheduler().runTaskLater(SpectateSystem.get(), () -> {
|
||||||
|
if(InspectCommand.inspecting)
|
||||||
|
return;
|
||||||
|
|
||||||
PacketContainer gm1packet = ProtocolLibrary.getProtocolManager().createPacket(PacketType.Play.Server.PLAYER_INFO);
|
PacketContainer gm1packet = ProtocolLibrary.getProtocolManager().createPacket(PacketType.Play.Server.PLAYER_INFO);
|
||||||
gm1packet.getPlayerInfoAction().write(0, EnumWrappers.PlayerInfoAction.UPDATE_GAME_MODE);
|
gm1packet.getPlayerInfoAction().write(0, EnumWrappers.PlayerInfoAction.UPDATE_GAME_MODE);
|
||||||
List<PlayerInfoData> playerInfoActions = new ArrayList<>();
|
List<PlayerInfoData> playerInfoActions = new ArrayList<>();
|
||||||
|
@ -19,6 +19,7 @@
|
|||||||
|
|
||||||
package de.steamwar.spectatesystem;
|
package de.steamwar.spectatesystem;
|
||||||
|
|
||||||
|
import de.steamwar.spectatesystem.commands.InspectCommand;
|
||||||
import de.steamwar.spectatesystem.commands.ReplayCommand;
|
import de.steamwar.spectatesystem.commands.ReplayCommand;
|
||||||
import de.steamwar.spectatesystem.elements.RScoreboard;
|
import de.steamwar.spectatesystem.elements.RScoreboard;
|
||||||
import de.steamwar.spectatesystem.listener.PlayerListener;
|
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.JoinListener;
|
||||||
import de.steamwar.spectatesystem.listener.PlayerSeatListener;
|
import de.steamwar.spectatesystem.listener.PlayerSeatListener;
|
||||||
import de.steamwar.spectatesystem.util.WorldLoader;
|
import de.steamwar.spectatesystem.util.WorldLoader;
|
||||||
|
import de.steamwar.sql.UserGroup;
|
||||||
import org.bukkit.Bukkit;
|
import org.bukkit.Bukkit;
|
||||||
import org.bukkit.plugin.java.JavaPlugin;
|
import org.bukkit.plugin.java.JavaPlugin;
|
||||||
|
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
|
import java.util.EnumSet;
|
||||||
|
import java.util.Set;
|
||||||
import java.util.logging.Level;
|
import java.util.logging.Level;
|
||||||
|
|
||||||
public class SpectateSystem extends JavaPlugin {
|
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 SpectateSystem instance;
|
||||||
private static RScoreboard scoreboard;
|
private static RScoreboard scoreboard;
|
||||||
private ConnectionAcceptor acceptor;
|
private ConnectionAcceptor acceptor;
|
||||||
@ -53,6 +59,7 @@ public class SpectateSystem extends JavaPlugin {
|
|||||||
}
|
}
|
||||||
|
|
||||||
Bukkit.getPluginCommand("replay").setExecutor(new ReplayCommand());
|
Bukkit.getPluginCommand("replay").setExecutor(new ReplayCommand());
|
||||||
|
Bukkit.getPluginCommand("inspect").setExecutor(new InspectCommand());
|
||||||
WorldLoader.configureForceLoad();
|
WorldLoader.configureForceLoad();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
29
src/de/steamwar/spectatesystem/commands/InspectCommand.java
Normale Datei
29
src/de/steamwar/spectatesystem/commands/InspectCommand.java
Normale Datei
@ -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;
|
||||||
|
}
|
||||||
|
}
|
@ -20,8 +20,8 @@
|
|||||||
package de.steamwar.spectatesystem.commands;
|
package de.steamwar.spectatesystem.commands;
|
||||||
|
|
||||||
import de.steamwar.spectatesystem.FightfileConnection;
|
import de.steamwar.spectatesystem.FightfileConnection;
|
||||||
|
import de.steamwar.spectatesystem.SpectateSystem;
|
||||||
import de.steamwar.sql.SteamwarUser;
|
import de.steamwar.sql.SteamwarUser;
|
||||||
import de.steamwar.sql.UserGroup;
|
|
||||||
import org.bukkit.Bukkit;
|
import org.bukkit.Bukkit;
|
||||||
import org.bukkit.command.Command;
|
import org.bukkit.command.Command;
|
||||||
import org.bukkit.command.CommandExecutor;
|
import org.bukkit.command.CommandExecutor;
|
||||||
@ -30,20 +30,16 @@ import org.bukkit.entity.Player;
|
|||||||
|
|
||||||
import java.io.File;
|
import java.io.File;
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
import java.util.EnumSet;
|
|
||||||
import java.util.Set;
|
|
||||||
import java.util.logging.Level;
|
import java.util.logging.Level;
|
||||||
|
|
||||||
public class ReplayCommand implements CommandExecutor {
|
public class ReplayCommand implements CommandExecutor {
|
||||||
|
|
||||||
private static final Set<UserGroup> allowedGroups = EnumSet.of(UserGroup.Admin, UserGroup.Developer, UserGroup.Moderator);
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean onCommand(CommandSender sender, Command command, String alias, String[] args) {
|
public boolean onCommand(CommandSender sender, Command command, String alias, String[] args) {
|
||||||
if(sender instanceof Player){
|
if(sender instanceof Player){
|
||||||
Player player = (Player) sender;
|
Player player = (Player) sender;
|
||||||
SteamwarUser user = SteamwarUser.get(player.getUniqueId());
|
SteamwarUser user = SteamwarUser.get(player.getUniqueId());
|
||||||
if(!allowedGroups.contains(user.getUserGroup())){
|
if(!SpectateSystem.allowedGroups.contains(user.getUserGroup())){
|
||||||
player.sendMessage("§eSteam§8War» §cUnbekannter Befehl.");
|
player.sendMessage("§eSteam§8War» §cUnbekannter Befehl.");
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
@ -23,18 +23,34 @@ import de.steamwar.scoreboard.SWScoreboard;
|
|||||||
import de.steamwar.spectatesystem.Config;
|
import de.steamwar.spectatesystem.Config;
|
||||||
import de.steamwar.spectatesystem.PlayerSetup;
|
import de.steamwar.spectatesystem.PlayerSetup;
|
||||||
import de.steamwar.spectatesystem.SpectateSystem;
|
import de.steamwar.spectatesystem.SpectateSystem;
|
||||||
|
import de.steamwar.spectatesystem.commands.InspectCommand;
|
||||||
import de.steamwar.spectatesystem.elements.REntity;
|
import de.steamwar.spectatesystem.elements.REntity;
|
||||||
|
import de.steamwar.sql.SteamwarUser;
|
||||||
import org.bukkit.entity.Player;
|
import org.bukkit.entity.Player;
|
||||||
import org.bukkit.event.EventHandler;
|
import org.bukkit.event.EventHandler;
|
||||||
import org.bukkit.event.player.PlayerJoinEvent;
|
import org.bukkit.event.player.PlayerJoinEvent;
|
||||||
|
import org.bukkit.event.player.PlayerLoginEvent;
|
||||||
import org.bukkit.event.player.PlayerQuitEvent;
|
import org.bukkit.event.player.PlayerQuitEvent;
|
||||||
|
|
||||||
public class JoinListener extends BasicListener {
|
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
|
@EventHandler
|
||||||
public void onJoin(PlayerJoinEvent e){
|
public void onJoin(PlayerJoinEvent e){
|
||||||
e.setJoinMessage(null);
|
e.setJoinMessage(null);
|
||||||
Player player = e.getPlayer();
|
Player player = e.getPlayer();
|
||||||
|
|
||||||
player.teleport(Config.SpecSpawn);
|
player.teleport(Config.SpecSpawn);
|
||||||
REntity.playerJoins(player);
|
REntity.playerJoins(player);
|
||||||
PlayerSetup.playerJoins(player);
|
PlayerSetup.playerJoins(player);
|
||||||
|
@ -22,6 +22,7 @@ package de.steamwar.spectatesystem.listener;
|
|||||||
import de.steamwar.spectatesystem.Config;
|
import de.steamwar.spectatesystem.Config;
|
||||||
import de.steamwar.spectatesystem.PlayerSetup;
|
import de.steamwar.spectatesystem.PlayerSetup;
|
||||||
import de.steamwar.spectatesystem.SpectateSystem;
|
import de.steamwar.spectatesystem.SpectateSystem;
|
||||||
|
import de.steamwar.spectatesystem.commands.InspectCommand;
|
||||||
import de.steamwar.spectatesystem.util.Region;
|
import de.steamwar.spectatesystem.util.Region;
|
||||||
import net.md_5.bungee.api.ChatMessageType;
|
import net.md_5.bungee.api.ChatMessageType;
|
||||||
import net.md_5.bungee.api.chat.BaseComponent;
|
import net.md_5.bungee.api.chat.BaseComponent;
|
||||||
@ -53,6 +54,9 @@ public class PlayerListener extends BasicListener {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private void checkMovementInArena(PlayerMoveEvent event, Location to){
|
private void checkMovementInArena(PlayerMoveEvent event, Location to){
|
||||||
|
if(InspectCommand.inspecting)
|
||||||
|
return;
|
||||||
|
|
||||||
boolean inArenaY = to.getY() + 1.8 <= Config.upperArenaBorder;
|
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 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);
|
boolean inRedArea = inArenaY && Region.isIn2DRange(to, Config.TeamRedCornerX, Config.TeamRedCornerZ, Config.SchemsizeX, Config.SchemsizeZ, Config.BorderFromSchematic);
|
||||||
|
@ -35,6 +35,7 @@ import com.sk89q.worldedit.world.World;
|
|||||||
import com.sk89q.worldedit.world.block.BaseBlock;
|
import com.sk89q.worldedit.world.block.BaseBlock;
|
||||||
import com.sk89q.worldedit.world.block.BlockTypes;
|
import com.sk89q.worldedit.world.block.BlockTypes;
|
||||||
import de.steamwar.spectatesystem.Config;
|
import de.steamwar.spectatesystem.Config;
|
||||||
|
import de.steamwar.spectatesystem.commands.InspectCommand;
|
||||||
import de.steamwar.sql.NoClipboardException;
|
import de.steamwar.sql.NoClipboardException;
|
||||||
import de.steamwar.sql.Schematic;
|
import de.steamwar.sql.Schematic;
|
||||||
import org.bukkit.Bukkit;
|
import org.bukkit.Bukkit;
|
||||||
@ -90,7 +91,7 @@ public class Paster {
|
|||||||
for(int y = 0; y < clipboard.getDimensions().getY(); y++){
|
for(int y = 0; y < clipboard.getDimensions().getY(); y++){
|
||||||
for(int z = 0; z < clipboard.getDimensions().getZ(); z++){
|
for(int z = 0; z < clipboard.getDimensions().getZ(); z++){
|
||||||
BlockVector3 blockPos = minimum.add(x, y, 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 {
|
try {
|
||||||
clipboard.setBlock(blockPos, obfuscateWith);
|
clipboard.setBlock(blockPos, obfuscateWith);
|
||||||
} catch (WorldEditException e) {
|
} catch (WorldEditException e) {
|
||||||
|
@ -11,3 +11,4 @@ depend:
|
|||||||
- ProtocolLib
|
- ProtocolLib
|
||||||
commands:
|
commands:
|
||||||
replay:
|
replay:
|
||||||
|
inspect:
|
||||||
|
In neuem Issue referenzieren
Einen Benutzer sperren