Skip to content
This repository has been archived by the owner on Nov 5, 2019. It is now read-only.

Now working in 1.13 #1347

Open
wants to merge 3 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions plugin.yml
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
main: ${project.groupId}.${project.name}
name: ${project.name}
api-version: 1.13
version: ${project.version}
website: ${project.url}
description: ${project.description}
Expand Down
4 changes: 2 additions & 2 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
<parent>
<groupId>com.massivecraft.massivesuper</groupId>
<artifactId>MassiveSuper</artifactId>
<version>2.14.1-SNAPSHOT</version>
<version>2.15.1-SNAPSHOT</version>
<relativePath>../MassiveSuper</relativePath>
</parent>

Expand Down Expand Up @@ -39,7 +39,7 @@
<!-- WorldGuard -->
<dependency>
<groupId>com.sk89q.worldguard</groupId>
<artifactId>worldguard-legacy</artifactId>
<artifactId>worldguard-bukkit</artifactId>
</dependency>
<!-- Vault -->
<dependency>
Expand Down
4 changes: 2 additions & 2 deletions src/com/massivecraft/factions/cmd/CmdFactionsSeeChunkOld.java
Original file line number Diff line number Diff line change
Expand Up @@ -68,8 +68,8 @@ public static void showPillar(Player player, World world, int blockX, int blockZ
{
Location loc = new Location(world, blockX, blockY, blockZ);
if (loc.getBlock().getType() != Material.AIR) continue;
int typeId = blockY % 5 == 0 ? Material.GLOWSTONE.getId() : Material.GLASS.getId();
VisualizeUtil.addLocation(player, loc, typeId);
Material type = blockY % 5 == 0 ? Material.GLOWSTONE : Material.GLASS;
VisualizeUtil.addLocation(player, loc, type);
}
}

Expand Down
26 changes: 18 additions & 8 deletions src/com/massivecraft/factions/engine/EngineExploit.java
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package com.massivecraft.factions.engine;

import com.massivecraft.factions.entity.MConf;
import com.massivecraft.factions.util.EnumerationUtil;
import com.massivecraft.massivecore.Engine;
import com.massivecraft.massivecore.collections.MassiveList;
import com.massivecraft.massivecore.ps.PS;
Expand Down Expand Up @@ -45,9 +46,9 @@ public void obsidianGenerators(BlockFromToEvent event)

// thanks to ObGenBlocker and WorldGuard for this method
Block block = event.getToBlock();
int source = event.getBlock().getTypeId();
int target = block.getTypeId();
if ((target == 55 || target == 132) && (source == 0 || source == 10 || source == 11))
Material source = event.getBlock().getType();
Material target = block.getType();
if ((target == Material.REDSTONE_WIRE || target == Material.TRIPWIRE) && (source == Material.AIR || source == Material.CAVE_AIR || source == Material.VOID_AIR || source == Material.LAVA))
{
block.setType(Material.AIR);
}
Expand All @@ -70,8 +71,8 @@ public void enderPearlClipping(PlayerTeleportEvent event)
// blocks who occupy less than 1 block width or length wise need to be handled differently
Material mat = event.getTo().getBlock().getType();
if (
((mat == Material.THIN_GLASS || mat == Material.IRON_FENCE) && clippingThrough(target, from, 0.65))
|| ((mat == Material.FENCE || mat == Material.NETHER_FENCE) && clippingThrough(target, from, 0.45))
((EnumerationUtil.isMaterialGlassPane(mat) || mat == Material.IRON_BARS) && clippingThrough(target, from, 0.65))
|| (EnumerationUtil.isMaterialFence(mat) && clippingThrough(target, from, 0.45))
)
{
event.setTo(from);
Expand Down Expand Up @@ -123,9 +124,18 @@ public void tntWaterlog(EntityExplodeEvent event)
targets.add(center.getRelative(-1, 0, 0));
for (Block target : targets)
{
int id = target.getTypeId();
Material type = target.getType();
// ignore air, bedrock, water, lava, obsidian, enchanting table, etc.... too bad we can't get a blast resistance value through Bukkit yet
if (id != 0 && (id < 7 || id > 11) && id != 49 && id != 90 && id != 116 && id != 119 && id != 120 && id != 130)
if (type != Material.AIR && type != Material.CAVE_AIR && type != Material.VOID_AIR
&& type != Material.BEDROCK
&& type != Material.WATER
&& type != Material.LAVA
&& type != Material.OBSIDIAN
&& type != Material.NETHER_PORTAL
&& type != Material.ENCHANTING_TABLE
&& type != Material.END_PORTAL
&& type != Material.END_PORTAL_FRAME
&& type != Material.ENDER_CHEST)
{
target.breakNaturally();
}
Expand Down Expand Up @@ -240,7 +250,7 @@ public static List<Block> getPortal(Block from)
{
for (int z = -(NETHER_TRAP_RADIUS_CHECK); z <= NETHER_TRAP_RADIUS_CHECK; z ++)
{
if (from.getRelative(x, y, z).getType() == Material.PORTAL) ret.add(from.getRelative(x, y, z));
if (from.getRelative(x, y, z).getType() == Material.NETHER_PORTAL) ret.add(from.getRelative(x, y, z));
}
}
}
Expand Down
6 changes: 6 additions & 0 deletions src/com/massivecraft/factions/entity/MConf.java
Original file line number Diff line number Diff line change
Expand Up @@ -542,6 +542,12 @@ public MConf load(MConf that)

// Interacting with these materials placed in the terrain results in door toggling.
public BackstringSet<Material> materialsDoor = new BackstringSet<>(Material.class);

// Interacting with these materials placed in the terrain results in IDK.
public BackstringSet<Material> materialsGlassPane = new BackstringSet<>(Material.class);

// Interacting with these materials placed in the terrain results in IDK.
public BackstringSet<Material> materialsFence = new BackstringSet<>(Material.class);

// Interacting with these materials placed in the terrain results in opening a container.
public BackstringSet<Material> materialsContainer = new BackstringSet<>(Material.class);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,10 @@
import com.massivecraft.factions.event.EventFactionsChunksChange;
import com.massivecraft.massivecore.Engine;
import com.massivecraft.massivecore.ps.PS;
import com.sk89q.worldedit.BlockVector;
import com.sk89q.worldedit.bukkit.BukkitAdapter;
import com.sk89q.worldedit.math.BlockVector3;
import com.sk89q.worldguard.LocalPlayer;
import com.sk89q.worldguard.bukkit.WGBukkit;
import com.sk89q.worldguard.WorldGuard;
import com.sk89q.worldguard.bukkit.WorldGuardPlugin;
import com.sk89q.worldguard.protection.managers.RegionManager;
import com.sk89q.worldguard.protection.regions.GlobalProtectedRegion;
Expand Down Expand Up @@ -46,7 +47,7 @@ public void setActiveInner(boolean active)
{
if (active)
{
this.worldGuard = WGBukkit.getPlugin();
this.worldGuard = WorldGuardPlugin.inst();
}
else
{
Expand Down Expand Up @@ -119,11 +120,11 @@ public List<ProtectedRegion> getProtectedRegionsFor(PS ps)

int worldHeight = ps.asBukkitWorld().getMaxHeight();

BlockVector minChunk = new BlockVector(minChunkX, 0, minChunkZ);
BlockVector maxChunk = new BlockVector(maxChunkX, worldHeight, maxChunkZ);

RegionManager regionManager = this.worldGuard.getRegionManager(ps.asBukkitWorld());
BlockVector3 minChunk = BlockVector3.at(minChunkX, 0, minChunkZ);
BlockVector3 maxChunk = BlockVector3.at(maxChunkX, worldHeight, maxChunkZ);

RegionManager regionManager = WorldGuard.getInstance().getPlatform().getRegionContainer().get(BukkitAdapter.adapt(ps.asBukkitWorld()));

String regionName = "factions_temp";
ProtectedCuboidRegion region = new ProtectedCuboidRegion(regionName, minChunk, maxChunk);

Expand Down
56 changes: 56 additions & 0 deletions src/com/massivecraft/factions/util/EnumerationUtil.java
Original file line number Diff line number Diff line change
Expand Up @@ -81,6 +81,62 @@ public static boolean isMaterialDoor(Material material)
{
return MATERIALS_DOOR.contains(material) || MConf.get().materialsDoor.contains(material);
}

// -------------------------------------------- //
// MATERIAL GLASS_PANE
// -------------------------------------------- //

// Interacting with these materials placed in the terrain results in door toggling.
public static final BackstringSet<Material> MATERIALS_GLASS_PANE = new BackstringSet<>(Material.class,
Material.GLASS_PANE,
Material.BLACK_STAINED_GLASS_PANE,
Material.BLUE_STAINED_GLASS_PANE,
Material.BROWN_STAINED_GLASS_PANE,
Material.CYAN_STAINED_GLASS_PANE,
Material.GRAY_STAINED_GLASS_PANE,
Material.GREEN_STAINED_GLASS_PANE,
Material.LIGHT_BLUE_STAINED_GLASS_PANE,
Material.LIGHT_GRAY_STAINED_GLASS_PANE,
Material.LIME_STAINED_GLASS_PANE,
Material.MAGENTA_STAINED_GLASS_PANE,
Material.ORANGE_STAINED_GLASS_PANE,
Material.PINK_STAINED_GLASS_PANE,
Material.PURPLE_STAINED_GLASS_PANE,
Material.RED_STAINED_GLASS_PANE,
Material.WHITE_STAINED_GLASS_PANE
);

public static boolean isMaterialGlassPane(Material material)
{
return MATERIALS_GLASS_PANE.contains(material) || MConf.get().materialsGlassPane.contains(material);
}

// -------------------------------------------- //
// MATERIAL FENCE
// -------------------------------------------- //

// Interacting with these materials placed in the terrain results in door toggling.
public static final BackstringSet<Material> MATERIALS_FENCE = new BackstringSet<>(Material.class,
Material.NETHER_BRICK_FENCE,
Material.ACACIA_FENCE,
Material.BIRCH_FENCE,
Material.DARK_OAK_FENCE,
Material.JUNGLE_FENCE,
Material.OAK_FENCE,
Material.SPRUCE_FENCE,
Material.COBBLESTONE_WALL,
Material.MOSSY_COBBLESTONE_WALL,
Material.ACACIA_FENCE_GATE,
Material.BIRCH_FENCE_GATE,
Material.DARK_OAK_FENCE_GATE,
Material.JUNGLE_FENCE_GATE,
Material.OAK_FENCE_GATE
);

public static boolean isMaterialFence(Material material)
{
return MATERIALS_FENCE.contains(material) || MConf.get().materialsFence.contains(material);
}

// -------------------------------------------- //
// MATERIAL CONTAINER
Expand Down
23 changes: 12 additions & 11 deletions src/com/massivecraft/factions/util/VisualizeUtil.java
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package com.massivecraft.factions.util;

import org.bukkit.Location;
import org.bukkit.Material;
import org.bukkit.block.Block;
import org.bukkit.entity.Player;

Expand Down Expand Up @@ -39,54 +40,54 @@ public static Set<Location> getPlayerLocations(UUID uuid)
// -------------------------------------------- //

@SuppressWarnings("deprecation")
public static void addLocation(Player player, Location location, int typeId, byte data)
public static void addLocation(Player player, Location location, Material type, byte data)
{
getPlayerLocations(player).add(location);
player.sendBlockChange(location, typeId, data);
player.sendBlockChange(location, type, data);
}

@SuppressWarnings("deprecation")
public static void addLocation(Player player, Location location, int typeId)
public static void addLocation(Player player, Location location, Material type)
{
getPlayerLocations(player).add(location);
player.sendBlockChange(location, typeId, (byte) 0);
player.sendBlockChange(location, type, (byte) 0);
}

// -------------------------------------------- //
// MANY
// -------------------------------------------- //

@SuppressWarnings("deprecation")
public static void addLocations(Player player, Map<Location, Integer> locationMaterialIds)
public static void addLocations(Player player, Map<Location, Material> locationMaterials)
{
Set<Location> ploc = getPlayerLocations(player);
for (Entry<Location, Integer> entry : locationMaterialIds.entrySet())
for (Entry<Location, Material> entry : locationMaterials.entrySet())
{
ploc.add(entry.getKey());
player.sendBlockChange(entry.getKey(), entry.getValue(), (byte) 0);
}
}

@SuppressWarnings("deprecation")
public static void addLocations(Player player, Collection<Location> locations, int typeId)
public static void addLocations(Player player, Collection<Location> locations, Material type)
{
Set<Location> ploc = getPlayerLocations(player);
for (Location location : locations)
{
ploc.add(location);
player.sendBlockChange(location, typeId, (byte) 0);
player.sendBlockChange(location, type, (byte) 0);
}
}

@SuppressWarnings("deprecation")
public static void addBlocks(Player player, Collection<Block> blocks, int typeId)
public static void addBlocks(Player player, Collection<Block> blocks, Material type)
{
Set<Location> ploc = getPlayerLocations(player);
for (Block block : blocks)
{
Location location = block.getLocation();
ploc.add(location);
player.sendBlockChange(location, typeId, (byte) 0);
player.sendBlockChange(location, type, (byte) 0);
}
}

Expand All @@ -102,7 +103,7 @@ public static void clear(Player player)
for (Location location : locations)
{
Block block = location.getWorld().getBlockAt(location);
player.sendBlockChange(location, block.getTypeId(), block.getData());
player.sendBlockChange(location, block.getType(), block.getData());
}
locations.clear();
}
Expand Down