Skip to content
This repository has been archived by the owner on May 8, 2023. It is now read-only.

Commit

Permalink
Merge pull request #2 from TheCahyag/enhancement/0.2.0-database-restr…
Browse files Browse the repository at this point in the history
…ucture

Enhancement/0.2.0 database restructure
  • Loading branch information
TheCahyag authored Dec 27, 2017
2 parents 90fa1e1 + e691ed4 commit 8f02b51
Show file tree
Hide file tree
Showing 30 changed files with 981 additions and 171 deletions.
10 changes: 8 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ The Animation plugin works mostly as intended. The max animation size has been s
See the wiki for the commands and their respective usages. (Still a WIP)

#### Known bugs / Not Implemented Yet
* Many tile entities are wonky and mostly don't work
* Many tile entities are wonky and ~~mostly don't work~~ don't retain their data
* At a certain point the animation becomes too big and won't load -- leads to a OutOfMemory exception
* Pause button does nothing
* Settings button does nothing
Expand All @@ -23,7 +23,7 @@ See the wiki for the commands and their respective usages. (Still a WIP)
#### High Priority
[WIKI] Write basic usage guidelines
[BUGFIX] After playing the animation for awhile the frames fall out of sync
[BUGFIX] Tile entities aren't un-serialized correctly

#### Medium Priority
[UI] The message that tells the user that the frame has been created or deleted should link to that frame
[PERMISSIONS] Setup specific permissions for the usage of flags, and any other permissions that isn't already setup
Expand All @@ -35,6 +35,9 @@ See the wiki for the commands and their respective usages. (Still a WIP)
[BUGFIX] Setting the cycles when starting an animation doesn't do anything
[REQUIREMENT] Define characters that are illegal to have in a frame/animation name
[BUGFIX] There's a problem when displaying the volume of small subspaces, a 1x4x1 will have a volume of 0
[BUGFIX] Some animations, when stopped, play certain frames continuously even after they are stopped (maybe because it
was played and then stopped immediately)
[BUGFIX] Deleting a frame that doesn't exist leads to a index out of bounds error

#### Low Priority
[PERMISSIONS] Permissions that only allow certain values to be set with certain flags
Expand Down Expand Up @@ -108,6 +111,9 @@ the internal states and then starting the animation backup on the frame it stopp
* ~~An animation can only be paused if the current status is a played status~~
* ~~In the frame info view if there are contents show the number of not air blocks~~
* ~~In the animation info view add a line for the volume of the master subspace (no longer think I want to do this)~~
* [BUGFIX] ~~Tile entities aren't un-serialized correctly~~
#### Matt Notes
* Pausing the the animation should stop the animation on the given frame,

## Animations to show off
* Door opening
Expand Down
15 changes: 12 additions & 3 deletions build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,8 @@ sourceCompatibility = 1.8



project.ext.versionno = '0.1.1'
project.ext.versionno = '0.2.1'
project.ext.versionending = '-SNAPSHOT'
project.ext.buildno = '0'

task setBuildNum {
Expand All @@ -27,7 +28,7 @@ task setBuildNum {
setBuildNum

project.ext.minecraftversion = '1.11.2'
project.ext.spongeapiversion = '6.1'
project.ext.spongeapiversion = '6.1.0'
description = 'Animations - Allowing the creation of frame based animations.'
ext.url = 'https://github.com/TheCahyag/MinecraftAnimation'

Expand All @@ -41,7 +42,7 @@ task incrementBuildNum {
}

allprojects {
version = rootProject.minecraftversion + "-" + rootProject.versionno + "." + rootProject.buildno
version = rootProject.minecraftversion + "-" + rootProject.versionno + "." + rootProject.buildno + rootProject.versionending

incrementBuildNum

Expand Down Expand Up @@ -75,4 +76,12 @@ blossom {

replaceToken '@description@', project.description, location
replaceToken '@url@', project.url, location

location = 'src/main/resources/mcmod.info'

replaceToken '@name@', project.name, location
replaceToken '@version@', project.version, location

replaceToken '@description@', project.description, location
replaceToken '@url@', project.url, location
}
13 changes: 13 additions & 0 deletions description.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
# Animations

Animations is a Sponge plugin that allows for the creation of frame-based animations. Animations was inspired by [VoxelTronix](https://www.youtube.com/watch?annotation_id=annotation_683155&feature=iv&src_vid=UW54ks4ttIo&v=Y06Xgk2YI0I).
### Quick Links
[Basic Usage](https://github.com/TheCahyag/MinecraftAnimation/wiki/Basic-Usage) | [Commands](https://github.com/TheCahyag/MinecraftAnimation/wiki/Command-List) | [Permissions](https://github.com/TheCahyag/MinecraftAnimation/wiki/Permissions)
### Examples:
https://i.imgur.com/xapoJqA.mp4
or
https://imgur.com/Shdtj1N

**At the moment the plugin has only been tested for servers running API 6.0 and 6.1.** This should soon be updated to API 7.

See the [basic usage guide](https://github.com/TheCahyag/MinecraftAnimation/wiki/Basic-Usage) on the [wiki](https://github.com/TheCahyag/MinecraftAnimation/wiki).
24 changes: 17 additions & 7 deletions src/main/java/com/servegame/bl4de/Animation/AnimationPlugin.java
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
import com.servegame.bl4de.Animation.controller.AnimationController;
import com.servegame.bl4de.Animation.data.SQLManager;
import com.servegame.bl4de.Animation.task.TaskManager;
import com.servegame.bl4de.Animation.data.DatabaseSchemaUpdates;
import com.servegame.bl4de.Animation.util.Resource;
import com.servegame.bl4de.Animation.util.Util;
import org.slf4j.Logger;
Expand Down Expand Up @@ -35,8 +36,8 @@ public class AnimationPlugin {
@Inject
private Game game;

private final String CONFIG_DIR = "./config/animation";
private final String ANIMATION_DATA_DIR = CONFIG_DIR + "/animations";
public final String CONFIG_DIR = "./config/animation";
public final String ANIMATION_DATA_DIR = CONFIG_DIR + "/animation";

private boolean debug;

Expand Down Expand Up @@ -75,18 +76,27 @@ public void onInit(GameInitializationEvent event){

@Listener
public void onLoad(GameLoadCompleteEvent event){
instance = this;
plugin = Sponge.getPluginManager().getPlugin(Resource.ID).get();
taskManager = new TaskManager();
logger.info("Animation has loaded.");
}

@Listener
public void onStop(GameStoppingEvent event){
logger.info("Stopping animations...");
AnimationController.stopAllAnimations();
public void onServerStart(GameStartingServerEvent event){
logger.info("Checking database structure...");
if (DatabaseSchemaUpdates.checkForVersionOne()){
logger.info("...Old database structure found, converting animations.");
DatabaseSchemaUpdates.convertVersionOneToVersionTwo();
} else {
logger.info("...database is up to date, no action needed.");
}
}

@Listener
public void onMessage(MessageEvent event){

public void onStop(GameStoppingEvent event){
logger.info("Stopping animations...");
AnimationController.stopAllAnimations();
}

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,8 @@
import com.servegame.bl4de.Animation.command.animation.InfoAnimation;
import com.servegame.bl4de.Animation.command.animation.SetAnimation;
import com.servegame.bl4de.Animation.command.frame.*;
import com.servegame.bl4de.Animation.model.Animation;
import com.servegame.bl4de.Animation.controller.AnimationController;
import com.servegame.bl4de.Animation.model.Animation;
import com.servegame.bl4de.Animation.util.TextResponses;
import org.spongepowered.api.command.CommandException;
import org.spongepowered.api.command.CommandResult;
Expand Down Expand Up @@ -42,7 +42,7 @@ public CommandResult execute(CommandSource src, CommandContext args) throws Comm
return CommandResult.success();
}
String animationName = animationNameOptional.get();
Optional<Animation> animationOptional = AnimationController.getAnimation(animationName, player.getUniqueId());
Optional<Animation> animationOptional = AnimationController.getBareAnimation(animationName, player.getUniqueId());
if (!animationOptional.isPresent()){
// Animation wasn't found
player.sendMessage(TextResponses.ANIMATION_NOT_FOUND_ERROR);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ public CommandResult execute(CommandSource src, CommandContext args) throws Comm
/animate stop <name>
/animate list
/animate <name> info
/animate <name> set <pos1|pos2> -f
/animate <name> frame create <name> -h
/animate <name> frame delete_frame <name|num> -f
/animate <name> frame display <name|num>
Expand Down Expand Up @@ -80,7 +81,7 @@ public CommandResult execute(CommandSource src, CommandContext args) throws Comm
Util.NAME_COLOR, " <name>",
Util.ACTION_COLOR, " set",
Util.PRIMARY_COLOR, " <pos1|pos2> ",
Util.FLAG_COLOR, "[-f]\n"))
Util.FLAG_COLOR, "-f\n"))
.append(Text.of(TextColors.WHITE, "/",
Util.PRIMARY_COLOR, "animate",
Util.NAME_COLOR, " <name>",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ public CommandResult execute(CommandSource src, CommandContext args) throws Comm
int animationsToList = animationsByOwner.size() > 10 ? 10 : animationsByOwner.size();
for (int i = 0; i < animationsToList; i++) {
// Add all animations that are owned into a Text object
Optional<Animation> optionalAnimation = AnimationController.getAnimation(animationsByOwner.get(i), player.getUniqueId());
Optional<Animation> optionalAnimation = AnimationController.getBareAnimation(animationsByOwner.get(i), player.getUniqueId());
if (!optionalAnimation.isPresent()){
// There are no animations to display
if (AnimationPlugin.instance.isDebug()){
Expand Down Expand Up @@ -87,7 +87,7 @@ public CommandResult execute(CommandSource src, CommandContext args) throws Comm
}
if (!displayedAAnimation){
// There were animations to display but weren't
player.sendMessage(Text.of(PRIMARY_COLOR, "There were no animations displayed."));
player.sendMessage(Text.of(PRIMARY_COLOR, "No animations were displayed."));
}
return CommandResult.success();
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ public CommandResult execute(CommandSource src, CommandContext args) throws Comm
player.sendMessage(TextResponses.ANIMATION_NOT_SPECIFIED_ERROR);
return CommandResult.empty();
}
Optional<Animation> animationOptional = AnimationController.getAnimation(animationNameOptional.get(), player.getUniqueId());
Optional<Animation> animationOptional = AnimationController.getBareAnimation(animationNameOptional.get(), player.getUniqueId());
if (!animationOptional.isPresent()){
player.sendMessage(TextResponses.ANIMATION_NOT_FOUND_ERROR);
return CommandResult.success();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,12 @@ public CommandResult execute(CommandSource src, CommandContext args) throws Comm
}
Animation animation = animationOptional.get();

if (!animation.isInitialized()){
// Animation is not initialized
player.sendMessage(TextResponses.ANIMATION_NOT_INITIALIZED_ERROR);
return CommandResult.success();
}

if (animation.getStatus() == Animation.Status.RUNNING){
// Animation is already running
player.sendMessage(TextResponses.ANIMATION_ALREADY_RUNNING);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ public CommandResult execute(CommandSource src, CommandContext args) throws Comm
player.sendMessage(TextResponses.ANIMATION_NOT_SPECIFIED_ERROR);
return CommandResult.empty();
}
Optional<Animation> animationOptional = AnimationController.getAnimation(animationNameOptional.get(), player.getUniqueId());
Optional<Animation> animationOptional = AnimationController.getBareAnimation(animationNameOptional.get(), player.getUniqueId());
if (!animationOptional.isPresent()){
player.sendMessage(TextResponses.ANIMATION_NOT_FOUND_ERROR);
return CommandResult.success();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ public AnimationElement(Text key, Animation animation){

@Nullable
@Override
protected Object parseValue(CommandSource source, CommandArgs args) throws ArgumentParseException {
protected Optional<Animation> parseValue(CommandSource source, CommandArgs args) throws ArgumentParseException {
return null;
}

Expand Down
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
package com.servegame.bl4de.Animation.command.frame;

import com.servegame.bl4de.Animation.controller.AnimationController;
import com.servegame.bl4de.Animation.exception.UninitializedException;
import com.servegame.bl4de.Animation.model.Animation;
import com.servegame.bl4de.Animation.model.Frame;
import com.servegame.bl4de.Animation.controller.AnimationController;
import com.servegame.bl4de.Animation.util.TextResponses;
import org.spongepowered.api.command.CommandException;
import org.spongepowered.api.command.CommandResult;
Expand All @@ -13,10 +13,10 @@
import org.spongepowered.api.entity.living.player.Player;
import org.spongepowered.api.text.Text;

import static com.servegame.bl4de.Animation.util.Util.*;

import java.util.Optional;

import static com.servegame.bl4de.Animation.util.Util.*;

/**
* File: CreateFrame.java
*
Expand Down
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
package com.servegame.bl4de.Animation.command.frame;

import com.servegame.bl4de.Animation.controller.AnimationController;
import com.servegame.bl4de.Animation.model.Animation;
import com.servegame.bl4de.Animation.model.Frame;
import com.servegame.bl4de.Animation.controller.AnimationController;
import com.servegame.bl4de.Animation.util.TextResponses;
import org.apache.commons.lang3.StringUtils;
import org.spongepowered.api.command.CommandException;
Expand All @@ -14,10 +14,10 @@
import org.spongepowered.api.text.Text;
import org.spongepowered.api.text.action.TextActions;

import static com.servegame.bl4de.Animation.util.Util.*;

import java.util.Optional;

import static com.servegame.bl4de.Animation.util.Util.*;

/**
* File: DeleteFrame.java
*
Expand Down Expand Up @@ -55,8 +55,7 @@ public CommandResult execute(CommandSource src, CommandContext args) throws Comm
Optional<Frame> frameOptional;
if (StringUtils.isNumeric(frameName)){
// They gave the frame number
Integer frameNum = Integer.valueOf(frameName);
frameOptional = this.animation.getFrame(frameNum);
frameOptional = this.animation.getFrame(Integer.valueOf(frameName));
} else {
// They gave the frame name
frameOptional = this.animation.getFrame(frameName);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -52,10 +52,10 @@ public CommandResult execute(CommandSource src, CommandContext args) throws Comm

if (isNumeric(frameName)){
// User specified a frame number 0, 1, ..., n
frameOptional = this.animation.getFrame(Integer.parseInt(frameName));
frameOptional = FrameController.getFrameWithContents(this.animation, Integer.parseInt(frameName));
} else {
// User specified a frame name
frameOptional = this.animation.getFrame(frameName);
frameOptional = FrameController.getFrameWithContents(this.animation, frameName);
}

if (!frameOptional.isPresent()){
Expand All @@ -67,6 +67,12 @@ public CommandResult execute(CommandSource src, CommandContext args) throws Comm

Frame frame = frameOptional.get();

if (!frame.getContents().isPresent()) {
// The frame has no contents
player.sendMessage(TextResponses.FRAME_HAS_NO_CONTENT);
return CommandResult.success();
}

if (FrameController.displayContents(frame)){
Text message = Text.of(
PRIMARY_COLOR, "Frame '",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -54,10 +54,10 @@ public CommandResult execute(CommandSource src, CommandContext args) throws Comm

if (isNumeric(frameName)){
// User specified a frame number 0, 1, ..., n
frameOptional = this.animation.getFrame(Integer.parseInt(frameName));
frameOptional = FrameController.getFrameWithContents(this.animation, Integer.parseInt(frameName));
} else {
// User specified a frame name
frameOptional = this.animation.getFrame(frameName);
frameOptional = FrameController.getFrameWithContents(this.animation, frameName);
}

if (!frameOptional.isPresent()){
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -50,10 +50,10 @@ public CommandResult execute(CommandSource src, CommandContext args) throws Comm

if (isNumeric(frameName)){
// User specified a frame number 0, 1, ..., n
frameOptional = this.animation.getFrame(Integer.parseInt(frameName));
frameOptional = FrameController.getFrameWithContents(this.animation, Integer.parseInt(frameName));
} else {
// User specified a frame name
frameOptional = this.animation.getFrame(frameName);
frameOptional = FrameController.getFrameWithContents(this.animation, frameName);
}

if (!frameOptional.isPresent()){
Expand Down
Loading

0 comments on commit 8f02b51

Please sign in to comment.