Skip to content

Commit

Permalink
Create bindings to js via annotations
Browse files Browse the repository at this point in the history
  • Loading branch information
NeumimTo committed May 16, 2018
1 parent 2e29e36 commit 9784ed6
Show file tree
Hide file tree
Showing 41 changed files with 127 additions and 38 deletions.
7 changes: 6 additions & 1 deletion Plugin/src/main/java/cz/neumimto/rpg/ResourceLoader.java
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,8 @@
import cz.neumimto.rpg.players.properties.PropertyContainer;
import cz.neumimto.rpg.players.properties.PropertyService;
import cz.neumimto.rpg.players.properties.attributes.ICharacterAttribute;
import cz.neumimto.rpg.scripting.JSLoader;
import cz.neumimto.rpg.scripting.JsBinding;
import cz.neumimto.rpg.skills.ISkill;
import cz.neumimto.rpg.skills.SkillService;
import javassist.CannotCompileException;
Expand Down Expand Up @@ -216,11 +218,14 @@ public void loadClass(Class<?> clazz) throws IllegalAccessException, CannotCompi
if (clazz.isAnnotationPresent(Attribute.class)) {
propertyService.registerAttribute((ICharacterAttribute) clazz.newInstance());
}
if (clazz.isAnnotationPresent(JsBinding.class)) {
IoC.get().build(JSLoader.class).getDataToBind().put(clazz, clazz.getAnnotation(JsBinding.class).value());
}
//Effects
if (IEffect.class.isAssignableFrom(clazz)) {
ClassGenerator.Generate a = clazz.getAnnotation(ClassGenerator.Generate.class);
if (a != null) {
Class c = (Class<? extends IEffect>) clazz;
Class c = clazz;
IGlobalEffect iGlobalEffect = classGenerator.generateGlobalEffect(c);
if (iGlobalEffect == null) {
return;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,6 @@

package cz.neumimto.rpg.events;

import cz.neumimto.rpg.GlobalScope;
import cz.neumimto.rpg.NtRpgPlugin;
import org.spongepowered.api.event.Cancellable;
import org.spongepowered.api.event.cause.Cause;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,10 +1,11 @@
package cz.neumimto.rpg.events;

import cz.neumimto.rpg.players.IActiveCharacter;
import cz.neumimto.rpg.scripting.JsBinding;

/**
* Created by NeumimTo on 23.1.2016.
*/
@JsBinding(JsBinding.Type.CLASS)
public class CharacterAttributeChange extends CharacterEvent {
private final int attributechange;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,12 @@

import cz.neumimto.rpg.players.IActiveCharacter;
import cz.neumimto.rpg.players.groups.ConfigClass;
import cz.neumimto.rpg.scripting.JsBinding;

/**
* Created by ja on 29.4.2017.
*/
@JsBinding(JsBinding.Type.CLASS)
public class CharacterChangeClassEvent extends CharacterChangeGroupEvent {

private final int slot;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,12 @@

import cz.neumimto.rpg.players.IActiveCharacter;
import cz.neumimto.rpg.players.groups.PlayerGroup;
import cz.neumimto.rpg.scripting.JsBinding;

/**
* Created by NeumimTo on 29.4.2017.
*/
@JsBinding(JsBinding.Type.CLASS)
public class CharacterChangeGroupEvent extends CharacterEvent {
private final PlayerGroup _new;
private final PlayerGroup old;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,12 @@

import cz.neumimto.rpg.players.ExtendedNClass;
import cz.neumimto.rpg.players.IActiveCharacter;
import cz.neumimto.rpg.scripting.JsBinding;

/**
* Created by NeumimTo on 27.12.2015.
*/
@JsBinding(JsBinding.Type.CLASS)
public class CharacterGainedLevelEvent extends CharacterEvent {
private final ExtendedNClass aClass;
private final int level;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,12 @@

import cz.neumimto.rpg.IEntity;
import cz.neumimto.rpg.players.IActiveCharacter;
import cz.neumimto.rpg.scripting.JsBinding;

/**
* Created by NeumimTo on 17.6.2017.
*/

@JsBinding(JsBinding.Type.CLASS)
public class CharacterWeaponDamageEvent extends INEntityWeaponDamageEvent {


Expand Down
Original file line number Diff line number Diff line change
@@ -1,11 +1,13 @@
package cz.neumimto.rpg.events;

import cz.neumimto.rpg.players.IActiveCharacter;
import cz.neumimto.rpg.scripting.JsBinding;


/**
* Created by NeumimTo on 9.8.2015.
*/
@JsBinding(JsBinding.Type.CLASS)
public class ManaRegainEvent extends CancellableEvent {
private IActiveCharacter character;
private double newVal;
Expand Down

This file was deleted.

Original file line number Diff line number Diff line change
@@ -1,11 +1,13 @@
package cz.neumimto.rpg.events;

import cz.neumimto.rpg.IEntity;
import cz.neumimto.rpg.scripting.JsBinding;
import org.spongepowered.api.entity.projectile.Projectile;

/**
* Created by NeumimTo on 17.6.2017.
*/
@JsBinding(JsBinding.Type.CLASS)
public class ProjectileHitEvent extends CancellableEvent {

private IEntity shooter;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,12 +1,14 @@
package cz.neumimto.rpg.events;

import cz.neumimto.rpg.IEntity;
import cz.neumimto.rpg.scripting.JsBinding;
import cz.neumimto.rpg.skills.ISkill;
import org.spongepowered.api.event.cause.entity.damage.DamageType;

/**
* Created by NeumimTo on 18.6.2017.
*/
@JsBinding(JsBinding.Type.CLASS)
public class SkillDamageEvent extends INEntityDamageEvent {
ISkill skill;

Expand Down
Original file line number Diff line number Diff line change
@@ -1,12 +1,14 @@
package cz.neumimto.rpg.events;

import cz.neumimto.rpg.IEntity;
import cz.neumimto.rpg.scripting.JsBinding;
import cz.neumimto.rpg.skills.ISkill;
import org.spongepowered.api.event.cause.entity.damage.DamageType;

/**
* Created by ja on 18.6.2017.
*/
@JsBinding(JsBinding.Type.CLASS)
public class SkillDamageEventLate extends CancellableEvent {
IEntity caster;
IEntity target;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,11 +19,13 @@
package cz.neumimto.rpg.events.character;

import cz.neumimto.rpg.players.IActiveCharacter;
import cz.neumimto.rpg.scripting.JsBinding;
import org.spongepowered.api.entity.living.player.Player;

/**
* Created by NeumimTo on 13.3.2015.
*/
@JsBinding(JsBinding.Type.CLASS)
public class CharacterDamageEntityEvent extends CharacterEvent {
private Player damaged;
private double damage;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,17 +1,17 @@
package cz.neumimto.rpg.events.character;

import cz.neumimto.rpg.events.CancellableEvent;
import cz.neumimto.rpg.inventory.ConfigRPGItemType;
import cz.neumimto.rpg.players.IActiveCharacter;
import cz.neumimto.rpg.players.RPGItemWrapper;
import cz.neumimto.rpg.scripting.JsBinding;
import org.spongepowered.api.item.ItemType;

import java.util.Map;
import java.util.TreeSet;

/**
* Created by NeumimTo on 10.10.2015.
*/
@JsBinding(JsBinding.Type.CLASS)
public class CharacterWeaponUpdateEvent extends CancellableEvent {
private final IActiveCharacter character;
private final Map<ItemType, RPGItemWrapper> allowedArmor;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,11 +20,13 @@

import cz.neumimto.rpg.events.CancellableEvent;
import cz.neumimto.rpg.players.IActiveCharacter;
import cz.neumimto.rpg.scripting.JsBinding;


/**
* Created by NeumimTo on 9.8.2015.
*/
@JsBinding(JsBinding.Type.CLASS)
public class ManaRegainEvent extends CancellableEvent {
private IActiveCharacter character;
private double newVal;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,9 @@
package cz.neumimto.rpg.events.character;

import cz.neumimto.rpg.players.IActiveCharacter;
import cz.neumimto.rpg.scripting.JsBinding;

@JsBinding(JsBinding.Type.CLASS)
public class PlayerCombatEvent extends CharacterEvent {

private final cz.neumimto.rpg.players.IActiveCharacter target;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@
import cz.neumimto.rpg.NEventContextKeys;
import cz.neumimto.rpg.events.CancellableEvent;
import cz.neumimto.rpg.players.CharacterBase;
import cz.neumimto.rpg.scripting.JsBinding;
import org.spongepowered.api.event.cause.Cause;
import org.spongepowered.api.event.cause.EventContext;

Expand All @@ -30,6 +31,7 @@
/**
* Created by NeumimTo on 10.7.2015.
*/
@JsBinding(JsBinding.Type.CLASS)
public class PlayerDataPreloadComplete extends CancellableEvent {
private UUID player;
private List<CharacterBase> characterBases;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,10 +21,12 @@
import cz.neumimto.rpg.events.CancellableEvent;
import cz.neumimto.rpg.inventory.Weapon;
import cz.neumimto.rpg.players.IActiveCharacter;
import cz.neumimto.rpg.scripting.JsBinding;

/**
* Created by NeumimTo on 12.2.2015.
*/
@JsBinding(JsBinding.Type.CLASS)
public class WeaponEquipEvent extends CancellableEvent {
final IActiveCharacter player;
final Weapon newItem;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,11 +18,13 @@

package cz.neumimto.rpg.events.character;

import cz.neumimto.rpg.scripting.JsBinding;
import org.spongepowered.api.item.inventory.ItemStack;

/**
* Created by NeumimTo on 13.3.2015.
*/
@JsBinding(JsBinding.Type.CLASS)
public class WeaponSwitchEvent extends CharacterEvent {

public WeaponSwitchEvent(cz.neumimto.rpg.players.IActiveCharacter IActiveCharacter, ItemStack newWeapon) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,10 +21,12 @@
import cz.neumimto.rpg.events.CancellableEvent;
import cz.neumimto.rpg.players.IActiveCharacter;
import cz.neumimto.rpg.players.parties.Party;
import cz.neumimto.rpg.scripting.JsBinding;

/**
* Created by NeumimTo on 11.8.2015.
*/
@JsBinding(JsBinding.Type.CLASS)
public class PartyInviteEvent extends CancellableEvent {
private final Party party;
private IActiveCharacter character;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,10 +21,12 @@
import cz.neumimto.rpg.events.CancellableEvent;
import cz.neumimto.rpg.players.IActiveCharacter;
import cz.neumimto.rpg.players.parties.Party;
import cz.neumimto.rpg.scripting.JsBinding;

/**
* Created by ja on 2.9.2015.
*/
@JsBinding(JsBinding.Type.CLASS)
public class PartyJoinEvent extends CancellableEvent {
private final IActiveCharacter character;
private final Party party;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,10 +20,12 @@

import cz.neumimto.rpg.players.IActiveCharacter;
import cz.neumimto.rpg.players.parties.Party;
import cz.neumimto.rpg.scripting.JsBinding;

/**
* Created by ja on 2.9.2015.
*/
@JsBinding(JsBinding.Type.CLASS)
public class PartyKickEvent extends PartyLeaveEvent {

public PartyKickEvent(Party party, IActiveCharacter kicked) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,10 +21,12 @@
import cz.neumimto.rpg.events.CancellableEvent;
import cz.neumimto.rpg.players.IActiveCharacter;
import cz.neumimto.rpg.players.parties.Party;
import cz.neumimto.rpg.scripting.JsBinding;

/**
* Created by ja on 2.9.2015.
*/
@JsBinding(JsBinding.Type.CLASS)
public class PartyLeaveEvent extends CancellableEvent {
private Party party;
private IActiveCharacter leaver;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,9 +17,11 @@

import cz.neumimto.rpg.events.CancellableEvent;
import cz.neumimto.rpg.players.IActiveCharacter;
import cz.neumimto.rpg.scripting.JsBinding;
import cz.neumimto.rpg.skills.ISkill;
import org.spongepowered.api.entity.living.Living;

@JsBinding(JsBinding.Type.CLASS)
public class SkillFindTargetEvent extends CancellableEvent {
private IActiveCharacter character;
private Living target;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,10 +21,12 @@
import cz.neumimto.rpg.IEntity;
import cz.neumimto.rpg.effects.IEffectSourceProvider;
import cz.neumimto.rpg.events.CancellableEvent;
import cz.neumimto.rpg.scripting.JsBinding;

/**
* Created by NeumimTo on 7.8.2015.
*/
@JsBinding(JsBinding.Type.CLASS)
public class SkillHealEvent extends CancellableEvent {
private IEntity character;
private double amount;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,11 +20,13 @@

import cz.neumimto.rpg.events.CancellableEvent;
import cz.neumimto.rpg.players.IActiveCharacter;
import cz.neumimto.rpg.scripting.JsBinding;
import cz.neumimto.rpg.skills.ISkill;

/**
* Created by NeumimTo on 26.7.2015.
*/
@JsBinding(JsBinding.Type.CLASS)
public class SkillLearnEvent extends CancellableEvent {
IActiveCharacter character;
ISkill skill;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,10 +20,12 @@

import cz.neumimto.rpg.events.CancellableEvent;
import cz.neumimto.rpg.players.IActiveCharacter;
import cz.neumimto.rpg.scripting.JsBinding;

/**
* Created by NeumimTo on 7.8.2015.
*/
@JsBinding(JsBinding.Type.CLASS)
public class SkillPostUsageEvent extends CancellableEvent {
private IActiveCharacter character;
private double hpcost;
Expand Down
Loading

0 comments on commit 9784ed6

Please sign in to comment.