mirror of
https://github.com/taoneill/war.git
synced 2024-11-14 06:17:01 +01:00
Merge pull request #610 from cmastudios/colored-names
Add TagAPI support to War
This commit is contained in:
commit
e3e20fc704
10
war/pom.xml
10
war/pom.xml
@ -21,6 +21,10 @@
|
||||
<id>spout-repo</id>
|
||||
<url>http://repo.spout.org/</url>
|
||||
</repository>
|
||||
<repository>
|
||||
<id>tagapi-repo</id>
|
||||
<url>http://repo.kitteh.org/content/repositories/public/</url>
|
||||
</repository>
|
||||
</repositories>
|
||||
<issueManagement>
|
||||
<system>Github issues</system>
|
||||
@ -75,6 +79,12 @@
|
||||
<artifactId>bukkit</artifactId>
|
||||
<version>1.4.7-R1.0</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.kitteh</groupId>
|
||||
<artifactId>tagapi</artifactId>
|
||||
<version>2.0</version>
|
||||
<scope>compile</scope>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.mockito</groupId>
|
||||
<artifactId>mockito-all</artifactId>
|
||||
|
@ -26,6 +26,7 @@ import com.tommytony.war.utility.Direction;
|
||||
import com.tommytony.war.utility.SignHelper;
|
||||
import com.tommytony.war.volume.BlockInfo;
|
||||
import com.tommytony.war.volume.Volume;
|
||||
import org.kitteh.tag.TagAPI;
|
||||
|
||||
/**
|
||||
*
|
||||
@ -376,6 +377,9 @@ public class Team {
|
||||
|
||||
public void addPlayer(Player player) {
|
||||
this.players.add(player);
|
||||
if (War.war.isTagServer()) {
|
||||
TagAPI.refreshPlayer(player);
|
||||
}
|
||||
}
|
||||
|
||||
public List<Player> getPlayers() {
|
||||
@ -450,7 +454,9 @@ public class Team {
|
||||
t.teamcast("Cake " + ChatColor.GREEN + cake.getName() + ChatColor.WHITE + " was returned.");
|
||||
}
|
||||
}
|
||||
|
||||
if (War.war.isTagServer()) {
|
||||
TagAPI.refreshPlayer(thePlayer);
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
|
@ -39,6 +39,7 @@ import com.tommytony.war.event.WarBlockListener;
|
||||
import com.tommytony.war.event.WarEntityListener;
|
||||
import com.tommytony.war.event.WarPlayerListener;
|
||||
import com.tommytony.war.event.WarServerListener;
|
||||
import com.tommytony.war.event.WarTagListener;
|
||||
import com.tommytony.war.job.HelmetProtectionTask;
|
||||
import com.tommytony.war.job.SpoutFadeOutMessageJob;
|
||||
import com.tommytony.war.mapper.WarYmlMapper;
|
||||
@ -74,6 +75,7 @@ public class War extends JavaPlugin {
|
||||
private PluginDescriptionFile desc = null;
|
||||
private boolean loaded = false;
|
||||
private boolean isSpoutServer = false;
|
||||
private boolean tagServer = false;
|
||||
|
||||
// Zones and hub
|
||||
private List<Warzone> warzones = new ArrayList<Warzone>();
|
||||
@ -144,6 +146,15 @@ public class War extends JavaPlugin {
|
||||
pm.registerEvents(this.entityListener, this);
|
||||
pm.registerEvents(this.blockListener, this);
|
||||
pm.registerEvents(this.serverListener, this);
|
||||
if (pm.isPluginEnabled("TagAPI")) {
|
||||
try {
|
||||
Class.forName("org.kitteh.tag.TagAPI");
|
||||
pm.registerEvents(new WarTagListener(), this);
|
||||
this.tagServer = true;
|
||||
} catch (ClassNotFoundException e) {
|
||||
this.tagServer = false;
|
||||
}
|
||||
}
|
||||
|
||||
// Add defaults
|
||||
warConfig.put(WarConfig.BUILDINZONESONLY, false);
|
||||
@ -1211,4 +1222,8 @@ public class War extends JavaPlugin {
|
||||
public HubLobbyMaterials getWarhubMaterials() {
|
||||
return this.warhubMaterials;
|
||||
}
|
||||
|
||||
public boolean isTagServer() {
|
||||
return tagServer;
|
||||
}
|
||||
}
|
||||
|
@ -0,0 +1,19 @@
|
||||
package com.tommytony.war.event;
|
||||
|
||||
import com.tommytony.war.Team;
|
||||
import org.bukkit.ChatColor;
|
||||
import org.bukkit.event.EventHandler;
|
||||
import org.bukkit.event.EventPriority;
|
||||
import org.bukkit.event.Listener;
|
||||
import org.kitteh.tag.PlayerReceiveNameTagEvent;
|
||||
|
||||
public class WarTagListener implements Listener {
|
||||
@EventHandler(priority = EventPriority.HIGHEST)
|
||||
public void onNameTag(PlayerReceiveNameTagEvent event) {
|
||||
Team team = Team.getTeamByPlayerName(event.getNamedPlayer().getName());
|
||||
if (team != null) {
|
||||
ChatColor teamColor = team.getKind().getColor();
|
||||
event.setTag(teamColor + event.getNamedPlayer().getName());
|
||||
}
|
||||
}
|
||||
}
|
@ -4,7 +4,7 @@ description: Minecraft PVP arenas (called warzones) for a fast-paced and structu
|
||||
author: tommytony
|
||||
website: http://war.tommytony.com
|
||||
main: com.tommytony.war.War
|
||||
softdepend: [Spout]
|
||||
softdepend: [Spout, TagAPI]
|
||||
permissions:
|
||||
war.*:
|
||||
description: Full War permissions. Create and destroy warzones. Change War configuration.
|
||||
|
Loading…
Reference in New Issue
Block a user