Merge branch 'master' of ssh://git@github.com/sekwah41/Advanced-Portals.git

This commit is contained in:
sekwah41 2014-10-22 17:50:50 +01:00
commit 70f949dc23
4 changed files with 69 additions and 6 deletions

View File

@ -1,6 +1,5 @@
package com.sekwah.advancedportals;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collections;
import java.util.LinkedList;
@ -220,10 +219,7 @@ 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("");
IChatBaseComponent comp = ChatSerializer.a("{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] + "\"}}]}");
PacketPlayOutChat packet = new PacketPlayOutChat(comp, true);
((CraftPlayer) player).getHandle().playerConnection.sendPacket(packet);
sender.sendMessage("");
}
}

View File

@ -1,16 +1,20 @@
package com.sekwah.advancedportals;
import java.io.IOException;
import java.lang.reflect.InvocationTargetException;
import org.bukkit.plugin.java.JavaPlugin;
import com.sekwah.advancedportals.DataCollector.DataCollector;
import com.sekwah.advancedportals.compat.NMS;
import com.sekwah.advancedportals.destinations.Destination;
import com.sekwah.advancedportals.metrics.Metrics;
import com.sekwah.advancedportals.portalcontrolls.Portal;
public class AdvancedPortalsPlugin extends JavaPlugin {
public NMS nmsAccess;
public void onEnable() {
new Assets(this);
@ -60,6 +64,41 @@ public class AdvancedPortalsPlugin extends JavaPlugin {
this.getServer().getConsoleSender().sendMessage("§aAdvanced portals have been sucsessfully enabled!");
String packageName = getServer().getClass().getPackage().getName();
String[] packageSplit = packageName.split("\\.");
String version = packageSplit[packageSplit.length - 1];
try {
Class<?> nmsClass = Class.forName("com.sekwah.advancedportals.compat." + version);
if(NMS.class.isAssignableFrom(nmsClass)){
this.nmsAccess = (NMS) nmsClass.getConstructor().newInstance();
}else
{
System.out.println("Something went wrong, please notify the author and tell them this version v:" + version);
this.setEnabled(false);
}
} catch (ClassNotFoundException e) {
System.out.println("This version of craftbukkit is not yet supported, please notify the author and give them this version v:" + version);
this.setEnabled(false);
} catch (InstantiationException e) {
// TODO Auto-generated catch block
e.printStackTrace();
} catch (IllegalAccessException e) {
// TODO Auto-generated catch block
e.printStackTrace();
} catch (IllegalArgumentException e) {
// TODO Auto-generated catch block
e.printStackTrace();
} catch (InvocationTargetException e) {
// TODO Auto-generated catch block
e.printStackTrace();
} catch (NoSuchMethodException e) {
// TODO Auto-generated catch block
e.printStackTrace();
} catch (SecurityException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
}

View File

@ -0,0 +1,9 @@
package com.sekwah.advancedportals.compat;
import org.bukkit.entity.Player;
public interface NMS {
public void sendRawMessage(String rawMessage, Player player);
}

View File

@ -0,0 +1,19 @@
package com.sekwah.advancedportals.compat;
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.craftbukkit.v1_7_R3.entity.CraftPlayer;
import org.bukkit.entity.Player;
public class v1_7_R3 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);
}
}