SavageFactions 1.0.21

fixed this error (https://pastebin.com/4gtiQPYX)
 fixed damage bug (https://pastebin.com/56JHiPYt)
 fixed (https://prnt.sc/iy4l7q) (( I think I did, I could not replicate it ))
 Added methods to check if players can fly in claim types e.g.
 "if (fplayer.canflyinsafezone()){
 //do stuff
 }"
 Autofly now enables if you have bypass permissions.
 Fixed faction members, truces, and allies being able to hit each other and disable fly
 Fixed Autofly's enable message spamming multiple times if fly is already on.
This commit is contained in:
Naman 2018-03-30 21:22:06 -05:00
parent cdf870b782
commit e14af238bf
14 changed files with 691 additions and 123 deletions

10
pom.xml
View File

@ -47,6 +47,10 @@
<pattern>com.google.gson</pattern> <pattern>com.google.gson</pattern>
<shadedPattern>com.massivecraft.factions.shade.com.google.gson</shadedPattern> <shadedPattern>com.massivecraft.factions.shade.com.google.gson</shadedPattern>
</relocation> </relocation>
<relocation>
<pattern>com.darkblade12</pattern>
<shadedPattern>com.massivecraft.factions.shade.com.darkblade12</shadedPattern>
</relocation>
</relocations> </relocations>
</configuration> </configuration>
<executions> <executions>
@ -63,9 +67,9 @@
<dependencies> <dependencies>
<dependency> <dependency>
<groupId>org.inventivetalent</groupId> <groupId>com.darkblade12</groupId>
<artifactId>particleapi</artifactId> <artifactId>particleeffect</artifactId>
<version>2.1.1</version> <version>1.7.0-SNAPSHOT</version>
</dependency> </dependency>
<dependency> <dependency>
<groupId>org.spigotmc</groupId> <groupId>org.spigotmc</groupId>

View File

@ -159,6 +159,23 @@ public interface FPlayer extends EconomyParticipator {
public boolean hasMoney(int amt); public boolean hasMoney(int amt);
// Fly Checks
public Boolean canflyinWilderness();
public Boolean canflyinWarzone();
public Boolean canflyinSafezone();
public Boolean canflyinEnemy();
public Boolean canflyinAlly();
public Boolean canflyinTruce();
public Boolean canflyinNeutral();
// ------------------------------- // -------------------------------
// Relation and relation colors // Relation and relation colors
// ------------------------------- // -------------------------------

View File

@ -0,0 +1,498 @@
package com.massivecraft.factions;
/*
* Copyright 2018 (c) Massive Statistics LLC - All Rights Reserved
* This file may only be used in conjunction with the 'MassiveStats' service.
*/
import org.bukkit.Bukkit;
import org.bukkit.ChatColor;
import org.bukkit.event.EventHandler;
import org.bukkit.event.Listener;
import org.bukkit.event.player.PlayerJoinEvent;
import org.bukkit.plugin.java.JavaPlugin;
import org.bukkit.scheduler.BukkitRunnable;
import javax.net.ssl.HttpsURLConnection;
import java.io.BufferedReader;
import java.io.DataOutputStream;
import java.io.IOException;
import java.io.InputStreamReader;
import java.lang.reflect.InvocationTargetException;
import java.lang.reflect.Method;
import java.net.MalformedURLException;
import java.net.URL;
/**
* MassiveStats collects plugin and server information for plugin authors.
* You can learn more at our website: https://www.massivestats.com/
*
* @author Sam Jakob Harker, Brianna Hazel O'Keefe
* @version 3.0
*/
@SuppressWarnings("all")
public class MassiveStats implements Listener {
/* START: MASSIVESTATS SETTINGS */
public static final int CLIENT_VERSION = 0; // v3.0
public static final String API_URL = "https://report.massivestats.com/v2/";
public static final String MASSIVE_UPDATE_PERMISSION = "massivestats.update";
/* END: MASSIVESTATS SETTINGS */
private final JavaPlugin plugin;
private MassiveStatsUpdateTask task = null;
private int pingInterval;
private MassiveStatsDataResponse lastResponse;
private boolean listenerDisabled;
private Class jsonElement;
private Class jsonParser;
private Class jsonObject;
private Class jsonPrimitive;
/**
* @param plugin The plugin you wish to collect data for.
* @author Sam Jakob Harker
*/
public MassiveStats(JavaPlugin plugin) {
this(plugin, 900); // default value: 900 seconds (= 15 minutes)
}
/**
* @param plugin The plugin you wish to collect data for.
* @param pingInterval Duration between requests.
* @author Sam Jakob Harker
*/
public MassiveStats(JavaPlugin plugin, int pingInterval) {
try {
jsonElement = Class.forName("com.google.gson.JsonElement");
jsonParser = Class.forName("com.google.gson.JsonParser");
jsonObject = Class.forName("com.google.gson.JsonObject");
jsonPrimitive = Class.forName("com.google.gson.JsonPrimitive");
} catch (ClassNotFoundException ex) {
// Gson not included in classpath (so use NMS version)
try {
jsonElement = Class.forName("net.minecraft.util.com.google.gson.JsonElement");
jsonParser = Class.forName("net.minecraft.util.com.google.gson.JsonParser");
jsonObject = Class.forName("net.minecraft.util.com.google.gson.JsonObject");
jsonPrimitive = Class.forName("net.minecraft.util.com.google.gson.JsonPrimitive");
} catch (ClassNotFoundException ignored) {
Bukkit.getLogger().severe("MassiveStats could not find an instance/version of Gson to use.");
this.plugin = null;
return;
}
}
// Ensure the pingInterval that is set is reasonable.
if (pingInterval < 10 || pingInterval > 86400) {
pingInterval = 900;
}
// Ensure that a plugin instance has been provided.
if (plugin == null) {
throw new IllegalArgumentException("You must provide a plugin for MassiveStats to collect data for!");
}
// Set the ping interval.
this.pingInterval = pingInterval;
// Set the plugin reference.
this.plugin = plugin;
// and start sending data to the MassiveStats server immediately.
start();
// Register join/leave events for the plugin
Bukkit.getServer().getPluginManager().registerEvents(this, plugin);
}
/**
* Gets whether or not the built-in MassiveStats {@link org.bukkit.event.player.PlayerJoinEvent} listener is enabled.
*
* @return Whether or not the MassiveStats listener is enabled.
*/
public boolean isListenerDisabled() {
return listenerDisabled;
}
/**
* Sets whether or not the built-in MassiveStats {@link org.bukkit.event.player.PlayerJoinEvent} listener is enabled.
*
* @param listenerDisabled Whether or not the MassiveStats listener is enabled.
*/
public void setListenerDisabled(boolean listenerDisabled) {
this.listenerDisabled = listenerDisabled;
}
/**
* Start the MassiveStats reporting timer.
* If the timer is already running, this method will do nothing.
*
* @author Sam Jakob Harker
*/
public void start() {
if (this.plugin == null) {
Bukkit.getLogger().severe("MassiveStats could not find an instance/version of Gson to use and thus cannot start.");
return;
}
if (task == null) {
// If the API endpoint URL is invalid, don't start a new task to prevent the user from being spammed.
try {
new URL(MassiveStats.API_URL);
} catch (MalformedURLException ex) {
getPlugin()
.getLogger().warning("You have specified an invalid API endpoint for MassiveStats.");
return;
}
task = new MassiveStatsUpdateTask(this);
task.runTaskTimerAsynchronously(plugin, 0L, pingInterval * 20L);
}
}
/**
* Stop the MassiveStats reporting timer.
* Requests will no longer be sent to the server - or until {@link #start()} is invoked.
*
* @author Sam Jakob Harker
*/
public void stop() {
if (task == null) {
return;
}
task.cancel();
task = null;
}
/**
* Returns the duration, in seconds, that MassiveStats will wait before sending another request to the server.
*
* @return Duration between requests.
* @author Sam Jakob Harker
*/
public int getPingInterval() {
return pingInterval;
}
/**
* Sets the duration, in seconds, that MassiveStats should wait before sending another request to the server.
*
* @param pingInterval Duration between requests.
* @author Sam Jakob Harker
*/
public void setPingInterval(int pingInterval) {
this.pingInterval = pingInterval;
stop();
start();
}
/**
* Returns the plugin that this MassiveStats instance is collecting data for.
*
* @return MassiveStats instance plugin.
* @author Sam Jakob Harker
*/
public JavaPlugin getPlugin() {
return plugin;
}
/**
* Returns the contents of the last response from the MassiveStats server.
*
* @return MassiveStats server response.
* @author Sam Jakob Harker
*/
public MassiveStatsDataResponse getLastResponse() {
return lastResponse;
}
void setLastResponse(MassiveStatsDataResponse lastResponse) {
this.lastResponse = lastResponse;
}
@EventHandler
public void onPlayerJoin(PlayerJoinEvent event) {
// Ensure the listener should be active
if (lastResponse == null || listenerDisabled) {
return;
}
// Of course, only notify the user if the plugin is not up to date.
if (lastResponse.isUpToDate()) {
return;
}
// and only notify operators - or players with the correct permission.
if (!event.getPlayer().isOp() && !event.getPlayer().hasPermission(MassiveStats.MASSIVE_UPDATE_PERMISSION)) {
return;
}
event.getPlayer().sendMessage(lastResponse.getUpdateMessage());
}
Class getJsonElement() {
return jsonElement;
}
Class getJsonParser() {
return jsonParser;
}
Class getJsonObject() {
return jsonObject;
}
Class getJsonPrimitive() {
return jsonPrimitive;
}
}
class MassiveStatsUpdateTask extends BukkitRunnable {
private final MassiveStats instance;
MassiveStatsUpdateTask(MassiveStats requester) {
instance = requester;
}
@Override
@SuppressWarnings("all")
public void run() {
try {
// Generate the request payload and serialize it as JSON.
String payload = new MassiveStatsDataRequest(instance).serialize();
// Then create a new HttpsUrlConnection to the API server and open it.
HttpsURLConnection connection = (HttpsURLConnection) new URL(MassiveStats.API_URL).openConnection();
// Ensure that we don't hang the server with our 'dang shenanigans'.
connection.setConnectTimeout(2500);
connection.setReadTimeout(3500);
// Set the all-important request headers before we begin POSTing...
connection.setRequestMethod("POST");
connection.setRequestProperty("Accept", "application/json");
connection.setRequestProperty("Content-Type", "application/json; charset=utf-8");
connection.setRequestProperty("User-Agent", "Massive/" + MassiveStats.CLIENT_VERSION);
// Open the output stream, write the payload, and then close the stream.
connection.setDoOutput(true);
DataOutputStream output = new DataOutputStream(connection.getOutputStream());
output.writeBytes(payload);
output.flush();
output.close();
// Ensure that the server was happy with our data.
int responseCode = connection.getResponseCode();
if (responseCode != 200) {
throw new IOException();
}
// Now, read the server's response to our payload...
BufferedReader input = new BufferedReader(new InputStreamReader(connection.getInputStream()));
StringBuilder response = new StringBuilder();
// ...line by line.
String line;
while ((line = input.readLine()) != null) {
response.append(line);
}
input.close();
// Now, we parse the JSON object.
try {
if (response.toString().contains("ERR_DATA_MISSING")) {
Bukkit.getLogger().severe("MassiveStats has encountered an error for the following plugin: "
+ instance.getPlugin().getName());
instance.stop();
return;
}
Object parser = instance.getJsonParser().newInstance();
// JsonElement
Object serverResponseRaw =
parser.getClass().getMethod("parse", String.class).invoke(parser, response.toString());
// JsonObject
Object serverResponse = serverResponseRaw.getClass().getMethod("getAsJsonObject", null)
.invoke(serverResponseRaw, null);
Method serverResponseGet = instance.getJsonObject().getMethod("get", String.class);
Method getAsBoolean =
instance.getJsonPrimitive().getMethod("getAsBoolean", null);
Method getAsString =
instance.getJsonPrimitive().getMethod("getAsString", null);
if (serverResponseGet.invoke(serverResponse, "upToDate") == null) {
Bukkit.getLogger().severe("MassiveStats has encountered an error for the following plugin: "
+ instance.getPlugin().getName());
instance.stop();
return;
}
if (serverResponseGet.invoke(serverResponse, "notice") != null) {
Bukkit.getLogger().severe(
(String) getAsString.invoke(serverResponseGet.invoke(serverResponse, "notice"))
);
instance.stop();
return;
}
boolean upToDate = (boolean) getAsBoolean.invoke(serverResponseGet.invoke(serverResponse, "upToDate"), null);
String latestVersion = (String) getAsString.invoke(serverResponseGet.invoke(serverResponse, "latestVersion"), null);
String updateMessage = ChatColor.translateAlternateColorCodes(
'&', (String) getAsString.invoke(serverResponseGet.invoke(serverResponse, "updateMessage"), null)
);
instance.setLastResponse(new MassiveStatsDataResponse(
upToDate, latestVersion, updateMessage
));
} catch (IllegalAccessException | InstantiationException | NoSuchMethodException | InvocationTargetException e) {
instance.getPlugin()
.getLogger().warning("MassiveStats returned an invalid response for this plugin.");
}
// Finally, call an event to mark the update.
} catch (MalformedURLException ex) {
instance.getPlugin()
.getLogger().warning("You have specified an invalid API endpoint for MassiveStats.");
} catch (IOException ex) {
instance.getPlugin()
.getLogger().warning("MassiveStats was unable to communicate with its API endpoint.");
}
}
}
class MassiveStatsDataRequest {
private Object jsonObject;
MassiveStatsDataRequest(MassiveStats requester) {
try {
jsonObject = requester.getJsonObject().newInstance();
Method add =
requester.getJsonObject().newInstance().getClass().getMethod("add", String.class, requester.getJsonElement());
Method addPropertyString =
requester.getJsonObject().newInstance().getClass().getMethod("addProperty", String.class, String.class);
Method addPropertyNumber =
requester.getJsonObject().newInstance().getClass().getMethod("addProperty", String.class, Number.class);
Method addPropertyBoolean =
requester.getJsonObject().newInstance().getClass().getMethod("addProperty", String.class, Boolean.class);
addPropertyNumber.invoke(jsonObject, "now", System.currentTimeMillis());
/* PLUGIN DATA */
Object pluginObject = jsonObject.getClass().newInstance();
addPropertyString.invoke(pluginObject, "name", requester.getPlugin().getDescription().getName());
addPropertyString.invoke(pluginObject, "version", requester.getPlugin().getDescription().getVersion());
add.invoke(jsonObject, "plugin", pluginObject);
/* SERVER DATA */
Object minecraftServerObject = jsonObject.getClass().newInstance();
addPropertyNumber.invoke(minecraftServerObject, "players", Bukkit.getServer().getOnlinePlayers().size());
addPropertyBoolean.invoke(minecraftServerObject, "onlineMode", Bukkit.getServer().getOnlineMode());
addPropertyString.invoke(minecraftServerObject, "version", Bukkit.getServer().getVersion());
Object javaServerObject = jsonObject.getClass().newInstance();
addPropertyString.invoke(javaServerObject, "version", System.getProperty("java.version"));
Object osServerObject = jsonObject.getClass().newInstance();
addPropertyString.invoke(osServerObject, "name", System.getProperty("os.name"));
addPropertyString.invoke(osServerObject, "arch", System.getProperty("os.arch"));
addPropertyString.invoke(osServerObject, "version", System.getProperty("os.version"));
Object hardwareServerObject = jsonObject.getClass().newInstance();
addPropertyNumber.invoke(hardwareServerObject, "cores", Runtime.getRuntime().availableProcessors());
Object serverObject = jsonObject.getClass().newInstance();
add.invoke(serverObject, "minecraft", minecraftServerObject);
add.invoke(serverObject, "java", javaServerObject);
add.invoke(serverObject, "os", osServerObject);
add.invoke(serverObject, "hardware", hardwareServerObject);
add.invoke(jsonObject, "server", serverObject);
/* MASSIVE DATA */
Object massiveObject = jsonObject.getClass().newInstance();
addPropertyNumber.invoke(massiveObject, "version", MassiveStats.CLIENT_VERSION);
addPropertyNumber.invoke(massiveObject, "pingInterval", requester.getPingInterval());
//object.add("Massive", massiveObject);
add.invoke(jsonObject, "Massive", massiveObject);
} catch (IllegalAccessException | InstantiationException | NoSuchMethodException | InvocationTargetException e) {
e.printStackTrace();
}
}
@SuppressWarnings("all")
public String serialize() {
//return object.toString();
try {
Method toString = jsonObject.getClass().getMethod("toString", null);
return (String) toString.invoke(jsonObject);
} catch (NoSuchMethodException | IllegalAccessException | InvocationTargetException e) {
e.printStackTrace();
}
return null;
}
}
@SuppressWarnings("unused")
final class MassiveStatsDataResponse {
private final boolean isUpToDate;
private final String newVersion;
private final String updateMessage;
MassiveStatsDataResponse(boolean isUpToDate, String newVersion, String updateMessage) {
this.isUpToDate = isUpToDate;
if (!isUpToDate) {
this.newVersion = newVersion;
this.updateMessage = updateMessage;
return;
}
this.newVersion = null;
this.updateMessage = null;
}
/**
* Indicates whether or not this version of the plugin is the latest.
* True = This is the latest version of the plugin.
* False = There is an update available.
*
* @return Whether or not there is an update available.
*/
public boolean isUpToDate() {
return isUpToDate;
}
/**
* Gets the name of the latest version. If this is the latest version, it returns null.
*
* @return The name of the latest version.
*/
public String getLatestVersion() {
return newVersion;
}
/**
* Gets the message to display, convincing the user to update to the new version of the plugin.
*
* @return The update message to display.
*/
public String getUpdateMessage() {
return updateMessage;
}
}

View File

@ -139,6 +139,8 @@ public class P extends MPlugin {
// start up task which runs the autoLeaveAfterDaysOfInactivity routine // start up task which runs the autoLeaveAfterDaysOfInactivity routine
startAutoLeaveTask(false); startAutoLeaveTask(false);
//massive stats
MassiveStats massive = new MassiveStats(this);
mc17 = Bukkit.getServer().getClass().getPackage().getName().contains("1.7"); mc17 = Bukkit.getServer().getClass().getPackage().getName().contains("1.7");

View File

@ -1,5 +1,6 @@
package com.massivecraft.factions.cmd; package com.massivecraft.factions.cmd;
import com.darkblade12.particleeffect.ParticleEffect;
import com.massivecraft.factions.*; import com.massivecraft.factions.*;
import com.massivecraft.factions.struct.Permission; import com.massivecraft.factions.struct.Permission;
import com.massivecraft.factions.struct.Relation; import com.massivecraft.factions.struct.Relation;
@ -9,7 +10,6 @@ import org.bukkit.Bukkit;
import org.bukkit.GameMode; import org.bukkit.GameMode;
import org.bukkit.entity.Entity; import org.bukkit.entity.Entity;
import org.bukkit.entity.Player; import org.bukkit.entity.Player;
import org.inventivetalent.particle.ParticleEffect;
import java.util.HashMap; import java.util.HashMap;
import java.util.Iterator; import java.util.Iterator;
@ -19,8 +19,8 @@ public class CmdFly extends FCommand {
public static HashMap<String,Boolean> flyMap = new HashMap<String,Boolean>(); public static HashMap<String,Boolean> flyMap = new HashMap<String,Boolean>();
public int id = -1; public static int id = -1;
public int flyid = -1; public static int flyid = -1;
public CmdFly() { public CmdFly() {
super(); super();
this.aliases.add("fly"); this.aliases.add("fly");
@ -156,7 +156,7 @@ public class CmdFly extends FCommand {
} }
public void startParticles(){ public static void startParticles() {
id = Bukkit.getScheduler().scheduleSyncRepeatingTask(P.p, new Runnable() { id = Bukkit.getScheduler().scheduleSyncRepeatingTask(P.p, new Runnable() {
@Override @Override
public void run() { public void run() {
@ -169,7 +169,8 @@ public class CmdFly extends FCommand {
continue; continue;
} }
ParticleEffect.CLOUD.send(Bukkit.getOnlinePlayers(), player.getLocation().add(0, -0.35, 0), 0, 0, 0, 0, 3, 16);
ParticleEffect.CLOUD.display(0, 0, 0, 0, 1, player.getLocation().add(0, -0.35, 0), 16);
} }
if (flyMap.keySet().size() == 0){ if (flyMap.keySet().size() == 0){
@ -180,7 +181,7 @@ public class CmdFly extends FCommand {
}, 10L, 10L); }, 10L, 10L);
} }
public void startFlyCheck(){ public static void startFlyCheck() {
flyid = Bukkit.getScheduler().scheduleSyncRepeatingTask(P.p, new Runnable() { flyid = Bukkit.getScheduler().scheduleSyncRepeatingTask(P.p, new Runnable() {
@Override @Override
public void run() { public void run() {
@ -210,7 +211,7 @@ public class CmdFly extends FCommand {
if (Board.getInstance().getFactionAt(myFloc) != myFaction) { if (Board.getInstance().getFactionAt(myFloc) != myFaction) {
if (!checkBypassPerms(fPlayer,player,toFac)){ if (!checkBypassPerms(fPlayer,player,toFac)){
fPlayer.setFlying(false); fPlayer.setFlying(false);
flyMap.remove(name); itr.remove();
continue; continue;
} }
@ -224,8 +225,7 @@ public class CmdFly extends FCommand {
} }
private static boolean checkBypassPerms(FPlayer fplayer, Player player, Faction toFac) {
private boolean checkBypassPerms(FPlayer fplayer, Player player,Faction toFac){
if (player.hasPermission("factions.fly.wilderness") && toFac.isWilderness()){ if (player.hasPermission("factions.fly.wilderness") && toFac.isWilderness()){
return true; return true;
} }
@ -250,7 +250,7 @@ public class CmdFly extends FCommand {
return false; return false;
} }
public void checkTaskState(){ public static void checkTaskState() {
if (flyMap.keySet().size() == 0) { if (flyMap.keySet().size() == 0) {
Bukkit.getScheduler().cancelTask(flyid); Bukkit.getScheduler().cancelTask(flyid);
flyid = -1; flyid = -1;
@ -258,9 +258,6 @@ public class CmdFly extends FCommand {
} }
private void toggleFlight(final boolean toggle, final Player player) { private void toggleFlight(final boolean toggle, final Player player) {
if (!toggle) { if (!toggle) {
fme.setFlying(false); fme.setFlying(false);

View File

@ -1,6 +1,7 @@
package com.massivecraft.factions.cmd; package com.massivecraft.factions.cmd;
import com.darkblade12.particleeffect.ParticleEffect;
import com.massivecraft.factions.FLocation; import com.massivecraft.factions.FLocation;
import com.massivecraft.factions.P; import com.massivecraft.factions.P;
import com.massivecraft.factions.struct.Permission; import com.massivecraft.factions.struct.Permission;
@ -11,7 +12,6 @@ import org.bukkit.Location;
import org.bukkit.Material; import org.bukkit.Material;
import org.bukkit.World; import org.bukkit.World;
import org.bukkit.entity.Player; import org.bukkit.entity.Player;
import org.inventivetalent.particle.ParticleEffect;
import java.util.Arrays; import java.util.Arrays;
import java.util.HashMap; import java.util.HashMap;
@ -29,6 +29,7 @@ public class CmdSeeChunk extends FCommand {
private int taskID = -1; private int taskID = -1;
//I remade it cause of people getting mad that I had the same seechunk as drtshock //I remade it cause of people getting mad that I had the same seechunk as drtshock
@ -46,7 +47,8 @@ public class CmdSeeChunk extends FCommand {
this.useParticles = p.getConfig().getBoolean("see-chunk.particles", true); this.useParticles = p.getConfig().getBoolean("see-chunk.particles", true);
interval = P.p.getConfig().getLong("see-chunk.interval", 10L); interval = P.p.getConfig().getLong("see-chunk.interval", 10L);
effect = ParticleEffect.valueOf(P.p.getConfig().getString("see-chunk.particle", "REDSTONE")); effect = ParticleEffect.fromName(P.p.getConfig().getString("see-chunk.particle", "REDSTONE"));
} }
@Override @Override
@ -101,6 +103,7 @@ public class CmdSeeChunk extends FCommand {
blockZ = chunkZ * 16; blockZ = chunkZ * 16;
showPillar(me, world, blockX, blockZ); showPillar(me, world, blockX, blockZ);
blockX = chunkX * 16 + 15; blockX = chunkX * 16 + 15;
blockZ = chunkZ * 16; blockZ = chunkZ * 16;
showPillar(me, world, blockX, blockZ); showPillar(me, world, blockX, blockZ);
@ -123,8 +126,10 @@ public class CmdSeeChunk extends FCommand {
} }
if (useParticles) { if (useParticles) {
//api didnt seem to have anything for a single player, so I used a one player list :P
effect.send(onePlayer, loc, 0, 0, 0, 0, 1, 50); this.effect.display(0, 0, 0, 0, 3, loc, player);
} else { } else {
int typeId = blockY % 5 == 0 ? Material.REDSTONE_LAMP_ON.getId() : Material.STAINED_GLASS.getId(); int typeId = blockY % 5 == 0 ? Material.REDSTONE_LAMP_ON.getId() : Material.STAINED_GLASS.getId();
VisualizeUtil.addLocation(player, loc, typeId); VisualizeUtil.addLocation(player, loc, typeId);
@ -132,6 +137,7 @@ public class CmdSeeChunk extends FCommand {
} }
} }
@Override @Override
public TL getUsageTranslation() { public TL getUsageTranslation() {
return TL.GENERIC_PLACEHOLDER; return TL.GENERIC_PLACEHOLDER;

View File

@ -1,13 +1,13 @@
package com.massivecraft.factions.cmd; package com.massivecraft.factions.cmd;
import com.massivecraft.factions.*; import com.massivecraft.factions.Conf;
import com.massivecraft.factions.Faction;
import com.massivecraft.factions.P;
import com.massivecraft.factions.struct.Permission; import com.massivecraft.factions.struct.Permission;
import com.massivecraft.factions.struct.Role;
import com.massivecraft.factions.zcore.util.TL; import com.massivecraft.factions.zcore.util.TL;
import com.massivecraft.factions.zcore.util.TagReplacer; import com.massivecraft.factions.zcore.util.TagReplacer;
import com.massivecraft.factions.zcore.util.TagUtil; import com.massivecraft.factions.zcore.util.TagUtil;
import mkremins.fanciful.FancyMessage; import mkremins.fanciful.FancyMessage;
import org.bukkit.Bukkit;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.List; import java.util.List;
@ -19,7 +19,6 @@ public class CmdShow extends FCommand {
public CmdShow() { public CmdShow() {
this.aliases.add("show"); this.aliases.add("show");
this.aliases.add("who"); this.aliases.add("who");
this.aliases.add("f");
// add defaults to /f show in case config doesnt have it // add defaults to /f show in case config doesnt have it
defaults.add("{header}"); defaults.add("{header}");
@ -48,7 +47,6 @@ public class CmdShow extends FCommand {
@Override @Override
public void perform() { public void perform() {
Faction faction = myFaction; Faction faction = myFaction;
if (this.argIsSet(0)) { if (this.argIsSet(0)) {
faction = this.argAsFaction(0); faction = this.argAsFaction(0);
} }
@ -56,11 +54,6 @@ public class CmdShow extends FCommand {
return; return;
} }
if (!fme.hasFaction() && fme.getFaction() == faction){
fme.msg(TL.COMMAND_SHOW_NEEDFACTION);
return;
}
if (fme != null && !fme.getPlayer().hasPermission("factions.show.bypassexempt") if (fme != null && !fme.getPlayer().hasPermission("factions.show.bypassexempt")
&& P.p.getConfig().getStringList("show-exempt").contains(faction.getTag())) { && P.p.getConfig().getStringList("show-exempt").contains(faction.getTag())) {
msg(TL.COMMAND_SHOW_EXEMPT); msg(TL.COMMAND_SHOW_EXEMPT);
@ -76,65 +69,6 @@ public class CmdShow extends FCommand {
if (show == null || show.isEmpty()) { if (show == null || show.isEmpty()) {
show = defaults; show = defaults;
} }
/* for (int i = 0; i <= show.size()-1; i ++){
if (show.get(i).contains("{description}")){
show.set(i,show.get(i).replace("{description}",faction.getDescription()));
}
if (show.get(i).contains("{online-list}")){
String message = "";
StringBuilder string = new StringBuilder(message);
for (FPlayer fPlayer : faction.getFPlayers()){
Bukkit.broadcastMessage(fPlayer.getTag());
if (fPlayer.getPlayer().isOnline()){
String prefix = "";
if (fPlayer.getRole() == Role.ADMIN){
prefix = Conf.prefixAdmin;
}
if (fPlayer.getRole() == Role.COLEADER){
prefix = Conf.prefixCoLeader;
}
if (fPlayer.getRole() == Role.MODERATOR){
prefix = Conf.prefixMod;
}
if (fPlayer.getRole() == Role.NORMAL){
prefix = Conf.prefixNormal;
}
if (fPlayer.getRole() == Role.RECRUIT){
prefix = Conf.prefixRecruit;
}
string.append(prefix + fPlayer.getName() + ",");
}
if (string.toString().equals("")) { continue; }
show.set(i,show.get(i).replace("{online-list}",string.toString()));
}
}
if (show.get(i).contains("{offline-list}")){
String message = "";
StringBuilder string = new StringBuilder(message);
for (FPlayer fPlayer : faction.getFPlayers()){
if (!fPlayer.getPlayer().isOnline()){
String prefix = "";
if (fPlayer.getRole() == Role.ADMIN){
prefix = Conf.prefixAdmin;
}
if (fPlayer.getRole() == Role.COLEADER){
prefix = Conf.prefixCoLeader;
}
if (fPlayer.getRole() == Role.MODERATOR){
prefix = Conf.prefixMod;
}
if (fPlayer.getRole() == Role.NORMAL){
prefix = Conf.prefixNormal;
}
if (fPlayer.getRole() == Role.RECRUIT){
prefix = Conf.prefixRecruit;
}
string.append(prefix + fPlayer.getName() + ",");
}
show.set(i,show.get(i).replace("{offline-list}",string.toString()));
}
}
}*/
if (!faction.isNormal()) { if (!faction.isNormal()) {
String tag = faction.getTag(fme); String tag = faction.getTag(fme);
@ -154,9 +88,11 @@ public class CmdShow extends FCommand {
continue; // Due to minimal f show. continue; // Due to minimal f show.
} }
if (fme != null) {
parsed = TagUtil.parsePlaceholders(fme.getPlayer(), parsed); parsed = TagUtil.parsePlaceholders(fme.getPlayer(), parsed);
}
if (TagUtil.hasFancy(parsed)) { if (fme != null && TagUtil.hasFancy(parsed)) {
List<FancyMessage> fancy = TagUtil.parseFancy(faction, fme, parsed); List<FancyMessage> fancy = TagUtil.parseFancy(faction, fme, parsed);
if (fancy != null) { if (fancy != null) {
sendFancyMessage(fancy); sendFancyMessage(fancy);

View File

@ -99,7 +99,17 @@ public class FactionsEntityListener implements Listener {
Entity damagee = sub.getEntity(); Entity damagee = sub.getEntity();
Entity damager = sub.getDamager(); Entity damager = sub.getDamager();
if (damagee instanceof Player) {
if (damager instanceof Player) {
FPlayer fdamager = FPlayers.getInstance().getByPlayer((Player) damager);
FPlayer fdamagee = FPlayers.getInstance().getByPlayer((Player) damagee);
if ((fdamagee.getRelationTo(fdamager) == Relation.ALLY) ||
(fdamagee.getRelationTo(fdamager) == Relation.TRUCE) ||
(fdamagee.getFaction() == fdamager.getFaction())) {
return;
}
}
}
if (damagee != null && damagee instanceof Player) { if (damagee != null && damagee instanceof Player) {
cancelFStuckTeleport((Player) damagee); cancelFStuckTeleport((Player) damagee);
cancelFFly((Player) damagee); cancelFFly((Player) damagee);
@ -587,11 +597,13 @@ public class FactionsEntityListener implements Listener {
public void onBowHit(EntityDamageByEntityEvent e){ public void onBowHit(EntityDamageByEntityEvent e){
if (e.getDamager() instanceof Projectile){ if (e.getDamager() instanceof Projectile){
if (e.getEntity() instanceof Player){ if (e.getEntity() instanceof Player){
Projectile arrow = ((Projectile) e.getDamager());
if (arrow.getShooter() instanceof Player) {
Player damager = (Player) ((Projectile) e.getDamager()).getShooter(); Player damager = (Player) ((Projectile) e.getDamager()).getShooter();
Player victim = (Player) e.getEntity(); Player victim = (Player) e.getEntity();
FPlayer fdamager = FPlayers.getInstance().getByPlayer(damager); FPlayer fdamager = FPlayers.getInstance().getByPlayer(damager);
FPlayer fvictim = FPlayers.getInstance().getByPlayer(victim); FPlayer fvictim = FPlayers.getInstance().getByPlayer(victim);
if (fvictim.getRelationTo(fdamager) == Relation.TRUCE){ if (fvictim.getRelationTo(fdamager) == Relation.TRUCE) {
fdamager.msg(TL.PLAYER_PVP_CANTHURT, fvictim.describeTo(fdamager)); fdamager.msg(TL.PLAYER_PVP_CANTHURT, fvictim.describeTo(fdamager));
e.setCancelled(true); e.setCancelled(true);
} }
@ -603,6 +615,7 @@ public class FactionsEntityListener implements Listener {
} }
} }
} }
}
private boolean stopEndermanBlockManipulation(Location loc) { private boolean stopEndermanBlockManipulation(Location loc) {
if (loc == null) { if (loc == null) {

View File

@ -1,5 +1,6 @@
package com.massivecraft.factions.listeners; package com.massivecraft.factions.listeners;
import com.darkblade12.particleeffect.ParticleEffect;
import com.massivecraft.factions.*; import com.massivecraft.factions.*;
import com.massivecraft.factions.cmd.CmdFly; import com.massivecraft.factions.cmd.CmdFly;
import com.massivecraft.factions.cmd.CmdSeeChunk; import com.massivecraft.factions.cmd.CmdSeeChunk;
@ -41,7 +42,6 @@ import org.bukkit.inventory.ItemStack;
import org.bukkit.potion.PotionEffect; import org.bukkit.potion.PotionEffect;
import org.bukkit.potion.PotionEffectType; import org.bukkit.potion.PotionEffectType;
import org.bukkit.util.NumberConversions; import org.bukkit.util.NumberConversions;
import org.inventivetalent.particle.ParticleEffect;
import java.util.*; import java.util.*;
import java.util.logging.Level; import java.util.logging.Level;
@ -240,6 +240,22 @@ public class FactionsPlayerListener implements Listener {
return string; return string;
} }
public void enableFly(FPlayer me) {
if (P.p.getConfig().getBoolean("ffly.AutoEnable")) {
me.setFlying(true);
CmdFly.flyMap.put(me.getName(), true);
if (CmdFly.id == -1) {
if (P.p.getConfig().getBoolean("ffly.Particles.Enabled")) {
CmdFly.startParticles();
}
}
if (CmdFly.flyid == -1) {
CmdFly.startFlyCheck();
}
}
}
// Holds the next time a player can have a map shown. // Holds the next time a player can have a map shown.
private HashMap<UUID, Long> showTimes = new HashMap<>(); private HashMap<UUID, Long> showTimes = new HashMap<>();
@ -289,26 +305,27 @@ public class FactionsPlayerListener implements Listener {
me.getPlayer().sendTitle(P.p.color(title), P.p.color(subTitle)); me.getPlayer().sendTitle(P.p.color(title), P.p.color(subTitle));
} }
// enable fly :) // enable fly :)
if (me.hasFaction()) { if (me.hasFaction() && !me.isFlying()) {
if (factionTo == me.getFaction()) { if (factionTo == me.getFaction()) {
if (P.p.getConfig().getBoolean("ffly.AutoEnable")) { enableFly(me);
CmdFly Fly = new CmdFly(); }
me.setFlying(true); // bypass checks
Fly.flyMap.put(player.getName(), true); if ((factionTo.isWilderness() && me.canflyinWilderness()) ||
if (Fly.id == -1) { (factionTo.isWarZone() && me.canflyinWarzone()) ||
if (P.p.getConfig().getBoolean("ffly.Particles.Enabled")) { (factionTo.isSafeZone() && me.canflyinSafezone()) ||
Fly.startParticles(); (factionTo.getRelationTo(me) == Relation.ENEMY && me.canflyinEnemy()) ||
} (factionTo.getRelationTo(me) == Relation.ALLY && me.canflyinAlly()) ||
} (factionTo.getRelationTo(me) == Relation.TRUCE && me.canflyinTruce()) ||
if (Fly.flyid == -1) { (factionTo.getRelationTo(me) == Relation.NEUTRAL && me.canflyinNeutral())) {
Fly.startFlyCheck(); enableFly(me);
} }
}
}
} }
} }
if (me.isMapAutoUpdating()) { if (me.isMapAutoUpdating()) {
if (showTimes.containsKey(player.getUniqueId()) && (showTimes.get(player.getUniqueId()) > System.currentTimeMillis())) { if (showTimes.containsKey(player.getUniqueId()) && (showTimes.get(player.getUniqueId()) > System.currentTimeMillis())) {
if (P.p.getConfig().getBoolean("findfactionsexploit.log", false)) { if (P.p.getConfig().getBoolean("findfactionsexploit.log", false)) {
@ -371,6 +388,7 @@ public class FactionsPlayerListener implements Listener {
} }
HashMap<String,Boolean> bannerCooldownMap = new HashMap<>(); HashMap<String,Boolean> bannerCooldownMap = new HashMap<>();
public static HashMap<String,Location> bannerLocations = new HashMap<>(); public static HashMap<String,Location> bannerLocations = new HashMap<>();
@EventHandler @EventHandler
@ -437,8 +455,8 @@ public class FactionsPlayerListener implements Listener {
String[] components = effect.split(":"); String[] components = effect.split(":");
player.addPotionEffect(new PotionEffect(PotionEffectType.getByName(components[0]),100,Integer.parseInt(components[1]))); player.addPotionEffect(new PotionEffect(PotionEffectType.getByName(components[0]),100,Integer.parseInt(components[1])));
} }
ParticleEffect.FLAME.send(Bukkit.getOnlinePlayers(), banner.getLocation(), 1, 1, 1, 1, 10, 16); ParticleEffect.LAVA.display(1, 1, 1, 1, 10, banner.getLocation(), 16);
ParticleEffect.LAVA.send(Bukkit.getOnlinePlayers(), banner.getLocation(), 1, 1, 1, 1, 10, 16); ParticleEffect.FLAME.display(1, 1, 1, 1, 10, banner.getLocation(), 16);
if (banner.getType() != bannerType){ if (banner.getType() != bannerType){
banner.setType(bannerType); banner.setType(bannerType);

View File

@ -1130,6 +1130,79 @@ public abstract class MemoryFPlayer implements FPlayer {
return false; return false;
} }
@Override
public Boolean canflyinWilderness() {
if (getPlayer().hasPermission("factions.fly.wilderness")) {
return true;
} else {
return false;
}
}
@Override
public Boolean canflyinWarzone() {
if (getPlayer().hasPermission("factions.fly.warzone")) {
return true;
} else {
return false;
}
}
@Override
public Boolean canflyinSafezone() {
if (getPlayer().hasPermission("factions.fly.safezone")) {
return true;
} else {
return false;
}
}
@Override
public Boolean canflyinEnemy() {
if (getPlayer().hasPermission("factions.fly.enemy")) {
return true;
} else {
return false;
}
}
@Override
public Boolean canflyinAlly() {
if (getPlayer().hasPermission("factions.fly.ally")) {
return true;
} else {
return false;
}
}
@Override
public Boolean canflyinTruce() {
if (getPlayer().hasPermission("factions.fly.truce")) {
return true;
} else {
return false;
}
}
@Override
public Boolean canflyinNeutral() {
if (getPlayer().hasPermission("factions.fly.neutral")) {
return true;
} else {
return false;
}
}
@Override @Override
public String getRolePrefix() { public String getRolePrefix() {

View File

@ -279,6 +279,9 @@ public enum TagReplacer {
* @return if the raw line contains this enums variable * @return if the raw line contains this enums variable
*/ */
public boolean contains(String toSearch) { public boolean contains(String toSearch) {
if (tag == null) {
return false;
}
return toSearch.contains(tag); return toSearch.contains(tag);
} }

View File

@ -858,7 +858,8 @@ see-chunk:
# Interval between when particles are sent # Interval between when particles are sent
# setting to 10 makes it a constant heartbeat effect # setting to 10 makes it a constant heartbeat effect
# setting to 5, makes it almost solid ( looks better imo but is more intensive) # setting to 5, makes it almost solid ( looks better imo but is more intensive)
interval: 10 interval: 20
############################################################ ############################################################
# +------------------------------------------------------+ # # +------------------------------------------------------+ #

View File

@ -1,5 +1,5 @@
name: Factions name: Factions
version: ${project.version}-SF-1.0.19 version: ${project.version}-SF-1.0.21 crea
main: com.massivecraft.factions.P main: com.massivecraft.factions.P
authors: [Olof Larsson, Brett Flannigan, drtshock, ProSavage] authors: [Olof Larsson, Brett Flannigan, drtshock, ProSavage]
softdepend: [PlayerVaults, PlaceholderAPI, MVdWPlaceholderAPI, PermissionsEx, Permissions, Essentials, EssentialsChat, HeroChat, iChat, LocalAreaChat, LWC, nChat, ChatManager, CAPI, AuthMe, Vault, Spout, WorldEdit, WorldGuard, AuthDB, CaptureThePoints, CombatTag, dynmap, FactionsTop] softdepend: [PlayerVaults, PlaceholderAPI, MVdWPlaceholderAPI, PermissionsEx, Permissions, Essentials, EssentialsChat, HeroChat, iChat, LocalAreaChat, LWC, nChat, ChatManager, CAPI, AuthMe, Vault, Spout, WorldEdit, WorldGuard, AuthDB, CaptureThePoints, CombatTag, dynmap, FactionsTop]