forked from SteamWar/SteamWar
Fix some stuff
This commit is contained in:
@@ -53,5 +53,4 @@ public enum ArenaMode {
|
|||||||
public static final Set<ArenaMode> SoloLeader = Collections.unmodifiableSet(EnumSet.of(TEST, CHECK, PREPARE));
|
public static final Set<ArenaMode> SoloLeader = Collections.unmodifiableSet(EnumSet.of(TEST, CHECK, PREPARE));
|
||||||
public static final Set<ArenaMode> NotOnBau = Collections.unmodifiableSet(EnumSet.complementOf(EnumSet.of(TEST, CHECK, PREPARE, REPLAY)));
|
public static final Set<ArenaMode> NotOnBau = Collections.unmodifiableSet(EnumSet.complementOf(EnumSet.of(TEST, CHECK, PREPARE, REPLAY)));
|
||||||
public static final Set<ArenaMode> SeriousFight = Collections.unmodifiableSet(EnumSet.complementOf(EnumSet.of(TEST, CHECK, REPLAY)));
|
public static final Set<ArenaMode> SeriousFight = Collections.unmodifiableSet(EnumSet.complementOf(EnumSet.of(TEST, CHECK, REPLAY)));
|
||||||
public static final Set<ArenaMode> CheckOrTest = Collections.unmodifiableSet(EnumSet.of(TEST, CHECK));
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -107,7 +107,7 @@ public class FightSystem extends JavaPlugin {
|
|||||||
new HotbarKit.HotbarKitListener();
|
new HotbarKit.HotbarKitListener();
|
||||||
new JoinRequestListener();
|
new JoinRequestListener();
|
||||||
new OneShotStateDependent(ArenaMode.All, FightState.PreSchemSetup, () -> Fight.playSound(SWSound.BLOCK_NOTE_PLING.getSound(), 100.0f, 2.0f));
|
new OneShotStateDependent(ArenaMode.All, FightState.PreSchemSetup, () -> Fight.playSound(SWSound.BLOCK_NOTE_PLING.getSound(), 100.0f, 2.0f));
|
||||||
new OneShotStateDependent(ArenaMode.CheckOrTest, FightState.All, WorldEditRendererCUIEditor::new);
|
new OneShotStateDependent(ArenaMode.Test, FightState.All, WorldEditRendererCUIEditor::new);
|
||||||
|
|
||||||
new EnterHandler();
|
new EnterHandler();
|
||||||
techHider = new TechHiderWrapper();
|
techHider = new TechHiderWrapper();
|
||||||
|
|||||||
@@ -20,8 +20,6 @@
|
|||||||
package de.steamwar.core;
|
package de.steamwar.core;
|
||||||
|
|
||||||
import com.comphenix.tinyprotocol.TinyProtocol;
|
import com.comphenix.tinyprotocol.TinyProtocol;
|
||||||
import com.google.gson.Gson;
|
|
||||||
import com.google.gson.JsonObject;
|
|
||||||
import de.steamwar.Reflection;
|
import de.steamwar.Reflection;
|
||||||
import de.steamwar.command.*;
|
import de.steamwar.command.*;
|
||||||
import de.steamwar.core.authlib.AuthlibInjector;
|
import de.steamwar.core.authlib.AuthlibInjector;
|
||||||
@@ -38,37 +36,23 @@ import de.steamwar.sql.internal.Statement;
|
|||||||
import org.bukkit.Bukkit;
|
import org.bukkit.Bukkit;
|
||||||
import org.bukkit.command.CommandSender;
|
import org.bukkit.command.CommandSender;
|
||||||
import org.bukkit.entity.Player;
|
import org.bukkit.entity.Player;
|
||||||
import org.bukkit.event.EventHandler;
|
|
||||||
import org.bukkit.event.EventPriority;
|
|
||||||
import org.bukkit.event.Listener;
|
import org.bukkit.event.Listener;
|
||||||
import org.bukkit.event.player.PlayerQuitEvent;
|
|
||||||
import org.bukkit.plugin.java.JavaPlugin;
|
import org.bukkit.plugin.java.JavaPlugin;
|
||||||
import org.bukkit.plugin.messaging.PluginMessageListener;
|
|
||||||
|
|
||||||
import java.io.BufferedReader;
|
import java.io.BufferedReader;
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
import java.io.InputStreamReader;
|
import java.io.InputStreamReader;
|
||||||
import java.util.Collection;
|
import java.util.Collection;
|
||||||
import java.util.HashMap;
|
|
||||||
import java.util.Map;
|
|
||||||
import java.util.logging.Level;
|
import java.util.logging.Level;
|
||||||
|
|
||||||
public class Core extends JavaPlugin implements PluginMessageListener, Listener {
|
public class Core extends JavaPlugin {
|
||||||
|
|
||||||
public static final Message MESSAGE = new Message("SpigotCore", Core.class.getClassLoader());
|
public static final Message MESSAGE = new Message("SpigotCore", Core.class.getClassLoader());
|
||||||
|
|
||||||
private static final String CHANNEL = "vv:proxy_details";
|
|
||||||
private static final Gson GSON = new Gson();
|
|
||||||
private static final Map<Player, Integer> playerVersions = new HashMap<>();
|
|
||||||
|
|
||||||
public static int getVersion(){
|
public static int getVersion(){
|
||||||
return Reflection.MAJOR_VERSION;
|
return Reflection.MAJOR_VERSION;
|
||||||
}
|
}
|
||||||
|
|
||||||
public static int getPlayerVersion(Player player) {
|
|
||||||
return playerVersions.getOrDefault(player, -1);
|
|
||||||
}
|
|
||||||
|
|
||||||
public static boolean isBedrockPlayer(Player player) {
|
public static boolean isBedrockPlayer(Player player) {
|
||||||
return player.getName().startsWith(".");
|
return player.getName().startsWith(".");
|
||||||
}
|
}
|
||||||
@@ -91,8 +75,7 @@ public class Core extends JavaPlugin implements PluginMessageListener, Listener
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onEnable() {
|
public void onEnable() {
|
||||||
this.getServer().getMessenger().registerIncomingPluginChannel(this, CHANNEL, this);
|
new PlayerVersion();
|
||||||
Bukkit.getPluginManager().registerEvents(this, this);
|
|
||||||
|
|
||||||
errorHandler = new ErrorHandler();
|
errorHandler = new ErrorHandler();
|
||||||
crashDetector = new CrashDetector();
|
crashDetector = new CrashDetector();
|
||||||
@@ -151,20 +134,4 @@ public class Core extends JavaPlugin implements PluginMessageListener, Listener
|
|||||||
Statement.closeAll();
|
Statement.closeAll();
|
||||||
this.getServer().getMessenger().unregisterIncomingPluginChannel(this);
|
this.getServer().getMessenger().unregisterIncomingPluginChannel(this);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
|
||||||
public void onPluginMessageReceived(String channel, Player player, byte[] bytes) {
|
|
||||||
if (!channel.equals(CHANNEL)) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
final JsonObject payload = GSON.fromJson(new String(bytes), JsonObject.class);
|
|
||||||
final String version = payload.get("versionName").getAsString();
|
|
||||||
playerVersions.put(player, Integer.parseInt(version.split("-")[0].split("\\.")[1]));
|
|
||||||
}
|
|
||||||
|
|
||||||
@EventHandler(priority = EventPriority.MONITOR, ignoreCancelled = true)
|
|
||||||
public void onPlayerQuit(PlayerQuitEvent event) {
|
|
||||||
playerVersions.remove(event.getPlayer());
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -0,0 +1,65 @@
|
|||||||
|
/*
|
||||||
|
* This file is a part of the SteamWar software.
|
||||||
|
*
|
||||||
|
* Copyright (C) 2020 SteamWar.de-Serverteam
|
||||||
|
*
|
||||||
|
* This program is free software: you can redistribute it and/or modify
|
||||||
|
* it under the terms of the GNU Affero General Public License as published by
|
||||||
|
* the Free Software Foundation, either version 3 of the License, or
|
||||||
|
* (at your option) any later version.
|
||||||
|
*
|
||||||
|
* This program is distributed in the hope that it will be useful,
|
||||||
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
* GNU Affero General Public License for more details.
|
||||||
|
*
|
||||||
|
* You should have received a copy of the GNU Affero General Public License
|
||||||
|
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||||
|
*/
|
||||||
|
|
||||||
|
package de.steamwar.core;
|
||||||
|
|
||||||
|
import com.google.gson.Gson;
|
||||||
|
import com.google.gson.JsonObject;
|
||||||
|
import org.bukkit.Bukkit;
|
||||||
|
import org.bukkit.entity.Player;
|
||||||
|
import org.bukkit.event.EventHandler;
|
||||||
|
import org.bukkit.event.EventPriority;
|
||||||
|
import org.bukkit.event.Listener;
|
||||||
|
import org.bukkit.event.player.PlayerQuitEvent;
|
||||||
|
import org.bukkit.plugin.messaging.PluginMessageListener;
|
||||||
|
|
||||||
|
import java.util.HashMap;
|
||||||
|
import java.util.Map;
|
||||||
|
|
||||||
|
public class PlayerVersion implements PluginMessageListener, Listener {
|
||||||
|
|
||||||
|
private static final String PLAYER_VERSION_CHANNEL = "vv:proxy_details";
|
||||||
|
private static final Gson GSON = new Gson();
|
||||||
|
private static final Map<Player, Integer> playerVersions = new HashMap<>();
|
||||||
|
|
||||||
|
public static int getVersion(Player player) {
|
||||||
|
return playerVersions.getOrDefault(player, -1);
|
||||||
|
}
|
||||||
|
|
||||||
|
public PlayerVersion() {
|
||||||
|
Core.getInstance().getServer().getMessenger().registerIncomingPluginChannel(Core.getInstance(), PLAYER_VERSION_CHANNEL, this);
|
||||||
|
Bukkit.getPluginManager().registerEvents(this, Core.getInstance());
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void onPluginMessageReceived(String channel, Player player, byte[] bytes) {
|
||||||
|
if (!channel.equals(PLAYER_VERSION_CHANNEL)) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
final JsonObject payload = GSON.fromJson(new String(bytes), JsonObject.class);
|
||||||
|
final String version = payload.get("versionName").getAsString();
|
||||||
|
playerVersions.put(player, Integer.parseInt(version.split("-")[0].split("\\.")[1]));
|
||||||
|
}
|
||||||
|
|
||||||
|
@EventHandler(priority = EventPriority.MONITOR, ignoreCancelled = true)
|
||||||
|
public void onPlayerQuit(PlayerQuitEvent event) {
|
||||||
|
playerVersions.remove(event.getPlayer());
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -105,11 +105,6 @@ public class WorldEditRenderer implements Listener {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@EventHandler
|
|
||||||
public void onPlayerJoin(PlayerJoinEvent event) {
|
|
||||||
renderPlayer(event.getPlayer());
|
|
||||||
}
|
|
||||||
|
|
||||||
@EventHandler
|
@EventHandler
|
||||||
public void onPlayerMove(PlayerMoveEvent event) {
|
public void onPlayerMove(PlayerMoveEvent event) {
|
||||||
if(event.getPlayer().getItemInHand().getType() == WAND) {
|
if(event.getPlayer().getItemInHand().getType() == WAND) {
|
||||||
|
|||||||
@@ -27,7 +27,7 @@ public interface WorldEditRendererWrapper {
|
|||||||
WorldEditRendererWrapper impl = VersionDependent.getVersionImpl(Core.getInstance());
|
WorldEditRendererWrapper impl = VersionDependent.getVersionImpl(Core.getInstance());
|
||||||
|
|
||||||
static void safeDraw(Player player, Player owner, boolean clipboard, Vector pos1, Vector pos2) {
|
static void safeDraw(Player player, Player owner, boolean clipboard, Vector pos1, Vector pos2) {
|
||||||
if (Core.isBedrockPlayer(player) || Core.getPlayerVersion(player) < 20) {
|
if (Core.isBedrockPlayer(player) || PlayerVersion.getVersion(player) < 20) {
|
||||||
fallback.draw(player, owner, clipboard, pos1, pos2);
|
fallback.draw(player, owner, clipboard, pos1, pos2);
|
||||||
} else {
|
} else {
|
||||||
impl.draw(player, owner, clipboard, pos1, pos2);
|
impl.draw(player, owner, clipboard, pos1, pos2);
|
||||||
|
|||||||
Reference in New Issue
Block a user