Skip to content

Commit 984f694

Browse files
authored
refactor: update guide order, refactor and fix indentation (#310)
* fix: fix tab indentation * refactor: change guide order and move ecs guide over to the rest of guide * refactor: adjust wording and provide further clarification on ECS, fix links to ecs guide * refactor: remove useless info from ECS systems guide * refactor: add warning in env setup and building
1 parent c137e13 commit 984f694

6 files changed

Lines changed: 25 additions & 36 deletions

File tree

content/docs/en/guides/ecs/systems.mdx

Lines changed: 4 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -115,51 +115,28 @@ public class PermissionAttachmentSystem extends RefChangeSystem<EntityStore, Per
115115
return EntityStoreRegistry.get().getPermissionAttachmentComponentType();
116116
}
117117

118-
private PermissibleProvider getProvider() {
119-
for (PermissionProvider provider : PermissionsModule.get().getProviders()) {
120-
if (provider instanceof PermissibleProvider) {
121-
return (PermissibleProvider) provider;
122-
}
123-
}
124-
LOGGER.atWarning().log("PermissibleProvider not found in PermissionsModule!");
125-
return null;
126-
}
127-
128118
@Override
129119
public void onComponentAdded(@Nonnull Ref<EntityStore> ref, @Nonnull PermissionAttachment permissionAttachment, @Nonnull Store<EntityStore> store, @Nonnull CommandBuffer<EntityStore> commandBuffer) {
130120
UUIDComponent component = store.getComponent(ref, UUIDComponent.getComponentType());
131121
UUID playerUuid = component.getUuid();
132122

133-
PermissibleProvider provider = getProvider();
134-
if (provider != null) {
135-
provider.updateCache(playerUuid, permissionAttachment.getPermissions(), permissionAttachment.getGroups());
136-
}
123+
// PermissionAttachment component was added to a new entity
137124
}
138125

139126
@Override
140127
public void onComponentSet(@Nonnull Ref<EntityStore> ref, @Nullable PermissionAttachment oldAttachment, @Nonnull PermissionAttachment newAttachment, @Nonnull Store<EntityStore> store, @Nonnull CommandBuffer<EntityStore> commandBuffer) {
141128
UUIDComponent component = store.getComponent(ref, UUIDComponent.getComponentType());
142129
UUID playerUuid = component.getUuid();
143130

144-
PermissionRepository repository = PermissiblePlugin.getInstance().getInternalPermissionRepository();
145-
repository.savePlayerPermissions(playerUuid, newAttachment.getPermissions());
146-
repository.savePlayerGroups(playerUuid, newAttachment.getGroups());
147-
148-
PermissibleProvider provider = getProvider();
149-
if (provider != null) {
150-
provider.updateCache(playerUuid, newAttachment.getPermissions(), newAttachment.getGroups());
151-
}
131+
// PermissionAttachment component was updated using replaceComponent or putComponent
152132
}
153133

154134
@Override
155135
public void onComponentRemoved(@Nonnull Ref<EntityStore> ref, @Nonnull PermissionAttachment permissionAttachment, @Nonnull Store<EntityStore> store, @Nonnull CommandBuffer<EntityStore> commandBuffer) {
156136
UUIDComponent component = store.getComponent(ref, UUIDComponent.getComponentType());
157137
UUID playerUuid = component.getUuid();
158138

159-
PermissibleProvider provider = getProvider();
160-
if (provider != null) {
161-
provider.removeFromCache(playerUuid);
162-
}
139+
// PermissionAttachment component was removed from an entity
163140
}
164141

165142
@Nullable
@@ -171,7 +148,7 @@ public class PermissionAttachmentSystem extends RefChangeSystem<EntityStore, Per
171148
```
172149

173150
In this system we listen for changes on the `PermissionAttachment` component inside of the `EntityStore`. This gives us access to `onComponentAdded`, `onComponentSet` and `onComponentRemoved` which in this example caches and persists permission data
174-
which is stored on a player inside of a custom `PermissionAttachment` component. This example comes from [Permissible](https://github.com/oskarscot/Permissible) permissions plugin where you can find more examples of heavy ECS usage.
151+
which is stored on a player inside of a custom `PermissionAttachment` component.
175152

176153

177154

content/docs/en/guides/meta.json

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2,13 +2,12 @@
22
"title": "{meta.guides.title}",
33
"pages": [
44
"learning-to-learn.mdx",
5-
"plugin",
65
"java-basics",
6+
"plugin",
7+
"ecs",
78
"...",
89
"---Gameplay Systems---",
9-
"prefabs.mdx",
10-
"---Advanced Guides---",
11-
"ecs"
10+
"prefabs.mdx"
1211
],
1312
"icon": "GraduationCap"
1413
}

content/docs/en/guides/plugin/build-and-test.mdx

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,10 @@ authors:
55
- name: "Michael B"
66
---
77

8+
<Callout type="warning">
9+
This guide is outdated and will be updated soon. Whilst this guide is still accurate, there are now better alternatives for building your mod.
10+
</Callout>
11+
812
If you followed along with the [Setting Up Your Development Environment](./setting-up-env) page, you should now be able to build your project.
913

1014
## Building Your Mod

content/docs/en/guides/plugin/creating-commands.mdx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ It's important to know that `AbstractPlayerCommand` extends `AbstractAsyncComman
1919

2020
You can use the `Store` along with the `Ref` to access all entity components like the `Player` component, `UUIDComponent` or `TransformComponent`.
2121

22-
For more information about Hytale's Entity Component System visit the [Hytale ECS Theory](https://hytalemodding.dev/en/docs/guides/ecs/hytale-ecs-theory) guide.
22+
For more information about Hytale's Entity Component System visit the [Hytale ECS Theory](https://hytalemodding.dev/en/docs/plugin/ecs/hytale-ecs-theory) guide.
2323

2424

2525
```java

content/docs/en/guides/plugin/setting-up-env.mdx

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,11 @@ authors:
66
link: "https://itsneil.dev"
77
---
88

9+
<Callout type="warning">
10+
This guide is outdated and will be updated soon. Whilst this guide is still accurate, there are now better alternatives for setting up your environment.
11+
</Callout>
12+
13+
914
This guide will walk you through setting up a complete development environment for Hytale modding, including all necessary tools and dependencies.
1015

1116
## Prerequisites

content/docs/en/guides/plugin/store-persistant-data.mdx

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,8 @@ authors:
66
url: "https://github.com/ArcticRaven"
77
- name: "Neil Revin"
88
url: "https://itsneil.dev/"
9+
- name: "oskarscot"
10+
url: "https://oskar.scot"
911
---
1012

1113
Here is how to store persistent data using a custom component on a Player.
@@ -105,7 +107,7 @@ public class YourPlugin extends JavaPlugin {
105107
106108
Your component will be stored within the `Store<EntityStore>` when added to the player. In the provided example,
107109
we'll fetch this data off the player using the `ensureAndGetComponent()` method, which will add the component to
108-
the player if it does not exist.
110+
the player if it does not exist with the default values.
109111

110112
```java
111113
public class IncompleteCustomCommand extends AbstractPlayerCommand {
@@ -123,13 +125,15 @@ public class IncompleteCustomCommand extends AbstractPlayerCommand {
123125
@NonNullDecl World world
124126
) {
125127
YourPlayerData customData = store.ensureAndGetComponent(ref, YourPlugin.instance().getYourPlayerDataComponent());
126-
128+
// ensureAndGetComponent adds the component to the ref, with the default values defined inside your component.
127129
// use your data
128130
}
129131
}
130132
```
131133

132134
And that's it! Your data will now be saved and loaded automatically with the player.
133135
134-
## Conclusion
135-
Using custom components to store persistent data on players is a powerful way to maintain state across sessions. By following the steps outlined above, you can easily create, register, and utilize your own data structures within the Hytale modding framework. This approach ensures that your data is seamlessly integrated with the game's existing systems, providing a robust solution for managing player-specific information. Happy modding!
136+
Using custom components to store persistent data on players is a powerful way to maintain state across sessions.
137+
By following the steps outlined above, you can easily create, register, and utilize your own data structures within the Hytale ECS framework.
138+
This approach ensures that your data is seamlessly integrated with the game's existing systems.
139+
For more information about Hytale's Entity Component System visit the [Hytale ECS Theory](https://hytalemodding.dev/en/docs/plugin/plugin/hytale-ecs-theory) guide.

0 commit comments

Comments
 (0)