-
-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #5 from LlmDl/shops
- Item Sign shop creation can be limited to just Shop plots. - Optionally it can be a personally owned shop plot, or any shop plot where the creator can build. - Made disabledWorlds tests also ignore worlds where usingTowny is false.
- Loading branch information
Showing
8 changed files
with
169 additions
and
49 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
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
50 changes: 50 additions & 0 deletions
50
src/main/java/com/gmail/llmdlio/townytne/ShopListener.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,50 @@ | ||
package com.gmail.llmdlio.townytne; | ||
|
||
import java.util.UUID; | ||
|
||
import org.bukkit.Bukkit; | ||
import org.bukkit.ChatColor; | ||
import org.bukkit.Location; | ||
import org.bukkit.entity.Player; | ||
import org.bukkit.event.EventHandler; | ||
import org.bukkit.event.EventPriority; | ||
import org.bukkit.event.Listener; | ||
|
||
import com.palmergames.bukkit.towny.TownyAPI; | ||
import com.palmergames.bukkit.towny.exceptions.NotRegisteredException; | ||
import com.palmergames.bukkit.towny.utils.ShopPlotUtil; | ||
|
||
import net.tnemc.core.event.module.TNEModuleDataEvent; | ||
|
||
public class ShopListener implements Listener{ | ||
|
||
@SuppressWarnings("unused") | ||
private TownyTNE plugin; | ||
|
||
public ShopListener (TownyTNE instance) { | ||
this.plugin = instance; | ||
} | ||
|
||
@EventHandler (priority = EventPriority.NORMAL) | ||
public void onShopCreate (TNEModuleDataEvent event) throws NotRegisteredException { | ||
|
||
if (!event.getEventName().equals("SignCreate")) | ||
return; | ||
if (!event.getData().get("type").equals("item")) | ||
return; | ||
Location loc = (Location) event.getData().get("location"); | ||
if (TownyTNE.disabledWorlds.contains(loc.getWorld().getName()) || !TownyAPI.getInstance().getDataSource().getWorld(loc.getWorld().getName()).isUsingTowny()) | ||
return; | ||
Player player = Bukkit.getPlayer((UUID) event.getData().get("creator")); | ||
boolean allowedShopCreation = false; | ||
if (TownyTNE.requireShopPlotOwnership) | ||
allowedShopCreation = ShopPlotUtil.doesPlayerOwnShopPlot(player, loc); | ||
else | ||
allowedShopCreation = ShopPlotUtil.doesPlayerHaveAbilityToEditShopPlot(player, loc); | ||
|
||
if (!allowedShopCreation) { | ||
player.sendMessage(ChatColor.DARK_RED + "Your shop must be made inside of a Shop plot " + (TownyTNE.requireShopPlotOwnership ? "that you own." : "where you can build.")); | ||
event.setCancelled(true); | ||
} | ||
} | ||
} |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
v1.0: | ||
- Initial version. | ||
- Currency notes can be limited to Bank plots. | ||
- Currency drops can be altered inside towns, while exempting a list of towns. | ||
- Currency notes and drops manipulation can be disabled in a list of worlds. | ||
v1.1: | ||
- Item Sign shop creation can be limited to just Shop plots. | ||
- Optionally it can be a personally owned shop plot, or any shop plot where the creator can build. | ||
- Made disabledWorlds tests also ignore worlds where usingTowny is false. |
Oops, something went wrong.