DemigodsRPG / Demigods3

The (now defunct) Demigods RPG experience for survival/PvP Minecraft servers.
http://www.demigodsrpg.com/
MIT License
4 stars 2 forks source link

General API and Internal Code Unity #198

Open HmmmQuestionMark opened 10 years ago

HmmmQuestionMark commented 10 years ago

The plugin is a mess of different styles and different ideas on how to organize things and all of that jazz.

Along with reorganizing CensoredLib (before actual launch), it would make sense to unify the code-base under a single "style".

I'd vote for the way Bukkit does things, for the sake of making things familiar when working with APIs and when fixing bugs.

Examples:

Just like Bukkit does Bukkit.getServer(), we'd do Demigods.getServer().

i.e. Bukkit.getOnlinePlayers() => Demigods.getOnlinePlayers();

Demigods.getOnlineCharacters();
DemigodsServer server = Demigods.getServer();
DemigodsWorld world = server.getWorld("world");
for(DemigodsCharacter character : world.getOnlineCharacters()
{
    character.updateQuest(Quest.TEST_QUEST, QuestProgress.TEST); // just an example, nothing serious
}

Sometimes, for our own sanity, we'd have to break conventions for easy faux "casting" to our own objects.

DemigodsPlayer player = DemigodsPlayer.of(event.getPlayer);
DemigodsCharacter character = DemigodsCharacter.of(event.getPlayer);
character = player.getCharacter();
character.setInactive();
newCharacter = player.getCharacter("SamwiseGamgee");
newCharacter.setActive(); // automatically set all other character inactive? and do the below inventory stuff?
character.saveData();
player.setInventory(newCharacter.getInventory());

Collection<DemigodsCharacter> inactiveCharacters = DemigodsCharacter.inactive(event.getPlayer);
inactiveCharacters = player.getInactiveCharacters();
Collection<DemigodsPlayer> allPlayers = Demigods.getServer().getAllPlayers();
allPlayers

DemigodsLocation location = player.getLocation();
location = DemigodsLocation.of(event.getPlayer().getLocation());
location = DemigodsLocation.of(event.getPlayer());
Location bukkitLocation = location.getBukkitLocation();
bukkitLocation = player.getBukkitLocation();

I could probably go on forever, but I think you get the point.

This unified style of code would allow us to easily know where things are, easily fix bugs, and easily implement new features.

It would probably make it easier for developers to contribute to Demigods as well.

Now the Demigods is very close to Feature complete (for launch) we could easily keep the current features while doing this, and design the style around them.

Deities and the Mythos are easy, we won't have to change them much:

Deity deity = Demigods.getMythos().getDeity("Zeus"); // allow case insensitive?
Collection<Ability> abilities = deity.getAbilities();
PassiveAbility passiveAbility = (PassiveAbility) deity.getAbility("no fall damage"); 
AbilityScope[] scope = passiveAbility.getScopes(); // not grammatically correct but this is just an example.

That's all I got. Let me know what you think.

HmmmQuestionMark commented 10 years ago

I'm getting tired of my own refactors, and I tried to convince myself this wasn't needed, but it really is.

To be brutally honest, the code is a mess--it needs cleaning up--and this is the best way to do it.

HmmmQuestionMark commented 10 years ago

Just gonna make a list here of things we don't need to change for this issue (not counting simple renames or re-locations):

Things we only need to tweak a tiny bit:

Things we should touch:

Am I missing anything?


We should also take a look at what we really need from CensoredLib. At this point, it looks more and more like we actually don't most of it. We've slimmed down DG to the point where almost everything is accounted for except:

It might make sense to trim out the things we don't need in CLib, making it easier for us to manage it.

alexbennett commented 10 years ago

I'm getting tired of my own refactors

lol, join the club!

But I like this.

alexbennett commented 10 years ago

Seems like everything... I haven't looked at Demigods in so long that I wouldn't realize if something were missing to be honest... I'm in class at the moment. I'll take a closer look tonight.

HmmmQuestionMark commented 10 years ago

kk

Just updated a few comments I made. Heading to class for exam in a few, I'll talk to you later tonight if you're on.