Skip to content

Commit 14f3158

Browse files
committed
Aureus - Custom changes 2.0.4
Signed-off-by: petulikan1 <petulikan@gmail.com> Took 4 hours 11 minutes
1 parent 93226c4 commit 14f3158

6 files changed

Lines changed: 123 additions & 24 deletions

File tree

Core/pom.xml

Lines changed: 1 addition & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010

1111
<modelVersion>4.0.0</modelVersion>
1212
<artifactId>Core</artifactId>
13-
<version>2.0.3</version>
13+
<version>2.0.4_Aureus</version>
1414

1515
<properties>
1616
<maven.compiler.source>8</maven.compiler.source>
@@ -157,13 +157,6 @@
157157
<scope>provided</scope>
158158
</dependency>
159159

160-
<dependency>
161-
<groupId>org.geysermc.geyser</groupId>
162-
<artifactId>api</artifactId>
163-
<version>2.2.0-SNAPSHOT</version>
164-
<scope>provided</scope>
165-
</dependency>
166-
167160
<dependency>
168161
<groupId>com.github.decentsoftware-eu</groupId>
169162
<artifactId>decentholograms</artifactId>

Core/src/main/java/xzot1k/plugins/ds/DisplayShops.java

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -104,6 +104,7 @@ public class DisplayShops extends JavaPlugin implements DisplayShopsAPI {
104104
private FileConfiguration langConfig;
105105
private File langFile, loggingFile;
106106
private HashMap<String, Menu> menuMap;
107+
/* public GeyserHook geyserHook;*/
107108

108109
/**
109110
* @return Returns the plugin's instance.
@@ -160,6 +161,10 @@ public void onEnable() {
160161
throw new RuntimeException("Plugin is not compatible with this server version! Your server version: "+Ref.serverVersion());
161162
}
162163

164+
/*if(isGeyserInstalled()){
165+
log(Level.INFO,"Geyser is present! Initiating Geyser API features...");
166+
geyserHook=new GeyserHook(this);
167+
}*/
163168

164169

165170
setPaperSpigot(false);

Core/src/main/java/xzot1k/plugins/ds/core/Listeners.java

Lines changed: 29 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -103,12 +103,12 @@ public void onInteract(PlayerInteractEvent e) {
103103
if (e.getClickedBlock() == null) {
104104
return;
105105
}
106-
boolean block =false;
107-
if(e.getAction() == Action.RIGHT_CLICK_BLOCK && e.getItem() != null && e.getItem().getType().name().contains("SIGN")){
108-
if(e.getPlayer().isSneaking()){
106+
boolean block = false;
107+
if (e.getAction() == Action.RIGHT_CLICK_BLOCK && e.getItem() != null && e.getItem().getType().name().contains("SIGN")) {
108+
if (e.getPlayer().isSneaking()) {
109109
return;
110110
}
111-
block=true;
111+
block = true;
112112
}
113113

114114
final boolean isOffhandVersion = Ref.isNewerThan(8);
@@ -159,7 +159,7 @@ public void onInteract(PlayerInteractEvent e) {
159159

160160
final Shop shop = getPluginInstance().getManager().getShop(e.getClickedBlock().getLocation());
161161
if (shop == null) return;
162-
if(block){
162+
if (block) {
163163
e.setCancelled(true);
164164
return;
165165
}
@@ -339,7 +339,16 @@ public void onInteract(PlayerInteractEvent e) {
339339

340340
if (editPrevention) shop.setCurrentEditor(e.getPlayer().getUniqueId());
341341
dataPack.setSelectedShop(shop);
342-
342+
/*System.out.println("A");
343+
if (pluginInstance.isGeyserInstalled()) {
344+
GeyserConnection conn = pluginInstance.geyserHook.getPlayer(e.getPlayer());
345+
if (conn != null) {
346+
System.out.println("SEND_FORM_1");
347+
conn.sendForm(CustomForm.builder().title("TestTitle").toggle("test_toggle", true).closedOrInvalidResultHandler(() -> System.out.println("Test_1")).resultHandler((a, b) -> System.out.println(a.content() + " | " + b.responseType())).build());
348+
getPluginInstance().runEventCommands("shop-edit", e.getPlayer());
349+
return;
350+
}
351+
}*/
343352
final Menu editMenu = getPluginInstance().getMenu("edit");
344353
if (editMenu != null) editMenu.build(e.getPlayer());
345354

@@ -359,7 +368,17 @@ public void onInteract(PlayerInteractEvent e) {
359368
if (shopTransactionEvent.isCancelled()) return;
360369

361370
dataPack.setSelectedShop(shop);
362-
371+
/*System.out.println("B");
372+
if (pluginInstance.isGeyserInstalled()) {
373+
GeyserConnection conn = pluginInstance.geyserHook.getPlayer(e.getPlayer());
374+
if (conn != null) {
375+
System.out.println("SEND_FORM_2");
376+
FloodgateApi api = FloodgateApi.getInstance();
377+
api.getPlayer(e.getPlayer().getUniqueId()).sendForm(CustomForm.builder().title("TestTitle").toggle("test_toggle", true).closedOrInvalidResultHandler(() -> System.out.println("Test_1")).resultHandler((a, b) -> System.out.println(a.content() + " | " + b.responseType())));
378+
getPluginInstance().runEventCommands("shop-edit", e.getPlayer());
379+
return;
380+
}
381+
}*/
363382
final Menu editMenu = getPluginInstance().getMenu("transaction");
364383
if (editMenu != null) editMenu.build(e.getPlayer());
365384

@@ -494,10 +513,12 @@ public void onInteract(PlayerInteractEvent e) {
494513
dataPack.setSelectedShop(shop);
495514

496515
final Menu editMenu = getPluginInstance().getMenu("edit");
497-
if (editMenu != null) editMenu.build(e.getPlayer());
516+
if (editMenu != null)
517+
editMenu.build(e.getPlayer());
498518

499519
getPluginInstance().runEventCommands("shop-edit", e.getPlayer());
500520
} else {
521+
System.out.println("B");
501522
if (!shop.isAdminShop() && !getPluginInstance().getConfig().getBoolean("offline-mode")) {
502523
Player player = getPluginInstance().getServer().getPlayer(shop.getOwnerUniqueId());
503524
if (player == null || !player.isOnline()) {
Lines changed: 54 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,54 @@
1+
/*
2+
package xzot1k.plugins.ds.core.hooks;
3+
4+
import org.bukkit.Bukkit;
5+
import org.bukkit.entity.Player;
6+
import org.geysermc.cumulus.form.CustomForm;
7+
import org.geysermc.event.subscribe.Subscribe;
8+
import org.geysermc.geyser.api.GeyserApi;
9+
import org.geysermc.geyser.api.connection.GeyserConnection;
10+
import org.geysermc.geyser.api.event.EventRegistrar;
11+
import org.geysermc.geyser.api.event.lifecycle.GeyserPostInitializeEvent;
12+
import org.jetbrains.annotations.NotNull;
13+
import xzot1k.plugins.ds.DisplayShops;
14+
15+
import javax.annotation.Nullable;
16+
import java.util.UUID;
17+
import java.util.logging.Level;
18+
19+
public class GeyserHook implements EventRegistrar {
20+
21+
private final DisplayShops main;
22+
private final GeyserApi geyser;
23+
24+
public GeyserHook(@NotNull DisplayShops main){
25+
this.main=main;
26+
geyser = GeyserApi.api();
27+
geyser.eventBus().subscribe(this,GeyserPostInitializeEvent.class,this::onGeyser);
28+
}
29+
30+
31+
@Nullable
32+
public GeyserConnection getPlayer(@NotNull UUID uuid){
33+
return geyser.connectionByUuid(uuid);
34+
}
35+
36+
@Nullable
37+
public GeyserConnection getPlayer(@NotNull String player){
38+
Player p = Bukkit.getPlayer(player);
39+
if(p==null)
40+
return null;
41+
return getPlayer(p.getUniqueId());
42+
}
43+
44+
@Nullable
45+
public GeyserConnection getPlayer(@NotNull Player player){
46+
return getPlayer(player.getUniqueId());
47+
}
48+
49+
@Subscribe
50+
public void onGeyser(GeyserPostInitializeEvent e){
51+
main.log(Level.SEVERE,"Geyser initialized!");
52+
}
53+
}
54+
*/

Core/src/main/java/xzot1k/plugins/ds/core/tasks/VisualTask.java

Lines changed: 27 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
package xzot1k.plugins.ds.core.tasks;
66

77
import me.devtec.shared.Ref;
8+
import org.bukkit.Location;
89
import org.bukkit.World;
910
import org.bukkit.entity.ItemDisplay;
1011
import org.bukkit.entity.Player;
@@ -119,14 +120,32 @@ public void run() {
119120

120121
for (Player player : getPluginInstance().getServer().getOnlinePlayers()) {
121122
if (player == null || !player.isOnline()) {continue;}
122-
123-
final Shop foundShopAtLocation = getPluginInstance().getManager().getShopRayTraced(player.getWorld().getName(),
124-
player.getEyeLocation().toVector(), player.getEyeLocation().getDirection(), 10/*getViewDistance()*/);
125-
126-
boolean isFocused = foundShopAtLocation != null && foundShopAtLocation.getShopId().toString().equals(shop.getShopId().toString());
123+
boolean experimental = DisplayShops.getPluginInstance().getConfig().getBoolean("experimental");
124+
125+
boolean isFocused=false;
126+
if(!experimental) {
127+
final Shop foundShopAtLocation = getPluginInstance().getManager().getShopRayTraced(player.getWorld().getName(),
128+
player.getEyeLocation().toVector(), player.getEyeLocation().getDirection(), 10/*getViewDistance()*/);
129+
130+
isFocused = foundShopAtLocation != null && foundShopAtLocation.getShopId().toString().equals(shop.getShopId().toString());
131+
} else {
132+
double value = (double) DisplayShops.getPluginInstance().getConfig().getInt("display-distance") /2;
133+
Location min = shop.getBaseLocation().asBukkitLocation().clone().subtract(value,value,value);
134+
Location max = shop.getBaseLocation().asBukkitLocation().clone().add(value,value,value);
135+
for(x=min.getBlockX();x<=max.getBlockY();x++){
136+
for(y=min.getBlockY();y<=max.getBlockY();y++){
137+
for(z=min.getBlockZ();z<=max.getBlockZ();z++){
138+
if(player.getLocation().getBlockX()==x&&player.getLocation().getBlockY()==y&&player.getLocation().getBlockZ()==z){
139+
isFocused=true;
140+
break;
141+
}
142+
}
143+
}
144+
}
145+
}
146+
boolean finFocused = isFocused;
127147
DisplayShops.getPluginInstance().getServer().getScheduler().runTask(DisplayShops.getPluginInstance(), () -> {
128-
129-
display.show(player, isFocused);
148+
display.show(player, finFocused);
130149
});
131150
}
132151

@@ -160,6 +179,7 @@ && getPluginInstance().getDisplayPacketMap().get(player.getUniqueId()).containsK
160179

161180
if (!packetExists) getPluginInstance().sendDisplayPacket(shop, player, false);
162181

182+
163183
Shop currentShop = null;
164184
if (!getPluginInstance().getShopMemory().isEmpty() && getPluginInstance().getShopMemory().containsKey(player.getUniqueId())) {
165185
final UUID shopId = getPluginInstance().getShopMemory().getOrDefault(player.getUniqueId(), null);

pom.xml

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -128,7 +128,13 @@
128128
<dependency>
129129
<groupId>org.geysermc.geyser</groupId>
130130
<artifactId>api</artifactId>
131-
<version>2.1.2-SNAPSHOT</version>
131+
<version>2.4.3-SNAPSHOT</version>
132+
<scope>provided</scope>
133+
</dependency>
134+
<dependency>
135+
<groupId>org.geysermc.floodgate</groupId>
136+
<artifactId>api</artifactId>
137+
<version>2.2.3-SNAPSHOT</version>
132138
<scope>provided</scope>
133139
</dependency>
134140

0 commit comments

Comments
 (0)