Unifying, simplifying and messing around with land claiming and the related costs.

This commit is contained in:
Olof Larsson
2013-04-24 11:16:37 +02:00
parent 8ac19453b6
commit 05da06594a
17 changed files with 312 additions and 291 deletions

View File

@ -13,7 +13,7 @@ public abstract class FactionsEventAbstractSender extends MCoreEvent
private final CommandSender sender;
public CommandSender getSender() { return this.sender; }
public UPlayer getFSender() { return UPlayer.get(this.sender); }
public UPlayer getUSender() { return this.sender == null ? null : UPlayer.get(this.sender); }
// -------------------------------------------- //
// CONSTRUCT

View File

@ -0,0 +1,59 @@
package com.massivecraft.factions.event;
import org.bukkit.command.CommandSender;
import org.bukkit.event.HandlerList;
import com.massivecraft.factions.entity.BoardColls;
import com.massivecraft.factions.entity.Faction;
import com.massivecraft.factions.entity.UPlayer;
import com.massivecraft.mcore.ps.PS;
public class FactionsEventChunkChange extends FactionsEventAbstractSender
{
// -------------------------------------------- //
// 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 PS chunk;
public PS getChunk() { return this.chunk; }
private final Faction newFaction;
public Faction getNewFaction() { return this.newFaction; }
// -------------------------------------------- //
// CONSTRUCT
// -------------------------------------------- //
public FactionsEventChunkChange(CommandSender sender, PS chunk, Faction newFaction)
{
super(sender);
this.chunk = chunk.getChunk(true);
this.newFaction = newFaction;
}
// -------------------------------------------- //
// UTIL
// -------------------------------------------- //
public FactionsEventChunkChangeType getType()
{
Faction currentFaction = BoardColls.get().getFactionAt(chunk);
if (currentFaction.isNone()) return FactionsEventChunkChangeType.BUY;
if (newFaction.isNormal()) return FactionsEventChunkChangeType.CONQUER;
UPlayer usender = this.getUSender();
if (usender != null && usender.getFaction() == currentFaction) return FactionsEventChunkChangeType.SELL;
return FactionsEventChunkChangeType.PILLAGE;
}
}

View File

@ -0,0 +1,10 @@
package com.massivecraft.factions.event;
public enum FactionsEventChunkChangeType
{
BUY,
SELL,
CONQUER,
PILLAGE,
;
}

View File

@ -1,40 +0,0 @@
package com.massivecraft.factions.event;
import org.bukkit.command.CommandSender;
import org.bukkit.event.HandlerList;
import com.massivecraft.factions.entity.Faction;
import com.massivecraft.mcore.ps.PS;
public class FactionsEventLandClaim extends FactionsEventAbstractSender
{
// -------------------------------------------- //
// 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 final PS chunk;
public PS getChunk() { return this.chunk; }
// -------------------------------------------- //
// CONSTRUCT
// -------------------------------------------- //
public FactionsEventLandClaim(CommandSender sender, Faction faction, PS chunk)
{
super(sender);
this.faction = faction;
this.chunk = chunk.getChunk(true);
}
}

View File

@ -1,40 +0,0 @@
package com.massivecraft.factions.event;
import org.bukkit.command.CommandSender;
import org.bukkit.event.HandlerList;
import com.massivecraft.factions.entity.Faction;
import com.massivecraft.mcore.ps.PS;
public class FactionsEventLandUnclaim extends FactionsEventAbstractSender
{
// -------------------------------------------- //
// 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 final PS chunk;
public PS getChunk() { return this.chunk; }
// -------------------------------------------- //
// CONSTRUCT
// -------------------------------------------- //
public FactionsEventLandUnclaim(CommandSender sender, Faction faction, PS chunk)
{
super(sender);
this.chunk = chunk.getChunk(true);
this.faction = faction;
}
}

View File

@ -1,35 +0,0 @@
package com.massivecraft.factions.event;
import org.bukkit.command.CommandSender;
import org.bukkit.event.HandlerList;
import com.massivecraft.factions.entity.Faction;
public class FactionsEventLandUnclaimAll extends FactionsEventAbstractSender
{
// -------------------------------------------- //
// 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; }
// -------------------------------------------- //
// CONSTRUCT
// -------------------------------------------- //
public FactionsEventLandUnclaimAll(CommandSender sender, Faction faction)
{
super(sender);
this.faction = faction;
}
}