mirror of
https://github.com/darksaid98/Carbon.git
synced 2026-12-03 06:28:54 +00:00
Add radius/same-world/same-server to channel options
This commit is contained in:
1 parent
ddb6998bc8
commit
60285830d4
11 files changed
+259
No files matched your search
@@ -44,6 +44,7 @@ import net.draycia.carbon.bukkit.util.CarbonChatHook;
|
||||
import net.draycia.carbon.common.channels.CarbonChannelRegistry;
|
||||
import net.draycia.carbon.common.messages.CarbonMessages;
|
||||
import net.draycia.carbon.common.messaging.MessagingManager;
|
||||
import net.draycia.carbon.common.listeners.RadiusListener;
|
||||
import net.draycia.carbon.common.users.CarbonPlayerCommon;
|
||||
import net.draycia.carbon.common.util.CloudUtils;
|
||||
import net.draycia.carbon.common.util.ListenerUtils;
|
||||
@@ -121,6 +122,7 @@ public final class CarbonChatBukkit extends JavaPlugin implements CarbonChat {
|
||||
|
||||
// Listeners
|
||||
ListenerUtils.registerCommonListeners(this.injector);
|
||||
this.injector.getInstance(RadiusListener.class);
|
||||
|
||||
// Commands
|
||||
// This is a bit awkward looking
|
||||
|
||||
@@ -24,6 +24,7 @@ import java.util.Collection;
|
||||
import java.util.Locale;
|
||||
import java.util.Optional;
|
||||
import java.util.Set;
|
||||
import net.draycia.carbon.api.users.CarbonPlayer;
|
||||
import net.draycia.carbon.api.util.InventorySlot;
|
||||
import net.draycia.carbon.common.users.CarbonPlayerCommon;
|
||||
import net.draycia.carbon.common.users.WrappedCarbonPlayer;
|
||||
@@ -65,6 +66,38 @@ public final class CarbonPlayerBukkit extends WrappedCarbonPlayer implements For
|
||||
return this.player().map(player -> (Audience) player).orElse(Audience.empty());
|
||||
}
|
||||
|
||||
@Override
|
||||
public double distanceSquaredFrom(final CarbonPlayer other) {
|
||||
if (this.player().isEmpty()) {
|
||||
return -1;
|
||||
}
|
||||
|
||||
final @Nullable Player player = this.player().orElse(null);
|
||||
final @Nullable Player otherPlayer = Bukkit.getPlayer(other.uuid());
|
||||
|
||||
if (player == null || otherPlayer == null) {
|
||||
return -1;
|
||||
}
|
||||
|
||||
return player.getLocation().distanceSquared(otherPlayer.getLocation());
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean sameWorldAs(final CarbonPlayer other) {
|
||||
if (this.player().isEmpty()) {
|
||||
return false;
|
||||
}
|
||||
|
||||
final Optional<Player> player = this.player();
|
||||
final @Nullable Player otherPlayer = Bukkit.getPlayer(other.uuid());
|
||||
|
||||
if (player.isEmpty() || otherPlayer == null) {
|
||||
return false;
|
||||
}
|
||||
|
||||
return player.get().getWorld().equals(otherPlayer.getWorld());
|
||||
}
|
||||
|
||||
@Override
|
||||
public void displayName(final @Nullable Component displayName) {
|
||||
this.carbonPlayerCommon.displayName(displayName);
|
||||
|
||||
Reference in new issue
Block a user