Initial commit
Signed-off-by: Simon <simongiesel@gmail.com>
This commit is contained in:
commit
1de9dc0600
14 changed files with 309 additions and 0 deletions
2
.idea/.gitignore
vendored
Normal file
2
.idea/.gitignore
vendored
Normal file
|
@ -0,0 +1,2 @@
|
|||
# Default ignored files
|
||||
/workspace.xml
|
13
.idea/compiler.xml
Normal file
13
.idea/compiler.xml
Normal file
|
@ -0,0 +1,13 @@
|
|||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<project version="4">
|
||||
<component name="CompilerConfiguration">
|
||||
<annotationProcessing>
|
||||
<profile name="Maven default annotation processors profile" enabled="true">
|
||||
<sourceOutputDir name="target/generated-sources/annotations" />
|
||||
<sourceTestOutputDir name="target/generated-test-sources/test-annotations" />
|
||||
<outputRelativeToContentRoot value="true" />
|
||||
<module name="CliffbreakCore" />
|
||||
</profile>
|
||||
</annotationProcessing>
|
||||
</component>
|
||||
</project>
|
7
.idea/dictionaries/simon.xml
Normal file
7
.idea/dictionaries/simon.xml
Normal file
|
@ -0,0 +1,7 @@
|
|||
<component name="ProjectDictionaryState">
|
||||
<dictionary name="simon">
|
||||
<words>
|
||||
<w>cliffbreak</w>
|
||||
</words>
|
||||
</dictionary>
|
||||
</component>
|
14
.idea/misc.xml
Normal file
14
.idea/misc.xml
Normal file
|
@ -0,0 +1,14 @@
|
|||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<project version="4">
|
||||
<component name="ExternalStorageConfigurationManager" enabled="true" />
|
||||
<component name="MavenProjectsManager">
|
||||
<option name="originalFiles">
|
||||
<list>
|
||||
<option value="$PROJECT_DIR$/pom.xml" />
|
||||
</list>
|
||||
</option>
|
||||
</component>
|
||||
<component name="ProjectRootManager" version="2" languageLevel="JDK_1_8" project-jdk-name="1.8" project-jdk-type="JavaSDK">
|
||||
<output url="file://$PROJECT_DIR$/out" />
|
||||
</component>
|
||||
</project>
|
6
.idea/vcs.xml
Normal file
6
.idea/vcs.xml
Normal file
|
@ -0,0 +1,6 @@
|
|||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<project version="4">
|
||||
<component name="VcsDirectoryMappings">
|
||||
<mapping directory="$PROJECT_DIR$" vcs="Git" />
|
||||
</component>
|
||||
</project>
|
2
CliffbreakCore.iml
Normal file
2
CliffbreakCore.iml
Normal file
|
@ -0,0 +1,2 @@
|
|||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<module type="JAVA_MODULE" version="4" />
|
42
pom.xml
Normal file
42
pom.xml
Normal file
|
@ -0,0 +1,42 @@
|
|||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<project xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
||||
xmlns="http://maven.apache.org/POM/4.0.0"
|
||||
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>de.cliffbreak.core</groupId>
|
||||
<artifactId>CliffbreakCore</artifactId>
|
||||
<version>1.0-SNAPSHOT</version>
|
||||
<build>
|
||||
<plugins>
|
||||
<plugin>
|
||||
<groupId>org.apache.maven.plugins</groupId>
|
||||
<artifactId>maven-compiler-plugin</artifactId>
|
||||
<configuration>
|
||||
<source>6</source>
|
||||
<target>6</target>
|
||||
</configuration>
|
||||
</plugin>
|
||||
</plugins>
|
||||
</build>
|
||||
|
||||
<properties>
|
||||
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
|
||||
</properties>
|
||||
|
||||
<repositories>
|
||||
<repository>
|
||||
<id>spigotmc-repo</id>
|
||||
<url>https://hub.spigotmc.org/nexus/content/repositories/snapshots/</url>
|
||||
</repository>
|
||||
</repositories>
|
||||
|
||||
<dependencies>
|
||||
<dependency>
|
||||
<groupId>org.spigotmc</groupId>
|
||||
<artifactId>spigot-api</artifactId>
|
||||
<version>1.13-R0.1-SNAPSHOT</version>
|
||||
<scope>provided</scope>
|
||||
</dependency>
|
||||
</dependencies>
|
||||
</project>
|
27
src/main/java/de/cliffbreak/core/CliffbreakCore.java
Normal file
27
src/main/java/de/cliffbreak/core/CliffbreakCore.java
Normal file
|
@ -0,0 +1,27 @@
|
|||
package de.cliffbreak.core;
|
||||
|
||||
import de.cliffbreak.core.commands.CommandGM;
|
||||
import de.cliffbreak.core.commands.CommandHub;
|
||||
import de.cliffbreak.core.commands.CommandSpeed;
|
||||
import de.cliffbreak.core.listeners.ChatListener;
|
||||
import de.cliffbreak.core.listeners.PlayerJoinListener;
|
||||
import org.bukkit.configuration.file.FileConfiguration;
|
||||
import org.bukkit.configuration.file.YamlConfiguration;
|
||||
import org.bukkit.plugin.java.JavaPlugin;
|
||||
|
||||
import java.io.File;
|
||||
|
||||
public class CliffbreakCore extends JavaPlugin {
|
||||
|
||||
public File cfgFile = new File("plugins/Core", "config.yml");
|
||||
public FileConfiguration cfg = YamlConfiguration.loadConfiguration(cfgFile);
|
||||
|
||||
@Override
|
||||
public void onEnable() {
|
||||
getServer().getPluginManager().registerEvents(new PlayerJoinListener(this), this);
|
||||
getServer().getPluginManager().registerEvents(new ChatListener(), this);
|
||||
this.getCommand("gm").setExecutor(new CommandGM());
|
||||
this.getCommand("speed").setExecutor(new CommandSpeed());
|
||||
this.getCommand("hub").setExecutor(new CommandHub(this));
|
||||
}
|
||||
}
|
24
src/main/java/de/cliffbreak/core/commands/CommandGM.java
Normal file
24
src/main/java/de/cliffbreak/core/commands/CommandGM.java
Normal file
|
@ -0,0 +1,24 @@
|
|||
package de.cliffbreak.core.commands;
|
||||
|
||||
import org.bukkit.GameMode;
|
||||
import org.bukkit.command.Command;
|
||||
import org.bukkit.command.CommandExecutor;
|
||||
import org.bukkit.command.CommandSender;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
public class CommandGM implements CommandExecutor {
|
||||
@Override
|
||||
public boolean onCommand(CommandSender commandSender, Command command, String s, String[] strings) {
|
||||
if (commandSender instanceof Player) {
|
||||
Player p = (Player) commandSender;
|
||||
if (!p.hasPermission("cliffbreak.command.gm")) {
|
||||
p.sendMessage("§cNope");
|
||||
return true;
|
||||
}
|
||||
if (p.getGameMode() == GameMode.CREATIVE)
|
||||
p.setGameMode(GameMode.SURVIVAL);
|
||||
else p.setGameMode(GameMode.CREATIVE);
|
||||
}
|
||||
return true;
|
||||
}
|
||||
}
|
63
src/main/java/de/cliffbreak/core/commands/CommandHub.java
Normal file
63
src/main/java/de/cliffbreak/core/commands/CommandHub.java
Normal file
|
@ -0,0 +1,63 @@
|
|||
package de.cliffbreak.core.commands;
|
||||
|
||||
import de.cliffbreak.core.CliffbreakCore;
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.Location;
|
||||
import org.bukkit.World;
|
||||
import org.bukkit.command.Command;
|
||||
import org.bukkit.command.CommandExecutor;
|
||||
import org.bukkit.command.CommandSender;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
import java.io.IOException;
|
||||
|
||||
public class CommandHub implements CommandExecutor {
|
||||
|
||||
private CliffbreakCore plugin;
|
||||
|
||||
public CommandHub(CliffbreakCore plugin) {
|
||||
this.plugin = plugin;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean onCommand(CommandSender commandSender, Command command, String s, String[] args) {
|
||||
if (commandSender instanceof Player) {
|
||||
Player p = (Player) commandSender;
|
||||
|
||||
if (args.length == 0) {
|
||||
World w = Bukkit.getWorld(plugin.cfg.getString("Hub.Spawn.World"));
|
||||
double x = plugin.cfg.getDouble("Hub.Spawn.X");
|
||||
double y = plugin.cfg.getDouble("Hub.Spawn.Y");
|
||||
double z = plugin.cfg.getDouble("Hub.Spawn.Z");
|
||||
float yaw = (float) plugin.cfg.getDouble("Hub.Spawn.Yaw");
|
||||
float pitch = (float) plugin.cfg.getDouble("Hub.Spawn.Pitch");
|
||||
|
||||
p.teleport(new Location(w, x, y, z, yaw, pitch));
|
||||
return true;
|
||||
}
|
||||
|
||||
if (!p.hasPermission("cliffbreak.command.hub")) {
|
||||
p.sendMessage("§cNope");
|
||||
return true;
|
||||
}
|
||||
if (args.length == 1 && args[0].equalsIgnoreCase("setspawn")) {
|
||||
plugin.cfg.set("Hub.Spawn.World", p.getLocation().getWorld().getName());
|
||||
plugin.cfg.set("Hub.Spawn.X", p.getLocation().getX());
|
||||
plugin.cfg.set("Hub.Spawn.Y", p.getLocation().getY());
|
||||
plugin.cfg.set("Hub.Spawn.Z", p.getLocation().getZ());
|
||||
plugin.cfg.set("Hub.Spawn.Yaw", (double) p.getLocation().getYaw());
|
||||
plugin.cfg.set("Hub.Spawn.Pitch", (double) p.getLocation().getPitch());
|
||||
|
||||
try {
|
||||
plugin.cfg.save(plugin.cfgFile);
|
||||
p.sendMessage("§aDer §lHub-Spawn §r§awurde erfolgreich gesetzt.");
|
||||
} catch (IOException e) {
|
||||
p.sendMessage("§cDer §lHub-Spawn §r§cwurde NICHT erfolgreich gesetzt.");
|
||||
e.printStackTrace();
|
||||
}
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return true;
|
||||
}
|
||||
}
|
32
src/main/java/de/cliffbreak/core/commands/CommandSpeed.java
Normal file
32
src/main/java/de/cliffbreak/core/commands/CommandSpeed.java
Normal file
|
@ -0,0 +1,32 @@
|
|||
package de.cliffbreak.core.commands;
|
||||
|
||||
import org.bukkit.command.Command;
|
||||
import org.bukkit.command.CommandExecutor;
|
||||
import org.bukkit.command.CommandSender;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
public class CommandSpeed implements CommandExecutor {
|
||||
@Override
|
||||
public boolean onCommand(CommandSender commandSender, Command command, String s, String[] strings) {
|
||||
if (commandSender instanceof Player) {
|
||||
Player p = (Player) commandSender;
|
||||
if (!p.hasPermission("cliffbreak.command.speed")) {
|
||||
p.sendMessage("§cNope");
|
||||
return true;
|
||||
}
|
||||
if (strings.length == 0)
|
||||
p.setFlySpeed(0.1f);
|
||||
else
|
||||
try {
|
||||
int speed = Integer.parseInt(strings[0]);
|
||||
if (speed < 0 || speed > 10)
|
||||
p.sendMessage("§c§lFehler: §rDas Argument muss zwischen 0 und 10 liegen.");
|
||||
else
|
||||
p.setFlySpeed(speed / 10f);
|
||||
} catch (NumberFormatException ex) {
|
||||
p.sendMessage("§c§lFehler: §rDas Argument muss zwischen 0 und 10 liegen.");
|
||||
}
|
||||
}
|
||||
return true;
|
||||
}
|
||||
}
|
25
src/main/java/de/cliffbreak/core/listeners/ChatListener.java
Normal file
25
src/main/java/de/cliffbreak/core/listeners/ChatListener.java
Normal file
|
@ -0,0 +1,25 @@
|
|||
package de.cliffbreak.core.listeners;
|
||||
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.event.EventHandler;
|
||||
import org.bukkit.event.Listener;
|
||||
import org.bukkit.event.player.AsyncPlayerChatEvent;
|
||||
|
||||
import java.util.Calendar;
|
||||
import java.util.Date;
|
||||
|
||||
public class ChatListener implements Listener {
|
||||
|
||||
@EventHandler()
|
||||
public void onChat(AsyncPlayerChatEvent e) {
|
||||
e.setCancelled(true);
|
||||
Calendar calendar = Calendar.getInstance();
|
||||
Date date = calendar.getTime();
|
||||
String timestamp = String.format("%02d", date.getHours()) + ":" + String.format("%02d", date.getMinutes());
|
||||
for (Player all : Bukkit.getOnlinePlayers()) {
|
||||
all.sendMessage(" §8" + timestamp + " §7| §b" + e.getPlayer().getName() + " §7>> §f" + e.getMessage());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,38 @@
|
|||
package de.cliffbreak.core.listeners;
|
||||
|
||||
import de.cliffbreak.core.CliffbreakCore;
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.GameMode;
|
||||
import org.bukkit.Location;
|
||||
import org.bukkit.World;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.event.EventHandler;
|
||||
import org.bukkit.event.Listener;
|
||||
import org.bukkit.event.player.PlayerJoinEvent;
|
||||
|
||||
public class PlayerJoinListener implements Listener {
|
||||
private CliffbreakCore plugin;
|
||||
|
||||
public PlayerJoinListener(CliffbreakCore plugin) {
|
||||
this.plugin = plugin;
|
||||
}
|
||||
|
||||
@EventHandler()
|
||||
public void onPlayerJoin(PlayerJoinEvent e) {
|
||||
Player p = e.getPlayer();
|
||||
e.setJoinMessage(null);
|
||||
|
||||
World w = Bukkit.getWorld(plugin.cfg.getString("Hub.Spawn.World"));
|
||||
double x = plugin.cfg.getDouble("Hub.Spawn.X");
|
||||
double y = plugin.cfg.getDouble("Hub.Spawn.Y");
|
||||
double z = plugin.cfg.getDouble("Hub.Spawn.Z");
|
||||
float yaw = (float) plugin.cfg.getDouble("Hub.Spawn.Yaw");
|
||||
float pitch = (float) plugin.cfg.getDouble("Hub.Spawn.Pitch");
|
||||
p.teleport(new Location(w, x, y, z, yaw, pitch));
|
||||
|
||||
p.setFlySpeed(0.1f);
|
||||
p.setAllowFlight(false);
|
||||
p.setFlying(false);
|
||||
p.setGameMode(GameMode.ADVENTURE);
|
||||
}
|
||||
}
|
14
src/main/resources/plugin.yml
Normal file
14
src/main/resources/plugin.yml
Normal file
|
@ -0,0 +1,14 @@
|
|||
name: CliffbreakCore
|
||||
version: 0.1
|
||||
main: de.cliffbreak.core.CliffbreakCore
|
||||
api-version: 1.14
|
||||
commands:
|
||||
gm:
|
||||
description: Change GameMode to creative or survival
|
||||
usage: /gm
|
||||
speed:
|
||||
description: Change FlyingSpeed
|
||||
usage: /speed
|
||||
hub:
|
||||
description: Default Hub Command
|
||||
usage: /hub
|
Loading…
Reference in a new issue