Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fly on join feature #68

Open
wants to merge 9 commits into
base: master
Choose a base branch
from
Open
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,9 @@
import com.google.common.io.ByteArrayDataOutput;
import com.google.common.io.ByteStreams;
import fun.lewisdev.deluxehub.DeluxeHubPlugin;
import fun.lewisdev.deluxehub.Permissions;
import fun.lewisdev.deluxehub.action.Action;
import fun.lewisdev.deluxehub.config.Messages;
import org.bukkit.entity.Player;

public class BungeeAction implements Action {
Expand All @@ -16,9 +18,12 @@ public String getIdentifier() {
@Override
public void execute(DeluxeHubPlugin plugin, Player player, String data) {
ByteArrayDataOutput out = ByteStreams.newDataOutput();
String[] args = data.split(";");
out.writeUTF("ConnectOther");
out.writeUTF(player.getName());
out.writeUTF(data);
player.sendPluginMessage(plugin, "BungeeCord", out.toByteArray());
out.writeUTF(args[0]);
if (player.hasPermission(args[1]))
player.sendPluginMessage(plugin, "BungeeCord", out.toByteArray());
else Messages.NO_PERMISSION.send(player);
}
}
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package fun.lewisdev.deluxehub.module.modules.player;

import fun.lewisdev.deluxehub.DeluxeHubPlugin;
import fun.lewisdev.deluxehub.Permissions;
import fun.lewisdev.deluxehub.config.ConfigType;
import fun.lewisdev.deluxehub.module.Module;
import fun.lewisdev.deluxehub.module.ModuleType;
Expand Down Expand Up @@ -33,6 +34,7 @@ public class PlayerListener extends Module {
private boolean spawnHeal;
private boolean extinguish;
private boolean clearInventory;
private boolean flyOnJoin;

private boolean fireworkEnabled;
private boolean fireworkFirstJoin;
Expand Down Expand Up @@ -60,6 +62,7 @@ public void onEnable() {
spawnHeal = config.getBoolean("join_settings.heal", false);
extinguish = config.getBoolean("join_settings.extinguish", false);
clearInventory = config.getBoolean("join_settings.clear_inventory", false);
flyOnJoin = config.getBoolean("join_settings.fly_on_join", false);

fireworkEnabled = config.getBoolean("join_settings.firework.enabled", true);
if (fireworkEnabled) {
Expand Down Expand Up @@ -108,6 +111,10 @@ public void onPlayerJoin(PlayerJoinEvent event) {
// Clear the player inventory
if (clearInventory) player.getInventory().clear();

// Enable flight
if (flyOnJoin && player.hasPermission(Permissions.COMMAND_FLIGHT.getPermission())) player.setAllowFlight(true);


Bukkit.getScheduler().scheduleSyncDelayedTask(getPlugin(), () -> {
// Join events
executeActions(player, joinActions);
Expand Down
4 changes: 3 additions & 1 deletion src/main/resources/config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@
# [COMMAND] - Execute a command as the player
# [CONSOLE] - Execute a command as console
# [GAMEMODE] - Change a players' gamemode
# [BUNGEE] - Send a player to a server
# [BUNGEE] - e.g. SERVER;PERMISSION Send a player to a server
# [EFFECT] e.g. EFFECT;LEVEL - Give a potion effect
# [MENU] - Open a menu from (plugins/DeluxeHub/menus)
# [CLOSE] - Close an open inventory gui
Expand Down Expand Up @@ -305,6 +305,8 @@ join_settings:
extinguish: true
# Should we clear their inventory?
clear_inventory: false
# Should we enable flight (only if the player has the permission deluxehub.commands.fly)?
fly_on_join: true
# Spawn a firework on join
firework:
# Should we send a firework on join?
Expand Down