Add latest changes

This commit is contained in:
mathias 2018-10-01 16:05:37 +03:00
parent 71555ef96e
commit 1745cd83bf
4 changed files with 41 additions and 180 deletions

24
pom.xml
View file

@ -11,16 +11,6 @@
<version>1.12.2-R0.1-SNAPSHOT</version>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>com.boydti</groupId>
<artifactId>fawe-api</artifactId>
<version>latest</version>
</dependency>
<dependency>
<groupId>com.sk89q.worldedit</groupId>
<artifactId>worldedit-bukkit</artifactId>
<version>6.1.1-SNAPSHOT</version>
</dependency>
</dependencies>
<repositories>
@ -28,20 +18,6 @@
<id>destroystokyo-repo</id>
<url>https://repo.destroystokyo.com/repository/maven-public/</url>
</repository>
<repository>
<id>empcraft</id>
<url>http://ci.athion.net/job/FastAsyncWorldEdit/ws/mvn/</url>
</repository>
<repository>
<id>sk89q-snapshots</id>
<url>http://maven.sk89q.com/artifactory/repo</url>
<releases>
<enabled>true</enabled>
</releases>
<snapshots>
<enabled>true</enabled>
</snapshots>
</repository>
</repositories>
<build>

View file

@ -1,8 +1,5 @@
package pw.kaboom.extras;
import java.lang.reflect.Field;
import java.lang.reflect.Modifier;
import com.destroystokyo.paper.profile.PlayerProfile;
import org.bukkit.Bukkit;

View file

@ -5,8 +5,6 @@ import java.util.Iterator;
import com.destroystokyo.paper.event.entity.EntityAddToWorldEvent;
import com.destroystokyo.paper.profile.PlayerProfile;
import com.boydti.fawe.FaweAPI;
import org.bukkit.Bukkit;
@ -17,28 +15,24 @@ import org.bukkit.Location;
import org.bukkit.World;
import org.bukkit.WorldBorder;
import org.bukkit.block.Block;
import org.bukkit.attribute.Attribute;
import org.bukkit.attribute.AttributeInstance;
import org.bukkit.command.BlockCommandSender;
import org.bukkit.block.Block;
import org.bukkit.entity.Player;
import org.bukkit.entity.Entity;
import org.bukkit.entity.EntityType;
import org.bukkit.entity.LivingEntity;
import org.bukkit.entity.MagmaCube;
import org.bukkit.entity.Slime;
import org.bukkit.event.EventHandler;
import org.bukkit.event.Listener;
import org.bukkit.event.block.BlockBreakEvent;
import org.bukkit.event.block.BlockBurnEvent;
import org.bukkit.event.block.BlockDamageEvent;
import org.bukkit.event.block.BlockExplodeEvent;
import org.bukkit.event.block.BlockFadeEvent;
import org.bukkit.event.block.BlockFromToEvent;
import org.bukkit.event.block.BlockGrowEvent;
import org.bukkit.event.block.BlockPhysicsEvent;
import org.bukkit.event.block.BlockPlaceEvent;
import org.bukkit.event.block.BlockRedstoneEvent;
import org.bukkit.event.entity.EntityChangeBlockEvent;
@ -53,37 +47,19 @@ import org.bukkit.event.entity.PotionSplashEvent;
import org.bukkit.event.hanging.HangingPlaceEvent;
import org.bukkit.event.player.AsyncPlayerChatEvent;
import org.bukkit.event.player.PlayerPreLoginEvent;
import org.bukkit.event.player.PlayerBucketEmptyEvent;
import org.bukkit.event.player.PlayerChangedWorldEvent;
import org.bukkit.event.player.PlayerCommandPreprocessEvent;
import org.bukkit.event.player.PlayerJoinEvent;
import org.bukkit.event.player.PlayerKickEvent;
import org.bukkit.event.player.PlayerLoginEvent;
import org.bukkit.event.player.PlayerMoveEvent;
import org.bukkit.event.player.PlayerPortalEvent;
import org.bukkit.event.player.PlayerQuitEvent;
import org.bukkit.event.player.PlayerRespawnEvent;
import org.bukkit.event.player.PlayerTeleportEvent.TeleportCause;
import org.bukkit.event.server.ServerCommandEvent;
import org.bukkit.event.server.ServerListPingEvent;
import org.bukkit.permissions.PermissionAttachment;
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.event.extent.EditSessionEvent;
import com.sk89q.worldedit.extent.clipboard.io.ClipboardFormat;
import com.sk89q.worldedit.extent.logging.AbstractLoggingExtent;
import com.sk89q.worldedit.math.transform.Transform;
import com.sk89q.worldedit.util.eventbus.EventHandler.Priority;
import com.sk89q.worldedit.util.eventbus.Subscribe;
class Tick extends BukkitRunnable {
public void run() {
for (World world : Bukkit.getServer().getWorlds()) {
@ -104,7 +80,7 @@ class Tick extends BukkitRunnable {
class Update extends BukkitRunnable {
public void run() {
File file = new File("spawn.schematic");
File file = new File("worlds/world/spawn.schematic");
boolean allowUndo = false;
boolean noAir = false;
Vector position = new Vector(0, 100, 0);
@ -139,46 +115,6 @@ class Events implements Listener {
}
}
@EventHandler
void onBlockBreakEvent(BlockBreakEvent event) {
Block block = event.getBlock();
double x = block.getLocation().getX();
double z = block.getLocation().getZ();
if (block.getWorld().getName().equals("world")) {
if ((x > -20 && x < 20) && (z > -20 && z < 20)) {
event.setCancelled(true);
}
}
}
@EventHandler
void onBlockBurnEvent(BlockBurnEvent event) {
Block block = event.getBlock();
double x = block.getLocation().getX();
double z = block.getLocation().getZ();
if (block.getWorld().getName().equals("world")) {
if ((x > -20 && x < 20) && (z > -20 && z < 20)) {
event.setCancelled(true);
}
}
}
@EventHandler
void onBlockDamage(BlockDamageEvent event) {
Block block = event.getBlock();
double x = block.getLocation().getX();
double z = block.getLocation().getZ();
if (block.getWorld().getName().equals("world")) {
if ((x > -20 && x < 20) && (z > -20 && z < 20)) {
event.setCancelled(true);
}
}
}
@EventHandler
void onBlockExplode(BlockExplodeEvent event) {
Block block = event.getBlock();
@ -199,19 +135,6 @@ class Events implements Listener {
event.setYield(0);
}
@EventHandler
void onBlockFade(BlockFadeEvent event) {
Block block = event.getBlock();
double x = block.getLocation().getX();
double z = block.getLocation().getZ();
if (block.getWorld().getName().equals("world")) {
if ((x > -20 && x < 20) && (z > -20 && z < 20)) {
event.setCancelled(true);
}
}
}
@EventHandler
void onBlockFromTo(BlockFromToEvent event) {
Block block = event.getBlock();
@ -225,19 +148,6 @@ class Events implements Listener {
}
}
@EventHandler
void onBlockGrow(BlockGrowEvent event) {
Block block = event.getBlock();
double x = block.getLocation().getX();
double z = block.getLocation().getZ();
if (block.getWorld().getName().equals("world")) {
if ((x > -20 && x < 20) && (z > -20 && z < 20)) {
event.setCancelled(true);
}
}
}
@EventHandler
void onBlockPhysics(BlockPhysicsEvent event) {
Block block = event.getBlock();
@ -259,28 +169,11 @@ class Events implements Listener {
}
}
@EventHandler
void onBlockPlaceEvent(BlockPlaceEvent event) {
Block block = event.getBlock();
double x = block.getLocation().getX();
double z = block.getLocation().getZ();
if (block.getWorld().getName().equals("world")) {
if ((x > -20 && x < 20) && (z > -20 && z < 20)) {
event.setCancelled(true);
}
}
}
@EventHandler
void onBlockRedstone(BlockRedstoneEvent event) {
Block block = event.getBlock();
double x = block.getLocation().getX();
double z = block.getLocation().getZ();
double tps = Bukkit.getServer().getTPS()[0];
if (block.getWorld().getName().equals("world") && (x > -20 && x < 20) && (z > -20 && z < 20) ||
tps < 14) {
if (tps < 14) {
event.setNewCurrent(0);
}
}
@ -368,6 +261,7 @@ class Events implements Listener {
@EventHandler
void onEntitySpawn(EntitySpawnEvent event) {
Entity entity = event.getEntity();
LivingEntity mob = (LivingEntity) event.getEntity();
Location entityLocation = event.getLocation();
int onChunk = 0;
@ -380,6 +274,40 @@ class Events implements Listener {
if (onChunk >= 50) {
event.setCancelled(true);
}
AttributeInstance followAttribute = mob.getAttribute(Attribute.GENERIC_FOLLOW_RANGE);
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
@ -435,19 +363,6 @@ class Events implements Listener {
}
}
@EventHandler
void onPlayerBucketEmpty(PlayerBucketEmptyEvent event) {
Player player = event.getPlayer();
double x = player.getLocation().getX();
double z = player.getLocation().getZ();
if (player.getWorld().getName().equals("world")) {
if ((x > -20 && x < 20) && (z > -20 && z < 20)) {
event.setCancelled(true);
}
}
}
@EventHandler
void onPlayerCommandPreprocess(PlayerCommandPreprocessEvent event) {
String arr[] = event.getMessage().split(" ");
@ -546,18 +461,3 @@ class Events implements Listener {
event.setMaxPlayers(event.getNumPlayers() + 1);
}
}
class WorldEditEvent {
@Subscribe(priority = Priority.VERY_EARLY)
public void onEditSessionEvent(final EditSessionEvent event) {
event.setExtent(new AbstractLoggingExtent(event.getExtent()) {
private void onBlockChange(Vector position) {
double x = position.getBlockX();
double z = position.getBlockZ();
if (event.getWorld().getName().equals("world") && (x > -20 && x < 20) && (z > -20 && z < 20)) {
event.setCancelled(true);
}
}
});
}
}

View file

@ -1,20 +1,10 @@
package pw.kaboom.extras;
import java.util.Arrays;
import java.util.HashMap;
import java.util.HashSet;
import java.util.UUID;
import org.bukkit.WorldCreator;
import org.bukkit.entity.Player;
import org.bukkit.permissions.PermissionAttachment;
import org.bukkit.plugin.java.JavaPlugin;
import com.sk89q.worldedit.WorldEdit;
public class Main extends JavaPlugin {
HashSet<String> consoleCommandBlacklist = new HashSet<String>(Arrays.asList(new String[] {
"essentials:action",
@ -309,7 +299,6 @@ public class Main extends JavaPlugin {
"pm",
"shoutworld",
"say",
"setblock",
"silence",
"sp",
"spec",
@ -364,6 +353,5 @@ public class Main extends JavaPlugin {
new Tick().runTaskTimer(this, 0, 1);
new Update().runTaskTimer(this, 0, 200);
this.getServer().getPluginManager().registerEvents(new Events(this), this);
WorldEdit.getInstance().getEventBus().register(new WorldEditEvent());
}
}