SteamWar/SpigotCore
Archiviert
13
0

Fix Messagesystem for 1.8

Dieser Commit ist enthalten in:
Lixfel 2021-09-11 16:51:36 +02:00
Ursprung 95b9551c70
Commit ef2553e6ac
4 geänderte Dateien mit 25 neuen und 2 gelöschten Zeilen

Datei anzeigen

@ -19,7 +19,12 @@
package de.steamwar.core; package de.steamwar.core;
import net.md_5.bungee.api.ChatMessageType;
import net.md_5.bungee.api.chat.BaseComponent;
import net.minecraft.server.v1_8_R3.ChatComponentText;
import net.minecraft.server.v1_8_R3.PacketPlayOutChat;
import org.bukkit.Sound; import org.bukkit.Sound;
import org.bukkit.craftbukkit.v1_8_R3.entity.CraftPlayer;
import org.bukkit.entity.Player; import org.bukkit.entity.Player;
public class BountifulWrapper8 implements BountifulWrapper.IBountifulWrapper { public class BountifulWrapper8 implements BountifulWrapper.IBountifulWrapper {
@ -28,4 +33,9 @@ public class BountifulWrapper8 implements BountifulWrapper.IBountifulWrapper {
public void playPling(Player player) { public void playPling(Player player) {
player.playSound(player.getLocation(), Sound.ORB_PICKUP, 1, 1); player.playSound(player.getLocation(), Sound.ORB_PICKUP, 1, 1);
} }
@Override
public void sendMessage(Player player, ChatMessageType type, BaseComponent... msg) {
((CraftPlayer) player).getHandle().playerConnection.sendPacket(new PacketPlayOutChat(new ChatComponentText(BaseComponent.toLegacyText(msg)), (byte)type.ordinal()));
}
} }

Datei anzeigen

@ -19,6 +19,8 @@
package de.steamwar.core; package de.steamwar.core;
import net.md_5.bungee.api.ChatMessageType;
import net.md_5.bungee.api.chat.BaseComponent;
import org.bukkit.Sound; import org.bukkit.Sound;
import org.bukkit.entity.Player; import org.bukkit.entity.Player;
@ -28,4 +30,9 @@ public class BountifulWrapper9 implements BountifulWrapper.IBountifulWrapper {
public void playPling(Player player) { public void playPling(Player player) {
player.playSound(player.getLocation(), Sound.ENTITY_EXPERIENCE_ORB_PICKUP, 1, 1); player.playSound(player.getLocation(), Sound.ENTITY_EXPERIENCE_ORB_PICKUP, 1, 1);
} }
@Override
public void sendMessage(Player player, ChatMessageType type, BaseComponent... msg) {
player.spigot().sendMessage(type, msg);
}
} }

Datei anzeigen

@ -19,6 +19,8 @@
package de.steamwar.core; package de.steamwar.core;
import net.md_5.bungee.api.ChatMessageType;
import net.md_5.bungee.api.chat.BaseComponent;
import org.bukkit.entity.Player; import org.bukkit.entity.Player;
public class BountifulWrapper { public class BountifulWrapper {
@ -28,5 +30,7 @@ public class BountifulWrapper {
public interface IBountifulWrapper { public interface IBountifulWrapper {
void playPling(Player player); void playPling(Player player);
void sendMessage(Player player, ChatMessageType type, BaseComponent... msg);
} }
} }

Datei anzeigen

@ -19,6 +19,7 @@
package de.steamwar.message; package de.steamwar.message;
import de.steamwar.core.BountifulWrapper;
import de.steamwar.core.WorldOfColorWrapper; import de.steamwar.core.WorldOfColorWrapper;
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;
@ -108,10 +109,11 @@ public class Message {
msg.setHoverEvent(new HoverEvent(HoverEvent.Action.SHOW_TEXT, TextComponent.fromLegacyText(onHover))); msg.setHoverEvent(new HoverEvent(HoverEvent.Action.SHOW_TEXT, TextComponent.fromLegacyText(onHover)));
if(onClick != null) if(onClick != null)
msg.setClickEvent(onClick); msg.setClickEvent(onClick);
if(sender instanceof Player) if(sender instanceof Player)
((Player)sender).spigot().sendMessage(type, msg); BountifulWrapper.impl.sendMessage((Player)sender, type, msg);
else else
sender.spigot().sendMessage(msg); sender.sendMessage(msg.toPlainText());
} }
/* Send message to all players */ /* Send message to all players */