-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: moved tweak events to split file
chore: moved from intellij idea to vscode chore: commented all tweaks in config.yml build: removed paperweight since it's not being used build: added run-paper plugin for debugging purposes
- Loading branch information
Showing
8 changed files
with
142 additions
and
15 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
root = true | ||
charset = utf-8 | ||
|
||
[*.java] | ||
indent_style = space | ||
indent_size = 4 | ||
tab_width = 4 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -108,4 +108,8 @@ nb-configuration.xml | |
.nb-gradle/ | ||
|
||
### MacOS ### | ||
.DS_Store | ||
.DS_Store | ||
|
||
|
||
### | ||
run/ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,4 @@ | ||
{ | ||
"java.compile.nullAnalysis.mode": "automatic" | ||
"java.compile.nullAnalysis.mode": "automatic", | ||
"java.configuration.updateBuildConfiguration": "automatic" | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
99 changes: 99 additions & 0 deletions
99
src/main/java/me/shockpast/roflan/listeners/TweakListener.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,99 @@ | ||
package me.shockpast.roflan.listeners; | ||
|
||
import java.util.List; | ||
|
||
import org.bukkit.GameMode; | ||
import org.bukkit.Material; | ||
import org.bukkit.World; | ||
import org.bukkit.World.Environment; | ||
import org.bukkit.block.Block; | ||
import org.bukkit.block.BlockFace; | ||
import org.bukkit.block.Chest; | ||
import org.bukkit.configuration.file.FileConfiguration; | ||
import org.bukkit.entity.Player; | ||
import org.bukkit.event.EventHandler; | ||
import org.bukkit.event.Listener; | ||
import org.bukkit.event.inventory.InventoryCloseEvent; | ||
import org.bukkit.event.player.PlayerBucketEmptyEvent; | ||
import org.bukkit.event.player.PlayerInteractEvent; | ||
import org.bukkit.metadata.FixedMetadataValue; | ||
import org.bukkit.metadata.MetadataValue; | ||
import org.bukkit.plugin.java.JavaPlugin; | ||
|
||
import io.papermc.paper.event.player.PlayerItemCooldownEvent; | ||
|
||
public class TweakListener implements Listener { | ||
private final JavaPlugin plugin; | ||
private final FileConfiguration config; | ||
|
||
public TweakListener(JavaPlugin plugin) { | ||
this.plugin = plugin; | ||
this.config = plugin.getConfig(); | ||
} | ||
|
||
@EventHandler | ||
public void creativeNetherWaterPlacement(PlayerBucketEmptyEvent event) { | ||
if (!config.getBoolean("tweaks.creativeNetherWaterPlacement")) | ||
return; | ||
|
||
World world = event.getBlock().getWorld(); | ||
if (world.getEnvironment() != Environment.NETHER) | ||
return; | ||
|
||
Block block = event.getBlockClicked(); | ||
BlockFace blockFace = event.getBlockFace(); | ||
|
||
block.getRelative(blockFace) | ||
.setType(Material.WATER); | ||
} | ||
|
||
@EventHandler | ||
public void creativeNoItemCooldown(PlayerItemCooldownEvent event) { | ||
if (!config.getBoolean("tweaks.creativeNoItemCooldown")) | ||
return; | ||
|
||
Player player = event.getPlayer(); | ||
if (player.getGameMode() != GameMode.CREATIVE) | ||
return; | ||
|
||
event.setCooldown(0); | ||
} | ||
|
||
@EventHandler | ||
public void creativeOpenContainerForcibly(PlayerInteractEvent event) { | ||
if (!config.getBoolean("tweaks.creativeOpenContainerForcibly")) | ||
return; | ||
|
||
Player player = event.getPlayer(); | ||
if (player.getGameMode() != GameMode.CREATIVE) | ||
return; | ||
|
||
Block block = event.getClickedBlock(); | ||
if (block == null) | ||
return; | ||
if (!(block.getState() instanceof Chest)) | ||
return; | ||
|
||
Chest chest = (Chest)block.getState(); | ||
if (chest.isBlocked() || chest.isLocked()) { | ||
player.openInventory(chest.getInventory()); | ||
player.setMetadata("creativeOpenContainerForcibly", new FixedMetadataValue(plugin, chest)); | ||
|
||
chest.open(); | ||
} | ||
} | ||
|
||
@EventHandler | ||
public void creativeOpenContainerForcibly_InventoryClose(InventoryCloseEvent event) { | ||
Player player = (Player)event.getPlayer(); | ||
if (player == null) | ||
return; | ||
|
||
List<MetadataValue> meta = player.getMetadata("creativeOpenContainerForcibly"); | ||
if (meta.isEmpty()) | ||
return; | ||
|
||
Chest chest = (Chest)meta.getFirst().value(); | ||
chest.close(); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,2 +1,14 @@ | ||
# fabric-carpet but made as paper plugin | ||
tweaks: | ||
explosionNoBlockDamage: false | ||
# explosions will be cancelled at last tick | ||
# so it won't actually explode anything | ||
explosionNoBlockDamage: false | ||
# water can be placed if player is in creative | ||
# (in nether) | ||
creativeNetherWaterPlacement: false | ||
# removes any cooldown from items for players | ||
# that are in creative | ||
creativeNoItemCooldown: false | ||
# players in creative will open containers | ||
# regardless of it's block/lock state | ||
creativeOpenContainerForcibly: false |