Add Faction warps
This commit is contained in:
		
							
								
								
									
										18
									
								
								plugin.yml
									
									
									
									
									
								
							
							
						
						
									
										18
									
								
								plugin.yml
									
									
									
									
									
								
							@@ -38,7 +38,6 @@ permissions:
 | 
				
			|||||||
  factions.flag.list: {description: list flags, default: false}
 | 
					  factions.flag.list: {description: list flags, default: false}
 | 
				
			||||||
  factions.flag.set: {description: set flags, default: false}
 | 
					  factions.flag.set: {description: set flags, default: false}
 | 
				
			||||||
  factions.flag.show: {description: show flags, default: false}
 | 
					  factions.flag.show: {description: show flags, default: false}
 | 
				
			||||||
  factions.home: {description: teleport to faction home, default: false}
 | 
					 | 
				
			||||||
  factions.invite: {description: manage invites, default: false}
 | 
					  factions.invite: {description: manage invites, default: false}
 | 
				
			||||||
  factions.invite.list: {description: list invited players, default: false}
 | 
					  factions.invite.list: {description: list invited players, default: false}
 | 
				
			||||||
  factions.invite.list.other: {description: list invited players of another factions, default: false}
 | 
					  factions.invite.list.other: {description: list invited players of another factions, default: false}
 | 
				
			||||||
@@ -87,7 +86,6 @@ permissions:
 | 
				
			|||||||
  factions.relation.wishes: {description: list the relation wishes, default: false}
 | 
					  factions.relation.wishes: {description: list the relation wishes, default: false}
 | 
				
			||||||
  factions.seechunk: {description: see the chunk you stand in, default: false}
 | 
					  factions.seechunk: {description: see the chunk you stand in, default: false}
 | 
				
			||||||
  factions.seechunkold: {description: see the chunk you stand in, default: false}
 | 
					  factions.seechunkold: {description: see the chunk you stand in, default: false}
 | 
				
			||||||
  factions.sethome: {description: set the faction home, default: false}
 | 
					 | 
				
			||||||
  factions.setpower: {description: set power, default: false}
 | 
					  factions.setpower: {description: set power, default: false}
 | 
				
			||||||
  factions.status: {description: show status, default: false}
 | 
					  factions.status: {description: show status, default: false}
 | 
				
			||||||
  factions.name: {description: set faction name, default: false}
 | 
					  factions.name: {description: set faction name, default: false}
 | 
				
			||||||
@@ -101,7 +99,11 @@ permissions:
 | 
				
			|||||||
  factions.unclaim.square: {description: unclaim by square and radius, default: false}
 | 
					  factions.unclaim.square: {description: unclaim by square and radius, default: false}
 | 
				
			||||||
  factions.unclaim.circle: {description: unclaim by circle and radius, default: false}
 | 
					  factions.unclaim.circle: {description: unclaim by circle and radius, default: false}
 | 
				
			||||||
  factions.unclaim.all: {description: unclaim all faction land, default: false}
 | 
					  factions.unclaim.all: {description: unclaim all faction land, default: false}
 | 
				
			||||||
  factions.unsethome: {description: unset faction home, default: false}
 | 
					  factions.warp: {description: use warps, default: false}
 | 
				
			||||||
 | 
					  factions.warp.go: {description: go to a warp, default: false}
 | 
				
			||||||
 | 
					  factions.warp.list: {description: list warps, default: false}
 | 
				
			||||||
 | 
					  factions.warp.add: {description: add new warp, default: false}
 | 
				
			||||||
 | 
					  factions.warp.remove: {description: remove warp, default: false}
 | 
				
			||||||
  factions.unstuck: {description: teleport to nearest wilderness, default: false}
 | 
					  factions.unstuck: {description: teleport to nearest wilderness, default: false}
 | 
				
			||||||
  factions.config: {description: edit the factions config, default: false}
 | 
					  factions.config: {description: edit the factions config, default: false}
 | 
				
			||||||
  factions.clean: {description: clean the factions database, default: false}
 | 
					  factions.clean: {description: clean the factions database, default: false}
 | 
				
			||||||
@@ -209,6 +211,11 @@ permissions:
 | 
				
			|||||||
      factions.unclaim.all: true
 | 
					      factions.unclaim.all: true
 | 
				
			||||||
      factions.unsethome: true
 | 
					      factions.unsethome: true
 | 
				
			||||||
      factions.unstuck: true
 | 
					      factions.unstuck: true
 | 
				
			||||||
 | 
					      factions.warp: true
 | 
				
			||||||
 | 
					      factions.warp.go: true
 | 
				
			||||||
 | 
					      factions.warp.list: true
 | 
				
			||||||
 | 
					      factions.warp.add: true
 | 
				
			||||||
 | 
					      factions.warp.remove: true
 | 
				
			||||||
      factions.config: true
 | 
					      factions.config: true
 | 
				
			||||||
      factions.clean: true
 | 
					      factions.clean: true
 | 
				
			||||||
      factions.version: true
 | 
					      factions.version: true
 | 
				
			||||||
@@ -335,6 +342,11 @@ permissions:
 | 
				
			|||||||
      factions.unclaim.all: true
 | 
					      factions.unclaim.all: true
 | 
				
			||||||
      factions.unsethome: true
 | 
					      factions.unsethome: true
 | 
				
			||||||
      factions.unstuck: true
 | 
					      factions.unstuck: true
 | 
				
			||||||
 | 
					      factions.warp: true
 | 
				
			||||||
 | 
					      factions.warp.go: true
 | 
				
			||||||
 | 
					      factions.warp.list: true
 | 
				
			||||||
 | 
					      factions.warp.add: true
 | 
				
			||||||
 | 
					      factions.warp.remove: true
 | 
				
			||||||
      factions.version: true
 | 
					      factions.version: true
 | 
				
			||||||
  factions.kit.default:
 | 
					  factions.kit.default:
 | 
				
			||||||
    default: true
 | 
					    default: true
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -53,10 +53,12 @@ import com.massivecraft.factions.entity.MPermColl;
 | 
				
			|||||||
import com.massivecraft.factions.entity.MPlayerColl;
 | 
					import com.massivecraft.factions.entity.MPlayerColl;
 | 
				
			||||||
import com.massivecraft.factions.entity.migrator.MigratorFaction001Invitations;
 | 
					import com.massivecraft.factions.entity.migrator.MigratorFaction001Invitations;
 | 
				
			||||||
import com.massivecraft.factions.entity.migrator.MigratorFaction002Ranks;
 | 
					import com.massivecraft.factions.entity.migrator.MigratorFaction002Ranks;
 | 
				
			||||||
 | 
					import com.massivecraft.factions.entity.migrator.MigratorFaction003Warps;
 | 
				
			||||||
import com.massivecraft.factions.entity.migrator.MigratorMConf001EnumerationUtil;
 | 
					import com.massivecraft.factions.entity.migrator.MigratorMConf001EnumerationUtil;
 | 
				
			||||||
import com.massivecraft.factions.entity.migrator.MigratorMConf002CleanInactivity;
 | 
					import com.massivecraft.factions.entity.migrator.MigratorMConf002CleanInactivity;
 | 
				
			||||||
import com.massivecraft.factions.entity.migrator.MigratorMConf003CleanInactivity;
 | 
					import com.massivecraft.factions.entity.migrator.MigratorMConf003CleanInactivity;
 | 
				
			||||||
import com.massivecraft.factions.entity.migrator.MigratorMConf004Rank;
 | 
					import com.massivecraft.factions.entity.migrator.MigratorMConf004Rank;
 | 
				
			||||||
 | 
					import com.massivecraft.factions.entity.migrator.MigratorMConf005Warps;
 | 
				
			||||||
import com.massivecraft.factions.entity.migrator.MigratorMPlayer001Ranks;
 | 
					import com.massivecraft.factions.entity.migrator.MigratorMPlayer001Ranks;
 | 
				
			||||||
import com.massivecraft.factions.event.EventFactionsChunkChangeType;
 | 
					import com.massivecraft.factions.event.EventFactionsChunkChangeType;
 | 
				
			||||||
import com.massivecraft.factions.integration.V18.IntegrationV18;
 | 
					import com.massivecraft.factions.integration.V18.IntegrationV18;
 | 
				
			||||||
@@ -139,10 +141,12 @@ public class Factions extends MassivePlugin
 | 
				
			|||||||
		return MUtil.list(
 | 
							return MUtil.list(
 | 
				
			||||||
			MigratorFaction001Invitations.class,
 | 
								MigratorFaction001Invitations.class,
 | 
				
			||||||
			MigratorFaction002Ranks.class,
 | 
								MigratorFaction002Ranks.class,
 | 
				
			||||||
 | 
								MigratorFaction003Warps.class,
 | 
				
			||||||
			MigratorMConf001EnumerationUtil.class,
 | 
								MigratorMConf001EnumerationUtil.class,
 | 
				
			||||||
			MigratorMConf002CleanInactivity.class,
 | 
								MigratorMConf002CleanInactivity.class,
 | 
				
			||||||
			MigratorMConf003CleanInactivity.class,
 | 
								MigratorMConf003CleanInactivity.class,
 | 
				
			||||||
			MigratorMConf004Rank.class,
 | 
								MigratorMConf004Rank.class,
 | 
				
			||||||
 | 
								MigratorMConf005Warps.class,
 | 
				
			||||||
			MigratorMPlayer001Ranks.class
 | 
								MigratorMPlayer001Ranks.class
 | 
				
			||||||
		);
 | 
							);
 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -102,6 +102,11 @@ public enum Perm implements Identified
 | 
				
			|||||||
	UNCLAIM_ALL,
 | 
						UNCLAIM_ALL,
 | 
				
			||||||
	UNSETHOME,
 | 
						UNSETHOME,
 | 
				
			||||||
	UNSTUCK,
 | 
						UNSTUCK,
 | 
				
			||||||
 | 
						WARP,
 | 
				
			||||||
 | 
						WARP_GO,
 | 
				
			||||||
 | 
						WARP_LIST,
 | 
				
			||||||
 | 
						WARP_ADD,
 | 
				
			||||||
 | 
						WARP_REMOVE,
 | 
				
			||||||
	CONFIG,
 | 
						CONFIG,
 | 
				
			||||||
	CLEAN,
 | 
						CLEAN,
 | 
				
			||||||
	VERSION,
 | 
						VERSION,
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -29,14 +29,12 @@ public class CmdFactions extends FactionsCommand
 | 
				
			|||||||
	public CmdFactionsStatus cmdFactionsStatus = new CmdFactionsStatus();
 | 
						public CmdFactionsStatus cmdFactionsStatus = new CmdFactionsStatus();
 | 
				
			||||||
	public CmdFactionsJoin cmdFactionsJoin = new CmdFactionsJoin();
 | 
						public CmdFactionsJoin cmdFactionsJoin = new CmdFactionsJoin();
 | 
				
			||||||
	public CmdFactionsLeave cmdFactionsLeave = new CmdFactionsLeave();
 | 
						public CmdFactionsLeave cmdFactionsLeave = new CmdFactionsLeave();
 | 
				
			||||||
	public CmdFactionsHome cmdFactionsHome = new CmdFactionsHome();
 | 
						public CmdFactionsWarp cmdFactionsWarp = new CmdFactionsWarp();
 | 
				
			||||||
	public CmdFactionsMap cmdFactionsMap = new CmdFactionsMap();
 | 
						public CmdFactionsMap cmdFactionsMap = new CmdFactionsMap();
 | 
				
			||||||
	public CmdFactionsCreate cmdFactionsCreate = new CmdFactionsCreate();
 | 
						public CmdFactionsCreate cmdFactionsCreate = new CmdFactionsCreate();
 | 
				
			||||||
	public CmdFactionsName cmdFactionsName = new CmdFactionsName();
 | 
						public CmdFactionsName cmdFactionsName = new CmdFactionsName();
 | 
				
			||||||
	public CmdFactionsDescription cmdFactionsDescription = new CmdFactionsDescription();
 | 
						public CmdFactionsDescription cmdFactionsDescription = new CmdFactionsDescription();
 | 
				
			||||||
	public CmdFactionsMotd cmdFactionsMotd = new CmdFactionsMotd();
 | 
						public CmdFactionsMotd cmdFactionsMotd = new CmdFactionsMotd();
 | 
				
			||||||
	public CmdFactionsSethome cmdFactionsSethome = new CmdFactionsSethome();
 | 
					 | 
				
			||||||
	public CmdFactionsUnsethome cmdFactionsUnsethome = new CmdFactionsUnsethome();
 | 
					 | 
				
			||||||
	public CmdFactionsInvite cmdFactionsInvite = new CmdFactionsInvite();
 | 
						public CmdFactionsInvite cmdFactionsInvite = new CmdFactionsInvite();
 | 
				
			||||||
	public CmdFactionsKick cmdFactionsKick = new CmdFactionsKick();
 | 
						public CmdFactionsKick cmdFactionsKick = new CmdFactionsKick();
 | 
				
			||||||
	public CmdFactionsTitle cmdFactionsTitle = new CmdFactionsTitle();
 | 
						public CmdFactionsTitle cmdFactionsTitle = new CmdFactionsTitle();
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -1,69 +0,0 @@
 | 
				
			|||||||
package com.massivecraft.factions.cmd;
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
import com.massivecraft.factions.Perm;
 | 
					 | 
				
			||||||
import com.massivecraft.factions.cmd.type.TypeFaction;
 | 
					 | 
				
			||||||
import com.massivecraft.factions.entity.Faction;
 | 
					 | 
				
			||||||
import com.massivecraft.factions.entity.MPerm;
 | 
					 | 
				
			||||||
import com.massivecraft.factions.event.EventFactionsHomeChange;
 | 
					 | 
				
			||||||
import com.massivecraft.massivecore.MassiveException;
 | 
					 | 
				
			||||||
import com.massivecraft.massivecore.command.requirement.RequirementHasPerm;
 | 
					 | 
				
			||||||
import com.massivecraft.massivecore.command.requirement.RequirementIsPlayer;
 | 
					 | 
				
			||||||
import com.massivecraft.massivecore.ps.PS;
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
public class CmdFactionsSethome extends FactionsCommandHome
 | 
					 | 
				
			||||||
{
 | 
					 | 
				
			||||||
	// -------------------------------------------- //
 | 
					 | 
				
			||||||
	// CONSTRUCT
 | 
					 | 
				
			||||||
	// -------------------------------------------- //
 | 
					 | 
				
			||||||
	
 | 
					 | 
				
			||||||
	public CmdFactionsSethome()
 | 
					 | 
				
			||||||
	{
 | 
					 | 
				
			||||||
		// Parameters
 | 
					 | 
				
			||||||
		this.addParameter(TypeFaction.get(), "faction", "you");
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
		// Requirements
 | 
					 | 
				
			||||||
		this.addRequirements(RequirementHasPerm.get(Perm.SETHOME));
 | 
					 | 
				
			||||||
		this.addRequirements(RequirementIsPlayer.get());
 | 
					 | 
				
			||||||
	}
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
	// -------------------------------------------- //
 | 
					 | 
				
			||||||
	// OVERRIDE
 | 
					 | 
				
			||||||
	// -------------------------------------------- //
 | 
					 | 
				
			||||||
	
 | 
					 | 
				
			||||||
	@Override
 | 
					 | 
				
			||||||
	public void perform() throws MassiveException
 | 
					 | 
				
			||||||
	{
 | 
					 | 
				
			||||||
		// Args
 | 
					 | 
				
			||||||
		Faction faction = this.readArg(msenderFaction);
 | 
					 | 
				
			||||||
		
 | 
					 | 
				
			||||||
		PS newHome = PS.valueOf(me.getLocation());
 | 
					 | 
				
			||||||
		
 | 
					 | 
				
			||||||
		// MPerm
 | 
					 | 
				
			||||||
		if ( ! MPerm.getPermSethome().has(msender, faction, true)) return;
 | 
					 | 
				
			||||||
		
 | 
					 | 
				
			||||||
		// Verify
 | 
					 | 
				
			||||||
		if (!msender.isOverriding() && !faction.isValidHome(newHome))
 | 
					 | 
				
			||||||
		{
 | 
					 | 
				
			||||||
			msender.msg("<b>Sorry, your faction home can only be set inside your own claimed territory.");
 | 
					 | 
				
			||||||
			return;
 | 
					 | 
				
			||||||
		}
 | 
					 | 
				
			||||||
		
 | 
					 | 
				
			||||||
		// Event
 | 
					 | 
				
			||||||
		EventFactionsHomeChange event = new EventFactionsHomeChange(sender, faction, newHome);
 | 
					 | 
				
			||||||
		event.run();
 | 
					 | 
				
			||||||
		if (event.isCancelled()) return;
 | 
					 | 
				
			||||||
		newHome = event.getNewHome();
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
		// Apply
 | 
					 | 
				
			||||||
		faction.setHome(newHome);
 | 
					 | 
				
			||||||
		
 | 
					 | 
				
			||||||
		// Inform
 | 
					 | 
				
			||||||
		faction.msg("%s<i> set the home for your faction. You can now use:", msender.describeTo(msenderFaction, true));
 | 
					 | 
				
			||||||
		faction.sendMessage(CmdFactions.get().cmdFactionsHome.getTemplate());
 | 
					 | 
				
			||||||
		if (faction != msenderFaction)
 | 
					 | 
				
			||||||
		{
 | 
					 | 
				
			||||||
			msender.msg("<i>You have set the home for " + faction.getName(msender) + "<i>.");
 | 
					 | 
				
			||||||
		}
 | 
					 | 
				
			||||||
	}
 | 
					 | 
				
			||||||
	
 | 
					 | 
				
			||||||
}
 | 
					 | 
				
			||||||
							
								
								
									
										14
									
								
								src/com/massivecraft/factions/cmd/CmdFactionsWarp.java
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										14
									
								
								src/com/massivecraft/factions/cmd/CmdFactionsWarp.java
									
									
									
									
									
										Normal file
									
								
							@@ -0,0 +1,14 @@
 | 
				
			|||||||
 | 
					package com.massivecraft.factions.cmd;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					public class CmdFactionsWarp extends FactionsCommand
 | 
				
			||||||
 | 
					{
 | 
				
			||||||
 | 
						// -------------------------------------------- //
 | 
				
			||||||
 | 
						// FIELDS
 | 
				
			||||||
 | 
						// -------------------------------------------- //
 | 
				
			||||||
 | 
						
 | 
				
			||||||
 | 
						public CmdFactionsWarpGo cmdFactionsWarpGo = new CmdFactionsWarpGo();
 | 
				
			||||||
 | 
						public CmdFactionsWarpList cmdFactionsWarpList = new CmdFactionsWarpList();
 | 
				
			||||||
 | 
						public CmdFactionsWarpAdd cmdFactionWarpAdd = new CmdFactionsWarpAdd();
 | 
				
			||||||
 | 
						public CmdFactionsWarpRemove cmdFactionWarpRemove = new CmdFactionsWarpRemove();
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
							
								
								
									
										85
									
								
								src/com/massivecraft/factions/cmd/CmdFactionsWarpAdd.java
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										85
									
								
								src/com/massivecraft/factions/cmd/CmdFactionsWarpAdd.java
									
									
									
									
									
										Normal file
									
								
							@@ -0,0 +1,85 @@
 | 
				
			|||||||
 | 
					package com.massivecraft.factions.cmd;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					import com.massivecraft.factions.cmd.type.TypeFaction;
 | 
				
			||||||
 | 
					import com.massivecraft.factions.entity.Faction;
 | 
				
			||||||
 | 
					import com.massivecraft.factions.entity.MConf;
 | 
				
			||||||
 | 
					import com.massivecraft.factions.entity.MPerm;
 | 
				
			||||||
 | 
					import com.massivecraft.factions.entity.Warp;
 | 
				
			||||||
 | 
					import com.massivecraft.factions.event.EventFactionsWarpAdd;
 | 
				
			||||||
 | 
					import com.massivecraft.massivecore.MassiveException;
 | 
				
			||||||
 | 
					import com.massivecraft.massivecore.command.requirement.RequirementIsPlayer;
 | 
				
			||||||
 | 
					import com.massivecraft.massivecore.command.type.primitive.TypeString;
 | 
				
			||||||
 | 
					import com.massivecraft.massivecore.ps.PS;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					public class CmdFactionsWarpAdd extends FactionsCommandWarp
 | 
				
			||||||
 | 
					{
 | 
				
			||||||
 | 
						// -------------------------------------------- //
 | 
				
			||||||
 | 
						// CONSTRUCT
 | 
				
			||||||
 | 
						// -------------------------------------------- //
 | 
				
			||||||
 | 
						
 | 
				
			||||||
 | 
						public CmdFactionsWarpAdd()
 | 
				
			||||||
 | 
						{
 | 
				
			||||||
 | 
							// Parameters
 | 
				
			||||||
 | 
							this.addParameter(TypeString.get(), "name");
 | 
				
			||||||
 | 
							this.addParameter(TypeFaction.get(), "faction", "you");
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
							// Aliases
 | 
				
			||||||
 | 
							this.addAliases("create");
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
							// Requirements
 | 
				
			||||||
 | 
							this.addRequirements(RequirementIsPlayer.get());
 | 
				
			||||||
 | 
						}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
						// -------------------------------------------- //
 | 
				
			||||||
 | 
						// OVERRIDE
 | 
				
			||||||
 | 
						// -------------------------------------------- //
 | 
				
			||||||
 | 
						
 | 
				
			||||||
 | 
						@Override
 | 
				
			||||||
 | 
						public void perform() throws MassiveException
 | 
				
			||||||
 | 
						{
 | 
				
			||||||
 | 
							// Args
 | 
				
			||||||
 | 
							String name = this.readArg();
 | 
				
			||||||
 | 
							Faction faction = this.readArg(msenderFaction);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
							
 | 
				
			||||||
 | 
							PS ps = PS.valueOf(me.getLocation());
 | 
				
			||||||
 | 
							Warp warp = new Warp(name, ps);
 | 
				
			||||||
 | 
							
 | 
				
			||||||
 | 
							// MPerm
 | 
				
			||||||
 | 
							if ( ! MPerm.getPermSethome().has(msender, faction, true)) return;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
							if (faction.getWarps().getAll().stream().map(Warp::getName).anyMatch(s -> s.equalsIgnoreCase(name)))
 | 
				
			||||||
 | 
							{
 | 
				
			||||||
 | 
								throw new MassiveException().addMsg("<b>There is already a warp called <h>%s<b>.", name);
 | 
				
			||||||
 | 
							}
 | 
				
			||||||
 | 
							
 | 
				
			||||||
 | 
							// Verify
 | 
				
			||||||
 | 
							if (!msender.isOverriding() && !warp.isValidFor(faction))
 | 
				
			||||||
 | 
							{
 | 
				
			||||||
 | 
								throw new MassiveException().addMsg("<b>Sorry, your faction warps can only be set inside your own claimed territory.");
 | 
				
			||||||
 | 
							}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
							if (!msender.isOverriding() && faction.getWarps().size() >= MConf.get().warpsMax && MConf.get().warpsMax >= 0)
 | 
				
			||||||
 | 
							{
 | 
				
			||||||
 | 
								throw new MassiveException().addMsg("<b>You can at most have <h>%d <b>warps at a time.", MConf.get().warpsMax);
 | 
				
			||||||
 | 
							}
 | 
				
			||||||
 | 
							
 | 
				
			||||||
 | 
							// Event
 | 
				
			||||||
 | 
							EventFactionsWarpAdd event = new EventFactionsWarpAdd(sender, faction, warp);
 | 
				
			||||||
 | 
							event.run();
 | 
				
			||||||
 | 
							if (event.isCancelled()) return;
 | 
				
			||||||
 | 
							warp = event.getNewWarp();
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
							// Apply
 | 
				
			||||||
 | 
							faction.getWarps().attach(warp);
 | 
				
			||||||
 | 
							
 | 
				
			||||||
 | 
							// Inform
 | 
				
			||||||
 | 
							faction.msg("%s<i> added the warp <h>%s <i>to your faction. You can now use:", msender.describeTo(msenderFaction, true), warp.getName());
 | 
				
			||||||
 | 
							faction.sendMessage(CmdFactions.get().cmdFactionsWarp.cmdFactionsWarpGo.getTemplateWithArgs(null, warp.getName()));
 | 
				
			||||||
 | 
							if (faction != msenderFaction)
 | 
				
			||||||
 | 
							{
 | 
				
			||||||
 | 
								msender.msg("<i>You added the warp <h>%s <i>to %s<i>.", warp.getName(), faction.describeTo(msender));
 | 
				
			||||||
 | 
							}
 | 
				
			||||||
 | 
						}
 | 
				
			||||||
 | 
						
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
@@ -2,13 +2,15 @@ package com.massivecraft.factions.cmd;
 | 
				
			|||||||
 | 
					
 | 
				
			||||||
import com.massivecraft.factions.Rel;
 | 
					import com.massivecraft.factions.Rel;
 | 
				
			||||||
import com.massivecraft.factions.cmd.type.TypeFaction;
 | 
					import com.massivecraft.factions.cmd.type.TypeFaction;
 | 
				
			||||||
 | 
					import com.massivecraft.factions.cmd.type.TypeWarp;
 | 
				
			||||||
import com.massivecraft.factions.entity.BoardColl;
 | 
					import com.massivecraft.factions.entity.BoardColl;
 | 
				
			||||||
import com.massivecraft.factions.entity.Faction;
 | 
					import com.massivecraft.factions.entity.Faction;
 | 
				
			||||||
import com.massivecraft.factions.entity.MConf;
 | 
					import com.massivecraft.factions.entity.MConf;
 | 
				
			||||||
import com.massivecraft.factions.entity.MFlag;
 | 
					import com.massivecraft.factions.entity.MFlag;
 | 
				
			||||||
import com.massivecraft.factions.entity.MPerm;
 | 
					import com.massivecraft.factions.entity.MPerm;
 | 
				
			||||||
import com.massivecraft.factions.entity.MPlayer;
 | 
					import com.massivecraft.factions.entity.MPlayer;
 | 
				
			||||||
import com.massivecraft.factions.event.EventFactionsHomeTeleport;
 | 
					import com.massivecraft.factions.entity.Warp;
 | 
				
			||||||
 | 
					import com.massivecraft.factions.event.EventFactionsWarpTeleport;
 | 
				
			||||||
import com.massivecraft.massivecore.MassiveException;
 | 
					import com.massivecraft.massivecore.MassiveException;
 | 
				
			||||||
import com.massivecraft.massivecore.command.requirement.RequirementIsPlayer;
 | 
					import com.massivecraft.massivecore.command.requirement.RequirementIsPlayer;
 | 
				
			||||||
import com.massivecraft.massivecore.mixin.MixinMessage;
 | 
					import com.massivecraft.massivecore.mixin.MixinMessage;
 | 
				
			||||||
@@ -18,19 +20,21 @@ import com.massivecraft.massivecore.ps.PS;
 | 
				
			|||||||
import com.massivecraft.massivecore.teleport.Destination;
 | 
					import com.massivecraft.massivecore.teleport.Destination;
 | 
				
			||||||
import com.massivecraft.massivecore.teleport.DestinationSimple;
 | 
					import com.massivecraft.massivecore.teleport.DestinationSimple;
 | 
				
			||||||
import com.massivecraft.massivecore.util.MUtil;
 | 
					import com.massivecraft.massivecore.util.MUtil;
 | 
				
			||||||
 | 
					import com.massivecraft.massivecore.util.Txt;
 | 
				
			||||||
import org.bukkit.Location;
 | 
					import org.bukkit.Location;
 | 
				
			||||||
import org.bukkit.World;
 | 
					import org.bukkit.World;
 | 
				
			||||||
import org.bukkit.entity.Player;
 | 
					import org.bukkit.entity.Player;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
public class CmdFactionsHome extends FactionsCommandHome
 | 
					public class CmdFactionsWarpGo extends FactionsCommandWarp
 | 
				
			||||||
{
 | 
					{
 | 
				
			||||||
	// -------------------------------------------- //
 | 
						// -------------------------------------------- //
 | 
				
			||||||
	// CONSTRUCT
 | 
						// CONSTRUCT
 | 
				
			||||||
	// -------------------------------------------- //
 | 
						// -------------------------------------------- //
 | 
				
			||||||
	
 | 
						
 | 
				
			||||||
	public CmdFactionsHome()
 | 
						public CmdFactionsWarpGo()
 | 
				
			||||||
	{
 | 
						{
 | 
				
			||||||
		// Parameters
 | 
							// Parameters
 | 
				
			||||||
 | 
							this.addParameter(TypeWarp.get(), "warp");
 | 
				
			||||||
		this.addParameter(TypeFaction.get(), "faction", "you");
 | 
							this.addParameter(TypeFaction.get(), "faction", "you");
 | 
				
			||||||
 | 
					
 | 
				
			||||||
		// Requirements
 | 
							// Requirements
 | 
				
			||||||
@@ -44,53 +48,31 @@ public class CmdFactionsHome extends FactionsCommandHome
 | 
				
			|||||||
	@Override
 | 
						@Override
 | 
				
			||||||
	public void perform() throws MassiveException
 | 
						public void perform() throws MassiveException
 | 
				
			||||||
	{
 | 
						{
 | 
				
			||||||
		if ( ! MConf.get().homesTeleportCommandEnabled)
 | 
					 | 
				
			||||||
		{
 | 
					 | 
				
			||||||
			msender.msg("<b>Sorry, the ability to teleport to Faction homes is disabled on this server.");
 | 
					 | 
				
			||||||
			return;
 | 
					 | 
				
			||||||
		}
 | 
					 | 
				
			||||||
		
 | 
					 | 
				
			||||||
		// Args
 | 
							// Args
 | 
				
			||||||
		Faction faction = this.readArg(msenderFaction);
 | 
							Faction faction = this.readArgAt(1, msenderFaction);
 | 
				
			||||||
		PS home = faction.getHome();
 | 
							Warp warp = TypeWarp.get(faction).read(this.argAt(0), sender);
 | 
				
			||||||
		String homeDesc = "home for " + faction.describeTo(msender, false);
 | 
							String warpDesc = Txt.parse("<h>%s <i>in <reset>%s<i>.", warp.getName(), faction.describeTo(msender, false));
 | 
				
			||||||
		
 | 
							
 | 
				
			||||||
		// Any and MPerm
 | 
							// Any and MPerm
 | 
				
			||||||
		if ( ! MPerm.getPermHome().has(msender, faction, true)) return;
 | 
							if ( ! MPerm.getPermHome().has(msender, faction, true)) return;
 | 
				
			||||||
		
 | 
							
 | 
				
			||||||
		if (home == null)
 | 
							if ( ! MConf.get().warpsTeleportAllowedFromEnemyTerritory && msender.isInEnemyTerritory())
 | 
				
			||||||
		{
 | 
							{
 | 
				
			||||||
			msender.msg("<b>%s <b>does not have a home.", faction.describeTo(msender, true));
 | 
								throw new MassiveException().addMsg("<b>You cannot teleport to %s <b>while in the territory of an enemy faction.", warp);
 | 
				
			||||||
			
 | 
					 | 
				
			||||||
			if (MPerm.getPermSethome().has(msender, faction, false))
 | 
					 | 
				
			||||||
			{
 | 
					 | 
				
			||||||
				msender.msg("<i>You should:");
 | 
					 | 
				
			||||||
				msender.message(CmdFactions.get().cmdFactionsSethome.getTemplate());
 | 
					 | 
				
			||||||
		}
 | 
							}
 | 
				
			||||||
		
 | 
							
 | 
				
			||||||
			return;
 | 
							if ( ! MConf.get().warpsTeleportAllowedFromDifferentWorld && !me.getWorld().getName().equalsIgnoreCase(warp.getWorld()))
 | 
				
			||||||
		}
 | 
					 | 
				
			||||||
		
 | 
					 | 
				
			||||||
		if ( ! MConf.get().homesTeleportAllowedFromEnemyTerritory && msender.isInEnemyTerritory())
 | 
					 | 
				
			||||||
		{
 | 
							{
 | 
				
			||||||
			msender.msg("<b>You cannot teleport to %s <b>while in the territory of an enemy faction.", homeDesc);
 | 
								throw new MassiveException().addMsg("<b>You cannot teleport to %s <b>while in a different world.", warpDesc);
 | 
				
			||||||
			return;
 | 
					 | 
				
			||||||
		}
 | 
							}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
		if ( ! MConf.get().homesTeleportAllowedFromDifferentWorld && !me.getWorld().getName().equalsIgnoreCase(home.getWorld()))
 | 
					 | 
				
			||||||
		{
 | 
					 | 
				
			||||||
			msender.msg("<b>You cannot teleport to %s <b>while in a different world.", homeDesc);
 | 
					 | 
				
			||||||
			return;
 | 
					 | 
				
			||||||
		}
 | 
					 | 
				
			||||||
		
 | 
					 | 
				
			||||||
		
 | 
					 | 
				
			||||||
		Faction factionHere = BoardColl.get().getFactionAt(PS.valueOf(me.getLocation()));
 | 
							Faction factionHere = BoardColl.get().getFactionAt(PS.valueOf(me.getLocation()));
 | 
				
			||||||
		Location locationHere = me.getLocation().clone();
 | 
							Location locationHere = me.getLocation().clone();
 | 
				
			||||||
		
 | 
							
 | 
				
			||||||
		// if player is not in a safe zone or their own faction territory, only allow teleport if no enemies are nearby
 | 
							// if player is not in a safe zone or their own faction territory, only allow teleport if no enemies are nearby
 | 
				
			||||||
		if
 | 
							if
 | 
				
			||||||
		(
 | 
							(
 | 
				
			||||||
			MConf.get().homesTeleportAllowedEnemyDistance > 0
 | 
								MConf.get().warpsTeleportAllowedEnemyDistance > 0
 | 
				
			||||||
			&&
 | 
								&&
 | 
				
			||||||
			factionHere.getFlag(MFlag.getFlagPvp())
 | 
								factionHere.getFlag(MFlag.getFlagPvp())
 | 
				
			||||||
			&&
 | 
								&&
 | 
				
			||||||
@@ -100,7 +82,7 @@ public class CmdFactionsHome extends FactionsCommandHome
 | 
				
			|||||||
				(
 | 
									(
 | 
				
			||||||
					msender.isInOwnTerritory()
 | 
										msender.isInOwnTerritory()
 | 
				
			||||||
					&&
 | 
										&&
 | 
				
			||||||
					! MConf.get().homesTeleportIgnoreEnemiesIfInOwnTerritory
 | 
										! MConf.get().warpsTeleportIgnoreEnemiesIfInOwnTerritory
 | 
				
			||||||
				)
 | 
									)
 | 
				
			||||||
			)
 | 
								)
 | 
				
			||||||
		)
 | 
							)
 | 
				
			||||||
@@ -110,41 +92,38 @@ public class CmdFactionsHome extends FactionsCommandHome
 | 
				
			|||||||
			double y = locationHere.getY();
 | 
								double y = locationHere.getY();
 | 
				
			||||||
			double z = locationHere.getZ();
 | 
								double z = locationHere.getZ();
 | 
				
			||||||
 | 
					
 | 
				
			||||||
			for (Player p : me.getServer().getOnlinePlayers())
 | 
								for (Player p : w.getPlayers())
 | 
				
			||||||
			{
 | 
								{
 | 
				
			||||||
				if (MUtil.isntPlayer(p)) continue;
 | 
									if (MUtil.isntPlayer(p)) continue;
 | 
				
			||||||
				
 | 
									
 | 
				
			||||||
				if (p == null || !p.isOnline() || p.isDead() || p == me || p.getWorld() != w)
 | 
									if (p == null || !p.isOnline() || p.isDead() || p == me || p.getWorld() != w) continue;
 | 
				
			||||||
					continue;
 | 
					 | 
				
			||||||
 | 
					
 | 
				
			||||||
				MPlayer fp = MPlayer.get(p);
 | 
									MPlayer fp = MPlayer.get(p);
 | 
				
			||||||
				if (msender.getRelationTo(fp) != Rel.ENEMY)
 | 
									if (msender.getRelationTo(fp) != Rel.ENEMY) continue;
 | 
				
			||||||
					continue;
 | 
					 | 
				
			||||||
 | 
					
 | 
				
			||||||
				Location l = p.getLocation();
 | 
									Location l = p.getLocation();
 | 
				
			||||||
				double dx = Math.abs(x - l.getX());
 | 
									double dx = Math.abs(x - l.getX());
 | 
				
			||||||
				double dy = Math.abs(y - l.getY());
 | 
									double dy = Math.abs(y - l.getY());
 | 
				
			||||||
				double dz = Math.abs(z - l.getZ());
 | 
									double dz = Math.abs(z - l.getZ());
 | 
				
			||||||
				double max = MConf.get().homesTeleportAllowedEnemyDistance;
 | 
									double max = MConf.get().warpsTeleportAllowedEnemyDistance;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
				// box-shaped distance check
 | 
									// box-shaped distance check
 | 
				
			||||||
				if (dx > max || dy > max || dz > max)
 | 
									if (dx > max || dy > max || dz > max)
 | 
				
			||||||
					continue;
 | 
										continue;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
				msender.msg("<b>You cannot teleport to %s <b>while an enemy is within %f blocks of you.", homeDesc, MConf.get().homesTeleportAllowedEnemyDistance);
 | 
									throw new MassiveException().addMsg("<b>You cannot teleport to %s <b>while an enemy is within %f blocks of you.", warpDesc, max);
 | 
				
			||||||
				return;
 | 
					 | 
				
			||||||
			}
 | 
								}
 | 
				
			||||||
		}
 | 
							}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
		// Event
 | 
							// Event
 | 
				
			||||||
		EventFactionsHomeTeleport event = new EventFactionsHomeTeleport(sender);
 | 
							EventFactionsWarpTeleport event = new EventFactionsWarpTeleport(sender, warp);
 | 
				
			||||||
		event.run();
 | 
							event.run();
 | 
				
			||||||
		if (event.isCancelled()) return;
 | 
							if (event.isCancelled()) return;
 | 
				
			||||||
		
 | 
							
 | 
				
			||||||
		// Apply
 | 
							// Apply
 | 
				
			||||||
		try
 | 
							try
 | 
				
			||||||
		{
 | 
							{
 | 
				
			||||||
			Destination destination = new DestinationSimple(home, homeDesc);
 | 
								Destination destination = new DestinationSimple(warp.getLocation(), warpDesc);
 | 
				
			||||||
			MixinTeleport.get().teleport(me, destination, sender);
 | 
								MixinTeleport.get().teleport(me, destination, sender);
 | 
				
			||||||
		}
 | 
							}
 | 
				
			||||||
		catch (TeleporterException e)
 | 
							catch (TeleporterException e)
 | 
				
			||||||
							
								
								
									
										48
									
								
								src/com/massivecraft/factions/cmd/CmdFactionsWarpList.java
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										48
									
								
								src/com/massivecraft/factions/cmd/CmdFactionsWarpList.java
									
									
									
									
									
										Normal file
									
								
							@@ -0,0 +1,48 @@
 | 
				
			|||||||
 | 
					package com.massivecraft.factions.cmd;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					import com.massivecraft.factions.cmd.type.TypeFaction;
 | 
				
			||||||
 | 
					import com.massivecraft.factions.entity.Faction;
 | 
				
			||||||
 | 
					import com.massivecraft.factions.entity.MPerm;
 | 
				
			||||||
 | 
					import com.massivecraft.factions.entity.Warp;
 | 
				
			||||||
 | 
					import com.massivecraft.massivecore.MassiveException;
 | 
				
			||||||
 | 
					import com.massivecraft.massivecore.command.Parameter;
 | 
				
			||||||
 | 
					import com.massivecraft.massivecore.pager.Pager;
 | 
				
			||||||
 | 
					import com.massivecraft.massivecore.pager.Stringifier;
 | 
				
			||||||
 | 
					import com.massivecraft.massivecore.ps.PSFormatDesc;
 | 
				
			||||||
 | 
					import com.massivecraft.massivecore.util.Txt;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					public class CmdFactionsWarpList extends FactionsCommandWarp
 | 
				
			||||||
 | 
					{
 | 
				
			||||||
 | 
						// -------------------------------------------- //
 | 
				
			||||||
 | 
						// CONSTRUCT
 | 
				
			||||||
 | 
						// -------------------------------------------- //
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
						public CmdFactionsWarpList()
 | 
				
			||||||
 | 
						{
 | 
				
			||||||
 | 
							// Parameters
 | 
				
			||||||
 | 
							this.addParameter(TypeFaction.get(), "faction", "you");
 | 
				
			||||||
 | 
							this.addParameter(Parameter.getPage());
 | 
				
			||||||
 | 
						}
 | 
				
			||||||
 | 
						
 | 
				
			||||||
 | 
						// -------------------------------------------- //
 | 
				
			||||||
 | 
						// OVERRIDE
 | 
				
			||||||
 | 
						// -------------------------------------------- //
 | 
				
			||||||
 | 
						
 | 
				
			||||||
 | 
						@Override
 | 
				
			||||||
 | 
						public void perform() throws MassiveException
 | 
				
			||||||
 | 
						{
 | 
				
			||||||
 | 
							// Args
 | 
				
			||||||
 | 
							Faction faction = this.readArg(msenderFaction);
 | 
				
			||||||
 | 
							int idx = this.readArg();
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
							// Any and MPerm
 | 
				
			||||||
 | 
							if ( ! MPerm.getPermHome().has(msender, faction, true)) return;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
							Pager<Warp> pager = new Pager<>(this, "Warps for " + faction.getName(), idx, faction.getWarps().getAll());
 | 
				
			||||||
 | 
							pager.setMsonifier((Stringifier<Warp>)  (warp, i) ->
 | 
				
			||||||
 | 
								Txt.parse("<lime>%s<i>: %s", warp.getName(), warp.getLocation().getBlock(true).toString(PSFormatDesc.get())));
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
							pager.message();
 | 
				
			||||||
 | 
						}
 | 
				
			||||||
 | 
						
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
@@ -1,20 +1,23 @@
 | 
				
			|||||||
package com.massivecraft.factions.cmd;
 | 
					package com.massivecraft.factions.cmd;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
import com.massivecraft.factions.cmd.type.TypeFaction;
 | 
					import com.massivecraft.factions.cmd.type.TypeFaction;
 | 
				
			||||||
 | 
					import com.massivecraft.factions.cmd.type.TypeWarp;
 | 
				
			||||||
import com.massivecraft.factions.entity.Faction;
 | 
					import com.massivecraft.factions.entity.Faction;
 | 
				
			||||||
import com.massivecraft.factions.entity.MPerm;
 | 
					import com.massivecraft.factions.entity.MPerm;
 | 
				
			||||||
import com.massivecraft.factions.event.EventFactionsHomeChange;
 | 
					import com.massivecraft.factions.entity.Warp;
 | 
				
			||||||
 | 
					import com.massivecraft.factions.event.EventFactionsWarpRemove;
 | 
				
			||||||
import com.massivecraft.massivecore.MassiveException;
 | 
					import com.massivecraft.massivecore.MassiveException;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
public class CmdFactionsUnsethome extends FactionsCommandHome
 | 
					public class CmdFactionsWarpRemove extends FactionsCommandWarp
 | 
				
			||||||
{
 | 
					{
 | 
				
			||||||
	// -------------------------------------------- //
 | 
						// -------------------------------------------- //
 | 
				
			||||||
	// CONSTRUCT
 | 
						// CONSTRUCT
 | 
				
			||||||
	// -------------------------------------------- //
 | 
						// -------------------------------------------- //
 | 
				
			||||||
	
 | 
						
 | 
				
			||||||
	public CmdFactionsUnsethome()
 | 
						public CmdFactionsWarpRemove()
 | 
				
			||||||
	{
 | 
						{
 | 
				
			||||||
		// Parameters
 | 
							// Parameters
 | 
				
			||||||
 | 
							this.addParameter(TypeWarp.get(), "warp");
 | 
				
			||||||
		this.addParameter(TypeFaction.get(), "faction", "you");
 | 
							this.addParameter(TypeFaction.get(), "faction", "you");
 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
@@ -26,31 +29,25 @@ public class CmdFactionsUnsethome extends FactionsCommandHome
 | 
				
			|||||||
	public void perform() throws MassiveException
 | 
						public void perform() throws MassiveException
 | 
				
			||||||
	{
 | 
						{
 | 
				
			||||||
		// Args
 | 
							// Args
 | 
				
			||||||
		Faction faction = this.readArg(msenderFaction);
 | 
							Faction faction = this.readArgAt(1, msenderFaction);
 | 
				
			||||||
 | 
							Warp warp = TypeWarp.get(faction).read(this.argAt(0), sender);
 | 
				
			||||||
		
 | 
							
 | 
				
			||||||
		// Any and MPerm
 | 
							// Any and MPerm
 | 
				
			||||||
		if ( ! MPerm.getPermSethome().has(msender, faction, true)) return;
 | 
							if ( ! MPerm.getPermSethome().has(msender, faction, true)) return;
 | 
				
			||||||
		
 | 
							
 | 
				
			||||||
		// NoChange
 | 
					 | 
				
			||||||
		if ( ! faction.hasHome())
 | 
					 | 
				
			||||||
		{
 | 
					 | 
				
			||||||
			msender.msg("<i>%s <i>does already not have a home.", faction.describeTo(msender));
 | 
					 | 
				
			||||||
			return;
 | 
					 | 
				
			||||||
		}
 | 
					 | 
				
			||||||
		
 | 
					 | 
				
			||||||
		// Event
 | 
							// Event
 | 
				
			||||||
		EventFactionsHomeChange event = new EventFactionsHomeChange(sender, faction, null);
 | 
							EventFactionsWarpRemove event = new EventFactionsWarpRemove(sender, faction, warp);
 | 
				
			||||||
		event.run();
 | 
							event.run();
 | 
				
			||||||
		if (event.isCancelled()) return;
 | 
							if (event.isCancelled()) return;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
		// Apply
 | 
							// Apply
 | 
				
			||||||
		faction.setHome(null);
 | 
							warp.detach();
 | 
				
			||||||
		
 | 
							
 | 
				
			||||||
		// Inform
 | 
							// Inform
 | 
				
			||||||
		faction.msg("%s<i> unset the home for your faction.", msender.describeTo(msenderFaction, true));
 | 
							faction.msg("%s<i> removed the warp <h>%s <i>for your faction.", msender.describeTo(msenderFaction, true), warp.getName());
 | 
				
			||||||
		if (faction != msenderFaction)
 | 
							if (faction != msenderFaction)
 | 
				
			||||||
		{
 | 
							{
 | 
				
			||||||
			msender.msg("<i>You have unset the home for " + faction.getName(msender) + "<i>.");
 | 
								msender.msg("<i>You have removed the warp <h>%s <i>for %s<i>.", warp.getName(), faction.getName(msender));
 | 
				
			||||||
		}
 | 
							}
 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
	
 | 
						
 | 
				
			||||||
@@ -1,6 +1,6 @@
 | 
				
			|||||||
package com.massivecraft.factions.cmd;
 | 
					package com.massivecraft.factions.cmd;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
import com.massivecraft.factions.cmd.req.ReqFactionHomesEnabled;
 | 
					import com.massivecraft.factions.cmd.req.ReqFactionWarpsEnabled;
 | 
				
			||||||
import com.massivecraft.massivecore.mson.Mson;
 | 
					import com.massivecraft.massivecore.mson.Mson;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
public class FactionsCommandDocumentation extends FactionsCommand
 | 
					public class FactionsCommandDocumentation extends FactionsCommand
 | 
				
			||||||
@@ -11,7 +11,7 @@ public class FactionsCommandDocumentation extends FactionsCommand
 | 
				
			|||||||
 | 
					
 | 
				
			||||||
	public FactionsCommandDocumentation()
 | 
						public FactionsCommandDocumentation()
 | 
				
			||||||
	{
 | 
						{
 | 
				
			||||||
		this.addRequirements(ReqFactionHomesEnabled.get());
 | 
							this.addRequirements(ReqFactionWarpsEnabled.get());
 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
	
 | 
						
 | 
				
			||||||
	// -------------------------------------------- //
 | 
						// -------------------------------------------- //
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -1,18 +1,18 @@
 | 
				
			|||||||
package com.massivecraft.factions.cmd;
 | 
					package com.massivecraft.factions.cmd;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
import com.massivecraft.factions.cmd.req.ReqFactionHomesEnabled;
 | 
					import com.massivecraft.factions.cmd.req.ReqFactionWarpsEnabled;
 | 
				
			||||||
import com.massivecraft.factions.entity.MConf;
 | 
					import com.massivecraft.factions.entity.MConf;
 | 
				
			||||||
import com.massivecraft.massivecore.command.Visibility;
 | 
					import com.massivecraft.massivecore.command.Visibility;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
public class FactionsCommandHome extends FactionsCommand
 | 
					public class FactionsCommandWarp extends FactionsCommand
 | 
				
			||||||
{
 | 
					{
 | 
				
			||||||
	// -------------------------------------------- //
 | 
						// -------------------------------------------- //
 | 
				
			||||||
	// CONSTRUCT
 | 
						// CONSTRUCT
 | 
				
			||||||
	// -------------------------------------------- //
 | 
						// -------------------------------------------- //
 | 
				
			||||||
	
 | 
						
 | 
				
			||||||
	public FactionsCommandHome()
 | 
						public FactionsCommandWarp()
 | 
				
			||||||
	{
 | 
						{
 | 
				
			||||||
		this.addRequirements(ReqFactionHomesEnabled.get());
 | 
							this.addRequirements(ReqFactionWarpsEnabled.get());
 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
	
 | 
						
 | 
				
			||||||
	// -------------------------------------------- //
 | 
						// -------------------------------------------- //
 | 
				
			||||||
@@ -22,7 +22,7 @@ public class FactionsCommandHome extends FactionsCommand
 | 
				
			|||||||
	@Override
 | 
						@Override
 | 
				
			||||||
	public Visibility getVisibility()
 | 
						public Visibility getVisibility()
 | 
				
			||||||
	{
 | 
						{
 | 
				
			||||||
		return MConf.get().homesEnabled ? super.getVisibility() : Visibility.INVISIBLE;  
 | 
							return MConf.get().warpsEnabled ? super.getVisibility() : Visibility.INVISIBLE;
 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
	
 | 
						
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
@@ -6,7 +6,7 @@ import com.massivecraft.massivecore.command.requirement.RequirementAbstract;
 | 
				
			|||||||
import com.massivecraft.massivecore.util.Txt;
 | 
					import com.massivecraft.massivecore.util.Txt;
 | 
				
			||||||
import org.bukkit.command.CommandSender;
 | 
					import org.bukkit.command.CommandSender;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
public class ReqFactionHomesEnabled extends RequirementAbstract
 | 
					public class ReqFactionWarpsEnabled extends RequirementAbstract
 | 
				
			||||||
{
 | 
					{
 | 
				
			||||||
	// -------------------------------------------- //
 | 
						// -------------------------------------------- //
 | 
				
			||||||
	// SERIALIZABLE
 | 
						// SERIALIZABLE
 | 
				
			||||||
@@ -18,8 +18,8 @@ public class ReqFactionHomesEnabled extends RequirementAbstract
 | 
				
			|||||||
	// INSTANCE & CONSTRUCT
 | 
						// INSTANCE & CONSTRUCT
 | 
				
			||||||
	// -------------------------------------------- //
 | 
						// -------------------------------------------- //
 | 
				
			||||||
	
 | 
						
 | 
				
			||||||
	private static ReqFactionHomesEnabled i = new ReqFactionHomesEnabled();
 | 
						private static ReqFactionWarpsEnabled i = new ReqFactionWarpsEnabled();
 | 
				
			||||||
	public static ReqFactionHomesEnabled get() { return i; }
 | 
						public static ReqFactionWarpsEnabled get() { return i; }
 | 
				
			||||||
	
 | 
						
 | 
				
			||||||
	// -------------------------------------------- //
 | 
						// -------------------------------------------- //
 | 
				
			||||||
	// OVERRIDE
 | 
						// OVERRIDE
 | 
				
			||||||
@@ -28,13 +28,13 @@ public class ReqFactionHomesEnabled extends RequirementAbstract
 | 
				
			|||||||
	@Override
 | 
						@Override
 | 
				
			||||||
	public boolean apply(CommandSender sender, MassiveCommand command)
 | 
						public boolean apply(CommandSender sender, MassiveCommand command)
 | 
				
			||||||
	{
 | 
						{
 | 
				
			||||||
		return MConf.get().homesEnabled;
 | 
							return MConf.get().warpsEnabled;
 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
	
 | 
						
 | 
				
			||||||
	@Override
 | 
						@Override
 | 
				
			||||||
	public String createErrorMessage(CommandSender sender, MassiveCommand command)
 | 
						public String createErrorMessage(CommandSender sender, MassiveCommand command)
 | 
				
			||||||
	{
 | 
						{
 | 
				
			||||||
		return Txt.parse("<b>Homes must be enabled on the server to %s.", getDesc(command));
 | 
							return Txt.parse("<b>Warps must be enabled on the server to %s.", getDesc(command));
 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
	
 | 
						
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
@@ -0,0 +1,56 @@
 | 
				
			|||||||
 | 
					package com.massivecraft.factions.cmd.type;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					import com.massivecraft.factions.entity.Faction;
 | 
				
			||||||
 | 
					import com.massivecraft.massivecore.command.type.TypeAbstractChoice;
 | 
				
			||||||
 | 
					import com.massivecraft.massivecore.store.EntityInternal;
 | 
				
			||||||
 | 
					import org.bukkit.command.CommandSender;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					import java.util.Collection;
 | 
				
			||||||
 | 
					import java.util.Collections;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					public abstract class TypeEntityInternalFaction<E extends EntityInternal<E>> extends TypeAbstractChoice<E>
 | 
				
			||||||
 | 
					{
 | 
				
			||||||
 | 
						// -------------------------------------------- //
 | 
				
			||||||
 | 
						// INSTANCE & CONSTRUCT
 | 
				
			||||||
 | 
						// -------------------------------------------- //
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
						protected TypeEntityInternalFaction(Class<E> clazz)
 | 
				
			||||||
 | 
						{
 | 
				
			||||||
 | 
							super(clazz);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
							this.faction = null;
 | 
				
			||||||
 | 
							this.setAll(Collections.emptyList());
 | 
				
			||||||
 | 
						}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
						protected TypeEntityInternalFaction(Class<E> clazz, Faction faction)
 | 
				
			||||||
 | 
						{
 | 
				
			||||||
 | 
							super(clazz);
 | 
				
			||||||
 | 
							if (faction == null) throw new NullPointerException("faction");
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
							this.faction = faction;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
							this.setAll(this.getAll(faction));
 | 
				
			||||||
 | 
						}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
						protected abstract Collection<E> getAll(Faction faction);
 | 
				
			||||||
 | 
						
 | 
				
			||||||
 | 
						// -------------------------------------------- //
 | 
				
			||||||
 | 
						// FIELDS
 | 
				
			||||||
 | 
						// -------------------------------------------- //
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
						private final Faction faction;
 | 
				
			||||||
 | 
						public Faction getFaction() { return this.faction; }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
						// -------------------------------------------- //
 | 
				
			||||||
 | 
						// OVERRIDE
 | 
				
			||||||
 | 
						// -------------------------------------------- //
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
						@Override
 | 
				
			||||||
 | 
						public boolean isValid(String arg, CommandSender sender)
 | 
				
			||||||
 | 
						{
 | 
				
			||||||
 | 
							// In the generic case accept all
 | 
				
			||||||
 | 
							if (this.getAll().isEmpty()) return true;
 | 
				
			||||||
 | 
							else return super.isValid(arg, sender);
 | 
				
			||||||
 | 
						}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
@@ -1,16 +1,13 @@
 | 
				
			|||||||
package com.massivecraft.factions.cmd.type;
 | 
					package com.massivecraft.factions.cmd.type;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
import com.massivecraft.factions.Rel;
 | 
					 | 
				
			||||||
import com.massivecraft.factions.entity.Faction;
 | 
					import com.massivecraft.factions.entity.Faction;
 | 
				
			||||||
import com.massivecraft.factions.entity.Rank;
 | 
					import com.massivecraft.factions.entity.Rank;
 | 
				
			||||||
import com.massivecraft.massivecore.command.type.TypeAbstractChoice;
 | 
					 | 
				
			||||||
import com.massivecraft.massivecore.util.MUtil;
 | 
					import com.massivecraft.massivecore.util.MUtil;
 | 
				
			||||||
import org.bukkit.command.CommandSender;
 | 
					 | 
				
			||||||
 | 
					
 | 
				
			||||||
import java.util.Collections;
 | 
					import java.util.Collection;
 | 
				
			||||||
import java.util.Set;
 | 
					import java.util.Set;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
public class TypeRank extends TypeAbstractChoice<Rank>
 | 
					public class TypeRank extends TypeEntityInternalFaction<Rank>
 | 
				
			||||||
{
 | 
					{
 | 
				
			||||||
	// -------------------------------------------- //
 | 
						// -------------------------------------------- //
 | 
				
			||||||
	// INSTANCE & CONSTRUCT
 | 
						// INSTANCE & CONSTRUCT
 | 
				
			||||||
@@ -21,39 +18,22 @@ public class TypeRank extends TypeAbstractChoice<Rank>
 | 
				
			|||||||
	private TypeRank()
 | 
						private TypeRank()
 | 
				
			||||||
	{
 | 
						{
 | 
				
			||||||
		super(Rank.class);
 | 
							super(Rank.class);
 | 
				
			||||||
 | 
					 | 
				
			||||||
		this.faction = null;
 | 
					 | 
				
			||||||
		this.setAll(Collections.emptyList());
 | 
					 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	public static TypeRank get(Faction faction) { return new TypeRank(faction); }
 | 
						public static TypeRank get(Faction faction) { return new TypeRank(faction); }
 | 
				
			||||||
	public TypeRank(Faction faction)
 | 
						public TypeRank(Faction faction)
 | 
				
			||||||
	{
 | 
						{
 | 
				
			||||||
		super(Rel.class);
 | 
							super(Rank.class, faction);
 | 
				
			||||||
		if (faction == null) throw new NullPointerException("faction");
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
		this.faction = faction;
 | 
					 | 
				
			||||||
		
 | 
					 | 
				
			||||||
		this.setAll(faction.getRanks().getAll());
 | 
					 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	// -------------------------------------------- //
 | 
					 | 
				
			||||||
	// FIELDS
 | 
					 | 
				
			||||||
	// -------------------------------------------- //
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
	private final Faction faction;
 | 
					 | 
				
			||||||
	public Faction getFaction() { return this.faction; }
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
	// -------------------------------------------- //
 | 
						// -------------------------------------------- //
 | 
				
			||||||
	// OVERRIDE
 | 
						// OVERRIDE
 | 
				
			||||||
	// -------------------------------------------- //
 | 
						// -------------------------------------------- //
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	@Override
 | 
						@Override
 | 
				
			||||||
	public boolean isValid(String arg, CommandSender sender)
 | 
						public Collection<Rank> getAll(Faction faction)
 | 
				
			||||||
	{
 | 
						{
 | 
				
			||||||
		// In the generic case accept all
 | 
							return faction.getRanks().getAll();
 | 
				
			||||||
		if (this.getAll().isEmpty()) return true;
 | 
					 | 
				
			||||||
		else return super.isValid(arg, sender);
 | 
					 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	@Override
 | 
						@Override
 | 
				
			||||||
 
 | 
				
			|||||||
							
								
								
									
										37
									
								
								src/com/massivecraft/factions/cmd/type/TypeWarp.java
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										37
									
								
								src/com/massivecraft/factions/cmd/type/TypeWarp.java
									
									
									
									
									
										Normal file
									
								
							@@ -0,0 +1,37 @@
 | 
				
			|||||||
 | 
					package com.massivecraft.factions.cmd.type;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					import com.massivecraft.factions.entity.Faction;
 | 
				
			||||||
 | 
					import com.massivecraft.factions.entity.Warp;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					import java.util.Collection;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					public class TypeWarp extends TypeEntityInternalFaction<Warp>
 | 
				
			||||||
 | 
					{
 | 
				
			||||||
 | 
						// -------------------------------------------- //
 | 
				
			||||||
 | 
						// INSTANCE & CONSTRUCT
 | 
				
			||||||
 | 
						// -------------------------------------------- //
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
						private static TypeWarp i = new TypeWarp();
 | 
				
			||||||
 | 
						public static TypeWarp get() { return i; }
 | 
				
			||||||
 | 
						private TypeWarp()
 | 
				
			||||||
 | 
						{
 | 
				
			||||||
 | 
							super(Warp.class);
 | 
				
			||||||
 | 
						}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
						public static TypeWarp get(Faction faction) { return new TypeWarp(faction); }
 | 
				
			||||||
 | 
						public TypeWarp(Faction faction)
 | 
				
			||||||
 | 
						{
 | 
				
			||||||
 | 
							super(Warp.class, faction);
 | 
				
			||||||
 | 
						}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
						// -------------------------------------------- //
 | 
				
			||||||
 | 
						// OVERRIDE
 | 
				
			||||||
 | 
						// -------------------------------------------- //
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
						@Override
 | 
				
			||||||
 | 
						public Collection<Warp> getAll(Faction faction)
 | 
				
			||||||
 | 
						{
 | 
				
			||||||
 | 
							return faction.getWarps().getAll();
 | 
				
			||||||
 | 
						}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
@@ -12,8 +12,9 @@ import com.massivecraft.factions.event.EventFactionsCreate;
 | 
				
			|||||||
import com.massivecraft.factions.event.EventFactionsDescriptionChange;
 | 
					import com.massivecraft.factions.event.EventFactionsDescriptionChange;
 | 
				
			||||||
import com.massivecraft.factions.event.EventFactionsDisband;
 | 
					import com.massivecraft.factions.event.EventFactionsDisband;
 | 
				
			||||||
import com.massivecraft.factions.event.EventFactionsFlagChange;
 | 
					import com.massivecraft.factions.event.EventFactionsFlagChange;
 | 
				
			||||||
import com.massivecraft.factions.event.EventFactionsHomeChange;
 | 
					import com.massivecraft.factions.event.EventFactionsWarpAdd;
 | 
				
			||||||
import com.massivecraft.factions.event.EventFactionsHomeTeleport;
 | 
					import com.massivecraft.factions.event.EventFactionsWarpRemove;
 | 
				
			||||||
 | 
					import com.massivecraft.factions.event.EventFactionsWarpTeleport;
 | 
				
			||||||
import com.massivecraft.factions.event.EventFactionsInvitedChange;
 | 
					import com.massivecraft.factions.event.EventFactionsInvitedChange;
 | 
				
			||||||
import com.massivecraft.factions.event.EventFactionsMembershipChange;
 | 
					import com.massivecraft.factions.event.EventFactionsMembershipChange;
 | 
				
			||||||
import com.massivecraft.factions.event.EventFactionsMembershipChange.MembershipChangeReason;
 | 
					import com.massivecraft.factions.event.EventFactionsMembershipChange.MembershipChangeReason;
 | 
				
			||||||
@@ -177,10 +178,19 @@ public class EngineEcon extends Engine
 | 
				
			|||||||
	}
 | 
						}
 | 
				
			||||||
	
 | 
						
 | 
				
			||||||
	@EventHandler(priority = EventPriority.HIGH, ignoreCancelled = true)
 | 
						@EventHandler(priority = EventPriority.HIGH, ignoreCancelled = true)
 | 
				
			||||||
	public void payForCommand(EventFactionsHomeChange event)
 | 
						public void payForCommand(EventFactionsWarpAdd event)
 | 
				
			||||||
	{
 | 
						{
 | 
				
			||||||
		Double cost = MConf.get().econCostSethome;
 | 
							Double cost = MConf.get().econCostWarpAdd;
 | 
				
			||||||
		String desc = CmdFactions.get().cmdFactionsSethome.getDesc();
 | 
							String desc = CmdFactions.get().cmdFactionsWarp.cmdFactionWarpAdd.getDesc();
 | 
				
			||||||
 | 
							
 | 
				
			||||||
 | 
							payForAction(event, cost, desc);
 | 
				
			||||||
 | 
						}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
						@EventHandler(priority = EventPriority.HIGH, ignoreCancelled = true)
 | 
				
			||||||
 | 
						public void payForCommand(EventFactionsWarpRemove event)
 | 
				
			||||||
 | 
						{
 | 
				
			||||||
 | 
							Double cost = MConf.get().econCostWarpRemove;
 | 
				
			||||||
 | 
							String desc = CmdFactions.get().cmdFactionsWarp.cmdFactionWarpRemove.getDesc();
 | 
				
			||||||
 | 
					
 | 
				
			||||||
		payForAction(event, cost, desc);
 | 
							payForAction(event, cost, desc);
 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
@@ -240,13 +250,12 @@ public class EngineEcon extends Engine
 | 
				
			|||||||
	}
 | 
						}
 | 
				
			||||||
	
 | 
						
 | 
				
			||||||
	@EventHandler(priority = EventPriority.HIGH, ignoreCancelled = true)
 | 
						@EventHandler(priority = EventPriority.HIGH, ignoreCancelled = true)
 | 
				
			||||||
	public void payForCommand(EventFactionsHomeTeleport event)
 | 
						public void payForCommand(EventFactionsWarpTeleport event)
 | 
				
			||||||
	{
 | 
						{
 | 
				
			||||||
		Double cost = MConf.get().econCostHome;
 | 
							Double cost = MConf.get().econCostWarpGo;
 | 
				
			||||||
		String desc = CmdFactions.get().cmdFactionsHome.getDesc();
 | 
							String desc = CmdFactions.get().cmdFactionsWarp.cmdFactionsWarpGo.getDesc();
 | 
				
			||||||
		
 | 
							
 | 
				
			||||||
		payForAction(event, cost, desc);
 | 
							payForAction(event, cost, desc);
 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -3,8 +3,8 @@ package com.massivecraft.factions.engine;
 | 
				
			|||||||
import com.massivecraft.factions.entity.Faction;
 | 
					import com.massivecraft.factions.entity.Faction;
 | 
				
			||||||
import com.massivecraft.factions.entity.MConf;
 | 
					import com.massivecraft.factions.entity.MConf;
 | 
				
			||||||
import com.massivecraft.factions.entity.MPlayer;
 | 
					import com.massivecraft.factions.entity.MPlayer;
 | 
				
			||||||
 | 
					import com.massivecraft.factions.entity.Warp;
 | 
				
			||||||
import com.massivecraft.massivecore.Engine;
 | 
					import com.massivecraft.massivecore.Engine;
 | 
				
			||||||
import com.massivecraft.massivecore.ps.PS;
 | 
					 | 
				
			||||||
import com.massivecraft.massivecore.util.MUtil;
 | 
					import com.massivecraft.massivecore.util.MUtil;
 | 
				
			||||||
import org.bukkit.Location;
 | 
					import org.bukkit.Location;
 | 
				
			||||||
import org.bukkit.entity.Player;
 | 
					import org.bukkit.entity.Player;
 | 
				
			||||||
@@ -12,6 +12,8 @@ import org.bukkit.event.EventHandler;
 | 
				
			|||||||
import org.bukkit.event.EventPriority;
 | 
					import org.bukkit.event.EventPriority;
 | 
				
			||||||
import org.bukkit.event.player.PlayerRespawnEvent;
 | 
					import org.bukkit.event.player.PlayerRespawnEvent;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					import java.util.List;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
public class EngineTeleportHomeOnDeath extends Engine
 | 
					public class EngineTeleportHomeOnDeath extends Engine
 | 
				
			||||||
{
 | 
					{
 | 
				
			||||||
	// -------------------------------------------- //
 | 
						// -------------------------------------------- //
 | 
				
			||||||
@@ -33,23 +35,25 @@ public class EngineTeleportHomeOnDeath extends Engine
 | 
				
			|||||||
		final MPlayer mplayer = MPlayer.get(player);
 | 
							final MPlayer mplayer = MPlayer.get(player);
 | 
				
			||||||
		
 | 
							
 | 
				
			||||||
		// ... homes are enabled, active and at this priority ...
 | 
							// ... homes are enabled, active and at this priority ...
 | 
				
			||||||
		if (!MConf.get().homesEnabled) return;
 | 
							if (!MConf.get().warpsEnabled) return;
 | 
				
			||||||
		if (!MConf.get().homesTeleportToOnDeathActive) return;
 | 
							if (!MConf.get().warpsTeleportToOnDeathActive) return;
 | 
				
			||||||
		if (MConf.get().homesTeleportToOnDeathPriority != priority) return;
 | 
							if (MConf.get().warpsTeleportToOnDeathPriority != priority) return;
 | 
				
			||||||
		
 | 
							
 | 
				
			||||||
		// ... and the player has a faction ...
 | 
							// ... and the player has a faction ...
 | 
				
			||||||
		final Faction faction = mplayer.getFaction();
 | 
							final Faction faction = mplayer.getFaction();
 | 
				
			||||||
		if (faction.isNone()) return;
 | 
							if (faction.isNone()) return;
 | 
				
			||||||
		
 | 
							
 | 
				
			||||||
		// ... and the faction has a home ...
 | 
							// ... and the faction has a home ...
 | 
				
			||||||
		PS home = faction.getHome();
 | 
							List<Warp> warps = faction.getWarps().getAll(warp -> warp.getName().equalsIgnoreCase(MConf.get().warpsTeleportToOnDeathName));
 | 
				
			||||||
		if (home == null) return;
 | 
							if (warps.isEmpty()) return;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
							Warp warp = warps.get(0);
 | 
				
			||||||
		
 | 
							
 | 
				
			||||||
		// ... and the home is translatable ...
 | 
							// ... and the home is translatable ...
 | 
				
			||||||
		Location respawnLocation = null;
 | 
							Location respawnLocation = null;
 | 
				
			||||||
		try
 | 
							try
 | 
				
			||||||
		{
 | 
							{
 | 
				
			||||||
			respawnLocation = home.asBukkitLocation(true);
 | 
								respawnLocation = warp.getLocation().asBukkitLocation(true);
 | 
				
			||||||
		}
 | 
							}
 | 
				
			||||||
		catch (Exception e)
 | 
							catch (Exception e)
 | 
				
			||||||
		{
 | 
							{
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -70,7 +70,7 @@ public class Faction extends Entity<Faction> implements FactionsParticipator, MP
 | 
				
			|||||||
		this.setDescription(that.description);
 | 
							this.setDescription(that.description);
 | 
				
			||||||
		this.setMotd(that.motd);
 | 
							this.setMotd(that.motd);
 | 
				
			||||||
		this.setCreatedAtMillis(that.createdAtMillis);
 | 
							this.setCreatedAtMillis(that.createdAtMillis);
 | 
				
			||||||
		this.setHome(that.home);
 | 
							this.warps.load(that.warps);
 | 
				
			||||||
		this.setPowerBoost(that.powerBoost);
 | 
							this.setPowerBoost(that.powerBoost);
 | 
				
			||||||
		this.invitations.load(that.invitations);
 | 
							this.invitations.load(that.invitations);
 | 
				
			||||||
		this.ranks.load(that.ranks);
 | 
							this.ranks.load(that.ranks);
 | 
				
			||||||
@@ -99,7 +99,7 @@ public class Faction extends Entity<Faction> implements FactionsParticipator, MP
 | 
				
			|||||||
	// VERSION
 | 
						// VERSION
 | 
				
			||||||
	// -------------------------------------------- //
 | 
						// -------------------------------------------- //
 | 
				
			||||||
	
 | 
						
 | 
				
			||||||
	public int version = 2;
 | 
						public int version = 3;
 | 
				
			||||||
	
 | 
						
 | 
				
			||||||
	// -------------------------------------------- //
 | 
						// -------------------------------------------- //
 | 
				
			||||||
	// FIELDS: RAW
 | 
						// FIELDS: RAW
 | 
				
			||||||
@@ -126,10 +126,8 @@ public class Faction extends Entity<Faction> implements FactionsParticipator, MP
 | 
				
			|||||||
	// It can be displayed on info pages etc.
 | 
						// It can be displayed on info pages etc.
 | 
				
			||||||
	private long createdAtMillis = System.currentTimeMillis();
 | 
						private long createdAtMillis = System.currentTimeMillis();
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	// Factions can optionally set a home location.
 | 
						// Factions can set a few significant locations (warps)
 | 
				
			||||||
	// If they do their members can teleport there using /f home
 | 
						private EntityInternalMap<Warp> warps = new EntityInternalMap<>(this, Warp.class);
 | 
				
			||||||
	// Null means the faction has no home.
 | 
					 | 
				
			||||||
	private PS home = null;
 | 
					 | 
				
			||||||
	
 | 
						
 | 
				
			||||||
	// Factions usually do not have a powerboost. It defaults to 0.
 | 
						// Factions usually do not have a powerboost. It defaults to 0.
 | 
				
			||||||
	// The powerBoost is a custom increase/decrease to default and maximum power.
 | 
						// The powerBoost is a custom increase/decrease to default and maximum power.
 | 
				
			||||||
@@ -362,46 +360,37 @@ public class Faction extends Entity<Faction> implements FactionsParticipator, MP
 | 
				
			|||||||
	}
 | 
						}
 | 
				
			||||||
	
 | 
						
 | 
				
			||||||
	// -------------------------------------------- //
 | 
						// -------------------------------------------- //
 | 
				
			||||||
	// FIELD: home
 | 
						// FIELD: warp
 | 
				
			||||||
	// -------------------------------------------- //
 | 
						// -------------------------------------------- //
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	public PS getHome()
 | 
						public EntityInternalMap<Warp> getWarps() { return this.warps; }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
						public Warp getWarp(Object oid)
 | 
				
			||||||
	{
 | 
						{
 | 
				
			||||||
		this.verifyHomeIsValid();
 | 
							if (oid == null) throw new NullPointerException("oid");
 | 
				
			||||||
		return this.home;
 | 
							Warp warp = this.getWarps().get(oid);
 | 
				
			||||||
 | 
							if (warp == null) return null;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
							if (!warp.verifyIsValid()) return null;
 | 
				
			||||||
 | 
							return warp;
 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	public void verifyHomeIsValid()
 | 
						public PS getWarpPS(Object oid)
 | 
				
			||||||
	{
 | 
						{
 | 
				
			||||||
		if (this.isValidHome(this.home)) return;
 | 
							if (oid == null) throw new NullPointerException("oid");
 | 
				
			||||||
		this.home = null;
 | 
							Warp warp = this.getWarp(oid);
 | 
				
			||||||
		this.changed();
 | 
							if (warp == null) return null;
 | 
				
			||||||
		msg("<b>Your faction home has been un-set since it is no longer in your territory.");
 | 
							return warp.getLocation();
 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
	
 | 
						
 | 
				
			||||||
	public boolean isValidHome(PS ps)
 | 
						public String addWarp(Warp warp)
 | 
				
			||||||
	{
 | 
						{
 | 
				
			||||||
		if (ps == null) return true;
 | 
							return this.getWarps().attach(warp);
 | 
				
			||||||
		if (!MConf.get().homesMustBeInClaimedTerritory) return true;
 | 
					 | 
				
			||||||
		if (BoardColl.get().getFactionAt(ps) == this) return true;
 | 
					 | 
				
			||||||
		return false;
 | 
					 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	public boolean hasHome()
 | 
						public Warp removeWarp(Warp warp)
 | 
				
			||||||
	{
 | 
						{
 | 
				
			||||||
		return this.getHome() != null;
 | 
							return this.getWarps().detachEntity(warp);
 | 
				
			||||||
	}
 | 
					 | 
				
			||||||
	
 | 
					 | 
				
			||||||
	public void setHome(PS home)
 | 
					 | 
				
			||||||
	{
 | 
					 | 
				
			||||||
		// Detect Nochange
 | 
					 | 
				
			||||||
		if (MUtil.equals(this.home, home)) return;
 | 
					 | 
				
			||||||
		
 | 
					 | 
				
			||||||
		// Apply
 | 
					 | 
				
			||||||
		this.home = home;
 | 
					 | 
				
			||||||
		
 | 
					 | 
				
			||||||
		// Mark as changed
 | 
					 | 
				
			||||||
		this.changed();
 | 
					 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
	
 | 
						
 | 
				
			||||||
	// -------------------------------------------- //
 | 
						// -------------------------------------------- //
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -23,11 +23,11 @@ public class Invitation extends EntityInternal<Invitation>
 | 
				
			|||||||
	
 | 
						
 | 
				
			||||||
	private String inviterId;
 | 
						private String inviterId;
 | 
				
			||||||
	public String getInviterId() { return inviterId; }
 | 
						public String getInviterId() { return inviterId; }
 | 
				
			||||||
	public void setInviterId(String inviterId) { this.inviterId = inviterId; }
 | 
						public void setInviterId(String inviterId) { this.inviterId = inviterId; this.changed(); }
 | 
				
			||||||
	
 | 
						
 | 
				
			||||||
	private Long creationMillis;
 | 
						private Long creationMillis;
 | 
				
			||||||
	public Long getCreationMillis() { return creationMillis; }
 | 
						public Long getCreationMillis() { return creationMillis; }
 | 
				
			||||||
	public void setCreationMillis(Long creationMillis) { this.creationMillis = creationMillis; }
 | 
						public void setCreationMillis(Long creationMillis) { this.creationMillis = creationMillis; this.changed(); }
 | 
				
			||||||
	
 | 
						
 | 
				
			||||||
	// -------------------------------------------- //
 | 
						// -------------------------------------------- //
 | 
				
			||||||
	// CONSTRUCT
 | 
						// CONSTRUCT
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -59,7 +59,7 @@ public class MConf extends Entity<MConf>
 | 
				
			|||||||
	// VERSION
 | 
						// VERSION
 | 
				
			||||||
	// -------------------------------------------- //
 | 
						// -------------------------------------------- //
 | 
				
			||||||
	
 | 
						
 | 
				
			||||||
	public int version = 4;
 | 
						public int version = 5;
 | 
				
			||||||
	
 | 
						
 | 
				
			||||||
	// -------------------------------------------- //
 | 
						// -------------------------------------------- //
 | 
				
			||||||
	// COMMAND ALIASES
 | 
						// COMMAND ALIASES
 | 
				
			||||||
@@ -243,32 +243,34 @@ public class MConf extends Entity<MConf>
 | 
				
			|||||||
	// HOMES
 | 
						// HOMES
 | 
				
			||||||
	// -------------------------------------------- //
 | 
						// -------------------------------------------- //
 | 
				
			||||||
	
 | 
						
 | 
				
			||||||
	// Is the home feature enabled?
 | 
						// Is the warps feature enabled?
 | 
				
			||||||
	// If you set this to false players can't set homes or teleport home.
 | 
						// If you set this to false players can't set warps or teleport to a warp.
 | 
				
			||||||
	public boolean homesEnabled = true;
 | 
						public boolean warpsEnabled = true;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	// Must homes be located inside the faction's territory?
 | 
						// How many warps can they have?
 | 
				
			||||||
 | 
						public int warpsMax = 1;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
						// Must warps be located inside the faction's territory?
 | 
				
			||||||
	// It's usually a wise idea keeping this true.
 | 
						// It's usually a wise idea keeping this true.
 | 
				
			||||||
	// Otherwise players can set their homes inside enemy territory.
 | 
						// Otherwise players can set their warps inside enemy territory.
 | 
				
			||||||
	public boolean homesMustBeInClaimedTerritory = true;
 | 
						public boolean warpsMustBeInClaimedTerritory = true;
 | 
				
			||||||
	
 | 
						
 | 
				
			||||||
	// Is the home teleport command available?
 | 
						// These options can be used to limit rights to warp under different circumstances.
 | 
				
			||||||
	// One reason you might set this to false is if you only want players going home on respawn after death.
 | 
						public boolean warpsTeleportAllowedFromEnemyTerritory = true;
 | 
				
			||||||
	public boolean homesTeleportCommandEnabled = true;
 | 
						public boolean warpsTeleportAllowedFromDifferentWorld = true;
 | 
				
			||||||
 | 
						public double warpsTeleportAllowedEnemyDistance = 32.0;
 | 
				
			||||||
 | 
						public boolean warpsTeleportIgnoreEnemiesIfInOwnTerritory = true;
 | 
				
			||||||
	
 | 
						
 | 
				
			||||||
	// These options can be used to limit rights to tp home under different circumstances.
 | 
						// Should players teleport to faction warp on death?
 | 
				
			||||||
	public boolean homesTeleportAllowedFromEnemyTerritory = true;
 | 
					 | 
				
			||||||
	public boolean homesTeleportAllowedFromDifferentWorld = true;
 | 
					 | 
				
			||||||
	public double homesTeleportAllowedEnemyDistance = 32.0;
 | 
					 | 
				
			||||||
	public boolean homesTeleportIgnoreEnemiesIfInOwnTerritory = true;
 | 
					 | 
				
			||||||
	
 | 
					 | 
				
			||||||
	// Should players teleport to faction home on death?
 | 
					 | 
				
			||||||
	// Set this to true to override the default respawn location.
 | 
						// Set this to true to override the default respawn location.
 | 
				
			||||||
	public boolean homesTeleportToOnDeathActive = false;
 | 
						public boolean warpsTeleportToOnDeathActive = false;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
						// And waht faction warp should it be? It must have a specific name.
 | 
				
			||||||
 | 
						public String warpsTeleportToOnDeathName = "home";
 | 
				
			||||||
	
 | 
						
 | 
				
			||||||
	// This value can be used to tweak compatibility with other plugins altering the respawn location.
 | 
						// This value can be used to tweak compatibility with other plugins altering the respawn location.
 | 
				
			||||||
	// Choose between: LOWEST, LOW, NORMAL, HIGH, HIGHEST and MONITOR.
 | 
						// Choose between: LOWEST, LOW, NORMAL, HIGH, HIGHEST and MONITOR.
 | 
				
			||||||
	public EventPriority homesTeleportToOnDeathPriority = EventPriority.NORMAL;
 | 
						public EventPriority warpsTeleportToOnDeathPriority = EventPriority.NORMAL;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	// -------------------------------------------- //
 | 
						// -------------------------------------------- //
 | 
				
			||||||
	// TERRITORY INFO
 | 
						// TERRITORY INFO
 | 
				
			||||||
@@ -590,13 +592,16 @@ public class MConf extends Entity<MConf>
 | 
				
			|||||||
	public double econCostCreate = 100.0;
 | 
						public double econCostCreate = 100.0;
 | 
				
			||||||
	
 | 
						
 | 
				
			||||||
	// And so on and so forth ... you get the idea.
 | 
						// And so on and so forth ... you get the idea.
 | 
				
			||||||
	public double econCostSethome = 0.0;
 | 
						@Deprecated public double econCostSethome = 0.0;
 | 
				
			||||||
 | 
						public double econCostWarpAdd = 0.0;
 | 
				
			||||||
 | 
						public double econCostWarpRemove = 0.0;
 | 
				
			||||||
	public double econCostJoin = 0.0;
 | 
						public double econCostJoin = 0.0;
 | 
				
			||||||
	public double econCostLeave = 0.0;
 | 
						public double econCostLeave = 0.0;
 | 
				
			||||||
	public double econCostKick = 0.0;
 | 
						public double econCostKick = 0.0;
 | 
				
			||||||
	public double econCostInvite = 0.0;
 | 
						public double econCostInvite = 0.0;
 | 
				
			||||||
	public double econCostDeinvite = 0.0;
 | 
						public double econCostDeinvite = 0.0;
 | 
				
			||||||
	public double econCostHome = 0.0;
 | 
						@Deprecated public double econCostHome = 0.0;
 | 
				
			||||||
 | 
						public double econCostWarpGo = 0.0;
 | 
				
			||||||
	public double econCostName = 0.0;
 | 
						public double econCostName = 0.0;
 | 
				
			||||||
	public double econCostDescription = 0.0;
 | 
						public double econCostDescription = 0.0;
 | 
				
			||||||
	public double econCostTitle = 0.0;
 | 
						public double econCostTitle = 0.0;
 | 
				
			||||||
 
 | 
				
			|||||||
							
								
								
									
										93
									
								
								src/com/massivecraft/factions/entity/Warp.java
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										93
									
								
								src/com/massivecraft/factions/entity/Warp.java
									
									
									
									
									
										Normal file
									
								
							@@ -0,0 +1,93 @@
 | 
				
			|||||||
 | 
					package com.massivecraft.factions.entity;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					import com.massivecraft.massivecore.Named;
 | 
				
			||||||
 | 
					import com.massivecraft.massivecore.ps.PS;
 | 
				
			||||||
 | 
					import com.massivecraft.massivecore.ps.PSFormatHumanSpace;
 | 
				
			||||||
 | 
					import com.massivecraft.massivecore.store.EntityInternal;
 | 
				
			||||||
 | 
					import com.massivecraft.massivecore.store.EntityInternalMap;
 | 
				
			||||||
 | 
					import com.massivecraft.massivecore.util.Txt;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					public class Warp extends EntityInternal<Warp> implements Named
 | 
				
			||||||
 | 
					{
 | 
				
			||||||
 | 
						// -------------------------------------------- //
 | 
				
			||||||
 | 
						// OVERRIDE: ENTITY
 | 
				
			||||||
 | 
						// -------------------------------------------- //
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
						@Override
 | 
				
			||||||
 | 
						public Warp load(Warp that)
 | 
				
			||||||
 | 
						{
 | 
				
			||||||
 | 
							this.name = that.name;
 | 
				
			||||||
 | 
							this.location = that.location;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
							return this;
 | 
				
			||||||
 | 
						}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
						// -------------------------------------------- //
 | 
				
			||||||
 | 
						// FIELDS
 | 
				
			||||||
 | 
						// -------------------------------------------- //
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
						private String name;
 | 
				
			||||||
 | 
						public String getName() { return name; }
 | 
				
			||||||
 | 
						public void setName(String name) { this.name = name; this.changed(); }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
						private PS location;
 | 
				
			||||||
 | 
						public PS getLocation() { return location; }
 | 
				
			||||||
 | 
						public void setLocation(PS location) { this.location = location; this.changed(); }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
						public String getWorld() { return this.getLocation().getWorld(); }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
						public Faction getFaction()
 | 
				
			||||||
 | 
						{
 | 
				
			||||||
 | 
							EntityInternalMap<?> internalMap = (EntityInternalMap<?>) this.getContainer();
 | 
				
			||||||
 | 
							Faction faction = (Faction) internalMap.getEntity();
 | 
				
			||||||
 | 
							return faction;
 | 
				
			||||||
 | 
						}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
						// -------------------------------------------- //
 | 
				
			||||||
 | 
						// CONSTRUCT
 | 
				
			||||||
 | 
						// -------------------------------------------- //
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
						public Warp()
 | 
				
			||||||
 | 
						{
 | 
				
			||||||
 | 
							this(null, null);
 | 
				
			||||||
 | 
						}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
						public Warp(String name, PS location)
 | 
				
			||||||
 | 
						{
 | 
				
			||||||
 | 
							this.name = name;
 | 
				
			||||||
 | 
							this.location = location;
 | 
				
			||||||
 | 
						}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
						// -------------------------------------------- //
 | 
				
			||||||
 | 
						// VISUAL
 | 
				
			||||||
 | 
						// -------------------------------------------- //
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
						public String getVisual(Object senderObject)
 | 
				
			||||||
 | 
						{
 | 
				
			||||||
 | 
							return Txt.parse("<h>%s<reset>:%s", this.getName(), this.getLocation().toString(PSFormatHumanSpace.get()));
 | 
				
			||||||
 | 
						}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
						// -------------------------------------------- //
 | 
				
			||||||
 | 
						// VALID
 | 
				
			||||||
 | 
						// -------------------------------------------- //
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
						public boolean verifyIsValid()
 | 
				
			||||||
 | 
						{
 | 
				
			||||||
 | 
							if (this.isValid()) return true;
 | 
				
			||||||
 | 
							this.detach();
 | 
				
			||||||
 | 
							this.getFaction().msg("<b>Your faction warp <h>%s <b>has been un-set since it is no longer in your territory.", this.getName());
 | 
				
			||||||
 | 
							return false;
 | 
				
			||||||
 | 
						}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
						public boolean isValidFor(Faction faction)
 | 
				
			||||||
 | 
						{
 | 
				
			||||||
 | 
							if (!MConf.get().warpsMustBeInClaimedTerritory) return true;
 | 
				
			||||||
 | 
							if (BoardColl.get().getFactionAt(this.getLocation()) == faction) return true;
 | 
				
			||||||
 | 
							return false;
 | 
				
			||||||
 | 
						}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
						public boolean isValid()
 | 
				
			||||||
 | 
						{
 | 
				
			||||||
 | 
							return this.isValidFor(this.getFaction());
 | 
				
			||||||
 | 
						}
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
@@ -0,0 +1,51 @@
 | 
				
			|||||||
 | 
					package com.massivecraft.factions.entity.migrator;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					import com.google.gson.JsonElement;
 | 
				
			||||||
 | 
					import com.google.gson.JsonObject;
 | 
				
			||||||
 | 
					import com.google.gson.reflect.TypeToken;
 | 
				
			||||||
 | 
					import com.massivecraft.factions.entity.Faction;
 | 
				
			||||||
 | 
					import com.massivecraft.factions.entity.Warp;
 | 
				
			||||||
 | 
					import com.massivecraft.massivecore.MassiveCore;
 | 
				
			||||||
 | 
					import com.massivecraft.massivecore.collections.MassiveMap;
 | 
				
			||||||
 | 
					import com.massivecraft.massivecore.ps.PS;
 | 
				
			||||||
 | 
					import com.massivecraft.massivecore.store.MStore;
 | 
				
			||||||
 | 
					import com.massivecraft.massivecore.store.migrator.MigratorRoot;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					import java.util.Map;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					public class MigratorFaction003Warps extends MigratorRoot
 | 
				
			||||||
 | 
					{
 | 
				
			||||||
 | 
						// -------------------------------------------- //
 | 
				
			||||||
 | 
						// INSTANCE & CONSTRUCT
 | 
				
			||||||
 | 
						// -------------------------------------------- //
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
						private static MigratorFaction003Warps i = new MigratorFaction003Warps();
 | 
				
			||||||
 | 
						public static MigratorFaction003Warps get() { return i; }
 | 
				
			||||||
 | 
						private MigratorFaction003Warps()
 | 
				
			||||||
 | 
						{
 | 
				
			||||||
 | 
							super(Faction.class);
 | 
				
			||||||
 | 
						}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
						// -------------------------------------------- //
 | 
				
			||||||
 | 
						// OVERRIDE
 | 
				
			||||||
 | 
						// -------------------------------------------- //
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
						@Override
 | 
				
			||||||
 | 
						public void migrateInner(JsonObject entity)
 | 
				
			||||||
 | 
						{
 | 
				
			||||||
 | 
							JsonElement jsonHome = entity.remove("home");
 | 
				
			||||||
 | 
							if (jsonHome == null ||jsonHome.isJsonNull()) return;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
							if (!jsonHome.isJsonObject()) throw new RuntimeException("not JsonObject " + jsonHome);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
							PS psHome = MassiveCore.gson.fromJson(jsonHome, PS.class);
 | 
				
			||||||
 | 
							Warp warp = new Warp("home", psHome);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
							Map<String, Warp> warps = new MassiveMap<>();
 | 
				
			||||||
 | 
							warps.put(MStore.createId(), warp);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
							JsonElement jsonMap = MassiveCore.gson.toJsonTree(warps, (new TypeToken<Map<String,Warp>>(){}).getType());
 | 
				
			||||||
 | 
							entity.add("warps", jsonMap);
 | 
				
			||||||
 | 
						}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
@@ -0,0 +1,28 @@
 | 
				
			|||||||
 | 
					package com.massivecraft.factions.entity.migrator;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					import com.massivecraft.factions.entity.MConf;
 | 
				
			||||||
 | 
					import com.massivecraft.massivecore.store.migrator.MigratorFieldRename;
 | 
				
			||||||
 | 
					import com.massivecraft.massivecore.store.migrator.MigratorRoot;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					public class MigratorMConf005Warps extends MigratorRoot
 | 
				
			||||||
 | 
					{
 | 
				
			||||||
 | 
						// -------------------------------------------- //
 | 
				
			||||||
 | 
						// INSTANCE & CONSTRUCT
 | 
				
			||||||
 | 
						// -------------------------------------------- //
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
						private static MigratorMConf005Warps i = new MigratorMConf005Warps();
 | 
				
			||||||
 | 
						public static MigratorMConf005Warps get() { return i; }
 | 
				
			||||||
 | 
						private MigratorMConf005Warps()
 | 
				
			||||||
 | 
						{
 | 
				
			||||||
 | 
							super(MConf.class);
 | 
				
			||||||
 | 
							this.addInnerMigrator(MigratorFieldRename.get("homesEnabled", "warpsEnabled"));
 | 
				
			||||||
 | 
							this.addInnerMigrator(MigratorFieldRename.get("homesMustBeInClaimedTerritory", "warpsMustBeInClaimedTerritory"));
 | 
				
			||||||
 | 
							this.addInnerMigrator(MigratorFieldRename.get("homesTeleportAllowedFromEnemyTerritory", "warpsTeleportAllowedFromEnemyTerritory"));
 | 
				
			||||||
 | 
							this.addInnerMigrator(MigratorFieldRename.get("homesTeleportAllowedFromDifferentWorld", "warpsTeleportAllowedFromDifferentWorld"));
 | 
				
			||||||
 | 
							this.addInnerMigrator(MigratorFieldRename.get("homesTeleportAllowedEnemyDistance", "warpsTeleportAllowedEnemyDistance"));
 | 
				
			||||||
 | 
							this.addInnerMigrator(MigratorFieldRename.get("homesTeleportIgnoreEnemiesIfInOwnTerritory", "warpsTeleportIgnoreEnemiesIfInOwnTerritory"));
 | 
				
			||||||
 | 
							this.addInnerMigrator(MigratorFieldRename.get("homesTeleportToOnDeathActive", "warpsTeleportToOnDeathActive"));
 | 
				
			||||||
 | 
							this.addInnerMigrator(MigratorFieldRename.get("homesTeleportToOnDeathPriority", "warpsTeleportToOnDeathPriority"));
 | 
				
			||||||
 | 
						}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
@@ -1,11 +1,11 @@
 | 
				
			|||||||
package com.massivecraft.factions.event;
 | 
					package com.massivecraft.factions.event;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
import com.massivecraft.factions.entity.Faction;
 | 
					import com.massivecraft.factions.entity.Faction;
 | 
				
			||||||
import com.massivecraft.massivecore.ps.PS;
 | 
					import com.massivecraft.factions.entity.Warp;
 | 
				
			||||||
import org.bukkit.command.CommandSender;
 | 
					import org.bukkit.command.CommandSender;
 | 
				
			||||||
import org.bukkit.event.HandlerList;
 | 
					import org.bukkit.event.HandlerList;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
public class EventFactionsHomeChange extends EventFactionsAbstractSender
 | 
					public class EventFactionsWarpAdd extends EventFactionsAbstractSender
 | 
				
			||||||
{	
 | 
					{	
 | 
				
			||||||
	// -------------------------------------------- //
 | 
						// -------------------------------------------- //
 | 
				
			||||||
	// REQUIRED EVENT CODE
 | 
						// REQUIRED EVENT CODE
 | 
				
			||||||
@@ -22,19 +22,19 @@ public class EventFactionsHomeChange extends EventFactionsAbstractSender
 | 
				
			|||||||
	private final Faction faction;
 | 
						private final Faction faction;
 | 
				
			||||||
	public Faction getFaction() { return this.faction; }
 | 
						public Faction getFaction() { return this.faction; }
 | 
				
			||||||
	
 | 
						
 | 
				
			||||||
	private PS newHome;
 | 
						private Warp warp;
 | 
				
			||||||
	public PS getNewHome() { return this.newHome; }
 | 
						public Warp getNewWarp() { return this.warp; }
 | 
				
			||||||
	public void setNewHome(PS newHome) { this.newHome = newHome; }
 | 
						public void setNewWarp(Warp warp) { this.warp = warp; }
 | 
				
			||||||
	
 | 
						
 | 
				
			||||||
	// -------------------------------------------- //
 | 
						// -------------------------------------------- //
 | 
				
			||||||
	// CONSTRUCT
 | 
						// CONSTRUCT
 | 
				
			||||||
	// -------------------------------------------- //
 | 
						// -------------------------------------------- //
 | 
				
			||||||
	
 | 
						
 | 
				
			||||||
	public EventFactionsHomeChange(CommandSender sender, Faction faction, PS newHome)
 | 
						public EventFactionsWarpAdd(CommandSender sender, Faction faction, Warp warp)
 | 
				
			||||||
	{
 | 
						{
 | 
				
			||||||
		super(sender);
 | 
							super(sender);
 | 
				
			||||||
		this.faction = faction;
 | 
							this.faction = faction;
 | 
				
			||||||
		this.newHome = newHome;
 | 
							this.warp = warp;
 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
	
 | 
						
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
@@ -0,0 +1,40 @@
 | 
				
			|||||||
 | 
					package com.massivecraft.factions.event;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					import com.massivecraft.factions.entity.Faction;
 | 
				
			||||||
 | 
					import com.massivecraft.factions.entity.Warp;
 | 
				
			||||||
 | 
					import org.bukkit.command.CommandSender;
 | 
				
			||||||
 | 
					import org.bukkit.event.HandlerList;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					public class EventFactionsWarpRemove extends EventFactionsAbstractSender
 | 
				
			||||||
 | 
					{
 | 
				
			||||||
 | 
						// -------------------------------------------- //
 | 
				
			||||||
 | 
						// REQUIRED EVENT CODE
 | 
				
			||||||
 | 
						// -------------------------------------------- //
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
						private static final HandlerList handlers = new HandlerList();
 | 
				
			||||||
 | 
						@Override public HandlerList getHandlers() { return handlers; }
 | 
				
			||||||
 | 
						public static HandlerList getHandlerList() { return handlers; }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
						// -------------------------------------------- //
 | 
				
			||||||
 | 
						// FIELDS
 | 
				
			||||||
 | 
						// -------------------------------------------- //
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
						private final Faction faction;
 | 
				
			||||||
 | 
						public Faction getFaction() { return this.faction; }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
						private Warp warp;
 | 
				
			||||||
 | 
						public Warp getNewWarp() { return this.warp; }
 | 
				
			||||||
 | 
						public void setNewWarp(Warp warp) { this.warp = warp; }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
						// -------------------------------------------- //
 | 
				
			||||||
 | 
						// CONSTRUCT
 | 
				
			||||||
 | 
						// -------------------------------------------- //
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
						public EventFactionsWarpRemove(CommandSender sender, Faction faction, Warp warp)
 | 
				
			||||||
 | 
						{
 | 
				
			||||||
 | 
							super(sender);
 | 
				
			||||||
 | 
							this.faction = faction;
 | 
				
			||||||
 | 
							this.warp = warp;
 | 
				
			||||||
 | 
						}
 | 
				
			||||||
 | 
						
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
@@ -1,9 +1,10 @@
 | 
				
			|||||||
package com.massivecraft.factions.event;
 | 
					package com.massivecraft.factions.event;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					import com.massivecraft.factions.entity.Warp;
 | 
				
			||||||
import org.bukkit.command.CommandSender;
 | 
					import org.bukkit.command.CommandSender;
 | 
				
			||||||
import org.bukkit.event.HandlerList;
 | 
					import org.bukkit.event.HandlerList;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
public class EventFactionsHomeTeleport extends EventFactionsAbstractSender
 | 
					public class EventFactionsWarpTeleport extends EventFactionsAbstractSender
 | 
				
			||||||
{	
 | 
					{	
 | 
				
			||||||
	// -------------------------------------------- //
 | 
						// -------------------------------------------- //
 | 
				
			||||||
	// REQUIRED EVENT CODE
 | 
						// REQUIRED EVENT CODE
 | 
				
			||||||
@@ -13,13 +14,21 @@ public class EventFactionsHomeTeleport extends EventFactionsAbstractSender
 | 
				
			|||||||
	@Override public HandlerList getHandlers() { return handlers; }
 | 
						@Override public HandlerList getHandlers() { return handlers; }
 | 
				
			||||||
	public static HandlerList getHandlerList() { return handlers; }
 | 
						public static HandlerList getHandlerList() { return handlers; }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
						// -------------------------------------------- //
 | 
				
			||||||
 | 
						// FIELDS
 | 
				
			||||||
 | 
						// -------------------------------------------- //
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
						private final Warp warp;
 | 
				
			||||||
 | 
						public Warp getWarp() { return this.warp; }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	// -------------------------------------------- //
 | 
						// -------------------------------------------- //
 | 
				
			||||||
	// CONSTRUCT
 | 
						// CONSTRUCT
 | 
				
			||||||
	// -------------------------------------------- //
 | 
						// -------------------------------------------- //
 | 
				
			||||||
	
 | 
						
 | 
				
			||||||
	public EventFactionsHomeTeleport(CommandSender sender)
 | 
						public EventFactionsWarpTeleport(CommandSender sender, Warp warp)
 | 
				
			||||||
	{
 | 
						{
 | 
				
			||||||
		super(sender);
 | 
							super(sender);
 | 
				
			||||||
 | 
							this.warp = warp;
 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
	
 | 
						
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
@@ -5,7 +5,6 @@ import com.massivecraft.factions.entity.Faction;
 | 
				
			|||||||
import com.massivecraft.factions.entity.MConf;
 | 
					import com.massivecraft.factions.entity.MConf;
 | 
				
			||||||
import com.massivecraft.factions.entity.MPlayer;
 | 
					import com.massivecraft.factions.entity.MPlayer;
 | 
				
			||||||
import com.massivecraft.massivecore.Engine;
 | 
					import com.massivecraft.massivecore.Engine;
 | 
				
			||||||
import kangarko.chatcontrol.ChatControl;
 | 
					 | 
				
			||||||
import mineverse.Aust1n46.chat.api.MineverseChatAPI;
 | 
					import mineverse.Aust1n46.chat.api.MineverseChatAPI;
 | 
				
			||||||
import mineverse.Aust1n46.chat.api.MineverseChatPlayer;
 | 
					import mineverse.Aust1n46.chat.api.MineverseChatPlayer;
 | 
				
			||||||
import mineverse.Aust1n46.chat.channel.ChatChannel;
 | 
					import mineverse.Aust1n46.chat.channel.ChatChannel;
 | 
				
			||||||
@@ -68,7 +67,6 @@ public class EngineVentureChat extends Engine
 | 
				
			|||||||
		Predicate<Player> predicate = isSpy.or(predicateChannel);
 | 
							Predicate<Player> predicate = isSpy.or(predicateChannel);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
		EngineChat.filterToPredicate(event, predicate);
 | 
							EngineChat.filterToPredicate(event, predicate);
 | 
				
			||||||
		ChatControl
 | 
					 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
	
 | 
						
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 
 | 
				
			|||||||
		Reference in New Issue
	
	Block a user