Moved code around and started adding bungee destination warps as well as starting the tag registration

This commit is contained in:
Alastair 2016-03-29 12:35:34 +01:00
parent 541a7f11e9
commit 08d2a58c45
8 changed files with 113 additions and 4 deletions

View File

@ -1,5 +1,6 @@
package com.sekwah.advancedportals;
import com.sekwah.advancedportals.listeners.Listeners;
import com.sekwah.advancedportals.portals.Portal;
import com.sekwah.advancedportals.portals.PortalArg;
import org.bukkit.Location;

View File

@ -4,6 +4,7 @@ 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.metrics.Metrics;
import com.sekwah.advancedportals.portals.Portal;
import org.bukkit.plugin.java.JavaPlugin;
@ -97,6 +98,10 @@ public class AdvancedPortalsPlugin extends JavaPlugin {
Selection.LoadData(this);
DataCollector.setupMetrics();
this.getServer().getMessenger().registerOutgoingPluginChannel(this, "BungeeCord");
this.getServer().getMessenger().registerIncomingPluginChannel(this, "BungeeCord", new BungeeListener(this));
}

View File

@ -0,0 +1,53 @@
package com.sekwah.advancedportals.listeners;
import com.sekwah.advancedportals.AdvancedPortalsPlugin;
import net.minecraft.util.com.google.common.io.ByteArrayDataInput;
import net.minecraft.util.com.google.common.io.ByteStreams;
import org.bukkit.entity.Player;
import org.bukkit.plugin.messaging.PluginMessageListener;
/**
* Created by on 29/03/2016.
*
* @author sekwah41
*/
public class BungeeListener implements PluginMessageListener {
private AdvancedPortalsPlugin plugin;
public BungeeListener(AdvancedPortalsPlugin plugin) {
this.plugin = plugin;
}
@Override
public void onPluginMessageReceived(String channel, Player player, byte[] message) {
if (!channel.equals("BungeeCord")) {
return;
}
ByteArrayDataInput in = ByteStreams.newDataInput(message);
String subchannel = in.readUTF();
if (subchannel.equals("AdvancedPortals")) {
// Any data after this is read like the packets used in the naruto mod
// (same order as sent)
}
}
/**
* Example forward packet.
*
* Construct like the forge packets.
*
* out.writeUTF("Forward"); // So BungeeCord knows to forward it
out.writeUTF("ALL");
out.writeUTF("MyChannel"); // The channel name to check if this your data
ByteArrayOutputStream msgbytes = new ByteArrayOutputStream();
DataOutputStream msgout = new DataOutputStream(msgbytes);
msgout.writeUTF("Some kind of data here"); // You can do anything you want with msgout
msgout.writeShort(123);
out.writeShort(msgbytes.toByteArray().length);
out.write(msgbytes.toByteArray());
*
*/
}

View File

@ -1,5 +1,7 @@
package com.sekwah.advancedportals;
package com.sekwah.advancedportals.listeners;
import com.sekwah.advancedportals.AdvancedPortalsPlugin;
import com.sekwah.advancedportals.ConfigAccessor;
import com.sekwah.advancedportals.portals.AdvancedPortal;
import com.sekwah.advancedportals.portals.Portal;
import org.bukkit.block.Block;

View File

@ -1,5 +1,7 @@
package com.sekwah.advancedportals;
package com.sekwah.advancedportals.listeners;
import com.sekwah.advancedportals.AdvancedPortalsPlugin;
import com.sekwah.advancedportals.ConfigAccessor;
import com.sekwah.advancedportals.events.WarpEvent;
import com.sekwah.advancedportals.portals.AdvancedPortal;
import com.sekwah.advancedportals.portals.Portal;

View File

@ -1,5 +1,7 @@
package com.sekwah.advancedportals;
package com.sekwah.advancedportals.listeners;
import com.sekwah.advancedportals.AdvancedPortalsPlugin;
import com.sekwah.advancedportals.ConfigAccessor;
import com.sekwah.advancedportals.portals.AdvancedPortal;
import com.sekwah.advancedportals.portals.Portal;
import org.bukkit.Material;

View File

@ -1,5 +1,7 @@
package com.sekwah.advancedportals;
package com.sekwah.advancedportals.listeners;
import com.sekwah.advancedportals.AdvancedPortalsPlugin;
import com.sekwah.advancedportals.ConfigAccessor;
import com.sekwah.advancedportals.portals.AdvancedPortal;
import com.sekwah.advancedportals.portals.Portal;
import org.bukkit.block.Block;

View File

@ -0,0 +1,42 @@
package com.sekwah.advancedportals.portals;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.Map;
/**
* Created by on 29/03/2016.
*
* TODO add all the normal tags then add the extradata tags
*
* @author sekwah41
*/
public class PortalTags {
// TODO create a list or hashmap of tags to check for.
public Map<String, String> tagDesc = new HashMap<String,String>();
public ArrayList<String> tags = new ArrayList<String>();
public void registerTag(String tagName){
this.registerTag(tagName, false);
}
/**
* Will only be used if a /portal tags command is created. The descriptions will be used for help text
* so please keep it short.
*
* @param tagName
* @param description
*/
public void registerTag(String tagName, boolean multiWord, String description){
this.registerTag(tagName, multiWord);
}
public void registerTag(String tagName, boolean multiWord){
}
}