feat: un peu quoi
This commit is contained in:
parent
6808c97096
commit
56be8b1656
|
@ -11,13 +11,18 @@ public class Camera extends JavaPlugin {
|
||||||
|
|
||||||
public static List<Location> locations;
|
public static List<Location> locations;
|
||||||
public static Logger logger;
|
public static Logger logger;
|
||||||
|
public static Camera plugin;
|
||||||
|
public static float t;
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onEnable() {
|
public void onEnable() {
|
||||||
|
plugin = this;
|
||||||
|
|
||||||
// setup commands
|
// setup commands
|
||||||
this.getCommand("point").setExecutor(new NewPoint());
|
this.getCommand("point").setExecutor(new NewPoint());
|
||||||
this.getCommand("points").setExecutor(new ListPoints());
|
this.getCommand("points").setExecutor(new ListPoints());
|
||||||
this.getCommand("goto").setExecutor(new GotoPoint());
|
this.getCommand("goto").setExecutor(new GotoPoint());
|
||||||
|
this.getCommand("test").setExecutor(new Test());
|
||||||
|
|
||||||
// init logger
|
// init logger
|
||||||
logger = getLogger();
|
logger = getLogger();
|
||||||
|
|
51
src/main/java/com/tocard/cam/Test.java
Normal file
51
src/main/java/com/tocard/cam/Test.java
Normal file
|
@ -0,0 +1,51 @@
|
||||||
|
package com.tocard.cam;
|
||||||
|
|
||||||
|
import java.util.logging.Level;
|
||||||
|
|
||||||
|
import org.bukkit.Location;
|
||||||
|
import org.bukkit.command.Command;
|
||||||
|
import org.bukkit.command.CommandExecutor;
|
||||||
|
import org.bukkit.command.CommandSender;
|
||||||
|
import org.bukkit.entity.Player;
|
||||||
|
import org.bukkit.Bukkit;
|
||||||
|
import java.util.ArrayList;
|
||||||
|
|
||||||
|
public class Test implements CommandExecutor {
|
||||||
|
|
||||||
|
// This method is called, when somebody uses our command
|
||||||
|
@Override
|
||||||
|
public boolean onCommand(CommandSender sender, Command command, String label, String[] args) {
|
||||||
|
if (sender instanceof Player) {
|
||||||
|
try {
|
||||||
|
Bukkit.getScheduler().cancelTask(Integer.parseInt(args[0]));
|
||||||
|
|
||||||
|
} catch (Exception e) {
|
||||||
|
Player player = (Player) sender;
|
||||||
|
|
||||||
|
Camera.t = 0;
|
||||||
|
|
||||||
|
int taskID = Bukkit.getScheduler().scheduleSyncDelayedTask(Camera.plugin, new Runnable() {
|
||||||
|
@Override
|
||||||
|
public void run() {
|
||||||
|
ArrayList<Location> P = new ArrayList<>(Camera.locations);
|
||||||
|
|
||||||
|
int N = P.size();
|
||||||
|
for (int k = N - 1; k > 0; k--) {
|
||||||
|
for (int i = 0; i < k; i++) {
|
||||||
|
P.set(i, P.get(i).multiply(1 - Camera.t).add(P.get(i + 1).multiply(Camera.t)));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
player.teleport(P.get(0));
|
||||||
|
|
||||||
|
Camera.t += 0.01;
|
||||||
|
Camera.t %= 1;
|
||||||
|
}
|
||||||
|
}, 0, 0);
|
||||||
|
Bukkit.broadcastMessage("" + taskID);
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
}
|
|
@ -17,3 +17,7 @@ commands:
|
||||||
description: Goto camera n°i
|
description: Goto camera n°i
|
||||||
usage: /goto i
|
usage: /goto i
|
||||||
permission: com.tocard.cam.listPoints
|
permission: com.tocard.cam.listPoints
|
||||||
|
test:
|
||||||
|
description: Test
|
||||||
|
usage: /test
|
||||||
|
permission: com.tocard.cam.listPoints
|
||||||
|
|
Loading…
Reference in a new issue