mirror of
https://github.com/sekwah41/Advanced-Portals.git
synced 2024-12-26 02:48:15 +01:00
Finished the NMS system and added a new config variable to hide bungee
warp messages(as they can be annoying)
This commit is contained in:
parent
70f949dc23
commit
4e00c6a293
@ -41,29 +41,29 @@ warpParticles: 1
|
||||
# 0 = disabled(no sound)
|
||||
# 1 = Enderman Warp Sound
|
||||
# 2 = Explosion
|
||||
warpSound: 1
|
||||
|
||||
|
||||
WarpSound: 1
|
||||
|
||||
# In case you want to show the bungee attempting warp message
|
||||
ShowBungeeWarpMessage: false
|
||||
|
||||
# This changes how long the show seletion lasts in seconds
|
||||
|
||||
ShowSelectionShowDuration: 10
|
||||
|
||||
# If a player is riding a entity, warp the entity too?
|
||||
# If a player is riding a entity, warp the entity too?(unless its a bungee portal)
|
||||
|
||||
WarpRiddenEntity: true
|
||||
|
||||
# Use the default warp messages for portals
|
||||
portalWarpMessages: true
|
||||
PortalWarpMessages: true
|
||||
|
||||
# Use plugin name in the warp messages
|
||||
useWarpPrefix: true
|
||||
UseWarpPrefix: true
|
||||
|
||||
# If this is true a custom prefix can be used
|
||||
|
||||
useCustomPrefix: false
|
||||
UseCustomPrefix: false
|
||||
|
||||
customPrefix: '[Test]'
|
||||
CustomPrefix: '[Test]'
|
||||
|
||||
|
||||
|
@ -5,10 +5,6 @@ import java.util.Collections;
|
||||
import java.util.LinkedList;
|
||||
import java.util.List;
|
||||
|
||||
import net.minecraft.server.v1_7_R3.ChatSerializer;
|
||||
import net.minecraft.server.v1_7_R3.IChatBaseComponent;
|
||||
import net.minecraft.server.v1_7_R3.PacketPlayOutChat;
|
||||
|
||||
import org.bukkit.Location;
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.World;
|
||||
@ -16,7 +12,6 @@ import org.bukkit.command.Command;
|
||||
import org.bukkit.command.CommandExecutor;
|
||||
import org.bukkit.command.CommandSender;
|
||||
import org.bukkit.command.TabCompleter;
|
||||
import org.bukkit.craftbukkit.v1_7_R3.entity.CraftPlayer;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.inventory.ItemStack;
|
||||
import org.bukkit.inventory.PlayerInventory;
|
||||
@ -219,7 +214,8 @@ public class AdvancedPortalsCommand implements CommandExecutor, TabCompleter {
|
||||
sender.sendMessage("");
|
||||
sender.sendMessage("§c[§7AdvancedPortals§c] Are you sure you would like to remove the portal §e" + args[2] + "§c?");
|
||||
sender.sendMessage("");
|
||||
|
||||
plugin.nmsAccess.sendRawMessage("{text:\" \",extra:[{text:\"§e[Yes]\",hoverEvent:{action:show_text,value:\"Confirm removing this portal\"},clickEvent:{action:run_command,value:\"/portal remove " + args[2] + "\"}}, " +
|
||||
"{text:\" \"},{text:\"§e[No]\",hoverEvent:{action:show_text,value:\"Cancel removing this portal\"},clickEvent:{action:run_command,value:\"/portal edit " + args[2] + "\"}}]}", player);
|
||||
sender.sendMessage("");
|
||||
}
|
||||
}
|
||||
@ -403,12 +399,17 @@ public class AdvancedPortalsCommand implements CommandExecutor, TabCompleter {
|
||||
|
||||
Player player = (Player)sender;
|
||||
|
||||
IChatBaseComponent comp = ChatSerializer.a("{text:\"§aFunctions§e: \",extra:[{text:\"§eRemove\",hoverEvent:{action:show_text,value:\"Remove the selected portal\"},clickEvent:{action:run_command,value:\"/portal gui remove " + portalName + "\"}}"
|
||||
plugin.nmsAccess.sendRawMessage("{text:\"§aFunctions§e: \",extra:[{text:\"§eRemove\",hoverEvent:{action:show_text,value:\"Remove the selected portal\"},clickEvent:{action:run_command,value:\"/portal gui remove " + portalName + "\"}}"
|
||||
+ ",{text:\" \"},{text:\"§eShow\",hoverEvent:{action:show_text,value:\"Show the selected portal\"},clickEvent:{action:run_command,value:\"/portal show " + portalName + "\"}}"
|
||||
+ ",{text:\" \"},{text:\"§eRename\",hoverEvent:{action:show_text,value:\"Change the name of the portal\"},clickEvent:{action:suggest_command,value:\"/portal rename \"}}"
|
||||
+ ",{text:\" \"},{text:\"§eActivate\",hoverEvent:{action:show_text,value:\"Teleport to the set destination\n(same as entering the portal)\"},clickEvent:{action:run_command,value:\"/warp " + destination + "\"}}]}", player);
|
||||
|
||||
/**IChatBaseComponent comp = ChatSerializer.a("{text:\"§aFunctions§e: \",extra:[{text:\"§eRemove\",hoverEvent:{action:show_text,value:\"Remove the selected portal\"},clickEvent:{action:run_command,value:\"/portal gui remove " + portalName + "\"}}"
|
||||
+ ",{text:\" \"},{text:\"§eShow\",hoverEvent:{action:show_text,value:\"Show the selected portal\"},clickEvent:{action:run_command,value:\"/portal show " + portalName + "\"}}"
|
||||
+ ",{text:\" \"},{text:\"§eRename\",hoverEvent:{action:show_text,value:\"Change the name of the portal\"},clickEvent:{action:suggest_command,value:\"/portal rename \"}}"
|
||||
+ ",{text:\" \"},{text:\"§eActivate\",hoverEvent:{action:show_text,value:\"Teleport to the set destination\n(same as entering the portal)\"},clickEvent:{action:run_command,value:\"/warp " + destination + "\"}}]}");
|
||||
PacketPlayOutChat packet = new PacketPlayOutChat(comp, true);
|
||||
((CraftPlayer) player).getHandle().playerConnection.sendPacket(packet);
|
||||
((CraftPlayer) player).getHandle().playerConnection.sendPacket(packet);*/
|
||||
sender.sendMessage("");
|
||||
|
||||
}
|
||||
|
@ -8,8 +8,8 @@ public class Assets {
|
||||
|
||||
public Assets(AdvancedPortalsPlugin plugin) {
|
||||
ConfigAccessor config = new ConfigAccessor(plugin, "Config.yml");
|
||||
currentWarpParticles = config.getConfig().getInt("warpParticles");
|
||||
currentWarpSound = config.getConfig().getInt("warpSound");
|
||||
currentWarpParticles = config.getConfig().getInt("WarpParticles");
|
||||
currentWarpSound = config.getConfig().getInt("WarpSound");
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -23,7 +23,7 @@ public class Listeners implements Listener {
|
||||
|
||||
private final AdvancedPortalsPlugin plugin;
|
||||
|
||||
private boolean defaultPortalMessages = true;
|
||||
private boolean DefaultPortalMessages = true;
|
||||
|
||||
// The needed config values will be stored so they are easier to access later
|
||||
// an example is in the interact event in this if statement if((!UseOnlyServerAxe || event.getItem().getItemMeta().getDisplayName().equals("§eP...
|
||||
@ -31,6 +31,8 @@ public class Listeners implements Listener {
|
||||
|
||||
private static Material WandMaterial;
|
||||
|
||||
private static boolean ShowBungeeMessage;
|
||||
|
||||
@SuppressWarnings("deprecation")
|
||||
public Listeners(AdvancedPortalsPlugin plugin) {
|
||||
this.plugin = plugin;
|
||||
@ -40,7 +42,7 @@ public class Listeners implements Listener {
|
||||
|
||||
String ItemID = config.getConfig().getString("AxeItemId");
|
||||
|
||||
defaultPortalMessages = config.getConfig().getBoolean("portalWarpMessages");
|
||||
DefaultPortalMessages = config.getConfig().getBoolean("PortalWarpMessages");
|
||||
|
||||
try
|
||||
{
|
||||
@ -60,6 +62,8 @@ public class Listeners implements Listener {
|
||||
ConfigAccessor config = new ConfigAccessor(plugin, "Config.yml");
|
||||
UseOnlyServerAxe = config.getConfig().getBoolean("UseOnlyServerMadeAxe");
|
||||
|
||||
ShowBungeeMessage = config.getConfig().getBoolean("ShowBungeeWarpMessage");
|
||||
|
||||
String ItemID = config.getConfig().getString("AxeItemId");
|
||||
|
||||
try
|
||||
@ -93,7 +97,7 @@ public class Listeners implements Listener {
|
||||
|
||||
|
||||
boolean warped = Portal.activate(player, portal.portalName);
|
||||
if(defaultPortalMessages && warped){
|
||||
if(DefaultPortalMessages && warped){
|
||||
ConfigAccessor config = new ConfigAccessor(plugin, "Portals.yml");
|
||||
player.sendMessage("");
|
||||
player.sendMessage("§a[§eAdvancedPortals§a] You have warped to §e" + config.getConfig().getString(Portal.Portals[portalId].portalName + ".destination") + ".");
|
||||
|
@ -0,0 +1,19 @@
|
||||
package com.sekwah.advancedportals.compat;
|
||||
|
||||
import net.minecraft.server.v1_7_R1.ChatSerializer;
|
||||
import net.minecraft.server.v1_7_R1.IChatBaseComponent;
|
||||
import net.minecraft.server.v1_7_R1.PacketPlayOutChat;
|
||||
|
||||
import org.bukkit.craftbukkit.v1_7_R1.entity.CraftPlayer;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
public class v1_7_R1 implements NMS {
|
||||
|
||||
@Override
|
||||
public void sendRawMessage(String rawMessage, Player player) {
|
||||
IChatBaseComponent comp = ChatSerializer.a(rawMessage);
|
||||
PacketPlayOutChat packet = new PacketPlayOutChat(comp, true);
|
||||
((CraftPlayer) player).getHandle().playerConnection.sendPacket(packet);
|
||||
}
|
||||
|
||||
}
|
@ -0,0 +1,19 @@
|
||||
package com.sekwah.advancedportals.compat;
|
||||
|
||||
import net.minecraft.server.v1_7_R2.ChatSerializer;
|
||||
import net.minecraft.server.v1_7_R2.IChatBaseComponent;
|
||||
import net.minecraft.server.v1_7_R2.PacketPlayOutChat;
|
||||
|
||||
import org.bukkit.craftbukkit.v1_7_R2.entity.CraftPlayer;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
public class v1_7_R2 implements NMS {
|
||||
|
||||
@Override
|
||||
public void sendRawMessage(String rawMessage, Player player) {
|
||||
IChatBaseComponent comp = ChatSerializer.a(rawMessage);
|
||||
PacketPlayOutChat packet = new PacketPlayOutChat(comp, true);
|
||||
((CraftPlayer) player).getHandle().playerConnection.sendPacket(packet);
|
||||
}
|
||||
|
||||
}
|
@ -1,6 +1,5 @@
|
||||
package com.sekwah.advancedportals.portalcontrolls;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Set;
|
||||
import java.util.logging.Level;
|
||||
|
||||
@ -25,7 +24,12 @@ public class Portal {
|
||||
|
||||
public static AdvancedPortal[] Portals;
|
||||
|
||||
private static boolean ShowBungeeMessage;
|
||||
|
||||
public Portal(AdvancedPortalsPlugin plugin) {
|
||||
ConfigAccessor config = new ConfigAccessor(plugin, "Config.yml");
|
||||
ShowBungeeMessage = config.getConfig().getBoolean("ShowBungeeWarpMessage");
|
||||
|
||||
Portal.plugin = plugin;
|
||||
Portal.loadPortals();
|
||||
}
|
||||
@ -39,7 +43,6 @@ public class Portal {
|
||||
*
|
||||
*/
|
||||
|
||||
@SuppressWarnings("deprecation")
|
||||
public static void loadPortals(){
|
||||
|
||||
ConfigAccessor config = new ConfigAccessor(plugin, "Portals.yml");
|
||||
@ -325,7 +328,9 @@ public class Portal {
|
||||
// add other variables or filter code here, or somehow have a way to register them
|
||||
|
||||
if(config.getConfig().getString(portalName + ".bungee") != null){
|
||||
if(ShowBungeeMessage){
|
||||
player.sendMessage("§a[§eAdvancedPortals§a] Attempting to warp to §e" + config.getConfig().getString(portalName + ".bungee") + "§a.");
|
||||
}
|
||||
ByteArrayDataOutput out = ByteStreams.newDataOutput();
|
||||
out.writeUTF("Connect");
|
||||
out.writeUTF(config.getConfig().getString(portalName + ".bungee"));
|
||||
|
Loading…
Reference in New Issue
Block a user