Simplify plugin

This commit is contained in:
mathias 2018-10-01 16:38:38 +03:00
parent 1745cd83bf
commit f69143812d
5 changed files with 34 additions and 105 deletions

View file

@ -11,6 +11,11 @@
<version>1.12.2-R0.1-SNAPSHOT</version>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>com.sk89q.worldedit</groupId>
<artifactId>worldedit-bukkit</artifactId>
<version>6.1.1-SNAPSHOT</version>
</dependency>
</dependencies>
<repositories>
@ -18,6 +23,10 @@
<id>destroystokyo-repo</id>
<url>https://repo.destroystokyo.com/repository/maven-public/</url>
</repository>
<repository>
<id>sk89q-snapshots</id>
<url>http://maven.sk89q.com/artifactory/repo</url>
</repository>
</repositories>
<build>

View file

@ -114,15 +114,6 @@ class CommandEnchantAll implements CommandExecutor {
}
}
class CommandEnd implements CommandExecutor {
public boolean onCommand(CommandSender sender, Command command, String label, String[] args) {
Player player = (Player)sender;
player.teleport(Bukkit.getWorld("world_the_end").getSpawnLocation());
player.sendMessage("Successfully moved to the End");
return true;
}
}
class CommandJumpscare implements CommandExecutor {
private void createJumpscare(Player player) {
player.spawnParticle(Particle.MOB_APPEARANCE, player.getLocation(), 4);
@ -155,24 +146,6 @@ class CommandJumpscare implements CommandExecutor {
}
}
class CommandNether implements CommandExecutor {
public boolean onCommand(CommandSender sender, Command command, String label, String[] args) {
Player player = (Player)sender;
player.teleport(Bukkit.getWorld("world_nether").getSpawnLocation());
player.sendMessage("Successfully moved to the Nether");
return true;
}
}
class CommandOverworld implements CommandExecutor {
public boolean onCommand(CommandSender sender, Command command, String label, String[] args) {
Player player = (Player)sender;
player.teleport(new Location(Bukkit.getWorld("world"), 0.5, 100, 0.5));
player.sendMessage("Successfully moved to the Overworld");
return true;
}
}
class CommandPrefix implements CommandExecutor {
Main main;
CommandPrefix(Main main) {
@ -250,15 +223,3 @@ class CommandUsername implements CommandExecutor {
return true;
}
}
class CommandVote implements CommandExecutor {
public boolean onCommand(CommandSender sender, Command command, String label, String[] args) {
Player player = (Player)sender;
player.sendMessage("Feel free to vote for the server to help it grow");
Bukkit.getServer().dispatchCommand(Bukkit.getConsoleSender(), "minecraft:tellraw " + player.getName() + " [\"\",{\"text\":\"[1] \",\"color\":\"dark_green\"},{\"text\":\"TopG.org\",\"color\":\"green\",\"clickEvent\":{\"action\":\"open_url\",\"value\":\"https://topg.org/Minecraft/in-414108\"}}]");
Bukkit.getServer().dispatchCommand(Bukkit.getConsoleSender(), "minecraft:tellraw " + player.getName() + " [\"\",{\"text\":\"[2] \",\"color\":\"dark_green\"},{\"text\":\"MinecraftServers.biz\",\"color\":\"green\",\"clickEvent\":{\"action\":\"open_url\",\"value\":\"https://minecraftservers.biz/servers/140916/\"}}]");
Bukkit.getServer().dispatchCommand(Bukkit.getConsoleSender(), "minecraft:tellraw " + player.getName() + " [\"\",{\"text\":\"[3] \",\"color\":\"dark_green\"},{\"text\":\"MinecraftServers.org\",\"color\":\"green\",\"clickEvent\":{\"action\":\"open_url\",\"value\":\"http://minecraftservers.org/vote/153833\"}}]");
Bukkit.getServer().dispatchCommand(Bukkit.getConsoleSender(), "minecraft:tellraw " + player.getName() + " [\"\",{\"text\":\"[4] \",\"color\":\"dark_green\"},{\"text\":\"Minecraft Multiplayer\",\"color\":\"green\",\"clickEvent\":{\"action\":\"open_url\",\"value\":\"http://minecraft-mp.com/server/155223/vote/\"}}]");
return true;
}
}

View file

@ -5,8 +5,6 @@ import java.util.Iterator;
import com.destroystokyo.paper.event.entity.EntityAddToWorldEvent;
import com.boydti.fawe.FaweAPI;
import org.bukkit.Bukkit;
import org.bukkit.ChatColor;
import org.bukkit.Chunk;
@ -60,6 +58,30 @@ import org.bukkit.scheduler.BukkitRunnable;
import org.spigotmc.event.player.PlayerSpawnLocationEvent;
import com.sk89q.worldedit.EditSession;
import com.sk89q.worldedit.Vector;
import com.sk89q.worldedit.WorldEdit;
import com.sk89q.worldedit.bukkit.BukkitWorld;
import com.sk89q.worldedit.schematic.SchematicFormat;
class PasteSpawn extends BukkitRunnable {
public void run() {
File file = new File("worlds/world/spawn.schematic");
boolean noAir = false;
boolean entities = false;
BukkitWorld world = new BukkitWorld(Bukkit.getServer().getWorld("world"));
EditSession editSession = WorldEdit.getInstance().getEditSessionFactory().getEditSession(world, -1);
Vector position = new Vector(0, 100, 0);
try {
SchematicFormat.getFormat(file).load(file).paste(editSession, position, noAir, entities);
editSession.flushQueue();
} catch(Exception exception) {
exception.printStackTrace();
}
}
}
class Tick extends BukkitRunnable {
public void run() {
for (World world : Bukkit.getServer().getWorlds()) {
@ -69,25 +91,6 @@ class Tick extends BukkitRunnable {
} else if (worldborder.getCenter().getX() != 0 || worldborder.getCenter().getZ() != 0) {
worldborder.setCenter(0, 0);
}
/*String tickSpeed = world.getGameRuleValue("randomTickSpeed");
if (Integer.parseInt(tickSpeed) > 10) {
world.setGameRuleValue("randomTickSpeed", "10");
}*/
}
}
}
class Update extends BukkitRunnable {
public void run() {
File file = new File("worlds/world/spawn.schematic");
boolean allowUndo = false;
boolean noAir = false;
Vector position = new Vector(0, 100, 0);
try {
EditSession editSession = ClipboardFormat.SCHEMATIC.load(file).paste(FaweAPI.getWorld("world"), position, allowUndo, !noAir, (Transform) null);
} catch(Exception exception) {
exception.printStackTrace();
}
}
}
@ -280,34 +283,6 @@ class Events implements Listener {
if (followAttribute.getBaseValue() > 32) {
followAttribute.setBaseValue(32);
}
/*System.out.println(String.valueOf("begin"));
if (mob.getAttribute(Attribute.GENERIC_ARMOR) != null) {
System.out.println("ARMOR " + String.valueOf(mob.getAttribute(Attribute.GENERIC_ARMOR).getBaseValue()));
} else if (mob.getAttribute(Attribute.GENERIC_ARMOR_TOUGHNESS) != null) {
System.out.println("ARMOR_TOUGHNESS " + String.valueOf(mob.getAttribute(Attribute.GENERIC_ARMOR_TOUGHNESS).getBaseValue()));
} else if (mob.getAttribute(Attribute.GENERIC_ATTACK_DAMAGE) != null) {
System.out.println("ATTACK_DAMAGE " + String.valueOf(mob.getAttribute(Attribute.GENERIC_ATTACK_DAMAGE).getBaseValue()));
} else if (mob.getAttribute(Attribute.GENERIC_ATTACK_SPEED) != null) {
System.out.println("ATTACK_SPEED " + String.valueOf(mob.getAttribute(Attribute.GENERIC_ATTACK_SPEED).getBaseValue()));
} else if (mob.getAttribute(Attribute.GENERIC_FLYING_SPEED) != null) {
System.out.println("FLYING_SPEED " + String.valueOf(mob.getAttribute(Attribute.GENERIC_FLYING_SPEED).getBaseValue()));
} else if (mob.getAttribute(Attribute.GENERIC_FOLLOW_RANGE) != null) {
System.out.println("FOLLOW_RANGE " + String.valueOf(mob.getAttribute(Attribute.GENERIC_FOLLOW_RANGE).getBaseValue()));
} else if (mob.getAttribute(Attribute.GENERIC_KNOCKBACK_RESISTANCE) != null) {
System.out.println("KNOCKBACK_RESISTANCE " + String.valueOf(mob.getAttribute(Attribute.GENERIC_KNOCKBACK_RESISTANCE).getBaseValue()));
} else if (mob.getAttribute(Attribute.GENERIC_LUCK) != null) {
System.out.println("LUCK " + String.valueOf(mob.getAttribute(Attribute.GENERIC_LUCK).getBaseValue()));
} else if (mob.getAttribute(Attribute.GENERIC_MAX_HEALTH) != null) {
System.out.println("MAX_HEALTH " + String.valueOf(mob.getAttribute(Attribute.GENERIC_MAX_HEALTH).getBaseValue()));
} else if (mob.getAttribute(Attribute.GENERIC_MOVEMENT_SPEED) != null) {
System.out.println("MOVEMENT_SPEED " + String.valueOf(mob.getAttribute(Attribute.GENERIC_MOVEMENT_SPEED).getBaseValue()));
} else if (mob.getAttribute(Attribute.HORSE_JUMP_STRENGTH) != null) {
System.out.println("HORSE_JUMP_STRENGTH " + String.valueOf(mob.getAttribute(Attribute.HORSE_JUMP_STRENGTH).getBaseValue()));
} else if (mob.getAttribute(Attribute.ZOMBIE_SPAWN_REINFORCEMENTS) != null) {
System.out.println("ZOMBIE_SPAWN_REINFORCEMENTS " + String.valueOf(mob.getAttribute(Attribute.ZOMBIE_SPAWN_REINFORCEMENTS).getBaseValue()));
}
System.out.println(String.valueOf("end"));*/
}
@EventHandler

View file

@ -339,19 +339,15 @@ public class Main extends JavaPlugin {
this.getCommand("destroyentities").setExecutor(new CommandDestroyEntities());
this.getCommand("discord").setExecutor(new CommandDiscord());
this.getCommand("enchantall").setExecutor(new CommandEnchantAll());
this.getCommand("end").setExecutor(new CommandEnd());
this.getCommand("jumpscare").setExecutor(new CommandJumpscare());
this.getCommand("nether").setExecutor(new CommandNether());
this.getCommand("overworld").setExecutor(new CommandOverworld());
this.getCommand("prefix").setExecutor(new CommandPrefix(this));
this.getCommand("spawn").setExecutor(new CommandSpawn());
this.getCommand("tellraw").setExecutor(new CommandTellraw());
this.getCommand("unloadchunks").setExecutor(new CommandUnloadChunks());
this.getCommand("username").setExecutor(new CommandUsername());
this.getCommand("vote").setExecutor(new CommandVote());
new PasteSpawn().runTaskTimer(this, 0, 100);
new Tick().runTaskTimer(this, 0, 1);
new Update().runTaskTimer(this, 0, 200);
this.getServer().getPluginManager().registerEvents(new Events(this), this);
}
}

View file

@ -21,19 +21,10 @@ commands:
enchantall:
description: Adds every enchantment to a held item
permission: extras.enchantall
end:
description: Moves you to the End
permission: extras.end
jumpscare:
aliases: scare
description: Scares a player
permission: extras.jumpscare
nether:
description: Moves you to the Nether
permission: extras.nether
overworld:
description: Moves you to the Overworld
permission: extras.overworld
prefix:
aliases: [rank, tag]
description: Changes your tag
@ -50,6 +41,3 @@ commands:
username:
description: Changes your username on the server
permission: extras.username
vote:
description: Shows vote links for the server
permission: extras.vote