forked from funniray/minimap-control
-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
5a92b66
commit cbfedaa
Showing
10 changed files
with
104 additions
and
111 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
package net.edenor.minimap; | ||
|
||
import net.edenor.minimap.api.MinimapPlayer; | ||
import org.bukkit.event.EventHandler; | ||
import org.bukkit.event.Listener; | ||
import org.bukkit.event.player.PlayerChangedWorldEvent; | ||
import org.bukkit.event.player.PlayerJoinEvent; | ||
import org.jetbrains.annotations.NotNull; | ||
|
||
public class MinimapEvents implements @NotNull Listener { | ||
|
||
private MinimapPlugin plugin; | ||
|
||
public MinimapEvents(MinimapPlugin plugin){ | ||
this.plugin = plugin; | ||
} | ||
|
||
@EventHandler | ||
public void onJoin(PlayerJoinEvent event) { | ||
plugin.getServer().getGlobalRegionScheduler().runDelayed(plugin, | ||
v->this.handlePackets(new MinimapPlayer(event.getPlayer())), 20L); | ||
plugin.getServer().getGlobalRegionScheduler().runDelayed(plugin, | ||
v->this.handlePackets(new MinimapPlayer(event.getPlayer())), 100L); //Resend later | ||
plugin.getServer().getGlobalRegionScheduler().runDelayed(plugin, | ||
v->this.handlePackets(new MinimapPlayer(event.getPlayer())), 200L); //Resend later | ||
} | ||
|
||
@EventHandler | ||
public void onWorldChange(PlayerChangedWorldEvent event) { | ||
handlePackets(new MinimapPlayer(event.getPlayer())); | ||
} | ||
|
||
public void handlePackets(MinimapPlayer player) { | ||
plugin.xaerosHandler.sendXaerosHandshake(player); | ||
plugin.xaerosHandler.sendXaerosConfig(player); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,50 @@ | ||
package net.edenor.minimap; | ||
|
||
import net.edenor.minimap.api.MinimapPlayer; | ||
import org.bukkit.entity.Player; | ||
import org.bukkit.plugin.messaging.PluginMessageListener; | ||
import org.jetbrains.annotations.NotNull; | ||
|
||
import java.util.Arrays; | ||
import java.util.List; | ||
|
||
public class MinimapListener implements PluginMessageListener { | ||
|
||
private static final List<String> listenChannels = Arrays.asList( | ||
"journeymap:version", | ||
"journeymap:perm_req", | ||
"journeymap:admin_req", | ||
"journeymap:admin_save", | ||
"journeymap:teleport_req", | ||
"journeymap:common", | ||
"worldinfo:world_id", | ||
"xaerominimap:main", | ||
"xaeroworldmap:main" | ||
); | ||
|
||
private MinimapPlugin plugin; | ||
|
||
public MinimapListener(MinimapPlugin plugin){ | ||
this.plugin = plugin; | ||
|
||
listenChannels.forEach(this::registerChannel); | ||
} | ||
|
||
public void registerChannel(String channel) { | ||
plugin.getServer().getMessenger().registerOutgoingPluginChannel(MinimapPlugin.getInstance(), channel); | ||
plugin.getServer().getMessenger().registerIncomingPluginChannel(MinimapPlugin.getInstance(), channel, this); | ||
} | ||
|
||
public void onPluginMessage(String channel, MinimapPlayer player, byte[] message) { | ||
switch (channel.split(":")[0]) { | ||
case "journeymap" -> plugin.jmHandler.onPluginMessage(channel, player, message); | ||
case "xaerominimap", "xaeroworldmap" -> plugin.xaerosHandler.onPluginMessage(channel, player, message); | ||
case "worldinfo" -> plugin.worldInfoHandler.onPluginMessage(channel, player, message); | ||
} | ||
} | ||
|
||
@Override | ||
public void onPluginMessageReceived(@NotNull String channel, @NotNull Player player, @NotNull byte[] message) { | ||
this.onPluginMessage(channel, new MinimapPlayer(player), message); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters