mirror of
https://github.com/sekwah41/Advanced-Portals.git
synced 2025-01-27 10:31:34 +01:00
Fixed issues with release for 1.13
The original release works but was a little rushed, the action text interaction didn't work and water was replacing itself to STATIONARY_WATER
This commit is contained in:
parent
faf14757f8
commit
360618cd96
@ -4,7 +4,7 @@ apply plugin: 'idea'
|
||||
apply plugin: 'eclipse'
|
||||
|
||||
group = 'com.sekwah.advancedportals'
|
||||
version = '0.0.42-snapshot'
|
||||
version = '0.0.43-snapshot'
|
||||
|
||||
description = ""
|
||||
|
||||
|
@ -1,8 +1,9 @@
|
||||
main: com.sekwah.advancedportals.AdvancedPortalsPlugin
|
||||
name: AdvancedPortals
|
||||
version: 0.0.41
|
||||
version: 0.0.42
|
||||
author: sekwah41
|
||||
description: An advanced portals plugin for bukkit.
|
||||
api-version: 1.13
|
||||
commands:
|
||||
advancedportals:
|
||||
description: The main command for the advanced portals
|
||||
|
@ -317,7 +317,7 @@ public class AdvancedPortalsCommand implements CommandExecutor, TabCompleter {
|
||||
}
|
||||
break;
|
||||
case "unselect":
|
||||
if(player.hasMetadata("selectedPortal")){
|
||||
if(player.getMetadata("selectedPortal").size() != 0){
|
||||
player.sendMessage(PluginMessages.customPrefix + " You have unselected\u00A7e" + player.getMetadata("selectedPortal").get(0).asString()
|
||||
+ "\u00A7a.");
|
||||
}
|
||||
@ -347,7 +347,7 @@ public class AdvancedPortalsCommand implements CommandExecutor, TabCompleter {
|
||||
sender.sendMessage(PluginMessages.customPrefixFail + " No portal by the name \u00A7e" + args[1] + "\u00A7c exists!");
|
||||
}
|
||||
} else {
|
||||
if (player.hasMetadata("selectedPortal")) {
|
||||
if (player.getMetadata("selectedPortal").size() != 0) {
|
||||
String portalName = player.getMetadata("selectedPortal").get(0).asString();
|
||||
String posX = portalConfig.getConfig().getString(portalName + ".pos1.X");
|
||||
if (posX != null) {
|
||||
@ -365,7 +365,7 @@ public class AdvancedPortalsCommand implements CommandExecutor, TabCompleter {
|
||||
|
||||
// not finished yet /
|
||||
if (args.length > 1) {
|
||||
if (player.hasMetadata("selectedPortal")) {
|
||||
if (player.getMetadata("selectedPortal").size() != 0) {
|
||||
String portalName = player.getMetadata("selectedPortal").get(0).asString();
|
||||
if (portalName.toLowerCase() != args[1].toLowerCase()) {
|
||||
String posX = portalConfig.getConfig().getString(portalName + ".pos1.X");
|
||||
@ -392,7 +392,7 @@ public class AdvancedPortalsCommand implements CommandExecutor, TabCompleter {
|
||||
}
|
||||
break;
|
||||
case "command":
|
||||
if (player.hasMetadata("selectedPortal")) {
|
||||
if (player.getMetadata("selectedPortal").size() != 0) {
|
||||
String portalName = player.getMetadata("selectedPortal").get(0).asString();
|
||||
if (args.length > 1) {
|
||||
// TODO add the command autocompletes, add, remove and show
|
||||
@ -435,7 +435,7 @@ public class AdvancedPortalsCommand implements CommandExecutor, TabCompleter {
|
||||
sender.sendMessage(PluginMessages.customPrefixFail + " No portal by that name exists!");
|
||||
}
|
||||
} else {
|
||||
if (player.hasMetadata("selectedPortal")) {
|
||||
if (player.getMetadata("selectedPortal").size() != 0) {
|
||||
String portalName = player.getMetadata("selectedPortal").get(0).asString();
|
||||
String posX = portalConfig.getConfig().getString(portalName + ".pos1.X");
|
||||
if (posX != null) {
|
||||
@ -462,7 +462,7 @@ public class AdvancedPortalsCommand implements CommandExecutor, TabCompleter {
|
||||
sender.sendMessage(PluginMessages.customPrefixFail + " No portal by that name exists!");
|
||||
}
|
||||
} else {
|
||||
if (player.hasMetadata("selectedPortal")) {
|
||||
if (player.getMetadata("selectedPortal").size() != 0) {
|
||||
player.sendMessage(PluginMessages.customPrefix + " Your currently selected portal has been shown, it will dissapear shortly!");
|
||||
Selection.show(player, this.plugin, player.getMetadata("selectedPortal").get(0).asString());
|
||||
} else if (player.hasMetadata("Pos1World") && player.hasMetadata("Pos2World")) {
|
||||
|
@ -30,8 +30,6 @@ public class CraftBukkit {
|
||||
private Field playerConnection;
|
||||
private Method sendPacket;
|
||||
|
||||
private boolean useEnumType = false;
|
||||
|
||||
|
||||
// Classes so it doesnt keep fetching them.
|
||||
|
||||
@ -48,33 +46,14 @@ public class CraftBukkit {
|
||||
Class<?> chatBaseComponent = Class.forName(minecraftPackage + "IChatBaseComponent"); // string to packet methods
|
||||
Class<?> chatSerialClass = this.findClass(chatBaseComponent, "ChatSerializer");
|
||||
|
||||
try{
|
||||
Class<?> chatMessageTypeClass = Class.forName(minecraftPackage + "ChatMessageType");
|
||||
Class<?> chatMessageTypeClass = Class.forName(minecraftPackage + "ChatMessageType");
|
||||
|
||||
this.chatMessageTypeMethod = chatMessageTypeClass.getMethod("a", byte.class);
|
||||
this.chatMessageTypeMethod = chatMessageTypeClass.getMethod("a", byte.class);
|
||||
|
||||
this.chatPacketConstructor = Class.forName(minecraftPackage + "PacketPlayOutChat").getConstructor(chatBaseComponent, chatMessageTypeClass);
|
||||
this.chatPacketConstructor = Class.forName(minecraftPackage + "PacketPlayOutChat").getConstructor(chatBaseComponent, chatMessageTypeClass);
|
||||
|
||||
useEnumType = true;
|
||||
}
|
||||
catch(ClassNotFoundException e) {
|
||||
plugin.getLogger().info("Old version detected, changing chat method");
|
||||
this.chatPacketConstructor = Class.forName(minecraftPackage + "PacketPlayOutChat").getConstructor(chatBaseComponent, byte.class);
|
||||
}
|
||||
|
||||
if(chatSerialClass != null){
|
||||
this.serializeMessage = chatSerialClass.getMethod("a", String.class);
|
||||
}
|
||||
else{
|
||||
plugin.getLogger().info("Attempting support for 1.8");
|
||||
try {
|
||||
this.reallyOldChatConstructor = Class.forName(minecraftPackage + "ChatMessage").getConstructor(String.class, Object[].class);
|
||||
}
|
||||
catch (ClassNotFoundException e) {
|
||||
plugin.getLogger().info("Fallback (I forget what version uses this but it was here for a reason)");
|
||||
this.serializeMessage = chatBaseComponent.getMethod("a", String.class);
|
||||
}
|
||||
}
|
||||
this.serializeMessage = chatSerialClass.getMethod("a", String.class);
|
||||
|
||||
this.playerGetHandle = Class.forName(craftBukkitPackage + "entity.CraftPlayer").getMethod("getHandle");
|
||||
this.playerConnection = Class.forName(minecraftPackage + "EntityPlayer").getField("playerConnection"); // get player connection
|
||||
@ -100,25 +79,13 @@ public class CraftBukkit {
|
||||
}
|
||||
|
||||
public void sendActionBarMessage(String rawMessage, Player player) {
|
||||
this.sendMessage(rawMessage,player, (byte) 2);
|
||||
this.sendMessage("{\"text\":\"" + rawMessage + "\"}",player, (byte) 2);
|
||||
}
|
||||
|
||||
public void sendMessage(String rawMessage, Player player, byte msgType) {
|
||||
try {
|
||||
Object comp;
|
||||
if(this.reallyOldChatConstructor != null) {
|
||||
comp = this.reallyOldChatConstructor.newInstance(rawMessage,new Object[]{});
|
||||
}
|
||||
else {
|
||||
comp = this.serializeMessage.invoke(null,"{\"text\":\"" + rawMessage + "\"}");
|
||||
}
|
||||
Object packet;
|
||||
if(this.useEnumType){
|
||||
packet = this.chatPacketConstructor.newInstance(comp, this.chatMessageTypeMethod.invoke(null,msgType)); // convert bytes into packet
|
||||
}
|
||||
else{
|
||||
packet = this.chatPacketConstructor.newInstance(comp, msgType); // convert bytes into packet
|
||||
}
|
||||
Object comp = this.serializeMessage.invoke(null, rawMessage);
|
||||
Object packet = this.chatPacketConstructor.newInstance(comp, this.chatMessageTypeMethod.invoke(null,msgType)); // convert bytes into packet
|
||||
|
||||
Object handle = this.playerGetHandle.invoke(player);
|
||||
Object playerConnection = this.playerConnection.get(handle); // get players connection
|
||||
@ -127,11 +94,6 @@ public class CraftBukkit {
|
||||
this.plugin.getLogger().warning("Error creating raw message, something must be wrong with reflection");
|
||||
e.printStackTrace();
|
||||
}
|
||||
|
||||
/*IChatBaseComponent comp = IChatBaseComponent.ChatSerializer.a(rawMessage);
|
||||
// "json message", position(0: chat (chat box), 1: system message (chat box), 2: above action bar)
|
||||
PacketPlayOutChat packet = new PacketPlayOutChat(comp, (byte) 1);
|
||||
((CraftPlayer) player).getHandle().playerConnection.sendPacket(packet);*/
|
||||
}
|
||||
|
||||
|
||||
|
@ -186,7 +186,7 @@ public class Portal {
|
||||
|
||||
portalData.getConfig().set(name + ".world", pos1.getWorld().getName());
|
||||
|
||||
portalData.getConfig().set(name + ".triggerblock", checkMaterial(triggerBlock));
|
||||
portalData.getConfig().set(name + ".triggerblock", triggerBlock.toString());
|
||||
|
||||
portalData.getConfig().set(name + ".destination", destination);
|
||||
|
||||
@ -264,15 +264,6 @@ public class Portal {
|
||||
return false;
|
||||
}
|
||||
|
||||
private static String checkMaterial(Material triggerBlock) {
|
||||
if (triggerBlock.equals(Material.WATER)) {
|
||||
return "STATIONARY_WATER";
|
||||
} else if (triggerBlock.equals(Material.LAVA)) {
|
||||
return "STATIONARY_LAVA";
|
||||
}
|
||||
return triggerBlock.toString();
|
||||
}
|
||||
|
||||
@SuppressWarnings("deprecation")
|
||||
public static String create(Location pos1, Location pos2, String name, String destination, String serverName, PortalArg... extraData) { // add stuff for destination names or coordinates
|
||||
ConfigAccessor config = new ConfigAccessor(plugin, "config.yml");
|
||||
@ -535,9 +526,7 @@ public class Portal {
|
||||
}
|
||||
|
||||
public static boolean locationInPortalTrigger(AdvancedPortal portal, Location loc) {
|
||||
if (portal.getTrigger().equals(loc.getBlock().getType()))
|
||||
return locationInPortal(portal, loc, 0);
|
||||
return false;
|
||||
return portal.getTrigger().equals(loc.getBlock().getType()) && locationInPortal(portal, loc, 0);
|
||||
}
|
||||
|
||||
public static boolean inPortalRegion(Location loc, int additionalArea) {
|
||||
|
@ -1,6 +1,6 @@
|
||||
main: com.sekwah.advancedportals.AdvancedPortalsPlugin
|
||||
name: AdvancedPortals
|
||||
version: 0.0.42
|
||||
version: 0.0.43
|
||||
author: sekwah41
|
||||
description: An advanced portals plugin for bukkit.
|
||||
api-version: 1.13
|
||||
|
Loading…
Reference in New Issue
Block a user