Skip to content
This repository was archived by the owner on Nov 17, 2020. It is now read-only.
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
31 changes: 31 additions & 0 deletions .classpath
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
<?xml version="1.0" encoding="UTF-8"?>
<classpath>
<classpathentry kind="src" output="target/classes" path="src/main/java">
<attributes>
<attribute name="optional" value="true"/>
<attribute name="maven.pomderived" value="true"/>
</attributes>
</classpathentry>
<classpathentry excluding="**" kind="src" output="target/classes" path="src/main/resources">
<attributes>
<attribute name="maven.pomderived" value="true"/>
</attributes>
</classpathentry>
<classpathentry kind="src" output="target/test-classes" path="src/test/java">
<attributes>
<attribute name="optional" value="true"/>
<attribute name="maven.pomderived" value="true"/>
</attributes>
</classpathentry>
<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/JavaSE-1.8">
<attributes>
<attribute name="maven.pomderived" value="true"/>
</attributes>
</classpathentry>
<classpathentry kind="con" path="org.eclipse.m2e.MAVEN2_CLASSPATH_CONTAINER">
<attributes>
<attribute name="maven.pomderived" value="true"/>
</attributes>
</classpathentry>
<classpathentry kind="output" path="target/classes"/>
</classpath>
23 changes: 23 additions & 0 deletions .project
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
<?xml version="1.0" encoding="UTF-8"?>
<projectDescription>
<name>PhantomCombat</name>
<comment></comment>
<projects>
</projects>
<buildSpec>
<buildCommand>
<name>org.eclipse.jdt.core.javabuilder</name>
<arguments>
</arguments>
</buildCommand>
<buildCommand>
<name>org.eclipse.m2e.core.maven2Builder</name>
<arguments>
</arguments>
</buildCommand>
</buildSpec>
<natures>
<nature>org.eclipse.jdt.core.javanature</nature>
<nature>org.eclipse.m2e.core.maven2Nature</nature>
</natures>
</projectDescription>
4 changes: 4 additions & 0 deletions .settings/org.eclipse.core.resources.prefs
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
eclipse.preferences.version=1
encoding//src/main/java=UTF-8
encoding//src/main/resources=UTF-8
encoding/<project>=UTF-8
5 changes: 5 additions & 0 deletions .settings/org.eclipse.jdt.core.prefs
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
eclipse.preferences.version=1
org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.8
org.eclipse.jdt.core.compiler.compliance=1.8
org.eclipse.jdt.core.compiler.problem.forbiddenReference=warning
org.eclipse.jdt.core.compiler.source=1.8
15 changes: 14 additions & 1 deletion src/main/java/io/github/lokka30/phantomcombat/PhantomCombat.java
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
import net.md_5.bungee.api.ChatMessageType;
import net.md_5.bungee.api.chat.TextComponent;
import org.bstats.bukkit.Metrics;
import org.bukkit.Bukkit;
import org.bukkit.ChatColor;
import org.bukkit.entity.Player;
import org.bukkit.plugin.PluginManager;
Expand All @@ -28,6 +29,7 @@ public class PhantomCombat extends JavaPlugin {
public FlatFile data;
boolean configEnabled = false;
public boolean hasWorldGuard = false;
private TempFlyRequirement tempflyRequirement;

public Utils utils;
public GracePeriodListener gracePeriodListener;
Expand All @@ -46,6 +48,9 @@ public void onEnable() {
log(LogLevel.INFO, "----- ENABLING BEGAN ----");
log(LogLevel.INFO, "&8[&71/5&8] &7Checking compatibility...");
checkCompatibility();
if (Bukkit.getPluginManager().getPlugin("TempFly") != null) {
try {tempflyRequirement = new TempFlyRequirement();} catch (Exception e) {}
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I put this in a try block as it will error with old TempFly versions that do not contain requirement provider. I didn't factor in their support as it was bugged anyway. You can add a message here in console to update TempFly to latest version for support.

}

log(LogLevel.INFO, "&8[&72/5&8] &7Loading files...");
loadFiles();
Expand Down Expand Up @@ -86,6 +91,14 @@ private void checkCompatibility() {
}
}

public TempFlyRequirement getTempFlyHook() {
return tempflyRequirement;
}

public boolean hasTempFly() {
return tempflyRequirement != null;
}

/*
Sets up the files from LightningStorage.
*/
Expand Down Expand Up @@ -229,4 +242,4 @@ public void actionBar(final Player p, final String msg) {
p.spigot().sendMessage(ChatMessageType.ACTION_BAR, TextComponent.fromLegacyText(colorize(msg)));
}

}
}
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
package io.github.lokka30.phantomcombat.listeners;

import com.moneybags.tempfly.TempFly;
import io.github.lokka30.phantomcombat.PhantomCombat;
import io.github.lokka30.phantomcombat.utils.CombatCause;
import org.bukkit.Bukkit;
Expand All @@ -26,7 +25,7 @@
public class CombatModeListener implements Listener {

private PhantomCombat instance;

public CombatModeListener(final PhantomCombat instance) {
this.instance = instance;
}
Expand Down Expand Up @@ -259,10 +258,6 @@ public void enterCombat(final Player player, CombatCause cause, String extraInfo
final int time = instance.settings.get("combat-mode.time", 15);
final UUID uuid = player.getUniqueId();

if (Bukkit.getPluginManager().getPlugin("TempFly") != null) {
TempFly.getAPI().toggleTempfly(player, false, false);
}

if (combatMap.containsKey(uuid)) {
//Since the user is already in combat, reset their timer.
combatMap.replace(uuid, time);
Expand All @@ -275,6 +270,10 @@ public void enterCombat(final Player player, CombatCause cause, String extraInfo
final boolean useBossBar = instance.messages.get("combat-mode.status.boss-bar.enable", true);
final boolean useChat = instance.messages.get("combat-mode.status.chat.enable", true);

if (instance.hasTempFly()) {
instance.getTempFlyHook().enterCombat(player);
}

//Setting reason for combat mode
String reason = getReason(cause, extraInfo);

Expand Down Expand Up @@ -305,11 +304,14 @@ public void run() {
cancel.remove(uuid);
return;
}


if (cancel.contains(uuid)) {
//the combat mode can be forced to expire, e.g. from death.
cancel();
if (instance.hasTempFly()) {
instance.getTempFlyHook().exitCombat(player);
}
if (wasAllowedFlight.contains(player)) {
player.setAllowFlight(true);
}
Expand Down Expand Up @@ -339,6 +341,9 @@ public void run() {
combatMap.remove(uuid);
cancel.remove(uuid);
combatFinished(player, bossBar, useBossBar, useChat, useActionBar);
if (instance.hasTempFly()) {
instance.getTempFlyHook().exitCombat(player);
}
}
}
}.runTaskTimer(instance, 0, 20);
Expand Down Expand Up @@ -410,4 +415,4 @@ public String getReason(CombatCause cause, String extraInfo) {
}
return reason;
}
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
package io.github.lokka30.phantomcombat.listeners;

import org.bukkit.entity.Player;

import com.moneybags.tempfly.TempFly;
import com.moneybags.tempfly.fly.RequirementProvider;
import com.moneybags.tempfly.fly.result.FlightResult;
import com.moneybags.tempfly.fly.result.ResultAllow;
import com.moneybags.tempfly.fly.result.ResultDeny;
import com.moneybags.tempfly.util.V;

public class TempFlyRequirement implements RequirementProvider {

public TempFlyRequirement() {
TempFly.getAPI().registerRequirementProvider(this);
}

@Override
public boolean handles(InquiryType type) {
return true;
}

public void enterCombat(Player p) {
TempFly.getAPI().getUser(p).submitFlightResult(new ResultDeny(FlightResult.DenyReason.COMBAT, this, RequirementProvider.InquiryType.OUT_OF_SCOPE, V.requireFailCombat, !V.damageCombat));
}

public void exitCombat(Player p) {
TempFly.getAPI().getUser(p).submitFlightResult(new ResultAllow(this, RequirementProvider.InquiryType.OUT_OF_SCOPE, V.requirePassCombat));
}

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You can control the fall damage and chat messages in the ResultDeny and ResultAllow constructors if you want.

}
Binary file modified src/main/resources/TempFly.jar
Binary file not shown.