Configurable coefficients and reload command
This commit is contained in:
parent
3bad24ab89
commit
452e8ceb23
5 changed files with 56 additions and 3 deletions
|
|
@ -1,15 +1,32 @@
|
|||
package xyz.hynse.foliaflow;
|
||||
|
||||
import org.bukkit.plugin.java.JavaPlugin;
|
||||
|
||||
import xyz.hynse.foliaflow.command.ReloadCommand;
|
||||
import xyz.hynse.foliaflow.watcher.PortalWatcher;
|
||||
|
||||
public class FoliaFlow extends JavaPlugin {
|
||||
|
||||
public static FoliaFlow instance;
|
||||
public static double horizontalCoefficient;
|
||||
public static double verticalCoefficient;
|
||||
|
||||
@Override
|
||||
public void onEnable() {
|
||||
instance = this;
|
||||
register();
|
||||
reload();
|
||||
}
|
||||
|
||||
public void reload() {
|
||||
saveDefaultConfig();
|
||||
reloadConfig();
|
||||
horizontalCoefficient = getConfig().getDouble("horizontal_coefficient");
|
||||
verticalCoefficient = getConfig().getDouble("vertical_coefficient");
|
||||
}
|
||||
|
||||
private void register() {
|
||||
getCommand("flowreload").setExecutor(new ReloadCommand());
|
||||
getServer().getPluginManager().registerEvents(new PortalWatcher(), this);
|
||||
}
|
||||
}
|
||||
|
|
|
|||
23
src/main/java/xyz/hynse/foliaflow/command/ReloadCommand.java
Normal file
23
src/main/java/xyz/hynse/foliaflow/command/ReloadCommand.java
Normal file
|
|
@ -0,0 +1,23 @@
|
|||
package xyz.hynse.foliaflow.command;
|
||||
|
||||
import org.bukkit.ChatColor;
|
||||
import org.bukkit.command.Command;
|
||||
import org.bukkit.command.CommandExecutor;
|
||||
import org.bukkit.command.CommandSender;
|
||||
|
||||
import xyz.hynse.foliaflow.FoliaFlow;
|
||||
|
||||
public class ReloadCommand implements CommandExecutor {
|
||||
@Override
|
||||
public boolean onCommand(CommandSender sender, Command command, String label, String[] args) {
|
||||
if (!sender.hasPermission("foliaflow.reload")) return true;
|
||||
try {
|
||||
FoliaFlow.instance.reload();
|
||||
sender.sendMessage(ChatColor.YELLOW + "FoliaFlow reloaded.");
|
||||
} catch (Exception e) {
|
||||
sender.sendMessage(ChatColor.RED + "Something went wrong reloading FoliaFlow, see the console for more.");
|
||||
e.printStackTrace();
|
||||
}
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
|
@ -17,6 +17,7 @@ import xyz.hynse.foliaflow.util.SchedulerUtil;
|
|||
import static xyz.hynse.foliaflow.util.VelocityUtil.getBlockMovingTo;
|
||||
|
||||
public class PortalWatcher implements Listener {
|
||||
|
||||
@EventHandler
|
||||
public void onFallingBlockToBlock(EntityChangeBlockEvent e){
|
||||
if(e.getEntityType() != EntityType.FALLING_BLOCK) return;
|
||||
|
|
@ -31,8 +32,8 @@ public class PortalWatcher implements Listener {
|
|||
|
||||
FallingBlock dummy = loc.getWorld().spawnFallingBlock(spawnLoc, ((FallingBlock) entity).getBlockData());
|
||||
Vector dummyVel = vel.clone();
|
||||
dummyVel.setY(-dummyVel.getY());
|
||||
dummyVel.multiply(1.3); // This seems vanilla.
|
||||
dummyVel.multiply(FoliaFlow.horizontalCoefficient);
|
||||
dummyVel.setY(vel.getY() * FoliaFlow.verticalCoefficient);
|
||||
dummy.setVelocity(dummyVel);
|
||||
|
||||
// Add vector seems vanilla.
|
||||
|
|
|
|||
7
src/main/resources/config.yml
Normal file
7
src/main/resources/config.yml
Normal file
|
|
@ -0,0 +1,7 @@
|
|||
# Don't touch this file unless you know what you're doing
|
||||
# Default values seems vanilla.
|
||||
# If you find values that seems more vanilla please create a PR
|
||||
# https://github.com/Hynse/FoliaFlow
|
||||
|
||||
vertical_coefficient: -1.7
|
||||
horizontal_coefficient: 1.46
|
||||
|
|
@ -3,3 +3,8 @@ version: '${version}'
|
|||
main: xyz.hynse.foliaflow.FoliaFlow
|
||||
api-version: 1.19
|
||||
folia-supported: true
|
||||
commands:
|
||||
flowreload:
|
||||
description: Reload FoliaFlow
|
||||
usage: /<command>
|
||||
permission: foliaflow.reload
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue