Remove spout features, add worldguard and worldedit.

This commit is contained in:
drtshock 2014-04-05 15:42:01 -05:00
parent d9b7cf7058
commit c4f7d6b756
15 changed files with 47 additions and 214 deletions

View File

@ -1,4 +1,4 @@
Factions - Guilding and user-controlled antigrief plugin for Minecraft
Factions - Guilding and user-controlled antigrief plugin for Minecraft - Now working with UUIDs
====================
This plugin will allow the players on the server to create factions/guilds. The factions can claim territory that will be protected from non-members. Factions can forge alliances and declare themselves enemies with others. Land may be taken from other factions through war.

31
pom.xml
View File

@ -2,13 +2,12 @@
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>com.minetime</groupId>
<groupId>com.massivecraft</groupId>
<artifactId>Factions</artifactId>
<version>1.6.9.5-SNAPSHOT</version>
<packaging>jar</packaging>
<name>Factions</name>
<url>http://maven.apache.org</url>
<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
@ -61,6 +60,26 @@
<artifactId>lwc</artifactId>
<version>4.4.0-SNAPSHOT</version>
</dependency>
<dependency>
<groupId>net.ess3</groupId>
<artifactId>Essentials</artifactId>
<version>2.x-SNAPSHOT</version>
</dependency>
<dependency>
<groupId>net.ess3</groupId>
<artifactId>EssentialsChat</artifactId>
<version>2.x-SNAPSHOT</version>
</dependency>
<dependency>
<groupId>com.sk89q</groupId>
<artifactId>worldguard</artifactId>
<version>5.8.1-SNAPSHOT</version>
</dependency>
<dependency>
<groupId>com.sk89q</groupId>
<artifactId>worldedit</artifactId>
<version>5.6.1</version>
</dependency>
</dependencies>
<repositories>
@ -77,5 +96,13 @@
<name>mcstats.org releases</name>
<url>http://repo.mcstats.org/content/repositories/</url>
</repository>
<repository>
<id>essrel</id>
<url>http://repo.ess3.net/content/repositories/essrel</url>
</repository>
<repository>
<id>maven.sk89q.com</id>
<url>http://maven.sk89q.com/repo/</url>
</repository>
</repositories>
</project>

View File

@ -1,6 +1,7 @@
package com.massivecraft.factions;
import org.bukkit.*;
import org.bukkit.ChatColor;
import org.bukkit.Material;
import org.bukkit.entity.EntityType;
import java.util.*;

View File

@ -342,7 +342,7 @@ public class FPlayer extends PlayerEntity implements EconomyParticipator {
}
/*public String getNameAndTag(Faction faction)
{
{
return this.getRelationColor(faction)+this.getNameAndTag();
}
public String getNameAndTag(FPlayer fplayer)
@ -351,9 +351,9 @@ public class FPlayer extends PlayerEntity implements EconomyParticipator {
}*/
// TODO: REmovded for refactoring.
/*public String getNameAndRelevant(Faction faction)
{
{
// Which relation?
Relation rel = this.getRelationTo(faction);

View File

@ -7,7 +7,9 @@ import com.massivecraft.factions.integration.LWCFeatures;
import com.massivecraft.factions.struct.Permission;
import com.massivecraft.factions.struct.Relation;
import com.massivecraft.factions.struct.Role;
import com.massivecraft.factions.util.*;
import com.massivecraft.factions.util.LazyLocation;
import com.massivecraft.factions.util.MiscUtil;
import com.massivecraft.factions.util.RelationUtil;
import com.massivecraft.factions.zcore.persist.Entity;
import org.bukkit.ChatColor;
import org.bukkit.Location;

View File

@ -2,8 +2,10 @@ package com.massivecraft.factions;
import com.massivecraft.factions.cmd.CmdAutoHelp;
import com.massivecraft.factions.cmd.FCmdRoot;
import com.massivecraft.factions.integration.*;
import com.massivecraft.factions.integration.capi.CapiFeatures;
import com.massivecraft.factions.integration.Econ;
import com.massivecraft.factions.integration.EssentialsFeatures;
import com.massivecraft.factions.integration.LWCFeatures;
import com.massivecraft.factions.integration.Worldguard;
import com.massivecraft.factions.listeners.*;
import com.massivecraft.factions.struct.ChatMode;
import com.massivecraft.factions.util.AutoLeaveTask;
@ -99,7 +101,6 @@ public class P extends MPlugin {
EssentialsFeatures.setup();
Econ.setup();
CapiFeatures.setup();
LWCFeatures.setup();
if (Conf.worldGuardChecking || Conf.worldGuardBuildPriority) {

View File

@ -6,7 +6,7 @@ public class CmdLock extends FCommand {
// TODO: This solution needs refactoring.
/*
factions.lock:
factions.lock:
description: use the /f lock [on/off] command to temporarily lock the data files from being overwritten
default: op
*/

View File

@ -4,16 +4,12 @@ import com.earth2me.essentials.IEssentials;
import com.earth2me.essentials.Teleport;
import com.earth2me.essentials.Trade;
import com.earth2me.essentials.chat.EssentialsChat;
import com.earth2me.essentials.chat.EssentialsLocalChatEvent;
import com.massivecraft.factions.Conf;
import com.massivecraft.factions.P;
import org.bukkit.Bukkit;
import org.bukkit.ChatColor;
import org.bukkit.Location;
import org.bukkit.entity.Player;
import org.bukkit.event.EventHandler;
import org.bukkit.event.EventPriority;
import org.bukkit.event.Listener;
import org.bukkit.plugin.Plugin;
@ -50,20 +46,11 @@ public class EssentialsFeatures {
Class.forName("com.earth2me.essentials.chat.EssentialsLocalChatEvent");
integrateChat(essChat);
} catch (ClassNotFoundException ex) {
// no? try older Essentials 2.x integration method
try {
EssentialsOldVersionFeatures.integrateChat(essChat);
} catch (NoClassDefFoundError ex2) { /* no known integration method, then */ }
}
}
public static void unhookChat() {
if (essChat == null) return;
try {
EssentialsOldVersionFeatures.unhookChat();
} catch (NoClassDefFoundError ex) {
}
}
@ -85,7 +72,6 @@ public class EssentialsFeatures {
public static void integrateChat(EssentialsChat instance) {
essChat = instance;
try {
Bukkit.getServer().getPluginManager().registerEvents(new LocalChatListener(), P.p);
P.p.log("Found and will integrate chat with newer " + essChat.getDescription().getFullName());
// curly braces used to be accepted by the format string EssentialsChat but no longer are, so... deal with chatTagReplaceString which might need updating
@ -97,17 +83,4 @@ public class EssentialsFeatures {
essChat = null;
}
}
private static class LocalChatListener implements Listener {
@SuppressWarnings("unused")
@EventHandler(priority = EventPriority.NORMAL)
public void onPlayerChat(EssentialsLocalChatEvent event) {
Player speaker = event.getPlayer();
String format = event.getFormat();
format = format.replace(Conf.chatTagReplaceString, P.p.getPlayerFactionTag(speaker)).replace("[FACTION_TITLE]", P.p.getPlayerTitle(speaker));
event.setFormat(format);
// NOTE: above doesn't do relation coloring. if/when we can get a local recipient list from EssentialsLocalChatEvent, we'll probably
// want to pass it on to FactionsPlayerListener.onPlayerChat(PlayerChatEvent event) rather than duplicating code
}
}
}

View File

@ -1,47 +0,0 @@
package com.massivecraft.factions.integration;
import com.earth2me.essentials.chat.EssentialsChat;
import com.earth2me.essentials.chat.IEssentialsChatListener;
import com.massivecraft.factions.Conf;
import com.massivecraft.factions.P;
import org.bukkit.entity.Player;
import org.bukkit.event.player.AsyncPlayerChatEvent;
/*
* This Essentials integration handler is for older 2.x.x versions of Essentials which have "IEssentialsChatListener"
*/
public class EssentialsOldVersionFeatures {
private static EssentialsChat essChat;
public static void integrateChat(EssentialsChat instance) {
essChat = instance;
try {
essChat.addEssentialsChatListener("Factions", new IEssentialsChatListener() {
public boolean shouldHandleThisChat(AsyncPlayerChatEvent event) {
return P.p.shouldLetFactionsHandleThisChat(event);
}
public String modifyMessage(AsyncPlayerChatEvent event, Player target, String message) {
return message.replace(Conf.chatTagReplaceString, P.p.getPlayerFactionTagRelation(event.getPlayer(), target)).replace("[FACTION_TITLE]", P.p.getPlayerTitle(event.getPlayer()));
}
});
P.p.log("Found and will integrate chat with " + essChat.getDescription().getFullName());
// As of Essentials 2.8+, curly braces are not accepted and are instead replaced with square braces, so... deal with it
if (essChat.getDescription().getVersion().startsWith("2.8.") && Conf.chatTagReplaceString.contains("{")) {
Conf.chatTagReplaceString = Conf.chatTagReplaceString.replace("{", "[").replace("}", "]");
P.p.log("NOTE: as of Essentials 2.8+, we've had to switch the default chat replacement tag from \"{FACTION}\" to \"[FACTION]\". This has automatically been updated for you.");
}
} catch (NoSuchMethodError ex) {
essChat = null;
}
}
public static void unhookChat() {
if (essChat != null) {
essChat.removeEssentialsChatListener("Factions");
}
}
}

View File

@ -19,7 +19,7 @@ import java.util.ArrayList;
import java.util.List;
import java.util.Map;
import static com.sk89q.worldguard.bukkit.BukkitUtil.*;
import static com.sk89q.worldguard.bukkit.BukkitUtil.toVector;
/*
* Worldguard Region Checking

View File

@ -1,15 +0,0 @@
package com.massivecraft.factions.integration.capi;
import com.massivecraft.factions.P;
import org.bukkit.Bukkit;
import org.bukkit.plugin.Plugin;
public class CapiFeatures {
public static void setup() {
Plugin plug = Bukkit.getServer().getPluginManager().getPlugin("capi");
if (plug != null && plug.getClass().getName().equals("com.massivecraft.capi.P")) {
P.p.log("Integration with the CAPI plugin was successful");
Bukkit.getPluginManager().registerEvents(new PluginCapiListener(P.p), P.p);
}
}
}

View File

@ -1,109 +0,0 @@
package com.massivecraft.factions.integration.capi;
import com.massivecraft.capi.Channel;
import com.massivecraft.capi.Channels;
import com.massivecraft.capi.events.CAPIListChannelsEvent;
import com.massivecraft.capi.events.CAPIMessageToChannelEvent;
import com.massivecraft.capi.events.CAPIMessageToPlayerEvent;
import com.massivecraft.capi.events.CAPISelectChannelEvent;
import com.massivecraft.factions.FPlayer;
import com.massivecraft.factions.FPlayers;
import com.massivecraft.factions.Faction;
import com.massivecraft.factions.P;
import com.massivecraft.factions.struct.Relation;
import org.bukkit.Bukkit;
import org.bukkit.entity.Player;
import org.bukkit.event.EventHandler;
import org.bukkit.event.EventPriority;
import org.bukkit.event.Listener;
import java.util.LinkedHashSet;
import java.util.Set;
public class PluginCapiListener implements Listener {
P p;
Set<String> myChannelIds = new LinkedHashSet<String>();
public PluginCapiListener(P p) {
this.p = p;
myChannelIds.add("faction");
myChannelIds.add("allies");
}
private String replacePlayerTags(String format, FPlayer me, FPlayer you) {
String meFactionTag = me.getChatTag(you);
format = format.replace("{ME_FACTIONTAG}", meFactionTag.length() == 0 ? "" : meFactionTag);
format = format.replace("{ME_FACTIONTAG_PADR}", meFactionTag.length() == 0 ? "" : meFactionTag + " ");
format = format.replace("{ME_FACTIONTAG_PADL}", meFactionTag.length() == 0 ? "" : " " + meFactionTag);
format = format.replace("{ME_FACTIONTAG_PADB}", meFactionTag.length() == 0 ? "" : " " + meFactionTag + " ");
String youFactionTag = you.getChatTag(me);
format = format.replace("{YOU_FACTIONTAG}", youFactionTag.length() == 0 ? "" : youFactionTag);
format = format.replace("{YOU_FACTIONTAG_PADR}", youFactionTag.length() == 0 ? "" : youFactionTag + " ");
format = format.replace("{YOU_FACTIONTAG_PADL}", youFactionTag.length() == 0 ? "" : " " + youFactionTag);
format = format.replace("{YOU_FACTIONTAG_PADB}", youFactionTag.length() == 0 ? "" : " " + youFactionTag + " ");
return format;
}
@EventHandler(priority = EventPriority.NORMAL)
public void onListChannelsEvent(CAPIListChannelsEvent event) {
for (Channel c : Channels.i.getAll()) {
if (myChannelIds.contains(c.getId())) {
event.getChannels().add(c);
}
}
}
@EventHandler(priority = EventPriority.NORMAL)
public void onMessageToChannel(CAPIMessageToChannelEvent event) {
if (event.isCancelled()) return;
if (!myChannelIds.contains(event.getChannel().getId())) return;
Player me = event.getMe();
FPlayer fme = FPlayers.i.get(me);
Faction myFaction = fme.getFaction();
if (event.getChannel().getId().equals("faction") && myFaction.isNormal()) {
event.getThem().addAll(myFaction.getOnlinePlayers());
// Send to any players who are spying chat... could probably be implemented better than this
for (FPlayer fplayer : FPlayers.i.getOnline()) {
if (fplayer.isSpyingChat() && fplayer.getFaction() != myFaction)
fplayer.sendMessage("[FCspy] " + myFaction.getTag() + ": " + event.getMessage());
}
} else if (event.getChannel().getId().equals("allies")) {
for (Player somePlayer : Bukkit.getServer().getOnlinePlayers()) {
FPlayer someFPlayer = FPlayers.i.get(somePlayer);
if (someFPlayer.getRelationTo(fme).isAtLeast(Relation.ALLY))
event.getThem().add(somePlayer);
// Send to any players who are spying chat
else if (someFPlayer.isSpyingChat())
someFPlayer.sendMessage("[ACspy]: " + event.getMessage());
}
}
}
@EventHandler(priority = EventPriority.NORMAL)
public void onMessageToPlayer(CAPIMessageToPlayerEvent event) {
if (event.isCancelled()) return;
event.setFormat(this.replacePlayerTags(event.getFormat(), FPlayers.i.get(event.getMe()), FPlayers.i.get(event.getYou())));
}
@EventHandler(priority = EventPriority.NORMAL)
public void onSelectChannel(CAPISelectChannelEvent event) {
if (event.isCancelled()) return;
String channelId = event.getChannel().getId();
if (!myChannelIds.contains(channelId)) return;
Player me = event.getMe();
FPlayer fme = FPlayers.i.get(me);
if (!fme.hasFaction()) {
event.setFailMessage(p.txt.parse("<b>You must be member in a faction to use this channel."));
event.setCancelled(true);
}
}
}

View File

@ -245,7 +245,7 @@ public class TextUtil {
// -------------------------------------------- //
/*private static int commonStartLength(String a, String b)
{
{
int len = a.length() < b.length() ? a.length() : b.length();
int i;
for (i = 0; i < len; i++)

View File

@ -8,7 +8,7 @@ public class WorldUtil {
// Previously We had crappy support for multiworld management.
// This should however be handled by an external plugin!
/*public static boolean load(String name) {
if (isWorldLoaded(name)) {
if (isWorldLoaded(name)) {
return true;
}

View File

@ -1,7 +1,7 @@
name: Factions
version: 1.6.9.5
main: com.massivecraft.factions.P
authors: [Olof Larsson, Brett Flannigan]
authors: [Olof Larsson, Brett Flannigan, drtshock]
softdepend: [PermissionsEx, Permissions, Essentials, EssentialsChat, HeroChat, iChat, LocalAreaChat, LWC, nChat, ChatManager, CAPI, AuthMe, Vault, Spout, WorldEdit, WorldGuard, AuthDB, CaptureThePoints, CombatTag]
commands:
factions: