Use FactionsUUID and latest Towny

This commit is contained in:
Norbi Peti 2020-07-24 23:46:25 +02:00
parent c49ab63e25
commit 97928aff30
No known key found for this signature in database
GPG key ID: DBA4C4549A927E56
2 changed files with 33 additions and 39 deletions

13
pom.xml
View file

@ -54,8 +54,8 @@
<url>https://jitpack.io</url> <url>https://jitpack.io</url>
</repository> </repository>
<repository> <repository>
<id>repo</id> <id>Factions</id>
<url>file://${basedir}/repo</url> <url>http://ci.ender.zone/plugin/repository/everything/</url>
</repository> </repository>
</repositories> </repositories>
<dependencies> <dependencies>
@ -83,17 +83,12 @@
<dependency> <dependency>
<groupId>com.massivecraft</groupId> <groupId>com.massivecraft</groupId>
<artifactId>Factions</artifactId> <artifactId>Factions</artifactId>
<version>3.2.2</version> <version>1.6.9.5-U0.5.16</version>
</dependency>
<dependency>
<groupId>com.massivecraft</groupId>
<artifactId>MassiveCore</artifactId>
<version>3.2.2</version>
</dependency> </dependency>
<dependency> <dependency>
<groupId>com.palmergames.bukkit.towny</groupId> <groupId>com.palmergames.bukkit.towny</groupId>
<artifactId>Towny</artifactId> <artifactId>Towny</artifactId>
<version>0.95.2.0</version> <version>0.96.2.0</version>
<scope>provided</scope> <scope>provided</scope>
</dependency> </dependency>
<dependency> <dependency>

View file

@ -3,13 +3,13 @@ package buttondevteam.presents.components.townyfactions;
import buttondevteam.lib.architecture.Component; import buttondevteam.lib.architecture.Component;
import buttondevteam.lib.architecture.ConfigData; import buttondevteam.lib.architecture.ConfigData;
import buttondevteam.presents.ButtonPresents; import buttondevteam.presents.ButtonPresents;
import com.massivecraft.factions.entity.BoardColl; import com.massivecraft.factions.Board;
import com.massivecraft.factions.event.EventFactionsChunksChange; import com.massivecraft.factions.FLocation;
import com.massivecraft.massivecore.ps.PS; import com.massivecraft.factions.event.LandClaimEvent;
import com.palmergames.bukkit.towny.TownyAPI;
import com.palmergames.bukkit.towny.event.TownPreClaimEvent; import com.palmergames.bukkit.towny.event.TownPreClaimEvent;
import com.palmergames.bukkit.towny.exceptions.NotRegisteredException; import com.palmergames.bukkit.towny.exceptions.NotRegisteredException;
import com.palmergames.bukkit.towny.object.Coord; import com.palmergames.bukkit.towny.object.Coord;
import com.palmergames.bukkit.towny.object.TownyUniverse;
import com.palmergames.bukkit.towny.object.WorldCoord; import com.palmergames.bukkit.towny.object.WorldCoord;
import org.bukkit.Location; import org.bukkit.Location;
import org.bukkit.World; import org.bukkit.World;
@ -35,21 +35,21 @@ public class TownyFactionsComponent extends Component<ButtonPresents> implements
} }
@EventHandler(ignoreCancelled = true) @EventHandler(ignoreCancelled = true)
public void onFactionsClaim(EventFactionsChunksChange event) throws NotRegisteredException { public void onFactionsClaim(LandClaimEvent event) throws NotRegisteredException {
if (event.getNewFaction().isNone()) if (event.getFaction().isWilderness())
return; //Allow unclaiming return; //Allow unclaiming
for (PS chunk : event.getChunks()) { FLocation chunk = event.getLocation();
int x = chunk.getChunkX() * 16; long x = chunk.getX() << 4;
int z = chunk.getChunkZ() * 16; long z = chunk.getZ() << 4;
int size = Coord.getCellSize(); int size = Coord.getCellSize();
int amount = 16 / size; int amount = 16 / size;
World world = chunk.asBukkitWorld(); World world = chunk.getWorld();
int max = 0; int max = 0;
if (amount < 1) amount = 1; //For plot sizes > 16 if (amount < 1) amount = 1; //For plot sizes > 16
for (int i = 0; i < amount; i++) { for (int i = 0; i < amount; i++) {
for (int j = 0; j < amount; j++) { for (int j = 0; j < amount; j++) {
Coord coord = Coord.parseCoord(new Location(world, x + i * size, 64, z + j * size)); Coord coord = Coord.parseCoord(new Location(world, x + i * size, 64, z + j * size));
int dist = TownyUniverse.getDataSource().getWorld(world.getName()) int dist = TownyAPI.getInstance().getDataSource().getWorld(world.getName())
.getMinDistanceFromOtherTownsPlots(coord); .getMinDistanceFromOtherTownsPlots(coord);
if (dist > max) max = dist; if (dist > max) max = dist;
} }
@ -57,21 +57,20 @@ public class TownyFactionsComponent extends Component<ButtonPresents> implements
int distance = max / amount; int distance = max / amount;
if (distance().get() >= distance) { if (distance().get() >= distance) {
event.setCancelled(true); event.setCancelled(true);
event.getSender().sendMessage("§cYou are too close to a town! " + (distance - 1) + " chunks away, " + distance().get() + " is allowed."); event.getfPlayer().sendMessage("§cYou are too close to a town! " + (distance - 1) + " chunks away, " + distance().get() + " is allowed.");
}
} }
} }
@EventHandler(ignoreCancelled = true) @EventHandler(ignoreCancelled = true)
public void onTownyClaim(TownPreClaimEvent event) { public void onTownyClaim(TownPreClaimEvent event) {
PS coord = PS.valueOf(getLocation(event.getTownBlock().getWorldCoord())); FLocation coord = new FLocation(getLocation(event.getTownBlock().getWorldCoord()));
int distance = distance().get(); int distance = distance().get();
for (int i = -distance + 1; i <= distance - 1; i++) { for (int i = -distance + 1; i <= distance - 1; i++) {
for (int j = -distance + 1; j <= distance - 1; j++) { for (int j = -distance + 1; j <= distance - 1; j++) {
if (i * i + j * j <= distance * distance) { if (i * i + j * j <= distance * distance) {
PS chunk = PS.valueOf(coord.getChunkX(true) + i, coord.getChunkZ(true) + j) FLocation chunk = new FLocation(coord.getWorldName(), (int) coord.getX() + i, (int) coord.getZ() + j);
.withWorld(coord.getWorld()); if (!Board.getInstance().getFactionAt(chunk).isWilderness()) {
if (!BoardColl.get().getFactionAt(chunk).isNone()) { event.setCancelMessage("§cYou are too close to a faction! " + (distance - 1) + " chunks away, " + distance().get() + " is allowed.");
event.setCancelled(true); event.setCancelled(true);
} }
} }