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>
|
||||
<groupId>org.bukkit</groupId>
|
||||
<artifactId>spigot-api</artifactId>
|
||||
<version>1.8</version>
|
||||
<version>1.8.3</version>
|
||||
<scope>provided</scope>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.bukkit</groupId>
|
||||
<artifactId>spigot</artifactId>
|
||||
<version>1.8</version>
|
||||
<version>1.8.3</version>
|
||||
<scope>provided</scope>
|
||||
</dependency>
|
||||
<dependency>
|
||||
@ -186,12 +186,6 @@
|
||||
<version>5.6.7</version>
|
||||
<scope>compile</scope>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>com.cnaude.mineversechat</groupId>
|
||||
<artifactId>MineverseChat</artifactId>
|
||||
<version>2.0</version>
|
||||
<scope>compile</scope>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>com.cnaude.jobs</groupId>
|
||||
<artifactId>Jobs</artifactId>
|
||||
@ -362,7 +356,7 @@
|
||||
<properties>
|
||||
<build.number>SNAPSHOT</build.number>
|
||||
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
|
||||
<bukkit.version>1.8</bukkit.version>
|
||||
<bukkit.version>1.8.3</bukkit.version>
|
||||
</properties>
|
||||
</project>
|
||||
|
||||
|
@ -18,9 +18,6 @@ package com.cnaude.purpleirc.Hooks;
|
||||
|
||||
import com.cnaude.purpleirc.TemplateName;
|
||||
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 java.util.ArrayList;
|
||||
import org.bukkit.entity.Player;
|
||||
@ -32,7 +29,6 @@ import org.bukkit.entity.Player;
|
||||
public class JobsHook {
|
||||
|
||||
private final PurpleIRC plugin;
|
||||
private PlayerManager playerManager = null;
|
||||
|
||||
/**
|
||||
*
|
||||
@ -40,32 +36,49 @@ public class JobsHook {
|
||||
*/
|
||||
public JobsHook(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());
|
||||
try {
|
||||
if (plugin.isPluginEnabled("Jobs")) {
|
||||
ArrayList<String> j = new ArrayList<>();
|
||||
String m = plugin.getServer().getPluginManager().getPlugin("Jobs").getDescription().getMain();
|
||||
if (m.contains("me.zford")) {
|
||||
me.zford.jobs.PlayerManager playerManager = me.zford.jobs.Jobs.getPlayerManager();
|
||||
if (playerManager == null) {
|
||||
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()) {
|
||||
return Joiner.on(plugin.getMsgTemplate(TemplateName.JOBS_SEPARATOR)).join(j);
|
||||
}
|
||||
} catch (Exception ex) {
|
||||
plugin.logError("getPlayerJob: " + ex.getMessage());
|
||||
}
|
||||
}
|
||||
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.FactionChatHook;
|
||||
import com.cnaude.purpleirc.Hooks.JobsHook;
|
||||
import com.cnaude.purpleirc.Hooks.JobsHookOld;
|
||||
import com.cnaude.purpleirc.Hooks.ReportRTSHook;
|
||||
import com.cnaude.purpleirc.Hooks.ShortifyHook;
|
||||
import com.cnaude.purpleirc.Hooks.SuperVanishHook;
|
||||
@ -169,7 +168,6 @@ public class PurpleIRC extends JavaPlugin {
|
||||
public TownyChatHook tcHook;
|
||||
public DynmapHook dynmapHook;
|
||||
public JobsHook jobsHook;
|
||||
public JobsHookOld jobsHookOld;
|
||||
public AdminPrivateChatHook adminPrivateChatHook;
|
||||
public ShortifyHook shortifyHook;
|
||||
public ReportRTSHook reportRTSHook;
|
||||
@ -329,17 +327,8 @@ public class PurpleIRC extends JavaPlugin {
|
||||
logInfo("CommandBook not detected.");
|
||||
}
|
||||
if (isPluginEnabled("Jobs")) {
|
||||
String m = getServer().getPluginManager().getPlugin("Jobs").getDescription().getMain();
|
||||
String jobsVersion = getServer().getPluginManager().getPlugin("Jobs").getDescription().getVersion();
|
||||
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);
|
||||
}
|
||||
logInfo("Enabling new Jobs support.");
|
||||
jobsHook = new JobsHook(this);
|
||||
} else {
|
||||
logInfo("Jobs not detected.");
|
||||
}
|
||||
|
@ -596,10 +596,6 @@ public class ChatTokenizer {
|
||||
job = plugin.jobsHook.getPlayerJob(player, false);
|
||||
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);
|
||||
return message.replace("%DISPLAYNAME%", displayName)
|
||||
.replace("%JOBS%", job)
|
||||
@ -670,13 +666,6 @@ public class ChatTokenizer {
|
||||
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);
|
||||
return message.replace("%DISPLAYNAME%", displayName)
|
||||
.replace("%JOBS%", job)
|
||||
|
Loading…
Reference in New Issue
Block a user