Skip to content
Merged
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
19 changes: 17 additions & 2 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -6,14 +6,15 @@

<groupId>com.modnmetl</groupId>
<artifactId>virtualrealty</artifactId>
<version>2.6.0</version>
<version>2.8.0</version>
<packaging>jar</packaging>

<description>A plot creation and management plugin for Minecraft</description>

<properties>
<java.version>1.8</java.version>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<mainclass>com.modnmetl.virtualrealty.VirtualRealty</mainclass>
</properties>

<build>
Expand Down Expand Up @@ -76,6 +77,10 @@
</build>

<repositories>
<repository>
<id>plytki-repo</id>
<url>https://maven.pkg.github.com/plytki/base-api</url>
</repository>
<repository>
<id>spigot-repo</id>
<url>https://hub.spigotmc.org/nexus/content/repositories/snapshots/</url>
Expand Down Expand Up @@ -105,6 +110,10 @@
<url>https://repo.codemc.org/repository/maven-public/</url>
<layout>default</layout>
</repository>
<repository>
<id>Modrinth</id>
<url>https://api.modrinth.com/maven</url>
</repository>
</repositories>

<dependencies>
Expand Down Expand Up @@ -184,7 +193,7 @@
<dependency>
<groupId>de.tr7zw</groupId>
<artifactId>item-nbt-api</artifactId>
<version>2.12.1</version>
<version>2.13.1</version>
<scope>compile</scope>
</dependency>
<dependency>
Expand All @@ -193,6 +202,12 @@
<version>4.0.3</version>
<scope>compile</scope>
</dependency>
<!-- <dependency>-->
<!-- <groupId>maven.modrinth</groupId>-->
<!-- <artifactId>pl3xmap</artifactId>-->
<!-- <version>1.21-500</version>-->
<!-- <scope>provided</scope>-->
<!-- </dependency>-->
</dependencies>

</project>
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@
import com.modnmetl.virtualrealty.util.multiversion.VMaterial;
import com.modnmetl.virtualrealty.util.UpdateChecker;
import com.zaxxer.hikari.HikariDataSource;
import de.tr7zw.changeme.nbtapi.utils.MinecraftVersion;
import lombok.Getter;
import lombok.Setter;
import org.apache.commons.io.FileUtils;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -412,7 +412,7 @@ public List<String> onTabComplete(@NotNull CommandSender sender, @NotNull Comman
case "LEAVE": {
if (args.length == 2) {
String trim = finalArgs[1].trim();
PlotManager.getInstance().getMembershipPlots(player.getUniqueId()).forEach((integer, plot) -> {
PlotManager.getInstance().getAccessPlots(player.getUniqueId()).forEach((integer, plot) -> {
if (trim.isEmpty()) {
tabCompleter.add(String.valueOf(plot.getID()));
} else if (String.valueOf(plot.getID()).toLowerCase().startsWith(trim.toLowerCase())) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,12 @@
import com.modnmetl.virtualrealty.VirtualRealty;
import com.modnmetl.virtualrealty.commands.SubCommand;
import com.modnmetl.virtualrealty.exception.FailedCommandException;
import com.modnmetl.virtualrealty.manager.ConfirmationManager;
import com.modnmetl.virtualrealty.manager.PlotManager;
import com.modnmetl.virtualrealty.model.other.ChatMessage;
import com.modnmetl.virtualrealty.model.other.CommandType;
import com.modnmetl.virtualrealty.model.other.Confirmation;
import com.modnmetl.virtualrealty.model.other.ConfirmationType;
import com.modnmetl.virtualrealty.model.permission.ManagementPermission;
import com.modnmetl.virtualrealty.model.plot.Plot;
import com.modnmetl.virtualrealty.model.plot.PlotMember;
Expand Down Expand Up @@ -60,11 +63,38 @@ public void exec(CommandSender sender, Command command, String label, String[] a
}
PlotMember plotMember = plot.getMember(player.getUniqueId());
if (plot.getOwnedBy().equals(player.getUniqueId())) {
ChatMessage.of(VirtualRealty.getMessages().cantLeaveOwnPlot).sendWithPrefix(sender);
return;
for (String s : VirtualRealty.getMessages().leaveConfirmation) {
player.sendMessage(VirtualRealty.PREFIX + s.replaceAll("%plot_id%", String.valueOf(plotID)));
}
Confirmation confirmation = new Confirmation(ConfirmationType.PLOT_OWNER_LEAVE, player, "YES") {
@Override
public void success() {
ChatMessage.of(VirtualRealty.getMessages().plotLeave.replaceAll("%plot_id%", String.valueOf(plotID)))
.sendWithPrefix(sender);
plot.removeAllMembers();
plot.setAssignedBy(null);
plot.setOwnedBy(null);
plot.update();
ConfirmationManager.removeConfirmations(this.getConfirmationType());
}
@Override
public void failed() {
ChatMessage.of(VirtualRealty.getMessages().leaveConfirmationCancelled.replaceAll("%plot_id%", String.valueOf(plotID)))
.sendWithPrefix(sender);
ConfirmationManager.removeConfirmations(this.getConfirmationType());
}
@Override
public void expiry() {
ChatMessage.of(VirtualRealty.getMessages().confirmationExpired.replaceAll("%plot_id%", String.valueOf(plotID)))
.sendWithPrefix(sender);
ConfirmationManager.removeConfirmations(this.getConfirmationType());
}
};
ConfirmationManager.addConfirmation(confirmation);
} else {
plot.removeMember(plotMember);
ChatMessage.of(VirtualRealty.getMessages().plotLeave.replaceAll("%plot_id%", String.valueOf(plot.getID()))).sendWithPrefix(sender);
}
plot.removeMember(plotMember);
ChatMessage.of(VirtualRealty.getMessages().plotLeave.replaceAll("%plot_id%", String.valueOf(plot.getID()))).sendWithPrefix(sender);
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,13 @@

import com.modnmetl.virtualrealty.commands.CommandRegistry;
import com.modnmetl.virtualrealty.commands.SubCommand;
import com.modnmetl.virtualrealty.manager.PlotManager;
import com.modnmetl.virtualrealty.model.other.CommandType;
import com.modnmetl.virtualrealty.exception.FailedCommandException;
import com.modnmetl.virtualrealty.VirtualRealty;
import com.modnmetl.virtualrealty.exception.InsufficientPermissionsException;
import org.bukkit.command.*;
import org.bukkit.entity.Player;
import org.bukkit.permissions.Permission;
import org.jetbrains.annotations.NotNull;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,6 @@ public class MessagesConfiguration extends OkaeriConfig {
public String notStandingOnPlot = "§cYou aren't standing on any plot!";
public String playerKick = "§aPlayer §7%player% §ahas been kicked out of your plot!";
public String plotLeave = "§aYou have left the plot with id %plot_id%!";
public String cantLeaveOwnPlot = "§6You can't leave your own plot!";
public String playerAdd = "§aPlayer §7%player% §ahas been added to your plot!";
public String gamemodeSwitched = "§aYour gamemode has changed!";
public String gamemodeAlreadySelected = "§cThis gamemode is already selected!";
Expand Down Expand Up @@ -142,6 +141,11 @@ public class MessagesConfiguration extends OkaeriConfig {
"§7You are about to remove §a%plot_id%§7, once done you cannot undo.",
"§7Type §aYES §7to proceed."
);
public List<String> leaveConfirmation = Arrays.asList(
"§7You are about to leave your owned plot §a%plot_id%§7.",
"§7Type §aYES §7to confirm."
);
public String leaveConfirmationCancelled = "§cLeaving process cancelled!";

//Other
public String confirmationExpired = "§cConfirmation not received, command cancelled.";
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
import com.modnmetl.virtualrealty.model.region.GridStructure;
import com.modnmetl.virtualrealty.util.RegionUtil;
import com.modnmetl.virtualrealty.model.other.ChatMessage;
import de.tr7zw.changeme.nbtapi.NBTItem;
import de.tr7zw.changeme.nbtapi.NBT;
import net.md_5.bungee.api.chat.BaseComponent;
import net.md_5.bungee.api.chat.ClickEvent;
import net.md_5.bungee.api.chat.HoverEvent;
Expand All @@ -37,6 +37,7 @@

import java.time.LocalDateTime;
import java.util.AbstractMap;
import java.util.Map;

public class PlayerActionListener extends VirtualListener {

Expand Down Expand Up @@ -217,7 +218,6 @@ public void success() {
int height = plotItem.getHeight();
int width = plotItem.getWidth();
ItemStack plotItemStack = DraftListener.DRAFT_MAP.get(this.getSender()).getValue().getValue().getItemStack();
NBTItem item = new NBTItem(plotItemStack);
gridStructure.removeGrid();
this.getSender().sendMessage(VirtualRealty.PREFIX + VirtualRealty.getMessages().notCollidingCreating);
long timeStart = System.currentTimeMillis();
Expand All @@ -230,15 +230,27 @@ public void success() {
} else {
plot = PlotManager.getInstance().createPlot(location, plotSize, plotItem.isNatural());
}
AbstractMap.SimpleEntry<String, Byte> floorData = new AbstractMap.SimpleEntry<>(item.getString("vrplot_floor_material"), item.getByte("vrplot_floor_data"));
AbstractMap.SimpleEntry<String, Byte> borderData = new AbstractMap.SimpleEntry<>(item.getString("vrplot_border_material"), item.getByte("vrplot_border_data"));
String floorMaterial = NBT.get(plotItemStack, nbt -> {
return nbt.getString("vrplot_floor_material");
});
byte floorData = NBT.get(plotItemStack, nbt -> {
return nbt.getByte("vrplot_floor_data");
});
String borderMaterial = NBT.get(plotItemStack, nbt -> {
return nbt.getString("vrplot_border_material");
});
byte borderData = NBT.get(plotItemStack, nbt -> {
return nbt.getByte("vrplot_border_data");
});
AbstractMap.SimpleEntry<String, Byte> floorDataEntry = new AbstractMap.SimpleEntry<>(floorMaterial, floorData);
AbstractMap.SimpleEntry<String, Byte> borderDataEntry = new AbstractMap.SimpleEntry<>(borderMaterial, borderData);
if (!plotItem.isNatural()) {
if (VirtualRealty.legacyVersion) {
plot.setFloorMaterial(Material.valueOf(floorData.getKey()), floorData.getValue());
plot.setBorderMaterial(Material.valueOf(borderData.getKey()), borderData.getValue());
plot.setFloorMaterial(Material.valueOf(floorDataEntry.getKey()), floorDataEntry.getValue());
plot.setBorderMaterial(Material.valueOf(borderDataEntry.getKey()), borderDataEntry.getValue());
} else {
plot.setFloorMaterial(Bukkit.createBlockData(floorData.getKey()).getMaterial(), floorData.getValue());
plot.setBorderMaterial(Bukkit.createBlockData(borderData.getKey()).getMaterial(), borderData.getValue());
plot.setFloorMaterial(Bukkit.createBlockData(floorDataEntry.getKey()).getMaterial(), floorDataEntry.getValue());
plot.setBorderMaterial(Bukkit.createBlockData(borderDataEntry.getKey()).getMaterial(), borderDataEntry.getValue());
}
}
plot.setOwnedBy(this.getSender().getUniqueId());
Expand Down Expand Up @@ -325,10 +337,12 @@ public void onPlotItemDraft(PlayerInteractEvent e) {
}
PlayerInventory inv = player.getInventory();
ItemStack claimItem = VirtualRealty.legacyVersion ? player.getItemInHand() : inv.getItemInMainHand();
NBTItem claimNbtItem;

String item = NBT.get(claimItem, nbt -> {
return nbt.getString("vrplot_item");
});
if (!(claimItem.getType() == (VirtualRealty.legacyVersion ? Material.valueOf("SKULL_ITEM") : Material.PLAYER_HEAD)
&&
(claimNbtItem = new NBTItem(claimItem)).getString("vrplot_item") != null && claimNbtItem.getString("vrplot_item").equals("CLAIM"))) {
&& item != null && item.equals("CLAIM"))) {
return;
}
e.setCancelled(true);
Expand Down Expand Up @@ -385,7 +399,10 @@ public void onPlotItemDraft(PlayerInteractEvent e) {
));
return;
}
PlotSize plotSize = PlotSize.valueOf(claimNbtItem.getString("vrplot_size"));
String size = NBT.get(claimItem, nbt -> {
return nbt.getString("vrplot_size");
});
PlotSize plotSize = PlotSize.valueOf(size);
Cuboid cuboid = RegionUtil.getRegion(player.getLocation(), Direction.byYaw(player.getLocation().getYaw()), plotSize.getLength(), plotSize.getHeight(), plotSize.getWidth());
if (RegionUtil.isCollidingWithAnotherPlot(cuboid)) {
player.sendMessage(VirtualRealty.PREFIX + VirtualRealty.getMessages().claimModeCancelledCollision);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
import com.modnmetl.virtualrealty.listener.VirtualListener;
import com.modnmetl.virtualrealty.model.plot.PlotItem;
import com.modnmetl.virtualrealty.model.region.GridStructure;
import de.tr7zw.changeme.nbtapi.NBTItem;
import de.tr7zw.changeme.nbtapi.NBT;
import org.bukkit.Material;
import org.bukkit.entity.Player;
import org.bukkit.event.EventHandler;
Expand Down Expand Up @@ -73,7 +73,10 @@ public void onPlayerDeath(PlayerDeathEvent e) {
public void onBlockPlace(BlockPlaceEvent e) {
Player player = e.getPlayer();
ItemStack itemInHand = VirtualRealty.legacyVersion ? player.getItemInHand() : player.getInventory().getItemInMainHand();
if (itemInHand.getType() == (VirtualRealty.legacyVersion ? Material.valueOf("SKULL_ITEM") : Material.PLAYER_HEAD) && (new NBTItem(itemInHand)).hasKey("vrplot_item")) {
boolean hasItemKey = NBT.get(itemInHand, nbt -> {
return nbt.hasTag("vrplot_item");
});
if (itemInHand.getType() == (VirtualRealty.legacyVersion ? Material.valueOf("SKULL_ITEM") : Material.PLAYER_HEAD) && hasItemKey) {
e.setCancelled(true);
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,10 @@ public static void removeConfirmations(int plotID, ConfirmationType confirmation
confirmations.removeIf(confirmation -> confirmation.getPlotID() == plotID && confirmation.getConfirmationType() == confirmationType);
}

public static void removeConfirmations(ConfirmationType confirmationType) {
confirmations.removeIf(confirmation -> confirmation.getConfirmationType() == confirmationType);
}

public static void removeStakeConfirmations(ConfirmationType confirmationType, UUID sender) {
confirmations.removeIf(confirmation -> confirmation.getConfirmationType() == confirmationType && confirmation.getSender().getUniqueId() == sender);
}
Expand Down
Loading