mirror of
https://github.com/cnaude/PurpleIRC-spigot.git
synced 2024-11-05 18:09:37 +01:00
Change the way we hook to Jobs.
This commit is contained in:
parent
3fea73a9ac
commit
9c5e2a2ab9
@ -133,13 +133,13 @@
|
|||||||
<dependency>
|
<dependency>
|
||||||
<groupId>org.bukkit</groupId>
|
<groupId>org.bukkit</groupId>
|
||||||
<artifactId>spigot-api</artifactId>
|
<artifactId>spigot-api</artifactId>
|
||||||
<version>1.8</version>
|
<version>1.8.3</version>
|
||||||
<scope>provided</scope>
|
<scope>provided</scope>
|
||||||
</dependency>
|
</dependency>
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>org.bukkit</groupId>
|
<groupId>org.bukkit</groupId>
|
||||||
<artifactId>spigot</artifactId>
|
<artifactId>spigot</artifactId>
|
||||||
<version>1.8</version>
|
<version>1.8.3</version>
|
||||||
<scope>provided</scope>
|
<scope>provided</scope>
|
||||||
</dependency>
|
</dependency>
|
||||||
<dependency>
|
<dependency>
|
||||||
@ -186,12 +186,6 @@
|
|||||||
<version>5.6.7</version>
|
<version>5.6.7</version>
|
||||||
<scope>compile</scope>
|
<scope>compile</scope>
|
||||||
</dependency>
|
</dependency>
|
||||||
<dependency>
|
|
||||||
<groupId>com.cnaude.mineversechat</groupId>
|
|
||||||
<artifactId>MineverseChat</artifactId>
|
|
||||||
<version>2.0</version>
|
|
||||||
<scope>compile</scope>
|
|
||||||
</dependency>
|
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>com.cnaude.jobs</groupId>
|
<groupId>com.cnaude.jobs</groupId>
|
||||||
<artifactId>Jobs</artifactId>
|
<artifactId>Jobs</artifactId>
|
||||||
@ -362,7 +356,7 @@
|
|||||||
<properties>
|
<properties>
|
||||||
<build.number>SNAPSHOT</build.number>
|
<build.number>SNAPSHOT</build.number>
|
||||||
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
|
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
|
||||||
<bukkit.version>1.8</bukkit.version>
|
<bukkit.version>1.8.3</bukkit.version>
|
||||||
</properties>
|
</properties>
|
||||||
</project>
|
</project>
|
||||||
|
|
||||||
|
@ -18,9 +18,6 @@ package com.cnaude.purpleirc.Hooks;
|
|||||||
|
|
||||||
import com.cnaude.purpleirc.TemplateName;
|
import com.cnaude.purpleirc.TemplateName;
|
||||||
import com.cnaude.purpleirc.PurpleIRC;
|
import com.cnaude.purpleirc.PurpleIRC;
|
||||||
import com.gamingmesh.jobs.Jobs;
|
|
||||||
import com.gamingmesh.jobs.PlayerManager;
|
|
||||||
import com.gamingmesh.jobs.container.Job;
|
|
||||||
import com.google.common.base.Joiner;
|
import com.google.common.base.Joiner;
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import org.bukkit.entity.Player;
|
import org.bukkit.entity.Player;
|
||||||
@ -32,7 +29,6 @@ import org.bukkit.entity.Player;
|
|||||||
public class JobsHook {
|
public class JobsHook {
|
||||||
|
|
||||||
private final PurpleIRC plugin;
|
private final PurpleIRC plugin;
|
||||||
private PlayerManager playerManager = null;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
*
|
*
|
||||||
@ -40,32 +36,49 @@ public class JobsHook {
|
|||||||
*/
|
*/
|
||||||
public JobsHook(PurpleIRC plugin) {
|
public JobsHook(PurpleIRC plugin) {
|
||||||
this.plugin = plugin;
|
this.plugin = plugin;
|
||||||
try {
|
|
||||||
this.playerManager = Jobs.getPlayerManager();
|
|
||||||
} catch (Exception ex) {
|
|
||||||
plugin.logError("Jobs: " + ex.getMessage());
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public String getPlayerJob(Player player, boolean shortName) {
|
public String getPlayerJob(Player player, boolean shortName) {
|
||||||
if (playerManager == null) {
|
|
||||||
return "";
|
|
||||||
}
|
|
||||||
if (player != null) {
|
if (player != null) {
|
||||||
ArrayList<String> j = new ArrayList<>();
|
try {
|
||||||
if (plugin.isPluginEnabled("Jobs")) {
|
if (plugin.isPluginEnabled("Jobs")) {
|
||||||
for (Job job : Jobs.getJobs()) {
|
ArrayList<String> j = new ArrayList<>();
|
||||||
if (playerManager.getJobsPlayer(player).isInJob(job)) {
|
String m = plugin.getServer().getPluginManager().getPlugin("Jobs").getDescription().getMain();
|
||||||
if (shortName) {
|
if (m.contains("me.zford")) {
|
||||||
j.add(job.getShortName());
|
me.zford.jobs.PlayerManager playerManager = me.zford.jobs.Jobs.getPlayerManager();
|
||||||
} else {
|
if (playerManager == null) {
|
||||||
j.add(job.getName());
|
return "";
|
||||||
|
}
|
||||||
|
for (me.zford.jobs.container.Job job : me.zford.jobs.Jobs.getJobs()) {
|
||||||
|
if (playerManager.getJobsPlayer(player).isInJob(job)) {
|
||||||
|
if (shortName) {
|
||||||
|
j.add(job.getShortName());
|
||||||
|
} else {
|
||||||
|
j.add(job.getName());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
} else if (m.contains("com.gamingmesh")) {
|
||||||
|
com.gamingmesh.jobs.PlayerManager playerManager = com.gamingmesh.jobs.Jobs.getPlayerManager();
|
||||||
|
if (playerManager == null) {
|
||||||
|
return "";
|
||||||
|
}
|
||||||
|
for (com.gamingmesh.jobs.container.Job job : com.gamingmesh.jobs.Jobs.getJobs()) {
|
||||||
|
if (playerManager.getJobsPlayer(player).isInJob(job)) {
|
||||||
|
if (shortName) {
|
||||||
|
j.add(job.getShortName());
|
||||||
|
} else {
|
||||||
|
j.add(job.getName());
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
if (!j.isEmpty()) {
|
||||||
|
return Joiner.on(plugin.getMsgTemplate(TemplateName.JOBS_SEPARATOR)).join(j);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
if (!j.isEmpty()) {
|
} catch (Exception ex) {
|
||||||
return Joiner.on(plugin.getMsgTemplate(TemplateName.JOBS_SEPARATOR)).join(j);
|
plugin.logError("getPlayerJob: " + ex.getMessage());
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return "";
|
return "";
|
||||||
|
@ -1,73 +0,0 @@
|
|||||||
/*
|
|
||||||
* Copyright (C) 2014 cnaude
|
|
||||||
*
|
|
||||||
* This program is free software: you can redistribute it and/or modify
|
|
||||||
* it under the terms of the GNU General Public License as published by
|
|
||||||
* the Free Software Foundation, either version 3 of the License, or
|
|
||||||
* (at your option) any later version.
|
|
||||||
*
|
|
||||||
* This program is distributed in the hope that it will be useful,
|
|
||||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
||||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
||||||
* GNU General Public License for more details.
|
|
||||||
*
|
|
||||||
* You should have received a copy of the GNU General Public License
|
|
||||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
|
||||||
*/
|
|
||||||
package com.cnaude.purpleirc.Hooks;
|
|
||||||
|
|
||||||
import com.cnaude.purpleirc.TemplateName;
|
|
||||||
import com.cnaude.purpleirc.PurpleIRC;
|
|
||||||
import com.google.common.base.Joiner;
|
|
||||||
import java.util.ArrayList;
|
|
||||||
import me.zford.jobs.Jobs;
|
|
||||||
import me.zford.jobs.PlayerManager;
|
|
||||||
import me.zford.jobs.container.Job;
|
|
||||||
import org.bukkit.entity.Player;
|
|
||||||
|
|
||||||
/**
|
|
||||||
*
|
|
||||||
* @author cnaude
|
|
||||||
*/
|
|
||||||
public class JobsHookOld {
|
|
||||||
|
|
||||||
private final PurpleIRC plugin;
|
|
||||||
private PlayerManager playerManager = null;
|
|
||||||
|
|
||||||
/**
|
|
||||||
*
|
|
||||||
* @param plugin
|
|
||||||
*/
|
|
||||||
public JobsHookOld(PurpleIRC plugin) {
|
|
||||||
this.plugin = plugin;
|
|
||||||
try {
|
|
||||||
this.playerManager = Jobs.getPlayerManager();
|
|
||||||
} catch (Exception ex) {
|
|
||||||
plugin.logError("Jobs: " + ex.getMessage());
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public String getPlayerJob(Player player, boolean shortName) {
|
|
||||||
if (playerManager == null) {
|
|
||||||
return "";
|
|
||||||
}
|
|
||||||
if (player != null) {
|
|
||||||
ArrayList<String> j = new ArrayList<>();
|
|
||||||
if (plugin.isPluginEnabled("Jobs")) {
|
|
||||||
for (Job job : Jobs.getJobs()) {
|
|
||||||
if (playerManager.getJobsPlayer(player).isInJob(job)) {
|
|
||||||
if (shortName) {
|
|
||||||
j.add(job.getShortName());
|
|
||||||
} else {
|
|
||||||
j.add(job.getName());
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
if (!j.isEmpty()) {
|
|
||||||
return Joiner.on(plugin.getMsgTemplate(TemplateName.JOBS_SEPARATOR)).join(j);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return "";
|
|
||||||
}
|
|
||||||
}
|
|
@ -44,7 +44,6 @@ import com.cnaude.purpleirc.Hooks.CommandBookHook;
|
|||||||
import com.cnaude.purpleirc.Hooks.DynmapHook;
|
import com.cnaude.purpleirc.Hooks.DynmapHook;
|
||||||
import com.cnaude.purpleirc.Hooks.FactionChatHook;
|
import com.cnaude.purpleirc.Hooks.FactionChatHook;
|
||||||
import com.cnaude.purpleirc.Hooks.JobsHook;
|
import com.cnaude.purpleirc.Hooks.JobsHook;
|
||||||
import com.cnaude.purpleirc.Hooks.JobsHookOld;
|
|
||||||
import com.cnaude.purpleirc.Hooks.ReportRTSHook;
|
import com.cnaude.purpleirc.Hooks.ReportRTSHook;
|
||||||
import com.cnaude.purpleirc.Hooks.ShortifyHook;
|
import com.cnaude.purpleirc.Hooks.ShortifyHook;
|
||||||
import com.cnaude.purpleirc.Hooks.SuperVanishHook;
|
import com.cnaude.purpleirc.Hooks.SuperVanishHook;
|
||||||
@ -169,7 +168,6 @@ public class PurpleIRC extends JavaPlugin {
|
|||||||
public TownyChatHook tcHook;
|
public TownyChatHook tcHook;
|
||||||
public DynmapHook dynmapHook;
|
public DynmapHook dynmapHook;
|
||||||
public JobsHook jobsHook;
|
public JobsHook jobsHook;
|
||||||
public JobsHookOld jobsHookOld;
|
|
||||||
public AdminPrivateChatHook adminPrivateChatHook;
|
public AdminPrivateChatHook adminPrivateChatHook;
|
||||||
public ShortifyHook shortifyHook;
|
public ShortifyHook shortifyHook;
|
||||||
public ReportRTSHook reportRTSHook;
|
public ReportRTSHook reportRTSHook;
|
||||||
@ -329,17 +327,8 @@ public class PurpleIRC extends JavaPlugin {
|
|||||||
logInfo("CommandBook not detected.");
|
logInfo("CommandBook not detected.");
|
||||||
}
|
}
|
||||||
if (isPluginEnabled("Jobs")) {
|
if (isPluginEnabled("Jobs")) {
|
||||||
String m = getServer().getPluginManager().getPlugin("Jobs").getDescription().getMain();
|
logInfo("Enabling new Jobs support.");
|
||||||
String jobsVersion = getServer().getPluginManager().getPlugin("Jobs").getDescription().getVersion();
|
jobsHook = new JobsHook(this);
|
||||||
if (m.contains("me.zford")) {
|
|
||||||
logInfo("Enabling legacy Jobs support: " + jobsVersion);
|
|
||||||
jobsHookOld = new JobsHookOld(this);
|
|
||||||
} else if (m.contains("com.gamingmesh")) {
|
|
||||||
logInfo("Enabling new Jobs support: " + jobsVersion);
|
|
||||||
jobsHook = new JobsHook(this);
|
|
||||||
} else {
|
|
||||||
logError("Unable to hook into Jobs: " + m);
|
|
||||||
}
|
|
||||||
} else {
|
} else {
|
||||||
logInfo("Jobs not detected.");
|
logInfo("Jobs not detected.");
|
||||||
}
|
}
|
||||||
|
@ -596,10 +596,6 @@ public class ChatTokenizer {
|
|||||||
job = plugin.jobsHook.getPlayerJob(player, false);
|
job = plugin.jobsHook.getPlayerJob(player, false);
|
||||||
jobShort = plugin.jobsHook.getPlayerJob(player, true);
|
jobShort = plugin.jobsHook.getPlayerJob(player, true);
|
||||||
}
|
}
|
||||||
if (plugin.jobsHookOld != null) {
|
|
||||||
job = plugin.jobsHookOld.getPlayerJob(player, false);
|
|
||||||
jobShort = plugin.jobsHookOld.getPlayerJob(player, true);
|
|
||||||
}
|
|
||||||
plugin.logDebug("[P]Raw message: " + message);
|
plugin.logDebug("[P]Raw message: " + message);
|
||||||
return message.replace("%DISPLAYNAME%", displayName)
|
return message.replace("%DISPLAYNAME%", displayName)
|
||||||
.replace("%JOBS%", job)
|
.replace("%JOBS%", job)
|
||||||
@ -670,13 +666,6 @@ public class ChatTokenizer {
|
|||||||
jobShort = plugin.jobsHook.getPlayerJob(player, true);
|
jobShort = plugin.jobsHook.getPlayerJob(player, true);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
plugin.logDebug("playerTokenizer: 15 ");
|
|
||||||
if (player != null) {
|
|
||||||
if (plugin.jobsHookOld != null) {
|
|
||||||
job = plugin.jobsHookOld.getPlayerJob(player, false);
|
|
||||||
jobShort = plugin.jobsHookOld.getPlayerJob(player, true);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
plugin.logDebug("[S]Raw message: " + message);
|
plugin.logDebug("[S]Raw message: " + message);
|
||||||
return message.replace("%DISPLAYNAME%", displayName)
|
return message.replace("%DISPLAYNAME%", displayName)
|
||||||
.replace("%JOBS%", job)
|
.replace("%JOBS%", job)
|
||||||
|
Loading…
Reference in New Issue
Block a user