Initializing repository
parent
f96c703965
commit
c9ba2dea15
@ -0,0 +1,46 @@
|
||||
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
|
||||
<modelVersion>4.0.0</modelVersion>
|
||||
|
||||
<groupId>com.zivilon</groupId>
|
||||
<artifactId>FakePlayer</artifactId>
|
||||
<version>1.0</version>
|
||||
<packaging>jar</packaging>
|
||||
|
||||
<name>FakePlayer</name>
|
||||
|
||||
<properties>
|
||||
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
|
||||
<maven.compiler.source>1.7</maven.compiler.source>
|
||||
<maven.compiler.target>1.7</maven.compiler.target>
|
||||
</properties>
|
||||
|
||||
<dependencies>
|
||||
<dependency>
|
||||
<groupId>org.bukkit</groupId>
|
||||
<artifactId>bukkit</artifactId>
|
||||
<version>1.7.10-R0.1-SNAPSHOT</version>
|
||||
<scope>provided</scope>
|
||||
</dependency>
|
||||
</dependencies>
|
||||
|
||||
<build>
|
||||
<defaultGoal>package</defaultGoal>
|
||||
<resources>
|
||||
<resource>
|
||||
<directory>src/main/resources</directory>
|
||||
<filtering>true</filtering>
|
||||
</resource>
|
||||
</resources>
|
||||
<plugins>
|
||||
<plugin>
|
||||
<groupId>org.apache.maven.plugins</groupId>
|
||||
<artifactId>maven-compiler-plugin</artifactId>
|
||||
<version>3.8.0</version>
|
||||
<configuration>
|
||||
<source>1.7</source>
|
||||
<target>1.7</target>
|
||||
</configuration>
|
||||
</plugin>
|
||||
</plugins>
|
||||
</build>
|
||||
</project>
|
||||
File diff suppressed because it is too large
Load Diff
@ -0,0 +1,23 @@
|
||||
package com.zivilon.fakeplayer;
|
||||
|
||||
import org.bukkit.plugin.java.JavaPlugin;
|
||||
|
||||
import com.zivilon.fakeplayer.FakePlayer;
|
||||
import com.zivilon.fakeplayer.commands.run_command;
|
||||
import com.zivilon.fakeplayer.commands.area_command;
|
||||
|
||||
public class FakePlayerPlugin extends JavaPlugin {
|
||||
|
||||
@Override
|
||||
public void onEnable() {
|
||||
// Fired when the server enables the plugin
|
||||
getLogger().info("FakePlayer enabled!");
|
||||
this.getCommand("fakeplayer_run").setExecutor(new run_command());
|
||||
this.getCommand("area_command").setExecutor(new area_command());
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onDisable() {
|
||||
getLogger().info("FakePlayer disabled!");
|
||||
}
|
||||
}
|
||||
@ -0,0 +1,53 @@
|
||||
package com.zivilon.fakeplayer.commands;
|
||||
|
||||
import org.bukkit.command.Command;
|
||||
import org.bukkit.command.CommandExecutor;
|
||||
import org.bukkit.command.CommandSender;
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.Location;
|
||||
import org.bukkit.World;
|
||||
import org.bukkit.ChatColor;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
import java.util.Arrays;
|
||||
|
||||
import com.zivilon.fakeplayer.FakePlayerPlugin;
|
||||
import com.zivilon.fakeplayer.FakePlayer;
|
||||
|
||||
public class area_command implements CommandExecutor {
|
||||
|
||||
public boolean onCommand(CommandSender sender, Command command, String label, String[] args) {
|
||||
if (!sender.hasPermission("fakeplayer.area")) {
|
||||
sender.sendMessage(ChatColor.RED + "You do not have permission to use this command.");
|
||||
return true;
|
||||
}
|
||||
World world = Bukkit.getWorld("DIM100");
|
||||
int x;
|
||||
int y;
|
||||
int z;
|
||||
|
||||
if (args.length < 4) {
|
||||
sender.sendMessage(ChatColor.RED + "Usage: /area_command <x> <y> <z> <command>");
|
||||
return true;
|
||||
}
|
||||
try {
|
||||
x = Integer.parseInt(args[0]);
|
||||
y = Integer.parseInt(args[1]);
|
||||
z = Integer.parseInt(args[2]);
|
||||
} catch (NumberFormatException e) {
|
||||
sender.sendMessage(ChatColor.RED + "Coordinates need to be numbers!");
|
||||
return true;
|
||||
}
|
||||
|
||||
Location location = new Location(world, x, y, z);
|
||||
Player fakePlayer = new FakePlayer(location);
|
||||
|
||||
if(args.length > 2){
|
||||
String cmdToExecute = String.join(" ", Arrays.copyOfRange(args, 3, args.length));
|
||||
fakePlayer.performCommand(cmdToExecute);
|
||||
} else {
|
||||
sender.sendMessage(ChatColor.RED + "No command specified.");
|
||||
}
|
||||
return true;
|
||||
}
|
||||
}
|
||||
@ -0,0 +1,42 @@
|
||||
package com.zivilon.fakeplayer.commands;
|
||||
|
||||
import org.bukkit.command.Command;
|
||||
import org.bukkit.command.CommandExecutor;
|
||||
import org.bukkit.command.CommandSender;
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.Location;
|
||||
import org.bukkit.World;
|
||||
import org.bukkit.ChatColor;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
|
||||
import com.zivilon.fakeplayer.FakePlayerPlugin;
|
||||
import com.zivilon.fakeplayer.FakePlayer;
|
||||
|
||||
public class run_command implements CommandExecutor {
|
||||
|
||||
public boolean onCommand(CommandSender sender, Command command, String label, String[] args) {
|
||||
Location location;
|
||||
if (!sender.hasPermission("fakeplayer.use")) {
|
||||
sender.sendMessage(ChatColor.RED + "You do not have permission to use this command.");
|
||||
return true;
|
||||
}
|
||||
World world = Bukkit.getWorld("DIM100");
|
||||
if(sender instanceof Player) {
|
||||
Player player = (Player) sender;
|
||||
location = player.getLocation();
|
||||
} else {
|
||||
location = new Location(world, 0, 64, 0);
|
||||
|
||||
}
|
||||
Player fakePlayer = new FakePlayer(location);
|
||||
|
||||
if(args.length > 0){
|
||||
String cmdToExecute = String.join(" ", args);
|
||||
fakePlayer.performCommand(cmdToExecute);
|
||||
} else {
|
||||
sender.sendMessage(ChatColor.RED + "No command specified.");
|
||||
}
|
||||
return true;
|
||||
}
|
||||
}
|
||||
@ -0,0 +1,15 @@
|
||||
main: com.zivilon.fakeplayer.FakePlayerPlugin
|
||||
name: FakePlayer
|
||||
author: Shinare
|
||||
version: 1.0
|
||||
commands:
|
||||
fakeplayer_run:
|
||||
description: Run commands as fake player
|
||||
Usage: /fakeplayer_run
|
||||
# This command is probably not even necessary, might be deleted later
|
||||
fakeplayer_create:
|
||||
description: Create a fake player.
|
||||
Usage: /fakeplayer_create
|
||||
area_command:
|
||||
description: Run a command through fake player in specific coordinates
|
||||
Usage: /area_command
|
||||
Loading…
Reference in New Issue