mirror of
https://github.com/darksaid98/Carbon.git
synced 2026-12-02 06:28:54 +00:00
Folia support & display name state handling improvements (#240)
This commit is contained in:
1 parent
0efeeaa5c8
commit
052c3731f5
12 files changed
+232
-17
No files matched your search
@@ -0,0 +1,45 @@
|
||||
/*
|
||||
* CarbonChat
|
||||
*
|
||||
* Copyright (c) 2023 Josua Parks (Vicarious)
|
||||
* Contributors
|
||||
*
|
||||
* 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
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
package net.draycia.carbon.common;
|
||||
|
||||
import com.google.inject.Inject;
|
||||
import com.google.inject.Singleton;
|
||||
import net.draycia.carbon.api.users.CarbonPlayer;
|
||||
import org.checkerframework.checker.nullness.qual.NonNull;
|
||||
import org.checkerframework.framework.qual.DefaultQualifier;
|
||||
|
||||
@DefaultQualifier(NonNull.class)
|
||||
public interface PlatformScheduler {
|
||||
|
||||
void scheduleForPlayer(CarbonPlayer carbonPlayer, Runnable runnable);
|
||||
|
||||
@Singleton
|
||||
final class RunImmediately implements PlatformScheduler {
|
||||
@Inject
|
||||
private RunImmediately() {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void scheduleForPlayer(final CarbonPlayer carbonPlayer, final Runnable runnable) {
|
||||
runnable.run();
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
@@ -33,6 +33,7 @@ import net.draycia.carbon.api.CarbonChat;
|
||||
import net.draycia.carbon.api.channels.ChatChannel;
|
||||
import net.draycia.carbon.api.users.CarbonPlayer;
|
||||
import net.draycia.carbon.api.util.InventorySlot;
|
||||
import net.draycia.carbon.common.PlatformScheduler;
|
||||
import net.kyori.adventure.audience.Audience;
|
||||
import net.kyori.adventure.audience.ForwardingAudience;
|
||||
import net.kyori.adventure.identity.Identity;
|
||||
@@ -51,6 +52,7 @@ public class CarbonPlayerCommon implements CarbonPlayer, ForwardingAudience.Sing
|
||||
|
||||
private transient @MonotonicNonNull @Inject CarbonChat carbonChat;
|
||||
private transient @MonotonicNonNull @Inject ProfileResolver profileResolver;
|
||||
private transient @MonotonicNonNull @Inject PlatformScheduler scheduler;
|
||||
private volatile transient long transientLoadedSince = -1;
|
||||
|
||||
protected final PersistentUserProperty<Boolean> muted;
|
||||
@@ -141,6 +143,10 @@ public class CarbonPlayerCommon implements CarbonPlayer, ForwardingAudience.Sing
|
||||
);
|
||||
}
|
||||
|
||||
public void schedule(final Runnable task) {
|
||||
this.scheduler.scheduleForPlayer(this, task);
|
||||
}
|
||||
|
||||
public void registerPropertyUpdateListener(final Runnable task) {
|
||||
this.properties().forEach(prop -> prop.registerUpdateListener(task));
|
||||
}
|
||||
|
||||
Reference in new issue
Block a user