-
-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Replace fabric metadata impl with data attachment api
- Loading branch information
1 parent
b0180ea
commit 83ed16a
Showing
10 changed files
with
99 additions
and
122 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
50 changes: 50 additions & 0 deletions
50
fabric/src/main/java/me/moros/bending/fabric/platform/FabricDataHolder.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,50 @@ | ||
/* | ||
* Copyright 2020-2024 Moros | ||
* | ||
* This file is part of Bending. | ||
* | ||
* Bending is free software: you can redistribute it and/or modify | ||
* it under the terms of the GNU Affero General Public License as published by | ||
* the Free Software Foundation, either version 3 of the License, or | ||
* (at your option) any later version. | ||
* | ||
* Bending 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 Affero General Public License for more details. | ||
* | ||
* You should have received a copy of the GNU Affero General Public License | ||
* along with Bending. If not, see <https://www.gnu.org/licenses/>. | ||
*/ | ||
|
||
package me.moros.bending.fabric.platform; | ||
|
||
import java.util.Optional; | ||
|
||
import me.moros.bending.api.util.data.DataHolder; | ||
import me.moros.bending.api.util.data.DataKey; | ||
import net.fabricmc.fabric.api.attachment.v1.AttachmentTarget; | ||
|
||
public record FabricDataHolder(AttachmentTarget handle) implements DataHolder { | ||
@Override | ||
public <T> Optional<T> get(DataKey<T> key) { | ||
var type = PlatformAdapter.dataTypeIfExists(key); | ||
if (type == null) { | ||
return Optional.empty(); | ||
} | ||
return Optional.ofNullable(handle().getAttached(type)); | ||
} | ||
|
||
@Override | ||
public <T> void add(DataKey<T> key, T value) { | ||
handle().setAttached(PlatformAdapter.dataType(key), value); | ||
} | ||
|
||
@Override | ||
public <T> void remove(DataKey<T> key) { | ||
var type = PlatformAdapter.dataTypeIfExists(key); | ||
if (type != null) { | ||
handle().removeAttached(type); | ||
} | ||
} | ||
} |
101 changes: 0 additions & 101 deletions
101
fabric/src/main/java/me/moros/bending/fabric/platform/FabricMetadata.java
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters