-
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.
- Loading branch information
Showing
10 changed files
with
277 additions
and
3 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
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
142 changes: 142 additions & 0 deletions
142
src/main/java/io/wdsj/hybridfix/entry/bukkit/HybridFixInternalPlugin.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,142 @@ | ||
package io.wdsj.hybridfix.entry.bukkit; | ||
|
||
import io.wdsj.hybridfix.HybridFix; | ||
import org.bukkit.Bukkit; | ||
import org.bukkit.Server; | ||
import org.bukkit.command.Command; | ||
import org.bukkit.command.CommandSender; | ||
import org.bukkit.configuration.file.FileConfiguration; | ||
import org.bukkit.generator.ChunkGenerator; | ||
import org.bukkit.plugin.PluginBase; | ||
import org.bukkit.plugin.PluginDescriptionFile; | ||
import org.bukkit.plugin.PluginLoader; | ||
import org.bukkit.plugin.PluginLogger; | ||
import org.bukkit.plugin.java.JavaPluginLoader; | ||
|
||
import java.io.File; | ||
import java.io.InputStream; | ||
import java.util.List; | ||
|
||
public class HybridFixInternalPlugin extends PluginBase { | ||
private boolean enabled = true; | ||
private PluginLoader loader; | ||
private static final HybridFixInternalPlugin INSTANCE = new HybridFixInternalPlugin(); | ||
public static HybridFixInternalPlugin getInstance() { | ||
return INSTANCE; | ||
} | ||
private final String pluginName; | ||
private PluginDescriptionFile pdf; | ||
|
||
public HybridFixInternalPlugin() { | ||
this.pluginName = "HybridFix"; | ||
pdf = new PluginDescriptionFile(pluginName, HybridFix.VERSION, "hybridfix"); | ||
} | ||
|
||
public void setEnabled(boolean enabled) { | ||
this.enabled = enabled; | ||
} | ||
|
||
@Override | ||
public File getDataFolder() { | ||
throw new UnsupportedOperationException("Not supported."); | ||
} | ||
|
||
@Override | ||
public PluginDescriptionFile getDescription() { | ||
return pdf; | ||
} | ||
|
||
@Override | ||
public FileConfiguration getConfig() { | ||
throw new UnsupportedOperationException("Not supported."); | ||
} | ||
|
||
@Override | ||
public InputStream getResource(String filename) { | ||
throw new UnsupportedOperationException("Not supported."); | ||
} | ||
|
||
@Override | ||
public void saveConfig() { | ||
throw new UnsupportedOperationException("Not supported."); | ||
} | ||
|
||
@Override | ||
public void saveDefaultConfig() { | ||
throw new UnsupportedOperationException("Not supported."); | ||
} | ||
|
||
@Override | ||
public void saveResource(String resourcePath, boolean replace) { | ||
throw new UnsupportedOperationException("Not supported."); | ||
} | ||
|
||
@Override | ||
public void reloadConfig() { | ||
throw new UnsupportedOperationException("Not supported."); | ||
} | ||
|
||
@Override | ||
public PluginLogger getLogger() { | ||
throw new UnsupportedOperationException("Not supported."); | ||
} | ||
|
||
@Override | ||
public PluginLoader getPluginLoader() { | ||
if (loader == null) { | ||
loader = new JavaPluginLoader(Bukkit.getServer()); | ||
} | ||
return loader; | ||
} | ||
|
||
@Override | ||
public Server getServer() { | ||
return Bukkit.getServer(); | ||
} | ||
|
||
@Override | ||
public boolean isEnabled() { | ||
return enabled; | ||
} | ||
|
||
@Override | ||
public void onDisable() { | ||
throw new UnsupportedOperationException("Not supported."); | ||
} | ||
|
||
@Override | ||
public void onLoad() { | ||
throw new UnsupportedOperationException("Not supported."); | ||
} | ||
|
||
@Override | ||
public void onEnable() { | ||
throw new UnsupportedOperationException("Not supported."); | ||
} | ||
|
||
@Override | ||
public boolean isNaggable() { | ||
throw new UnsupportedOperationException("Not supported."); | ||
} | ||
|
||
@Override | ||
public void setNaggable(boolean canNag) { | ||
throw new UnsupportedOperationException("Not supported."); | ||
} | ||
|
||
@Override | ||
public ChunkGenerator getDefaultWorldGenerator(String worldName, String id) { | ||
throw new UnsupportedOperationException("Not supported."); | ||
} | ||
|
||
@Override | ||
public boolean onCommand(CommandSender sender, Command command, String label, String[] args) { | ||
throw new UnsupportedOperationException("Not supported."); | ||
} | ||
|
||
@Override | ||
public List<String> onTabComplete(CommandSender sender, Command command, String alias, String[] args) { | ||
throw new UnsupportedOperationException("Not supported."); | ||
} | ||
|
||
} |
31 changes: 31 additions & 0 deletions
31
src/main/java/io/wdsj/hybridfix/entry/bukkit/listener/ExplodeListener.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,31 @@ | ||
package io.wdsj.hybridfix.entry.bukkit.listener; | ||
|
||
import io.wdsj.hybridfix.config.Settings; | ||
import org.bukkit.event.EventHandler; | ||
import org.bukkit.event.Listener; | ||
import org.bukkit.event.block.BlockExplodeEvent; | ||
import org.bukkit.event.entity.EntityExplodeEvent; | ||
|
||
public class ExplodeListener implements Listener { | ||
@EventHandler | ||
public void onEntityExplode(EntityExplodeEvent event) { | ||
String worldName = event.getEntity().getWorld().getName(); | ||
for (String s : Settings.bukkitPluginConfig.antiExplodeWorlds) { | ||
if (s.equalsIgnoreCase(worldName)) { | ||
event.setCancelled(true); | ||
break; | ||
} | ||
} | ||
} | ||
|
||
@EventHandler | ||
public void onBlockExplode(BlockExplodeEvent event) { | ||
String worldName = event.getBlock().getWorld().getName(); | ||
for (String s : Settings.bukkitPluginConfig.antiExplodeWorlds) { | ||
if (s.equalsIgnoreCase(worldName)) { | ||
event.setCancelled(true); | ||
break; | ||
} | ||
} | ||
} | ||
} |
32 changes: 32 additions & 0 deletions
32
src/main/java/io/wdsj/hybridfix/mixin/bukkit/plugin/CraftServerMixin.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,32 @@ | ||
package io.wdsj.hybridfix.mixin.bukkit.plugin; | ||
|
||
import io.wdsj.hybridfix.HybridFix; | ||
import io.wdsj.hybridfix.entry.bukkit.HybridFixInternalPlugin; | ||
import org.bukkit.craftbukkit.v1_12_R1.CraftServer; | ||
import org.bukkit.event.HandlerList; | ||
import org.spongepowered.asm.mixin.Mixin; | ||
import org.spongepowered.asm.mixin.Unique; | ||
import org.spongepowered.asm.mixin.injection.At; | ||
import org.spongepowered.asm.mixin.injection.Inject; | ||
import org.spongepowered.asm.mixin.injection.callback.CallbackInfo; | ||
|
||
@Mixin(CraftServer.class) | ||
public abstract class CraftServerMixin { | ||
|
||
@Inject( | ||
method = "disablePlugins", | ||
at = @At( | ||
value = "TAIL" | ||
), | ||
remap = false | ||
) | ||
public void onDisablePlugins(CallbackInfo ci) { | ||
hybridFix$disableInternalPlugin(); | ||
} | ||
|
||
@Unique | ||
private void hybridFix$disableInternalPlugin() { | ||
HybridFix.LOGGER.info("[HybridFix] Disabling HybridFix internal plugin v{}", HybridFix.VERSION); | ||
HandlerList.unregisterAll(HybridFixInternalPlugin.getInstance()); | ||
} | ||
} |
35 changes: 35 additions & 0 deletions
35
src/main/java/io/wdsj/hybridfix/mixin/bukkit/plugin/DedicatedServerMixin.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,35 @@ | ||
package io.wdsj.hybridfix.mixin.bukkit.plugin; | ||
|
||
import io.wdsj.hybridfix.HybridFix; | ||
import io.wdsj.hybridfix.config.Settings; | ||
import io.wdsj.hybridfix.entry.bukkit.HybridFixInternalPlugin; | ||
import io.wdsj.hybridfix.entry.bukkit.listener.ExplodeListener; | ||
import net.minecraft.server.dedicated.DedicatedServer; | ||
import org.bukkit.Bukkit; | ||
import org.spongepowered.asm.mixin.Mixin; | ||
import org.spongepowered.asm.mixin.Unique; | ||
import org.spongepowered.asm.mixin.injection.At; | ||
import org.spongepowered.asm.mixin.injection.Inject; | ||
import org.spongepowered.asm.mixin.injection.callback.CallbackInfoReturnable; | ||
|
||
@Mixin(DedicatedServer.class) | ||
public abstract class DedicatedServerMixin { | ||
|
||
@Inject( | ||
method = "init", | ||
at = @At( | ||
value = "TAIL" | ||
) | ||
) | ||
public void onInit(CallbackInfoReturnable<Boolean> cir) { | ||
hybridFix$register(); | ||
} | ||
|
||
@Unique | ||
private void hybridFix$register() { | ||
HybridFix.LOGGER.info("[HybridFix] Enabling HybridFix internal plugin v{}", HybridFix.VERSION); | ||
if (Settings.bukkitPluginConfig.antiExplode) { | ||
Bukkit.getServer().getPluginManager().registerEvents(new ExplodeListener(), HybridFixInternalPlugin.getInstance()); | ||
} | ||
} | ||
} |
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,12 @@ | ||
{ | ||
"package": "io.wdsj.hybridfix.mixin.bukkit.plugin", | ||
"required": true, | ||
"refmap": "${mixin_refmap}", | ||
"target": "@env(DEFAULT)", | ||
"minVersion": "0.8", | ||
"compatibilityLevel": "JAVA_8", | ||
"mixins": [ | ||
"DedicatedServerMixin", | ||
"CraftServerMixin" | ||
] | ||
} |