Skip to content

Commit 95588b2

Browse files
committed
Add heroes support
1 parent 9a4cfca commit 95588b2

File tree

5 files changed

+146
-4
lines changed

5 files changed

+146
-4
lines changed

base/pom.xml

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -61,5 +61,12 @@
6161
<scope>compile</scope>
6262
<optional>true</optional>
6363
</dependency>
64+
<dependency>
65+
<groupId>net.techcable.spawnshield</groupId>
66+
<artifactId>heroes</artifactId>
67+
<version>${project.parent.version}</version>
68+
<scope>compile</scope>
69+
<optional>true</optional>
70+
</dependency>
6471
</dependencies>
6572
</project>

combat-tag-plus/pom.xml

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,4 +25,10 @@
2525
</dependency>
2626
</dependencies>
2727

28+
<repositories>
29+
<repository>
30+
<id>minelink-repo</id>
31+
<url>http://repo.minelink.net/content/groups/public/</url>
32+
</repository>
33+
</repositories>
2834
</project>

heroes/pom.xml

Lines changed: 45 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,45 @@
1+
<?xml version="1.0" encoding="UTF-8"?>
2+
<project xmlns="http://maven.apache.org/POM/4.0.0"
3+
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
4+
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
5+
<modelVersion>4.0.0</modelVersion>
6+
<parent>
7+
<artifactId>parent</artifactId>
8+
<groupId>net.techcable.spawnshield</groupId>
9+
<version>1.2.1-SNAPSHOT</version>
10+
</parent>
11+
<artifactId>heroes</artifactId>
12+
13+
<dependencies>
14+
<dependency>
15+
<groupId>net.techcable.spawnshield</groupId>
16+
<artifactId>api</artifactId>
17+
<version>${parent.version}</version>
18+
<scope>provided</scope>
19+
</dependency>
20+
<dependency>
21+
<groupId>com.herocraftonline.heroes</groupId>
22+
<artifactId>Heroes</artifactId>
23+
<version>1.5.5</version>
24+
<scope>provided</scope>
25+
<exclusions>
26+
<!-- Its all broken so bad -->
27+
<exclusion>
28+
<groupId>org.spigotmc</groupId>
29+
<artifactId>spigot</artifactId>
30+
</exclusion>
31+
<exclusion>
32+
<groupId>net.milkbowl.vault</groupId>
33+
<artifactId>Vault</artifactId>
34+
</exclusion>
35+
</exclusions>
36+
</dependency>
37+
</dependencies>
38+
39+
<repositories>
40+
<repository>
41+
<id>yeti-repo</id>
42+
<url>http://nexus.theyeticave.net/content/repositories/pub_releases/</url>
43+
</repository>
44+
</repositories>
45+
</project>
Lines changed: 87 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,87 @@
1+
/**
2+
* The MIT License
3+
* Copyright (c) 2015 Techcable
4+
*
5+
* Permission is hereby granted, free of charge, to any person obtaining a copy
6+
* of this software and associated documentation files (the "Software"), to deal
7+
* in the Software without restriction, including without limitation the rights
8+
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9+
* copies of the Software, and to permit persons to whom the Software is
10+
* furnished to do so, subject to the following conditions:
11+
*
12+
* The above copyright notice and this permission notice shall be included in
13+
* all copies or substantial portions of the Software.
14+
*
15+
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16+
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17+
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18+
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19+
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20+
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
21+
* THE SOFTWARE.
22+
*/
23+
package net.techcable.spawnshield.combattag.heroes;
24+
25+
import lombok.*;
26+
27+
import com.herocraftonline.heroes.Heroes;
28+
import com.herocraftonline.heroes.characters.effects.CombatEffect;
29+
30+
import net.techcable.spawnshield.combattag.CombatTagPlugin;
31+
32+
import org.bukkit.Bukkit;
33+
import org.bukkit.entity.Entity;
34+
import org.bukkit.entity.Player;
35+
import org.bukkit.plugin.Plugin;
36+
37+
public class HeroesSupport implements CombatTagPlugin {
38+
public static final String PLUGIN_NAME = "Heroes";
39+
@Getter
40+
private final Heroes plugin;
41+
42+
public HeroesSupport() {
43+
Plugin rawPlugin = Bukkit.getPluginManager().getPlugin(PLUGIN_NAME);
44+
this.plugin = rawPlugin instanceof Heroes ? (Heroes) rawPlugin : null;
45+
}
46+
47+
@Override
48+
public boolean isTagged(Player player) {
49+
assertInstalled();
50+
return plugin.getCharacterManager().getHero(player).isInCombat();
51+
}
52+
53+
@Override
54+
public long getRemainingTagTime(Player player) {
55+
assertInstalled();
56+
long time = plugin.getCharacterManager().getHero(player).getCombatEffect().getTimeLeft();
57+
if (time <= 0) return -1;
58+
return time;
59+
}
60+
61+
@Override
62+
public boolean isNPC(Entity entity) {
63+
assertInstalled();
64+
return false;
65+
}
66+
67+
@Override
68+
public void tag(Player player) {
69+
assertInstalled();
70+
throw new UnsupportedOperationException();
71+
}
72+
73+
@Override
74+
public void unTag(Player player) {
75+
assertInstalled();
76+
plugin.getCharacterManager().getHero(player).leaveCombat(CombatEffect.LeaveCombatReason.CUSTOM);
77+
}
78+
79+
@Override
80+
public boolean isInstalled() {
81+
return plugin != null;
82+
}
83+
84+
private void assertInstalled() {
85+
if (!isInstalled()) throw new UnsupportedOperationException("Not installed");
86+
}
87+
}

pom.xml

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -19,10 +19,6 @@
1919
<id>techcable-repo</id>
2020
<url>https://repo.techcable.net/content/groups/public/</url>
2121
</repository>
22-
<repository>
23-
<id>minelink-repo</id>
24-
<url>http://repo.minelink.net/content/groups/public/</url>
25-
</repository>
2622
<repository>
2723
<id>oss-repo</id>
2824
<url>https://oss.sonatype.org/content/groups/public/</url>
@@ -44,6 +40,7 @@
4440
<module>combat-tag</module>
4541
<module>combat-tag-plus</module>
4642
<module>pvp-manager</module>
43+
<module>heroes</module>
4744
</modules>
4845
<dependencies>
4946
<dependency>

0 commit comments

Comments
 (0)