Skip to content

Commit

Permalink
Update to v5.9.6: Readd legacy action bar method to restore 1.8? and …
Browse files Browse the repository at this point in the history
…lower support
  • Loading branch information
LeonMangler committed Jul 2, 2017
1 parent 897b823 commit 960f497
Show file tree
Hide file tree
Showing 6 changed files with 32 additions and 9 deletions.
6 changes: 4 additions & 2 deletions src/main/java/de/myzelyam/supervanish/SuperVanish.java
Original file line number Diff line number Diff line change
Expand Up @@ -64,8 +64,10 @@

public class SuperVanish extends JavaPlugin {

private static final String[] NON_REQUIRED_SETTING_UPDATES = new String[]{"5.9.2", "5.9.3", "5.9.4"};
private static final String[] NON_REQUIRED_MESSAGE_UPDATES = new String[]{"5.9.2", "5.9.3", "5.9.4"};
private static final String[] NON_REQUIRED_SETTING_UPDATES = new String[]{"5.9.2", "5.9.3", "5.9.4",
"5.9.5"};
private static final String[] NON_REQUIRED_MESSAGE_UPDATES = new String[]{"5.9.2", "5.9.3", "5.9.4",
"5.9.5"};
public boolean requiresCfgUpdate = false;
public boolean requiresMsgUpdate = false;
public boolean packetNightVision = false;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,11 +6,14 @@

package de.myzelyam.supervanish.utils;

import com.comphenix.protocol.PacketType;
import com.comphenix.protocol.ProtocolLibrary;
import com.comphenix.protocol.events.PacketContainer;
import com.comphenix.protocol.wrappers.WrappedChatComponent;

import de.myzelyam.supervanish.SuperVanish;

import org.bukkit.ChatColor;
import org.bukkit.entity.Player;
import org.bukkit.potion.PotionEffect;
import org.bukkit.potion.PotionEffectType;
Expand All @@ -29,6 +32,21 @@ public ProtocolLibPacketUtils(SuperVanish plugin) {
this.plugin = plugin;
}

public void sendActionBarLegacy(Player p, String bar) {
String json = "{\"text\": \""
+ ChatColor.translateAlternateColorCodes('&', bar) + "\"}";
WrappedChatComponent msg = WrappedChatComponent.fromJson(json);
PacketContainer chatMsg = new PacketContainer(
PacketType.Play.Server.CHAT);
chatMsg.getChatComponents().write(0, msg);
chatMsg.getBytes().write(0, (byte) 2);
try {
ProtocolLibrary.getProtocolManager().sendServerPacket(p, chatMsg);
} catch (InvocationTargetException e) {
throw new RuntimeException("Cannot send packet " + chatMsg, e);
}
}

public void sendAddPotionEffect(final Player p, PotionEffect effect) {
//noinspection deprecation
final int effectID = effect.getType().getId();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,8 +36,11 @@ public void run() {
List<Player> actionBars = ImmutableList.copyOf(ActionBarMgr.this.actionBars);
for (Player player : actionBars) {
String message = plugin.convertString(plugin.getMsg("ActionBarMessage"), player);
player.spigot().sendMessage(ChatMessageType.ACTION_BAR, TextComponent
.fromLegacyText(message));
if (!plugin.isOneDotXOrHigher(11)) {
plugin.getProtocolLibPacketUtils().sendActionBarLegacy(player, message);
} else
player.spigot().sendMessage(ChatMessageType.ACTION_BAR, TextComponent
.fromLegacyText(message));
}
} catch (Exception e) {
plugin.printException(e);
Expand Down
4 changes: 2 additions & 2 deletions src/main/resources/config.yml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# SuperVanish v5.9.5 - Configuration
# SuperVanish v5.9.6 - Configuration
#
Configuration:
##################################################
Expand Down Expand Up @@ -124,4 +124,4 @@ Configuration:
#################################################
################# DO NOT TOUCH ##################
#################################################
ConfigVersion: 5.9.5
ConfigVersion: 5.9.6
4 changes: 2 additions & 2 deletions src/main/resources/messages.yml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# SuperVanish v5.9.5 - Messages
# SuperVanish v5.9.6 - Messages
# Information:
# You can use the & character for color codes. Example: '&cThe color of this text would be red!'
# You can use %p to get the player's name. Example: '&4&l%p, you aren't allowed to execute this command!'
Expand Down Expand Up @@ -40,4 +40,4 @@ Messages:
NoConfigUpdateAvailableMessage: '&eYour SuperVanish-files are up to date!'
DynmapFakeJoin: '%d joined'
DynmapFakeQuit: '%d left'
MessagesVersion: 5.9.5
MessagesVersion: 5.9.6
2 changes: 1 addition & 1 deletion src/main/resources/plugin.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ name: SuperVanish
main: de.myzelyam.supervanish.SuperVanish
author: MyzelYam
description: Advanced /vanish plugin which makes other players think that you're not on the server
version: 5.9.5
version: 5.9.6
website: https://www.spigotmc.org/resources/supervanish-be-invisible.1331/
softdepend:
- ProtocolLib
Expand Down

0 comments on commit 960f497

Please sign in to comment.