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

Rework how skins are handled #152

Merged
merged 30 commits into from
Sep 10, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
30 commits
Select commit Hold shift + click to select a range
5e9f191
Rework how skins are handled
OliverSchlueter Aug 5, 2024
9fcdc10
.
OliverSchlueter Aug 5, 2024
91807e9
update build.yml
OliverSchlueter Aug 5, 2024
bbcd6f3
Fix stackoverflow
OliverSchlueter Aug 12, 2024
59e45e6
Fix messages
OliverSchlueter Aug 12, 2024
d315cae
Fix messages again
OliverSchlueter Aug 12, 2024
6b69f3d
skin saving & loading
OliverSchlueter Aug 12, 2024
97f224f
async
OliverSchlueter Aug 12, 2024
fddb3c7
add npc update scheduler
OliverSchlueter Aug 12, 2024
89a2718
add logging
OliverSchlueter Aug 12, 2024
65caeb8
add skin cache
OliverSchlueter Aug 20, 2024
2cbf2fb
cache player skin on join
OliverSchlueter Aug 20, 2024
44e7805
cache skin after fetching
OliverSchlueter Aug 20, 2024
98a719a
more caching
OliverSchlueter Aug 20, 2024
d7e2b1a
more caching
OliverSchlueter Aug 20, 2024
39882dc
more caching
OliverSchlueter Aug 20, 2024
e533708
more caching
OliverSchlueter Aug 20, 2024
1410368
less caching
OliverSchlueter Aug 20, 2024
f1ccec7
yes
OliverSchlueter Aug 21, 2024
296a7fe
add empty check
OliverSchlueter Aug 29, 2024
adafcc9
fix loading mirrorSkin
OliverSchlueter Aug 29, 2024
941a833
use npcThread
OliverSchlueter Aug 29, 2024
6a10f66
send ClientboundPlayerInfoRemovePacket with a 2 seconds delay instead…
OliverSchlueter Aug 30, 2024
3487530
add remove_npcs_from_playerlist_delay config option
OliverSchlueter Aug 30, 2024
c490aa1
update cache times
OliverSchlueter Sep 3, 2024
7e8782a
fix show in tab
OliverSchlueter Sep 3, 2024
7211688
disable playerInfoRemovePacket if removeNpcsFromPlayerlistDelay is -1
OliverSchlueter Sep 4, 2024
5704d20
cache skins from old system
OliverSchlueter Sep 4, 2024
c163105
remove logs
OliverSchlueter Sep 6, 2024
a1dff8d
take backup when migrating skins
OliverSchlueter Sep 6, 2024
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 3 additions & 1 deletion .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,9 @@ name: Build plugin

on:
push:

pull_request:
types:
- opened
jobs:
build-plugin:
runs-on: ubuntu-latest
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,10 +15,14 @@ public interface FancyNpcsConfig {

int getAutoSaveInterval();

int getNpcUpdateInterval();

int getTurnToPlayerDistance();

int getVisibilityDistance();

int getRemoveNpcsFromPlayerlistDelay();

List<String> getBlockedCommands();

Map<String, Integer> getMaxNpcsPerPermission();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

import de.oliver.fancylib.serverSoftware.schedulers.FancyScheduler;
import de.oliver.fancylib.translations.Translator;
import de.oliver.fancynpcs.api.utils.SkinCache;
import org.bukkit.Bukkit;
import org.bukkit.plugin.PluginManager;
import org.bukkit.plugin.java.JavaPlugin;
Expand Down Expand Up @@ -36,4 +37,6 @@ static FancyNpcsPlugin get() {
AttributeManager getAttributeManager();

Translator getTranslator();

SkinCache getSkinCache();
}
10 changes: 5 additions & 5 deletions api/src/main/java/de/oliver/fancynpcs/api/NpcData.java
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,8 @@ public class NpcData {
private final String name;
private final UUID creator;
private String displayName;
private SkinFetcher skin;
private SkinFetcher.SkinData skin;
private boolean mirrorSkin;
private Location location;
private boolean showInTab;
private boolean spawnEntity;
Expand All @@ -36,14 +37,13 @@ public class NpcData {
private float scale;
private Map<NpcAttribute, String> attributes;
private boolean isDirty;
private boolean mirrorSkin;

public NpcData(
String id,
String name,
UUID creator,
String displayName,
SkinFetcher skin,
SkinFetcher.SkinData skin,
Location location,
boolean showInTab,
boolean spawnEntity,
Expand Down Expand Up @@ -141,11 +141,11 @@ public NpcData setDisplayName(String displayName) {
return this;
}

public SkinFetcher getSkin() {
public SkinFetcher.SkinData getSkin() {
return skin;
}

public NpcData setSkin(SkinFetcher skin) {
public NpcData setSkin(SkinFetcher.SkinData skin) {
this.skin = skin;
isDirty = true;
return this;
Expand Down
26 changes: 26 additions & 0 deletions api/src/main/java/de/oliver/fancynpcs/api/utils/SkinCache.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
package de.oliver.fancynpcs.api.utils;

import java.util.List;

public interface SkinCache {

/**
* Load all cached skins from the cache and removes all expired skins
*
* @return List of cached skins
*/
List<SkinFetcher.SkinCacheData> load();

/**
* Save a skin to the cache
*
* @param skinCacheData Skin data to save
* @param onlyIfExists If true, the skin will only be replaced/updated if it already exists in the cache
*/
void upsert(SkinFetcher.SkinCacheData skinCacheData, boolean onlyIfExists);

default void upsert(SkinFetcher.SkinCacheData skinCacheData) {
upsert(skinCacheData, false);
}

}
Loading
Loading