mirror of
https://github.com/sekwah41/Advanced-Portals.git
synced 2024-11-25 12:06:17 +01:00
Added support for 1.9.4
This commit is contained in:
parent
eff5319a9d
commit
7bcd88fd1d
@ -4,17 +4,16 @@ import com.sekwah.advancedportals.DataCollector.DataCollector;
|
||||
import com.sekwah.advancedportals.compat.bukkit.NMS;
|
||||
import com.sekwah.advancedportals.destinations.Destination;
|
||||
import com.sekwah.advancedportals.effects.WarpEffects;
|
||||
import com.sekwah.advancedportals.listeners.*;
|
||||
import com.sekwah.advancedportals.listeners.BungeeListener;
|
||||
import com.sekwah.advancedportals.listeners.FlowStopper;
|
||||
import com.sekwah.advancedportals.listeners.PortalPlacer;
|
||||
import com.sekwah.advancedportals.listeners.PortalProtect;
|
||||
import com.sekwah.advancedportals.metrics.Metrics;
|
||||
import com.sekwah.advancedportals.portals.Portal;
|
||||
import org.bukkit.Chunk;
|
||||
import org.bukkit.entity.Entity;
|
||||
import org.bukkit.plugin.java.JavaPlugin;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.lang.reflect.InvocationTargetException;
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
|
||||
public class AdvancedPortalsPlugin extends JavaPlugin {
|
||||
|
||||
@ -43,12 +42,56 @@ public class AdvancedPortalsPlugin extends JavaPlugin {
|
||||
Class<?> nmsClass = Class.forName("com.sekwah.advancedportals.compat.bukkit." + version);
|
||||
if (NMS.class.isAssignableFrom(nmsClass)) {
|
||||
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);
|
||||
|
||||
|
||||
// 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 {
|
||||
System.out.println("Something went wrong, please notify the author and tell them this version v:" + version);
|
||||
this.getLogger().warning("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 version v:" + version);
|
||||
this.getLogger().warning("This version of craftbukkit is not yet supported, please notify the author and give version v:" + version);
|
||||
this.setEnabled(false);
|
||||
} catch (InstantiationException | IllegalAccessException | IllegalArgumentException | InvocationTargetException |
|
||||
NoSuchMethodException | SecurityException e) {
|
||||
@ -67,47 +110,6 @@ public class AdvancedPortalsPlugin extends JavaPlugin {
|
||||
this.customPrefixFail = config.getConfig().getString("CustomPrefixFail").replaceAll("&", "\u00A7");
|
||||
}
|
||||
|
||||
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);
|
||||
|
||||
|
||||
// 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!");
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
27
src/com/sekwah/advancedportals/compat/bukkit/v1_9_R2.java
Normal file
27
src/com/sekwah/advancedportals/compat/bukkit/v1_9_R2.java
Normal file
@ -0,0 +1,27 @@
|
||||
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);
|
||||
}
|
||||
}
|
Loading…
Reference in New Issue
Block a user