-
Notifications
You must be signed in to change notification settings - Fork 9
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
Showing
10 changed files
with
450 additions
and
2 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
23 changes: 23 additions & 0 deletions
23
Implementations/Spigot/src/main/java/cz/neumimto/rpg/spigot/bridges/denizen/DenizenHook.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,23 @@ | ||
package cz.neumimto.rpg.spigot.bridges.denizen; | ||
|
||
import com.denizenscript.denizen.events.entity.EntityKilledScriptEvent; | ||
import com.denizenscript.denizencore.events.ScriptEvent; | ||
import com.denizenscript.denizencore.objects.ObjectFetcher; | ||
import cz.neumimto.rpg.common.skills.SkillConfigLoader; | ||
import cz.neumimto.rpg.common.skills.SkillConfigLoaders; | ||
import cz.neumimto.rpg.spigot.bridges.denizen.tags.CharacterTag; | ||
import cz.neumimto.rpg.spigot.bridges.denizen.tags.SkillContextTag; | ||
import org.bukkit.plugin.Plugin; | ||
|
||
public class DenizenHook { | ||
|
||
public static SkillConfigLoader DENIZEN_SCRIPT = new SkillConfigLoader("denizen", DenizenScriptSkillWrapper.class); | ||
|
||
public void init(Plugin plugin) { | ||
SkillConfigLoaders.register(DENIZEN_SCRIPT); | ||
ObjectFetcher.registerWithObjectFetcher(CharacterTag.class, CharacterTag.tagProcessor); // char@ | ||
ObjectFetcher.registerWithObjectFetcher(SkillContextTag.class, SkillContextTag.tagProcessor); // skillcontext@ | ||
ScriptEvent.registerScriptEvent(EntityKilledScriptEvent.class); | ||
} | ||
|
||
} |
51 changes: 51 additions & 0 deletions
51
...pigot/src/main/java/cz/neumimto/rpg/spigot/bridges/denizen/DenizenScriptSkillWrapper.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,51 @@ | ||
package cz.neumimto.rpg.spigot.bridges.denizen; | ||
|
||
import cz.neumimto.rpg.common.ResourceLoader; | ||
import cz.neumimto.rpg.common.skills.PlayerSkillContext; | ||
import cz.neumimto.rpg.common.skills.SkillData; | ||
import cz.neumimto.rpg.common.skills.SkillResult; | ||
import cz.neumimto.rpg.common.skills.types.ActiveSkill; | ||
import cz.neumimto.rpg.spigot.entities.players.ISpigotCharacter; | ||
|
||
public class DenizenScriptSkillWrapper extends ActiveSkill<ISpigotCharacter> { | ||
|
||
private String catalogId; | ||
|
||
public DenizenScriptSkillWrapper() { | ||
ResourceLoader.Skill sk = this.getClass().getAnnotation(ResourceLoader.Skill.class); | ||
if (sk != null) { | ||
catalogId = sk.value().toLowerCase(); | ||
} | ||
} | ||
|
||
@Override | ||
public SkillResult cast(ISpigotCharacter character, PlayerSkillContext info) { | ||
EntityCastSkillDenizenEvent event = new EntityCastSkillDenizenEvent(); | ||
event.character = character; | ||
event.context = info; | ||
event.fire(); | ||
return SkillResult.OK; | ||
} | ||
|
||
@Override | ||
public DenizenSkillData constructSkillData() { | ||
return new DenizenSkillData(getId()); | ||
} | ||
|
||
public static class DenizenSkillData extends SkillData { | ||
|
||
private String scriptPath; | ||
|
||
public DenizenSkillData(String skill) { | ||
super(skill); | ||
} | ||
|
||
public String getScriptPath() { | ||
return scriptPath; | ||
} | ||
|
||
public void setScriptPath(String scriptPath) { | ||
this.scriptPath = scriptPath; | ||
} | ||
} | ||
} |
77 changes: 77 additions & 0 deletions
77
...got/src/main/java/cz/neumimto/rpg/spigot/bridges/denizen/EntityCastSkillDenizenEvent.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,77 @@ | ||
package cz.neumimto.rpg.spigot.bridges.denizen; | ||
|
||
import com.denizenscript.denizen.events.BukkitScriptEvent; | ||
import com.denizenscript.denizen.utilities.implementation.BukkitScriptEntryData; | ||
import com.denizenscript.denizencore.objects.ObjectTag; | ||
import com.denizenscript.denizencore.scripts.ScriptEntryData; | ||
import cz.neumimto.rpg.common.skills.PlayerSkillContext; | ||
import cz.neumimto.rpg.spigot.bridges.denizen.tags.CharacterTag; | ||
import cz.neumimto.rpg.spigot.bridges.denizen.tags.SkillContextTag; | ||
import cz.neumimto.rpg.spigot.entities.players.ISpigotCharacter; | ||
|
||
public class EntityCastSkillDenizenEvent extends BukkitScriptEvent { | ||
|
||
public ISpigotCharacter character; | ||
public PlayerSkillContext context; | ||
|
||
public static EntityCastSkillDenizenEvent instance; | ||
|
||
public EntityCastSkillDenizenEvent() { | ||
this.registerCouldMatcher("<entity> casts skill <'skill'>"); | ||
instance = this; | ||
} | ||
|
||
|
||
@Override | ||
public boolean matches(ScriptPath path) { | ||
String cmd = path.eventArgLowerAt(1); | ||
String arg0 = path.eventArgLowerAt(0); | ||
String arg2 = path.eventArgLowerAt(2); | ||
String arg3 = path.eventArgLowerAt(3); | ||
String attacker = cmd.equals("kills") ? arg0 : arg2.equals("by") ? arg3 : ""; | ||
String target = cmd.equals("kills") ? arg2 : arg0; | ||
|
||
// if (!attacker.isEmpty()) { | ||
// if (damager != null) { | ||
// if (!cause.asString().equals(attacker) && | ||
// !tryEntity(projectile, attacker) && !tryEntity(damager, attacker)) { | ||
// return false; | ||
// } | ||
// } | ||
// else if (!cause.asString().equals(attacker)) { | ||
// return false; | ||
// } | ||
// } | ||
|
||
// if (!tryEntity(entity, target)) { | ||
// return false; | ||
// } | ||
|
||
// if (!runInCheck(path, entity.getLocation())) { | ||
// return false; | ||
// } | ||
|
||
return super.matches(path); | ||
} | ||
|
||
@Override | ||
public String getName() { | ||
return "EntityCastsSkill"; | ||
} | ||
|
||
public ObjectTag getContext(String name) { | ||
switch (name) { | ||
case "caster": | ||
return new CharacterTag(character); | ||
case "skill_context": | ||
return new SkillContextTag(context, character); | ||
} | ||
return super.getContext(name); | ||
} | ||
|
||
public ScriptEntryData getScriptEntryData() { | ||
return new BukkitScriptEntryData(character.getPlayer()); | ||
} | ||
|
||
|
||
} |
89 changes: 89 additions & 0 deletions
89
...ations/Spigot/src/main/java/cz/neumimto/rpg/spigot/bridges/denizen/tags/CharacterTag.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,89 @@ | ||
package cz.neumimto.rpg.spigot.bridges.denizen.tags; | ||
|
||
import com.denizenscript.denizen.objects.EntityFormObject; | ||
import com.denizenscript.denizen.objects.EntityTag; | ||
import com.denizenscript.denizen.objects.PlayerTag; | ||
import com.denizenscript.denizencore.objects.Fetchable; | ||
import com.denizenscript.denizencore.objects.ObjectTag; | ||
import com.denizenscript.denizencore.tags.ObjectTagProcessor; | ||
import com.denizenscript.denizencore.tags.TagContext; | ||
import cz.neumimto.rpg.common.Rpg; | ||
import cz.neumimto.rpg.common.entity.players.IActiveCharacter; | ||
import org.bukkit.entity.Entity; | ||
import org.bukkit.entity.Player; | ||
|
||
import java.util.UUID; | ||
|
||
public class CharacterTag implements EntityFormObject { | ||
|
||
private IActiveCharacter character; | ||
private String prefix; | ||
|
||
public static ObjectTagProcessor<CharacterTag> tagProcessor = new ObjectTagProcessor<>(); | ||
|
||
public CharacterTag(IActiveCharacter character) { | ||
this.character = character; | ||
} | ||
|
||
public IActiveCharacter getCharacter() { | ||
return character; | ||
} | ||
|
||
public Player player() { | ||
return (Player) character.getEntity(); | ||
} | ||
|
||
@Override | ||
public EntityTag getDenizenEntity() { | ||
return new EntityTag((Entity) character.getEntity()); | ||
} | ||
|
||
@Override | ||
public String getPrefix() { | ||
return prefix; | ||
} | ||
|
||
@Override | ||
public boolean isUnique() { | ||
return true; | ||
} | ||
|
||
@Override | ||
public String getObjectType() { | ||
return "Character"; | ||
} | ||
|
||
@Override | ||
public String identify() { | ||
return "char@" + character.getUUID(); | ||
} | ||
|
||
@Fetchable("char") | ||
public static CharacterTag valueOf(String string, TagContext context) { | ||
if (string == null) { | ||
return null; | ||
} else { | ||
if (string.startsWith("char@")) { | ||
string = string.substring("char@".length()); | ||
UUID uuid = UUID.fromString(string); | ||
return new CharacterTag(Rpg.get().getCharacterService().getCharacter(uuid)); | ||
} | ||
} | ||
return null; | ||
} | ||
|
||
@Override | ||
public String identifySimple() { | ||
return this.identify(); | ||
} | ||
|
||
@Override | ||
public ObjectTag setPrefix(String s) { | ||
this.prefix = s; | ||
return this; | ||
} | ||
|
||
public static void registerTags() { | ||
tagProcessor.registerTag(PlayerTag.class, "player", (attribute, object) -> new PlayerTag(object.player())); | ||
} | ||
} |
Oops, something went wrong.