-
-
Notifications
You must be signed in to change notification settings - Fork 5
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[PlaybackController] Added playback metadata registry
- Loading branch information
1 parent
f28cc1f
commit d11b2ac
Showing
5 changed files
with
79 additions
and
6 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
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
61 changes: 61 additions & 0 deletions
61
src/main/java/com/minecrafttas/tasmod/playback/metadata/PlaybackMetadataRegistry.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,61 @@ | ||
package com.minecrafttas.tasmod.playback.metadata; | ||
|
||
import java.util.ArrayList; | ||
|
||
import com.minecrafttas.mctcommon.MCTCommon; | ||
|
||
public class PlaybackMetadataRegistry { | ||
|
||
private static final ArrayList<PlaybackMetadataExtension> METADATA_EXTENSION = new ArrayList<>(); | ||
|
||
public static void register(PlaybackMetadataExtension extension) { | ||
if(extension==null) { | ||
throw new NullPointerException("Tried to register a playback extension with value null"); | ||
} | ||
|
||
if(containsClass(extension)) { | ||
MCTCommon.LOGGER.warn("Trying to register the playback extension {}, but another instance of this class is already registered!", extension.getClass().getName()); | ||
return; | ||
} | ||
|
||
if (!METADATA_EXTENSION.contains(extension)) { | ||
METADATA_EXTENSION.add(extension); | ||
} else { | ||
MCTCommon.LOGGER.warn("Trying to register the playback extension {}, but it is already registered!", extension.getClass().getName()); | ||
} | ||
} | ||
|
||
public static void unregister(PlaybackMetadataExtension extension) { | ||
if(extension==null) { | ||
throw new NullPointerException("Tried to unregister an extension with value null"); | ||
} | ||
if (METADATA_EXTENSION.contains(extension)) { | ||
METADATA_EXTENSION.remove(extension); | ||
} else { | ||
MCTCommon.LOGGER.warn("Trying to unregister the playback extension {}, but it was not registered!", extension.getClass().getName()); | ||
} | ||
} | ||
|
||
public static PlaybackMetadata handleOnLoad() { | ||
return null; //TODO implement | ||
} | ||
|
||
public static void handleOnStore(PlaybackMetadata metadata) { | ||
//TODO | ||
} | ||
|
||
private static boolean containsClass(PlaybackMetadataExtension newExtension) { | ||
for(PlaybackMetadataExtension extension : METADATA_EXTENSION) { | ||
if(extension.getClass().equals(newExtension.getClass())) { | ||
return true; | ||
} | ||
} | ||
return false; | ||
} | ||
|
||
public static interface PlaybackMetadataExtension { | ||
public PlaybackMetadata onStore(); | ||
|
||
public void onLoad(PlaybackMetadata metadata); | ||
} | ||
} |