Dieser Commit ist enthalten in:
Commit
cef153efca
@ -222,11 +222,9 @@ public class FlatteningWrapper14 implements FlatteningWrapper.IFlatteningWrapper
|
|||||||
}
|
}
|
||||||
|
|
||||||
private static final Reflection.FieldAccessor<?> scoreboardName = Reflection.getField(FlatteningWrapper.scoreboardObjective, Reflection.getClass("{nms.network.chat}.IChatBaseComponent"), 0);
|
private static final Reflection.FieldAccessor<?> scoreboardName = Reflection.getField(FlatteningWrapper.scoreboardObjective, Reflection.getClass("{nms.network.chat}.IChatBaseComponent"), 0);
|
||||||
private static final Reflection.ConstructorInvoker chatComponentConstructor = Reflection.getConstructor(Reflection.getClass("{nms.network.chat}.ChatComponentText"), String.class);
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void setScoreboardTitle(Object packet, String title) {
|
public void setScoreboardTitle(Object packet, String title) {
|
||||||
scoreboardName.set(packet, chatComponentConstructor.invoke(title));
|
scoreboardName.set(packet, ChatWrapper.impl.stringToChatComponent(title));
|
||||||
}
|
}
|
||||||
|
|
||||||
private static final Class<?> scoreActionEnum = Reflection.getClass("{nms.server}.ScoreboardServer$Action");
|
private static final Class<?> scoreActionEnum = Reflection.getClass("{nms.server}.ScoreboardServer$Action");
|
||||||
|
38
SpigotCore_19/src/de/steamwar/core/ChatWrapper19.java
Normale Datei
38
SpigotCore_19/src/de/steamwar/core/ChatWrapper19.java
Normale Datei
@ -0,0 +1,38 @@
|
|||||||
|
/*
|
||||||
|
* This file is a part of the SteamWar software.
|
||||||
|
*
|
||||||
|
* Copyright (C) 2022 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.comphenix.tinyprotocol.Reflection;
|
||||||
|
import com.comphenix.tinyprotocol.TinyProtocol;
|
||||||
|
import net.minecraft.network.chat.IChatMutableComponent;
|
||||||
|
import net.minecraft.network.chat.contents.LiteralContents;
|
||||||
|
|
||||||
|
public class ChatWrapper19 implements ChatWrapper {
|
||||||
|
@Override
|
||||||
|
public Object stringToChatComponent(String text) {
|
||||||
|
return IChatMutableComponent.a(new LiteralContents(text));
|
||||||
|
}
|
||||||
|
|
||||||
|
private static final Reflection.FieldAccessor<String> getName = Reflection.getField(TinyProtocol.PACKET_LOGIN_IN_START, String.class, 0);
|
||||||
|
@Override
|
||||||
|
public String getNameByLoginPacket(Object packet) {
|
||||||
|
return getName.get(packet);
|
||||||
|
}
|
||||||
|
}
|
39
SpigotCore_8/src/de/steamwar/core/ChatWrapper8.java
Normale Datei
39
SpigotCore_8/src/de/steamwar/core/ChatWrapper8.java
Normale Datei
@ -0,0 +1,39 @@
|
|||||||
|
/*
|
||||||
|
* This file is a part of the SteamWar software.
|
||||||
|
*
|
||||||
|
* Copyright (C) 2022 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.comphenix.tinyprotocol.Reflection;
|
||||||
|
import com.comphenix.tinyprotocol.TinyProtocol;
|
||||||
|
import com.mojang.authlib.GameProfile;
|
||||||
|
|
||||||
|
public class ChatWrapper8 implements ChatWrapper {
|
||||||
|
|
||||||
|
private static final Reflection.ConstructorInvoker chatComponentConstructor = Reflection.getConstructor(Reflection.getClass("{nms.network.chat}.ChatComponentText"), String.class);
|
||||||
|
@Override
|
||||||
|
public Object stringToChatComponent(String text) {
|
||||||
|
return chatComponentConstructor.invoke(text);
|
||||||
|
}
|
||||||
|
|
||||||
|
private static final Reflection.FieldAccessor<GameProfile> getGameProfile = Reflection.getField(TinyProtocol.PACKET_LOGIN_IN_START, GameProfile.class, 0);
|
||||||
|
@Override
|
||||||
|
public String getNameByLoginPacket(Object packet) {
|
||||||
|
return getGameProfile.get(packet).getName();
|
||||||
|
}
|
||||||
|
}
|
@ -4,7 +4,7 @@ import com.comphenix.tinyprotocol.Reflection.FieldAccessor;
|
|||||||
import com.comphenix.tinyprotocol.Reflection.MethodInvoker;
|
import com.comphenix.tinyprotocol.Reflection.MethodInvoker;
|
||||||
import com.google.common.collect.Lists;
|
import com.google.common.collect.Lists;
|
||||||
import com.google.common.collect.MapMaker;
|
import com.google.common.collect.MapMaker;
|
||||||
import com.mojang.authlib.GameProfile;
|
import de.steamwar.core.ChatWrapper;
|
||||||
import de.steamwar.core.Core;
|
import de.steamwar.core.Core;
|
||||||
import io.netty.channel.*;
|
import io.netty.channel.*;
|
||||||
import org.bukkit.Bukkit;
|
import org.bukkit.Bukkit;
|
||||||
@ -48,8 +48,7 @@ public class TinyProtocol {
|
|||||||
private static final FieldAccessor<Collection> getNetworkMarkers = Reflection.getField(serverConnectionClass, Collection.class, 1);
|
private static final FieldAccessor<Collection> getNetworkMarkers = Reflection.getField(serverConnectionClass, Collection.class, 1);
|
||||||
|
|
||||||
// Packets we have to intercept
|
// Packets we have to intercept
|
||||||
private static final Class<?> PACKET_LOGIN_IN_START = Reflection.getClass("{nms.network.protocol.login}.PacketLoginInStart");
|
public static final Class<?> PACKET_LOGIN_IN_START = Reflection.getClass("{nms.network.protocol.login}.PacketLoginInStart");
|
||||||
private static final FieldAccessor<GameProfile> getGameProfile = Reflection.getField(PACKET_LOGIN_IN_START, GameProfile.class, 0);
|
|
||||||
|
|
||||||
// Speedup channel lookup
|
// Speedup channel lookup
|
||||||
private final Map<String, Channel> channelLookup = new MapMaker().weakValues().makeMap();
|
private final Map<String, Channel> channelLookup = new MapMaker().weakValues().makeMap();
|
||||||
@ -404,8 +403,7 @@ public class TinyProtocol {
|
|||||||
|
|
||||||
private void handleLoginStart(Channel channel, Object packet) {
|
private void handleLoginStart(Channel channel, Object packet) {
|
||||||
if (PACKET_LOGIN_IN_START.isInstance(packet)) {
|
if (PACKET_LOGIN_IN_START.isInstance(packet)) {
|
||||||
GameProfile profile = getGameProfile.get(packet);
|
channelLookup.put(ChatWrapper.impl.getNameByLoginPacket(packet), channel);
|
||||||
channelLookup.put(profile.getName(), channel);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
27
SpigotCore_Main/src/de/steamwar/core/ChatWrapper.java
Normale Datei
27
SpigotCore_Main/src/de/steamwar/core/ChatWrapper.java
Normale Datei
@ -0,0 +1,27 @@
|
|||||||
|
/*
|
||||||
|
* This file is a part of the SteamWar software.
|
||||||
|
*
|
||||||
|
* Copyright (C) 2022 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;
|
||||||
|
|
||||||
|
public interface ChatWrapper {
|
||||||
|
ChatWrapper impl = VersionDependent.getVersionImpl(Core.getInstance());
|
||||||
|
|
||||||
|
Object stringToChatComponent(String text);
|
||||||
|
String getNameByLoginPacket(Object packet);
|
||||||
|
}
|
@ -49,7 +49,9 @@ public class Core extends JavaPlugin{
|
|||||||
private static final int VERSION;
|
private static final int VERSION;
|
||||||
static{
|
static{
|
||||||
String packageName = Bukkit.getServer().getClass().getPackage().getName();
|
String packageName = Bukkit.getServer().getClass().getPackage().getName();
|
||||||
if(packageName.contains("1_18"))
|
if(packageName.contains("1_19"))
|
||||||
|
VERSION = 19;
|
||||||
|
else if(packageName.contains("1_18"))
|
||||||
VERSION = 18;
|
VERSION = 18;
|
||||||
else if(packageName.contains("1_15"))
|
else if(packageName.contains("1_15"))
|
||||||
VERSION = 15;
|
VERSION = 15;
|
||||||
@ -120,6 +122,7 @@ public class Core extends JavaPlugin{
|
|||||||
Bukkit.getPluginManager().registerEvents(new WorldLoadEvent(), this);
|
Bukkit.getPluginManager().registerEvents(new WorldLoadEvent(), this);
|
||||||
getServer().getMessenger().registerIncomingPluginChannel(this, "sw:bridge", new NetworkReceiver());
|
getServer().getMessenger().registerIncomingPluginChannel(this, "sw:bridge", new NetworkReceiver());
|
||||||
getServer().getMessenger().registerOutgoingPluginChannel(this, "sw:bridge");
|
getServer().getMessenger().registerOutgoingPluginChannel(this, "sw:bridge");
|
||||||
|
if(Core.getVersion() < 19)
|
||||||
AuthlibInjector.inject();
|
AuthlibInjector.inject();
|
||||||
TinyProtocol.init();
|
TinyProtocol.init();
|
||||||
try {
|
try {
|
||||||
|
@ -20,7 +20,7 @@
|
|||||||
package de.steamwar.message;
|
package de.steamwar.message;
|
||||||
|
|
||||||
import de.steamwar.core.BountifulWrapper;
|
import de.steamwar.core.BountifulWrapper;
|
||||||
import de.steamwar.core.WorldOfColorWrapper;
|
import de.steamwar.core.Core;
|
||||||
import de.steamwar.sql.SteamwarUser;
|
import de.steamwar.sql.SteamwarUser;
|
||||||
import net.md_5.bungee.api.ChatMessageType;
|
import net.md_5.bungee.api.ChatMessageType;
|
||||||
import net.md_5.bungee.api.chat.ClickEvent;
|
import net.md_5.bungee.api.chat.ClickEvent;
|
||||||
@ -30,12 +30,12 @@ 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 java.nio.charset.StandardCharsets;
|
||||||
import java.text.MessageFormat;
|
import java.text.MessageFormat;
|
||||||
import java.util.Locale;
|
import java.util.Locale;
|
||||||
import java.util.ResourceBundle;
|
import java.util.ResourceBundle;
|
||||||
|
|
||||||
public class Message {
|
public class Message {
|
||||||
|
|
||||||
private final String resourceBundleName;
|
private final String resourceBundleName;
|
||||||
private final ClassLoader classLoader;
|
private final ClassLoader classLoader;
|
||||||
|
|
||||||
@ -68,12 +68,19 @@ public class Message {
|
|||||||
ResourceBundle resourceBundle = ResourceBundle.getBundle(resourceBundleName, locale, classLoader);
|
ResourceBundle resourceBundle = ResourceBundle.getBundle(resourceBundleName, locale, classLoader);
|
||||||
String pattern = "";
|
String pattern = "";
|
||||||
if(prefixed)
|
if(prefixed)
|
||||||
pattern = resourceBundle.getObject("PREFIX") + " ";
|
pattern = fromRB(resourceBundle, "PREFIX") + " ";
|
||||||
pattern += (String)resourceBundle.getObject(message);
|
pattern += fromRB(resourceBundle, message);
|
||||||
|
|
||||||
return new MessageFormat(pattern, locale).format(params);
|
return new MessageFormat(pattern, locale).format(params);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private String fromRB(ResourceBundle bundle, String key) {
|
||||||
|
String result = bundle.getString(key);
|
||||||
|
if(Core.getVersion() < 12)
|
||||||
|
result = new String(result.getBytes(StandardCharsets.ISO_8859_1), StandardCharsets.UTF_8);
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
private Locale getLocale(Player player){
|
private Locale getLocale(Player player){
|
||||||
return SteamwarUser.get(player).getLocale();
|
return SteamwarUser.get(player).getLocale();
|
||||||
}
|
}
|
||||||
|
In neuem Issue referenzieren
Einen Benutzer sperren