Add GravityTubes
This commit is contained in:
parent
e48fab5652
commit
5533a67f0b
Binary file not shown.
|
@ -32,8 +32,8 @@
|
|||
<url>http://repo.citizensnpcs.co/</url>
|
||||
</repository>
|
||||
<repository>
|
||||
<id>drtshock-repo</id>
|
||||
<url>http://ci.drtshock.net/plugin/repository/everything/</url>
|
||||
<id>repo-public</id>
|
||||
<url>https://repo.codemc.org/repository/maven-public/</url>
|
||||
</repository>
|
||||
</repositories>
|
||||
|
||||
|
@ -48,13 +48,13 @@
|
|||
<dependency>
|
||||
<groupId>com.gmail.nossr50.mcMMO</groupId>
|
||||
<artifactId>mcMMO</artifactId>
|
||||
<version>1.5.04-SNAPSHOT</version>
|
||||
<version>2.1.158</version>
|
||||
<scope>provided</scope>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>fr.neatmonster</groupId>
|
||||
<artifactId>nocheatplus</artifactId>
|
||||
<version>3.16.0-SNAPSHOT</version>
|
||||
<version>3.16.1-SNAPSHOT</version>
|
||||
<scope>provided</scope>
|
||||
</dependency>
|
||||
<dependency>
|
||||
|
@ -62,10 +62,43 @@
|
|||
<artifactId>citizensapi</artifactId>
|
||||
<version>2.0.16-SNAPSHOT</version>
|
||||
<scope>provided</scope>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>com.benzoft.gravitytubes</groupId>
|
||||
<artifactId>gravitytubes</artifactId>
|
||||
<version>1.0</version>
|
||||
<scope>system</scope>
|
||||
<systemPath>${basedir}/libs/GravityTubes.jar</systemPath>
|
||||
</dependency>
|
||||
</dependencies>
|
||||
|
||||
<!-- Building -->
|
||||
|
||||
<!-- Build Description Profiles -->
|
||||
<profiles>
|
||||
<profile>
|
||||
<id>timestamp</id>
|
||||
<activation>
|
||||
<property>
|
||||
<name>!env.BUILD_NUMBER</name>
|
||||
</property>
|
||||
</activation>
|
||||
<properties>
|
||||
<buildDescription>${maven.build.timestamp}</buildDescription>
|
||||
</properties>
|
||||
</profile>
|
||||
<profile>
|
||||
<id>dynamic_build_number</id>
|
||||
<activation>
|
||||
<property>
|
||||
<name>env.BUILD_NUMBER</name>
|
||||
</property>
|
||||
</activation>
|
||||
<properties>
|
||||
<buildDescription>b${env.BUILD_NUMBER}</buildDescription>
|
||||
</properties>
|
||||
</profile>
|
||||
</profiles>
|
||||
|
||||
<!-- Building -->
|
||||
<build>
|
||||
<defaultGoal>clean package</defaultGoal>
|
||||
<sourceDirectory>${basedir}/src</sourceDirectory>
|
||||
|
@ -86,8 +119,8 @@
|
|||
<artifactId>maven-compiler-plugin</artifactId>
|
||||
<version>2.5.1</version>
|
||||
<configuration>
|
||||
<source>1.6</source>
|
||||
<target>1.6</target>
|
||||
<source>1.8</source>
|
||||
<target>1.8</target>
|
||||
</configuration>
|
||||
</plugin>
|
||||
<plugin>
|
||||
|
@ -106,7 +139,6 @@
|
|||
</archive>
|
||||
</configuration>
|
||||
</plugin>
|
||||
|
||||
</plugins>
|
||||
</build>
|
||||
|
||||
|
@ -115,7 +147,6 @@
|
|||
<!-- Properties -->
|
||||
<properties>
|
||||
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
|
||||
<BUILD_SERIES>?</BUILD_SERIES>
|
||||
<BUILD_NUMBER>?</BUILD_NUMBER>
|
||||
<maven.build.timestamp.format>yyyy_MM_dd-HH_mm</maven.build.timestamp.format>
|
||||
</properties>
|
||||
</project>
|
|
@ -182,6 +182,11 @@ public class CompatNoCheatPlus extends JavaPlugin implements Listener {
|
|||
builtinHooks.add(new me.asofold.bpl.cncp.hooks.mcmmo.HookmcMMO());
|
||||
}
|
||||
catch (Throwable t){}
|
||||
// GravityTubes
|
||||
try {
|
||||
builtinHooks.add(new me.asofold.bpl.cncp.hooks.GravityTubes.HookGravityTubes());
|
||||
}
|
||||
catch(Throwable t){}
|
||||
// // MagicSpells
|
||||
// try{
|
||||
// builtinHooks.add(new me.asofold.bpl.cncp.hooks.magicspells.HookMagicSpells());
|
||||
|
|
|
@ -0,0 +1,82 @@
|
|||
package me.asofold.bpl.cncp.hooks.GravityTubes;
|
||||
|
||||
import org.bukkit.GameMode;
|
||||
import org.bukkit.Location;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.event.player.PlayerMoveEvent;
|
||||
import org.bukkit.permissions.Permissible;
|
||||
|
||||
import com.benzoft.gravitytubes.GTPerm;
|
||||
import com.benzoft.gravitytubes.GravityTube;
|
||||
import com.benzoft.gravitytubes.files.ConfigFile;
|
||||
import com.benzoft.gravitytubes.files.GravityTubesFile;
|
||||
|
||||
import fr.neatmonster.nocheatplus.checks.CheckType;
|
||||
import fr.neatmonster.nocheatplus.checks.access.IViolationInfo;
|
||||
import fr.neatmonster.nocheatplus.checks.moving.MovingData;
|
||||
import fr.neatmonster.nocheatplus.hooks.NCPHook;
|
||||
import fr.neatmonster.nocheatplus.players.DataManager;
|
||||
import fr.neatmonster.nocheatplus.players.IPlayerData;
|
||||
import fr.neatmonster.nocheatplus.utilities.location.TrigUtil;
|
||||
import me.asofold.bpl.cncp.hooks.GravityTubes.HookGravityTubes.HookFacade;
|
||||
|
||||
public class HookFacadeImpl implements HookFacade, NCPHook {
|
||||
|
||||
public HookFacadeImpl(){}
|
||||
|
||||
@Override
|
||||
public String getHookName() {
|
||||
return "GravityTubes(cncp)";
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getHookVersion() {
|
||||
return "1.1";
|
||||
}
|
||||
|
||||
@Override
|
||||
public final boolean onCheckFailure(final CheckType checkType, final Player player, final IViolationInfo info) {
|
||||
//if (checkType == CheckType.MOVING_CREATIVEFLY && !ConfigFile.getInstance().isSneakToFall() )
|
||||
if (player.getGameMode() == GameMode.SPECTATOR) return false;
|
||||
if ((checkType == CheckType.MOVING_CREATIVEFLY || checkType == CheckType.MOVING_SURVIVALFLY) && GTPerm.USE.checkPermission((Permissible)player)) {
|
||||
final GravityTube tube = GravityTubesFile.getInstance().getTubes().stream().filter(gravityTube -> isInTube(gravityTube, player, true, true)).findFirst().orElse(null);
|
||||
if (tube != null) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
private boolean isInTube(GravityTube tube, Player p, boolean longerH, boolean extendxz) {
|
||||
final int tubePower = tube.getPower();
|
||||
int power = tubePower > 171 ? 4 : tubePower > 80 ? 3 : tubePower > 25 ? 2 : 1;
|
||||
final Location pLoc = p.getLocation();
|
||||
final Location tLoc = tube.getSourceLocation();
|
||||
final boolean b1 = p.getWorld().equals(tLoc.getWorld()) && pLoc.getY() >= tLoc.getBlockY() && pLoc.getY() <= tLoc.getBlockY() + tube.getHeight() + (longerH ? power : 0);
|
||||
if (!extendxz)
|
||||
return b1 && pLoc.getBlockX() == tLoc.getBlockX() && pLoc.getBlockZ() == tLoc.getBlockZ();
|
||||
return b1 && isTubeNearby(pLoc.getBlockX(), pLoc.getBlockZ(), tLoc.getBlockX(), tLoc.getBlockZ());
|
||||
}
|
||||
|
||||
private boolean isTubeNearby(int x1, int z1, int x2, int z2) {
|
||||
return TrigUtil.distance(x1,z1,x2,z2) < 1.5;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onMoveLowest(PlayerMoveEvent event) {
|
||||
final Player p = event.getPlayer();
|
||||
if (p.getGameMode() == GameMode.SPECTATOR) return;
|
||||
final double hDist = TrigUtil.xzDistance(event.getFrom(), event.getTo());
|
||||
final double vDist = event.getFrom().getY() - event.getTo().getY();
|
||||
if (GTPerm.USE.checkPermission((Permissible)p)
|
||||
&& vDist > 0 && hDist < 0.35
|
||||
&& ConfigFile.getInstance().isDisableFallDamage() && p.isSneaking()) {
|
||||
final GravityTube tube = GravityTubesFile.getInstance().getTubes().stream().filter(gravityTube -> isInTube(gravityTube, p, false, false)).findFirst().orElse(null);
|
||||
final IPlayerData pData = DataManager.getPlayerData(p);
|
||||
if (tube != null && pData != null) {
|
||||
final MovingData mData = pData.getGenericInstance(MovingData.class);
|
||||
mData.clearNoFallData();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
|
@ -0,0 +1,77 @@
|
|||
package me.asofold.bpl.cncp.hooks.GravityTubes;
|
||||
|
||||
import org.bukkit.event.EventHandler;
|
||||
import org.bukkit.event.EventPriority;
|
||||
import org.bukkit.event.Listener;
|
||||
import org.bukkit.event.player.PlayerMoveEvent;
|
||||
import fr.neatmonster.nocheatplus.hooks.NCPHook;
|
||||
import me.asofold.bpl.cncp.config.compatlayer.CompatConfig;
|
||||
import me.asofold.bpl.cncp.config.compatlayer.CompatConfigFactory;
|
||||
import me.asofold.bpl.cncp.config.compatlayer.ConfigUtil;
|
||||
import me.asofold.bpl.cncp.hooks.AbstractHook;
|
||||
import me.asofold.bpl.cncp.hooks.generic.ConfigurableHook;
|
||||
|
||||
public class HookGravityTubes extends AbstractHook implements Listener, ConfigurableHook {
|
||||
|
||||
public static interface HookFacade{
|
||||
public void onMoveLowest(PlayerMoveEvent event);
|
||||
}
|
||||
|
||||
protected HookFacade ncpHook = null;
|
||||
|
||||
protected boolean enabled = true;
|
||||
|
||||
protected String configPrefix = "gravitytubes.";
|
||||
|
||||
public HookGravityTubes(){
|
||||
assertPluginPresent("GravityTubes");
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getHookName() {
|
||||
return "GravityTubes(default)";
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getHookVersion() {
|
||||
return "1.0";
|
||||
}
|
||||
|
||||
@Override
|
||||
public Listener[] getListeners() {
|
||||
return new Listener[]{
|
||||
this
|
||||
};
|
||||
}
|
||||
|
||||
@Override
|
||||
public NCPHook getNCPHook() {
|
||||
if (ncpHook == null){
|
||||
ncpHook = new HookFacadeImpl();
|
||||
}
|
||||
return (NCPHook) ncpHook;
|
||||
}
|
||||
|
||||
@EventHandler(priority=EventPriority.LOWEST)
|
||||
//@RegisterMethodWithOrder(tag = CompatNoCheatPlus.tagEarlyFeature, beforeTag = CompatNoCheatPlus.beforeTagEarlyFeature)
|
||||
public final void onMoveLowest(final PlayerMoveEvent event){
|
||||
ncpHook.onMoveLowest(event);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void applyConfig(CompatConfig cfg, String prefix) {
|
||||
enabled = cfg.getBoolean(prefix + configPrefix + "enabled", true);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean updateConfig(CompatConfig cfg, String prefix) {
|
||||
CompatConfig defaults = CompatConfigFactory.getConfig(null);
|
||||
defaults.set(prefix + configPrefix + "enabled", true);
|
||||
return ConfigUtil.forceDefaults(defaults, cfg);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isEnabled() {
|
||||
return enabled;
|
||||
}
|
||||
}
|
Loading…
Reference in New Issue