Skip to content

Commit

Permalink
Creating start of a compatibility layer with FactionsV1/FactionsUUID.
Browse files Browse the repository at this point in the history
  • Loading branch information
JeremyFail committed Jan 26, 2025
1 parent 9c58035 commit 42982b5
Show file tree
Hide file tree
Showing 10 changed files with 1,823 additions and 2 deletions.
45 changes: 45 additions & 0 deletions Factions/src/com/massivecraft/factions/Board.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
package com.massivecraft.factions;

import com.massivecraft.factions.entity.BoardColl;
import com.massivecraft.massivecore.ps.PS;

/**
* This class attempts to provide minimal compatibility with Factions V1/FactionsUUID
* by providing wrapper classes/methods that convert to the V2/V3 class structure.
*
* <p><strong>DO NOT USE THIS FOR NEW IMPLEMENTATIONS.</strong></p>
*
* @deprecated
*/
@Deprecated
public class Board
{

// -------------------------------------------- //
// INSTANCE & CONSTRUCT
// -------------------------------------------- //

private static Board instance;
public static Board getInstance()
{
if (instance == null) {
instance = new Board();
}
return instance;
}
// Private constructor to prevent instantiation
private Board() {}

// -------------------------------------------- //
// METHODS
// -------------------------------------------- //

public Faction getFactionAt(FLocation location)
{
com.massivecraft.factions.entity.Board realBoard = BoardColl.get().get(location.getLocation().getWorld());
com.massivecraft.factions.entity.Faction faction = realBoard.getFactionAt(PS.valueOf(location.getLocation()).getChunkCoords(true));

return new LegacyFaction(faction);
}

}
29 changes: 29 additions & 0 deletions Factions/src/com/massivecraft/factions/FLocation.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
package com.massivecraft.factions;

import org.bukkit.Location;

/**
* This class attempts to provide minimal compatibility with Factions V1/FactionsUUID
* by providing wrapper classes/methods that convert to the V2/V3 class structure.
*
* <p><strong>DO NOT USE THIS FOR NEW IMPLEMENTATIONS.</strong></p>
*
* @deprecated
*/
@Deprecated
public class FLocation
{

private Location location;

public FLocation(Location location)
{
this.location = location;
}

public Location getLocation()
{
return this.location;
}

}
169 changes: 169 additions & 0 deletions Factions/src/com/massivecraft/factions/FPlayer.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,169 @@
package com.massivecraft.factions;

import java.util.List;

import org.bukkit.Location;
import org.bukkit.command.CommandSender;
import org.bukkit.entity.Player;

/**
* This class attempts to provide minimal compatibility with Factions V1/FactionsUUID
* by providing wrapper classes/methods that convert to the V2/V3 class structure.
*
* <p><strong>DO NOT USE THIS FOR NEW IMPLEMENTATIONS.</strong></p>
*
* @deprecated
*/
@Deprecated
public interface FPlayer
{

public Faction getFaction();

boolean hasFaction();

void setFaction(Faction faction);

public boolean shouldTakeFallDamage();

// public void setTakeFallDamage(boolean fallDamage);

double getPowerBoost();

void setPowerBoost(double powerBoost);

Faction getAutoClaimFor();

void setAutoClaimFor(Faction faction);

Faction getAutoUnclaimFor();

void setAutoUnclaimFor(Faction faction);

boolean isAdminBypassing();

boolean isVanished();

void setIsAdminBypassing(boolean val);

void resetFactionData(boolean doSpoutUpdate);

void resetFactionData();

long getLastLoginTime();

boolean isMapAutoUpdating();

void setMapAutoUpdating(boolean mapAutoUpdating);

String getTitle();

void setTitle(CommandSender sender, String title);

String getName();

String getTag();

// Base concatenations:

String getNameAndSomething(String something);

String getNameAndTitle();

String getNameAndTag();

// Colored concatenations:
// These are used in information messages

String getNameAndTitle(Faction faction);

String getNameAndTitle(FPlayer fplayer);

//----------------------------------------------//
// Health
//----------------------------------------------//
void heal(int amnt);


//----------------------------------------------//
// Power
//----------------------------------------------//
double getPower();

void alterPower(double delta);

double getPowerMax();

double getPowerMin();

int getPowerRounded();

int getPowerMaxRounded();

int getPowerMinRounded();

void updatePower();

void losePowerFromBeingOffline();

//----------------------------------------------//
// Territory
//----------------------------------------------//
boolean isInOwnTerritory();

boolean isInOthersTerritory();

boolean isInAllyTerritory();

boolean isInNeutralTerritory();

boolean isInEnemyTerritory();

void sendFactionHereMessage(Faction from);

// -------------------------------
// Actions
// -------------------------------

void leave(boolean makePay);

boolean canClaimForFaction(Faction forFaction);

@Deprecated
boolean canClaimForFactionAtLocation(Faction forFaction, Location location, boolean notifyFailure);

boolean canClaimForFactionAtLocation(Faction forFaction, FLocation location, boolean notifyFailure);

boolean attemptClaim(Faction forFaction, Location location, boolean notifyFailure);

boolean attemptClaim(Faction forFaction, FLocation location, boolean notifyFailure);

boolean attemptUnclaim(Faction forFaction, FLocation flocation, boolean notifyFailure);

String getId();

Player getPlayer();

boolean isOnline();

void sendMessage(String message);

void sendMessage(List<String> messages);

boolean isOnlineAndVisibleTo(Player me);

boolean isOffline();

void flightCheck();

boolean isFlying();

void setFlying(boolean fly);

void setFlying(boolean fly, boolean damage);

boolean canFlyAtLocation();

boolean canFlyAtLocation(FLocation location);

}
40 changes: 40 additions & 0 deletions Factions/src/com/massivecraft/factions/FPlayers.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
package com.massivecraft.factions;

import org.bukkit.OfflinePlayer;

/**
* This class attempts to provide minimal compatibility with Factions V1/FactionsUUID
* by providing wrapper classes/methods that convert to the V2/V3 class structure.
*
* <p><strong>DO NOT USE THIS FOR NEW IMPLEMENTATIONS.</strong></p>
*
* @deprecated
*/
@Deprecated
public class FPlayers
{
// -------------------------------------------- //
// INSTANCE & CONSTRUCT
// -------------------------------------------- //

private static FPlayers instance;
public static FPlayers getInstance()
{
if (instance == null) {
instance = new FPlayers();
}
return instance;
}
// Private constructor to prevent instantiation
private FPlayers() {}

// -------------------------------------------- //
// METHODS
// -------------------------------------------- //

public FPlayer getByOfflinePlayer(OfflinePlayer player)
{
return new LegacyFPlayer(player);
}

}
Loading

0 comments on commit 42982b5

Please sign in to comment.