Skip to content

Commit

Permalink
BungeeCord improvements
Browse files Browse the repository at this point in the history
  • Loading branch information
GeorgH93 committed Jan 31, 2024
1 parent 853410c commit d4f78c4
Show file tree
Hide file tree
Showing 6 changed files with 26 additions and 19 deletions.
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright (C) 2022 GeorgH93
* Copyright (C) 2024 GeorgH93
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
Expand All @@ -25,6 +25,7 @@
import at.pcgamingfreaks.MarriageMaster.Bukkit.MarriageMaster;
import at.pcgamingfreaks.MarriageMaster.Database.PluginChannelCommunicatorBase;

import org.bukkit.Bukkit;
import org.bukkit.entity.Player;
import org.bukkit.event.EventHandler;
import org.bukkit.event.EventPriority;
Expand Down Expand Up @@ -202,6 +203,16 @@ public void sendMessage(final byte[] data)
}

private void sendMessage(String channel, byte[] data)
{
if (Bukkit.isPrimaryThread())
performSendMessage(channel, data);
else
{
Bukkit.getScheduler().runTask(plugin, () -> performSendMessage(channel, data));
}
}

private void performSendMessage(String channel, byte[] data)
{
if(!plugin.getServer().getOnlinePlayers().isEmpty())
{
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright (C) 2021 GeorgH93
* Copyright (C) 2024 GeorgH93
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
Expand Down Expand Up @@ -257,7 +257,7 @@ public void sendHome(final ProxiedPlayer player, final Marriage marriage)
if(!player.getServer().getInfo().getName().equals(homeServer.getName()))
{
player.connect(homeServer);
plugin.getProxy().getScheduler().schedule(plugin, () -> sendHome(homeServer, player.getUniqueId(), (player.equals(marriage.getPartner1().getPlayer()) ? marriage.getPartner2() : marriage.getPartner1()).getUUID()), 1L, TimeUnit.SECONDS);
plugin.getProxy().getScheduler().schedule(plugin, () -> sendHome(homeServer, player.getUniqueId(), (player.equals(marriage.getPartner1().getPlayer()) ? marriage.getPartner2() : marriage.getPartner1()).getUUID()), 2L, TimeUnit.SECONDS);
}
else
{
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright (C) 2021 GeorgH93
* Copyright (C) 2024 GeorgH93
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
Expand Down Expand Up @@ -138,7 +138,7 @@ public void sendTP(final ProxiedPlayer player, final ProxiedPlayer partner)
if(!player.getServer().getInfo().getName().equals(partnerServer.getName()))
{
player.connect(partner.getServer().getInfo());
plugin.getProxy().getScheduler().schedule(plugin, () -> communicator.sendMessage(partner.getServer().getInfo(), "tp", player.getUniqueId().toString(), partner.getUniqueId().toString()), 1L, TimeUnit.SECONDS);
plugin.getProxy().getScheduler().schedule(plugin, () -> communicator.sendMessage(partner.getServer().getInfo(), "tp", player.getUniqueId().toString(), partner.getUniqueId().toString()), 2L, TimeUnit.SECONDS);
}
else
{
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright (C) 2023 GeorgH93
* Copyright (C) 2024 GeorgH93
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
Expand Down Expand Up @@ -548,21 +548,18 @@ public void updatePriestStatus(final @NotNull MARRIAGE_PLAYER player, final @Nul
public void updateHome(final @NotNull MARRIAGE marriage, final @Nullable Consumer<MarriageDataBase> updateCallback)
{
Home home = marriage.getHome();
if(home == null)
if (home == null)
{
runStatementAsyncIncludeKey(queryDelHome, marriage);
}
else if(useBungee)
{
runStatementAsyncIncludeKeyFirst((updateCallback != null) ? () -> updateCallback.accept(marriage) : null,
queryUpdateHome, marriage, home.getX(), home.getY(), home.getZ(), home.getYaw(), home.getPitch(), home.getWorldName(), home.getHomeServer());
}
else
{
if(useBungee)
{
runStatementAsyncIncludeKeyFirst((updateCallback != null) ? () -> updateCallback.accept(marriage) : null,
queryUpdateHome, marriage, home.getX(), home.getY(), home.getZ(), home.getYaw(), home.getPitch(), home.getWorldName(), home.getHomeServer());
}
else
{
runStatementAsyncIncludeKeyFirst(queryUpdateHome, marriage, home.getX(), home.getY(), home.getZ(), home.getYaw(), home.getPitch(), home.getWorldName());
}
runStatementAsyncIncludeKeyFirst(queryUpdateHome, marriage, home.getX(), home.getY(), home.getZ(), home.getYaw(), home.getPitch(), home.getWorldName());
}
}

Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright (C) 2023 GeorgH93
* Copyright (C) 2024 GeorgH93
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
Expand All @@ -20,7 +20,6 @@
import at.pcgamingfreaks.ConsoleColor;
import at.pcgamingfreaks.Database.ConnectionProvider.ConnectionProvider;
import at.pcgamingfreaks.MarriageMaster.API.Home;
import at.pcgamingfreaks.MarriageMaster.API.Marriage;
import at.pcgamingfreaks.MarriageMaster.API.MarriageMasterPlugin;
import at.pcgamingfreaks.MarriageMaster.Database.Backend.DatabaseBackend;
import at.pcgamingfreaks.MarriageMaster.Database.Backend.MySQL;
Expand Down
2 changes: 1 addition & 1 deletion pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
<packaging>pom</packaging>

<properties>
<revision>2.7.2</revision>
<revision>2.7.3</revision>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<project.reporting.outputEncoding>UTF-8</project.reporting.outputEncoding>
<bukkitVersion>1.15.2-R0.1-SNAPSHOT</bukkitVersion>
Expand Down

0 comments on commit d4f78c4

Please sign in to comment.