mirror of
https://github.com/sekwah41/Advanced-Portals.git
synced 2024-12-28 11:59:27 +01:00
Removed craftbukkit folder and started remaking the compatability file
This commit is contained in:
parent
6219f2c32b
commit
6aa354c2eb
@ -1,8 +0,0 @@
|
|||||||
Currently needed craftbukkit versions to compile:
|
|
||||||
|
|
||||||
1.8
|
|
||||||
1.8.3
|
|
||||||
1.8.8
|
|
||||||
1.9
|
|
||||||
1.9.4
|
|
||||||
1.10.2
|
|
83
pom.xml
83
pom.xml
@ -3,29 +3,6 @@
|
|||||||
<groupId>com.sekwah.advancedportals</groupId>
|
<groupId>com.sekwah.advancedportals</groupId>
|
||||||
<artifactId>Advanced-Portals</artifactId>
|
<artifactId>Advanced-Portals</artifactId>
|
||||||
<build>
|
<build>
|
||||||
<plugins>
|
|
||||||
<plugin>
|
|
||||||
<groupId>org.apache.maven.plugins</groupId>
|
|
||||||
<artifactId>maven-dependency-plugin</artifactId>
|
|
||||||
<executions>
|
|
||||||
<execution>
|
|
||||||
<id>copy-dependencies</id>
|
|
||||||
<phase>prepare-package</phase>
|
|
||||||
<goals>
|
|
||||||
<goal>copy-dependencies</goal>
|
|
||||||
</goals>
|
|
||||||
<configuration>
|
|
||||||
<outputDirectory>${project.build.directory}/classes/lib</outputDirectory>
|
|
||||||
<overWriteReleases>false</overWriteReleases>
|
|
||||||
<overWriteSnapshots>false</overWriteSnapshots>
|
|
||||||
<overWriteIfNewer>true</overWriteIfNewer>
|
|
||||||
</configuration>
|
|
||||||
</execution>
|
|
||||||
</executions>
|
|
||||||
</plugin>
|
|
||||||
</plugins>
|
|
||||||
|
|
||||||
|
|
||||||
<sourceDirectory>${basedir}/src/</sourceDirectory>
|
<sourceDirectory>${basedir}/src/</sourceDirectory>
|
||||||
<resources>
|
<resources>
|
||||||
<resource>
|
<resource>
|
||||||
@ -61,65 +38,5 @@
|
|||||||
<version>1.10.2-R0.1-SNAPSHOT</version>
|
<version>1.10.2-R0.1-SNAPSHOT</version>
|
||||||
<scope>provided</scope>
|
<scope>provided</scope>
|
||||||
</dependency>
|
</dependency>
|
||||||
<!--<dependency>
|
|
||||||
<groupId>org.bukkit</groupId>
|
|
||||||
<artifactId>bukkit</artifactId>
|
|
||||||
<version>1.9.4-R0.1-SNAPSHOT</version>
|
|
||||||
<scope>provided</scope>
|
|
||||||
</dependency>
|
|
||||||
<dependency>
|
|
||||||
<groupId>org.bukkit</groupId>
|
|
||||||
<artifactId>craftbukkit</artifactId>
|
|
||||||
<version>1.9.4-R0.1-SNAPSHOT</version>
|
|
||||||
<scope>provided</scope>
|
|
||||||
</dependency>
|
|
||||||
<dependency>
|
|
||||||
<groupId>org.bukkit</groupId>
|
|
||||||
<artifactId>bukkit</artifactId>
|
|
||||||
<version>1.9-R0.1-SNAPSHOT</version>
|
|
||||||
<scope>provided</scope>
|
|
||||||
</dependency>
|
|
||||||
<dependency>
|
|
||||||
<groupId>org.bukkit</groupId>
|
|
||||||
<artifactId>craftbukkit</artifactId>
|
|
||||||
<version>1.9-R0.1-SNAPSHOT</version>
|
|
||||||
<scope>provided</scope>
|
|
||||||
</dependency>
|
|
||||||
<dependency>
|
|
||||||
<groupId>org.bukkit</groupId>
|
|
||||||
<artifactId>bukkit</artifactId>
|
|
||||||
<version>1.8.8-R0.1-SNAPSHOT</version>
|
|
||||||
<scope>provided</scope>
|
|
||||||
</dependency>
|
|
||||||
<dependency>
|
|
||||||
<groupId>org.bukkit</groupId>
|
|
||||||
<artifactId>craftbukkit</artifactId>
|
|
||||||
<version>1.8.8-R0.1-SNAPSHOT</version>
|
|
||||||
<scope>provided</scope>
|
|
||||||
</dependency>
|
|
||||||
<dependency>
|
|
||||||
<groupId>org.bukkit</groupId>
|
|
||||||
<artifactId>bukkit</artifactId>
|
|
||||||
<version>1.8.3-R0.1-SNAPSHOT</version>
|
|
||||||
<scope>provided</scope>
|
|
||||||
</dependency>
|
|
||||||
<dependency>
|
|
||||||
<groupId>org.bukkit</groupId>
|
|
||||||
<artifactId>craftbukkit</artifactId>
|
|
||||||
<version>1.8.3-R0.1-SNAPSHOT</version>
|
|
||||||
<scope>provided</scope>
|
|
||||||
</dependency>
|
|
||||||
<dependency>
|
|
||||||
<groupId>org.bukkit</groupId>
|
|
||||||
<artifactId>bukkit</artifactId>
|
|
||||||
<version>1.8-R0.1-SNAPSHOT</version>
|
|
||||||
<scope>provided</scope>
|
|
||||||
</dependency>
|
|
||||||
<dependency>
|
|
||||||
<groupId>org.bukkit</groupId>
|
|
||||||
<artifactId>craftbukkit</artifactId>
|
|
||||||
<version>1.8-R0.1-SNAPSHOT</version>
|
|
||||||
<scope>provided</scope>
|
|
||||||
</dependency>-->
|
|
||||||
</dependencies>
|
</dependencies>
|
||||||
</project>
|
</project>
|
@ -238,7 +238,7 @@ public class AdvancedPortalsCommand implements CommandExecutor, TabCompleter {
|
|||||||
sender.sendMessage("");
|
sender.sendMessage("");
|
||||||
sender.sendMessage("\u00A7c[\u00A77AdvancedPortals\u00A7c] Are you sure you would like to remove the portal \u00A7e" + args[2] + "\u00A7c?");
|
sender.sendMessage("\u00A7c[\u00A77AdvancedPortals\u00A7c] Are you sure you would like to remove the portal \u00A7e" + args[2] + "\u00A7c?");
|
||||||
sender.sendMessage("");
|
sender.sendMessage("");
|
||||||
plugin.nmsAccess.sendRawMessage("{\"text\":\" \",\"extra\":[{\"text\":\"\u00A7e[Yes]\",\"hoverEvent\":{\"action\":\"show_text\",\"value\":\"Confirm removing this portal\"},\"clickEvent\":{\"action\":\"run_command\",\"value\":\"/portal remove " + args[2] + "\"}}, " +
|
plugin.compat.sendRawMessage("{\"text\":\" \",\"extra\":[{\"text\":\"\u00A7e[Yes]\",\"hoverEvent\":{\"action\":\"show_text\",\"value\":\"Confirm removing this portal\"},\"clickEvent\":{\"action\":\"run_command\",\"value\":\"/portal remove " + args[2] + "\"}}, " +
|
||||||
"{\"text\":\" \"},{\"text\":\"\u00A7e[No]\",\"hoverEvent\":{\"action\":\"show_text\",\"value\":\"Cancel removing this portal\"},\"clickEvent\":{\"action\":\"run_command\",\"value\":\"/portal edit " + args[2] + "\"}}]}", player);
|
"{\"text\":\" \"},{\"text\":\"\u00A7e[No]\",\"hoverEvent\":{\"action\":\"show_text\",\"value\":\"Cancel removing this portal\"},\"clickEvent\":{\"action\":\"run_command\",\"value\":\"/portal edit " + args[2] + "\"}}]}", player);
|
||||||
sender.sendMessage("");
|
sender.sendMessage("");
|
||||||
}
|
}
|
||||||
@ -363,7 +363,7 @@ public class AdvancedPortalsCommand implements CommandExecutor, TabCompleter {
|
|||||||
sender.sendMessage("\u00A7a[\u00A7eAdvancedPortals\u00A7a] Still designing in game help page :(");
|
sender.sendMessage("\u00A7a[\u00A7eAdvancedPortals\u00A7a] Still designing in game help page :(");
|
||||||
sender.sendMessage("\u00A7a[\u00A7eAdvancedPortals\u00A7a] For now please use the wiki http://bit.ly/portals-help");
|
sender.sendMessage("\u00A7a[\u00A7eAdvancedPortals\u00A7a] For now please use the wiki http://bit.ly/portals-help");
|
||||||
} else if (args[0].toLowerCase().equals("bukkitpage")) {
|
} else if (args[0].toLowerCase().equals("bukkitpage")) {
|
||||||
sender.sendMessage("\u00A7a[\u00A7eAdvancedPortals\u00A7a] Bukkit page: http://bit.ly/adv-portals!");
|
sender.sendMessage("\u00A7a[\u00A7eAdvancedPortals\u00A7a] CraftBukkit page: http://bit.ly/adv-portals!");
|
||||||
} else if (args[0].toLowerCase().equals("helppage")) {
|
} else if (args[0].toLowerCase().equals("helppage")) {
|
||||||
sender.sendMessage("\u00A7a[\u00A7eAdvancedPortals\u00A7a] Help page: http://bit.ly/portals-help!");
|
sender.sendMessage("\u00A7a[\u00A7eAdvancedPortals\u00A7a] Help page: http://bit.ly/portals-help!");
|
||||||
} else if (args[0].toLowerCase().equals("show")) {
|
} else if (args[0].toLowerCase().equals("show")) {
|
||||||
@ -475,7 +475,7 @@ public class AdvancedPortalsCommand implements CommandExecutor, TabCompleter {
|
|||||||
|
|
||||||
Player player = (Player) sender;
|
Player player = (Player) sender;
|
||||||
|
|
||||||
plugin.nmsAccess.sendRawMessage("{\"text\":\"\u00A7aFunctions\u00A7e: \",\"extra\":[{\"text\":\"\u00A7eRemove\",\"hoverEvent\":{\"action\":\"show_text\",\"value\":\"Remove the selected portal\"},\"clickEvent\":{\"action\":\"clickEvent\",\"value\":\"/portal gui remove " + portalName + "\"}}"
|
plugin.compat.sendRawMessage("{\"text\":\"\u00A7aFunctions\u00A7e: \",\"extra\":[{\"text\":\"\u00A7eRemove\",\"hoverEvent\":{\"action\":\"show_text\",\"value\":\"Remove the selected portal\"},\"clickEvent\":{\"action\":\"clickEvent\",\"value\":\"/portal gui remove " + portalName + "\"}}"
|
||||||
+ ",{\"text\":\" \"},{\"text\":\"\u00A7eShow\",\"hoverEvent\":{\"action\":\"show_text\",\"value\":\"Show the selected portal\"},\"clickEvent\":{\"action\":\"clickEvent\",\"value\":\"/portal show " + portalName + "\"}}"
|
+ ",{\"text\":\" \"},{\"text\":\"\u00A7eShow\",\"hoverEvent\":{\"action\":\"show_text\",\"value\":\"Show the selected portal\"},\"clickEvent\":{\"action\":\"clickEvent\",\"value\":\"/portal show " + portalName + "\"}}"
|
||||||
+ ",{\"text\":\" \"},{\"text\":\"\u00A7eRename\",\"hoverEvent\":{\"action\":\"show_text\",\"value\":\"Change the name of the portal\"},\"clickEvent\":{\"action\":\"suggest_command\",\"value\":\"/portal rename \"}}"
|
+ ",{\"text\":\" \"},{\"text\":\"\u00A7eRename\",\"hoverEvent\":{\"action\":\"show_text\",\"value\":\"Change the name of the portal\"},\"clickEvent\":{\"action\":\"suggest_command\",\"value\":\"/portal rename \"}}"
|
||||||
+ ",{\"text\":\" \"},{\"text\":\"\u00A7eActivate\",\"hoverEvent\":{\"action\":\"show_text\",\"value\":\"Teleport to the set destination\n(same as entering the portal)\"},\"clickEvent\":{\"action\":\"clickEvent\",\"value\":\"/warp " + destination + "\"}}]}", player);
|
+ ",{\"text\":\" \"},{\"text\":\"\u00A7eActivate\",\"hoverEvent\":{\"action\":\"show_text\",\"value\":\"Teleport to the set destination\n(same as entering the portal)\"},\"clickEvent\":{\"action\":\"clickEvent\",\"value\":\"/warp " + destination + "\"}}]}", player);
|
||||||
|
@ -1,7 +1,7 @@
|
|||||||
package com.sekwah.advancedportals;
|
package com.sekwah.advancedportals;
|
||||||
|
|
||||||
import com.sekwah.advancedportals.DataCollector.DataCollector;
|
import com.sekwah.advancedportals.DataCollector.DataCollector;
|
||||||
import com.sekwah.advancedportals.compat.bukkit.NMS;
|
import com.sekwah.advancedportals.compat.CraftBukkit;
|
||||||
import com.sekwah.advancedportals.destinations.Destination;
|
import com.sekwah.advancedportals.destinations.Destination;
|
||||||
import com.sekwah.advancedportals.effects.WarpEffects;
|
import com.sekwah.advancedportals.effects.WarpEffects;
|
||||||
import com.sekwah.advancedportals.listeners.*;
|
import com.sekwah.advancedportals.listeners.*;
|
||||||
@ -10,18 +10,17 @@ import com.sekwah.advancedportals.portals.Portal;
|
|||||||
import org.bukkit.plugin.java.JavaPlugin;
|
import org.bukkit.plugin.java.JavaPlugin;
|
||||||
|
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
import java.lang.reflect.InvocationTargetException;
|
|
||||||
|
|
||||||
public class AdvancedPortalsPlugin extends JavaPlugin {
|
public class AdvancedPortalsPlugin extends JavaPlugin {
|
||||||
|
|
||||||
public NMS nmsAccess;
|
|
||||||
|
|
||||||
public boolean useCustomPrefix = false;
|
public boolean useCustomPrefix = false;
|
||||||
|
|
||||||
public String customPrefix = "\u00A7a[\u00A7eAdvancedPortals\u00A7a]";
|
public String customPrefix = "\u00A7a[\u00A7eAdvancedPortals\u00A7a]";
|
||||||
|
|
||||||
public String customPrefixFail = "\u00A7c[\u00A77AdvancedPortals\u00A7c]";
|
public String customPrefixFail = "\u00A7c[\u00A77AdvancedPortals\u00A7c]";
|
||||||
|
|
||||||
|
public CraftBukkit compat = null;
|
||||||
|
|
||||||
public void onEnable() {
|
public void onEnable() {
|
||||||
|
|
||||||
try {
|
try {
|
||||||
@ -36,63 +35,60 @@ public class AdvancedPortalsPlugin extends JavaPlugin {
|
|||||||
String version = packageSplit[packageSplit.length - 1];
|
String version = packageSplit[packageSplit.length - 1];
|
||||||
|
|
||||||
try {
|
try {
|
||||||
Class<?> nmsClass = Class.forName("com.sekwah.advancedportals.compat.bukkit." + version);
|
|
||||||
if (NMS.class.isAssignableFrom(nmsClass)) {
|
this.compat = new CraftBukkit(version);
|
||||||
this.nmsAccess = (NMS) nmsClass.getConstructor().newInstance();
|
|
||||||
|
ConfigAccessor portalConfig = new ConfigAccessor(this, "portals.yml");
|
||||||
|
portalConfig.saveDefaultConfig();
|
||||||
|
|
||||||
|
ConfigAccessor destinationConfig = new ConfigAccessor(this, "destinations.yml");
|
||||||
|
destinationConfig.saveDefaultConfig();
|
||||||
|
|
||||||
|
new Assets(this);
|
||||||
|
|
||||||
|
// Opens a channel that messages bungeeCord
|
||||||
|
this.getServer().getMessenger().registerOutgoingPluginChannel(this, "BungeeCord");
|
||||||
|
|
||||||
|
// Loads the portal and destination editors
|
||||||
|
new Portal(this);
|
||||||
|
new Destination(this);
|
||||||
|
|
||||||
|
new DataCollector(this);
|
||||||
|
|
||||||
|
// These register the commands
|
||||||
|
new AdvancedPortalsCommand(this);
|
||||||
|
new DestinationCommand(this);
|
||||||
|
new WarpCommand(this);
|
||||||
|
|
||||||
|
new WarpEffects(this);
|
||||||
|
|
||||||
|
|
||||||
ConfigAccessor portalConfig = new ConfigAccessor(this, "portals.yml");
|
// These register the listeners
|
||||||
portalConfig.saveDefaultConfig();
|
new Listeners(this);
|
||||||
|
|
||||||
ConfigAccessor destinationConfig = new ConfigAccessor(this, "destinations.yml");
|
new FlowStopper(this);
|
||||||
destinationConfig.saveDefaultConfig();
|
new PortalProtect(this);
|
||||||
|
new PortalPlacer(this);
|
||||||
|
|
||||||
new Assets(this);
|
Selection.LoadData(this);
|
||||||
|
|
||||||
// Opens a channel that messages bungeeCord
|
DataCollector.setupMetrics();
|
||||||
this.getServer().getMessenger().registerOutgoingPluginChannel(this, "BungeeCord");
|
|
||||||
|
|
||||||
// Loads the portal and destination editors
|
this.getServer().getMessenger().registerOutgoingPluginChannel(this, "BungeeCord");
|
||||||
new Portal(this);
|
this.getServer().getMessenger().registerIncomingPluginChannel(this, "BungeeCord", new BungeeListener(this));
|
||||||
new Destination(this);
|
|
||||||
|
|
||||||
new DataCollector(this);
|
this.getServer().getConsoleSender().sendMessage("\u00A7aAdvanced portals have been successfully enabled!");
|
||||||
|
|
||||||
// These register the commands
|
|
||||||
new AdvancedPortalsCommand(this);
|
|
||||||
new DestinationCommand(this);
|
|
||||||
new WarpCommand(this);
|
|
||||||
|
|
||||||
new WarpEffects(this);
|
|
||||||
|
|
||||||
|
|
||||||
// These register the listeners
|
|
||||||
new Listeners(this);
|
|
||||||
|
|
||||||
new FlowStopper(this);
|
|
||||||
new PortalProtect(this);
|
|
||||||
new PortalPlacer(this);
|
|
||||||
|
|
||||||
Selection.LoadData(this);
|
|
||||||
|
|
||||||
DataCollector.setupMetrics();
|
|
||||||
|
|
||||||
this.getServer().getMessenger().registerOutgoingPluginChannel(this, "BungeeCord");
|
|
||||||
this.getServer().getMessenger().registerIncomingPluginChannel(this, "BungeeCord", new BungeeListener(this));
|
|
||||||
|
|
||||||
this.getServer().getConsoleSender().sendMessage("\u00A7aAdvanced portals have been successfully enabled!");
|
|
||||||
|
|
||||||
|
|
||||||
} else {
|
|
||||||
this.getLogger().warning("Something went wrong, please notify the author and tell them this version v:" + version);
|
|
||||||
this.setEnabled(false);
|
|
||||||
}
|
|
||||||
} catch (ClassNotFoundException e) {
|
} catch (ClassNotFoundException e) {
|
||||||
this.getLogger().warning("This version of craftbukkit is not yet supported, please notify the author and give version v:" + version);
|
this.getLogger().warning("This version of craftbukkit is not yet supported, please notify sekwah and tell him about this version v:" + version);
|
||||||
this.setEnabled(false);
|
this.setEnabled(false);
|
||||||
} catch (InstantiationException | IllegalAccessException | IllegalArgumentException | InvocationTargetException |
|
} catch (IllegalArgumentException |
|
||||||
NoSuchMethodException | SecurityException e) {
|
NoSuchFieldException | SecurityException e) {
|
||||||
e.printStackTrace();
|
e.printStackTrace();
|
||||||
|
this.getLogger().warning("Something went wrong, please notify sekwah and tell him about this version v:" + version);
|
||||||
|
this.getLogger().warning("Along with the above stacktrace");
|
||||||
|
this.setEnabled(false);
|
||||||
}
|
}
|
||||||
|
|
||||||
saveDefaultConfig();
|
saveDefaultConfig();
|
||||||
|
@ -77,7 +77,7 @@ public class DestinationCommand implements CommandExecutor, TabCompleter {
|
|||||||
sender.sendMessage("");
|
sender.sendMessage("");
|
||||||
} else if (PortalMessagesDisplay == 2) {
|
} else if (PortalMessagesDisplay == 2) {
|
||||||
ConfigAccessor config = new ConfigAccessor(plugin, "destinations.yml");
|
ConfigAccessor config = new ConfigAccessor(plugin, "destinations.yml");
|
||||||
plugin.nmsAccess.sendActionBarMessage("{\"text\":\"\u00A7aYou have warped to \u00A7e" + args[1].replaceAll("_", " ") + "\u00A7a.\"}", (Player) sender);
|
plugin.compat.sendActionBarMessage("{\"text\":\"\u00A7aYou have warped to \u00A7e" + args[1].replaceAll("_", " ") + "\u00A7a.\"}", (Player) sender);
|
||||||
/**plugin.nmsAccess.sendActionBarMessage("[{text:\"You have warped to \",color:green},{text:\"" + config.getConfig().getString(Portal.Portals[portalId].portalName + ".destination").replaceAll("_", " ")
|
/**plugin.nmsAccess.sendActionBarMessage("[{text:\"You have warped to \",color:green},{text:\"" + config.getConfig().getString(Portal.Portals[portalId].portalName + ".destination").replaceAll("_", " ")
|
||||||
+ "\",color:yellow},{\"text\":\".\",color:green}]", player);*/
|
+ "\",color:yellow},{\"text\":\".\",color:green}]", player);*/
|
||||||
}
|
}
|
||||||
|
@ -36,7 +36,7 @@ public class WarpCommand implements CommandExecutor, TabCompleter {
|
|||||||
sender.sendMessage("");
|
sender.sendMessage("");
|
||||||
} else if (DestinationCommand.PortalMessagesDisplay == 2) {
|
} else if (DestinationCommand.PortalMessagesDisplay == 2) {
|
||||||
ConfigAccessor config = new ConfigAccessor(plugin, "destinations.yml");
|
ConfigAccessor config = new ConfigAccessor(plugin, "destinations.yml");
|
||||||
plugin.nmsAccess.sendActionBarMessage("{\"text\":\"\u00A7aYou have warped to \u00A7e" + args[0].replaceAll("_", " ") + "\u00A7a.\"}", (Player) sender);
|
plugin.compat.sendActionBarMessage("{\"text\":\"\u00A7aYou have warped to \u00A7e" + args[0].replaceAll("_", " ") + "\u00A7a.\"}", (Player) sender);
|
||||||
/**plugin.nmsAccess.sendActionBarMessage("[{text:\"You have warped to \",color:green},{text:\"" + config.getConfig().getString(Portal.Portals[portalId].portalName + ".destination").replaceAll("_", " ")
|
/**plugin.nmsAccess.sendActionBarMessage("[{text:\"You have warped to \",color:green},{text:\"" + config.getConfig().getString(Portal.Portals[portalId].portalName + ".destination").replaceAll("_", " ")
|
||||||
+ "\",color:yellow},{\"text\":\".\",color:green}]", player);*/
|
+ "\",color:yellow},{\"text\":\".\",color:green}]", player);*/
|
||||||
}
|
}
|
||||||
|
69
src/com/sekwah/advancedportals/compat/CraftBukkit.java
Normal file
69
src/com/sekwah/advancedportals/compat/CraftBukkit.java
Normal file
@ -0,0 +1,69 @@
|
|||||||
|
package com.sekwah.advancedportals.compat;
|
||||||
|
|
||||||
|
import org.bukkit.entity.Player;
|
||||||
|
|
||||||
|
import java.lang.reflect.Field;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Created by on 02/08/2016.
|
||||||
|
*
|
||||||
|
* I don't think there will be any others supported other than bukkit but if there are its not just the compat that will
|
||||||
|
* need to change.
|
||||||
|
*
|
||||||
|
* @author sekwah41
|
||||||
|
*/
|
||||||
|
public class CraftBukkit {
|
||||||
|
|
||||||
|
private final String craftBukkitVer;
|
||||||
|
|
||||||
|
private final String craftBukkitPackage;
|
||||||
|
|
||||||
|
private final String minecraftPackage;
|
||||||
|
|
||||||
|
|
||||||
|
// Classes so it doesnt keep fetching them.
|
||||||
|
private Class<?> chatBaseComponent;
|
||||||
|
private Class<?> chatSerializer;
|
||||||
|
|
||||||
|
public CraftBukkit(String craftBukkitVer) throws ClassNotFoundException, NoSuchFieldException {
|
||||||
|
this.craftBukkitVer = craftBukkitVer;
|
||||||
|
this.craftBukkitPackage = "org.bukkit.craftbukkit." + craftBukkitVer;
|
||||||
|
this.minecraftPackage = "net.minecraft.server." + craftBukkitVer;
|
||||||
|
|
||||||
|
|
||||||
|
this.setupCompat();
|
||||||
|
}
|
||||||
|
|
||||||
|
private void setupCompat() throws ClassNotFoundException, NoSuchFieldException {
|
||||||
|
this.chatBaseComponent = Class.forName(minecraftPackage + "IChatBaseComponent");
|
||||||
|
Field modfield = chatBaseComponent.getDeclaredField("modifiers");
|
||||||
|
chatBaseComponent.getDeclaredClasses();
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
// Convert to reflection
|
||||||
|
public void sendRawMessage(String rawMessage, Player player) {
|
||||||
|
|
||||||
|
try {
|
||||||
|
|
||||||
|
Class<?> nmsClass = Class.forName(minecraftPackage + "IChatBaseComponent");
|
||||||
|
|
||||||
|
} catch (ClassNotFoundException e) {
|
||||||
|
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);*/
|
||||||
|
}
|
||||||
|
|
||||||
|
public void sendActionBarMessage(String rawMessage, Player player) {
|
||||||
|
/*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) 2);
|
||||||
|
((CraftPlayer) player).getHandle().playerConnection.sendPacket(packet);*/
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
}
|
@ -1,10 +0,0 @@
|
|||||||
package com.sekwah.advancedportals.compat.bukkit;
|
|
||||||
|
|
||||||
import org.bukkit.entity.Player;
|
|
||||||
|
|
||||||
public interface NMS {
|
|
||||||
|
|
||||||
void sendRawMessage(String rawMessage, Player player);
|
|
||||||
|
|
||||||
void sendActionBarMessage(String rawMessage, Player player);
|
|
||||||
}
|
|
@ -1,27 +0,0 @@
|
|||||||
package com.sekwah.advancedportals.compat.bukkit;
|
|
||||||
|
|
||||||
import net.minecraft.server.v1_10_R1.IChatBaseComponent;
|
|
||||||
import net.minecraft.server.v1_10_R1.PacketPlayOutChat;
|
|
||||||
import org.bukkit.craftbukkit.v1_10_R1.entity.CraftPlayer;
|
|
||||||
import org.bukkit.entity.Player;
|
|
||||||
|
|
||||||
|
|
||||||
public class v1_10_R1 implements NMS {
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void sendRawMessage(String rawMessage, Player player) {
|
|
||||||
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);
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void sendActionBarMessage(String rawMessage, Player player) {
|
|
||||||
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) 2);
|
|
||||||
((CraftPlayer) player).getHandle().playerConnection.sendPacket(packet);
|
|
||||||
}
|
|
||||||
}
|
|
@ -1,28 +0,0 @@
|
|||||||
package com.sekwah.advancedportals.compat.bukkit;
|
|
||||||
|
|
||||||
import net.minecraft.server.v1_8_R1.ChatSerializer;
|
|
||||||
import net.minecraft.server.v1_8_R1.IChatBaseComponent;
|
|
||||||
import net.minecraft.server.v1_8_R1.PacketPlayOutChat;
|
|
||||||
import org.bukkit.craftbukkit.v1_8_R1.entity.CraftPlayer;
|
|
||||||
import org.bukkit.entity.Player;
|
|
||||||
|
|
||||||
|
|
||||||
public class v1_8_R1 implements NMS {
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void sendRawMessage(String rawMessage, Player player) {
|
|
||||||
IChatBaseComponent comp = 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);
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void sendActionBarMessage(String rawMessage, Player player) {
|
|
||||||
IChatBaseComponent comp = 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) 2);
|
|
||||||
((CraftPlayer) player).getHandle().playerConnection.sendPacket(packet);
|
|
||||||
}
|
|
||||||
}
|
|
@ -1,27 +0,0 @@
|
|||||||
package com.sekwah.advancedportals.compat.bukkit;
|
|
||||||
|
|
||||||
import net.minecraft.server.v1_8_R2.IChatBaseComponent;
|
|
||||||
import net.minecraft.server.v1_8_R2.PacketPlayOutChat;
|
|
||||||
import org.bukkit.craftbukkit.v1_8_R2.entity.CraftPlayer;
|
|
||||||
import org.bukkit.entity.Player;
|
|
||||||
|
|
||||||
|
|
||||||
public class v1_8_R2 implements NMS {
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void sendRawMessage(String rawMessage, Player player) {
|
|
||||||
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);
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void sendActionBarMessage(String rawMessage, Player player) {
|
|
||||||
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) 2);
|
|
||||||
((CraftPlayer) player).getHandle().playerConnection.sendPacket(packet);
|
|
||||||
}
|
|
||||||
}
|
|
@ -1,27 +0,0 @@
|
|||||||
package com.sekwah.advancedportals.compat.bukkit;
|
|
||||||
|
|
||||||
import net.minecraft.server.v1_8_R3.IChatBaseComponent;
|
|
||||||
import net.minecraft.server.v1_8_R3.PacketPlayOutChat;
|
|
||||||
import org.bukkit.craftbukkit.v1_8_R3.entity.CraftPlayer;
|
|
||||||
import org.bukkit.entity.Player;
|
|
||||||
|
|
||||||
|
|
||||||
public class v1_8_R3 implements NMS {
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void sendRawMessage(String rawMessage, Player player) {
|
|
||||||
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);
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void sendActionBarMessage(String rawMessage, Player player) {
|
|
||||||
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) 2);
|
|
||||||
((CraftPlayer) player).getHandle().playerConnection.sendPacket(packet);
|
|
||||||
}
|
|
||||||
}
|
|
@ -1,27 +0,0 @@
|
|||||||
package com.sekwah.advancedportals.compat.bukkit;
|
|
||||||
|
|
||||||
import net.minecraft.server.v1_9_R1.IChatBaseComponent;
|
|
||||||
import net.minecraft.server.v1_9_R1.PacketPlayOutChat;
|
|
||||||
import org.bukkit.craftbukkit.v1_9_R1.entity.CraftPlayer;
|
|
||||||
import org.bukkit.entity.Player;
|
|
||||||
|
|
||||||
|
|
||||||
public class v1_9_R1 implements NMS {
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void sendRawMessage(String rawMessage, Player player) {
|
|
||||||
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);
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void sendActionBarMessage(String rawMessage, Player player) {
|
|
||||||
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) 2);
|
|
||||||
((CraftPlayer) player).getHandle().playerConnection.sendPacket(packet);
|
|
||||||
}
|
|
||||||
}
|
|
@ -1,27 +0,0 @@
|
|||||||
package com.sekwah.advancedportals.compat.bukkit;
|
|
||||||
|
|
||||||
import net.minecraft.server.v1_9_R2.IChatBaseComponent;
|
|
||||||
import net.minecraft.server.v1_9_R2.PacketPlayOutChat;
|
|
||||||
import org.bukkit.craftbukkit.v1_9_R2.entity.CraftPlayer;
|
|
||||||
import org.bukkit.entity.Player;
|
|
||||||
|
|
||||||
|
|
||||||
public class v1_9_R2 implements NMS {
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void sendRawMessage(String rawMessage, Player player) {
|
|
||||||
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);
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void sendActionBarMessage(String rawMessage, Player player) {
|
|
||||||
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) 2);
|
|
||||||
((CraftPlayer) player).getHandle().playerConnection.sendPacket(packet);
|
|
||||||
}
|
|
||||||
}
|
|
@ -113,7 +113,7 @@ public class Listeners implements Listener {
|
|||||||
player.sendMessage("");
|
player.sendMessage("");
|
||||||
} else if (PortalMessagesDisplay == 2 && warped) {
|
} else if (PortalMessagesDisplay == 2 && warped) {
|
||||||
ConfigAccessor config = new ConfigAccessor(plugin, "inPortals.yml");
|
ConfigAccessor config = new ConfigAccessor(plugin, "inPortals.yml");
|
||||||
plugin.nmsAccess.sendActionBarMessage("{\"text\":\"\u00A7aYou have been warped to \u00A7e" + inPortal.destiation.replaceAll("_", " ") + "\u00A7a.\"}", player);
|
plugin.compat.sendActionBarMessage("{\"text\":\"\u00A7aYou have been warped to \u00A7e" + inPortal.destiation.replaceAll("_", " ") + "\u00A7a.\"}", player);
|
||||||
}
|
}
|
||||||
if (!warped) {
|
if (!warped) {
|
||||||
player.teleport(fromloc, PlayerTeleportEvent.TeleportCause.PLUGIN);
|
player.teleport(fromloc, PlayerTeleportEvent.TeleportCause.PLUGIN);
|
||||||
|
@ -436,9 +436,9 @@ public class Metrics {
|
|||||||
boolean onlineMode = Bukkit.getServer().getOnlineMode(); // TRUE if online mode is enabled
|
boolean onlineMode = Bukkit.getServer().getOnlineMode(); // TRUE if online mode is enabled
|
||||||
String pluginVersion = description.getVersion();
|
String pluginVersion = description.getVersion();
|
||||||
String serverVersion = Bukkit.getVersion();
|
String serverVersion = Bukkit.getVersion();
|
||||||
// make sure that the older versions of bukkit are added first in project imports, so it can be compiled
|
// make sure that the older versions of CraftBukkit are added first in project imports, so it can be compiled
|
||||||
// against an older version
|
// against an older version
|
||||||
int playersOnline = Bukkit.getOnlinePlayers().size(); //Bukkit.getServer().getOnlinePlayers().length;
|
int playersOnline = Bukkit.getOnlinePlayers().size(); //CraftBukkit.getServer().getOnlinePlayers().length;
|
||||||
|
|
||||||
// END server software specific section -- all code below does not use any code outside of this class / Java
|
// END server software specific section -- all code below does not use any code outside of this class / Java
|
||||||
|
|
||||||
|
@ -363,7 +363,7 @@ public class Portal {
|
|||||||
// add other variables or filter code here, or somehow have a way to register them
|
// add other variables or filter code here, or somehow have a way to register them
|
||||||
|
|
||||||
// TODO on load and unload recode the permissions to try to register themselves
|
// TODO on load and unload recode the permissions to try to register themselves
|
||||||
// https://hub.spigotmc.org/javadocs/bukkit/org/bukkit/plugin/PluginManager.html#addPermission(org.bukkit.permissions.Permission)
|
// https://hub.spigotmc.org/javadocs/bukkit/org/bukkit/plugin/PluginManager.html#addPermission(org.CraftBukkit.permissions.Permission)
|
||||||
// check they havent been registered before too and store a list of ones made by this plugin to remove when portals are unloaded.
|
// check they havent been registered before too and store a list of ones made by this plugin to remove when portals are unloaded.
|
||||||
// When a portal is added or removed it reloads all portals(i think) so add code for unloading too.
|
// When a portal is added or removed it reloads all portals(i think) so add code for unloading too.
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user