-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
9f70fae
commit e63b730
Showing
5 changed files
with
47 additions
and
19 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
33 changes: 33 additions & 0 deletions
33
src/main/java/me/mmmjjkx/bbox/moreflags/config/FlagSetSerializer.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,33 @@ | ||
package me.mmmjjkx.bbox.moreflags.config; | ||
|
||
import org.bukkit.configuration.MemorySection; | ||
import world.bentobox.bentobox.database.objects.adapters.AdapterInterface; | ||
|
||
import java.util.Map; | ||
|
||
public class FlagSetSerializer implements AdapterInterface<FlagSet, Map<String, Object>> { | ||
|
||
public FlagSetSerializer() { | ||
} | ||
|
||
@Override | ||
public FlagSet deserialize(Object o) { | ||
FlagSet flagSet = new FlagSet(); | ||
if (o instanceof MemorySection ms) { | ||
flagSet.setEnabled(ms.getBoolean("enabled")); | ||
flagSet.setChangeCooldown(ms.getInt("change-cooldown")); | ||
} | ||
return flagSet; | ||
} | ||
|
||
@Override | ||
public Map<String, Object> serialize(Object o) { | ||
if (o instanceof FlagSet fs) { | ||
boolean enabled = fs.isEnabled(); | ||
int changeCooldown = fs.getChangeCooldown(); | ||
return Map.of("enabled", enabled, "change-cooldown", changeCooldown); | ||
} else { | ||
return null; | ||
} | ||
} | ||
} |
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