-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathindex.html
More file actions
150 lines (116 loc) · 6.33 KB
/
index.html
File metadata and controls
150 lines (116 loc) · 6.33 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
<!DOCTYPE html>
<html lang="en">
<head>
<title>Scribe</title>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1">
<meta content="Scribe" property="og:title">
<meta content="A MagicSpells source interpreter by Iniquit" property="og:description">
<meta content='img/hat.svg' property='og:image'>
<link rel="icon" type="image/svg" href="img/hat.svg">
<link rel="stylesheet" href="css/normalize.css">
<link href="https://fonts.googleapis.com/css?family=Roboto&display=swap" rel="stylesheet">
<link rel="stylesheet" href="css/styles.css">
</head>
<body>
<div class="wrapper" style="flex: 5">
<div class="content">
<p><span style="font-size: 1.5em">Scribe.</span> A <a href="https://github.com/TheComputerGeek2/MagicSpells" target="_blank">MagicSpells</a> sourcecode intrepreter by <a href="https://github.com/Iniquit" target="_blank">Iniquit<img src="img/ext.png" style="max-height: 12px;display: inline-block;"></a> that reads <a href="https://github.com/TheComputerGeek2/MagicSpells/tree/4.0/core/src/main/java/com/nisovin/magicspells/spells" target="_blank">MS 4.0+<img src="img/ext.png" style="max-height: 12px;display: inline-block;"></a> spell java files using regex to generate default spell config YAML. </p>
<p class="warn">⚠️ This utility is experimental. Review your config manually before requesting support.</p>
<div class="aligner">
<h2>Source</h2><span> (Paste the raw source of a MagicSpells spell.java file into this field)</span>
</div>
<form>
<textarea class="test" onchange="doMainLoop()" onblur="doMainLoop()" onclick="doMainLoop()"
placeholder="Paste the raw source of a MagicSpells spell.java file here.">
package com.nisovin.magicspells.spells.targeted;
import org.bukkit.entity.LivingEntity;
import org.bukkit.event.entity.EntityRegainHealthEvent.RegainReason;
import com.nisovin.magicspells.util.Util;
import com.nisovin.magicspells.util.TargetInfo;
import com.nisovin.magicspells.util.MagicConfig;
import com.nisovin.magicspells.spells.TargetedSpell;
import com.nisovin.magicspells.util.compat.EventUtil;
import com.nisovin.magicspells.util.ValidTargetChecker;
import com.nisovin.magicspells.spells.TargetedEntitySpell;
import com.nisovin.magicspells.spelleffects.EffectPosition;
import com.nisovin.magicspells.events.MagicSpellsEntityRegainHealthEvent;
public class HealSpell extends TargetedSpell implements TargetedEntitySpell {
private double healAmount;
private boolean checkPlugins;
private boolean cancelIfFull;
private String strMaxHealth;
private ValidTargetChecker checker;
public HealSpell(MagicConfig config, String spellName) {
super(config, spellName);
healAmount = getConfigFloat("heal-amount", 10);
checkPlugins = getConfigBoolean("check-plugins", true);
cancelIfFull = getConfigBoolean("cancel-if-full", true);
strMaxHealth = getConfigString("str-max-health", "%t is already at max health.");
checker = (LivingEntity entity) -> entity.getHealth() < Util.getMaxHealth(entity);
}
@Override
public PostCastAction castSpell(LivingEntity livingEntity, SpellCastState state, float power, String[] args) {
if (state == SpellCastState.NORMAL) {
TargetInfo<LivingEntity> targetInfo = getTargetedEntity(livingEntity, power, checker);
if (targetInfo == null) return noTarget(livingEntity);
LivingEntity target = targetInfo.getTarget();
power = targetInfo.getPower();
if (cancelIfFull && target.getHealth() == Util.getMaxHealth(target)) return noTarget(livingEntity, formatMessage(strMaxHealth, "%t", getTargetName(target)));
boolean healed = heal(livingEntity, target, power);
if (!healed) return noTarget(livingEntity);
sendMessages(livingEntity, target);
return PostCastAction.NO_MESSAGES;
}
return PostCastAction.HANDLE_NORMALLY;
}
@Override
public boolean castAtEntity(LivingEntity caster, LivingEntity target, float power) {
if (validTargetList.canTarget(caster, target) && target.getHealth() < Util.getMaxHealth(target)) return heal(caster, target, power);
return false;
}
@Override
public boolean castAtEntity(LivingEntity target, float power) {
if (validTargetList.canTarget(target) && target.getHealth() < Util.getMaxHealth(target)) return heal(null, target, power);
return false;
}
@Override
public ValidTargetChecker getValidTargetChecker() {
return checker;
}
private boolean heal(LivingEntity livingEntity, LivingEntity target, float power) {
double health = target.getHealth();
double amt = healAmount * power;
if (checkPlugins) {
MagicSpellsEntityRegainHealthEvent evt = new MagicSpellsEntityRegainHealthEvent(target, amt, RegainReason.CUSTOM);
EventUtil.call(evt);
if (evt.isCancelled()) return false;
amt = evt.getAmount();
}
health += amt;
if (health > Util.getMaxHealth(target)) health = Util.getMaxHealth(target);
target.setHealth(health);
if (livingEntity == null) playSpellEffects(EffectPosition.TARGET, target);
else playSpellEffects(livingEntity, target);
return true;
}
}
</textarea>
</form>
<h2>Result </h2><span class="configcount">test</span>
<div>
<pre id="output" class="output"></pre>
<button class="btn" data-clipboard-target="#output" style="cursor: pointer; font-size: 1.2em;">Copy</button>
</div>
<div>
<h2>Options:</h2><br>
<input style="cursor: pointer;" type="checkbox" id="optionShowValueTypes" onchange="doMainLoop()">
<label style="cursor: pointer;" for="optionShowValueTypes">Include the expected value types of config options</label>
</div>
</div>
</div>
</body>
<script type="text/javascript" src="js/script.js"></script>
<script type="text/javascript" src="js/clipboard.min.js"></script>
<script type="text/javascript">new ClipboardJS('.btn');</script>
</html>