mirror of
https://github.com/MassiveCraft/Factions.git
synced 2024-11-26 12:16:24 +01:00
Fixing a few bugs, and adding in some debug output for unsolved ones.
This commit is contained in:
parent
f6d601446e
commit
7626aed06a
@ -165,6 +165,7 @@ permissions:
|
||||
factions.list: true
|
||||
factions.map: true
|
||||
factions.money.*: true
|
||||
factions.officer: true
|
||||
factions.open: true
|
||||
factions.perm: true
|
||||
factions.power: true
|
||||
|
@ -49,7 +49,7 @@ public class CmdFactionsMap extends FCommand
|
||||
|
||||
public void showMap()
|
||||
{
|
||||
sendMessage(BoardColls.get().getMap(usenderFaction, PS.valueOf(me), usender.getPlayer().getLocation().getYaw()));
|
||||
sendMessage(BoardColls.get().getMap(usenderFaction, PS.valueOf(me), me.getLocation().getYaw()));
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -18,6 +18,8 @@ public abstract class CmdFactionsRelationAbstract extends FCommand
|
||||
|
||||
public CmdFactionsRelationAbstract()
|
||||
{
|
||||
this.addRequiredArg("faction");
|
||||
|
||||
this.addRequirements(ReqFactionsEnabled.get());
|
||||
this.addRequirements(ReqHasPerm.get(Perm.RELATION.node));
|
||||
this.addRequirements(ReqHasFaction.get());
|
||||
|
@ -98,7 +98,8 @@ public class Board extends Entity<Board> implements BoardInterface
|
||||
public Faction getFactionAt(PS ps)
|
||||
{
|
||||
if (ps == null) return null;
|
||||
return FactionColls.get().get(this).get(this.getTerritoryAccessAt(ps).getHostFactionId());
|
||||
String factionId = this.getTerritoryAccessAt(ps).getHostFactionId();
|
||||
return FactionColls.get().get(this).get(factionId);
|
||||
}
|
||||
|
||||
// SET
|
||||
@ -158,16 +159,18 @@ public class Board extends Entity<Board> implements BoardInterface
|
||||
@Override
|
||||
public void clean()
|
||||
{
|
||||
FactionColl factionColl = FactionColls.get().get(this);
|
||||
|
||||
for (Entry<PS, TerritoryAccess> entry : this.map.entrySet())
|
||||
{
|
||||
TerritoryAccess territoryAccess = entry.getValue();
|
||||
|
||||
if (FactionColls.get().get(this).containsId(territoryAccess.getHostFactionId())) continue;
|
||||
String factionId = territoryAccess.getHostFactionId();
|
||||
if (factionColl.containsId(factionId)) continue;
|
||||
|
||||
PS ps = entry.getKey();
|
||||
this.removeAt(ps);
|
||||
|
||||
Factions.get().log("Board cleaner removed "+territoryAccess.getHostFactionId()+" from "+entry.getKey());
|
||||
Factions.get().log("Board cleaner removed "+factionId+" from "+ps);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -642,7 +642,14 @@ public class Faction extends Entity<Faction> implements EconomyParticipator
|
||||
while (iter.hasNext())
|
||||
{
|
||||
Entry<FPerm, Set<Rel>> entry = iter.next();
|
||||
if (entry.getKey().getDefault(this).equals(entry.getValue()))
|
||||
FPerm key = entry.getKey();
|
||||
Set<Rel> keyDefault = key.getDefault(this);
|
||||
Set<Rel> value = entry.getValue();
|
||||
|
||||
if (keyDefault == null) System.out.println("keyDefault was null");
|
||||
if (value == null) System.out.println("value was null");
|
||||
|
||||
if (keyDefault.equals(value))
|
||||
{
|
||||
iter.remove();
|
||||
}
|
||||
|
@ -40,29 +40,6 @@ public class FactionColl extends Coll<Faction>
|
||||
this.createSpecialFactions();
|
||||
}
|
||||
|
||||
/*
|
||||
@Override
|
||||
protected synchronized String attach(Faction faction, Object oid, boolean noteChange)
|
||||
{
|
||||
String ret = super.attach(faction, oid, noteChange);
|
||||
|
||||
// Factions start with 0 money.
|
||||
// TODO: Can this be done here?
|
||||
// TODO: Or will it be a to heavy operation to do this often?
|
||||
|
||||
//System.out.println("faction "+faction);
|
||||
//System.out.println("faction.getId() "+faction.getId());
|
||||
// TODO: Why does this happen for Wilderness?
|
||||
if (faction.getId() == null) return ret;
|
||||
|
||||
if (!Money.exists(faction))
|
||||
{
|
||||
Money.set(faction, 0);
|
||||
}
|
||||
|
||||
return ret;
|
||||
}*/
|
||||
|
||||
// TODO: I hope this one is not crucial anymore.
|
||||
// If it turns out to be I will just have to recreate the feature in the proper place.
|
||||
/*
|
||||
@ -80,6 +57,23 @@ public class FactionColl extends Coll<Faction>
|
||||
}
|
||||
*/
|
||||
|
||||
@Override
|
||||
public Faction get(Object oid)
|
||||
{
|
||||
Faction ret = super.get(oid);
|
||||
|
||||
if (ret == null)
|
||||
{
|
||||
String message = Txt.parse("<b>Non existing factionId <h>%s <b>requested. <i>Cleaning all boards and uplayers.", this.fixId(oid));
|
||||
Factions.get().log(message);
|
||||
|
||||
BoardColls.get().clean();
|
||||
UPlayerColls.get().clean();
|
||||
}
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Faction detachId(Object oid)
|
||||
{
|
||||
|
@ -80,4 +80,16 @@ public class UPlayerColls extends XColls<UPlayerColl, UPlayer>
|
||||
oldFile.renameTo(newFile);
|
||||
}
|
||||
|
||||
// -------------------------------------------- //
|
||||
// EXTRAS
|
||||
// -------------------------------------------- //
|
||||
|
||||
public void clean()
|
||||
{
|
||||
for (UPlayerColl coll : this.getColls())
|
||||
{
|
||||
coll.clean();
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -1,29 +1,22 @@
|
||||
package com.massivecraft.factions.listeners;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
import org.bukkit.block.Block;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.entity.TNTPrimed;
|
||||
import org.bukkit.event.block.BlockFromToEvent;
|
||||
import org.bukkit.event.entity.EntityExplodeEvent;
|
||||
import org.bukkit.event.player.PlayerInteractEvent;
|
||||
import org.bukkit.event.player.PlayerTeleportEvent;
|
||||
import org.bukkit.event.EventHandler;
|
||||
import org.bukkit.event.EventPriority;
|
||||
import org.bukkit.event.Listener;
|
||||
import org.bukkit.util.NumberConversions;
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.Location;
|
||||
import org.bukkit.Material;
|
||||
|
||||
import com.massivecraft.factions.Factions;
|
||||
import com.massivecraft.factions.entity.MConf;
|
||||
import com.massivecraft.mcore.util.SenderUtil;
|
||||
import com.massivecraft.mcore.util.Txt;
|
||||
|
||||
|
||||
public class FactionsListenerExploit implements Listener
|
||||
@ -48,7 +41,9 @@ public class FactionsListenerExploit implements Listener
|
||||
// INTERACT SPAM
|
||||
// -------------------------------------------- //
|
||||
// TODO: Now that I decoupled this one it may be to sensitive.
|
||||
// TODO: Yeah it's faaaaaaaaaar to sensitive. Let's just comment it out for now.
|
||||
|
||||
/*
|
||||
@EventHandler(priority = EventPriority.LOW, ignoreCancelled = true)
|
||||
public void interactSpam(PlayerInteractEvent event)
|
||||
{
|
||||
@ -91,6 +86,7 @@ public class FactionsListenerExploit implements Listener
|
||||
return attempts;
|
||||
}
|
||||
}
|
||||
*/
|
||||
|
||||
// -------------------------------------------- //
|
||||
// OBSIDIAN GENERATORS
|
||||
|
@ -6,6 +6,7 @@ import java.util.Iterator;
|
||||
import java.util.List;
|
||||
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.Location;
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.block.Block;
|
||||
import org.bukkit.entity.Enderman;
|
||||
@ -560,14 +561,14 @@ public class FactionsListenerMain implements Listener
|
||||
@EventHandler(priority = EventPriority.NORMAL, ignoreCancelled = true)
|
||||
public void blockExplosion(EntityExplodeEvent event)
|
||||
{
|
||||
// If an entity is exploding ...
|
||||
Entity entity = event.getEntity();
|
||||
// If an explosion occurs at a location ...
|
||||
Location location = event.getLocation();
|
||||
|
||||
// Check Disabled
|
||||
if (UConf.isDisabled(entity)) return;
|
||||
if (UConf.isDisabled(location)) return;
|
||||
|
||||
// Check the entity. Are explosions disabled there?
|
||||
if (BoardColls.get().getFactionAt(PS.valueOf(event.getEntity())).getFlag(FFlag.EXPLOSIONS) == false)
|
||||
if (BoardColls.get().getFactionAt(PS.valueOf(location)).getFlag(FFlag.EXPLOSIONS) == false)
|
||||
{
|
||||
event.setCancelled(true);
|
||||
return;
|
||||
@ -637,6 +638,16 @@ public class FactionsListenerMain implements Listener
|
||||
// If the faction at the block has firespread disabled ...
|
||||
PS ps = PS.valueOf(block);
|
||||
Faction faction = BoardColls.get().getFactionAt(ps);
|
||||
|
||||
// TODO: Remove this debug output soon.
|
||||
if (faction == null)
|
||||
{
|
||||
System.out.println("faction was null");
|
||||
System.out.println("block was "+block);
|
||||
System.out.println("ps was "+ps);
|
||||
return;
|
||||
}
|
||||
|
||||
if (faction.getFlag(FFlag.FIRESPREAD)) return;
|
||||
|
||||
// then cancel the event.
|
||||
|
Loading…
Reference in New Issue
Block a user