Moved features to separate projects
This commit is contained in:
commit
8383a77730
18
AntiVoid/.classpath
Normal file
18
AntiVoid/.classpath
Normal file
@ -0,0 +1,18 @@
|
|||||||
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
|
<classpath>
|
||||||
|
<classpathentry kind="src" path="src" including="**/*.java"/>
|
||||||
|
<classpathentry kind="output" path="target/classes"/>
|
||||||
|
<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER"/>
|
||||||
|
<classpathentry kind="src" path="/MarwCore"/>
|
||||||
|
<classpathentry kind="lib" path="/home/erik/Dokumenty/Java/marwland/res/MassiveCore.jar"/>
|
||||||
|
<classpathentry kind="lib" path="/home/erik/Dokumenty/Java/marwland/res/Factions.jar"/>
|
||||||
|
<classpathentry kind="var" path="M2_REPO/org/spigotmc/spigot-api/1.12-R0.1-SNAPSHOT/spigot-api-1.12-R0.1-SNAPSHOT.jar" sourcepath="M2_REPO/org/spigotmc/spigot-api/1.12-R0.1-SNAPSHOT/spigot-api-1.12-R0.1-SNAPSHOT-sources.jar"/>
|
||||||
|
<classpathentry kind="var" path="M2_REPO/commons-lang/commons-lang/2.6/commons-lang-2.6.jar" sourcepath="M2_REPO/commons-lang/commons-lang/2.6/commons-lang-2.6-sources.jar"/>
|
||||||
|
<classpathentry kind="var" path="M2_REPO/com/googlecode/json-simple/json-simple/1.1.1/json-simple-1.1.1.jar" sourcepath="M2_REPO/com/googlecode/json-simple/json-simple/1.1.1/json-simple-1.1.1-sources.jar"/>
|
||||||
|
<classpathentry kind="var" path="M2_REPO/junit/junit/4.10/junit-4.10.jar" sourcepath="M2_REPO/junit/junit/4.10/junit-4.10-sources.jar"/>
|
||||||
|
<classpathentry kind="var" path="M2_REPO/org/hamcrest/hamcrest-core/1.1/hamcrest-core-1.1.jar" sourcepath="M2_REPO/org/hamcrest/hamcrest-core/1.1/hamcrest-core-1.1-sources.jar"/>
|
||||||
|
<classpathentry kind="var" path="M2_REPO/com/google/guava/guava/21.0/guava-21.0.jar" sourcepath="M2_REPO/com/google/guava/guava/21.0/guava-21.0-sources.jar"/>
|
||||||
|
<classpathentry kind="var" path="M2_REPO/com/google/code/gson/gson/2.8.0/gson-2.8.0.jar" sourcepath="M2_REPO/com/google/code/gson/gson/2.8.0/gson-2.8.0-sources.jar"/>
|
||||||
|
<classpathentry kind="var" path="M2_REPO/org/yaml/snakeyaml/1.18/snakeyaml-1.18.jar" sourcepath="M2_REPO/org/yaml/snakeyaml/1.18/snakeyaml-1.18-sources.jar"/>
|
||||||
|
<classpathentry kind="var" path="M2_REPO/net/md-5/bungeecord-chat/1.12-SNAPSHOT/bungeecord-chat-1.12-SNAPSHOT.jar" sourcepath="M2_REPO/net/md-5/bungeecord-chat/1.12-SNAPSHOT/bungeecord-chat-1.12-SNAPSHOT-sources.jar"/>
|
||||||
|
</classpath>
|
2
AntiVoid/.gitignore
vendored
Normal file
2
AntiVoid/.gitignore
vendored
Normal file
@ -0,0 +1,2 @@
|
|||||||
|
/bin/
|
||||||
|
/target/
|
20
AntiVoid/.project
Normal file
20
AntiVoid/.project
Normal file
@ -0,0 +1,20 @@
|
|||||||
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
|
<projectDescription>
|
||||||
|
<name>AntiVoid</name>
|
||||||
|
<comment>NO_M2ECLIPSE_SUPPORT: Project files created with the maven-eclipse-plugin are not supported in M2Eclipse.</comment>
|
||||||
|
<projects>
|
||||||
|
<project>MarwCore</project>
|
||||||
|
</projects>
|
||||||
|
<buildSpec>
|
||||||
|
<buildCommand>
|
||||||
|
<name>org.eclipse.jdt.core.javabuilder</name>
|
||||||
|
</buildCommand>
|
||||||
|
<buildCommand>
|
||||||
|
<name>org.eclipse.m2e.core.maven2Builder</name>
|
||||||
|
</buildCommand>
|
||||||
|
</buildSpec>
|
||||||
|
<natures>
|
||||||
|
<nature>org.eclipse.m2e.core.maven2Nature</nature>
|
||||||
|
<nature>org.eclipse.jdt.core.javanature</nature>
|
||||||
|
</natures>
|
||||||
|
</projectDescription>
|
13
AntiVoid/.settings/org.eclipse.jdt.core.prefs
Normal file
13
AntiVoid/.settings/org.eclipse.jdt.core.prefs
Normal file
@ -0,0 +1,13 @@
|
|||||||
|
eclipse.preferences.version=1
|
||||||
|
org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled
|
||||||
|
org.eclipse.jdt.core.compiler.codegen.targetPlatform=10
|
||||||
|
org.eclipse.jdt.core.compiler.codegen.unusedLocal=preserve
|
||||||
|
org.eclipse.jdt.core.compiler.compliance=10
|
||||||
|
org.eclipse.jdt.core.compiler.debug.lineNumber=generate
|
||||||
|
org.eclipse.jdt.core.compiler.debug.localVariable=generate
|
||||||
|
org.eclipse.jdt.core.compiler.debug.sourceFile=generate
|
||||||
|
org.eclipse.jdt.core.compiler.problem.assertIdentifier=error
|
||||||
|
org.eclipse.jdt.core.compiler.problem.enumIdentifier=error
|
||||||
|
org.eclipse.jdt.core.compiler.problem.forbiddenReference=warning
|
||||||
|
org.eclipse.jdt.core.compiler.release=enabled
|
||||||
|
org.eclipse.jdt.core.compiler.source=10
|
4
AntiVoid/.settings/org.eclipse.m2e.core.prefs
Normal file
4
AntiVoid/.settings/org.eclipse.m2e.core.prefs
Normal file
@ -0,0 +1,4 @@
|
|||||||
|
activeProfiles=
|
||||||
|
eclipse.preferences.version=1
|
||||||
|
resolveWorkspaceProjects=true
|
||||||
|
version=1
|
30
AntiVoid/pom.xml
Normal file
30
AntiVoid/pom.xml
Normal file
@ -0,0 +1,30 @@
|
|||||||
|
<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>cz.marwland.mc.features</groupId>
|
||||||
|
<artifactId>AntiVoid</artifactId>
|
||||||
|
<parent>
|
||||||
|
<groupId>cz.marwland.mc</groupId>
|
||||||
|
<artifactId>MarwStuff</artifactId>
|
||||||
|
<version>0.0.1-SNAPSHOT</version>
|
||||||
|
<relativePath>MarwStuff</relativePath>
|
||||||
|
</parent>
|
||||||
|
<build>
|
||||||
|
<sourceDirectory>src</sourceDirectory>
|
||||||
|
<plugins>
|
||||||
|
<plugin>
|
||||||
|
<artifactId>maven-compiler-plugin</artifactId>
|
||||||
|
<version>3.7.0</version>
|
||||||
|
<configuration>
|
||||||
|
<release>10</release>
|
||||||
|
</configuration>
|
||||||
|
</plugin>
|
||||||
|
</plugins>
|
||||||
|
</build>
|
||||||
|
<dependencies>
|
||||||
|
<dependency>
|
||||||
|
<groupId>cz.marwland.mc</groupId>
|
||||||
|
<artifactId>MarwCore</artifactId>
|
||||||
|
<version>${project.parent.version}</version>
|
||||||
|
</dependency>
|
||||||
|
</dependencies>
|
||||||
|
</project>
|
56
AntiVoid/src/cz/marwland/mc/features/AntiVoid.java
Normal file
56
AntiVoid/src/cz/marwland/mc/features/AntiVoid.java
Normal file
@ -0,0 +1,56 @@
|
|||||||
|
package cz.marwland.mc.features;
|
||||||
|
|
||||||
|
import java.util.ArrayList;
|
||||||
|
|
||||||
|
import org.bukkit.Bukkit;
|
||||||
|
import org.bukkit.World;
|
||||||
|
import org.bukkit.configuration.file.FileConfiguration;
|
||||||
|
import org.bukkit.entity.Player;
|
||||||
|
import org.bukkit.event.EventHandler;
|
||||||
|
import org.bukkit.event.player.PlayerMoveEvent;
|
||||||
|
|
||||||
|
import cz.marwland.mc.core.features.Feature;
|
||||||
|
import cz.marwland.mc.core.util.Cooldown;
|
||||||
|
|
||||||
|
public class AntiVoid extends Feature {
|
||||||
|
|
||||||
|
private FileConfiguration cfg;
|
||||||
|
private ArrayList<World> allowedWorlds = new ArrayList<>();
|
||||||
|
private double triggery = 0d;
|
||||||
|
|
||||||
|
public AntiVoid() {
|
||||||
|
super();
|
||||||
|
this.registerConfig("antivoid.yml");
|
||||||
|
Cooldown xd = new Cooldown(this);
|
||||||
|
}
|
||||||
|
|
||||||
|
@EventHandler
|
||||||
|
public void onPlayerMove(PlayerMoveEvent e) {
|
||||||
|
Player p = e.getPlayer();
|
||||||
|
if (p.getLocation().getY() > triggery)
|
||||||
|
return;
|
||||||
|
|
||||||
|
World w = p.getWorld();
|
||||||
|
if (!allowedWorlds.contains(w))
|
||||||
|
return;
|
||||||
|
|
||||||
|
p.teleport(w.getSpawnLocation());
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void onEnable() {
|
||||||
|
super.onEnable();
|
||||||
|
cfg = getConfig("antivoid.yml");
|
||||||
|
|
||||||
|
triggery = cfg.getDouble("triggery", 0d);
|
||||||
|
allowedWorlds = new ArrayList<>();
|
||||||
|
for (String wname : cfg.getStringList("worlds")) {
|
||||||
|
World w = Bukkit.getWorld(wname);
|
||||||
|
|
||||||
|
if (w == null)
|
||||||
|
continue;
|
||||||
|
allowedWorlds.add(w);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
18
Borders/.classpath
Normal file
18
Borders/.classpath
Normal file
@ -0,0 +1,18 @@
|
|||||||
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
|
<classpath>
|
||||||
|
<classpathentry kind="src" path="src" including="**/*.java"/>
|
||||||
|
<classpathentry kind="output" path="target/classes"/>
|
||||||
|
<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER"/>
|
||||||
|
<classpathentry kind="src" path="/MarwCore"/>
|
||||||
|
<classpathentry kind="lib" path="/home/erik/Dokumenty/Java/marwland/res/MassiveCore.jar"/>
|
||||||
|
<classpathentry kind="lib" path="/home/erik/Dokumenty/Java/marwland/res/Factions.jar"/>
|
||||||
|
<classpathentry kind="var" path="M2_REPO/org/spigotmc/spigot-api/1.12-R0.1-SNAPSHOT/spigot-api-1.12-R0.1-SNAPSHOT.jar" sourcepath="M2_REPO/org/spigotmc/spigot-api/1.12-R0.1-SNAPSHOT/spigot-api-1.12-R0.1-SNAPSHOT-sources.jar"/>
|
||||||
|
<classpathentry kind="var" path="M2_REPO/commons-lang/commons-lang/2.6/commons-lang-2.6.jar" sourcepath="M2_REPO/commons-lang/commons-lang/2.6/commons-lang-2.6-sources.jar"/>
|
||||||
|
<classpathentry kind="var" path="M2_REPO/com/googlecode/json-simple/json-simple/1.1.1/json-simple-1.1.1.jar" sourcepath="M2_REPO/com/googlecode/json-simple/json-simple/1.1.1/json-simple-1.1.1-sources.jar"/>
|
||||||
|
<classpathentry kind="var" path="M2_REPO/junit/junit/4.10/junit-4.10.jar" sourcepath="M2_REPO/junit/junit/4.10/junit-4.10-sources.jar"/>
|
||||||
|
<classpathentry kind="var" path="M2_REPO/org/hamcrest/hamcrest-core/1.1/hamcrest-core-1.1.jar" sourcepath="M2_REPO/org/hamcrest/hamcrest-core/1.1/hamcrest-core-1.1-sources.jar"/>
|
||||||
|
<classpathentry kind="var" path="M2_REPO/com/google/guava/guava/21.0/guava-21.0.jar" sourcepath="M2_REPO/com/google/guava/guava/21.0/guava-21.0-sources.jar"/>
|
||||||
|
<classpathentry kind="var" path="M2_REPO/com/google/code/gson/gson/2.8.0/gson-2.8.0.jar" sourcepath="M2_REPO/com/google/code/gson/gson/2.8.0/gson-2.8.0-sources.jar"/>
|
||||||
|
<classpathentry kind="var" path="M2_REPO/org/yaml/snakeyaml/1.18/snakeyaml-1.18.jar" sourcepath="M2_REPO/org/yaml/snakeyaml/1.18/snakeyaml-1.18-sources.jar"/>
|
||||||
|
<classpathentry kind="var" path="M2_REPO/net/md-5/bungeecord-chat/1.12-SNAPSHOT/bungeecord-chat-1.12-SNAPSHOT.jar" sourcepath="M2_REPO/net/md-5/bungeecord-chat/1.12-SNAPSHOT/bungeecord-chat-1.12-SNAPSHOT-sources.jar"/>
|
||||||
|
</classpath>
|
2
Borders/.gitignore
vendored
Normal file
2
Borders/.gitignore
vendored
Normal file
@ -0,0 +1,2 @@
|
|||||||
|
/bin/
|
||||||
|
/target/
|
20
Borders/.project
Normal file
20
Borders/.project
Normal file
@ -0,0 +1,20 @@
|
|||||||
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
|
<projectDescription>
|
||||||
|
<name>Borders</name>
|
||||||
|
<comment>NO_M2ECLIPSE_SUPPORT: Project files created with the maven-eclipse-plugin are not supported in M2Eclipse.</comment>
|
||||||
|
<projects>
|
||||||
|
<project>MarwCore</project>
|
||||||
|
</projects>
|
||||||
|
<buildSpec>
|
||||||
|
<buildCommand>
|
||||||
|
<name>org.eclipse.jdt.core.javabuilder</name>
|
||||||
|
</buildCommand>
|
||||||
|
<buildCommand>
|
||||||
|
<name>org.eclipse.m2e.core.maven2Builder</name>
|
||||||
|
</buildCommand>
|
||||||
|
</buildSpec>
|
||||||
|
<natures>
|
||||||
|
<nature>org.eclipse.m2e.core.maven2Nature</nature>
|
||||||
|
<nature>org.eclipse.jdt.core.javanature</nature>
|
||||||
|
</natures>
|
||||||
|
</projectDescription>
|
13
Borders/.settings/org.eclipse.jdt.core.prefs
Normal file
13
Borders/.settings/org.eclipse.jdt.core.prefs
Normal file
@ -0,0 +1,13 @@
|
|||||||
|
eclipse.preferences.version=1
|
||||||
|
org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled
|
||||||
|
org.eclipse.jdt.core.compiler.codegen.targetPlatform=10
|
||||||
|
org.eclipse.jdt.core.compiler.codegen.unusedLocal=preserve
|
||||||
|
org.eclipse.jdt.core.compiler.compliance=10
|
||||||
|
org.eclipse.jdt.core.compiler.debug.lineNumber=generate
|
||||||
|
org.eclipse.jdt.core.compiler.debug.localVariable=generate
|
||||||
|
org.eclipse.jdt.core.compiler.debug.sourceFile=generate
|
||||||
|
org.eclipse.jdt.core.compiler.problem.assertIdentifier=error
|
||||||
|
org.eclipse.jdt.core.compiler.problem.enumIdentifier=error
|
||||||
|
org.eclipse.jdt.core.compiler.problem.forbiddenReference=warning
|
||||||
|
org.eclipse.jdt.core.compiler.release=enabled
|
||||||
|
org.eclipse.jdt.core.compiler.source=10
|
4
Borders/.settings/org.eclipse.m2e.core.prefs
Normal file
4
Borders/.settings/org.eclipse.m2e.core.prefs
Normal file
@ -0,0 +1,4 @@
|
|||||||
|
activeProfiles=
|
||||||
|
eclipse.preferences.version=1
|
||||||
|
resolveWorkspaceProjects=true
|
||||||
|
version=1
|
30
Borders/pom.xml
Normal file
30
Borders/pom.xml
Normal file
@ -0,0 +1,30 @@
|
|||||||
|
<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>cz.marwland.mc.features</groupId>
|
||||||
|
<artifactId>Borders</artifactId>
|
||||||
|
<parent>
|
||||||
|
<groupId>cz.marwland.mc</groupId>
|
||||||
|
<artifactId>MarwStuff</artifactId>
|
||||||
|
<version>0.0.1-SNAPSHOT</version>
|
||||||
|
<relativePath>../../MarwStuff</relativePath>
|
||||||
|
</parent>
|
||||||
|
<build>
|
||||||
|
<sourceDirectory>src</sourceDirectory>
|
||||||
|
<plugins>
|
||||||
|
<plugin>
|
||||||
|
<artifactId>maven-compiler-plugin</artifactId>
|
||||||
|
<version>3.7.0</version>
|
||||||
|
<configuration>
|
||||||
|
<release>10</release>
|
||||||
|
</configuration>
|
||||||
|
</plugin>
|
||||||
|
</plugins>
|
||||||
|
</build>
|
||||||
|
<dependencies>
|
||||||
|
<dependency>
|
||||||
|
<groupId>cz.marwland.mc</groupId>
|
||||||
|
<artifactId>MarwCore</artifactId>
|
||||||
|
<version>${project.parent.version}</version>
|
||||||
|
</dependency>
|
||||||
|
</dependencies>
|
||||||
|
</project>
|
230
Borders/src/cz/marwland/mc/features/Borders.java
Normal file
230
Borders/src/cz/marwland/mc/features/Borders.java
Normal file
@ -0,0 +1,230 @@
|
|||||||
|
package cz.marwland.mc.features;
|
||||||
|
|
||||||
|
import java.util.ArrayList;
|
||||||
|
import java.util.Arrays;
|
||||||
|
import java.util.Collections;
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
import org.bukkit.Bukkit;
|
||||||
|
import org.bukkit.World;
|
||||||
|
import org.bukkit.command.CommandSender;
|
||||||
|
import org.bukkit.command.defaults.BukkitCommand;
|
||||||
|
import org.bukkit.configuration.file.FileConfiguration;
|
||||||
|
import org.bukkit.util.StringUtil;
|
||||||
|
import org.bukkit.util.Vector;
|
||||||
|
|
||||||
|
import cz.marwland.mc.core.config.ConfigEntry;
|
||||||
|
import cz.marwland.mc.core.config.EntryManager;
|
||||||
|
import cz.marwland.mc.core.config.IValueExecuter;
|
||||||
|
import cz.marwland.mc.core.config.ValueValidator;
|
||||||
|
import cz.marwland.mc.core.features.Feature;
|
||||||
|
import net.md_5.bungee.api.ChatColor;
|
||||||
|
|
||||||
|
public class Borders extends Feature {
|
||||||
|
|
||||||
|
FileConfiguration cfg;
|
||||||
|
EntryManager emgr = new EntryManager();
|
||||||
|
|
||||||
|
public Borders() {
|
||||||
|
super();
|
||||||
|
// String name, String description, String usageMessage, List<String> aliases)
|
||||||
|
this.addCommand(new BukkitCommand(
|
||||||
|
"worldborder",
|
||||||
|
"Modify the world's borders",
|
||||||
|
"/border [world] (key) (value)",
|
||||||
|
Arrays.asList() ) {
|
||||||
|
@Override
|
||||||
|
public boolean execute(CommandSender sender, String commandLabel, String[] args) {
|
||||||
|
if (!permissionMissingCheck(sender, this.getPermission()))
|
||||||
|
return false;
|
||||||
|
|
||||||
|
if (args.length < 2) {
|
||||||
|
sender.sendMessage(
|
||||||
|
ChatColor.YELLOW + "Format: " +
|
||||||
|
ChatColor.GRAY + ChatColor.ITALIC + "/" + commandLabel +
|
||||||
|
ChatColor.YELLOW + ChatColor.GRAY + " (world) (key) [value]");
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
World w = Bukkit.getServer().getWorld(args[0]);
|
||||||
|
if (w == null) {
|
||||||
|
sender.sendMessage(ChatColor.RED + "Invalid world!");
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
ConfigEntry<?> entry = emgr.getEntry(args[1]);
|
||||||
|
if (entry == null) {
|
||||||
|
sender.sendMessage(
|
||||||
|
ChatColor.RED + "Invalid key " +
|
||||||
|
ChatColor.YELLOW + args[1] +
|
||||||
|
ChatColor.RED + "! Available: " +
|
||||||
|
ChatColor.GRAY + String.join(", ", emgr.getKeys()));
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (args.length == 2) { // get
|
||||||
|
if (!cfg.contains(w.getName())) {
|
||||||
|
sender.sendMessage(
|
||||||
|
ChatColor.RED + "No border specified for " +
|
||||||
|
ChatColor.YELLOW + args[0] +
|
||||||
|
ChatColor.RED + "!");
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
Object val = entry.getFrom(cfg, w.getName());
|
||||||
|
|
||||||
|
sender.sendMessage(
|
||||||
|
ChatColor.YELLOW + args[1] +
|
||||||
|
ChatColor.GRAY + " @ " +
|
||||||
|
ChatColor.AQUA + w.getName() +
|
||||||
|
ChatColor.GRAY + ": " + (val == null ? ChatColor.ITALIC + "[" + entry.getDefaultValue() + "]": val));
|
||||||
|
} else { // set
|
||||||
|
String oldval = "" + entry.getFrom(cfg, w.getName());
|
||||||
|
String newval = String.join(" ", args).substring(args[0].length() + args[1].length() + 2);
|
||||||
|
if (entry.setIn(cfg, w.getName(), newval)) {
|
||||||
|
plugin.getConfigManager().save();
|
||||||
|
cfg = getConfig("borders.yml");
|
||||||
|
loadWorlds();
|
||||||
|
sender.sendMessage(
|
||||||
|
ChatColor.GREEN + "Changed " +
|
||||||
|
ChatColor.YELLOW + entry.getSubpath() +
|
||||||
|
ChatColor.GRAY + " @ " +
|
||||||
|
ChatColor.AQUA + w.getName() +
|
||||||
|
ChatColor.GRAY + ": " + oldval +
|
||||||
|
ChatColor.GOLD + " => " +
|
||||||
|
ChatColor.GRAY + newval);
|
||||||
|
} else {
|
||||||
|
sender.sendMessage(
|
||||||
|
ChatColor.RED + "Invalid value for " +
|
||||||
|
ChatColor.YELLOW + args[1] +
|
||||||
|
ChatColor.RED + ": " +
|
||||||
|
ChatColor.GRAY + newval);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public List<String> tabComplete(CommandSender sender, String alias, String[] args) throws IllegalArgumentException {
|
||||||
|
ArrayList<String> hints = new ArrayList<String>();
|
||||||
|
if (!sender.hasPermission(this.getPermission()) || args.length < 1)
|
||||||
|
return hints;
|
||||||
|
|
||||||
|
String lastWord = args[args.length - 1];
|
||||||
|
if (args.length == 1) {
|
||||||
|
for (World w : Bukkit.getServer().getWorlds()) {
|
||||||
|
if (StringUtil.startsWithIgnoreCase(w.getName(), lastWord))
|
||||||
|
hints.add(w.getName());
|
||||||
|
}
|
||||||
|
} else if(args.length == 2) {
|
||||||
|
for (String key : emgr.getKeys()) {
|
||||||
|
if (StringUtil.startsWithIgnoreCase(key, lastWord))
|
||||||
|
hints.add(key);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
Collections.sort(hints, String.CASE_INSENSITIVE_ORDER);
|
||||||
|
return hints;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String getPermission() {
|
||||||
|
return getPermissionPath() + "." + this.getName().toLowerCase();
|
||||||
|
}
|
||||||
|
});
|
||||||
|
emgr.addEntry(new ConfigEntry<>("center", ValueValidator.VECTOR, new Vector(0, 0, 0)));
|
||||||
|
// emgr.addEntry(new ConfigEntry<>("size", ValueValidator.DOUBLE));
|
||||||
|
emgr.addEntry(new ConfigEntry<>("radius", ValueValidator.INTEGER, 60000000));
|
||||||
|
emgr.addEntry(new ConfigEntry<>("warningdist", ValueValidator.INTEGER, 5));
|
||||||
|
emgr.addEntry(new ConfigEntry<>("warningtime", ValueValidator.INTEGER, 15));
|
||||||
|
emgr.addEntry(new ConfigEntry<>("damage", ValueValidator.DOUBLE, 0.2d));
|
||||||
|
emgr.addEntry(new ConfigEntry<>("buffer", ValueValidator.DOUBLE, 5d));
|
||||||
|
this.registerConfig("borders.yml");
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void onEnable() {
|
||||||
|
super.onEnable();
|
||||||
|
cfg = getConfig("borders.yml");
|
||||||
|
this.loadWorlds();
|
||||||
|
}
|
||||||
|
|
||||||
|
public void loadWorlds() {
|
||||||
|
for(World w : Bukkit.getServer().getWorlds()) {
|
||||||
|
final String wname = w.getName();
|
||||||
|
if (!cfg.contains(wname)) {
|
||||||
|
w.getWorldBorder().reset();
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
emgr.getEntry("center").doStuff(cfg, wname, new IValueExecuter<Object>() {
|
||||||
|
public void doStuff(Object val) {
|
||||||
|
Vector v = (Vector) val;
|
||||||
|
w.getWorldBorder().setCenter(v.getX(), v.getZ());
|
||||||
|
}
|
||||||
|
});
|
||||||
|
emgr.getEntry("radius").doStuff(cfg, wname, new IValueExecuter<Object>() {
|
||||||
|
public void doStuff(Object val) {
|
||||||
|
w.getWorldBorder().setSize((int) val);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
emgr.getEntry("warningdist").doStuff(cfg, wname, new IValueExecuter<Object>() {
|
||||||
|
public void doStuff(Object val) {
|
||||||
|
w.getWorldBorder().setWarningDistance((int) val);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
emgr.getEntry("warningtime").doStuff(cfg, wname, new IValueExecuter<Object>() {
|
||||||
|
public void doStuff(Object val) {
|
||||||
|
w.getWorldBorder().setWarningTime((int) val);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
emgr.getEntry("damage").doStuff(cfg, wname, new IValueExecuter<Object>() {
|
||||||
|
public void doStuff(Object val) {
|
||||||
|
w.getWorldBorder().setDamageAmount((double) val);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
emgr.getEntry("buffer").doStuff(cfg, wname, new IValueExecuter<Object>() {
|
||||||
|
public void doStuff(Object val) {
|
||||||
|
w.getWorldBorder().setDamageBuffer((double) val);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
/*
|
||||||
|
Region r = new Region();
|
||||||
|
if (cfg.contains(wname + ".center") && cfg.contains(wname + ".size")) {
|
||||||
|
plugin.getLogger().info("should i?");
|
||||||
|
String centerstr = cfg.getString(wname + ".center");
|
||||||
|
Vector center = LocationUtil.deserializeVector(centerstr);
|
||||||
|
String sizestr = cfg.getString(wname + ".size");
|
||||||
|
if (sizestr.indexOf(' ') == -1) {
|
||||||
|
w.getWorldBorder().setCenter(center.getX(), center.getZ());
|
||||||
|
w.getWorldBorder().setSize(cfg.getDouble(wname + ".size", 0));
|
||||||
|
plugin.getLogger().info("set the ghetto way");
|
||||||
|
} else {
|
||||||
|
Vector size = LocationUtil.deserializeVector(sizestr);
|
||||||
|
if (center == null) {
|
||||||
|
plugin.getLogger().config("[Borders] Invalid center coordinates for " + wname + ": " + centerstr);
|
||||||
|
} else if (size == null) {
|
||||||
|
plugin.getLogger().config("[Borders] Invalid size for " + wname + ": " + sizestr);
|
||||||
|
} else {
|
||||||
|
size.divide(new Vector(2f, 2f, 2f));
|
||||||
|
r.setOne(center.add(size));
|
||||||
|
r.setTwo(center.subtract(size));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (cfg.contains(wname + ".points")) {
|
||||||
|
List<String> points = cfg.getStringList(wname + ".points");
|
||||||
|
for (String pstr : points) {
|
||||||
|
Vector p = LocationUtil.deserializeVector(pstr);
|
||||||
|
if (p == null)
|
||||||
|
continue;
|
||||||
|
r.ensureInside(p);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (r.isValid()) {
|
||||||
|
Vector c = r.getCenter();
|
||||||
|
w.getWorldBorder().setCenter(c.getX(), c.getZ());
|
||||||
|
}
|
||||||
|
*/
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
20
ChatNotifier/.classpath
Normal file
20
ChatNotifier/.classpath
Normal file
@ -0,0 +1,20 @@
|
|||||||
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
|
<classpath>
|
||||||
|
<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/JavaSE-10">
|
||||||
|
<attributes>
|
||||||
|
<attribute name="maven.pomderived" value="true"/>
|
||||||
|
</attributes>
|
||||||
|
</classpathentry>
|
||||||
|
<classpathentry kind="src" output="target/classes" path="src">
|
||||||
|
<attributes>
|
||||||
|
<attribute name="optional" value="true"/>
|
||||||
|
<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>
|
2
ChatNotifier/.gitignore
vendored
Normal file
2
ChatNotifier/.gitignore
vendored
Normal file
@ -0,0 +1,2 @@
|
|||||||
|
/bin/
|
||||||
|
/target/
|
23
ChatNotifier/.project
Normal file
23
ChatNotifier/.project
Normal file
@ -0,0 +1,23 @@
|
|||||||
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
|
<projectDescription>
|
||||||
|
<name>ChatNotifier</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.m2e.core.maven2Nature</nature>
|
||||||
|
<nature>org.eclipse.jdt.core.javanature</nature>
|
||||||
|
</natures>
|
||||||
|
</projectDescription>
|
13
ChatNotifier/.settings/org.eclipse.jdt.core.prefs
Normal file
13
ChatNotifier/.settings/org.eclipse.jdt.core.prefs
Normal file
@ -0,0 +1,13 @@
|
|||||||
|
eclipse.preferences.version=1
|
||||||
|
org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled
|
||||||
|
org.eclipse.jdt.core.compiler.codegen.targetPlatform=10
|
||||||
|
org.eclipse.jdt.core.compiler.codegen.unusedLocal=preserve
|
||||||
|
org.eclipse.jdt.core.compiler.compliance=10
|
||||||
|
org.eclipse.jdt.core.compiler.debug.lineNumber=generate
|
||||||
|
org.eclipse.jdt.core.compiler.debug.localVariable=generate
|
||||||
|
org.eclipse.jdt.core.compiler.debug.sourceFile=generate
|
||||||
|
org.eclipse.jdt.core.compiler.problem.assertIdentifier=error
|
||||||
|
org.eclipse.jdt.core.compiler.problem.enumIdentifier=error
|
||||||
|
org.eclipse.jdt.core.compiler.problem.forbiddenReference=warning
|
||||||
|
org.eclipse.jdt.core.compiler.release=enabled
|
||||||
|
org.eclipse.jdt.core.compiler.source=10
|
4
ChatNotifier/.settings/org.eclipse.m2e.core.prefs
Normal file
4
ChatNotifier/.settings/org.eclipse.m2e.core.prefs
Normal file
@ -0,0 +1,4 @@
|
|||||||
|
activeProfiles=
|
||||||
|
eclipse.preferences.version=1
|
||||||
|
resolveWorkspaceProjects=true
|
||||||
|
version=1
|
34
ChatNotifier/pom.xml
Normal file
34
ChatNotifier/pom.xml
Normal file
@ -0,0 +1,34 @@
|
|||||||
|
<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>cz.marwland.mc.features</groupId>
|
||||||
|
<artifactId>ChatNotifier</artifactId>
|
||||||
|
<parent>
|
||||||
|
<groupId>cz.marwland.mc</groupId>
|
||||||
|
<artifactId>MarwStuff</artifactId>
|
||||||
|
<version>0.0.1-SNAPSHOT</version>
|
||||||
|
<relativePath>../../MarwStuff</relativePath>
|
||||||
|
</parent>
|
||||||
|
<build>
|
||||||
|
<sourceDirectory>src</sourceDirectory>
|
||||||
|
<plugins>
|
||||||
|
<plugin>
|
||||||
|
<artifactId>maven-compiler-plugin</artifactId>
|
||||||
|
<version>3.7.0</version>
|
||||||
|
<configuration>
|
||||||
|
<release>10</release>
|
||||||
|
</configuration>
|
||||||
|
</plugin>
|
||||||
|
</plugins>
|
||||||
|
</build>
|
||||||
|
<dependencies>
|
||||||
|
<dependency>
|
||||||
|
<groupId>cz.marwland.mc</groupId>
|
||||||
|
<artifactId>MarwCore</artifactId>
|
||||||
|
<version>${project.parent.version}</version>
|
||||||
|
</dependency>
|
||||||
|
<dependency>
|
||||||
|
<groupId>com.connorlinfoot</groupId>
|
||||||
|
<artifactId>BountifulAPI</artifactId>
|
||||||
|
</dependency>
|
||||||
|
</dependencies>
|
||||||
|
</project>
|
31
ChatNotifier/src/cz/marwland/mc/features/ChatNotifier.java
Normal file
31
ChatNotifier/src/cz/marwland/mc/features/ChatNotifier.java
Normal file
@ -0,0 +1,31 @@
|
|||||||
|
package cz.marwland.mc.features;
|
||||||
|
|
||||||
|
import org.bukkit.Bukkit;
|
||||||
|
import org.bukkit.Sound;
|
||||||
|
import org.bukkit.entity.Player;
|
||||||
|
import org.bukkit.event.EventHandler;
|
||||||
|
import org.bukkit.event.player.AsyncPlayerChatEvent;
|
||||||
|
|
||||||
|
import com.connorlinfoot.bountifulapi.BountifulAPI;
|
||||||
|
|
||||||
|
import cz.marwland.mc.core.features.Feature;
|
||||||
|
import net.md_5.bungee.api.ChatColor;
|
||||||
|
|
||||||
|
public class ChatNotifier extends Feature {
|
||||||
|
|
||||||
|
// TODO: Per-player highlighting
|
||||||
|
@EventHandler
|
||||||
|
public void onPlayerChat(AsyncPlayerChatEvent e) {
|
||||||
|
for (Player p : Bukkit.getServer().getOnlinePlayers()) {
|
||||||
|
String msg = e.getMessage();
|
||||||
|
if (msg.toLowerCase().contains(p.getName().toLowerCase()) && p.getPlayer() != e.getPlayer()) {
|
||||||
|
/*e.getRecipients().remove(p);
|
||||||
|
msg = ChatColor.RED + msg;*/
|
||||||
|
BountifulAPI.sendActionBar(p, ChatColor.RED + "Byl jsi zminen v chatu!");
|
||||||
|
p.playSound(p.getLocation(), Sound.ENTITY_EXPERIENCE_ORB_PICKUP, 1.0F, 3.0F);
|
||||||
|
}
|
||||||
|
//p.sendMessage(String.format(e.getFormat(), e.getPlayer().getDisplayName(), msg));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
20
ChorusLimiter/.classpath
Normal file
20
ChorusLimiter/.classpath
Normal file
@ -0,0 +1,20 @@
|
|||||||
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
|
<classpath>
|
||||||
|
<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/JavaSE-10">
|
||||||
|
<attributes>
|
||||||
|
<attribute name="maven.pomderived" value="true"/>
|
||||||
|
</attributes>
|
||||||
|
</classpathentry>
|
||||||
|
<classpathentry kind="src" output="target/classes" path="src">
|
||||||
|
<attributes>
|
||||||
|
<attribute name="optional" value="true"/>
|
||||||
|
<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>
|
2
ChorusLimiter/.gitignore
vendored
Normal file
2
ChorusLimiter/.gitignore
vendored
Normal file
@ -0,0 +1,2 @@
|
|||||||
|
/bin/
|
||||||
|
/target/
|
23
ChorusLimiter/.project
Normal file
23
ChorusLimiter/.project
Normal file
@ -0,0 +1,23 @@
|
|||||||
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
|
<projectDescription>
|
||||||
|
<name>ChorusLimiter</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.m2e.core.maven2Nature</nature>
|
||||||
|
<nature>org.eclipse.jdt.core.javanature</nature>
|
||||||
|
</natures>
|
||||||
|
</projectDescription>
|
13
ChorusLimiter/.settings/org.eclipse.jdt.core.prefs
Normal file
13
ChorusLimiter/.settings/org.eclipse.jdt.core.prefs
Normal file
@ -0,0 +1,13 @@
|
|||||||
|
eclipse.preferences.version=1
|
||||||
|
org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled
|
||||||
|
org.eclipse.jdt.core.compiler.codegen.targetPlatform=10
|
||||||
|
org.eclipse.jdt.core.compiler.codegen.unusedLocal=preserve
|
||||||
|
org.eclipse.jdt.core.compiler.compliance=10
|
||||||
|
org.eclipse.jdt.core.compiler.debug.lineNumber=generate
|
||||||
|
org.eclipse.jdt.core.compiler.debug.localVariable=generate
|
||||||
|
org.eclipse.jdt.core.compiler.debug.sourceFile=generate
|
||||||
|
org.eclipse.jdt.core.compiler.problem.assertIdentifier=error
|
||||||
|
org.eclipse.jdt.core.compiler.problem.enumIdentifier=error
|
||||||
|
org.eclipse.jdt.core.compiler.problem.forbiddenReference=warning
|
||||||
|
org.eclipse.jdt.core.compiler.release=enabled
|
||||||
|
org.eclipse.jdt.core.compiler.source=10
|
4
ChorusLimiter/.settings/org.eclipse.m2e.core.prefs
Normal file
4
ChorusLimiter/.settings/org.eclipse.m2e.core.prefs
Normal file
@ -0,0 +1,4 @@
|
|||||||
|
activeProfiles=
|
||||||
|
eclipse.preferences.version=1
|
||||||
|
resolveWorkspaceProjects=true
|
||||||
|
version=1
|
34
ChorusLimiter/pom.xml
Normal file
34
ChorusLimiter/pom.xml
Normal file
@ -0,0 +1,34 @@
|
|||||||
|
<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>cz.marwland.mc.features</groupId>
|
||||||
|
<artifactId>ChorusLimiter</artifactId>
|
||||||
|
<parent>
|
||||||
|
<groupId>cz.marwland.mc</groupId>
|
||||||
|
<artifactId>MarwStuff</artifactId>
|
||||||
|
<version>0.0.1-SNAPSHOT</version>
|
||||||
|
<relativePath>../../MarwStuff</relativePath>
|
||||||
|
</parent>
|
||||||
|
<build>
|
||||||
|
<sourceDirectory>src</sourceDirectory>
|
||||||
|
<plugins>
|
||||||
|
<plugin>
|
||||||
|
<artifactId>maven-compiler-plugin</artifactId>
|
||||||
|
<version>3.7.0</version>
|
||||||
|
<configuration>
|
||||||
|
<release>10</release>
|
||||||
|
</configuration>
|
||||||
|
</plugin>
|
||||||
|
</plugins>
|
||||||
|
</build>
|
||||||
|
<dependencies>
|
||||||
|
<dependency>
|
||||||
|
<groupId>cz.marwland.mc</groupId>
|
||||||
|
<artifactId>MarwCore</artifactId>
|
||||||
|
<version>${project.parent.version}</version>
|
||||||
|
</dependency>
|
||||||
|
<dependency>
|
||||||
|
<groupId>com.connorlinfoot</groupId>
|
||||||
|
<artifactId>BountifulAPI</artifactId>
|
||||||
|
</dependency>
|
||||||
|
</dependencies>
|
||||||
|
</project>
|
31
ChorusLimiter/src/cz/marwland/mc/features/ChorusLimiter.java
Normal file
31
ChorusLimiter/src/cz/marwland/mc/features/ChorusLimiter.java
Normal file
@ -0,0 +1,31 @@
|
|||||||
|
package cz.marwland.mc.features;
|
||||||
|
|
||||||
|
import org.bukkit.Material;
|
||||||
|
import org.bukkit.event.EventHandler;
|
||||||
|
import org.bukkit.event.player.PlayerItemConsumeEvent;
|
||||||
|
|
||||||
|
import com.connorlinfoot.bountifulapi.BountifulAPI;
|
||||||
|
|
||||||
|
import cz.marwland.mc.core.features.Feature;
|
||||||
|
import cz.marwland.mc.core.util.Cooldown;
|
||||||
|
import net.md_5.bungee.api.ChatColor;
|
||||||
|
|
||||||
|
public class ChorusLimiter extends Feature {
|
||||||
|
|
||||||
|
private Cooldown chorusCooldown = new Cooldown(this);
|
||||||
|
|
||||||
|
@EventHandler
|
||||||
|
public void onPlayerItemConsume(PlayerItemConsumeEvent e) {
|
||||||
|
if (e.getItem().getType() != Material.CHORUS_FRUIT)
|
||||||
|
return;
|
||||||
|
|
||||||
|
long left = chorusCooldown.timeLeftSeconds(e.getPlayer());
|
||||||
|
if (left > 0) {
|
||||||
|
BountifulAPI.sendActionBar(e.getPlayer(), ChatColor.RED + "Musis pockat jeste " + left + " sekund pro pouziti Chorus Fruitu!");
|
||||||
|
e.setCancelled(true);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
chorusCooldown.resetPlayer(e.getPlayer());
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
26
RandomTeleport/.classpath
Normal file
26
RandomTeleport/.classpath
Normal file
@ -0,0 +1,26 @@
|
|||||||
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
|
<classpath>
|
||||||
|
<classpathentry kind="src" path="src" including="**/*.java"/>
|
||||||
|
<classpathentry kind="output" path="target/classes"/>
|
||||||
|
<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER"/>
|
||||||
|
<classpathentry kind="var" path="M2_REPO/cz/marwland/mc/MarwCore/0.0.1-SNAPSHOT/MarwCore-0.0.1-SNAPSHOT.jar"/>
|
||||||
|
<classpathentry kind="lib" path="/home/erik/Dokumenty/Java/marwland/res/MassiveCore.jar"/>
|
||||||
|
<classpathentry kind="lib" path="/home/erik/Dokumenty/Java/marwland/res/Factions.jar"/>
|
||||||
|
<classpathentry kind="var" path="M2_REPO/com/sk89q/worldedit/worldedit-core/6.0.0-SNAPSHOT/worldedit-core-6.0.0-SNAPSHOT.jar" sourcepath="M2_REPO/com/sk89q/worldedit/worldedit-core/6.0.0-SNAPSHOT/worldedit-core-6.0.0-SNAPSHOT-sources.jar"/>
|
||||||
|
<classpathentry kind="var" path="M2_REPO/de/schlichtherle/truezip/6.8.3/truezip-6.8.3.jar" sourcepath="M2_REPO/de/schlichtherle/truezip/6.8.3/truezip-6.8.3-sources.jar"/>
|
||||||
|
<classpathentry kind="var" path="M2_REPO/com/google/guava/guava/17.0/guava-17.0.jar" sourcepath="M2_REPO/com/google/guava/guava/17.0/guava-17.0-sources.jar"/>
|
||||||
|
<classpathentry kind="var" path="M2_REPO/rhino/js/1.7R2/js-1.7R2.jar" sourcepath="M2_REPO/rhino/js/1.7R2/js-1.7R2-sources.jar"/>
|
||||||
|
<classpathentry kind="var" path="M2_REPO/org/yaml/snakeyaml/1.9/snakeyaml-1.9.jar" sourcepath="M2_REPO/org/yaml/snakeyaml/1.9/snakeyaml-1.9-sources.jar"/>
|
||||||
|
<classpathentry kind="var" path="M2_REPO/com/google/code/findbugs/jsr305/1.3.9/jsr305-1.3.9.jar"/>
|
||||||
|
<classpathentry kind="var" path="M2_REPO/com/thoughtworks/paranamer/paranamer/2.6/paranamer-2.6.jar" sourcepath="M2_REPO/com/thoughtworks/paranamer/paranamer/2.6/paranamer-2.6-sources.jar"/>
|
||||||
|
<classpathentry kind="var" path="M2_REPO/com/google/code/gson/gson/2.2.4/gson-2.2.4.jar" sourcepath="M2_REPO/com/google/code/gson/gson/2.2.4/gson-2.2.4-sources.jar"/>
|
||||||
|
<classpathentry kind="var" path="M2_REPO/com/sk89q/lib/jlibnoise/1.0.0/jlibnoise-1.0.0.jar"/>
|
||||||
|
<classpathentry kind="var" path="M2_REPO/com/sk89q/jchronic/0.2.4a/jchronic-0.2.4a.jar"/>
|
||||||
|
<classpathentry kind="var" path="M2_REPO/junit/junit/4.8.1/junit-4.8.1.jar" sourcepath="M2_REPO/junit/junit/4.8.1/junit-4.8.1-sources.jar"/>
|
||||||
|
<classpathentry kind="var" path="M2_REPO/com/sk89q/worldguard/worldguard-legacy/6.2/worldguard-legacy-6.2.jar"/>
|
||||||
|
<classpathentry kind="var" path="M2_REPO/org/spigotmc/spigot-api/1.12-R0.1-SNAPSHOT/spigot-api-1.12-R0.1-SNAPSHOT.jar" sourcepath="M2_REPO/org/spigotmc/spigot-api/1.12-R0.1-SNAPSHOT/spigot-api-1.12-R0.1-SNAPSHOT-sources.jar"/>
|
||||||
|
<classpathentry kind="var" path="M2_REPO/commons-lang/commons-lang/2.6/commons-lang-2.6.jar" sourcepath="M2_REPO/commons-lang/commons-lang/2.6/commons-lang-2.6-sources.jar"/>
|
||||||
|
<classpathentry kind="var" path="M2_REPO/com/googlecode/json-simple/json-simple/1.1.1/json-simple-1.1.1.jar" sourcepath="M2_REPO/com/googlecode/json-simple/json-simple/1.1.1/json-simple-1.1.1-sources.jar"/>
|
||||||
|
<classpathentry kind="var" path="M2_REPO/org/hamcrest/hamcrest-core/1.1/hamcrest-core-1.1.jar" sourcepath="M2_REPO/org/hamcrest/hamcrest-core/1.1/hamcrest-core-1.1-sources.jar"/>
|
||||||
|
<classpathentry kind="var" path="M2_REPO/net/md-5/bungeecord-chat/1.12-SNAPSHOT/bungeecord-chat-1.12-SNAPSHOT.jar" sourcepath="M2_REPO/net/md-5/bungeecord-chat/1.12-SNAPSHOT/bungeecord-chat-1.12-SNAPSHOT-sources.jar"/>
|
||||||
|
</classpath>
|
2
RandomTeleport/.gitignore
vendored
Normal file
2
RandomTeleport/.gitignore
vendored
Normal file
@ -0,0 +1,2 @@
|
|||||||
|
/bin/
|
||||||
|
/target/
|
18
RandomTeleport/.project
Normal file
18
RandomTeleport/.project
Normal file
@ -0,0 +1,18 @@
|
|||||||
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
|
<projectDescription>
|
||||||
|
<name>RandomTeleport</name>
|
||||||
|
<comment>NO_M2ECLIPSE_SUPPORT: Project files created with the maven-eclipse-plugin are not supported in M2Eclipse.</comment>
|
||||||
|
<projects/>
|
||||||
|
<buildSpec>
|
||||||
|
<buildCommand>
|
||||||
|
<name>org.eclipse.jdt.core.javabuilder</name>
|
||||||
|
</buildCommand>
|
||||||
|
<buildCommand>
|
||||||
|
<name>org.eclipse.m2e.core.maven2Builder</name>
|
||||||
|
</buildCommand>
|
||||||
|
</buildSpec>
|
||||||
|
<natures>
|
||||||
|
<nature>org.eclipse.m2e.core.maven2Nature</nature>
|
||||||
|
<nature>org.eclipse.jdt.core.javanature</nature>
|
||||||
|
</natures>
|
||||||
|
</projectDescription>
|
13
RandomTeleport/.settings/org.eclipse.jdt.core.prefs
Normal file
13
RandomTeleport/.settings/org.eclipse.jdt.core.prefs
Normal file
@ -0,0 +1,13 @@
|
|||||||
|
eclipse.preferences.version=1
|
||||||
|
org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled
|
||||||
|
org.eclipse.jdt.core.compiler.codegen.targetPlatform=10
|
||||||
|
org.eclipse.jdt.core.compiler.codegen.unusedLocal=preserve
|
||||||
|
org.eclipse.jdt.core.compiler.compliance=10
|
||||||
|
org.eclipse.jdt.core.compiler.debug.lineNumber=generate
|
||||||
|
org.eclipse.jdt.core.compiler.debug.localVariable=generate
|
||||||
|
org.eclipse.jdt.core.compiler.debug.sourceFile=generate
|
||||||
|
org.eclipse.jdt.core.compiler.problem.assertIdentifier=error
|
||||||
|
org.eclipse.jdt.core.compiler.problem.enumIdentifier=error
|
||||||
|
org.eclipse.jdt.core.compiler.problem.forbiddenReference=warning
|
||||||
|
org.eclipse.jdt.core.compiler.release=enabled
|
||||||
|
org.eclipse.jdt.core.compiler.source=10
|
4
RandomTeleport/.settings/org.eclipse.m2e.core.prefs
Normal file
4
RandomTeleport/.settings/org.eclipse.m2e.core.prefs
Normal file
@ -0,0 +1,4 @@
|
|||||||
|
activeProfiles=
|
||||||
|
eclipse.preferences.version=1
|
||||||
|
resolveWorkspaceProjects=true
|
||||||
|
version=1
|
63
RandomTeleport/pom.xml
Normal file
63
RandomTeleport/pom.xml
Normal file
@ -0,0 +1,63 @@
|
|||||||
|
<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>cz.marwland.mc.features</groupId>
|
||||||
|
<artifactId>RandomTeleport</artifactId>
|
||||||
|
<parent>
|
||||||
|
<groupId>cz.marwland.mc</groupId>
|
||||||
|
<artifactId>MarwStuff</artifactId>
|
||||||
|
<version>0.0.1-SNAPSHOT</version>
|
||||||
|
<relativePath>../../MarwStuff</relativePath>
|
||||||
|
</parent>
|
||||||
|
<build>
|
||||||
|
<sourceDirectory>src</sourceDirectory>
|
||||||
|
<plugins>
|
||||||
|
<plugin>
|
||||||
|
<artifactId>maven-compiler-plugin</artifactId>
|
||||||
|
<version>3.7.0</version>
|
||||||
|
<configuration>
|
||||||
|
<release>10</release>
|
||||||
|
</configuration>
|
||||||
|
</plugin>
|
||||||
|
</plugins>
|
||||||
|
</build>
|
||||||
|
<dependencies>
|
||||||
|
<dependency>
|
||||||
|
<groupId>cz.marwland.mc</groupId>
|
||||||
|
<artifactId>MarwCore</artifactId>
|
||||||
|
<version>${project.parent.version}</version>
|
||||||
|
</dependency>
|
||||||
|
<dependency>
|
||||||
|
<groupId>com.sk89q.worldedit</groupId>
|
||||||
|
<artifactId>worldedit-core</artifactId>
|
||||||
|
<version>6.0.0-SNAPSHOT</version>
|
||||||
|
<scope>provided</scope>
|
||||||
|
</dependency>
|
||||||
|
<dependency>
|
||||||
|
<groupId>com.sk89q.worldguard</groupId>
|
||||||
|
<artifactId>worldguard-legacy</artifactId>
|
||||||
|
<version>6.2</version>
|
||||||
|
<scope>provided</scope>
|
||||||
|
</dependency>
|
||||||
|
<dependency>
|
||||||
|
<groupId>com.massivecraft.massivecore</groupId>
|
||||||
|
<artifactId>MassiveCore</artifactId>
|
||||||
|
<version>2.14.1-SNAPSHOT</version>
|
||||||
|
<scope>system</scope>
|
||||||
|
<systemPath>/home/erik/Dokumenty/Java/marwland/res/MassiveCore.jar</systemPath>
|
||||||
|
</dependency>
|
||||||
|
<dependency>
|
||||||
|
<groupId>com.massivecraft.factions</groupId>
|
||||||
|
<artifactId>Factions</artifactId>
|
||||||
|
<version>2.14.1-SNAPSHOT</version>
|
||||||
|
<scope>system</scope>
|
||||||
|
<systemPath>/home/erik/Dokumenty/Java/marwland/res/Factions.jar</systemPath>
|
||||||
|
</dependency>
|
||||||
|
</dependencies>
|
||||||
|
|
||||||
|
<repositories>
|
||||||
|
<repository>
|
||||||
|
<id>sk89q-repo</id>
|
||||||
|
<url>http://maven.sk89q.com/repo/</url>
|
||||||
|
</repository>
|
||||||
|
</repositories>
|
||||||
|
</project>
|
169
RandomTeleport/src/cz/marwland/mc/features/RandomTeleport.java
Normal file
169
RandomTeleport/src/cz/marwland/mc/features/RandomTeleport.java
Normal file
@ -0,0 +1,169 @@
|
|||||||
|
package cz.marwland.mc.features;
|
||||||
|
|
||||||
|
import java.util.Arrays;
|
||||||
|
import java.util.HashSet;
|
||||||
|
import java.util.Set;
|
||||||
|
|
||||||
|
import org.bukkit.Bukkit;
|
||||||
|
import org.bukkit.Location;
|
||||||
|
import org.bukkit.Material;
|
||||||
|
import org.bukkit.World;
|
||||||
|
import org.bukkit.block.Block;
|
||||||
|
import org.bukkit.command.CommandSender;
|
||||||
|
import org.bukkit.command.defaults.BukkitCommand;
|
||||||
|
import org.bukkit.entity.Player;
|
||||||
|
import org.bukkit.event.block.BlockCanBuildEvent;
|
||||||
|
import org.bukkit.event.player.PlayerTeleportEvent.TeleportCause;
|
||||||
|
|
||||||
|
import cz.marwland.mc.core.features.Feature;
|
||||||
|
import cz.marwland.mc.core.util.Cooldown;
|
||||||
|
import net.md_5.bungee.api.ChatColor;
|
||||||
|
|
||||||
|
public class RandomTeleport extends Feature {
|
||||||
|
|
||||||
|
private final int MAX_TRIES = 100;
|
||||||
|
private Cooldown telCooldown = new Cooldown(this);
|
||||||
|
|
||||||
|
private static final Set<Material> INVALID_MATERIALS = new HashSet<>(Arrays.asList(
|
||||||
|
Material.AIR,
|
||||||
|
Material.WATER,
|
||||||
|
Material.STATIONARY_WATER,
|
||||||
|
Material.LAVA,
|
||||||
|
Material.STATIONARY_LAVA,
|
||||||
|
Material.MAGMA,
|
||||||
|
Material.MAGMA_CREAM,
|
||||||
|
Material.FIRE,
|
||||||
|
Material.WEB,
|
||||||
|
Material.CACTUS,
|
||||||
|
Material.ENDER_PORTAL,
|
||||||
|
Material.PORTAL
|
||||||
|
));
|
||||||
|
|
||||||
|
public RandomTeleport() {
|
||||||
|
super();
|
||||||
|
this.addCommand(new BukkitCommand(
|
||||||
|
"rtp",
|
||||||
|
"Teleport player to random location in the current world.",
|
||||||
|
"/rtp [player]",
|
||||||
|
Arrays.asList("randomtp", "randomteleport") ) {
|
||||||
|
@Override
|
||||||
|
public boolean execute(CommandSender sender, String commandLabel, String[] args) {
|
||||||
|
if (!permissionMissingCheck(sender, this.getPermission()))
|
||||||
|
return true;
|
||||||
|
|
||||||
|
if (!(sender instanceof Player) && args.length < 1) {
|
||||||
|
sender.sendMessage(ChatColor.RED + "You need to specify the player! " + ChatColor.YELLOW + "/rtp [player] [world]");
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
Player p = (Player) sender;
|
||||||
|
if (args.length >= 1) {
|
||||||
|
p = Bukkit.getServer().getPlayer(args[0]);
|
||||||
|
if (p != sender && !permissionMissingCheck(sender, this.getPermission() + ".others")) {
|
||||||
|
return true;
|
||||||
|
} else if (p == null) {
|
||||||
|
sender.sendMessage(ChatColor.RED + "Player not found!");
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
World w = p.getWorld();
|
||||||
|
if (args.length >= 2) {
|
||||||
|
w = Bukkit.getServer().getWorld(args[1]);
|
||||||
|
if (w == null) {
|
||||||
|
sender.sendMessage(ChatColor.RED + "World not found!");
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!sender.hasPermission(this.getPermission() + ".world." + w.getName())) {
|
||||||
|
sender.sendMessage(ChatColor.RED + "V tomhle svete se nemuzes nahodne teleportovat!");
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
long left = telCooldown.timeLeftSeconds(p);
|
||||||
|
if (left > 0) {
|
||||||
|
sender.sendMessage(ChatColor.RED + "Nemuzes se nahodne teleportovat jeste " + ChatColor.YELLOW + left + ChatColor.RED + " sekund" + (left == 1 ? "u!" : (left > 4 ? "!" : "y!")));
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
telCooldown.resetPlayer(p);
|
||||||
|
randomTeleport(w, p);
|
||||||
|
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String getPermission() {
|
||||||
|
return getPermissionPath();
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
public void randomTeleport(World w, Player p) {
|
||||||
|
Location loc = null;
|
||||||
|
for (int i = 0; i < MAX_TRIES && loc == null; i++) {
|
||||||
|
loc = generateLoc(w);
|
||||||
|
if (!canTeleportHere(loc, p, false))
|
||||||
|
loc = null;
|
||||||
|
else {
|
||||||
|
loc.add(0.5d, 1d, 0.5d);
|
||||||
|
if (!canTeleportHere(loc, p, true))
|
||||||
|
loc = null;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (loc != null) {
|
||||||
|
loc.setYaw((float) (Math.random() * 360f));
|
||||||
|
p.teleport(loc, TeleportCause.COMMAND);
|
||||||
|
} else {
|
||||||
|
p.sendMessage(ChatColor.RED + "V tomhle svete se pro tebe nenaslo bezpecne misto!");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public Location generateLoc(World w) {
|
||||||
|
int wboff = 16;
|
||||||
|
Location loc = w.getWorldBorder().getCenter();
|
||||||
|
int radius = (int) w.getWorldBorder().getSize() / 2;
|
||||||
|
int minx = loc.getBlockX() - radius;
|
||||||
|
int minz = loc.getBlockZ() - radius;
|
||||||
|
int maxx = loc.getBlockX() + radius;
|
||||||
|
int maxz = loc.getBlockZ() + radius;
|
||||||
|
if (wboff >= radius)
|
||||||
|
wboff = 0;
|
||||||
|
int rangex = (maxx - minx) - wboff * 2;
|
||||||
|
int rangez = (maxz - minz) - wboff * 2;
|
||||||
|
int finx = minx + (int) (Math.random() * rangex) + wboff;
|
||||||
|
int finz = minz + (int) (Math.random() * rangez) + wboff;
|
||||||
|
Location targetloc = w.getHighestBlockAt(finx, finz).getLocation();
|
||||||
|
targetloc.subtract(0d, 1d, 0d);
|
||||||
|
return targetloc;
|
||||||
|
}
|
||||||
|
|
||||||
|
public boolean canTeleportHere(Location loc, Player p, boolean allowAir) {
|
||||||
|
Block block = loc.getWorld().getBlockAt(loc);
|
||||||
|
if (INVALID_MATERIALS.contains(block.getType()) && (allowAir ? block.getType() != Material.AIR : true))
|
||||||
|
return false;
|
||||||
|
|
||||||
|
BlockCanBuildEvent canBuildEvent = new BlockCanBuildEvent(block, block.getData(), true);
|
||||||
|
Bukkit.getServer().getPluginManager().callEvent(canBuildEvent);
|
||||||
|
if (!canBuildEvent.isBuildable())
|
||||||
|
return false;
|
||||||
|
|
||||||
|
try {
|
||||||
|
if (!com.sk89q.worldguard.bukkit.WGBukkit.getPlugin().canBuild(p, block)) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
} catch (NoClassDefFoundError e) {
|
||||||
|
}
|
||||||
|
|
||||||
|
try {
|
||||||
|
if (com.massivecraft.factions.entity.BoardColl.get().getFactionAt(com.massivecraft.massivecore.ps.PS.valueOf(loc)) != com.massivecraft.factions.entity.FactionColl.get().getNone()) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
} catch (NoClassDefFoundError e) {
|
||||||
|
}
|
||||||
|
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
Loading…
Reference in New Issue
Block a user