-
-
Notifications
You must be signed in to change notification settings - Fork 32
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add GUI for editing Challenge and Challenge Level lore messages.
Rework Lore message construction.
- Loading branch information
Showing
9 changed files
with
1,277 additions
and
312 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
63 changes: 63 additions & 0 deletions
63
src/main/java/world/bentobox/challenges/database/object/adapters/ChallengeLoreAdapter.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,63 @@ | ||
// | ||
// Created by BONNe | ||
// Copyright - 2019 | ||
// | ||
|
||
|
||
package world.bentobox.challenges.database.object.adapters; | ||
|
||
|
||
import java.util.ArrayList; | ||
import java.util.List; | ||
import java.util.stream.Collectors; | ||
|
||
import world.bentobox.bentobox.database.objects.adapters.AdapterInterface; | ||
import world.bentobox.challenges.config.SettingsUtils.ChallengeLore; | ||
|
||
|
||
/** | ||
* This adapter allows to serialize and deserialize ChallengeLore object. | ||
*/ | ||
public class ChallengeLoreAdapter implements AdapterInterface<List<ChallengeLore>, List<String>> | ||
{ | ||
@SuppressWarnings("unchecked") | ||
@Override | ||
public List<ChallengeLore> deserialize(Object from) | ||
{ | ||
List<ChallengeLore> result; | ||
|
||
if (from instanceof List) | ||
{ | ||
result = ((List<String>) from).stream(). | ||
map(ChallengeLore::valueOf). | ||
collect(Collectors.toCollection(ArrayList::new)); | ||
} | ||
else | ||
{ | ||
result = new ArrayList<>(0); | ||
} | ||
|
||
return result; | ||
} | ||
|
||
|
||
@SuppressWarnings("unchecked") | ||
@Override | ||
public List<String> serialize(Object to) | ||
{ | ||
List<String> result; | ||
|
||
if (to instanceof List) | ||
{ | ||
result = ((List<ChallengeLore>) to).stream(). | ||
map(ChallengeLore::name). | ||
collect(Collectors.toCollection(ArrayList::new)); | ||
} | ||
else | ||
{ | ||
result = new ArrayList<>(0); | ||
} | ||
|
||
return result; | ||
} | ||
} |
63 changes: 63 additions & 0 deletions
63
src/main/java/world/bentobox/challenges/database/object/adapters/LevelLoreAdapter.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,63 @@ | ||
// | ||
// Created by BONNe | ||
// Copyright - 2019 | ||
// | ||
|
||
|
||
package world.bentobox.challenges.database.object.adapters; | ||
|
||
|
||
import java.util.ArrayList; | ||
import java.util.List; | ||
import java.util.stream.Collectors; | ||
|
||
import world.bentobox.bentobox.database.objects.adapters.AdapterInterface; | ||
import world.bentobox.challenges.config.SettingsUtils.LevelLore; | ||
|
||
|
||
/** | ||
* This adapter allows to serialize and deserialize LevelLore object. | ||
*/ | ||
public class LevelLoreAdapter implements AdapterInterface<List<LevelLore>, List<String>> | ||
{ | ||
@SuppressWarnings("unchecked") | ||
@Override | ||
public List<LevelLore> deserialize(Object from) | ||
{ | ||
List<LevelLore> result; | ||
|
||
if (from instanceof List) | ||
{ | ||
result = ((List<String>) from).stream(). | ||
map(LevelLore::valueOf). | ||
collect(Collectors.toCollection(ArrayList::new)); | ||
} | ||
else | ||
{ | ||
result = new ArrayList<>(0); | ||
} | ||
|
||
return result; | ||
} | ||
|
||
|
||
@SuppressWarnings("unchecked") | ||
@Override | ||
public List<String> serialize(Object to) | ||
{ | ||
List<String> result; | ||
|
||
if (to instanceof List) | ||
{ | ||
result = ((List<LevelLore>) to).stream(). | ||
map(LevelLore::name). | ||
collect(Collectors.toCollection(ArrayList::new)); | ||
} | ||
else | ||
{ | ||
result = new ArrayList<>(0); | ||
} | ||
|
||
return result; | ||
} | ||
} |
Oops, something went wrong.