Skip to content
Permalink
Browse files

Bump API to 1.15.1

THIS WILL NOT WORK ON EARLIER VERSIONS. IT SHOULD IMPROVE 1.15 COMPATIBILITY THOUGH.
  • Loading branch information
me4502 committed Jan 1, 2020
1 parent 543ec70 commit f5ca0941283136e32ee3cb988b28e2d69bc1f1bf
@@ -93,9 +93,9 @@ allprojects {
}

dependencies {
compile 'com.destroystokyo.paper:paper-api:1.13.2-R0.1-SNAPSHOT'
compile 'com.sk89q.worldedit:worldedit-core:7.0.0-SNAPSHOT'
compile 'com.sk89q.worldedit:worldedit-bukkit:7.0.0-SNAPSHOT'
compile 'com.destroystokyo.paper:paper-api:1.15.1-R0.1-SNAPSHOT'
compile 'com.sk89q.worldedit:worldedit-core:7.1.0-SNAPSHOT'
compile 'com.sk89q.worldedit:worldedit-bukkit:7.1.0-SNAPSHOT'
compile 'com.sk89q.worldguard:worldguard-core:7.0.0-SNAPSHOT'
compile 'com.sk89q.worldguard:worldguard-legacy:7.0.0-SNAPSHOT'
compile "io.papermc:paperlib:1.0.2"
@@ -1,20 +1,18 @@
package com.me4502.util;

import java.io.File;
import java.io.IOException;
import java.io.PrintWriter;
import java.util.Arrays;
import java.util.Map;
import java.util.logging.Level;
import java.util.regex.Matcher;

import com.sk89q.craftbook.CraftBookMechanic;
import com.sk89q.craftbook.bukkit.CraftBookPlugin;
import com.sk89q.craftbook.util.RegexUtil;
import com.sk89q.craftbook.util.developer.ExternalUtilityBase;
import com.sk89q.util.yaml.YAMLProcessor;
import org.bukkit.Bukkit;

import java.io.File;
import java.io.IOException;
import java.io.PrintWriter;
import java.util.Map;
import java.util.logging.Level;

public class GenerateWikiConfigLists extends ExternalUtilityBase {

public GenerateWikiConfigLists (String[] args) {
@@ -2,40 +2,30 @@

import static com.me4502.util.GenerateWikiConfigLists.createStringOfLength;

import java.io.BufferedReader;
import java.io.File;
import java.io.FileReader;
import java.io.IOException;
import java.io.PrintWriter;
import java.util.ArrayList;
import java.util.HashSet;
import java.util.List;
import java.util.Map;
import java.util.Set;

import javax.security.auth.login.LoginException;

import com.sk89q.craftbook.bukkit.util.CraftBookBukkitUtil;
import com.sk89q.worldedit.bukkit.BukkitAdapter;
import org.apache.commons.lang.StringUtils;
import org.bukkit.Bukkit;
import org.bukkit.Material;
import org.bukkit.block.BlockState;
import org.wikipedia.Wiki;

import com.sk89q.craftbook.bukkit.CraftBookPlugin;
import com.sk89q.craftbook.bukkit.util.CraftBookBukkitUtil;
import com.sk89q.craftbook.mechanics.ic.ChipState;
import com.sk89q.craftbook.mechanics.ic.CommandIC;
import com.sk89q.craftbook.mechanics.ic.ConfigurableIC;
import com.sk89q.craftbook.mechanics.ic.IC;
import com.sk89q.craftbook.mechanics.ic.ICConfiguration;
import com.sk89q.craftbook.mechanics.ic.ICFamily;
import com.sk89q.craftbook.mechanics.ic.ICManager;
import com.sk89q.craftbook.mechanics.ic.RegisteredICFactory;
import com.sk89q.craftbook.mechanics.ic.families.FamilyAISO;
import com.sk89q.craftbook.util.developer.ExternalUtilityBase;
import com.sk89q.util.yaml.YAMLFormat;
import com.sk89q.util.yaml.YAMLProcessor;
import com.sk89q.worldedit.bukkit.BukkitAdapter;
import org.apache.commons.lang.StringUtils;
import org.bukkit.Bukkit;
import org.bukkit.Material;
import org.bukkit.block.BlockState;

import java.io.File;
import java.io.IOException;
import java.io.PrintWriter;
import java.util.HashSet;
import java.util.Map;
import java.util.Set;

public class GenerateWikiICPages extends ExternalUtilityBase {

@@ -51,7 +41,7 @@ public void generate(String[] args) {
file.mkdir();

BlockState oldState = Bukkit.getWorlds().get(0).getBlockAt(0, 255, 0).getState();
Bukkit.getWorlds().get(0).getBlockAt(0, 255, 0).setType(Material.WALL_SIGN);
Bukkit.getWorlds().get(0).getBlockAt(0, 255, 0).setType(Material.OAK_WALL_SIGN);

CraftBookPlugin.inst().createDefaultConfiguration(new File(getGenerationFolder(), "ic-config.yml"), "ic-config.yml");
ICConfiguration icConfiguration = new ICConfiguration(new YAMLProcessor(new File(getGenerationFolder(), "ic-config.yml"), true, YAMLFormat.EXTENDED), CraftBookPlugin.logger());
@@ -1,22 +1,22 @@
package com.sk89q.craftbook.mechanics;

import com.sk89q.craftbook.bukkit.util.CraftBookBukkitUtil;
import org.bukkit.block.Block;
import org.bukkit.block.BlockState;
import org.bukkit.block.Sign;
import org.bukkit.event.EventHandler;
import org.bukkit.event.EventPriority;
import org.bukkit.event.block.SignChangeEvent;
import org.bukkit.event.world.ChunkUnloadEvent;

import com.sk89q.craftbook.AbstractCraftBookMechanic;
import com.sk89q.craftbook.ChangedSign;
import com.sk89q.craftbook.CraftBookPlayer;
import com.sk89q.craftbook.bukkit.CraftBookPlugin;
import com.sk89q.craftbook.bukkit.util.CraftBookBukkitUtil;
import com.sk89q.craftbook.util.EventUtil;
import com.sk89q.craftbook.util.SignUtil;
import com.sk89q.craftbook.util.events.SourcedBlockRedstoneEvent;
import com.sk89q.util.yaml.YAMLProcessor;
import org.bukkit.Chunk;
import org.bukkit.block.Block;
import org.bukkit.block.BlockState;
import org.bukkit.block.Sign;
import org.bukkit.event.EventHandler;
import org.bukkit.event.EventPriority;
import org.bukkit.event.block.SignChangeEvent;
import org.bukkit.event.world.ChunkLoadEvent;

public class ChunkAnchor extends AbstractCraftBookMechanic {

@@ -51,6 +51,13 @@ public void onSignChange(SignChangeEvent event) {
lplayer.print("mech.anchor.create");
}

@EventHandler
public void onChunkLoad(ChunkLoadEvent event) {
if (!EventUtil.passesFilter(event)) return;

updateChunkTicket(event.getChunk());
}

@EventHandler
public void onBlockRedstoneChange(SourcedBlockRedstoneEvent event) {

@@ -65,38 +72,30 @@ public void onBlockRedstoneChange(SourcedBlockRedstoneEvent event) {

sign.setLine(3, event.getNewCurrent() > event.getOldCurrent() ? "on" : "off");
sign.update(false);

updateChunkTicket(event.getBlock().getChunk());
}
}

@EventHandler(priority = EventPriority.LOWEST)
public void onUnload(final ChunkUnloadEvent event) {

if(!EventUtil.passesFilter(event)) return;

try {
boolean isOn = false;
boolean foundSign = false;
private void updateChunkTicket(Chunk chunk) {
boolean shouldAnchor = false;

for(BlockState state : event.getChunk().getTileEntities()) {
if(state == null) continue;
if(state instanceof Sign) {
if(((Sign) state).getLine(1).equals("[Chunk]")) {
foundSign = true;
isOn = !((Sign) state).getLine(3).equalsIgnoreCase("off");
for(BlockState state : chunk.getTileEntities()) {
if(state == null) continue;
if(state instanceof Sign) {
if(((Sign) state).getLine(1).equals("[Chunk]")) {
if (!allowRedstone || !((Sign) state).getLine(3).equalsIgnoreCase("off")) {
shouldAnchor = true;
break;
}
}
}
}

if (!foundSign) return;
if (!isOn && allowRedstone) return;
event.setCancelled(true);
CraftBookPlugin.inst().getServer().getScheduler().runTaskLater(CraftBookPlugin.inst(),
() -> event.getWorld().loadChunk(event.getChunk().getX(), event.getChunk().getZ(), true), 2L);
} catch(Throwable t) {
CraftBookPlugin.logger().warning("A chunk failed to be kept in memory. Is the chunk corrupt? (X:" + event.getChunk().getX() + ", Z:" + event.getChunk().getZ() + ")");
if(CraftBookPlugin.inst().getConfiguration().debugMode)
CraftBookBukkitUtil.printStacktrace(t);
if (shouldAnchor) {
chunk.addPluginChunkTicket(CraftBookPlugin.inst());
} else {
chunk.removePluginChunkTicket(CraftBookPlugin.inst());
}
}

@@ -3,6 +3,7 @@
import com.sk89q.craftbook.bukkit.CraftBookPlugin;
import org.bukkit.Location;
import org.bukkit.Material;
import org.bukkit.Tag;
import org.bukkit.block.Block;
import org.bukkit.block.BlockFace;
import org.bukkit.block.data.BlockData;
@@ -63,20 +64,18 @@ public static boolean isBlockReplacable(Material id) {
}

public static boolean hasTileData(Material material) {

switch(material) {

case CHEST:
case FURNACE:
case BREWING_STAND:
case DISPENSER:
case DROPPER:
case HOPPER:
case SIGN:
case TRAPPED_CHEST:
case BARREL:
return true;
default:
return false;
return Tag.SIGNS.isTagged(material) || Tag.SHULKER_BOXES.isTagged(material);
}
}

@@ -10,11 +10,29 @@
import org.bukkit.Location;
import org.bukkit.attribute.Attribute;
import org.bukkit.block.Block;
import org.bukkit.block.BlockState;
import org.bukkit.entity.*;
import org.bukkit.entity.Ageable;
import org.bukkit.entity.Arrow;
import org.bukkit.entity.ChestedHorse;
import org.bukkit.entity.Creeper;
import org.bukkit.entity.Damageable;
import org.bukkit.entity.Enderman;
import org.bukkit.entity.Entity;
import org.bukkit.entity.Horse;
import org.bukkit.entity.Horse.Color;
import org.bukkit.entity.Horse.Style;
import org.bukkit.material.MaterialData;
import org.bukkit.entity.LivingEntity;
import org.bukkit.entity.MagmaCube;
import org.bukkit.entity.Minecart;
import org.bukkit.entity.Ocelot;
import org.bukkit.entity.Pig;
import org.bukkit.entity.PigZombie;
import org.bukkit.entity.Sheep;
import org.bukkit.entity.Slime;
import org.bukkit.entity.TNTPrimed;
import org.bukkit.entity.Tameable;
import org.bukkit.entity.ThrownExpBottle;
import org.bukkit.entity.Villager;
import org.bukkit.entity.Wolf;

import java.util.ArrayList;
import java.util.List;
@@ -262,10 +280,12 @@ public static void setEntityData(Entity ent, String bit) {
case VILLAGER:
if (data[0].equalsIgnoreCase("butcher")) {
((Villager) ent).setProfession(Villager.Profession.BUTCHER);
} else if (data[0].equalsIgnoreCase("smith")) {
((Villager) ent).setProfession(Villager.Profession.BLACKSMITH);
} else if (data[0].equalsIgnoreCase("toolsmith")) {
((Villager) ent).setProfession(Villager.Profession.TOOLSMITH);
} else if (data[0].equalsIgnoreCase("wepsmith") || data[0].equalsIgnoreCase("smith")) {
((Villager) ent).setProfession(Villager.Profession.WEAPONSMITH);
} else if (data[0].equalsIgnoreCase("priest")) {
((Villager) ent).setProfession(Villager.Profession.PRIEST);
((Villager) ent).setProfession(Villager.Profession.CLERIC);
} else if (data[0].equalsIgnoreCase("library")) {
((Villager) ent).setProfession(Villager.Profession.LIBRARIAN);
} else if (data[0].equalsIgnoreCase("farmer")) {
@@ -501,7 +501,7 @@ public static ItemStack getSmeletedResult(ItemStack item) {
case COBBLESTONE:
return new ItemStack(Material.STONE);
case CACTUS:
return new ItemStack(Material.CACTUS_GREEN);
return new ItemStack(Material.GREEN_DYE);
case IRON_ORE:
return new ItemStack(Material.IRON_INGOT);
case COAL_ORE:
@@ -697,7 +697,6 @@ public static boolean isAFuel(ItemStack item) {
case BIRCH_FENCE_GATE:
case ACACIA_FENCE_GATE:
case DARK_OAK_FENCE_GATE:
case SIGN:
case FISHING_ROD:
case BOW:
case LADDER:
@@ -715,7 +714,8 @@ public static boolean isAFuel(ItemStack item) {
|| Tag.WOODEN_SLABS.isTagged(item.getType())
|| Tag.SAPLINGS.isTagged(item.getType())
|| Tag.WOOL.isTagged(item.getType())
|| Tag.WOODEN_PRESSURE_PLATES.isTagged(item.getType());
|| Tag.WOODEN_PRESSURE_PLATES.isTagged(item.getType())
|| Tag.SIGNS.isTagged(item.getType());
}
}

@@ -17,9 +17,7 @@
package com.sk89q.craftbook.util;

import com.sk89q.craftbook.bukkit.util.CraftBookBukkitUtil;
import com.sk89q.worldedit.bukkit.BukkitAdapter;
import com.sk89q.worldedit.world.block.BlockCategory;
import org.bukkit.Material;
import org.bukkit.Tag;
import org.bukkit.block.Block;
import org.bukkit.block.BlockFace;
import org.bukkit.block.data.BlockData;
@@ -54,35 +52,16 @@
*/
public final class SignUtil {

private static BlockCategory SIGNS_CATEGORY;
private static BlockCategory STANDING_SIGNS_CATEGORY;
private static BlockCategory WALL_SIGNS_CATEGORY;

static {
SIGNS_CATEGORY = BlockCategory.REGISTRY.get("minecraft:signs");
STANDING_SIGNS_CATEGORY = BlockCategory.REGISTRY.get("minecraft:standing_signs");
WALL_SIGNS_CATEGORY = BlockCategory.REGISTRY.get("minecraft:wall_signs");
}

public static boolean isSign(Block block) {
if (SIGNS_CATEGORY != null) {
return SIGNS_CATEGORY.contains(BukkitAdapter.asBlockType(block.getType()));
}
return isStandingSign(block) || isWallSign(block);
}

public static boolean isStandingSign(Block block) {
if (STANDING_SIGNS_CATEGORY != null) {
return STANDING_SIGNS_CATEGORY.contains(BukkitAdapter.asBlockType(block.getType()));
}
return block.getType() == Material.SIGN;
return Tag.STANDING_SIGNS.isTagged(block.getType());
}

public static boolean isWallSign(Block block) {
if (WALL_SIGNS_CATEGORY != null) {
return WALL_SIGNS_CATEGORY.contains(BukkitAdapter.asBlockType(block.getType()));
}
return block.getType() == Material.WALL_SIGN;
return Tag.WALL_SIGNS.isTagged(block.getType());
}

/**
@@ -56,15 +56,6 @@ public void testIsBlockReplacable() {
assertTrue(BlockUtil.isBlockReplacable(Material.AIR));
}

@Test
public void testHasTileData() {

assertTrue(!BlockUtil.hasTileData(Material.STONE));
assertTrue(BlockUtil.isBlockReplacable(Material.WATER));
assertTrue(BlockUtil.isBlockReplacable(Material.LAVA));
assertTrue(BlockUtil.isBlockReplacable(Material.AIR));
}

@Test
public void testGetBlockCentre() {

0 comments on commit f5ca094

Please sign in to comment.
You can’t perform that action at this time.